0028966: Coding Rules - remove Adaptor2d_HCurve2d, Adaptor3d_HCurve and Adaptor3d_HSu...
[occt.git] / src / GeomLib / GeomLib.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-07-07
2// Created by: Jean Claude VAUTHIER
3// Copyright (c) 1993-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 _GeomLib_HeaderFile
18#define _GeomLib_HeaderFile
19
c22b52d6 20#include <Adaptor3d_Surface.hxx>
42cf5bc1 21#include <GeomAbs_Shape.hxx>
42cf5bc1 22#include <TColgp_Array1OfPnt.hxx>
23#include <TColStd_Array1OfReal.hxx>
24#include <TColStd_HArray1OfReal.hxx>
25#include <TColStd_SequenceOfReal.hxx>
c22b52d6 26
42cf5bc1 27class Geom_Curve;
28class gp_Ax2;
29class Geom2d_Curve;
30class gp_GTrsf2d;
31class Adaptor3d_CurveOnSurface;
32class Geom_BoundedCurve;
33class gp_Pnt;
34class gp_Vec;
35class Geom_BoundedSurface;
36class gp_Dir;
37class Adaptor3d_Curve;
38class Geom_BSplineSurface;
39067947 39class Geom_BezierSurface;
42cf5bc1 40class Geom_Surface;
41class gp_Pnt2d;
42class GeomLib_MakeCurvefromApprox;
43class GeomLib_Interpolate;
44class GeomLib_DenominatorMultiplier;
45class GeomLib_CheckBSplineCurve;
46class GeomLib_Check2dBSplineCurve;
47class GeomLib_IsPlanarSurface;
48class GeomLib_Tool;
49class GeomLib_PolyFunc;
50class GeomLib_LogSample;
51
c22b52d6 52typedef class Adaptor2d_Curve2d Adaptor2d_Curve2d;
42cf5bc1 53
54//! Geom Library. This package provides an
55//! implementation of functions for basic computation
56//! on geometric entity from packages Geom and Geom2d.
57class GeomLib
58{
59public:
60
61 DEFINE_STANDARD_ALLOC
62
63
64 //! Computes the curve 3d from package Geom
65 //! corresponding to curve 2d from package Geom2d, on
66 //! the plan defined with the local coordinate system
67 //! Position.
68 Standard_EXPORT static Handle(Geom_Curve) To3d (const gp_Ax2& Position, const Handle(Geom2d_Curve)& Curve2d);
69
70 //! Computes the curve 3d from package Geom
71 //! corresponding to the curve 3d from package Geom,
72 //! transformed with the transformation <GTrsf>
73 //! WARNING : this method may return a null Handle if
74 //! it's impossible to compute the transformation of
75 //! a curve. It's not implemented when :
76 //! 1) the curve is an infinite parabola or hyperbola
77 //! 2) the curve is an offsetcurve
78 Standard_EXPORT static Handle(Geom2d_Curve) GTransform (const Handle(Geom2d_Curve)& Curve, const gp_GTrsf2d& GTrsf);
79
80 //! Make the curve Curve2dPtr have the imposed
81 //! range First to List the most economic way,
82 //! that is if it can change the range without
83 //! changing the nature of the curve it will try
84 //! to do that. Otherwise it will produce a Bspline
85 //! curve that has the required range
86 Standard_EXPORT static void SameRange (const Standard_Real Tolerance, const Handle(Geom2d_Curve)& Curve2dPtr, const Standard_Real First, const Standard_Real Last, const Standard_Real RequestedFirst, const Standard_Real RequestedLast, Handle(Geom2d_Curve)& NewCurve2dPtr);
87
88 Standard_EXPORT static void BuildCurve3d (const Standard_Real Tolerance, Adaptor3d_CurveOnSurface& CurvePtr, const Standard_Real FirstParameter, const Standard_Real LastParameter, Handle(Geom_Curve)& NewCurvePtr, Standard_Real& MaxDeviation, Standard_Real& AverageDeviation, const GeomAbs_Shape Continuity = GeomAbs_C1, const Standard_Integer MaxDegree = 14, const Standard_Integer MaxSegment = 30);
89
90 Standard_EXPORT static void AdjustExtremity (Handle(Geom_BoundedCurve)& Curve, const gp_Pnt& P1, const gp_Pnt& P2, const gp_Vec& T1, const gp_Vec& T2);
91
92 //! Extends the bounded curve Curve to the point Point.
93 //! The extension is built:
94 //! - at the end of the curve if After equals true, or
95 //! - at the beginning of the curve if After equals false.
96 //! The extension is performed according to a degree of
97 //! continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
98 //! This function converts the bounded curve Curve into a BSpline curve.
99 //! Warning
100 //! - Nothing is done, and Curve is not modified if Cont is
101 //! not equal to 1, 2 or 3.
102 //! - It is recommended that the extension should not be
103 //! too large with respect to the size of the bounded
104 //! curve Curve: Point must not be located too far from
105 //! one of the extremities of Curve.
106 Standard_EXPORT static void ExtendCurveToPoint (Handle(Geom_BoundedCurve)& Curve, const gp_Pnt& Point, const Standard_Integer Cont, const Standard_Boolean After);
107
108
109 //! Extends the bounded surface Surf along one of its
110 //! boundaries. The chord length of the extension is equal to Length.
111 //! The direction of the extension is given as:
112 //! - the u parametric direction of Surf, if InU equals true, or
113 //! - the v parametric direction of Surf, if InU equals false.
114 //! In this parametric direction, the extension is built on the side of:
115 //! - the last parameter of Surf, if After equals true, or
116 //! - the first parameter of Surf, if After equals false.
117 //! The extension is performed according to a degree of
118 //! continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
119 //! This function converts the bounded surface Surf into a BSpline surface.
120 //! Warning
121 //! - Nothing is done, and Surf is not modified if Cont is
122 //! not equal to 1, 2 or 3.
123 //! - It is recommended that Length, the size of the
124 //! extension should not be too large with respect to the
125 //! size of the bounded surface Surf.
126 //! - Surf must not be a periodic BSpline surface in the
127 //! parametric direction corresponding to the direction of extension.
128 Standard_EXPORT static void ExtendSurfByLength (Handle(Geom_BoundedSurface)& Surf, const Standard_Real Length, const Standard_Integer Cont, const Standard_Boolean InU, const Standard_Boolean After);
129
130 //! Compute axes of inertia, of some points -- -- --
131 //! <Axe>.Location() is the BaryCentre -- -- -- -- --
132 //! <Axe>.XDirection is the axe of upper inertia -- -- --
133 //! -- <Axe>.Direction is the Normal to the average plane
134 //! -- -- -- IsSingular is True if points are on line --
135 //! Tol is used to determine singular cases.
136 Standard_EXPORT static void AxeOfInertia (const TColgp_Array1OfPnt& Points, gp_Ax2& Axe, Standard_Boolean& IsSingular, const Standard_Real Tol = 1.0e-7);
137
138 //! Compute principale axes of inertia, and dispertion
139 //! value of some points.
140 Standard_EXPORT static void Inertia (const TColgp_Array1OfPnt& Points, gp_Pnt& Bary, gp_Dir& XDir, gp_Dir& YDir, Standard_Real& Xgap, Standard_Real& YGap, Standard_Real& ZGap);
141
142 //! Warning! This assume that the InParameter is an increasing sequence
143 //! of real number and it will not check for that : Unpredictable
144 //! result can happen if this is not satisfied. It is the caller
21c7c457 145 //! responsibility to check for that property.
42cf5bc1 146 //!
147 //! This method makes uniform NumPoints segments S1,...SNumPoints out
148 //! of the segment defined by the first parameter and the
149 //! last parameter ofthe InParameter ; keeps only one
150 //! point of the InParameters set of parameter in each of
151 //! the uniform segments taking care of the first and the
152 //! last parameters. For the ith segment the element of
153 //! the InParameter is the one that is the first to exceed
154 //! the midpoint of the segment and to fall before the
155 //! midpoint of the next segment
156 //! There will be at the end at most NumPoints + 1 if
157 //! NumPoints > 2 in the OutParameters Array
158 Standard_EXPORT static void RemovePointsFromArray (const Standard_Integer NumPoints, const TColStd_Array1OfReal& InParameters, Handle(TColStd_HArray1OfReal)& OutParameters);
159
160 //! this makes sure that there is at least MinNumPoints
161 //! in OutParameters taking into account the parameters in
162 //! the InParameters array provided those are in order,
163 //! that is the sequence of real in the InParameter is strictly
164 //! non decreasing
165 Standard_EXPORT static void DensifyArray1OfReal (const Standard_Integer MinNumPoints, const TColStd_Array1OfReal& InParameters, Handle(TColStd_HArray1OfReal)& OutParameters);
166
167 Standard_EXPORT static void FuseIntervals (const TColStd_Array1OfReal& Interval1, const TColStd_Array1OfReal& Interval2, TColStd_SequenceOfReal& Fusion, const Standard_Real Confusion = 1.0e-9);
168
169 //! this will compute the maximum distance at the
170 //! parameters given in the Parameters array by
171 //! evaluating each parameter the two curves and taking
172 //! the maximum of the evaluated distance
173 Standard_EXPORT static void EvalMaxParametricDistance (const Adaptor3d_Curve& Curve, const Adaptor3d_Curve& AReferenceCurve, const Standard_Real Tolerance, const TColStd_Array1OfReal& Parameters, Standard_Real& MaxDistance);
174
175 //! this will compute the maximum distancef at the parameters
176 //! given in the Parameters array by projecting from the Curve
177 //! to the reference curve and taking the minimum distance
178 //! Than the maximum will be taken on those minimas.
179 Standard_EXPORT static void EvalMaxDistanceAlongParameter (const Adaptor3d_Curve& Curve, const Adaptor3d_Curve& AReferenceCurve, const Standard_Real Tolerance, const TColStd_Array1OfReal& Parameters, Standard_Real& MaxDistance);
180
181 //! Cancel,on the boudaries,the denominator first derivative
182 //! in the directions wished by the user and set its value to 1.
183 Standard_EXPORT static void CancelDenominatorDerivative (Handle(Geom_BSplineSurface)& BSurf, const Standard_Boolean UDirection, const Standard_Boolean VDirection);
184
185 Standard_EXPORT static Standard_Integer NormEstim (const Handle(Geom_Surface)& S, const gp_Pnt2d& UV, const Standard_Real Tol, gp_Dir& N);
186
39067947 187 //! This method defines if opposite boundaries of surface
188 //! coincide with given tolerance
189 Standard_EXPORT static void IsClosed(const Handle(Geom_Surface)& S, const Standard_Real Tol,
190 Standard_Boolean& isUClosed, Standard_Boolean& isVClosed);
191
192 //! Returns true if the poles of U1 isoline and the poles of
193 //! U2 isoline of surface are identical according to tolerance criterion.
194 //! For rational surfaces Weights(i)*Poles(i) are checked.
195 Standard_EXPORT static Standard_Boolean IsBSplUClosed(const Handle(Geom_BSplineSurface)& S,
196 const Standard_Real U1,
197 const Standard_Real U2,
198 const Standard_Real Tol);
199
200 //! Returns true if the poles of V1 isoline and the poles of
201 //! V2 isoline of surface are identical according to tolerance criterion.
202 //! For rational surfaces Weights(i)*Poles(i) are checked.
203 Standard_EXPORT static Standard_Boolean IsBSplVClosed(const Handle(Geom_BSplineSurface)& S,
204 const Standard_Real V1,
205 const Standard_Real V2,
206 const Standard_Real Tol);
207
208 //! Returns true if the poles of U1 isoline and the poles of
209 //! U2 isoline of surface are identical according to tolerance criterion.
210 Standard_EXPORT static Standard_Boolean IsBzUClosed(const Handle(Geom_BezierSurface)& S,
211 const Standard_Real U1,
212 const Standard_Real U2,
213 const Standard_Real Tol);
214
215 //! Returns true if the poles of V1 isoline and the poles of
216 //! V2 isoline of surface are identical according to tolerance criterion.
217 Standard_EXPORT static Standard_Boolean IsBzVClosed(const Handle(Geom_BezierSurface)& S,
218 const Standard_Real V1,
219 const Standard_Real V2,
220 const Standard_Real Tol);
42cf5bc1 221
552a74d8 222 //! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
223 //! or geometric line. This line should have natural parameterization.
224 //! @param theC2D Trimmed curve to be checked.
225 //! @param theIsU Flag indicating that line is u const.
226 //! @param theParam Line parameter.
227 //! @param theIsForward Flag indicating forward parameterization on a isoline.
228 //! @return Standard_True when 2d curve is a line and Standard_False otherwise.
c22b52d6 229 Standard_EXPORT static Standard_Boolean isIsoLine (const Handle(Adaptor2d_Curve2d) theC2D,
552a74d8 230 Standard_Boolean& theIsU,
231 Standard_Real& theParam,
232 Standard_Boolean& theIsForward);
42cf5bc1 233
552a74d8 234 //! Builds 3D curve for a isoline. This method takes corresponding isoline from
235 //! the input surface.
236 //! @param theC2D Trimmed curve to be approximated.
237 //! @param theIsU Flag indicating that line is u const.
238 //! @param theParam Line parameter.
239 //! @param theIsForward Flag indicating forward parameterization on a isoline.
240 //! @return Standard_True when 3d curve is built and Standard_False otherwise.
c22b52d6 241 Standard_EXPORT static Handle(Geom_Curve) buildC3dOnIsoLine (const Handle(Adaptor2d_Curve2d) theC2D,
242 const Handle(Adaptor3d_Surface) theSurf,
552a74d8 243 const Standard_Real theFirst,
244 const Standard_Real theLast,
245 const Standard_Real theTolerance,
246 const Standard_Boolean theIsU,
247 const Standard_Real theParam,
248 const Standard_Boolean theIsForward);
42cf5bc1 249
552a74d8 250protected:
42cf5bc1 251
252
253private:
254
255
256
257
258friend class GeomLib_MakeCurvefromApprox;
259friend class GeomLib_Interpolate;
260friend class GeomLib_DenominatorMultiplier;
261friend class GeomLib_CheckBSplineCurve;
262friend class GeomLib_Check2dBSplineCurve;
263friend class GeomLib_IsPlanarSurface;
264friend class GeomLib_Tool;
265friend class GeomLib_PolyFunc;
266friend class GeomLib_LogSample;
267
268};
269
270
271
272
273
274
275
276#endif // _GeomLib_HeaderFile