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;
50 //! The BRepLib package provides general utilities for
53 //! * FindSurface : Class to compute a surface through
56 //! * Compute missing 3d curve on an edge.
65 //! Computes the max distance between edge
66 //! and its 2d representation on the face.
67 //! Sets the default precision. The current Precision
69 Standard_EXPORT static void Precision (const Standard_Real P);
71 //! Returns the default precision.
72 Standard_EXPORT static Standard_Real Precision();
74 //! Sets the current plane to P.
75 Standard_EXPORT static void Plane (const Handle(Geom_Plane)& P);
77 //! Returns the current plane.
78 Standard_EXPORT static const Handle(Geom_Plane)& Plane();
80 //! checks if the Edge is same range IGNORING
81 //! the same range flag of the edge
82 //! Confusion argument is to compare real numbers
83 //! idenpendently of any model space tolerance
84 Standard_EXPORT static Standard_Boolean CheckSameRange (const TopoDS_Edge& E, const Standard_Real Confusion = 1.0e-12);
86 //! will make all the curve representation have
87 //! the same range domain for the parameters.
88 //! This will IGNORE the same range flag value
90 //! If there is a 3D curve there it will the
91 //! range of that curve. If not the first curve representation
92 //! encountered in the list will give its range to
93 //! the all the other curves.
94 Standard_EXPORT static void SameRange (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5);
96 //! Computes the 3d curve for the edge <E> if it does
97 //! not exist. Returns True if the curve was computed
98 //! or existed. Returns False if there is no planar
99 //! pcurve or the computation failed.
100 //! <MaxSegment> >= 30 in approximation
101 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);
103 //! Computes the 3d curves for all the edges of <S>
104 //! return False if one of the computation failed.
105 //! <MaxSegment> >= 30 in approximation
106 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);
108 //! Computes the 3d curves for all the edges of <S>
109 //! return False if one of the computation failed.
110 Standard_EXPORT static Standard_Boolean BuildCurves3d (const TopoDS_Shape& S);
112 //! Checks if the edge has a Tolerance smaller than -- --
113 //! -- -- MaxToleranceToCheck if so it will compute the
114 //! radius of -- the cylindrical pipe surface that
115 //! MinToleranceRequest is the minimum tolerance before it
116 //! is usefull to start testing. Usually it should be arround
118 //! contains all -- the curve represenation of the edge
119 //! returns True if the Edge tolerance had to be updated
120 Standard_EXPORT static Standard_Boolean UpdateEdgeTol (const TopoDS_Edge& E, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
122 //! -- Checks all the edges of the shape whose -- -- --
123 //! Tolerance is smaller than MaxToleranceToCheck --
124 //! Returns True if at least one edge was updated --
125 //! MinToleranceRequest is the minimum tolerance before
126 //! -- it -- is usefull to start testing. Usually it
127 //! should be arround -- 10e-5--
129 //! Warning :The method is very slow as it checks all.
130 //! Use only in interfaces or processing assimilate batch
131 Standard_EXPORT static Standard_Boolean UpdateEdgeTolerance (const TopoDS_Shape& S, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
133 //! Computes new 2d curve(s) for the edge <E> to have
134 //! the same parameter as the 3d curve.
135 //! The algorithm is not done if the flag SameParameter
136 //! was True on the Edge.
137 Standard_EXPORT static void SameParameter (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5);
139 //! Computes new 2d curve(s) for all the edges of <S>
140 //! to have the same parameter as the 3d curve.
141 //! The algorithm is not done if the flag SameParameter
142 //! was True on an Edge.
143 Standard_EXPORT static void SameParameter (const TopoDS_Shape& S, const Standard_Real Tolerance = 1.0e-5, const Standard_Boolean forced = Standard_False);
145 //! Replaces tolerance of FACE EDGE VERTEX by the
146 //! tolerance Max of their connected handling shapes.
147 //! It is not necessary to use this call after
148 //! SameParameter. (called in)
149 Standard_EXPORT static void UpdateTolerances (const TopoDS_Shape& S, const Standard_Boolean verifyFaceTolerance = Standard_False);
151 //! Checks tolerances of edges (including inner points) and vertices
152 //! of a shape and updates them to satisfy "SameParameter" condition
153 Standard_EXPORT static void UpdateInnerTolerances (const TopoDS_Shape& S);
155 //! Orients the solid forward and the shell with the
156 //! orientation to have matter in the solid. Returns
157 //! False if the solid is unOrientable (open or incoherent)
158 Standard_EXPORT static Standard_Boolean OrientClosedSolid (TopoDS_Solid& solid);
160 //! Encodes the Regularity of edges on a Shape.
161 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
162 //! Warning: If the edges's regularity are coded before, nothing
164 Standard_EXPORT static void EncodeRegularity (const TopoDS_Shape& S, const Standard_Real TolAng = 1.0e-10);
166 //! Encodes the Regularity of edges in list <LE> on the shape <S>
167 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
168 //! Warning: If the edges's regularity are coded before, nothing
170 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, const TopTools_ListOfShape& LE, const Standard_Real TolAng = 1.0e-10);
172 //! Encodes the Regularity beetween <F1> and <F2> by <E>
173 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
174 //! Warning: If the edge's regularity is coded before, nothing
176 Standard_EXPORT static void EncodeRegularity (TopoDS_Edge& E, const TopoDS_Face& F1, const TopoDS_Face& F2, const Standard_Real TolAng = 1.0e-10);
178 //! Sorts in LF the Faces of S on the complexity of
180 //! (Plane,Cylinder,Cone,Sphere,Torus,other)
181 Standard_EXPORT static void SortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
183 //! Sorts in LF the Faces of S on the reverse
184 //! complexity of their surfaces
185 //! (other,Torus,Sphere,Cone,Cylinder,Plane)
186 Standard_EXPORT static void ReverseSortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
188 //! Corrects the normals in Poly_Triangulation of faces,
189 //! in such way that normals at nodes lying along smooth
190 //! edges have the same value on both adjacent triangulations.
191 //! Returns TRUE if any correction is done.
192 Standard_EXPORT static Standard_Boolean EnsureNormalConsistency (const TopoDS_Shape& S, const Standard_Real theAngTol = 0.001, const Standard_Boolean ForceComputeNormals = Standard_False);
194 //! Calculates the bounding sphere around the set of vertexes from the theLV list.
195 //! Returns the center (theNewCenter) and the radius (theNewTol) of this sphere.
196 //! This can be used to construct the new vertex which covers the given set of
198 Standard_EXPORT static void BoundingVertex(const NCollection_List<TopoDS_Shape>& theLV,
199 gp_Pnt& theNewCenter, Standard_Real& theNewTol);
212 friend class BRepLib_Command;
213 friend class BRepLib_MakeShape;
214 friend class BRepLib_MakeVertex;
215 friend class BRepLib_MakeEdge;
216 friend class BRepLib_MakeEdge2d;
217 friend class BRepLib_MakePolygon;
218 friend class BRepLib_MakeFace;
219 friend class BRepLib_MakeWire;
220 friend class BRepLib_MakeShell;
221 friend class BRepLib_MakeSolid;
222 friend class BRepLib_FindSurface;
223 friend class BRepLib_FuseEdges;
224 friend class BRepLib_CheckCurveOnSurface;
234 #endif // _BRepLib_HeaderFile