|
|
|||
File indexing completed on 2026-05-19 08:16:06
0001 // Created on: 1993-12-15 0002 // Created by: Remi LEQUETTE 0003 // Copyright (c) 1993-1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _BRepLib_HeaderFile 0018 #define _BRepLib_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Real.hxx> 0025 #include <Standard_Boolean.hxx> 0026 #include <GeomAbs_Shape.hxx> 0027 #include <Standard_Integer.hxx> 0028 #include <TopoDS.hxx> 0029 #include <TopoDS_Edge.hxx> 0030 #include <TopTools_ListOfShape.hxx> 0031 #include <NCollection_List.hxx> 0032 0033 class Geom2d_Curve; 0034 class Adaptor3d_Curve; 0035 class Geom_Plane; 0036 class TopoDS_Shape; 0037 class TopoDS_Solid; 0038 class TopoDS_Face; 0039 class BRepTools_ReShape; 0040 0041 //! The BRepLib package provides general utilities for 0042 //! BRep. 0043 //! 0044 //! * FindSurface : Class to compute a surface through 0045 //! a set of edges. 0046 //! 0047 //! * Compute missing 3d curve on an edge. 0048 class BRepLib 0049 { 0050 public: 0051 DEFINE_STANDARD_ALLOC 0052 0053 //! Computes the max distance between edge 0054 //! and its 2d representation on the face. 0055 //! Sets the default precision. The current Precision 0056 //! is returned. 0057 Standard_EXPORT static void Precision(const Standard_Real P); 0058 0059 //! Returns the default precision. 0060 Standard_EXPORT static Standard_Real Precision(); 0061 0062 //! Sets the current plane to P. 0063 Standard_EXPORT static void Plane(const Handle(Geom_Plane)& P); 0064 0065 //! Returns the current plane. 0066 Standard_EXPORT static const Handle(Geom_Plane)& Plane(); 0067 0068 //! checks if the Edge is same range IGNORING 0069 //! the same range flag of the edge 0070 //! Confusion argument is to compare real numbers 0071 //! idenpendently of any model space tolerance 0072 Standard_EXPORT static Standard_Boolean CheckSameRange(const TopoDS_Edge& E, 0073 const Standard_Real Confusion = 1.0e-12); 0074 0075 //! will make all the curve representation have 0076 //! the same range domain for the parameters. 0077 //! This will IGNORE the same range flag value 0078 //! to proceed. 0079 //! If there is a 3D curve there it will the 0080 //! range of that curve. If not the first curve representation 0081 //! encountered in the list will give its range to 0082 //! the all the other curves. 0083 Standard_EXPORT static void SameRange(const TopoDS_Edge& E, 0084 const Standard_Real Tolerance = 1.0e-5); 0085 0086 //! Computes the 3d curve for the edge <E> if it does 0087 //! not exist. Returns True if the curve was computed 0088 //! or existed. Returns False if there is no planar 0089 //! pcurve or the computation failed. 0090 //! <MaxSegment> >= 30 in approximation 0091 Standard_EXPORT static Standard_Boolean BuildCurve3d(const TopoDS_Edge& E, 0092 const Standard_Real Tolerance = 1.0e-5, 0093 const GeomAbs_Shape Continuity = GeomAbs_C1, 0094 const Standard_Integer MaxDegree = 14, 0095 const Standard_Integer MaxSegment = 0); 0096 0097 //! Computes the 3d curves for all the edges of <S> 0098 //! return False if one of the computation failed. 0099 //! <MaxSegment> >= 30 in approximation 0100 Standard_EXPORT static Standard_Boolean BuildCurves3d(const TopoDS_Shape& S, 0101 const Standard_Real Tolerance, 0102 const GeomAbs_Shape Continuity = GeomAbs_C1, 0103 const Standard_Integer MaxDegree = 14, 0104 const Standard_Integer MaxSegment = 0); 0105 0106 //! Computes the 3d curves for all the edges of <S> 0107 //! return False if one of the computation failed. 0108 Standard_EXPORT static Standard_Boolean BuildCurves3d(const TopoDS_Shape& S); 0109 0110 //! Builds pcurve of edge on face if the surface is plane, and updates the edge. 0111 Standard_EXPORT static void BuildPCurveForEdgeOnPlane(const TopoDS_Edge& theE, 0112 const TopoDS_Face& theF); 0113 0114 //! Builds pcurve of edge on face if the surface is plane, but does not update the edge. 0115 //! The output are the pcurve and the flag telling that pcurve was built. 0116 Standard_EXPORT static void BuildPCurveForEdgeOnPlane(const TopoDS_Edge& theE, 0117 const TopoDS_Face& theF, 0118 Handle(Geom2d_Curve)& aC2D, 0119 Standard_Boolean& bToUpdate); 0120 0121 //! Builds pcurves of edges on face if the surface is plane, and update the edges. 0122 template <class TCont> 0123 static void BuildPCurveForEdgesOnPlane(const TCont& theLE, const TopoDS_Face& theF) 0124 { 0125 for (typename TCont::Iterator aIt(theLE); aIt.More(); aIt.Next()) 0126 { 0127 const TopoDS_Edge& aE = TopoDS::Edge(aIt.Value()); 0128 if (!aE.IsNull()) 0129 BRepLib::BuildPCurveForEdgeOnPlane(aE, theF); 0130 } 0131 } 0132 0133 //! Checks if the edge has a Tolerance smaller than -- -- 0134 //! -- -- MaxToleranceToCheck if so it will compute the 0135 //! radius of -- the cylindrical pipe surface that 0136 //! MinToleranceRequest is the minimum tolerance before it 0137 //! is useful to start testing. 0138 //! Usually it should be around 10e-5 0139 //! contains all -- the curve representation of the edge 0140 //! returns True if the Edge tolerance had to be updated 0141 Standard_EXPORT static Standard_Boolean UpdateEdgeTol(const TopoDS_Edge& E, 0142 const Standard_Real MinToleranceRequest, 0143 const Standard_Real MaxToleranceToCheck); 0144 0145 //! -- Checks all the edges of the shape whose -- -- -- 0146 //! Tolerance is smaller than MaxToleranceToCheck -- 0147 //! Returns True if at least one edge was updated -- 0148 //! MinToleranceRequest is the minimum tolerance before 0149 //! -- it -- is useful to start testing. 0150 //! Usually it should be around -- 10e-5-- 0151 //! 0152 //! Warning :The method is very slow as it checks all. 0153 //! Use only in interfaces or processing assimilate batch 0154 Standard_EXPORT static Standard_Boolean UpdateEdgeTolerance( 0155 const TopoDS_Shape& S, 0156 const Standard_Real MinToleranceRequest, 0157 const Standard_Real MaxToleranceToCheck); 0158 0159 //! Computes new 2d curve(s) for the edge <theEdge> to have 0160 //! the same parameter as the 3d curve. 0161 //! The algorithm is not done if the flag SameParameter 0162 //! was True on the Edge. 0163 Standard_EXPORT static void SameParameter(const TopoDS_Edge& theEdge, 0164 const Standard_Real Tolerance = 1.0e-5); 0165 0166 //! Computes new 2d curve(s) for the edge <theEdge> to have 0167 //! the same parameter as the 3d curve. 0168 //! The algorithm is not done if the flag SameParameter 0169 //! was True on the Edge.<br> 0170 //! theNewTol is a new tolerance of vertices of the input edge 0171 //! (not applied inside the algorithm, but pre-computed). 0172 //! If IsUseOldEdge is true then the input edge will be modified, 0173 //! otherwise the new copy of input edge will be created. 0174 //! Returns the new edge as a result, can be ignored if IsUseOldEdge is true. 0175 Standard_EXPORT static TopoDS_Edge SameParameter(const TopoDS_Edge& theEdge, 0176 const Standard_Real theTolerance, 0177 Standard_Real& theNewTol, 0178 const Standard_Boolean IsUseOldEdge); 0179 0180 //! Computes new 2d curve(s) for all the edges of <S> 0181 //! to have the same parameter as the 3d curve. 0182 //! The algorithm is not done if the flag SameParameter 0183 //! was True on an Edge. 0184 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S, 0185 const Standard_Real Tolerance = 1.0e-5, 0186 const Standard_Boolean forced = Standard_False); 0187 0188 //! Computes new 2d curve(s) for all the edges of <S> 0189 //! to have the same parameter as the 3d curve. 0190 //! The algorithm is not done if the flag SameParameter 0191 //! was True on an Edge.<br> 0192 //! theReshaper is used to record the modifications of input shape <S> to prevent any 0193 //! modifications on the shape itself. 0194 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will 0195 //! contain a modified empty-copies of original subshapes as substitutions. 0196 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S, 0197 BRepTools_ReShape& theReshaper, 0198 const Standard_Real Tolerance = 1.0e-5, 0199 const Standard_Boolean forced = Standard_False); 0200 0201 //! Replaces tolerance of FACE EDGE VERTEX by the 0202 //! tolerance Max of their connected handling shapes. 0203 //! It is not necessary to use this call after 0204 //! SameParameter. (called in) 0205 Standard_EXPORT static void UpdateTolerances( 0206 const TopoDS_Shape& S, 0207 const Standard_Boolean verifyFaceTolerance = Standard_False); 0208 0209 //! Replaces tolerance of FACE EDGE VERTEX by the 0210 //! tolerance Max of their connected handling shapes. 0211 //! It is not necessary to use this call after 0212 //! SameParameter. (called in)<br> 0213 //! theReshaper is used to record the modifications of input shape <S> to prevent any 0214 //! modifications on the shape itself. 0215 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will 0216 //! contain a modified empty-copies of original subshapes as substitutions. 0217 Standard_EXPORT static void UpdateTolerances( 0218 const TopoDS_Shape& S, 0219 BRepTools_ReShape& theReshaper, 0220 const Standard_Boolean verifyFaceTolerance = Standard_False); 0221 0222 //! Checks tolerances of edges (including inner points) and vertices 0223 //! of a shape and updates them to satisfy "SameParameter" condition 0224 Standard_EXPORT static void UpdateInnerTolerances(const TopoDS_Shape& S); 0225 0226 //! Orients the solid forward and the shell with the 0227 //! orientation to have matter in the solid. Returns 0228 //! False if the solid is unOrientable (open or incoherent) 0229 Standard_EXPORT static Standard_Boolean OrientClosedSolid(TopoDS_Solid& solid); 0230 0231 //! Returns the order of continuity between two faces 0232 //! connected by an edge 0233 Standard_EXPORT static GeomAbs_Shape ContinuityOfFaces(const TopoDS_Edge& theEdge, 0234 const TopoDS_Face& theFace1, 0235 const TopoDS_Face& theFace2, 0236 const Standard_Real theAngleTol); 0237 0238 //! Encodes the Regularity of edges on a Shape. 0239 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0240 //! Warning: If the edges's regularity are coded before, nothing 0241 //! is done. 0242 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, 0243 const Standard_Real TolAng = 1.0e-10); 0244 0245 //! Encodes the Regularity of edges in list <LE> on the shape <S> 0246 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0247 //! Warning: If the edges's regularity are coded before, nothing 0248 //! is done. 0249 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, 0250 const TopTools_ListOfShape& LE, 0251 const Standard_Real TolAng = 1.0e-10); 0252 0253 //! Encodes the Regularity between <F1> and <F2> by <E> 0254 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0255 //! Warning: If the edge's regularity is coded before, nothing 0256 //! is done. 0257 Standard_EXPORT static void EncodeRegularity(TopoDS_Edge& E, 0258 const TopoDS_Face& F1, 0259 const TopoDS_Face& F2, 0260 const Standard_Real TolAng = 1.0e-10); 0261 0262 //! Sorts in LF the Faces of S on the complexity of 0263 //! their surfaces 0264 //! (Plane,Cylinder,Cone,Sphere,Torus,other) 0265 Standard_EXPORT static void SortFaces(const TopoDS_Shape& S, TopTools_ListOfShape& LF); 0266 0267 //! Sorts in LF the Faces of S on the reverse 0268 //! complexity of their surfaces 0269 //! (other,Torus,Sphere,Cone,Cylinder,Plane) 0270 Standard_EXPORT static void ReverseSortFaces(const TopoDS_Shape& S, TopTools_ListOfShape& LF); 0271 0272 //! Corrects the normals in Poly_Triangulation of faces, 0273 //! in such way that normals at nodes lying along smooth 0274 //! edges have the same value on both adjacent triangulations. 0275 //! Returns TRUE if any correction is done. 0276 Standard_EXPORT static Standard_Boolean EnsureNormalConsistency( 0277 const TopoDS_Shape& S, 0278 const Standard_Real theAngTol = 0.001, 0279 const Standard_Boolean ForceComputeNormals = Standard_False); 0280 0281 //! Updates value of deflection in Poly_Triangulation of faces 0282 //! by the maximum deviation measured on existing triangulation. 0283 Standard_EXPORT static void UpdateDeflection(const TopoDS_Shape& S); 0284 0285 //! Calculates the bounding sphere around the set of vertexes from the theLV list. 0286 //! Returns the center (theNewCenter) and the radius (theNewTol) of this sphere. 0287 //! This can be used to construct the new vertex which covers the given set of 0288 //! other vertices. 0289 Standard_EXPORT static void BoundingVertex(const NCollection_List<TopoDS_Shape>& theLV, 0290 gp_Pnt& theNewCenter, 0291 Standard_Real& theNewTol); 0292 0293 //! For an edge defined by 3d curve and tolerance and vertices defined by points, 0294 //! parameters on curve and tolerances, 0295 //! finds a range of curve between vertices not covered by vertices tolerances. 0296 //! Returns false if there is no such range. Otherwise, sets theFirst and 0297 //! theLast as its bounds. 0298 Standard_EXPORT static Standard_Boolean FindValidRange(const Adaptor3d_Curve& theCurve, 0299 const Standard_Real theTolE, 0300 const Standard_Real theParV1, 0301 const gp_Pnt& thePntV1, 0302 const Standard_Real theTolV1, 0303 const Standard_Real theParV2, 0304 const gp_Pnt& thePntV2, 0305 const Standard_Real theTolV2, 0306 Standard_Real& theFirst, 0307 Standard_Real& theLast); 0308 0309 //! Finds a range of 3d curve of the edge not covered by vertices tolerances. 0310 //! Returns false if there is no such range. Otherwise, sets theFirst and 0311 //! theLast as its bounds. 0312 Standard_EXPORT static Standard_Boolean FindValidRange(const TopoDS_Edge& theEdge, 0313 Standard_Real& theFirst, 0314 Standard_Real& theLast); 0315 0316 //! Enlarges the face on the given value. 0317 //! @param[in] theF The face to extend 0318 //! @param[in] theExtVal The extension value 0319 //! @param[in] theExtUMin Defines whether to extend the face in UMin direction 0320 //! @param[in] theExtUMax Defines whether to extend the face in UMax direction 0321 //! @param[in] theExtVMin Defines whether to extend the face in VMin direction 0322 //! @param[in] theExtVMax Defines whether to extend the face in VMax direction 0323 //! @param[in] theFExtended The extended face 0324 Standard_EXPORT static void ExtendFace(const TopoDS_Face& theF, 0325 const Standard_Real theExtVal, 0326 const Standard_Boolean theExtUMin, 0327 const Standard_Boolean theExtUMax, 0328 const Standard_Boolean theExtVMin, 0329 const Standard_Boolean theExtVMax, 0330 TopoDS_Face& theFExtended); 0331 }; 0332 0333 #endif // _BRepLib_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|