1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and / or modify it
6 // under the terms of the GNU Lesser General Public version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include "VoxelClient_VisDrawer.h"
16 #include <OpenGl_GlCore11.hxx>
20 #include <Geom_Plane.hxx>
21 #include <gce_MakePln.hxx>
22 #include <Quantity_Color.hxx>
23 #include <Aspect_TypeOfLine.hxx>
24 #include <Graphic3d_CUserDraw.hxx>
26 #include <InterfaceGraphic_telem.hxx>
27 #include <OpenGl_Element.hxx>
28 #include <OpenGl_GraphicDriver.hxx>
29 #include <OpenGl_NamedStatus.hxx>
30 #include <OpenGl_Workspace.hxx>
32 /**************************************************************************/
34 class VoxelClient_VisDrawer::VisElement : public OpenGl_Element
38 VisElement (Voxel_VisData*);
39 virtual ~VisElement();
41 void EvaluateBounds (Graphic3d_BndBox4f& theMinMax);
43 void Render (const Handle(OpenGl_Workspace) &theWorkspace) const;
45 virtual void Release (OpenGl_Context* theContext)
52 VoxelClient_VisDrawer* myHandler;
60 //=======================================================================
61 //function : VisElement
62 //purpose : Constructor
63 //=======================================================================
65 VoxelClient_VisDrawer::VisElement::VisElement (Voxel_VisData* theData)
67 myHandler = new VoxelClient_VisDrawer (theData);
70 //=======================================================================
71 //function : ~VisElement
72 //purpose : Destructor
73 //=======================================================================
75 VoxelClient_VisDrawer::VisElement::~VisElement ()
80 //=======================================================================
81 //function : EvaluateBounds
83 //=======================================================================
85 void VoxelClient_VisDrawer::VisElement::EvaluateBounds
86 (Graphic3d_BndBox4f& theMinMax)
88 myHandler->EvalMinMax (theMinMax);
91 //=======================================================================
93 //purpose : display element
94 //=======================================================================
96 void VoxelClient_VisDrawer::VisElement::Render
97 (const Handle (OpenGl_Workspace) &theWorkspace) const
99 const Standard_Boolean aHl = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT);
100 myHandler->Display (aHl);
103 //=======================================================================
104 //function : VisDrawerCallBack
105 //purpose : visdrawer element create callback, adds an element to graphic
106 // driver's structure
107 //=======================================================================
109 static OpenGl_Element* VisDrawerCallBack (const Graphic3d_CUserDraw* theUserDraw)
111 if (theUserDraw == 0)
114 // Retrieve the user structure
115 Voxel_VisData* aUserData = (Voxel_VisData*) (theUserDraw->Data);
120 VoxelClient_VisDrawer::VisElement *aElem =
121 new VoxelClient_VisDrawer::VisElement (aUserData);
123 if (theUserDraw->Bounds != 0)
124 aElem->EvaluateBounds (*(theUserDraw->Bounds));
129 /**************************************************************************/
130 void VoxelClient_VisDrawer::Init (Handle(OpenGl_GraphicDriver)& theDriver)
132 static Standard_Boolean isInitializeded(Standard_False);
134 if (!isInitializeded)
136 isInitializeded = Standard_True;
137 theDriver->UserDrawCallback() = VisDrawerCallBack;
141 /**************************************************************************/
142 VoxelClient_VisDrawer::VoxelClient_VisDrawer(Voxel_VisData * theData):myData(theData)
147 /**************************************************************************/
148 VoxelClient_VisDrawer::~VoxelClient_VisDrawer()
152 // Because a pointer to the data is copied,
153 // it is possible to make an attempt to delete GL lists for
154 // a structure, which is already deleted.
155 // Such a situation may happen on close of the application.
156 // Therefore, this try / catch is used.
160 Standard_Integer idir;
165 if (myData->myDisplay.myBoolPointsList > 0)
167 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
168 myData->myDisplay.myBoolPointsList = -1;
170 for (idir = Xminus; idir <= Zplus; idir++)
172 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
174 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
175 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
180 if (myData->myDisplay.myColorPointsList > 0)
182 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
183 myData->myDisplay.myColorPointsList = -1;
185 for (idir = Xminus; idir <= Zplus; idir++)
187 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
189 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
190 myData->myDisplay.myColorNearestPointsList[idir] = -1;
195 if (myData->myDisplay.myROctBoolPointsList > 0)
197 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
198 myData->myDisplay.myROctBoolPointsList = -1;
200 for (idir = Xminus; idir <= Zplus; idir++)
202 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
204 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
205 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
210 if (myData->myDisplay.myTriangulationList > 0)
212 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
213 myData->myDisplay.myTriangulationList = -1;
223 /**************************************************************************/
224 void VoxelClient_VisDrawer::EvalMinMax(Graphic3d_BndBox4f& theMinMax) const
226 Graphic3d_Vec4 aMinPt (FLT_MAX, FLT_MAX, FLT_MAX, 1.0f);
227 Graphic3d_Vec4 aMaxPt (-FLT_MAX, -FLT_MAX, -FLT_MAX, 1.0f);
231 if(myData->myBoolVoxels)
233 Graphic3d_Vec4 aBoolVoxelsMin (RealToShortReal (myData->myBoolVoxels->GetX()),
234 RealToShortReal (myData->myBoolVoxels->GetY()),
235 RealToShortReal (myData->myBoolVoxels->GetZ()),
237 Graphic3d_Vec4 aBoolVoxelsMax (
238 RealToShortReal (myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen()),
239 RealToShortReal (myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen()),
240 RealToShortReal (myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen()),
243 aMinPt = aMinPt.cwiseMin (aBoolVoxelsMin);
244 aMaxPt = aMaxPt.cwiseMax (aBoolVoxelsMax);
246 if(myData->myColorVoxels)
248 Graphic3d_Vec4 aColorVoxelsMin (RealToShortReal (myData->myColorVoxels->GetX()),
249 RealToShortReal (myData->myColorVoxels->GetY()),
250 RealToShortReal (myData->myColorVoxels->GetZ()),
252 Graphic3d_Vec4 aColorVoxelsMax (
253 RealToShortReal (myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen()),
254 RealToShortReal (myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen()),
255 RealToShortReal (myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen()),
258 aMinPt = aMinPt.cwiseMin (aColorVoxelsMin);
259 aMaxPt = aMaxPt.cwiseMax (aColorVoxelsMax);
261 if(myData->myROctBoolVoxels)
263 Graphic3d_Vec4 aROctBoolVoxelsMin (RealToShortReal (myData->myROctBoolVoxels->GetX()),
264 RealToShortReal (myData->myROctBoolVoxels->GetY()),
265 RealToShortReal (myData->myROctBoolVoxels->GetZ()),
267 Graphic3d_Vec4 aROctBoolVoxelsMax (
268 RealToShortReal (myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen()),
269 RealToShortReal (myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen()),
270 RealToShortReal (myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen()),
273 aMinPt = aMinPt.cwiseMin (aROctBoolVoxelsMin);
274 aMaxPt = aMaxPt.cwiseMax (aROctBoolVoxelsMax);
276 if (!myData->myTriangulation.IsNull())
278 Standard_Real x, y, z;
279 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
280 Standard_Integer inode = nodes.Lower(), nb_nodes = nodes.Upper();
281 for (; inode <= nb_nodes; inode++)
283 nodes.Value(inode).Coord(x, y, z);
284 Graphic3d_Vec4 aNodeCoord (RealToShortReal (x),
288 aMinPt = aMinPt.cwiseMin (aNodeCoord);
289 aMaxPt = aMaxPt.cwiseMax (aNodeCoord);
293 if (theMinMax.IsValid())
295 theMinMax.CornerMin() = aMinPt;
296 theMinMax.CornerMax() = aMaxPt;
300 theMinMax.Add (aMinPt);
301 theMinMax.Add (aMaxPt);
305 /**************************************************************************/
306 void VoxelClient_VisDrawer::Display(const Standard_Boolean theHighlight)
310 if (myData->myBoolVoxels)
311 DisplayVoxels(theHighlight);
312 if (myData->myColorVoxels)
313 DisplayVoxels(theHighlight);
314 if (myData->myROctBoolVoxels)
315 DisplayVoxels(theHighlight);
316 if (!myData->myTriangulation.IsNull())
317 DisplayTriangulation(theHighlight);
320 // Some static method to define Open GL visual attributes
322 static void setColor(const Quantity_Color& color, const Standard_Boolean highlight)
324 static Quantity_Color highlight_color(Quantity_NOC_BLUE1);
326 glColor3f(highlight_color.Red(), highlight_color.Green(), highlight_color.Blue());
328 glColor3d(color.Red(), color.Green(), color.Blue());
332 static void setTypeOfLine(const Aspect_TypeOfLine type)
334 if(type == Aspect_TOL_SOLID)
336 glDisable(GL_LINE_STIPPLE);
340 glEnable(GL_LINE_STIPPLE);
341 if(type == Aspect_TOL_DOT)
342 glLineStipple(1, 0xCCCC);
343 else if(type == Aspect_TOL_DASH)
344 glLineStipple(1, 0xFFC0);
345 else if(type == Aspect_TOL_DOTDASH)
346 glLineStipple(1, 0xFF18);
351 static void setWidthOfLine(const Standard_Integer width)
353 glLineWidth((Standard_ShortReal) width);
356 // Normal of the view
357 static void getNormal(gp_Dir& normal)
359 Standard_Real x, y, z;
361 GLdouble model_matrix[16], proj_matrix[16];
363 glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix);
364 glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix);
365 glGetIntegerv(GL_VIEWPORT, viewport);
367 gluUnProject(viewport[0], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
369 gluUnProject(viewport[0] + viewport[2], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
371 gluUnProject(viewport[0], viewport[1] + viewport[3], 0., model_matrix, proj_matrix, viewport, &x, &y, &z);
374 gce_MakePln mkNormal(p1, p2, p3);
375 if (mkNormal.IsDone())
377 const gp_Pln& normal_plane = mkNormal.Value();
378 normal = normal_plane.Axis().Direction();
386 // Normal 2 VoxelDirection converter
387 static VoxelDirection getVoxelDirection(const gp_Dir& viewnormal)
390 Standard_Real fabsviewnormalx = fabs(viewnormal.X());
391 Standard_Real fabsviewnormaly = fabs(viewnormal.Y());
392 Standard_Real fabsviewnormalz = fabs(viewnormal.Z());
393 if (fabsviewnormalx >= fabsviewnormaly &&
394 fabsviewnormalx >= fabsviewnormalz)
396 if (viewnormal.X() > 0)
401 else if (fabsviewnormaly >= fabsviewnormalx &&
402 fabsviewnormaly >= fabsviewnormalz)
404 if (viewnormal.Y() > 0)
409 else if (fabsviewnormalz >= fabsviewnormalx &&
410 fabsviewnormalz >= fabsviewnormaly)
412 if (viewnormal.Z() > 0)
420 // Normal 2 VoxelDirection 3 converter
421 static void getVoxel3Directions(const gp_Dir& viewnormal,
422 VoxelDirection& vdir1,
423 VoxelDirection& vdir2,
424 VoxelDirection& vdir3)
426 Standard_Boolean vdir1_set = Standard_False, vdir2_set = Standard_False, vdir3_set = Standard_False;
429 Standard_Real dot = viewnormal.Dot(-gp::DX());
435 vdir1_set = Standard_True;
440 vdir2_set = Standard_True;
445 vdir3_set = Standard_True;
450 dot = viewnormal.Dot(gp::DX());
456 vdir1_set = Standard_True;
461 vdir2_set = Standard_True;
466 vdir3_set = Standard_True;
471 dot = viewnormal.Dot(-gp::DY());
477 vdir1_set = Standard_True;
482 vdir2_set = Standard_True;
487 vdir3_set = Standard_True;
492 dot = viewnormal.Dot(gp::DY());
498 vdir1_set = Standard_True;
503 vdir2_set = Standard_True;
508 vdir3_set = Standard_True;
513 dot = viewnormal.Dot(-gp::DZ());
519 vdir1_set = Standard_True;
524 vdir2_set = Standard_True;
529 vdir3_set = Standard_True;
534 dot = viewnormal.Dot(gp::DZ());
540 vdir1_set = Standard_True;
545 vdir2_set = Standard_True;
550 vdir3_set = Standard_True;
555 static Standard_Boolean CheckSize(Voxel_DS* voxels,
556 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
557 const Standard_Real xmin, const Standard_Real xmax,
558 const Standard_Real ymin, const Standard_Real ymax,
559 const Standard_Real zmin, const Standard_Real zmax,
560 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
562 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
563 if (xc < xmin || xc > xmax)
564 return Standard_False;
565 if (yc < ymin || yc > ymax)
566 return Standard_False;
567 if (zc < zmin || zc > zmax)
568 return Standard_False;
569 return Standard_True;
572 static Standard_Boolean CheckSize(Voxel_ROctBoolDS* voxels,
573 const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz,
574 const Standard_Integer i, const Standard_Integer j,
575 const Standard_Real xmin, const Standard_Real xmax,
576 const Standard_Real ymin, const Standard_Real ymax,
577 const Standard_Real zmin, const Standard_Real zmax,
578 Standard_Real& xc, Standard_Real& yc, Standard_Real& zc)
581 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
583 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
584 if (xc < xmin || xc > xmax)
585 return Standard_False;
586 if (yc < ymin || yc > ymax)
587 return Standard_False;
588 if (zc < zmin || zc > zmax)
589 return Standard_False;
590 return Standard_True;
593 static void drawBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
594 Voxel_BoolDS* voxels,
595 const Standard_Real xmin, const Standard_Real xmax,
596 const Standard_Real ymin, const Standard_Real ymax,
597 const Standard_Real zmin, const Standard_Real zmax)
599 Standard_Real xc, yc, zc;
600 Standard_Integer ix = 0, nbx = voxels->GetNbX();
601 Standard_Integer iy = 0, nby = voxels->GetNbY();
602 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
604 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
605 ymin <= DBL_MAX && ymax >= DBL_MAX &&
606 zmin <= DBL_MAX && zmax >= DBL_MAX);
607 check_size = !check_size;
614 for (iy = 0; iy < nby; iy++)
616 for (iz = 0; iz < nbz; iz++)
618 for (ix = 0; ix < nbx; ix++)
620 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
622 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
626 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
627 glVertex3d(xc, yc, zc);
638 for (iy = 0; iy < nby; iy++)
640 for (iz = 0; iz < nbz; iz++)
642 for (ix = nbx - 1; ix >= 0; ix--)
644 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
646 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
650 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
651 glVertex3d(xc, yc, zc);
662 for (ix = 0; ix < nbx; ix++)
664 for (iz = 0; iz < nbz; iz++)
666 for (iy = 0; iy < nby; iy++)
668 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
670 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
674 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
675 glVertex3d(xc, yc, zc);
686 for (ix = 0; ix < nbx; ix++)
688 for (iz = 0; iz < nbz; iz++)
690 for (iy = nby - 1; iy >= 0; iy--)
692 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
694 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
698 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
699 glVertex3d(xc, yc, zc);
710 for (ix = 0; ix < nbx; ix++)
712 for (iy = 0; iy < nby; iy++)
714 for (iz = 0; iz < nbz; iz++)
716 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
718 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
722 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
723 glVertex3d(xc, yc, zc);
734 for (ix = 0; ix < nbx; ix++)
736 for (iy = 0; iy < nby; iy++)
738 for (iz = nbz - 1; iz >= 0; iz--)
740 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
742 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
746 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
747 glVertex3d(xc, yc, zc);
760 static void drawROctBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
761 Voxel_ROctBoolDS* voxels,
762 const Standard_Real xmin, const Standard_Real xmax,
763 const Standard_Real ymin, const Standard_Real ymax,
764 const Standard_Real zmin, const Standard_Real zmax)
766 Standard_Real xc, yc, zc;
767 Standard_Integer ix = 0, nbx = voxels->GetNbX();
768 Standard_Integer iy = 0, nby = voxels->GetNbY();
769 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
770 Standard_Integer i, j;
772 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
773 ymin <= DBL_MAX && ymax >= DBL_MAX &&
774 zmin <= DBL_MAX && zmax >= DBL_MAX);
775 check_size = !check_size;
782 for (iy = 0; iy < nby; iy++)
784 for (iz = 0; iz < nbz; iz++)
786 for (ix = 0; ix < nbx; ix++)
788 switch (voxels->Deepness(ix, iy, iz))
792 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
794 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
798 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
799 glVertex3d(xc, yc, zc);
807 for (i = 0; i < 8; i++)
809 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
811 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
815 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
816 glVertex3d(xc, yc, zc);
825 for (i = 0; i < 8; i++)
827 for (j = 0; j < 8; j++)
829 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
831 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
835 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
836 glVertex3d(xc, yc, zc);
852 for (iy = 0; iy < nby; iy++)
854 for (iz = 0; iz < nbz; iz++)
856 for (ix = nbx - 1; ix >= 0; ix--)
858 switch (voxels->Deepness(ix, iy, iz))
862 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
864 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
868 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
869 glVertex3d(xc, yc, zc);
877 for (i = 0; i < 8; i++)
879 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
881 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
885 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
886 glVertex3d(xc, yc, zc);
895 for (i = 0; i < 8; i++)
897 for (j = 0; j < 8; j++)
899 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
901 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
905 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
906 glVertex3d(xc, yc, zc);
922 for (ix = 0; ix < nbx; ix++)
924 for (iz = 0; iz < nbz; iz++)
926 for (iy = 0; iy < nby; iy++)
928 switch (voxels->Deepness(ix, iy, iz))
932 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
934 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
938 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
939 glVertex3d(xc, yc, zc);
947 for (i = 0; i < 8; i++)
949 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
951 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
955 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
956 glVertex3d(xc, yc, zc);
965 for (i = 0; i < 8; i++)
967 for (j = 0; j < 8; j++)
969 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
971 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
975 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
976 glVertex3d(xc, yc, zc);
992 for (ix = 0; ix < nbx; ix++)
994 for (iz = 0; iz < nbz; iz++)
996 for (iy = nby - 1; iy >= 0; iy--)
998 switch (voxels->Deepness(ix, iy, iz))
1002 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1004 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1008 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1009 glVertex3d(xc, yc, zc);
1017 for (i = 0; i < 8; i++)
1019 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1021 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1025 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1026 glVertex3d(xc, yc, zc);
1035 for (i = 0; i < 8; i++)
1037 for (j = 0; j < 8; j++)
1039 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1041 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1045 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1046 glVertex3d(xc, yc, zc);
1062 for (ix = 0; ix < nbx; ix++)
1064 for (iy = 0; iy < nby; iy++)
1066 for (iz = 0; iz < nbz; iz++)
1068 switch (voxels->Deepness(ix, iy, iz))
1072 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1074 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1078 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1079 glVertex3d(xc, yc, zc);
1087 for (i = 0; i < 8; i++)
1089 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1091 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1095 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1096 glVertex3d(xc, yc, zc);
1105 for (i = 0; i < 8; i++)
1107 for (j = 0; j < 8; j++)
1109 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1111 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1115 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1116 glVertex3d(xc, yc, zc);
1132 for (ix = 0; ix < nbx; ix++)
1134 for (iy = 0; iy < nby; iy++)
1136 for (iz = nbz - 1; iz >= 0; iz--)
1138 switch (voxels->Deepness(ix, iy, iz))
1142 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1144 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1148 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1149 glVertex3d(xc, yc, zc);
1157 for (i = 0; i < 8; i++)
1159 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1161 Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True;
1165 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1166 glVertex3d(xc, yc, zc);
1175 for (i = 0; i < 8; i++)
1177 for (j = 0; j < 8; j++)
1179 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1181 Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1185 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1186 glVertex3d(xc, yc, zc);
1206 static void drawColorPoints(const VoxelDirection vdir, const Standard_Boolean nearest,
1207 Voxel_ColorDS* voxels, const Handle(Quantity_HArray1OfColor)& hcolors,
1208 const Standard_Byte minvalue, const Standard_Byte maxvalue,
1209 const Standard_Real xmin, const Standard_Real xmax,
1210 const Standard_Real ymin, const Standard_Real ymax,
1211 const Standard_Real zmin, const Standard_Real zmax)
1213 Standard_Real xc, yc, zc;
1214 Standard_Integer ix = 0, nbx = voxels->GetNbX();
1215 Standard_Integer iy = 0, nby = voxels->GetNbY();
1216 Standard_Integer iz = 0, nbz = voxels->GetNbZ();
1217 Standard_Byte value;
1220 const Quantity_Array1OfColor& colors = hcolors->Array1();
1222 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1223 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1224 zmin <= DBL_MAX && zmax >= DBL_MAX);
1225 check_size = !check_size;
1232 for (iy = 0; iy < nby; iy++)
1234 for (iz = 0; iz < nbz; iz++)
1236 for (ix = 0; ix < nbx; ix++)
1238 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1240 value = voxels->Get(ix, iy, iz);
1241 if (value >= minvalue && value <= maxvalue)
1244 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1245 setColor(colors.Value(value), Standard_False);
1246 glVertex3d(xc, yc, zc);
1257 for (iy = 0; iy < nby; iy++)
1259 for (iz = 0; iz < nbz; iz++)
1261 for (ix = nbx - 1; ix >= 0; ix--)
1263 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1265 value = voxels->Get(ix, iy, iz);
1266 if (value >= minvalue && value <= maxvalue)
1269 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1270 setColor(colors.Value(value), Standard_False);
1271 glVertex3d(xc, yc, zc);
1282 for (ix = 0; ix < nbx; ix++)
1284 for (iz = 0; iz < nbz; iz++)
1286 for (iy = 0; iy < nby; iy++)
1288 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1290 value = voxels->Get(ix, iy, iz);
1291 if (value >= minvalue && value <= maxvalue)
1294 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1295 setColor(colors.Value(value), Standard_False);
1296 glVertex3d(xc, yc, zc);
1307 for (ix = 0; ix < nbx; ix++)
1309 for (iz = 0; iz < nbz; iz++)
1311 for (iy = nby - 1; iy >= 0; iy--)
1313 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1315 value = voxels->Get(ix, iy, iz);
1316 if (value >= minvalue && value <= maxvalue)
1319 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1320 setColor(colors.Value(value), Standard_False);
1321 glVertex3d(xc, yc, zc);
1332 for (ix = 0; ix < nbx; ix++)
1334 for (iy = 0; iy < nby; iy++)
1336 for (iz = 0; iz < nbz; iz++)
1338 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1340 value = voxels->Get(ix, iy, iz);
1341 if (value >= minvalue && value <= maxvalue)
1344 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1345 setColor(colors.Value(value), Standard_False);
1346 glVertex3d(xc, yc, zc);
1357 for (ix = 0; ix < nbx; ix++)
1359 for (iy = 0; iy < nby; iy++)
1361 for (iz = nbz - 1; iz >= 0; iz--)
1363 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1365 value = voxels->Get(ix, iy, iz);
1366 if (value >= minvalue && value <= maxvalue)
1369 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1370 setColor(colors.Value(value), Standard_False);
1371 glVertex3d(xc, yc, zc);
1384 static void drawBoolQuadrangles(Voxel_BoolDS* voxels, const VoxelDirection vdir,
1385 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1386 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1387 const Standard_Real xmin, const Standard_Real xmax,
1388 const Standard_Real ymin, const Standard_Real ymax,
1389 const Standard_Real zmin, const Standard_Real zmax)
1392 gp_Pnt pc1, pc2, pc3, pc4;
1393 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1394 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
1397 viewnormal.Coord(xn, yn, zn);
1399 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1400 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1401 zmin <= DBL_MAX && zmax >= DBL_MAX);
1402 check_size = !check_size;
1409 for (iy = 0; iy < nby; iy++)
1411 for (iz = 0; iz < nbz; iz++)
1413 for (ix = 0; ix < nbx; ix++)
1415 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1417 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1420 // Define translation vector
1422 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1423 vc.SetCoord(xc, yc, zc);
1426 pc1 = p1.Translated(vc);
1427 pc2 = p2.Translated(vc);
1428 pc3 = p3.Translated(vc);
1429 pc4 = p4.Translated(vc);
1432 glNormal3d(xn, yn, zn);
1433 pc1.Coord(xc, yc, zc);
1434 glVertex3d(xc, yc, zc);
1435 pc2.Coord(xc, yc, zc);
1436 glVertex3d(xc, yc, zc);
1437 pc3.Coord(xc, yc, zc);
1438 glVertex3d(xc, yc, zc);
1439 pc4.Coord(xc, yc, zc);
1440 glVertex3d(xc, yc, zc);
1452 for (iy = 0; iy < nby; iy++)
1454 for (iz = 0; iz < nbz; iz++)
1456 for (ix = nbx - 1; ix >= 0; ix--)
1458 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1460 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1463 // Define translation vector
1465 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1466 vc.SetCoord(xc, yc, zc);
1469 pc1 = p1.Translated(vc);
1470 pc2 = p2.Translated(vc);
1471 pc3 = p3.Translated(vc);
1472 pc4 = p4.Translated(vc);
1475 glNormal3d(xn, yn, zn);
1476 pc1.Coord(xc, yc, zc);
1477 glVertex3d(xc, yc, zc);
1478 pc2.Coord(xc, yc, zc);
1479 glVertex3d(xc, yc, zc);
1480 pc3.Coord(xc, yc, zc);
1481 glVertex3d(xc, yc, zc);
1482 pc4.Coord(xc, yc, zc);
1483 glVertex3d(xc, yc, zc);
1495 for (ix = 0; ix < nbx; ix++)
1497 for (iz = 0; iz < nbz; iz++)
1499 for (iy = 0; iy < nby; iy++)
1501 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1503 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1506 // Define translation vector
1508 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1509 vc.SetCoord(xc, yc, zc);
1512 pc1 = p1.Translated(vc);
1513 pc2 = p2.Translated(vc);
1514 pc3 = p3.Translated(vc);
1515 pc4 = p4.Translated(vc);
1518 glNormal3d(xn, yn, zn);
1519 pc1.Coord(xc, yc, zc);
1520 glVertex3d(xc, yc, zc);
1521 pc2.Coord(xc, yc, zc);
1522 glVertex3d(xc, yc, zc);
1523 pc3.Coord(xc, yc, zc);
1524 glVertex3d(xc, yc, zc);
1525 pc4.Coord(xc, yc, zc);
1526 glVertex3d(xc, yc, zc);
1538 for (ix = 0; ix < nbx; ix++)
1540 for (iz = 0; iz < nbz; iz++)
1542 for (iy = nby - 1; iy >= 0; iy--)
1544 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1546 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1549 // Define translation vector
1551 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1552 vc.SetCoord(xc, yc, zc);
1555 pc1 = p1.Translated(vc);
1556 pc2 = p2.Translated(vc);
1557 pc3 = p3.Translated(vc);
1558 pc4 = p4.Translated(vc);
1561 glNormal3d(xn, yn, zn);
1562 pc1.Coord(xc, yc, zc);
1563 glVertex3d(xc, yc, zc);
1564 pc2.Coord(xc, yc, zc);
1565 glVertex3d(xc, yc, zc);
1566 pc3.Coord(xc, yc, zc);
1567 glVertex3d(xc, yc, zc);
1568 pc4.Coord(xc, yc, zc);
1569 glVertex3d(xc, yc, zc);
1581 for (ix = 0; ix < nbx; ix++)
1583 for (iy = 0; iy < nby; iy++)
1585 for (iz = 0; iz < nbz; iz++)
1587 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1589 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1592 // Define translation vector
1594 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1595 vc.SetCoord(xc, yc, zc);
1598 pc1 = p1.Translated(vc);
1599 pc2 = p2.Translated(vc);
1600 pc3 = p3.Translated(vc);
1601 pc4 = p4.Translated(vc);
1604 glNormal3d(xn, yn, zn);
1605 pc1.Coord(xc, yc, zc);
1606 glVertex3d(xc, yc, zc);
1607 pc2.Coord(xc, yc, zc);
1608 glVertex3d(xc, yc, zc);
1609 pc3.Coord(xc, yc, zc);
1610 glVertex3d(xc, yc, zc);
1611 pc4.Coord(xc, yc, zc);
1612 glVertex3d(xc, yc, zc);
1624 for (ix = 0; ix < nbx; ix++)
1626 for (iy = 0; iy < nby; iy++)
1628 for (iz = nbz - 1; iz >= 0; iz--)
1630 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1632 Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True;
1635 // Define translation vector
1637 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
1638 vc.SetCoord(xc, yc, zc);
1641 pc1 = p1.Translated(vc);
1642 pc2 = p2.Translated(vc);
1643 pc3 = p3.Translated(vc);
1644 pc4 = p4.Translated(vc);
1647 glNormal3d(xn, yn, zn);
1648 pc1.Coord(xc, yc, zc);
1649 glVertex3d(xc, yc, zc);
1650 pc2.Coord(xc, yc, zc);
1651 glVertex3d(xc, yc, zc);
1652 pc3.Coord(xc, yc, zc);
1653 glVertex3d(xc, yc, zc);
1654 pc4.Coord(xc, yc, zc);
1655 glVertex3d(xc, yc, zc);
1669 static void drawROctBoolQuadrangles(Voxel_ROctBoolDS* voxels, const VoxelDirection vdir,
1670 const gp_Dir& viewnormal, const Standard_Boolean nearest,
1671 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
1672 const Standard_Real xmin, const Standard_Real xmax,
1673 const Standard_Real ymin, const Standard_Real ymax,
1674 const Standard_Real zmin, const Standard_Real zmax)
1677 gp_Pnt pc1, pc2, pc3, pc4;
1678 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0;
1679 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(), i, j, deepness;
1682 viewnormal.Coord(xn, yn, zn);
1684 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
1685 ymin <= DBL_MAX && ymax >= DBL_MAX &&
1686 zmin <= DBL_MAX && zmax >= DBL_MAX);
1687 check_size = !check_size;
1694 for (iy = 0; iy < nby; iy++)
1696 for (iz = 0; iz < nbz; iz++)
1698 for (ix = 0; ix < nbx; ix++)
1700 deepness = voxels->Deepness(ix, iy, iz);
1701 for (i = 0; i < 8; i++)
1703 for (j = 0; j < 8; j++)
1705 if (deepness == 0 && j)
1710 if (deepness == 1 && j)
1714 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1717 else if (deepness == 1)
1719 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1722 else if (deepness == 2)
1724 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1728 Standard_Boolean value;
1732 value = voxels->Get(ix, iy, iz) == Standard_True;
1735 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1738 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1744 // Define translation vector
1750 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1753 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1756 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1760 vc.SetCoord(xc, yc, zc);
1763 pc1 = p1.Translated(vc);
1764 pc2 = p2.Translated(vc);
1765 pc3 = p3.Translated(vc);
1766 pc4 = p4.Translated(vc);
1769 glNormal3d(xn, yn, zn);
1770 pc1.Coord(xc, yc, zc);
1771 glVertex3d(xc, yc, zc);
1772 pc2.Coord(xc, yc, zc);
1773 glVertex3d(xc, yc, zc);
1774 pc3.Coord(xc, yc, zc);
1775 glVertex3d(xc, yc, zc);
1776 pc4.Coord(xc, yc, zc);
1777 glVertex3d(xc, yc, zc);
1791 for (iy = 0; iy < nby; iy++)
1793 for (iz = 0; iz < nbz; iz++)
1795 for (ix = nbx - 1; ix >= 0; ix--)
1797 deepness = voxels->Deepness(ix, iy, iz);
1798 for (i = 0; i < 8; i++)
1800 for (j = 0; j < 8; j++)
1802 if (deepness == 0 && j)
1807 if (deepness == 1 && j)
1811 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1814 else if (deepness == 1)
1816 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1819 else if (deepness == 2)
1821 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1825 Standard_Boolean value;
1829 value = voxels->Get(ix, iy, iz) == Standard_True;
1832 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1835 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1841 // Define translation vector
1847 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1850 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1853 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1857 vc.SetCoord(xc, yc, zc);
1860 pc1 = p1.Translated(vc);
1861 pc2 = p2.Translated(vc);
1862 pc3 = p3.Translated(vc);
1863 pc4 = p4.Translated(vc);
1866 glNormal3d(xn, yn, zn);
1867 pc1.Coord(xc, yc, zc);
1868 glVertex3d(xc, yc, zc);
1869 pc2.Coord(xc, yc, zc);
1870 glVertex3d(xc, yc, zc);
1871 pc3.Coord(xc, yc, zc);
1872 glVertex3d(xc, yc, zc);
1873 pc4.Coord(xc, yc, zc);
1874 glVertex3d(xc, yc, zc);
1888 for (ix = 0; ix < nbx; ix++)
1890 for (iz = 0; iz < nbz; iz++)
1892 for (iy = 0; iy < nby; iy++)
1894 deepness = voxels->Deepness(ix, iy, iz);
1895 for (i = 0; i < 8; i++)
1897 for (j = 0; j < 8; j++)
1899 if (deepness == 0 && j)
1904 if (deepness == 1 && j)
1908 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1911 else if (deepness == 1)
1913 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1916 else if (deepness == 2)
1918 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
1922 Standard_Boolean value;
1926 value = voxels->Get(ix, iy, iz) == Standard_True;
1929 value = voxels->Get(ix, iy, iz, i) == Standard_True;
1932 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
1938 // Define translation vector
1944 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
1947 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
1950 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
1954 vc.SetCoord(xc, yc, zc);
1957 pc1 = p1.Translated(vc);
1958 pc2 = p2.Translated(vc);
1959 pc3 = p3.Translated(vc);
1960 pc4 = p4.Translated(vc);
1963 glNormal3d(xn, yn, zn);
1964 pc1.Coord(xc, yc, zc);
1965 glVertex3d(xc, yc, zc);
1966 pc2.Coord(xc, yc, zc);
1967 glVertex3d(xc, yc, zc);
1968 pc3.Coord(xc, yc, zc);
1969 glVertex3d(xc, yc, zc);
1970 pc4.Coord(xc, yc, zc);
1971 glVertex3d(xc, yc, zc);
1985 for (ix = 0; ix < nbx; ix++)
1987 for (iz = 0; iz < nbz; iz++)
1989 for (iy = nby - 1; iy >= 0; iy--)
1991 deepness = voxels->Deepness(ix, iy, iz);
1992 for (i = 0; i < 8; i++)
1994 for (j = 0; j < 8; j++)
1996 if (deepness == 0 && j)
2001 if (deepness == 1 && j)
2005 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2008 else if (deepness == 1)
2010 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2013 else if (deepness == 2)
2015 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2019 Standard_Boolean value;
2023 value = voxels->Get(ix, iy, iz) == Standard_True;
2026 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2029 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2035 // Define translation vector
2041 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2044 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2047 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2051 vc.SetCoord(xc, yc, zc);
2054 pc1 = p1.Translated(vc);
2055 pc2 = p2.Translated(vc);
2056 pc3 = p3.Translated(vc);
2057 pc4 = p4.Translated(vc);
2060 glNormal3d(xn, yn, zn);
2061 pc1.Coord(xc, yc, zc);
2062 glVertex3d(xc, yc, zc);
2063 pc2.Coord(xc, yc, zc);
2064 glVertex3d(xc, yc, zc);
2065 pc3.Coord(xc, yc, zc);
2066 glVertex3d(xc, yc, zc);
2067 pc4.Coord(xc, yc, zc);
2068 glVertex3d(xc, yc, zc);
2082 for (ix = 0; ix < nbx; ix++)
2084 for (iy = 0; iy < nby; iy++)
2086 for (iz = 0; iz < nbz; iz++)
2088 deepness = voxels->Deepness(ix, iy, iz);
2089 for (i = 0; i < 8; i++)
2091 for (j = 0; j < 8; j++)
2093 if (deepness == 0 && j)
2098 if (deepness == 1 && j)
2102 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2105 else if (deepness == 1)
2107 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2110 else if (deepness == 2)
2112 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2116 Standard_Boolean value;
2120 value = voxels->Get(ix, iy, iz) == Standard_True;
2123 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2126 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2132 // Define translation vector
2138 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2141 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2144 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2148 vc.SetCoord(xc, yc, zc);
2151 pc1 = p1.Translated(vc);
2152 pc2 = p2.Translated(vc);
2153 pc3 = p3.Translated(vc);
2154 pc4 = p4.Translated(vc);
2157 glNormal3d(xn, yn, zn);
2158 pc1.Coord(xc, yc, zc);
2159 glVertex3d(xc, yc, zc);
2160 pc2.Coord(xc, yc, zc);
2161 glVertex3d(xc, yc, zc);
2162 pc3.Coord(xc, yc, zc);
2163 glVertex3d(xc, yc, zc);
2164 pc4.Coord(xc, yc, zc);
2165 glVertex3d(xc, yc, zc);
2179 for (ix = 0; ix < nbx; ix++)
2181 for (iy = 0; iy < nby; iy++)
2183 for (iz = nbz - 1; iz >= 0; iz--)
2185 deepness = voxels->Deepness(ix, iy, iz);
2186 for (i = 0; i < 8; i++)
2188 for (j = 0; j < 8; j++)
2190 if (deepness == 0 && j)
2195 if (deepness == 1 && j)
2199 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2202 else if (deepness == 1)
2204 if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2207 else if (deepness == 2)
2209 if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2213 Standard_Boolean value;
2217 value = voxels->Get(ix, iy, iz) == Standard_True;
2220 value = voxels->Get(ix, iy, iz, i) == Standard_True;
2223 value = voxels->Get(ix, iy, iz, i, j) == Standard_True;
2229 // Define translation vector
2235 ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc);
2238 voxels->GetCenter(ix, iy, iz, i, xc, yc, zc);
2241 voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
2245 vc.SetCoord(xc, yc, zc);
2248 pc1 = p1.Translated(vc);
2249 pc2 = p2.Translated(vc);
2250 pc3 = p3.Translated(vc);
2251 pc4 = p4.Translated(vc);
2254 glNormal3d(xn, yn, zn);
2255 pc1.Coord(xc, yc, zc);
2256 glVertex3d(xc, yc, zc);
2257 pc2.Coord(xc, yc, zc);
2258 glVertex3d(xc, yc, zc);
2259 pc3.Coord(xc, yc, zc);
2260 glVertex3d(xc, yc, zc);
2261 pc4.Coord(xc, yc, zc);
2262 glVertex3d(xc, yc, zc);
2280 static void drawColorQuadrangles(Voxel_ColorDS* voxels, const VoxelDirection vdir,
2281 const gp_Dir& viewnormal, const Standard_Boolean nearest,
2282 const Handle(Quantity_HArray1OfColor)& hcolors,
2283 const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4,
2284 const Standard_Byte minvalue, const Standard_Byte maxvalue,
2285 const Standard_Real xmin, const Standard_Real xmax,
2286 const Standard_Real ymin, const Standard_Real ymax,
2287 const Standard_Real zmin, const Standard_Real zmax)
2290 gp_Pnt pc1, pc2, pc3, pc4;
2291 Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 0.0;
2292 Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ();
2293 Standard_Byte value;
2296 //viewnormal.Coord(xn, yn, zn);
2297 glNormal3d(xn, yn, zn);
2300 const Quantity_Array1OfColor& colors = hcolors->Array1();
2302 Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX &&
2303 ymin <= DBL_MAX && ymax >= DBL_MAX &&
2304 zmin <= DBL_MAX && zmax >= DBL_MAX);
2305 check_size = !check_size;
2312 for (iy = 0; iy < nby; iy++)
2314 for (iz = 0; iz < nbz; iz++)
2316 for (ix = 0; ix < nbx; ix++)
2318 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2320 value = voxels->Get(ix, iy, iz);
2321 if (value >= minvalue && value <= maxvalue)
2323 // Define translation vector
2325 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2326 vc.SetCoord(xc, yc, zc);
2329 pc1 = p1.Translated(vc);
2330 pc2 = p2.Translated(vc);
2331 pc3 = p3.Translated(vc);
2332 pc4 = p4.Translated(vc);
2335 setColor(colors.Value(value), Standard_False);
2338 //glNormal3d(xn, yn, zn);
2339 pc1.Coord(xc, yc, zc);
2340 glVertex3d(xc, yc, zc);
2341 pc2.Coord(xc, yc, zc);
2342 glVertex3d(xc, yc, zc);
2343 pc3.Coord(xc, yc, zc);
2344 glVertex3d(xc, yc, zc);
2345 pc4.Coord(xc, yc, zc);
2346 glVertex3d(xc, yc, zc);
2358 for (iy = 0; iy < nby; iy++)
2360 for (iz = 0; iz < nbz; iz++)
2362 for (ix = nbx - 1; ix >= 0; ix--)
2364 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2366 value = voxels->Get(ix, iy, iz);
2367 if (value >= minvalue && value <= maxvalue)
2369 // Define translation vector
2371 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2372 vc.SetCoord(xc, yc, zc);
2375 pc1 = p1.Translated(vc);
2376 pc2 = p2.Translated(vc);
2377 pc3 = p3.Translated(vc);
2378 pc4 = p4.Translated(vc);
2381 setColor(colors.Value(value), Standard_False);
2384 //glNormal3d(xn, yn, zn);
2385 pc1.Coord(xc, yc, zc);
2386 glVertex3d(xc, yc, zc);
2387 pc2.Coord(xc, yc, zc);
2388 glVertex3d(xc, yc, zc);
2389 pc3.Coord(xc, yc, zc);
2390 glVertex3d(xc, yc, zc);
2391 pc4.Coord(xc, yc, zc);
2392 glVertex3d(xc, yc, zc);
2404 for (ix = 0; ix < nbx; ix++)
2406 for (iz = 0; iz < nbz; iz++)
2408 for (iy = 0; iy < nby; iy++)
2410 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2412 value = voxels->Get(ix, iy, iz);
2413 if (value >= minvalue && value <= maxvalue)
2415 // Define translation vector
2417 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2418 vc.SetCoord(xc, yc, zc);
2421 pc1 = p1.Translated(vc);
2422 pc2 = p2.Translated(vc);
2423 pc3 = p3.Translated(vc);
2424 pc4 = p4.Translated(vc);
2427 setColor(colors.Value(value), Standard_False);
2430 //glNormal3d(xn, yn, zn);
2431 pc1.Coord(xc, yc, zc);
2432 glVertex3d(xc, yc, zc);
2433 pc2.Coord(xc, yc, zc);
2434 glVertex3d(xc, yc, zc);
2435 pc3.Coord(xc, yc, zc);
2436 glVertex3d(xc, yc, zc);
2437 pc4.Coord(xc, yc, zc);
2438 glVertex3d(xc, yc, zc);
2450 for (ix = 0; ix < nbx; ix++)
2452 for (iz = 0; iz < nbz; iz++)
2454 for (iy = nby - 1; iy >= 0; iy--)
2456 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2458 value = voxels->Get(ix, iy, iz);
2459 if (value >= minvalue && value <= maxvalue)
2461 // Define translation vector
2463 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2464 vc.SetCoord(xc, yc, zc);
2467 pc1 = p1.Translated(vc);
2468 pc2 = p2.Translated(vc);
2469 pc3 = p3.Translated(vc);
2470 pc4 = p4.Translated(vc);
2473 setColor(colors.Value(value), Standard_False);
2476 //glNormal3d(xn, yn, zn);
2477 pc1.Coord(xc, yc, zc);
2478 glVertex3d(xc, yc, zc);
2479 pc2.Coord(xc, yc, zc);
2480 glVertex3d(xc, yc, zc);
2481 pc3.Coord(xc, yc, zc);
2482 glVertex3d(xc, yc, zc);
2483 pc4.Coord(xc, yc, zc);
2484 glVertex3d(xc, yc, zc);
2496 for (ix = 0; ix < nbx; ix++)
2498 for (iy = 0; iy < nby; iy++)
2500 for (iz = 0; iz < nbz; iz++)
2502 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2504 value = voxels->Get(ix, iy, iz);
2505 if (value >= minvalue && value <= maxvalue)
2507 // Define translation vector
2509 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2510 vc.SetCoord(xc, yc, zc);
2513 pc1 = p1.Translated(vc);
2514 pc2 = p2.Translated(vc);
2515 pc3 = p3.Translated(vc);
2516 pc4 = p4.Translated(vc);
2519 setColor(colors.Value(value), Standard_False);
2522 //glNormal3d(xn, yn, zn);
2523 pc1.Coord(xc, yc, zc);
2524 glVertex3d(xc, yc, zc);
2525 pc2.Coord(xc, yc, zc);
2526 glVertex3d(xc, yc, zc);
2527 pc3.Coord(xc, yc, zc);
2528 glVertex3d(xc, yc, zc);
2529 pc4.Coord(xc, yc, zc);
2530 glVertex3d(xc, yc, zc);
2542 for (ix = 0; ix < nbx; ix++)
2544 for (iy = 0; iy < nby; iy++)
2546 for (iz = nbz - 1; iz >= 0; iz--)
2548 if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc))
2550 value = voxels->Get(ix, iy, iz);
2551 if (value >= minvalue && value <= maxvalue)
2553 // Define translation vector
2555 voxels->GetCenter(ix, iy, iz, xc, yc, zc);
2556 vc.SetCoord(xc, yc, zc);
2559 pc1 = p1.Translated(vc);
2560 pc2 = p2.Translated(vc);
2561 pc3 = p3.Translated(vc);
2562 pc4 = p4.Translated(vc);
2565 setColor(colors.Value(value), Standard_False);
2568 //glNormal3d(xn, yn, zn);
2569 pc1.Coord(xc, yc, zc);
2570 glVertex3d(xc, yc, zc);
2571 pc2.Coord(xc, yc, zc);
2572 glVertex3d(xc, yc, zc);
2573 pc3.Coord(xc, yc, zc);
2574 glVertex3d(xc, yc, zc);
2575 pc4.Coord(xc, yc, zc);
2576 glVertex3d(xc, yc, zc);
2590 static void genListIndex(GLint& index)
2593 while (++i <= INT_MAX)
2603 static void setPlaneNormal(const VoxelDirection& dir,
2604 const Standard_Real dx, const Standard_Real dy, const Standard_Real dz,
2605 gp_Pln& plane, gp_Pnt& p1, gp_Pnt& p2, gp_Pnt& p3, gp_Pnt& p4)
2607 gp_Ax3 axes = plane.Position();
2608 Standard_Real dx2 = 0.5 * dx, dy2 = 0.5 * dy, dz2 = 0.5 * dz;
2612 p1.SetCoord(-dx2, -dy2, dz2);
2613 p2.SetCoord(-dx2, -dy2, -dz2);
2614 p3.SetCoord(-dx2, dy2, -dz2);
2615 p4.SetCoord(-dx2, dy2, dz2);
2616 axes.SetDirection(-gp::DX());
2619 p1.SetCoord(dx2, -dy2, dz2);
2620 p2.SetCoord(dx2, -dy2, -dz2);
2621 p3.SetCoord(dx2, dy2, -dz2);
2622 p4.SetCoord(dx2, dy2, dz2);
2623 axes.SetDirection(gp::DX());
2626 p1.SetCoord(dx2, -dy2, dz2);
2627 p2.SetCoord(dx2, -dy2, -dz2);
2628 p3.SetCoord(-dx2, -dy2, -dz2);
2629 p4.SetCoord(-dx2, -dy2, dz2);
2630 axes.SetDirection(-gp::DY());
2633 p1.SetCoord(dx2, dy2, dz2);
2634 p2.SetCoord(dx2, dy2, -dz2);
2635 p3.SetCoord(-dx2, dy2, -dz2);
2636 p4.SetCoord(-dx2, dy2, dz2);
2637 axes.SetDirection(gp::DY());
2640 p1.SetCoord(dx2, dy2, -dz2);
2641 p2.SetCoord(-dx2, dy2, -dz2);
2642 p3.SetCoord(-dx2, -dy2, -dz2);
2643 p4.SetCoord(dx2, -dy2, -dz2);
2644 axes.SetDirection(-gp::DZ());
2647 p1.SetCoord(dx2, dy2, dz2);
2648 p2.SetCoord(-dx2, dy2, dz2);
2649 p3.SetCoord(-dx2, -dy2, dz2);
2650 p4.SetCoord(dx2, -dy2, dz2);
2651 axes.SetDirection(gp::DZ());
2656 /**************************************************************************/
2657 void VoxelClient_VisDrawer::DisplayVoxels(const Standard_Boolean theHighlight)
2662 glEnable(GL_DEPTH_TEST);
2665 if (myData->myBoolVoxels)
2668 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2669 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2671 glDisable(GL_LIGHTING);
2672 if (myData->myDisplay.mySmoothPoints)
2673 glEnable(GL_POINT_SMOOTH);
2675 glDisable(GL_POINT_SMOOTH);
2677 // Draw the points of voxels (center points of the voxels)
2678 // starting visualization from the side looking out from the user.
2679 setColor(myData->myDisplay.myColor, theHighlight);
2680 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2683 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2688 if (myData->myColorVoxels)
2691 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2692 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2694 glDisable(GL_LIGHTING);
2695 if (myData->myDisplay.mySmoothPoints)
2696 glEnable(GL_POINT_SMOOTH);
2698 glDisable(GL_POINT_SMOOTH);
2700 // Draw the points of voxels (center points of the voxels)
2701 // starting visualization from the side looking out from the user.
2702 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2705 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2709 // Recursive Octree Boolean voxels
2710 if (myData->myROctBoolVoxels)
2713 if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS ||
2714 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS)
2716 glDisable(GL_LIGHTING);
2717 if (myData->myDisplay.mySmoothPoints)
2718 glEnable(GL_POINT_SMOOTH);
2720 glDisable(GL_POINT_SMOOTH);
2722 // Draw the points of voxels (center points of the voxels)
2723 // starting visualization from the side looking out from the user.
2724 setColor(myData->myDisplay.myColor, theHighlight);
2725 glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize);
2728 DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS);
2732 // Shading drawn by boxes
2733 if (myData->myDisplay.myDisplayMode == Voxel_VDM_BOXES ||
2734 myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES)
2736 glEnable(GL_LIGHTING);
2737 glEnable(GL_COLOR_MATERIAL);
2739 // Draw quadrangles of voxels looking to the user.
2740 setColor(myData->myDisplay.myColor, theHighlight);
2743 DisplayBoxes(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES);
2745 glDisable(GL_COLOR_MATERIAL);
2748 // Highlighted voxel
2752 /**************************************************************************/
2753 void VoxelClient_VisDrawer::DisplayPoints(const Standard_Boolean nearest)
2758 // Find the side of the cube which normal looks to (or out) the user's eye.
2760 getNormal(viewnormal);
2762 // Range of displayed data
2763 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
2764 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
2765 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
2766 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
2767 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
2768 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
2771 if (myData->myBoolVoxels)
2773 if (nearest || myData->myDisplay.myDegenerateMode)
2775 VoxelDirection vdir1, vdir2, vdir3;
2776 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2778 if (myData->myDisplay.myUsageOfGLlists)
2780 // Clean all allocated GL lists for the case of first call.
2781 if (myData->myDisplay.myBoolNearestPointsFirst)
2783 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2785 if (myData->myDisplay.myBoolNearestPointsList[idir] > 0)
2787 glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1);
2788 myData->myDisplay.myBoolNearestPointsList[idir] = -1;
2791 myData->myDisplay.myBoolNearestPointsFirst = Standard_False;
2794 // Generate GL lists if needed.
2795 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
2797 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2798 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2799 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2800 xmin, xmax, ymin, ymax, zmin, zmax);
2803 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
2805 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2806 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2807 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2808 xmin, xmax, ymin, ymax, zmin, zmax);
2811 if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
2813 genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2814 glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2815 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2816 xmin, xmax, ymin, ymax, zmin, zmax);
2819 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]);
2820 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]);
2821 glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]);
2825 drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels,
2826 xmin, xmax, ymin, ymax, zmin, zmax);
2827 drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels,
2828 xmin, xmax, ymin, ymax, zmin, zmax);
2829 drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels,
2830 xmin, xmax, ymin, ymax, zmin, zmax);
2835 if (myData->myDisplay.myUsageOfGLlists)
2837 if (myData->myDisplay.myBoolPointsFirst)
2839 // Delete previous GL list.
2840 if (myData->myDisplay.myBoolPointsList > 0)
2842 glDeleteLists(myData->myDisplay.myBoolPointsList, 1);
2843 myData->myDisplay.myBoolPointsList = -1;
2846 // Generate a new GL list
2847 genListIndex(myData->myDisplay.myBoolPointsList);
2848 glNewList(myData->myDisplay.myBoolPointsList, GL_COMPILE);
2849 VoxelDirection vdir = getVoxelDirection(viewnormal);
2850 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2851 xmin, xmax, ymin, ymax, zmin, zmax);
2854 // The first call has just been passed...
2855 myData->myDisplay.myBoolPointsFirst = Standard_False;
2857 glCallList(myData->myDisplay.myBoolPointsList);
2861 VoxelDirection vdir = getVoxelDirection(viewnormal);
2862 drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels,
2863 xmin, xmax, ymin, ymax, zmin, zmax);
2869 if (myData->myColorVoxels)
2871 if (nearest || myData->myDisplay.myDegenerateMode)
2873 VoxelDirection vdir1, vdir2, vdir3;
2874 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2876 if (myData->myDisplay.myUsageOfGLlists)
2878 // Clean all allocated GL lists for the case of first call.
2879 if (myData->myDisplay.myColorNearestPointsFirst)
2881 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2883 if (myData->myDisplay.myColorNearestPointsList[idir] > 0)
2885 glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1);
2886 myData->myDisplay.myColorNearestPointsList[idir] = -1;
2889 myData->myDisplay.myColorNearestPointsFirst = Standard_False;
2892 // Generate GL lists if needed.
2893 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1] < 0)
2895 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2896 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
2897 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2898 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2899 xmin, xmax, ymin, ymax, zmin, zmax);
2902 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2] < 0)
2904 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2905 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
2906 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2907 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2908 xmin, xmax, ymin, ymax, zmin, zmax);
2911 if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3] < 0)
2913 genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2914 glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
2915 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2916 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2917 xmin, xmax, ymin, ymax, zmin, zmax);
2921 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]);
2922 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]);
2923 glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]);
2927 drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2928 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2929 xmin, xmax, ymin, ymax, zmin, zmax);
2930 drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2931 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2932 xmin, xmax, ymin, ymax, zmin, zmax);
2933 drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors,
2934 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2935 xmin, xmax, ymin, ymax, zmin, zmax);
2940 if (myData->myDisplay.myUsageOfGLlists)
2942 if (myData->myDisplay.myColorPointsFirst)
2944 // Delete previous GL list.
2945 if (myData->myDisplay.myColorPointsList > 0)
2947 glDeleteLists(myData->myDisplay.myColorPointsList, 1);
2948 myData->myDisplay.myColorPointsList = -1;
2951 // Generate a new GL list
2952 genListIndex(myData->myDisplay.myColorPointsList);
2953 glNewList(myData->myDisplay.myColorPointsList, GL_COMPILE);
2954 VoxelDirection vdir = getVoxelDirection(viewnormal);
2955 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2956 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2957 xmin, xmax, ymin, ymax, zmin, zmax);
2960 // The first call has just been passed...
2961 myData->myDisplay.myColorPointsFirst = Standard_False;
2963 glCallList(myData->myDisplay.myColorPointsList);
2967 VoxelDirection vdir = getVoxelDirection(viewnormal);
2968 drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors,
2969 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
2970 xmin, xmax, ymin, ymax, zmin, zmax);
2975 // Recursive Octree Boolean points
2976 if (myData->myROctBoolVoxels)
2978 if (nearest || myData->myDisplay.myDegenerateMode)
2980 VoxelDirection vdir1, vdir2, vdir3;
2981 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
2983 if (myData->myDisplay.myUsageOfGLlists)
2985 // Clean all allocated GL lists for the case of first call.
2986 if (myData->myDisplay.myROctBoolNearestPointsFirst)
2988 for (Standard_Integer idir = Xminus; idir <= Zplus; idir++)
2990 if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0)
2992 glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1);
2993 myData->myDisplay.myROctBoolNearestPointsList[idir] = -1;
2996 myData->myDisplay.myROctBoolNearestPointsFirst = Standard_False;
2999 // Generate GL lists if needed.
3000 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1] < 0)
3002 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3003 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE);
3004 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3005 xmin, xmax, ymin, ymax, zmin, zmax);
3008 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2] < 0)
3010 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3011 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE);
3012 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3013 xmin, xmax, ymin, ymax, zmin, zmax);
3016 if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3] < 0)
3018 genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3019 glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE);
3020 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3021 xmin, xmax, ymin, ymax, zmin, zmax);
3024 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]);
3025 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]);
3026 glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]);
3030 drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels,
3031 xmin, xmax, ymin, ymax, zmin, zmax);
3032 drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels,
3033 xmin, xmax, ymin, ymax, zmin, zmax);
3034 drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels,
3035 xmin, xmax, ymin, ymax, zmin, zmax);
3040 if (myData->myDisplay.myUsageOfGLlists)
3042 if (myData->myDisplay.myROctBoolPointsFirst)
3044 // Delete previous GL list.
3045 if (myData->myDisplay.myROctBoolPointsList > 0)
3047 glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1);
3048 myData->myDisplay.myROctBoolPointsList = -1;
3051 // Generate a new GL list
3052 genListIndex(myData->myDisplay.myROctBoolPointsList);
3053 glNewList(myData->myDisplay.myROctBoolPointsList, GL_COMPILE);
3054 VoxelDirection vdir = getVoxelDirection(viewnormal);
3055 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3056 xmin, xmax, ymin, ymax, zmin, zmax);
3059 // The first call has just been passed...
3060 myData->myDisplay.myROctBoolPointsFirst = Standard_False;
3062 glCallList(myData->myDisplay.myROctBoolPointsList);
3066 VoxelDirection vdir = getVoxelDirection(viewnormal);
3067 drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels,
3068 xmin, xmax, ymin, ymax, zmin, zmax);
3074 //Standard_Real seconds, cpu;
3075 //Standard_Integer minutes, hours;
3076 //timer.Show(seconds, minutes, hours, cpu);
3077 //cout<<"DisplayPoints()"<<" took "<<minutes<<" minutes, "<<seconds<<" seconds"<<endl;
3080 /**************************************************************************/
3081 void VoxelClient_VisDrawer::DisplayBoxes(const Standard_Boolean nearest)
3083 // Range of displayed data
3084 Standard_Real xmin = myData->myDisplay.myDisplayedXMin;
3085 Standard_Real xmax = myData->myDisplay.myDisplayedXMax;
3086 Standard_Real ymin = myData->myDisplay.myDisplayedYMin;
3087 Standard_Real ymax = myData->myDisplay.myDisplayedYMax;
3088 Standard_Real zmin = myData->myDisplay.myDisplayedZMin;
3089 Standard_Real zmax = myData->myDisplay.myDisplayedZMax;
3091 // Find the side of the cube which normal looks to (or out) the user's eye.
3093 getNormal(viewnormal);
3095 // Get three sides of the box looking to the user.
3096 VoxelDirection vdir1, vdir2, vdir3;
3097 getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3);
3099 // Three quadrangles with normals looking to the user
3100 gp_Pln plane1(gp::Origin(), viewnormal);
3101 gp_Pln plane2(plane1), plane3(plane1);
3104 if (myData->myBoolVoxels &&
3105 myData->myBoolVoxels->GetNbX() &&
3106 myData->myBoolVoxels->GetNbY() &&
3107 myData->myBoolVoxels->GetNbZ())
3110 Standard_Real dx = myData->myBoolVoxels->GetXLen() / (Standard_Real) myData->myBoolVoxels->GetNbX();
3111 Standard_Real dy = myData->myBoolVoxels->GetYLen() / (Standard_Real) myData->myBoolVoxels->GetNbY();
3112 Standard_Real dz = myData->myBoolVoxels->GetZLen() / (Standard_Real) myData->myBoolVoxels->GetNbZ();
3113 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3118 // Translatethe quadrangles to the side of the voxel
3119 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3120 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3121 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3122 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3125 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3126 drawBoolQuadrangles(myData->myBoolVoxels, vdir1, plane1.Axis().Direction(),
3127 skin, p11, p12, p13, p14,
3128 xmin, xmax, ymin, ymax, zmin, zmax);
3129 drawBoolQuadrangles(myData->myBoolVoxels, vdir2, plane2.Axis().Direction(),
3130 skin, p21, p22, p23, p24,
3131 xmin, xmax, ymin, ymax, zmin, zmax);
3132 drawBoolQuadrangles(myData->myBoolVoxels, vdir3, plane3.Axis().Direction(),
3133 skin, p31, p32, p33, p34,
3134 xmin, xmax, ymin, ymax, zmin, zmax);
3136 // Color quadrangles
3137 else if (myData->myColorVoxels &&
3138 myData->myColorVoxels->GetNbX() &&
3139 myData->myColorVoxels->GetNbY() &&
3140 myData->myColorVoxels->GetNbZ())
3143 Standard_Real dx = myData->myColorVoxels->GetXLen() / (Standard_Real) myData->myColorVoxels->GetNbX();
3144 Standard_Real dy = myData->myColorVoxels->GetYLen() / (Standard_Real) myData->myColorVoxels->GetNbY();
3145 Standard_Real dz = myData->myColorVoxels->GetZLen() / (Standard_Real) myData->myColorVoxels->GetNbZ();
3146 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3151 // Translatethe quadrangles to the side of the voxel
3152 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3153 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3154 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3155 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3158 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3159 drawColorQuadrangles(myData->myColorVoxels, vdir1, plane1.Axis().Direction(), skin,
3160 myData->myDisplay.myColors, p11, p12, p13, p14,
3161 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3162 xmin, xmax, ymin, ymax, zmin, zmax);
3163 drawColorQuadrangles(myData->myColorVoxels, vdir2, plane2.Axis().Direction(), skin,
3164 myData->myDisplay.myColors, p21, p22, p23, p24,
3165 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3166 xmin, xmax, ymin, ymax, zmin, zmax);
3167 drawColorQuadrangles(myData->myColorVoxels, vdir3, plane3.Axis().Direction(), skin,
3168 myData->myDisplay.myColors, p31, p32, p33, p34,
3169 myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue,
3170 xmin, xmax, ymin, ymax, zmin, zmax);
3172 // Recursive Octree Boolean boxes
3173 else if (myData->myROctBoolVoxels &&
3174 myData->myROctBoolVoxels->GetNbX() &&
3175 myData->myROctBoolVoxels->GetNbY() &&
3176 myData->myROctBoolVoxels->GetNbZ())
3179 Standard_Real dx = myData->myROctBoolVoxels->GetXLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbX();
3180 Standard_Real dy = myData->myROctBoolVoxels->GetYLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbY();
3181 Standard_Real dz = myData->myROctBoolVoxels->GetZLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbZ();
3182 Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize;
3187 // Translatethe quadrangles to the side of the voxel
3188 gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34;
3189 setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14);
3190 setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24);
3191 setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34);
3194 Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode;
3195 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir1, plane1.Axis().Direction(),
3196 skin, p11, p12, p13, p14,
3197 xmin, xmax, ymin, ymax, zmin, zmax);
3198 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir2, plane2.Axis().Direction(),
3199 skin, p21, p22, p23, p24,
3200 xmin, xmax, ymin, ymax, zmin, zmax);
3201 drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir3, plane3.Axis().Direction(),
3202 skin, p31, p32, p33, p34,
3203 xmin, xmax, ymin, ymax, zmin, zmax);
3207 /**************************************************************************/
3208 void VoxelClient_VisDrawer::DisplayTriangulation(const Standard_Boolean theHighlight)
3210 if(!myData || myData->myTriangulation.IsNull())
3213 glEnable(GL_DEPTH_TEST);
3214 glEnable(GL_LIGHTING);
3216 const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes();
3217 const Poly_Array1OfTriangle& triangles = myData->myTriangulation->Triangles();
3218 Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
3220 Standard_Boolean compute_normals = Standard_False;
3221 if (myData->myNormalsOfNodes.IsNull())
3223 compute_normals = Standard_True;
3224 myData->myNormalsOfNodes = new TColgp_HArray1OfDir(itriangle, nb_triangles);
3226 // Release the GL list
3227 if (myData->myDisplay.myTriangulationList > 0)
3229 glDeleteLists(myData->myDisplay.myTriangulationList, 1);
3230 myData->myDisplay.myTriangulationList = -1;
3233 // Generate a new GL list
3234 if (myData->myDisplay.myUsageOfGLlists)
3236 genListIndex(myData->myDisplay.myTriangulationList);
3237 glNewList(myData->myDisplay.myTriangulationList, GL_COMPILE);
3240 TColgp_Array1OfDir& normals = myData->myNormalsOfNodes->ChangeArray1();
3242 if (!myData->myDisplay.myUsageOfGLlists || compute_normals)
3245 glBegin(GL_TRIANGLES);
3247 Standard_Integer n1, n2, n3;
3248 Standard_Real x, y, z;
3249 for (; itriangle <= nb_triangles; itriangle++)
3251 const Poly_Triangle& t = triangles.Value(itriangle);
3254 const gp_Pnt& p1 = nodes.Value(n1);
3255 const gp_Pnt& p2 = nodes.Value(n2);
3256 const gp_Pnt& p3 = nodes.Value(n3);
3259 if (compute_normals)
3261 gp_Vec v1(p1, p2), v2(p1, p3);
3263 if (v1.SquareMagnitude() > 1.e-14)
3266 v1.SetCoord(0.0, 0.0, 1.0);
3267 normals.SetValue(itriangle, v1);
3272 normals.Value(itriangle).Coord(x, y, z);
3274 glNormal3d(x, y, z);
3278 glVertex3d(x, y, z);
3282 glVertex3d(x, y, z);
3286 glVertex3d(x, y, z);
3291 if (myData->myDisplay.myUsageOfGLlists)
3295 if (myData->myDisplay.myUsageOfGLlists)
3296 glCallList(myData->myDisplay.myTriangulationList);
3299 void VoxelClient_VisDrawer::HighlightVoxel()
3302 myData->myDisplay.myHighlightx >= 0 &&
3303 myData->myDisplay.myHighlighty >= 0 &&
3304 myData->myDisplay.myHighlightz >= 0)
3306 Standard_Integer nbx, nby, nbz;
3307 Standard_Real xlen, ylen, zlen, xc, yc, zc;
3308 Voxel_DS* ds = (Voxel_DS*) myData->myBoolVoxels;
3309 if (myData->myColorVoxels)
3310 ds = (Voxel_DS*) myData->myColorVoxels;
3311 if (myData->myROctBoolVoxels)
3312 ds = (Voxel_DS*) myData->myROctBoolVoxels;
3316 xlen = ds->GetXLen();
3317 ylen = ds->GetYLen();
3318 zlen = ds->GetZLen();
3319 ds->GetCenter(myData->myDisplay.myHighlightx,
3320 myData->myDisplay.myHighlighty,
3321 myData->myDisplay.myHighlightz,
3324 Standard_Real half_voxelx = xlen / Standard_Real(nbx) / 2.0;
3325 Standard_Real half_voxely = ylen / Standard_Real(nby) / 2.0;
3326 Standard_Real half_voxelz = zlen / Standard_Real(nbz) / 2.0;
3327 Standard_Real x1 = xc - half_voxelx, y1 = yc - half_voxely, z1 = zc - half_voxelz;
3328 Standard_Real x2 = xc + half_voxelx, y2 = yc + half_voxely, z2 = zc + half_voxelz;
3330 setColor(Quantity_NOC_BLUE1, Standard_True);
3331 setTypeOfLine(Aspect_TOL_SOLID);
3336 glVertex3d(x1, y1, z1);
3337 glVertex3d(x1, y2, z1);
3339 glVertex3d(x1, y1, z1);
3340 glVertex3d(x2, y1, z1);
3342 glVertex3d(x1, y1, z1);
3343 glVertex3d(x1, y1, z2);
3345 glVertex3d(x1, y2, z1);
3346 glVertex3d(x2, y2, z1);
3348 glVertex3d(x2, y1, z1);
3349 glVertex3d(x2, y2, z1);
3351 glVertex3d(x2, y2, z1);
3352 glVertex3d(x2, y2, z2);
3354 glVertex3d(x1, y1, z2);
3355 glVertex3d(x1, y2, z2);
3357 glVertex3d(x1, y1, z2);
3358 glVertex3d(x2, y1, z2);
3360 glVertex3d(x2, y1, z2);
3361 glVertex3d(x2, y2, z2);
3363 glVertex3d(x2, y2, z2);
3364 glVertex3d(x1, y2, z2);
3366 glVertex3d(x1, y2, z2);
3367 glVertex3d(x1, y2, z1);
3369 glVertex3d(x2, y1, z1);
3370 glVertex3d(x2, y1, z2);