1 // Created on: 1992-08-28
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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 _BRepTools_HeaderFile
18 #define _BRepTools_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_DefineAlloc.hxx>
22 #include <Standard_Handle.hxx>
24 #include <Standard_Real.hxx>
25 #include <Standard_Boolean.hxx>
26 #include <TopTools_IndexedMapOfShape.hxx>
27 #include <Standard_OStream.hxx>
28 #include <Standard_IStream.hxx>
29 #include <Standard_CString.hxx>
31 #include <Message_ProgressIndicator.hxx>
40 class TopoDS_CompSolid;
41 class TopoDS_Compound;
43 class Message_ProgressIndicator;
45 class BRepTools_WireExplorer;
46 class BRepTools_Modification;
47 class BRepTools_Modifier;
48 class BRepTools_TrsfModification;
49 class BRepTools_NurbsConvertModification;
50 class BRepTools_GTrsfModification;
51 class BRepTools_Substitution;
52 class BRepTools_Quilt;
53 class BRepTools_ShapeSet;
54 class BRepTools_ReShape;
60 //! The BRepTools package provides utilities for BRep
63 //! * WireExplorer : A tool to explore the topology of
64 //! a wire in the order of the edges.
66 //! * ShapeSet : Tools used for dumping, writing and
69 //! * UVBounds : Methods to compute the limits of the
70 //! boundary of a face, a wire or an edge in the
71 //! parametric space of a face.
73 //! * Update : Methods to call when a topology has
74 //! been created to compute all missing data.
76 //! * UpdateFaceUVPoints: Method to update the UV points
77 //! stored with the edges on a face.
79 //! * Compare : Method to compare two vertices.
81 //! * Compare : Method to compare two edges.
83 //! * OuterWire : A method to find the outer wire of a
86 //! * Map3DEdges : A method to map all the 3D Edges of
89 //! * Dump : A method to dump a BRep object.
97 //! Returns in UMin, UMax, VMin, VMax the bounding
98 //! values in the parametric space of F.
99 Standard_EXPORT static void UVBounds (const TopoDS_Face& F, Standard_Real& UMin, Standard_Real& UMax, Standard_Real& VMin, Standard_Real& VMax);
101 //! Returns in UMin, UMax, VMin, VMax the bounding
102 //! values of the wire in the parametric space of F.
103 Standard_EXPORT static void UVBounds (const TopoDS_Face& F, const TopoDS_Wire& W, Standard_Real& UMin, Standard_Real& UMax, Standard_Real& VMin, Standard_Real& VMax);
105 //! Returns in UMin, UMax, VMin, VMax the bounding
106 //! values of the edge in the parametric space of F.
107 Standard_EXPORT static void UVBounds (const TopoDS_Face& F, const TopoDS_Edge& E, Standard_Real& UMin, Standard_Real& UMax, Standard_Real& VMin, Standard_Real& VMax);
109 //! Adds to the box <B> the bounding values in the
110 //! parametric space of F.
111 Standard_EXPORT static void AddUVBounds (const TopoDS_Face& F, Bnd_Box2d& B);
113 //! Adds to the box <B> the bounding values of the
114 //! wire in the parametric space of F.
115 Standard_EXPORT static void AddUVBounds (const TopoDS_Face& F, const TopoDS_Wire& W, Bnd_Box2d& B);
117 //! Adds to the box <B> the bounding values of the
118 //! edge in the parametric space of F.
119 Standard_EXPORT static void AddUVBounds (const TopoDS_Face& F, const TopoDS_Edge& E, Bnd_Box2d& B);
121 //! Update a vertex (nothing is done)
122 Standard_EXPORT static void Update (const TopoDS_Vertex& V);
124 //! Update an edge, compute 2d bounding boxes.
125 Standard_EXPORT static void Update (const TopoDS_Edge& E);
127 //! Update a wire (nothing is done)
128 Standard_EXPORT static void Update (const TopoDS_Wire& W);
130 //! Update a Face, update UV points.
131 Standard_EXPORT static void Update (const TopoDS_Face& F);
133 //! Update a shell (nothing is done)
134 Standard_EXPORT static void Update (const TopoDS_Shell& S);
136 //! Update a solid (nothing is done)
137 Standard_EXPORT static void Update (const TopoDS_Solid& S);
139 //! Update a composite solid (nothing is done)
140 Standard_EXPORT static void Update (const TopoDS_CompSolid& C);
142 //! Update a compound (nothing is done)
143 Standard_EXPORT static void Update (const TopoDS_Compound& C);
145 //! Update a shape, call the corect update.
146 Standard_EXPORT static void Update (const TopoDS_Shape& S);
148 //! For each edge of the face <F> reset the UV points
149 //! to the bounding points of the parametric curve of the
150 //! edge on the face.
151 Standard_EXPORT static void UpdateFaceUVPoints (const TopoDS_Face& theF);
153 //! Removes all cashed polygonal representation of the shape,
154 //! i.e. the triangulations of the faces of <S> and polygons on
155 //! triangulations and polygons 3d of the edges.
156 //! In case polygonal representation is the only available representation
157 //! for the shape (shape does not have geometry) it is not removed.
158 Standard_EXPORT static void Clean (const TopoDS_Shape& S);
160 //! Removes geometry (curves and surfaces) from all edges and faces of the shape
161 Standard_EXPORT static void CleanGeometry(const TopoDS_Shape& theShape);
163 //! Removes all the pcurves of the edges of <S> that
164 //! refer to surfaces not belonging to any face of <S>
165 Standard_EXPORT static void RemoveUnusedPCurves (const TopoDS_Shape& S);
167 //! Verifies that each Face from the shape has got a triangulation with a deflection smaller or equal to specified one
168 //! and the Edges a discretization on this triangulation.
169 //! @param theShape [in] shape to verify
170 //! @param theLinDefl [in] maximum allowed linear deflection
171 //! @param theToCheckFreeEdges [in] if TRUE, then free Edges are required to have 3D polygon
172 //! @return FALSE if input Shape contains Faces without triangulation,
173 //! or that triangulation has worse (greater) deflection than specified one,
174 //! or Edges in Shape lack polygons on triangulation
175 //! or free Edges in Shape lack 3D polygons
176 Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& theShape,
177 const Standard_Real theLinDefl,
178 const Standard_Boolean theToCheckFreeEdges = Standard_False);
180 //! Returns True if the distance between the two
181 //! vertices is lower than their tolerance.
182 Standard_EXPORT static Standard_Boolean Compare (const TopoDS_Vertex& V1, const TopoDS_Vertex& V2);
184 //! Returns True if the distance between the two
185 //! edges is lower than their tolerance.
186 Standard_EXPORT static Standard_Boolean Compare (const TopoDS_Edge& E1, const TopoDS_Edge& E2);
188 //! Returns the outer most wire of <F>. Returns a Null
189 //! wire if <F> has no wires.
190 Standard_EXPORT static TopoDS_Wire OuterWire (const TopoDS_Face& F);
192 //! Stores in the map <M> all the 3D topology edges
194 Standard_EXPORT static void Map3DEdges (const TopoDS_Shape& S, TopTools_IndexedMapOfShape& M);
196 //! Verifies that the edge <E> is found two times on
197 //! the face <F> before calling BRep_Tool::IsClosed.
198 Standard_EXPORT static Standard_Boolean IsReallyClosed (const TopoDS_Edge& E, const TopoDS_Face& F);
200 //! Detect closedness of face in U and V directions
201 Standard_EXPORT static void DetectClosedness (const TopoDS_Face& theFace,
202 Standard_Boolean& theUclosed,
203 Standard_Boolean& theVclosed);
205 //! Dumps the topological structure and the geometry
206 //! of <Sh> on the stream <S>.
207 Standard_EXPORT static void Dump (const TopoDS_Shape& Sh, Standard_OStream& S);
209 //! Writes <Sh> on <S> in an ASCII format.
210 Standard_EXPORT static void Write (const TopoDS_Shape& Sh, Standard_OStream& S, const Handle(Message_ProgressIndicator)& PR = NULL);
212 //! Reads a Shape from <S> in returns it in <Sh>.
213 //! <B> is used to build the shape.
214 Standard_EXPORT static void Read (TopoDS_Shape& Sh, Standard_IStream& S, const BRep_Builder& B, const Handle(Message_ProgressIndicator)& PR = NULL);
216 //! Writes <Sh> in <File>.
217 Standard_EXPORT static Standard_Boolean Write (const TopoDS_Shape& Sh, const Standard_CString File, const Handle(Message_ProgressIndicator)& PR = NULL);
219 //! Reads a Shape from <File>, returns it in <Sh>.
220 //! <B> is used to build the shape.
221 Standard_EXPORT static Standard_Boolean Read (TopoDS_Shape& Sh, const Standard_CString File, const BRep_Builder& B, const Handle(Message_ProgressIndicator)& PR = NULL);
223 //! Evals real tolerance of edge <theE>.
224 //! <theC3d>, <theC2d>, <theS>, <theF>, <theL> are
225 //! correspondently 3d curve of edge, 2d curve on surface <theS> and
227 //! If calculated tolerance is more then current edge tolerance, edge is updated.
228 //! Method returns actual tolerance of edge
229 Standard_EXPORT static Standard_Real EvalAndUpdateTol(const TopoDS_Edge& theE,
230 const Handle(Geom_Curve)& theC3d,
231 const Handle(Geom2d_Curve) theC2d,
232 const Handle(Geom_Surface)& theS,
233 const Standard_Real theF,
234 const Standard_Real theL);
236 //! returns the cumul of the orientation of <Edge>
237 //! and thc containing wire in <Face>
238 Standard_EXPORT static TopAbs_Orientation OriEdgeInFace(const TopoDS_Edge& theEdge,
239 const TopoDS_Face& theFace);
253 friend class BRepTools_WireExplorer;
254 friend class BRepTools_Modification;
255 friend class BRepTools_Modifier;
256 friend class BRepTools_TrsfModification;
257 friend class BRepTools_NurbsConvertModification;
258 friend class BRepTools_GTrsfModification;
259 friend class BRepTools_Substitution;
260 friend class BRepTools_Quilt;
261 friend class BRepTools_ShapeSet;
262 friend class BRepTools_ReShape;
272 #endif // _BRepTools_HeaderFile