|
|
|||
File indexing completed on 2026-11-15 10:21:45
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 <TopoDS_Shape.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 double P); 0058 0059 //! Returns the default precision. 0060 Standard_EXPORT static double Precision(); 0061 0062 //! Sets the current plane to P. 0063 Standard_EXPORT static void Plane(const occ::handle<Geom_Plane>& P); 0064 0065 //! Returns the current plane. 0066 Standard_EXPORT static const occ::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 bool CheckSameRange(const TopoDS_Edge& E, 0073 const double 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, const double Tolerance = 1.0e-5); 0084 0085 //! Computes the 3d curve for the edge <E> if it does 0086 //! not exist. Returns True if the curve was computed 0087 //! or existed. Returns False if there is no planar 0088 //! pcurve or the computation failed. 0089 //! <MaxSegment> >= 30 in approximation 0090 Standard_EXPORT static bool BuildCurve3d(const TopoDS_Edge& E, 0091 const double Tolerance = 1.0e-5, 0092 const GeomAbs_Shape Continuity = GeomAbs_C1, 0093 const int MaxDegree = 14, 0094 const int MaxSegment = 0); 0095 0096 //! Computes the 3d curves for all the edges of <S> 0097 //! return False if one of the computation failed. 0098 //! <MaxSegment> >= 30 in approximation 0099 Standard_EXPORT static bool BuildCurves3d(const TopoDS_Shape& S, 0100 const double Tolerance, 0101 const GeomAbs_Shape Continuity = GeomAbs_C1, 0102 const int MaxDegree = 14, 0103 const int MaxSegment = 0); 0104 0105 //! Computes the 3d curves for all the edges of <S> 0106 //! return False if one of the computation failed. 0107 Standard_EXPORT static bool BuildCurves3d(const TopoDS_Shape& S); 0108 0109 //! Builds pcurve of edge on face if the surface is plane, and updates the edge. 0110 Standard_EXPORT static void BuildPCurveForEdgeOnPlane(const TopoDS_Edge& theE, 0111 const TopoDS_Face& theF); 0112 0113 //! Builds pcurve of edge on face if the surface is plane, but does not update the edge. 0114 //! The output are the pcurve and the flag telling that pcurve was built. 0115 Standard_EXPORT static void BuildPCurveForEdgeOnPlane(const TopoDS_Edge& theE, 0116 const TopoDS_Face& theF, 0117 occ::handle<Geom2d_Curve>& aC2D, 0118 bool& bToUpdate); 0119 0120 //! Builds pcurves of edges on face if the surface is plane, and update the edges. 0121 template <class TCont> 0122 static void BuildPCurveForEdgesOnPlane(const TCont& theLE, const TopoDS_Face& theF) 0123 { 0124 for (typename TCont::Iterator aIt(theLE); aIt.More(); aIt.Next()) 0125 { 0126 const TopoDS_Edge& aE = TopoDS::Edge(aIt.Value()); 0127 if (!aE.IsNull()) 0128 BRepLib::BuildPCurveForEdgeOnPlane(aE, theF); 0129 } 0130 } 0131 0132 //! Checks if the edge has a Tolerance smaller than 0133 //! MaxToleranceToCheck if so it will compute the 0134 //! radius of the cylindrical pipe surface that 0135 //! MinToleranceRequest is the minimum tolerance before it 0136 //! is useful to start testing. 0137 //! Usually it should be around 10e-5 0138 //! contains all the curve representation of the edge 0139 //! returns True if the Edge tolerance had to be updated 0140 Standard_EXPORT static bool UpdateEdgeTol(const TopoDS_Edge& E, 0141 const double MinToleranceRequest, 0142 const double MaxToleranceToCheck); 0143 0144 //! Checks all the edges of the shape whose 0145 //! Tolerance is smaller than MaxToleranceToCheck 0146 //! Returns True if at least one edge was updated 0147 //! MinToleranceRequest is the minimum tolerance before 0148 //! it is useful to start testing. 0149 //! Usually it should be around 10e-5 0150 //! 0151 //! Warning: The method is very slow as it checks all. 0152 //! Use only in interfaces or processing assimilate batch 0153 Standard_EXPORT static bool UpdateEdgeTolerance(const TopoDS_Shape& S, 0154 const double MinToleranceRequest, 0155 const double MaxToleranceToCheck); 0156 0157 //! Computes new 2d curve(s) for the edge <theEdge> to have 0158 //! the same parameter as the 3d curve. 0159 //! The algorithm is not done if the flag SameParameter 0160 //! was True on the Edge. 0161 Standard_EXPORT static void SameParameter(const TopoDS_Edge& theEdge, 0162 const double Tolerance = 1.0e-5); 0163 0164 //! Computes new 2d curve(s) for the edge <theEdge> to have 0165 //! the same parameter as the 3d curve. 0166 //! The algorithm is not done if the flag SameParameter 0167 //! was True on the Edge. 0168 //! theNewTol is a new tolerance of vertices of the input edge 0169 //! (not applied inside the algorithm, but pre-computed). 0170 //! If IsUseOldEdge is true then the input edge will be modified, 0171 //! otherwise the new copy of input edge will be created. 0172 //! Returns the new edge as a result, can be ignored if IsUseOldEdge is true. 0173 Standard_EXPORT static TopoDS_Edge SameParameter(const TopoDS_Edge& theEdge, 0174 const double theTolerance, 0175 double& theNewTol, 0176 const bool IsUseOldEdge); 0177 0178 //! Computes new 2d curve(s) for all the edges of <S> 0179 //! to have the same parameter as the 3d curve. 0180 //! The algorithm is not done if the flag SameParameter 0181 //! was True on an Edge. 0182 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S, 0183 const double Tolerance = 1.0e-5, 0184 const bool forced = false); 0185 0186 //! Computes new 2d curve(s) for all the edges of <S> 0187 //! to have the same parameter as the 3d curve. 0188 //! The algorithm is not done if the flag SameParameter 0189 //! was True on an Edge. 0190 //! theReshaper is used to record the modifications of input shape <S> to prevent any 0191 //! modifications on the shape itself. 0192 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will 0193 //! contain a modified empty-copies of original subshapes as substitutions. 0194 Standard_EXPORT static void SameParameter(const TopoDS_Shape& S, 0195 BRepTools_ReShape& theReshaper, 0196 const double Tolerance = 1.0e-5, 0197 const bool forced = false); 0198 0199 //! Replaces tolerance of FACE EDGE VERTEX by the 0200 //! tolerance Max of their connected handling shapes. 0201 //! It is not necessary to use this call after 0202 //! SameParameter. (called in) 0203 Standard_EXPORT static void UpdateTolerances(const TopoDS_Shape& S, 0204 const bool verifyFaceTolerance = false); 0205 0206 //! Replaces tolerance of FACE EDGE VERTEX by the 0207 //! tolerance Max of their connected handling shapes. 0208 //! It is not necessary to use this call after 0209 //! SameParameter. (called in) 0210 //! theReshaper is used to record the modifications of input shape <S> to prevent any 0211 //! modifications on the shape itself. 0212 //! Thus the input shape (and its subshapes) will not be modified, instead the reshaper will 0213 //! contain a modified empty-copies of original subshapes as substitutions. 0214 Standard_EXPORT static void UpdateTolerances(const TopoDS_Shape& S, 0215 BRepTools_ReShape& theReshaper, 0216 const bool verifyFaceTolerance = false); 0217 0218 //! Checks tolerances of edges (including inner points) and vertices 0219 //! of a shape and updates them to satisfy "SameParameter" condition 0220 Standard_EXPORT static void UpdateInnerTolerances(const TopoDS_Shape& S); 0221 0222 //! Orients the solid forward and the shell with the 0223 //! orientation to have matter in the solid. Returns 0224 //! False if the solid is unOrientable (open or incoherent) 0225 Standard_EXPORT static bool OrientClosedSolid(TopoDS_Solid& solid); 0226 0227 //! Returns the order of continuity between two faces 0228 //! connected by an edge 0229 Standard_EXPORT static GeomAbs_Shape ContinuityOfFaces(const TopoDS_Edge& theEdge, 0230 const TopoDS_Face& theFace1, 0231 const TopoDS_Face& theFace2, 0232 const double theAngleTol); 0233 0234 //! Encodes the Regularity of edges on a Shape. 0235 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0236 //! Warning: If the edges's regularity are coded before, nothing 0237 //! is done. 0238 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, 0239 const double TolAng = 1.0e-10); 0240 0241 //! Encodes the Regularity of edges in list <LE> on the shape <S> 0242 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0243 //! Warning: If the edges's regularity are coded before, nothing 0244 //! is done. 0245 Standard_EXPORT static void EncodeRegularity(const TopoDS_Shape& S, 0246 const NCollection_List<TopoDS_Shape>& LE, 0247 const double TolAng = 1.0e-10); 0248 0249 //! Encodes the Regularity between <F1> and <F2> by <E> 0250 //! Warning: <TolAng> is an angular tolerance, expressed in Rad. 0251 //! Warning: If the edge's regularity is coded before, nothing 0252 //! is done. 0253 Standard_EXPORT static void EncodeRegularity(TopoDS_Edge& E, 0254 const TopoDS_Face& F1, 0255 const TopoDS_Face& F2, 0256 const double TolAng = 1.0e-10); 0257 0258 //! Sorts in LF the Faces of S on the complexity of 0259 //! their surfaces 0260 //! (Plane,Cylinder,Cone,Sphere,Torus,other) 0261 Standard_EXPORT static void SortFaces(const TopoDS_Shape& S, NCollection_List<TopoDS_Shape>& LF); 0262 0263 //! Sorts in LF the Faces of S on the reverse 0264 //! complexity of their surfaces 0265 //! (other,Torus,Sphere,Cone,Cylinder,Plane) 0266 Standard_EXPORT static void ReverseSortFaces(const TopoDS_Shape& S, 0267 NCollection_List<TopoDS_Shape>& LF); 0268 0269 //! Corrects the normals in Poly_Triangulation of faces, 0270 //! in such way that normals at nodes lying along smooth 0271 //! edges have the same value on both adjacent triangulations. 0272 //! Returns TRUE if any correction is done. 0273 Standard_EXPORT static bool EnsureNormalConsistency(const TopoDS_Shape& S, 0274 const double theAngTol = 0.001, 0275 const bool ForceComputeNormals = false); 0276 0277 //! Updates value of deflection in Poly_Triangulation of faces 0278 //! by the maximum deviation measured on existing triangulation. 0279 Standard_EXPORT static void UpdateDeflection(const TopoDS_Shape& S); 0280 0281 //! Calculates the bounding sphere around the set of vertexes from the theLV list. 0282 //! Returns the center (theNewCenter) and the radius (theNewTol) of this sphere. 0283 //! This can be used to construct the new vertex which covers the given set of 0284 //! other vertices. 0285 Standard_EXPORT static void BoundingVertex(const NCollection_List<TopoDS_Shape>& theLV, 0286 gp_Pnt& theNewCenter, 0287 double& theNewTol); 0288 0289 //! For an edge defined by 3d curve and tolerance and vertices defined by points, 0290 //! parameters on curve and tolerances, 0291 //! finds a range of curve between vertices not covered by vertices tolerances. 0292 //! Returns false if there is no such range. Otherwise, sets theFirst and 0293 //! theLast as its bounds. 0294 Standard_EXPORT static bool FindValidRange(const Adaptor3d_Curve& theCurve, 0295 const double theTolE, 0296 const double theParV1, 0297 const gp_Pnt& thePntV1, 0298 const double theTolV1, 0299 const double theParV2, 0300 const gp_Pnt& thePntV2, 0301 const double theTolV2, 0302 double& theFirst, 0303 double& theLast); 0304 0305 //! Finds a range of 3d curve of the edge not covered by vertices tolerances. 0306 //! Returns false if there is no such range. Otherwise, sets theFirst and 0307 //! theLast as its bounds. 0308 Standard_EXPORT static bool FindValidRange(const TopoDS_Edge& theEdge, 0309 double& theFirst, 0310 double& theLast); 0311 0312 //! Enlarges the face on the given value. 0313 //! @param[in] theF The face to extend 0314 //! @param[in] theExtVal The extension value 0315 //! @param[in] theExtUMin Defines whether to extend the face in UMin direction 0316 //! @param[in] theExtUMax Defines whether to extend the face in UMax direction 0317 //! @param[in] theExtVMin Defines whether to extend the face in VMin direction 0318 //! @param[in] theExtVMax Defines whether to extend the face in VMax direction 0319 //! @param[in] theFExtended The extended face 0320 Standard_EXPORT static void ExtendFace(const TopoDS_Face& theF, 0321 const double theExtVal, 0322 const bool theExtUMin, 0323 const bool theExtUMax, 0324 const bool theExtVMin, 0325 const bool theExtVMax, 0326 TopoDS_Face& theFExtended); 0327 }; 0328 0329 #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 |
|