0026741: Problem with building samples and demo
[occt.git] / src / Voxel / Voxel_ROctBoolDS.hxx
1 // Created on: 2008-09-01
2 // Created by: Vladislav ROMASHKO
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Voxel_ROctBoolDS_HeaderFile
17 #define _Voxel_ROctBoolDS_HeaderFile
18
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22
23 #include <Voxel_DS.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Boolean.hxx>
27
28
29 //! A 3D voxel model keeping a boolean flag (1 or 0)
30 //! value for each voxel, and having an opportunity to split each voxel
31 //! into 8 sub-voxels recursively.
32 class Voxel_ROctBoolDS  : public Voxel_DS
33 {
34 public:
35
36   DEFINE_STANDARD_ALLOC
37
38   
39   //! An empty constructor.
40   Standard_EXPORT Voxel_ROctBoolDS();
41   
42   //! A constructor initializing the voxel model.
43   //! (x, y, z) - the start point of the box.
44   //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system.
45   //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
46   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);
47   
48   //! Initialization of the voxel model.
49   //! (x, y, z) - the start point of the box.
50   //! (x_len, y_len, z_len) - lengths in x, y and z directions along axes of a co-ordinate system.
51   //! (nb_x, nb_y, nb_z) - number of splits (voxels) along x, y and z directions.
52   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;
53   
54   //! A destructor of the voxel model.
55   Standard_EXPORT void Destroy();
56 ~Voxel_ROctBoolDS()
57 {
58   Destroy();
59 }
60   
61   //! The method sets all values equal to 0 (false) and
62   //! releases the memory.
63   Standard_EXPORT void SetZero();
64   
65   //! The method searches voxels with equal-value of sub-voxels
66   //! and removes them (remaining the value for the voxel).
67   Standard_EXPORT void OptimizeMemory();
68   
69   //! Defines a value for voxel with co-ordinates (ix, iy, iz).
70   //! If the voxel is split into 8 sub-voxels, the split disappears.
71   //! Initial state of the model is so that all voxels have value 0 (false),
72   //! and this data doesn't occupy memory.
73   //! Memory for data is allocating during setting non-zero values (true).
74   Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Boolean data);
75   
76   //! Defines a value for a sub-voxel of a voxel with co-ordinates (ix, iy, iz).
77   //! If the voxel is not split into 8 sub-voxels yet, this method splits the voxel.
78   //! Range of sub-voxels is 0 - 7.
79   Standard_EXPORT void Set (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1, const Standard_Boolean data);
80   
81   //! Defines a value for a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz).
82   //! If the voxel is not split into 8 sub-voxels yet, this method splits the voxel.
83   //! Range of sub-voxels is 0 - 7.
84   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);
85   
86   //! Returns true if the voxel is split into 8 sub-voxels.
87   Standard_EXPORT Standard_Boolean IsSplit (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const;
88   
89   //! Returns the deepness of splits of a voxel.
90   //! 0 - no splits (::IsSplit() being called would return false).
91   //! 1 - the voxel is split into 8 sub-voxels.
92   //! 2 - the voxels is split into 8 sub-voxels,
93   //! and each of the sub-voxels is split into 8 sub-sub-voxels.
94   //! 3 - ...
95   Standard_EXPORT Standard_Integer Deepness (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const;
96   
97   //! Returns the value of voxel with co-ordinates (ix, iy, iz).
98   //! Warning!: the returned value may not coincide with the value of its 8 sub-voxels.
99   //! Use the method ::IsSplit() to check whether a voxel has sub-voxels.
100   Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz) const;
101   
102   //! Returns the value of a sub-voxel of a voxel with co-ordinates (ix, iy, iz).
103   //! If the voxel is not split, it returns the value of the voxel.
104   //! Range of sub-voxels is 0 - 7.
105   Standard_EXPORT Standard_Boolean Get (const Standard_Integer ix, const Standard_Integer iy, const Standard_Integer iz, const Standard_Integer ioct1) const;
106   
107   //! Returns the value of a sub-voxel of a sub-voxel of a voxel with co-ordinates (ix, iy, iz).
108   //! If the voxel is not split, it returns the value of the voxel.
109   //! Range of sub-voxels is 0 - 7.
110   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;
111   
112   //! Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i).
113   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;
114   
115   //! Returns the center point of a sub-voxel with co-ordinates (ix, iy, iz, i, j).
116   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;
117
118
119
120
121 protected:
122
123
124
125
126
127 private:
128
129
130
131
132
133 };
134
135
136
137
138
139
140
141 #endif // _Voxel_ROctBoolDS_HeaderFile