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