summaryrefslogtreecommitdiff
path: root/inc/Voxel_FastConverter.hxx
blob: 8f718d4172fd07aea0ae13ac69934a718763a2ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _Voxel_FastConverter_HeaderFile
#define _Voxel_FastConverter_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _Standard_Address_HeaderFile
#include <Standard_Address.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _Standard_Byte_HeaderFile
#include <Standard_Byte.hxx>
#endif
class TopoDS_Shape;
class Voxel_BoolDS;
class Voxel_ColorDS;
class Voxel_ROctBoolDS;
class gp_Pnt;
class gp_Pln;


//! Converts a shape to voxel representation. <br>
//!          It does it fast, but with less precision. <br>
//!          Also, it doesn't fill-in volumic part of the shape. <br>
class Voxel_FastConverter  {
public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! A constructor for conversion of a shape into a cube of boolean voxels. <br>
//!          It allocates the voxels in memory. <br>
//!          "nbthreads" defines the number of threads used to convert the shape. <br>
  Standard_EXPORT   Voxel_FastConverter(const TopoDS_Shape& shape,Voxel_BoolDS& voxels,const Standard_Real delfection = 0.1,const Standard_Integer nbx = 10,const Standard_Integer nby = 10,const Standard_Integer nbz = 10,const Standard_Integer nbthreads = 1);
  //! A constructor for conversion of a shape into a cube of colored voxels. <br>
//!          It allocates the voxels in memory. <br>
//!          "nbthreads" defines the number of threads used to convert the shape. <br>
  Standard_EXPORT   Voxel_FastConverter(const TopoDS_Shape& shape,Voxel_ColorDS& voxels,const Standard_Real delfection = 0.1,const Standard_Integer nbx = 10,const Standard_Integer nby = 10,const Standard_Integer nbz = 10,const Standard_Integer nbthreads = 1);
  //! A constructor for conversion of a shape into a cube of boolean voxels <br>
//!          split into 8 sub-voxels recursively. <br>
//!          It allocates the voxels in memory. <br>
//!          "nbthreads" defines the number of threads used to convert the shape. <br>
  Standard_EXPORT   Voxel_FastConverter(const TopoDS_Shape& shape,Voxel_ROctBoolDS& voxels,const Standard_Real delfection = 0.1,const Standard_Integer nbx = 10,const Standard_Integer nby = 10,const Standard_Integer nbz = 10,const Standard_Integer nbthreads = 1);
  //! Converts a shape into a voxel representation. <br>
//!          It sets to 0 the outside volume of the shape and <br>
//!          1 for surfacic part of the shape. <br>
//!          "ithread" is the index of the thread for current call of ::Convert(). <br>
//!          Start numeration of "ithread" with 1, please. <br>
  Standard_EXPORT     Standard_Boolean Convert(Standard_Integer& progress,const Standard_Integer ithread = 1) ;
  //! Fills-in volume of the shape by a value. <br>
  Standard_EXPORT     Standard_Boolean FillInVolume(const Standard_Byte inner,const Standard_Integer ithread = 1) ;
  //! A destructor. <br>
  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;


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;


};





// other Inline functions and methods (like "C++: function call" methods)


#endif