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>
34 class BRepLib_Command;
35 class BRepLib_MakeShape;
36 class BRepLib_MakeVertex;
37 class BRepLib_MakeEdge;
38 class BRepLib_MakeEdge2d;
39 class BRepLib_MakePolygon;
40 class BRepLib_MakeFace;
41 class BRepLib_MakeWire;
42 class BRepLib_MakeShell;
43 class BRepLib_MakeSolid;
44 class BRepLib_FindSurface;
45 class BRepLib_FuseEdges;
46 class BRepLib_CheckCurveOnSurface;
49 //! The BRepLib package provides general utilities for
52 //! * FindSurface : Class to compute a surface through
55 //! * Compute missing 3d curve on an edge.
64 //! Computes the max distance between edge
65 //! and its 2d representation on the face.
66 //! Sets the default precision. The current Precision
68 Standard_EXPORT static void Precision (const Standard_Real P);
70 //! Returns the default precision.
71 Standard_EXPORT static Standard_Real Precision();
73 //! Sets the current plane to P.
74 Standard_EXPORT static void Plane (const Handle(Geom_Plane)& P);
76 //! Returns the current plane.
77 Standard_EXPORT static const Handle(Geom_Plane)& Plane();
79 //! checks if the Edge is same range IGNORING
80 //! the same range flag of the edge
81 //! Confusion argument is to compare real numbers
82 //! idenpendently of any model space tolerance
83 Standard_EXPORT static Standard_Boolean CheckSameRange (const TopoDS_Edge& E, const Standard_Real Confusion = 1.0e-12);
85 //! will make all the curve representation have
86 //! the same range domain for the parameters.
87 //! This will IGNORE the same range flag value
89 //! If there is a 3D curve there it will the
90 //! range of that curve. If not the first curve representation
91 //! encountered in the list will give its range to
92 //! the all the other curves.
93 Standard_EXPORT static void SameRange (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5);
95 //! Computes the 3d curve for the edge <E> if it does
96 //! not exist. Returns True if the curve was computed
97 //! or existed. Returns False if there is no planar
98 //! pcurve or the computation failed.
99 //! <MaxSegment> >= 30 in approximation
100 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);
102 //! Computes the 3d curves for all the edges of <S>
103 //! return False if one of the computation failed.
104 //! <MaxSegment> >= 30 in approximation
105 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);
107 //! Computes the 3d curves for all the edges of <S>
108 //! return False if one of the computation failed.
109 Standard_EXPORT static Standard_Boolean BuildCurves3d (const TopoDS_Shape& S);
111 //! Checks if the edge has a Tolerance smaller than -- --
112 //! -- -- MaxToleranceToCheck if so it will compute the
113 //! radius of -- the cylindrical pipe surface that
114 //! MinToleranceRequest is the minimum tolerance before it
115 //! is usefull to start testing. Usually it should be arround
117 //! contains all -- the curve represenation of the edge
118 //! returns True if the Edge tolerance had to be updated
119 Standard_EXPORT static Standard_Boolean UpdateEdgeTol (const TopoDS_Edge& E, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
121 //! -- Checks all the edges of the shape whose -- -- --
122 //! Tolerance is smaller than MaxToleranceToCheck --
123 //! Returns True if at least one edge was updated --
124 //! MinToleranceRequest is the minimum tolerance before
125 //! -- it -- is usefull to start testing. Usually it
126 //! should be arround -- 10e-5--
128 //! Warning :The method is very slow as it checks all.
129 //! Use only in interfaces or processing assimilate batch
130 Standard_EXPORT static Standard_Boolean UpdateEdgeTolerance (const TopoDS_Shape& S, const Standard_Real MinToleranceRequest, const Standard_Real MaxToleranceToCheck);
132 //! Computes new 2d curve(s) for the edge <E> to have
133 //! the same parameter as the 3d curve.
134 //! The algorithm is not done if the flag SameParameter
135 //! was True on the Edge.
136 Standard_EXPORT static void SameParameter (const TopoDS_Edge& E, const Standard_Real Tolerance = 1.0e-5);
138 //! Computes new 2d curve(s) for all the edges of <S>
139 //! to have the same parameter as the 3d curve.
140 //! The algorithm is not done if the flag SameParameter
141 //! was True on an Edge.
142 Standard_EXPORT static void SameParameter (const TopoDS_Shape& S, const Standard_Real Tolerance = 1.0e-5, const Standard_Boolean forced = Standard_False);
144 //! Replaces tolerance of FACE EDGE VERTEX by the
145 //! tolerance Max of their connected handling shapes.
146 //! It is not necessary to use this call after
147 //! SameParameter. (called in)
148 Standard_EXPORT static void UpdateTolerances (const TopoDS_Shape& S, const Standard_Boolean verifyFaceTolerance = Standard_False);
150 //! Checks tolerances of edges (including inner points) and vertices
151 //! of a shape and updates them to satisfy "SameParameter" condition
152 Standard_EXPORT static void UpdateInnerTolerances (const TopoDS_Shape& S);
154 //! Orients the solid forward and the shell with the
155 //! orientation to have matter in the solid. Returns
156 //! False if the solid is unOrientable (open or incoherent)
157 Standard_EXPORT static Standard_Boolean OrientClosedSolid (TopoDS_Solid& solid);
159 //! Encodes the Regularity of edges on a Shape.
160 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
161 //! Warning: If the edges's regularity are coded before, nothing
163 Standard_EXPORT static void EncodeRegularity (const TopoDS_Shape& S, const Standard_Real TolAng = 1.0e-10);
165 //! Encodes the Regularity beetween <F1> and <F2> by <E>
166 //! Warning: <TolAng> is an angular tolerance, expressed in Rad.
167 //! Warning: If the edge's regularity is coded before, nothing
169 Standard_EXPORT static void EncodeRegularity (TopoDS_Edge& S, const TopoDS_Face& F1, const TopoDS_Face& F2, const Standard_Real TolAng = 1.0e-10);
171 //! Sorts in LF the Faces of S on the complexity of
173 //! (Plane,Cylinder,Cone,Sphere,Torus,other)
174 Standard_EXPORT static void SortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
176 //! Sorts in LF the Faces of S on the reverse
177 //! complexity of their surfaces
178 //! (other,Torus,Sphere,Cone,Cylinder,Plane)
179 Standard_EXPORT static void ReverseSortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF);
181 //! Corrects the normals in Poly_Triangulation of faces,
182 //! in such way that normals at nodes lying along smooth
183 //! edges have the same value on both adjacent triangulations.
184 //! Returns TRUE if any correction is done.
185 Standard_EXPORT static Standard_Boolean EnsureNormalConsistency (const TopoDS_Shape& S, const Standard_Real theAngTol = 0.001, const Standard_Boolean ForceComputeNormals = Standard_False);
201 friend class BRepLib_Command;
202 friend class BRepLib_MakeShape;
203 friend class BRepLib_MakeVertex;
204 friend class BRepLib_MakeEdge;
205 friend class BRepLib_MakeEdge2d;
206 friend class BRepLib_MakePolygon;
207 friend class BRepLib_MakeFace;
208 friend class BRepLib_MakeWire;
209 friend class BRepLib_MakeShell;
210 friend class BRepLib_MakeSolid;
211 friend class BRepLib_FindSurface;
212 friend class BRepLib_FuseEdges;
213 friend class BRepLib_CheckCurveOnSurface;
223 #endif // _BRepLib_HeaderFile