1 // Created on: 1993-12-15
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1993-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 _BRepLib_HeaderFile
18 #define _BRepLib_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 <GeomAbs_Shape.hxx>
27 #include <Standard_Integer.hxx>
28 #include <TopTools_ListOfShape.hxx>
29 #include <NCollection_List.hxx>
35 class BRepLib_Command;
36 class BRepLib_MakeShape;
37 class BRepLib_MakeVertex;
38 class BRepLib_MakeEdge;
39 class BRepLib_MakeEdge2d;
40 class BRepLib_MakePolygon;
41 class BRepLib_MakeFace;
42 class BRepLib_MakeWire;
43 class BRepLib_MakeShell;
44 class BRepLib_MakeSolid;
45 class BRepLib_FindSurface;
46 class BRepLib_FuseEdges;
47 class BRepLib_CheckCurveOnSurface;
48 class BRepTools_ReShape;
51 //! The BRepLib package provides general utilities for
54 //! * FindSurface : Class to compute a surface through
57 //! * Compute missing 3d curve on an edge.
66 //! Computes the max distance between edge
67 //! and its 2d representation on the face.
68 //! Sets the default precision. The current Precision
70 Standard_EXPORT static void Precision (const Standard_Real P);
72 //! Returns the default precision.
73 Standard_EXPORT static Standard_Real Precision();
75 //! Sets the current plane to P.
76 Standard_EXPORT static void Plane (const Handle(Geom_Plane)& P);
78 //! Returns the current plane.
79 Standard_EXPORT static const Handle(Geom_Plane)& Plane();
81 //! checks if the Edge is same range IGNORING
82 //! the same range flag of the edge
83 //! Confusion argument is to compare real numbers
84 //! idenpendently of any model space tolerance
85 Standard_EXPORT static Standard_Boolean CheckSameRange (const TopoDS_Edge& E, const Standard_Real Confusion = 1.0e-12);
87 //! will make all the curve representation have
88 //! the same range domain for the parameters.
89 //! This will IGNORE the same range flag value
91 //! If there is a 3D curve there it will the
92 //! range of that curve. If not the first curve representation
93 //! encountered in the list will give its range to
94 //! the all the other curves.
95 Standard_EXPORT static void SameRange (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5);
97 //! Computes the 3d curve for the edge <E> if it does
98 //! not exist. Returns True if the curve was computed
99 //! or existed. Returns False if there is no planar
100 //! pcurve or the computation failed.
101 //! <MaxSegment> >= 30 in approximation
102 Standard_EXPORT static Standard_Boolean BuildCurve3d (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5, const GeomAbs_Shape Continuity = GeomAbs_C1, const Standard_Integer MaxDegree = 14, const Standard_Integer MaxSegment = 0);
104 //! Computes the 3d curves for all the edges of <S>
105 //! return False if one of the computation failed.
106 //! <MaxSegment> >= 30 in approximation
107 Standard_EXPORT static Standard_Boolean BuildCurves3d (const TopoDS_Shape& S, const Standard_Real Tolerance, const GeomAbs_Shape Continuity = GeomAbs_C1, const Standard_Integer MaxDegree = 14, const Standard_Integer MaxSegment = 0);
109 //! Computes the 3d curves for all the edges of <S>
110 //! return False if one of the computation failed.
111 Standard_EXPORT static Standard_Boolean BuildCurves3d (const TopoDS_Shape& S);
113 //! Checks if the edge has a Tolerance smaller than -- --
114 //! -- -- MaxToleranceToCheck if so it will compute the
115 //! radius of -- the cylindrical pipe surface that
116 //! MinToleranceRequest is the minimum tolerance before it
117 //! is usefull to start testing. Usually it should be arround
119 //! contains all -- the curve represenation of the edge
120 //! returns True if the Edge tolerance had to be updated
121 Standard_EXPORT static Standard_Boolean UpdateEdgeTol (const TopoDS_Edge& E, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
123 //! -- Checks all the edges of the shape whose -- -- --
124 //! Tolerance is smaller than MaxToleranceToCheck --
125 //! Returns True if at least one edge was updated --
126 //! MinToleranceRequest is the minimum tolerance before
127 //! -- it -- is usefull to start testing. Usually it
128 //! should be arround -- 10e-5--
130 //! Warning :The method is very slow as it checks all.
131 //! Use only in interfaces or processing assimilate batch
132 Standard_EXPORT static Standard_Boolean UpdateEdgeTolerance (const TopoDS_Shape& S, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
134 //! Computes new 2d curve(s) for the edge <theEdge> to have
135 //! the same parameter as the 3d curve.
136 //! The algorithm is not done if the flag SameParameter
137 //! was True on the Edge.
138 Standard_EXPORT static void SameParameter (const TopoDS_Edge& theEdge, const Standard_Real Tolerance = 1.0e-5);
140 //! Computes new 2d curve(s) for the edge <theEdge> to have
141 //! the same parameter as the 3d curve.
142 //! The algorithm is not done if the flag SameParameter
143 //! was True on the Edge.<br>
144 //! theNewTol is a new tolerance of vertices of the input edge
145 //! (not applied inside the algorithm, but pre-computed).
146 //! If IsUseOldEdge is true then the input edge will be modified,
147 //! otherwise the new copy of input edge will be created.
148 //! Returns the new edge as a result, can be ignored if IsUseOldEdge is true.
149 Standard_EXPORT static TopoDS_Edge SameParameter(const TopoDS_Edge& theEdge,
150 const Standard_Real theTolerance, Standard_Real& theNewTol, const Standard_Boolean IsUseOldEdge);
152 //! Computes new 2d curve(s) for all the edges of <S>
153 //! to have the same parameter as the 3d curve.
154 //! The algorithm is not done if the flag SameParameter
155 //! was True on an Edge.
156 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S,
157 const Standard_Real Tolerance = 1.0e-5, const Standard_Boolean forced = Standard_False);
159 //! Computes new 2d curve(s) for all the edges of <S>
160 //! to have the same parameter as the 3d curve.
161 //! The algorithm is not done if the flag SameParameter
162 //! was True on an Edge.<br>
163 //! theReshaper is used to record the modifications of input shape <S> to prevent any
164 //! modifications on the shape itself.
165 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will
166 //! contain a modified empty-copies of original subshapes as substitutions.
167 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S, BRepTools_ReShape& theReshaper,
168 const Standard_Real Tolerance = 1.0e-5, const Standard_Boolean forced = Standard_False );
170 //! Replaces tolerance of FACE EDGE VERTEX by the
171 //! tolerance Max of their connected handling shapes.
172 //! It is not necessary to use this call after
173 //! SameParameter. (called in)
174 Standard_EXPORT static void UpdateTolerances (const TopoDS_Shape& S, const Standard_Boolean verifyFaceTolerance = Standard_False);
176 //! Replaces tolerance of FACE EDGE VERTEX by the
177 //! tolerance Max of their connected handling shapes.
178 //! It is not necessary to use this call after
179 //! SameParameter. (called in)<br>
180 //! theReshaper is used to record the modifications of input shape <S> to prevent any
181 //! modifications on the shape itself.
182 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will
183 //! contain a modified empty-copies of original subshapes as substitutions.
184 Standard_EXPORT static void UpdateTolerances (const TopoDS_Shape& S, BRepTools_ReShape& theReshaper,
185 const Standard_Boolean verifyFaceTolerance = Standard_False );
187 //! Checks tolerances of edges (including inner points) and vertices
188 //! of a shape and updates them to satisfy "SameParameter" condition
189 Standard_EXPORT static void UpdateInnerTolerances (const TopoDS_Shape& S);
191 //! Orients the solid forward and the shell with the
192 //! orientation to have matter in the solid. Returns
193 //! False if the solid is unOrientable (open or incoherent)
194 Standard_EXPORT static Standard_Boolean OrientClosedSolid (TopoDS_Solid& solid);
196 //! Encodes the Regularity of edges on a Shape.
197 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
198 //! Warning: If the edges's regularity are coded before, nothing
200 Standard_EXPORT static void EncodeRegularity (const TopoDS_Shape& S, const Standard_Real TolAng = 1.0e-10);
202 //! Encodes the Regularity of edges in list <LE> on the shape <S>
203 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
204 //! Warning: If the edges's regularity are coded before, nothing
206 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, const TopTools_ListOfShape& LE, const Standard_Real TolAng = 1.0e-10);
208 //! Encodes the Regularity beetween <F1> and <F2> by <E>
209 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
210 //! Warning: If the edge's regularity is coded before, nothing
212 Standard_EXPORT static void EncodeRegularity (TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const Standard_Real TolAng = 1.0e-10);
214 //! Sorts in LF the Faces of S on the complexity of
216 //! (Plane,Cylinder,Cone,Sphere,Torus,other)
217 Standard_EXPORT static void SortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
219 //! Sorts in LF the Faces of S on the reverse
220 //! complexity of their surfaces
221 //! (other,Torus,Sphere,Cone,Cylinder,Plane)
222 Standard_EXPORT static void ReverseSortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
224 //! Corrects the normals in Poly_Triangulation of faces,
225 //! in such way that normals at nodes lying along smooth
226 //! edges have the same value on both adjacent triangulations.
227 //! Returns TRUE if any correction is done.
228 Standard_EXPORT static Standard_Boolean EnsureNormalConsistency (const TopoDS_Shape& S, const Standard_Real theAngTol = 0.001, const Standard_Boolean ForceComputeNormals = Standard_False);
230 //! Calculates the bounding sphere around the set of vertexes from the theLV list.
231 //! Returns the center (theNewCenter) and the radius (theNewTol) of this sphere.
232 //! This can be used to construct the new vertex which covers the given set of
234 Standard_EXPORT static void BoundingVertex(const NCollection_List<TopoDS_Shape>& theLV,
235 gp_Pnt& theNewCenter, Standard_Real& theNewTol);
248 friend class BRepLib_Command;
249 friend class BRepLib_MakeShape;
250 friend class BRepLib_MakeVertex;
251 friend class BRepLib_MakeEdge;
252 friend class BRepLib_MakeEdge2d;
253 friend class BRepLib_MakePolygon;
254 friend class BRepLib_MakeFace;
255 friend class BRepLib_MakeWire;
256 friend class BRepLib_MakeShell;
257 friend class BRepLib_MakeSolid;
258 friend class BRepLib_FindSurface;
259 friend class BRepLib_FuseEdges;
260 friend class BRepLib_CheckCurveOnSurface;
270 #endif // _BRepLib_HeaderFile