|
|
|||
File indexing completed on 2026-09-17 09:20:29
0001 // Created on: 1991-10-03 0002 // Created by: JeanClaude 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 _GeomConvert_HeaderFile 0018 #define _GeomConvert_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 <Geom_BSplineCurve.hxx> 0029 #include <NCollection_Array1.hxx> 0030 #include <NCollection_HArray1.hxx> 0031 class Geom_BSplineCurve; 0032 class Geom_BSplineSurface; 0033 class Geom_Curve; 0034 class Geom_Surface; 0035 0036 //! The GeomConvert package provides some global functions as follows 0037 //! - converting classical Geom curves into BSpline curves, 0038 //! - segmenting BSpline curves, particularly at knots 0039 //! values: this function may be used in conjunction with the 0040 //! GeomConvert_BSplineCurveKnotSplitting 0041 //! class to segment a BSpline curve into arcs which 0042 //! comply with required continuity levels, 0043 //! - converting classical Geom surfaces into BSpline surfaces, and 0044 //! - segmenting BSpline surfaces, particularly at 0045 //! knots values: this function may be used in conjunction with the 0046 //! GeomConvert_BSplineSurfaceKnotSplitting 0047 //! class to segment a BSpline surface into patches 0048 //! which comply with required continuity levels. 0049 //! All geometric entities used in this package are bounded. 0050 //! 0051 //! References : 0052 //! . Generating the Bezier Points of B-spline curves and surfaces 0053 //! (Wolfgang Bohm) CAGD volume 13 number 6 november 1981 0054 //! . On NURBS: A Survey (Leslie Piegl) IEEE Computer Graphics and 0055 //! Application January 1991 0056 //! . Curve and surface construction using rational B-splines 0057 //! (Leslie Piegl and Wayne Tiller) CAD Volume 19 number 9 november 0058 //! 1987 0059 //! . A survey of curve and surface methods in CAGD (Wolfgang BOHM) 0060 //! CAGD 1 1984 0061 class GeomConvert 0062 { 0063 public: 0064 DEFINE_STANDARD_ALLOC 0065 0066 //! Convert a curve from Geom by an approximation method 0067 //! 0068 //! This method computes the arc of B-spline curve between the two 0069 //! knots FromK1 and ToK2. If C is periodic the arc has the same 0070 //! orientation as C if SameOrientation = true. 0071 //! If C is not periodic SameOrientation is not used for the 0072 //! computation and C is oriented from the knot fromK1 to the knot toK2. 0073 //! We just keep the local definition of C between the knots 0074 //! FromK1 and ToK2. The returned B-spline curve has its first 0075 //! and last knots with a multiplicity equal to degree + 1, where 0076 //! degree is the polynomial degree of C. 0077 //! The indexes of the knots FromK1 and ToK2 doesn't include the 0078 //! repetition of multiple knots in their definition. 0079 //! Raised if FromK1 = ToK2 0080 //! Raised if FromK1 or ToK2 are out of the bounds 0081 //! [FirstUKnotIndex, LastUKnotIndex] 0082 Standard_EXPORT static occ::handle<Geom_BSplineCurve> SplitBSplineCurve( 0083 const occ::handle<Geom_BSplineCurve>& C, 0084 const int FromK1, 0085 const int ToK2, 0086 const bool SameOrientation = true); 0087 0088 //! This function computes the segment of B-spline curve between the 0089 //! parametric values FromU1, ToU2. 0090 //! If C is periodic the arc has the same orientation as C if 0091 //! SameOrientation = True. 0092 //! If C is not periodic SameOrientation is not used for the 0093 //! computation and C is oriented fromU1 toU2. 0094 //! If U1 and U2 and two parametric values we consider that 0095 //! U1 = U2 if Abs (U1 - U2) <= ParametricTolerance and 0096 //! ParametricTolerance must be greater or equal to Resolution 0097 //! from package gp. 0098 //! 0099 //! Raised if FromU1 or ToU2 are out of the parametric bounds of the 0100 //! curve (The tolerance criterion is ParametricTolerance). 0101 //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance 0102 //! Raised if ParametricTolerance < Resolution from gp. 0103 Standard_EXPORT static occ::handle<Geom_BSplineCurve> SplitBSplineCurve( 0104 const occ::handle<Geom_BSplineCurve>& C, 0105 const double FromU1, 0106 const double ToU2, 0107 const double ParametricTolerance, 0108 const bool SameOrientation = true); 0109 0110 //! Computes the B-spline surface patche between the knots values 0111 //! FromUK1, ToUK2, FromVK1, ToVK2. 0112 //! If S is periodic in one direction the patche has the same 0113 //! orientation as S in this direction if the flag is true in this 0114 //! direction (SameUOrientation, SameVOrientation). 0115 //! If S is not periodic SameUOrientation and SameVOrientation are not 0116 //! used for the computation and S is oriented FromUK1 ToUK2 and 0117 //! FromVK1 ToVK2. 0118 //! Raised if 0119 //! FromUK1 = ToUK2 or FromVK1 = ToVK2 0120 //! FromUK1 or ToUK2 are out of the bounds 0121 //! [FirstUKnotIndex, LastUKnotIndex] 0122 //! FromVK1 or ToVK2 are out of the bounds 0123 //! [FirstVKnotIndex, LastVKnotIndex] 0124 Standard_EXPORT static occ::handle<Geom_BSplineSurface> SplitBSplineSurface( 0125 const occ::handle<Geom_BSplineSurface>& S, 0126 const int FromUK1, 0127 const int ToUK2, 0128 const int FromVK1, 0129 const int ToVK2, 0130 const bool SameUOrientation = true, 0131 const bool SameVOrientation = true); 0132 0133 //! This method splits a B-spline surface patche between the 0134 //! knots values FromK1, ToK2 in one direction. 0135 //! If USplit = True then the splitting direction is the U parametric 0136 //! direction else it is the V parametric direction. 0137 //! If S is periodic in the considered direction the patche has the 0138 //! same orientation as S in this direction if SameOrientation is True 0139 //! If S is not periodic in this direction SameOrientation is not used 0140 //! for the computation and S is oriented FromK1 ToK2. 0141 //! Raised if FromK1 = ToK2 or if 0142 //! FromK1 or ToK2 are out of the bounds 0143 //! [FirstUKnotIndex, LastUKnotIndex] in the 0144 //! considered parametric direction. 0145 Standard_EXPORT static occ::handle<Geom_BSplineSurface> SplitBSplineSurface( 0146 const occ::handle<Geom_BSplineSurface>& S, 0147 const int FromK1, 0148 const int ToK2, 0149 const bool USplit, 0150 const bool SameOrientation = true); 0151 0152 //! This method computes the B-spline surface patche between the 0153 //! parametric values FromU1, ToU2, FromV1, ToV2. 0154 //! If S is periodic in one direction the patche has the same 0155 //! orientation as S in this direction if the flag is True in this 0156 //! direction (SameUOrientation, SameVOrientation). 0157 //! If S is not periodic SameUOrientation and SameVOrientation are not 0158 //! used for the computation and S is oriented FromU1 ToU2 and 0159 //! FromV1 ToV2. 0160 //! If U1 and U2 and two parametric values we consider that U1 = U2 if 0161 //! Abs (U1 - U2) <= ParametricTolerance and ParametricTolerance must 0162 //! be greater or equal to Resolution from package gp. 0163 //! 0164 //! Raised if FromU1 or ToU2 or FromV1 or ToU2 are out of the 0165 //! parametric bounds of the surface (the tolerance criterion is 0166 //! ParametricTolerance). 0167 //! Raised if Abs (FromU1 - ToU2) <= ParametricTolerance or 0168 //! Abs (FromV1 - ToV2) <= ParametricTolerance. 0169 //! Raised if ParametricTolerance < Resolution. 0170 Standard_EXPORT static occ::handle<Geom_BSplineSurface> SplitBSplineSurface( 0171 const occ::handle<Geom_BSplineSurface>& S, 0172 const double FromU1, 0173 const double ToU2, 0174 const double FromV1, 0175 const double ToV2, 0176 const double ParametricTolerance, 0177 const bool SameUOrientation = true, 0178 const bool SameVOrientation = true); 0179 0180 //! This method splits the B-spline surface S in one direction 0181 //! between the parametric values FromParam1, ToParam2. 0182 //! If USplit = True then the Splitting direction is the U parametric 0183 //! direction else it is the V parametric direction. 0184 //! If S is periodic in the considered direction the patche has 0185 //! the same orientation as S in this direction if SameOrientation 0186 //! is true. 0187 //! If S is not periodic in the considered direction SameOrientation 0188 //! is not used for the computation and S is oriented FromParam1 0189 //! ToParam2. 0190 //! If U1 and U2 and two parametric values we consider that U1 = U2 0191 //! if Abs (U1 - U2) <= ParametricTolerance and ParametricTolerance 0192 //! must be greater or equal to Resolution from package gp. 0193 //! 0194 //! Raises if FromParam1 or ToParam2 are out of the parametric bounds 0195 //! of the surface in the considered direction. 0196 //! Raises if Abs (FromParam1 - ToParam2) <= ParametricTolerance. 0197 Standard_EXPORT static occ::handle<Geom_BSplineSurface> SplitBSplineSurface( 0198 const occ::handle<Geom_BSplineSurface>& S, 0199 const double FromParam1, 0200 const double ToParam2, 0201 const bool USplit, 0202 const double ParametricTolerance, 0203 const bool SameOrientation = true); 0204 0205 //! This function converts a non infinite curve from 0206 //! Geom into a B-spline curve. C must be an ellipse or a 0207 //! circle or a trimmed conic or a trimmed line or a Bezier 0208 //! curve or a trimmed Bezier curve or a BSpline curve or a 0209 //! trimmed BSpline curve or an OffsetCurve. The returned B-spline is 0210 //! not periodic except if C is a Circle or an Ellipse. If 0211 //! the Parameterisation is QuasiAngular than the returned 0212 //! curve is NOT periodic in case a periodic Geom_Circle or 0213 //! Geom_Ellipse. For TgtThetaOver2_1 and TgtThetaOver2_2 the 0214 //! method raises an exception in case of a periodic 0215 //! Geom_Circle or a Geom_Ellipse ParameterisationType applies 0216 //! only if the curve is a Circle or an ellipse: 0217 //! TgtThetaOver2, TgtThetaOver2_1, TgtThetaOver2_2, 0218 //! TgtThetaOver2_3, TgtThetaOver2_4, 0219 //! 0220 //! Purpose: this is the classical rational parameterisation 0221 //! 2 0222 //! 1 - t 0223 //! cos(theta) = ------ 0224 //! 2 0225 //! 1 + t 0226 //! 0227 //! 2t 0228 //! sin(theta) = ------ 0229 //! 2 0230 //! 1 + t 0231 //! 0232 //! t = tan (theta/2) 0233 //! 0234 //! with TgtThetaOver2 the routine will compute the number of spans 0235 //! using the rule num_spans = [ (ULast - UFirst) / 1.2 ] + 1 0236 //! with TgtThetaOver2_N, N spans will be forced: an error will 0237 //! be raized if (ULast - UFirst) >= PI and N = 1, 0238 //! ULast - UFirst >= 2 PI and N = 2 0239 //! 0240 //! QuasiAngular, 0241 //! here t is a rational function that approximates 0242 //! theta ----> tan(theta/2). 0243 //! Nevetheless the composing with above function yields exact 0244 //! functions whose square sum up to 1 0245 //! RationalC1 ; 0246 //! t is replaced by a polynomial function of u so as to grant 0247 //! C1 contiuity across knots. 0248 //! Exceptions 0249 //! Standard_DomainError: 0250 //! - if the curve C is infinite, or 0251 //! - if C is a (complete) circle or ellipse, and Parameterisation is equal to 0252 //! Convert_TgtThetaOver2_1 or Convert_TgtThetaOver2_2. 0253 //! Standard_ConstructionError: 0254 //! - if C is a (complete) circle or ellipse, and if Parameterisation is not equal to 0255 //! Convert_TgtThetaOver2, Convert_RationalC1, 0256 //! Convert_QuasiAngular (the curve is converted 0257 //! in these three cases) or to Convert_TgtThetaOver2_1 or 0258 //! Convert_TgtThetaOver2_2 (another exception is raised in these two cases). 0259 //! - if C is a trimmed circle or ellipse, if Parameterisation is equal to 0260 //! Convert_TgtThetaOver2_1 and if U2 - U1 > 0.9999 * Pi, where U1 and U2 are 0261 //! respectively the first and the last parameters of the 0262 //! trimmed curve (this method of parameterization 0263 //! cannot be used to convert a half-circle or a half-ellipse, for example), or 0264 //! - if C is a trimmed circle or ellipse, if 0265 //! Parameterisation is equal to Convert_TgtThetaOver2_2 and U2 - U1 > 0266 //! 1.9999 * Pi where U1 and U2 are 0267 //! respectively the first and the last parameters of the 0268 //! trimmed curve (this method of parameterization 0269 //! cannot be used to convert a quasi-complete circle or ellipse). 0270 Standard_EXPORT static occ::handle<Geom_BSplineCurve> CurveToBSplineCurve( 0271 const occ::handle<Geom_Curve>& C, 0272 const Convert_ParameterisationType Parameterisation = Convert_TgtThetaOver2); 0273 0274 //! This algorithm converts a non infinite surface from Geom 0275 //! into a B-spline surface. 0276 //! S must be a trimmed plane or a trimmed cylinder or a trimmed cone 0277 //! or a trimmed sphere or a trimmed torus or a sphere or a torus or 0278 //! a Bezier surface of a trimmed Bezier surface or a trimmed swept 0279 //! surface with a corresponding basis curve which can be turned into 0280 //! a B-spline curve (see the method CurveToBSplineCurve). 0281 //! Raises DomainError if the type of the surface is not previously defined. 0282 Standard_EXPORT static occ::handle<Geom_BSplineSurface> SurfaceToBSplineSurface( 0283 const occ::handle<Geom_Surface>& S); 0284 0285 //! This Method concatenates G1 the ArrayOfCurves as far 0286 //! as it is possible. 0287 //! ArrayOfCurves[0..N-1] 0288 //! ArrayOfToler contains the biggest tolerance of the two 0289 //! points shared by two consecutives curves. 0290 //! Its dimension: [0..N-2] 0291 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0292 //! In this case ClosedTolerance contains the biggest tolerance 0293 //! of the two points which are at the closure. 0294 //! Otherwise its value is 0.0 0295 //! ClosedFlag becomes False on the output 0296 //! if it is impossible to build closed curve. 0297 Standard_EXPORT static void ConcatG1( 0298 NCollection_Array1<occ::handle<Geom_BSplineCurve>>& ArrayOfCurves, 0299 const NCollection_Array1<double>& ArrayOfToler, 0300 occ::handle<NCollection_HArray1<occ::handle<Geom_BSplineCurve>>>& ArrayOfConcatenated, 0301 bool& ClosedFlag, 0302 const double ClosedTolerance); 0303 0304 //! This Method concatenates C1 the ArrayOfCurves as far 0305 //! as it is possible. 0306 //! ArrayOfCurves[0..N-1] 0307 //! ArrayOfToler contains the biggest tolerance of the two 0308 //! points shared by two consecutives curves. 0309 //! Its dimension: [0..N-2] 0310 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0311 //! In this case ClosedTolerance contains the biggest tolerance 0312 //! of the two points which are at the closure. 0313 //! Otherwise its value is 0.0 0314 //! ClosedFlag becomes False on the output 0315 //! if it is impossible to build closed curve. 0316 Standard_EXPORT static void ConcatC1( 0317 NCollection_Array1<occ::handle<Geom_BSplineCurve>>& ArrayOfCurves, 0318 const NCollection_Array1<double>& ArrayOfToler, 0319 occ::handle<NCollection_HArray1<int>>& ArrayOfIndices, 0320 occ::handle<NCollection_HArray1<occ::handle<Geom_BSplineCurve>>>& ArrayOfConcatenated, 0321 bool& ClosedFlag, 0322 const double ClosedTolerance); 0323 0324 //! This Method concatenates C1 the ArrayOfCurves as far 0325 //! as it is possible. 0326 //! ArrayOfCurves[0..N-1] 0327 //! ArrayOfToler contains the biggest tolerance of the two 0328 //! points shared by two consecutives curves. 0329 //! Its dimension: [0..N-2] 0330 //! ClosedFlag indicates if the ArrayOfCurves is closed. 0331 //! In this case ClosedTolerance contains the biggest tolerance 0332 //! of the two points which are at the closure. 0333 //! Otherwise its value is 0.0 0334 //! ClosedFlag becomes False on the output 0335 //! if it is impossible to build closed curve. 0336 Standard_EXPORT static void ConcatC1( 0337 NCollection_Array1<occ::handle<Geom_BSplineCurve>>& ArrayOfCurves, 0338 const NCollection_Array1<double>& ArrayOfToler, 0339 occ::handle<NCollection_HArray1<int>>& ArrayOfIndices, 0340 occ::handle<NCollection_HArray1<occ::handle<Geom_BSplineCurve>>>& ArrayOfConcatenated, 0341 bool& ClosedFlag, 0342 const double ClosedTolerance, 0343 const double AngularTolerance); 0344 0345 //! This Method reduces as far as it is possible the 0346 //! multiplicities of the knots of the BSpline BS.(keeping the 0347 //! geometry). It returns a new BSpline which could still be C0. 0348 //! tolerance is a geometrical tolerance. 0349 //! The Angular toleranceis in radians and measures the angle of 0350 //! the tangents on the left and on the right to decide if the 0351 //! curve is G1 or not at a given point 0352 Standard_EXPORT static void C0BSplineToC1BSplineCurve(occ::handle<Geom_BSplineCurve>& BS, 0353 const double tolerance, 0354 const double AngularTolerance = 1.0e-7); 0355 0356 //! This Method reduces as far as it is possible the 0357 //! multiplicities of the knots of the BSpline BS.(keeping the geometry). 0358 //! It returns an array of BSpline C1. tolerance is a geometrical tolerance. 0359 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve( 0360 const occ::handle<Geom_BSplineCurve>& BS, 0361 occ::handle<NCollection_HArray1<occ::handle<Geom_BSplineCurve>>>& tabBS, 0362 const double tolerance); 0363 0364 //! This Method reduces as far as it is possible the 0365 //! multiplicities of the knots of the BSpline BS.(keeping the 0366 //! geometry). It returns an array of BSpline C1. tolerance is a 0367 //! geometrical tolerance : it allows for the maximum deformation 0368 //! The Angular tolerance is in radians and measures the angle of 0369 //! the tangents on the left and on the right to decide if the curve 0370 //! is C1 or not at a given point 0371 Standard_EXPORT static void C0BSplineToArrayOfC1BSplineCurve( 0372 const occ::handle<Geom_BSplineCurve>& BS, 0373 occ::handle<NCollection_HArray1<occ::handle<Geom_BSplineCurve>>>& tabBS, 0374 const double AngularTolerance, 0375 const double tolerance); 0376 }; 0377 0378 #endif // _GeomConvert_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|