Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00034 #include<vcg/complex/complex.h>
00035 #include<vcg/complex/algorithms/update/topology.h>
00036 #include<vcg/complex/algorithms/update/normal.h>
00037 #include<vcg/complex/algorithms/create/platonic.h>
00038 #include<vcg/complex/algorithms/point_sampling.h>
00039 #include<wrap/io_trimesh/import_off.h>
00040 #include<vcg/space/point_matching.h>
00041
00042 using namespace vcg;
00043 using namespace std;
00044
00045 class MyEdge;
00046 class MyFace;
00047 class MyVertex;
00048 struct MyUsedTypes : public vcg::UsedTypes< vcg::Use<MyVertex> ::AsVertexType,
00049 vcg::Use<MyEdge> ::AsEdgeType,
00050 vcg::Use<MyFace> ::AsFaceType>{};
00051
00052 class MyVertex : public vcg::Vertex<MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags >{};
00053 class MyFace : public vcg::Face< MyUsedTypes, vcg::face::FFAdj, vcg::face::VertexRef, vcg::face::Normal3f, vcg::face::BitFlags > {};
00054 class MyEdge : public vcg::Edge<MyUsedTypes>{};
00055 class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge> > {};
00056
00057 float EvalPlane(vcg::Plane3f &pl, std::vector<vcg::Point3f> posVec)
00058 {
00059 float off=0;
00060 for(size_t i=0;i<posVec.size();++i)
00061 off += fabs(vcg::SignedDistancePlanePoint(pl,posVec[i]));
00062
00063 off/=float(posVec.size());
00064 return off;
00065 }
00066
00067
00068 int main( )
00069 {
00070 MyMesh m;
00071 vcg::tri::Icosahedron(m);
00072 vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFaceNormalized(m);
00073 vcg::tri::UpdateBounding<MyMesh>::Box(m);
00074
00075
00076
00077
00078
00079 std::vector<vcg::Point3f> ExactVec;
00080 std::vector<vcg::Point3f> PerturbVec;
00081 tri::MontecarloSampling(m,ExactVec,10);
00082 PerturbVec=ExactVec;
00083
00084 Matrix44f RotM;
00085 Matrix44f TraM;
00086 Point3f dir;
00087 vcg::math::MarsenneTwisterRNG rnd;
00088
00089 vcg::math::GeneratePointInUnitBallUniform<float>(rnd);
00090 RotM.SetRotateDeg(rand()%360,dir);
00091 TraM.SetTranslate(1,2,3);
00092 Matrix44f RigidM = RotM*TraM;
00093
00094 for(size_t i=0;i<ExactVec.size();++i)
00095 PerturbVec[i]=RigidM*ExactVec[i];
00096
00097 Quaternionf q;
00098 Point3f tr;
00099 Matrix44f res;
00100 ComputeRigidMatchMatrix(PerturbVec,ExactVec,res);
00101
00102 res.print();
00103 RigidM.print();
00104
00105 return 0;
00106 }