0030480: Visualization - Clear of Select3D_SensitiveGroup does not update internal...
[occt.git] / src / ShapeFix / ShapeFix_Face.hxx
CommitLineData
42cf5bc1 1// Created on: 1998-06-03
2// Created by: data exchange team
3// Copyright (c) 1998-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _ShapeFix_Face_HeaderFile
18#define _ShapeFix_Face_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <TopoDS_Face.hxx>
24#include <TopoDS_Shape.hxx>
25#include <Standard_Boolean.hxx>
26#include <Standard_Integer.hxx>
27#include <ShapeFix_Root.hxx>
28#include <Standard_Real.hxx>
29#include <TopTools_DataMapOfShapeListOfShape.hxx>
30#include <TopTools_SequenceOfShape.hxx>
31#include <ShapeFix_DataMapOfShapeBox2d.hxx>
32#include <ShapeExtend_Status.hxx>
33class ShapeAnalysis_Surface;
34class ShapeFix_Wire;
42cf5bc1 35class Geom_Surface;
36class ShapeExtend_BasicMsgRegistrator;
37class TopoDS_Wire;
38class ShapeExtend_WireData;
39class TopoDS_Vertex;
40
9fd2d2c3 41// resolve name collisions with X11 headers
42#ifdef Status
43 #undef Status
44#endif
42cf5bc1 45
46class ShapeFix_Face;
47DEFINE_STANDARD_HANDLE(ShapeFix_Face, ShapeFix_Root)
48
49//! This operator allows to perform various fixes on face
50//! and its wires: fixes provided by ShapeFix_Wire,
51//! fixing orientation of wires, addition of natural bounds,
52//! fixing of missing seam edge,
53//! and detection and removal of null-area wires
54class ShapeFix_Face : public ShapeFix_Root
55{
56
57public:
58
59
60 //! Creates an empty tool
61 Standard_EXPORT ShapeFix_Face();
62
63 //! Creates a tool and loads a face
64 Standard_EXPORT ShapeFix_Face(const TopoDS_Face& face);
65
66 //! Sets all modes to default
67 Standard_EXPORT virtual void ClearModes();
68
69 //! Loads a whole face already created, with its wires, sense and
70 //! location
71 Standard_EXPORT void Init (const TopoDS_Face& face);
72
73 //! Starts the creation of the face
74 //! By default it will be FORWARD, or REVERSED if <fwd> is False
75 Standard_EXPORT void Init (const Handle(Geom_Surface)& surf, const Standard_Real preci, const Standard_Boolean fwd = Standard_True);
76
77 //! Starts the creation of the face
78 //! By default it will be FORWARD, or REVERSED if <fwd> is False
79 Standard_EXPORT void Init (const Handle(ShapeAnalysis_Surface)& surf, const Standard_Real preci, const Standard_Boolean fwd = Standard_True);
80
81 //! Sets message registrator
82 Standard_EXPORT virtual void SetMsgRegistrator (const Handle(ShapeExtend_BasicMsgRegistrator)& msgreg) Standard_OVERRIDE;
83
84 //! Sets basic precision value (also to FixWireTool)
85 Standard_EXPORT virtual void SetPrecision (const Standard_Real preci) Standard_OVERRIDE;
86
87 //! Sets minimal allowed tolerance (also to FixWireTool)
88 Standard_EXPORT virtual void SetMinTolerance (const Standard_Real mintol) Standard_OVERRIDE;
89
90 //! Sets maximal allowed tolerance (also to FixWireTool)
91 Standard_EXPORT virtual void SetMaxTolerance (const Standard_Real maxtol) Standard_OVERRIDE;
92
93 //! Returns (modifiable) the mode for applying fixes of
94 //! ShapeFix_Wire, by default True.
95 Standard_Integer& FixWireMode();
96
97 //! Returns (modifiable) the fix orientation mode, by default
98 //! True. If True, wires oriented to border limited square.
99 Standard_Integer& FixOrientationMode();
100
101 //! Returns (modifiable) the add natural bound mode.
102 //! If true, natural boundary is added on faces that miss them.
103 //! Default is False for faces with single wire (they are
104 //! handled by FixOrientation in that case) and True for others.
105 Standard_Integer& FixAddNaturalBoundMode();
106
107 //! Returns (modifiable) the fix missing seam mode, by default
108 //! True. If True, tries to insert seam is missed.
109 Standard_Integer& FixMissingSeamMode();
110
111 //! Returns (modifiable) the fix small area wire mode, by default
112 //! False. If True, drops small wires.
113 Standard_Integer& FixSmallAreaWireMode();
114
115 //! Returns (modifiable) the remove face with small area, by default
116 //! False. If True, drops faces with small outer wires.
117 Standard_Integer& RemoveSmallAreaFaceMode();
118
119 //! Returns (modifiable) the fix intersecting wires mode
120 //! by default True.
121 Standard_Integer& FixIntersectingWiresMode();
122
123 //! Returns (modifiable) the fix loop wires mode
124 //! by default True.
125 Standard_Integer& FixLoopWiresMode();
126
127 //! Returns (modifiable) the fix split face mode
128 //! by default True.
129 Standard_Integer& FixSplitFaceMode();
130
131 //! Returns (modifiable) the auto-correct precision mode
132 //! by default False.
133 Standard_Integer& AutoCorrectPrecisionMode();
134
135 //! Returns (modifiable) the activation flag for periodic
136 //! degenerated fix. False by default.
137 Standard_Integer& FixPeriodicDegeneratedMode();
138
139 //! Returns a face which corresponds to the current state
140 //! Warning: The finally produced face may be another one ... but with the
141 //! same support
142 TopoDS_Face Face() const;
143
144 //! Returns resulting shape (Face or Shell if splitted)
145 //! To be used instead of Face() if FixMissingSeam involved
146 TopoDS_Shape Result() const;
147
148 //! Add a wire to current face using BRep_Builder.
149 //! Wire is added without taking into account orientation of face
150 //! (as if face were FORWARD).
151 Standard_EXPORT void Add (const TopoDS_Wire& wire);
152
153 //! Performs all the fixes, depending on modes
154 //! Function Status returns the status of last call to Perform()
155 //! ShapeExtend_OK : face was OK, nothing done
156 //! ShapeExtend_DONE1: some wires are fixed
157 //! ShapeExtend_DONE2: orientation of wires fixed
158 //! ShapeExtend_DONE3: missing seam added
159 //! ShapeExtend_DONE4: small area wire removed
160 //! ShapeExtend_DONE5: natural bounds added
161 //! ShapeExtend_FAIL1: some fails during fixing wires
162 //! ShapeExtend_FAIL2: cannot fix orientation of wires
163 //! ShapeExtend_FAIL3: cannot add missing seam
164 //! ShapeExtend_FAIL4: cannot remove small area wire
165 Standard_EXPORT Standard_Boolean Perform();
166
167 //! Fixes orientation of wires on the face
168 //! It tries to make all wires lie outside all others (according
169 //! to orientation) by reversing orientation of some of them.
170 //! If face lying on sphere or torus has single wire and
171 //! AddNaturalBoundMode is True, that wire is not reversed in
172 //! any case (supposing that natural bound will be added).
173 //! Returns True if wires were reversed
174 Standard_EXPORT Standard_Boolean FixOrientation();
175
176 //! Fixes orientation of wires on the face
177 //! It tries to make all wires lie outside all others (according
178 //! to orientation) by reversing orientation of some of them.
179 //! If face lying on sphere or torus has single wire and
180 //! AddNaturalBoundMode is True, that wire is not reversed in
181 //! any case (supposing that natural bound will be added).
182 //! Returns True if wires were reversed
183 //! OutWires return information about out wires + list of
184 //! internal wires for each (for performing split face).
185 Standard_EXPORT Standard_Boolean FixOrientation (TopTools_DataMapOfShapeListOfShape& MapWires);
186
187 //! Adds natural boundary on face if it is missing.
188 //! Two cases are supported:
189 //! - face has no wires
190 //! - face lies on geometrically double-closed surface
191 //! (sphere or torus) and none of wires is left-oriented
192 //! Returns True if natural boundary was added
193 Standard_EXPORT Standard_Boolean FixAddNaturalBound();
194
195 //! Detects and fixes the special case when face on a closed
196 //! surface is given by two wires closed in 3d but with gap in 2d.
197 //! In that case it creates a new wire from the two, and adds a
198 //! missing seam edge
199 //! Returns True if missing seam was added
200 Standard_EXPORT Standard_Boolean FixMissingSeam();
201
202 //! Detects wires with small area (that is less than
203 //! 100*Precision::PConfusion(). Removes these wires if they are internal.
204 //! Returns : True if at least one small wire removed,
205 //! False if does nothing.
206 Standard_EXPORT Standard_Boolean FixSmallAreaWire (const Standard_Boolean theIsRemoveSmallFace);
207
208 //! Detects if wire has a loop and fixes this situation by splitting on the few parts.
209 //! if wire has a loops and it was splitted Status was set to value ShapeExtend_DONE6.
210 Standard_EXPORT Standard_Boolean FixLoopWire (TopTools_SequenceOfShape& aResWires);
211
212 //! Detects and fixes the special case when face has more than one wire
213 //! and this wires have intersection point
214 Standard_EXPORT Standard_Boolean FixIntersectingWires();
215
216 //! If wire contains two coincidence edges it must be removed
217 //! Queries on status after Perform()
218 Standard_EXPORT Standard_Boolean FixWiresTwoCoincEdges();
219
220 //! Split face if there are more than one out wire
221 //! using inrormation after FixOrientation()
222 Standard_EXPORT Standard_Boolean FixSplitFace (const TopTools_DataMapOfShapeListOfShape& MapWires);
223
224 //! Fixes topology for a specific case when face is composed
225 //! by a single wire belting a periodic surface. In that case
226 //! a degenerated edge is reconstructed in the degenerated pole
227 //! of the surface. Initial wire gets consistent orientation.
228 //! Must be used in couple and before FixMissingSeam routine
229 Standard_EXPORT Standard_Boolean FixPeriodicDegenerated();
230
231 //! Returns the status of last call to Perform()
232 //! ShapeExtend_OK : face was OK, nothing done
233 //! ShapeExtend_DONE1: some wires are fixed
234 //! ShapeExtend_DONE2: orientation of wires fixed
235 //! ShapeExtend_DONE3: missing seam added
236 //! ShapeExtend_DONE4: small area wire removed
237 //! ShapeExtend_DONE5: natural bounds added
238 //! ShapeExtend_DONE8: face may be splited
239 //! ShapeExtend_FAIL1: some fails during fixing wires
240 //! ShapeExtend_FAIL2: cannot fix orientation of wires
241 //! ShapeExtend_FAIL3: cannot add missing seam
242 //! ShapeExtend_FAIL4: cannot remove small area wire
243 Standard_Boolean Status (const ShapeExtend_Status status) const;
244
245 //! Returns tool for fixing wires.
246 Handle(ShapeFix_Wire) FixWireTool();
247
248
249
250
92efcf78 251 DEFINE_STANDARD_RTTIEXT(ShapeFix_Face,ShapeFix_Root)
42cf5bc1 252
253protected:
254
255
256 Handle(ShapeAnalysis_Surface) mySurf;
257 TopoDS_Face myFace;
258 TopoDS_Shape myResult;
259 Handle(ShapeFix_Wire) myFixWire;
260 Standard_Boolean myFwd;
261 Standard_Integer myStatus;
262
263
264private:
265
266
267 Standard_EXPORT Standard_Boolean SplitEdge (const Handle(ShapeExtend_WireData)& sewd, const Standard_Integer num, const Standard_Real param, const TopoDS_Vertex& vert, const Standard_Real preci, ShapeFix_DataMapOfShapeBox2d& boxes);
268
269 Standard_EXPORT Standard_Boolean SplitEdge (const Handle(ShapeExtend_WireData)& sewd, const Standard_Integer num, const Standard_Real param1, const Standard_Real param2, const TopoDS_Vertex& vert, const Standard_Real preci, ShapeFix_DataMapOfShapeBox2d& boxes);
270
271 Standard_Integer myFixWireMode;
272 Standard_Integer myFixOrientationMode;
273 Standard_Integer myFixAddNaturalBoundMode;
274 Standard_Integer myFixMissingSeamMode;
275 Standard_Integer myFixSmallAreaWireMode;
276 Standard_Integer myRemoveSmallAreaFaceMode;
277 Standard_Integer myFixLoopWiresMode;
278 Standard_Integer myFixIntersectingWiresMode;
279 Standard_Integer myFixSplitFaceMode;
280 Standard_Integer myAutoCorrectPrecisionMode;
281 Standard_Integer myFixPeriodicDegenerated;
282
283
284};
285
286
287#include <ShapeFix_Face.lxx>
288
289
290
291
292
293#endif // _ShapeFix_Face_HeaderFile