Commit a6712e85 authored by Jan Möbius's avatar Jan Möbius

- Don't show statistics on non existing entities.

refs #1
parent 555215e0
......@@ -419,118 +419,150 @@ void InfoMeshObjectPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _
sumV += valence;
}
//valence
//=============================
// Vertex valence
//=============================
info_->valenceMin->setText( QString::number(minV) );
info_->valenceMean->setText( QString::number( sumV / (float)_mesh->n_vertices(),'f' ) );
info_->valenceMax->setText( QString::number(maxV) );
//edge length
info_->edgeMin->setText( QString::number(minE,'f') );
info_->edgeMean->setText( QString::number( sumE / (_mesh->n_edges()*2),'f' ) );
info_->edgeMax->setText( QString::number(maxE,'f') );
//=============================
// edge length
//=============================
if (_mesh->n_edges() >0 ) {
info_->edgeMin->setText( QString::number(minE,'f') );
info_->edgeMean->setText( QString::number( sumE / (_mesh->n_edges()*2),'f' ) );
info_->edgeMax->setText( QString::number(maxE,'f') );
} else {
info_->edgeMin->setText( "-" );
info_->edgeMean->setText( "-" );
info_->edgeMax->setText( "-" );
}
//get aspect ratio
//=============================
// Triangle information
//=============================
if (_mesh->n_faces() > 0 ) {
typename MeshT::FaceIter f_it;
typename MeshT::FaceIter f_end = _mesh->faces_end();
typename MeshT::FaceIter f_it;
typename MeshT::FaceIter f_end = _mesh->faces_end();
float maxA = FLT_MIN;
float minA = FLT_MAX;
float sumA = 0.0;
float maxI = FLT_MIN;
float minI = FLT_MAX;
//float sumI = 0.0;
float maxD = FLT_MIN;
float minD = FLT_MAX;
float sumD = 0.0;
int numD = 0;
unsigned int maxFValence = std::numeric_limits<unsigned int>::min();
unsigned int minFValence = std::numeric_limits<unsigned int>::max();
size_t sumFValence = 0;
float maxA = FLT_MIN;
float minA = FLT_MAX;
float sumA = 0.0;
float maxI = FLT_MIN;
float minI = FLT_MAX;
//float sumI = 0.0;
float maxD = FLT_MIN;
float minD = FLT_MAX;
float sumD = 0.0;
int numD = 0;
unsigned int maxFValence = std::numeric_limits<unsigned int>::min();
unsigned int minFValence = std::numeric_limits<unsigned int>::max();
size_t sumFValence = 0;
//iterate over all faces
for (f_it = _mesh->faces_begin(); f_it != f_end; ++f_it){
typename MeshT::ConstFaceVertexIter cfv_it = _mesh->cfv_iter(*f_it);
//iterate over all faces
for (f_it = _mesh->faces_begin(); f_it != f_end; ++f_it){
typename MeshT::ConstFaceVertexIter cfv_it = _mesh->cfv_iter(*f_it);
const typename MeshT::Point v0 = _mesh->point( *cfv_it );
++cfv_it;
const typename MeshT::Point v1 = _mesh->point( *cfv_it );
++cfv_it;
const typename MeshT::Point v2 = _mesh->point( *cfv_it );
const typename MeshT::Point v0 = _mesh->point( *cfv_it );
++cfv_it;
const typename MeshT::Point v1 = _mesh->point( *cfv_it );
++cfv_it;
const typename MeshT::Point v2 = _mesh->point( *cfv_it );
const float aspect = ACG::Geometry::aspectRatio(v0, v1, v2);
const float aspect = ACG::Geometry::aspectRatio(v0, v1, v2);
if (aspect < minA) minA = aspect;
if (aspect > maxA) maxA = aspect;
sumA += aspect;
if (aspect < minA) minA = aspect;
if (aspect > maxA) maxA = aspect;
sumA += aspect;
//inner triangle angles
//inner triangle angles
double angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v0) | MathTools::sane_normalized(v1 - v0) )));
double angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v0) | MathTools::sane_normalized(v1 - v0) )));
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v1) | MathTools::sane_normalized(v0 - v1) )));
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v2 - v1) | MathTools::sane_normalized(v0 - v1) )));
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v1 - v2) | MathTools::sane_normalized(v0 - v2) )));
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(v1 - v2) | MathTools::sane_normalized(v0 - v2) )));
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
if (angle < minI) minI = angle;
if (angle > maxI) maxI = angle;
//sumI += angle;
//compute dihedral angles
typename MeshT::FaceFaceIter ff_it;
const typename MeshT::Normal n1 = _mesh->normal(*f_it);
//compute dihedral angles
typename MeshT::FaceFaceIter ff_it;
const typename MeshT::Normal n1 = _mesh->normal(*f_it);
for (ff_it = _mesh->ff_iter(*f_it); ff_it.is_valid(); ++ff_it){
for (ff_it = _mesh->ff_iter(*f_it); ff_it.is_valid(); ++ff_it){
const typename MeshT::Normal n2 = _mesh->normal(*ff_it);
const typename MeshT::Normal n2 = _mesh->normal(*ff_it);
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(n1) | MathTools::sane_normalized(n2) )));
angle = OpenMesh::rad_to_deg(acos(OpenMesh::sane_aarg( MathTools::sane_normalized(n1) | MathTools::sane_normalized(n2) )));
if (angle < minD) minD = angle;
if (angle > maxD) maxD = angle;
sumD += angle;
numD ++;
if (angle < minD) minD = angle;
if (angle > maxD) maxD = angle;
sumD += angle;
numD ++;
}
const unsigned int valence = _mesh->valence(*f_it);
minFValence = std::min(minFValence, valence);
maxFValence = std::max(maxFValence, valence);
sumFValence += valence;
}
const unsigned int valence = _mesh->valence(*f_it);
minFValence = std::min(minFValence, valence);
maxFValence = std::max(maxFValence, valence);
sumFValence += valence;
}
info_->aspectMin->setText( QString::number(minA,'f') );
info_->aspectMean->setText( QString::number( sumA / _mesh->n_faces(),'f' ) );
info_->aspectMax->setText( QString::number(maxA,'f') );
info_->aspectMin->setText( QString::number(minA,'f') );
info_->aspectMean->setText( QString::number( sumA / _mesh->n_faces(),'f' ) );
info_->aspectMax->setText( QString::number(maxA,'f') );
info_->angleMin->setText( QString::number(minI,'f') );
info_->angleMean->setText( "-" );
info_->angleMax->setText( QString::number(maxI,'f') );
info_->angleMin->setText( QString::number(minI,'f') );
info_->angleMean->setText( "-" );
info_->angleMax->setText( QString::number(maxI,'f') );
info_->faceValenceMin->setText(trUtf8("%1").arg(minFValence));
info_->faceValenceMax->setText(trUtf8("%1").arg(maxFValence));
info_->faceValenceMean->setText(trUtf8("%1").arg(
static_cast<float>(sumFValence) / _mesh->n_faces()));
// Only one face or no face -> don't output angles
if ( _mesh->n_faces() > 1 ) {
info_->dihedralMin->setText( QString::number(minD,'f') );
info_->dihedralMean->setText( QString::number( sumD / numD,'f' ) );
info_->dihedralMax->setText( QString::number(maxD,'f') );
info_->faceValenceMin->setText(trUtf8("%1").arg(minFValence));
info_->faceValenceMax->setText(trUtf8("%1").arg(maxFValence));
info_->faceValenceMean->setText(trUtf8("%1").arg( static_cast<float>(sumFValence) / _mesh->n_faces()));
if ( _mesh->n_faces() > 1 ) {
info_->dihedralMin->setText( QString::number(minD,'f') );
info_->dihedralMean->setText( QString::number( sumD / numD,'f' ) );
info_->dihedralMax->setText( QString::number(maxD,'f') );
} else {
info_->dihedralMin->setText( "-" );
info_->dihedralMean->setText( "-" );
info_->dihedralMax->setText( "-" );
}
} else {
// No triangles, no info
info_->aspectMin->setText( "-" );
info_->aspectMean->setText( "-" );
info_->aspectMax->setText( "-" );
info_->angleMin->setText( "-" );
info_->angleMean->setText( "-" );
info_->angleMax->setText( "-" );
info_->faceValenceMin->setText("-");
info_->faceValenceMax->setText("-");
info_->faceValenceMean->setText("-");
info_->dihedralMin->setText( "-" );
info_->dihedralMean->setText( "-" );
info_->dihedralMax->setText( "-" );
}
//Calculate Bounding Box(min,max,cog)
ACG::Vec3d min;
ACG::Vec3d max;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment