1 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 // The content of this file is subject to the Open CASCADE Technology Public
4 // License Version 6.5 (the "License"). You may not use the content of this file
5 // except in compliance with the License. Please obtain a copy of the License
6 // at http://www.opencascade.org and read it completely before using this file.
8 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 // The Original Code and all software distributed under the License is
12 // distributed on an "AS IS" basis, without warranty of any kind, and the
13 // Initial Developer hereby disclaims all such warranties, including without
14 // limitation, any warranties of merchantability, fitness for a particular
15 // purpose or non-infringement. Please see the License for the specific terms
16 // and conditions governing the rights and limitations under the License.
18 #include "VoxelClient_VisDrawer.h"
22 #include <Geom_Plane.hxx>
23 #include <gce_MakePln.hxx>
24 #include <Quantity_Color.hxx>
25 #include <Aspect_TypeOfLine.hxx>
26 #include <Graphic3d_CUserDraw.hxx>
28 #include <InterfaceGraphic_telem.hxx>
29 #include <OpenGl_Element.hxx>
30 #include <OpenGl_GraphicDriver.hxx>
31 #include <OpenGl_NamedStatus.hxx>
36 /**************************************************************************/
38 class VoxelClient_VisDrawer::VisElement : public OpenGl_Element
42 VisElement (Voxel_VisData*);
43 virtual ~VisElement();
45 void EvaluateBounds (Graphic3d_CBounds& theMinMax);
47 void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
49 virtual void Release (const Handle(OpenGl_Context)& theContext)
56 VoxelClient_VisDrawer* myHandler;
64 //=======================================================================
65 //function : VisElement
66 //purpose : Constructor
67 //=======================================================================
69 VoxelClient_VisDrawer::VisElement::VisElement (Voxel_VisData* theData)
71 myHandler = new VoxelClient_VisDrawer (theData);
74 //=======================================================================
75 //function : ~VisElement
76 //purpose : Destructor
77 //=======================================================================
79 VoxelClient_VisDrawer::VisElement::~VisElement ()
84 //=======================================================================
85 //function : EvaluateBounds
87 //=======================================================================
89 void VoxelClient_VisDrawer::VisElement::EvaluateBounds
90 (Graphic3d_CBounds& theMinMax)
92 myHandler->EvalMinMax (theMinMax);
95 //=======================================================================
97 //purpose : display element
98 //=======================================================================
100 void VoxelClient_VisDrawer::VisElement::Render
101 (const Handle (OpenGl_Workspace) &theWorkspace) const
103 const Standard_Boolean aHl = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT);
104 myHandler->Display (aHl);
107 //=======================================================================
108 //function : VisDrawerCallBack
109 //purpose : visdrawer element create callback, adds an element to graphic
110 // driver's structure
111 //=======================================================================
113 static OpenGl_Element* VisDrawerCallBack (const Graphic3d_CUserDraw* theUserDraw)
115 if (theUserDraw == 0)
118 // Retrieve the user structure
119 Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);
124 VoxelClient_VisDrawer::VisElement *aElem =
125 new VoxelClient_VisDrawer::VisElement (aUserData);
127 if (theUserDraw->Bounds != 0)
128 aElem->EvaluateBounds (*(theUserDraw->Bounds));
133 /**************************************************************************/
134 void VoxelClient_VisDrawer::Init (Handle(OpenGl_GraphicDriver)& theDriver)
136 static Standard_Boolean isInitializeded(Standard_False);
138 if (!isInitializeded)
140 isInitializeded = Standard_True;
141 theDriver->UserDrawCallback() = VisDrawerCallBack;
145 /**************************************************************************/
146 VoxelClient_VisDrawer::VoxelClient_VisDrawer(Voxel_VisData * theData):myData(theData)
151 /**************************************************************************/
152 VoxelClient_VisDrawer::~VoxelClient_VisDrawer()
156 // Because a pointer to the data is copied,
157 // it is possible to make an attempt to delete GL lists for
158 // a structure, which is already deleted.
159 // Such a situation may happen on close of the application.
160 // Therefore, this try / catch is used.
164 Standard_Integer idir;
169 if (myData->myDisplay.myBoolPointsList > 0)
171 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
172 myData->myDisplay.myBoolPointsList = -1;
174 for (idir = Xminus; idir <= Zplus; idir++)
176 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
178 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
179 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
184 if (myData->myDisplay.myColorPointsList > 0)
186 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
187 myData->myDisplay.myColorPointsList = -1;
189 for (idir = Xminus; idir <= Zplus; idir++)
191 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
193 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
194 myData->myDisplay.myColorNearestPointsList[idir] = -1;
199 if (myData->myDisplay.myROctBoolPointsList > 0)
201 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
202 myData->myDisplay.myROctBoolPointsList = -1;
204 for (idir = Xminus; idir <= Zplus; idir++)
206 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
208 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
209 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
214 if (myData->myDisplay.myTriangulationList > 0)
216 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
217 myData->myDisplay.myTriangulationList = -1;
227 /**************************************************************************/
228 void VoxelClient_VisDrawer::EvalMinMax(Graphic3d_CBounds & theMinMax) const
230 theMinMax.XMin = FLT_MAX;
231 theMinMax.YMin = FLT_MAX;
232 theMinMax.ZMin = FLT_MAX;
233 theMinMax.XMax = -FLT_MAX;
234 theMinMax.YMax = -FLT_MAX;
235 theMinMax.ZMax = -FLT_MAX;
238 if(myData->myBoolVoxels)
240 if (theMinMax.XMin > myData->myBoolVoxels->GetX())
241 theMinMax.XMin = myData->myBoolVoxels->GetX();
242 if (theMinMax.XMax < myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen())
243 theMinMax.XMax = myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen();
244 if (theMinMax.YMin > myData->myBoolVoxels->GetY())
245 theMinMax.YMin = myData->myBoolVoxels->GetY();
246 if (theMinMax.YMax < myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen())
247 theMinMax.YMax = myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen();
248 if (theMinMax.ZMin > myData->myBoolVoxels->GetZ())
249 theMinMax.ZMin = myData->myBoolVoxels->GetZ();
250 if (theMinMax.ZMax < myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen())
251 theMinMax.ZMax = myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen();
253 if(myData->myColorVoxels)
255 if (theMinMax.XMin > myData->myColorVoxels->GetX())
256 theMinMax.XMin = myData->myColorVoxels->GetX();
257 if (theMinMax.XMax < myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen())
258 theMinMax.XMax = myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen();
259 if (theMinMax.YMin > myData->myColorVoxels->GetY())
260 theMinMax.YMin = myData->myColorVoxels->GetY();
261 if (theMinMax.YMax < myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen())
262 theMinMax.YMax = myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen();
263 if (theMinMax.ZMin > myData->myColorVoxels->GetZ())
264 theMinMax.ZMin = myData->myColorVoxels->GetZ();
265 if (theMinMax.ZMax < myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen())
266 theMinMax.ZMax = myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen();
268 if(myData->myROctBoolVoxels)
270 if (theMinMax.XMin > myData->myROctBoolVoxels->GetX())
271 theMinMax.XMin = myData->myROctBoolVoxels->GetX();
272 if (theMinMax.XMax < myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen())
273 theMinMax.XMax = myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen();
274 if (theMinMax.YMin > myData->myROctBoolVoxels->GetY())
275 theMinMax.YMin = myData->myROctBoolVoxels->GetY();
276 if (theMinMax.YMax < myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen())
277 theMinMax.YMax = myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen();
278 if (theMinMax.ZMin > myData->myROctBoolVoxels->GetZ())
279 theMinMax.ZMin = myData->myROctBoolVoxels->GetZ();
280 if (theMinMax.ZMax < myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen())
281 theMinMax.ZMax = myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen();
283 if (!myData->myTriangulation.IsNull())
285 Standard_Real x, y, z;
286 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
287 Standard_Integer inode = nodes.Lower(), nb_nodes = nodes.Upper();
288 for (; inode <= nb_nodes; inode++)
290 nodes.Value(inode).Coord(x, y, z);
291 if (theMinMax.XMin > x)
293 if (theMinMax.XMax < x)
295 if (theMinMax.YMin > y)
297 if (theMinMax.YMax < y)
299 if (theMinMax.ZMin > z)
301 if (theMinMax.ZMax < z)
307 /**************************************************************************/
308 void VoxelClient_VisDrawer::Display(const Standard_Boolean theHighlight)
312 if (myData->myBoolVoxels)
313 DisplayVoxels(theHighlight);
314 if (myData->myColorVoxels)
315 DisplayVoxels(theHighlight);
316 if (myData->myROctBoolVoxels)
317 DisplayVoxels(theHighlight);
318 if (!myData->myTriangulation.IsNull())
319 DisplayTriangulation(theHighlight);
322 // Some static method to define Open GL visual attributes
324 static void setColor(const Quantity_Color& color, const Standard_Boolean highlight)
326 static Quantity_Color highlight_color(Quantity_NOC_BLUE1);
328 glColor3f(highlight_color.Red(), highlight_color.Green(), highlight_color.Blue());
330 glColor3d(color.Red(), color.Green(), color.Blue());
334 static void setTypeOfLine(const Aspect_TypeOfLine type)
336 if(type == Aspect_TOL_SOLID)
338 glDisable(GL_LINE_STIPPLE);
342 glEnable(GL_LINE_STIPPLE);
343 if(type == Aspect_TOL_DOT)
344 glLineStipple(1, 0xCCCC);
345 else if(type == Aspect_TOL_DASH)
346 glLineStipple(1, 0xFFC0);
347 else if(type == Aspect_TOL_DOTDASH)
348 glLineStipple(1, 0xFF18);
353 static void setWidthOfLine(const Standard_Integer width)
355 glLineWidth((Standard_ShortReal) width);
358 // Normal of the view
359 static void getNormal(gp_Dir& normal)
361 Standard_Real x, y, z;
363 GLdouble model_matrix[16], proj_matrix[16];
365 glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
366 glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix);
367 glGetIntegerv(GL_VIEWPORT, viewport);
369 gluUnProject(viewport[0], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
371 gluUnProject(viewport[0] + viewport[2], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
373 gluUnProject(viewport[0], viewport[1] + viewport[3], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
376 gce_MakePln mkNormal(p1, p2, p3);
377 if (mkNormal.IsDone())
379 const gp_Pln& normal_plane = mkNormal.Value();
380 normal = normal_plane.Axis().Direction();
388 // Normal 2 VoxelDirection converter
389 static VoxelDirection getVoxelDirection(const gp_Dir& viewnormal)
392 Standard_Real fabsviewnormalx = fabs(viewnormal.X());
393 Standard_Real fabsviewnormaly = fabs(viewnormal.Y());
394 Standard_Real fabsviewnormalz = fabs(viewnormal.Z());
395 if (fabsviewnormalx >= fabsviewnormaly &&
396 fabsviewnormalx >= fabsviewnormalz)
398 if (viewnormal.X() > 0)
403 else if (fabsviewnormaly >= fabsviewnormalx &&
404 fabsviewnormaly >= fabsviewnormalz)
406 if (viewnormal.Y() > 0)
411 else if (fabsviewnormalz >= fabsviewnormalx &&
412 fabsviewnormalz >= fabsviewnormaly)
414 if (viewnormal.Z() > 0)
422 // Normal 2 VoxelDirection 3 converter
423 static void getVoxel3Directions(const gp_Dir& viewnormal,
424 VoxelDirection& vdir1,
425 VoxelDirection& vdir2,
426 VoxelDirection& vdir3)
428 Standard_Boolean vdir1_set = Standard_False, vdir2_set = Standard_False, vdir3_set = Standard_False;
431 Standard_Real dot = viewnormal.Dot(-gp::DX());
437 vdir1_set = Standard_True;
442 vdir2_set = Standard_True;
447 vdir3_set = Standard_True;
452 dot = viewnormal.Dot(gp::DX());
458 vdir1_set = Standard_True;
463 vdir2_set = Standard_True;
468 vdir3_set = Standard_True;
473 dot = viewnormal.Dot(-gp::DY());
479 vdir1_set = Standard_True;
484 vdir2_set = Standard_True;
489 vdir3_set = Standard_True;
494 dot = viewnormal.Dot(gp::DY());
500 vdir1_set = Standard_True;
505 vdir2_set = Standard_True;
510 vdir3_set = Standard_True;
515 dot = viewnormal.Dot(-gp::DZ());
521 vdir1_set = Standard_True;
526 vdir2_set = Standard_True;
531 vdir3_set = Standard_True;
536 dot = viewnormal.Dot(gp::DZ());
542 vdir1_set = Standard_True;
547 vdir2_set = Standard_True;
552 vdir3_set = Standard_True;
557 static Standard_Boolean CheckSize(Voxel_DS* voxels,
558 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
559 const Standard_Real xmin, const Standard_Real xmax,
560 const Standard_Real ymin, const Standard_Real ymax,
561 const Standard_Real zmin, const Standard_Real zmax,
562 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
564 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
565 if (xc < xmin || xc > xmax)
566 return Standard_False;
567 if (yc < ymin || yc > ymax)
568 return Standard_False;
569 if (zc < zmin || zc > zmax)
570 return Standard_False;
571 return Standard_True;
574 static Standard_Boolean CheckSize(Voxel_ROctBoolDS* voxels,
575 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
576 const Standard_Integer i, const Standard_Integer j,
577 const Standard_Real xmin, const Standard_Real xmax,
578 const Standard_Real ymin, const Standard_Real ymax,
579 const Standard_Real zmin, const Standard_Real zmax,
580 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
583 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
585 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
586 if (xc < xmin || xc > xmax)
587 return Standard_False;
588 if (yc < ymin || yc > ymax)
589 return Standard_False;
590 if (zc < zmin || zc > zmax)
591 return Standard_False;
592 return Standard_True;
595 static void drawBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
596 Voxel_BoolDS* voxels,
597 const Standard_Real xmin, const Standard_Real xmax,
598 const Standard_Real ymin, const Standard_Real ymax,
599 const Standard_Real zmin, const Standard_Real zmax)
601 Standard_Real xc, yc, zc;
602 Standard_Integer ix = 0, nbx = voxels->GetNbX();
603 Standard_Integer iy = 0, nby = voxels->GetNbY();
604 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
606 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
607 ymin <= DBL_MAX && ymax >= DBL_MAX &&
608 zmin <= DBL_MAX && zmax >= DBL_MAX);
609 check_size = !check_size;
616 for (iy = 0; iy < nby; iy++)
618 for (iz = 0; iz < nbz; iz++)
620 for (ix = 0; ix < nbx; ix++)
622 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
624 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
628 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
629 glVertex3d(xc, yc, zc);
640 for (iy = 0; iy < nby; iy++)
642 for (iz = 0; iz < nbz; iz++)
644 for (ix = nbx - 1; ix >= 0; ix--)
646 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
648 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
652 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
653 glVertex3d(xc, yc, zc);
664 for (ix = 0; ix < nbx; ix++)
666 for (iz = 0; iz < nbz; iz++)
668 for (iy = 0; iy < nby; iy++)
670 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
672 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
676 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
677 glVertex3d(xc, yc, zc);
688 for (ix = 0; ix < nbx; ix++)
690 for (iz = 0; iz < nbz; iz++)
692 for (iy = nby - 1; iy >= 0; iy--)
694 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
696 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
700 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
701 glVertex3d(xc, yc, zc);
712 for (ix = 0; ix < nbx; ix++)
714 for (iy = 0; iy < nby; iy++)
716 for (iz = 0; iz < nbz; iz++)
718 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
720 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
724 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
725 glVertex3d(xc, yc, zc);
736 for (ix = 0; ix < nbx; ix++)
738 for (iy = 0; iy < nby; iy++)
740 for (iz = nbz - 1; iz >= 0; iz--)
742 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
744 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
748 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
749 glVertex3d(xc, yc, zc);
762 static void drawROctBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
763 Voxel_ROctBoolDS* voxels,
764 const Standard_Real xmin, const Standard_Real xmax,
765 const Standard_Real ymin, const Standard_Real ymax,
766 const Standard_Real zmin, const Standard_Real zmax)
768 Standard_Real xc, yc, zc;
769 Standard_Integer ix = 0, nbx = voxels->GetNbX();
770 Standard_Integer iy = 0, nby = voxels->GetNbY();
771 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
772 Standard_Integer i, j;
774 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
775 ymin <= DBL_MAX && ymax >= DBL_MAX &&
776 zmin <= DBL_MAX && zmax >= DBL_MAX);
777 check_size = !check_size;
784 for (iy = 0; iy < nby; iy++)
786 for (iz = 0; iz < nbz; iz++)
788 for (ix = 0; ix < nbx; ix++)
790 switch (voxels->Deepness(ix, iy, iz))
794 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
796 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
800 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
801 glVertex3d(xc, yc, zc);
809 for (i = 0; i < 8; i++)
811 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
813 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
817 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
818 glVertex3d(xc, yc, zc);
827 for (i = 0; i < 8; i++)
829 for (j = 0; j < 8; j++)
831 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
833 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
837 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
838 glVertex3d(xc, yc, zc);
854 for (iy = 0; iy < nby; iy++)
856 for (iz = 0; iz < nbz; iz++)
858 for (ix = nbx - 1; ix >= 0; ix--)
860 switch (voxels->Deepness(ix, iy, iz))
864 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
866 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
870 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
871 glVertex3d(xc, yc, zc);
879 for (i = 0; i < 8; i++)
881 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
883 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
887 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
888 glVertex3d(xc, yc, zc);
897 for (i = 0; i < 8; i++)
899 for (j = 0; j < 8; j++)
901 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
903 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
907 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
908 glVertex3d(xc, yc, zc);
924 for (ix = 0; ix < nbx; ix++)
926 for (iz = 0; iz < nbz; iz++)
928 for (iy = 0; iy < nby; iy++)
930 switch (voxels->Deepness(ix, iy, iz))
934 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
936 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
940 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
941 glVertex3d(xc, yc, zc);
949 for (i = 0; i < 8; i++)
951 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
953 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
957 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
958 glVertex3d(xc, yc, zc);
967 for (i = 0; i < 8; i++)
969 for (j = 0; j < 8; j++)
971 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
973 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
977 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
978 glVertex3d(xc, yc, zc);
994 for (ix = 0; ix < nbx; ix++)
996 for (iz = 0; iz < nbz; iz++)
998 for (iy = nby - 1; iy >= 0; iy--)
1000 switch (voxels->Deepness(ix, iy, iz))
1004 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1006 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1010 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1011 glVertex3d(xc, yc, zc);
1019 for (i = 0; i < 8; i++)
1021 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1023 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1027 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1028 glVertex3d(xc, yc, zc);
1037 for (i = 0; i < 8; i++)
1039 for (j = 0; j < 8; j++)
1041 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1043 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1047 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1048 glVertex3d(xc, yc, zc);
1064 for (ix = 0; ix < nbx; ix++)
1066 for (iy = 0; iy < nby; iy++)
1068 for (iz = 0; iz < nbz; iz++)
1070 switch (voxels->Deepness(ix, iy, iz))
1074 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1076 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1080 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1081 glVertex3d(xc, yc, zc);
1089 for (i = 0; i < 8; i++)
1091 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1093 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1097 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1098 glVertex3d(xc, yc, zc);
1107 for (i = 0; i < 8; i++)
1109 for (j = 0; j < 8; j++)
1111 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1113 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1117 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1118 glVertex3d(xc, yc, zc);
1134 for (ix = 0; ix < nbx; ix++)
1136 for (iy = 0; iy < nby; iy++)
1138 for (iz = nbz - 1; iz >= 0; iz--)
1140 switch (voxels->Deepness(ix, iy, iz))
1144 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1146 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1150 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1151 glVertex3d(xc, yc, zc);
1159 for (i = 0; i < 8; i++)
1161 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1163 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1167 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1168 glVertex3d(xc, yc, zc);
1177 for (i = 0; i < 8; i++)
1179 for (j = 0; j < 8; j++)
1181 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1183 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1187 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1188 glVertex3d(xc, yc, zc);
1208 static void drawColorPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
1209 Voxel_ColorDS* voxels, const Handle(Quantity_HArray1OfColor)& hcolors,
1210 const Standard_Byte minvalue, const Standard_Byte maxvalue,
1211 const Standard_Real xmin, const Standard_Real xmax,
1212 const Standard_Real ymin, const Standard_Real ymax,
1213 const Standard_Real zmin, const Standard_Real zmax)
1215 Standard_Real xc, yc, zc;
1216 Standard_Integer ix = 0, nbx = voxels->GetNbX();
1217 Standard_Integer iy = 0, nby = voxels->GetNbY();
1218 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
1219 Standard_Byte value;
1222 const Quantity_Array1OfColor& colors = hcolors->Array1();
1224 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1225 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1226 zmin <= DBL_MAX && zmax >= DBL_MAX);
1227 check_size = !check_size;
1234 for (iy = 0; iy < nby; iy++)
1236 for (iz = 0; iz < nbz; iz++)
1238 for (ix = 0; ix < nbx; ix++)
1240 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1242 value = voxels->Get(ix, iy, iz);
1243 if (value >= minvalue && value <= maxvalue)
1246 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1247 setColor(colors.Value(value), Standard_False);
1248 glVertex3d(xc, yc, zc);
1259 for (iy = 0; iy < nby; iy++)
1261 for (iz = 0; iz < nbz; iz++)
1263 for (ix = nbx - 1; ix >= 0; ix--)
1265 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1267 value = voxels->Get(ix, iy, iz);
1268 if (value >= minvalue && value <= maxvalue)
1271 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1272 setColor(colors.Value(value), Standard_False);
1273 glVertex3d(xc, yc, zc);
1284 for (ix = 0; ix < nbx; ix++)
1286 for (iz = 0; iz < nbz; iz++)
1288 for (iy = 0; iy < nby; iy++)
1290 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1292 value = voxels->Get(ix, iy, iz);
1293 if (value >= minvalue && value <= maxvalue)
1296 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1297 setColor(colors.Value(value), Standard_False);
1298 glVertex3d(xc, yc, zc);
1309 for (ix = 0; ix < nbx; ix++)
1311 for (iz = 0; iz < nbz; iz++)
1313 for (iy = nby - 1; iy >= 0; iy--)
1315 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1317 value = voxels->Get(ix, iy, iz);
1318 if (value >= minvalue && value <= maxvalue)
1321 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1322 setColor(colors.Value(value), Standard_False);
1323 glVertex3d(xc, yc, zc);
1334 for (ix = 0; ix < nbx; ix++)
1336 for (iy = 0; iy < nby; iy++)
1338 for (iz = 0; iz < nbz; iz++)
1340 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1342 value = voxels->Get(ix, iy, iz);
1343 if (value >= minvalue && value <= maxvalue)
1346 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1347 setColor(colors.Value(value), Standard_False);
1348 glVertex3d(xc, yc, zc);
1359 for (ix = 0; ix < nbx; ix++)
1361 for (iy = 0; iy < nby; iy++)
1363 for (iz = nbz - 1; iz >= 0; iz--)
1365 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1367 value = voxels->Get(ix, iy, iz);
1368 if (value >= minvalue && value <= maxvalue)
1371 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1372 setColor(colors.Value(value), Standard_False);
1373 glVertex3d(xc, yc, zc);
1386 static void drawBoolQuadrangles(Voxel_BoolDS* voxels, const VoxelDirection vdir,
1387 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1388 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1389 const Standard_Real xmin, const Standard_Real xmax,
1390 const Standard_Real ymin, const Standard_Real ymax,
1391 const Standard_Real zmin, const Standard_Real zmax)
1394 gp_Pnt pc1, pc2, pc3, pc4;
1395 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1396 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
1399 viewnormal.Coord(xn, yn, zn);
1401 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1402 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1403 zmin <= DBL_MAX && zmax >= DBL_MAX);
1404 check_size = !check_size;
1411 for (iy = 0; iy < nby; iy++)
1413 for (iz = 0; iz < nbz; iz++)
1415 for (ix = 0; ix < nbx; ix++)
1417 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1419 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1422 // Define translation vector
1424 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1425 vc.SetCoord(xc, yc, zc);
1428 pc1 = p1.Translated(vc);
1429 pc2 = p2.Translated(vc);
1430 pc3 = p3.Translated(vc);
1431 pc4 = p4.Translated(vc);
1434 glNormal3d(xn, yn, zn);
1435 pc1.Coord(xc, yc, zc);
1436 glVertex3d(xc, yc, zc);
1437 pc2.Coord(xc, yc, zc);
1438 glVertex3d(xc, yc, zc);
1439 pc3.Coord(xc, yc, zc);
1440 glVertex3d(xc, yc, zc);
1441 pc4.Coord(xc, yc, zc);
1442 glVertex3d(xc, yc, zc);
1454 for (iy = 0; iy < nby; iy++)
1456 for (iz = 0; iz < nbz; iz++)
1458 for (ix = nbx - 1; ix >= 0; ix--)
1460 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1462 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1465 // Define translation vector
1467 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1468 vc.SetCoord(xc, yc, zc);
1471 pc1 = p1.Translated(vc);
1472 pc2 = p2.Translated(vc);
1473 pc3 = p3.Translated(vc);
1474 pc4 = p4.Translated(vc);
1477 glNormal3d(xn, yn, zn);
1478 pc1.Coord(xc, yc, zc);
1479 glVertex3d(xc, yc, zc);
1480 pc2.Coord(xc, yc, zc);
1481 glVertex3d(xc, yc, zc);
1482 pc3.Coord(xc, yc, zc);
1483 glVertex3d(xc, yc, zc);
1484 pc4.Coord(xc, yc, zc);
1485 glVertex3d(xc, yc, zc);
1497 for (ix = 0; ix < nbx; ix++)
1499 for (iz = 0; iz < nbz; iz++)
1501 for (iy = 0; iy < nby; iy++)
1503 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1505 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1508 // Define translation vector
1510 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1511 vc.SetCoord(xc, yc, zc);
1514 pc1 = p1.Translated(vc);
1515 pc2 = p2.Translated(vc);
1516 pc3 = p3.Translated(vc);
1517 pc4 = p4.Translated(vc);
1520 glNormal3d(xn, yn, zn);
1521 pc1.Coord(xc, yc, zc);
1522 glVertex3d(xc, yc, zc);
1523 pc2.Coord(xc, yc, zc);
1524 glVertex3d(xc, yc, zc);
1525 pc3.Coord(xc, yc, zc);
1526 glVertex3d(xc, yc, zc);
1527 pc4.Coord(xc, yc, zc);
1528 glVertex3d(xc, yc, zc);
1540 for (ix = 0; ix < nbx; ix++)
1542 for (iz = 0; iz < nbz; iz++)
1544 for (iy = nby - 1; iy >= 0; iy--)
1546 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1548 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1551 // Define translation vector
1553 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1554 vc.SetCoord(xc, yc, zc);
1557 pc1 = p1.Translated(vc);
1558 pc2 = p2.Translated(vc);
1559 pc3 = p3.Translated(vc);
1560 pc4 = p4.Translated(vc);
1563 glNormal3d(xn, yn, zn);
1564 pc1.Coord(xc, yc, zc);
1565 glVertex3d(xc, yc, zc);
1566 pc2.Coord(xc, yc, zc);
1567 glVertex3d(xc, yc, zc);
1568 pc3.Coord(xc, yc, zc);
1569 glVertex3d(xc, yc, zc);
1570 pc4.Coord(xc, yc, zc);
1571 glVertex3d(xc, yc, zc);
1583 for (ix = 0; ix < nbx; ix++)
1585 for (iy = 0; iy < nby; iy++)
1587 for (iz = 0; iz < nbz; iz++)
1589 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1591 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1594 // Define translation vector
1596 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1597 vc.SetCoord(xc, yc, zc);
1600 pc1 = p1.Translated(vc);
1601 pc2 = p2.Translated(vc);
1602 pc3 = p3.Translated(vc);
1603 pc4 = p4.Translated(vc);
1606 glNormal3d(xn, yn, zn);
1607 pc1.Coord(xc, yc, zc);
1608 glVertex3d(xc, yc, zc);
1609 pc2.Coord(xc, yc, zc);
1610 glVertex3d(xc, yc, zc);
1611 pc3.Coord(xc, yc, zc);
1612 glVertex3d(xc, yc, zc);
1613 pc4.Coord(xc, yc, zc);
1614 glVertex3d(xc, yc, zc);
1626 for (ix = 0; ix < nbx; ix++)
1628 for (iy = 0; iy < nby; iy++)
1630 for (iz = nbz - 1; iz >= 0; iz--)
1632 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1634 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1637 // Define translation vector
1639 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1640 vc.SetCoord(xc, yc, zc);
1643 pc1 = p1.Translated(vc);
1644 pc2 = p2.Translated(vc);
1645 pc3 = p3.Translated(vc);
1646 pc4 = p4.Translated(vc);
1649 glNormal3d(xn, yn, zn);
1650 pc1.Coord(xc, yc, zc);
1651 glVertex3d(xc, yc, zc);
1652 pc2.Coord(xc, yc, zc);
1653 glVertex3d(xc, yc, zc);
1654 pc3.Coord(xc, yc, zc);
1655 glVertex3d(xc, yc, zc);
1656 pc4.Coord(xc, yc, zc);
1657 glVertex3d(xc, yc, zc);
1671 static void drawROctBoolQuadrangles(Voxel_ROctBoolDS* voxels, const VoxelDirection vdir,
1672 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1673 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1674 const Standard_Real xmin, const Standard_Real xmax,
1675 const Standard_Real ymin, const Standard_Real ymax,
1676 const Standard_Real zmin, const Standard_Real zmax)
1679 gp_Pnt pc1, pc2, pc3, pc4;
1680 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1681 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(), i, j, deepness;
1684 viewnormal.Coord(xn, yn, zn);
1686 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1687 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1688 zmin <= DBL_MAX && zmax >= DBL_MAX);
1689 check_size = !check_size;
1696 for (iy = 0; iy < nby; iy++)
1698 for (iz = 0; iz < nbz; iz++)
1700 for (ix = 0; ix < nbx; ix++)
1702 deepness = voxels->Deepness(ix, iy, iz);
1703 for (i = 0; i < 8; i++)
1705 for (j = 0; j < 8; j++)
1707 if (deepness == 0 && j)
1712 if (deepness == 1 && j)
1716 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1719 else if (deepness == 1)
1721 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1724 else if (deepness == 2)
1726 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1730 Standard_Boolean value;
1734 value = voxels->Get(ix, iy, iz) == Standard_True;
1737 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1740 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1746 // Define translation vector
1752 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1755 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1758 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1762 vc.SetCoord(xc, yc, zc);
1765 pc1 = p1.Translated(vc);
1766 pc2 = p2.Translated(vc);
1767 pc3 = p3.Translated(vc);
1768 pc4 = p4.Translated(vc);
1771 glNormal3d(xn, yn, zn);
1772 pc1.Coord(xc, yc, zc);
1773 glVertex3d(xc, yc, zc);
1774 pc2.Coord(xc, yc, zc);
1775 glVertex3d(xc, yc, zc);
1776 pc3.Coord(xc, yc, zc);
1777 glVertex3d(xc, yc, zc);
1778 pc4.Coord(xc, yc, zc);
1779 glVertex3d(xc, yc, zc);
1793 for (iy = 0; iy < nby; iy++)
1795 for (iz = 0; iz < nbz; iz++)
1797 for (ix = nbx - 1; ix >= 0; ix--)
1799 deepness = voxels->Deepness(ix, iy, iz);
1800 for (i = 0; i < 8; i++)
1802 for (j = 0; j < 8; j++)
1804 if (deepness == 0 && j)
1809 if (deepness == 1 && j)
1813 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1816 else if (deepness == 1)
1818 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1821 else if (deepness == 2)
1823 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1827 Standard_Boolean value;
1831 value = voxels->Get(ix, iy, iz) == Standard_True;
1834 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1837 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1843 // Define translation vector
1849 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1852 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1855 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1859 vc.SetCoord(xc, yc, zc);
1862 pc1 = p1.Translated(vc);
1863 pc2 = p2.Translated(vc);
1864 pc3 = p3.Translated(vc);
1865 pc4 = p4.Translated(vc);
1868 glNormal3d(xn, yn, zn);
1869 pc1.Coord(xc, yc, zc);
1870 glVertex3d(xc, yc, zc);
1871 pc2.Coord(xc, yc, zc);
1872 glVertex3d(xc, yc, zc);
1873 pc3.Coord(xc, yc, zc);
1874 glVertex3d(xc, yc, zc);
1875 pc4.Coord(xc, yc, zc);
1876 glVertex3d(xc, yc, zc);
1890 for (ix = 0; ix < nbx; ix++)
1892 for (iz = 0; iz < nbz; iz++)
1894 for (iy = 0; iy < nby; iy++)
1896 deepness = voxels->Deepness(ix, iy, iz);
1897 for (i = 0; i < 8; i++)
1899 for (j = 0; j < 8; j++)
1901 if (deepness == 0 && j)
1906 if (deepness == 1 && j)
1910 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1913 else if (deepness == 1)
1915 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1918 else if (deepness == 2)
1920 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1924 Standard_Boolean value;
1928 value = voxels->Get(ix, iy, iz) == Standard_True;
1931 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1934 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1940 // Define translation vector
1946 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1949 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1952 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1956 vc.SetCoord(xc, yc, zc);
1959 pc1 = p1.Translated(vc);
1960 pc2 = p2.Translated(vc);
1961 pc3 = p3.Translated(vc);
1962 pc4 = p4.Translated(vc);
1965 glNormal3d(xn, yn, zn);
1966 pc1.Coord(xc, yc, zc);
1967 glVertex3d(xc, yc, zc);
1968 pc2.Coord(xc, yc, zc);
1969 glVertex3d(xc, yc, zc);
1970 pc3.Coord(xc, yc, zc);
1971 glVertex3d(xc, yc, zc);
1972 pc4.Coord(xc, yc, zc);
1973 glVertex3d(xc, yc, zc);
1987 for (ix = 0; ix < nbx; ix++)
1989 for (iz = 0; iz < nbz; iz++)
1991 for (iy = nby - 1; iy >= 0; iy--)
1993 deepness = voxels->Deepness(ix, iy, iz);
1994 for (i = 0; i < 8; i++)
1996 for (j = 0; j < 8; j++)
1998 if (deepness == 0 && j)
2003 if (deepness == 1 && j)
2007 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2010 else if (deepness == 1)
2012 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2015 else if (deepness == 2)
2017 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2021 Standard_Boolean value;
2025 value = voxels->Get(ix, iy, iz) == Standard_True;
2028 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2031 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2037 // Define translation vector
2043 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2046 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2049 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2053 vc.SetCoord(xc, yc, zc);
2056 pc1 = p1.Translated(vc);
2057 pc2 = p2.Translated(vc);
2058 pc3 = p3.Translated(vc);
2059 pc4 = p4.Translated(vc);
2062 glNormal3d(xn, yn, zn);
2063 pc1.Coord(xc, yc, zc);
2064 glVertex3d(xc, yc, zc);
2065 pc2.Coord(xc, yc, zc);
2066 glVertex3d(xc, yc, zc);
2067 pc3.Coord(xc, yc, zc);
2068 glVertex3d(xc, yc, zc);
2069 pc4.Coord(xc, yc, zc);
2070 glVertex3d(xc, yc, zc);
2084 for (ix = 0; ix < nbx; ix++)
2086 for (iy = 0; iy < nby; iy++)
2088 for (iz = 0; iz < nbz; iz++)
2090 deepness = voxels->Deepness(ix, iy, iz);
2091 for (i = 0; i < 8; i++)
2093 for (j = 0; j < 8; j++)
2095 if (deepness == 0 && j)
2100 if (deepness == 1 && j)
2104 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2107 else if (deepness == 1)
2109 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2112 else if (deepness == 2)
2114 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2118 Standard_Boolean value;
2122 value = voxels->Get(ix, iy, iz) == Standard_True;
2125 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2128 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2134 // Define translation vector
2140 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2143 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2146 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2150 vc.SetCoord(xc, yc, zc);
2153 pc1 = p1.Translated(vc);
2154 pc2 = p2.Translated(vc);
2155 pc3 = p3.Translated(vc);
2156 pc4 = p4.Translated(vc);
2159 glNormal3d(xn, yn, zn);
2160 pc1.Coord(xc, yc, zc);
2161 glVertex3d(xc, yc, zc);
2162 pc2.Coord(xc, yc, zc);
2163 glVertex3d(xc, yc, zc);
2164 pc3.Coord(xc, yc, zc);
2165 glVertex3d(xc, yc, zc);
2166 pc4.Coord(xc, yc, zc);
2167 glVertex3d(xc, yc, zc);
2181 for (ix = 0; ix < nbx; ix++)
2183 for (iy = 0; iy < nby; iy++)
2185 for (iz = nbz - 1; iz >= 0; iz--)
2187 deepness = voxels->Deepness(ix, iy, iz);
2188 for (i = 0; i < 8; i++)
2190 for (j = 0; j < 8; j++)
2192 if (deepness == 0 && j)
2197 if (deepness == 1 && j)
2201 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2204 else if (deepness == 1)
2206 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2209 else if (deepness == 2)
2211 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2215 Standard_Boolean value;
2219 value = voxels->Get(ix, iy, iz) == Standard_True;
2222 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2225 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2231 // Define translation vector
2237 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2240 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2243 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2247 vc.SetCoord(xc, yc, zc);
2250 pc1 = p1.Translated(vc);
2251 pc2 = p2.Translated(vc);
2252 pc3 = p3.Translated(vc);
2253 pc4 = p4.Translated(vc);
2256 glNormal3d(xn, yn, zn);
2257 pc1.Coord(xc, yc, zc);
2258 glVertex3d(xc, yc, zc);
2259 pc2.Coord(xc, yc, zc);
2260 glVertex3d(xc, yc, zc);
2261 pc3.Coord(xc, yc, zc);
2262 glVertex3d(xc, yc, zc);
2263 pc4.Coord(xc, yc, zc);
2264 glVertex3d(xc, yc, zc);
2282 static void drawColorQuadrangles(Voxel_ColorDS* voxels, const VoxelDirection vdir,
2283 const gp_Dir& viewnormal, const Standard_Boolean nearest,
2284 const Handle(Quantity_HArray1OfColor)& hcolors,
2285 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
2286 const Standard_Byte minvalue, const Standard_Byte maxvalue,
2287 const Standard_Real xmin, const Standard_Real xmax,
2288 const Standard_Real ymin, const Standard_Real ymax,
2289 const Standard_Real zmin, const Standard_Real zmax)
2292 gp_Pnt pc1, pc2, pc3, pc4;
2293 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 0.0;
2294 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
2295 Standard_Byte value;
2298 //viewnormal.Coord(xn, yn, zn);
2299 glNormal3d(xn, yn, zn);
2302 const Quantity_Array1OfColor& colors = hcolors->Array1();
2304 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
2305 ymin <= DBL_MAX && ymax >= DBL_MAX &&
2306 zmin <= DBL_MAX && zmax >= DBL_MAX);
2307 check_size = !check_size;
2314 for (iy = 0; iy < nby; iy++)
2316 for (iz = 0; iz < nbz; iz++)
2318 for (ix = 0; ix < nbx; ix++)
2320 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2322 value = voxels->Get(ix, iy, iz);
2323 if (value >= minvalue && value <= maxvalue)
2325 // Define translation vector
2327 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2328 vc.SetCoord(xc, yc, zc);
2331 pc1 = p1.Translated(vc);
2332 pc2 = p2.Translated(vc);
2333 pc3 = p3.Translated(vc);
2334 pc4 = p4.Translated(vc);
2337 setColor(colors.Value(value), Standard_False);
2340 //glNormal3d(xn, yn, zn);
2341 pc1.Coord(xc, yc, zc);
2342 glVertex3d(xc, yc, zc);
2343 pc2.Coord(xc, yc, zc);
2344 glVertex3d(xc, yc, zc);
2345 pc3.Coord(xc, yc, zc);
2346 glVertex3d(xc, yc, zc);
2347 pc4.Coord(xc, yc, zc);
2348 glVertex3d(xc, yc, zc);
2360 for (iy = 0; iy < nby; iy++)
2362 for (iz = 0; iz < nbz; iz++)
2364 for (ix = nbx - 1; ix >= 0; ix--)
2366 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2368 value = voxels->Get(ix, iy, iz);
2369 if (value >= minvalue && value <= maxvalue)
2371 // Define translation vector
2373 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2374 vc.SetCoord(xc, yc, zc);
2377 pc1 = p1.Translated(vc);
2378 pc2 = p2.Translated(vc);
2379 pc3 = p3.Translated(vc);
2380 pc4 = p4.Translated(vc);
2383 setColor(colors.Value(value), Standard_False);
2386 //glNormal3d(xn, yn, zn);
2387 pc1.Coord(xc, yc, zc);
2388 glVertex3d(xc, yc, zc);
2389 pc2.Coord(xc, yc, zc);
2390 glVertex3d(xc, yc, zc);
2391 pc3.Coord(xc, yc, zc);
2392 glVertex3d(xc, yc, zc);
2393 pc4.Coord(xc, yc, zc);
2394 glVertex3d(xc, yc, zc);
2406 for (ix = 0; ix < nbx; ix++)
2408 for (iz = 0; iz < nbz; iz++)
2410 for (iy = 0; iy < nby; iy++)
2412 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2414 value = voxels->Get(ix, iy, iz);
2415 if (value >= minvalue && value <= maxvalue)
2417 // Define translation vector
2419 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2420 vc.SetCoord(xc, yc, zc);
2423 pc1 = p1.Translated(vc);
2424 pc2 = p2.Translated(vc);
2425 pc3 = p3.Translated(vc);
2426 pc4 = p4.Translated(vc);
2429 setColor(colors.Value(value), Standard_False);
2432 //glNormal3d(xn, yn, zn);
2433 pc1.Coord(xc, yc, zc);
2434 glVertex3d(xc, yc, zc);
2435 pc2.Coord(xc, yc, zc);
2436 glVertex3d(xc, yc, zc);
2437 pc3.Coord(xc, yc, zc);
2438 glVertex3d(xc, yc, zc);
2439 pc4.Coord(xc, yc, zc);
2440 glVertex3d(xc, yc, zc);
2452 for (ix = 0; ix < nbx; ix++)
2454 for (iz = 0; iz < nbz; iz++)
2456 for (iy = nby - 1; iy >= 0; iy--)
2458 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2460 value = voxels->Get(ix, iy, iz);
2461 if (value >= minvalue && value <= maxvalue)
2463 // Define translation vector
2465 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2466 vc.SetCoord(xc, yc, zc);
2469 pc1 = p1.Translated(vc);
2470 pc2 = p2.Translated(vc);
2471 pc3 = p3.Translated(vc);
2472 pc4 = p4.Translated(vc);
2475 setColor(colors.Value(value), Standard_False);
2478 //glNormal3d(xn, yn, zn);
2479 pc1.Coord(xc, yc, zc);
2480 glVertex3d(xc, yc, zc);
2481 pc2.Coord(xc, yc, zc);
2482 glVertex3d(xc, yc, zc);
2483 pc3.Coord(xc, yc, zc);
2484 glVertex3d(xc, yc, zc);
2485 pc4.Coord(xc, yc, zc);
2486 glVertex3d(xc, yc, zc);
2498 for (ix = 0; ix < nbx; ix++)
2500 for (iy = 0; iy < nby; iy++)
2502 for (iz = 0; iz < nbz; iz++)
2504 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2506 value = voxels->Get(ix, iy, iz);
2507 if (value >= minvalue && value <= maxvalue)
2509 // Define translation vector
2511 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2512 vc.SetCoord(xc, yc, zc);
2515 pc1 = p1.Translated(vc);
2516 pc2 = p2.Translated(vc);
2517 pc3 = p3.Translated(vc);
2518 pc4 = p4.Translated(vc);
2521 setColor(colors.Value(value), Standard_False);
2524 //glNormal3d(xn, yn, zn);
2525 pc1.Coord(xc, yc, zc);
2526 glVertex3d(xc, yc, zc);
2527 pc2.Coord(xc, yc, zc);
2528 glVertex3d(xc, yc, zc);
2529 pc3.Coord(xc, yc, zc);
2530 glVertex3d(xc, yc, zc);
2531 pc4.Coord(xc, yc, zc);
2532 glVertex3d(xc, yc, zc);
2544 for (ix = 0; ix < nbx; ix++)
2546 for (iy = 0; iy < nby; iy++)
2548 for (iz = nbz - 1; iz >= 0; iz--)
2550 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2552 value = voxels->Get(ix, iy, iz);
2553 if (value >= minvalue && value <= maxvalue)
2555 // Define translation vector
2557 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2558 vc.SetCoord(xc, yc, zc);
2561 pc1 = p1.Translated(vc);
2562 pc2 = p2.Translated(vc);
2563 pc3 = p3.Translated(vc);
2564 pc4 = p4.Translated(vc);
2567 setColor(colors.Value(value), Standard_False);
2570 //glNormal3d(xn, yn, zn);
2571 pc1.Coord(xc, yc, zc);
2572 glVertex3d(xc, yc, zc);
2573 pc2.Coord(xc, yc, zc);
2574 glVertex3d(xc, yc, zc);
2575 pc3.Coord(xc, yc, zc);
2576 glVertex3d(xc, yc, zc);
2577 pc4.Coord(xc, yc, zc);
2578 glVertex3d(xc, yc, zc);
2592 static void genListIndex(GLint& index)
2595 while (++i <= INT_MAX)
2605 static void setPlaneNormal(const VoxelDirection& dir,
2606 const Standard_Real dx, const Standard_Real dy, const Standard_Real dz,
2607 gp_Pln& plane, gp_Pnt& p1, gp_Pnt& p2, gp_Pnt& p3, gp_Pnt& p4)
2609 gp_Ax3 axes = plane.Position();
2610 Standard_Real dx2 = 0.5 * dx, dy2 = 0.5 * dy, dz2 = 0.5 * dz;
2614 p1.SetCoord(-dx2, -dy2, dz2);
2615 p2.SetCoord(-dx2, -dy2, -dz2);
2616 p3.SetCoord(-dx2, dy2, -dz2);
2617 p4.SetCoord(-dx2, dy2, dz2);
2618 axes.SetDirection(-gp::DX());
2621 p1.SetCoord(dx2, -dy2, dz2);
2622 p2.SetCoord(dx2, -dy2, -dz2);
2623 p3.SetCoord(dx2, dy2, -dz2);
2624 p4.SetCoord(dx2, dy2, dz2);
2625 axes.SetDirection(gp::DX());
2628 p1.SetCoord(dx2, -dy2, dz2);
2629 p2.SetCoord(dx2, -dy2, -dz2);
2630 p3.SetCoord(-dx2, -dy2, -dz2);
2631 p4.SetCoord(-dx2, -dy2, dz2);
2632 axes.SetDirection(-gp::DY());
2635 p1.SetCoord(dx2, dy2, dz2);
2636 p2.SetCoord(dx2, dy2, -dz2);
2637 p3.SetCoord(-dx2, dy2, -dz2);
2638 p4.SetCoord(-dx2, dy2, dz2);
2639 axes.SetDirection(gp::DY());
2642 p1.SetCoord(dx2, dy2, -dz2);
2643 p2.SetCoord(-dx2, dy2, -dz2);
2644 p3.SetCoord(-dx2, -dy2, -dz2);
2645 p4.SetCoord(dx2, -dy2, -dz2);
2646 axes.SetDirection(-gp::DZ());
2649 p1.SetCoord(dx2, dy2, dz2);
2650 p2.SetCoord(-dx2, dy2, dz2);
2651 p3.SetCoord(-dx2, -dy2, dz2);
2652 p4.SetCoord(dx2, -dy2, dz2);
2653 axes.SetDirection(gp::DZ());
2658 /**************************************************************************/
2659 void VoxelClient_VisDrawer::DisplayVoxels(const Standard_Boolean theHighlight)
2664 glEnable(GL_DEPTH_TEST);
2667 if (myData->myBoolVoxels)
2670 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2671 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2673 glDisable(GL_LIGHTING);
2674 if (myData->myDisplay.mySmoothPoints)
2675 glEnable(GL_POINT_SMOOTH);
2677 glDisable(GL_POINT_SMOOTH);
2679 // Draw the points of voxels (center points of the voxels)
2680 // starting visualization from the side looking out from the user.
2681 setColor(myData->myDisplay.myColor, theHighlight);
2682 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2685 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2690 if (myData->myColorVoxels)
2693 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2694 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2696 glDisable(GL_LIGHTING);
2697 if (myData->myDisplay.mySmoothPoints)
2698 glEnable(GL_POINT_SMOOTH);
2700 glDisable(GL_POINT_SMOOTH);
2702 // Draw the points of voxels (center points of the voxels)
2703 // starting visualization from the side looking out from the user.
2704 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2707 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2711 // Recursive Octree Boolean voxels
2712 if (myData->myROctBoolVoxels)
2715 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2716 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2718 glDisable(GL_LIGHTING);
2719 if (myData->myDisplay.mySmoothPoints)
2720 glEnable(GL_POINT_SMOOTH);
2722 glDisable(GL_POINT_SMOOTH);
2724 // Draw the points of voxels (center points of the voxels)
2725 // starting visualization from the side looking out from the user.
2726 setColor(myData->myDisplay.myColor, theHighlight);
2727 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2730 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2734 // Shading drawn by boxes
2735 if (myData->myDisplay.myDisplayMode == Voxel_VDM_BOXES ||
2736 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES)
2738 glEnable(GL_LIGHTING);
2739 glEnable(GL_COLOR_MATERIAL);
2741 // Draw quadrangles of voxels looking to the user.
2742 setColor(myData->myDisplay.myColor, theHighlight);
2745 DisplayBoxes(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES);
2747 glDisable(GL_COLOR_MATERIAL);
2750 // Highlighted voxel
2754 /**************************************************************************/
2755 void VoxelClient_VisDrawer::DisplayPoints(const Standard_Boolean nearest)
2760 // Find the side of the cube which normal looks to (or out) the user's eye.
2762 getNormal(viewnormal);
2764 // Range of displayed data
2765 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
2766 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
2767 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
2768 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
2769 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
2770 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
2773 if (myData->myBoolVoxels)
2775 if (nearest || myData->myDisplay.myDegenerateMode)
2777 VoxelDirection vdir1, vdir2, vdir3;
2778 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2780 if (myData->myDisplay.myUsageOfGLlists)
2782 // Clean all allocated GL lists for the case of first call.
2783 if (myData->myDisplay.myBoolNearestPointsFirst)
2785 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2787 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
2789 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
2790 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
2793 myData->myDisplay.myBoolNearestPointsFirst = Standard_False;
2796 // Generate GL lists if needed.
2797 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
2799 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2800 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2801 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2802 xmin, xmax, ymin, ymax, zmin, zmax);
2805 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
2807 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2808 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2809 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2810 xmin, xmax, ymin, ymax, zmin, zmax);
2813 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
2815 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2816 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2817 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2818 xmin, xmax, ymin, ymax, zmin, zmax);
2821 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2822 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2823 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2827 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2828 xmin, xmax, ymin, ymax, zmin, zmax);
2829 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2830 xmin, xmax, ymin, ymax, zmin, zmax);
2831 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2832 xmin, xmax, ymin, ymax, zmin, zmax);
2837 if (myData->myDisplay.myUsageOfGLlists)
2839 if (myData->myDisplay.myBoolPointsFirst)
2841 // Delete previous GL list.
2842 if (myData->myDisplay.myBoolPointsList > 0)
2844 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
2845 myData->myDisplay.myBoolPointsList = -1;
2848 // Generate a new GL list
2849 genListIndex(myData->myDisplay.myBoolPointsList);
2850 glNewList(myData->myDisplay.myBoolPointsList, GL_COMPILE);
2851 VoxelDirection vdir = getVoxelDirection(viewnormal);
2852 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2853 xmin, xmax, ymin, ymax, zmin, zmax);
2856 // The first call has just been passed...
2857 myData->myDisplay.myBoolPointsFirst = Standard_False;
2859 glCallList(myData->myDisplay.myBoolPointsList);
2863 VoxelDirection vdir = getVoxelDirection(viewnormal);
2864 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2865 xmin, xmax, ymin, ymax, zmin, zmax);
2871 if (myData->myColorVoxels)
2873 if (nearest || myData->myDisplay.myDegenerateMode)
2875 VoxelDirection vdir1, vdir2, vdir3;
2876 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2878 if (myData->myDisplay.myUsageOfGLlists)
2880 // Clean all allocated GL lists for the case of first call.
2881 if (myData->myDisplay.myColorNearestPointsFirst)
2883 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2885 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
2887 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
2888 myData->myDisplay.myColorNearestPointsList[idir] = -1;
2891 myData->myDisplay.myColorNearestPointsFirst = Standard_False;
2894 // Generate GL lists if needed.
2895 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1] < 0)
2897 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2898 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2899 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2900 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2901 xmin, xmax, ymin, ymax, zmin, zmax);
2904 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2] < 0)
2906 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2907 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2908 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2909 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2910 xmin, xmax, ymin, ymax, zmin, zmax);
2913 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3] < 0)
2915 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2916 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2917 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2918 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2919 xmin, xmax, ymin, ymax, zmin, zmax);
2923 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2924 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2925 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2929 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2930 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2931 xmin, xmax, ymin, ymax, zmin, zmax);
2932 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2933 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2934 xmin, xmax, ymin, ymax, zmin, zmax);
2935 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2936 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2937 xmin, xmax, ymin, ymax, zmin, zmax);
2942 if (myData->myDisplay.myUsageOfGLlists)
2944 if (myData->myDisplay.myColorPointsFirst)
2946 // Delete previous GL list.
2947 if (myData->myDisplay.myColorPointsList > 0)
2949 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
2950 myData->myDisplay.myColorPointsList = -1;
2953 // Generate a new GL list
2954 genListIndex(myData->myDisplay.myColorPointsList);
2955 glNewList(myData->myDisplay.myColorPointsList, GL_COMPILE);
2956 VoxelDirection vdir = getVoxelDirection(viewnormal);
2957 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2958 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2959 xmin, xmax, ymin, ymax, zmin, zmax);
2962 // The first call has just been passed...
2963 myData->myDisplay.myColorPointsFirst = Standard_False;
2965 glCallList(myData->myDisplay.myColorPointsList);
2969 VoxelDirection vdir = getVoxelDirection(viewnormal);
2970 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2971 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2972 xmin, xmax, ymin, ymax, zmin, zmax);
2977 // Recursive Octree Boolean points
2978 if (myData->myROctBoolVoxels)
2980 if (nearest || myData->myDisplay.myDegenerateMode)
2982 VoxelDirection vdir1, vdir2, vdir3;
2983 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2985 if (myData->myDisplay.myUsageOfGLlists)
2987 // Clean all allocated GL lists for the case of first call.
2988 if (myData->myDisplay.myROctBoolNearestPointsFirst)
2990 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2992 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
2994 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
2995 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
2998 myData->myDisplay.myROctBoolNearestPointsFirst = Standard_False;
3001 // Generate GL lists if needed.
3002 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
3004 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3005 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
3006 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3007 xmin, xmax, ymin, ymax, zmin, zmax);
3010 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
3012 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3013 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
3014 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3015 xmin, xmax, ymin, ymax, zmin, zmax);
3018 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
3020 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3021 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
3022 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3023 xmin, xmax, ymin, ymax, zmin, zmax);
3026 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3027 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3028 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3032 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3033 xmin, xmax, ymin, ymax, zmin, zmax);
3034 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3035 xmin, xmax, ymin, ymax, zmin, zmax);
3036 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3037 xmin, xmax, ymin, ymax, zmin, zmax);
3042 if (myData->myDisplay.myUsageOfGLlists)
3044 if (myData->myDisplay.myROctBoolPointsFirst)
3046 // Delete previous GL list.
3047 if (myData->myDisplay.myROctBoolPointsList > 0)
3049 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
3050 myData->myDisplay.myROctBoolPointsList = -1;
3053 // Generate a new GL list
3054 genListIndex(myData->myDisplay.myROctBoolPointsList);
3055 glNewList(myData->myDisplay.myROctBoolPointsList, GL_COMPILE);
3056 VoxelDirection vdir = getVoxelDirection(viewnormal);
3057 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3058 xmin, xmax, ymin, ymax, zmin, zmax);
3061 // The first call has just been passed...
3062 myData->myDisplay.myROctBoolPointsFirst = Standard_False;
3064 glCallList(myData->myDisplay.myROctBoolPointsList);
3068 VoxelDirection vdir = getVoxelDirection(viewnormal);
3069 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3070 xmin, xmax, ymin, ymax, zmin, zmax);
3076 //Standard_Real seconds, cpu;
3077 //Standard_Integer minutes, hours;
3078 //timer.Show(seconds, minutes, hours, cpu);
3079 //cout<<"DisplayPoints()"<<" took "<<minutes<<" minutes, "<<seconds<<" seconds"<<endl;
3082 /**************************************************************************/
3083 void VoxelClient_VisDrawer::DisplayBoxes(const Standard_Boolean nearest)
3085 // Range of displayed data
3086 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
3087 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
3088 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
3089 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
3090 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
3091 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
3093 // Find the side of the cube which normal looks to (or out) the user's eye.
3095 getNormal(viewnormal);
3097 // Get three sides of the box looking to the user.
3098 VoxelDirection vdir1, vdir2, vdir3;
3099 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
3101 // Three quadrangles with normals looking to the user
3102 gp_Pln plane1(gp::Origin(), viewnormal);
3103 gp_Pln plane2(plane1), plane3(plane1);
3106 if (myData->myBoolVoxels &&
3107 myData->myBoolVoxels->GetNbX() &&
3108 myData->myBoolVoxels->GetNbY() &&
3109 myData->myBoolVoxels->GetNbZ())
3112 Standard_Real dx = myData->myBoolVoxels->GetXLen() / (Standard_Real) myData->myBoolVoxels->GetNbX();
3113 Standard_Real dy = myData->myBoolVoxels->GetYLen() / (Standard_Real) myData->myBoolVoxels->GetNbY();
3114 Standard_Real dz = myData->myBoolVoxels->GetZLen() / (Standard_Real) myData->myBoolVoxels->GetNbZ();
3115 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3120 // Translatethe quadrangles to the side of the voxel
3121 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3122 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3123 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3124 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3127 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3128 drawBoolQuadrangles(myData->myBoolVoxels, vdir1, plane1.Axis().Direction(),
3129 skin, p11, p12, p13, p14,
3130 xmin, xmax, ymin, ymax, zmin, zmax);
3131 drawBoolQuadrangles(myData->myBoolVoxels, vdir2, plane2.Axis().Direction(),
3132 skin, p21, p22, p23, p24,
3133 xmin, xmax, ymin, ymax, zmin, zmax);
3134 drawBoolQuadrangles(myData->myBoolVoxels, vdir3, plane3.Axis().Direction(),
3135 skin, p31, p32, p33, p34,
3136 xmin, xmax, ymin, ymax, zmin, zmax);
3138 // Color quadrangles
3139 else if (myData->myColorVoxels &&
3140 myData->myColorVoxels->GetNbX() &&
3141 myData->myColorVoxels->GetNbY() &&
3142 myData->myColorVoxels->GetNbZ())
3145 Standard_Real dx = myData->myColorVoxels->GetXLen() / (Standard_Real) myData->myColorVoxels->GetNbX();
3146 Standard_Real dy = myData->myColorVoxels->GetYLen() / (Standard_Real) myData->myColorVoxels->GetNbY();
3147 Standard_Real dz = myData->myColorVoxels->GetZLen() / (Standard_Real) myData->myColorVoxels->GetNbZ();
3148 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3153 // Translatethe quadrangles to the side of the voxel
3154 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3155 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3156 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3157 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3160 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3161 drawColorQuadrangles(myData->myColorVoxels, vdir1, plane1.Axis().Direction(), skin,
3162 myData->myDisplay.myColors, p11, p12, p13, p14,
3163 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3164 xmin, xmax, ymin, ymax, zmin, zmax);
3165 drawColorQuadrangles(myData->myColorVoxels, vdir2, plane2.Axis().Direction(), skin,
3166 myData->myDisplay.myColors, p21, p22, p23, p24,
3167 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3168 xmin, xmax, ymin, ymax, zmin, zmax);
3169 drawColorQuadrangles(myData->myColorVoxels, vdir3, plane3.Axis().Direction(), skin,
3170 myData->myDisplay.myColors, p31, p32, p33, p34,
3171 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3172 xmin, xmax, ymin, ymax, zmin, zmax);
3174 // Recursive Octree Boolean boxes
3175 else if (myData->myROctBoolVoxels &&
3176 myData->myROctBoolVoxels->GetNbX() &&
3177 myData->myROctBoolVoxels->GetNbY() &&
3178 myData->myROctBoolVoxels->GetNbZ())
3181 Standard_Real dx = myData->myROctBoolVoxels->GetXLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbX();
3182 Standard_Real dy = myData->myROctBoolVoxels->GetYLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbY();
3183 Standard_Real dz = myData->myROctBoolVoxels->GetZLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbZ();
3184 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3189 // Translatethe quadrangles to the side of the voxel
3190 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3191 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3192 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3193 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3196 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3197 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir1, plane1.Axis().Direction(),
3198 skin, p11, p12, p13, p14,
3199 xmin, xmax, ymin, ymax, zmin, zmax);
3200 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir2, plane2.Axis().Direction(),
3201 skin, p21, p22, p23, p24,
3202 xmin, xmax, ymin, ymax, zmin, zmax);
3203 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir3, plane3.Axis().Direction(),
3204 skin, p31, p32, p33, p34,
3205 xmin, xmax, ymin, ymax, zmin, zmax);
3209 /**************************************************************************/
3210 void VoxelClient_VisDrawer::DisplayTriangulation(const Standard_Boolean theHighlight)
3212 if(!myData || myData->myTriangulation.IsNull())
3215 glEnable(GL_DEPTH_TEST);
3216 glEnable(GL_LIGHTING);
3218 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
3219 const Poly_Array1OfTriangle& triangles = myData->myTriangulation->Triangles();
3220 Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
3222 Standard_Boolean compute_normals = Standard_False;
3223 if (myData->myNormalsOfNodes.IsNull())
3225 compute_normals = Standard_True;
3226 myData->myNormalsOfNodes = new TColgp_HArray1OfDir(itriangle, nb_triangles);
3228 // Release the GL list
3229 if (myData->myDisplay.myTriangulationList > 0)
3231 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
3232 myData->myDisplay.myTriangulationList = -1;
3235 // Generate a new GL list
3236 if (myData->myDisplay.myUsageOfGLlists)
3238 genListIndex(myData->myDisplay.myTriangulationList);
3239 glNewList(myData->myDisplay.myTriangulationList, GL_COMPILE);
3242 TColgp_Array1OfDir& normals = myData->myNormalsOfNodes->ChangeArray1();
3244 if (!myData->myDisplay.myUsageOfGLlists || compute_normals)
3247 glBegin(GL_TRIANGLES);
3249 Standard_Integer n1, n2, n3;
3250 Standard_Real x, y, z;
3251 for (; itriangle <= nb_triangles; itriangle++)
3253 const Poly_Triangle& t = triangles.Value(itriangle);
3256 const gp_Pnt& p1 = nodes.Value(n1);
3257 const gp_Pnt& p2 = nodes.Value(n2);
3258 const gp_Pnt& p3 = nodes.Value(n3);
3261 if (compute_normals)
3263 gp_Vec v1(p1, p2), v2(p1, p3);
3265 if (v1.SquareMagnitude() > 1.e-14)
3268 v1.SetCoord(0.0, 0.0, 1.0);
3269 normals.SetValue(itriangle, v1);
3274 normals.Value(itriangle).Coord(x, y, z);
3276 glNormal3d(x, y, z);
3280 glVertex3d(x, y, z);
3284 glVertex3d(x, y, z);
3288 glVertex3d(x, y, z);
3293 if (myData->myDisplay.myUsageOfGLlists)
3297 if (myData->myDisplay.myUsageOfGLlists)
3298 glCallList(myData->myDisplay.myTriangulationList);
3301 void VoxelClient_VisDrawer::HighlightVoxel()
3304 myData->myDisplay.myHighlightx >= 0 &&
3305 myData->myDisplay.myHighlighty >= 0 &&
3306 myData->myDisplay.myHighlightz >= 0)
3308 Standard_Integer nbx, nby, nbz;
3309 Standard_Real xlen, ylen, zlen, xc, yc, zc;
3310 Voxel_DS* ds = (Voxel_DS*) myData->myBoolVoxels;
3311 if (myData->myColorVoxels)
3312 ds = (Voxel_DS*) myData->myColorVoxels;
3313 if (myData->myROctBoolVoxels)
3314 ds = (Voxel_DS*) myData->myROctBoolVoxels;
3318 xlen = ds->GetXLen();
3319 ylen = ds->GetYLen();
3320 zlen = ds->GetZLen();
3321 ds->GetCenter(myData->myDisplay.myHighlightx,
3322 myData->myDisplay.myHighlighty,
3323 myData->myDisplay.myHighlightz,
3326 Standard_Real half_voxelx = xlen / Standard_Real(nbx) / 2.0;
3327 Standard_Real half_voxely = ylen / Standard_Real(nby) / 2.0;
3328 Standard_Real half_voxelz = zlen / Standard_Real(nbz) / 2.0;
3329 Standard_Real x1 = xc - half_voxelx, y1 = yc - half_voxely, z1 = zc - half_voxelz;
3330 Standard_Real x2 = xc + half_voxelx, y2 = yc + half_voxely, z2 = zc + half_voxelz;
3332 setColor(Quantity_NOC_BLUE1, Standard_True);
3333 setTypeOfLine(Aspect_TOL_SOLID);
3338 glVertex3d(x1, y1, z1);
3339 glVertex3d(x1, y2, z1);
3341 glVertex3d(x1, y1, z1);
3342 glVertex3d(x2, y1, z1);
3344 glVertex3d(x1, y1, z1);
3345 glVertex3d(x1, y1, z2);
3347 glVertex3d(x1, y2, z1);
3348 glVertex3d(x2, y2, z1);
3350 glVertex3d(x2, y1, z1);
3351 glVertex3d(x2, y2, z1);
3353 glVertex3d(x2, y2, z1);
3354 glVertex3d(x2, y2, z2);
3356 glVertex3d(x1, y1, z2);
3357 glVertex3d(x1, y2, z2);
3359 glVertex3d(x1, y1, z2);
3360 glVertex3d(x2, y1, z2);
3362 glVertex3d(x2, y1, z2);
3363 glVertex3d(x2, y2, z2);
3365 glVertex3d(x2, y2, z2);
3366 glVertex3d(x1, y2, z2);
3368 glVertex3d(x1, y2, z2);
3369 glVertex3d(x1, y2, z1);
3371 glVertex3d(x2, y1, z1);
3372 glVertex3d(x2, y1, z2);