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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _ShapeFix_Face_HeaderFile
18 #define _ShapeFix_Face_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
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>
33 class ShapeAnalysis_Surface;
37 class ShapeExtend_BasicMsgRegistrator;
39 class ShapeExtend_WireData;
44 DEFINE_STANDARD_HANDLE(ShapeFix_Face, ShapeFix_Root)
46 //! This operator allows to perform various fixes on face
47 //! and its wires: fixes provided by ShapeFix_Wire,
48 //! fixing orientation of wires, addition of natural bounds,
49 //! fixing of missing seam edge,
50 //! and detection and removal of null-area wires
51 class ShapeFix_Face : public ShapeFix_Root
57 //! Creates an empty tool
58 Standard_EXPORT ShapeFix_Face();
60 //! Creates a tool and loads a face
61 Standard_EXPORT ShapeFix_Face(const TopoDS_Face& face);
63 //! Sets all modes to default
64 Standard_EXPORT virtual void ClearModes();
66 //! Loads a whole face already created, with its wires, sense and
68 Standard_EXPORT void Init (const TopoDS_Face& face);
70 //! Starts the creation of the face
71 //! By default it will be FORWARD, or REVERSED if <fwd> is False
72 Standard_EXPORT void Init (const Handle(Geom_Surface)& surf, const Standard_Real preci, const Standard_Boolean fwd = Standard_True);
74 //! Starts the creation of the face
75 //! By default it will be FORWARD, or REVERSED if <fwd> is False
76 Standard_EXPORT void Init (const Handle(ShapeAnalysis_Surface)& surf, const Standard_Real preci, const Standard_Boolean fwd = Standard_True);
78 //! Sets message registrator
79 Standard_EXPORT virtual void SetMsgRegistrator (const Handle(ShapeExtend_BasicMsgRegistrator)& msgreg) Standard_OVERRIDE;
81 //! Sets basic precision value (also to FixWireTool)
82 Standard_EXPORT virtual void SetPrecision (const Standard_Real preci) Standard_OVERRIDE;
84 //! Sets minimal allowed tolerance (also to FixWireTool)
85 Standard_EXPORT virtual void SetMinTolerance (const Standard_Real mintol) Standard_OVERRIDE;
87 //! Sets maximal allowed tolerance (also to FixWireTool)
88 Standard_EXPORT virtual void SetMaxTolerance (const Standard_Real maxtol) Standard_OVERRIDE;
90 //! Returns (modifiable) the mode for applying fixes of
91 //! ShapeFix_Wire, by default True.
92 Standard_Integer& FixWireMode();
94 //! Returns (modifiable) the fix orientation mode, by default
95 //! True. If True, wires oriented to border limited square.
96 Standard_Integer& FixOrientationMode();
98 //! Returns (modifiable) the add natural bound mode.
99 //! If true, natural boundary is added on faces that miss them.
100 //! Default is False for faces with single wire (they are
101 //! handled by FixOrientation in that case) and True for others.
102 Standard_Integer& FixAddNaturalBoundMode();
104 //! Returns (modifiable) the fix missing seam mode, by default
105 //! True. If True, tries to insert seam is missed.
106 Standard_Integer& FixMissingSeamMode();
108 //! Returns (modifiable) the fix small area wire mode, by default
109 //! False. If True, drops small wires.
110 Standard_Integer& FixSmallAreaWireMode();
112 //! Returns (modifiable) the remove face with small area, by default
113 //! False. If True, drops faces with small outer wires.
114 Standard_Integer& RemoveSmallAreaFaceMode();
116 //! Returns (modifiable) the fix intersecting wires mode
118 Standard_Integer& FixIntersectingWiresMode();
120 //! Returns (modifiable) the fix loop wires mode
122 Standard_Integer& FixLoopWiresMode();
124 //! Returns (modifiable) the fix split face mode
126 Standard_Integer& FixSplitFaceMode();
128 //! Returns (modifiable) the auto-correct precision mode
129 //! by default False.
130 Standard_Integer& AutoCorrectPrecisionMode();
132 //! Returns (modifiable) the activation flag for periodic
133 //! degenerated fix. False by default.
134 Standard_Integer& FixPeriodicDegeneratedMode();
136 //! Returns a face which corresponds to the current state
137 //! Warning: The finally produced face may be another one ... but with the
139 TopoDS_Face Face() const;
141 //! Returns resulting shape (Face or Shell if splitted)
142 //! To be used instead of Face() if FixMissingSeam involved
143 TopoDS_Shape Result() const;
145 //! Add a wire to current face using BRep_Builder.
146 //! Wire is added without taking into account orientation of face
147 //! (as if face were FORWARD).
148 Standard_EXPORT void Add (const TopoDS_Wire& wire);
150 //! Performs all the fixes, depending on modes
151 //! Function Status returns the status of last call to Perform()
152 //! ShapeExtend_OK : face was OK, nothing done
153 //! ShapeExtend_DONE1: some wires are fixed
154 //! ShapeExtend_DONE2: orientation of wires fixed
155 //! ShapeExtend_DONE3: missing seam added
156 //! ShapeExtend_DONE4: small area wire removed
157 //! ShapeExtend_DONE5: natural bounds added
158 //! ShapeExtend_FAIL1: some fails during fixing wires
159 //! ShapeExtend_FAIL2: cannot fix orientation of wires
160 //! ShapeExtend_FAIL3: cannot add missing seam
161 //! ShapeExtend_FAIL4: cannot remove small area wire
162 Standard_EXPORT Standard_Boolean Perform();
164 //! Fixes orientation of wires on the face
165 //! It tries to make all wires lie outside all others (according
166 //! to orientation) by reversing orientation of some of them.
167 //! If face lying on sphere or torus has single wire and
168 //! AddNaturalBoundMode is True, that wire is not reversed in
169 //! any case (supposing that natural bound will be added).
170 //! Returns True if wires were reversed
171 Standard_EXPORT Standard_Boolean FixOrientation();
173 //! Fixes orientation of wires on the face
174 //! It tries to make all wires lie outside all others (according
175 //! to orientation) by reversing orientation of some of them.
176 //! If face lying on sphere or torus has single wire and
177 //! AddNaturalBoundMode is True, that wire is not reversed in
178 //! any case (supposing that natural bound will be added).
179 //! Returns True if wires were reversed
180 //! OutWires return information about out wires + list of
181 //! internal wires for each (for performing split face).
182 Standard_EXPORT Standard_Boolean FixOrientation (TopTools_DataMapOfShapeListOfShape& MapWires);
184 //! Adds natural boundary on face if it is missing.
185 //! Two cases are supported:
186 //! - face has no wires
187 //! - face lies on geometrically double-closed surface
188 //! (sphere or torus) and none of wires is left-oriented
189 //! Returns True if natural boundary was added
190 Standard_EXPORT Standard_Boolean FixAddNaturalBound();
192 //! Detects and fixes the special case when face on a closed
193 //! surface is given by two wires closed in 3d but with gap in 2d.
194 //! In that case it creates a new wire from the two, and adds a
195 //! missing seam edge
196 //! Returns True if missing seam was added
197 Standard_EXPORT Standard_Boolean FixMissingSeam();
199 //! Detects wires with small area (that is less than
200 //! 100*Precision::PConfusion(). Removes these wires if they are internal.
201 //! Returns : True if at least one small wire removed,
202 //! False if does nothing.
203 Standard_EXPORT Standard_Boolean FixSmallAreaWire (const Standard_Boolean theIsRemoveSmallFace);
205 //! Detects if wire has a loop and fixes this situation by splitting on the few parts.
206 //! if wire has a loops and it was splitted Status was set to value ShapeExtend_DONE6.
207 Standard_EXPORT Standard_Boolean FixLoopWire (TopTools_SequenceOfShape& aResWires);
209 //! Detects and fixes the special case when face has more than one wire
210 //! and this wires have intersection point
211 Standard_EXPORT Standard_Boolean FixIntersectingWires();
213 //! If wire contains two coincidence edges it must be removed
214 //! Queries on status after Perform()
215 Standard_EXPORT Standard_Boolean FixWiresTwoCoincEdges();
217 //! Split face if there are more than one out wire
218 //! using inrormation after FixOrientation()
219 Standard_EXPORT Standard_Boolean FixSplitFace (const TopTools_DataMapOfShapeListOfShape& MapWires);
221 //! Fixes topology for a specific case when face is composed
222 //! by a single wire belting a periodic surface. In that case
223 //! a degenerated edge is reconstructed in the degenerated pole
224 //! of the surface. Initial wire gets consistent orientation.
225 //! Must be used in couple and before FixMissingSeam routine
226 Standard_EXPORT Standard_Boolean FixPeriodicDegenerated();
228 //! Returns the status of last call to Perform()
229 //! ShapeExtend_OK : face was OK, nothing done
230 //! ShapeExtend_DONE1: some wires are fixed
231 //! ShapeExtend_DONE2: orientation of wires fixed
232 //! ShapeExtend_DONE3: missing seam added
233 //! ShapeExtend_DONE4: small area wire removed
234 //! ShapeExtend_DONE5: natural bounds added
235 //! ShapeExtend_DONE8: face may be splited
236 //! ShapeExtend_FAIL1: some fails during fixing wires
237 //! ShapeExtend_FAIL2: cannot fix orientation of wires
238 //! ShapeExtend_FAIL3: cannot add missing seam
239 //! ShapeExtend_FAIL4: cannot remove small area wire
240 Standard_Boolean Status (const ShapeExtend_Status status) const;
242 //! Returns tool for fixing wires.
243 Handle(ShapeFix_Wire) FixWireTool();
248 DEFINE_STANDARD_RTTIEXT(ShapeFix_Face,ShapeFix_Root)
253 Handle(ShapeAnalysis_Surface) mySurf;
255 TopoDS_Shape myResult;
256 Handle(ShapeFix_Wire) myFixWire;
257 Standard_Boolean myFwd;
258 Standard_Integer myStatus;
264 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);
266 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);
268 Standard_Integer myFixWireMode;
269 Standard_Integer myFixOrientationMode;
270 Standard_Integer myFixAddNaturalBoundMode;
271 Standard_Integer myFixMissingSeamMode;
272 Standard_Integer myFixSmallAreaWireMode;
273 Standard_Integer myRemoveSmallAreaFaceMode;
274 Standard_Integer myFixLoopWiresMode;
275 Standard_Integer myFixIntersectingWiresMode;
276 Standard_Integer myFixSplitFaceMode;
277 Standard_Integer myAutoCorrectPrecisionMode;
278 Standard_Integer myFixPeriodicDegenerated;
284 #include <ShapeFix_Face.lxx>
290 #endif // _ShapeFix_Face_HeaderFile