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_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Standard_Integer.hxx>
27 #include <gp_Pnt2d.hxx>
28 #include <Standard_Transient.hxx>
29 #include <ShapeExtend_Status.hxx>
30 #include <GeomAbs_Shape.hxx>
31 #include <TColStd_Array1OfReal.hxx>
32 #include <TColgp_HArray1OfPnt2d.hxx>
33 #include <TColgp_HArray1OfPnt.hxx>
34 #include <TColgp_SequenceOfPnt.hxx>
35 #include <TColgp_SequenceOfPnt2d.hxx>
36 #include <TColStd_SequenceOfReal.hxx>
37 class ShapeAnalysis_Surface;
42 // resolve name collisions with X11 headers
47 class ShapeConstruct_ProjectCurveOnSurface;
48 DEFINE_STANDARD_HANDLE(ShapeConstruct_ProjectCurveOnSurface, Standard_Transient)
50 //! This tool provides a method for computing pcurve by projecting
51 //! 3d curve onto a surface.
52 //! Projection is done by 23 or more points (this number is changed
53 //! for B-Splines according to the following rule:
54 //! the total number of the points is not less than number of spans *
56 //! it is increased recursively starting with 23 and is added with 22
57 //! until the condition is fulfilled).
58 //! Isoparametric cases (if curve corresponds to U=const or V=const on
59 //! the surface) are recognized with the given precision.
60 class ShapeConstruct_ProjectCurveOnSurface : public Standard_Transient
66 //! Empty constructor.
67 Standard_EXPORT ShapeConstruct_ProjectCurveOnSurface();
69 //! Initializes the object with all necessary parameters,
70 //! i.e. surface and precision
71 Standard_EXPORT virtual void Init (const Handle(Geom_Surface)& surf, const Standard_Real preci);
73 //! Initializes the object with all necessary parameters,
74 //! i.e. surface and precision
75 Standard_EXPORT virtual void Init (const Handle(ShapeAnalysis_Surface)& surf, const Standard_Real preci);
77 //! Loads a surface (in the form of Geom_Surface) to project on
78 Standard_EXPORT void SetSurface (const Handle(Geom_Surface)& surf);
80 //! Loads a surface (in the form of ShapeAnalysis_Surface) to project on
81 Standard_EXPORT void SetSurface (const Handle(ShapeAnalysis_Surface)& surf);
83 //! Sets value for current precision
84 Standard_EXPORT void SetPrecision (const Standard_Real preci);
86 //! Returns (modifiable) the build-curve-3d mode, by default False
87 //! If True, if the projected curve has been recomputed by
88 //! interpolation, the 3d curve is also rebuild by interpolation
89 Standard_EXPORT Standard_Boolean& BuildCurveMode();
91 //! Returns (modifiable) the flag specifying to which side of
92 //! parametrical space adjust part of pcurve which lies on seam.
93 //! This is required in very rare case when 3d curve which is
94 //! to be projected goes partly along the seam on the closed
95 //! surface with singularity (e.g. sphere), goes through the
96 //! degenerated point and paerly lies on internal area of surface.
98 //! If this flag is True, the seam part of such curve will be
99 //! adjusted to the left side of parametric space (on sphere U=0),
100 //! else to the right side (on sphere U=2*PI)
101 //! Default value is True
102 Standard_EXPORT Standard_Integer& AdjustOverDegenMode();
104 //! Returns the status of last Peform
105 Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status theStatus) const;
107 //! Computes the projection of 3d curve onto a surface using the
108 //! specialized algorithm. Returns False if projector fails,
109 //! otherwise, if pcurve computed successfully, returns True.
110 //! The output curve 2D is guaranteed to be same-parameter
111 //! with input curve 3D on the interval [First, Last]. If the output curve
112 //! lies on a direct line the infinite line is returned, in the case
113 //! same-parameter condition is satisfied.
114 //! TolFirst and TolLast are the tolerances at the ends of input curve 3D.
115 Standard_EXPORT virtual Standard_Boolean Perform (Handle(Geom_Curve)& c3d,
116 const Standard_Real First,
117 const Standard_Real Last,
118 Handle(Geom2d_Curve)& c2d,
119 const Standard_Real TolFirst = -1,
120 const Standard_Real TolLast = -1);
122 //! Computes the projection of 3d curve onto a surface using the
123 //! standard algorithm from ProjLib. Returns False if standard
124 //! projector fails or raises an exception or cuts the curve by
125 //! parametrical bounds of the surface. Else, if pcurve computed
126 //! successfully, returns True.
127 //! The continuity, maxdeg and nbinterval are parameters of call
128 //! to Approx_CurveOnSurface. If nbinterval is equal to -1
129 //! (default), this value is computed depending on source 3d curve
131 Standard_EXPORT Standard_Boolean PerformByProjLib (Handle(Geom_Curve)& c3d,
132 const Standard_Real First,
133 const Standard_Real Last,
134 Handle(Geom2d_Curve)& c2d,
135 const GeomAbs_Shape continuity = GeomAbs_C1,
136 const Standard_Integer maxdeg = 12,
137 const Standard_Integer nbinterval = -1);
141 DEFINE_STANDARD_RTTIEXT(ShapeConstruct_ProjectCurveOnSurface,Standard_Transient)
146 //! Try to approximate 3D curve by Geom2d_Line
147 //! or Geom2d_BsplineCurve with degree 1 with specified tolerance.
148 //! points - points obtained from 3d curve.
149 //! params - parameters corresponding points on 3d curves
150 //! points2d - 2d points lies on line in parametric space
151 //! theTol - tolerance used for compare initial points 3d and
152 //! 3d points obtained from line lying in parameric space of surface
153 Standard_EXPORT Handle(Geom2d_Curve) getLine (const TColgp_SequenceOfPnt& points,
154 const TColStd_SequenceOfReal& params,
155 TColgp_SequenceOfPnt2d& points2d,
156 const Standard_Real theTol,
157 Standard_Boolean& IsRecompute,
158 Standard_Boolean &isFromCashe) const;
160 Handle(ShapeAnalysis_Surface) mySurf;
161 Standard_Real myPreci;
162 Standard_Boolean myBuild;
163 Standard_Integer myStatus;
164 Standard_Integer myAdjustOverDegen;
165 Standard_Integer myNbCashe;
167 gp_Pnt2d myCashe2d[2];
173 Standard_EXPORT Handle(Geom2d_Curve) ProjectAnalytic (const Handle(Geom_Curve)& c3d) const;
175 Standard_EXPORT Standard_Boolean ApproxPCurve (const Standard_Integer nbrPnt,
176 const Handle(Geom_Curve)& c3d,
177 const Standard_Real TolFirst,
178 const Standard_Real TolLast,
179 TColgp_SequenceOfPnt& points,
180 TColStd_SequenceOfReal& params,
181 TColgp_SequenceOfPnt2d& points2d,
182 Handle(Geom2d_Curve)& c2d);
184 Standard_EXPORT void CorrectExtremity(const Handle(Geom_Curve)& theC3d,
185 const TColStd_SequenceOfReal& theParams,
186 TColgp_SequenceOfPnt2d& thePnt2d,
187 const Standard_Boolean theIsFirstPoint,
188 const gp_Pnt2d& thePointOnIsoLine,
189 const Standard_Boolean theIsUiso);
191 Standard_EXPORT void InsertAdditionalPointOrAdjust(Standard_Boolean& ToAdjust,
192 const Standard_Integer theIndCoord,
193 const Standard_Real Period,
194 const Standard_Real TolOnPeriod,
195 Standard_Real& CurCoord,
196 const Standard_Real prevCoord,
197 const Handle(Geom_Curve)& c3d,
198 Standard_Integer& theIndex,
199 TColgp_SequenceOfPnt& points,
200 TColStd_SequenceOfReal& params,
201 TColgp_SequenceOfPnt2d& pnt2d);
203 Standard_EXPORT Handle(Geom2d_Curve) InterpolatePCurve (const Standard_Integer nbrPnt,
204 Handle(TColgp_HArray1OfPnt2d)& points2d,
205 Handle(TColStd_HArray1OfReal)& params,
206 const Handle(Geom_Curve)& orig) const;
208 Standard_EXPORT Handle(Geom2d_Curve) ApproximatePCurve (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt2d)& points2d, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
210 Standard_EXPORT Handle(Geom_Curve) InterpolateCurve3d (const Standard_Integer nbrPnt, Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, const Handle(Geom_Curve)& orig) const;
212 Standard_EXPORT void CheckPoints (Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
214 Standard_EXPORT void CheckPoints2d (Handle(TColgp_HArray1OfPnt2d)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
216 Standard_EXPORT Standard_Boolean IsAnIsoparametric (const Standard_Integer nbrPnt,
217 const TColgp_SequenceOfPnt& points,
218 const TColStd_SequenceOfReal& params,
219 Standard_Boolean& isoTypeU,
220 Standard_Boolean& p1OnIso,
222 Standard_Boolean& p2OnIso,
224 Standard_Boolean& isoPar2d3d,
225 Handle(Geom_Curve)& cIso,
228 TColStd_Array1OfReal& pout) const;
240 #endif // _ShapeConstruct_ProjectCurveOnSurface_HeaderFile