8013367c |
1 | // Created on: 2016-10-13 |
2 | // Created by: Alexander MALYSHEV |
3 | // Copyright (c) 1999-2016 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 _BRepOffset_MakeSimpleOffset_HeaderFile |
17 | #define _BRepOffset_MakeSimpleOffset_HeaderFile |
18 | |
19 | #include <BRepTools_Modifier.hxx> |
20 | #include <ShapeBuild_ReShape.hxx> |
21 | #include <NCollection_DataMap.hxx> |
22 | #include <Standard_Macro.hxx> |
23 | #include <Standard_Real.hxx> |
24 | #include <TCollection_AsciiString.hxx> |
25 | #include <TopoDS_Edge.hxx> |
26 | #include <TopoDS_Face.hxx> |
27 | #include <TopoDS_Vertex.hxx> |
28 | #include <TopoDS_Shape.hxx> |
29 | |
30 | |
31 | enum BRepOffsetSimple_Status |
32 | { |
33 | BRepOffsetSimple_OK, |
34 | BRepOffsetSimple_NullInputShape, |
35 | BRepOffsetSimple_ErrorOffsetComputation, |
36 | BRepOffsetSimple_ErrorWallFaceComputation, |
37 | BRepOffsetSimple_ErrorInvalidNbShells, |
38 | BRepOffsetSimple_ErrorNonClosedShell |
39 | }; |
40 | |
41 | //! This class represents simple offset algorithm itself. It builds simple offset without intersection. |
42 | //! Solid can be created using SetBuildSolidFlag method (set flag to true). By default shell will be constructed. |
43 | //! |
44 | //! Algorithm: |
45 | //! 1. Build source-image maps for vertices, edges and faces.BRepTools_Modification class will be used |
46 | //! to store this information. An image of a shared edge can be constructed from the corresponding edge |
47 | //! of the first iterated face. |
48 | //! 2. Run BRepTools_Modifier to obtain offset shape. |
49 | // 3. Ensure topological integrity of the output shape. |
50 | //! |
51 | //! Limitations: |
52 | //! According to the algorithm nature result depends on the smoothness of input data. Smooth (G1-continuity) input shape |
53 | //! will lead to the good result. |
54 | //! |
55 | //! The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing. |
56 | //! The tolerances have to grow in order to cover the gaps between the neighbor faces in the output. |
57 | //! It should be noted that the actual tolerance growth depends on the offset distance and the quality of |
58 | //! joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces) |
59 | //! will lead to good result. |
60 | class BRepOffset_MakeSimpleOffset |
61 | { |
62 | public: |
63 | |
64 | |
65 | //! Constructor. Does nothing. |
66 | Standard_EXPORT BRepOffset_MakeSimpleOffset(); |
67 | |
68 | //! Constructor. |
69 | Standard_EXPORT BRepOffset_MakeSimpleOffset(const TopoDS_Shape& theInputShape, |
70 | const Standard_Real theOffsetValue); |
71 | |
72 | //! Initialies shape for modifications. |
73 | Standard_EXPORT void Initialize(const TopoDS_Shape& theInputShape, |
74 | const Standard_Real theOffsetValue); |
75 | |
76 | //! Computes offset shape. |
77 | Standard_EXPORT void Perform(); |
78 | |
79 | //! Gets error message. |
80 | Standard_EXPORT TCollection_AsciiString GetErrorMessage() const; |
81 | |
82 | //! Gets error code. |
83 | BRepOffsetSimple_Status GetError() const { return myError; } |
84 | |
85 | // Inline methods. |
86 | //! Gets solid building flag. |
87 | Standard_Boolean GetBuildSolidFlag() const { return myIsBuildSolid; } |
88 | |
89 | //! Sets solid building flag. |
90 | void SetBuildSolidFlag(const Standard_Boolean theBuildFlag) { myIsBuildSolid = theBuildFlag; } |
91 | |
92 | //! Gets offset value. |
93 | Standard_Real GetOffsetValue() const { return myOffsetValue; } |
94 | |
95 | //! Sets offset value. |
96 | void SetOffsetValue(const Standard_Real theOffsetValue) { myOffsetValue = theOffsetValue; } |
97 | |
8574e329 |
98 | //! Gets tolerance (used for handling singularities). |
99 | Standard_Real GetTolerance() const { return myTolerance; } |
100 | |
101 | //! Sets tolerance (used for handling singularities). |
102 | void SetTolerance (const Standard_Real theValue) { myTolerance = theValue; } |
103 | |
8013367c |
104 | //! Gets done state. |
105 | Standard_Boolean IsDone() const { return myIsDone; } |
106 | |
107 | //! Returns result shape. |
108 | const TopoDS_Shape& GetResultShape() const { return myResShape; } |
109 | |
110 | //! Computes max safe offset value for the given tolerance. |
111 | Standard_Real GetSafeOffset(const Standard_Real theExpectedToler); |
112 | |
b81b237f |
113 | //! Returns result shape for the given one (if exists). |
8013367c |
114 | Standard_EXPORT const TopoDS_Shape Generated(const TopoDS_Shape& theShape) const; |
115 | |
b81b237f |
116 | //! Returns modified shape for the given one (if exists). |
8013367c |
117 | Standard_EXPORT const TopoDS_Shape Modified(const TopoDS_Shape& theShape) const; |
118 | |
119 | protected: |
120 | |
121 | //! Computes max angle in faces junction. |
122 | void ComputeMaxAngle(); |
123 | |
124 | //! Clears previous result. |
125 | void Clear(); |
126 | |
127 | private: |
128 | |
129 | //! Builds face on specified wall. |
130 | TopoDS_Face BuildWallFace(const TopoDS_Edge& theOrigEdge); |
131 | |
132 | //! Builds missing walls. |
133 | Standard_Boolean BuildMissingWalls(); |
134 | |
135 | // Input data. |
136 | |
137 | //! Input shape. |
138 | TopoDS_Shape myInputShape; |
139 | |
140 | //! Offset value. |
141 | Standard_Real myOffsetValue; |
142 | |
8574e329 |
143 | //! Tolerance (for singularities) |
144 | Standard_Real myTolerance; |
145 | |
8013367c |
146 | //! Solid building flag. True means solid construction. |
147 | Standard_Boolean myIsBuildSolid; |
148 | |
149 | // Internal data. |
150 | |
151 | //! Maximal angle in faces junction. This value helps to estimate result tolerance. |
152 | Standard_Real myMaxAngle; |
153 | |
154 | //! Error message. |
155 | BRepOffsetSimple_Status myError; |
156 | |
157 | //! Done state. |
158 | Standard_Boolean myIsDone; |
159 | |
160 | //! Map of vertex - wall edge. |
161 | //! Used to build shared edge between adjacent wall faces. |
162 | NCollection_DataMap<TopoDS_Vertex, TopoDS_Edge> myMapVE; |
163 | |
164 | //! Used for histrory support. |
165 | BRepTools_Modifier myBuilder; |
166 | |
167 | //! Used for history support. |
168 | Handle(ShapeBuild_ReShape) myReShape; |
169 | |
170 | // Output data. |
171 | |
172 | //! Result shape. |
173 | TopoDS_Shape myResShape; |
174 | |
175 | }; |
176 | |
177 | #endif // _BRepOffset_MakeSimpleOffset_HeaderFile |