|
|
|||
File indexing completed on 2026-10-04 09:14:19
0001 // Created on: 1995-11-02 0002 // Created by: Jacques GOUSSARD 0003 // Copyright (c) 1995-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 _GCPnts_QuasiUniformDeflection_HeaderFile 0018 #define _GCPnts_QuasiUniformDeflection_HeaderFile 0019 0020 #include <StdFail_NotDone.hxx> 0021 #include <NCollection_Sequence.hxx> 0022 #include <gp_Pnt.hxx> 0023 #include <GeomAbs_Shape.hxx> 0024 0025 class Adaptor3d_Curve; 0026 class Adaptor2d_Curve2d; 0027 class gp_Pnt; 0028 0029 //! This class computes a distribution of points on a curve. 0030 //! The points may respect the deflection. 0031 //! The algorithm is not based on the classical prediction (with second derivative of curve), 0032 //! but either on the evaluation of the distance between the mid point 0033 //! and the point of mid parameter of the two points, 0034 //! or the distance between the mid point and the point at parameter 0.5 0035 //! on the cubic interpolation of the two points and their tangents. 0036 //! 0037 //! Note: this algorithm is faster than a GCPnts_UniformDeflection algorithm, 0038 //! and is able to work with non-"C2" continuous curves. 0039 //! However, it generates more points in the distribution. 0040 class GCPnts_QuasiUniformDeflection 0041 { 0042 public: 0043 DEFINE_STANDARD_ALLOC 0044 0045 //! Constructs an empty algorithm. 0046 //! To define the problem to be solved, use the function Initialize(). 0047 Standard_EXPORT GCPnts_QuasiUniformDeflection(); 0048 0049 //! Computes a QuasiUniform Deflection distribution of points on the Curve. 0050 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor3d_Curve& theC, 0051 const double theDeflection, 0052 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0053 0054 //! Computes a QuasiUniform Deflection distribution of points on the Curve. 0055 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor2d_Curve2d& theC, 0056 const double theDeflection, 0057 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0058 0059 //! Computes a QuasiUniform Deflection distribution of points on a part of the Curve. 0060 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor3d_Curve& theC, 0061 const double theDeflection, 0062 const double theU1, 0063 const double theU2, 0064 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0065 0066 //! Computes a QuasiUniform Deflection distribution of points on a part of the Curve. 0067 //! This and the above algorithms compute a distribution of points: 0068 //! - on the curve theC, or 0069 //! - on the part of curve theC limited by the two parameter values theU1 and theU2, 0070 //! where the deflection resulting from the distributed 0071 //! points is not greater than theDeflection. 0072 //! 0073 //! The first point of the distribution is either the origin of 0074 //! curve theC or the point of parameter theU1. 0075 //! The last point of the distribution is either the end point 0076 //! of curve theC or the point of parameter theU2. 0077 //! 0078 //! Intermediate points of the distribution are built such 0079 //! that the deflection is not greater than theDeflection. 0080 //! Using the following evaluation of the deflection: 0081 //! if Pi and Pj are two consecutive points of the 0082 //! distribution, respectively of parameter ui and uj on the curve, 0083 //! the deflection is the distance between: 0084 //! - the mid-point of Pi and Pj (the center of the chord joining these two points) 0085 //! - and the point of mid-parameter of these two 0086 //! points (the point of parameter [(ui+uj) / 2] on curve theC). 0087 //! theContinuity, defaulted to GeomAbs_C1, gives the degree of continuity of the curve theC. 0088 //! (Note that C is an Adaptor3d_Curve or an Adaptor2d_Curve2d object, 0089 //! and does not know the degree of continuity of the underlying curve). 0090 //! Use the function IsDone() to verify that the computation was successful, 0091 //! the function NbPoints() to obtain the number of points of the computed distribution, 0092 //! and the function Parameter() to read the parameter of each point. 0093 //! 0094 //! Warning 0095 //! - The roles of theU1 and theU2 are inverted if theU1 > theU2. 0096 //! - Derivative functions on the curve are called according to theContinuity. 0097 //! An error may occur if theContinuity is greater than 0098 //! the real degree of continuity of the curve. 0099 //! 0100 //! Warning 0101 //! theC is an adapted curve, i.e. an object which is an interface between: 0102 //! - the services provided by either a 2D curve from 0103 //! the package Geom2d (in the case of an Adaptor2d_Curve2d curve) 0104 //! or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve), 0105 //! - and those required on the curve by the computation algorithm. 0106 Standard_EXPORT GCPnts_QuasiUniformDeflection(const Adaptor2d_Curve2d& theC, 0107 const double theDeflection, 0108 const double theU1, 0109 const double theU2, 0110 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0111 0112 //! Initialize the algorithms with 3D curve and deflection. 0113 Standard_EXPORT void Initialize(const Adaptor3d_Curve& theC, 0114 const double theDeflection, 0115 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0116 0117 //! Initialize the algorithms with 2D curve and deflection. 0118 Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& theC, 0119 const double theDeflection, 0120 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0121 0122 //! Initialize the algorithms with 3D curve, deflection and parameter range. 0123 Standard_EXPORT void Initialize(const Adaptor3d_Curve& theC, 0124 const double theDeflection, 0125 const double theU1, 0126 const double theU2, 0127 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0128 0129 //! Initialize the algorithms with theC, theDeflection, theU1, theU2. 0130 //! This and the above algorithms initialize (or reinitialize) 0131 //! this algorithm and compute a distribution of points: 0132 //! - on the curve theC, or 0133 //! - on the part of curve theC limited by the two parameter values theU1 and theU2, 0134 //! where the deflection resulting from the distributed 0135 //! points is not greater than theDeflection. 0136 //! 0137 //! The first point of the distribution is either the origin 0138 //! of curve theC or the point of parameter theU1. 0139 //! The last point of the distribution is either the end point of 0140 //! curve theC or the point of parameter theU2. 0141 //! 0142 //! Intermediate points of the distribution are built in 0143 //! such a way that the deflection is not greater than theDeflection. 0144 //! Using the following evaluation of the deflection: 0145 //! if Pi and Pj are two consecutive points of the distribution, 0146 //! respectively of parameter ui and uj on the curve, 0147 //! the deflection is the distance between: 0148 //! - the mid-point of Pi and Pj (the center of the chord joining these two points) 0149 //! - and the point of mid-parameter of these two 0150 //! points (the point of parameter [(ui+uj) / 2] on curve theC). 0151 //! theContinuity, defaulted to GeomAbs_C1, gives the degree of continuity of the curve theC. 0152 //! (Note that C is an Adaptor3d_Curve or an Adaptor2d_Curve2d object, 0153 //! and does not know the degree of continuity of the underlying curve). 0154 //! Use the function IsDone to verify that the computation was successful, 0155 //! the function NbPoints() to obtain the number of points of the computed distribution, 0156 //! and the function Parameter() to read the parameter of each point. 0157 //! 0158 //! Warning 0159 //! - The roles of theU1 and theU2 are inverted if theU1 > theU2. 0160 //! - Derivative functions on the curve are called according to theContinuity. 0161 //! An error may occur if theContinuity is greater than 0162 //! the real degree of continuity of the curve. 0163 //! 0164 //! Warning 0165 //! theC is an adapted curve, i.e. an object which is an interface between: 0166 //! - the services provided by either a 2D curve from 0167 //! the package Geom2d (in the case of an Adaptor2d_Curve2d curve) 0168 //! or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve), 0169 //! and those required on the curve by the computation algorithm. 0170 Standard_EXPORT void Initialize(const Adaptor2d_Curve2d& theC, 0171 const double theDeflection, 0172 const double theU1, 0173 const double theU2, 0174 const GeomAbs_Shape theContinuity = GeomAbs_C1); 0175 0176 //! Returns true if the computation was successful. 0177 //! IsDone is a protection against: 0178 //! - non-convergence of the algorithm 0179 //! - querying the results before computation. 0180 bool IsDone() const { return myDone; } 0181 0182 //! Returns the number of points of the distribution 0183 //! computed by this algorithm. 0184 //! Exceptions 0185 //! StdFail_NotDone if this algorithm has not been 0186 //! initialized, or if the computation was not successful. 0187 int NbPoints() const 0188 { 0189 StdFail_NotDone_Raise_if(!myDone, "GCPnts_QuasiUniformDeflection::NbPoints()"); 0190 return myParams.Length(); 0191 } 0192 0193 //! Returns the parameter of the point of index Index in 0194 //! the distribution computed by this algorithm. 0195 //! Warning 0196 //! Index must be greater than or equal to 1, and less 0197 //! than or equal to the number of points of the 0198 //! distribution. However, pay particular attention as this 0199 //! condition is not checked by this function. 0200 //! Exceptions 0201 //! StdFail_NotDone if this algorithm has not been 0202 //! initialized, or if the computation was not successful. 0203 double Parameter(const int Index) const 0204 { 0205 StdFail_NotDone_Raise_if(!myDone, "GCPnts_QuasiUniformDeflection::Parameter()"); 0206 return myParams(Index); 0207 } 0208 0209 //! Returns the point of index Index in the distribution 0210 //! computed by this algorithm. 0211 //! Warning 0212 //! Index must be greater than or equal to 1, and less 0213 //! than or equal to the number of points of the 0214 //! distribution. However, pay particular attention as this 0215 //! condition is not checked by this function. 0216 //! Exceptions 0217 //! StdFail_NotDone if this algorithm has not been 0218 //! initialized, or if the computation was not successful. 0219 Standard_EXPORT gp_Pnt Value(const int Index) const; 0220 0221 //! Returns the deflection between the curve and the 0222 //! polygon resulting from the points of the distribution 0223 //! computed by this algorithm. 0224 //! This is the value given to the algorithm at the time 0225 //! of construction (or initialization). 0226 //! Exceptions 0227 //! StdFail_NotDone if this algorithm has not been 0228 //! initialized, or if the computation was not successful. 0229 double Deflection() const 0230 { 0231 StdFail_NotDone_Raise_if(!myDone, "GCPnts_QuasiUniformDeflection::Deflection()"); 0232 return myDeflection; 0233 } 0234 0235 private: 0236 //! Initializes algorithm. 0237 template <class TheCurve> 0238 void initialize(const TheCurve& theC, 0239 const double theDeflection, 0240 const double theU1, 0241 const double theU2, 0242 const GeomAbs_Shape theContinuity); 0243 0244 private: 0245 bool myDone; 0246 double myDeflection; 0247 NCollection_Sequence<double> myParams; 0248 NCollection_Sequence<gp_Pnt> myPoints; 0249 GeomAbs_Shape myCont; 0250 }; 0251 0252 #endif // _GCPnts_QuasiUniformDeflection_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|