|
|
|||
File indexing completed on 2026-09-20 09:17:09
0001 // Copyright (c) 2013 OPEN CASCADE SAS 0002 // 0003 // This file is part of Open CASCADE Technology software library. 0004 // 0005 // This library is free software; you can redistribute it and/or modify it under 0006 // the terms of the GNU Lesser General Public License version 2.1 as published 0007 // by the Free Software Foundation, with special exception defined in the file 0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0009 // distribution for complete text of the license and disclaimer of any warranty. 0010 // 0011 // Alternatively, this file may be used under the terms of Open CASCADE 0012 // commercial license or contractual agreement. 0013 0014 #ifndef _BRepMesh_GeomTool_HeaderFile 0015 #define _BRepMesh_GeomTool_HeaderFile 0016 0017 #include <BRepAdaptor_Surface.hxx> 0018 #include <GCPnts_TangentialDeflection.hxx> 0019 #include <GeomAbs_IsoType.hxx> 0020 #include <TopoDS_Edge.hxx> 0021 #include <Precision.hxx> 0022 0023 class BRepAdaptor_Curve; 0024 class gp_Pnt2d; 0025 class BRepMesh_DefaultRangeSplitter; 0026 0027 //! Tool class accumulating common geometrical functions as well as 0028 //! functionality using shape geometry to produce data necessary for 0029 //! tessellation. 0030 //! General aim is to calculate discretization points for the given 0031 //! curve or iso curve of surface according to the specified parameters. 0032 class BRepMesh_GeomTool 0033 { 0034 public: 0035 //! Enumerates states of segments intersection check. 0036 enum IntFlag 0037 { 0038 NoIntersection, 0039 Cross, 0040 EndPointTouch, 0041 PointOnSegment, 0042 Glued, 0043 Same 0044 }; 0045 0046 public: 0047 DEFINE_STANDARD_ALLOC 0048 0049 //! Constructor. 0050 //! Initiates discretization of the given geometric curve. 0051 //! @param theCurve curve to be discretized. 0052 //! @param theFirstParam first parameter of the curve. 0053 //! @param theLastParam last parameter of the curve. 0054 //! @param theLinDeflection linear deflection. 0055 //! @param theAngDeflection angular deflection. 0056 //! @param theMinPointsNb minimum number of points to be produced. 0057 Standard_EXPORT BRepMesh_GeomTool(const BRepAdaptor_Curve& theCurve, 0058 const double theFirstParam, 0059 const double theLastParam, 0060 const double theLinDeflection, 0061 const double theAngDeflection, 0062 const int theMinPointsNb = 2, 0063 const double theMinSize = Precision::Confusion()); 0064 0065 //! Constructor. 0066 //! Initiates discretization of geometric curve corresponding 0067 //! to iso curve of the given surface. 0068 //! @param theSurface surface the iso curve to be taken from. 0069 //! @param theIsoType type of iso curve to be used, U or V. 0070 //! @param theParamIso parameter on the surface specifying the iso curve. 0071 //! @param theFirstParam first parameter of the curve. 0072 //! @param theLastParam last parameter of the curve. 0073 //! @param theLinDeflection linear deflection. 0074 //! @param theAngDeflection angular deflection. 0075 //! @param theMinPointsNb minimum number of points to be produced. 0076 Standard_EXPORT BRepMesh_GeomTool(const occ::handle<BRepAdaptor_Surface>& theSurface, 0077 const GeomAbs_IsoType theIsoType, 0078 const double theParamIso, 0079 const double theFirstParam, 0080 const double theLastParam, 0081 const double theLinDeflection, 0082 const double theAngDeflection, 0083 const int theMinPointsNb = 2, 0084 const double theMinSize = Precision::Confusion()); 0085 0086 //! Adds point to already calculated points (or replaces existing). 0087 //! @param thePoint point to be added. 0088 //! @param theParam parameter on the curve corresponding to the given point. 0089 //! @param theIsReplace if TRUE replaces existing point lying within 0090 //! parametric tolerance of the given point. 0091 //! @return index of new added point or found with parametric tolerance 0092 int AddPoint(const gp_Pnt& thePoint, const double theParam, const bool theIsReplace = true) 0093 { 0094 return myDiscretTool.AddPoint(thePoint, theParam, theIsReplace); 0095 } 0096 0097 //! Returns number of discretization points. 0098 int NbPoints() const { return myDiscretTool.NbPoints(); } 0099 0100 //! Gets parameters of discretization point with the given index. 0101 //! @param theIndex index of discretization point. 0102 //! @param theIsoParam parameter on surface to be used as second coordinate 0103 //! of resulting 2d point. 0104 //! @param[out] theParam parameter of the point on the iso curve. 0105 //! @param[out] thePoint discretization point. 0106 //! @param[out] theUV discretization point in parametric space of the surface. 0107 //! @return TRUE on success, FALSE elsewhere. 0108 Standard_EXPORT bool Value(const int theIndex, 0109 const double theIsoParam, 0110 double& theParam, 0111 gp_Pnt& thePoint, 0112 gp_Pnt2d& theUV) const; 0113 0114 //! Gets parameters of discretization point with the given index. 0115 //! @param theIndex index of discretization point. 0116 //! @param theSurface surface the curve is lying onto. 0117 //! @param[out] theParam parameter of the point on the curve. 0118 //! @param[out] thePoint discretization point. 0119 //! @param[out] theUV discretization point in parametric space of the surface. 0120 //! @return TRUE on success, FALSE elsewhere. 0121 Standard_EXPORT bool Value(const int theIndex, 0122 const occ::handle<BRepAdaptor_Surface>& theSurface, 0123 double& theParam, 0124 gp_Pnt& thePoint, 0125 gp_Pnt2d& theUV) const; 0126 0127 public: //! @name static API 0128 //! Computes normal to the given surface at the specified 0129 //! position in parametric space. 0130 //! @param theSurface surface the normal should be found for. 0131 //! @param theParamU U parameter in parametric space of the surface. 0132 //! @param theParamV V parameter in parametric space of the surface. 0133 //! @param[out] thePoint 3d point corresponding to the given parameters. 0134 //! @param[out] theNormal normal vector at the point specified by the parameters. 0135 //! @return FALSE if the normal can not be computed, TRUE elsewhere. 0136 Standard_EXPORT static bool Normal(const occ::handle<BRepAdaptor_Surface>& theSurface, 0137 const double theParamU, 0138 const double theParamV, 0139 gp_Pnt& thePoint, 0140 gp_Dir& theNormal); 0141 0142 //! Checks intersection between two lines defined by two points. 0143 //! @param theStartPnt1 start point of first line. 0144 //! @param theEndPnt1 end point of first line. 0145 //! @param theStartPnt2 start point of second line. 0146 //! @param theEndPnt2 end point of second line. 0147 //! @param[out] theIntPnt point of intersection. 0148 //! @param[out] theParamOnSegment parameters of intersection point 0149 //! corresponding to first and second segment. 0150 //! @return status of intersection check. 0151 Standard_EXPORT static IntFlag IntLinLin(const gp_XY& theStartPnt1, 0152 const gp_XY& theEndPnt1, 0153 const gp_XY& theStartPnt2, 0154 const gp_XY& theEndPnt2, 0155 gp_XY& theIntPnt, 0156 double (&theParamOnSegment)[2]); 0157 0158 //! Checks intersection between the two segments. 0159 //! Checks that intersection point lies within ranges of both segments. 0160 //! @param theStartPnt1 start point of first segment. 0161 //! @param theEndPnt1 end point of first segment. 0162 //! @param theStartPnt2 start point of second segment. 0163 //! @param theEndPnt2 end point of second segment. 0164 //! @param isConsiderEndPointTouch if TRUE EndPointTouch status will be 0165 //! returned in case if segments are touching by end points, if FALSE 0166 //! returns NoIntersection flag. 0167 //! @param isConsiderPointOnSegment if TRUE PointOnSegment status will be 0168 //! returned in case if end point of one segment lies onto another one, 0169 //! if FALSE returns NoIntersection flag. 0170 //! @param[out] theIntPnt point of intersection. 0171 //! @return status of intersection check. 0172 Standard_EXPORT static IntFlag IntSegSeg(const gp_XY& theStartPnt1, 0173 const gp_XY& theEndPnt1, 0174 const gp_XY& theStartPnt2, 0175 const gp_XY& theEndPnt2, 0176 const bool isConsiderEndPointTouch, 0177 const bool isConsiderPointOnSegment, 0178 gp_Pnt2d& theIntPnt); 0179 0180 //! Compute deflection of the given segment. 0181 static double SquareDeflectionOfSegment(const gp_Pnt& theFirstPoint, 0182 const gp_Pnt& theLastPoint, 0183 const gp_Pnt& theMidPoint) 0184 { 0185 // 23.03.2010 skl for OCC21645 - change precision for comparison 0186 if (theFirstPoint.SquareDistance(theLastPoint) > Precision::SquareConfusion()) 0187 { 0188 gp_Lin aLin(theFirstPoint, gp_Dir(gp_Vec(theFirstPoint, theLastPoint))); 0189 return aLin.SquareDistance(theMidPoint); 0190 } 0191 0192 return theFirstPoint.SquareDistance(theMidPoint); 0193 } 0194 0195 // For better meshing performance we try to estimate the acceleration circles grid structure 0196 // sizes: For each parametric direction (U, V) we estimate firstly an approximate distance between 0197 // the future points - this estimation takes into account the required face deflection and the 0198 // complexity of the face. Particularly, the complexity of the faces based on BSpline curves and 0199 // surfaces requires much more points. At the same time, for planar faces and linear parts of the 0200 // arbitrary surfaces usually no intermediate points are necessary. The general idea for each 0201 // parametric direction: cells_count = 2 ^ log10 ( estimated_points_count ) For linear parametric 0202 // direction we fall back to the initial vertex count: cells_count = 2 ^ log10 ( 0203 // initial_vertex_count ) 0204 Standard_EXPORT static std::pair<int, int> CellsCount( 0205 const occ::handle<Adaptor3d_Surface>& theSurface, 0206 const int theVerticesNb, 0207 const double theDeflection, 0208 const BRepMesh_DefaultRangeSplitter* theRangeSplitter); 0209 0210 private: 0211 //! Classifies the point in case of coincidence of two vectors. 0212 //! @param thePoint1 the start point of a segment (base point). 0213 //! @param thePoint2 the end point of a segment. 0214 //! @param thePointToCheck the point to classify. 0215 //! @return zero value if point is out of segment and non zero value 0216 //! if point is between the first and the second point of segment. 0217 static int classifyPoint(const gp_XY& thePoint1, 0218 const gp_XY& thePoint2, 0219 const gp_XY& thePointToCheck); 0220 0221 private: 0222 const TopoDS_Edge* myEdge; 0223 GCPnts_TangentialDeflection myDiscretTool; 0224 GeomAbs_IsoType myIsoType; 0225 }; 0226 0227 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|