0024013: Voxel_FastConverter is able to use existing triangulation
[occt.git] / src / Voxel / Voxel_FastConverter.cdl
1 -- Created on: 2008-05-30
2 -- Created by: Vladislav ROMASHKO
3 -- Copyright (c) 2008-2012 OPEN CASCADE SAS
4 --
5 -- The content of this file is subject to the Open CASCADE Technology Public
6 -- License Version 6.5 (the "License"). You may not use the content of this file
7 -- except in compliance with the License. Please obtain a copy of the License
8 -- at http://www.opencascade.org and read it completely before using this file.
9 --
10 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 --
13 -- The Original Code and all software distributed under the License is
14 -- distributed on an "AS IS" basis, without warranty of any kind, and the
15 -- Initial Developer hereby disclaims all such warranties, including without
16 -- limitation, any warranties of merchantability, fitness for a particular
17 -- purpose or non-infringement. Please see the License for the specific terms
18 -- and conditions governing the rights and limitations under the License.
19
20
21 class FastConverter from Voxel
22
23     ---Purpose: Converts a shape to voxel representation.
24     --          It does it fast, but with less precision.
25     --          Also, it doesn't fill-in volumic part of the shape.
26
27 uses
28
29     Pnt     from gp,
30     Pln     from gp,
31     Shape   from TopoDS,
32     BoolDS  from Voxel,
33     ColorDS from Voxel,
34     ROctBoolDS from Voxel
35
36 is
37
38     Create(shape  :     Shape   from TopoDS;
39            voxels : out BoolDS  from Voxel;
40            deflection : Real    from Standard = 0.1;
41            nbx    :     Integer from Standard = 10;
42            nby    :     Integer from Standard = 10;
43            nbz    :     Integer from Standard = 10;
44            nbthreads :  Integer from Standard = 1;
45            useExistingTriangulation : Boolean from Standard = Standard_False)
46     ---Purpose: A constructor for conversion of a shape into a cube of boolean voxels.
47     --          It allocates the voxels in memory.
48     --          "nbthreads" defines the number of threads used to convert the shape.
49     returns FastConverter from Voxel;
50
51     Create(shape  :     Shape   from TopoDS;
52            voxels : out ColorDS from Voxel;
53            deflection : Real    from Standard = 0.1;
54            nbx    :     Integer from Standard = 10;
55            nby    :     Integer from Standard = 10;
56            nbz    :     Integer from Standard = 10;
57            nbthreads :  Integer from Standard = 1;
58            useExistingTriangulation : Boolean from Standard = Standard_False)
59     ---Purpose: A constructor for conversion of a shape into a cube of colored voxels.
60     --          It allocates the voxels in memory.
61     --          "nbthreads" defines the number of threads used to convert the shape.
62     returns FastConverter from Voxel;
63
64     Create(shape  :     Shape   from TopoDS;
65            voxels : out ROctBoolDS from Voxel;
66            deflection : Real    from Standard = 0.1;
67            nbx    :     Integer from Standard = 10;
68            nby    :     Integer from Standard = 10;
69            nbz    :     Integer from Standard = 10;
70            nbthreads :  Integer from Standard = 1;
71            useExistingTriangulation : Boolean from Standard = Standard_False)
72     ---Purpose: A constructor for conversion of a shape into a cube of boolean voxels
73     --          split into 8 sub-voxels recursively.
74     --          It allocates the voxels in memory.
75     --          "nbthreads" defines the number of threads used to convert the shape.
76     returns FastConverter from Voxel;
77
78     Convert(me : in out;
79             progress : out Integer from Standard;
80             ithread : Integer from Standard = 1)
81     ---Purpose: Converts a shape into a voxel representation.
82     --          It sets to 0 the outside volume of the shape and
83     --          1 for surfacic part of the shape.
84     --          "ithread" is the index of the thread for current call of ::Convert().
85     --          Start numeration of "ithread" with 1, please.
86     returns Boolean from Standard;
87
88     FillInVolume(me : in out;
89                  inner : Byte from Standard;
90                  ithread : Integer from Standard = 1)
91     ---Purpose: Fills-in volume of the shape by a value.
92     returns Boolean from Standard;
93
94
95     ---Category: Private area
96     --           ============
97
98     Destroy(me : in out);
99     ---C++: alias ~
100     ---Purpose: A destructor.
101
102     Init(me : in out)
103     is private;
104
105     GetBndBox(me;
106               p1   : Pnt      from gp;
107               p2   : Pnt      from gp;
108               p3   : Pnt      from gp;
109               xmin : out Real from Standard;
110               ymin : out Real from Standard;
111               zmin : out Real from Standard;
112               xmax : out Real from Standard;
113               ymax : out Real from Standard;
114               zmax : out Real from Standard)
115     is private;
116
117     ComputeVoxelsNearTriangle(me;
118                               plane :     Pln           from gp;
119                               p1    :     Pnt           from gp;
120                               p2    :     Pnt           from gp;
121                               p3    :     Pnt           from gp;
122                               hdiag :     Real          from Standard;
123                               ixmin :     Integer       from Standard;
124                               iymin :     Integer       from Standard;
125                               izmin :     Integer       from Standard;
126                               ixmax :     Integer       from Standard;
127                               iymax :     Integer       from Standard;
128                               izmax :     Integer       from Standard)
129     is private;
130
131 fields
132
133     myShape       : Shape   from TopoDS;
134     myVoxels      : Address from Standard;
135     myDeflection  : Real    from Standard;
136     myIsBool      : Integer from Standard; -- 0 - ColorDS, 1 - BoolDS, 2 - ROctBoolDS
137     myNbX         : Integer from Standard;
138     myNbY         : Integer from Standard;
139     myNbZ         : Integer from Standard;
140     myNbThreads   : Integer from Standard;
141     myNbTriangles : Integer from Standard;
142     myUseExistingTriangulation : Boolean from Standard;
143
144 end FastConverter;