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_Callback.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;
51 VoxelClient_VisDrawer* myHandler;
59 //=======================================================================
60 //function : VisElement
61 //purpose : Constructor
62 //=======================================================================
64 VoxelClient_VisDrawer::VisElement::VisElement (Voxel_VisData* theData)
66 myHandler = new VoxelClient_VisDrawer (theData);
69 //=======================================================================
70 //function : ~VisElement
71 //purpose : Destructor
72 //=======================================================================
74 VoxelClient_VisDrawer::VisElement::~VisElement ()
79 //=======================================================================
80 //function : EvaluateBounds
82 //=======================================================================
84 void VoxelClient_VisDrawer::VisElement::EvaluateBounds
85 (Graphic3d_CBounds& theMinMax)
87 myHandler->EvalMinMax (theMinMax);
90 //=======================================================================
92 //purpose : display element
93 //=======================================================================
95 void VoxelClient_VisDrawer::VisElement::Render
96 (const Handle (OpenGl_Workspace) &theWorkspace) const
98 const Standard_Boolean aHl = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT);
99 myHandler->Display (aHl);
102 //=======================================================================
103 //function : VisDrawerCallBack
104 //purpose : visdrawer element create callback, adds an element to graphic
105 // driver's structure
106 //=======================================================================
108 static OpenGl_Element* VisDrawerCallBack (const Graphic3d_CUserDraw* theUserDraw)
110 if (theUserDraw == 0)
113 // Retrieve the user structure
114 Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);
119 VoxelClient_VisDrawer::VisElement *aElem =
120 new VoxelClient_VisDrawer::VisElement (aUserData);
122 if (theUserDraw->Bounds != 0)
123 aElem->EvaluateBounds (*(theUserDraw->Bounds));
128 /**************************************************************************/
129 void VoxelClient_VisDrawer::Init()
131 static Standard_Boolean isInitializeded(Standard_False);
133 if (!isInitializeded)
135 isInitializeded = Standard_True;
137 OpenGl_UserDrawCallback& aCallback = UserDrawCallback ();
138 aCallback = VisDrawerCallBack;
142 /**************************************************************************/
143 VoxelClient_VisDrawer::VoxelClient_VisDrawer(Voxel_VisData * theData):myData(theData)
148 /**************************************************************************/
149 VoxelClient_VisDrawer::~VoxelClient_VisDrawer()
153 // Because a pointer to the data is copied,
154 // it is possible to make an attempt to delete GL lists for
155 // a structure, which is already deleted.
156 // Such a situation may happen on close of the application.
157 // Therefore, this try / catch is used.
161 Standard_Integer idir;
166 if (myData->myDisplay.myBoolPointsList > 0)
168 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
169 myData->myDisplay.myBoolPointsList = -1;
171 for (idir = Xminus; idir <= Zplus; idir++)
173 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
175 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
176 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
181 if (myData->myDisplay.myColorPointsList > 0)
183 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
184 myData->myDisplay.myColorPointsList = -1;
186 for (idir = Xminus; idir <= Zplus; idir++)
188 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
190 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
191 myData->myDisplay.myColorNearestPointsList[idir] = -1;
196 if (myData->myDisplay.myROctBoolPointsList > 0)
198 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
199 myData->myDisplay.myROctBoolPointsList = -1;
201 for (idir = Xminus; idir <= Zplus; idir++)
203 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
205 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
206 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
211 if (myData->myDisplay.myTriangulationList > 0)
213 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
214 myData->myDisplay.myTriangulationList = -1;
224 /**************************************************************************/
225 void VoxelClient_VisDrawer::EvalMinMax(Graphic3d_CBounds & theMinMax) const
227 theMinMax.XMin = FLT_MAX;
228 theMinMax.YMin = FLT_MAX;
229 theMinMax.ZMin = FLT_MAX;
230 theMinMax.XMax = -FLT_MAX;
231 theMinMax.YMax = -FLT_MAX;
232 theMinMax.ZMax = -FLT_MAX;
235 if(myData->myBoolVoxels)
237 if (theMinMax.XMin > myData->myBoolVoxels->GetX())
238 theMinMax.XMin = myData->myBoolVoxels->GetX();
239 if (theMinMax.XMax < myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen())
240 theMinMax.XMax = myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen();
241 if (theMinMax.YMin > myData->myBoolVoxels->GetY())
242 theMinMax.YMin = myData->myBoolVoxels->GetY();
243 if (theMinMax.YMax < myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen())
244 theMinMax.YMax = myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen();
245 if (theMinMax.ZMin > myData->myBoolVoxels->GetZ())
246 theMinMax.ZMin = myData->myBoolVoxels->GetZ();
247 if (theMinMax.ZMax < myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen())
248 theMinMax.ZMax = myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen();
250 if(myData->myColorVoxels)
252 if (theMinMax.XMin > myData->myColorVoxels->GetX())
253 theMinMax.XMin = myData->myColorVoxels->GetX();
254 if (theMinMax.XMax < myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen())
255 theMinMax.XMax = myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen();
256 if (theMinMax.YMin > myData->myColorVoxels->GetY())
257 theMinMax.YMin = myData->myColorVoxels->GetY();
258 if (theMinMax.YMax < myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen())
259 theMinMax.YMax = myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen();
260 if (theMinMax.ZMin > myData->myColorVoxels->GetZ())
261 theMinMax.ZMin = myData->myColorVoxels->GetZ();
262 if (theMinMax.ZMax < myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen())
263 theMinMax.ZMax = myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen();
265 if(myData->myROctBoolVoxels)
267 if (theMinMax.XMin > myData->myROctBoolVoxels->GetX())
268 theMinMax.XMin = myData->myROctBoolVoxels->GetX();
269 if (theMinMax.XMax < myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen())
270 theMinMax.XMax = myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen();
271 if (theMinMax.YMin > myData->myROctBoolVoxels->GetY())
272 theMinMax.YMin = myData->myROctBoolVoxels->GetY();
273 if (theMinMax.YMax < myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen())
274 theMinMax.YMax = myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen();
275 if (theMinMax.ZMin > myData->myROctBoolVoxels->GetZ())
276 theMinMax.ZMin = myData->myROctBoolVoxels->GetZ();
277 if (theMinMax.ZMax < myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen())
278 theMinMax.ZMax = myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen();
280 if (!myData->myTriangulation.IsNull())
282 Standard_Real x, y, z;
283 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
284 Standard_Integer inode = nodes.Lower(), nb_nodes = nodes.Upper();
285 for (; inode <= nb_nodes; inode++)
287 nodes.Value(inode).Coord(x, y, z);
288 if (theMinMax.XMin > x)
290 if (theMinMax.XMax < x)
292 if (theMinMax.YMin > y)
294 if (theMinMax.YMax < y)
296 if (theMinMax.ZMin > z)
298 if (theMinMax.ZMax < z)
304 /**************************************************************************/
305 void VoxelClient_VisDrawer::Display(const Standard_Boolean theHighlight)
309 if (myData->myBoolVoxels)
310 DisplayVoxels(theHighlight);
311 if (myData->myColorVoxels)
312 DisplayVoxels(theHighlight);
313 if (myData->myROctBoolVoxels)
314 DisplayVoxels(theHighlight);
315 if (!myData->myTriangulation.IsNull())
316 DisplayTriangulation(theHighlight);
319 // Some static method to define Open GL visual attributes
321 static void setColor(const Quantity_Color& color, const Standard_Boolean highlight)
323 static Quantity_Color highlight_color(Quantity_NOC_BLUE1);
325 glColor3f(highlight_color.Red(), highlight_color.Green(), highlight_color.Blue());
327 glColor3d(color.Red(), color.Green(), color.Blue());
331 static void setTypeOfLine(const Aspect_TypeOfLine type)
333 if(type == Aspect_TOL_SOLID)
335 glDisable(GL_LINE_STIPPLE);
339 glEnable(GL_LINE_STIPPLE);
340 if(type == Aspect_TOL_DOT)
341 glLineStipple(1, 0xCCCC);
342 else if(type == Aspect_TOL_DASH)
343 glLineStipple(1, 0xFFC0);
344 else if(type == Aspect_TOL_DOTDASH)
345 glLineStipple(1, 0xFF18);
350 static void setWidthOfLine(const Standard_Integer width)
352 glLineWidth((Standard_ShortReal) width);
355 // Normal of the view
356 static void getNormal(gp_Dir& normal)
358 Standard_Real x, y, z;
360 GLdouble model_matrix[16], proj_matrix[16];
362 glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
363 glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix);
364 glGetIntegerv(GL_VIEWPORT, viewport);
366 gluUnProject(viewport[0], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
368 gluUnProject(viewport[0] + viewport[2], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
370 gluUnProject(viewport[0], viewport[1] + viewport[3], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
373 gce_MakePln mkNormal(p1, p2, p3);
374 if (mkNormal.IsDone())
376 const gp_Pln& normal_plane = mkNormal.Value();
377 normal = normal_plane.Axis().Direction();
385 // Normal 2 VoxelDirection converter
386 static VoxelDirection getVoxelDirection(const gp_Dir& viewnormal)
389 Standard_Real fabsviewnormalx = fabs(viewnormal.X());
390 Standard_Real fabsviewnormaly = fabs(viewnormal.Y());
391 Standard_Real fabsviewnormalz = fabs(viewnormal.Z());
392 if (fabsviewnormalx >= fabsviewnormaly &&
393 fabsviewnormalx >= fabsviewnormalz)
395 if (viewnormal.X() > 0)
400 else if (fabsviewnormaly >= fabsviewnormalx &&
401 fabsviewnormaly >= fabsviewnormalz)
403 if (viewnormal.Y() > 0)
408 else if (fabsviewnormalz >= fabsviewnormalx &&
409 fabsviewnormalz >= fabsviewnormaly)
411 if (viewnormal.Z() > 0)
419 // Normal 2 VoxelDirection 3 converter
420 static void getVoxel3Directions(const gp_Dir& viewnormal,
421 VoxelDirection& vdir1,
422 VoxelDirection& vdir2,
423 VoxelDirection& vdir3)
425 Standard_Boolean vdir1_set = Standard_False, vdir2_set = Standard_False, vdir3_set = Standard_False;
428 Standard_Real dot = viewnormal.Dot(-gp::DX());
434 vdir1_set = Standard_True;
439 vdir2_set = Standard_True;
444 vdir3_set = Standard_True;
449 dot = viewnormal.Dot(gp::DX());
455 vdir1_set = Standard_True;
460 vdir2_set = Standard_True;
465 vdir3_set = Standard_True;
470 dot = viewnormal.Dot(-gp::DY());
476 vdir1_set = Standard_True;
481 vdir2_set = Standard_True;
486 vdir3_set = Standard_True;
491 dot = viewnormal.Dot(gp::DY());
497 vdir1_set = Standard_True;
502 vdir2_set = Standard_True;
507 vdir3_set = Standard_True;
512 dot = viewnormal.Dot(-gp::DZ());
518 vdir1_set = Standard_True;
523 vdir2_set = Standard_True;
528 vdir3_set = Standard_True;
533 dot = viewnormal.Dot(gp::DZ());
539 vdir1_set = Standard_True;
544 vdir2_set = Standard_True;
549 vdir3_set = Standard_True;
554 static Standard_Boolean CheckSize(Voxel_DS* voxels,
555 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
556 const Standard_Real xmin, const Standard_Real xmax,
557 const Standard_Real ymin, const Standard_Real ymax,
558 const Standard_Real zmin, const Standard_Real zmax,
559 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
561 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
562 if (xc < xmin || xc > xmax)
563 return Standard_False;
564 if (yc < ymin || yc > ymax)
565 return Standard_False;
566 if (zc < zmin || zc > zmax)
567 return Standard_False;
568 return Standard_True;
571 static Standard_Boolean CheckSize(Voxel_ROctBoolDS* voxels,
572 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
573 const Standard_Integer i, const Standard_Integer j,
574 const Standard_Real xmin, const Standard_Real xmax,
575 const Standard_Real ymin, const Standard_Real ymax,
576 const Standard_Real zmin, const Standard_Real zmax,
577 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
580 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
582 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
583 if (xc < xmin || xc > xmax)
584 return Standard_False;
585 if (yc < ymin || yc > ymax)
586 return Standard_False;
587 if (zc < zmin || zc > zmax)
588 return Standard_False;
589 return Standard_True;
592 static void drawBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
593 Voxel_BoolDS* voxels,
594 const Standard_Real xmin, const Standard_Real xmax,
595 const Standard_Real ymin, const Standard_Real ymax,
596 const Standard_Real zmin, const Standard_Real zmax)
598 Standard_Real xc, yc, zc;
599 Standard_Integer ix = 0, nbx = voxels->GetNbX();
600 Standard_Integer iy = 0, nby = voxels->GetNbY();
601 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
603 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
604 ymin <= DBL_MAX && ymax >= DBL_MAX &&
605 zmin <= DBL_MAX && zmax >= DBL_MAX);
606 check_size = !check_size;
613 for (iy = 0; iy < nby; iy++)
615 for (iz = 0; iz < nbz; iz++)
617 for (ix = 0; ix < nbx; ix++)
619 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
621 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
625 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
626 glVertex3d(xc, yc, zc);
637 for (iy = 0; iy < nby; iy++)
639 for (iz = 0; iz < nbz; iz++)
641 for (ix = nbx - 1; ix >= 0; ix--)
643 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
645 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
649 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
650 glVertex3d(xc, yc, zc);
661 for (ix = 0; ix < nbx; ix++)
663 for (iz = 0; iz < nbz; iz++)
665 for (iy = 0; iy < nby; iy++)
667 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
669 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
673 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
674 glVertex3d(xc, yc, zc);
685 for (ix = 0; ix < nbx; ix++)
687 for (iz = 0; iz < nbz; iz++)
689 for (iy = nby - 1; iy >= 0; iy--)
691 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
693 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
697 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
698 glVertex3d(xc, yc, zc);
709 for (ix = 0; ix < nbx; ix++)
711 for (iy = 0; iy < nby; iy++)
713 for (iz = 0; iz < nbz; iz++)
715 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
717 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
721 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
722 glVertex3d(xc, yc, zc);
733 for (ix = 0; ix < nbx; ix++)
735 for (iy = 0; iy < nby; iy++)
737 for (iz = nbz - 1; iz >= 0; iz--)
739 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
741 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
745 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
746 glVertex3d(xc, yc, zc);
759 static void drawROctBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
760 Voxel_ROctBoolDS* voxels,
761 const Standard_Real xmin, const Standard_Real xmax,
762 const Standard_Real ymin, const Standard_Real ymax,
763 const Standard_Real zmin, const Standard_Real zmax)
765 Standard_Real xc, yc, zc;
766 Standard_Integer ix = 0, nbx = voxels->GetNbX();
767 Standard_Integer iy = 0, nby = voxels->GetNbY();
768 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
769 Standard_Integer i, j;
771 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
772 ymin <= DBL_MAX && ymax >= DBL_MAX &&
773 zmin <= DBL_MAX && zmax >= DBL_MAX);
774 check_size = !check_size;
781 for (iy = 0; iy < nby; iy++)
783 for (iz = 0; iz < nbz; iz++)
785 for (ix = 0; ix < nbx; ix++)
787 switch (voxels->Deepness(ix, iy, iz))
791 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
793 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
797 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
798 glVertex3d(xc, yc, zc);
806 for (i = 0; i < 8; i++)
808 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
810 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
814 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
815 glVertex3d(xc, yc, zc);
824 for (i = 0; i < 8; i++)
826 for (j = 0; j < 8; j++)
828 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
830 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
834 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
835 glVertex3d(xc, yc, zc);
851 for (iy = 0; iy < nby; iy++)
853 for (iz = 0; iz < nbz; iz++)
855 for (ix = nbx - 1; ix >= 0; ix--)
857 switch (voxels->Deepness(ix, iy, iz))
861 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
863 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
867 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
868 glVertex3d(xc, yc, zc);
876 for (i = 0; i < 8; i++)
878 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
880 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
884 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
885 glVertex3d(xc, yc, zc);
894 for (i = 0; i < 8; i++)
896 for (j = 0; j < 8; j++)
898 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
900 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
904 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
905 glVertex3d(xc, yc, zc);
921 for (ix = 0; ix < nbx; ix++)
923 for (iz = 0; iz < nbz; iz++)
925 for (iy = 0; iy < nby; iy++)
927 switch (voxels->Deepness(ix, iy, iz))
931 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
933 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
937 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
938 glVertex3d(xc, yc, zc);
946 for (i = 0; i < 8; i++)
948 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
950 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
954 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
955 glVertex3d(xc, yc, zc);
964 for (i = 0; i < 8; i++)
966 for (j = 0; j < 8; j++)
968 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
970 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
974 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
975 glVertex3d(xc, yc, zc);
991 for (ix = 0; ix < nbx; ix++)
993 for (iz = 0; iz < nbz; iz++)
995 for (iy = nby - 1; iy >= 0; iy--)
997 switch (voxels->Deepness(ix, iy, iz))
1001 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1003 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1007 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1008 glVertex3d(xc, yc, zc);
1016 for (i = 0; i < 8; i++)
1018 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1020 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1024 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1025 glVertex3d(xc, yc, zc);
1034 for (i = 0; i < 8; i++)
1036 for (j = 0; j < 8; j++)
1038 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1040 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1044 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1045 glVertex3d(xc, yc, zc);
1061 for (ix = 0; ix < nbx; ix++)
1063 for (iy = 0; iy < nby; iy++)
1065 for (iz = 0; iz < nbz; iz++)
1067 switch (voxels->Deepness(ix, iy, iz))
1071 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1073 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1077 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1078 glVertex3d(xc, yc, zc);
1086 for (i = 0; i < 8; i++)
1088 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1090 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1094 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1095 glVertex3d(xc, yc, zc);
1104 for (i = 0; i < 8; i++)
1106 for (j = 0; j < 8; j++)
1108 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1110 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1114 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1115 glVertex3d(xc, yc, zc);
1131 for (ix = 0; ix < nbx; ix++)
1133 for (iy = 0; iy < nby; iy++)
1135 for (iz = nbz - 1; iz >= 0; iz--)
1137 switch (voxels->Deepness(ix, iy, iz))
1141 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1143 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1147 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1148 glVertex3d(xc, yc, zc);
1156 for (i = 0; i < 8; i++)
1158 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1160 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1164 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1165 glVertex3d(xc, yc, zc);
1174 for (i = 0; i < 8; i++)
1176 for (j = 0; j < 8; j++)
1178 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1180 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1184 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1185 glVertex3d(xc, yc, zc);
1205 static void drawColorPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
1206 Voxel_ColorDS* voxels, const Handle(Quantity_HArray1OfColor)& hcolors,
1207 const Standard_Byte minvalue, const Standard_Byte maxvalue,
1208 const Standard_Real xmin, const Standard_Real xmax,
1209 const Standard_Real ymin, const Standard_Real ymax,
1210 const Standard_Real zmin, const Standard_Real zmax)
1212 Standard_Real xc, yc, zc;
1213 Standard_Integer ix = 0, nbx = voxels->GetNbX();
1214 Standard_Integer iy = 0, nby = voxels->GetNbY();
1215 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
1216 Standard_Byte value;
1219 const Quantity_Array1OfColor& colors = hcolors->Array1();
1221 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1222 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1223 zmin <= DBL_MAX && zmax >= DBL_MAX);
1224 check_size = !check_size;
1231 for (iy = 0; iy < nby; iy++)
1233 for (iz = 0; iz < nbz; iz++)
1235 for (ix = 0; ix < nbx; ix++)
1237 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1239 value = voxels->Get(ix, iy, iz);
1240 if (value >= minvalue && value <= maxvalue)
1243 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1244 setColor(colors.Value(value), Standard_False);
1245 glVertex3d(xc, yc, zc);
1256 for (iy = 0; iy < nby; iy++)
1258 for (iz = 0; iz < nbz; iz++)
1260 for (ix = nbx - 1; ix >= 0; ix--)
1262 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1264 value = voxels->Get(ix, iy, iz);
1265 if (value >= minvalue && value <= maxvalue)
1268 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1269 setColor(colors.Value(value), Standard_False);
1270 glVertex3d(xc, yc, zc);
1281 for (ix = 0; ix < nbx; ix++)
1283 for (iz = 0; iz < nbz; iz++)
1285 for (iy = 0; iy < nby; iy++)
1287 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1289 value = voxels->Get(ix, iy, iz);
1290 if (value >= minvalue && value <= maxvalue)
1293 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1294 setColor(colors.Value(value), Standard_False);
1295 glVertex3d(xc, yc, zc);
1306 for (ix = 0; ix < nbx; ix++)
1308 for (iz = 0; iz < nbz; iz++)
1310 for (iy = nby - 1; iy >= 0; iy--)
1312 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1314 value = voxels->Get(ix, iy, iz);
1315 if (value >= minvalue && value <= maxvalue)
1318 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1319 setColor(colors.Value(value), Standard_False);
1320 glVertex3d(xc, yc, zc);
1331 for (ix = 0; ix < nbx; ix++)
1333 for (iy = 0; iy < nby; iy++)
1335 for (iz = 0; iz < nbz; iz++)
1337 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1339 value = voxels->Get(ix, iy, iz);
1340 if (value >= minvalue && value <= maxvalue)
1343 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1344 setColor(colors.Value(value), Standard_False);
1345 glVertex3d(xc, yc, zc);
1356 for (ix = 0; ix < nbx; ix++)
1358 for (iy = 0; iy < nby; iy++)
1360 for (iz = nbz - 1; iz >= 0; iz--)
1362 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1364 value = voxels->Get(ix, iy, iz);
1365 if (value >= minvalue && value <= maxvalue)
1368 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1369 setColor(colors.Value(value), Standard_False);
1370 glVertex3d(xc, yc, zc);
1383 static void drawBoolQuadrangles(Voxel_BoolDS* voxels, const VoxelDirection vdir,
1384 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1385 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1386 const Standard_Real xmin, const Standard_Real xmax,
1387 const Standard_Real ymin, const Standard_Real ymax,
1388 const Standard_Real zmin, const Standard_Real zmax)
1391 gp_Pnt pc1, pc2, pc3, pc4;
1392 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1393 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
1396 viewnormal.Coord(xn, yn, zn);
1398 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1399 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1400 zmin <= DBL_MAX && zmax >= DBL_MAX);
1401 check_size = !check_size;
1408 for (iy = 0; iy < nby; iy++)
1410 for (iz = 0; iz < nbz; iz++)
1412 for (ix = 0; ix < nbx; ix++)
1414 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1416 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1419 // Define translation vector
1421 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1422 vc.SetCoord(xc, yc, zc);
1425 pc1 = p1.Translated(vc);
1426 pc2 = p2.Translated(vc);
1427 pc3 = p3.Translated(vc);
1428 pc4 = p4.Translated(vc);
1431 glNormal3d(xn, yn, zn);
1432 pc1.Coord(xc, yc, zc);
1433 glVertex3d(xc, yc, zc);
1434 pc2.Coord(xc, yc, zc);
1435 glVertex3d(xc, yc, zc);
1436 pc3.Coord(xc, yc, zc);
1437 glVertex3d(xc, yc, zc);
1438 pc4.Coord(xc, yc, zc);
1439 glVertex3d(xc, yc, zc);
1451 for (iy = 0; iy < nby; iy++)
1453 for (iz = 0; iz < nbz; iz++)
1455 for (ix = nbx - 1; ix >= 0; ix--)
1457 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1459 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1462 // Define translation vector
1464 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1465 vc.SetCoord(xc, yc, zc);
1468 pc1 = p1.Translated(vc);
1469 pc2 = p2.Translated(vc);
1470 pc3 = p3.Translated(vc);
1471 pc4 = p4.Translated(vc);
1474 glNormal3d(xn, yn, zn);
1475 pc1.Coord(xc, yc, zc);
1476 glVertex3d(xc, yc, zc);
1477 pc2.Coord(xc, yc, zc);
1478 glVertex3d(xc, yc, zc);
1479 pc3.Coord(xc, yc, zc);
1480 glVertex3d(xc, yc, zc);
1481 pc4.Coord(xc, yc, zc);
1482 glVertex3d(xc, yc, zc);
1494 for (ix = 0; ix < nbx; ix++)
1496 for (iz = 0; iz < nbz; iz++)
1498 for (iy = 0; iy < nby; iy++)
1500 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1502 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1505 // Define translation vector
1507 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1508 vc.SetCoord(xc, yc, zc);
1511 pc1 = p1.Translated(vc);
1512 pc2 = p2.Translated(vc);
1513 pc3 = p3.Translated(vc);
1514 pc4 = p4.Translated(vc);
1517 glNormal3d(xn, yn, zn);
1518 pc1.Coord(xc, yc, zc);
1519 glVertex3d(xc, yc, zc);
1520 pc2.Coord(xc, yc, zc);
1521 glVertex3d(xc, yc, zc);
1522 pc3.Coord(xc, yc, zc);
1523 glVertex3d(xc, yc, zc);
1524 pc4.Coord(xc, yc, zc);
1525 glVertex3d(xc, yc, zc);
1537 for (ix = 0; ix < nbx; ix++)
1539 for (iz = 0; iz < nbz; iz++)
1541 for (iy = nby - 1; iy >= 0; iy--)
1543 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1545 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1548 // Define translation vector
1550 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1551 vc.SetCoord(xc, yc, zc);
1554 pc1 = p1.Translated(vc);
1555 pc2 = p2.Translated(vc);
1556 pc3 = p3.Translated(vc);
1557 pc4 = p4.Translated(vc);
1560 glNormal3d(xn, yn, zn);
1561 pc1.Coord(xc, yc, zc);
1562 glVertex3d(xc, yc, zc);
1563 pc2.Coord(xc, yc, zc);
1564 glVertex3d(xc, yc, zc);
1565 pc3.Coord(xc, yc, zc);
1566 glVertex3d(xc, yc, zc);
1567 pc4.Coord(xc, yc, zc);
1568 glVertex3d(xc, yc, zc);
1580 for (ix = 0; ix < nbx; ix++)
1582 for (iy = 0; iy < nby; iy++)
1584 for (iz = 0; iz < nbz; iz++)
1586 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1588 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1591 // Define translation vector
1593 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1594 vc.SetCoord(xc, yc, zc);
1597 pc1 = p1.Translated(vc);
1598 pc2 = p2.Translated(vc);
1599 pc3 = p3.Translated(vc);
1600 pc4 = p4.Translated(vc);
1603 glNormal3d(xn, yn, zn);
1604 pc1.Coord(xc, yc, zc);
1605 glVertex3d(xc, yc, zc);
1606 pc2.Coord(xc, yc, zc);
1607 glVertex3d(xc, yc, zc);
1608 pc3.Coord(xc, yc, zc);
1609 glVertex3d(xc, yc, zc);
1610 pc4.Coord(xc, yc, zc);
1611 glVertex3d(xc, yc, zc);
1623 for (ix = 0; ix < nbx; ix++)
1625 for (iy = 0; iy < nby; iy++)
1627 for (iz = nbz - 1; iz >= 0; iz--)
1629 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1631 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1634 // Define translation vector
1636 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1637 vc.SetCoord(xc, yc, zc);
1640 pc1 = p1.Translated(vc);
1641 pc2 = p2.Translated(vc);
1642 pc3 = p3.Translated(vc);
1643 pc4 = p4.Translated(vc);
1646 glNormal3d(xn, yn, zn);
1647 pc1.Coord(xc, yc, zc);
1648 glVertex3d(xc, yc, zc);
1649 pc2.Coord(xc, yc, zc);
1650 glVertex3d(xc, yc, zc);
1651 pc3.Coord(xc, yc, zc);
1652 glVertex3d(xc, yc, zc);
1653 pc4.Coord(xc, yc, zc);
1654 glVertex3d(xc, yc, zc);
1668 static void drawROctBoolQuadrangles(Voxel_ROctBoolDS* voxels, const VoxelDirection vdir,
1669 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1670 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1671 const Standard_Real xmin, const Standard_Real xmax,
1672 const Standard_Real ymin, const Standard_Real ymax,
1673 const Standard_Real zmin, const Standard_Real zmax)
1676 gp_Pnt pc1, pc2, pc3, pc4;
1677 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1678 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(), i, j, deepness;
1681 viewnormal.Coord(xn, yn, zn);
1683 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1684 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1685 zmin <= DBL_MAX && zmax >= DBL_MAX);
1686 check_size = !check_size;
1693 for (iy = 0; iy < nby; iy++)
1695 for (iz = 0; iz < nbz; iz++)
1697 for (ix = 0; ix < nbx; ix++)
1699 deepness = voxels->Deepness(ix, iy, iz);
1700 for (i = 0; i < 8; i++)
1702 for (j = 0; j < 8; j++)
1704 if (deepness == 0 && j)
1709 if (deepness == 1 && j)
1713 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1716 else if (deepness == 1)
1718 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1721 else if (deepness == 2)
1723 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1727 Standard_Boolean value;
1731 value = voxels->Get(ix, iy, iz) == Standard_True;
1734 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1737 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1743 // Define translation vector
1749 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1752 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1755 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1759 vc.SetCoord(xc, yc, zc);
1762 pc1 = p1.Translated(vc);
1763 pc2 = p2.Translated(vc);
1764 pc3 = p3.Translated(vc);
1765 pc4 = p4.Translated(vc);
1768 glNormal3d(xn, yn, zn);
1769 pc1.Coord(xc, yc, zc);
1770 glVertex3d(xc, yc, zc);
1771 pc2.Coord(xc, yc, zc);
1772 glVertex3d(xc, yc, zc);
1773 pc3.Coord(xc, yc, zc);
1774 glVertex3d(xc, yc, zc);
1775 pc4.Coord(xc, yc, zc);
1776 glVertex3d(xc, yc, zc);
1790 for (iy = 0; iy < nby; iy++)
1792 for (iz = 0; iz < nbz; iz++)
1794 for (ix = nbx - 1; ix >= 0; ix--)
1796 deepness = voxels->Deepness(ix, iy, iz);
1797 for (i = 0; i < 8; i++)
1799 for (j = 0; j < 8; j++)
1801 if (deepness == 0 && j)
1806 if (deepness == 1 && j)
1810 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1813 else if (deepness == 1)
1815 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1818 else if (deepness == 2)
1820 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1824 Standard_Boolean value;
1828 value = voxels->Get(ix, iy, iz) == Standard_True;
1831 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1834 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1840 // Define translation vector
1846 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1849 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1852 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1856 vc.SetCoord(xc, yc, zc);
1859 pc1 = p1.Translated(vc);
1860 pc2 = p2.Translated(vc);
1861 pc3 = p3.Translated(vc);
1862 pc4 = p4.Translated(vc);
1865 glNormal3d(xn, yn, zn);
1866 pc1.Coord(xc, yc, zc);
1867 glVertex3d(xc, yc, zc);
1868 pc2.Coord(xc, yc, zc);
1869 glVertex3d(xc, yc, zc);
1870 pc3.Coord(xc, yc, zc);
1871 glVertex3d(xc, yc, zc);
1872 pc4.Coord(xc, yc, zc);
1873 glVertex3d(xc, yc, zc);
1887 for (ix = 0; ix < nbx; ix++)
1889 for (iz = 0; iz < nbz; iz++)
1891 for (iy = 0; iy < nby; iy++)
1893 deepness = voxels->Deepness(ix, iy, iz);
1894 for (i = 0; i < 8; i++)
1896 for (j = 0; j < 8; j++)
1898 if (deepness == 0 && j)
1903 if (deepness == 1 && j)
1907 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1910 else if (deepness == 1)
1912 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1915 else if (deepness == 2)
1917 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1921 Standard_Boolean value;
1925 value = voxels->Get(ix, iy, iz) == Standard_True;
1928 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1931 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1937 // Define translation vector
1943 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1946 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1949 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1953 vc.SetCoord(xc, yc, zc);
1956 pc1 = p1.Translated(vc);
1957 pc2 = p2.Translated(vc);
1958 pc3 = p3.Translated(vc);
1959 pc4 = p4.Translated(vc);
1962 glNormal3d(xn, yn, zn);
1963 pc1.Coord(xc, yc, zc);
1964 glVertex3d(xc, yc, zc);
1965 pc2.Coord(xc, yc, zc);
1966 glVertex3d(xc, yc, zc);
1967 pc3.Coord(xc, yc, zc);
1968 glVertex3d(xc, yc, zc);
1969 pc4.Coord(xc, yc, zc);
1970 glVertex3d(xc, yc, zc);
1984 for (ix = 0; ix < nbx; ix++)
1986 for (iz = 0; iz < nbz; iz++)
1988 for (iy = nby - 1; iy >= 0; iy--)
1990 deepness = voxels->Deepness(ix, iy, iz);
1991 for (i = 0; i < 8; i++)
1993 for (j = 0; j < 8; j++)
1995 if (deepness == 0 && j)
2000 if (deepness == 1 && j)
2004 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2007 else if (deepness == 1)
2009 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2012 else if (deepness == 2)
2014 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2018 Standard_Boolean value;
2022 value = voxels->Get(ix, iy, iz) == Standard_True;
2025 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2028 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2034 // Define translation vector
2040 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2043 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2046 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2050 vc.SetCoord(xc, yc, zc);
2053 pc1 = p1.Translated(vc);
2054 pc2 = p2.Translated(vc);
2055 pc3 = p3.Translated(vc);
2056 pc4 = p4.Translated(vc);
2059 glNormal3d(xn, yn, zn);
2060 pc1.Coord(xc, yc, zc);
2061 glVertex3d(xc, yc, zc);
2062 pc2.Coord(xc, yc, zc);
2063 glVertex3d(xc, yc, zc);
2064 pc3.Coord(xc, yc, zc);
2065 glVertex3d(xc, yc, zc);
2066 pc4.Coord(xc, yc, zc);
2067 glVertex3d(xc, yc, zc);
2081 for (ix = 0; ix < nbx; ix++)
2083 for (iy = 0; iy < nby; iy++)
2085 for (iz = 0; iz < nbz; iz++)
2087 deepness = voxels->Deepness(ix, iy, iz);
2088 for (i = 0; i < 8; i++)
2090 for (j = 0; j < 8; j++)
2092 if (deepness == 0 && j)
2097 if (deepness == 1 && j)
2101 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2104 else if (deepness == 1)
2106 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2109 else if (deepness == 2)
2111 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2115 Standard_Boolean value;
2119 value = voxels->Get(ix, iy, iz) == Standard_True;
2122 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2125 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2131 // Define translation vector
2137 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2140 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2143 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2147 vc.SetCoord(xc, yc, zc);
2150 pc1 = p1.Translated(vc);
2151 pc2 = p2.Translated(vc);
2152 pc3 = p3.Translated(vc);
2153 pc4 = p4.Translated(vc);
2156 glNormal3d(xn, yn, zn);
2157 pc1.Coord(xc, yc, zc);
2158 glVertex3d(xc, yc, zc);
2159 pc2.Coord(xc, yc, zc);
2160 glVertex3d(xc, yc, zc);
2161 pc3.Coord(xc, yc, zc);
2162 glVertex3d(xc, yc, zc);
2163 pc4.Coord(xc, yc, zc);
2164 glVertex3d(xc, yc, zc);
2178 for (ix = 0; ix < nbx; ix++)
2180 for (iy = 0; iy < nby; iy++)
2182 for (iz = nbz - 1; iz >= 0; iz--)
2184 deepness = voxels->Deepness(ix, iy, iz);
2185 for (i = 0; i < 8; i++)
2187 for (j = 0; j < 8; j++)
2189 if (deepness == 0 && j)
2194 if (deepness == 1 && j)
2198 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2201 else if (deepness == 1)
2203 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2206 else if (deepness == 2)
2208 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2212 Standard_Boolean value;
2216 value = voxels->Get(ix, iy, iz) == Standard_True;
2219 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2222 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2228 // Define translation vector
2234 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2237 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2240 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2244 vc.SetCoord(xc, yc, zc);
2247 pc1 = p1.Translated(vc);
2248 pc2 = p2.Translated(vc);
2249 pc3 = p3.Translated(vc);
2250 pc4 = p4.Translated(vc);
2253 glNormal3d(xn, yn, zn);
2254 pc1.Coord(xc, yc, zc);
2255 glVertex3d(xc, yc, zc);
2256 pc2.Coord(xc, yc, zc);
2257 glVertex3d(xc, yc, zc);
2258 pc3.Coord(xc, yc, zc);
2259 glVertex3d(xc, yc, zc);
2260 pc4.Coord(xc, yc, zc);
2261 glVertex3d(xc, yc, zc);
2279 static void drawColorQuadrangles(Voxel_ColorDS* voxels, const VoxelDirection vdir,
2280 const gp_Dir& viewnormal, const Standard_Boolean nearest,
2281 const Handle(Quantity_HArray1OfColor)& hcolors,
2282 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
2283 const Standard_Byte minvalue, const Standard_Byte maxvalue,
2284 const Standard_Real xmin, const Standard_Real xmax,
2285 const Standard_Real ymin, const Standard_Real ymax,
2286 const Standard_Real zmin, const Standard_Real zmax)
2289 gp_Pnt pc1, pc2, pc3, pc4;
2290 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 0.0;
2291 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
2292 Standard_Byte value;
2295 //viewnormal.Coord(xn, yn, zn);
2296 glNormal3d(xn, yn, zn);
2299 const Quantity_Array1OfColor& colors = hcolors->Array1();
2301 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
2302 ymin <= DBL_MAX && ymax >= DBL_MAX &&
2303 zmin <= DBL_MAX && zmax >= DBL_MAX);
2304 check_size = !check_size;
2311 for (iy = 0; iy < nby; iy++)
2313 for (iz = 0; iz < nbz; iz++)
2315 for (ix = 0; ix < nbx; ix++)
2317 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2319 value = voxels->Get(ix, iy, iz);
2320 if (value >= minvalue && value <= maxvalue)
2322 // Define translation vector
2324 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2325 vc.SetCoord(xc, yc, zc);
2328 pc1 = p1.Translated(vc);
2329 pc2 = p2.Translated(vc);
2330 pc3 = p3.Translated(vc);
2331 pc4 = p4.Translated(vc);
2334 setColor(colors.Value(value), Standard_False);
2337 //glNormal3d(xn, yn, zn);
2338 pc1.Coord(xc, yc, zc);
2339 glVertex3d(xc, yc, zc);
2340 pc2.Coord(xc, yc, zc);
2341 glVertex3d(xc, yc, zc);
2342 pc3.Coord(xc, yc, zc);
2343 glVertex3d(xc, yc, zc);
2344 pc4.Coord(xc, yc, zc);
2345 glVertex3d(xc, yc, zc);
2357 for (iy = 0; iy < nby; iy++)
2359 for (iz = 0; iz < nbz; iz++)
2361 for (ix = nbx - 1; ix >= 0; ix--)
2363 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2365 value = voxels->Get(ix, iy, iz);
2366 if (value >= minvalue && value <= maxvalue)
2368 // Define translation vector
2370 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2371 vc.SetCoord(xc, yc, zc);
2374 pc1 = p1.Translated(vc);
2375 pc2 = p2.Translated(vc);
2376 pc3 = p3.Translated(vc);
2377 pc4 = p4.Translated(vc);
2380 setColor(colors.Value(value), Standard_False);
2383 //glNormal3d(xn, yn, zn);
2384 pc1.Coord(xc, yc, zc);
2385 glVertex3d(xc, yc, zc);
2386 pc2.Coord(xc, yc, zc);
2387 glVertex3d(xc, yc, zc);
2388 pc3.Coord(xc, yc, zc);
2389 glVertex3d(xc, yc, zc);
2390 pc4.Coord(xc, yc, zc);
2391 glVertex3d(xc, yc, zc);
2403 for (ix = 0; ix < nbx; ix++)
2405 for (iz = 0; iz < nbz; iz++)
2407 for (iy = 0; iy < nby; iy++)
2409 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2411 value = voxels->Get(ix, iy, iz);
2412 if (value >= minvalue && value <= maxvalue)
2414 // Define translation vector
2416 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2417 vc.SetCoord(xc, yc, zc);
2420 pc1 = p1.Translated(vc);
2421 pc2 = p2.Translated(vc);
2422 pc3 = p3.Translated(vc);
2423 pc4 = p4.Translated(vc);
2426 setColor(colors.Value(value), Standard_False);
2429 //glNormal3d(xn, yn, zn);
2430 pc1.Coord(xc, yc, zc);
2431 glVertex3d(xc, yc, zc);
2432 pc2.Coord(xc, yc, zc);
2433 glVertex3d(xc, yc, zc);
2434 pc3.Coord(xc, yc, zc);
2435 glVertex3d(xc, yc, zc);
2436 pc4.Coord(xc, yc, zc);
2437 glVertex3d(xc, yc, zc);
2449 for (ix = 0; ix < nbx; ix++)
2451 for (iz = 0; iz < nbz; iz++)
2453 for (iy = nby - 1; iy >= 0; iy--)
2455 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2457 value = voxels->Get(ix, iy, iz);
2458 if (value >= minvalue && value <= maxvalue)
2460 // Define translation vector
2462 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2463 vc.SetCoord(xc, yc, zc);
2466 pc1 = p1.Translated(vc);
2467 pc2 = p2.Translated(vc);
2468 pc3 = p3.Translated(vc);
2469 pc4 = p4.Translated(vc);
2472 setColor(colors.Value(value), Standard_False);
2475 //glNormal3d(xn, yn, zn);
2476 pc1.Coord(xc, yc, zc);
2477 glVertex3d(xc, yc, zc);
2478 pc2.Coord(xc, yc, zc);
2479 glVertex3d(xc, yc, zc);
2480 pc3.Coord(xc, yc, zc);
2481 glVertex3d(xc, yc, zc);
2482 pc4.Coord(xc, yc, zc);
2483 glVertex3d(xc, yc, zc);
2495 for (ix = 0; ix < nbx; ix++)
2497 for (iy = 0; iy < nby; iy++)
2499 for (iz = 0; iz < nbz; iz++)
2501 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2503 value = voxels->Get(ix, iy, iz);
2504 if (value >= minvalue && value <= maxvalue)
2506 // Define translation vector
2508 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2509 vc.SetCoord(xc, yc, zc);
2512 pc1 = p1.Translated(vc);
2513 pc2 = p2.Translated(vc);
2514 pc3 = p3.Translated(vc);
2515 pc4 = p4.Translated(vc);
2518 setColor(colors.Value(value), Standard_False);
2521 //glNormal3d(xn, yn, zn);
2522 pc1.Coord(xc, yc, zc);
2523 glVertex3d(xc, yc, zc);
2524 pc2.Coord(xc, yc, zc);
2525 glVertex3d(xc, yc, zc);
2526 pc3.Coord(xc, yc, zc);
2527 glVertex3d(xc, yc, zc);
2528 pc4.Coord(xc, yc, zc);
2529 glVertex3d(xc, yc, zc);
2541 for (ix = 0; ix < nbx; ix++)
2543 for (iy = 0; iy < nby; iy++)
2545 for (iz = nbz - 1; iz >= 0; iz--)
2547 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2549 value = voxels->Get(ix, iy, iz);
2550 if (value >= minvalue && value <= maxvalue)
2552 // Define translation vector
2554 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2555 vc.SetCoord(xc, yc, zc);
2558 pc1 = p1.Translated(vc);
2559 pc2 = p2.Translated(vc);
2560 pc3 = p3.Translated(vc);
2561 pc4 = p4.Translated(vc);
2564 setColor(colors.Value(value), Standard_False);
2567 //glNormal3d(xn, yn, zn);
2568 pc1.Coord(xc, yc, zc);
2569 glVertex3d(xc, yc, zc);
2570 pc2.Coord(xc, yc, zc);
2571 glVertex3d(xc, yc, zc);
2572 pc3.Coord(xc, yc, zc);
2573 glVertex3d(xc, yc, zc);
2574 pc4.Coord(xc, yc, zc);
2575 glVertex3d(xc, yc, zc);
2589 static void genListIndex(GLint& index)
2592 while (++i <= INT_MAX)
2602 static void setPlaneNormal(const VoxelDirection& dir,
2603 const Standard_Real dx, const Standard_Real dy, const Standard_Real dz,
2604 gp_Pln& plane, gp_Pnt& p1, gp_Pnt& p2, gp_Pnt& p3, gp_Pnt& p4)
2606 gp_Ax3 axes = plane.Position();
2607 Standard_Real dx2 = 0.5 * dx, dy2 = 0.5 * dy, dz2 = 0.5 * dz;
2611 p1.SetCoord(-dx2, -dy2, dz2);
2612 p2.SetCoord(-dx2, -dy2, -dz2);
2613 p3.SetCoord(-dx2, dy2, -dz2);
2614 p4.SetCoord(-dx2, dy2, dz2);
2615 axes.SetDirection(-gp::DX());
2618 p1.SetCoord(dx2, -dy2, dz2);
2619 p2.SetCoord(dx2, -dy2, -dz2);
2620 p3.SetCoord(dx2, dy2, -dz2);
2621 p4.SetCoord(dx2, dy2, dz2);
2622 axes.SetDirection(gp::DX());
2625 p1.SetCoord(dx2, -dy2, dz2);
2626 p2.SetCoord(dx2, -dy2, -dz2);
2627 p3.SetCoord(-dx2, -dy2, -dz2);
2628 p4.SetCoord(-dx2, -dy2, dz2);
2629 axes.SetDirection(-gp::DY());
2632 p1.SetCoord(dx2, dy2, dz2);
2633 p2.SetCoord(dx2, dy2, -dz2);
2634 p3.SetCoord(-dx2, dy2, -dz2);
2635 p4.SetCoord(-dx2, dy2, dz2);
2636 axes.SetDirection(gp::DY());
2639 p1.SetCoord(dx2, dy2, -dz2);
2640 p2.SetCoord(-dx2, dy2, -dz2);
2641 p3.SetCoord(-dx2, -dy2, -dz2);
2642 p4.SetCoord(dx2, -dy2, -dz2);
2643 axes.SetDirection(-gp::DZ());
2646 p1.SetCoord(dx2, dy2, dz2);
2647 p2.SetCoord(-dx2, dy2, dz2);
2648 p3.SetCoord(-dx2, -dy2, dz2);
2649 p4.SetCoord(dx2, -dy2, dz2);
2650 axes.SetDirection(gp::DZ());
2655 /**************************************************************************/
2656 void VoxelClient_VisDrawer::DisplayVoxels(const Standard_Boolean theHighlight)
2661 glEnable(GL_DEPTH_TEST);
2664 if (myData->myBoolVoxels)
2667 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2668 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2670 glDisable(GL_LIGHTING);
2671 if (myData->myDisplay.mySmoothPoints)
2672 glEnable(GL_POINT_SMOOTH);
2674 glDisable(GL_POINT_SMOOTH);
2676 // Draw the points of voxels (center points of the voxels)
2677 // starting visualization from the side looking out from the user.
2678 setColor(myData->myDisplay.myColor, theHighlight);
2679 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2682 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2687 if (myData->myColorVoxels)
2690 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2691 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2693 glDisable(GL_LIGHTING);
2694 if (myData->myDisplay.mySmoothPoints)
2695 glEnable(GL_POINT_SMOOTH);
2697 glDisable(GL_POINT_SMOOTH);
2699 // Draw the points of voxels (center points of the voxels)
2700 // starting visualization from the side looking out from the user.
2701 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2704 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2708 // Recursive Octree Boolean voxels
2709 if (myData->myROctBoolVoxels)
2712 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2713 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2715 glDisable(GL_LIGHTING);
2716 if (myData->myDisplay.mySmoothPoints)
2717 glEnable(GL_POINT_SMOOTH);
2719 glDisable(GL_POINT_SMOOTH);
2721 // Draw the points of voxels (center points of the voxels)
2722 // starting visualization from the side looking out from the user.
2723 setColor(myData->myDisplay.myColor, theHighlight);
2724 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2727 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2731 // Shading drawn by boxes
2732 if (myData->myDisplay.myDisplayMode == Voxel_VDM_BOXES ||
2733 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES)
2735 glEnable(GL_LIGHTING);
2736 glEnable(GL_COLOR_MATERIAL);
2738 // Draw quadrangles of voxels looking to the user.
2739 setColor(myData->myDisplay.myColor, theHighlight);
2742 DisplayBoxes(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES);
2744 glDisable(GL_COLOR_MATERIAL);
2747 // Highlighted voxel
2751 /**************************************************************************/
2752 void VoxelClient_VisDrawer::DisplayPoints(const Standard_Boolean nearest)
2757 // Find the side of the cube which normal looks to (or out) the user's eye.
2759 getNormal(viewnormal);
2761 // Range of displayed data
2762 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
2763 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
2764 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
2765 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
2766 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
2767 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
2770 if (myData->myBoolVoxels)
2772 if (nearest || myData->myDisplay.myDegenerateMode)
2774 VoxelDirection vdir1, vdir2, vdir3;
2775 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2777 if (myData->myDisplay.myUsageOfGLlists)
2779 // Clean all allocated GL lists for the case of first call.
2780 if (myData->myDisplay.myBoolNearestPointsFirst)
2782 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2784 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
2786 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
2787 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
2790 myData->myDisplay.myBoolNearestPointsFirst = Standard_False;
2793 // Generate GL lists if needed.
2794 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
2796 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2797 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2798 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2799 xmin, xmax, ymin, ymax, zmin, zmax);
2802 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
2804 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2805 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2806 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2807 xmin, xmax, ymin, ymax, zmin, zmax);
2810 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
2812 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2813 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2814 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2815 xmin, xmax, ymin, ymax, zmin, zmax);
2818 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2819 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2820 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2824 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2825 xmin, xmax, ymin, ymax, zmin, zmax);
2826 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2827 xmin, xmax, ymin, ymax, zmin, zmax);
2828 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2829 xmin, xmax, ymin, ymax, zmin, zmax);
2834 if (myData->myDisplay.myUsageOfGLlists)
2836 if (myData->myDisplay.myBoolPointsFirst)
2838 // Delete previous GL list.
2839 if (myData->myDisplay.myBoolPointsList > 0)
2841 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
2842 myData->myDisplay.myBoolPointsList = -1;
2845 // Generate a new GL list
2846 genListIndex(myData->myDisplay.myBoolPointsList);
2847 glNewList(myData->myDisplay.myBoolPointsList, GL_COMPILE);
2848 VoxelDirection vdir = getVoxelDirection(viewnormal);
2849 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2850 xmin, xmax, ymin, ymax, zmin, zmax);
2853 // The first call has just been passed...
2854 myData->myDisplay.myBoolPointsFirst = Standard_False;
2856 glCallList(myData->myDisplay.myBoolPointsList);
2860 VoxelDirection vdir = getVoxelDirection(viewnormal);
2861 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2862 xmin, xmax, ymin, ymax, zmin, zmax);
2868 if (myData->myColorVoxels)
2870 if (nearest || myData->myDisplay.myDegenerateMode)
2872 VoxelDirection vdir1, vdir2, vdir3;
2873 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2875 if (myData->myDisplay.myUsageOfGLlists)
2877 // Clean all allocated GL lists for the case of first call.
2878 if (myData->myDisplay.myColorNearestPointsFirst)
2880 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2882 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
2884 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
2885 myData->myDisplay.myColorNearestPointsList[idir] = -1;
2888 myData->myDisplay.myColorNearestPointsFirst = Standard_False;
2891 // Generate GL lists if needed.
2892 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1] < 0)
2894 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2895 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2896 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2897 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2898 xmin, xmax, ymin, ymax, zmin, zmax);
2901 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2] < 0)
2903 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2904 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2905 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2906 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2907 xmin, xmax, ymin, ymax, zmin, zmax);
2910 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3] < 0)
2912 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2913 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2914 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2915 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2916 xmin, xmax, ymin, ymax, zmin, zmax);
2920 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2921 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2922 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2926 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2927 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2928 xmin, xmax, ymin, ymax, zmin, zmax);
2929 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2930 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2931 xmin, xmax, ymin, ymax, zmin, zmax);
2932 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2933 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2934 xmin, xmax, ymin, ymax, zmin, zmax);
2939 if (myData->myDisplay.myUsageOfGLlists)
2941 if (myData->myDisplay.myColorPointsFirst)
2943 // Delete previous GL list.
2944 if (myData->myDisplay.myColorPointsList > 0)
2946 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
2947 myData->myDisplay.myColorPointsList = -1;
2950 // Generate a new GL list
2951 genListIndex(myData->myDisplay.myColorPointsList);
2952 glNewList(myData->myDisplay.myColorPointsList, GL_COMPILE);
2953 VoxelDirection vdir = getVoxelDirection(viewnormal);
2954 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2955 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2956 xmin, xmax, ymin, ymax, zmin, zmax);
2959 // The first call has just been passed...
2960 myData->myDisplay.myColorPointsFirst = Standard_False;
2962 glCallList(myData->myDisplay.myColorPointsList);
2966 VoxelDirection vdir = getVoxelDirection(viewnormal);
2967 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2968 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2969 xmin, xmax, ymin, ymax, zmin, zmax);
2974 // Recursive Octree Boolean points
2975 if (myData->myROctBoolVoxels)
2977 if (nearest || myData->myDisplay.myDegenerateMode)
2979 VoxelDirection vdir1, vdir2, vdir3;
2980 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2982 if (myData->myDisplay.myUsageOfGLlists)
2984 // Clean all allocated GL lists for the case of first call.
2985 if (myData->myDisplay.myROctBoolNearestPointsFirst)
2987 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2989 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
2991 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
2992 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
2995 myData->myDisplay.myROctBoolNearestPointsFirst = Standard_False;
2998 // Generate GL lists if needed.
2999 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
3001 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3002 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
3003 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3004 xmin, xmax, ymin, ymax, zmin, zmax);
3007 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
3009 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3010 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
3011 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3012 xmin, xmax, ymin, ymax, zmin, zmax);
3015 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
3017 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3018 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
3019 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3020 xmin, xmax, ymin, ymax, zmin, zmax);
3023 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3024 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3025 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3029 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3030 xmin, xmax, ymin, ymax, zmin, zmax);
3031 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3032 xmin, xmax, ymin, ymax, zmin, zmax);
3033 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3034 xmin, xmax, ymin, ymax, zmin, zmax);
3039 if (myData->myDisplay.myUsageOfGLlists)
3041 if (myData->myDisplay.myROctBoolPointsFirst)
3043 // Delete previous GL list.
3044 if (myData->myDisplay.myROctBoolPointsList > 0)
3046 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
3047 myData->myDisplay.myROctBoolPointsList = -1;
3050 // Generate a new GL list
3051 genListIndex(myData->myDisplay.myROctBoolPointsList);
3052 glNewList(myData->myDisplay.myROctBoolPointsList, GL_COMPILE);
3053 VoxelDirection vdir = getVoxelDirection(viewnormal);
3054 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3055 xmin, xmax, ymin, ymax, zmin, zmax);
3058 // The first call has just been passed...
3059 myData->myDisplay.myROctBoolPointsFirst = Standard_False;
3061 glCallList(myData->myDisplay.myROctBoolPointsList);
3065 VoxelDirection vdir = getVoxelDirection(viewnormal);
3066 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3067 xmin, xmax, ymin, ymax, zmin, zmax);
3073 //Standard_Real seconds, cpu;
3074 //Standard_Integer minutes, hours;
3075 //timer.Show(seconds, minutes, hours, cpu);
3076 //cout<<"DisplayPoints()"<<" took "<<minutes<<" minutes, "<<seconds<<" seconds"<<endl;
3079 /**************************************************************************/
3080 void VoxelClient_VisDrawer::DisplayBoxes(const Standard_Boolean nearest)
3082 // Range of displayed data
3083 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
3084 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
3085 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
3086 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
3087 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
3088 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
3090 // Find the side of the cube which normal looks to (or out) the user's eye.
3092 getNormal(viewnormal);
3094 // Get three sides of the box looking to the user.
3095 VoxelDirection vdir1, vdir2, vdir3;
3096 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
3098 // Three quadrangles with normals looking to the user
3099 gp_Pln plane1(gp::Origin(), viewnormal);
3100 gp_Pln plane2(plane1), plane3(plane1);
3103 if (myData->myBoolVoxels &&
3104 myData->myBoolVoxels->GetNbX() &&
3105 myData->myBoolVoxels->GetNbY() &&
3106 myData->myBoolVoxels->GetNbZ())
3109 Standard_Real dx = myData->myBoolVoxels->GetXLen() / (Standard_Real) myData->myBoolVoxels->GetNbX();
3110 Standard_Real dy = myData->myBoolVoxels->GetYLen() / (Standard_Real) myData->myBoolVoxels->GetNbY();
3111 Standard_Real dz = myData->myBoolVoxels->GetZLen() / (Standard_Real) myData->myBoolVoxels->GetNbZ();
3112 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3117 // Translatethe quadrangles to the side of the voxel
3118 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3119 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3120 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3121 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3124 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3125 drawBoolQuadrangles(myData->myBoolVoxels, vdir1, plane1.Axis().Direction(),
3126 skin, p11, p12, p13, p14,
3127 xmin, xmax, ymin, ymax, zmin, zmax);
3128 drawBoolQuadrangles(myData->myBoolVoxels, vdir2, plane2.Axis().Direction(),
3129 skin, p21, p22, p23, p24,
3130 xmin, xmax, ymin, ymax, zmin, zmax);
3131 drawBoolQuadrangles(myData->myBoolVoxels, vdir3, plane3.Axis().Direction(),
3132 skin, p31, p32, p33, p34,
3133 xmin, xmax, ymin, ymax, zmin, zmax);
3135 // Color quadrangles
3136 else if (myData->myColorVoxels &&
3137 myData->myColorVoxels->GetNbX() &&
3138 myData->myColorVoxels->GetNbY() &&
3139 myData->myColorVoxels->GetNbZ())
3142 Standard_Real dx = myData->myColorVoxels->GetXLen() / (Standard_Real) myData->myColorVoxels->GetNbX();
3143 Standard_Real dy = myData->myColorVoxels->GetYLen() / (Standard_Real) myData->myColorVoxels->GetNbY();
3144 Standard_Real dz = myData->myColorVoxels->GetZLen() / (Standard_Real) myData->myColorVoxels->GetNbZ();
3145 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3150 // Translatethe quadrangles to the side of the voxel
3151 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3152 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3153 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3154 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3157 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3158 drawColorQuadrangles(myData->myColorVoxels, vdir1, plane1.Axis().Direction(), skin,
3159 myData->myDisplay.myColors, p11, p12, p13, p14,
3160 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3161 xmin, xmax, ymin, ymax, zmin, zmax);
3162 drawColorQuadrangles(myData->myColorVoxels, vdir2, plane2.Axis().Direction(), skin,
3163 myData->myDisplay.myColors, p21, p22, p23, p24,
3164 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3165 xmin, xmax, ymin, ymax, zmin, zmax);
3166 drawColorQuadrangles(myData->myColorVoxels, vdir3, plane3.Axis().Direction(), skin,
3167 myData->myDisplay.myColors, p31, p32, p33, p34,
3168 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3169 xmin, xmax, ymin, ymax, zmin, zmax);
3171 // Recursive Octree Boolean boxes
3172 else if (myData->myROctBoolVoxels &&
3173 myData->myROctBoolVoxels->GetNbX() &&
3174 myData->myROctBoolVoxels->GetNbY() &&
3175 myData->myROctBoolVoxels->GetNbZ())
3178 Standard_Real dx = myData->myROctBoolVoxels->GetXLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbX();
3179 Standard_Real dy = myData->myROctBoolVoxels->GetYLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbY();
3180 Standard_Real dz = myData->myROctBoolVoxels->GetZLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbZ();
3181 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3186 // Translatethe quadrangles to the side of the voxel
3187 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3188 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3189 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3190 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3193 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3194 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir1, plane1.Axis().Direction(),
3195 skin, p11, p12, p13, p14,
3196 xmin, xmax, ymin, ymax, zmin, zmax);
3197 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir2, plane2.Axis().Direction(),
3198 skin, p21, p22, p23, p24,
3199 xmin, xmax, ymin, ymax, zmin, zmax);
3200 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir3, plane3.Axis().Direction(),
3201 skin, p31, p32, p33, p34,
3202 xmin, xmax, ymin, ymax, zmin, zmax);
3206 /**************************************************************************/
3207 void VoxelClient_VisDrawer::DisplayTriangulation(const Standard_Boolean theHighlight)
3209 if(!myData || myData->myTriangulation.IsNull())
3212 glEnable(GL_DEPTH_TEST);
3213 glEnable(GL_LIGHTING);
3215 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
3216 const Poly_Array1OfTriangle& triangles = myData->myTriangulation->Triangles();
3217 Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
3219 Standard_Boolean compute_normals = Standard_False;
3220 if (myData->myNormalsOfNodes.IsNull())
3222 compute_normals = Standard_True;
3223 myData->myNormalsOfNodes = new TColgp_HArray1OfDir(itriangle, nb_triangles);
3225 // Release the GL list
3226 if (myData->myDisplay.myTriangulationList > 0)
3228 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
3229 myData->myDisplay.myTriangulationList = -1;
3232 // Generate a new GL list
3233 if (myData->myDisplay.myUsageOfGLlists)
3235 genListIndex(myData->myDisplay.myTriangulationList);
3236 glNewList(myData->myDisplay.myTriangulationList, GL_COMPILE);
3239 TColgp_Array1OfDir& normals = myData->myNormalsOfNodes->ChangeArray1();
3241 if (!myData->myDisplay.myUsageOfGLlists || compute_normals)
3244 glBegin(GL_TRIANGLES);
3246 Standard_Integer n1, n2, n3;
3247 Standard_Real x, y, z;
3248 for (; itriangle <= nb_triangles; itriangle++)
3250 const Poly_Triangle& t = triangles.Value(itriangle);
3253 const gp_Pnt& p1 = nodes.Value(n1);
3254 const gp_Pnt& p2 = nodes.Value(n2);
3255 const gp_Pnt& p3 = nodes.Value(n3);
3258 if (compute_normals)
3260 gp_Vec v1(p1, p2), v2(p1, p3);
3262 if (v1.SquareMagnitude() > 1.e-14)
3265 v1.SetCoord(0.0, 0.0, 1.0);
3266 normals.SetValue(itriangle, v1);
3271 normals.Value(itriangle).Coord(x, y, z);
3273 glNormal3d(x, y, z);
3277 glVertex3d(x, y, z);
3281 glVertex3d(x, y, z);
3285 glVertex3d(x, y, z);
3290 if (myData->myDisplay.myUsageOfGLlists)
3294 if (myData->myDisplay.myUsageOfGLlists)
3295 glCallList(myData->myDisplay.myTriangulationList);
3298 void VoxelClient_VisDrawer::HighlightVoxel()
3301 myData->myDisplay.myHighlightx >= 0 &&
3302 myData->myDisplay.myHighlighty >= 0 &&
3303 myData->myDisplay.myHighlightz >= 0)
3305 Standard_Integer nbx, nby, nbz;
3306 Standard_Real xlen, ylen, zlen, xc, yc, zc;
3307 Voxel_DS* ds = (Voxel_DS*) myData->myBoolVoxels;
3308 if (myData->myColorVoxels)
3309 ds = (Voxel_DS*) myData->myColorVoxels;
3310 if (myData->myROctBoolVoxels)
3311 ds = (Voxel_DS*) myData->myROctBoolVoxels;
3315 xlen = ds->GetXLen();
3316 ylen = ds->GetYLen();
3317 zlen = ds->GetZLen();
3318 ds->GetCenter(myData->myDisplay.myHighlightx,
3319 myData->myDisplay.myHighlighty,
3320 myData->myDisplay.myHighlightz,
3323 Standard_Real half_voxelx = xlen / Standard_Real(nbx) / 2.0;
3324 Standard_Real half_voxely = ylen / Standard_Real(nby) / 2.0;
3325 Standard_Real half_voxelz = zlen / Standard_Real(nbz) / 2.0;
3326 Standard_Real x1 = xc - half_voxelx, y1 = yc - half_voxely, z1 = zc - half_voxelz;
3327 Standard_Real x2 = xc + half_voxelx, y2 = yc + half_voxely, z2 = zc + half_voxelz;
3329 setColor(Quantity_NOC_BLUE1, Standard_True);
3330 setTypeOfLine(Aspect_TOL_SOLID);
3335 glVertex3d(x1, y1, z1);
3336 glVertex3d(x1, y2, z1);
3338 glVertex3d(x1, y1, z1);
3339 glVertex3d(x2, y1, z1);
3341 glVertex3d(x1, y1, z1);
3342 glVertex3d(x1, y1, z2);
3344 glVertex3d(x1, y2, z1);
3345 glVertex3d(x2, y2, z1);
3347 glVertex3d(x2, y1, z1);
3348 glVertex3d(x2, y2, z1);
3350 glVertex3d(x2, y2, z1);
3351 glVertex3d(x2, y2, z2);
3353 glVertex3d(x1, y1, z2);
3354 glVertex3d(x1, y2, z2);
3356 glVertex3d(x1, y1, z2);
3357 glVertex3d(x2, y1, z2);
3359 glVertex3d(x2, y1, z2);
3360 glVertex3d(x2, y2, z2);
3362 glVertex3d(x2, y2, z2);
3363 glVertex3d(x1, y2, z2);
3365 glVertex3d(x1, y2, z2);
3366 glVertex3d(x1, y2, z1);
3368 glVertex3d(x2, y1, z1);
3369 glVertex3d(x2, y1, z2);