Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:55

0001 // Created on: 1998-07-14
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 _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
0018 #define _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Standard_Integer.hxx>
0024 #include <gp_Pnt.hxx>
0025 #include <gp_Pnt2d.hxx>
0026 #include <Standard_Transient.hxx>
0027 #include <ShapeExtend_Status.hxx>
0028 #include <GeomAbs_Shape.hxx>
0029 #include <TColStd_Array1OfReal.hxx>
0030 #include <TColgp_HArray1OfPnt2d.hxx>
0031 #include <TColgp_HArray1OfPnt.hxx>
0032 #include <TColgp_SequenceOfPnt.hxx>
0033 #include <TColgp_SequenceOfPnt2d.hxx>
0034 #include <TColStd_SequenceOfReal.hxx>
0035 class ShapeAnalysis_Surface;
0036 class Geom_Surface;
0037 class Geom_Curve;
0038 class Geom2d_Curve;
0039 
0040 // resolve name collisions with X11 headers
0041 #ifdef Status
0042   #undef Status
0043 #endif
0044 
0045 class ShapeConstruct_ProjectCurveOnSurface;
0046 DEFINE_STANDARD_HANDLE(ShapeConstruct_ProjectCurveOnSurface, Standard_Transient)
0047 
0048 //! This tool provides a method for computing pcurve by projecting
0049 //! 3d curve onto a surface.
0050 //! Projection is done by 23 or more points (this number is changed
0051 //! for B-Splines according to the following rule:
0052 //! the total number of the points is not less than number of spans *
0053 //! (degree + 1);
0054 //! it is increased recursively starting with 23 and is added with 22
0055 //! until the condition is fulfilled).
0056 //! Isoparametric cases (if curve corresponds to U=const or V=const on
0057 //! the surface) are recognized with the given precision.
0058 class ShapeConstruct_ProjectCurveOnSurface : public Standard_Transient
0059 {
0060 
0061 public:
0062 
0063   
0064   //! Empty constructor.
0065   Standard_EXPORT ShapeConstruct_ProjectCurveOnSurface();
0066   
0067   //! Initializes the object with all necessary parameters,
0068   //! i.e. surface and precision
0069   Standard_EXPORT virtual void Init (const Handle(Geom_Surface)& surf, const Standard_Real preci);
0070   
0071   //! Initializes the object with all necessary parameters,
0072   //! i.e. surface and precision
0073   Standard_EXPORT virtual void Init (const Handle(ShapeAnalysis_Surface)& surf, const Standard_Real preci);
0074   
0075   //! Loads a surface (in the form of Geom_Surface) to project on
0076   Standard_EXPORT void SetSurface (const Handle(Geom_Surface)& surf);
0077   
0078   //! Loads a surface (in the form of ShapeAnalysis_Surface) to project on
0079   Standard_EXPORT void SetSurface (const Handle(ShapeAnalysis_Surface)& surf);
0080   
0081   //! Sets value for current precision
0082   Standard_EXPORT void SetPrecision (const Standard_Real preci);
0083   
0084   //! Returns (modifiable) the build-curve-3d mode, by default False
0085   //! If True, if the projected curve has been recomputed by
0086   //! interpolation, the 3d curve is also rebuild by interpolation
0087   Standard_EXPORT Standard_Boolean& BuildCurveMode();
0088   
0089   //! Returns (modifiable) the flag specifying to which side of
0090   //! parametrical space adjust part of pcurve which lies on seam.
0091   //! This is required in very rare case when 3d curve which is
0092   //! to be projected goes partly along the seam on the closed
0093   //! surface with singularity (e.g. sphere), goes through the
0094   //! degenerated point and paerly lies on internal area of surface.
0095   //!
0096   //! If this flag is True, the seam part of such curve will be
0097   //! adjusted to the left side of parametric space (on sphere U=0),
0098   //! else to the right side (on sphere U=2*PI)
0099   //! Default value is True
0100   Standard_EXPORT Standard_Integer& AdjustOverDegenMode();
0101   
0102   //! Returns the status of last Perform
0103   Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status theStatus) const;
0104   
0105   //! Computes the projection of 3d curve onto a surface using the
0106   //! specialized algorithm. Returns False if projector fails,
0107   //! otherwise, if pcurve computed successfully, returns True.
0108   //! The output curve 2D is guaranteed to be same-parameter
0109   //! with input curve 3D on the interval [First, Last]. If the output curve
0110   //! lies on a direct line the infinite line is returned, in the case
0111   //! same-parameter condition is satisfied.
0112   //! TolFirst and TolLast are the tolerances at the ends of input curve 3D.
0113   Standard_EXPORT virtual Standard_Boolean Perform (Handle(Geom_Curve)& c3d,
0114                                                     const Standard_Real First,
0115                                                     const Standard_Real Last,
0116                                                     Handle(Geom2d_Curve)& c2d,
0117                                                     const Standard_Real TolFirst = -1,
0118                                                     const Standard_Real TolLast  = -1);
0119   
0120   //! Computes the projection of 3d curve onto a surface using the
0121   //! standard algorithm from ProjLib. Returns False if standard
0122   //! projector fails or raises an exception or cuts the curve by
0123   //! parametrical bounds of the surface. Else, if pcurve computed
0124   //! successfully, returns True.
0125   //! The continuity, maxdeg and nbinterval are parameters of call
0126   //! to Approx_CurveOnSurface. If nbinterval is equal to -1
0127   //! (default), this value is computed depending on source 3d curve
0128   //! and surface.
0129   Standard_EXPORT Standard_Boolean PerformByProjLib (Handle(Geom_Curve)& c3d,
0130                                                      const Standard_Real First,
0131                                                      const Standard_Real Last,
0132                                                      Handle(Geom2d_Curve)& c2d,
0133                                                      const GeomAbs_Shape continuity = GeomAbs_C1,
0134                                                      const Standard_Integer maxdeg = 12,
0135                                                      const Standard_Integer nbinterval = -1);
0136   
0137 
0138 
0139   DEFINE_STANDARD_RTTIEXT(ShapeConstruct_ProjectCurveOnSurface,Standard_Transient)
0140 
0141 protected:
0142 
0143   
0144   //! Try to approximate 3D curve by Geom2d_Line
0145   //! or Geom2d_BsplineCurve with degree 1 with specified tolerance.
0146   //! points - points obtained from 3d curve.
0147   //! params - parameters corresponding points on 3d curves
0148   //! points2d - 2d points lies on line in parametric space
0149   //! theTol - tolerance used for compare initial points 3d and
0150   //! 3d points obtained from line lying in parameric space of surface
0151   Standard_EXPORT Handle(Geom2d_Curve) getLine (const TColgp_SequenceOfPnt& points,
0152                                                 const TColStd_SequenceOfReal& params,
0153                                                 TColgp_SequenceOfPnt2d& points2d,
0154                                                 const Standard_Real theTol,
0155                                                 Standard_Boolean& IsRecompute,
0156                                                 Standard_Boolean &isFromCashe) const;
0157 
0158   Handle(ShapeAnalysis_Surface) mySurf;
0159   Standard_Real myPreci;
0160   Standard_Boolean myBuild;
0161   Standard_Integer myStatus;
0162   Standard_Integer myAdjustOverDegen;
0163   Standard_Integer myNbCashe;
0164   gp_Pnt myCashe3d[2];
0165   gp_Pnt2d myCashe2d[2];
0166 
0167 
0168 private:
0169 
0170   
0171   Standard_EXPORT Handle(Geom2d_Curve) ProjectAnalytic (const Handle(Geom_Curve)& c3d) const;
0172   
0173   Standard_EXPORT Standard_Boolean ApproxPCurve (const Standard_Integer nbrPnt,
0174                                                  const Handle(Geom_Curve)& c3d,
0175                                                  const Standard_Real TolFirst,
0176                                                  const Standard_Real TolLast,
0177                                                  TColgp_SequenceOfPnt& points,
0178                                                  TColStd_SequenceOfReal& params,
0179                                                  TColgp_SequenceOfPnt2d& points2d,
0180                                                  Handle(Geom2d_Curve)& c2d);
0181 
0182   Standard_EXPORT void CorrectExtremity(const Handle(Geom_Curve)& theC3d,
0183                                         const TColStd_SequenceOfReal& theParams,
0184                                         TColgp_SequenceOfPnt2d& thePnt2d,
0185                                         const Standard_Boolean theIsFirstPoint,
0186                                         const gp_Pnt2d& thePointOnIsoLine,
0187                                         const Standard_Boolean theIsUiso);
0188   
0189   Standard_EXPORT void InsertAdditionalPointOrAdjust(Standard_Boolean& ToAdjust,
0190                                                      const Standard_Integer theIndCoord,
0191                                                      const Standard_Real Period,
0192                                                      const Standard_Real TolOnPeriod,
0193                                                      Standard_Real& CurCoord,
0194                                                      const Standard_Real prevCoord,
0195                                                      const Handle(Geom_Curve)& c3d,
0196                                                      Standard_Integer& theIndex,
0197                                                      TColgp_SequenceOfPnt& points,
0198                                                      TColStd_SequenceOfReal& params,
0199                                                      TColgp_SequenceOfPnt2d& pnt2d);
0200   
0201   Standard_EXPORT Handle(Geom2d_Curve) InterpolatePCurve (const Standard_Integer nbrPnt,
0202                                                           Handle(TColgp_HArray1OfPnt2d)& points2d,
0203                                                           Handle(TColStd_HArray1OfReal)& params,
0204                                                           const Handle(Geom_Curve)& orig) const;
0205   
0206   Standard_EXPORT Handle(Geom2d_Curve) ApproximatePCurve (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt2d)& points2d, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
0207   
0208   Standard_EXPORT Handle(Geom_Curve) InterpolateCurve3d (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
0209   
0210   Standard_EXPORT void CheckPoints (Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
0211   
0212   Standard_EXPORT void CheckPoints2d (Handle(TColgp_HArray1OfPnt2d)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
0213   
0214   Standard_EXPORT Standard_Boolean IsAnIsoparametric (const Standard_Integer nbrPnt,
0215                                                       const TColgp_SequenceOfPnt& points,
0216                                                       const TColStd_SequenceOfReal& params,
0217                                                       Standard_Boolean& isoTypeU,
0218                                                       Standard_Boolean& p1OnIso,
0219                                                       gp_Pnt2d& valueP1,
0220                                                       Standard_Boolean& p2OnIso,
0221                                                       gp_Pnt2d& valueP2,
0222                                                       Standard_Boolean& isoPar2d3d,
0223                                                       Handle(Geom_Curve)& cIso,
0224                                                       Standard_Real& t1,
0225                                                       Standard_Real& t2,
0226                                                       TColStd_Array1OfReal& pout) const;
0227 
0228 
0229 
0230 };
0231 
0232 
0233 
0234 
0235 
0236 
0237 
0238 #endif // _ShapeConstruct_ProjectCurveOnSurface_HeaderFile