0026741: Problem with building samples and demo
[occt.git] / src / Voxel / Voxel_FastConverter.hxx
CommitLineData
42cf5bc1 1// Created on: 2008-05-30
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_FastConverter_HeaderFile
17#define _Voxel_FastConverter_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_DefineAlloc.hxx>
21#include <Standard_Handle.hxx>
22
23#include <TopoDS_Shape.hxx>
24#include <Standard_Address.hxx>
25#include <Standard_Real.hxx>
26#include <Standard_Integer.hxx>
27#include <Standard_Boolean.hxx>
28#include <Standard_Byte.hxx>
29class TopoDS_Shape;
30class Voxel_BoolDS;
31class Voxel_ColorDS;
32class Voxel_ROctBoolDS;
33class gp_Pnt;
34class gp_Pln;
35
36
37//! Converts a shape to voxel representation.
38//! It does it fast, but with less precision.
39//! Also, it doesn't fill-in volumic part of the shape.
40class Voxel_FastConverter
41{
42public:
43
44 DEFINE_STANDARD_ALLOC
45
46
47 //! A constructor for conversion of a shape into a cube of boolean voxels.
48 //! It allocates the voxels in memory.
49 //! "nbthreads" defines the number of threads used to convert the shape.
50 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);
51
52 //! A constructor for conversion of a shape into a cube of colored voxels.
53 //! It allocates the voxels in memory.
54 //! "nbthreads" defines the number of threads used to convert the shape.
55 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);
56
57 //! A constructor for conversion of a shape into a cube of boolean voxels
58 //! split into 8 sub-voxels recursively.
59 //! It allocates the voxels in memory.
60 //! "nbthreads" defines the number of threads used to convert the shape.
61 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);
62
63 //! Converts a shape into a voxel representation.
64 //! It sets to 0 the outside volume of the shape and
65 //! 1 for surfacic part of the shape.
66 //! "ithread" is the index of the thread for current call of ::Convert().
67 //! Start numeration of "ithread" with 1, please.
68 Standard_EXPORT Standard_Boolean Convert (Standard_Integer& progress, const Standard_Integer ithread = 1);
69
70 //! Converts a shape into a voxel representation using separating axis theorem.
71 //! It sets to 0 the outside volume of the shape and
72 //! 1 for surfacic part of the shape.
73 //! "ithread" is the index of the thread for current call of ::Convert().
74 //! Start numeration of "ithread" with 1, please.
75 Standard_EXPORT Standard_Boolean ConvertUsingSAT (Standard_Integer& progress, const Standard_Integer ithread = 1);
76
77 //! Fills-in volume of the shape by a value.
78 Standard_EXPORT Standard_Boolean FillInVolume (const Standard_Byte inner, const Standard_Integer ithread = 1);
79
80 //! Fills-in volume of the shape by a value.
81 //! Uses the topological information from the provided shape
82 //! to judge whether points are inside the shape or not
83 //! (only when processing vertical faces).
84 //! The inner value has to be positive.
85 Standard_EXPORT Standard_Boolean FillInVolume (const Standard_Byte inner, const TopoDS_Shape& shape, const Standard_Integer ithread = 1);
86
87 //! A destructor.
88 Standard_EXPORT void Destroy();
89~Voxel_FastConverter()
90{
91 Destroy();
92}
93
94
95
96
97protected:
98
99
100
101
102
103private:
104
105
106 Standard_EXPORT void Init();
107
108 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;
109
110 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;
111
112 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;
113
114
115 TopoDS_Shape myShape;
116 Standard_Address myVoxels;
117 Standard_Real myDeflection;
118 Standard_Integer myIsBool;
119 Standard_Integer myNbX;
120 Standard_Integer myNbY;
121 Standard_Integer myNbZ;
122 Standard_Integer myNbThreads;
123 Standard_Integer myNbTriangles;
124 Standard_Boolean myUseExistingTriangulation;
125
126
127};
128
129
130
131
132
133
134
135#endif // _Voxel_FastConverter_HeaderFile