diff --git a/adm/MODULES b/adm/MODULES index 566647483f..10b1b2c6b8 100644 --- a/adm/MODULES +++ b/adm/MODULES @@ -1,7 +1,7 @@ FoundationClasses TKernel TKMath ModelingData TKG2d TKG3d TKGeomBase TKBRep ModelingAlgorithms TKGeomAlgo TKTopAlgo TKPrim TKBO TKBool TKHLR TKFillet TKOffset TKFeat TKMesh TKXMesh TKShHealing -Visualization TKService TKV3d TKOpenGl TKMeshVS TKVoxel TKIVtk +Visualization TKService TKV3d TKOpenGl TKMeshVS TKIVtk ApplicationFramework TKCDF TKLCAF TKCAF TKBinL TKXmlL TKBin TKXml FWOSPlugin TKTObj TKBinTObj TKXmlTObj DataExchange TKXSBase TKSTEPBase TKSTEPAttr TKSTEP209 TKSTEP TKIGES TKXCAF TKXDEIGES TKXDESTEP TKSTL TKVRML TKXmlXCAF TKBinXCAF Draw TKDraw TKTopTest TKViewerTest TKXSDRAW TKDCAF TKXDEDRAW TKTObjDRAW TKQADraw TKIVtkDraw DRAWEXE \ No newline at end of file diff --git a/adm/UDLIST b/adm/UDLIST index 35248dbf5f..56446c378a 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -212,7 +212,6 @@ n StdPrs n StdSelect n TColQuantity n V3d -n Voxel n WNT n Xw n Cocoa @@ -223,7 +222,6 @@ t TKOpenGl t TKD3DHost t TKService t TKV3d -t TKVoxel n BinTObjDrivers n LDOM n TObj diff --git a/dox/FILES_HTML.txt b/dox/FILES_HTML.txt index 7db38e4504..a1ef0b24e6 100644 --- a/dox/FILES_HTML.txt +++ b/dox/FILES_HTML.txt @@ -35,7 +35,6 @@ user_guides/brep_wp/brep_wp.md user_guides/ocaf_functionmechanism_wp/ocaf_functionmechanism_wp.md user_guides/ocaf_tree_wp/ocaf_tree_wp.md user_guides/ocaf_wp/ocaf_wp.md -user_guides/voxels_wp/voxels_wp.md user_guides/vis/vis.md dev_guides/dev_guides.md diff --git a/dox/FILES_PDF.txt b/dox/FILES_PDF.txt index 3d1d797a1e..f4f7ffcdcb 100644 --- a/dox/FILES_PDF.txt +++ b/dox/FILES_PDF.txt @@ -19,7 +19,6 @@ user_guides/step/step.md user_guides/draw_test_harness/draw_test_harness.md user_guides/tobj/tobj.md user_guides/visualization/visualization.md -user_guides/voxels_wp/voxels_wp.md user_guides/xde/xde.md user_guides/vis/vis.md diff --git a/dox/dev_guides/tests/tests.md b/dox/dev_guides/tests/tests.md index fe36b4208c..2004d4850f 100644 --- a/dox/dev_guides/tests/tests.md +++ b/dox/dev_guides/tests/tests.md @@ -987,7 +987,7 @@ This group allows testing extended data exchange packages. | Foundation Classes | TKernel, TKMath | fclasses | | Modeling_algorithms | TKGeomAlgo, TKTopAlgo, TKPrim, TKBO, TKBool, TKHLR, TKFillet, TKOffset, TKFeat, TKXMesh | modalg | | Modeling Data | TKG2d, TKG3d, TKGeomBase, TKBRep | moddata | -| Visualization | TKService, TKV2d, TKV3d, TKOpenGl, TKMeshVS, TKNIS, TKVoxel | vis | +| Visualization | TKService, TKV2d, TKV3d, TKOpenGl, TKMeshVS, TKNIS | vis | @subsection testmanual_5_3 Recommended approaches to checking test results diff --git a/dox/overview/overview.md b/dox/overview/overview.md index 199ebcd4d6..21957069ad 100644 --- a/dox/overview/overview.md +++ b/dox/overview/overview.md @@ -556,13 +556,6 @@ The combination of these resources allows creating substantial applications. **See also:** @ref occt__tutorial "OCCT Tutorial" - Voxel ------- - -This is a demonstration application showing OCCT voxel models. It also includes a set of non-regression tests and other commands for testing this functionality (accessible only through TEST pre-processor definition). - -**See also:** Voxels User's guide - **Remarks:** * Qt samples are available on all supported platforms; diff --git a/dox/technical_overview/technical_overview.md b/dox/technical_overview/technical_overview.md index 85fbcbf678..f0077cee03 100644 --- a/dox/technical_overview/technical_overview.md +++ b/dox/technical_overview/technical_overview.md @@ -208,10 +208,6 @@ For more details see @ref occt_user_guides__visualization "Visualization User's The visualization of OCCT topological shapes by means of VTK library provided by VIS component is described in a separate @ref occt_user_guides__vis "VTK Integration Services" User's Guide. -Open CASCADE Technology also supports voxel representation providing basic data containers and visualization of voxels as colored or grayscale bricks. - -See @ref occt_user_guides__voxels_wp "Voxels User's Guide" for more information. - See also: our E-learning & Training offerings. diff --git a/dox/user_guides/user_guides.md b/dox/user_guides/user_guides.md index 70b1a20a72..289ed21f3c 100644 --- a/dox/user_guides/user_guides.md +++ b/dox/user_guides/user_guides.md @@ -10,7 +10,6 @@ OCCT User Guides are organized by OCCT modules: * @subpage occt_user_guides__boolean_operations "Boolean Operations" * @subpage occt_user_guides__shape_healing "Shape Healing" * @subpage occt_user_guides__visualization "Visualization" - * @subpage occt_user_guides__voxels_wp "Voxels" * @subpage occt_user_guides__vis "VTK Integration Services" * Data Exchange * @subpage occt_user_guides__iges "IGES translator" diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image003.png b/dox/user_guides/voxels_wp/images/voxels_wp_image003.png deleted file mode 100644 index 3e08944508..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image003.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image004.png b/dox/user_guides/voxels_wp/images/voxels_wp_image004.png deleted file mode 100644 index 666bca154e..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image004.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image005.png b/dox/user_guides/voxels_wp/images/voxels_wp_image005.png deleted file mode 100644 index 33bd9cc32a..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image005.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image006.png b/dox/user_guides/voxels_wp/images/voxels_wp_image006.png deleted file mode 100644 index 5d9222144a..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image006.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image007.png b/dox/user_guides/voxels_wp/images/voxels_wp_image007.png deleted file mode 100644 index 0e1723ce69..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image007.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image008.png b/dox/user_guides/voxels_wp/images/voxels_wp_image008.png deleted file mode 100644 index 9671a0afd5..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image008.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image009.png b/dox/user_guides/voxels_wp/images/voxels_wp_image009.png deleted file mode 100644 index 7228234e56..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image009.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/images/voxels_wp_image010.png b/dox/user_guides/voxels_wp/images/voxels_wp_image010.png deleted file mode 100644 index b024013e00..0000000000 Binary files a/dox/user_guides/voxels_wp/images/voxels_wp_image010.png and /dev/null differ diff --git a/dox/user_guides/voxels_wp/voxels_wp.md b/dox/user_guides/voxels_wp/voxels_wp.md deleted file mode 100644 index d6e05c5787..0000000000 --- a/dox/user_guides/voxels_wp/voxels_wp.md +++ /dev/null @@ -1,158 +0,0 @@ -Voxel Package {#occt_user_guides__voxels_wp} -======================== - -@tableofcontents - -@section occt_voxels_wp_1 Introduction - - A voxel is a sub-volume box with constant scalar/vector value. - The object in voxel representation is split into many small sub-volumes (voxels) - and its properties are distributed through voxels. - - Voxels are used for analysis and visualization of 3D-dimensional distribution of data. - Medicine (mainly, tomography), computational physics (hydrodynamics, aerodynamics, nuclear physics) - and many other industries use voxels for 3D data visualization and analysis of physical processes. - - To produce a voxel representation the 3D space is split by equal intervals - along the main orthogonal coordinate axes to obtain nx x ny x nz voxels (small cubes): - -@image html voxels_wp_image003.png "A cube of 3 X 3 X 3  = 9 voxels." -@image latex voxels_wp_image003.png "A cube of 3 X 3 X 3  = 9 voxels." - - The data are attached to each voxel and remain the same within the voxel. - It means that we obtain the 3D space with discrete data distribution. - - The number of voxels used in a calculation can vary. - An average model contains several tens of millions of voxels. - Such a great amount of data requires special algorithms of computation, - data containers keeping data in memory and visualization tools. - - Open CASCADE Technology provides several basic data containers for voxels - with fast access to the data and optimal allocation of data in memory. - - Also, a special visualization toolkit allows visualizing voxels - as colored or black/white points and cubes, displaying only the voxels - visible from the user's point of view. - -@image html voxels_wp_image004.png "A shape and its voxel representation" -@image html voxels_wp_image005.png "A shape and its voxel representation" - -@image latex voxels_wp_image004.png "A shape and its voxel representation" -@image latex voxels_wp_image005.png "A shape and its voxel representation" - -In these images a boundary representation is displayed to the left. In the center and to the right there are 3D discrete representations (or 3D discrete topology). Any solid shape can be translated into a voxel representation. - -@section occt_voxels_wp_2 Data structure - - The data structure to store the voxels data is a special class which gives - fast access to the data of each voxel and allocates the data in an optimal way in the memory of a computer. - - Fast access to the data is provided by means of bit-wise operators on the indices of internal arrays. - - The optimal data allocation is reached through division - of the whole data set into data subsets and keeping only non-zero pieces of data in memory. - - A voxel can contain different data types,  - but presently Open CASCADE Technology implements only several basic ones: - * 1 bit or Boolean data type – a voxel contains a flag: 0 or 1 (false or true). - * 4 bits or Color data type – a voxel contains a value occupying 4 bits. - It is an integer in the range of 0 .. 15. The data can be divided into 16 subsets and displayed by Color-voxels. - * 4 bytes or Float data type – a voxel contains a floating-point data type. - - In addition, the data structures provide methods for calculation of a center point - by voxel indices and a reverse task – fast search of a voxel by a point inside the cube of voxels. - -@section occt_voxels_wp_3 Algorithms - - There are two service classes implemented for data structures of voxels: - - * Boolean operations – provides simple boolean operations on cubes of voxels (fuse and cut). - * Voxelization – the conversion of a geometrical model into its voxel representation. - -### Boolean operations - -Fusion and cutting of two cubes of voxels are performed the class *Voxel_BooleanOperations*. The cubes should have the same size and be split into voxels in the same way. -* \::Fuse() summarizes the values of the corresponding voxels and limits the result by the upper limit (if succeeded). -* \::Cut() subtracts the values of the corresponding voxels and limits the result by zero. - -### Voxelization - -A class *Voxel_Convert* converts a *TopoDS_Shape* into one of the voxel data structures filling the solid shape by non-zero values. - -The algorithm of voxelization generates only 1-bit or 4-bit voxels. Other data types may be obtained by conversion of voxels from one type to another. - -Voxelization of a shape is performed by means of computation of intersection points between lines filling the volume and triangulation of the shape. The lines are parallel to main orthogonal axes and can intersect the shape from different sides: along +X, +Y and/or +Z axes. - -The algorithm can run in multi-threaded mode (the number of threads is unlimited). The user can see an integer value indicating the progress of computation. - -@section occt_voxels_wp_4 Visualization - - Visualization of voxels is not a simple task due to a great amount of data used for 3D analysis. - - Open CASCADE Technology allows visualization of a cube of voxels in two modes: - * Points – the centers of voxels as 3D points. - * Boxes – the voxels as 3D cubes of adjustable size. - - A degenerated mode displays only the points (boxes) visible - from the point of view of the user for transformation operations (zoom, pan and rotate). - - To focus on a particular part of the model non-relevant voxels can be erased. - The displayed region is defined by six co-ordinates along X, Y and Z axes . - - It is possible to display the voxels from a particular range of values (iso-volume): - -@image html voxels_wp_image006.png "Iso-volume of a shape" -@image latex voxels_wp_image006.png "Iso-volume of a shape" - -The voxels are displayed by means of "direct drawing in Open GL" technology or "user draw" technology. Therefore, some visualization files are compiled within Open CASCADE Technology, but the files of "direct drawing" are compiled  by the end-user application. - -It is necessary to include the files *Voxel_VisData.h*, *VoxelClient_VisDrawer.h* and *VoxelClient_VisDrawer.cxx* into the visualization library of the application (containing all files of *OpenGl* package) and call the method *Voxel_VisDrawer::Init()* from the application before the visualization of voxels. - -@section occt_voxels_wp_5 Demo-application - - A demonstration application has been created to show OCCT voxel models. - This is a test demo application because it includes a set of non-regression tests - and other commands for testing the functionality (accessible only through TEST pre-processor definition). - - The *File* menu allows creation of canonical shapes (box, cylinder, sphere, torus) or loading of shapes in BREP format: - -@image html voxels_wp_image007.png "Demo-application. Creation or loading of a shape" -@image latex voxels_wp_image007.png "Demo-application. Creation or loading of a shape" - -The menu *Converter* voxelizes the shape. Two types of voxels can be obtained: 1-bit or 4-bit voxels. - * 1-bit voxels are displayed in white color on black background. - * 4-bit voxels use 16 colors filling the model in a special way for demonstrative purposes: - -@image html voxels_wp_image008.png "Demo-application. Voxelization" -@image latex voxels_wp_image008.png "Demo-application. Voxelization" - - The converter uses two threads (two processors, if available) to perform voxelization. - - The menu *Visualization* offers two modes of visualization: Points and Boxes, - allows defining the size of points and boxes (quadrangles), - the minimum and the maximum displayed color, and the boundaries of the bounding box for displayed voxels: - -@image html voxels_wp_image009.png "Demo-application. Visualization" -@image latex voxels_wp_image009.png "Demo-application. Visualization" - - The last menu, *Demo* contains a demo-command for running waves of 4-bit voxels: - -@image html voxels_wp_image010.png "Demo-application. Running waves" -@image latex voxels_wp_image010.png "Demo-application. Running waves" - -@section occt_voxels_wp_6 Future development - -In the future OPEN CASCADE plans to develop the platform of voxels in the following directions: - * Data structure: - * Extension of the list of basic data types. - * Development of a deeper hierarchy of voxels (for example, octree – division of a voxel into 8 sub-voxels). - * Development of a doxel (4D voxels where the fourth co-ordinate is the time, for example). - - * Algorithms: - * Conversion of a voxel model into a geometrical model (a reversed operation to voxelization). - - * Visualization: - * Optimization of visualization (mainly, the speed of visualization). - * New shapes of voxel presentation in the 3D Viewer and new approaches to visualization. - * Selection of voxels. - diff --git a/samples/qt/VoxelDemo/VoxelDemo-vc10.sln b/samples/qt/VoxelDemo/VoxelDemo-vc10.sln deleted file mode 100644 index 00a81bed2a..0000000000 --- a/samples/qt/VoxelDemo/VoxelDemo-vc10.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VoxelDemo", "VoxelDemo.vcxproj", "{EF9DFAE9-E10E-42D4-87D1-52431728AFDF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|Win32.ActiveCfg = Debug|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|Win32.Build.0 = Debug|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|x64.ActiveCfg = Debug|x64 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|x64.Build.0 = Debug|x64 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|Win32.ActiveCfg = Release|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|Win32.Build.0 = Release|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|x64.ActiveCfg = Release|x64 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/qt/VoxelDemo/VoxelDemo-vc12.sln b/samples/qt/VoxelDemo/VoxelDemo-vc12.sln deleted file mode 100644 index 7bf6231f7d..0000000000 --- a/samples/qt/VoxelDemo/VoxelDemo-vc12.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VoxelDemo", "VoxelDemo.vcxproj", "{59F93AA4-FBAD-3468-B4E7-2D6290D2D461}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Debug|Win32.ActiveCfg = Debug|x64 - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Debug|x64.ActiveCfg = Debug|x64 - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Debug|x64.Build.0 = Debug|x64 - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Release|Win32.ActiveCfg = Release|x64 - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Release|x64.ActiveCfg = Release|x64 - {59F93AA4-FBAD-3468-B4E7-2D6290D2D461}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/qt/VoxelDemo/VoxelDemo-vc9.sln b/samples/qt/VoxelDemo/VoxelDemo-vc9.sln deleted file mode 100644 index fabee776e4..0000000000 --- a/samples/qt/VoxelDemo/VoxelDemo-vc9.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VoxelDemo", "VoxelDemo.vcproj", "{EF9DFAE9-E10E-42D4-87D1-52431728AFDF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|Win32.ActiveCfg = Debug|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Debug|Win32.Build.0 = Debug|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|Win32.ActiveCfg = Release|Win32 - {EF9DFAE9-E10E-42D4-87D1-52431728AFDF}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/samples/qt/VoxelDemo/VoxelDemo.pro b/samples/qt/VoxelDemo/VoxelDemo.pro deleted file mode 100644 index 90a408003c..0000000000 --- a/samples/qt/VoxelDemo/VoxelDemo.pro +++ /dev/null @@ -1,185 +0,0 @@ -TEMPLATE = app -CONFIG += debug_and_release qt opengl - -TARGET = VoxelDemo - -SAMPLESROOT = $$(CASROOT)/samples/qt - -HEADERS = $${SAMPLESROOT}/voxeldemo/inc/*.h - -SOURCES = $${SAMPLESROOT}/voxeldemo/src/*.cxx \ - $${SAMPLESROOT}/voxeldemo/src/*.cpp - - -INCLUDEPATH += $$quote($${SAMPLESROOT}/voxeldemo/inc) - -DEFINES = - -unix { - UNAME = $$system(uname -s) - INCLUDES = $$(CSF_OPT_INC) - PATHS = $$split(INCLUDES,":") - for(path, PATHS):INCLUDEPATH += $${path} - LIBLIST = $$(LD_LIBRARY_PATH) - LIBPATHS = $$split(LIBLIST,":") - for(lib, LIBPATHS):LIBS += -L$${lib} - - CONFIG(debug, debug|release) { - DESTDIR = ./$$UNAME/bind - OBJECTS_DIR = ./$$UNAME/objd - MOC_DIR = ./$$UNAME/srcd - } else { - DESTDIR = ./$$UNAME/bin - OBJECTS_DIR = ./$$UNAME/obj - MOC_DIR = ./$$UNAME/src - } - - MACOSX_USE_GLX = $$(MACOSX_USE_GLX) - - !macx | equals(MACOSX_USE_GLX, true): INCLUDEPATH += $$QMAKE_INCDIR_X11 $$QMAKE_INCDIR_OPENGL $$QMAKE_INCDIR_THREAD - !macx | equals(MACOSX_USE_GLX, true): DEFINES += LIN LININTEL - equals(MACOSX_USE_GLX, true): DEFINES += MACOSX_USE_GLX - DEFINES += OCC_CONVERT_SIGNALS QT_NO_STL - !macx | equals(MACOSX_USE_GLX, true): LIBS += -L$$QMAKE_LIBDIR_X11 $$QMAKE_LIBS_X11 -L$$QMAKE_LIBDIR_OPENGL $$QMAKE_LIBS_OPENGL $$QMAKE_LIBS_THREAD - LIBS += -lfreeimageplus - LIBS += -ltbb -ltbbmalloc -} - -win32 { - INCLUDES = $$(CSF_OPT_INC) - PATHS = $$split(INCLUDES,";") - for(path, PATHS):INCLUDEPATH += $${path} - - CONFIG(debug, debug|release) { - DEFINES += _DEBUG - !contains(QMAKE_HOST.arch, x86_64) { - LIBS = -L$(CSF_OPT_LIB32D) - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) { - DESTDIR = ./win32/vc7/bind - OBJECTS_DIR = ./win32/vc7/objd - MOC_DIR = ./win32/vc7/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) { - DESTDIR = ./win32/vc8/bind - OBJECTS_DIR = ./win32/vc8/objd - MOC_DIR = ./win32/vc8/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) { - DESTDIR = ./win32/vc9/bind - OBJECTS_DIR = ./win32/vc9/objd - MOC_DIR = ./win32/vc9/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) { - DESTDIR = ./win32/vc10/bind - OBJECTS_DIR = ./win32/vc10/objd - MOC_DIR = ./win32/vc10/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) { - DESTDIR = ./win32/vc11/bind - OBJECTS_DIR = ./win32/vc11/objd - MOC_DIR = ./win32/vc11/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1800) { - DESTDIR = ./win32/vc12/bind - OBJECTS_DIR = ./win32/vc12/objd - MOC_DIR = ./win32/vc12/srcd - } - } else { - LIBS = -L$(CSF_OPT_LIB64D) - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) { - DESTDIR = ./win64/vc8/bind - OBJECTS_DIR = ./win64/vc8/objd - MOC_DIR = ./win64/vc8/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) { - DESTDIR = ./win64/vc9/bind - OBJECTS_DIR = ./win64/vc9/objd - MOC_DIR = ./win64/vc9/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) { - DESTDIR = ./win64/vc10/bind - OBJECTS_DIR = ./win64/vc10/objd - MOC_DIR = ./win64/vc10/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) { - DESTDIR = ./win64/vc11/bind - OBJECTS_DIR = ./win64/vc11/objd - MOC_DIR = ./win64/vc11/srcd - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1800) { - DESTDIR = ./win64/vc12/bind - OBJECTS_DIR = ./win64/vc12/objd - MOC_DIR = ./win64/vc12/srcd - } - } - } else { - DEFINES += NDEBUG - !contains(QMAKE_HOST.arch, x86_64) { - LIBS = -L$(CSF_OPT_LIB32) - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) { - DESTDIR = ./win32/vc7/bin - OBJECTS_DIR = ./win32/vc7/obj - MOC_DIR = ./win32/vc7/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) { - DESTDIR = ./win32/vc8/bin - OBJECTS_DIR = ./win32/vc8/obj - MOC_DIR = ./win32/vc8/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) { - DESTDIR = ./win32/vc9/bin - OBJECTS_DIR = ./win32/vc9/obj - MOC_DIR = ./win32/vc9/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) { - DESTDIR = ./win32/vc10/bin - OBJECTS_DIR = ./win32/vc10/obj - MOC_DIR = ./win32/vc10/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) { - DESTDIR = ./win32/vc11/bin - OBJECTS_DIR = ./win32/vc11/obj - MOC_DIR = ./win32/vc11/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1800) { - DESTDIR = ./win32/vc12/bin - OBJECTS_DIR = ./win32/vc12/obj - MOC_DIR = ./win32/vc12/src - } - } else { - LIBS = -L$(CSF_OPT_LIB64) - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) { - DESTDIR = ./win64/vc8/bin - OBJECTS_DIR = ./win64/vc8/obj - MOC_DIR = ./win64/vc8/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) { - DESTDIR = ./win64/vc9/bin - OBJECTS_DIR = ./win64/vc9/obj - MOC_DIR = ./win64/vc9/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) { - DESTDIR = ./win64/vc10/bin - OBJECTS_DIR = ./win64/vc10/obj - MOC_DIR = ./win64/vc10/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) { - DESTDIR = ./win64/vc11/bin - OBJECTS_DIR = ./win64/vc11/obj - MOC_DIR = ./win64/vc11/src - } - contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1800) { - DESTDIR = ./win64/vc12/bin - OBJECTS_DIR = ./win64/vc12/obj - MOC_DIR = ./win64/vc12/src - } - } - } - DEFINES +=WNT WIN32 NO_COMMONSAMPLE_EXPORTS NO_IESAMPLE_EXPORTS -} - -LIBS += -lTKernel -lTKMath -lTKService -lTKV3d \ - -lTKBRep -lTKGeomBase -lTKTopAlgo -lTKPrim \ - -lTKBool -lTKVoxel -lTKOpenGl \ - -QMAKE_CXXFLAGS = -Zc:wchar_t diff --git a/samples/qt/VoxelDemo/genproj.bat b/samples/qt/VoxelDemo/genproj.bat deleted file mode 100644 index 997b1612b8..0000000000 --- a/samples/qt/VoxelDemo/genproj.bat +++ /dev/null @@ -1,43 +0,0 @@ -REM Generation of vcproj files with qmake utilite -REM Variable QTDIR and PATH to qmake executable must be defined without fail - -REM Use first argument to specify version of Visual Studio (vc8, vc9, or vc10), -REM second argument specifies architecture) (win32 or win64) -REM third argument specifies Debug or Release mode - -call "%~dp0../../../env.bat" %1 %2 %3 - -set EXT=vcxproj - -if not "%1" == "" ( - if /I "%1" == "vc8" ( - set VCVER=vc8 - set "VCVARS=%VS80COMNTOOLS%..\..\VC\vcvarsall.bat" - ) else if /I "%1" == "vc9" ( - set VCVER=vc9 - set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat" - ) else if /I "%1" == "vc10" ( - set VCVER=vc10 - set EXT=vcxproj - set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat" - ) else if /I "%1" == "vc11" ( - set VCVER=vc11 - set EXT=vcxproj - set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat" - ) else if /I "%1" == "vc12" ( - set VCVER=vc12 - set EXT=vcxproj - set "VCVARS=%VS120COMNTOOLS%..\..\VC\vcvarsall.bat" - ) else ( - echo Error: first argument ^(%1^) should specify supported version of Visual C++, - echo one of: vc8 ^(VS 2005 SP1^), vc9 ^(VS 2008 SP1^), vc10 ^(VS 2010^) or vc11 ^(VS 2012^) - exit - ) -) - -if ["%ARCH%"] == ["32"] set VCARCH=x86 -if ["%ARCH%"] == ["64"] set VCARCH=amd64 - -call "%VCVARS%" %VCARCH% - -qmake -tp vc -o VoxelDemo.%EXT% VoxelDemo.pro diff --git a/samples/qt/VoxelDemo/inc/Application.h b/samples/qt/VoxelDemo/inc/Application.h deleted file mode 100755 index 48116014fb..0000000000 --- a/samples/qt/VoxelDemo/inc/Application.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef APPLICATION_H -#define APPLICATION_H - -#include -#include -#include -#include -#include -#include -#include "Viewer.h" - -class Application: public QMainWindow -{ - Q_OBJECT - -public: - Application(); - ~Application(); - -protected: - void closeEvent( QCloseEvent* ); - -private slots: - void box(); - void cylinder(); - void torus(); - void sphere(); - void choose(); - void load( const QString & ); - void load( const TopoDS_Shape & ); - void save(); - void open(); - - void testBoolDS(); - void testColorDS(); - void testFloatDS(); - void testOctBoolDS(); - void testROctBoolDS(); - - void testFuseBoolDS(); - void testFuseColorDS(); - void testFuseFloatDS(); - void testCutBoolDS(); - void testCutColorDS(); - void testCutFloatDS(); - - void convert2bool(); - void convert2color(); - void convert(const int ); - - void setNbX(); - void setNbY(); - void setNbZ(); - - void setScanSide(); - - void setVolumicBoolValue(); - void setVolumicColorValue(); - - void setQuadrangleSize(); - void setPointSize(); - - void setColorMinValue(); - void setColorMaxValue(); - - void setUsageOfGLlists(); - - void setDisplayedXMin(); - void setDisplayedXMax(); - void setDisplayedYMin(); - void setDisplayedYMax(); - void setDisplayedZMin(); - void setDisplayedZMax(); - - void displayPoints(); - void displayNearestPoints(); - void displayBoxes(); - void displayNearestBoxes(); - - void displayColorScale(); - - void displayWaves(); - void displayCut(); - void displayCollisions(); - - void about(); - -private: - void display(Voxel_VoxelDisplayMode ); - void initPrs(); - - Viewer* myViewer; - Handle(AIS_Shape) myShape; - Handle(Voxel_Prs) myVoxels; - Voxel_BoolDS* myBoolVoxels; - Voxel_ColorDS* myColorVoxels; - Handle(AIS_ColorScale) myColorScale; - int myNbX; - int myNbY; - int myNbZ; - unsigned char myScanSide; - bool myVolumicBoolValue; - unsigned char myVolumicColorValue; - int myQuadrangleSize; - int myPointSize; - unsigned char myColorMinValue; - unsigned char myColorMaxValue; - double myDisplayedXMin; - double myDisplayedXMax; - double myDisplayedYMin; - double myDisplayedYMax; - double myDisplayedZMin; - double myDisplayedZMax; -}; - -#endif // APPLICATION_H diff --git a/samples/qt/VoxelDemo/inc/ConversionThread.h b/samples/qt/VoxelDemo/inc/ConversionThread.h deleted file mode 100755 index 0b1b146dfd..0000000000 --- a/samples/qt/VoxelDemo/inc/ConversionThread.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _CONVERSIONTHREAD_H_ -#define _CONVERSIONTHREAD_H_ - -#include -//#include -#include - -class ConversionThread : public QThread -{ - -public: - - ConversionThread(); - ~ConversionThread(); - -// void setConverter(Voxel_Converter* converter); - void setConverter(Voxel_FastConverter* converter); - - void setVolumicValue(const int value); - void setScanSide(const int side); - void setThreadIndex(const int ithread); - - int* getProgress(); - -protected: - - void run(); - -private: - -// Voxel_Converter* myConverter; - Voxel_FastConverter* myFastConverter; - - int myVolumicValue; - int myScanSide; - int myThreadIndex; - int myProgress; -}; - -#endif // _CONVERSIONTHREAD_H_ diff --git a/samples/qt/VoxelDemo/inc/Timer.h b/samples/qt/VoxelDemo/inc/Timer.h deleted file mode 100755 index 338d7dc31b..0000000000 --- a/samples/qt/VoxelDemo/inc/Timer.h +++ /dev/null @@ -1,33 +0,0 @@ -// Timer.h: interface for the Timer class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_TIMER_H__528FB454_797E_11D7_9B1B_000103C0F1F9__INCLUDED_) -#define AFX_TIMER_H__528FB454_797E_11D7_9B1B_000103C0F1F9__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -class Timer -{ -public: - Standard_EXPORT Timer(); - Standard_EXPORT Timer(const char* filename); - Standard_EXPORT ~Timer(); - Standard_EXPORT void Start(); - Standard_EXPORT void Stop(); - Standard_EXPORT void Continue(); - Standard_EXPORT void Reset(); - Standard_EXPORT float Seconds(); - Standard_EXPORT int Minutes(); - Standard_EXPORT void Print(char* label); - -private: - OSD_Timer myTimer; - FILE* myWriter; -}; - -#endif // !defined(AFX_TIMER_H__528FB454_797E_11D7_9B1B_000103C0F1F9__INCLUDED_) diff --git a/samples/qt/VoxelDemo/inc/Viewer.h b/samples/qt/VoxelDemo/inc/Viewer.h deleted file mode 100755 index 41c8f2dff5..0000000000 --- a/samples/qt/VoxelDemo/inc/Viewer.h +++ /dev/null @@ -1,67 +0,0 @@ -#ifndef _VIEWER_H_ -#define _VIEWER_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -#include -#include -#include -#include - -#include -#include - -class Viewer : public QWidget -{ - - Q_OBJECT - -public: - - Viewer(QWidget* parent); - virtual ~Viewer(); - - Handle(AIS_InteractiveContext) getIC() const { return myIC; } - Handle(V3d_View) getView() const { return myView; } - Handle(OpenGl_GraphicDriver) getGraphicDriver() const { return myGraphicDriver; } - Voxel_Selector& getSelector() { return mySelector; } - void setPrs(const Handle(Voxel_Prs)& prs) { myPrs = prs; } - virtual QPaintEngine* paintEngine() const; - -signals: - - void mousePressed(Qt::KeyboardModifiers,int,int); - void mouseMoved(Qt::KeyboardModifiers,int,int); - void mouseReleased(Qt::KeyboardModifiers,int,int); - void mouseDoubleClick(Qt::KeyboardModifiers,int,int); - -protected: - virtual void paintEvent(QPaintEvent* pEvent); - virtual void resizeEvent(QResizeEvent* rsEvent); - virtual void mousePressEvent(QMouseEvent* mpEvent); - virtual void mouseMoveEvent(QMouseEvent* mmEvent); - virtual void mouseReleaseEvent(QMouseEvent* mrEvent); - virtual void mouseDoubleClickEvent(QMouseEvent* mdcEvent); - -private: - Handle(AIS_InteractiveContext) myIC; - Handle(V3d_View) myView; - Handle(OpenGl_GraphicDriver) myGraphicDriver; - - bool myRotate; - bool myZoom; - bool myPan; - - QPoint myStartPnt; - - void setDegenerateMode(const bool ); - - Voxel_Selector mySelector; - Handle(Voxel_Prs) myPrs; -}; - -#endif // _VIEWER_H_ diff --git a/samples/qt/VoxelDemo/inc/VoxelClient_VisDrawer.h b/samples/qt/VoxelDemo/inc/VoxelClient_VisDrawer.h deleted file mode 100644 index d79dbd0985..0000000000 --- a/samples/qt/VoxelDemo/inc/VoxelClient_VisDrawer.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (c) 1999-2014 OPEN CASCADE SAS - - This file is part of Open CASCADE Technology software library. - - This library is free software; you can redistribute it and / or modify it - under the terms of the GNU Lesser General Public version 2.1 as published - by the Free Software Foundation, with special exception defined in the file - OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT - distribution for complete text of the license and disclaimer of any warranty. - - Alternatively, this file may be used under the terms of Open CASCADE - commercial license or contractual agreement. -*/ - -#ifndef _VOXEL_VISDRAWER_H_ -#define _VOXEL_VISDRAWER_H_ - -#include "Voxel_VisData.h" -#include - -#include - -//! Voxel presentation using UserDraw. -class VoxelClient_PrsGl : public Voxel_Prs -{ - -public: - - //! Empty constructor. - VoxelClient_PrsGl() {} - -protected: - - //! Override compute to create UserDraw element. - Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, - const Handle(Prs3d_Presentation)& thePrs, - const Standard_Integer theMode) Standard_OVERRIDE; - -public: - - DEFINE_STANDARD_RTTI(VoxelClient_PrsGl, Voxel_Prs) - -}; - -DEFINE_STANDARD_HANDLE(VoxelClient_PrsGl, Voxel_Prs) - -class VoxelClient_VisDrawer -{ -public: - - class VisElement; - -public: - - Standard_EXPORT VoxelClient_VisDrawer(Voxel_VisData* theData); - Standard_EXPORT virtual ~VoxelClient_VisDrawer(); - - Standard_EXPORT void EvalMinMax(Graphic3d_BndBox4f& theMinMax) const; - Standard_EXPORT void Display(const Standard_Boolean theHighlight); - -private: - - Standard_EXPORT void DisplayVoxels(const Standard_Boolean theHighlight); - Standard_EXPORT void DisplayPoints(const Standard_Boolean nearest); - Standard_EXPORT void DisplayBoxes(const Standard_Boolean nearest); - Standard_EXPORT void HighlightVoxel(); - - Standard_EXPORT void DisplayTriangulation(const Standard_Boolean theHighlight); - - Voxel_VisData* myData; -}; - -#endif // _VOXEL_VISDRAWER_H_ diff --git a/samples/qt/VoxelDemo/msvc.bat b/samples/qt/VoxelDemo/msvc.bat deleted file mode 100644 index cccdc4032d..0000000000 --- a/samples/qt/VoxelDemo/msvc.bat +++ /dev/null @@ -1,38 +0,0 @@ -@echo off - -rem Setup environment -call "%~dp0..\..\..\env.bat" %1 %2 %3 - -rem Define path to project file -set "PRJFILE=%~dp0VoxelDemo-%VCVER%.sln" - -set "VisualStudioExpressName=VCExpress" - -if "%VCVER%" == "vc8" ( - set "DevEnvDir=%VS80COMNTOOLS%..\IDE" -) else if "%VCVER%" == "vc9" ( - set "DevEnvDir=%VS90COMNTOOLS%..\IDE" -) else if "%VCVER%" == "vc10" ( - set "DevEnvDir=%VS100COMNTOOLS%..\IDE" -) else if "%VCVER%" == "vc11" ( - set "DevEnvDir=%VS110COMNTOOLS%..\IDE" - rem Visual Studio Express starting from VS 2012 is called "for Windows Desktop" - rem and has a new name for executable - WDExpress - set "VisualStudioExpressName=WDExpress" -) else if "%VCVER%" == "vc12" ( - set "DevEnvDir=%VS120COMNTOOLS%..\IDE" - set "VisualStudioExpressName=WDExpress" -) else ( - echo Error: wrong VS identifier - exit /B -) - -rem Launch Visual Studio - either professional (devenv) or Express, as available -if exist "%DevEnvDir%\devenv.exe" ( - start "%DevEnvDir%\devenv.exe" "%PRJFILE%" -) else if exist "%DevEnvDir%\%VisualStudioExpressName%.exe" ( - start "%DevEnvDir%\%VisualStudioExpressName%.exe" "%PRJFILE%" -) else ( - echo Error: Could not find MS Visual Studio ^(%VCVER%^) - echo Check relevant environment variable ^(e.g. VS80COMNTOOLS for vc8^) -) diff --git a/samples/qt/VoxelDemo/run.bat b/samples/qt/VoxelDemo/run.bat deleted file mode 100644 index 87a3009028..0000000000 --- a/samples/qt/VoxelDemo/run.bat +++ /dev/null @@ -1,21 +0,0 @@ -call "%~dp0..\..\..\env.bat" %1 %2 %3 - -set "BIN_DIR=win%ARCH%\%VCVER%\bind" -if ["%CASDEB%"] == [""] ( - set "BIN_DIR=win%ARCH%\%VCVER%\bin" -) - -if not exist "%~dp0%BIN_DIR%\VoxelDemo.exe" goto ERR_EXE - -echo Starting VoxelDemo ..... -"%~dp0%BIN_DIR%\VoxelDemo.exe" - -goto END - -:ERR_EXE -echo Executable %~dp0%BIN_DIR%\VoxelDemo.exe not found. -echo Probably you didn't compile the application. -pause -goto END - -:END \ No newline at end of file diff --git a/samples/qt/VoxelDemo/src/Application.cpp b/samples/qt/VoxelDemo/src/Application.cpp deleted file mode 100644 index c7d5896a7e..0000000000 --- a/samples/qt/VoxelDemo/src/Application.cpp +++ /dev/null @@ -1,2343 +0,0 @@ -#include "Application.h" -#include "ConversionThread.h" -#include "Timer.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -Application::Application() - : QMainWindow( 0 ) -{ - // File - QMenu * file = menuBar()->addMenu( "&File" ); - - QAction* a; - // Box - a = new QAction("Box", this); - connect(a, SIGNAL(triggered()), this, SLOT(box())); - file->addAction(a); - // Cylinder - a = new QAction("Cylinder", this); - connect(a, SIGNAL(triggered()), this, SLOT(cylinder())); - file->addAction(a); - // Torus - a = new QAction("Torus", this); - connect(a, SIGNAL(triggered()), this, SLOT(torus())); - file->addAction(a); - // Sphere - a = new QAction("Sphere", this); - connect(a, SIGNAL(triggered()), this, SLOT(sphere())); - file->addAction(a); - // Load shape... - a = new QAction("Load shape...", this); - a->setShortcut(tr("Ctrl+O")); - connect(a, SIGNAL(triggered()), this, SLOT(choose())); - file->addAction(a); - - file->addSeparator(); - - // Open - a = new QAction("Open", this); - connect(a, SIGNAL(triggered()), this, SLOT(open())); - file->addAction(a); - - // Save - a = new QAction("Save", this); - connect(a, SIGNAL(triggered()), this, SLOT(save())); - file->addAction(a); - - file->addSeparator(); - - // Quit - a = new QAction("&Quit", this); - a->setShortcut(tr("Ctrl+Q")); - connect(a, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); - file->addAction(a); - - menuBar()->addSeparator(); - - -#ifdef TEST - QMenu * test = menuBar()->addMenu( "Test" ); - - a = new QAction("Test boolean", this); - connect(a, SIGNAL(triggered()), this, SLOT(testBoolDS())); - test->addAction(a); - - a = new QAction("Test color", this); - connect(a, SIGNAL(triggered()), this, SLOT(testColorDS())); - test->addAction(a); - - a = new QAction("Test float", this); - connect(a, SIGNAL(triggered()), this, SLOT(testFloatDS())); - test->addAction(a); - - a = new QAction("Test boolean / 8", this); - connect(a, SIGNAL(triggered()), this, SLOT(testOctBoolDS())); - test->addAction(a); - - a = new QAction("Test boolean / 8 / 8..", this); - connect(a, SIGNAL(triggered()), this, SLOT(testROctBoolDS())); - test->addAction(a); - - test->addSeparator(); - - a = new QAction("Test fusion of booleans", this); - connect(a, SIGNAL(triggered()), this, SLOT(testFuseBoolDS())); - test->addAction(a); - - a = new QAction("Test fusion of colors", this); - connect(a, SIGNAL(triggered()), this, SLOT(testFuseColorDS())); - test->addAction(a); - - a = new QAction("Test fusion of floating-points", this); - connect(a, SIGNAL(triggered()), this, SLOT(testFuseFloatDS())); - test->addAction(a); - - a = new QAction("Test cutting of booleans", this); - connect(a, SIGNAL(triggered()), this, SLOT(testCutBoolDS())); - test->addAction(a); - - a = new QAction("Test cutting of booleans", this); - connect(a, SIGNAL(triggered()), this, SLOT(testCutColorDS())); - test->addAction(a); - - a = new QAction("Test cutting of floating-points", this); - connect(a, SIGNAL(triggered()), this, SLOT(testCutFloatDS())); - test->addAction(a); - -#endif // TEST - - QMenu * converter = menuBar()->addMenu( "Converter" ); - -#ifdef TEST - - a = new QAction("Number of splits along X", this); - connect(a, SIGNAL(triggered()), this, SLOT(setNbX())); - converter->addAction(a); - - a = new QAction("Number of splits along Y", this); - connect(a, SIGNAL(triggered()), this, SLOT(setNbY())); - converter->addAction(a); - - a = new QAction("Number of splits along Z", this); - connect(a, SIGNAL(triggered()), this, SLOT(setNbZ())); - converter->addAction(a); - - converter->addSeparator(); - - a = new QAction("Side of scanning", this); - connect(a, SIGNAL(triggered()), this, SLOT(setScanSide())); - converter->addAction(a); - - converter->addSeparator(); - - a = new QAction("Volumic value of 1bit voxels", this); - connect(a, SIGNAL(triggered()), this, SLOT(setVolumicBoolValue())); - converter->addAction(a); - - a = new QAction("Volumic value of 4bit voxels", this); - connect(a, SIGNAL(triggered()), this, SLOT(setVolumicColorValue())); - converter->addAction(a); - - converter->addSeparator(); - -#endif // TEST - - a = new QAction("Convert to 1bit voxels", this); - connect(a, SIGNAL(triggered()), this, SLOT(convert2bool())); - converter->addAction(a); - - a = new QAction("Convert to 4bit voxels", this); - connect(a, SIGNAL(triggered()), this, SLOT(convert2color())); - converter->addAction(a); - - QMenu * vis = menuBar()->addMenu( "&Visualization" ); - - a = new QAction("Points", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayPoints())); - vis->addAction(a); - -#ifdef TEST - - a = new QAction("Nearest points", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayNearestPoints())); - vis->addAction(a); - -#endif // TEST - - a = new QAction("Boxes", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayBoxes())); - vis->addAction(a); - -#ifdef TEST - - a = new QAction("Nearest boxes", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayNearestBoxes())); - vis->addAction(a); - -#endif // TEST - - vis->addSeparator(); - - a = new QAction("Point size", this); - connect(a, SIGNAL(triggered()), this, SLOT(setPointSize())); - vis->addAction(a); - - a = new QAction("Quadrangle size (%)", this); - connect(a, SIGNAL(triggered()), this, SLOT(setQuadrangleSize())); - vis->addAction(a); - - vis->addSeparator(); - - a = new QAction("Color min value", this); - connect(a, SIGNAL(triggered()), this, SLOT(setColorMinValue())); - vis->addAction(a); - - a = new QAction("Color max value", this); - connect(a, SIGNAL(triggered()), this, SLOT(setColorMaxValue())); - vis->addAction(a); - -#ifdef TEST - - vis->addSeparator(); - - a = new QAction("Use GL lists", this); - connect(a, SIGNAL(triggered()), this, SLOT(setUsageOfGLlists())); - vis->addAction(a); - -#endif // TEST - - vis->addSeparator(); - - a = new QAction("Displayed X min", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedXMin())); - vis->addAction(a); - - a = new QAction("Displayed X max", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedXMax())); - vis->addAction(a); - - a = new QAction("Displayed Y min", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedYMin())); - vis->addAction(a); - - a = new QAction("Displayed Y max", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedYMax())); - vis->addAction(a); - - a = new QAction("Displayed Z min", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedZMin())); - vis->addAction(a); - - a = new QAction("Displayed Z max", this); - connect(a, SIGNAL(triggered()), this, SLOT(setDisplayedZMax())); - vis->addAction(a); - - - QMenu * demo = menuBar()->addMenu( "Demo" ); - - a = new QAction("Waves", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayWaves())); - demo->addAction(a); - - a = new QAction("Cut", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayCut())); - demo->addAction(a); - - a = new QAction("Collisions", this); - connect(a, SIGNAL(triggered()), this, SLOT(displayCollisions())); - demo->addAction(a); - - - QMenu * help = menuBar()->addMenu( "Help" ); - - a = new QAction("About", this); - a->setShortcut(tr("F1")); - connect(a, SIGNAL(triggered()), this, SLOT(about())); - help->addAction(a); - - - myViewer = new Viewer( this ); - myViewer->setFocus(); - setCentralWidget( myViewer ); - statusBar()->showMessage( "Ready", 2000 ); - - myNbX = 100; - myNbY = 100; - myNbZ = 100; - - myScanSide = 7; - - myVolumicBoolValue = false; - myVolumicColorValue = 0; - - myQuadrangleSize = 40; - - myColorMinValue = 1; - myColorMaxValue = 15; - - myBoolVoxels = 0; - myColorVoxels = 0; - myColorScale = new AIS_ColorScale; - myColorScale->SetZLayer (Graphic3d_ZLayerId_TopOSD); - myColorScale->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)); - - - myDisplayedXMin = -DBL_MAX; - myDisplayedXMax = DBL_MAX; - myDisplayedYMin = -DBL_MAX; - myDisplayedYMax = DBL_MAX; - myDisplayedZMin = -DBL_MAX; - myDisplayedZMax = DBL_MAX; - - resize( 450, 600 ); - - myViewer->getIC()->SetAutoActivateSelection (Standard_False); -} - -Application::~Application() -{ - if (myBoolVoxels) - delete myBoolVoxels; - if (myColorVoxels) - delete myColorVoxels; -} - -void Application::choose() -{ - QString fn = QFileDialog::getOpenFileName( this, QString::null, QString::null, "*.brep"); - if ( !fn.isEmpty() ) - load( fn ); - else - statusBar()->showMessage( "Loading aborted", 2000 ); -} - -void Application::load( const QString &fileName ) -{ - QFile f( fileName ); - if ( !f.open( QIODevice::ReadOnly ) ) - return; - - // Read shape - TopoDS_Shape S; - BRep_Builder B; - if (!BRepTools::Read(S, (char*) fileName.constData(), B)) - statusBar()->showMessage( "Loading failed", 2000 ); - - load(S); -} - -void Application::open() -{ - QString fn = QFileDialog::getOpenFileName( this, QString::null, QString::null, "*.vx"); - if ( fn.isEmpty() || !QFile::exists(fn) ) - { - statusBar()->showMessage( "Open aborted", 2000 ); - return; - } - - Timer timer; - timer.Start(); - - // Read the voxels - Voxel_Reader reader; - if (!reader.Read((char*)fn.constData())) - { - statusBar()->showMessage( "Open failed... sorry", 2000 ); - return; - } - - timer.Stop(); - timer.Print("Open"); - - // Release current voxels - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - if (myColorVoxels) - { - delete myColorVoxels; - myColorVoxels = 0; - } - - // Take the voxels - if (reader.IsBoolVoxels()) - { - myBoolVoxels = (Voxel_BoolDS*) reader.GetBoolVoxels(); - myViewer->getSelector().SetVoxels(*myBoolVoxels); - } - else if (reader.IsColorVoxels()) - { - myColorVoxels = (Voxel_ColorDS*) reader.GetColorVoxels(); - myViewer->getSelector().SetVoxels(*myColorVoxels); - } - - // Display the voxels - myViewer->getIC()->EraseAll(false); - Voxel_DS* ds = myBoolVoxels; - if (!ds) - ds = myColorVoxels; - if (ds) - { - myDisplayedXMin = ds->GetX() - 10.0 * Precision::Confusion(); - myDisplayedXMax = ds->GetX() + ds->GetXLen() + 10.0 * Precision::Confusion(); - myDisplayedYMin = ds->GetY() - 10.0 * Precision::Confusion(); - myDisplayedYMax = ds->GetY() + ds->GetYLen() + 10.0 * Precision::Confusion(); - myDisplayedZMin = ds->GetZ() - 10.0 * Precision::Confusion(); - myDisplayedZMax = ds->GetZ() + ds->GetZLen() + 10.0 * Precision::Confusion(); - } - - // Init visual data - initPrs(); - - // Set voxels and display - Handle(Poly_Triangulation) empty; - myVoxels->SetBoolVoxels(myBoolVoxels); - myVoxels->SetColorVoxels(myColorVoxels); - myVoxels->SetTriangulation(empty); - if (myViewer->getIC()->IsDisplayed(myVoxels)) - myViewer->getIC()->Redisplay(myVoxels, false); - else - myViewer->getIC()->Display(myVoxels, false); - - // Color scale - if (myColorVoxels) - displayColorScale(); - else - myViewer->getIC()->Erase(myColorScale); - - myViewer->getView()->FitAll(); - - statusBar()->showMessage( "Ready.", 2000 ); -} - -void Application::save() -{ - QString fn = QFileDialog::getSaveFileName( this, QString::null, QString::null, "*.vx"); - if ( fn.isEmpty() ) - { - statusBar()->showMessage( "Storage aborted", 2000 ); - return; - } - if (fn.indexOf(".vx", -1, Qt::CaseInsensitive) == -1) - fn += ".vx"; - - Timer timer; - timer.Start(); - - // Write the voxels - Voxel_Writer writer; - writer.SetFormat(Voxel_VFF_BINARY); - if (myBoolVoxels) - writer.SetVoxels(*myBoolVoxels); - else if (myColorVoxels) - writer.SetVoxels(*myColorVoxels); - else - { - statusBar()->showMessage( "Nothing to store", 2000 ); - return; - } - if (!writer.Write((char*)fn.constData())) - { - statusBar()->showMessage( "Storage failed... sorry", 2000 ); - return; - } - - timer.Stop(); - timer.Print("Save"); - - statusBar()->showMessage( "Saved.", 2000 ); -} - -void Application::closeEvent( QCloseEvent* ce ) -{ - ce->accept(); -} - -void Application::about() -{ - QMessageBox::about( this, "Voxel demo-application", - "This example demonstrates simple usage of " - "voxel models of Open CASCADE."); -} - -void Application::testBoolDS() -{ - Timer timer; - int ix, iy, iz; - int nbx = 100, nby = 100, nbz = 100; - - - // 1. BoolDS: - - timer.Start(); - - Voxel_BoolDS ds(0, 0, 0, 1, 1, 1, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds.Set(ix, iy, iz, false); - else - ds.Set(ix, iy, iz, true); - } - } - } - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - bool value = ds.Get(ix, iy, iz) == Standard_True; - if (ix & 0x01) - { - if (value != false) - cout<<"Wrong value!"<OptimizeMemory(); - - timer.Stop(); - timer.Print("ROctBoolDS::converter"); - - - // Display - myViewer->getIC()->EraseAll(false); - initPrs(); - myVoxels->SetBoolVoxels(0); - myVoxels->SetColorVoxels(0); - Handle(Poly_Triangulation) empty; - myVoxels->SetTriangulation(empty); - myVoxels->SetROctBoolVoxels(ds2); - myViewer->getIC()->Display(myVoxels, false); - myViewer->getIC()->Erase(myColorScale); - myViewer->getView()->FitAll(); - myViewer->getSelector().SetVoxels(*ds2); -} - -void Application::testFuseBoolDS() -{ - Timer timer; - int ix, iy, iz; - int nbx = 100, nby = 100, nbz = 100; - - - // 1. Set two BoolDS: - - timer.Start(); - - Voxel_BoolDS ds1(0, 0, 0, 1, 1, 1, nbx, nby, nbz); - Voxel_BoolDS ds2(0, 0, 0, 1, 1, 1, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds2.Set(ix, iy, iz, false); - else - ds2.Set(ix, iy, iz, true); - } - } - } - - // 2. Fuse them - - Voxel_BooleanOperation fuser; - if (!fuser.Fuse(ds1, ds2)) - cout<<"The operation failed..."< 0.001) - cout<<"Wrong value!"< 0.001) - cout<<"Wrong value!"< 0.001) - cout<<"Wrong value!"< 0.001) - cout<<"Wrong value!"<Shape(); - if (S.IsNull()) - { - QMessageBox::warning( this, "Voxel demo-application", "No shape for conversion!"); - return; - } - - switch (ivoxel) - { - case 0: - { - if (!myBoolVoxels) - myBoolVoxels = new Voxel_BoolDS; - if (myColorVoxels) - { - delete myColorVoxels; - myColorVoxels = 0; - } - break; - } - case 1: - { - if (!myColorVoxels) - myColorVoxels = new Voxel_ColorDS; - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - break; - } - } - - switch (ivoxel) - { - case 0: - { - Timer timer; - timer.Start(); - - /* - int progress; - Voxel_Converter converter(S, *myBoolVoxels, myNbX, myNbY, myNbZ); - if (!converter.Convert(progress, myVolumicBoolValue, myScanSide)) - { - QMessageBox::warning( this, "Voxel demo-application", "Conversion failed..."); - return; - } - */ - - /* - Voxel_Converter converter(S, *myBoolVoxels, myNbX, myNbY, myNbZ, 2); - ConversionThread thread1, thread2; - - thread1.setConverter(&converter); - thread2.setConverter(&converter); - - thread1.setVolumicValue(myVolumicBoolValue); - thread2.setVolumicValue(myVolumicBoolValue); - - thread1.setScanSide(myScanSide); - thread2.setScanSide(myScanSide); - - thread1.setThreadIndex(1); - thread2.setThreadIndex(2); - - thread1.start(); - thread2.start(); - - while (thread1.running() || thread2.running()) - { - ::Sleep(100); - } - */ - - /* - int progress; - Voxel_FastConverter converter(S, *myBoolVoxels, 0.1, myNbX, myNbY, myNbZ, 1); - converter.Convert(progress, 1); - //if (myVolumicBoolValue) - // converter.FillInVolume(myVolumicBoolValue); - */ - - Voxel_FastConverter converter(S, *myBoolVoxels, 0.1, myNbX, myNbY, myNbZ, 2); - ConversionThread thread1, thread2; - - thread1.setConverter(&converter); - thread2.setConverter(&converter); - - thread1.setThreadIndex(1); - thread2.setThreadIndex(2); - - thread1.start(); - thread2.start(); - - while (thread1.isRunning() || thread2.isRunning()) - { - ::Sleep(100); - } - - timer.Print("Converter"); - - myViewer->getSelector().SetVoxels(*myBoolVoxels); - break; - } - case 1: - { - - Timer timer; - timer.Start(); - - /* - int progress; - Voxel_Converter converter(S, *myColorVoxels, myNbX, myNbY, myNbZ); - if (!converter.Convert(progress, myVolumicColorValue, myScanSide)) - { - QMessageBox::warning( this, "Voxel demo-application", "Conversion failed..."); - return; - } - */ - - /* - Voxel_Converter converter(S, *myColorVoxels, myNbX, myNbY, myNbZ, 2); - ConversionThread thread1, thread2; - - thread1.setConverter(&converter); - thread2.setConverter(&converter); - - thread1.setVolumicValue(myVolumicColorValue); - thread2.setVolumicValue(myVolumicColorValue); - - thread1.setScanSide(myScanSide); - thread2.setScanSide(myScanSide); - - thread1.setThreadIndex(1); - thread2.setThreadIndex(2); - - thread1.start(); - thread2.start(); - - while (thread1.running() || thread2.running()) - { - ::Sleep(100); - } - */ - - /* - int progress; - Voxel_FastConverter converter(S, *myColorVoxels, myNbX, myNbY, myNbZ, 1); - converter.Convert(progress, 1); - if (myVolumicColorValue) - converter.FillInVolume(myVolumicColorValue); - */ - - Voxel_FastConverter converter(S, *myColorVoxels, 0.1, myNbX, myNbY, myNbZ, 2); - ConversionThread thread1, thread2; - - thread1.setConverter(&converter); - thread2.setConverter(&converter); - - thread1.setThreadIndex(1); - thread2.setThreadIndex(2); - - thread1.start(); - thread2.start(); - - while (thread1.isRunning() || thread2.isRunning()) - { - ::Sleep(100); - } - - timer.Print("Converter"); - - - // Set color for demonstration - double maxd = - fabs(myColorVoxels->GetX()) > fabs(myColorVoxels->GetY()) ? - fabs(myColorVoxels->GetX()) : fabs(myColorVoxels->GetY()); - maxd = maxd > fabs(myColorVoxels->GetZ()) ? maxd : fabs(myColorVoxels->GetZ()); - maxd = maxd > fabs(myColorVoxels->GetX() + myColorVoxels->GetXLen()) ? - maxd : fabs(myColorVoxels->GetX() + myColorVoxels->GetXLen()); - maxd = maxd > fabs(myColorVoxels->GetY() + myColorVoxels->GetYLen()) ? - maxd : fabs(myColorVoxels->GetY() + myColorVoxels->GetYLen()); - maxd = maxd > fabs(myColorVoxels->GetZ() + myColorVoxels->GetZLen()) ? - maxd : fabs(myColorVoxels->GetZ() + myColorVoxels->GetZLen()); - for (int ix = 0; ix < myNbX; ix++) - { - for (int iy = 0; iy < myNbY; iy++) - { - for (int iz = 0; iz < myNbZ; iz++) - { - unsigned char value = myColorVoxels->Get(ix, iy, iz); - if (value) - { - double xc, yc, zc, xd, yd, zd; - myColorVoxels->GetCenter(ix, iy, iz, xc, yc, zc); - xd = fabs(xc); - yd = fabs(yc); - zd = fabs(zc); - double mind = xd < yd ? xd : yd; - mind = zd < mind ? zd : mind; - value = unsigned char(15.0 * (maxd - mind) / maxd); - if (value <= 0) - value = 1; - myColorVoxels->Set(ix, iy, iz, value); - } - } - } - } - - myViewer->getSelector().SetVoxels(*myColorVoxels); - break; - } - } - - myViewer->getIC()->EraseAll(false); - - Voxel_DS* ds = myBoolVoxels; - if (!ds) - ds = myColorVoxels; - if (ds) - { - myDisplayedXMin = ds->GetX() - 10.0 * Precision::Confusion(); - myDisplayedXMax = ds->GetX() + ds->GetXLen() + 10.0 * Precision::Confusion(); - myDisplayedYMin = ds->GetY() - 10.0 * Precision::Confusion(); - myDisplayedYMax = ds->GetY() + ds->GetYLen() + 10.0 * Precision::Confusion(); - myDisplayedZMin = ds->GetZ() - 10.0 * Precision::Confusion(); - myDisplayedZMax = ds->GetZ() + ds->GetZLen() + 10.0 * Precision::Confusion(); - } - - // Init visual data - initPrs(); - - // Set voxels and display - Handle(Poly_Triangulation) empty; - myVoxels->SetBoolVoxels(myBoolVoxels); - myVoxels->SetColorVoxels(myColorVoxels); - myVoxels->SetTriangulation(empty); - if (myViewer->getIC()->IsDisplayed(myVoxels)) - myViewer->getIC()->Redisplay(myVoxels, false); - else - myViewer->getIC()->Display(myVoxels, false); - - // Color scale - if (myColorVoxels) - displayColorScale(); - else - myViewer->getIC()->Erase(myColorScale); - - myViewer->getView()->FitAll(); -} - -void Application::setNbX() -{ - bool ok; - myNbX = - QInputDialog::getInteger(this, "Voxel demo-application", "Number of splits in X-direction:", myNbX, - 1, 100000, 1, &ok); -} - -void Application::setNbY() -{ - bool ok; - myNbY = - QInputDialog::getInteger(this, "Voxel demo-application", "Number of splits in X-direction:", myNbY, - 1, 100000, 1, &ok); -} - -void Application::setNbZ() -{ - bool ok; - myNbZ = - QInputDialog::getInteger(this, "Voxel demo-application", "Number of splits in X-direction:", myNbZ, - 1, 100000, 1, &ok); -} - -void Application::setColorMinValue() -{ - bool ok; - myColorMinValue = - QInputDialog::getInteger(this, "Voxel demo-application", "Minimum value for color [0 .. 15]:", myColorMinValue, - 0, 15, 1, &ok); - if (!myVoxels.IsNull()) - myVoxels->SetColorRange(myColorMinValue, myColorMaxValue); -} - -void Application::setColorMaxValue() -{ - bool ok; - myColorMaxValue = - QInputDialog::getInteger(this, "Voxel demo-application", "Maximum value for color [0 .. 15]:", myColorMaxValue, - 0, 15, 1, &ok); - if (!myVoxels.IsNull()) - myVoxels->SetColorRange(myColorMinValue, myColorMaxValue); -} - -void Application::setUsageOfGLlists() -{ - int res = QMessageBox::question( this, "Voxel demo-application", "Press Yes to use GL lists and No not to use them.", QMessageBox::Yes, QMessageBox::No); - if (!myVoxels.IsNull()) - myVoxels->SetUsageOfGLlists(res == QMessageBox::Yes); -} - -void Application::setDisplayedXMin() -{ - myDisplayedXMin = QInputDialog::getDouble(this, "Voxel demo-application", "Minimum X value:", myDisplayedXMin); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setDisplayedXMax() -{ - myDisplayedXMax = QInputDialog::getDouble(this, "Voxel demo-application", "Maximum X value:", myDisplayedXMax); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setDisplayedYMin() -{ - myDisplayedYMin = QInputDialog::getDouble(this, "Voxel demo-application", "Minimum Y value:", myDisplayedYMin); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setDisplayedYMax() -{ - myDisplayedYMax = QInputDialog::getDouble(this, "Voxel demo-application", "Maximum Y value:", myDisplayedYMax); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setDisplayedZMin() -{ - myDisplayedZMin = QInputDialog::getDouble(this, "Voxel demo-application", "Minimum Z value:", myDisplayedZMin); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setDisplayedZMax() -{ - myDisplayedZMax = QInputDialog::getDouble(this, "Voxel demo-application", "Maximum Z value:", myDisplayedZMax); - if (!myVoxels.IsNull()) - { - myVoxels->SetSizeRange(myDisplayedXMin, myDisplayedXMax, - myDisplayedYMin, myDisplayedYMax, - myDisplayedZMin, myDisplayedZMax); - } -} - -void Application::setScanSide() -{ - myScanSide = - QInputDialog::getInteger(this, "Voxel demo-application", "Side of scanning (1: +X side, 2: +Y side, 3: +Z side, 4: +X & +Y sides, .. 7: +X, +Y,& +Z sides):", - myScanSide, 1, 7, 1); -} - -void Application::setVolumicBoolValue() -{ - myVolumicBoolValue = - QInputDialog::getInteger(this, "Voxel demo-application", "Volumic value on voxelization [0 .. 1]:", - myVolumicBoolValue, 0, 1, 1); -} - -void Application::setVolumicColorValue() -{ - myVolumicColorValue = - QInputDialog::getInteger(this, "Voxel demo-application", "Volumic value on voxelization [0 .. 15]:", - myVolumicColorValue, 0, 15, 1); -} - -void Application::setQuadrangleSize() -{ - myQuadrangleSize = - QInputDialog::getInteger(this, "Voxel demo-application", "Size of quadrangles (0% .. 100%):", - myQuadrangleSize, 1, 100, 10); - if (!myVoxels.IsNull()) - { - myVoxels->SetQuadrangleSize(myQuadrangleSize); - } -} - -void Application::setPointSize() -{ - myPointSize = - QInputDialog::getInteger(this, "Voxel demo-application", "Size of points (1 .. 10):", - myPointSize, 1, 10, 1); - if (!myVoxels.IsNull()) - { - myVoxels->SetPointSize(myPointSize); - } -} - -void Application::display(Voxel_VoxelDisplayMode mode) -{ - if (myVoxels.IsNull() || !myViewer->getIC()->IsDisplayed(myVoxels)) - { - QMessageBox::warning( this, "Voxel demo-application", "Voxels are not displayed"); - return; - } - - myVoxels->SetDisplayMode(mode); - - if (myColorVoxels) - displayColorScale(); - else - myViewer->getIC()->Erase(myColorScale); - - myViewer->getIC()->Redisplay(myVoxels, true); -} - -void Application::displayPoints() -{ - display(Voxel_VDM_POINTS); -} - -void Application::displayNearestPoints() -{ - display(Voxel_VDM_NEARESTPOINTS); -} - -void Application::displayBoxes() -{ - display(Voxel_VDM_BOXES); -} - -void Application::displayNearestBoxes() -{ - display(Voxel_VDM_NEARESTBOXES); -} - -void Application::displayColorScale() -{ - if (myColorScale.IsNull()) - { - myColorScale = new AIS_ColorScale; - } - if (!myColorScale.IsNull()) - { - int nb_colors = 1<<4 /* 4 bits */; - myColorScale->SetRange(0, nb_colors - 1); - myColorScale->SetNumberOfIntervals(nb_colors); - myColorScale->SetPosition(0.01, 0.5 - 0.01); - myColorScale->SetSize(0.5 - 0.01, 0.5 - 0.01); - } - myViewer->getIC()->Display(myColorScale); -} - -void Application::displayWaves() -{ - myViewer->getIC()->EraseAll(false); - - // Make voxels - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - if (myColorVoxels) - delete myColorVoxels; - - int nbx = 500, nby = 50, nbz = 50; - double xlen = 100.0, ylen = 100.0, zlen = 20.0; - double dx = xlen / (double) nbx, dy = ylen / (double) nby, dz = zlen / (double) nbz; - myColorVoxels = new Voxel_ColorDS(0.0, 0.0, 0.0, xlen, ylen, zlen, nbx, nby, nbz); - - // Initial state - no colors - int ix, iy, iz; - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - myColorVoxels->Set(ix, iy, iz, 0); - } - } - } - - // Init visual data - initPrs(); - myVoxels->SetDisplayMode(Voxel_VDM_POINTS); - myVoxels->SetUsageOfGLlists(false); - myVoxels->SetBoolVoxels(myBoolVoxels); - myVoxels->SetColorVoxels(myColorVoxels); - if (myViewer->getIC()->IsDisplayed(myVoxels)) - myViewer->getIC()->Redisplay(myVoxels, false); - else - myViewer->getIC()->Display(myVoxels, false); - myViewer->getView()->FitAll(); - - // Prepare arrays of values - // X&Z values - int i = 0, di = 5 /* nb waves */; - int* zvalues = new int[nbx]; - unsigned char* xvalues = new unsigned char[nbx]; - for (ix = 0; ix < nbx; ix++, i += di) - { - if (i > nbx || i < 0) - { - di *= -1; - i += di; - } - double rad = -M_PI / 2.0 + double(i) / (double) nbx * M_PI; - double c = cos(rad); - xvalues[ix] = 15.0 * c; - if (xvalues[ix] == 0) - xvalues[ix] = 1; - zvalues[ix] = (nbz - 2) * c; - } - - // Make waves - unsigned char value = 0; - for (i = 0; i <= 100; i++) - { - for (ix = 0; ix < nbx; ix++) - { - int ixi = ix + i; - if (ixi >= nbx) - ixi -= nbx; - for (iz = 0; iz < nbz; iz++) - { - value = 0; - if (iz < zvalues[ixi]) - value = xvalues[ixi]; - for (iy = 0; iy < nby; iy++) - { - myColorVoxels->Set(ix, iy, iz, value); - } - } - } - myViewer->getIC()->Redisplay(myVoxels, true); - qApp->processEvents(); - } - - delete[] xvalues; - delete[] zvalues; -} - -void Application::initPrs() -{ - if (myVoxels.IsNull()) - { - myVoxels = new VoxelClient_PrsGl(); - myVoxels->SetDisplayMode(Voxel_VDM_POINTS); - myVoxels->SetColor(Quantity_NOC_WHITE); - myVoxels->SetPointSize(1.0); - myVoxels->SetSmoothPoints(false); - myVoxels->SetQuadrangleSize(myQuadrangleSize); - myVoxels->SetColorRange(myColorMinValue, myColorMaxValue); - // Colors of ColorDS - int nb_colors = 16 /* 4 bits */; - Handle(Quantity_HArray1OfColor) colors = new Quantity_HArray1OfColor(0, nb_colors - 1); - for (int icolor = 0; icolor < nb_colors; icolor++) - { - Quantity_Color color; - AIS_ColorScale::FindColor(icolor, 0, nb_colors - 1, nb_colors, color); - colors->SetValue(icolor, color); - } - myVoxels->SetColors(colors); - myViewer->setPrs(myVoxels); - } - else - { - myViewer->getIC()->RecomputePrsOnly(myVoxels, false); - } -} - -void Application::box() -{ - gp_Ax2 axes(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1)); - TopoDS_Shape S = BRepPrimAPI_MakeBox(axes, 100, 100, 100); - load(S); -} - -void Application::cylinder() -{ - TopoDS_Shape S = BRepPrimAPI_MakeCylinder(50, 100); - load(S); -} - -void Application::torus() -{ - TopoDS_Shape S = BRepPrimAPI_MakeTorus(100, 20); - load(S); -} - -void Application::sphere() -{ - TopoDS_Shape S = BRepPrimAPI_MakeSphere(100); - load(S); -} - -void Application::load(const TopoDS_Shape& S) -{ - myViewer->getIC()->EraseAll(false); - - // Delete voxels of previous shape. - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - if (myColorVoxels) - { - delete myColorVoxels; - myColorVoxels = 0; - } - - // Set view size - Bnd_Box box; - double xmin, ymin, zmin, xmax, ymax, zmax, length = 0; - BRepBndLib::Add(S, box); - box.Get(xmin, ymin, zmin, xmax, ymax, zmax); - length = xmax - xmin > ymax - ymin ? xmax - xmin : ymax - ymin; - length = length > zmax - zmin ? length : zmax - zmin; - length *= 2.0; - myViewer->getView()->SetSize(length); - myViewer->getView()->SetZSize(length); - - // Display shape - if (myShape.IsNull()) - { - myShape = new AIS_Shape(S); - myShape->SetDisplayMode(1); - } - else - { - myShape->Set(S); - myViewer->getIC()->RecomputePrsOnly(myShape, false); - } - if (myViewer->getIC()->IsDisplayed(myShape)) - myViewer->getIC()->Redisplay(myShape, false); - else - myViewer->getIC()->Display(myShape, false); - myViewer->getView()->FitAll(); -} - -void Application::displayCut() -{ - myViewer->getIC()->EraseAll(false); - - // Make a sphere with a lot of toruses, - // cut the toruses from the sphere. - TopoDS_Shape sphere = BRepPrimAPI_MakeSphere(100.0); - TopoDS_Shape torus1 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt( 80, 0, 20), gp::DZ()), 30, 10); - TopoDS_Shape torus2 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt( 0, 80, 20), gp::DZ()), 30, 10); - TopoDS_Shape torus3 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(-80, 0, 20), gp::DZ()), 30, 10); - TopoDS_Shape torus4 = BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt( 0, -80, 20), gp::DZ()), 30, 10); - - // Compute bounding box of the shapes - Bnd_Box box; - BRepBndLib::Add(sphere, box); - BRepBndLib::Add(torus1, box); - BRepBndLib::Add(torus2, box); - BRepBndLib::Add(torus3, box); - BRepBndLib::Add(torus4, box); - - // Nullify voxels - if (myColorVoxels) - { - delete myColorVoxels; - myColorVoxels = 0; - } - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - - Timer timer; - timer.Start(); - - // Create a cube of voxels - int nbx = 100, nby = 100, nbz = 100; - double xmin, ymin, zmin, xmax, ymax, zmax; - box.Get(xmin, ymin, zmin, xmax, ymax, zmax); - myColorVoxels = new Voxel_ColorDS(xmin, ymin, zmin, - xmax - xmin, ymax - ymin, zmax - zmin, - nbx, nby, nbz); - Voxel_ColorDS vtorus(xmin, ymin, zmin, - xmax - xmin, ymax - ymin, zmax - zmin, - nbx, nby, nbz); - - // Make a cube of voxels for the sphere. - int progress; - Voxel_FastConverter converter(sphere, *myColorVoxels, 0.1, nbx, nby, nbz); - converter.Convert(progress); - converter.FillInVolume(15); - - // Torus 1 - Voxel_FastConverter converter1(torus1, vtorus, 0.1, nbx, nby, nbz); - converter1.Convert(progress); - converter1.FillInVolume(3); - - // Torus 2 - Voxel_FastConverter converter2(torus2, vtorus, 0.1, nbx, nby, nbz); - converter2.Convert(progress); - converter2.FillInVolume(7); - - // Torus 3 - Voxel_FastConverter converter3(torus3, vtorus, 0.1, nbx, nby, nbz); - converter3.Convert(progress); - converter3.FillInVolume(10); - - // Torus 4 - Voxel_FastConverter converter4(torus4, vtorus, 0.1, nbx, nby, nbz); - converter4.Convert(progress); - converter4.FillInVolume(12); - - // Cut - Voxel_BooleanOperation cutter; - cutter.Cut(*myColorVoxels, vtorus); - - // Remove volumic voxels - converter.FillInVolume(0); - - timer.Stop(); - timer.Print("Cut"); - - // Display - initPrs(); - myVoxels->SetDisplayMode(Voxel_VDM_POINTS); - myVoxels->SetUsageOfGLlists(true); - myVoxels->SetBoolVoxels(myBoolVoxels); - myVoxels->SetColorVoxels(myColorVoxels); - if (myViewer->getIC()->IsDisplayed(myVoxels)) - myViewer->getIC()->Redisplay(myVoxels, false); - else - myViewer->getIC()->Display(myVoxels, false); - myViewer->getView()->FitAll(); -} - -void Application::displayCollisions() -{ - myViewer->getIC()->EraseAll(false); - - // Make a big box with a lot of small spheres inside. - double x = 0.0, y = 0.0, z = 0.0, xlen = 100.0, ylen = 100.0, zlen = 100.0, r = 10.0; - gp_Pnt P1(x, y, z); // center point of moving sphere (S1). - TopoDS_Shape B = BRepPrimAPI_MakeBox(gp_Pnt(x-r, y-r, z-r), gp_Pnt(xlen+r, ylen+r, zlen+r)); - TopoDS_Shape S1 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, y, z), gp::DZ()), r / 2.0); - TopoDS_Shape S2 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., y, z), gp::DZ()), r); - TopoDS_Shape S3 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, y, z), gp::DZ()), r); - TopoDS_Shape S4 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen/2., z), gp::DZ()), r); - TopoDS_Shape S5 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen/2., z), gp::DZ()), r); - TopoDS_Shape S6 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen/2., z), gp::DZ()), r); - TopoDS_Shape S7 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen, z), gp::DZ()), r); - TopoDS_Shape S8 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen, z), gp::DZ()), r); - TopoDS_Shape S9 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen, z), gp::DZ()), r); - TopoDS_Shape S10 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, y, zlen/2.), gp::DZ()), r); - TopoDS_Shape S11 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., y, zlen/2.), gp::DZ()), r); - TopoDS_Shape S12 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, y, zlen/2.), gp::DZ()), r); - TopoDS_Shape S13 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen/2., zlen/2.), gp::DZ()), r); - TopoDS_Shape S14 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen/2., zlen/2.), gp::DZ()), r); - TopoDS_Shape S15 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen/2., zlen/2.), gp::DZ()), r); - TopoDS_Shape S16 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen, zlen/2.), gp::DZ()), r); - TopoDS_Shape S17 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen, zlen/2.), gp::DZ()), r); - TopoDS_Shape S18 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen, zlen/2.), gp::DZ()), r); - TopoDS_Shape S19 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, y, zlen), gp::DZ()), r); - TopoDS_Shape S20 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., y, zlen), gp::DZ()), r); - TopoDS_Shape S21 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, y, zlen), gp::DZ()), r); - TopoDS_Shape S22 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen/2., zlen), gp::DZ()), r); - TopoDS_Shape S23 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen/2., zlen), gp::DZ()), r); - TopoDS_Shape S24 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen/2., zlen), gp::DZ()), r); - TopoDS_Shape S25 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(x, ylen, zlen), gp::DZ()), r); - TopoDS_Shape S26 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen/2., ylen, zlen), gp::DZ()), r); - TopoDS_Shape S27 = BRepPrimAPI_MakeSphere(gp_Ax2(gp_Pnt(xlen, ylen, zlen), gp::DZ()), r); - - // Planes of the big box - gp_Ax2 xminusPlane(gp_Pnt(x, y, z), gp::DX()); - gp_Ax2 xplusPlane (gp_Pnt(xlen, y, z), gp::DX()); - gp_Ax2 yminusPlane(gp_Pnt(x, y, z), gp::DY()); - gp_Ax2 yplusPlane (gp_Pnt(x, ylen, z), gp::DY()); - gp_Ax2 zminusPlane(gp_Pnt(x, y, z), gp::DZ()); - gp_Ax2 zplusPlane (gp_Pnt(x, y, zlen), gp::DZ()); - - // Nullify voxels - if (myColorVoxels) - { - delete myColorVoxels; - myColorVoxels = 0; - } - if (myBoolVoxels) - { - delete myBoolVoxels; - myBoolVoxels = 0; - } - - // Prepare visualization - initPrs(); - myVoxels->SetDisplayMode(Voxel_VDM_POINTS); - myVoxels->SetColor(Quantity_NOC_RED); - myVoxels->SetPointSize(4); - myVoxels->SetSmoothPoints(false); - myVoxels->SetUsageOfGLlists(false); - myVoxels->SetColorVoxels(myColorVoxels); - - // Display all shapes - double transparency = 0.9; - Handle(AIS_Shape) aisB = new AIS_Shape(B); - Handle(AIS_Shape) aisS1 = new AIS_Shape(S1); - Handle(AIS_Shape) aisS2 = new AIS_Shape(S2); - Handle(AIS_Shape) aisS3 = new AIS_Shape(S3); - Handle(AIS_Shape) aisS4 = new AIS_Shape(S4); - Handle(AIS_Shape) aisS5 = new AIS_Shape(S5); - Handle(AIS_Shape) aisS6 = new AIS_Shape(S6); - Handle(AIS_Shape) aisS7 = new AIS_Shape(S7); - Handle(AIS_Shape) aisS8 = new AIS_Shape(S8); - Handle(AIS_Shape) aisS9 = new AIS_Shape(S9); - Handle(AIS_Shape) aisS10 = new AIS_Shape(S10); - Handle(AIS_Shape) aisS11 = new AIS_Shape(S11); - Handle(AIS_Shape) aisS12 = new AIS_Shape(S12); - Handle(AIS_Shape) aisS13 = new AIS_Shape(S13); - Handle(AIS_Shape) aisS14 = new AIS_Shape(S14); - Handle(AIS_Shape) aisS15 = new AIS_Shape(S15); - Handle(AIS_Shape) aisS16 = new AIS_Shape(S16); - Handle(AIS_Shape) aisS17 = new AIS_Shape(S17); - Handle(AIS_Shape) aisS18 = new AIS_Shape(S18); - Handle(AIS_Shape) aisS19 = new AIS_Shape(S19); - Handle(AIS_Shape) aisS20 = new AIS_Shape(S20); - Handle(AIS_Shape) aisS21 = new AIS_Shape(S21); - Handle(AIS_Shape) aisS22 = new AIS_Shape(S22); - Handle(AIS_Shape) aisS23 = new AIS_Shape(S23); - Handle(AIS_Shape) aisS24 = new AIS_Shape(S24); - Handle(AIS_Shape) aisS25 = new AIS_Shape(S25); - Handle(AIS_Shape) aisS26 = new AIS_Shape(S26); - Handle(AIS_Shape) aisS27 = new AIS_Shape(S27); - aisS1-> SetDisplayMode(1); - aisS2-> SetDisplayMode(1); - aisS3-> SetDisplayMode(1); - aisS4-> SetDisplayMode(1); - aisS5-> SetDisplayMode(1); - aisS6-> SetDisplayMode(1); - aisS7-> SetDisplayMode(1); - aisS8-> SetDisplayMode(1); - aisS9-> SetDisplayMode(1); - aisS10->SetDisplayMode(1); - aisS11->SetDisplayMode(1); - aisS12->SetDisplayMode(1); - aisS13->SetDisplayMode(1); - aisS14->SetDisplayMode(1); - aisS15->SetDisplayMode(1); - aisS16->SetDisplayMode(1); - aisS17->SetDisplayMode(1); - aisS18->SetDisplayMode(1); - aisS19->SetDisplayMode(1); - aisS20->SetDisplayMode(1); - aisS21->SetDisplayMode(1); - aisS22->SetDisplayMode(1); - aisS23->SetDisplayMode(1); - aisS24->SetDisplayMode(1); - aisS25->SetDisplayMode(1); - aisS26->SetDisplayMode(1); - aisS27->SetDisplayMode(1); - aisS1-> SetTransparency(2.0 * transparency / 3.0); - aisS2-> SetTransparency(transparency); - aisS3-> SetTransparency(transparency); - aisS4-> SetTransparency(transparency); - aisS5-> SetTransparency(transparency); - aisS6-> SetTransparency(transparency); - aisS7-> SetTransparency(transparency); - aisS8-> SetTransparency(transparency); - aisS9-> SetTransparency(transparency); - aisS10->SetTransparency(transparency); - aisS11->SetTransparency(transparency); - aisS12->SetTransparency(transparency); - aisS13->SetTransparency(transparency); - aisS14->SetTransparency(transparency); - aisS15->SetTransparency(transparency); - aisS16->SetTransparency(transparency); - aisS17->SetTransparency(transparency); - aisS18->SetTransparency(transparency); - aisS19->SetTransparency(transparency); - aisS20->SetTransparency(transparency); - aisS21->SetTransparency(transparency); - aisS22->SetTransparency(transparency); - aisS23->SetTransparency(transparency); - aisS24->SetTransparency(transparency); - aisS25->SetTransparency(transparency); - aisS26->SetTransparency(transparency); - aisS27->SetTransparency(transparency); - myViewer->getIC()->Display(aisB, false); - myViewer->getIC()->Display(aisS1, false); - myViewer->getIC()->Display(aisS2, false); - myViewer->getIC()->Display(aisS3, false); - myViewer->getIC()->Display(aisS4, false); - myViewer->getIC()->Display(aisS5, false); - myViewer->getIC()->Display(aisS6, false); - myViewer->getIC()->Display(aisS7, false); - myViewer->getIC()->Display(aisS8, false); - myViewer->getIC()->Display(aisS9, false); - myViewer->getIC()->Display(aisS10, false); - myViewer->getIC()->Display(aisS11, false); - myViewer->getIC()->Display(aisS12, false); - myViewer->getIC()->Display(aisS13, false); - myViewer->getIC()->Display(aisS14, false); - myViewer->getIC()->Display(aisS15, false); - myViewer->getIC()->Display(aisS16, false); - myViewer->getIC()->Display(aisS17, false); - myViewer->getIC()->Display(aisS18, false); - myViewer->getIC()->Display(aisS19, false); - myViewer->getIC()->Display(aisS20, false); - myViewer->getIC()->Display(aisS21, false); - myViewer->getIC()->Display(aisS22, false); - myViewer->getIC()->Display(aisS23, false); - myViewer->getIC()->Display(aisS24, false); - myViewer->getIC()->Display(aisS25, false); - myViewer->getIC()->Display(aisS26, false); - myViewer->getIC()->Display(aisS27, false); - - // Prepare computer of collisions - double deflection = 0.1; - int nbx = 100, nby = 100, nbz = 100; - - Voxel_CollisionDetection coldet(deflection, nbx, nby, nbz); - coldet.SetUsageOfVolume(false); - coldet.KeepCollisions(false); - coldet.AddShape(S1); - coldet.AddShape(S2); - coldet.AddShape(S3); - coldet.AddShape(S4); - coldet.AddShape(S5); - coldet.AddShape(S6); - coldet.AddShape(S7); - coldet.AddShape(S8); - coldet.AddShape(S9); - coldet.AddShape(S10); - coldet.AddShape(S11); - coldet.AddShape(S12); - coldet.AddShape(S13); - coldet.AddShape(S14); - coldet.AddShape(S15); - coldet.AddShape(S16); - coldet.AddShape(S17); - coldet.AddShape(S18); - coldet.AddShape(S19); - coldet.AddShape(S20); - coldet.AddShape(S21); - coldet.AddShape(S22); - coldet.AddShape(S23); - coldet.AddShape(S24); - coldet.AddShape(S25); - coldet.AddShape(S26); - coldet.AddShape(S27); - //coldet.AddShape(BRepPrimAPI_MakeBox(gp_Pnt(x, y, z), gp_Pnt(xlen, ylen, zlen))); - - Bnd_Box box; - BRepBndLib::Add(B, box); - coldet.SetBoundaryBox(box); - - coldet.Voxelize(); - - // Move one of the spheres inside the box - // and compute collisions - gp_Trsf trsf; - gp_Vec vmove(1, 0.5, 0.25); - - int imove = 0, nb_moves = 900; - while (imove < nb_moves) - { - // Move - trsf.SetTranslation(vmove); - TopLoc_Location loc(trsf); - S1.Move(loc); - P1.Translate(vmove); - - // Check whether S1 is inside the big box - // Detect the plane S1 touches to. - if (P1.X() < x) - vmove.Mirror(xminusPlane); - else if (P1.X() > xlen) - vmove.Mirror(xplusPlane); - else if (P1.Y() < y) - vmove.Mirror(yminusPlane); - else if (P1.Y() > ylen) - vmove.Mirror(yplusPlane); - else if (P1.Z() < z) - vmove.Mirror(zminusPlane); - else if (P1.Z() > zlen) - vmove.Mirror(zplusPlane); - - // Compute collisions - coldet.ReplaceShape(1, S1); - coldet.Voxelize(1); // only the first sphere (S1) - coldet.Compute(); - myBoolVoxels = &((Voxel_BoolDS&) coldet.GetCollisions()); - - // Redisplay S1 - aisS1->Set(S1); - myViewer->getIC()->Redisplay(aisS1, false); - - // Display the collisions - myVoxels->SetBoolVoxels(myBoolVoxels); - if (myViewer->getIC()->IsDisplayed(myVoxels)) - myViewer->getIC()->Redisplay(myVoxels, true); - else - { - myViewer->getIC()->Display(myVoxels, false); - myViewer->getView()->FitAll(); - } - - imove++; - qApp->processEvents(); - } - - // Copy the result of collision detection - int ix, iy, iz; - myBoolVoxels = new Voxel_BoolDS(coldet.GetCollisions().GetX(), - coldet.GetCollisions().GetY(), - coldet.GetCollisions().GetZ(), - coldet.GetCollisions().GetXLen(), - coldet.GetCollisions().GetYLen(), - coldet.GetCollisions().GetZLen(), - nbx, nby, nbz); - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (coldet.GetCollisions().Get(ix, iy, iz)) - myBoolVoxels->Set(ix, iy, iz, Standard_True); - } - } - } - myVoxels->SetBoolVoxels(myBoolVoxels); -} \ No newline at end of file diff --git a/samples/qt/VoxelDemo/src/ConversionThread.cpp b/samples/qt/VoxelDemo/src/ConversionThread.cpp deleted file mode 100644 index 6fee824a80..0000000000 --- a/samples/qt/VoxelDemo/src/ConversionThread.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "ConversionThread.h" - -ConversionThread::ConversionThread():QThread(), -/*myConverter(0),*/myFastConverter(0), -myVolumicValue(0),myScanSide(1), -myThreadIndex(1) -{ - -} - -ConversionThread::~ConversionThread() -{ - -} - -/* -void ConversionThread::setConverter(Voxel_Converter* converter) -{ - myConverter = converter; - myFastConverter = 0; -} -*/ - -void ConversionThread::setConverter(Voxel_FastConverter* converter) -{ - myFastConverter = converter; - //myConverter = 0; -} - -void ConversionThread::setVolumicValue(const int value) -{ - myVolumicValue = value; -} - -void ConversionThread::setScanSide(const int side) -{ - myScanSide = side; -} - -void ConversionThread::setThreadIndex(const int ithread) -{ - myThreadIndex = ithread; -} - -int* ConversionThread::getProgress() -{ - return &myProgress; -} - -void ConversionThread::run() -{ - if (/*!myConverter && */!myFastConverter) - return; - //if (myConverter) - // myConverter->Convert(myProgress, myVolumicValue, myScanSide, myThreadIndex); - //else - myFastConverter->Convert(myProgress, myThreadIndex); -} diff --git a/samples/qt/VoxelDemo/src/Main.cpp b/samples/qt/VoxelDemo/src/Main.cpp deleted file mode 100644 index e5f91752ea..0000000000 --- a/samples/qt/VoxelDemo/src/Main.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include -#include "application.h" - -int main( int argc, char ** argv ) -{ - QApplication a( argc, argv ); - - Application *w = new Application(); - w->setWindowTitle( "Voxel demo-application" ); - w->show(); - a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); - return a.exec(); -} diff --git a/samples/qt/VoxelDemo/src/Timer.cpp b/samples/qt/VoxelDemo/src/Timer.cpp deleted file mode 100644 index 783b004290..0000000000 --- a/samples/qt/VoxelDemo/src/Timer.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// Timer.cpp: implementation of the Timer class. -// -////////////////////////////////////////////////////////////////////// - -#include "Timer.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -Timer::Timer():myWriter(0) {} - -Timer::Timer(const char* filename) -{ - fopen_s(&myWriter,filename, "a"); -} - -Timer::~Timer() -{ - if (myWriter) - fclose(myWriter); -} - -void Timer::Start() { - myTimer.Reset(); - myTimer.Start(); -} - -void Timer::Stop() { - myTimer.Stop(); -} - -void Timer::Continue() { - myTimer.Start(); -} - -void Timer::Reset() { - myTimer.Reset(); -} - -float Timer::Seconds() { - Standard_Real sec, cpu; - Standard_Integer minutes, hours; - myTimer.Show(sec, minutes, hours, cpu); - return (float) sec; -} - -int Timer::Minutes() { - Standard_Real sec, cpu; - Standard_Integer minutes, hours; - myTimer.Show(sec, minutes, hours, cpu); - return minutes; -} - -void Timer::Print(char* label) { - Standard_Real seconds, cpu; - Standard_Integer minutes, hours; - myTimer.Show(seconds, minutes, hours, cpu); - if (myWriter) - { - fprintf(myWriter, "%s took %d minutes %g seconds\n", label, minutes, seconds); - } - else - { - cout< -#include -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -static Handle(Graphic3d_GraphicDriver) Viewer_aGraphicDriver; - -Viewer::Viewer(QWidget* parent):QWidget(parent) -{ - if (myGraphicDriver.IsNull()) - { - if (Viewer_aGraphicDriver.IsNull()) - { - Handle(Aspect_DisplayConnection) aDisplayConnection; - Viewer_aGraphicDriver = new OpenGl_GraphicDriver (aDisplayConnection); - } - myGraphicDriver = Handle(OpenGl_GraphicDriver)::DownCast(Viewer_aGraphicDriver); - } - - Handle(V3d_Viewer) aViewer = new V3d_Viewer(myGraphicDriver, TCollection_ExtendedString("Visu3D").ToExtString(), "", - 1000, V3d_XposYnegZpos, - Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, - true, true, V3d_TEX_NONE); - - aViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); - - myView = aViewer->CreateView(); - myIC = new AIS_InteractiveContext(aViewer); - myIC->SetDeviationCoefficient(1.e-3); - - Aspect_Handle aWindowHandle = (Aspect_Handle )winId(); - Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle); - - myView->SetWindow(hWnd); - if(!hWnd->IsMapped()) - hWnd->Map(); - - myView->MustBeResized(); - myView->SetSurfaceDetail(V3d_TEX_NONE); - myView->SetSize(10000.0); - myView->SetZSize(10000.0); - myView->SetViewMappingDefault(); - - myZoom = false; - myPan = false; - myRotate = false; - setMouseTracking(true); - - setMinimumSize(400, 200); - - myView->ZBufferTriedronSetup(); - myView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_BLACK, 0.1, V3d_ZBUFFER); - - mySelector.Init(myView); - - setBackgroundRole( QPalette::NoRole );//NoBackground ); - // set focus policy to threat QContextMenuEvent from keyboard - setFocusPolicy( Qt::StrongFocus ); - setAttribute( Qt::WA_PaintOnScreen ); - setAttribute( Qt::WA_NoSystemBackground ); - - aViewer->SetLightOn(new V3d_DirectionalLight(aViewer, V3d_XnegYnegZneg, Quantity_NOC_WHITE, Standard_True)); - aViewer->SetLightOn(new V3d_AmbientLight(aViewer, Quantity_NOC_WHITE)); -} - -Viewer::~Viewer() -{ - -} - -void Viewer::paintEvent(QPaintEvent * pEvent) -{ - if (!myView.IsNull()) - myView->Redraw(); -} - - -/*! - Get paint engine for the OpenGL viewer. [ virtual public ] -*/ -QPaintEngine* Viewer::paintEngine() const -{ - return 0; -} - -void Viewer::resizeEvent(QResizeEvent * e) -{ - if (!myView.IsNull()) - { - myView->MustBeResized(); - } -} - -void Viewer::mousePressEvent(QMouseEvent * mpEvent) -{ - // Memorize start point - myStartPnt.setX(mpEvent->x()); - myStartPnt.setY(mpEvent->y()); - - // Inform IC that the mouse cursor is at the point - myIC->MoveTo(myStartPnt.x(), myStartPnt.y(), myView); - - // In case of rotation, define the start rotation point - if ((mpEvent->modifiers() & Qt::ControlModifier) && (mpEvent->buttons() & Qt::RightButton)) - { - myView->StartRotation(myStartPnt.x(), myStartPnt.y()); - } - - // Start degenerate mode - setDegenerateMode(true); - - emit mousePressed(mpEvent->modifiers(), mpEvent->x(), mpEvent->y()); -} - -void Viewer::mouseMoveEvent(QMouseEvent * mmEvent) -{ - QPoint currentPnt(mmEvent->x(), mmEvent->y()); - - if (mmEvent->modifiers() & Qt::ControlModifier) - { - if (mmEvent->buttons() & Qt::LeftButton) - { - myView->Zoom(myStartPnt.x(), myStartPnt.y(), currentPnt.x(), currentPnt.y()); - myStartPnt = currentPnt; - } - else if (mmEvent->buttons() & Qt::MidButton) - { - myView->Pan(currentPnt.x() - myStartPnt.x(), myStartPnt.y() - currentPnt.y()); - myStartPnt = currentPnt; - } - else if (mmEvent->buttons() & Qt::RightButton) - { - myView->Rotation(currentPnt.x(), currentPnt.y()); - } - } - else - { - myIC->MoveTo(currentPnt.x(), currentPnt.y(), myView); - } - - emit mouseMoved(mmEvent->modifiers(), currentPnt.x(), currentPnt.y()); -} - -void Viewer::mouseReleaseEvent(QMouseEvent * mrEvent) -{ - if(mrEvent->button() == Qt::LeftButton) - { - if(!myZoom && !myPan && !myRotate) - { - if(mrEvent->modifiers() & Qt::ShiftModifier) - myIC->ShiftSelect(); - else - myIC->Select(); - - // Select a voxel - int ix = -1, iy = -1, iz = -1; - bool detected = mySelector.Detect(mrEvent->x(), mrEvent->y(), ix, iy, iz); - if (detected) - { - cout<<"("<Highlight(ix, iy, iz); - } - } - else if(mrEvent->button() == Qt::RightButton) - { - // Popup menu: - - - } - - // Finish degenerate mode - setDegenerateMode(false); - - emit mouseReleased(mrEvent->modifiers(), mrEvent->x(), mrEvent->y()); -} - -void Viewer::mouseDoubleClickEvent(QMouseEvent * mdcEvent) -{ - emit mouseDoubleClick(mdcEvent->modifiers(), mdcEvent->x(), mdcEvent->y()); -} - -void Viewer::setDegenerateMode(const bool on) -{ - AIS_ListOfInteractive displayed; - myIC->DisplayedObjects(displayed); - AIS_ListIteratorOfListOfInteractive itri(displayed); - for (; itri.More(); itri.Next()) - { - Handle(Voxel_Prs) prs = Handle(Voxel_Prs)::DownCast(itri.Value()); - if (!prs.IsNull()) - { - prs->SetDegenerateMode(on); - myView->Redraw(); - break; - } - } -} diff --git a/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx b/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx deleted file mode 100644 index f23e525e0d..0000000000 --- a/samples/qt/VoxelDemo/src/VoxelClient_VisDrawer.cxx +++ /dev/null @@ -1,3374 +0,0 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and / or modify it -// under the terms of the GNU Lesser General Public version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// required for correct APIENTRY definition -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) - #define WIN32_LEAN_AND_MEAN - #include -#endif - -#if defined(__APPLE__) - #include -#else - #include -#endif - -#include "VoxelClient_VisDrawer.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -/**************************************************************************/ - -class VoxelClient_VisDrawer::VisElement : public OpenGl_Element -{ -public: - - VisElement (Voxel_VisData*); - virtual ~VisElement(); - - void EvaluateBounds (Graphic3d_BndBox4f& theMinMax); - - void Render (const Handle(OpenGl_Workspace) &theWorkspace) const; - - virtual void Release (OpenGl_Context* theContext) - { - // - } - -private: - - VoxelClient_VisDrawer* myHandler; - -public: - - DEFINE_STANDARD_ALLOC - -}; - -//======================================================================= -//function : VisElement -//purpose : Constructor -//======================================================================= - -VoxelClient_VisDrawer::VisElement::VisElement (Voxel_VisData* theData) -{ - myHandler = new VoxelClient_VisDrawer (theData); -} - -//======================================================================= -//function : ~VisElement -//purpose : Destructor -//======================================================================= - -VoxelClient_VisDrawer::VisElement::~VisElement () -{ - delete myHandler; -} - -//======================================================================= -//function : EvaluateBounds -//purpose : -//======================================================================= - -void VoxelClient_VisDrawer::VisElement::EvaluateBounds - (Graphic3d_BndBox4f& theMinMax) -{ - myHandler->EvalMinMax (theMinMax); -} - -//======================================================================= -//function : Render -//purpose : display element -//======================================================================= - -void VoxelClient_VisDrawer::VisElement::Render - (const Handle (OpenGl_Workspace) &theWorkspace) const -{ - const Standard_Boolean aHl = (theWorkspace->NamedStatus & OPENGL_NS_HIGHLIGHT); - myHandler->Display (aHl); -} - -//======================================================================= -//function : VisDrawerCallBack -//purpose : visdrawer element create callback, adds an element to graphic -// driver's structure -//======================================================================= -void VoxelClient_PrsGl::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr, - const Handle(Prs3d_Presentation)& thePrs, - const Standard_Integer theMode) -{ - if (myVisData == NULL) - { - return; - } - Voxel_Prs::Compute (thePrsMgr, thePrs, theMode); - - Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (Prs3d_Root::CurrentGroup (thePrs)); - VoxelClient_VisDrawer::VisElement* anElem = new VoxelClient_VisDrawer::VisElement ((Voxel_VisData* )myVisData); - aGroup->AddElement (anElem); - - Graphic3d_BndBox4f aMinMax; - anElem->EvaluateBounds (aMinMax); - aGroup->SetMinMaxValues (aMinMax.CornerMin().x(), aMinMax.CornerMin().y(), aMinMax.CornerMin().z(), - aMinMax.CornerMax().x(), aMinMax.CornerMax().y(), aMinMax.CornerMax().z()); - thePrsMgr->StructureManager()->Update (thePrsMgr->StructureManager()->UpdateMode()); -} - -/**************************************************************************/ -VoxelClient_VisDrawer::VoxelClient_VisDrawer(Voxel_VisData * theData):myData(theData) -{ - -} - -/**************************************************************************/ -VoxelClient_VisDrawer::~VoxelClient_VisDrawer() -{ - if (myData) - { - // Because a pointer to the data is copied, - // it is possible to make an attempt to delete GL lists for - // a structure, which is already deleted. - // Such a situation may happen on close of the application. - // Therefore, this try / catch is used. - - try - { - Standard_Integer idir; - - // Points - - // BoolDS - if (myData->myDisplay.myBoolPointsList > 0) - { - glDeleteLists(myData->myDisplay.myBoolPointsList, 1); - myData->myDisplay.myBoolPointsList = -1; - } - for (idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myBoolNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1); - myData->myDisplay.myBoolNearestPointsList[idir] = -1; - } - } - - // ColorDS - if (myData->myDisplay.myColorPointsList > 0) - { - glDeleteLists(myData->myDisplay.myColorPointsList, 1); - myData->myDisplay.myColorPointsList = -1; - } - for (idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myColorNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1); - myData->myDisplay.myColorNearestPointsList[idir] = -1; - } - } - - // ROctBoolDS - if (myData->myDisplay.myROctBoolPointsList > 0) - { - glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1); - myData->myDisplay.myROctBoolPointsList = -1; - } - for (idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1); - myData->myDisplay.myROctBoolNearestPointsList[idir] = -1; - } - } - - // Triangulation - if (myData->myDisplay.myTriangulationList > 0) - { - glDeleteLists(myData->myDisplay.myTriangulationList, 1); - myData->myDisplay.myTriangulationList = -1; - } - } - catch (...) - { - - } - } -} - -/**************************************************************************/ -void VoxelClient_VisDrawer::EvalMinMax(Graphic3d_BndBox4f& theMinMax) const -{ - Graphic3d_Vec4 aMinPt (FLT_MAX, FLT_MAX, FLT_MAX, 1.0f); - Graphic3d_Vec4 aMaxPt (-FLT_MAX, -FLT_MAX, -FLT_MAX, 1.0f); - - if(!myData) - return; - if(myData->myBoolVoxels) - { - Graphic3d_Vec4 aBoolVoxelsMin (RealToShortReal (myData->myBoolVoxels->GetX()), - RealToShortReal (myData->myBoolVoxels->GetY()), - RealToShortReal (myData->myBoolVoxels->GetZ()), - 1.0f); - Graphic3d_Vec4 aBoolVoxelsMax ( - RealToShortReal (myData->myBoolVoxels->GetX() + myData->myBoolVoxels->GetXLen()), - RealToShortReal (myData->myBoolVoxels->GetY() + myData->myBoolVoxels->GetYLen()), - RealToShortReal (myData->myBoolVoxels->GetZ() + myData->myBoolVoxels->GetZLen()), - 1.0f); - - aMinPt = aMinPt.cwiseMin (aBoolVoxelsMin); - aMaxPt = aMaxPt.cwiseMax (aBoolVoxelsMax); - } - if(myData->myColorVoxels) - { - Graphic3d_Vec4 aColorVoxelsMin (RealToShortReal (myData->myColorVoxels->GetX()), - RealToShortReal (myData->myColorVoxels->GetY()), - RealToShortReal (myData->myColorVoxels->GetZ()), - 1.0f); - Graphic3d_Vec4 aColorVoxelsMax ( - RealToShortReal (myData->myColorVoxels->GetX() + myData->myColorVoxels->GetXLen()), - RealToShortReal (myData->myColorVoxels->GetY() + myData->myColorVoxels->GetYLen()), - RealToShortReal (myData->myColorVoxels->GetZ() + myData->myColorVoxels->GetZLen()), - 1.0f); - - aMinPt = aMinPt.cwiseMin (aColorVoxelsMin); - aMaxPt = aMaxPt.cwiseMax (aColorVoxelsMax); - } - if(myData->myROctBoolVoxels) - { - Graphic3d_Vec4 aROctBoolVoxelsMin (RealToShortReal (myData->myROctBoolVoxels->GetX()), - RealToShortReal (myData->myROctBoolVoxels->GetY()), - RealToShortReal (myData->myROctBoolVoxels->GetZ()), - 1.0f); - Graphic3d_Vec4 aROctBoolVoxelsMax ( - RealToShortReal (myData->myROctBoolVoxels->GetX() + myData->myROctBoolVoxels->GetXLen()), - RealToShortReal (myData->myROctBoolVoxels->GetY() + myData->myROctBoolVoxels->GetYLen()), - RealToShortReal (myData->myROctBoolVoxels->GetZ() + myData->myROctBoolVoxels->GetZLen()), - 1.0f); - - aMinPt = aMinPt.cwiseMin (aROctBoolVoxelsMin); - aMaxPt = aMaxPt.cwiseMax (aROctBoolVoxelsMax); - } - if (!myData->myTriangulation.IsNull()) - { - Standard_Real x, y, z; - const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes(); - Standard_Integer inode = nodes.Lower(), nb_nodes = nodes.Upper(); - for (; inode <= nb_nodes; inode++) - { - nodes.Value(inode).Coord(x, y, z); - Graphic3d_Vec4 aNodeCoord (RealToShortReal (x), - RealToShortReal (y), - RealToShortReal (z), - 1.0f); - aMinPt = aMinPt.cwiseMin (aNodeCoord); - aMaxPt = aMaxPt.cwiseMax (aNodeCoord); - } - } - - if (theMinMax.IsValid()) - { - theMinMax.CornerMin() = aMinPt; - theMinMax.CornerMax() = aMaxPt; - } - else - { - theMinMax.Add (aMinPt); - theMinMax.Add (aMaxPt); - } -} - -/**************************************************************************/ -void VoxelClient_VisDrawer::Display(const Standard_Boolean theHighlight) -{ - if (!myData) - return; - if (myData->myBoolVoxels) - DisplayVoxels(theHighlight); - if (myData->myColorVoxels) - DisplayVoxels(theHighlight); - if (myData->myROctBoolVoxels) - DisplayVoxels(theHighlight); - if (!myData->myTriangulation.IsNull()) - DisplayTriangulation(theHighlight); -} - -// Some static method to define Open GL visual attributes -// COlor -static void setColor(const Quantity_Color& color, const Standard_Boolean highlight) -{ - static Quantity_Color highlight_color(Quantity_NOC_BLUE1); - if(highlight) - glColor3f((GLfloat)highlight_color.Red(), (GLfloat)highlight_color.Green(), (GLfloat)highlight_color.Blue()); - else - glColor3d(color.Red(), color.Green(), color.Blue()); -} - -// Type of Line -static void setTypeOfLine(const Aspect_TypeOfLine type) -{ - if(type == Aspect_TOL_SOLID) - { - glDisable(GL_LINE_STIPPLE); - } - else - { - glEnable(GL_LINE_STIPPLE); - if(type == Aspect_TOL_DOT) - glLineStipple(1, 0xCCCC); - else if(type == Aspect_TOL_DASH) - glLineStipple(1, 0xFFC0); - else if(type == Aspect_TOL_DOTDASH) - glLineStipple(1, 0xFF18); - } -} - -// Width of Line -static void setWidthOfLine(const Standard_Integer width) -{ - glLineWidth((Standard_ShortReal) width); -} - -// Normal of the view -static void getNormal(gp_Dir& normal) -{ - Standard_Real x, y, z; - GLint viewport[4]; - GLdouble model_matrix[16], proj_matrix[16]; - - glGetDoublev(GL_MODELVIEW_MATRIX, model_matrix); - glGetDoublev(GL_PROJECTION_MATRIX, proj_matrix); - glGetIntegerv(GL_VIEWPORT, viewport); - - gluUnProject(viewport[0], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z); - gp_Pnt p1(x, y, z); - gluUnProject(viewport[0] + viewport[2], viewport[1], 0., model_matrix, proj_matrix, viewport, &x, &y, &z); - gp_Pnt p2(x, y, z); - gluUnProject(viewport[0], viewport[1] + viewport[3], 0., model_matrix, proj_matrix, viewport, &x, &y, &z); - gp_Pnt p3(x, y, z); - - gce_MakePln mkNormal(p1, p2, p3); - if (mkNormal.IsDone()) - { - const gp_Pln& normal_plane = mkNormal.Value(); - normal = normal_plane.Axis().Direction(); - } - else - { - normal = gp::DZ(); - } -} - -// Normal 2 VoxelDirection converter -static VoxelDirection getVoxelDirection(const gp_Dir& viewnormal) -{ - VoxelDirection vdir; - Standard_Real fabsviewnormalx = fabs(viewnormal.X()); - Standard_Real fabsviewnormaly = fabs(viewnormal.Y()); - Standard_Real fabsviewnormalz = fabs(viewnormal.Z()); - if (fabsviewnormalx >= fabsviewnormaly && - fabsviewnormalx >= fabsviewnormalz) - { - if (viewnormal.X() > 0) - vdir = Xminus; - else - vdir = Xplus; - } - else if (fabsviewnormaly >= fabsviewnormalx && - fabsviewnormaly >= fabsviewnormalz) - { - if (viewnormal.Y() > 0) - vdir = Yminus; - else - vdir = Yplus; - } - else if (fabsviewnormalz >= fabsviewnormalx && - fabsviewnormalz >= fabsviewnormaly) - { - if (viewnormal.Z() > 0) - vdir = Zminus; - else - vdir = Zplus; - } - return vdir; -} - -// Normal 2 VoxelDirection 3 converter -static void getVoxel3Directions(const gp_Dir& viewnormal, - VoxelDirection& vdir1, - VoxelDirection& vdir2, - VoxelDirection& vdir3) -{ - Standard_Boolean vdir1_set = Standard_False, vdir2_set = Standard_False, vdir3_set = Standard_False; - - // Test X minus - Standard_Real dot = viewnormal.Dot(-gp::DX()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Xminus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Xminus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Xminus; - vdir3_set = Standard_True; - } - } - - // Test X plus - dot = viewnormal.Dot(gp::DX()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Xplus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Xplus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Xplus; - vdir3_set = Standard_True; - } - } - - // Test Y minus - dot = viewnormal.Dot(-gp::DY()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Yminus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Yminus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Yminus; - vdir3_set = Standard_True; - } - } - - // Test Y plus - dot = viewnormal.Dot(gp::DY()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Yplus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Yplus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Yplus; - vdir3_set = Standard_True; - } - } - - // Test Z minus - dot = viewnormal.Dot(-gp::DZ()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Zminus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Zminus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Zminus; - vdir3_set = Standard_True; - } - } - - // Test Y plus - dot = viewnormal.Dot(gp::DZ()); - if (dot >= 0.0) - { - if (!vdir1_set) - { - vdir1 = Zplus; - vdir1_set = Standard_True; - } - else if (!vdir2_set) - { - vdir2 = Zplus; - vdir2_set = Standard_True; - } - else if (!vdir3_set) - { - vdir3 = Zplus; - vdir3_set = Standard_True; - } - } -} - -static Standard_Boolean CheckSize(Voxel_DS* voxels, - const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax, - Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) -{ - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - if (xc < xmin || xc > xmax) - return Standard_False; - if (yc < ymin || yc > ymax) - return Standard_False; - if (zc < zmin || zc > zmax) - return Standard_False; - return Standard_True; -} - -static Standard_Boolean CheckSize(Voxel_ROctBoolDS* voxels, - const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer i, const Standard_Integer j, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax, - Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) -{ - if (j == -1) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - else - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - if (xc < xmin || xc > xmax) - return Standard_False; - if (yc < ymin || yc > ymax) - return Standard_False; - if (zc < zmin || zc > zmax) - return Standard_False; - return Standard_True; -} - -static void drawBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest, - Voxel_BoolDS* voxels, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - Standard_Real xc, yc, zc; - Standard_Integer ix = 0, nbx = voxels->GetNbX(); - Standard_Integer iy = 0, nby = voxels->GetNbY(); - Standard_Integer iz = 0, nbz = voxels->GetNbZ(); - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_POINTS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - } - glEnd(); -} - -static void drawROctBoolPoints(const VoxelDirection vdir, const Standard_Boolean nearest, - Voxel_ROctBoolDS* voxels, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - Standard_Real xc, yc, zc; - Standard_Integer ix = 0, nbx = voxels->GetNbX(); - Standard_Integer iy = 0, nby = voxels->GetNbY(); - Standard_Integer iz = 0, nbz = voxels->GetNbZ(); - Standard_Integer i, j; - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_POINTS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - switch (voxels->Deepness(ix, iy, iz)) - { - case 0: - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - if (!check_size) - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - break; - } - case 1: - { - for (i = 0; i < 8; i++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - break; - } - case 2: - { - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - if (value) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - break; - } - } - } - } - } - break; - } - } - glEnd(); -} - - - -static void drawColorPoints(const VoxelDirection vdir, const Standard_Boolean nearest, - Voxel_ColorDS* voxels, const Handle(Quantity_HArray1OfColor)& hcolors, - const Standard_Byte minvalue, const Standard_Byte maxvalue, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - Standard_Real xc, yc, zc; - Standard_Integer ix = 0, nbx = voxels->GetNbX(); - Standard_Integer iy = 0, nby = voxels->GetNbY(); - Standard_Integer iz = 0, nbz = voxels->GetNbZ(); - Standard_Byte value; - - // Colors - const Quantity_Array1OfColor& colors = hcolors->Array1(); - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_POINTS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - setColor(colors.Value(value), Standard_False); - glVertex3d(xc, yc, zc); - if (nearest) - break; - } - } - } - } - break; - } - } - glEnd(); -} - -static void drawBoolQuadrangles(Voxel_BoolDS* voxels, const VoxelDirection vdir, - const gp_Dir& viewnormal, const Standard_Boolean nearest, - const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - gp_Vec vc; - gp_Pnt pc1, pc2, pc3, pc4; - Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0; - Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(); - - // Normal - viewnormal.Coord(xn, yn, zn); - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_QUADS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - Standard_Boolean value = voxels->Get(ix, iy, iz) == Standard_True; - if (value) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - } - glEnd(); -} - -static void drawROctBoolQuadrangles(Voxel_ROctBoolDS* voxels, const VoxelDirection vdir, - const gp_Dir& viewnormal, const Standard_Boolean nearest, - const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - gp_Vec vc; - gp_Pnt pc1, pc2, pc3, pc4; - Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 1.0; - Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(), i, j, deepness; - - // Normal - viewnormal.Coord(xn, yn, zn); - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_QUADS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - deepness = voxels->Deepness(ix, iy, iz); - for (i = 0; i < 8; i++) - { - for (j = 0; j < 8; j++) - { - if (deepness == 0 && j) - { - i = 8; - break; - } - if (deepness == 1 && j) - break; - if (deepness == 0) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 1) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, -1, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - else if (deepness == 2) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, i, j, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - } - - Standard_Boolean value; - switch (deepness) - { - case 0: - value = voxels->Get(ix, iy, iz) == Standard_True; - break; - case 1: - value = voxels->Get(ix, iy, iz, i) == Standard_True; - break; - case 2: - value = voxels->Get(ix, iy, iz, i, j) == Standard_True; - break; - } - - if (value) - { - // Define translation vector - if (!check_size) - { - switch (deepness) - { - case 0: - ((Voxel_DS*)voxels)->GetCenter(ix, iy, iz, xc, yc, zc); - break; - case 1: - voxels->GetCenter(ix, iy, iz, i, xc, yc, zc); - break; - case 2: - voxels->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - break; - } - } - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Display - glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - } - } - break; - } - } - glEnd(); -} - - - -static void drawColorQuadrangles(Voxel_ColorDS* voxels, const VoxelDirection vdir, - const gp_Dir& viewnormal, const Standard_Boolean nearest, - const Handle(Quantity_HArray1OfColor)& hcolors, - const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& p4, - const Standard_Byte minvalue, const Standard_Byte maxvalue, - const Standard_Real xmin, const Standard_Real xmax, - const Standard_Real ymin, const Standard_Real ymax, - const Standard_Real zmin, const Standard_Real zmax) -{ - gp_Vec vc; - gp_Pnt pc1, pc2, pc3, pc4; - Standard_Real xc, yc, zc, xn = 0.0, yn = 0.0, zn = 0.0; - Standard_Integer ix, iy, iz, nbx = voxels->GetNbX(), nby = voxels->GetNbY(), nbz = voxels->GetNbZ(); - Standard_Byte value; - - // Normal - //viewnormal.Coord(xn, yn, zn); - glNormal3d(xn, yn, zn); - - // Colors - const Quantity_Array1OfColor& colors = hcolors->Array1(); - - Standard_Boolean check_size = (xmin <= DBL_MAX && xmax >= DBL_MAX && - ymin <= DBL_MAX && ymax >= DBL_MAX && - zmin <= DBL_MAX && zmax >= DBL_MAX); - check_size = !check_size; - - glBegin(GL_QUADS); - switch (vdir) - { - case Xminus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = 0; ix < nbx; ix++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Xplus: - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - for (ix = nbx - 1; ix >= 0; ix--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Yminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = 0; iy < nby; iy++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Yplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iz = 0; iz < nbz; iz++) - { - for (iy = nby - 1; iy >= 0; iy--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Zminus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - case Zplus: - { - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = nbz - 1; iz >= 0; iz--) - { - if (check_size && !CheckSize(voxels, ix, iy, iz, xmin, xmax, ymin, ymax, zmin, zmax, xc, yc, zc)) - continue; - value = voxels->Get(ix, iy, iz); - if (value >= minvalue && value <= maxvalue) - { - // Define translation vector - if (!check_size) - voxels->GetCenter(ix, iy, iz, xc, yc, zc); - vc.SetCoord(xc, yc, zc); - - // Translate - pc1 = p1.Translated(vc); - pc2 = p2.Translated(vc); - pc3 = p3.Translated(vc); - pc4 = p4.Translated(vc); - - // Color - setColor(colors.Value(value), Standard_False); - - // Display - //glNormal3d(xn, yn, zn); - pc1.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc2.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc3.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - pc4.Coord(xc, yc, zc); - glVertex3d(xc, yc, zc); - - if (nearest) - break; - } - } - } - } - break; - } - } - glEnd(); -} - -static void genListIndex(GLint& index) -{ - GLint i = 0; - while (++i <= INT_MAX) - { - if (!glIsList(i)) - { - index = i; - break; - } - } -} - -static void setPlaneNormal(const VoxelDirection& dir, - const Standard_Real dx, const Standard_Real dy, const Standard_Real dz, - gp_Pln& plane, gp_Pnt& p1, gp_Pnt& p2, gp_Pnt& p3, gp_Pnt& p4) -{ - gp_Ax3 axes = plane.Position(); - Standard_Real dx2 = 0.5 * dx, dy2 = 0.5 * dy, dz2 = 0.5 * dz; - switch (dir) - { - case Xminus: - p1.SetCoord(-dx2, -dy2, dz2); - p2.SetCoord(-dx2, -dy2, -dz2); - p3.SetCoord(-dx2, dy2, -dz2); - p4.SetCoord(-dx2, dy2, dz2); - axes.SetDirection(-gp::DX()); - break; - case Xplus: - p1.SetCoord(dx2, -dy2, dz2); - p2.SetCoord(dx2, -dy2, -dz2); - p3.SetCoord(dx2, dy2, -dz2); - p4.SetCoord(dx2, dy2, dz2); - axes.SetDirection(gp::DX()); - break; - case Yminus: - p1.SetCoord(dx2, -dy2, dz2); - p2.SetCoord(dx2, -dy2, -dz2); - p3.SetCoord(-dx2, -dy2, -dz2); - p4.SetCoord(-dx2, -dy2, dz2); - axes.SetDirection(-gp::DY()); - break; - case Yplus: - p1.SetCoord(dx2, dy2, dz2); - p2.SetCoord(dx2, dy2, -dz2); - p3.SetCoord(-dx2, dy2, -dz2); - p4.SetCoord(-dx2, dy2, dz2); - axes.SetDirection(gp::DY()); - break; - case Zminus: - p1.SetCoord(dx2, dy2, -dz2); - p2.SetCoord(-dx2, dy2, -dz2); - p3.SetCoord(-dx2, -dy2, -dz2); - p4.SetCoord(dx2, -dy2, -dz2); - axes.SetDirection(-gp::DZ()); - break; - case Zplus: - p1.SetCoord(dx2, dy2, dz2); - p2.SetCoord(-dx2, dy2, dz2); - p3.SetCoord(-dx2, -dy2, dz2); - p4.SetCoord(dx2, -dy2, dz2); - axes.SetDirection(gp::DZ()); - break; - } -} - -/**************************************************************************/ -void VoxelClient_VisDrawer::DisplayVoxels(const Standard_Boolean theHighlight) -{ - if(!myData) - return; - - glEnable(GL_DEPTH_TEST); - - // Boolean voxels - if (myData->myBoolVoxels) - { - // Points - if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS || - myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS) - { - glDisable(GL_LIGHTING); - if (myData->myDisplay.mySmoothPoints) - glEnable(GL_POINT_SMOOTH); - else - glDisable(GL_POINT_SMOOTH); - - // Draw the points of voxels (center points of the voxels) - // starting visualization from the side looking out from the user. - setColor(myData->myDisplay.myColor, theHighlight); - glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize); - - // Display - DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS); - } - } - - // Color values - if (myData->myColorVoxels) - { - // Points - if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS || - myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS) - { - glDisable(GL_LIGHTING); - if (myData->myDisplay.mySmoothPoints) - glEnable(GL_POINT_SMOOTH); - else - glDisable(GL_POINT_SMOOTH); - - // Draw the points of voxels (center points of the voxels) - // starting visualization from the side looking out from the user. - glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize); - - // Display - DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS); - } - } - - // Recursive Octree Boolean voxels - if (myData->myROctBoolVoxels) - { - // Points - if (myData->myDisplay.myDisplayMode == Voxel_VDM_POINTS || - myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS) - { - glDisable(GL_LIGHTING); - if (myData->myDisplay.mySmoothPoints) - glEnable(GL_POINT_SMOOTH); - else - glDisable(GL_POINT_SMOOTH); - - // Draw the points of voxels (center points of the voxels) - // starting visualization from the side looking out from the user. - setColor(myData->myDisplay.myColor, theHighlight); - glPointSize((Standard_ShortReal) myData->myDisplay.myPointSize); - - // Display - DisplayPoints(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTPOINTS); - } - } - - // Shading drawn by boxes - if (myData->myDisplay.myDisplayMode == Voxel_VDM_BOXES || - myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES) - { - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); - - // Draw quadrangles of voxels looking to the user. - setColor(myData->myDisplay.myColor, theHighlight); - - // Display - DisplayBoxes(myData->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES); - - glDisable(GL_COLOR_MATERIAL); - } - - // Highlighted voxel - HighlightVoxel(); -} - -/**************************************************************************/ -void VoxelClient_VisDrawer::DisplayPoints(const Standard_Boolean nearest) -{ - //OSD_Timer timer; - //timer.Start(); - - // Find the side of the cube which normal looks to (or out) the user's eye. - gp_Dir viewnormal; - getNormal(viewnormal); - - // Range of displayed data - Standard_Real xmin = myData->myDisplay.myDisplayedXMin; - Standard_Real xmax = myData->myDisplay.myDisplayedXMax; - Standard_Real ymin = myData->myDisplay.myDisplayedYMin; - Standard_Real ymax = myData->myDisplay.myDisplayedYMax; - Standard_Real zmin = myData->myDisplay.myDisplayedZMin; - Standard_Real zmax = myData->myDisplay.myDisplayedZMax; - - // Boolean points - if (myData->myBoolVoxels) - { - if (nearest || myData->myDisplay.myDegenerateMode) - { - VoxelDirection vdir1, vdir2, vdir3; - getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3); - - if (myData->myDisplay.myUsageOfGLlists) - { - // Clean all allocated GL lists for the case of first call. - if (myData->myDisplay.myBoolNearestPointsFirst) - { - for (Standard_Integer idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myBoolNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myBoolNearestPointsList[idir], 1); - myData->myDisplay.myBoolNearestPointsList[idir] = -1; - } - } - myData->myDisplay.myBoolNearestPointsFirst = Standard_False; - } - - // Generate GL lists if needed. - if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1] < 0) - { - genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]); - glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE); - drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2] < 0) - { - genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]); - glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE); - drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3] < 0) - { - genListIndex(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]); - glNewList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE); - drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir1]); - glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir2]); - glCallList(myData->myDisplay.myBoolNearestPointsList[(Standard_Integer) vdir3]); - } - else - { - drawBoolPoints(vdir1, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - drawBoolPoints(vdir2, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - drawBoolPoints(vdir3, Standard_True, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - else - { - if (myData->myDisplay.myUsageOfGLlists) - { - if (myData->myDisplay.myBoolPointsFirst) - { - // Delete previous GL list. - if (myData->myDisplay.myBoolPointsList > 0) - { - glDeleteLists(myData->myDisplay.myBoolPointsList, 1); - myData->myDisplay.myBoolPointsList = -1; - } - - // Generate a new GL list - genListIndex(myData->myDisplay.myBoolPointsList); - glNewList(myData->myDisplay.myBoolPointsList, GL_COMPILE); - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - - // The first call has just been passed... - myData->myDisplay.myBoolPointsFirst = Standard_False; - } - glCallList(myData->myDisplay.myBoolPointsList); - } - else - { - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawBoolPoints(vdir, Standard_False, myData->myBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - } - - // Color points - if (myData->myColorVoxels) - { - if (nearest || myData->myDisplay.myDegenerateMode) - { - VoxelDirection vdir1, vdir2, vdir3; - getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3); - - if (myData->myDisplay.myUsageOfGLlists) - { - // Clean all allocated GL lists for the case of first call. - if (myData->myDisplay.myColorNearestPointsFirst) - { - for (Standard_Integer idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myColorNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myColorNearestPointsList[idir], 1); - myData->myDisplay.myColorNearestPointsList[idir] = -1; - } - } - myData->myDisplay.myColorNearestPointsFirst = Standard_False; - } - - // Generate GL lists if needed. - if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1] < 0) - { - genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]); - glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE); - drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2] < 0) - { - genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]); - glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE); - drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3] < 0) - { - genListIndex(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]); - glNewList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE); - drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - - glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir1]); - glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir2]); - glCallList(myData->myDisplay.myColorNearestPointsList[(Standard_Integer) vdir3]); - } - else - { - drawColorPoints(vdir1, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - drawColorPoints(vdir2, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - drawColorPoints(vdir3, Standard_True, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - else - { - if (myData->myDisplay.myUsageOfGLlists) - { - if (myData->myDisplay.myColorPointsFirst) - { - // Delete previous GL list. - if (myData->myDisplay.myColorPointsList > 0) - { - glDeleteLists(myData->myDisplay.myColorPointsList, 1); - myData->myDisplay.myColorPointsList = -1; - } - - // Generate a new GL list - genListIndex(myData->myDisplay.myColorPointsList); - glNewList(myData->myDisplay.myColorPointsList, GL_COMPILE); - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - - // The first call has just been passed... - myData->myDisplay.myColorPointsFirst = Standard_False; - } - glCallList(myData->myDisplay.myColorPointsList); - } - else - { - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawColorPoints(vdir, Standard_False, myData->myColorVoxels, myData->myDisplay.myColors, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - } - - // Recursive Octree Boolean points - if (myData->myROctBoolVoxels) - { - if (nearest || myData->myDisplay.myDegenerateMode) - { - VoxelDirection vdir1, vdir2, vdir3; - getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3); - - if (myData->myDisplay.myUsageOfGLlists) - { - // Clean all allocated GL lists for the case of first call. - if (myData->myDisplay.myROctBoolNearestPointsFirst) - { - for (Standard_Integer idir = Xminus; idir <= Zplus; idir++) - { - if (myData->myDisplay.myROctBoolNearestPointsList[idir] > 0) - { - glDeleteLists(myData->myDisplay.myROctBoolNearestPointsList[idir], 1); - myData->myDisplay.myROctBoolNearestPointsList[idir] = -1; - } - } - myData->myDisplay.myROctBoolNearestPointsFirst = Standard_False; - } - - // Generate GL lists if needed. - if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1] < 0) - { - genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]); - glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1], GL_COMPILE); - drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2] < 0) - { - genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]); - glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2], GL_COMPILE); - drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - if (myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3] < 0) - { - genListIndex(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]); - glNewList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3], GL_COMPILE); - drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - } - glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir1]); - glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir2]); - glCallList(myData->myDisplay.myROctBoolNearestPointsList[(Standard_Integer) vdir3]); - } - else - { - drawROctBoolPoints(vdir1, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - drawROctBoolPoints(vdir2, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - drawROctBoolPoints(vdir3, Standard_True, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - else - { - if (myData->myDisplay.myUsageOfGLlists) - { - if (myData->myDisplay.myROctBoolPointsFirst) - { - // Delete previous GL list. - if (myData->myDisplay.myROctBoolPointsList > 0) - { - glDeleteLists(myData->myDisplay.myROctBoolPointsList, 1); - myData->myDisplay.myROctBoolPointsList = -1; - } - - // Generate a new GL list - genListIndex(myData->myDisplay.myROctBoolPointsList); - glNewList(myData->myDisplay.myROctBoolPointsList, GL_COMPILE); - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - glEndList(); - - // The first call has just been passed... - myData->myDisplay.myROctBoolPointsFirst = Standard_False; - } - glCallList(myData->myDisplay.myROctBoolPointsList); - } - else - { - VoxelDirection vdir = getVoxelDirection(viewnormal); - drawROctBoolPoints(vdir, Standard_False, myData->myROctBoolVoxels, - xmin, xmax, ymin, ymax, zmin, zmax); - } - } - } - - //timer.Stop(); - //Standard_Real seconds, cpu; - //Standard_Integer minutes, hours; - //timer.Show(seconds, minutes, hours, cpu); - //cout<<"DisplayPoints()"<<" took "<myDisplay.myDisplayedXMin; - Standard_Real xmax = myData->myDisplay.myDisplayedXMax; - Standard_Real ymin = myData->myDisplay.myDisplayedYMin; - Standard_Real ymax = myData->myDisplay.myDisplayedYMax; - Standard_Real zmin = myData->myDisplay.myDisplayedZMin; - Standard_Real zmax = myData->myDisplay.myDisplayedZMax; - - // Find the side of the cube which normal looks to (or out) the user's eye. - gp_Dir viewnormal; - getNormal(viewnormal); - - // Get three sides of the box looking to the user. - VoxelDirection vdir1, vdir2, vdir3; - getVoxel3Directions(viewnormal, vdir1, vdir2, vdir3); - - // Three quadrangles with normals looking to the user - gp_Pln plane1(gp::Origin(), viewnormal); - gp_Pln plane2(plane1), plane3(plane1); - - // Boolean boxes - if (myData->myBoolVoxels && - myData->myBoolVoxels->GetNbX() && - myData->myBoolVoxels->GetNbY() && - myData->myBoolVoxels->GetNbZ()) - { - // Compute size - Standard_Real dx = myData->myBoolVoxels->GetXLen() / (Standard_Real) myData->myBoolVoxels->GetNbX(); - Standard_Real dy = myData->myBoolVoxels->GetYLen() / (Standard_Real) myData->myBoolVoxels->GetNbY(); - Standard_Real dz = myData->myBoolVoxels->GetZLen() / (Standard_Real) myData->myBoolVoxels->GetNbZ(); - Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize; - dx *= d; - dy *= d; - dz *= d; - - // Translatethe quadrangles to the side of the voxel - gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34; - setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14); - setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24); - setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34); - - // Display - Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode; - drawBoolQuadrangles(myData->myBoolVoxels, vdir1, plane1.Axis().Direction(), - skin, p11, p12, p13, p14, - xmin, xmax, ymin, ymax, zmin, zmax); - drawBoolQuadrangles(myData->myBoolVoxels, vdir2, plane2.Axis().Direction(), - skin, p21, p22, p23, p24, - xmin, xmax, ymin, ymax, zmin, zmax); - drawBoolQuadrangles(myData->myBoolVoxels, vdir3, plane3.Axis().Direction(), - skin, p31, p32, p33, p34, - xmin, xmax, ymin, ymax, zmin, zmax); - } - // Color quadrangles - else if (myData->myColorVoxels && - myData->myColorVoxels->GetNbX() && - myData->myColorVoxels->GetNbY() && - myData->myColorVoxels->GetNbZ()) - { - // Compute size - Standard_Real dx = myData->myColorVoxels->GetXLen() / (Standard_Real) myData->myColorVoxels->GetNbX(); - Standard_Real dy = myData->myColorVoxels->GetYLen() / (Standard_Real) myData->myColorVoxels->GetNbY(); - Standard_Real dz = myData->myColorVoxels->GetZLen() / (Standard_Real) myData->myColorVoxels->GetNbZ(); - Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize; - dx *= d; - dy *= d; - dz *= d; - - // Translatethe quadrangles to the side of the voxel - gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34; - setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14); - setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24); - setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34); - - // Display - Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode; - drawColorQuadrangles(myData->myColorVoxels, vdir1, plane1.Axis().Direction(), skin, - myData->myDisplay.myColors, p11, p12, p13, p14, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - drawColorQuadrangles(myData->myColorVoxels, vdir2, plane2.Axis().Direction(), skin, - myData->myDisplay.myColors, p21, p22, p23, p24, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - drawColorQuadrangles(myData->myColorVoxels, vdir3, plane3.Axis().Direction(), skin, - myData->myDisplay.myColors, p31, p32, p33, p34, - myData->myDisplay.myColorMinValue, myData->myDisplay.myColorMaxValue, - xmin, xmax, ymin, ymax, zmin, zmax); - } - // Recursive Octree Boolean boxes - else if (myData->myROctBoolVoxels && - myData->myROctBoolVoxels->GetNbX() && - myData->myROctBoolVoxels->GetNbY() && - myData->myROctBoolVoxels->GetNbZ()) - { - // Compute size - Standard_Real dx = myData->myROctBoolVoxels->GetXLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbX(); - Standard_Real dy = myData->myROctBoolVoxels->GetYLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbY(); - Standard_Real dz = myData->myROctBoolVoxels->GetZLen() / (Standard_Real) myData->myROctBoolVoxels->GetNbZ(); - Standard_Real d = 0.01 * (Standard_Real) myData->myDisplay.myQuadrangleSize; - dx *= d; - dy *= d; - dz *= d; - - // Translatethe quadrangles to the side of the voxel - gp_Pnt p11, p12, p13, p14, p21, p22, p23, p24, p31, p32, p33, p34; - setPlaneNormal(vdir1, dx, dy, dz, plane1, p11, p12, p13, p14); - setPlaneNormal(vdir2, dx, dy, dz, plane2, p21, p22, p23, p24); - setPlaneNormal(vdir3, dx, dy, dz, plane3, p31, p32, p33, p34); - - // Display - Standard_Boolean skin = nearest || myData->myDisplay.myDegenerateMode; - drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir1, plane1.Axis().Direction(), - skin, p11, p12, p13, p14, - xmin, xmax, ymin, ymax, zmin, zmax); - drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir2, plane2.Axis().Direction(), - skin, p21, p22, p23, p24, - xmin, xmax, ymin, ymax, zmin, zmax); - drawROctBoolQuadrangles(myData->myROctBoolVoxels, vdir3, plane3.Axis().Direction(), - skin, p31, p32, p33, p34, - xmin, xmax, ymin, ymax, zmin, zmax); - } -} - -/**************************************************************************/ -void VoxelClient_VisDrawer::DisplayTriangulation(const Standard_Boolean theHighlight) -{ - if(!myData || myData->myTriangulation.IsNull()) - return; - - glEnable(GL_DEPTH_TEST); - glEnable(GL_LIGHTING); - - const TColgp_Array1OfPnt& nodes = myData->myTriangulation->Nodes(); - const Poly_Array1OfTriangle& triangles = myData->myTriangulation->Triangles(); - Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper(); - - Standard_Boolean compute_normals = Standard_False; - if (myData->myNormalsOfNodes.IsNull()) - { - compute_normals = Standard_True; - myData->myNormalsOfNodes = new TColgp_HArray1OfDir(itriangle, nb_triangles); - - // Release the GL list - if (myData->myDisplay.myTriangulationList > 0) - { - glDeleteLists(myData->myDisplay.myTriangulationList, 1); - myData->myDisplay.myTriangulationList = -1; - } - - // Generate a new GL list - if (myData->myDisplay.myUsageOfGLlists) - { - genListIndex(myData->myDisplay.myTriangulationList); - glNewList(myData->myDisplay.myTriangulationList, GL_COMPILE); - } - } - TColgp_Array1OfDir& normals = myData->myNormalsOfNodes->ChangeArray1(); - - if (!myData->myDisplay.myUsageOfGLlists || compute_normals) - { - - glBegin(GL_TRIANGLES); - - Standard_Integer n1, n2, n3; - Standard_Real x, y, z; - for (; itriangle <= nb_triangles; itriangle++) - { - const Poly_Triangle& t = triangles.Value(itriangle); - t.Get(n1, n2, n3); - - const gp_Pnt& p1 = nodes.Value(n1); - const gp_Pnt& p2 = nodes.Value(n2); - const gp_Pnt& p3 = nodes.Value(n3); - - // Make the normal: - if (compute_normals) - { - gp_Vec v1(p1, p2), v2(p1, p3); - v1.Cross(v2); - if (v1.SquareMagnitude() > 1.e-14) - v1.Normalize(); - else - v1.SetCoord(0.0, 0.0, 1.0); - normals.SetValue(itriangle, v1); - v1.Coord(x, y, z); - } - else - { - normals.Value(itriangle).Coord(x, y, z); - } - glNormal3d(x, y, z); - - // P1 - p1.Coord(x, y, z); - glVertex3d(x, y, z); - - // P2 - p2.Coord(x, y, z); - glVertex3d(x, y, z); - - // P3 - p3.Coord(x, y, z); - glVertex3d(x, y, z); - } - - glEnd(); - - if (myData->myDisplay.myUsageOfGLlists) - glEndList(); - } - - if (myData->myDisplay.myUsageOfGLlists) - glCallList(myData->myDisplay.myTriangulationList); -} - -void VoxelClient_VisDrawer::HighlightVoxel() -{ - if (myData && - myData->myDisplay.myHighlightx >= 0 && - myData->myDisplay.myHighlighty >= 0 && - myData->myDisplay.myHighlightz >= 0) - { - Standard_Integer nbx, nby, nbz; - Standard_Real xlen, ylen, zlen, xc, yc, zc; - Voxel_DS* ds = (Voxel_DS*) myData->myBoolVoxels; - if (myData->myColorVoxels) - ds = (Voxel_DS*) myData->myColorVoxels; - if (myData->myROctBoolVoxels) - ds = (Voxel_DS*) myData->myROctBoolVoxels; - nbx = ds->GetNbX(); - nby = ds->GetNbY(); - nbz = ds->GetNbZ(); - xlen = ds->GetXLen(); - ylen = ds->GetYLen(); - zlen = ds->GetZLen(); - ds->GetCenter(myData->myDisplay.myHighlightx, - myData->myDisplay.myHighlighty, - myData->myDisplay.myHighlightz, - xc, yc, zc); - - Standard_Real half_voxelx = xlen / Standard_Real(nbx) / 2.0; - Standard_Real half_voxely = ylen / Standard_Real(nby) / 2.0; - Standard_Real half_voxelz = zlen / Standard_Real(nbz) / 2.0; - Standard_Real x1 = xc - half_voxelx, y1 = yc - half_voxely, z1 = zc - half_voxelz; - Standard_Real x2 = xc + half_voxelx, y2 = yc + half_voxely, z2 = zc + half_voxelz; - - setColor(Quantity_NOC_BLUE1, Standard_True); - setTypeOfLine(Aspect_TOL_SOLID); - setWidthOfLine(3); - - glBegin(GL_LINES); - - glVertex3d(x1, y1, z1); - glVertex3d(x1, y2, z1); - - glVertex3d(x1, y1, z1); - glVertex3d(x2, y1, z1); - - glVertex3d(x1, y1, z1); - glVertex3d(x1, y1, z2); - - glVertex3d(x1, y2, z1); - glVertex3d(x2, y2, z1); - - glVertex3d(x2, y1, z1); - glVertex3d(x2, y2, z1); - - glVertex3d(x2, y2, z1); - glVertex3d(x2, y2, z2); - - glVertex3d(x1, y1, z2); - glVertex3d(x1, y2, z2); - - glVertex3d(x1, y1, z2); - glVertex3d(x2, y1, z2); - - glVertex3d(x2, y1, z2); - glVertex3d(x2, y2, z2); - - glVertex3d(x2, y2, z2); - glVertex3d(x1, y2, z2); - - glVertex3d(x1, y2, z2); - glVertex3d(x1, y2, z1); - - glVertex3d(x2, y1, z1); - glVertex3d(x2, y1, z2); - - glEnd(); - } -} diff --git a/src/OS/Visualization.tcl b/src/OS/Visualization.tcl index 85bdfe9d27..a817f4ce3e 100644 --- a/src/OS/Visualization.tcl +++ b/src/OS/Visualization.tcl @@ -18,8 +18,7 @@ proc Visualization:toolkits { } { set aResult [list TKService \ TKV3d \ TKOpenGl \ - TKMeshVS \ - TKVoxel] + TKMeshVS] if { [info exists ::env(HAVE_VTK)] && "$::env(HAVE_VTK)" == "true" } { lappend aResult "TKIVtk" diff --git a/src/QABugs/QABugs_19.cxx b/src/QABugs/QABugs_19.cxx index f72eb665fb..3189c31ebb 100644 --- a/src/QABugs/QABugs_19.cxx +++ b/src/QABugs/QABugs_19.cxx @@ -691,53 +691,6 @@ static Standard_Integer OCC23945 (Draw_Interpretor& /*di*/,Standard_Integer n, c return 0; } -#include -#include -#include -static Standard_Integer OCC24019 (Draw_Interpretor& di, Standard_Integer argc, const char** argv) -{ - if ( argc != 2 ) { - di << "Error: " << argv[0] << " - invalid number of arguments" << "\n"; - return 1; - } - - TCollection_AsciiString aFileName = argv[1]; - TopoDS_Shape aShape; - BRep_Builder aBuilder; - - if (!BRepTools::Read(aShape, aFileName.ToCString(), aBuilder)) { - di << "Error: Could not read a shape!" << "\n"; - return 1; - } - - TopoDS_Solid aShape1 = BRepPrimAPI_MakeSphere(gp_Pnt(20,25,35), 7); - - Standard_Real deflection = 0.005; - Standard_Integer nbThreads = 1; - Standard_Integer nbx = 200, nby = 200, nbz = 200; - Voxel_BoolDS theVoxels(0,0,0, 50, 50, 50, nbx, nby, nbz); - Voxel_BoolDS theVoxels1(0,0,0, 50, 50, 50, nbx, nby, nbz); - - Standard_Integer progress = 0; - Voxel_FastConverter fcp(aShape, theVoxels, deflection, nbx, nby, nbz, nbThreads); - fcp.ConvertUsingSAT(progress, 1); - fcp.FillInVolume(1); - - Voxel_FastConverter fcp1(aShape1, theVoxels1, deflection, nbx, nby, nbz, nbThreads); - fcp1.ConvertUsingSAT(progress, 1); - fcp1.FillInVolume(1); - - Voxel_BooleanOperation op; - Standard_Boolean result = op.Cut(theVoxels1, theVoxels); - if ( result != 1 ) { - di << "Error: invalid boolean operation" << "\n"; - } else { - di << "OK: boolean operation is ok" << "\n"; - } - - return 0; -} - //======================================================================= //function : OCC11758 //purpose : @@ -1331,34 +1284,6 @@ static Standard_Integer OCC24012 (Draw_Interpretor& di, Standard_Integer argc, c return 0; } -#include -static Standard_Integer OCC24051 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if (argc != 1) { - di << "Usage : " << argv[0] << " should be one argument (command name only)"; - return 1; - } - - TopoDS_Shape shape = BRepPrimAPI_MakeBox(gp_Pnt(5, 10, 10), 10, 20, 30).Shape(); - Standard_Integer progress = 0; - Standard_Real deflection = 0.005; - Standard_Integer nbx = 200, nby = 200, nbz = 200; - Voxel_BoolDS theVoxels(-50,-50,-30, 100, 100, 100, nbx, nby, nbz); - Voxel_BoolDS theVoxels1(-50,-50,-30, 100, 100, 100, nbx, nby, nbz); - Standard_Integer nbThreads = 5; - Voxel_FastConverter fcp(shape, theVoxels, deflection, nbx, nby, nbz, nbThreads, Standard_True); - - #ifdef _MSC_VER - #pragma omp parallel for - for(int i = 0; i < nbThreads; i++) - fcp.ConvertUsingSAT(progress, i+1); - #endif - - fcp.ConvertUsingSAT(progress); - - return 0; -} - #include #include #include @@ -4635,7 +4560,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("test_offset", "test_offset", __FILE__, test_offset, group); theCommands.Add ("OCC23945", "OCC23945 surfname U V X Y Z [DUX DUY DUZ DVX DVY DVZ [D2UX D2UY D2UZ D2VX D2VY D2VZ D2UVX D2UVY D2UVZ]]", __FILE__, OCC23945,group); theCommands.Add ("OCC24008", "OCC24008 curve surface", __FILE__, OCC24008, group); - theCommands.Add ("OCC24019", "OCC24019 aShape", __FILE__, OCC24019, group); theCommands.Add ("OCC11758", "OCC11758", __FILE__, OCC11758, group); theCommands.Add ("OCC24005", "OCC24005 result", __FILE__, OCC24005, group); theCommands.Add ("OCC24137", "OCC24137 face vertex U V [N]", __FILE__, OCC24137, group); @@ -4644,7 +4568,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) { theCommands.Add ("OCC24370", "OCC24370 edge pcurve surface prec", __FILE__, OCC24370, group); theCommands.Add ("OCC24533", "OCC24533", __FILE__, OCC24533, group); theCommands.Add ("OCC24012", "OCC24012 face edge", __FILE__, OCC24012, group); - theCommands.Add ("OCC24051", "OCC24051", __FILE__, OCC24051, group); theCommands.Add ("OCC24086", "OCC24086 face wire", __FILE__, OCC24086, group); theCommands.Add ("OCC24622", "OCC24622 texture={1D|2D}\n Tests sourcing of 1D/2D pixmaps for AIS_TexturedShape", __FILE__, OCC24622, group); theCommands.Add ("OCC24667", "OCC24667 result Wire_spine Profile [Mode [Approx]], no args to get help", __FILE__, OCC24667, group); diff --git a/src/TKQADraw/EXTERNLIB b/src/TKQADraw/EXTERNLIB index 8bbf06a049..122b92fca4 100755 --- a/src/TKQADraw/EXTERNLIB +++ b/src/TKQADraw/EXTERNLIB @@ -31,7 +31,6 @@ TKSTEPBase TKXDESTEP TKXSDRAW TKSTL -TKVoxel CSF_gdi32 CSF_advapi32 CSF_user32 diff --git a/src/TKViewerTest/EXTERNLIB b/src/TKViewerTest/EXTERNLIB index 329892d6ad..dab82959d3 100755 --- a/src/TKViewerTest/EXTERNLIB +++ b/src/TKViewerTest/EXTERNLIB @@ -14,7 +14,6 @@ TKG2d TKTopTest TKG3d TKOffset -TKVoxel TKMesh TKV3d TKDraw diff --git a/src/TKVoxel/CMakeLists.txt b/src/TKVoxel/CMakeLists.txt deleted file mode 100644 index 2f65e0a898..0000000000 --- a/src/TKVoxel/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(TKVoxel) - -set (TOOLKIT_MODULES - Voxel -) - -OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKVoxel/EXTERNLIB b/src/TKVoxel/EXTERNLIB deleted file mode 100644 index 0a06c3417c..0000000000 --- a/src/TKVoxel/EXTERNLIB +++ /dev/null @@ -1,10 +0,0 @@ -TKBRep -TKernel -TKV3d -TKMath -TKService -TKGeomBase -TKG2d -TKTopAlgo -TKG3d -TKMesh diff --git a/src/TKVoxel/FILES b/src/TKVoxel/FILES deleted file mode 100644 index ee6f7057f7..0000000000 --- a/src/TKVoxel/FILES +++ /dev/null @@ -1 +0,0 @@ -EXTERNLIB diff --git a/src/TKVoxel/PACKAGES b/src/TKVoxel/PACKAGES deleted file mode 100755 index a04bc5d863..0000000000 --- a/src/TKVoxel/PACKAGES +++ /dev/null @@ -1 +0,0 @@ -Voxel diff --git a/src/ViewerTest/FILES b/src/ViewerTest/FILES index a60d157500..6706686d80 100755 --- a/src/ViewerTest/FILES +++ b/src/ViewerTest/FILES @@ -16,4 +16,3 @@ ViewerTest_OpenGlCommands.cxx ViewerTest_RelationCommands.cxx ViewerTest_ViewerCommands.cxx ViewerTest_ViewerCommands_1.mm -ViewerTest_VoxelCommands.cxx diff --git a/src/ViewerTest/ViewerTest.cxx b/src/ViewerTest/ViewerTest.cxx index 69e3e017d7..d59dd06ac4 100644 --- a/src/ViewerTest/ViewerTest.cxx +++ b/src/ViewerTest/ViewerTest.cxx @@ -5467,7 +5467,6 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands) ViewerTest::RelationCommands(theCommands); ViewerTest::ObjectCommands(theCommands); ViewerTest::FilletCommands(theCommands); - ViewerTest::VoxelCommands(theCommands); ViewerTest::OpenGlCommands(theCommands); const char *group = "AIS_Display"; diff --git a/src/ViewerTest/ViewerTest.hxx b/src/ViewerTest/ViewerTest.hxx index 266e68a252..0f26ac11d9 100644 --- a/src/ViewerTest/ViewerTest.hxx +++ b/src/ViewerTest/ViewerTest.hxx @@ -130,8 +130,6 @@ public: Standard_EXPORT static void FilletCommands (Draw_Interpretor& theCommands); - Standard_EXPORT static void VoxelCommands (Draw_Interpretor& theCommands); - Standard_EXPORT static void OpenGlCommands (Draw_Interpretor& theCommands); Standard_EXPORT static void GetMousePosition (Standard_Integer& xpix, Standard_Integer& ypix); diff --git a/src/ViewerTest/ViewerTest_VoxelCommands.cxx b/src/ViewerTest/ViewerTest_VoxelCommands.cxx deleted file mode 100644 index 41c3280473..0000000000 --- a/src/ViewerTest/ViewerTest_VoxelCommands.cxx +++ /dev/null @@ -1,1053 +0,0 @@ -// Created on: 2008-09-17 -// Created by: Vlad Romashko -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -// A method parses the input parameters. -static Standard_Boolean GetInputParameters(Standard_Integer nbargs, const char** args, - Standard_Real& x, Standard_Real& y, Standard_Real& z, - Standard_Real& dx, Standard_Real& dy, Standard_Real& dz, - Standard_Integer& nbx, Standard_Integer& nby, Standard_Integer& nbz) -{ - // Default values. - nbx = 10; nby = 10; nbz = 10; - x = 0.0; y = 0.0; z = 0.0; - dx = 1.0; dy = 1.0; dz = 1.0; - - // "voxelboolds 0 0 0 1 1 1 100 100 100" - if (nbargs == 10) - { - nbx = Draw::Atoi(args[7]); - nby = Draw::Atoi(args[8]); - nbz = Draw::Atoi(args[9]); - } - // "voxelboolds 0 0 0 1 1 1" - if (nbargs == 7 || nbargs == 10) - { - dx = Draw::Atof(args[4]); - dy = Draw::Atof(args[5]); - dz = Draw::Atof(args[6]); - } - // "voxelboolds 0 0 0" - if (nbargs == 4 || nbargs == 7 || nbargs == 10) - { - x = Draw::Atof(args[1]); - y = Draw::Atof(args[2]); - z = Draw::Atof(args[3]); - } - // "voxelboolds" - if (nbargs == 1) - { - // use default parameters - } - - return nbargs == 1 || nbargs == 4 || nbargs == 7 || nbargs == 10; -} - -static Standard_Integer VOXELBOOLDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelboolds [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. BoolDS: - Voxel_BoolDS ds(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds.Set(ix, iy, iz, Standard_False); - else - ds.Set(ix, iy, iz, Standard_True); - } - } - } - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - Standard_Boolean value = ds.Get(ix, iy, iz) == Standard_True; - if (ix & 0x01) - { - if (value != Standard_False) - { - di<<"error : voxelboolds"; - return 1; // error - } - } - else - { - if (value != Standard_True) - { - di<<"error : voxelboolds"; - return 1; // error - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELCOLORDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelcolords [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. ColorDS: - Voxel_ColorDS ds(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds.Set(ix, iy, iz, 8); - else - ds.Set(ix, iy, iz, 7); - } - } - } - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - Standard_Byte value = ds.Get(ix, iy, iz); - if (ix & 0x01) - { - if (value != 8) - { - di<<"error : voxelcolords"; - return 1; - } - } - else - { - if (value != 7) - { - di<<"error : voxelcolords"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELFLOATDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelfloatds [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. FloatDS: - Voxel_FloatDS ds(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds.Set(ix, iy, iz, 8.8f); - else - ds.Set(ix, iy, iz, 7.7f); - } - } - } - - /* - // Write the voxels - Voxel_Writer writer; - writer.SetFormat(Voxel_VFF_BINARY); - writer.SetVoxels(ds); - if (!writer.Write("W:\\OCC621\\samples\\standard\\voxeldemo\\f.vx")) - { - statusBar()->message( "Storage failed... sorry", 2000 ); - return; - } - - // Read the voxels - Voxel_Reader reader; - if (!reader.Read("W:\\OCC621\\samples\\standard\\voxeldemo\\f.vx")) - { - statusBar()->message( "Open failed... sorry", 2000 ); - return; - } - */ - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - float value = ds.Get(ix, iy, iz); - if (ix & 0x01) - { - if (value != 8.8f) - { - di<<"error : voxelfloatds"; - return 1; - } - } - else - { - if (value != 7.7f) - { - di<<"error : voxelfloatds"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELOCTBOOLDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxeloctboolds [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. OctBoolDS: - Voxel_OctBoolDS ds(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - { - ds.Set(ix, iy, iz, Standard_True); - } - else - { - for (Standard_Integer i = 0; i < 8; i++) - { - if (i & 0x01) - ds.Set(ix, iy, iz, i, Standard_True); - else - ds.Set(ix, iy, iz, i, Standard_False); - } - } - } - } - } - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - { - Standard_Boolean value = ds.Get(ix, iy, iz) == Standard_True; - if (value != Standard_True) - cout<<"Wrong value!"< 0.001) - { - di<<"error : voxelfusefloatds"; - return 1; - } - } - else - { - if (fabs(value - 16.6f) > 0.001) - { - di<<"error : voxelfusefloatds"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELCUTBOOLDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelcutboolds [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. Set two BoolDS: - Voxel_BoolDS ds1(x, y, z, dx, dy, dz, nbx, nby, nbz); - Voxel_BoolDS ds2(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - ds1.Set(ix, iy, iz, Standard_True); - } - } - } - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds2.Set(ix, iy, iz, Standard_False); - else - ds2.Set(ix, iy, iz, Standard_True); - } - } - } - - // 2. Cut them - - Voxel_BooleanOperation cutter; - if (!cutter.Cut(ds1, ds2)) - { - di<<"error : voxelcutboolds"; - return 1; - } - - // 3. Check result - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - Standard_Boolean value = ds1.Get(ix, iy, iz) == Standard_True; - if (ix & 0x01) - { - if (value != Standard_True) - { - di<<"error : voxelcutboolds"; - return 1; - } - } - else - { - if (value != Standard_False) - { - di<<"error : voxelcutboolds"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELCUTCOLORDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelcutcolords [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. Set two ColorDS: - Voxel_ColorDS ds1(x, y, z, dx, dy, dz, nbx, nby, nbz); - Voxel_ColorDS ds2(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - ds1.Set(ix, iy, iz, 11); - } - } - } - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds2.Set(ix, iy, iz, 3); - else - ds2.Set(ix, iy, iz, 5); - } - } - } - - // 2. Cut them - - Voxel_BooleanOperation cutter; - if (!cutter.Cut(ds1, ds2)) - { - di<<"error : voxelcutcolords"; - return 1; - } - - // 3. Check result - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - Standard_Byte value = ds1.Get(ix, iy, iz); - if (ix & 0x01) - { - if (value != 8) - { - di<<"error : voxelcutcolords"; - return 1; - } - } - else - { - if (value != 6) - { - di<<"error : voxelcutcolords"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELCUTFLOATDS(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - // Parse input parameters. - Standard_Real x, y, z, dx, dy, dz; - Standard_Integer ix, iy, iz, nbx, nby, nbz; - if (!GetInputParameters(nbargs, args, x, y, z, dx, dy, dz, nbx, nby, nbz)) - { - di << "Usage: voxelcutfloatds [x, y, z, dx, dy, dz nbx, nby, nbz]"; - return 1; - } - - // 1. Set two FloatDS: - Voxel_FloatDS ds1(x, y, z, dx, dy, dz, nbx, nby, nbz); - Voxel_FloatDS ds2(x, y, z, dx, dy, dz, nbx, nby, nbz); - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - ds1.Set(ix, iy, iz, 11.1f); - } - } - } - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - if (ix & 0x01) - ds2.Set(ix, iy, iz, 3.3f); - else - ds2.Set(ix, iy, iz, 5.5f); - } - } - } - - // 2. Cut them - - Voxel_BooleanOperation cutter; - if (!cutter.Cut(ds1, ds2)) - { - di<<"error : voxelcutcolords"; - return 1; - } - - // 3. Check result - - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - for (iz = 0; iz < nbz; iz++) - { - float value = ds1.Get(ix, iy, iz); - if (ix & 0x01) - { - if (fabs(value - 7.8f) > 0.001) - { - di<<"error : voxelcutcolords"; - return 1; - } - } - else - { - if (fabs(value - 5.6f) > 0.001) - { - di<<"error : voxelcutcolords"; - return 1; - } - } - } - } - } - - return 0; -} - -static Standard_Integer VOXELBOOLDSCONVERT(Draw_Interpretor& di, Standard_Integer nbargs, const char** args) -{ - TopoDS_Shape S; - Standard_Integer nbx = 100, nby = 100, nbz = 100; - Standard_Real deflection = 0.1; - Standard_Boolean fast = Standard_True; - Standard_Integer nbthreads = 1; - Standard_Boolean usetriangulation = Standard_False; - Standard_Integer fillInVolume = 0; - - if (nbargs < 2) - { - di << "Usage: voxelbooldsconvert shape [nbx nby nbz deflection 0|1(fast or accurate) nbthreads usetriangulation \ - 0|1|2(fill-in volume: no|yes|yes using shape)]"; - return 1; - } - - // Get shape for conversion. - S = DBRep::Get(args[1]); - - if (nbargs > 2) - { - if (nbargs >= 5) - { - nbx = Draw::Atoi(args[2]); - nby = Draw::Atoi(args[3]); - nbz = Draw::Atoi(args[4]); - } - if (nbargs >= 6) - { - deflection = Draw::Atof(args[5]); - } - if (nbargs >= 7) - { - // 0 means fast, - // 1 means accurate. - fast = Draw::Atoi(args[6]) == 0 ? Standard_True : Standard_False; - } - if (nbargs >= 8) - { - nbthreads = Draw::Atoi(args[7]); - if (nbthreads < 1) - { - di << "Wrong number of threads: 1 .. nb cores"; - return 1; - } - else if (nbthreads > 100) // seems too much... - { - di << "Too many threads..."; - } - } - if (nbargs >= 9) - { - usetriangulation = Draw::Atoi(args[8]) == 0 ? Standard_False : Standard_True; - } - if (nbargs >= 10) - { - fillInVolume = Draw::Atoi(args[9]); - if (fillInVolume < 0 || fillInVolume > 2) - { - di << "Fill-in volume parameter accepts the values: 0 - no, 1 - yes, 2 - yes wusing shape"; - return 1; - } - } - } - - // Call converter. - Voxel_BoolDS ds; - Standard_Boolean ret; - Standard_Integer progress = 0; - Voxel_FastConverter converter(S, ds, deflection, nbx, nby, nbz, nbthreads, usetriangulation); - - // Convert. - if (fast) - ret = converter.Convert(progress); - else - ret = converter.ConvertUsingSAT(progress); - - // Fill-in volume. - if (ret) - { - switch (fillInVolume) - { - case 0: - break; - case 1: - converter.FillInVolume(1, nbthreads); - break; - case 2: - converter.FillInVolume(1, S, nbthreads); - break; - } - } - - return ret == Standard_True ? 0 : 1; -} - -void ViewerTest::VoxelCommands(Draw_Interpretor& theCommands) -{ - const char* g = "Voxel draw-commands"; - // Basic commands. - theCommands.Add("voxelboolds" ,"voxelboolds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELBOOLDS,g); - theCommands.Add("voxelcolords" ,"voxelcolords [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELCOLORDS,g); - theCommands.Add("voxelfloatds" ,"voxelfloatds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELFLOATDS,g); - theCommands.Add("voxeloctboolds" ,"voxeloctboolds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELOCTBOOLDS,g); - theCommands.Add("voxelroctboolds" ,"voxelroctboolds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELROCTBOOLDS,g); - // Boolean operations. - theCommands.Add("voxelfuseboolds" ,"voxelfuseboolds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELFUSEBOOLDS,g); - theCommands.Add("voxelfusecolords","voxelfusecolords [x y z dx dy dz nbx nby nbz]",__FILE__,VOXELFUSECOLORDS,g); - theCommands.Add("voxelfusefloatds","voxelfusefloatds [x y z dx dy dz nbx nby nbz]",__FILE__,VOXELFUSEFLOATDS,g); - theCommands.Add("voxelcutboolds" ,"voxelcutboolds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELCUTBOOLDS,g); - theCommands.Add("voxelcutcolords" ,"voxelcutcolords [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELCUTCOLORDS,g); - theCommands.Add("voxelcutfloatds" ,"voxelcutfloatds [x y z dx dy dz nbx nby nbz]" ,__FILE__,VOXELCUTFLOATDS,g); - // Conversion of a shape into voxels. - theCommands.Add("voxelbooldsconvert", - "voxelbooldsconvert shape [nbx nby nbz deflection 0|1(fast or accurate) nbthreads usetriangulation \ - 0|1|2(fill-in volume: no|yes|yes using shape)]", - __FILE__,VOXELBOOLDSCONVERT,g); -} diff --git a/src/Voxel/FILES b/src/Voxel/FILES deleted file mode 100755 index 1271ed4fa5..0000000000 --- a/src/Voxel/FILES +++ /dev/null @@ -1,32 +0,0 @@ -Voxel_BoolDS.cxx -Voxel_BoolDS.hxx -Voxel_BooleanOperation.cxx -Voxel_BooleanOperation.hxx -Voxel_CollisionDetection.cxx -Voxel_CollisionDetection.hxx -Voxel_ColorDS.cxx -Voxel_ColorDS.hxx -Voxel_DS.cxx -Voxel_DS.hxx -Voxel_FastConverter.cxx -Voxel_FastConverter.hxx -Voxel_FloatDS.cxx -Voxel_FloatDS.hxx -Voxel_OctBoolDS.cxx -Voxel_OctBoolDS.hxx -Voxel_Prs.cxx -Voxel_Prs.hxx -Voxel_Reader.cxx -Voxel_Reader.hxx -Voxel_ROctBoolDS.cxx -Voxel_ROctBoolDS.hxx -Voxel_Selector.cxx -Voxel_Selector.hxx -Voxel_SplitData.cxx -Voxel_SplitData.hxx -Voxel_TypeDef.hxx -Voxel_VisData.h -Voxel_VoxelDisplayMode.hxx -Voxel_VoxelFileFormat.hxx -Voxel_Writer.cxx -Voxel_Writer.hxx diff --git a/src/Voxel/Voxel_BoolDS.cxx b/src/Voxel/Voxel_BoolDS.cxx deleted file mode 100644 index 20adea5b74..0000000000 --- a/src/Voxel/Voxel_BoolDS.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// Created on: 2008-06-21 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include - -#include -static Standard_Byte gbits[8] = {1, 2, 4, 8, 16, 32, 64, 128}; -static Standard_Byte gnbits[8] = {255-1, 255-2, 255-4, 255-8, 255-16, 255-32, 255-64, 255-128}; - -// Empty constructor -Voxel_BoolDS::Voxel_BoolDS():Voxel_DS() -{ - -} - -// Constructor with intialization. -Voxel_BoolDS::Voxel_BoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -:Voxel_DS() -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_BoolDS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Destroy(); - - Voxel_DS::Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - if (!myNbX || !myNbY || !myNbZ) - return; - - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - myData = (Standard_Address) calloc(nb_slices, sizeof(Standard_Byte*)); -} - -// Destructor -void Voxel_BoolDS::Destroy() -{ - if (myData) - { - SetZero(); - free((Standard_Byte**)myData); - myData = 0; - } -} - -void Voxel_BoolDS::SetZero() -{ - if (myData) - { - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - Standard_Integer ix = 0, nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - for (; ix < nb_slices; ix++) - { - if (((Standard_Byte**)myData)[ix]) - { - free(((Standard_Byte**)myData)[ix]); - ((Standard_Byte**)myData)[ix] = 0; - } - } - } -} - -// Access to the boolean information attached to a particular voxel: -// Info: (ix >= 0 && ix < theNb_x), etc. -void Voxel_BoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Boolean data) -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 6; - - if (!data && !((Standard_Byte**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Standard_Byte**)myData)[islice]) - { - ((Standard_Byte**)myData)[islice] = (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - - // Index within 8 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 6); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - // Set data - if (data != ((value & gbits[shift]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[shift]; - else - value &= gnbits[shift]; - ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte] = value; - } -} - -Standard_Boolean Voxel_BoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 6; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Standard_Byte**)myData)[islice]) - return Standard_False; - - // Index within 8 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 6); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - return ((value & gbits[shift]) ? Standard_True : Standard_False); -} diff --git a/src/Voxel/Voxel_BoolDS.hxx b/src/Voxel/Voxel_BoolDS.hxx deleted file mode 100644 index e672e6dcaa..0000000000 --- a/src/Voxel/Voxel_BoolDS.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Created on: 2008-05-04 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_BoolDS_HeaderFile -#define _Voxel_BoolDS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include - - -//! A 3D voxel model keeping a bool flag (1 or 0) -//! value for each voxel. -class Voxel_BoolDS : public Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_BoolDS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_BoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z) Standard_OVERRIDE; - - //! A destructor of the voxel model. - Standard_EXPORT void Destroy(); -~Voxel_BoolDS() -{ - Destroy(); -} - - //! The method sets all values equal to 0 (false) and - //! releases the memory. - Standard_EXPORT void SetZero(); - - //! Defines a value for voxel with co-ordinates (ix, iy, iz). - //! Initial state of the model is so that all voxels have value 0 (false), - //! and this data doesn't occupy memory. - //! Memory for data is allocating during setting non-zero values (true). - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Boolean data = Standard_True); - - //! Returns the value of voxel with co-ordinates (ix, iy, iz). - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - - - -protected: - - - - - -private: - - - - - -}; - - - - - - - -#endif // _Voxel_BoolDS_HeaderFile diff --git a/src/Voxel/Voxel_BooleanOperation.cxx b/src/Voxel/Voxel_BooleanOperation.cxx deleted file mode 100644 index 127120059b..0000000000 --- a/src/Voxel/Voxel_BooleanOperation.cxx +++ /dev/null @@ -1,230 +0,0 @@ -// Created on: 2008-05-21 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include - -Voxel_BooleanOperation::Voxel_BooleanOperation() -{ - -} - -Standard_Boolean Voxel_BooleanOperation::Fuse( Voxel_BoolDS& theVoxels1, - const Voxel_BoolDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Take the values of the second cube and put them to the first one. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_Boolean value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - theVoxels1.Set(ix, iy, iz, value2); - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Fuse( Voxel_ColorDS& theVoxels1, - const Voxel_ColorDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Take the values of the second cube and put them to the first one. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_Byte value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - { - Standard_Byte value1 = theVoxels1.Get(ix, iy, iz); - Standard_Byte value = value1 + value2; - if (value > 15) - value = 15; - theVoxels1.Set(ix, iy, iz, value); - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Fuse( Voxel_FloatDS& theVoxels1, - const Voxel_FloatDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Take the values of the second cube and put them to the first one. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_ShortReal value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - { - Standard_ShortReal value1 = theVoxels1.Get(ix, iy, iz); - theVoxels1.Set(ix, iy, iz, value1 + value2); - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Cut( Voxel_BoolDS& theVoxels1, - const Voxel_BoolDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Subtract the values. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_Boolean value1 = theVoxels1.Get(ix, iy, iz); - if (value1) - { - Standard_Boolean value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - theVoxels1.Set(ix, iy, iz, Standard_False); - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Cut( Voxel_ColorDS& theVoxels1, - const Voxel_ColorDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Subtract the values. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_Byte value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - { - Standard_Byte value1 = theVoxels1.Get(ix, iy, iz); - if (value1) - { - Standard_Integer value = value1 - value2; - if (value < 0) - value = 0; - theVoxels1.Set(ix, iy, iz, (Standard_Byte)value); - } - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Cut( Voxel_FloatDS& theVoxels1, - const Voxel_FloatDS& theVoxels2) const -{ - // Check the voxels - if (!Check(theVoxels1, theVoxels2)) - return Standard_False; - - // Subtract the values. - Standard_Integer ix, iy, iz; - for (iz = 0; iz < theVoxels2.GetNbZ(); iz++) - { - for (iy = 0; iy < theVoxels2.GetNbY(); iy++) - { - for (ix = 0; ix < theVoxels2.GetNbX(); ix++) - { - Standard_ShortReal value2 = theVoxels2.Get(ix, iy, iz); - if (value2) - { - Standard_ShortReal value1 = theVoxels1.Get(ix, iy, iz); - theVoxels1.Set(ix, iy, iz, value1 - value2); - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_BooleanOperation::Check(const Voxel_DS& theVoxels1, - const Voxel_DS& theVoxels2) const -{ - // Check the voxels - // Number of splits along X, Y and Z axes. - if (!theVoxels1.GetNbX() && theVoxels1.GetNbX() != theVoxels2.GetNbX()) - return Standard_False; - if (!theVoxels1.GetNbY() && theVoxels1.GetNbY() != theVoxels2.GetNbY()) - return Standard_False; - if (!theVoxels1.GetNbZ() && theVoxels1.GetNbZ() != theVoxels2.GetNbZ()) - return Standard_False; - // Start point - if (fabs(theVoxels1.GetX() - theVoxels2.GetX()) > Precision::Confusion() || - fabs(theVoxels1.GetY() - theVoxels2.GetY()) > Precision::Confusion() || - fabs(theVoxels1.GetZ() - theVoxels2.GetZ()) > Precision::Confusion()) - { - return Standard_False; - } - // Length along X, Y and Z axes. - if (fabs(theVoxels1.GetXLen() - theVoxels2.GetXLen()) > Precision::Confusion() || - fabs(theVoxels1.GetYLen() - theVoxels2.GetYLen()) > Precision::Confusion() || - fabs(theVoxels1.GetZLen() - theVoxels2.GetZLen()) > Precision::Confusion()) - { - return Standard_False; - } - return Standard_True; -} diff --git a/src/Voxel/Voxel_BooleanOperation.hxx b/src/Voxel/Voxel_BooleanOperation.hxx deleted file mode 100644 index f2ec647679..0000000000 --- a/src/Voxel/Voxel_BooleanOperation.hxx +++ /dev/null @@ -1,108 +0,0 @@ -// Created on: 2008-05-21 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_BooleanOperation_HeaderFile -#define _Voxel_BooleanOperation_HeaderFile - -#include -#include -#include - -#include -class Voxel_BoolDS; -class Voxel_ColorDS; -class Voxel_FloatDS; -class Voxel_DS; - - -//! Boolean operations (fuse, cut) -//! for voxels of the same dimension. -class Voxel_BooleanOperation -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_BooleanOperation(); - - //! Fuses two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - Standard_EXPORT Standard_Boolean Fuse (Voxel_BoolDS& theVoxels1, const Voxel_BoolDS& theVoxels2) const; - - //! Fuses two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - //! It summerizes the value of corresponding voxels and puts the result to theVoxels1. - //! If the result exceeds 15 or becomes greater, it keeps 15. - Standard_EXPORT Standard_Boolean Fuse (Voxel_ColorDS& theVoxels1, const Voxel_ColorDS& theVoxels2) const; - - //! Fuses two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - //! It summerizes the value of corresponding voxels and puts the result to theVoxels1. - Standard_EXPORT Standard_Boolean Fuse (Voxel_FloatDS& theVoxels1, const Voxel_FloatDS& theVoxels2) const; - - //! Cuts two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - Standard_EXPORT Standard_Boolean Cut (Voxel_BoolDS& theVoxels1, const Voxel_BoolDS& theVoxels2) const; - - //! Cuts two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - //! It subtracts the value of corresponding voxels and puts the result to theVoxels1. - Standard_EXPORT Standard_Boolean Cut (Voxel_ColorDS& theVoxels1, const Voxel_ColorDS& theVoxels2) const; - - //! Cuts two cubes of voxels. - //! It modifies the first cube of voxels. - //! It returns false in case of different dimension of the cube, - //! different number of voxels. - //! It subtracts the value of corresponding voxels and puts the result to theVoxels1. - Standard_EXPORT Standard_Boolean Cut (Voxel_FloatDS& theVoxels1, const Voxel_FloatDS& theVoxels2) const; - - - - -protected: - - - - - -private: - - - Standard_EXPORT Standard_Boolean Check (const Voxel_DS& theVoxels1, const Voxel_DS& theVoxels2) const; - - - - -}; - - - - - - - -#endif // _Voxel_BooleanOperation_HeaderFile diff --git a/src/Voxel/Voxel_CollisionDetection.cxx b/src/Voxel/Voxel_CollisionDetection.cxx deleted file mode 100644 index 5fd8b5f4dc..0000000000 --- a/src/Voxel/Voxel_CollisionDetection.cxx +++ /dev/null @@ -1,295 +0,0 @@ -// Created on: 2008-07-16 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include - -Voxel_CollisionDetection::Voxel_CollisionDetection() -:myDeflection(0.1), - myNbX(100), - myNbY(100), - myNbZ(100), - myUsageOfVolume(Standard_False), - myKeepCollisions(Standard_False), - myXLen(-1.0), - myYLen(-1.0), - myZLen(-1.0), - myVoxels(0), - myHasCollisions(Standard_False) -{ - -} - -Voxel_CollisionDetection::Voxel_CollisionDetection(const Standard_Real deflection, - const Standard_Integer nbx, - const Standard_Integer nby, - const Standard_Integer nbz) -:myDeflection(deflection), - myNbX(nbx), - myNbY(nby), - myNbZ(nbz), - myUsageOfVolume(Standard_False), - myKeepCollisions(Standard_False), - myXLen(-1.0), - myYLen(-1.0), - myZLen(-1.0), - myVoxels(0), - myHasCollisions(Standard_False) -{ - -} - -// Destructor -void Voxel_CollisionDetection::Destroy() -{ - Clear(); -} - -Standard_Integer Voxel_CollisionDetection::AddShape(const TopoDS_Shape& shape) -{ - Clear(); - myShapes.Append(shape); - return myShapes.Extent(); -} - -Standard_Boolean Voxel_CollisionDetection::ReplaceShape(const Standard_Integer ishape, - const TopoDS_Shape& shape) -{ - if (ishape == 1) - { - myShapes.RemoveFirst(); - myShapes.Prepend(shape); - return Standard_True; - } - - Standard_Integer i = 1; - Standard_Boolean is_replaced = Standard_False; - TopTools_ListIteratorOfListOfShape itr(myShapes); - for (; itr.More(); itr.Next(), i++) - { - if (i == ishape) - { - myShapes.Remove(itr); - myShapes.InsertBefore(shape, itr); - is_replaced = Standard_True; - break; - } - } - return is_replaced; -} - -void Voxel_CollisionDetection::SetDeflection(const Standard_Real deflection) -{ - myDeflection = deflection; -} - -void Voxel_CollisionDetection::SetNbVoxels(const Standard_Integer nbx, - const Standard_Integer nby, - const Standard_Integer nbz) -{ - myNbX = nbx; - myNbY = nby; - myNbZ = nbz; -} - -void Voxel_CollisionDetection::SetBoundaryBox(const Bnd_Box& box) -{ - if (box.IsVoid()) - return; - - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - box.Get(xmin, ymin, zmin, xmax, ymax, zmax); - - myX = xmin; - myY = ymin; - myZ = zmin; - - myXLen = xmax - xmin; - myYLen = ymax - ymin; - myZLen = zmax - zmin; -} - -void Voxel_CollisionDetection::SetUsageOfVolume(const Standard_Boolean usage) -{ - myUsageOfVolume = usage; -} - -void Voxel_CollisionDetection::KeepCollisions(const Standard_Boolean keep) -{ - myKeepCollisions = keep; -} - -Standard_Boolean Voxel_CollisionDetection::Voxelize(const Standard_Integer ishape) -{ - // Check the arguments - if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0) - return Standard_False; - - // Calculate the boundary box of the shapes to define the size of voxels. - // This code is called only if the user didn't define the boundary box himself. - if (myXLen < 0.0) - { - Bnd_Box B, b; - TopTools_ListIteratorOfListOfShape itrs(myShapes); - for (; itrs.More(); itrs.Next()) - { - TopoDS_Shape S = itrs.Value(); - BRepBndLib::Add(S, b); - B.Add(b); - } - SetBoundaryBox(B); - } - - // Voxelize the shapes - Standard_Integer progress, ithread = 1, i = 1; - TopTools_ListIteratorOfListOfShape itrs(myShapes); - for (; itrs.More(); itrs.Next(), i++) - { - if (ishape != -1 && i != ishape) - continue; - - if (!myVoxels) - myVoxels = (Standard_Address) new Voxel_BoolDS[myShapes.Extent()]; - Voxel_BoolDS& voxels = ((Voxel_BoolDS*)myVoxels)[i - 1]; - if (!CheckVoxels(voxels)) - { - voxels.Init(myX, myY, myZ, myXLen, myYLen, myZLen, myNbX, myNbY, myNbZ); - } - else - { - voxels.SetZero(); - } - - TopoDS_Shape S = itrs.Value(); - Voxel_FastConverter voxelizer(S, voxels, myDeflection, myNbX, myNbY, myNbZ, 1 /*number of threads */); - if (!voxelizer.Convert(progress, ithread)) - return Standard_False; - if (myUsageOfVolume && !voxelizer.FillInVolume(1, ithread)) - return Standard_False; - } - - return Standard_True; -} - -Standard_Boolean Voxel_CollisionDetection::Compute() -{ - myHasCollisions = Standard_False; - - // Check voxels of shapes - if (!myVoxels) - return Standard_False; - Standard_Integer ishape = 0, nb_shapes = myShapes.Extent(); - for (; ishape < nb_shapes; ishape++) - { - Voxel_BoolDS& voxels = ((Voxel_BoolDS*)myVoxels)[ishape]; - if (!CheckVoxels(voxels)) - { - return Standard_False; - } - } - - // Check the resulting voxels - Standard_Boolean created = Standard_False; - if (!CheckVoxels(myCollisions)) - { - // Create 0-voxels for the result, if it is needed. - created = Standard_True; - myCollisions.Init(myX, myY, myZ, myXLen, myYLen, myZLen, myNbX, myNbY, myNbZ); - } - - // Nullify the voxels of the result (it corresponds to the state of no collisions). - if (!myKeepCollisions && !created) - { - myCollisions.SetZero(); - } - - // Check collisions - if (nb_shapes) - { - Standard_Integer ix, iy, iz; - Voxel_BoolDS& voxels = ((Voxel_BoolDS*)myVoxels)[0]; // 1st shape - for (ix = 0; ix < myNbX; ix++) - { - for (iy = 0; iy < myNbY; iy++) - { - for (iz = 0; iz < myNbZ; iz++) - { - if (voxels.Get(ix, iy, iz)) - { - for (ishape = 1; ishape < nb_shapes; ishape++) // start with second shape - { - Voxel_BoolDS& anOtherVoxels = ((Voxel_BoolDS*)myVoxels)[ishape]; - if (anOtherVoxels.Get(ix, iy, iz)) - { - myCollisions.Set(ix, iy, iz, Standard_True); - if (!myHasCollisions) - { - myHasCollisions = Standard_True; - } - break; - } - } - } - } - } - } - } - - - return Standard_True; -} - -Standard_Boolean Voxel_CollisionDetection::HasCollisions() const -{ - return myHasCollisions; -} - -const Voxel_BoolDS& Voxel_CollisionDetection::GetCollisions() const -{ - return myCollisions; -} - -void Voxel_CollisionDetection::Clear() -{ - if (myVoxels) - { - delete[] ((Voxel_BoolDS*)myVoxels); - myVoxels = 0; - } -} - -Standard_Boolean Voxel_CollisionDetection::CheckVoxels(const Voxel_BoolDS& voxels) const -{ - if (fabs(voxels.GetX() - myX) > Precision::Confusion() || - fabs(voxels.GetY() - myY) > Precision::Confusion() || - fabs(voxels.GetZ() - myZ) > Precision::Confusion() || - fabs(voxels.GetXLen() - myXLen) > Precision::Confusion() || - fabs(voxels.GetYLen() - myYLen) > Precision::Confusion() || - fabs(voxels.GetZLen() - myZLen) > Precision::Confusion() || - voxels.GetNbX() != myNbX || - voxels.GetNbY() != myNbY || - voxels.GetNbZ() != myNbZ) - { - return Standard_False; - } - return Standard_True; -} diff --git a/src/Voxel/Voxel_CollisionDetection.hxx b/src/Voxel/Voxel_CollisionDetection.hxx deleted file mode 100644 index 2733984d10..0000000000 --- a/src/Voxel/Voxel_CollisionDetection.hxx +++ /dev/null @@ -1,151 +0,0 @@ -// Created on: 2008-07-14 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_CollisionDetection_HeaderFile -#define _Voxel_CollisionDetection_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -class TopoDS_Shape; -class Bnd_Box; -class Voxel_BoolDS; - - -//! Detects collisions between shapes. -class Voxel_CollisionDetection -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_CollisionDetection(); - - //! A constructor. - //! It defines deflection of triangulation for the shapes. - //! As lower the deflection is, as proper the triangulation is generated. - //! Also, it defines number of splits along X, Y and Z axes for generation of voxels. - //! As greater the numbers are, as greater number of voxels is used for detection of collision. - Standard_EXPORT Voxel_CollisionDetection(const Standard_Real deflection, const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz); - - //! Adds a shape. - //! Returns an index of the shape. - Standard_EXPORT Standard_Integer AddShape (const TopoDS_Shape& shape); - - //! Replaces a shape by another one. - //! is an index of the shape. - //! This method is useful for moving shape, for example. - Standard_EXPORT Standard_Boolean ReplaceShape (const Standard_Integer ishape, const TopoDS_Shape& shape); - - //! Defines the deflection of triangulation of shapes. - Standard_EXPORT void SetDeflection (const Standard_Real deflection); - - //! Defines the number of voxels along X, Y and Z axes. - Standard_EXPORT void SetNbVoxels (const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz); - - //! Defines a user-defined boundary box for generation of voxels. - //! If this method is not called, the algorithm calculates the boundary box itself. - Standard_EXPORT void SetBoundaryBox (const Bnd_Box& box); - - //! Defines usage of volume of shapes in collision detection algorithm. - //! Beware, usage of volume a little bit decreases the speed of algorithm. - Standard_EXPORT void SetUsageOfVolume (const Standard_Boolean usage); - - //! Doesn't clean the collision points on new call to the method Compute(). - //! It allows to see the collisions for a moving shape. - Standard_EXPORT void KeepCollisions (const Standard_Boolean keep); - - //! Prepares data for computation of collisions. - //! It checks the inner parameters (number of voxels along X, Y and Z axes) and - //! voxelizes the shapes. - //! If the shape is not changed since the last call to this method, - //! this method may be not called for this shape. - //! - is the index of the shape for processing by this method. - //! If it is equal to -1, all shapes will be processed. - Standard_EXPORT Standard_Boolean Voxelize (const Standard_Integer ishape = -1); - - //! Computes the collisions. - //! This method may be called many times if, for example, the shapes are being moved. - Standard_EXPORT Standard_Boolean Compute(); - - //! Returns true if a collision is detected. - Standard_EXPORT Standard_Boolean HasCollisions() const; - - //! Returns the collided voxels. - Standard_EXPORT const Voxel_BoolDS& GetCollisions() const; - - //! A destructor. - Standard_EXPORT void Destroy(); -~Voxel_CollisionDetection() -{ - Destroy(); -} - - - - -protected: - - - - - -private: - - - //! An internal method for cleaning the intermediate data. - Standard_EXPORT void Clear(); - - //! An internal method, which checks correspondance - //! of voxels to the parameters defined by user. - Standard_EXPORT Standard_Boolean CheckVoxels (const Voxel_BoolDS& voxels) const; - - - TopTools_ListOfShape myShapes; - Standard_Real myDeflection; - Standard_Integer myNbX; - Standard_Integer myNbY; - Standard_Integer myNbZ; - Standard_Boolean myUsageOfVolume; - Standard_Boolean myKeepCollisions; - Standard_Real myX; - Standard_Real myY; - Standard_Real myZ; - Standard_Real myXLen; - Standard_Real myYLen; - Standard_Real myZLen; - Standard_Address myVoxels; - Voxel_BoolDS myCollisions; - Standard_Boolean myHasCollisions; - - -}; - - - - - - - -#endif // _Voxel_CollisionDetection_HeaderFile diff --git a/src/Voxel/Voxel_ColorDS.cxx b/src/Voxel/Voxel_ColorDS.cxx deleted file mode 100644 index 1ec26750f1..0000000000 --- a/src/Voxel/Voxel_ColorDS.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// Created on: 2008-05-08 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include - -#include -static Standard_Byte gbits[8] = {1, 2, 4, 8, 16, 32, 64, 128}; -static Standard_Byte gnbits[8] = {255-1, 255-2, 255-4, 255-8, 255-16, 255-32, 255-64, 255-128}; - -// Empty constructor -Voxel_ColorDS::Voxel_ColorDS():Voxel_DS() -{ - -} - -// Constructor with intialization. -Voxel_ColorDS::Voxel_ColorDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -:Voxel_DS() -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_ColorDS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Destroy(); - - Voxel_DS::Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - if (!myNbX || !myNbY || !myNbZ) - return; - - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 2.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - myData = (Standard_Address) calloc(nb_slices, sizeof(Standard_Byte*)); -} - -// Destructor -void Voxel_ColorDS::Destroy() -{ - if (myData) - { - SetZero(); - free((Standard_Byte**)myData); - myData = 0; - } -} - -void Voxel_ColorDS::SetZero() -{ - if (myData) - { - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 2.0)); - Standard_Integer ix = 0, nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - for (; ix < nb_slices; ix++) - { - if (((Standard_Byte**)myData)[ix]) - { - free(((Standard_Byte**)myData)[ix]); - ((Standard_Byte**)myData)[ix] = 0; - } - } - } -} - -// Access to the boolean information attached to a particular voxel: -// Info: (ix >= 0 && ix < theNb_x), etc. -void Voxel_ColorDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Byte data) -{ - Standard_Integer ibit = 4 * (ix + myNbX * iy + myNbXY * iz); - Standard_Integer islice = ibit >> 8; - - if (!data && !((Standard_Byte**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Standard_Byte**)myData)[islice]) - { - ((Standard_Byte**)myData)[islice] = (Standard_Byte*) calloc(32/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - - // Index within 32 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 8); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value": - // It is either 0 (first part of the byte) or 2 (second part of the byte) - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - // Set data - Standard_Integer i = 0, j = 0, nb = 4; // first part of byte - if (shift == 4) - { - // second part of byte - i = 4; - nb = 8; - } - - for (; i < nb; i++, j++) - { - if (data & gbits[j]) // if j-th bit is 1 - { - value |= gbits[i]; // set 1 to the i-th bit - } - else - { - value &= gnbits[i]; // set 0 to the i-th bit - } - } - - ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte] = value; -} - -Standard_Byte Voxel_ColorDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Byte ret = 0; - Standard_Integer ibit = 4 * (ix + myNbX * iy + myNbXY * iz); - Standard_Integer islice = ibit >> 8; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Standard_Byte**)myData)[islice]) - return ret; - - // Index within 8 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 8); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - // Return a byte with 4 first bits filled-in by the value. - Standard_Integer i = 0, j = 0, nb = 4; // first part of byte - if (shift == 4) - { - // second part of byte - i = 4; - nb = 8; - } - - for (; i < nb; i++, j++) - { - if (value & gbits[i]) // if i-th bit is 1 - { - ret |= gbits[j]; // set 1 to the j-th bit - } - } - - return ret; -} diff --git a/src/Voxel/Voxel_ColorDS.hxx b/src/Voxel/Voxel_ColorDS.hxx deleted file mode 100644 index b58963319c..0000000000 --- a/src/Voxel/Voxel_ColorDS.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Created on: 2008-05-08 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_ColorDS_HeaderFile -#define _Voxel_ColorDS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include - - -//! A 3D voxel model keeping 4 bits for each voxel (one of 16 colors). -class Voxel_ColorDS : public Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_ColorDS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_ColorDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z) Standard_OVERRIDE; - - //! A destructor of the voxel model. - Standard_EXPORT void Destroy(); -~Voxel_ColorDS() -{ - Destroy(); -} - - //! The method sets all values equal to 0 (false) and - //! releases the memory. - Standard_EXPORT void SetZero(); - - //! Defines a value for voxel with co-ordinates (ix, iy, iz). - //! Only the first four bits are used! - //! Initial state of the model is so that all voxels have value 0x0000, - //! and this data doesn't occupy memory. - //! Memory for data is allocating during setting non-zero values (0x0101, for example). - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Byte data); - - //! Returns the value of voxel with co-ordinates (ix, iy, iz). - Standard_EXPORT Standard_Byte Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - - - -protected: - - - - - -private: - - - - - -}; - - - - - - - -#endif // _Voxel_ColorDS_HeaderFile diff --git a/src/Voxel/Voxel_DS.cxx b/src/Voxel/Voxel_DS.cxx deleted file mode 100644 index e7d84111e2..0000000000 --- a/src/Voxel/Voxel_DS.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// Created on: 2008-05-11 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include - -// Empty constructor -Voxel_DS::Voxel_DS() -:myData(0), - myX(0.0),myY(0.0),myZ(0.0), - myXLen(0.0),myYLen(0.0),myZLen(0.0), - myNbX(0),myNbY(0),myNbZ(0), - myNbXY(0),myDX(0.0),myDY(0.0),myDZ(0.0), - myHalfDX(0.0),myHalfDY(0.0),myHalfDZ(0.0) -{ - -} - -// Constructor with intialization. -Voxel_DS::Voxel_DS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_DS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - myX = x; - myY = y; - myZ = z; - myXLen = xlen; - myYLen = ylen; - myZLen = zlen; - myNbX = nbx; - myNbY = nby; - myNbZ = nbz; - myNbXY = myNbX * myNbY; - myDX = myXLen / (Standard_Real) myNbX; - myDY = myYLen / (Standard_Real) myNbY; - myDZ = myZLen / (Standard_Real) myNbZ; - myHalfDX = myDX / 2.0; - myHalfDY = myDY / 2.0; - myHalfDZ = myDZ / 2.0; -} - -// Get the initial information on voxels -Standard_Real Voxel_DS::GetX() const -{ - return myX; -} - -Standard_Real Voxel_DS::GetY() const -{ - return myY; -} - -Standard_Real Voxel_DS::GetZ() const -{ - return myZ; -} - -Standard_Real Voxel_DS::GetXLen() const -{ - return myXLen; -} - -Standard_Real Voxel_DS::GetYLen() const -{ - return myYLen; -} - -Standard_Real Voxel_DS::GetZLen() const -{ - return myZLen; -} - -Standard_Integer Voxel_DS::GetNbX() const -{ - return myNbX; -} - -Standard_Integer Voxel_DS::GetNbY() const -{ - return myNbY; -} - -Standard_Integer Voxel_DS::GetNbZ() const -{ - return myNbZ; -} - -void Voxel_DS::GetCenter(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const -{ - GetOrigin(ix, iy, iz, xc, yc, zc); - xc += myHalfDX; - yc += myHalfDY; - zc += myHalfDZ; -} - -void Voxel_DS::GetOrigin(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - Standard_Real& x0, Standard_Real& y0, Standard_Real& z0) const -{ - x0 = myX + ix * myDX; - y0 = myY + iy * myDY; - z0 = myZ + iz * myDZ; -} - -// The method uses a chordial approach to find the index of voxel by co-ordinate. -static Standard_Integer findIndex(const Standard_Real xstart, const Standard_Real dx, - const Standard_Integer ix1, const Standard_Integer ix2, - const Standard_Real x) -{ - if (ix2 - ix1 < 2) - { - if (x < xstart + ix2 * dx) - return ix1; - return ix2; - } - - // Middle index - const Standard_Integer ixm = (ix1 + ix2) / 2; - - // Check if it is in the first half: - if (x >= xstart + ix1 * dx && x < xstart + ixm * dx) - { - return findIndex(xstart, dx, ix1, ixm, x); - } - - return findIndex(xstart, dx, ixm, ix2, x); -} - -Standard_Boolean Voxel_DS::GetVoxel(const Standard_Real x, const Standard_Real y, const Standard_Real z, - Standard_Integer& ix, Standard_Integer& iy, Standard_Integer& iz) const -{ - // X - if (!GetVoxelX(x, ix)) - return Standard_False; - - // Y - if (!GetVoxelY(y, iy)) - return Standard_False; - - // Z - return GetVoxelZ(z, iz); -} - -Standard_Boolean Voxel_DS::GetVoxelX(const Standard_Real x, - Standard_Integer& ix) const -{ - // X - if (x < myX || x > myX + myXLen) - return Standard_False; - ix = findIndex(myX, myXLen / (Standard_Real) myNbX, 0, myNbX - 1, x); - return Standard_True; -} - -Standard_Boolean Voxel_DS::GetVoxelY(const Standard_Real y, - Standard_Integer& iy) const -{ - // Y - if (y < myY || y > myY + myYLen) - return Standard_False; - iy = findIndex(myY, myYLen / (Standard_Real) myNbY, 0, myNbY - 1, y); - return Standard_True; -} - -Standard_Boolean Voxel_DS::GetVoxelZ(const Standard_Real z, - Standard_Integer& iz) const -{ - // Z - if (z < myZ || z > myZ + myZLen) - return Standard_False; - iz = findIndex(myZ, myZLen / (Standard_Real) myNbZ, 0, myNbZ - 1, z); - return Standard_True; -} diff --git a/src/Voxel/Voxel_DS.hxx b/src/Voxel/Voxel_DS.hxx deleted file mode 100644 index a6969bd2b4..0000000000 --- a/src/Voxel/Voxel_DS.hxx +++ /dev/null @@ -1,134 +0,0 @@ -// Created on: 2008-05-07 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_DS_HeaderFile -#define _Voxel_DS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -class Voxel_Writer; -class Voxel_Reader; - - -//! A base class for all voxel data structures. -class Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_DS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_DS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - //! The methods below return initial data of the voxel model. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - Standard_EXPORT Standard_Real GetX() const; - - Standard_EXPORT Standard_Real GetY() const; - - Standard_EXPORT Standard_Real GetZ() const; - - Standard_EXPORT Standard_Real GetXLen() const; - - Standard_EXPORT Standard_Real GetYLen() const; - - Standard_EXPORT Standard_Real GetZLen() const; - - Standard_EXPORT Standard_Integer GetNbX() const; - - Standard_EXPORT Standard_Integer GetNbY() const; - - Standard_EXPORT Standard_Integer GetNbZ() const; - - //! Returns the center point of a voxel with co-ordinates (ix, iy, iz). - Standard_EXPORT void GetCenter (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const; - - //! Returns the origin point of a voxel with co-ordinates (ix, iy, iz). - Standard_EXPORT void GetOrigin (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, Standard_Real& x0, Standard_Real& y0, Standard_Real& z0) const; - - //! Finds a voxel corresponding to a 3D point. - //! Returns true if it is found. - Standard_EXPORT Standard_Boolean GetVoxel (const Standard_Real x, const Standard_Real y, const Standard_Real z, Standard_Integer& ix, Standard_Integer& iy, Standard_Integer& iz) const; - - //! Returns x-index of a voxel corresponding to x-coordinate. - Standard_EXPORT Standard_Boolean GetVoxelX (const Standard_Real x, Standard_Integer& ix) const; - - //! Returns y-index of a voxel corresponding to y-coordinate. - Standard_EXPORT Standard_Boolean GetVoxelY (const Standard_Real y, Standard_Integer& iy) const; - - //! Returns z-index of a voxel corresponding to z-coordinate. - Standard_EXPORT Standard_Boolean GetVoxelZ (const Standard_Real z, Standard_Integer& iz) const; - - -friend class Voxel_Writer; -friend class Voxel_Reader; - - -protected: - - - - Standard_Address myData; - Standard_Real myX; - Standard_Real myY; - Standard_Real myZ; - Standard_Real myXLen; - Standard_Real myYLen; - Standard_Real myZLen; - Standard_Integer myNbX; - Standard_Integer myNbY; - Standard_Integer myNbZ; - Standard_Integer myNbXY; - Standard_Real myDX; - Standard_Real myDY; - Standard_Real myDZ; - Standard_Real myHalfDX; - Standard_Real myHalfDY; - Standard_Real myHalfDZ; - - -private: - - - - - -}; - - - - - - - -#endif // _Voxel_DS_HeaderFile diff --git a/src/Voxel/Voxel_FastConverter.cxx b/src/Voxel/Voxel_FastConverter.cxx deleted file mode 100644 index 249b94bb20..0000000000 --- a/src/Voxel/Voxel_FastConverter.cxx +++ /dev/null @@ -1,1174 +0,0 @@ -// Created on: 2008-05-30 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Printing the progress in stdout. -//#define CONV_DUMP -Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape, - Voxel_ROctBoolDS& voxels, - const Standard_Real deflection, - const Standard_Integer nbx, - const Standard_Integer nby, - const Standard_Integer nbz, - const Standard_Integer nbthreads, - const Standard_Boolean useExistingTriangulation) -:myShape(shape),myVoxels(&voxels), - myDeflection(deflection), - myIsBool(2), - myNbX(nbx),myNbY(nby),myNbZ(nbz), - myNbThreads(nbthreads), - myNbTriangles(0), - myUseExistingTriangulation(useExistingTriangulation) -{ - Init(); -} - -Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape, - Voxel_BoolDS& voxels, - const Standard_Real deflection, - const Standard_Integer nbx, - const Standard_Integer nby, - const Standard_Integer nbz, - const Standard_Integer nbthreads, - const Standard_Boolean useExistingTriangulation) -:myShape(shape),myVoxels(&voxels), - myDeflection(deflection), - myIsBool(1), - myNbX(nbx),myNbY(nby),myNbZ(nbz), - myNbThreads(nbthreads), - myNbTriangles(0), - myUseExistingTriangulation(useExistingTriangulation) -{ - Init(); -} - -Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape, - Voxel_ColorDS& voxels, - const Standard_Real deflection, - const Standard_Integer nbx, - const Standard_Integer nby, - const Standard_Integer nbz, - const Standard_Integer nbthreads, - const Standard_Boolean useExistingTriangulation) -:myShape(shape),myVoxels(&voxels), - myDeflection(deflection), - myIsBool(0), - myNbX(nbx),myNbY(nby),myNbZ(nbz), - myNbThreads(nbthreads), - myNbTriangles(0), - myUseExistingTriangulation(useExistingTriangulation) -{ - Init(); -} - -void Voxel_FastConverter::Init() -{ - if (myShape.IsNull()) - return; - if (myNbThreads < 1) - return; - - // Check number of splits. - Voxel_DS* voxels = (Voxel_DS*) myVoxels; - if (voxels->GetNbX() != myNbX || voxels->GetNbY() != myNbY || voxels->GetNbZ() != myNbZ) - { - // Compute boundary box of the shape - Bnd_Box box; - BRepBndLib::Add(myShape, box); - - // Define the voxel model by means of the boundary box of shape - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - box.Get(xmin, ymin, zmin, xmax, ymax, zmax); - - // Initialize the voxels. - if (myIsBool == 2) - ((Voxel_ROctBoolDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ); - else if (myIsBool == 1) - ((Voxel_BoolDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ); - else if (myIsBool == 0) - ((Voxel_ColorDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ); - } - - // Check presence of triangulation. - TopLoc_Location L; - Standard_Boolean triangulate = Standard_False; - TopExp_Explorer expl(myShape, TopAbs_FACE); - if(myUseExistingTriangulation == Standard_False) - { - for (; expl.More(); expl.Next()) - { - const TopoDS_Face & F = TopoDS::Face(expl.Current()); - Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L); - if (T.IsNull() || (T->Deflection() > myDeflection)) - { - triangulate = Standard_True; - break; - } - } - } - - // Re-create the triangulation. - if (triangulate) - { - BRepMesh_IncrementalMesh(myShape, myDeflection); - } - - // Compute the number of triangles. - myNbTriangles = 0; - expl.Init(myShape, TopAbs_FACE); - for (; expl.More(); expl.Next()) - { - const TopoDS_Face & F = TopoDS::Face(expl.Current()); - Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L); - if (T.IsNull() == Standard_False) - myNbTriangles += T->NbTriangles(); - } -} - -// Destructor -void Voxel_FastConverter::Destroy() -{ - -} - -Standard_Boolean Voxel_FastConverter::Convert(Standard_Integer& progress, - const Standard_Integer ithread) -{ - if (ithread == 1) - progress = 0; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - - if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0) - return Standard_False; - - if(myNbTriangles == 0) - return Standard_False; - - // Half of diagonal of a voxel - Voxel_DS* ds = (Voxel_DS*) myVoxels; - Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(), - dy = ds->GetYLen() / (Standard_Real) ds->GetNbY(), - dz = ds->GetZLen() / (Standard_Real) ds->GetNbZ(); - Standard_Real hdiagonal = sqrt(dx * dx + dy * dy + dz * dz); - hdiagonal /= 2.0; - - // Compute the scope of triangles for current thread - Standard_Integer start_thread_triangle = 1, end_thread_triangle = myNbTriangles, ithread_triangle = 0; - if(myNbTriangles < myNbThreads) - { - if(ithread != 1) - return Standard_False; - //in case we're in thread one process all triangles - } - else - { - div_t division = div(myNbTriangles, myNbThreads); - start_thread_triangle = (ithread - 1) * division.quot + 1; - end_thread_triangle = (ithread - 0) * division.quot; - - if(ithread == myNbThreads) - end_thread_triangle += division.rem; - } - - // Convert - TopLoc_Location L; - Standard_Integer iprogress = 0; - Standard_Integer n1, n2, n3; - Standard_Integer ixmin, iymin, izmin, ixmax, iymax, izmax; - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - TopExp_Explorer expl(myShape, TopAbs_FACE); - for (; expl.More(); expl.Next()) - { - const TopoDS_Face & F = TopoDS::Face(expl.Current()); - Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L); - if (T.IsNull()) - continue; - - gp_Trsf trsf; - Standard_Boolean transform = !L.IsIdentity(); - if (transform) - trsf = L.Transformation(); - - const TColgp_Array1OfPnt& nodes = T->Nodes(); - const Poly_Array1OfTriangle& triangles = T->Triangles(); - Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper(); - for (; itriangle <= nb_triangles; itriangle++) - { - ithread_triangle++; - if (ithread_triangle < start_thread_triangle ) - continue; - if (ithread_triangle > end_thread_triangle) - { - if (ithread == 1) - progress = 100; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - return Standard_True; - } - - const Poly_Triangle& t = triangles.Value(itriangle); - t.Get(n1, n2, n3); - gp_Pnt p1 = nodes.Value(n1); - gp_Pnt p2 = nodes.Value(n2); - gp_Pnt p3 = nodes.Value(n3); - if (transform) - { - p1.Transform(trsf); - p2.Transform(trsf); - p3.Transform(trsf); - } - - // Get boundary box of the triangle - GetBndBox(p1, p2, p3, xmin, ymin, zmin, xmax, ymax, zmax); - - // Find the range of voxels inside the boudary box of the triangle. - if (!ds->GetVoxel(xmin, ymin, zmin, ixmin, iymin, izmin)) - continue; - if (!ds->GetVoxel(xmax, ymax, zmax, ixmax, iymax, izmax)) - continue; - - // Refuse voxels for whom distance from their center to plane of triangle is greater than half of diagonal. - // Make a line from center of each voxel to the center of triangle and - // compute intersection of the line with sides of triangle. - // Refuse the voxel in case of intersection. - gce_MakePln mkPlane(p1, p2, p3); - if (!mkPlane.IsDone()) - continue; - gp_Pln plane = mkPlane.Value(); - ComputeVoxelsNearTriangle(plane, p1, p2, p3, hdiagonal, ixmin, iymin, izmin, ixmax, iymax, izmax); - - // Progress - if (ithread == 1) - { - iprogress++; - progress = (Standard_Integer) ( (Standard_Real) iprogress / (Standard_Real) myNbTriangles * 100.0 ); - } -#ifdef CONV_DUMP - if (ithread == 1 && prev_progress != progress) - { - printf("Progress = %d \r", progress); - prev_progress = progress; - } -#endif - - } // iteration of triangles - } // iteration of faces - - if (ithread == 1) - progress = 100; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - return Standard_True; -} - -Standard_Boolean Voxel_FastConverter::ConvertUsingSAT(Standard_Integer& progress, - const Standard_Integer ithread) -{ - if (ithread == 1) - progress = 0; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - - if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0) - return Standard_False; - - if(myNbTriangles == 0) - return Standard_False; - - // Half of size of a voxel (also for Voxel_ROctBoolDS) - Voxel_DS* ds = (Voxel_DS*) myVoxels; - Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(), - dy = ds->GetYLen() / (Standard_Real) ds->GetNbY(), - dz = ds->GetZLen() / (Standard_Real) ds->GetNbZ(); - gp_Pnt extents(dx/2.0, dy/2.0, dz/2.0); - gp_Pnt extents2(dx/4.0, dy/4.0, dz/4.0); - gp_Pnt extents4(dx/8.0, dy/8.0, dz/8.0); - - // Compute the scope of triangles for current thread - Standard_Integer start_thread_triangle = 1, end_thread_triangle = myNbTriangles, ithread_triangle = 0; - if(myNbTriangles < myNbThreads) - { - if(ithread != 1) - return Standard_False; - //in case we're in thread one process all triangles - } - else - { - div_t division = div(myNbTriangles, myNbThreads); - start_thread_triangle = (ithread - 1) * division.quot + 1; - end_thread_triangle = (ithread - 0) * division.quot; - - if(ithread == myNbThreads) - end_thread_triangle += division.rem; - } - - // Convert - TopLoc_Location L; - Standard_Integer iprogress = 0; - Standard_Integer n1, n2, n3; - Standard_Integer ixmin, iymin, izmin, ixmax, iymax, izmax; - Standard_Real xmin, ymin, zmin, xmax, ymax, zmax; - TopExp_Explorer expl(myShape, TopAbs_FACE); - for (; expl.More(); expl.Next()) - { - const TopoDS_Face & F = TopoDS::Face(expl.Current()); - Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L); - if (T.IsNull()) - continue; - - gp_Trsf trsf; - Standard_Boolean transform = !L.IsIdentity(); - if (transform) - trsf = L.Transformation(); - - const TColgp_Array1OfPnt& nodes = T->Nodes(); - const Poly_Array1OfTriangle& triangles = T->Triangles(); - Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper(); - for (; itriangle <= nb_triangles; itriangle++) - { - ithread_triangle++; - if (ithread_triangle < start_thread_triangle ) - continue; - if (ithread_triangle > end_thread_triangle) - { - if (ithread == 1) - progress = 100; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - return Standard_True; - } - - const Poly_Triangle& t = triangles.Value(itriangle); - - t.Get(n1, n2, n3); - gp_Pnt p1 = nodes.Value(n1); - gp_Pnt p2 = nodes.Value(n2); - gp_Pnt p3 = nodes.Value(n3); - if (transform) - { - p1.Transform(trsf); - p2.Transform(trsf); - p3.Transform(trsf); - } - - // Get boundary box of the triangle - GetBndBox(p1, p2, p3, xmin, ymin, zmin, xmax, ymax, zmax); - - // Find the range of voxels inside the boudary box of the triangle. - if (!ds->GetVoxel(xmin, ymin, zmin, ixmin, iymin, izmin)) - continue; - if (!ds->GetVoxel(xmax, ymax, zmax, ixmax, iymax, izmax)) - continue; - - // Perform triangle-box intersection to find the voxels resulting from the processed triangle.; - // Using SAT theorem to quickly find the intersection. - ComputeVoxelsNearTriangle(p1, p2, p3, - extents, extents2, extents4, - ixmin, iymin, izmin, ixmax, iymax, izmax); - - // Progress - if (ithread == 1) - { - iprogress++; - progress = (Standard_Integer) ( (Standard_Real) iprogress / (Standard_Real) myNbTriangles * 100.0 ); - } -#ifdef CONV_DUMP - if (ithread == 1 && prev_progress != progress) - { - printf("Progress = %d \r", progress); - prev_progress = progress; - } -#endif - - } // iteration of triangles - } // iteration of faces - - if (ithread == 1) - progress = 100; -#ifdef CONV_DUMP - if (ithread == 1) - printf("Progress = %d \r", progress); -#endif - return Standard_True; -} - -Standard_Boolean Voxel_FastConverter::FillInVolume(const Standard_Byte inner, - const Standard_Integer /*ithread*/) -{ - Voxel_DS* ds = (Voxel_DS*) myVoxels; - Standard_Integer ix, iy, iz, nbx = ds->GetNbX(), nby = ds->GetNbY(), nbz = ds->GetNbZ(); - Standard_Boolean prev_surface, surface, volume; - - if (inner) - { - // Fill-in internal voxels by the value "inner" - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - // Check existence of volume. - volume = Standard_False; - surface = Standard_False; - prev_surface = Standard_False; - for (iz = 0; iz < nbz; iz++) - { - surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0; - if (prev_surface && !surface) - { - volume = !volume; - } - prev_surface = surface; - } - if (volume) - continue; - - // Fill-in the volume. - volume = Standard_False; - surface = Standard_False; - prev_surface = Standard_False; - for (iz = 0; iz < nbz; iz++) - { - surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0; - if (prev_surface && !surface) - { - volume = !volume; - } - if (volume && !surface) - { - (myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) : - ((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner); - } - prev_surface = surface; - } - } - } - } - else - { - // Set value of interbal voxels to 0 ("inner" = 0) - Standard_Boolean next_surface; - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - volume = Standard_False; - surface = Standard_False; - prev_surface = Standard_False; - next_surface = Standard_False; - for (iz = 0; iz < nbz; iz++) - { - surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0; - if (prev_surface != surface) - { - volume = !volume; - } - if (volume && iz + 1 < nbz) - { - next_surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz + 1) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz + 1) > 0; - } - if (volume && prev_surface == surface && next_surface) - { - (myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) : - ((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner); - } - prev_surface = surface; - } - } - } - } - - return Standard_True; -} - -Standard_Boolean Voxel_FastConverter::FillInVolume(const Standard_Byte inner, const TopoDS_Shape & shape, const Standard_Integer /*ithread*/) -{ - Voxel_DS* ds = (Voxel_DS*) myVoxels; - Standard_Integer ix, iy, iz, nbx = ds->GetNbX(), nby = ds->GetNbY(), nbz = ds->GetNbZ(); - Standard_Boolean prev_surface, surface, volume, isOnVerticalSurface; - - BRepClass3d_SolidClassifier solidClassifier(shape); - Standard_Real xc, yc, zc; - - if (inner) - { - // Fill-in internal voxels by the value "inner" - for (ix = 0; ix < nbx; ix++) - { - for (iy = 0; iy < nby; iy++) - { - // Check existence of volume. - volume = Standard_False; - surface = Standard_False; - prev_surface = Standard_False; - isOnVerticalSurface = Standard_False; - for (iz = 0; iz < nbz; iz++) - { - surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0; - if (prev_surface && !surface) - { - if(isOnVerticalSurface) - { - isOnVerticalSurface = Standard_False; - ((Voxel_BoolDS*)myVoxels)->GetCenter(ix, iy, iz, xc, yc, zc); - gp_Pnt P(xc, yc, zc); - solidClassifier.Perform(P, Precision::Confusion()); - - if(solidClassifier.State() == TopAbs_IN) - volume = Standard_True; - else - volume = Standard_False; - } - else - volume = !volume; - } - if(prev_surface && surface) - isOnVerticalSurface = Standard_True; - else - isOnVerticalSurface = Standard_False; - prev_surface = surface; - } - if (volume) - continue; - - // Fill-in the volume. - volume = Standard_False; - surface = Standard_False; - prev_surface = Standard_False; - isOnVerticalSurface = Standard_False; - for (iz = 0; iz < nbz; iz++) - { - surface = (myIsBool == 1) ? - ((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True : - ((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0; - if (prev_surface && !surface) - { - if(isOnVerticalSurface) - { - isOnVerticalSurface = Standard_False; - ((Voxel_BoolDS*)myVoxels)->GetCenter(ix, iy, iz, xc, yc, zc); - gp_Pnt P(xc, yc, zc); - solidClassifier.Perform(P, Precision::Confusion()); - - if(solidClassifier.State() == TopAbs_IN) - volume = Standard_True; - else - volume = Standard_False; - } - else - volume = !volume; - } - if (volume && !surface) - { - (myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) : - ((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner); - } - if(prev_surface && surface) - isOnVerticalSurface = Standard_True; - else - isOnVerticalSurface = Standard_False; - prev_surface = surface; - } - } - } - } - - return Standard_True; -} - -void Voxel_FastConverter::GetBndBox(const gp_Pnt& p1, - const gp_Pnt& p2, - const gp_Pnt& p3, - Standard_Real& xmin, - Standard_Real& ymin, - Standard_Real& zmin, - Standard_Real& xmax, - Standard_Real& ymax, - Standard_Real& zmax) const -{ - // P1: - xmin = p1.X(); - ymin = p1.Y(); - zmin = p1.Z(); - xmax = p1.X(); - ymax = p1.Y(); - zmax = p1.Z(); - // P2: - if (xmin > p2.X()) - xmin = p2.X(); - if (ymin > p2.Y()) - ymin = p2.Y(); - if (zmin > p2.Z()) - zmin = p2.Z(); - if (xmax < p2.X()) - xmax = p2.X(); - if (ymax < p2.Y()) - ymax = p2.Y(); - if (zmax < p2.Z()) - zmax = p2.Z(); - // P3: - if (xmin > p3.X()) - xmin = p3.X(); - if (ymin > p3.Y()) - ymin = p3.Y(); - if (zmin > p3.Z()) - zmin = p3.Z(); - if (xmax < p3.X()) - xmax = p3.X(); - if (ymax < p3.Y()) - ymax = p3.Y(); - if (zmax < p3.Z()) - zmax = p3.Z(); -} - -// This method is copied from Voxel_ShapeIntersector.cxx -static Standard_Boolean mayIntersect(const gp_Pnt2d& p11, const gp_Pnt2d& p12, - const gp_Pnt2d& p21, const gp_Pnt2d& p22) -{ - if (p11.X() > p21.X() && p11.X() > p22.X() && p12.X() > p21.X() && p12.X() > p22.X()) - return Standard_False; - if (p11.X() < p21.X() && p11.X() < p22.X() && p12.X() < p21.X() && p12.X() < p22.X()) - return Standard_False; - if (p11.Y() > p21.Y() && p11.Y() > p22.Y() && p12.Y() > p21.Y() && p12.Y() > p22.Y()) - return Standard_False; - if (p11.Y() < p21.Y() && p11.Y() < p22.Y() && p12.Y() < p21.Y() && p12.Y() < p22.Y()) - return Standard_False; - return Standard_True; -} - -void Voxel_FastConverter::ComputeVoxelsNearTriangle(const gp_Pln& plane, - const gp_Pnt& p1, - const gp_Pnt& p2, - const gp_Pnt& p3, - const Standard_Real hdiagonal, - const Standard_Integer ixmin, - const Standard_Integer iymin, - const Standard_Integer izmin, - const Standard_Integer ixmax, - const Standard_Integer iymax, - const Standard_Integer izmax) const -{ - gp_Pnt pc; - Standard_Real xc, yc, zc, uc, vc, u1, v1, u2, v2, u3, v3; - Standard_Integer ix, iy, iz; - IntAna2d_AnaIntersection intersector2d; - - // Project points of triangle onto the plane - ElSLib::Parameters(plane, p1, u1, v1); - ElSLib::Parameters(plane, p2, u2, v2); - ElSLib::Parameters(plane, p3, u3, v3); - - // Make lines of triangle - gp_Pnt2d p2d1(u1, v1), p2d2(u2, v2), p2d3(u3, v3), p2dt((u1+u2+u3)/3.0,(v1+v2+v3)/3.0), p2dc; - gp_Vec2d v2d12(p2d1, p2d2), v2d23(p2d2, p2d3), v2d31(p2d3, p2d1); - gp_Lin2d L1(p2d1, v2d12), L2(p2d2, v2d23), L3(p2d3, v2d31), Lv; - Standard_Real d1 = p2d1.Distance(p2d2) - Precision::Confusion(), - d2 = p2d2.Distance(p2d3) - Precision::Confusion(), - d3 = p2d3.Distance(p2d1) - Precision::Confusion(), dv; - - Voxel_DS* ds = (Voxel_DS*) myVoxels; - for (ix = ixmin; ix <= ixmax; ix++) - { - for (iy = iymin; iy <= iymax; iy++) - { - for (iz = izmin; iz <= izmax; iz++) - { - ds->GetCenter(ix, iy, iz, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - if (plane.Distance(pc) < hdiagonal) - { - ElSLib::Parameters(plane, pc, uc, vc); - p2dc.SetCoord(uc, vc); - - gp_Vec2d v2dct(p2dc, p2dt); - dv = v2dct.Magnitude() - Precision::Confusion(); - Lv.SetLocation(p2dc); - Lv.SetDirection(v2dct); - - // Side 1: - if (mayIntersect(p2d1, p2d2, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L1); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d1) - { - continue; - } - } - } - - // Side 2: - if (mayIntersect(p2d2, p2d3, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L2); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d2) - { - continue; - } - } - } - - // Side 3: - if (mayIntersect(p2d3, p2d1, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L3); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d3) - { - continue; - } - } - } - - // Set positive value to this voxel: - switch (myIsBool) - { - case 0: - ((Voxel_ColorDS*) myVoxels)->Set(ix, iy, iz, 15); - break; - case 1: - ((Voxel_BoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True); - break; - case 2: - { - //((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True); - - // Check intersection between the triangle & sub-voxels of the voxel. - Standard_Real hdiagonal2 = hdiagonal / 2.0, hdiagonal4 = hdiagonal / 4.0; - for (Standard_Integer i = 0; i < 8; i++) - { - ((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - if (plane.Distance(pc) < hdiagonal2) - { - ElSLib::Parameters(plane, pc, uc, vc); - p2dc.SetCoord(uc, vc); - - gp_Vec2d aVec2dct1(p2dc, p2dt); - dv = aVec2dct1.Magnitude() - Precision::Confusion(); - Lv.SetLocation(p2dc); - Lv.SetDirection(aVec2dct1); - - // Side 1: - if (mayIntersect(p2d1, p2d2, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L1); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d1) - { - continue; - } - } - } - - // Side 2: - if (mayIntersect(p2d2, p2d3, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L2); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d2) - { - continue; - } - } - } - - // Side 3: - if (mayIntersect(p2d3, p2d1, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L3); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d3) - { - continue; - } - } - } - - //((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, Standard_True); - - // Check intersection between the triangle & sub-voxels of the sub-voxel. - for (Standard_Integer j = 0; j < 8; j++) - { - ((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - if (plane.Distance(pc) < hdiagonal4) - { - ElSLib::Parameters(plane, pc, uc, vc); - p2dc.SetCoord(uc, vc); - - gp_Vec2d aVec2dct2(p2dc, p2dt); - dv = aVec2dct2.Magnitude() - Precision::Confusion(); - Lv.SetLocation(p2dc); - Lv.SetDirection(aVec2dct2); - - // Side 1: - if (mayIntersect(p2d1, p2d2, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L1); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d1) - { - continue; - } - } - } - - // Side 2: - if (mayIntersect(p2d2, p2d3, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L2); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d2) - { - continue; - } - } - } - - // Side 3: - if (mayIntersect(p2d3, p2d1, p2dc, p2dt)) - { - intersector2d.Perform(Lv, L3); - if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints()) - { - const IntAna2d_IntPoint& i2d = intersector2d.Point(1); - Standard_Real param1 = i2d.ParamOnFirst(); - Standard_Real param2 = i2d.ParamOnSecond(); - if (param1 > Precision::Confusion() && param1 < dv && - param2 > Precision::Confusion() && param2 < d3) - { - continue; - } - } - } - - ((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, j, Standard_True); - } - } // End of "Check level 2". - - } - } // End of "Check level 1". - - break; - } - } - } - } - } - } -} - -//! This macro quickly finds the min & max values among 3 variables -#define FINDMINMAX(x0, x1, x2, min, max) \ - min = max = x0; \ - if(x1max) max=x1; \ - if(x2max) max=x2; - -static bool planeBoxOverlap(const gp_Vec & normal, const double d, const gp_Pnt & maxbox) -{ - gp_Vec vmin, vmax; - if(normal.X() > 0.0) { vmin.SetX(-maxbox.X()); vmax.SetX(maxbox.X()); } - else { vmin.SetX(maxbox.X()); vmax.SetX(-maxbox.X()); } - - if(normal.Y() > 0.0) { vmin.SetY(-maxbox.Y()); vmax.SetY(maxbox.Y()); } - else { vmin.SetY(maxbox.Y()); vmax.SetY(-maxbox.Y()); } - - if(normal.Z() > 0.0) { vmin.SetZ(-maxbox.Z()); vmax.SetZ(maxbox.Z()); } - else { vmin.SetZ(maxbox.Z()); vmax.SetZ(-maxbox.Z()); } - - if((normal.Dot(vmin)) + d > 0.0) return false; - if((normal.Dot(vmax)) + d>= 0.0) return true; - - return false; -} - -#define AXISTEST_X01(a, b, fa, fb) \ - min = a*v0.Y() - b*v0.Z(); \ - max = a*v2.Y() - b*v2.Z(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.Y() + fb * extents.Z(); \ - if(min>rad || max<-rad) return false; - -#define AXISTEST_X2(a, b, fa, fb) \ - min = a*v0.Y() - b*v0.Z(); \ - max = a*v1.Y() - b*v1.Z(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.Y() + fb * extents.Z(); \ - if(min>rad || max<-rad) return false; - -#define AXISTEST_Y02(a, b, fa, fb) \ - min = b*v0.Z() - a*v0.X(); \ - max = b*v2.Z() - a*v2.X(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.X() + fb * extents.Z(); \ - if(min>rad || max<-rad) return false; - -#define AXISTEST_Y1(a, b, fa, fb) \ - min = b*v0.Z() - a*v0.X(); \ - max = b*v1.Z() - a*v1.X(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.X() + fb * extents.Z(); \ - if(min>rad || max<-rad) return false; - -#define AXISTEST_Z12(a, b, fa, fb) \ - min = a*v1.X() - b*v1.Y(); \ - max = a*v2.X() - b*v2.Y(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.X() + fb * extents.Y(); \ - if(min>rad || max<-rad) return false; - -#define AXISTEST_Z0(a, b, fa, fb) \ - min = a*v0.X() - b*v0.Y(); \ - max = a*v1.X() - b*v1.Y(); \ - if(min>max) {const double tmp=max; max=min; min=tmp; } \ - rad = fa * extents.X() + fb * extents.Y(); \ - if(min>rad || max<-rad) return false; - -// compute triangle edges -// - edges lazy evaluated to take advantage of early exits -// - fabs precomputed (half less work, possible since extents are always >0) -// - customized macros to take advantage of the null component -// - axis vector discarded, possibly saves useless movs -#define IMPLEMENT_CLASS3_TESTS \ - double rad; \ - double min, max; \ - \ - const double fey0 = fabs(e0.Y()); \ - const double fez0 = fabs(e0.Z()); \ - AXISTEST_X01(e0.Z(), e0.Y(), fez0, fey0); \ - const double fex0 = fabs(e0.X()); \ - AXISTEST_Y02(e0.Z(), e0.X(), fez0, fex0); \ - AXISTEST_Z12(e0.Y(), e0.X(), fey0, fex0); \ - \ - const double fey1 = fabs(e1.Y()); \ - const double fez1 = fabs(e1.Z()); \ - AXISTEST_X01(e1.Z(), e1.Y(), fez1, fey1); \ - const double fex1 = fabs(e1.X()); \ - AXISTEST_Y02(e1.Z(), e1.X(), fez1, fex1); \ - AXISTEST_Z0(e1.Y(), e1.X(), fey1, fex1); \ - \ - const gp_Vec e2 = v2 - v0; \ - const double fey2 = fabs(e2.Y()); \ - const double fez2 = fabs(e2.Z()); \ - AXISTEST_X2(e2.Z(), e2.Y(), fez2, fey2); \ - const double fex2 = fabs(e2.X()); \ - AXISTEST_Y1(e2.Z(), e2.X(), fez2, fex2); \ - AXISTEST_Z12(e2.Y(), e2.X(), fey2, fex2); - -static bool TriBoxOverlap(const gp_Pnt & p1, const gp_Pnt & p2, const gp_Pnt & p3, - const gp_Pnt & center, const gp_Pnt & extents) -{ - // use separating axis theorem to test overlap between triangle and box - // need to test for overlap in these directions: - // 1) the {x,y,z}-directions (actually, since we use the AABB of the triangle - // we do not even need to test these) - // 2) normal of the triangle - // 3) crossproduct(edge from tri, {x,y,z}-directin) - // this gives 3x3=9 more tests - - // move everything so that the boxcenter is in (0,0,0) - gp_Vec v0(center, p1); - gp_Vec v1(center, p2); - gp_Vec v2(center, p3); - - // First, test overlap in the {x,y,z}-directions - double aMin,aMax; - // Find min, max of the triangle in x-direction, and test for overlap in X - FINDMINMAX(v0.X(), v1.X(), v2.X(), aMin, aMax); - if(aMin>extents.X() || aMax<-extents.X()) return false; - - // Same for Y - FINDMINMAX(v0.Y(), v1.Y(), v2.Y(), aMin, aMax); - if(aMin>extents.Y() || aMax<-extents.Y()) return false; - - // Same for Z - FINDMINMAX(v0.Z(), v1.Z(), v2.Z(), aMin, aMax); - if(aMin>extents.Z() || aMax<-extents.Z()) return false; - - // 2) Test if the box intersects the plane of the triangle - // compute plane equation of triangle: normal*x+d=0 - // ### could be precomputed since we use the same leaf triangle several times - const gp_Vec e0 = v1 - v0; - const gp_Vec e1 = v2 - v1; - const gp_Vec normal = e0.Crossed(e1); - const double d = -normal.Dot(v0); - if(!planeBoxOverlap(normal, d, extents)) return false; - - // 3) "Class III" tests - //if(mFullPrimBoxTest) - { - IMPLEMENT_CLASS3_TESTS - } - - return true; -} - -void Voxel_FastConverter::ComputeVoxelsNearTriangle(const gp_Pnt& p1, - const gp_Pnt& p2, - const gp_Pnt& p3, - const gp_Pnt& extents, - const gp_Pnt& extents2, - const gp_Pnt& extents4, - const Standard_Integer ixmin, - const Standard_Integer iymin, - const Standard_Integer izmin, - const Standard_Integer ixmax, - const Standard_Integer iymax, - const Standard_Integer izmax) const -{ - gp_Pnt pc; - Standard_Real xc, yc, zc; - Standard_Integer ix, iy, iz; - - Voxel_DS* ds = (Voxel_DS*) myVoxels; - for (ix = ixmin; ix <= ixmax; ix++) - { - for (iy = iymin; iy <= iymax; iy++) - { - for (iz = izmin; iz <= izmax; iz++) - { - ds->GetCenter(ix, iy, iz, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - - if(TriBoxOverlap(p1, p2, p3, pc, extents)) - { - // Set positive value to this voxel: - switch (myIsBool) - { - case 0: - ((Voxel_ColorDS*) myVoxels)->Set(ix, iy, iz, 15); - break; - case 1: - ((Voxel_BoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True); - break; - case 2: - { - //((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True); - - // Check intersection between the triangle & sub-voxels of the voxel. - for (Standard_Integer i = 0; i < 8; i++) - { - ((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - if(TriBoxOverlap(p1, p2, p3, pc, extents2)) - { - //((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, Standard_True); - - // Check intersection between the triangle & sub-voxels of the sub-voxel. - for (Standard_Integer j = 0; j < 8; j++) - { - ((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, j, xc, yc, zc); - pc.SetCoord(xc, yc, zc); - if(TriBoxOverlap(p1, p2, p3, pc, extents4)) - { - ((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, j, Standard_True); - } - } // End of "Check level 2". - - } - } // End of "Check level 1". - break; - } - } - } - } - } - } -} diff --git a/src/Voxel/Voxel_FastConverter.hxx b/src/Voxel/Voxel_FastConverter.hxx deleted file mode 100644 index 9e6b533b2b..0000000000 --- a/src/Voxel/Voxel_FastConverter.hxx +++ /dev/null @@ -1,135 +0,0 @@ -// Created on: 2008-05-30 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_FastConverter_HeaderFile -#define _Voxel_FastConverter_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -class TopoDS_Shape; -class Voxel_BoolDS; -class Voxel_ColorDS; -class Voxel_ROctBoolDS; -class gp_Pnt; -class gp_Pln; - - -//! Converts a shape to voxel representation. -//! It does it fast, but with less precision. -//! Also, it doesn't fill-in volumic part of the shape. -class Voxel_FastConverter -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! A constructor for conversion of a shape into a cube of boolean voxels. - //! It allocates the voxels in memory. - //! "nbthreads" defines the number of threads used to convert the shape. - Standard_EXPORT Voxel_FastConverter(const TopoDS_Shape& shape, Voxel_BoolDS& voxels, const Standard_Real deflection = 0.1, const Standard_Integer nbx = 10, const Standard_Integer nby = 10, const Standard_Integer nbz = 10, const Standard_Integer nbthreads = 1, const Standard_Boolean useExistingTriangulation = Standard_False); - - //! A constructor for conversion of a shape into a cube of colored voxels. - //! It allocates the voxels in memory. - //! "nbthreads" defines the number of threads used to convert the shape. - Standard_EXPORT Voxel_FastConverter(const TopoDS_Shape& shape, Voxel_ColorDS& voxels, const Standard_Real deflection = 0.1, const Standard_Integer nbx = 10, const Standard_Integer nby = 10, const Standard_Integer nbz = 10, const Standard_Integer nbthreads = 1, const Standard_Boolean useExistingTriangulation = Standard_False); - - //! A constructor for conversion of a shape into a cube of boolean voxels - //! split into 8 sub-voxels recursively. - //! It allocates the voxels in memory. - //! "nbthreads" defines the number of threads used to convert the shape. - Standard_EXPORT Voxel_FastConverter(const TopoDS_Shape& shape, Voxel_ROctBoolDS& voxels, const Standard_Real deflection = 0.1, const Standard_Integer nbx = 10, const Standard_Integer nby = 10, const Standard_Integer nbz = 10, const Standard_Integer nbthreads = 1, const Standard_Boolean useExistingTriangulation = Standard_False); - - //! Converts a shape into a voxel representation. - //! It sets to 0 the outside volume of the shape and - //! 1 for surfacic part of the shape. - //! "ithread" is the index of the thread for current call of ::Convert(). - //! Start numeration of "ithread" with 1, please. - Standard_EXPORT Standard_Boolean Convert (Standard_Integer& progress, const Standard_Integer ithread = 1); - - //! Converts a shape into a voxel representation using separating axis theorem. - //! It sets to 0 the outside volume of the shape and - //! 1 for surfacic part of the shape. - //! "ithread" is the index of the thread for current call of ::Convert(). - //! Start numeration of "ithread" with 1, please. - Standard_EXPORT Standard_Boolean ConvertUsingSAT (Standard_Integer& progress, const Standard_Integer ithread = 1); - - //! Fills-in volume of the shape by a value. - Standard_EXPORT Standard_Boolean FillInVolume (const Standard_Byte inner, const Standard_Integer ithread = 1); - - //! Fills-in volume of the shape by a value. - //! Uses the topological information from the provided shape - //! to judge whether points are inside the shape or not - //! (only when processing vertical faces). - //! The inner value has to be positive. - Standard_EXPORT Standard_Boolean FillInVolume (const Standard_Byte inner, const TopoDS_Shape& shape, const Standard_Integer ithread = 1); - - //! A destructor. - Standard_EXPORT void Destroy(); -~Voxel_FastConverter() -{ - Destroy(); -} - - - - -protected: - - - - - -private: - - - Standard_EXPORT void Init(); - - Standard_EXPORT void GetBndBox (const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, Standard_Real& xmin, Standard_Real& ymin, Standard_Real& zmin, Standard_Real& xmax, Standard_Real& ymax, Standard_Real& zmax) const; - - Standard_EXPORT void ComputeVoxelsNearTriangle (const gp_Pln& plane, const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const Standard_Real hdiag, const Standard_Integer ixmin, const Standard_Integer iymin, const Standard_Integer izmin, const Standard_Integer ixmax, const Standard_Integer iymax, const Standard_Integer izmax) const; - - Standard_EXPORT void ComputeVoxelsNearTriangle (const gp_Pnt& p1, const gp_Pnt& p2, const gp_Pnt& p3, const gp_Pnt& extents, const gp_Pnt& extents2, const gp_Pnt& extents4, const Standard_Integer ixmin, const Standard_Integer iymin, const Standard_Integer izmin, const Standard_Integer ixmax, const Standard_Integer iymax, const Standard_Integer izmax) const; - - - TopoDS_Shape myShape; - Standard_Address myVoxels; - Standard_Real myDeflection; - Standard_Integer myIsBool; - Standard_Integer myNbX; - Standard_Integer myNbY; - Standard_Integer myNbZ; - Standard_Integer myNbThreads; - Standard_Integer myNbTriangles; - Standard_Boolean myUseExistingTriangulation; - - -}; - - - - - - - -#endif // _Voxel_FastConverter_HeaderFile diff --git a/src/Voxel/Voxel_FloatDS.cxx b/src/Voxel/Voxel_FloatDS.cxx deleted file mode 100644 index 294f4fe0fc..0000000000 --- a/src/Voxel/Voxel_FloatDS.cxx +++ /dev/null @@ -1,116 +0,0 @@ -// Created on: 2008-05-15 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include - -#include -// Empty constructor -Voxel_FloatDS::Voxel_FloatDS():Voxel_DS() -{ - -} - -// Constructor with intialization. -Voxel_FloatDS::Voxel_FloatDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -:Voxel_DS() -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_FloatDS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Destroy(); - - Voxel_DS::Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - if (!myNbX || !myNbY || !myNbZ) - return; - - Standard_Integer nb_floats = myNbXY * myNbZ; - Standard_Integer nb_slices = RealToInt(ceil(nb_floats / 32.0)); // 32 values in 1 slice - myData = (Standard_Address) calloc(nb_slices, sizeof(Standard_ShortReal*)); -} - -// Destructor -void Voxel_FloatDS::Destroy() -{ - if (myData) - { - SetZero(); - free((Standard_ShortReal**)myData); - myData = 0; - } -} - -void Voxel_FloatDS::SetZero() -{ - if (myData) - { - Standard_Integer nb_bytes = myNbXY * myNbZ; - Standard_Integer ix = 0, nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - for (; ix < nb_slices; ix++) - { - if (((Standard_ShortReal**)myData)[ix]) - { - free(((Standard_ShortReal**)myData)[ix]); - ((Standard_ShortReal**)myData)[ix] = 0; - } - } - } -} - -// Access to the floating-point information attached to a particular voxel: -// Info: (ix >= 0 && ix < theNb_x), etc. -void Voxel_FloatDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_ShortReal data) -{ - Standard_Integer ifloat = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ifloat >> 5; - - // Allocate the slice if it is not done yet. - if (!((Standard_ShortReal**)myData)[islice]) - { - ((Standard_ShortReal**)myData)[islice] = - (Standard_ShortReal*) calloc(32/*number of floating values in slice*/, sizeof(Standard_ShortReal)); - } - - // Index of start-byte of the value within the slice. - Standard_Integer ivalue = ifloat - (islice << 5); - - // Value (float) - ((Standard_ShortReal*)((Standard_ShortReal**)myData)[islice])[ivalue] = data; -} - -Standard_ShortReal Voxel_FloatDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ifloat = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ifloat >> 5; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Standard_ShortReal**)myData)[islice]) - return 0.0f; - - // Index of start-byte of the value within the slice. - Standard_Integer ivalue = ifloat - (islice << 5); - - // Value (floating-point value) - return ((Standard_ShortReal*)((Standard_ShortReal**)myData)[islice])[ivalue]; -} diff --git a/src/Voxel/Voxel_FloatDS.hxx b/src/Voxel/Voxel_FloatDS.hxx deleted file mode 100644 index fb91733490..0000000000 --- a/src/Voxel/Voxel_FloatDS.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Created on: 2008-05-15 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_FloatDS_HeaderFile -#define _Voxel_FloatDS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include - - -//! A 3D voxel model keeping a foating-point -//! value for each voxel. -class Voxel_FloatDS : public Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_FloatDS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_FloatDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z) Standard_OVERRIDE; - - //! A destructor of the voxel model. - Standard_EXPORT void Destroy(); -~Voxel_FloatDS() -{ - Destroy(); -} - - //! The method sets all values equal to 0 (false) and - //! releases the memory. - Standard_EXPORT void SetZero(); - - //! Defines a value for voxel with co-ordinates (ix, iy, iz). - //! Initial state of the model is so that all voxels have value 0.0f, - //! and this data doesn't occupy memory. - //! Memory for data is allocating during setting non-zero values. - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_ShortReal data); - - //! Returns the value of voxel with co-ordinates (ix, iy, iz). - Standard_EXPORT Standard_ShortReal Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - - - -protected: - - - - - -private: - - - - - -}; - - - - - - - -#endif // _Voxel_FloatDS_HeaderFile diff --git a/src/Voxel/Voxel_OctBoolDS.cxx b/src/Voxel/Voxel_OctBoolDS.cxx deleted file mode 100644 index 14d1183d5f..0000000000 --- a/src/Voxel/Voxel_OctBoolDS.cxx +++ /dev/null @@ -1,303 +0,0 @@ -// Created on: 2008-08-27 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include - -#include -static Standard_Byte gbits[8] = {1, 2, 4, 8, 16, 32, 64, 128}; -static Standard_Byte gnbits[8] = {255-1, 255-2, 255-4, 255-8, 255-16, 255-32, 255-64, 255-128}; -static iXYZ xyz; - -// Empty constructor -Voxel_OctBoolDS::Voxel_OctBoolDS():Voxel_DS(),mySubVoxels(0) -{ - -} - -// Constructor with intialization. -Voxel_OctBoolDS::Voxel_OctBoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -:Voxel_DS(),mySubVoxels(0) -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_OctBoolDS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Destroy(); - - Voxel_DS::Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - if (!myNbX || !myNbY || !myNbZ) - return; - - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - myData = (Standard_Address) calloc(nb_slices, sizeof(Standard_Byte*)); -} - -// Destructor -void Voxel_OctBoolDS::Destroy() -{ - if (myData) - { - SetZero(); - free((Standard_Byte**)myData); - myData = 0; - if (mySubVoxels) - { - delete (iXYZBool*)mySubVoxels; - mySubVoxels = 0; - } - } -} - -void Voxel_OctBoolDS::SetZero() -{ - if (myData) - { - Standard_Integer nb_bytes = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - Standard_Integer ix = 0, nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - for (; ix < nb_slices; ix++) - { - if (((Standard_Byte**)myData)[ix]) - { - free(((Standard_Byte**)myData)[ix]); - ((Standard_Byte**)myData)[ix] = 0; - } - } - } - - if (mySubVoxels) - { - iXYZBool* map = (iXYZBool*) mySubVoxels; - map->Clear(); - } -} - -// Access to the boolean information attached to a particular voxel: -// Info: (ix >= 0 && ix < theNb_x), etc. -void Voxel_OctBoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Boolean data) -{ - // All 8 sub-voxels have the same value. - // No need anymore to keep them in memory. - if (IsSplit(ix, iy, iz)) - { - UnSplit(ix, iy, iz); - } - - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 6; - - if (!data && !((Standard_Byte**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Standard_Byte**)myData)[islice]) - { - ((Standard_Byte**)myData)[islice] = (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - - // Index within 8 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 6); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - // Set data - if (data != ((value & gbits[shift]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[shift]; - else - value &= gnbits[shift]; - ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte] = value; - } -} - -void Voxel_OctBoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct, const Standard_Boolean data) -{ - // If the voxel is not split yet, do it now. - if (!IsSplit(ix, iy, iz)) - { - Split(ix, iy, iz); - } - - // Voxel - xyz.ix = ix; - xyz.iy = iy; - xyz.iz = iz; - - // Take the value - Standard_Byte value = ((iXYZBool*)mySubVoxels)->Find(xyz); - - // Set data - if (data != ((value & gbits[ioct]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[ioct]; - else - value &= gnbits[ioct]; - ((iXYZBool*)mySubVoxels)->ChangeFind(xyz) = value; - } -} - -Standard_Boolean Voxel_OctBoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 6; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Standard_Byte**)myData)[islice]) - return Standard_False; - - // Index within 8 bytes of the slice. - Standard_Integer ibit_in_current_slice = ibit - (islice << 6); - Standard_Integer ibyte = ibit_in_current_slice >> 3; - - // Value (byte) - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)myData)[islice])[ibyte]; - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit_in_current_slice - (ibyte << 3); - - return ((value & gbits[shift]) ? Standard_True : Standard_False); -} - -Standard_Boolean Voxel_OctBoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct) const -{ - // If the voxel is not split, return the value of the voxel. - if (!IsSplit(ix, iy, iz)) - { - return Get(ix, iy, iz); - } - - // Voxel - xyz.ix = ix; - xyz.iy = iy; - xyz.iz = iz; - - // Take the value - const Standard_Byte value = ((iXYZBool*)mySubVoxels)->Find(xyz); - - // Return data - return (value & gbits[ioct]) ? Standard_True : Standard_False; -} - -Standard_Boolean Voxel_OctBoolDS::IsSplit(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - if (!mySubVoxels) - return Standard_False; - - // Voxel - xyz.ix = ix; - xyz.iy = iy; - xyz.iz = iz; - - return ((iXYZBool*)mySubVoxels)->IsBound(xyz); -} - -void Voxel_OctBoolDS::Split(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) -{ - // Voxel - xyz.ix = ix; - xyz.iy = iy; - xyz.iz = iz; - - if (mySubVoxels) - { - if (!((iXYZBool*)mySubVoxels)->IsBound(xyz)) - { - ((iXYZBool*)mySubVoxels)->Bind(xyz, 0); - } - } - else - { - mySubVoxels = (Standard_Address) new iXYZBool; - ((iXYZBool*)mySubVoxels)->Bind(xyz, 0); - } -} - -void Voxel_OctBoolDS::UnSplit(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) -{ - if (!mySubVoxels) - return; - - // Voxel - xyz.ix = ix; - xyz.iy = iy; - xyz.iz = iz; - - if (((iXYZBool*)mySubVoxels)->IsBound(xyz)) - { - ((iXYZBool*)mySubVoxels)->UnBind(xyz); - } -} - -void Voxel_OctBoolDS::OptimizeMemory() -{ - if (!mySubVoxels) - return; - - Standard_Byte value; - TColStd_ListOfInteger ixs, iys, izs, values; - iXYZBool::Iterator itr(*((iXYZBool*)mySubVoxels)); - for (; itr.More(); itr.Next()) - { - value = itr.Value(); - if (value == 0 || value == 255) - { - xyz = itr.Key(); - ixs.Append(xyz.ix); - iys.Append(xyz.iy); - izs.Append(xyz.iz); - values.Append((Standard_Integer)value); - } - } - - TColStd_ListIteratorOfListOfInteger itrix(ixs), itriy(iys), itriz(izs), itrvalues(values); - for (; itrix.More(); itrix.Next(), itriy.Next(), itriz.Next(), itrvalues.Next()) - { - const Standard_Integer ix = itrix.Value(); - const Standard_Integer iy = itriy.Value(); - const Standard_Integer iz = itriz.Value(); - const Standard_Integer aValue = itrvalues.Value(); - - Set(ix, iy, iz, (aValue ? Standard_True : Standard_False)); - UnSplit(ix, iy, iz); - } - - // If the map is empty, release it. - if (((iXYZBool*)mySubVoxels)->IsEmpty()) - { - delete (iXYZBool*)mySubVoxels; - mySubVoxels = 0; - } -} diff --git a/src/Voxel/Voxel_OctBoolDS.hxx b/src/Voxel/Voxel_OctBoolDS.hxx deleted file mode 100644 index fa36dc268a..0000000000 --- a/src/Voxel/Voxel_OctBoolDS.hxx +++ /dev/null @@ -1,123 +0,0 @@ -// Created on: 2008-08-26 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_OctBoolDS_HeaderFile -#define _Voxel_OctBoolDS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include -#include - - -//! A 3D voxel model keeping a boolean flag (1 or 0) -//! value for each voxel, and having an opportunity to split each voxel -//! into 8 sub-voxels. -class Voxel_OctBoolDS : public Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_OctBoolDS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_OctBoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z) Standard_OVERRIDE; - - //! A destructor of the voxel model. - Standard_EXPORT void Destroy(); -~Voxel_OctBoolDS() -{ - Destroy(); -} - - //! The method sets all values equal to 0 (false) and - //! releases the memory. - Standard_EXPORT void SetZero(); - - //! The method searches voxels with equal-value of sub-voxels - //! and removes them (remaining the value for the voxel). - Standard_EXPORT void OptimizeMemory(); - - //! Defines a value for voxel with co-ordinates (ix, iy, iz). - //! If the voxel is split into 8 sub-voxels, the split disappears. - //! Initial state of the model is so that all voxels have value 0 (false), - //! and this data doesn't occupy memory. - //! Memory for data is allocating during setting non-zero values (true). - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Boolean data); - - //! Defines a value for a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct, const Standard_Boolean data); - - //! Returns the value of voxel with co-ordinates (ix, iy, iz). - //! Warning!: the returned value may not coincide with the value of its 8 sub-voxels. - //! Use the method ::IsSplit() to check whether a voxel has sub-voxels. - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - //! Returns the value of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split, it returns the value of the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct) const; - - //! Returns true if the voxel is split into 8 sub-voxels. - Standard_EXPORT Standard_Boolean IsSplit (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - - - -protected: - - - - - -private: - - - Standard_EXPORT void Split (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz); - - Standard_EXPORT void UnSplit (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz); - - - Standard_Address mySubVoxels; - - -}; - - - - - - - -#endif // _Voxel_OctBoolDS_HeaderFile diff --git a/src/Voxel/Voxel_Prs.cxx b/src/Voxel/Voxel_Prs.cxx deleted file mode 100644 index 95623cb2c8..0000000000 --- a/src/Voxel/Voxel_Prs.cxx +++ /dev/null @@ -1,307 +0,0 @@ -// Created on: 2008-05-13 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Voxel_VisData.h" -Voxel_Prs::Voxel_Prs():AIS_InteractiveObject(PrsMgr_TOP_AllView),myVisData(0) -{ - -} - -void Voxel_Prs::SetBoolVoxels(const Standard_Address theVoxels) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myBoolVoxels = (Voxel_BoolDS*) theVoxels; -} - -void Voxel_Prs::SetColorVoxels(const Standard_Address theVoxels) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myColorVoxels = (Voxel_ColorDS*) theVoxels; -} - -void Voxel_Prs::SetROctBoolVoxels(const Standard_Address theVoxels) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myROctBoolVoxels = (Voxel_ROctBoolDS*) theVoxels; -} - -void Voxel_Prs::SetTriangulation(const Handle(Poly_Triangulation)& theTriangulation) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myTriangulation = theTriangulation; -} - -void Voxel_Prs::SetColor(const Quantity_Color& theColor) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myColor = theColor; -} - -void Voxel_Prs::SetPointSize(const Standard_Real theSize) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myPointSize = theSize; -} - -void Voxel_Prs::SetQuadrangleSize(const Standard_Integer theSize) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myQuadrangleSize = theSize; -} - -void Voxel_Prs::SetColors(const Handle(Quantity_HArray1OfColor)& theColors) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myColors = theColors; -} - -void Voxel_Prs::SetDisplayMode(const Voxel_VoxelDisplayMode theMode) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayMode = theMode; -} - -void Voxel_Prs::SetTransparency(const Standard_Real theTransparency) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myTransparency = theTransparency; -} - -static void setMaterial(const Handle(Graphic3d_Group)& G, - const Quantity_Color& C, - const Standard_Real T) -{ - Graphic3d_MaterialAspect material(Graphic3d_NOM_PLASTIC); - material.SetColor(C); - material.SetTransparency(T); - Handle(Graphic3d_AspectFillArea3d) aspect = - new Graphic3d_AspectFillArea3d(Aspect_IS_SOLID, C, C, Aspect_TOL_SOLID, 1, material, material); - aspect->SetDistinguishOff(); - aspect->SetEdgeOff(); - aspect->SetTextureMapOff(); - G->SetPrimitivesAspect(aspect); -} - -void Voxel_Prs::Compute(const Handle(PrsMgr_PresentationManager3d)& /*thePresentationManager*/, - const Handle(Prs3d_Presentation)& thePresentation, - const Standard_Integer /*theMode*/) -{ - thePresentation->Clear(); - if (!myVisData) - return; - - if (((Voxel_VisData*)myVisData)->myBoolVoxels) - { - // Reset GL lists. - // BoolDS - ((Voxel_VisData*)myVisData)->myDisplay.myBoolPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsFirst = 1; - } - - if (((Voxel_VisData*)myVisData)->myColorVoxels) - { - // Reset GL lists. - // ColorDS - ((Voxel_VisData*)myVisData)->myDisplay.myColorPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsFirst = 1; - } - - if (((Voxel_VisData*)myVisData)->myROctBoolVoxels) - { - // Reset GL lists. - // ROctBoolDS - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsFirst = 1; - } - - // Set data to the user draw function. - Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(thePresentation); - if (((Voxel_VisData*)myVisData)->myDisplay.myDisplayMode == Voxel_VDM_BOXES || - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayMode == Voxel_VDM_NEARESTBOXES || - !((Voxel_VisData*)myVisData)->myTriangulation.IsNull()) - { - setMaterial(G, ((Voxel_VisData*)myVisData)->myDisplay.myColor, - ((Voxel_VisData*)myVisData)->myDisplay.myTransparency); - - // Reset normals of triangulation - if (!((Voxel_VisData*)myVisData)->myTriangulation.IsNull()) - { - ((Voxel_VisData*)myVisData)->myNormalsOfNodes.Nullify(); - ((Voxel_VisData*)myVisData)->myDisplay.myTriangulationList = -1; - } - } - - ///Handle(OpenGl_Group) aGroup = Handle(OpenGl_Group)::DownCast (G); - ///aGroup->AddElement (myVisData); -} - -void Voxel_Prs::ComputeSelection(const Handle(SelectMgr_Selection)& /*theSelection*/, - const Standard_Integer /*theMode*/) -{ - -} - -// Destructor -void Voxel_Prs::Destroy() -{ - if (myVisData) - { - delete (Voxel_VisData*) myVisData; - myVisData = 0; - } -} - -void Voxel_Prs::Allocate() -{ - if (!myVisData) - { - myVisData = new Voxel_VisData; - - ((Voxel_VisData*)myVisData)->myBoolVoxels = 0; - ((Voxel_VisData*)myVisData)->myColorVoxels = 0; - ((Voxel_VisData*)myVisData)->myROctBoolVoxels = 0; - - // Points - - // BoolDS - ((Voxel_VisData*)myVisData)->myDisplay.myBoolPointsList = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[0] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[1] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[2] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[3] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[4] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[5] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsList[6] = -1; - - // ROctBoolDS - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolPointsList = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[0] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[1] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[2] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[3] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[4] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[5] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsList[6] = -1; - - // ColorDS: - ((Voxel_VisData*)myVisData)->myDisplay.myColorPointsList = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[0] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[1] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[2] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[3] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[4] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[5] = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsList[6] = -1; - - ((Voxel_VisData*)myVisData)->myDisplay.myColorMinValue = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorMaxValue = 15; - - ((Voxel_VisData*)myVisData)->myDisplay.myPointSize = 1.0; - ((Voxel_VisData*)myVisData)->myDisplay.myQuadrangleSize = 100; - ((Voxel_VisData*)myVisData)->myDisplay.myTransparency = 0.0; - ((Voxel_VisData*)myVisData)->myDisplay.myDegenerateMode = 0; - ((Voxel_VisData*)myVisData)->myDisplay.myUsageOfGLlists = 1; - ((Voxel_VisData*)myVisData)->myDisplay.mySmoothPoints = 0; - - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedXMin = -DBL_MAX; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedXMax = DBL_MAX; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedYMin = -DBL_MAX; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedYMax = DBL_MAX; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedZMin = -DBL_MAX; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedZMax = DBL_MAX; - - ((Voxel_VisData*)myVisData)->myDisplay.myTriangulationList = -1; - - ((Voxel_VisData*)myVisData)->myDisplay.myHighlightx = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myHighlighty = -1; - ((Voxel_VisData*)myVisData)->myDisplay.myHighlightz = -1; - } -} - -void Voxel_Prs::SetDegenerateMode(const Standard_Boolean theDegenerate) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myDegenerateMode = (theDegenerate == Standard_True); -} - -void Voxel_Prs::SetUsageOfGLlists(const Standard_Boolean theUsage) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.myUsageOfGLlists = (theUsage == Standard_True); -} - -void Voxel_Prs::SetSmoothPoints(const Standard_Boolean theSmooth) -{ - Allocate(); - ((Voxel_VisData*)myVisData)->myDisplay.mySmoothPoints = (theSmooth == Standard_True); -} - -void Voxel_Prs::SetColorRange(const Standard_Byte theMinValue, - const Standard_Byte theMaxValue) -{ - Allocate(); - - ((Voxel_VisData*)myVisData)->myDisplay.myColorMinValue = theMinValue; - ((Voxel_VisData*)myVisData)->myDisplay.myColorMaxValue = theMaxValue; - - // Reset GL lists - ((Voxel_VisData*)myVisData)->myDisplay.myColorPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsFirst = 1; -} - -void Voxel_Prs::SetSizeRange(const Standard_Real theDisplayedXMin, - const Standard_Real theDisplayedXMax, - const Standard_Real theDisplayedYMin, - const Standard_Real theDisplayedYMax, - const Standard_Real theDisplayedZMin, - const Standard_Real theDisplayedZMax) -{ - Allocate(); - - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedXMin = theDisplayedXMin; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedXMax = theDisplayedXMax; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedYMin = theDisplayedYMin; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedYMax = theDisplayedYMax; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedZMin = theDisplayedZMin; - ((Voxel_VisData*)myVisData)->myDisplay.myDisplayedZMax = theDisplayedZMax; - - // Reset GL lists - ((Voxel_VisData*)myVisData)->myDisplay.myBoolPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myBoolNearestPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myColorNearestPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolPointsFirst = 1; - ((Voxel_VisData*)myVisData)->myDisplay.myROctBoolNearestPointsFirst = 1; -} - -void Voxel_Prs::Highlight(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) -{ - Allocate(); - - ((Voxel_VisData*)myVisData)->myDisplay.myHighlightx = ix; - ((Voxel_VisData*)myVisData)->myDisplay.myHighlighty = iy; - ((Voxel_VisData*)myVisData)->myDisplay.myHighlightz = iz; -} diff --git a/src/Voxel/Voxel_Prs.hxx b/src/Voxel/Voxel_Prs.hxx deleted file mode 100644 index 05e225e8fc..0000000000 --- a/src/Voxel/Voxel_Prs.hxx +++ /dev/null @@ -1,149 +0,0 @@ -// Created on: 2008-05-06 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_Prs_HeaderFile -#define _Voxel_Prs_HeaderFile - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -class Poly_Triangulation; -class Quantity_Color; -class Prs3d_Presentation; - - -class Voxel_Prs; -DEFINE_STANDARD_HANDLE(Voxel_Prs, AIS_InteractiveObject) - -//! Interactive object for voxels. -class Voxel_Prs : public AIS_InteractiveObject -{ - -public: - - - //! An empty constructor. - Standard_EXPORT Voxel_Prs(); - - //! is a Voxel_BoolDS* object. - Standard_EXPORT void SetBoolVoxels (const Standard_Address theVoxels); - - //! is a Voxel_ColorDS* object. - Standard_EXPORT void SetColorVoxels (const Standard_Address theVoxels); - - //! is a Voxel_ROctBoolDS* object. - Standard_EXPORT void SetROctBoolVoxels (const Standard_Address theVoxels); - - //! Sets a triangulation for visualization. - Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& theTriangulation); - - //! Sets a display mode for voxels. - Standard_EXPORT void SetDisplayMode (const Voxel_VoxelDisplayMode theMode); - - //! Defines the color of points, quadrangles ... for BoolDS. - Standard_EXPORT virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE; - - //! Defines the color of points, quadrangles... for ColorDS. - //! For ColorDS the size of array is 0 .. 15. - //! 0 - means no color, this voxel is not drawn. - Standard_EXPORT void SetColors (const Handle(Quantity_HArray1OfColor)& theColors); - - //! Defines the size of points for all types of voxels. - Standard_EXPORT void SetPointSize (const Standard_Real theSize); - - //! Defines the size of quadrangles in per cents (0 .. 100). - Standard_EXPORT void SetQuadrangleSize (const Standard_Integer theSize); - - //! Defines the transparency value [0 .. 1] for quadrangular visualization. - Standard_EXPORT virtual void SetTransparency (const Standard_Real theTransparency) Standard_OVERRIDE; - - //! Highlights a voxel. - //! It doesn't re-computes the whole interactive object, - //! but only marks a voxels as "highlighted". - //! The voxel becomes highlighted on next swapping of buffers. - //! In order to unhighlight a voxel, set ix = iy = iz = -1. - Standard_EXPORT void Highlight (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz); - - //! A destructor of presentation data. - Standard_EXPORT void Destroy(); -~Voxel_Prs() -{ - Destroy(); -} - - //! Simplifies visualization of voxels in case of view rotation, panning and zooming. - Standard_EXPORT void SetDegenerateMode (const Standard_Boolean theDegenerate); - - //! GL lists accelerate view rotation, panning and zooming operations, but - //! it takes additional memory... - //! It is up to the user of this interactive object to decide whether - //! he has enough memory and may use GL lists or - //! he is lack of memory and usage of GL lists is not recommended. - //! By default, usage of GL lists is on. - //! Also, as I noticed, the view without GL lists looks more precisely. - Standard_EXPORT void SetUsageOfGLlists (const Standard_Boolean theUsage); - - //! Switches visualization of points from smooth to rough. - Standard_EXPORT void SetSmoothPoints (const Standard_Boolean theSmooth); - - //! Defines min-max values for visualization of voxels of ColorDS structure. - //! By default, min value = 1, max value = 15 (all non-zero values). - Standard_EXPORT void SetColorRange (const Standard_Byte theMinValue, const Standard_Byte theMaxValue); - - //! Defines the displayed area of voxels. - //! By default, the range is equal to the box of voxels (all voxels are displayed). - Standard_EXPORT void SetSizeRange (const Standard_Real theDisplayedXMin, const Standard_Real theDisplayedXMax, const Standard_Real theDisplayedYMin, const Standard_Real theDisplayedYMax, const Standard_Real theDisplayedZMin, const Standard_Real theDisplayedZMax); - - - - DEFINE_STANDARD_RTTI(Voxel_Prs,AIS_InteractiveObject) - -protected: - - - Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, const Handle(Prs3d_Presentation)& thePresentation, const Standard_Integer theMode = 0) Standard_OVERRIDE; - - - -protected: - - - Standard_EXPORT void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode); - - //! Allocates the data structure of visualization. - Standard_EXPORT void Allocate(); - - Standard_Address myVisData; - - -}; - - - - - - - -#endif // _Voxel_Prs_HeaderFile diff --git a/src/Voxel/Voxel_ROctBoolDS.cxx b/src/Voxel/Voxel_ROctBoolDS.cxx deleted file mode 100644 index 11b7c966a2..0000000000 --- a/src/Voxel/Voxel_ROctBoolDS.cxx +++ /dev/null @@ -1,727 +0,0 @@ -// Created on: 2008-09-01 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include - -#include -static Standard_Byte gbits[8] = {1, 2, 4, 8, 16, 32, 64, 128}; -static Standard_Byte gnbits[8] = {255-1, 255-2, 255-4, 255-8, 255-16, 255-32, 255-64, 255-128}; - -/* Data structure of the ROctBoolDS - -SplitData: 1 byte (8 values) - (a) SplitData: 8 bytes (64 values) - (b) SplitData: 64 bytes (512 values) - (c) SplitData: ... - (d) SplitData: ... -*/ - -// Empty constructor -Voxel_ROctBoolDS::Voxel_ROctBoolDS():Voxel_DS() -{ - -} - -// Constructor with intialization. -Voxel_ROctBoolDS::Voxel_ROctBoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -:Voxel_DS() -{ - Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); -} - -// Initialization. -void Voxel_ROctBoolDS::Init(const Standard_Real x, const Standard_Real y, const Standard_Real z, - const Standard_Real xlen, const Standard_Real ylen, const Standard_Real zlen, - const Standard_Integer nbx, const Standard_Integer nby, const Standard_Integer nbz) -{ - Destroy(); - - Voxel_DS::Init(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - if (!myNbX || !myNbY || !myNbZ) - return; - - Standard_Integer nb_slices = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - myData = (Standard_Address) calloc(nb_slices, sizeof(Voxel_SplitData*)); -} - -// Destructor -void Voxel_ROctBoolDS::Destroy() -{ - if (myData) - { - SetZero(); - free((Voxel_SplitData**)myData); - myData = 0; - } -} - -// A recursive method of deletion of data. -static void SetZeroSplitData(Voxel_SplitData* data) -{ - // Values: - free((Standard_Byte*) data->GetValues()); - data->GetValues() = 0; - if (data->GetSplitData()) - { - SetZeroSplitData((Voxel_SplitData*) data->GetSplitData()); - } - delete data; -} - -void Voxel_ROctBoolDS::SetZero() -{ - if (myData) - { - Standard_Integer ix = 0, nb_slices = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - for (; ix < nb_slices; ix++) - { - if (((Voxel_SplitData**)myData)[ix]) - { - SetZeroSplitData((Voxel_SplitData*)((Voxel_SplitData**)myData)[ix]); - ((Voxel_SplitData**)myData)[ix] = 0; - } - } - } -} - -// Access to the boolean information attached to a particular voxel: -// Info: (ix >= 0 && ix < theNb_x), etc. -void Voxel_ROctBoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Boolean data) -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - if (!data && !((Voxel_SplitData**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Voxel_SplitData**)myData)[islice]) - { - ((Voxel_SplitData**)myData)[islice] = (Voxel_SplitData*) new Voxel_SplitData; - // Values: - ((Voxel_SplitData**)myData)[islice]->GetValues() = - (Standard_Byte*) calloc(1/*one byte: 8 1-bit values*/, sizeof(Standard_Byte)); - // Sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = 0; - } - - // Value - Standard_Byte value = *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()); - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit - (islice << 3); - - // Set data - if (data != ((value & gbits[shift]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[shift]; - else - value &= gnbits[shift]; - *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()) = value; - } - - // Set the same value to sub-voxels. - if (((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - { - // Get sub-value - Standard_Byte subvalue = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift]; - - // Set sub-value - if (subvalue != (data ? 255 : 0)) - { - subvalue = data ? 255 : 0; - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift] = subvalue; - } - - // Set the same value to sub-sub-voxels. - if (((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - { - // Start index of 64-bit value (index of byte of sub-sub-voxel). - Standard_Integer ibyte2 = (shift << 3); - for (Standard_Integer ioct2 = 0; ioct2 < 8; ioct2++) - { - // Get sub-sub-value - Standard_Byte subsubvalue = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2 + ioct2]; - - // Set sub-sub-value - if (subsubvalue != (data ? 255 : 0)) - { - subsubvalue = data ? 255 : 0; - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2 + ioct2] = subsubvalue; - } - } - } - } -} - -void Voxel_ROctBoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct1, const Standard_Boolean data) -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - if (!data && !((Voxel_SplitData**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Voxel_SplitData**)myData)[islice]) - { - ((Voxel_SplitData**)myData)[islice] = (Voxel_SplitData*) new Voxel_SplitData; - // Values: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues() = - (Standard_Byte*) calloc(1/*one byte: 8 1-bit values*/, sizeof(Standard_Byte)); - // Sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = 0; - } - - // Check sub-voxels of the first level - if (!((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - { - // Sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = (Voxel_SplitData*) new Voxel_SplitData; - // Value of sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues() = - (Standard_Byte*) calloc(8/*eight bytes: 8 sub-voxels for each voxel*/, sizeof(Standard_Byte)); - - // Set parent value - Standard_Byte parent_value = *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()); - if (parent_value) - { - for (Standard_Integer shift = 0; shift < 8; shift++) - { - if ((parent_value & gbits[shift]) ? Standard_True : Standard_False) - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift] = 255; - } - else - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift] = 0; - } - } - } - - // Sub-sub-voxels - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData() = 0; - } - - // Index of sub-voxel corresponding to ioct1: 8 voxels correspond to 64 sub-voxels. - Standard_Integer ibyte = ibit - (islice << 3); - - // Value - Standard_Byte value = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte]; - - // Set data - if (data != ((value & gbits[ioct1]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[ioct1]; - else - value &= gnbits[ioct1]; - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte] = value; - } - - // Set the same value to sub-voxels. - if (((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - { - // Start index of 64-bit value (index of byte of sub-sub-voxel). - Standard_Integer ibyte2 = (ibyte << 3) + ioct1; - - // Get sub-sub-value - Standard_Byte subsubvalue = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2]; - - // Set sub-sub-value - if (subsubvalue != (data ? 255 : 0)) - { - subsubvalue = data ? 255 : 0; - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2] = subsubvalue; - } - } -} - -void Voxel_ROctBoolDS::Set(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct1, const Standard_Integer ioct2, const Standard_Boolean data) -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - if (!data && !((Voxel_SplitData**)myData)[islice]) - return; // don't allocate a slice of data for setting a 0 value - - // Allocate the slice if it is not done yet. - if (!((Voxel_SplitData**)myData)[islice]) - { - ((Voxel_SplitData**)myData)[islice] = (Voxel_SplitData*) new Voxel_SplitData; - // Values: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues() = - (Standard_Byte*) calloc(1/*one byte: 8 1-bit values*/, sizeof(Standard_Byte)); - // Sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = 0; - } - - // Check sub-voxels of the first level - if (!((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - { - // Sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = (Voxel_SplitData*) new Voxel_SplitData; - // Value of sub-voxels: - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues() = - (Standard_Byte*) calloc(8/*eight bytes: 8 sub-voxels for each voxel*/, sizeof(Standard_Byte)); - - // Set parent value - Standard_Byte parent_value = *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()); - if (parent_value) - { - for (Standard_Integer shift = 0; shift < 8; shift++) - { - if ((parent_value & gbits[shift]) ? Standard_True : Standard_False) - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift] = 255; - } - else - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[shift] = 0; - } - } - } - - // Sub-sub-voxels - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData() = 0; - } - - // Check sub-voxels of the second level - if (!((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - { - // Sub-voxels 2: - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData() = - (Voxel_SplitData*) new Voxel_SplitData; - // Value of sub-voxels 2: - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues() = - (Standard_Byte*) calloc(64/*sixty four bytes: 8 sub-voxels for each sub-voxel for each voxel*/, - sizeof(Standard_Byte)); - - // Set parent value - for (Standard_Integer ibyte1 = 0; ibyte1 < 8; ibyte1++) - { - Standard_Byte parent_value = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte1]; - if (parent_value) - { - Standard_Integer ibyte2 = (ibyte1 << 3); - for (Standard_Integer shift = 0; shift < 8; shift++) - { - if ((parent_value & gbits[shift]) ? Standard_True : Standard_False) - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2 + shift] = 255; - } - else - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2 + shift] = 0; - } - } - } - } - - // Sub-sub-sub-voxels - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetSplitData() = 0; - } - - // Index of sub-voxel corresponding to ioct1: 8 voxels correspond to 64 sub-voxels. - Standard_Integer ibyte1 = ibit - (islice << 3); // imdex of byte of 8-byte value (sub-voxel 1). - Standard_Integer ibyte2 = (ibyte1 << 3) + ioct1; // index of byte of 64-byte value (sub-voxel 2) - - // Value - Standard_Byte value = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2]; - - // Set data - if (data != ((value & gbits[ioct2]) ? Standard_True : Standard_False)) - { - if (data) - value |= gbits[ioct2]; - else - value &= gnbits[ioct2]; - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2] = value; - } -} - -Standard_Boolean Voxel_ROctBoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Voxel_SplitData**)myData)[islice]) - return Standard_False; - - // Value (byte) - Standard_Byte value = *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()); - - // Position of data in the 8 bit-"value". - Standard_Integer shift = ibit - (islice << 3); - return ((value & gbits[shift]) ? Standard_True : Standard_False); -} - -Standard_Boolean Voxel_ROctBoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct1) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Voxel_SplitData**)myData)[islice]) - return Standard_False; - - // If the voxel is not split, return the value of the voxel. - if (!((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - return Get(ix, iy, iz); - - // Index of sub-voxel corresponding to ioct1: 8 voxels correspond to 64 sub-voxels. - Standard_Integer ibyte = ibit - (islice << 3); - - // Value - Standard_Byte value = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte]; - - return ((value & gbits[ioct1]) ? Standard_True : Standard_False); -} - -Standard_Boolean Voxel_ROctBoolDS::Get(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer ioct1, const Standard_Integer ioct2) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - // If the slice of data is not allocated, it means that its values are 0. - if (!((Voxel_SplitData**)myData)[islice]) - return Standard_False; - - // If the voxel is not split, return the value of the voxel. - if (!((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - return Get(ix, iy, iz); - - // If the split voxel (sub-voxel 1) is not split, return the value of the sub-voxel 1. - if (!((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - return Get(ix, iy, iz, ioct1); - - // Index of sub-voxel corresponding to ioct1: 8 voxels correspond to 64 sub-voxels. - Standard_Integer ibyte1 = ibit - (islice << 3); // index of byte of 8-byte value (sub-voxel 1). - Standard_Integer ibyte2 = (ibyte1 << 3) + ioct1; // index of byte of 64-byte value (sub-voxel 2) - - // Value - Standard_Byte value = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2]; - - return ((value & gbits[ioct2]) ? Standard_True : Standard_False); -} - -Standard_Boolean Voxel_ROctBoolDS::IsSplit(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - // If the voxel has no value, it is not split. - if (!((Voxel_SplitData**)myData)[islice]) - return Standard_False; - - // Check existence of sub-voxels - if (((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - return Standard_True; - return Standard_False; -} - -Standard_Integer Voxel_ROctBoolDS::Deepness(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const -{ - Standard_Integer ibit = ix + myNbX * iy + myNbXY * iz; - Standard_Integer islice = ibit >> 3; - - // If the voxel has no value, it is not split. - if (!((Voxel_SplitData**)myData)[islice]) - return 0; - - // Test deepness. - if (((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - { - if (((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - { - return 2; - } - else - { - return 1; - } - } - return 0; -} - -void Voxel_ROctBoolDS::OptimizeMemory() -{ - // Iterate the array of voxels checking coincidence of values of sub-voxels. - Standard_Integer islice = 0, nb_slices = RealToInt(ceil(myNbXY * myNbZ / 8.0)); - for (; islice < nb_slices; islice++) - { - if (!((Voxel_SplitData**)myData)[islice]) - continue; - if (((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()) - { - Standard_Boolean suppress = Standard_False; - // Second level of sub-voxels - if (((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()) - { - suppress = Standard_False; - Standard_Byte value1 = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[0]; - if (value1 == 0 || value1 == 255) - { - suppress = Standard_True; - for (Standard_Integer ibyte2 = 1; ibyte2 < 64; ibyte2++) - { - Standard_Byte value2 = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData())->GetValues())[ibyte2]; - if (value2 != value1) - { - suppress = Standard_False; - break; - } - } - } - if (suppress) - { - SetZeroSplitData((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData()); - ((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetSplitData() = 0; - // Set value to upper level - for (Standard_Integer ibyte1 = 0; ibyte1 < 8; ibyte1++) - { - ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte1] = value1; - } - } - else - { - // If we don't suppress sub-sub-voxels, we don't touch sub-voxels. - continue; - } - } - // First level of sub-voxels - suppress = Standard_False; - Standard_Byte value1 = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[0]; - if (value1 == 0 || value1 == 255) - { - suppress = Standard_True; - for (Standard_Integer ibyte1 = 1; ibyte1 < 8; ibyte1++) - { - Standard_Byte value2 = ((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData())->GetValues())[ibyte1]; - if (value2 != value1) - { - suppress = Standard_False; - break; - } - } - } - if (suppress) - { - SetZeroSplitData((Voxel_SplitData*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData()); - ((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetSplitData() = 0; - // Set value to upper level - *((Standard_Byte*)((Voxel_SplitData*)((Voxel_SplitData**)myData)[islice])->GetValues()) = value1; - } - } - } -} - -void Voxel_ROctBoolDS::GetCenter(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer i, - Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const -{ - xc = myX + ix * myDX; - yc = myY + iy * myDY; - zc = myZ + iz * myDZ; - - switch (i) - { - case 0: - { - xc += 0.5 * myHalfDX; - yc += 0.5 * myHalfDY; - zc += 0.5 * myHalfDZ; - break; - } - case 1: - { - xc += 1.5 * myHalfDX; - yc += 0.5 * myHalfDY; - zc += 0.5 * myHalfDZ; - break; - } - case 2: - { - xc += 0.5 * myHalfDX; - yc += 1.5 * myHalfDY; - zc += 0.5 * myHalfDZ; - break; - } - case 3: - { - xc += 1.5 * myHalfDX; - yc += 1.5 * myHalfDY; - zc += 0.5 * myHalfDZ; - break; - } - case 4: - { - xc += 0.5 * myHalfDX; - yc += 0.5 * myHalfDY; - zc += 1.5 * myHalfDZ; - break; - } - case 5: - { - xc += 1.5 * myHalfDX; - yc += 0.5 * myHalfDY; - zc += 1.5 * myHalfDZ; - break; - } - case 6: - { - xc += 0.5 * myHalfDX; - yc += 1.5 * myHalfDY; - zc += 1.5 * myHalfDZ; - break; - } - case 7: - { - xc += 1.5 * myHalfDX; - yc += 1.5 * myHalfDY; - zc += 1.5 * myHalfDZ; - break; - } - } -} - -void Voxel_ROctBoolDS::GetCenter(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer i, const Standard_Integer j, - Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const -{ - xc = myX + ix * myDX; - yc = myY + iy * myDY; - zc = myZ + iz * myDZ; - - switch (i) - { - case 0: - { - break; - } - case 1: - { - xc += myHalfDX; - break; - } - case 2: - { - yc += myHalfDY; - break; - } - case 3: - { - xc += myHalfDX; - yc += myHalfDY; - break; - } - case 4: - { - zc += myHalfDZ; - break; - } - case 5: - { - xc += myHalfDX; - zc += myHalfDZ; - break; - } - case 6: - { - yc += myHalfDY; - zc += myHalfDZ; - break; - } - case 7: - { - xc += myHalfDX; - yc += myHalfDY; - zc += myHalfDZ; - break; - } - } - - switch (j) - { - case 0: - { - xc += 0.25 * myHalfDX; - yc += 0.25 * myHalfDY; - zc += 0.25 * myHalfDZ; - break; - } - case 1: - { - xc += 0.75 * myHalfDX; - yc += 0.25 * myHalfDY; - zc += 0.25 * myHalfDZ; - break; - } - case 2: - { - xc += 0.25 * myHalfDX; - yc += 0.75 * myHalfDY; - zc += 0.25 * myHalfDZ; - break; - } - case 3: - { - xc += 0.75 * myHalfDX; - yc += 0.75 * myHalfDY; - zc += 0.25 * myHalfDZ; - break; - } - case 4: - { - xc += 0.25 * myHalfDX; - yc += 0.25 * myHalfDY; - zc += 0.75 * myHalfDZ; - break; - } - case 5: - { - xc += 0.75 * myHalfDX; - yc += 0.25 * myHalfDY; - zc += 0.75 * myHalfDZ; - break; - } - case 6: - { - xc += 0.25 * myHalfDX; - yc += 0.75 * myHalfDY; - zc += 0.75 * myHalfDZ; - break; - } - case 7: - { - xc += 0.75 * myHalfDX; - yc += 0.75 * myHalfDY; - zc += 0.75 * myHalfDZ; - break; - } - } -} diff --git a/src/Voxel/Voxel_ROctBoolDS.hxx b/src/Voxel/Voxel_ROctBoolDS.hxx deleted file mode 100644 index 10bf8f9958..0000000000 --- a/src/Voxel/Voxel_ROctBoolDS.hxx +++ /dev/null @@ -1,141 +0,0 @@ -// Created on: 2008-09-01 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_ROctBoolDS_HeaderFile -#define _Voxel_ROctBoolDS_HeaderFile - -#include -#include -#include - -#include -#include -#include -#include - - -//! A 3D voxel model keeping a boolean flag (1 or 0) -//! value for each voxel, and having an opportunity to split each voxel -//! into 8 sub-voxels recursively. -class Voxel_ROctBoolDS : public Voxel_DS -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_ROctBoolDS(); - - //! A constructor initializing the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT Voxel_ROctBoolDS(const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z); - - //! Initialization of the voxel model. - //! (x, y, z) - the start point of the box. - //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system. - //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions. - Standard_EXPORT virtual void Init (const Standard_Real x, const Standard_Real y, const Standard_Real z, const Standard_Real x_len, const Standard_Real y_len, const Standard_Real z_len, const Standard_Integer nb_x, const Standard_Integer nb_y, const Standard_Integer nb_z) Standard_OVERRIDE; - - //! A destructor of the voxel model. - Standard_EXPORT void Destroy(); -~Voxel_ROctBoolDS() -{ - Destroy(); -} - - //! The method sets all values equal to 0 (false) and - //! releases the memory. - Standard_EXPORT void SetZero(); - - //! The method searches voxels with equal-value of sub-voxels - //! and removes them (remaining the value for the voxel). - Standard_EXPORT void OptimizeMemory(); - - //! Defines a value for voxel with co-ordinates (ix, iy, iz). - //! If the voxel is split into 8 sub-voxels, the split disappears. - //! Initial state of the model is so that all voxels have value 0 (false), - //! and this data doesn't occupy memory. - //! Memory for data is allocating during setting non-zero values (true). - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Boolean data); - - //! Defines a value for a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1, const Standard_Boolean data); - - //! Defines a value for a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split into 8 sub-voxels yet, this method splits the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1, const Standard_Integer ioct2, const Standard_Boolean data); - - //! Returns true if the voxel is split into 8 sub-voxels. - Standard_EXPORT Standard_Boolean IsSplit (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - //! Returns the deepness of splits of a voxel. - //! 0 - no splits (::IsSplit() being called would return false). - //! 1 - the voxel is split into 8 sub-voxels. - //! 2 - the voxels is split into 8 sub-voxels, - //! and each of the sub-voxels is split into 8 sub-sub-voxels. - //! 3 - ... - Standard_EXPORT Standard_Integer Deepness (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - //! Returns the value of voxel with co-ordinates (ix, iy, iz). - //! Warning!: the returned value may not coincide with the value of its 8 sub-voxels. - //! Use the method ::IsSplit() to check whether a voxel has sub-voxels. - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const; - - //! Returns the value of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split, it returns the value of the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1) const; - - //! Returns the value of a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz). - //! If the voxel is not split, it returns the value of the voxel. - //! Range of sub-voxels is 0 - 7. - Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1, const Standard_Integer ioct2) const; - - //! Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i). - Standard_EXPORT void GetCenter (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer i, Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const; - - //! Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i, j). - Standard_EXPORT void GetCenter (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer i, const Standard_Integer j, Standard_Real& xc, Standard_Real& yc, Standard_Real& zc) const; - - - - -protected: - - - - - -private: - - - - - -}; - - - - - - - -#endif // _Voxel_ROctBoolDS_HeaderFile diff --git a/src/Voxel/Voxel_Reader.cxx b/src/Voxel/Voxel_Reader.cxx deleted file mode 100644 index 17a6e5bd9d..0000000000 --- a/src/Voxel/Voxel_Reader.cxx +++ /dev/null @@ -1,575 +0,0 @@ -// Created on: 2008-08-28 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Voxel_Reader::Voxel_Reader():myBoolVoxels(0),myColorVoxels(0),myFloatVoxels(0) -{ - -} - -Standard_Boolean Voxel_Reader::Read(const TCollection_ExtendedString& file) -{ - // Open file in ASCII mode to read header - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - - // Read the header - Standard_Byte type; // 0 - bool, 1 - color, 2 - float - Voxel_VoxelFileFormat format; - Standard_Character svoxels[9], sformat[9], stype[9]; - if (fscanf(f, "%8s %8s %8s\n", svoxels, sformat, stype) != 3) - { - fclose(f); - return Standard_False; - } - fclose(f); - - // Take format, type of voxels. - // Voxels - if (strcmp(svoxels, VOXELS)) - return Standard_False; - // Format - if (strcmp(sformat, ASCII) == 0) - format = Voxel_VFF_ASCII; - else if (strcmp(sformat, BINARY) == 0) - format = Voxel_VFF_BINARY; - else - return Standard_False; - // Type of voxels - if (strcmp(stype, BOOL) == 0) - type = 0; - else if (strcmp(stype, COLOR) == 0) - type = 1; - else if (strcmp(stype, FLOAT) == 0) - type = 2; - else - return Standard_False; - - // Read the rest - switch (format) - { - case Voxel_VFF_ASCII: - { - switch (type) - { - case 0: - return ReadBoolAsciiVoxels(file); - case 1: - return ReadColorAsciiVoxels(file); - case 2: - return ReadFloatAsciiVoxels(file); - } - } - case Voxel_VFF_BINARY: - { - switch (type) - { - case 0: - return ReadBoolBinaryVoxels(file); - case 1: - return ReadColorBinaryVoxels(file); - case 2: - return ReadFloatBinaryVoxels(file); - } - } - } - - // No voxels or no format description is found: - return Standard_False; -} - -Standard_Boolean Voxel_Reader::IsBoolVoxels() const -{ - return (myBoolVoxels != 0); -} - -Standard_Boolean Voxel_Reader::IsColorVoxels() const -{ - return (myColorVoxels != 0); -} - -Standard_Boolean Voxel_Reader::IsFloatVoxels() const -{ - return (myFloatVoxels != 0); -} - -Standard_Address Voxel_Reader::GetBoolVoxels() const -{ - return myBoolVoxels; -} - -Standard_Address Voxel_Reader::GetColorVoxels() const -{ - return myColorVoxels; -} - -Standard_Address Voxel_Reader::GetFloatVoxels() const -{ - return myFloatVoxels; -} - -static Standard_Boolean has_slice(const Standard_CString line) -{ - Standard_Integer i = 0, nb_spaces = 0; - while (line[i] != '\0') - { - if (line[i] == ' ') - nb_spaces++; - i++; - } - return (nb_spaces == 2); -} - -Standard_Boolean Voxel_Reader::ReadBoolAsciiVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - Standard_Character line[65], sx[33], sy[33], sz[33]; - - // Header: skip it - if (fgets(line, 64, f) == NULL) - { - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - x = Atof(sx); y = Atof(sy); z = Atof(sz); - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - xlen = Atof(sx); ylen = Atof(sy); zlen = Atof(sz); - if (fscanf(f, "%d %d %d\n", &nbx, &nby, &nbz) != 3) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myBoolVoxels = (Standard_Address) new Voxel_BoolDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_BoolDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(nbx * nby * nbz / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - // myData[0 .. nb_slices - 1][0 .. 7] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0, value = 0; - while (!feof(f) - && fgets(line, 64, f) != NULL) - { - if (has_slice(line)) - { - if (sscanf(line, "%d %d %d\n", &i1, &i2, &value) != 3) - { - fclose(f); - return Standard_False; - } - } - else - { - if (sscanf(line, "%d %d\n", &i2, &value) != 2) - { - fclose(f); - return Standard_False; - } - } - - // Set value - if (!((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1]) - { - ((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1] = - (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = (Standard_Byte)value; - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Reader::ReadColorAsciiVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - Standard_Character line[65], sx[33], sy[33], sz[33]; - - // Header: skip it - if (fgets(line, 64, f) == NULL) - { - fclose(f); - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - x = Atof(sx); y = Atof(sy); z = Atof(sz); - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - xlen = Atof(sx); ylen = Atof(sy); zlen = Atof(sz); - if (fscanf(f, "%d %d %d\n", &nbx, &nby, &nbz) != 3) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myColorVoxels = (Standard_Address) new Voxel_ColorDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_ColorDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(nbx * nby * nbz / 2.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0, value = 0; - while (!feof(f) - && fgets(line, 64, f) != NULL) - { - if (has_slice(line)) - { - if (sscanf(line, "%d %d %d\n", &i1, &i2, &value) != 3) - { - fclose(f); - return Standard_False; - } - } - else - { - if (sscanf(line, "%d %d\n", &i2, &value) != 2) - { - fclose(f); - return Standard_False; - } - } - - // Set value - if (!((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1]) - { - ((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1] = - (Standard_Byte*) calloc(32/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = (Standard_Byte)value; - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Reader::ReadFloatAsciiVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - Standard_Character line[65], sx[33], sy[33], sz[33]; - - // Header: skip it - if (fgets(line, 64, f) == NULL) - { - fclose(f); - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - x = Atof(sx); y = Atof(sy); z = Atof(sz); - if (fscanf(f, "%32s %32s %32s\n", sx, sy, sz) != 3) - { - fclose(f); - return Standard_False; - } - xlen = Atof(sx); ylen = Atof(sy); zlen = Atof(sz); - if (fscanf(f, "%d %d %d\n", &nbx, &nby, &nbz) != 3) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myFloatVoxels = (Standard_Address) new Voxel_FloatDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_FloatDS.cxx: - Standard_Integer nb_floats = nbx * nby * nbz; - Standard_Integer nb_slices = RealToInt(ceil(nb_floats / 32.0)); // 32 values in 1 slice - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - Standard_ShortReal value = 0.0; - while (!feof(f) - && fgets(line, 64, f) != NULL) - { - if (has_slice(line)) - { - if (sscanf(line, "%d %d %64s\n", &i1, &i2, line) != 3) - { - fclose(f); - return Standard_False; - } - } - else - { - if (sscanf(line, "%d %64s\n", &i2, line) != 2) - { - fclose(f); - return Standard_False; - } - } - value = (Standard_ShortReal)Atof(line); - - // Set value - if (!((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1]) - { - ((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1] = - (Standard_ShortReal*) calloc(32/*number of floats in slice*/, sizeof(Standard_ShortReal)); - } - (((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1])[i2] = value; - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Reader::ReadBoolBinaryVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - - // Header: skip it - Standard_Character line[65]; - if (fgets(line, 64, f) == NULL) - { - fclose(f); - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fread(&x, sizeof(Standard_Real), 1, f) != 1 - || fread(&y, sizeof(Standard_Real), 1, f) != 1 - || fread(&z, sizeof(Standard_Real), 1, f) != 1 - || fread(&xlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&ylen, sizeof(Standard_Real), 1, f) != 1 - || fread(&zlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&nbx, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nby, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nbz, sizeof(Standard_Integer), 1, f) != 1) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myBoolVoxels = (Standard_Address) new Voxel_BoolDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_BoolDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(nbx * nby * nbz / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - // myData[0 .. nb_slices - 1][0 .. 7] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0, value = 0; - while (!feof(f) - && fread(&i1, sizeof(Standard_Integer), 1, f) == 1 - && fread(&i2, sizeof(Standard_Integer), 1, f) == 1 - && fread(&value, sizeof(Standard_Byte), 1, f) == 1) - { - // Set value - if (!((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1]) - { - ((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1] = - (Standard_Byte*) calloc(8/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - (((Standard_Byte**)((Voxel_DS*)myBoolVoxels)->myData)[i1])[i2] = (Standard_Byte)value; - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Reader::ReadColorBinaryVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - - // Header: skip it - Standard_Character line[65]; - if (fgets(line, 64, f) == NULL) - { - fclose(f); - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fread(&x, sizeof(Standard_Real), 1, f) != 1 - || fread(&y, sizeof(Standard_Real), 1, f) != 1 - || fread(&z, sizeof(Standard_Real), 1, f) != 1 - || fread(&xlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&ylen, sizeof(Standard_Real), 1, f) != 1 - || fread(&zlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&nbx, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nby, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nbz, sizeof(Standard_Integer), 1, f) != 1) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myColorVoxels = (Standard_Address) new Voxel_ColorDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_ColorDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(nbx * nby * nbz / 2.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0, value = 0; - while (!feof(f) - && fread(&i1, sizeof(Standard_Integer), 1, f) == 1 - && fread(&i2, sizeof(Standard_Integer), 1, f) == 1 - && fread(&value, sizeof(Standard_Byte), 1, f) == 1) - { - // Set value - if (!((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1]) - { - ((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1] = - (Standard_Byte*) calloc(32/*number of bytes in slice*/, sizeof(Standard_Byte)); - } - (((Standard_Byte**)((Voxel_DS*)myColorVoxels)->myData)[i1])[i2] = (Standard_Byte)value; - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Reader::ReadFloatBinaryVoxels(const TCollection_ExtendedString& file) -{ - // Open file for reading - FILE* f = OSD_OpenFile(file, "r"); - if (!f) - return Standard_False; - - // Header: skip it - Standard_Character line[65]; - if (fgets(line, 64, f) == NULL) - { - fclose(f); - return Standard_False; - } - - // Location, size, number of splits - Standard_Integer nbx = 0, nby = 0, nbz = 0; - Standard_Real x = 0.0, y = 0.0, z = 0.0, xlen = 0.0, ylen = 0.0, zlen = 0.0; - if (fread(&x, sizeof(Standard_Real), 1, f) != 1 - || fread(&y, sizeof(Standard_Real), 1, f) != 1 - || fread(&z, sizeof(Standard_Real), 1, f) != 1 - || fread(&xlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&ylen, sizeof(Standard_Real), 1, f) != 1 - || fread(&zlen, sizeof(Standard_Real), 1, f) != 1 - || fread(&nbx, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nby, sizeof(Standard_Integer), 1, f) != 1 - || fread(&nbz, sizeof(Standard_Integer), 1, f) != 1) - { - fclose(f); - return Standard_False; - } - - // Allocate the voxels - myFloatVoxels = (Standard_Address) new Voxel_FloatDS(x, y, z, xlen, ylen, zlen, nbx, nby, nbz); - - // Data - // Copied from Voxel_FloatDS.cxx: - Standard_Integer nb_floats = nbx * nby * nbz; - Standard_Integer nb_slices = RealToInt(ceil(nb_floats / 32.0)); // 32 values in 1 slice - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - Standard_ShortReal value = 0.0; - while (!feof(f) - && fread(&i1, sizeof(Standard_Integer), 1, f) == 1 - && fread(&i2, sizeof(Standard_Integer), 1, f) == 1 - && fread(&value, sizeof(Standard_ShortReal), 1, f) == 1) - { - // Set value - if (!((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1]) - { - ((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1] = - (Standard_ShortReal*) calloc(32/*number of floats in slice*/, sizeof(Standard_ShortReal)); - } - (((Standard_ShortReal**)((Voxel_DS*)myFloatVoxels)->myData)[i1])[i2] = value; - } - } - - fclose(f); - return Standard_True; -} diff --git a/src/Voxel/Voxel_Reader.hxx b/src/Voxel/Voxel_Reader.hxx deleted file mode 100644 index 4ea57ad743..0000000000 --- a/src/Voxel/Voxel_Reader.hxx +++ /dev/null @@ -1,105 +0,0 @@ -// Created on: 2008-08-28 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_Reader_HeaderFile -#define _Voxel_Reader_HeaderFile - -#include -#include -#include - -#include -#include -class TCollection_ExtendedString; - - -//! Reads a cube of voxels from disk. -//! Beware, a caller of the reader is responsible for deletion of the read voxels. -class Voxel_Reader -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_Reader(); - - //! Reads the voxels from disk - Standard_EXPORT Standard_Boolean Read (const TCollection_ExtendedString& file); - - //! Informs the user about the type of voxels he has read. - Standard_EXPORT Standard_Boolean IsBoolVoxels() const; - - //! Informs the user about the type of voxels he has read. - Standard_EXPORT Standard_Boolean IsColorVoxels() const; - - //! Informs the user about the type of voxels he has read. - Standard_EXPORT Standard_Boolean IsFloatVoxels() const; - - //! Returns a pointer to the read 1bit voxels. - Standard_EXPORT Standard_Address GetBoolVoxels() const; - - //! Returns a pointer to the read 4bit voxels. - Standard_EXPORT Standard_Address GetColorVoxels() const; - - //! Returns a pointer to the read 4bytes voxels. - Standard_EXPORT Standard_Address GetFloatVoxels() const; - - - - -protected: - - - - - -private: - - - //! Reads 1bit voxels from disk in ASCII format. - Standard_EXPORT Standard_Boolean ReadBoolAsciiVoxels (const TCollection_ExtendedString& file); - - //! Reads 4bit voxels from disk in ASCII format. - Standard_EXPORT Standard_Boolean ReadColorAsciiVoxels (const TCollection_ExtendedString& file); - - //! Reads 4bytes voxels from disk in ASCII format. - Standard_EXPORT Standard_Boolean ReadFloatAsciiVoxels (const TCollection_ExtendedString& file); - - //! Reads 1bit voxels from disk in BINARY format. - Standard_EXPORT Standard_Boolean ReadBoolBinaryVoxels (const TCollection_ExtendedString& file); - - //! Reads 4bit voxels from disk in BINARY format. - Standard_EXPORT Standard_Boolean ReadColorBinaryVoxels (const TCollection_ExtendedString& file); - - //! Reads 4bytes voxels from disk in BINARY format. - Standard_EXPORT Standard_Boolean ReadFloatBinaryVoxels (const TCollection_ExtendedString& file); - - - Standard_Address myBoolVoxels; - Standard_Address myColorVoxels; - Standard_Address myFloatVoxels; - - -}; - - - - - - - -#endif // _Voxel_Reader_HeaderFile diff --git a/src/Voxel/Voxel_Selector.cxx b/src/Voxel/Voxel_Selector.cxx deleted file mode 100644 index 1d01cd5115..0000000000 --- a/src/Voxel/Voxel_Selector.cxx +++ /dev/null @@ -1,581 +0,0 @@ -// Created on: 2008-07-30 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Voxel_Selector::Voxel_Selector():myVoxels(0) -{ - -} - -Voxel_Selector::Voxel_Selector(const Handle(V3d_View)& view):myView(view),myVoxels(0) -{ - -} - -void Voxel_Selector::Init(const Handle(V3d_View)& view) -{ - myView = view; -} - -void Voxel_Selector::SetVoxels(const Voxel_BoolDS& voxels) -{ - myIsBool = 1; - myVoxels = (void*) &voxels; -} - -void Voxel_Selector::SetVoxels(const Voxel_ColorDS& voxels) -{ - myIsBool = 0; - myVoxels = (void*) &voxels; -} - -void Voxel_Selector::SetVoxels(const Voxel_ROctBoolDS& voxels) -{ - myIsBool = 2; - myVoxels = (void*) &voxels; -} - -// This function is copied from ViewerTest_RelationCommands.cxx -static Standard_Boolean ComputeIntersection(const gp_Lin& L,const gp_Pln& ThePl, gp_Pnt& TheInter) -{ - static IntAna_Quadric TheQuad; - TheQuad.SetQuadric(ThePl); - static IntAna_IntConicQuad QQ; - QQ.Perform(L,TheQuad); - if(QQ.IsDone()){ - if(QQ.NbPoints()>0){ - TheInter = QQ.Point(1); - return Standard_True; - } - } - return Standard_False; -} - -static inline Standard_Integer GetIVoxel(const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, - const Standard_Integer nbx, const Standard_Integer nbxy) -{ - return ix + iy * nbx + iz * nbxy; -} - -static inline Standard_Boolean Get(const Standard_Address voxels, const Standard_Integer isBool, - const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) -{ - switch (isBool) - { - case 0: - return ((Voxel_ColorDS*) voxels)->Get(ix, iy, iz) > 0; - case 1: - return ((Voxel_BoolDS*) voxels)->Get(ix, iy, iz); - case 2: - { - Standard_Integer deepness = ((Voxel_ROctBoolDS*) voxels)->Deepness(ix, iy, iz); - switch (deepness) - { - case 0: - return ((Voxel_ROctBoolDS*) voxels)->Get(ix, iy, iz); - case 1: - { - for (Standard_Integer i = 0; i < 8; i++) - { - if (((Voxel_ROctBoolDS*) voxels)->Get(ix, iy, iz, i) == Standard_True) - return Standard_True; - } - break; - } - case 2: - { - for (Standard_Integer i = 0; i < 8; i++) - { - for (Standard_Integer j = 0; j < 8; j++) - { - if (((Voxel_ROctBoolDS*) voxels)->Get(ix, iy, iz, i, j) == Standard_True) - return Standard_True; - } - } - break; - } - } - } - } - return Standard_False; -} - -Standard_Boolean Voxel_Selector::Detect(const Standard_Integer winx, const Standard_Integer winy, - Standard_Integer& ixdetect, Standard_Integer& iydetect, Standard_Integer& izdetect) -{ - ixdetect = -1; iydetect = -1; izdetect = -1; - if (myView.IsNull() || !myVoxels) - return Standard_False; - - Voxel_DS* ds = 0; - switch (myIsBool) - { - case 0: - ds = (Voxel_ColorDS*) myVoxels; - break; - case 1: - ds = (Voxel_BoolDS*) myVoxels; - break; - case 2: - ds = (Voxel_ROctBoolDS*) myVoxels; - break; - } - Standard_Integer nbx = ds->GetNbX(), nby = ds->GetNbY(), nbz = ds->GetNbZ(), nbxy = nbx * nby; - - // Construct a line perpendicular to the screen - Standard_Real eyex, eyey, eyez, nx, ny, nz; - myView->Convert(winx, winy, eyex, eyey, eyez); - myView->Proj(nx, ny, nz); - gp_Pnt peye(eyex, eyey, eyez); - gp_Lin line(peye, gp_Dir(nx, ny, nz)); - - // Find the first voxel meeting the line at entrance to the cube of voxels. - // Construct planes of the cube of voxels - Standard_Real xstart = ds->GetX(), ystart = ds->GetY(), zstart = ds->GetZ(); - Standard_Real xlen = ds->GetXLen(), ylen = ds->GetYLen(), zlen = ds->GetZLen(); - Standard_Real xend = xstart + xlen, yend = ystart + ylen, zend = zstart + zlen; - gp_Pln xplane_minus(gp_Pnt(xstart, ystart, zstart), -gp::DX()); - gp_Pln xplane_plus (gp_Pnt(xend, ystart, zstart), gp::DX()); - gp_Pln yplane_minus(gp_Pnt(xstart, ystart, zstart), -gp::DY()); - gp_Pln yplane_plus (gp_Pnt(xstart, yend, zstart), gp::DY()); - gp_Pln zplane_minus(gp_Pnt(xstart, ystart, zstart), -gp::DZ()); - gp_Pln zplane_plus (gp_Pnt(xstart, ystart, zend), gp::DZ()); - // Intersect the planes with the line. - gp_Pnt pintersection, p; - Standard_Real depth = DBL_MAX, d; - Standard_Integer iplane = -1; // not found - if (ComputeIntersection(line, xplane_minus, p)) // -X - { - if (p.Y() >= ystart && p.Y() <= yend && - p.Z() >= zstart && p.Z() <= zend) - { - p.SetX(xstart); - depth = peye.SquareDistance(p); - iplane = 0; - pintersection = p; - } - } - if (ComputeIntersection(line, xplane_plus, p)) // +X - { - if (p.Y() >= ystart && p.Y() <= yend && - p.Z() >= zstart && p.Z() <= zend) - { - d = peye.SquareDistance(p); - if (d < depth) - { - p.SetX(xend); - depth = d; - iplane = 1; - pintersection = p; - } - } - } - if (ComputeIntersection(line, yplane_minus, p)) // -Y - { - if (p.X() >= xstart && p.X() <= xend && - p.Z() >= zstart && p.Z() <= zend) - { - d = peye.SquareDistance(p); - if (d < depth) - { - p.SetY(ystart); - depth = d; - iplane = 2; - pintersection = p; - } - } - } - if (ComputeIntersection(line, yplane_plus, p)) // +Y - { - if (p.X() >= xstart && p.X() <= xend && - p.Z() >= zstart && p.Z() <= zend) - { - d = peye.SquareDistance(p); - if (d < depth) - { - p.SetY(yend); - depth = d; - iplane = 3; - pintersection = p; - } - } - } - if (ComputeIntersection(line, zplane_minus, p)) // -Z - { - if (p.X() >= xstart && p.X() <= xend && - p.Y() >= ystart && p.Y() <= yend) - { - d = peye.SquareDistance(p); - if (d < depth) - { - p.SetZ(zstart); - depth = d; - iplane = 4; - pintersection = p; - } - } - } - if (ComputeIntersection(line, zplane_plus, p)) // +Z - { - if (p.X() >= xstart && p.X() <= xend && - p.Y() >= ystart && p.Y() <= yend) - { - d = peye.SquareDistance(p); - if (d < depth) - { - p.SetZ(zend); - depth = d; - iplane = 5; - pintersection = p; - } - } - } - // Find the voxel on the detected plane - if (iplane == -1) - return Standard_False; - Standard_Integer ix, iy, iz; - if (!ds->GetVoxel(pintersection.X(), pintersection.Y(), pintersection.Z(), ix, iy, iz)) - return Standard_False; - ixdetect = ix; iydetect = iy; izdetect = iz; - - // Find a non-zero voxel at the line - Standard_Real xmin = xlen / Standard_Real(nbx), - ymin = ylen / Standard_Real(nby), - zmin = zlen / Standard_Real(nbz), - vmin = sqrt(xmin * xmin + ymin * ymin + zmin * zmin) / 2.0; - Standard_Real xc, yc, zc, dist, distmin = DBL_MAX; - TColStd_MapOfInteger passed; - while (!Get(myVoxels, myIsBool, ixdetect, iydetect, izdetect)) - { - // Memorize already checked voxels - if (!passed.Add(GetIVoxel(ixdetect, iydetect, izdetect, nbx, nbxy))) - return Standard_False; - - distmin = DBL_MAX; - ix = ixdetect; iy = iydetect; iz = izdetect; - - //1: -X neighbour - if (ix - 1 >= 0 && !passed.Contains(GetIVoxel(ix - 1, iy, iz, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy; izdetect = iz; - distmin = dist; - } - } - //2: +X neighbour - if (ix + 1 < nbx && !passed.Contains(GetIVoxel(ix + 1, iy, iz, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy; izdetect = iz; - distmin = dist; - } - } - //3: -Y neighbour - if (iy - 1 >= 0 && !passed.Contains(GetIVoxel(ix, iy - 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix, iy - 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy - 1; izdetect = iz; - distmin = dist; - } - } - //4: +Y neighbour - if (iy + 1 < nby && !passed.Contains(GetIVoxel(ix, iy + 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix, iy + 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy + 1; izdetect = iz; - distmin = dist; - } - } - //5: -Z neighbour - if (iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix, iy, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy; izdetect = iz - 1; - distmin = dist; - } - } - //6: +Z neighbour - if (iz + 1 < nbz && !passed.Contains(GetIVoxel(ix, iy, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy; izdetect = iz + 1; - distmin = dist; - } - } - - // Diagonal voxels - //7: -X-Y neighbour - if (ix - 1 >= 0 && iy - 1 >= 0 && !passed.Contains(GetIVoxel(ix - 1, iy - 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy - 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy - 1; izdetect = iz; - distmin = dist; - } - } - //8: -X-Z neighbour - if (ix - 1 >= 0 && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix - 1, iy, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy; izdetect = iz - 1; - distmin = dist; - } - } - //9: -Y-Z neighbour - if (iy - 1 >= 0 && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix, iy - 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy - 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy - 1; izdetect = iz - 1; - distmin = dist; - } - } - - //10: +X-Y neighbour - if (ix + 1 < nbx && iy - 1 >= 0 && !passed.Contains(GetIVoxel(ix + 1, iy - 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy - 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy - 1; izdetect = iz; - distmin = dist; - } - } - //11: +X-Z neighbour - if (ix + 1 < nbx && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix + 1, iy, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy; izdetect = iz - 1; - distmin = dist; - } - } - //12: +Y-Z neighbour - if (iy + 1 < nby && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix, iy + 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy + 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy + 1; izdetect = iz - 1; - distmin = dist; - } - } - - //13: -X+Y neighbour - if (ix - 1 >= 0 && iy + 1 < nby && !passed.Contains(GetIVoxel(ix - 1, iy + 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy + 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy + 1; izdetect = iz; - distmin = dist; - } - } - //14: -X+Z neighbour - if (ix - 1 >= 0 && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix - 1, iy, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy; izdetect = iz + 1; - distmin = dist; - } - } - //15: -Y+Z neighbour - if (iy - 1 >= 0 && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix, iy - 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy - 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy - 1; izdetect = iz + 1; - distmin = dist; - } - } - - //16: +X+Y neighbour - if (ix + 1 < nbx && iy + 1 < nby && !passed.Contains(GetIVoxel(ix + 1, iy + 1, iz, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy + 1, iz, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy + 1; izdetect = iz; - distmin = dist; - } - } - //17: +X+Z neighbour - if (ix + 1 < nbx && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix + 1, iy, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy; izdetect = iz + 1; - distmin = dist; - } - } - //18: +Y+Z neighbour - if (iy + 1 < nby && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix, iy + 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix, iy + 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix; iydetect = iy + 1; izdetect = iz + 1; - distmin = dist; - } - } - - // Farest neighbours - //19: -X-Y-Z neighbour - if (ix - 1 >= 0 && iy - 1 >= 0 && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix - 1, iy - 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy - 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy - 1; izdetect = iz - 1; - distmin = dist; - } - } - //20: +X-Y-Z neighbour - if (ix + 1 < nbx && iy - 1 >= 0 && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix + 1, iy - 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy - 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy - 1; izdetect = iz - 1; - distmin = dist; - } - } - //21: -X+Y-Z neighbour - if (ix - 1 >= 0 && iy + 1 < nby && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix - 1, iy + 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy + 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy + 1; izdetect = iz - 1; - distmin = dist; - } - } - //22: -X-Y+Z neighbour - if (ix - 1 >= 0 && iy - 1 >= 0 && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix - 1, iy - 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy - 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy - 1; izdetect = iz + 1; - distmin = dist; - } - } - //23: +X+Y-Z neighbour - if (ix + 1 < nbx && iy + 1 < nby && iz - 1 >= 0 && !passed.Contains(GetIVoxel(ix + 1, iy + 1, iz - 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy + 1, iz - 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy + 1; izdetect = iz - 1; - distmin = dist; - } - } - //24: +X-Y+Z neighbour - if (ix + 1 < nbx && iy - 1 >= 0 && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix + 1, iy - 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy - 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy - 1; izdetect = iz + 1; - distmin = dist; - } - } - //25: -X+Y+Z neighbour - if (ix - 1 >= 0 && iy + 1 < nby && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix - 1, iy + 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix - 1, iy + 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix - 1; iydetect = iy + 1; izdetect = iz + 1; - distmin = dist; - } - } - //26: +X+Y+Z neighbour - if (ix + 1 < nbx && iy + 1 < nby && iz + 1 < nbz && !passed.Contains(GetIVoxel(ix + 1, iy + 1, iz + 1, nbx, nbxy))) - { - ds->GetCenter(ix + 1, iy + 1, iz + 1, xc, yc, zc); - dist = line.Distance(gp_Pnt(xc, yc, zc)); - if (dist < vmin && dist < distmin) - { - ixdetect = ix + 1; iydetect = iy + 1; izdetect = iz + 1; - distmin = dist; - } - } - - } // End of while (zero-voxel... - - if (!Get(myVoxels, myIsBool, ixdetect, iydetect, izdetect)) - return Standard_False; - return Standard_True; -} diff --git a/src/Voxel/Voxel_Selector.hxx b/src/Voxel/Voxel_Selector.hxx deleted file mode 100644 index 9234c56199..0000000000 --- a/src/Voxel/Voxel_Selector.hxx +++ /dev/null @@ -1,90 +0,0 @@ -// Created on: 2008-07-30 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_Selector_HeaderFile -#define _Voxel_Selector_HeaderFile - -#include -#include -#include - -#include -#include -#include -class V3d_View; -class Voxel_BoolDS; -class Voxel_ColorDS; -class Voxel_ROctBoolDS; - - -//! Detects voxels in the viewer 3d under the mouse cursor. -class Voxel_Selector -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_Selector(); - - //! A constructor of the selector, - //! which initializes the classes - //! by a view, where the user selects the voxels. - Standard_EXPORT Voxel_Selector(const Handle(V3d_View)& view); - - //! Initializes the selector by a view, - //! where the user selects the voxels. - Standard_EXPORT void Init (const Handle(V3d_View)& view); - - //! Defines the voxels (1bit). - Standard_EXPORT void SetVoxels (const Voxel_BoolDS& voxels); - - //! Defines the voxels (4bit). - Standard_EXPORT void SetVoxels (const Voxel_ColorDS& voxels); - - //! Defines the voxels (1bit recursive splitting). - Standard_EXPORT void SetVoxels (const Voxel_ROctBoolDS& voxels); - - //! Detects a voxel under the mouse cursor. - Standard_EXPORT Standard_Boolean Detect (const Standard_Integer winx, const Standard_Integer winy, Standard_Integer& ix, Standard_Integer& iy, Standard_Integer& iz); - - - - -protected: - - - - - -private: - - - - Handle(V3d_View) myView; - Standard_Address myVoxels; - Standard_Integer myIsBool; - - -}; - - - - - - - -#endif // _Voxel_Selector_HeaderFile diff --git a/src/Voxel/Voxel_SplitData.cxx b/src/Voxel/Voxel_SplitData.cxx deleted file mode 100644 index ce59c60309..0000000000 --- a/src/Voxel/Voxel_SplitData.cxx +++ /dev/null @@ -1,32 +0,0 @@ -// Created on: 2008-09-01 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include - -Voxel_SplitData::Voxel_SplitData():myValues(0),mySplitData(0) -{ - -} - -Standard_Address& Voxel_SplitData::GetValues() -{ - return myValues; -} - -Standard_Address& Voxel_SplitData::GetSplitData() -{ - return mySplitData; -} diff --git a/src/Voxel/Voxel_SplitData.hxx b/src/Voxel/Voxel_SplitData.hxx deleted file mode 100644 index 28b69fed50..0000000000 --- a/src/Voxel/Voxel_SplitData.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// Created on: 2008-09-01 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_SplitData_HeaderFile -#define _Voxel_SplitData_HeaderFile - -#include -#include -#include - -#include - - -//! A container of split information. -//! An instance of this class is used as a slice -//! in inner representation of recursive octtree voxels. -class Voxel_SplitData -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_SplitData(); - - //! Gives access to the values. - Standard_EXPORT Standard_Address& GetValues(); - - //! Gives access to the next split data. - Standard_EXPORT Standard_Address& GetSplitData(); - - - - -protected: - - - - - -private: - - - - Standard_Address myValues; - Standard_Address mySplitData; - - -}; - - - - - - - -#endif // _Voxel_SplitData_HeaderFile diff --git a/src/Voxel/Voxel_TypeDef.hxx b/src/Voxel/Voxel_TypeDef.hxx deleted file mode 100644 index b49b53597b..0000000000 --- a/src/Voxel/Voxel_TypeDef.hxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 1999-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _VOXEL_TYPEDEF_HXX_ -#define _VOXEL_TYPEDEF_HXX_ - -// Basic data types - -typedef struct -{ - Standard_Integer ix; - Standard_Integer iy; - Standard_Integer iz; -} iXYZ; - - -// Maps and Tables - -inline Standard_Integer HashCode(const iXYZ& me, const Standard_Integer upper) -{ - return (Abs(me.ix + me.iy + me.iz) % upper) + 1; -} - -inline Standard_Boolean IsEqual(const iXYZ& one, const iXYZ& two) -{ - return one.ix == two.ix && one.iy == two.iy && one.iz == two.iz; -} - -#include - -typedef NCollection_DataMap iXYZIndex; -typedef NCollection_DataMap iXYZBool; - -// Defines - -#define VOXELS "Voxels" -#define ASCII "Ascii" -#define BINARY "Binary" -#define BOOL "Bool" -#define COLOR "Color" -#define FLOAT "Float" - -#endif // _VOXEL_TYPEDEF_HXX_ diff --git a/src/Voxel/Voxel_VisData.h b/src/Voxel/Voxel_VisData.h deleted file mode 100644 index 80e573377a..0000000000 --- a/src/Voxel/Voxel_VisData.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - Copyright (c) 1999-2014 OPEN CASCADE SAS - - This file is part of Open CASCADE Technology software library. - - This library is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License version 2.1 as published - by the Free Software Foundation, with special exception defined in the file - OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT - distribution for complete text of the license and disclaimer of any warranty. - - Alternatively, this file may be used under the terms of Open CASCADE - commercial license or contractual agreement. -*/ - -#ifndef _VOXEL_VISDATA_H_ -#define _VOXEL_VISDATA_H_ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -enum VoxelDirection -{ - None, - Xminus, - Xplus, - Yminus, - Yplus, - Zminus, - Zplus -}; - -typedef struct -{ - - /* Display mode */ - Voxel_VoxelDisplayMode myDisplayMode; - - /* Range of displayed values */ - /* BoolDS */ - /* No range */ - /* ColorDS */ - Standard_Byte myColorMinValue; - Standard_Byte myColorMaxValue; - - /* Range of displayed size */ - Standard_Real myDisplayedXMin; - Standard_Real myDisplayedXMax; - Standard_Real myDisplayedYMin; - Standard_Real myDisplayedYMax; - Standard_Real myDisplayedZMin; - Standard_Real myDisplayedZMax; - - /* Colors */ - Quantity_Color myColor; - Handle(Quantity_HArray1OfColor) myColors; - - /* Size, width... */ - Standard_Real myPointSize; - Standard_Integer myQuadrangleSize; /* 0% .. 100% */ - Standard_Byte mySmoothPoints; - - /* Transparency */ - Standard_Real myTransparency; - - /* GL lists of each display mode */ - /* BoolDS */ - /* POINTS */ - Standard_Integer myBoolPointsList; - Standard_Byte myBoolPointsFirst; - /* NEAREST POINTS */ - Standard_Integer myBoolNearestPointsList[7]; - Standard_Byte myBoolNearestPointsFirst; - /* ColorDS */ - /* POINTS */ - Standard_Integer myColorPointsList; - Standard_Byte myColorPointsFirst; - /* NEAREST POINTS */ - Standard_Integer myColorNearestPointsList[7]; - Standard_Byte myColorNearestPointsFirst; - /* ROctBoolDS */ - /* POINTS */ - Standard_Integer myROctBoolPointsList; - Standard_Byte myROctBoolPointsFirst; - /* NEAREST POINTS */ - Standard_Integer myROctBoolNearestPointsList[7]; - Standard_Byte myROctBoolNearestPointsFirst; - /* TRIANGULATION */ - Standard_Integer myTriangulationList; - /* Usage of GL lists */ - Standard_Byte myUsageOfGLlists; - - /* Degenerate mode */ - Standard_Byte myDegenerateMode; - - /* Highlighted voxel */ - Standard_Integer myHighlightx; - Standard_Integer myHighlighty; - Standard_Integer myHighlightz; - -} DisplayData; - -typedef struct -{ - - // Voxels - Voxel_BoolDS* myBoolVoxels; - Voxel_ColorDS* myColorVoxels; - Voxel_ROctBoolDS* myROctBoolVoxels; - - // Triangulation - Handle(Poly_Triangulation) myTriangulation; - Handle(TColgp_HArray1OfDir) myNormalsOfNodes; - - // Display - DisplayData myDisplay; - -} Voxel_VisData; - -#endif // _VOXEL_VISDATA_H_ diff --git a/src/Voxel/Voxel_VoxelDisplayMode.hxx b/src/Voxel/Voxel_VoxelDisplayMode.hxx deleted file mode 100644 index 1d3ddb8678..0000000000 --- a/src/Voxel/Voxel_VoxelDisplayMode.hxx +++ /dev/null @@ -1,28 +0,0 @@ -// Created on: 2008-05-04 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_VoxelDisplayMode_HeaderFile -#define _Voxel_VoxelDisplayMode_HeaderFile - - -enum Voxel_VoxelDisplayMode -{ -Voxel_VDM_POINTS, -Voxel_VDM_NEARESTPOINTS, -Voxel_VDM_BOXES, -Voxel_VDM_NEARESTBOXES -}; - -#endif // _Voxel_VoxelDisplayMode_HeaderFile diff --git a/src/Voxel/Voxel_VoxelFileFormat.hxx b/src/Voxel/Voxel_VoxelFileFormat.hxx deleted file mode 100644 index 751f199fbb..0000000000 --- a/src/Voxel/Voxel_VoxelFileFormat.hxx +++ /dev/null @@ -1,26 +0,0 @@ -// Created on: 2008-05-04 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_VoxelFileFormat_HeaderFile -#define _Voxel_VoxelFileFormat_HeaderFile - - -enum Voxel_VoxelFileFormat -{ -Voxel_VFF_ASCII, -Voxel_VFF_BINARY -}; - -#endif // _Voxel_VoxelFileFormat_HeaderFile diff --git a/src/Voxel/Voxel_Writer.cxx b/src/Voxel/Voxel_Writer.cxx deleted file mode 100644 index 94aae86072..0000000000 --- a/src/Voxel/Voxel_Writer.cxx +++ /dev/null @@ -1,442 +0,0 @@ -// Created on: 2008-08-28 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -Voxel_Writer::Voxel_Writer():myFormat(Voxel_VFF_ASCII),myBoolVoxels(0),myColorVoxels(0),myFloatVoxels(0) -{ - -} - -void Voxel_Writer::SetFormat(const Voxel_VoxelFileFormat format) -{ - myFormat = format; -} - -void Voxel_Writer::SetVoxels(const Voxel_BoolDS& voxels) -{ - myBoolVoxels = (Standard_Address) &voxels; - myColorVoxels = 0; - myFloatVoxels = 0; -} - -void Voxel_Writer::SetVoxels(const Voxel_ColorDS& voxels) -{ - myBoolVoxels = 0; - myColorVoxels = (Standard_Address) &voxels; - myFloatVoxels = 0; -} - -void Voxel_Writer::SetVoxels(const Voxel_FloatDS& voxels) -{ - myBoolVoxels = 0; - myColorVoxels = 0; - myFloatVoxels = (Standard_Address) &voxels; -} - -Standard_Boolean Voxel_Writer::Write(const TCollection_ExtendedString& file) const -{ - switch (myFormat) - { - case Voxel_VFF_ASCII: - { - if (myBoolVoxels) - return WriteBoolAsciiVoxels(file); - else if (myColorVoxels) - return WriteColorAsciiVoxels(file); - else if (myFloatVoxels) - return WriteFloatAsciiVoxels(file); - } - case Voxel_VFF_BINARY: - { - if (myBoolVoxels) - return WriteBoolBinaryVoxels(file); - else if (myColorVoxels) - return WriteColorBinaryVoxels(file); - else if (myFloatVoxels) - return WriteFloatBinaryVoxels(file); - } - } - - // No voxels or no format description is found: - return Standard_False; -} - -Standard_Boolean Voxel_Writer::WriteBoolAsciiVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_BoolDS* ds = (Voxel_BoolDS*) myBoolVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "w+"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, ASCII); - fprintf(f, " "); - fprintf(f, BOOL); - fprintf(f, "\n"); - - // Location, size, number of splits - fprintf(f, "%g %g %g\n", ds->GetX(), ds->GetY(), ds->GetZ()); - fprintf(f, "%g %g %g\n", ds->GetXLen(), ds->GetYLen(), ds->GetZLen()); - fprintf(f, "%d %d %d\n", ds->GetNbX(), ds->GetNbY(), ds->GetNbZ()); - - // Data - // Copied from Voxel_BoolDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(ds->GetNbX() * ds->GetNbY() * ds->GetNbZ() / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - // myData[0 .. nb_slices - 1][0 .. 7] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_Byte**)ds->myData)[i1]) - { - Standard_Boolean has_value = Standard_False; - fprintf(f, "%d ", i1); // index of slice - for (i2 = 0; i2 < 8; i2++) - { - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)ds->myData)[i1])[i2]; - if (value) - { - has_value = Standard_True; - fprintf(f, "%d %d\n", i2, value); - } - } - if (!has_value) - { - fprintf(f, "0 0\n"); - } - } - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Writer::WriteColorAsciiVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_ColorDS* ds = (Voxel_ColorDS*) myColorVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "w+"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, ASCII); - fprintf(f, " "); - fprintf(f, COLOR); - fprintf(f, "\n"); - - // Location, size, number of splits - fprintf(f, "%g %g %g\n", ds->GetX(), ds->GetY(), ds->GetZ()); - fprintf(f, "%g %g %g\n", ds->GetXLen(), ds->GetYLen(), ds->GetZLen()); - fprintf(f, "%d %d %d\n", ds->GetNbX(), ds->GetNbY(), ds->GetNbZ()); - - // Data - // Copied from Voxel_ColorDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(ds->GetNbX() * ds->GetNbY() * ds->GetNbZ() / 2.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_Byte**)ds->myData)[i1]) - { - Standard_Boolean has_value = Standard_False; - fprintf(f, "%d ", i1); // index of slice - for (i2 = 0; i2 < 32; i2++) - { - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)ds->myData)[i1])[i2]; - if (value) - { - has_value = Standard_True; - fprintf(f, "%d %d\n", i2, value); - } - } - if (!has_value) - { - fprintf(f, "0 0\n"); - } - } - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Writer::WriteFloatAsciiVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_FloatDS* ds = (Voxel_FloatDS*) myFloatVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "w+"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, ASCII); - fprintf(f, " "); - fprintf(f, FLOAT); - fprintf(f, "\n"); - - // Location, size, number of splits - fprintf(f, "%g %g %g\n", ds->GetX(), ds->GetY(), ds->GetZ()); - fprintf(f, "%g %g %g\n", ds->GetXLen(), ds->GetYLen(), ds->GetZLen()); - fprintf(f, "%d %d %d\n", ds->GetNbX(), ds->GetNbY(), ds->GetNbZ()); - - // Data - // Copied from Voxel_FloatDS.cxx: - Standard_Integer nb_floats = ds->GetNbX() * ds->GetNbY() * ds->GetNbZ(); - Standard_Integer nb_slices = RealToInt(ceil(nb_floats / 32.0)); // 32 values in 1 slice - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_ShortReal**)ds->myData)[i1]) - { - Standard_Boolean has_value = Standard_False; - fprintf(f, "%d ", i1); // index of slice - for (i2 = 0; i2 < 32; i2++) - { - Standard_ShortReal value = ((Standard_ShortReal*)((Standard_ShortReal**)ds->myData)[i1])[i2]; - if (value) - { - has_value = Standard_True; - fprintf(f, "%d %g\n", i2, value); - } - } - if (!has_value) - { - fprintf(f, "0 0\n"); - } - } - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Writer::WriteBoolBinaryVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_BoolDS* ds = (Voxel_BoolDS*) myBoolVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "wb"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, BINARY); - fprintf(f, " "); - fprintf(f, BOOL); - fprintf(f, "\n"); - - // Location, size, number of splits - fwrite(&(ds->myX), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myY), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZ), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myXLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myYLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myNbX), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbY), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbZ), sizeof(Standard_Integer), 1, f); - - // Data - // Copied from Voxel_BoolDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(ds->GetNbX() * ds->GetNbY() * ds->GetNbZ() / 8.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 8.0)); - // myData[0 .. nb_slices - 1][0 .. 7] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_Byte**)ds->myData)[i1]) - { - for (i2 = 0; i2 < 8; i2++) - { - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)ds->myData)[i1])[i2]; - if (value) - { - fwrite(&i1, sizeof(Standard_Integer), 1, f); - fwrite(&i2, sizeof(Standard_Integer), 1, f); - fwrite(&value, sizeof(Standard_Byte), 1, f); - } - } - } - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Writer::WriteColorBinaryVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_ColorDS* ds = (Voxel_ColorDS*) myColorVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "wb"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, BINARY); - fprintf(f, " "); - fprintf(f, COLOR); - fprintf(f, "\n"); - - // Location, size, number of splits - fwrite(&(ds->myX), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myY), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZ), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myXLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myYLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myNbX), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbY), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbZ), sizeof(Standard_Integer), 1, f); - - // Data - // Copied from Voxel_ColorDS.cxx: - Standard_Integer nb_bytes = RealToInt(ceil(ds->myNbX * ds->myNbY * ds->myNbZ / 2.0)); - Standard_Integer nb_slices = RealToInt(ceil(nb_bytes / 32.0)); - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_Byte**)ds->myData)[i1]) - { - for (i2 = 0; i2 < 32; i2++) - { - Standard_Byte value = ((Standard_Byte*)((Standard_Byte**)ds->myData)[i1])[i2]; - if (value) - { - fwrite(&i1, sizeof(Standard_Integer), 1, f); - fwrite(&i2, sizeof(Standard_Integer), 1, f); - fwrite(&value, sizeof(Standard_Byte), 1, f); - } - } - } - } - } - - fclose(f); - return Standard_True; -} - -Standard_Boolean Voxel_Writer::WriteFloatBinaryVoxels(const TCollection_ExtendedString& file) const -{ - Voxel_FloatDS* ds = (Voxel_FloatDS*) myFloatVoxels; - if (!ds->myData) - return Standard_False; - - // Open file for writing - FILE* f = OSD_OpenFile(file, "wb"); - if (!f) - return Standard_False; - - // Header: file format, type of voxels - fprintf(f, VOXELS); - fprintf(f, " "); - fprintf(f, BINARY); - fprintf(f, " "); - fprintf(f, FLOAT); - fprintf(f, "\n"); - - // Location, size, number of splits - fwrite(&(ds->myX), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myY), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZ), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myXLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myYLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myZLen), sizeof(Standard_Real), 1, f); - fwrite(&(ds->myNbX), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbY), sizeof(Standard_Integer), 1, f); - fwrite(&(ds->myNbZ), sizeof(Standard_Integer), 1, f); - - // Data - // Copied from Voxel_FloatDS.cxx: - Standard_Integer nb_floats = ds->myNbX * ds->myNbY * ds->myNbZ; - Standard_Integer nb_slices = RealToInt(ceil(nb_floats / 32.0)); // 32 values in 1 slice - // myData[0 .. nb_slices - 1][0 .. 31] - if (nb_slices) - { - Standard_Integer i1 = 0, i2 = 0; - Standard_Real small = Precision::SquareConfusion(); - for (i1 = 0; i1 < nb_slices; i1++) - { - if (((Standard_ShortReal**)ds->myData)[i1]) - { - for (i2 = 0; i2 < 32; i2++) - { - Standard_ShortReal value = ((Standard_ShortReal*)((Standard_ShortReal**)ds->myData)[i1])[i2]; - if (fabs(value) > small) - { - fwrite(&i1, sizeof(Standard_Integer), 1, f); - fwrite(&i2, sizeof(Standard_Integer), 1, f); - fwrite(&value, sizeof(Standard_ShortReal), 1, f); - } - } - } - } - } - - fclose(f); - return Standard_True; -} diff --git a/src/Voxel/Voxel_Writer.hxx b/src/Voxel/Voxel_Writer.hxx deleted file mode 100644 index de8bfd8143..0000000000 --- a/src/Voxel/Voxel_Writer.hxx +++ /dev/null @@ -1,106 +0,0 @@ -// Created on: 2008-08-28 -// Created by: Vladislav ROMASHKO -// Copyright (c) 2008-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef _Voxel_Writer_HeaderFile -#define _Voxel_Writer_HeaderFile - -#include -#include -#include - -#include -#include -#include -class Voxel_BoolDS; -class Voxel_ColorDS; -class Voxel_FloatDS; -class TCollection_ExtendedString; - - -//! Writes a cube of voxels on disk. -class Voxel_Writer -{ -public: - - DEFINE_STANDARD_ALLOC - - - //! An empty constructor. - Standard_EXPORT Voxel_Writer(); - - //! Defines the file format for voxels. - //! ASCII - slow and occupies more space on disk. - //! BINARY - fast and occupies less space on disk. - Standard_EXPORT void SetFormat (const Voxel_VoxelFileFormat format); - - //! Defines the voxels (1bit). - Standard_EXPORT void SetVoxels (const Voxel_BoolDS& voxels); - - //! Defines the voxels (4bit). - Standard_EXPORT void SetVoxels (const Voxel_ColorDS& voxels); - - //! Defines the voxels (4bytes). - Standard_EXPORT void SetVoxels (const Voxel_FloatDS& voxels); - - //! Writes the voxels on disk - //! using the defined format and file name. - Standard_EXPORT Standard_Boolean Write (const TCollection_ExtendedString& file) const; - - - - -protected: - - - - - -private: - - - //! Writes 1bit voxels on disk in ASCII format. - Standard_EXPORT Standard_Boolean WriteBoolAsciiVoxels (const TCollection_ExtendedString& file) const; - - //! Writes 4bit voxels on disk in ASCII format. - Standard_EXPORT Standard_Boolean WriteColorAsciiVoxels (const TCollection_ExtendedString& file) const; - - //! Writes 4bytes voxels on disk in ASCII format. - Standard_EXPORT Standard_Boolean WriteFloatAsciiVoxels (const TCollection_ExtendedString& file) const; - - //! Writes 1bit voxels on disk in BINARY format. - Standard_EXPORT Standard_Boolean WriteBoolBinaryVoxels (const TCollection_ExtendedString& file) const; - - //! Writes 4bit voxels on disk in BINARY format. - Standard_EXPORT Standard_Boolean WriteColorBinaryVoxels (const TCollection_ExtendedString& file) const; - - //! Writes 4bytes voxels on disk in BINARY format. - Standard_EXPORT Standard_Boolean WriteFloatBinaryVoxels (const TCollection_ExtendedString& file) const; - - - Voxel_VoxelFileFormat myFormat; - Standard_Address myBoolVoxels; - Standard_Address myColorVoxels; - Standard_Address myFloatVoxels; - - -}; - - - - - - - -#endif // _Voxel_Writer_HeaderFile diff --git a/tests/bugs/vis/bug19820 b/tests/bugs/vis/bug19820 deleted file mode 100755 index 2b45b2cb8f..0000000000 --- a/tests/bugs/vis/bug19820 +++ /dev/null @@ -1,73 +0,0 @@ -puts "============" -puts "OCC19820" -puts "============" -puts "" -####################################################################### -# 3D discrete topology (voxels) -####################################################################### - -set BugNumber OCC19820 - -set status 0 - -puts "1. voxelboolds ..." -if [catch {voxelboolds}] { - set status 1 -} - -puts "2. voxelcolords ..." -if [catch {voxelcolords}] { - set status 1 -} - -puts "3. voxelfloatds ..." -if [catch {voxelfloatds}] { - set status 1 -} - -puts "4. voxeloctboolds ..." -if [catch {voxeloctboolds}] { - set status 1 -} - -puts "5. voxelroctboolds ..." -if [catch {voxelroctboolds}] { - set status 1 -} - -puts "6. voxelfuseboolds ..." -if [catch {voxelfuseboolds}] { - set status 1 -} - -puts "7. voxelfusecolords ..." -if [catch {voxelfusecolords}] { - set status 1 -} - -puts "8. voxelfusefloatds ..." -if [catch {voxelfusefloatds}] { - set status 1 -} - -puts "9. voxelcutboolds ..." -if [catch {voxelcutboolds}] { - set status 1 -} - -puts "10. voxelcutcolords ..." -if [catch {voxelcutcolords}] { - set status 1 -} - -puts "11. voxelcutfloatds ..." -if [catch {voxelcutfloatds}] { - set status 1 -} - -if { ${status} != 0 } { - puts "Faulty ${BugNumber}" -} else { - puts "OK ${BugNumber}" -} - diff --git a/tests/bugs/vis/bug24019 b/tests/bugs/vis/bug24019 deleted file mode 100644 index d70ed56ff5..0000000000 --- a/tests/bugs/vis/bug24019 +++ /dev/null @@ -1,9 +0,0 @@ -puts "===========" -puts "OCC24019" -puts "===========" - -########################################## -# Voxel_FastConverter: filleng problem -########################################## - -OCC24019 [locate_data_file bug24019_boxes5.brep] diff --git a/tests/bugs/vis/bug24051 b/tests/bugs/vis/bug24051 deleted file mode 100644 index f8c3ffc4c5..0000000000 --- a/tests/bugs/vis/bug24051 +++ /dev/null @@ -1,9 +0,0 @@ -puts "============" -puts "OCC24051" -puts "============" -puts "" -####################################################################################### -# Voxel_FastConverter::Convert / ConvertUsingSAT - problems in multithreaded scenario -####################################################################################### - -OCC24051 diff --git a/tests/v3d/grids.list b/tests/v3d/grids.list index 6603b373a4..2c20c13f5e 100644 --- a/tests/v3d/grids.list +++ b/tests/v3d/grids.list @@ -9,7 +9,6 @@ 009 vertex_wire 010 wire 011 wire_solid -012 voxel 013 glsl 014 raytrace 015 materials diff --git a/tests/v3d/voxel/A1 b/tests/v3d/voxel/A1 deleted file mode 100644 index c1ea8fcb4e..0000000000 --- a/tests/v3d/voxel/A1 +++ /dev/null @@ -1 +0,0 @@ -voxelboolds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A2 b/tests/v3d/voxel/A2 deleted file mode 100644 index 3862b61d63..0000000000 --- a/tests/v3d/voxel/A2 +++ /dev/null @@ -1 +0,0 @@ -voxelcolords -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A3 b/tests/v3d/voxel/A3 deleted file mode 100644 index 088d19451c..0000000000 --- a/tests/v3d/voxel/A3 +++ /dev/null @@ -1 +0,0 @@ -voxelfloatds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A4 b/tests/v3d/voxel/A4 deleted file mode 100644 index 44286960f4..0000000000 --- a/tests/v3d/voxel/A4 +++ /dev/null @@ -1 +0,0 @@ -voxeloctboolds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A5 b/tests/v3d/voxel/A5 deleted file mode 100644 index 6284750586..0000000000 --- a/tests/v3d/voxel/A5 +++ /dev/null @@ -1 +0,0 @@ -voxelroctboolds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A6 b/tests/v3d/voxel/A6 deleted file mode 100644 index 0b06845350..0000000000 --- a/tests/v3d/voxel/A6 +++ /dev/null @@ -1 +0,0 @@ -voxelfuseboolds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A7 b/tests/v3d/voxel/A7 deleted file mode 100644 index c1989bec1c..0000000000 --- a/tests/v3d/voxel/A7 +++ /dev/null @@ -1 +0,0 @@ -voxelfusecolords -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A8 b/tests/v3d/voxel/A8 deleted file mode 100644 index 191bebe4e4..0000000000 --- a/tests/v3d/voxel/A8 +++ /dev/null @@ -1 +0,0 @@ -voxelfusefloatds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/A9 b/tests/v3d/voxel/A9 deleted file mode 100644 index 87f668d864..0000000000 --- a/tests/v3d/voxel/A9 +++ /dev/null @@ -1 +0,0 @@ -voxelcutboolds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/B1 b/tests/v3d/voxel/B1 deleted file mode 100644 index 9d6372d197..0000000000 --- a/tests/v3d/voxel/B1 +++ /dev/null @@ -1 +0,0 @@ -voxelcutcolords -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/B2 b/tests/v3d/voxel/B2 deleted file mode 100644 index a0914c38d4..0000000000 --- a/tests/v3d/voxel/B2 +++ /dev/null @@ -1 +0,0 @@ -voxelcutfloatds -5 -5 -5 10 10 10 10 10 10 diff --git a/tests/v3d/voxel/B3 b/tests/v3d/voxel/B3 deleted file mode 100644 index 958d733630..0000000000 --- a/tests/v3d/voxel/B3 +++ /dev/null @@ -1,9 +0,0 @@ -psphere s 100.0 -voxelbooldsconvert s 100 100 100 1.0 0 1 0 0 -voxelbooldsconvert s 100 100 100 1.0 1 1 0 0 -voxelbooldsconvert s 100 100 100 1.0 0 1 1 0 -voxelbooldsconvert s 100 100 100 1.0 1 1 1 0 -voxelbooldsconvert s 100 100 100 1.0 0 2 1 0 -voxelbooldsconvert s 100 100 100 1.0 1 2 1 0 -voxelbooldsconvert s 100 100 100 1.0 0 2 1 1 -voxelbooldsconvert s 100 100 100 1.0 1 2 1 2 diff --git a/tests/v3d/voxel/begin b/tests/v3d/voxel/begin deleted file mode 100644 index 6cabd388d9..0000000000 --- a/tests/v3d/voxel/begin +++ /dev/null @@ -1 +0,0 @@ -vinit View1 \ No newline at end of file