area/perimeter of selection now uses transformation

This commit is contained in:
Marco Callieri 2016-11-07 14:34:26 +01:00
parent 25810e3527
commit 2ad66041b2

View File

@ -299,13 +299,18 @@ bool FilterMeasurePlugin::applyFilter( const QString& filterName,MeshDocument& m
}
Log("Selection is %i triangles", m.sfn);
if (m.Tr != Matrix44m::Identity())
Log("BEWARE: Area and Perimeter are calculated considering the current transformation matrix");
double fArea = 0.0;
double sArea=0;
for (CMeshO::FaceIterator fi = m.face.begin(); fi != m.face.end(); ++fi)
if (!(*fi).IsD())
if ((*fi).IsS())
{
sArea += DoubleArea(*fi) / 2.0;
// this line calculates the doublearea, I took the code from Triangle3.h (DoubleArea) and modified to use transformation
fArea = (((m.Tr * (*fi).cP(1)) - (m.Tr * (*fi).cP(0))) ^ ((m.Tr * (*fi).cP(2)) - (m.Tr * (*fi).cP(0)))).Norm();
sArea += fArea / 2.0;
}
Log("Selection Surface Area is %f", sArea);
@ -323,7 +328,7 @@ bool FilterMeasurePlugin::applyFilter( const QString& filterName,MeshDocument& m
if (adjf == &(*fi) || !(adjf->IsS()))
{
ePerimeter += 1;
sPerimeter += ((*fi).V(ei)->P() - (*fi).V((ei+1)%3)->P()).Norm();
sPerimeter += ((m.Tr * (*fi).V(ei)->P()) - (m.Tr * (*fi).V((ei + 1) % 3)->P())).Norm();
}
}
}