|
||||
File indexing completed on 2025-01-18 10:04:55
0001 // Created on: 1998-06-03 0002 // Created by: data exchange team 0003 // Copyright (c) 1998-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 _ShapeAnalysis_Surface_HeaderFile 0018 #define _ShapeAnalysis_Surface_HeaderFile 0019 0020 #include <Extrema_ExtPS.hxx> 0021 #include <GeomAdaptor_Surface.hxx> 0022 #include <gp_Pnt.hxx> 0023 #include <gp_Pnt2d.hxx> 0024 #include <Bnd_Box.hxx> 0025 #include <TColgp_SequenceOfPnt.hxx> 0026 #include <TColgp_SequenceOfPnt2d.hxx> 0027 0028 class Geom_Surface; 0029 class Geom_Curve; 0030 0031 DEFINE_STANDARD_HANDLE(ShapeAnalysis_Surface, Standard_Transient) 0032 0033 //! Complements standard tool Geom_Surface by providing additional 0034 //! functionality for detection surface singularities, checking 0035 //! spatial surface closure and computing projections of 3D points 0036 //! onto a surface. 0037 //! 0038 //! * The singularities 0039 //! Each singularity stores the precision with which corresponding 0040 //! surface iso-line is considered as degenerated. 0041 //! The number of singularities is determined by specifying precision 0042 //! and always not greater than 4. 0043 //! 0044 //! * The spatial closure 0045 //! The check for spatial closure is performed with given precision 0046 //! (default value is Precision::Confusion). 0047 //! If Geom_Surface says that the surface is closed, this class 0048 //! also says this. Otherwise additional analysis is performed. 0049 //! 0050 //! * The parameters of 3D point on the surface 0051 //! The projection of the point is performed with given precision. 0052 //! This class tries to find a solution taking into account possible 0053 //! singularities. 0054 //! Additional method for searching the solution from already built 0055 //! one is also provided. 0056 //! 0057 //! This tool is optimised: computes most information only once 0058 class ShapeAnalysis_Surface : public Standard_Transient 0059 { 0060 0061 public: 0062 0063 0064 //! Creates an analyzer object on the basis of existing surface 0065 Standard_EXPORT ShapeAnalysis_Surface(const Handle(Geom_Surface)& S); 0066 0067 //! Loads existing surface 0068 Standard_EXPORT void Init (const Handle(Geom_Surface)& S); 0069 0070 //! Reads all the data from another Surface, without recomputing 0071 Standard_EXPORT void Init (const Handle(ShapeAnalysis_Surface)& other); 0072 0073 Standard_EXPORT void SetDomain (const Standard_Real U1, const Standard_Real U2, 0074 const Standard_Real V1, const Standard_Real V2); 0075 0076 //! Returns a surface being analyzed 0077 const Handle(Geom_Surface)& Surface() const; 0078 0079 //! Returns the Adaptor. 0080 //! Creates it if not yet done. 0081 Standard_EXPORT const Handle(GeomAdaptor_Surface)& Adaptor3d(); 0082 0083 //! Returns the Adaptor (may be Null if method Adaptor() was not called) 0084 const Handle(GeomAdaptor_Surface)& TrueAdaptor3d() const; 0085 0086 //! Returns 3D distance found by one of the following methods. 0087 //! IsDegenerated, DegeneratedValues, ProjectDegenerated 0088 //! (distance between 3D point and found or last (if not found) 0089 //! singularity), 0090 //! IsUClosed, IsVClosed (minimum value of precision to consider 0091 //! the surface to be closed), 0092 //! ValueOfUV (distance between 3D point and found solution). 0093 Standard_Real Gap() const; 0094 0095 //! Returns a 3D point specified by parameters in surface 0096 //! parametrical space 0097 gp_Pnt Value (const Standard_Real u, const Standard_Real v); 0098 0099 //! Returns a 3d point specified by a point in surface 0100 //! parametrical space 0101 gp_Pnt Value (const gp_Pnt2d& p2d); 0102 0103 //! Returns True if the surface has singularities for the given 0104 //! precision (i.e. if there are surface singularities with sizes 0105 //! not greater than precision). 0106 Standard_EXPORT Standard_Boolean HasSingularities (const Standard_Real preci); 0107 0108 //! Returns the number of singularities for the given precision 0109 //! (i.e. number of surface singularities with sizes not greater 0110 //! than precision). 0111 Standard_EXPORT Standard_Integer NbSingularities (const Standard_Real preci); 0112 0113 //! Returns the characteristics of the singularity specified by 0114 //! its rank number <num>. 0115 //! That means, that it is not necessary for <num> to be in the 0116 //! range [1, NbSingularities] but must be not greater than 0117 //! possible (see ComputeSingularities). 0118 //! The returned characteristics are: 0119 //! preci: the smallest precision with which the iso-line is 0120 //! considered as degenerated, 0121 //! P3d: 3D point of singularity (middle point of the surface 0122 //! iso-line), 0123 //! firstP2d and lastP2d: first and last 2D points of the 0124 //! iso-line in parametrical surface, 0125 //! firstpar and lastpar: first and last parameters of the 0126 //! iso-line in parametrical surface, 0127 //! uisodeg: if the degenerated iso-line is U-iso (True) or 0128 //! V-iso (False). 0129 //! Returns False if <num> is out of range, else returns True. 0130 Standard_EXPORT Standard_Boolean Singularity (const Standard_Integer num, 0131 Standard_Real& preci, 0132 gp_Pnt& P3d, 0133 gp_Pnt2d& firstP2d, 0134 gp_Pnt2d& lastP2d, 0135 Standard_Real& firstpar, 0136 Standard_Real& lastpar, 0137 Standard_Boolean& uisodeg); 0138 0139 //! Returns True if there is at least one surface boundary which 0140 //! is considered as degenerated with <preci> and distance 0141 //! between P3d and corresponding singular point is less than 0142 //! <preci> 0143 Standard_EXPORT Standard_Boolean IsDegenerated (const gp_Pnt& P3d, const Standard_Real preci); 0144 0145 //! Returns True if there is at least one surface iso-line which 0146 //! is considered as degenerated with <preci> and distance 0147 //! between P3d and corresponding singular point is less than 0148 //! <preci> (like IsDegenerated). 0149 //! Returns characteristics of the first found boundary matching 0150 //! those criteria. 0151 Standard_EXPORT Standard_Boolean DegeneratedValues (const gp_Pnt& P3d, 0152 const Standard_Real preci, 0153 gp_Pnt2d& firstP2d, 0154 gp_Pnt2d& lastP2d, 0155 Standard_Real& firstpar, 0156 Standard_Real& lastpar, 0157 const Standard_Boolean forward = Standard_True); 0158 0159 //! Projects a point <P3d> on a singularity by computing 0160 //! one of the coordinates of preliminary computed <result>. 0161 //! 0162 //! Finds the iso-line which is considered as degenerated with 0163 //! <preci> and 0164 //! a. distance between P3d and corresponding singular point is 0165 //! less than <preci> (like IsDegenerated) or 0166 //! b. difference between already computed <result>'s coordinate 0167 //! and iso-coordinate of the boundary is less than 2D 0168 //! resolution (computed from <preci> by Geom_Adaptor). 0169 //! Then sets not yet computed <result>'s coordinate taking it 0170 //! from <neighbour> and returns True. 0171 Standard_EXPORT Standard_Boolean ProjectDegenerated (const gp_Pnt& P3d, 0172 const Standard_Real preci, 0173 const gp_Pnt2d& neighbour, 0174 gp_Pnt2d& result); 0175 0176 //! Checks points at the beginning (direct is True) or end 0177 //! (direct is False) of array <points> to lie in singularity of 0178 //! surface, and if yes, adjusts the indeterminate 2d coordinate 0179 //! of these points by nearest point which is not in singularity. 0180 //! Returns True if some points were adjusted. 0181 Standard_EXPORT Standard_Boolean ProjectDegenerated (const Standard_Integer nbrPnt, 0182 const TColgp_SequenceOfPnt& points, 0183 TColgp_SequenceOfPnt2d& pnt2d, 0184 const Standard_Real preci, const Standard_Boolean direct); 0185 0186 //! Returns True if straight pcurve going from point p2d1 to p2d2 0187 //! is degenerate, i.e. lies in the singularity of the surface. 0188 //! NOTE: it uses another method of detecting singularity than 0189 //! used by ComputeSingularities() et al.! 0190 //! For that, maximums of distances between points p2d1, p2d2 0191 //! and 0.5*(p2d1+p2d2) and between corresponding 3d points are 0192 //! computed. 0193 //! The pcurve (p2d1, p2d2) is considered as degenerate if: 0194 //! - max distance in 3d is less than <tol> 0195 //! - max distance in 2d is at least <ratio> times greater than 0196 //! the Resolution computed from max distance in 3d 0197 //! (max3d < tol && max2d > ratio * Resolution(max3d)) 0198 //! NOTE: <ratio> should be >1 (e.g. 10) 0199 Standard_EXPORT Standard_Boolean IsDegenerated (const gp_Pnt2d& p2d1, 0200 const gp_Pnt2d& p2d2, 0201 const Standard_Real tol, 0202 const Standard_Real ratio); 0203 0204 //! Returns the bounds of the surface 0205 //! (from Bounds from Surface, but buffered) 0206 void Bounds (Standard_Real& ufirst, Standard_Real& ulast, 0207 Standard_Real& vfirst, Standard_Real& vlast) const; 0208 0209 //! Computes bound isos (protected against exceptions) 0210 Standard_EXPORT void ComputeBoundIsos(); 0211 0212 //! Returns a U-Iso. Null if not possible or failed 0213 //! Remark : bound isos are buffered 0214 Standard_EXPORT Handle(Geom_Curve) UIso (const Standard_Real U); 0215 0216 //! Returns a V-Iso. Null if not possible or failed 0217 //! Remark : bound isos are buffered 0218 Standard_EXPORT Handle(Geom_Curve) VIso (const Standard_Real V); 0219 0220 //! Tells if the Surface is spatially closed in U with given 0221 //! precision. If <preci> < 0 then Precision::Confusion is used. 0222 //! If Geom_Surface says that the surface is U-closed, this method 0223 //! also says this. Otherwise additional analysis is performed, 0224 //! comparing given precision with the following distances: 0225 //! - periodic B-Splines are closed, 0226 //! - polinomial B-Spline with boundary multiplicities degree+1 0227 //! and Bezier - maximum distance between poles, 0228 //! - rational B-Spline or one with boundary multiplicities not 0229 //! degree+1 - maximum distance computed at knots and their 0230 //! middles, 0231 //! - surface of extrusion - distance between ends of basis 0232 //! curve, 0233 //! - other (RectangularTrimmed and Offset) - maximum distance 0234 //! computed at 100 equi-distanted points. 0235 Standard_EXPORT Standard_Boolean IsUClosed (const Standard_Real preci = -1); 0236 0237 //! Tells if the Surface is spatially closed in V with given 0238 //! precision. If <preci> < 0 then Precision::Confusion is used. 0239 //! If Geom_Surface says that the surface is V-closed, this method 0240 //! also says this. Otherwise additional analysis is performed, 0241 //! comparing given precision with the following distances: 0242 //! - periodic B-Splines are closed, 0243 //! - polinomial B-Spline with boundary multiplicities degree+1 0244 //! and Bezier - maximum distance between poles, 0245 //! - rational B-Spline or one with boundary multiplicities not 0246 //! degree+1 - maximum distance computed at knots and their 0247 //! middles, 0248 //! - surface of revolution - distance between ends of basis 0249 //! curve, 0250 //! - other (RectangularTrimmed and Offset) - maximum distance 0251 //! computed at 100 equi-distanted points. 0252 Standard_EXPORT Standard_Boolean IsVClosed (const Standard_Real preci = -1); 0253 0254 //! Computes the parameters in the surface parametrical space of 0255 //! 3D point. 0256 //! The result is parameters of the point projected onto the 0257 //! surface. 0258 //! This method enhances functionality provided by the standard 0259 //! tool GeomAPI_ProjectPointOnSurface by treatment of cases when 0260 //! the projected point is near to the surface boundaries and 0261 //! when this standard tool fails. 0262 Standard_EXPORT gp_Pnt2d ValueOfUV (const gp_Pnt& P3D, const Standard_Real preci); 0263 0264 //! Projects a point P3D on the surface. 0265 //! Does the same thing as ValueOfUV but tries to optimize 0266 //! computations by taking into account previous point <p2dPrev>: 0267 //! makes a step by UV and tries Newton algorithm. 0268 //! If <maxpreci> >0. and distance between solution and 0269 //! P3D is greater than <maxpreci>, that solution is considered 0270 //! as bad, and ValueOfUV() is used. 0271 //! If not succeeded, calls ValueOfUV() 0272 Standard_EXPORT gp_Pnt2d NextValueOfUV (const gp_Pnt2d& p2dPrev, 0273 const gp_Pnt& P3D, 0274 const Standard_Real preci, 0275 const Standard_Real maxpreci = -1.0); 0276 0277 //! Tries a refinement of an already computed couple (U,V) by 0278 //! using projecting 3D point on iso-lines: 0279 //! 1. boundaries of the surface, 0280 //! 2. iso-lines passing through (U,V) 0281 //! 3. iteratively received iso-lines passing through new U and 0282 //! new V (number of iterations is limited by 5 in each 0283 //! direction) 0284 //! Returns the best resulting distance between P3D and Value(U,V) 0285 //! in the case of success. Else, returns a very great value 0286 Standard_EXPORT Standard_Real UVFromIso (const gp_Pnt& P3D, 0287 const Standard_Real preci, 0288 Standard_Real& U, 0289 Standard_Real& V); 0290 0291 //! Returns minimum value to consider the surface as U-closed 0292 Standard_Real UCloseVal() const; 0293 0294 //! Returns minimum value to consider the surface as V-closed 0295 Standard_Real VCloseVal() const; 0296 0297 Standard_EXPORT const Bnd_Box& GetBoxUF(); 0298 0299 Standard_EXPORT const Bnd_Box& GetBoxUL(); 0300 0301 Standard_EXPORT const Bnd_Box& GetBoxVF(); 0302 0303 Standard_EXPORT const Bnd_Box& GetBoxVL(); 0304 0305 0306 0307 0308 DEFINE_STANDARD_RTTIEXT(ShapeAnalysis_Surface,Standard_Transient) 0309 0310 protected: 0311 0312 0313 Handle(Geom_Surface) mySurf; 0314 Handle(GeomAdaptor_Surface) myAdSur; 0315 Extrema_ExtPS myExtPS; 0316 Standard_Boolean myExtOK; 0317 Standard_Integer myNbDeg; 0318 Standard_Real myPreci[4]; 0319 gp_Pnt myP3d[4]; 0320 gp_Pnt2d myFirstP2d[4]; 0321 gp_Pnt2d myLastP2d[4]; 0322 Standard_Real myFirstPar[4]; 0323 Standard_Real myLastPar[4]; 0324 Standard_Boolean myUIsoDeg[4]; 0325 Standard_Boolean myIsos; 0326 Standard_Real myUF; 0327 Standard_Real myUL; 0328 Standard_Real myVF; 0329 Standard_Real myVL; 0330 Handle(Geom_Curve) myIsoUF; 0331 Handle(Geom_Curve) myIsoUL; 0332 Handle(Geom_Curve) myIsoVF; 0333 Handle(Geom_Curve) myIsoVL; 0334 Standard_Boolean myIsoBoxes; 0335 Bnd_Box myBndUF; 0336 Bnd_Box myBndUL; 0337 Bnd_Box myBndVF; 0338 Bnd_Box myBndVL; 0339 Standard_Real myGap; 0340 Standard_Real myUDelt; 0341 Standard_Real myVDelt; 0342 Standard_Real myUCloseVal; 0343 Standard_Real myVCloseVal; 0344 0345 0346 private: 0347 0348 0349 //! Computes singularities on the surface. 0350 //! Computes the sizes of boundaries or singular ares of the 0351 //! surface. Then each boundary or area is considered as 0352 //! degenerated with precision not less than its size. 0353 //! 0354 //! The singularities and corresponding precisions are the 0355 //! following: 0356 //! - ConicalSurface - one degenerated point (apex of the cone), 0357 //! precision is 0., 0358 //! - ToroidalSurface - two degenerated points, precision is 0359 //! Max (0, majorR-minorR), 0360 //! - SphericalSurface - two degenerated points (poles), 0361 //! precision is 0. 0362 //! - Bounded, Surface Of Revolution, Offset - four degenerated 0363 //! points, precisions are maximum distance between corners 0364 //! and middle point on the boundary 0365 Standard_EXPORT void ComputeSingularities(); 0366 0367 Standard_EXPORT void ComputeBoxes(); 0368 0369 //! @return 0, 1 or 2. 0370 Standard_EXPORT Standard_Integer SurfaceNewton (const gp_Pnt2d& p2dPrev, 0371 const gp_Pnt& P3D, 0372 const Standard_Real preci, 0373 gp_Pnt2d& sol); 0374 0375 Standard_EXPORT void SortSingularities(); 0376 0377 0378 0379 }; 0380 0381 0382 #include <ShapeAnalysis_Surface.lxx> 0383 0384 0385 0386 0387 0388 #endif // _ShapeAnalysis_Surface_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |