Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:16:47

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