31 #define PAIRED_RANDOM_POSES
35 inline double MYRAND1(
size_t prec = 64)
37 return static_cast<double>(rand() % prec) /
static_cast<double>(prec - 1);
49 const pair<CPolyhedron::Ptr, CPolyhedron::Ptr>* polys;
50 vector<TSegment3D> intersection;
52 : polys(&
p), intersection()
57 const pair<CPolyhedron::Ptr, CPolyhedron::Ptr>&
p)
65 vector<TObject3D> ints;
66 CPolyhedron::getIntersection(
p.polys->first,
p.polys->second, ints);
67 TObject3D::getSegments(ints,
p.intersection);
78 vector<TSegment3D>& sgms;
82 sgms.insert(sgms.end(),
p.intersection.begin(),
p.intersection.end());
88 const vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>>&
v)
90 vector<TSegment3D> sgms;
92 vector<PIThreadParam> pars(
v.size());
93 vector<std::thread> threads(
v.size());
96 for_each(threads.begin(), threads.end(), [](std::thread&
t) { t.join(); });
99 vector<TObject3D> ints, TMP;
100 for (vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>>::
const_iterator it =
104 CPolyhedron::getIntersection(it->first, it->second, TMP);
105 ints.insert(ints.end(), TMP.begin(), TMP.end());
107 TObject3D::getSegments(ints, sgms);
110 lns->setLineWidth(9);
116 inline double randomZ(
double space = 25,
size_t prec = 64)
118 return space * (
MYRAND1(prec) - 0.5);
125 p1->makeConvexPolygons();
126 p2->makeConvexPolygons();
127 #ifdef PAIRED_RANDOM_POSES
144 return make_pair(p1, p2);
150 window.resize(640, 480);
153 mrpt::make_aligned_shared<CGridPlaneXY>(-25, 25, -25, 25, 0, 1);
155 scene1->insert(plane1);
157 mrpt::make_aligned_shared<CAxis>(-5, -5, -5, 5, 5, 5, 2.5, 3,
true));
159 vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>> polys;
165 CPolyhedron::CreateHexahedron(10),
166 CPolyhedron::CreateOctahedron(10), objs, -12.5, -12.5));
169 CPolyhedron::CreateIcosahedron(10),
170 CPolyhedron::CreateDodecahedron(10), objs, -12.5, 12.5));
173 CPolyhedron::CreateRhombicuboctahedron(10),
174 CPolyhedron::CreateCuboctahedron(10), objs, 12.5, 12.5));
177 CPolyhedron::CreateArchimedeanRegularAntiprism(4, 9),
178 CPolyhedron::CreateRegularDoublePyramid(9, 10, 15, 6), objs, 12.5,
182 CPolyhedron::CreateCuboctahedron(10),
183 CPolyhedron::CreateRhombicDodecahedron(10), objs, -37.5, -37.5));
186 CPolyhedron::CreateRhombicuboctahedron(10),
187 CPolyhedron::CreateDeltoidalIcositetrahedron(10), objs, -37.5,
191 CPolyhedron::CreateIcosidodecahedron(10),
192 CPolyhedron::CreateRhombicTriacontahedron(10), objs, -37.5, 12.5));
195 CPolyhedron::CreateRhombicosidodecahedron(10),
196 CPolyhedron::CreateDeltoidalHexecontahedron(10), objs, -37.5,
200 CPolyhedron::CreateTruncatedTetrahedron(10),
201 CPolyhedron::CreateTriakisTetrahedron(10), objs, -12.5, -37.5));
204 CPolyhedron::CreateTruncatedHexahedron(10),
205 CPolyhedron::CreateTriakisOctahedron(10), objs, -12.5, 37.5));
208 CPolyhedron::CreateTruncatedOctahedron(10),
209 CPolyhedron::CreateTetrakisHexahedron(10), objs, 12.5, -37.5));
212 CPolyhedron::CreateTruncatedDodecahedron(10),
213 CPolyhedron::CreateTriakisIcosahedron(10), objs, 12.5, 37.5));
216 CPolyhedron::CreateTruncatedIcosahedron(10),
217 CPolyhedron::CreatePentakisDodecahedron(10), objs, 37.5, -37.5));
220 CPolyhedron::CreateRandomPolyhedron(10),
221 CPolyhedron::CreateRandomPolyhedron(10), objs, 37.5, -12.5));
224 CPolyhedron::CreateDodecahedron(10),
225 CPolyhedron::CreateDeltoidalHexecontahedron(10), objs, 37.5, 12.5));
228 CPolyhedron::CreateTriakisIcosahedron(10),
229 CPolyhedron::CreatePentakisDodecahedron(10), objs, 37.5, 37.5));
232 scene1->insert(objs);
233 window.get3DSceneAndLock() = scene1;
234 window.unlockAccess3DScene();
235 window.setCameraElevationDeg(25.0f);
236 window.forceRepaint();
252 cout <<
"Error: " << e.what() <<
'.' << endl;
257 cout <<
"Unknown Error.\n";