|
|
|||
File indexing completed on 2026-09-21 09:16:59
0001 // Created on: 1991-10-03 0002 // Created by: Jean Claude VAUTHIER 0003 // Copyright (c) 1991-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 _Geom2dConvert_HeaderFile 0018 #define _Geom2dConvert_HeaderFile 0019 0020 #include <Standard.hxx> 0021 #include <Standard_DefineAlloc.hxx> 0022 #include <Standard_Handle.hxx> 0023 0024 #include <Standard_Integer.hxx> 0025 #include <Standard_Boolean.hxx> 0026 #include <Standard_Real.hxx> 0027 #include <Convert_ParameterisationType.hxx> 0028 #include <Geom2d_BSplineCurve.hxx> 0029 #include <NCollection_Array1.hxx> 0030 #include <NCollection_HArray1.hxx> 0031 class Geom2d_BSplineCurve; 0032 class Geom2d_Curve; 0033 0034 //! This package provides an implementation of algorithms to do 0035 //! the conversion between equivalent geometric entities from 0036 //! package Geom2d. 0037 //! It gives the possibility : 0038 //! . to obtain the B-spline representation of bounded curves. 0039 //! . to split a B-spline curve into several B-spline curves 0040 //! with some constraints of continuity, 0041 //! . to convert a B-spline curve into several Bezier curves 0042 //! or surfaces. 0043 //! All the geometric entities used in this package are bounded. 0044 //! References : 0045 //! . Generating the Bezier Points of B-spline curves and surfaces 0046 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981 0047 //! . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and 0048 //! Application January 1991 0049 //! . Curve and surface construction using rational B-splines 0050 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november 0051 //! 1987 0052 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM) 0053 //! CAGD 1 1984 0054 class Geom2dConvert 0055 { 0056 public: 0057 DEFINE_STANDARD_ALLOC 0058 0059 //! Convert a curve to BSpline by Approximation 0060 //! 0061 //! This method computes the arc of B-spline curve between the two 0062 //! knots FromK1 and ToK2. If C is periodic the arc has the same 0063 //! orientation as C if SameOrientation = true. 0064 //! If C is not periodic SameOrientation is not used for the 0065 //! computation and C is oriented from the knot fromK1 to the 0066 //! knot toK2. 0067 //! We just keep the local definition of C between the knots 0068 //! FromK1 and ToK2. The returned B-spline curve has its first 0069 //! and last knots with a multiplicity equal to degree + 1, where 0070 //! degree is the polynomial degree of C. 0071 //! The indexes of the knots FromK1 and ToK2 doesn't include the 0072 //! repetition of multiple knots in their definition. 0073 //! 0074 //! Raised if FromK1 or ToK2 are out of the bounds 0075 //! [FirstUKnotIndex, LastUKnotIndex] 0076 //! Raised if FromK1 = ToK2 0077 Standard_EXPORT static occ::handle<Geom2d_BSplineCurve> SplitBSplineCurve( 0078 const occ::handle<Geom2d_BSplineCurve>& C, 0079 const int FromK1, 0080 const int ToK2, 0081 const bool SameOrientation = true); 0082 0083 //! This function computes the segment of B-spline curve between the 0084 //! parametric values FromU1, ToU2. 0085 //! If C is periodic the arc has the same orientation as C if 0086 //! SameOrientation = True. 0087 //! If C is not periodic SameOrientation is not used for the 0088 //! computation and C is oriented fromU1 toU2. 0089 //! If U1 and U2 and two parametric values we consider that 0090 //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and 0091 //! ParametricTolerance must be greater or equal to Resolution 0092 //! from package gp. 0093 //! 0094 //! Raised if FromU1 or ToU2 are out of the parametric bounds of the 0095 //! curve (The tolerance criterion is ParametricTolerance). 0096 //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance 0097 //! Raised if ParametricTolerance < Resolution from gp. 0098 Standard_EXPORT static occ::handle<Geom2d_BSplineCurve> SplitBSplineCurve( 0099 const occ::handle<Geom2d_BSplineCurve>& C, 0100 const double FromU1, 0101 const double ToU2, 0102 const double ParametricTolerance, 0103 const bool SameOrientation = true); 0104 0105 //! This function converts a non infinite curve from 0106 //! Geom into a B-spline curve. C must be an ellipse or a 0107 //! circle or a trimmed conic or a trimmed line or a Bezier 0108 //! curve or a trimmed Bezier curve or a BSpline curve or a 0109 //! trimmed BSpline curve or an Offset curve or a trimmed 0110 //! Offset curve. 0111 //! The returned B-spline is not periodic except if C is a 0112 //! Circle or an Ellipse. 0113 //! ParameterisationType applies only if the curve is a Circle 0114 //! or an ellipse : 0115 //! TgtThetaOver2, 0116 //! TgtThetaOver2_1, 0117 //! TgtThetaOver2_2, 0118 //! TgtThetaOver2_3, 0119 //! TgtThetaOver2_4, 0120 //! Purpose: this is the classical rational parameterisation 0121 //! 2 0122 //! 1 - t 0123 //! cos(theta) = ------ 0124 //! 2 0125 //! 1 + t 0126 //! 0127 //! 2t 0128 //! sin(theta) = ------ 0129 //! 2 0130 //! 1 + t 0131 //! 0132 //! t = tan (theta/2) 0133 //! 0134 //! with TgtThetaOver2 the routine will compute the number of spans 0135 //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1 0136 //! with TgtThetaOver2_N, N spans will be forced: an error will 0137 //! be raized if (ULast - UFirst) >= PI and N = 1, 0138 //! ULast - UFirst >= 2 PI and N = 2 0139 //! 0140 //! QuasiAngular, 0141 //! here t is a rational function that approximates 0142 //! theta ----> tan(theta/2). 0143 //! Nevetheless the composing with above function yields exact 0144 //! functions whose square sum up to 1 0145 //! RationalC1 ; 0146 //! t is replaced by a polynomial function of u so as to grant 0147 //! C1 contiuity across knots. 0148 //! Exceptions 0149 //! Standard_DomainError if the curve C is infinite. 0150 //! Standard_ConstructionError: 0151 //! - if C is a complete circle or ellipse, and if 0152 //! Parameterisation is not equal to 0153 //! Convert_TgtThetaOver2 or to Convert_RationalC1, or 0154 //! - if C is a trimmed circle or ellipse and if 0155 //! Parameterisation is equal to 0156 //! Convert_TgtThetaOver2_1 and if U2 - U1 > 0157 //! 0.9999 * Pi where U1 and U2 are 0158 //! respectively the first and the last parameters of the 0159 //! trimmed curve (this method of parameterization 0160 //! cannot be used to convert a half-circle or a 0161 //! half-ellipse, for example), or 0162 //! - if C is a trimmed circle or ellipse and 0163 //! Parameterisation is equal to 0164 //! Convert_TgtThetaOver2_2 and U2 - U1 > 0165 //! 1.9999 * Pi where U1 and U2 are 0166 //! respectively the first and the last parameters of the 0167 //! trimmed curve (this method of parameterization 0168 //! cannot be used to convert a quasi-complete circle or ellipse). 0169 Standard_EXPORT static occ::handle<Geom2d_BSplineCurve> CurveToBSplineCurve( 0170 const occ::handle<Geom2d_Curve>& C, 0171 const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2); 0172 0173 //! This Method concatenates G1 the ArrayOfCurves as far 0174 //! as it is possible. 0175 //! ArrayOfCurves[0..N-1] 0176 //! ArrayOfToler contains the biggest tolerance of the two 0177 //! points shared by two consecutives curves. 0178 //! Its dimension: [0..N-2] 0179 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0180 //! In this case ClosedTolerance contains the biggest tolerance 0181 //! of the two points which are at the closure. 0182 //! Otherwise its value is 0.0 0183 //! ClosedFlag becomes False on the output 0184 //! if it is impossible to build closed curve. 0185 Standard_EXPORT static void ConcatG1( 0186 NCollection_Array1<occ::handle<Geom2d_BSplineCurve>>& ArrayOfCurves, 0187 const NCollection_Array1<double>& ArrayOfToler, 0188 occ::handle<NCollection_HArray1<occ::handle<Geom2d_BSplineCurve>>>& ArrayOfConcatenated, 0189 bool& ClosedFlag, 0190 const double ClosedTolerance); 0191 0192 //! This Method concatenates C1 the ArrayOfCurves as far 0193 //! as it is possible. 0194 //! ArrayOfCurves[0..N-1] 0195 //! ArrayOfToler contains the biggest tolerance of the two 0196 //! points shared by two consecutives curves. 0197 //! Its dimension: [0..N-2] 0198 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0199 //! In this case ClosedTolerance contains the biggest tolerance 0200 //! of the two points which are at the closure. 0201 //! Otherwise its value is 0.0 0202 //! ClosedFlag becomes False on the output 0203 //! if it is impossible to build closed curve. 0204 Standard_EXPORT static void ConcatC1( 0205 NCollection_Array1<occ::handle<Geom2d_BSplineCurve>>& ArrayOfCurves, 0206 const NCollection_Array1<double>& ArrayOfToler, 0207 occ::handle<NCollection_HArray1<int>>& ArrayOfIndices, 0208 occ::handle<NCollection_HArray1<occ::handle<Geom2d_BSplineCurve>>>& ArrayOfConcatenated, 0209 bool& ClosedFlag, 0210 const double ClosedTolerance); 0211 0212 //! This Method concatenates C1 the ArrayOfCurves as far 0213 //! as it is possible. 0214 //! ArrayOfCurves[0..N-1] 0215 //! ArrayOfToler contains the biggest tolerance of the two 0216 //! points shared by two consecutives curves. 0217 //! Its dimension: [0..N-2] 0218 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0219 //! In this case ClosedTolerance contains the biggest tolerance 0220 //! of the two points which are at the closure. 0221 //! Otherwise its value is 0.0 0222 //! ClosedFlag becomes False on the output 0223 //! if it is impossible to build closed curve. 0224 Standard_EXPORT static void ConcatC1( 0225 NCollection_Array1<occ::handle<Geom2d_BSplineCurve>>& ArrayOfCurves, 0226 const NCollection_Array1<double>& ArrayOfToler, 0227 occ::handle<NCollection_HArray1<int>>& ArrayOfIndices, 0228 occ::handle<NCollection_HArray1<occ::handle<Geom2d_BSplineCurve>>>& ArrayOfConcatenated, 0229 bool& ClosedFlag, 0230 const double ClosedTolerance, 0231 const double AngularTolerance); 0232 0233 //! This Method reduces as far as it is possible the 0234 //! multiplicities of the knots of the BSpline BS.(keeping the geometry). 0235 //! It returns a new BSpline which could still be C0. 0236 //! tolerance is a geometrical tolerance 0237 Standard_EXPORT static void C0BSplineToC1BSplineCurve(occ::handle<Geom2d_BSplineCurve>& BS, 0238 const double Tolerance); 0239 0240 //! This Method reduces as far as it is possible the 0241 //! multiplicities of the knots of the BSpline BS.(keeping the geometry). 0242 //! It returns an array of BSpline C1. 0243 //! Tolerance is a geometrical tolerance 0244 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve( 0245 const occ::handle<Geom2d_BSplineCurve>& BS, 0246 occ::handle<NCollection_HArray1<occ::handle<Geom2d_BSplineCurve>>>& tabBS, 0247 const double Tolerance); 0248 0249 //! This Method reduces as far as it is possible the 0250 //! multiplicities of the knots of the BSpline BS.(keeping the geometry). 0251 //! It returns an array of BSpline C1. 0252 //! tolerance is a geometrical tolerance 0253 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve( 0254 const occ::handle<Geom2d_BSplineCurve>& BS, 0255 occ::handle<NCollection_HArray1<occ::handle<Geom2d_BSplineCurve>>>& tabBS, 0256 const double AngularTolerance, 0257 const double Tolerance); 0258 }; 0259 0260 #endif // _Geom2dConvert_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|