| 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 |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 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. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | #ifndef _BRepLib_HeaderFile |
| 18 | #define _BRepLib_HeaderFile |
| 19 | |
| 20 | #include <Standard.hxx> |
| 21 | #include <Standard_DefineAlloc.hxx> |
| 22 | #include <Standard_Handle.hxx> |
| 23 | |
| 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 | class Geom_Plane; |
| 30 | class TopoDS_Edge; |
| 31 | class TopoDS_Shape; |
| 32 | class TopoDS_Solid; |
| 33 | class TopoDS_Face; |
| 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; |
| 47 | |
| 48 | |
| 49 | //! The BRepLib package provides general utilities for |
| 50 | //! BRep. |
| 51 | //! |
| 52 | //! * FindSurface : Class to compute a surface through |
| 53 | //! a set of edges. |
| 54 | //! |
| 55 | //! * Compute missing 3d curve on an edge. |
| 56 | class BRepLib |
| 57 | { |
| 58 | public: |
| 59 | |
| 60 | DEFINE_STANDARD_ALLOC |
| 61 | |
| 62 | |
| 63 | |
| 64 | //! Computes the max distance between edge |
| 65 | //! and its 2d representation on the face. |
| 66 | //! Sets the default precision. The current Precision |
| 67 | //! is returned. |
| 68 | Standard_EXPORT static void Precision (const Standard_Real P); |
| 69 | |
| 70 | //! Returns the default precision. |
| 71 | Standard_EXPORT static Standard_Real Precision(); |
| 72 | |
| 73 | //! Sets the current plane to P. |
| 74 | Standard_EXPORT static void Plane (const Handle(Geom_Plane)& P); |
| 75 | |
| 76 | //! Returns the current plane. |
| 77 | Standard_EXPORT static const Handle(Geom_Plane)& Plane(); |
| 78 | |
| 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); |
| 84 | |
| 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 |
| 88 | //! to proceed. |
| 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); |
| 94 | |
| 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); |
| 101 | |
| 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); |
| 106 | |
| 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); |
| 110 | |
| 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 |
| 116 | //! 10e-5 |
| 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); |
| 120 | |
| 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-- |
| 127 | //! |
| 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); |
| 131 | |
| 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); |
| 137 | |
| 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); |
| 143 | |
| 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); |
| 149 | |
| 150 | //! Orients the solid forward and the shell with the |
| 151 | //! orientation to have matter in the solid. Returns |
| 152 | //! False if the solid is unOrientable (open or incoherent) |
| 153 | Standard_EXPORT static Standard_Boolean OrientClosedSolid (TopoDS_Solid& solid); |
| 154 | |
| 155 | //! Encodes the Regularity of edges on a Shape. |
| 156 | //! Warning: <TolAng> is an angular tolerance, expressed in Rad. |
| 157 | //! Warning: If the edges's regularity are coded before, nothing |
| 158 | //! is done. |
| 159 | Standard_EXPORT static void EncodeRegularity (const TopoDS_Shape& S, const Standard_Real TolAng = 1.0e-10); |
| 160 | |
| 161 | //! Encodes the Regularity beetween <F1> and <F2> by <E> |
| 162 | //! Warning: <TolAng> is an angular tolerance, expressed in Rad. |
| 163 | //! Warning: If the edge's regularity is coded before, nothing |
| 164 | //! is done. |
| 165 | Standard_EXPORT static void EncodeRegularity (TopoDS_Edge& S, const TopoDS_Face& F1, const TopoDS_Face& F2, const Standard_Real TolAng = 1.0e-10); |
| 166 | |
| 167 | //! Sorts in LF the Faces of S on the complexity of |
| 168 | //! their surfaces |
| 169 | //! (Plane,Cylinder,Cone,Sphere,Torus,other) |
| 170 | Standard_EXPORT static void SortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF); |
| 171 | |
| 172 | //! Sorts in LF the Faces of S on the reverse |
| 173 | //! complexity of their surfaces |
| 174 | //! (other,Torus,Sphere,Cone,Cylinder,Plane) |
| 175 | Standard_EXPORT static void ReverseSortFaces (const TopoDS_Shape& S, TopTools_ListOfShape& LF); |
| 176 | |
| 177 | //! Corrects the normals in Poly_Triangulation of faces, |
| 178 | //! in such way that normals at nodes lying along smooth |
| 179 | //! edges have the same value on both adjacent triangulations. |
| 180 | //! Returns TRUE if any correction is done. |
| 181 | Standard_EXPORT static Standard_Boolean EnsureNormalConsistency (const TopoDS_Shape& S, const Standard_Real theAngTol = 0.001, const Standard_Boolean ForceComputeNormals = Standard_False); |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | protected: |
| 187 | |
| 188 | |
| 189 | |
| 190 | |
| 191 | |
| 192 | private: |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | friend class BRepLib_Command; |
| 198 | friend class BRepLib_MakeShape; |
| 199 | friend class BRepLib_MakeVertex; |
| 200 | friend class BRepLib_MakeEdge; |
| 201 | friend class BRepLib_MakeEdge2d; |
| 202 | friend class BRepLib_MakePolygon; |
| 203 | friend class BRepLib_MakeFace; |
| 204 | friend class BRepLib_MakeWire; |
| 205 | friend class BRepLib_MakeShell; |
| 206 | friend class BRepLib_MakeSolid; |
| 207 | friend class BRepLib_FindSurface; |
| 208 | friend class BRepLib_FuseEdges; |
| 209 | friend class BRepLib_CheckCurveOnSurface; |
| 210 | |
| 211 | }; |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | #endif // _BRepLib_HeaderFile |