1 // Created on: 1998-07-14
2 // Created by: data exchange team
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
18 #define _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Standard_Integer.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <Standard_Transient.hxx>
27 #include <ShapeExtend_Status.hxx>
28 #include <GeomAbs_Shape.hxx>
29 #include <TColStd_Array1OfReal.hxx>
30 #include <TColgp_HArray1OfPnt2d.hxx>
31 #include <TColgp_HArray1OfPnt.hxx>
32 #include <TColgp_SequenceOfPnt.hxx>
33 #include <TColgp_SequenceOfPnt2d.hxx>
34 #include <TColStd_SequenceOfReal.hxx>
35 class ShapeAnalysis_Surface;
40 // resolve name collisions with X11 headers
45 class ShapeConstruct_ProjectCurveOnSurface;
46 DEFINE_STANDARD_HANDLE(ShapeConstruct_ProjectCurveOnSurface, Standard_Transient)
48 //! This tool provides a method for computing pcurve by projecting
49 //! 3d curve onto a surface.
50 //! Projection is done by 23 or more points (this number is changed
51 //! for B-Splines according to the following rule:
52 //! the total number of the points is not less than number of spans *
54 //! it is increased recursively starting with 23 and is added with 22
55 //! until the condition is fulfilled).
56 //! Isoparametric cases (if curve corresponds to U=const or V=const on
57 //! the surface) are recognized with the given precision.
58 class ShapeConstruct_ProjectCurveOnSurface : public Standard_Transient
64 //! Empty constructor.
65 Standard_EXPORT ShapeConstruct_ProjectCurveOnSurface();
67 //! Initializes the object with all necessary parameters,
68 //! i.e. surface and precision
69 Standard_EXPORT virtual void Init (const Handle(Geom_Surface)& surf, const Standard_Real preci);
71 //! Initializes the object with all necessary parameters,
72 //! i.e. surface and precision
73 Standard_EXPORT virtual void Init (const Handle(ShapeAnalysis_Surface)& surf, const Standard_Real preci);
75 //! Loads a surface (in the form of Geom_Surface) to project on
76 Standard_EXPORT void SetSurface (const Handle(Geom_Surface)& surf);
78 //! Loads a surface (in the form of ShapeAnalysis_Surface) to project on
79 Standard_EXPORT void SetSurface (const Handle(ShapeAnalysis_Surface)& surf);
81 //! Sets value for current precision
82 Standard_EXPORT void SetPrecision (const Standard_Real preci);
84 //! Returns (modifiable) the build-curve-3d mode, by default False
85 //! If True, if the projected curve has been recomputed by
86 //! interpolation, the 3d curve is also rebuild by interpolation
87 Standard_EXPORT Standard_Boolean& BuildCurveMode();
89 //! Returns (modifiable) the flag specifying to which side of
90 //! parametrical space adjust part of pcurve which lies on seam.
91 //! This is required in very rare case when 3d curve which is
92 //! to be projected goes partly along the seam on the closed
93 //! surface with singularity (e.g. sphere), goes through the
94 //! degenerated point and paerly lies on internal area of surface.
96 //! If this flag is True, the seam part of such curve will be
97 //! adjusted to the left side of parametric space (on sphere U=0),
98 //! else to the right side (on sphere U=2*PI)
99 //! Default value is True
100 Standard_EXPORT Standard_Integer& AdjustOverDegenMode();
102 //! Returns the status of last Perform
103 Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status theStatus) const;
105 //! Computes the projection of 3d curve onto a surface using the
106 //! specialized algorithm. Returns False if projector fails,
107 //! otherwise, if pcurve computed successfully, returns True.
108 //! The output curve 2D is guaranteed to be same-parameter
109 //! with input curve 3D on the interval [First, Last]. If the output curve
110 //! lies on a direct line the infinite line is returned, in the case
111 //! same-parameter condition is satisfied.
112 //! TolFirst and TolLast are the tolerances at the ends of input curve 3D.
113 Standard_EXPORT virtual Standard_Boolean Perform (Handle(Geom_Curve)& c3d,
114 const Standard_Real First,
115 const Standard_Real Last,
116 Handle(Geom2d_Curve)& c2d,
117 const Standard_Real TolFirst = -1,
118 const Standard_Real TolLast = -1);
120 //! Computes the projection of 3d curve onto a surface using the
121 //! standard algorithm from ProjLib. Returns False if standard
122 //! projector fails or raises an exception or cuts the curve by
123 //! parametrical bounds of the surface. Else, if pcurve computed
124 //! successfully, returns True.
125 //! The continuity, maxdeg and nbinterval are parameters of call
126 //! to Approx_CurveOnSurface. If nbinterval is equal to -1
127 //! (default), this value is computed depending on source 3d curve
129 Standard_EXPORT Standard_Boolean PerformByProjLib (Handle(Geom_Curve)& c3d,
130 const Standard_Real First,
131 const Standard_Real Last,
132 Handle(Geom2d_Curve)& c2d,
133 const GeomAbs_Shape continuity = GeomAbs_C1,
134 const Standard_Integer maxdeg = 12,
135 const Standard_Integer nbinterval = -1);
139 DEFINE_STANDARD_RTTIEXT(ShapeConstruct_ProjectCurveOnSurface,Standard_Transient)
144 //! Try to approximate 3D curve by Geom2d_Line
145 //! or Geom2d_BsplineCurve with degree 1 with specified tolerance.
146 //! points - points obtained from 3d curve.
147 //! params - parameters corresponding points on 3d curves
148 //! points2d - 2d points lies on line in parametric space
149 //! theTol - tolerance used for compare initial points 3d and
150 //! 3d points obtained from line lying in parameric space of surface
151 Standard_EXPORT Handle(Geom2d_Curve) getLine (const TColgp_SequenceOfPnt& points,
152 const TColStd_SequenceOfReal& params,
153 TColgp_SequenceOfPnt2d& points2d,
154 const Standard_Real theTol,
155 Standard_Boolean& IsRecompute,
156 Standard_Boolean &isFromCashe) const;
158 Handle(ShapeAnalysis_Surface) mySurf;
159 Standard_Real myPreci;
160 Standard_Boolean myBuild;
161 Standard_Integer myStatus;
162 Standard_Integer myAdjustOverDegen;
163 Standard_Integer myNbCashe;
165 gp_Pnt2d myCashe2d[2];
171 Standard_EXPORT Handle(Geom2d_Curve) ProjectAnalytic (const Handle(Geom_Curve)& c3d) const;
173 Standard_EXPORT Standard_Boolean ApproxPCurve (const Standard_Integer nbrPnt,
174 const Handle(Geom_Curve)& c3d,
175 const Standard_Real TolFirst,
176 const Standard_Real TolLast,
177 TColgp_SequenceOfPnt& points,
178 TColStd_SequenceOfReal& params,
179 TColgp_SequenceOfPnt2d& points2d,
180 Handle(Geom2d_Curve)& c2d);
182 Standard_EXPORT void CorrectExtremity(const Handle(Geom_Curve)& theC3d,
183 const TColStd_SequenceOfReal& theParams,
184 TColgp_SequenceOfPnt2d& thePnt2d,
185 const Standard_Boolean theIsFirstPoint,
186 const gp_Pnt2d& thePointOnIsoLine,
187 const Standard_Boolean theIsUiso);
189 Standard_EXPORT void InsertAdditionalPointOrAdjust(Standard_Boolean& ToAdjust,
190 const Standard_Integer theIndCoord,
191 const Standard_Real Period,
192 const Standard_Real TolOnPeriod,
193 Standard_Real& CurCoord,
194 const Standard_Real prevCoord,
195 const Handle(Geom_Curve)& c3d,
196 Standard_Integer& theIndex,
197 TColgp_SequenceOfPnt& points,
198 TColStd_SequenceOfReal& params,
199 TColgp_SequenceOfPnt2d& pnt2d);
201 Standard_EXPORT Handle(Geom2d_Curve) InterpolatePCurve (const Standard_Integer nbrPnt,
202 Handle(TColgp_HArray1OfPnt2d)& points2d,
203 Handle(TColStd_HArray1OfReal)& params,
204 const Handle(Geom_Curve)& orig) const;
206 Standard_EXPORT Handle(Geom2d_Curve) ApproximatePCurve (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt2d)& points2d, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
208 Standard_EXPORT Handle(Geom_Curve) InterpolateCurve3d (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
210 Standard_EXPORT void CheckPoints (Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
212 Standard_EXPORT void CheckPoints2d (Handle(TColgp_HArray1OfPnt2d)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
214 Standard_EXPORT Standard_Boolean IsAnIsoparametric (const Standard_Integer nbrPnt,
215 const TColgp_SequenceOfPnt& points,
216 const TColStd_SequenceOfReal& params,
217 Standard_Boolean& isoTypeU,
218 Standard_Boolean& p1OnIso,
220 Standard_Boolean& p2OnIso,
222 Standard_Boolean& isoPar2d3d,
223 Handle(Geom_Curve)& cIso,
226 TColStd_Array1OfReal& pout) const;
238 #endif // _ShapeConstruct_ProjectCurveOnSurface_HeaderFile