vcglib/apps/tetraviewer/tetrastats.h

75 lines
1011 B
C
Raw Normal View History

2004-10-04 20:01:36 +02:00
template<class TETRA_MESH_TYPE>
class TetraStats
{
typedef typename TETRA_MESH_TYPE::TetraType TetraType;
TETRA_MESH_TYPE * Tetra;
TetraType* T;
public:
double volume;
double ratio;
2004-10-07 15:14:37 +02:00
TetraStats(){T=0;}
2004-10-04 20:01:36 +02:00
~TetraStats(){}
static double ComputeVolume(TETRA_MESH_TYPE *tm)
{
double total=0.f;
TETRA_MESH_TYPE::TetraIterator ti;
for (ti=tm->tetra.begin();ti<tm->tetra.end();ti++)
{
if (!ti->IsD())
total+=ti->ComputeVolume();
}
return total;
}
static double ComputeRatioMedia(TETRA_MESH_TYPE *tm)
{
double total=0.f;
TETRA_MESH_TYPE::TetraIterator ti;
int i=0;
for (ti=tm->tetra.begin();ti<tm->tetra.end();ti++)
{
if (!ti->IsD())
{
total+=ti->AspectRatio();
i++;
}
}
return (total/i);
}
void SetTetraMesh(TETRA_MESH_TYPE* T)
{
Tetra=T;
}
void Update()
{
ratio=ComputeRatioMedia(Tetra);
volume=ComputeVolume(Tetra);
}
2004-10-07 15:14:37 +02:00
void SetTetraInfo(TetraType *Te)
2004-10-04 20:01:36 +02:00
{
2004-10-07 15:14:37 +02:00
if (T!=0)
T->ClearS();
2004-10-04 20:01:36 +02:00
T=Te;
}
2004-10-07 15:14:37 +02:00
void ClearTetraInfo(TetraType *Te)
{
T=0;
}
2004-10-04 20:01:36 +02:00
TetraType * TCurrent()
{
return T;
}
};