1212
1313int main ()
1414{
15- auto initTime = std::chrono::high_resolution_clock::now ();
16-
17- std::shared_ptr<diffCheck::geometry::DFPointCloud> pcdSrc = std::make_shared<diffCheck::geometry::DFPointCloud>();
18-
19- std::vector<std::vector<std::shared_ptr<diffCheck::geometry::DFMesh>>> meshSrc = std::vector<std::vector<std::shared_ptr<diffCheck::geometry::DFMesh>>>();
20- std::vector<std::shared_ptr<diffCheck::geometry::DFPointCloud>> segments;
21- std::vector<std::string> meshPaths;
22-
23- std::string meshesFolderPath = R"( C:\Users\localuser\Desktop\meshes_for_diffCheck\joints\)" ;
24-
25- for (int i = 1 ; i <= 3 ; i++)
26- {
27- std::vector<std::shared_ptr<diffCheck::geometry::DFMesh>> fullJoint;
28- for (int j = 1 ; j <= 3 ; j++)
29- {
30- std::string meshPath = meshesFolderPath + std::to_string (i) + " /" + std::to_string (j) + " .ply" ;
31- std::shared_ptr<diffCheck::geometry::DFMesh> mesh = std::make_shared<diffCheck::geometry::DFMesh>();
32- mesh->LoadFromPLY (meshPath);
33- fullJoint.push_back (mesh);
34- }
35- meshSrc.push_back (fullJoint);
36- }
37-
38- std::string pathPcdSrc = R"( C:\Users\localuser\Desktop\meshes_for_diffCheck\joints\full_beam.ply)" ;
39-
40- pcdSrc->LoadFromPLY (pathPcdSrc);
41-
42- pcdSrc->EstimateNormals (false , 100 );
43- pcdSrc->VoxelDownsample (0.007 );
44- auto intermediateTime = std::chrono::high_resolution_clock::now ();
45- segments = diffCheck::segmentation::DFSegmentation::NormalBasedSegmentation (
46- pcdSrc,
47- 15 .0f ,
48- 15 ,
49- true ,
50- 50 ,
51- 0 .5f ,
52- false );
53- std::cout << " number of segments:" << segments.size ()<< std::endl;
54-
55- std::vector<std::shared_ptr<diffCheck::geometry::DFPointCloud>> unifiedSegments;
56- for (int i = 0 ; i < meshSrc.size (); i++)
57- {
58- std::shared_ptr<diffCheck::geometry::DFPointCloud> unifiedSegment = std::make_shared<diffCheck::geometry::DFPointCloud>();
59- unifiedSegment = diffCheck::segmentation::DFSegmentation::AssociateClustersToMeshes (
60- meshSrc[i],
61- segments,
62- .2 ,
63- .05 );
64- unifiedSegments.push_back (unifiedSegment);
65- }
66-
67- diffCheck::segmentation::DFSegmentation::CleanUnassociatedClusters (segments,
68- unifiedSegments,
69- meshSrc,
70- .2 ,
71- .05 );
72-
73- // Perform a registration per joint
74- for (int i = 0 ; i < meshSrc.size (); i++)
75- {
76- std::shared_ptr<diffCheck::geometry::DFPointCloud> referencePointCloud = std::make_shared<diffCheck::geometry::DFPointCloud>();
77- for (auto jointFace : meshSrc[i])
78- {
79- std::shared_ptr<diffCheck::geometry::DFPointCloud> facePointCloud = jointFace->SampleCloudUniform (1000 );
80- referencePointCloud->Points .insert (referencePointCloud->Points .end (), facePointCloud->Points .begin (), facePointCloud->Points .end ());
81- }
82- referencePointCloud->EstimateNormals (false , 100 );
83-
84- diffCheck::transformation::DFTransformation transformation = diffCheck::registrations::DFRefinedRegistration::O3DICP (
85- unifiedSegments[i],
86- referencePointCloud);
87-
88- std::cout << " Transformation matrix:" << std::endl;
89- std::cout << transformation.TransformationMatrix << std::endl;
90-
91- diffCheck::visualizer::Visualizer deVisu = diffCheck::visualizer::Visualizer (" DiffCheckApp" , 1000 , 800 , 50 , 50 , false , true , false );
92- for (int i = 0 ; i < segments.size (); i++)
93- {
94- segments[i]->ApplyTransformation (transformation);
95- deVisu.AddPointCloud (segments[i]);
96- }
97- for (auto joint : meshSrc)
98- {
99- for (auto face : joint)
100- {
101- deVisu.AddMesh (face);
102- }
103- }
104- deVisu.Run ();
105- }
106-
107- diffCheck::visualizer::Visualizer vis (std::string (" DiffCheckApp" ), 1000 , 800 , 50 , 50 , false , true , false );
108- for (auto segment : segments)
109- {
110- // colorize the segments with random colors
111- double r = static_cast <double >(rand ()) / RAND_MAX;
112- double g = static_cast <double >(rand ()) / RAND_MAX;
113- double b = static_cast <double >(rand ()) / RAND_MAX;
114-
115- segment->Colors .clear ();
116- for (int i = 0 ; i < segment->Points .size (); i++)
117- {
118- segment->Colors .push_back (Eigen::Vector3d (0 , 0 , 0 ));
119- }
120- vis.AddPointCloud (segment);
121- }
122- for (auto joint : meshSrc)
123- {
124- for (auto mesh : joint){vis.AddMesh (mesh);}
125- }
126-
127- int numSegments = unifiedSegments.size ();
128-
129- for (int i = 0 ; i < numSegments; i++)
130- {
131- for (int j = 0 ; j < unifiedSegments[i]->Points .size (); j++)
132- {
133- unifiedSegments[i]->Colors .push_back (Eigen::Vector3d ((double (numSegments) - double (i))/double (numSegments), 1 , double (i) / double (numSegments)));
134- }
135- }
136- for (auto seg : unifiedSegments)
137- {
138- vis.AddPointCloud (seg);
139- }
140-
141- auto endTime = std::chrono::high_resolution_clock::now ();
142- auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - initTime);
143- auto segmentationTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - intermediateTime);
144- std::cout << " Total computation time:" << duration.count () << std::endl;
145- std::cout << " Segmentation time:" << segmentationTime.count () << std::endl;
146-
147- vis.Run ();
148-
15+ std::cout << " Hello, World!" << std::endl;
14916 return 0 ;
15017}
0 commit comments