32 #define PAIRED_RANDOM_POSES
36 inline double MYRAND1(
size_t prec = 64)
38 return static_cast<double>(rand() % prec) /
static_cast<double>(prec - 1);
50 const pair<CPolyhedron::Ptr, CPolyhedron::Ptr>* polys{
nullptr};
51 vector<TSegment3D> intersection;
52 PIThreadParam(
const pair<CPolyhedron::Ptr, CPolyhedron::Ptr>& p)
53 : polys(&p), intersection()
58 const pair<CPolyhedron::Ptr, CPolyhedron::Ptr>& p)
66 vector<TObject3D> ints;
67 CPolyhedron::getIntersection(p.
polys->first, p.
polys->second, ints);
79 vector<TSegment3D>& sgms;
89 const vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>>& v)
91 vector<TSegment3D> sgms;
93 vector<PIThreadParam> pars(v.size());
94 vector<std::thread> threads(v.size());
96 transform(pars.begin(), pars.end(), threads.begin(), &
piCreateThread);
97 for_each(threads.begin(), threads.end(), [](std::thread& t) { t.join(); });
100 vector<TObject3D> ints, TMP;
101 for (vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>>::const_iterator it =
105 CPolyhedron::getIntersection(it->first, it->second, TMP);
106 ints.insert(ints.end(), TMP.begin(), TMP.end());
108 TObject3D::getSegments(ints, sgms);
111 lns->setLineWidth(9);
117 inline double randomZ(
double space = 25,
size_t prec = 64)
119 return space * (
MYRAND1(prec) - 0.5);
126 p1->makeConvexPolygons();
127 p2->makeConvexPolygons();
128 #ifdef PAIRED_RANDOM_POSES
145 return make_pair(p1, p2);
151 window.resize(640, 480);
154 CGridPlaneXY::Create(-25, 25, -25, 25, 0, 1);
156 scene1->insert(plane1);
157 scene1->insert(CAxis::Create(-5, -5, -5, 5, 5, 5, 2.5, 3,
true));
159 vector<pair<CPolyhedron::Ptr, CPolyhedron::Ptr>> polys;
164 CPolyhedron::CreateHexahedron(10), CPolyhedron::CreateOctahedron(10),
165 objs, -12.5, -12.5));
167 CPolyhedron::CreateIcosahedron(10), CPolyhedron::CreateDodecahedron(10),
170 CPolyhedron::CreateRhombicuboctahedron(10),
171 CPolyhedron::CreateCuboctahedron(10), objs, 12.5, 12.5));
173 CPolyhedron::CreateArchimedeanRegularAntiprism(4, 9),
174 CPolyhedron::CreateRegularDoublePyramid(9, 10, 15, 6), objs, 12.5,
177 CPolyhedron::CreateCuboctahedron(10),
178 CPolyhedron::CreateRhombicDodecahedron(10), objs, -37.5, -37.5));
180 CPolyhedron::CreateRhombicuboctahedron(10),
181 CPolyhedron::CreateDeltoidalIcositetrahedron(10), objs, -37.5, -12.5));
183 CPolyhedron::CreateIcosidodecahedron(10),
184 CPolyhedron::CreateRhombicTriacontahedron(10), objs, -37.5, 12.5));
186 CPolyhedron::CreateRhombicosidodecahedron(10),
187 CPolyhedron::CreateDeltoidalHexecontahedron(10), objs, -37.5, 37.5));
189 CPolyhedron::CreateTruncatedTetrahedron(10),
190 CPolyhedron::CreateTriakisTetrahedron(10), objs, -12.5, -37.5));
192 CPolyhedron::CreateTruncatedHexahedron(10),
193 CPolyhedron::CreateTriakisOctahedron(10), objs, -12.5, 37.5));
195 CPolyhedron::CreateTruncatedOctahedron(10),
196 CPolyhedron::CreateTetrakisHexahedron(10), objs, 12.5, -37.5));
198 CPolyhedron::CreateTruncatedDodecahedron(10),
199 CPolyhedron::CreateTriakisIcosahedron(10), objs, 12.5, 37.5));
201 CPolyhedron::CreateTruncatedIcosahedron(10),
202 CPolyhedron::CreatePentakisDodecahedron(10), objs, 37.5, -37.5));
204 CPolyhedron::CreateRandomPolyhedron(10),
205 CPolyhedron::CreateRandomPolyhedron(10), objs, 37.5, -12.5));
207 CPolyhedron::CreateDodecahedron(10),
208 CPolyhedron::CreateDeltoidalHexecontahedron(10), objs, 37.5, 12.5));
210 CPolyhedron::CreateTriakisIcosahedron(10),
211 CPolyhedron::CreatePentakisDodecahedron(10), objs, 37.5, 37.5));
214 scene1->insert(objs);
215 window.get3DSceneAndLock() = scene1;
216 window.unlockAccess3DScene();
217 window.setCameraElevationDeg(25.0f);
218 window.forceRepaint();
233 cout <<
"Error: " << e.what() <<
'.' << endl;
238 cout <<
"Unknown Error.\n";