minor changes to the samples, removed harmless warnings, updated interfaces
This commit is contained in:
parent
c5fcfd94c1
commit
ce0dfc02d2
|
@ -48,7 +48,7 @@ class MyFace : public vcg::Face < MyUsedTypes, vcg::face::VertexRef, vcg::fac
|
||||||
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
|
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> > {};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main()
|
||||||
{
|
{
|
||||||
MyMesh m;
|
MyMesh m;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::V
|
||||||
class MyEdge : public vcg::Edge<MyUsedTypes>{};
|
class MyEdge : public vcg::Edge<MyUsedTypes>{};
|
||||||
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
|
class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
|
||||||
|
|
||||||
float EvalPlane(vcg::Plane3f &pl, vcg::Point3f &dir, std::vector<vcg::Point3f> posVec)
|
float EvalPlane(vcg::Plane3f &pl, std::vector<vcg::Point3f> posVec)
|
||||||
{
|
{
|
||||||
float off=0;
|
float off=0;
|
||||||
for(size_t i=0;i<posVec.size();++i)
|
for(size_t i=0;i<posVec.size();++i)
|
||||||
|
@ -63,7 +63,7 @@ float EvalPlane(vcg::Plane3f &pl, vcg::Point3f &dir, std::vector<vcg::Point3f> p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main( int argc, char **argv )
|
int main( )
|
||||||
{
|
{
|
||||||
MyMesh m;
|
MyMesh m;
|
||||||
vcg::tri::Icosahedron(m);
|
vcg::tri::Icosahedron(m);
|
||||||
|
@ -76,6 +76,7 @@ int main( int argc, char **argv )
|
||||||
int cnt=0;
|
int cnt=0;
|
||||||
float scaleFac = m.bbox.Diag()/10.0f;
|
float scaleFac = m.bbox.Diag()/10.0f;
|
||||||
printf("ScaleFac %f\n\n",scaleFac);
|
printf("ScaleFac %f\n\n",scaleFac);
|
||||||
|
vcg::math::MarsenneTwisterRNG rnd;
|
||||||
for(int i=0;i<m.FN();++i)
|
for(int i=0;i<m.FN();++i)
|
||||||
{
|
{
|
||||||
std::vector<vcg::Point3f> ExactVec;
|
std::vector<vcg::Point3f> ExactVec;
|
||||||
|
@ -87,7 +88,7 @@ int main( int argc, char **argv )
|
||||||
{
|
{
|
||||||
vcg::Point3f p = vcg::tri::SurfaceSampling<MyMesh>::RandomPointInTriangle(m.face[i]);
|
vcg::Point3f p = vcg::tri::SurfaceSampling<MyMesh>::RandomPointInTriangle(m.face[i]);
|
||||||
ExactVec.push_back(p);
|
ExactVec.push_back(p);
|
||||||
vcg::Point3f off=vcg::tri::SurfaceSampling<MyMesh>::RandomPoint3fBall01();
|
vcg::Point3f off = vcg::math::GeneratePointInUnitBallUniform<float>(rnd);
|
||||||
p+=off*scaleFac;
|
p+=off*scaleFac;
|
||||||
float w = std::max(0.0, 1.0f-fabs(vcg::SignedDistancePlanePoint(pl,p))/scaleFac);
|
float w = std::max(0.0, 1.0f-fabs(vcg::SignedDistancePlanePoint(pl,p))/scaleFac);
|
||||||
PerturbVec.push_back(p);
|
PerturbVec.push_back(p);
|
||||||
|
@ -95,13 +96,13 @@ int main( int argc, char **argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
vcg::FitPlaneToPointSet(ExactVec,ple);
|
vcg::FitPlaneToPointSet(ExactVec,ple);
|
||||||
float err=EvalPlane(ple,m.face[i].N(),ExactVec);
|
float err=EvalPlane(ple,ExactVec);
|
||||||
|
|
||||||
vcg::FitPlaneToPointSet(PerturbVec,plf);
|
vcg::FitPlaneToPointSet(PerturbVec,plf);
|
||||||
float err0=EvalPlane(plf,m.face[i].N(),ExactVec);
|
float err0=EvalPlane(plf,ExactVec);
|
||||||
|
|
||||||
vcg::WeightedFitPlaneToPointSet(PerturbVec,WeightVec,plw);
|
vcg::WeightedFitPlaneToPointSet(PerturbVec,WeightVec,plw);
|
||||||
float err1=EvalPlane(plw,m.face[i].N(),ExactVec);
|
float err1=EvalPlane(plw,ExactVec);
|
||||||
printf("Exact %5.3f Fit to Perturbed %5.3f Weighted fit to perturbed %5.3f\n",err,err0,err1);
|
printf("Exact %5.3f Fit to Perturbed %5.3f Weighted fit to perturbed %5.3f\n",err,err0,err1);
|
||||||
if(err0>err1) cnt++;
|
if(err0>err1) cnt++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue