0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / ShapeConstruct / ShapeConstruct_ProjectCurveOnSurface.hxx
CommitLineData
42cf5bc1 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
5//
6// This file is part of Open CASCADE Technology software library.
7//
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
18#define _ShapeConstruct_ProjectCurveOnSurface_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Standard_Real.hxx>
24#include <Standard_Boolean.hxx>
25#include <Standard_Integer.hxx>
26#include <gp_Pnt.hxx>
27#include <gp_Pnt2d.hxx>
25e59720 28#include <Standard_Transient.hxx>
42cf5bc1 29#include <ShapeExtend_Status.hxx>
30#include <GeomAbs_Shape.hxx>
42cf5bc1 31#include <TColStd_Array1OfReal.hxx>
42cf5bc1 32#include <TColgp_HArray1OfPnt2d.hxx>
42cf5bc1 33#include <TColgp_HArray1OfPnt.hxx>
2c26a53d 34#include <TColgp_SequenceOfPnt.hxx>
35#include <TColgp_SequenceOfPnt2d.hxx>
36#include <TColStd_SequenceOfReal.hxx>
42cf5bc1 37class ShapeAnalysis_Surface;
38class Geom_Surface;
39class Geom_Curve;
40class Geom2d_Curve;
42cf5bc1 41
9fd2d2c3 42// resolve name collisions with X11 headers
43#ifdef Status
44 #undef Status
45#endif
42cf5bc1 46
47class ShapeConstruct_ProjectCurveOnSurface;
25e59720 48DEFINE_STANDARD_HANDLE(ShapeConstruct_ProjectCurveOnSurface, Standard_Transient)
42cf5bc1 49
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 *
55//! (degree + 1);
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.
25e59720 60class ShapeConstruct_ProjectCurveOnSurface : public Standard_Transient
42cf5bc1 61{
62
63public:
64
65
66 //! Empty constructor.
67 Standard_EXPORT ShapeConstruct_ProjectCurveOnSurface();
68
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);
72
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);
76
77 //! Loads a surface (in the form of Geom_Surface) to project on
78 Standard_EXPORT void SetSurface (const Handle(Geom_Surface)& surf);
79
80 //! Loads a surface (in the form of ShapeAnalysis_Surface) to project on
81 Standard_EXPORT void SetSurface (const Handle(ShapeAnalysis_Surface)& surf);
82
83 //! Sets value for current precision
84 Standard_EXPORT void SetPrecision (const Standard_Real preci);
85
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();
90
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.
97 //!
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();
103
104 //! Returns the status of last Peform
9fd2d2c3 105 Standard_EXPORT Standard_Boolean Status (const ShapeExtend_Status theStatus) const;
42cf5bc1 106
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.
2c26a53d 110 //! The output curve 2D is guaranteed to be same-parameter
42cf5bc1 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.
2c26a53d 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);
42cf5bc1 121
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
130 //! and surface.
2c26a53d 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);
42cf5bc1 138
42cf5bc1 139
140
25e59720 141 DEFINE_STANDARD_RTTIEXT(ShapeConstruct_ProjectCurveOnSurface,Standard_Transient)
42cf5bc1 142
143protected:
144
145
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
2c26a53d 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;
42cf5bc1 159
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;
166 gp_Pnt myCashe3d[2];
167 gp_Pnt2d myCashe2d[2];
168
169
170private:
171
172
173 Standard_EXPORT Handle(Geom2d_Curve) ProjectAnalytic (const Handle(Geom_Curve)& c3d) const;
174
2c26a53d 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);
183
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);
190
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);
202
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;
42cf5bc1 207
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;
209
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;
211
212 Standard_EXPORT void CheckPoints (Handle(TColgp_HArray1OfPnt)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
213
214 Standard_EXPORT void CheckPoints2d (Handle(TColgp_HArray1OfPnt2d)& points, Handle(TColStd_HArray1OfReal)& params, Standard_Real& preci) const;
215
2c26a53d 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,
221 gp_Pnt2d& valueP1,
222 Standard_Boolean& p2OnIso,
223 gp_Pnt2d& valueP2,
224 Standard_Boolean& isoPar2d3d,
225 Handle(Geom_Curve)& cIso,
226 Standard_Real& t1,
227 Standard_Real& t2,
228 TColStd_Array1OfReal& pout) const;
42cf5bc1 229
230
231
232};
233
234
235
236
237
238
239
240#endif // _ShapeConstruct_ProjectCurveOnSurface_HeaderFile