37 #include <GLUT/glut.h>
55 using namespace GMap3d;
61 Voxel_View::Voxel_View(CGMap * GM)
78 void Voxel_View::Calculate_Int_Bounding_Box(
float gmapBoundingBox[6],
79 int matrixBoundingBox[6])
84 for (
int i=0 ; i<5 ; i+=2)
89 up = ceilf(gmapBoundingBox[i]);
90 down = floorf(gmapBoundingBox[i]);
92 if (fabs(up - gmapBoundingBox[i])<
EPS)
93 matrixBoundingBox[i] = (int)up;
96 matrixBoundingBox[i] = (int)down;
100 up = ceilf(-gmapBoundingBox[i+1]);
101 down = floorf(-gmapBoundingBox[i+1]);
103 if (fabs(down + gmapBoundingBox[i+1])<
EPS)
104 matrixBoundingBox[i+1] = (int)down;
107 matrixBoundingBox[i+1] = (int)up;
120 void Voxel_View::Create_Matrix()
125 CDart * d01, * dO, * d;
130 float gmapBoundingBox[6];
131 int matrixBoundingBox[6];
134 int markVoxel = G->getNewMark();
137 CDynamicCoverageAll Cgm(G);
139 for (Cgm.reinit(); Cgm.cont(); Cgm++)
144 if (!G->isMarked(d, markVoxel))
151 Calculate_Int_Bounding_Box(gmapBoundingBox, matrixBoundingBox);
158 CCoverage* DC = G->getDynamicCoverage(d, ORBIT_0123);
161 for (DC->reinit(); DC->cont(); (*DC)++)
166 if (!G->isMarked(dO, markVoxel))
177 Calculate_Int_Bounding_Box(gmapBoundingBox,
184 alpha = G->getAttribute(dO, ORBIT_013,
190 for (
int t=0; t<2; t++)
192 for (
int i = matrixBoundingBox[1];
193 i <= matrixBoundingBox[0]; i++)
194 for (
int j = matrixBoundingBox[3];
195 j <= matrixBoundingBox[2]; j++)
196 for (
int k = matrixBoundingBox[5];
197 k <= matrixBoundingBox[4]; k++)
205 CCoverage* DCf = G->getDynamicCoverage(dO, ORBIT_01);
213 if (!G->isMarked(d01, markVoxel))
216 alpha = G->getAttribute(d01, ORBIT_023,
222 alpha = G->getAttribute(d01, ORBIT_0,
228 for (
int t=0; t<6; t++)
232 for (
int i = matrixBoundingBox[1];
233 i <= matrixBoundingBox[0]; i++)
234 for (
int j = matrixBoundingBox[3];
235 j <= matrixBoundingBox[2]; j++)
236 for (
int k = matrixBoundingBox[5];
237 k <= matrixBoundingBox[4]; k++)
245 G->setMark(d01, markVoxel);
246 G->setMark(G->alpha0(d01), markVoxel);
254 list<Voxel*> *l = (list<Voxel*>*)vList->
Get_Data();
258 for (
int i = matrixBoundingBox[1];
259 i <= matrixBoundingBox[0]; i++)
260 for (
int j = matrixBoundingBox[3];
261 j <= matrixBoundingBox[2]; j++)
262 for (
int k = matrixBoundingBox[5];
263 k <= matrixBoundingBox[4]; k++)
267 l->push_front(
new Voxel(i, j, k));
272 G->addAttribute(dO, ORBIT_013, vList);
277 G->setMark(dO, markVoxel);
282 for (DC->reinit(); DC->cont(); (*DC)++)
283 G->unsetMark(**DC, markVoxel);
286 for (DC->reinit(); DC->cont(); (*DC)++)
289 if (!G->isMarked(dO, markVoxel))
298 Calculate_Int_Bounding_Box(gmapBoundingBox,
305 alpha = G->getAttribute(dO, ORBIT_023,
310 for (
int t=0; t<6; t++)
313 for (
int i=matrixBoundingBox[1];
314 i<=matrixBoundingBox[0]; i++)
316 for (
int j=matrixBoundingBox[3];
317 j<=matrixBoundingBox[2]; j++)
319 for (
int k=matrixBoundingBox[5];
320 k<=matrixBoundingBox[4]; k++)
328 CCoverage* DCe = G->getDynamicCoverage(dO, ORBIT_023);
332 G->setMark(**DCe, markVoxel);
337 list<Voxel*> *l = (list<Voxel*>*)vList->
Get_Data();
342 for (
int i=matrixBoundingBox[1];
343 i<=matrixBoundingBox[0]; i++)
345 for (
int j=matrixBoundingBox[3];
346 j<=matrixBoundingBox[2]; j++)
348 for (
int k=matrixBoundingBox[5];
349 k<=matrixBoundingBox[4]; k++)
353 l->push_front(
new Voxel(i, j, k));
357 G->addAttribute(dO, ORBIT_023, vList);
363 G->setMark(dO, markVoxel);
367 for (DC->reinit(); DC->cont(); (*DC)++)
368 G->unsetMark(**DC, markVoxel);
372 for (DC->reinit(); DC->cont(); (*DC)++)
377 if (!G->isMarked(dO, markVoxel))
392 Calculate_Int_Bounding_Box(gmapBoundingBox,
399 for (
int t=0; t<6; t++)
402 for (
int i=matrixBoundingBox[1];
403 i<=matrixBoundingBox[0]; i++)
405 for (
int j=matrixBoundingBox[3];
406 j<=matrixBoundingBox[2]; j++)
408 for (
int k=matrixBoundingBox[5];
409 k<=matrixBoundingBox[4]; k++)
416 CCoverage* DCe = G->getDynamicCoverage(dO, ORBIT_123);
420 G->setMark(**DCe, markVoxel);
425 list<Voxel*> *l = (list<Voxel*>*)vList->
Get_Data();
429 for (
int i=matrixBoundingBox[1];
430 i<=matrixBoundingBox[0]; i++)
432 for (
int j=matrixBoundingBox[3];
433 j<=matrixBoundingBox[2]; j++)
435 for (
int k=matrixBoundingBox[5];
436 k<=matrixBoundingBox[4]; k++)
440 l->push_front(
new Voxel(i, j, k));
445 G->addAttribute(dO, ORBIT_123, vList);
450 G->addAttribute(d, ORBIT_0123, matrix);
452 for (DC->reinit(); DC->cont(); (*DC)++)
453 G->unsetMark(**DC, markVoxel);
455 for (DC->reinit(); DC->cont(); (*DC)++)
456 G->setMark(**DC, markVoxel);
460 for (Cgm.reinit(); Cgm.cont(); Cgm++)
461 G->unsetMark(*Cgm, markVoxel);
463 G->freeMark(markVoxel);
474 void Voxel_View::Draw_Vertices()
477 int markVoxel = G->getNewMark();
480 glEnable(GL_LIGHTING);
482 CDynamicCoverageAll Cgm(G);
483 for (Cgm.reinit(); Cgm.cont(); Cgm++)
488 if (!G->isMarked(d, markVoxel))
510 CCoverage* DC = G->getDynamicCoverage(d, ORBIT_0123);
511 for (DC->reinit(); DC->cont(); (*DC)++)
512 G->setMark(**DC, markVoxel);
516 for (Cgm.reinit(); Cgm.cont(); Cgm++)
517 G->unsetMark(*Cgm, markVoxel);
519 G->freeMark(markVoxel);
522 glDisable(GL_LIGHTING);
533 void Voxel_View::Draw_Edges()
536 int markVoxel = G->getNewMark();
539 glEnable(GL_LIGHTING);
541 CDynamicCoverageAll Cgm(G);
542 for (Cgm.reinit(); Cgm.cont(); Cgm++)
547 if (!G->isMarked(d, markVoxel))
567 CCoverage* DC = G->getDynamicCoverage(d, ORBIT_0123);
568 for (DC->reinit(); DC->cont(); (*DC)++)
569 G->setMark(**DC, markVoxel);
573 for (Cgm.reinit(); Cgm.cont(); Cgm++)
574 G->unsetMark(*Cgm, markVoxel);
576 G->freeMark(markVoxel);
579 glDisable(GL_LIGHTING);
590 void Voxel_View::Draw_Faces()
593 int markVoxel = G->getNewMark();
596 glEnable(GL_LIGHTING);
598 CDynamicCoverageAll Cgm(G);
599 for (Cgm.reinit(); Cgm.cont(); Cgm++)
604 if (!G->isMarked(d, markVoxel))
625 CCoverage* DC = G->getDynamicCoverage(d, ORBIT_0123);
626 for (DC->reinit(); DC->cont(); (*DC)++)
627 G->setMark(**DC, markVoxel);
631 for (Cgm.reinit(); Cgm.cont(); Cgm++)
632 G->unsetMark(*Cgm, markVoxel);
634 G->freeMark(markVoxel);
637 glDisable(GL_LIGHTING);