|
||||
File indexing completed on 2025-01-18 10:03:32
0001 // Created on: 1992-03-23 0002 // Created by: Herve LEGRAND 0003 // Copyright (c) 1992-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_UniformDeflection_HeaderFile 0018 #define _GCPnts_UniformDeflection_HeaderFile 0019 0020 #include <StdFail_NotDone.hxx> 0021 #include <TColStd_SequenceOfReal.hxx> 0022 #include <TColgp_SequenceOfPnt.hxx> 0023 0024 class Adaptor3d_Curve; 0025 class Adaptor2d_Curve2d; 0026 class gp_Pnt; 0027 0028 //! Provides an algorithm to compute a distribution of 0029 //! points on a 'C2' continuous curve. 0030 //! The algorithm respects a criterion of maximum deflection between 0031 //! the curve and the polygon that results from the computed points. 0032 //! Note: This algorithm is relatively time consuming. 0033 //! A GCPnts_QuasiUniformDeflection algorithm is quicker; 0034 //! it can also work with non-'C2' continuous curves, 0035 //! but it generates more points in the distribution. 0036 class GCPnts_UniformDeflection 0037 { 0038 public: 0039 0040 DEFINE_STANDARD_ALLOC 0041 0042 //! Constructs an empty algorithm. 0043 //! To define the problem to be solved, use the function Initialize. 0044 Standard_EXPORT GCPnts_UniformDeflection(); 0045 0046 //! Computes a uniform Deflection distribution of points on the curve. 0047 //! @param theC [in] input 3D curve 0048 //! @param theDeflection [in] target deflection 0049 //! @param theWithControl [in] when TRUE, the algorithm controls the estimate deflection 0050 Standard_EXPORT GCPnts_UniformDeflection (const Adaptor3d_Curve& theC, 0051 const Standard_Real theDeflection, 0052 const Standard_Boolean theWithControl = Standard_True); 0053 0054 //! Computes a uniform Deflection distribution of points on the curve. 0055 //! @param theC [in] input 2D curve 0056 //! @param theDeflection [in] target deflection 0057 //! @param theWithControl [in] when TRUE, the algorithm controls the estimate deflection 0058 Standard_EXPORT GCPnts_UniformDeflection (const Adaptor2d_Curve2d& theC, 0059 const Standard_Real theDeflection, 0060 const Standard_Boolean theWithControl = Standard_True); 0061 0062 //! Computes a Uniform Deflection distribution of points on a part of the curve. 0063 //! @param theC [in] input 3D curve 0064 //! @param theDeflection [in] target deflection 0065 //! @param theU1 [in] first parameter on curve 0066 //! @param theU2 [in] last parameter on curve 0067 //! @param theWithControl [in] when TRUE, the algorithm controls the estimate deflection 0068 Standard_EXPORT GCPnts_UniformDeflection (const Adaptor3d_Curve& theC, 0069 const Standard_Real theDeflection, 0070 const Standard_Real theU1, const Standard_Real theU2, 0071 const Standard_Boolean theWithControl = Standard_True); 0072 0073 //! Computes a Uniform Deflection distribution of points on a part of the curve. 0074 //! @param theC [in] input 2D curve 0075 //! @param theDeflection [in] target deflection 0076 //! @param theU1 [in] first parameter on curve 0077 //! @param theU2 [in] last parameter on curve 0078 //! @param theWithControl [in] when TRUE, the algorithm controls the estimate deflection 0079 Standard_EXPORT GCPnts_UniformDeflection (const Adaptor2d_Curve2d& theC, 0080 const Standard_Real theDeflection, 0081 const Standard_Real theU1, const Standard_Real theU2, 0082 const Standard_Boolean theWithControl = Standard_True); 0083 0084 //! Initialize the algorithms with 3D curve and deflection. 0085 Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC, 0086 const Standard_Real theDeflection, 0087 const Standard_Boolean theWithControl = Standard_True); 0088 0089 //! Initialize the algorithms with 2D curve and deflection. 0090 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC, 0091 const Standard_Real theDeflection, 0092 const Standard_Boolean theWithControl = Standard_True); 0093 0094 //! Initialize the algorithms with 3D curve, deflection, parameter range. 0095 Standard_EXPORT void Initialize (const Adaptor3d_Curve& theC, 0096 const Standard_Real theDeflection, 0097 const Standard_Real theU1, const Standard_Real theU2, 0098 const Standard_Boolean theWithControl = Standard_True); 0099 0100 //! Initialize the algorithms with curve, deflection, parameter range. 0101 //! This and the above methods initialize (or reinitialize) this algorithm and 0102 //! compute a distribution of points: 0103 //! - on the curve theC, or 0104 //! - on the part of curve theC limited by the two parameter values theU1 and theU2, 0105 //! where the maximum distance between theC and the 0106 //! polygon that results from the points of the 0107 //! distribution is not greater than theDeflection. 0108 //! The first point of the distribution is either the origin 0109 //! of curve theC or the point of parameter theU1. 0110 //! The last point of the distribution is either the end point of 0111 //! curve theC or the point of parameter theU2. 0112 //! Intermediate points of the distribution are built using 0113 //! interpolations of segments of the curve limited at the 2nd degree. 0114 //! The construction ensures, in a first step, 0115 //! that the chordal deviation for this 0116 //! interpolation of the curve is less than or equal to theDeflection. 0117 //! However, it does not ensure that the chordal deviation 0118 //! for the curve itself is less than or equal to theDeflection. 0119 //! To do this a check is necessary, 0120 //! which may generate (second step) additional intermediate points. 0121 //! This check is time consuming, and can be avoided by setting theWithControl to false. 0122 //! Note that by default theWithControl is true and check is performed. 0123 //! Use the function IsDone to verify that the computation was successful, 0124 //! the function NbPoints() to obtain the number of points of the computed distribution, 0125 //! and the function Parameter to read the parameter of each point. 0126 //! 0127 //! Warning 0128 //! - theC is necessary, 'C2' continuous. 0129 //! This property is not checked at construction time. 0130 //! - The roles of theU1 and theU2 are inverted if theU1 > theU2. 0131 //! 0132 //! Warning 0133 //! theC is an adapted curve, i.e. an object which is an interface between: 0134 //! - the services provided by either a 2D curve from 0135 //! the package Geom2d (in the case of an Adaptor2d_Curve2d curve) 0136 //! or a 3D curve from the package Geom (in the case of an Adaptor3d_Curve curve), 0137 //! - and those required on the curve by the computation algorithm. 0138 Standard_EXPORT void Initialize (const Adaptor2d_Curve2d& theC, 0139 const Standard_Real theDeflection, 0140 const Standard_Real theU1, const Standard_Real theU2, 0141 const Standard_Boolean theWithControl = Standard_True); 0142 0143 //! Returns true if the computation was successful. 0144 //! IsDone is a protection against: 0145 //! - non-convergence of the algorithm 0146 //! - querying the results before computation. 0147 Standard_Boolean IsDone () const 0148 { 0149 return myDone; 0150 } 0151 0152 //! Returns the number of points of the distribution 0153 //! computed by this algorithm. 0154 //! Exceptions 0155 //! StdFail_NotDone if this algorithm has not been 0156 //! initialized, or if the computation was not successful. 0157 Standard_Integer NbPoints () const 0158 { 0159 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::NbPoints()"); 0160 return myParams.Length (); 0161 } 0162 0163 //! Returns the parameter of the point of index Index in 0164 //! the distribution computed by this algorithm. 0165 //! Warning 0166 //! Index must be greater than or equal to 1, and less 0167 //! than or equal to the number of points of the 0168 //! distribution. However, pay particular attention as this 0169 //! condition is not checked by this function. 0170 //! Exceptions 0171 //! StdFail_NotDone if this algorithm has not been 0172 //! initialized, or if the computation was not successful. 0173 Standard_Real Parameter (const Standard_Integer Index) const 0174 { 0175 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Parameter()"); 0176 return myParams (Index); 0177 } 0178 0179 //! Returns the point of index Index in the distribution 0180 //! computed by this algorithm. 0181 //! Warning 0182 //! Index must be greater than or equal to 1, and less 0183 //! than or equal to the number of points of the 0184 //! distribution. However, pay particular attention as this 0185 //! condition is not checked by this function. 0186 //! Exceptions 0187 //! StdFAil_NotDone if this algorithm has not been 0188 //! initialized, or if the computation was not successful. 0189 Standard_EXPORT gp_Pnt Value (const Standard_Integer Index) const; 0190 0191 //! Returns the deflection between the curve and the 0192 //! polygon resulting from the points of the distribution 0193 //! computed by this algorithm. 0194 //! This value is the one given to the algorithm at the 0195 //! time of construction (or initialization). 0196 //! Exceptions 0197 //! StdFail_NotDone if this algorithm has not been 0198 //! initialized, or if the computation was not successful. 0199 Standard_Real Deflection () const 0200 { 0201 StdFail_NotDone_Raise_if (!myDone, "GCPnts_UniformDeflection::Deflection()"); 0202 return myDeflection; 0203 } 0204 0205 private: 0206 0207 //! Initialize the algorithm. 0208 template<class TheCurve> 0209 void initialize (const TheCurve& theC, 0210 const Standard_Real theDeflection, 0211 const Standard_Real theU1, 0212 const Standard_Real theU2, 0213 const Standard_Boolean theWithControl); 0214 0215 private: 0216 Standard_Boolean myDone; 0217 Standard_Real myDeflection; 0218 TColStd_SequenceOfReal myParams; 0219 TColgp_SequenceOfPnt myPoints; 0220 }; 0221 0222 #endif // _GCPnts_UniformDeflection_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |