1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

1
src/GeomLib/FILES Executable file
View File

@@ -0,0 +1 @@
GeomLib_CMPLRS.edl

301
src/GeomLib/GeomLib.cdl Executable file
View File

@@ -0,0 +1,301 @@
-- File: GeomLib.cdl
-- Created: Wed Jul 7 12:38:18 1993
-- Author: Jean Claude VAUTHIER
---Copyright: Matra Datavision 1993
-- jct : modified 15-Apr-97 : added method ExtendSurfByLength
package GeomLib
---Purpose: Geom Library. This package provides an
-- implementation of functions for basic computation
-- on geometric entity from packages Geom and Geom2d.
uses
TCollection,
TColStd,
TColgp,
TColGeom,
TColGeom2d,
Adaptor3d,
AdvApprox,
Geom,
Geom2d,
GeomAbs,
math,
gp,
StdFail
is
enumeration InterpolationErrors is
---Purpose: in case the interpolation errors out, this
-- tells what happened
NoError,
NotEnoughtPoints,
DegreeSmallerThan3,
InversionProblem
end InterpolationErrors;
-- -- --------------- --
-- C L A S S E S --
-- --------------- --
class Array1OfMat instantiates
Array1 from TCollection (Mat from gp);
class MakeCurvefromApprox;
---Purpose: This class is used to create the curves ( 2d or
-- 3d) rational or not created by the class
-- ApproxAFunction from AdvApprox.
class Interpolate ;
---Purpose: this class compute the poles of a curve given some
-- parameters, points to interpolate and boundary conditions
-- in 3d
class DenominatorMultiplier ;
---Purpose: this defines an evaluator for a function of 2 variables
-- that will be used by CancelDenominatorDerivative in one
-- direction.
class CheckBSplineCurve ;
---Purpose: Checks for the end tangents : wether or not those
-- are reversed regarding the third or n-3rd control
--
--
class Check2dBSplineCurve ;
---Purpose: Checks for the end tangents : wether or not those
-- are reversed
class IsPlanarSurface;
class Tool;
---Purpose: provides various methods with Geom2d and Geom curves
--- and surfaces.
private class PolyFunc;
private class LogSample;
pointer DenominatorMultiplierPtr to DenominatorMultiplier from GeomLib ;
-------------------------
-- M E T H O D E S --
-- ----------------- --
To3d (Position : in Ax2 from gp;
Curve2d : in Curve from Geom2d)
returns Curve from Geom;
---Purpose: Computes the curve 3d from package Geom
-- corresponding to curve 2d from package Geom2d, on
-- the plan defined with the local coordinate system
-- Position.
GTransform( Curve : in Curve from Geom2d;
GTrsf : in GTrsf2d from gp)
returns Curve from Geom2d;
---Purpose: Computes the curve 3d from package Geom
-- corresponding to the curve 3d from package Geom,
-- transformed with the transformation <GTrsf>
-- WARNING : this method may return a null Handle if
-- it's impossible to compute the transformation of
-- a curve. It's not implemented when :
-- 1) the curve is an infinite parabola or hyperbola
-- 2) the curve is an offsetcurve
SameRange(Tolerance : in Real from Standard ;
Curve2dPtr : in Curve from Geom2d ;
First : in Real from Standard ;
Last : in Real from Standard ;
RequestedFirst : in Real from Standard ;
RequestedLast : in Real from Standard ;
NewCurve2dPtr : out Curve from Geom2d) ;
---Purpose: Make the curve Curve2dPtr have the imposed
-- range First to List the most economic way,
-- that is if it can change the range without
-- changing the nature of the curve it will try
-- to do that. Otherwise it will produce a Bspline
-- curve that has the required range
BuildCurve3d(Tolerance : in Real from Standard ;
CurvePtr : in out CurveOnSurface from Adaptor3d ;
FirstParameter : in Real from Standard ;
LastParameter : in Real from Standard ;
NewCurvePtr : out Curve from Geom ;
MaxDeviation : out Real from Standard ;
AverageDeviation : out Real from Standard ;
Continuity : Shape from GeomAbs = GeomAbs_C1;
MaxDegree : Integer = 14;
MaxSegment : Integer = 30);
AdjustExtremity(Curve : in out BoundedCurve from Geom;
P1, P2 : Pnt from gp;
T1, T2 : Vec from gp);
ExtendCurveToPoint(Curve : in out BoundedCurve from Geom;
Point : Pnt from gp;
Cont : Integer from Standard;
After : Boolean from Standard);
---Purpose: Extends the bounded curve Curve to the point Point.
-- The extension is built:
-- - at the end of the curve if After equals true, or
-- - at the beginning of the curve if After equals false.
-- The extension is performed according to a degree of
-- continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
-- This function converts the bounded curve Curve into a BSpline curve.
-- Warning
-- - Nothing is done, and Curve is not modified if Cont is
-- not equal to 1, 2 or 3.
-- - It is recommended that the extension should not be
-- too large with respect to the size of the bounded
-- curve Curve: Point must not be located too far from
-- one of the extremities of Curve.
ExtendSurfByLength(Surf : in out BoundedSurface from Geom;
Length : Real from Standard;
Cont : Integer from Standard;
InU : Boolean from Standard;
After : Boolean from Standard);
---Purpose:
-- Extends the bounded surface Surf along one of its
-- boundaries. The chord length of the extension is equal to Length.
-- The direction of the extension is given as:
-- - the u parametric direction of Surf, if InU equals true, or
-- - the v parametric direction of Surf, if InU equals false.
-- In this parametric direction, the extension is built on the side of:
-- - the last parameter of Surf, if After equals true, or
-- - the first parameter of Surf, if After equals false.
-- The extension is performed according to a degree of
-- continuity equal to Cont, which in its turn must be equal to 1, 2 or 3.
-- This function converts the bounded surface Surf into a BSpline surface.
-- Warning
-- - Nothing is done, and Surf is not modified if Cont is
-- not equal to 1, 2 or 3.
-- - It is recommended that Length, the size of the
-- extension should not be too large with respect to the
-- size of the bounded surface Surf.
-- - Surf must not be a periodic BSpline surface in the
-- parametric direction corresponding to the direction of extension.
AxeOfInertia(Points : Array1OfPnt from TColgp;
Axe : out Ax2 from gp;
IsSingular : out Boolean;
Tol : Real = 1.0e-7);
---Purpose: Compute axes of inertia, of some points -- -- --
-- <Axe>.Location() is the BaryCentre -- -- -- -- --
-- <Axe>.XDirection is the axe of upper inertia -- -- --
-- -- <Axe>.Direction is the Normal to the average plane
-- -- -- -- IsSingular is True if points are on line --
-- Tol is used to determine singular cases.
Inertia(Points : Array1OfPnt from TColgp;
Bary : out Pnt from gp;
XDir,YDir : out Dir from gp;
Xgap,YGap,ZGap : out Real);
---Level: Advanced
---Purpose: Compute principale axes of inertia, and dispertion
-- value of some points.
RemovePointsFromArray(NumPoints : Integer from Standard ;
InParameters : Array1OfReal from TColStd ;
OutParameters : in out HArray1OfReal from TColStd) ;
---Purpose: Warning! This assume that the InParameter is an increasing sequence
-- of real number and it will not check for that : Unpredictable
-- result can happen if this is not satisfied. It is the caller
-- responsability to check for that property.
--
-- This method makes uniform NumPoints segments S1,...SNumPoints out
-- of the segment defined by the first parameter and the
-- last parameter ofthe InParameter ; keeps only one
-- point of the InParameters set of parameter in each of
-- the uniform segments taking care of the first and the
-- last parameters. For the ith segment the element of
-- the InParameter is the one that is the first to exceed
-- the midpoint of the segment and to fall before the
-- midpoint of the next segment
-- There will be at the end at most NumPoints + 1 if
-- NumPoints > 2 in the OutParameters Array
DensifyArray1OfReal(MinNumPoints : Integer from Standard ;
InParameters : Array1OfReal from TColStd ;
OutParameters : in out HArray1OfReal from TColStd) ;
---Purpose: this makes sure that there is at least MinNumPoints
-- in OutParameters taking into account the parameters in
-- the InParameters array provided those are in order,
-- that is the sequence of real in the InParameter is strictly
-- non decreasing
--
FuseIntervals(Interval1, Interval2 : Array1OfReal from TColStd;
Fusion : out SequenceOfReal from TColStd;
Confusion : Real = 1.0e-9);
EvalMaxParametricDistance(Curve : Curve from Adaptor3d ;
AReferenceCurve : Curve from Adaptor3d ;
Tolerance : Real from Standard ;
Parameters : Array1OfReal from TColStd ;
MaxDistance : out Real from Standard) ;
---Purpose: this will compute the maximum distance at the
-- parameters given in the Parameters array by
-- evaluating each parameter the two curves and taking
-- the maximum of the evaluated distance
EvalMaxDistanceAlongParameter(Curve : Curve from Adaptor3d ;
AReferenceCurve : Curve from Adaptor3d ;
Tolerance : Real from Standard ;
Parameters : Array1OfReal from TColStd ;
MaxDistance : out Real from Standard) ;
---Purpose: this will compute the maximum distancef at the parameters
-- given in the Parameters array by projecting from the Curve
-- to the reference curve and taking the minimum distance
-- Than the maximum will be taken on those minimas.
CancelDenominatorDerivative(BSurf : in out BSplineSurface from Geom ;
UDirection : in Boolean from Standard ;
VDirection : in Boolean from Standard) ;
---Purpose: Cancel,on the boudaries,the denominator first derivative
-- in the directions wished by the user and set its value to 1.
-- TensorialProduct(S : in out BSplineSurface from Geom;
-- Poles : Array1OfMat from GeomLib;
-- TPoles : Array1OfPnt from TColgp;
-- Knots : Array1OfReal from TColStd;
-- Mults : Array1OfInteger from TColStd);
-- Purpose: Compute the Tensorial product beetween an
-- BSplineSurface <S>(U,V) and an Transformation Law M(v)
-- given by NUBS form (<Poles>, <Knots>, <Mults>). The result
-- Surface is R(U,V) = M(V)*S(U,V)+T(V).
NormEstim(S : Surface from Geom;
UV : Pnt2d from gp;
Tol : Real from Standard;
N : in out Dir from gp)
returns Integer from Standard;
-- Purpose: Computes normal of surface S in UV point UV
-- for regular point N = DU^DV
-- if |DU| < Tol or |DV| < Tol special treatment is used:
-- N is computed on base of normal of corresponding isoline
-- of S
-- returns 0 for regular point,
-- 1 for quasysingular (ex.: sphere pole)
-- 2 for conical singular point
-- 3 if computation impossible (for ex. DU||DV - tangent isolines)
end GeomLib;

2452
src/GeomLib/GeomLib.cxx Executable file

File diff suppressed because it is too large Load Diff

19
src/GeomLib/GeomLib_CMPLRS.edl Executable file
View File

@@ -0,0 +1,19 @@
@ifnotdefined ( %GeomLib_CMPLRS_EDL ) then
@set %GeomLib_CMPLRS_EDL= "";
@if ( %Station == "wnt" ) then
@if ( %DebugMode == "False" ) then
@set %ModeOpt = "-Zi -DNDEBUG -DNo_Exception -O1 -G5 ";
@endif;
@endif;
@endif;

View File

@@ -0,0 +1,67 @@
-- File: GeomLib_CheckBSplineCurve.cdl
-- Created: Wed May 28 16:31:08 1997
-- Author: Xavier BENVENISTE
-- <xab@zozox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class Check2dBSplineCurve from GeomLib
---Purpose: this class is used to construct the BSpline curve
-- from an Approximation ( ApproxAFunction from AdvApprox).
uses
Pnt2d from gp,
BSplineCurve from Geom2d
raises
NotDone from StdFail,
OutOfRange from Standard
is
Create( Curve : BSplineCurve from Geom2d ;
Tolerance : Real from Standard ;
AngularTolerance : Real from Standard)
returns Check2dBSplineCurve from GeomLib;
IsDone(me) returns Boolean from Standard
---C++: inline
is static;
NeedTangentFix(me; FirstFlag : in out Boolean from Standard ;
SecondFlag : in out Boolean from Standard) ;
FixTangent (me : in out ; FirstFlag : Boolean from Standard ;
LastFlag : Boolean from Standard) ;
FixedTangent (me : in out ; FirstFlag : Boolean from Standard ;
LastFlag : Boolean from Standard)
---Purpose: modifies the curve
-- by fixing the first or the last tangencies
--
returns BSplineCurve from Geom2d
raises
OutOfRange from Standard,
---Purpose: if Index3D not in the Range [1,Nb3dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
fields
myCurve : BSplineCurve from Geom2d ;
myDone : Boolean from Standard ;
myFixFirstTangent : Boolean from Standard ;
myFixLastTangent : Boolean from Standard ;
myAngularTolerance : Real from Standard ;
myTolerance : Real from Standard ;
myFirstPole : Pnt2d from gp ;
-- the second pole that controls first tangency
myLastPole : Pnt2d from gp ;
-- the before last pole that controls last tangency
end Check2dBSplineCurve;

View File

@@ -0,0 +1,167 @@
// File: GeomLib_Check2dBSplineCurve.cxx
// Created: Wed May 28 17:26:47 1997
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
#include <GeomLib_Check2dBSplineCurve.ixx>
#include <Geom_BSplineCurve.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
//=======================================================================
//function : GeomLib_Check2dBSplineCurve
//purpose :
//=======================================================================
GeomLib_Check2dBSplineCurve::GeomLib_Check2dBSplineCurve(const Handle(Geom2d_BSplineCurve)& Curve,
const Standard_Real Tolerance,
const Standard_Real AngularTolerance)
:myCurve(Curve),
myDone(Standard_False),
myFixFirstTangent(Standard_False),
myFixLastTangent(Standard_False),
myAngularTolerance(Abs(AngularTolerance)),
myTolerance(Abs(Tolerance)),
myFirstPole(1.0,0.0e0),
myLastPole(1.0e0,0.0e0)
{
Standard_Integer ii,
num_poles ;
Standard_Real tangent_magnitude,
value,
angular_value,
factor,
vector_magnitude ;
num_poles = Curve->NbPoles() ;
if (( ! myCurve->IsPeriodic() )&& num_poles >= 4) {
gp_Vec2d tangent,
diff,
a_vector;
for (ii = 1 ; ii <= 2 ; ii++) {
tangent.SetCoord(ii,myCurve->Pole(2).Coord(ii) - myCurve->Pole(1).Coord(ii)) ;
a_vector.SetCoord(ii, myCurve->Pole(3).Coord(ii) - myCurve->Pole(1).Coord(ii)) ;
}
tangent_magnitude = tangent.Magnitude() ;
vector_magnitude = a_vector.Magnitude() ;
if (tangent_magnitude > myTolerance &&
vector_magnitude > myTolerance)
{
value = tangent.Dot(a_vector) ;
if ( value < 0.0e0) {
for (ii = 1 ; ii <= 2 ; ii++) {
diff.SetCoord(ii, (tangent.Coord(ii) / tangent_magnitude) + (a_vector.Coord(ii) / vector_magnitude)) ;
}
angular_value =
diff.Magnitude() ;
if (angular_value < myAngularTolerance) {
myFixFirstTangent = Standard_True ;
factor = 1.0e0 ;
if (tangent_magnitude > 0.5e0 * vector_magnitude) {
factor = 0.5e0 * vector_magnitude / tangent_magnitude ;
}
for (ii = 1 ; ii <= 2 ; ii++) {
myFirstPole.SetCoord(ii, myCurve->Pole(1).Coord(ii) - factor * tangent.Coord(ii)) ;
}
}
}
}
for (ii = 1 ; ii <= 2 ; ii++) {
tangent.SetCoord(ii,myCurve->Pole(num_poles-1).Coord(ii) - myCurve->Pole(num_poles).Coord(ii)) ;
a_vector.SetCoord(ii, myCurve->Pole(num_poles-2).Coord(ii) - myCurve->Pole(num_poles).Coord(ii)) ;
}
tangent_magnitude = tangent.Magnitude() ;
vector_magnitude = a_vector.Magnitude() ;
if (tangent_magnitude > myTolerance &&
vector_magnitude > myTolerance)
{
value = tangent.Dot(a_vector) ;
if (value < 0.0e0) {
for (ii = 1 ; ii <= 2 ; ii++) {
diff.SetCoord(ii, (tangent.Coord(ii) / tangent_magnitude) + (a_vector.Coord(ii) / vector_magnitude)) ;
}
angular_value =
diff.Magnitude() ;
if ( angular_value < myAngularTolerance) {
myFixLastTangent = Standard_True ;
factor = 1.0e0 ;
if (tangent_magnitude > 0.5e0 * vector_magnitude) {
factor = 0.5e0 * vector_magnitude / tangent_magnitude ;
}
for (ii = 1 ; ii <= 2 ; ii++) {
myLastPole.SetCoord(ii, myCurve->Pole(num_poles).Coord(ii) - factor * tangent.Coord(ii)) ;
}
}
}
}
}
else {
myDone = Standard_True ;
}
}
//=======================================================================
//function : NeedTangentFix
//purpose :
//=======================================================================
void GeomLib_Check2dBSplineCurve::NeedTangentFix(Standard_Boolean & FirstFlag,
Standard_Boolean & LastFlag) const
{
FirstFlag = myFixFirstTangent ;
LastFlag = myFixLastTangent ;
}
//=======================================================================
//function : FixTangent
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) GeomLib_Check2dBSplineCurve::FixedTangent(const Standard_Boolean FirstFlag,
const Standard_Boolean LastFlag)
{
Handle(Geom2d_BSplineCurve) new_curve ;
if ((myFixFirstTangent && FirstFlag) ||(myFixLastTangent && LastFlag)) {
new_curve =
Handle(Geom2d_BSplineCurve)::DownCast(myCurve->Copy()) ;
}
if (myFixFirstTangent && FirstFlag) {
new_curve->SetPole(2,
myFirstPole) ;
}
if (myFixLastTangent && LastFlag) {
Standard_Integer num_poles = myCurve->NbPoles() ;
new_curve->SetPole(num_poles-1,
myLastPole) ;
}
myDone = Standard_True ;
return new_curve ;
}
//=======================================================================
//function : FixTangent
//purpose :
//=======================================================================
void GeomLib_Check2dBSplineCurve::FixTangent(const Standard_Boolean FirstFlag,
const Standard_Boolean LastFlag)
{
if (myFixFirstTangent && FirstFlag) {
myCurve->SetPole(2,
myFirstPole) ;
}
if (myFixLastTangent && LastFlag) {
Standard_Integer num_poles = myCurve->NbPoles() ;
myCurve->SetPole(num_poles-1,
myLastPole) ;
}
myDone = Standard_True ;
}

View File

@@ -0,0 +1,8 @@
// File: GeomLib_Check2dBSplineCurve.lxx
// Created: Wed May 28 17:33:32 1997
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
inline Standard_Boolean GeomLib_Check2dBSplineCurve::IsDone() const
{
return myDone ;
}

View File

@@ -0,0 +1,68 @@
-- File: GeomLib_CheckBSplineCurve.cdl
-- Created: Wed May 28 16:31:08 1997
-- Author: Xavier BENVENISTE
-- <xab@zozox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class CheckBSplineCurve from GeomLib
---Purpose: this class is used to construct the BSpline curve
-- from an Approximation ( ApproxAFunction from AdvApprox).
uses
Pnt from gp,
BSplineCurve from Geom,
BSplineCurve from Geom2d
raises
NotDone from StdFail,
OutOfRange from Standard
is
Create( Curve : BSplineCurve from Geom ;
Tolerance : Real from Standard ;
AngularTolerance : Real from Standard)
returns CheckBSplineCurve from GeomLib;
IsDone(me) returns Boolean from Standard
---C++: inline
is static;
NeedTangentFix(me; FirstFlag : in out Boolean from Standard ;
SecondFlag : in out Boolean from Standard) ;
FixTangent (me : in out ; FirstFlag : Boolean from Standard ;
LastFlag : Boolean from Standard) ;
FixedTangent (me : in out ; FirstFlag : Boolean from Standard ;
LastFlag : Boolean from Standard)
---Purpose: modifies the curve
-- by fixing the first or the last tangencies
--
returns BSplineCurve from Geom
raises
OutOfRange from Standard,
---Purpose: if Index3D not in the Range [1,Nb3dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
fields
myCurve : BSplineCurve from Geom ;
myDone : Boolean from Standard ;
myFixFirstTangent : Boolean from Standard ;
myFixLastTangent : Boolean from Standard ;
myAngularTolerance : Real from Standard ;
myTolerance : Real from Standard ;
myFirstPole : Pnt from gp ;
-- the second pole that controls first tangency
myLastPole : Pnt from gp ;
-- the before last pole that controls last tangency
end CheckBSplineCurve;

View File

@@ -0,0 +1,167 @@
// File: GeomLib_CheckBSplineCurve.cxx
// Created: Wed May 28 17:26:47 1997
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
#include <GeomLib_CheckBSplineCurve.ixx>
#include <Geom_BSplineCurve.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
//=======================================================================
//function : GeomLib_CheckBSplineCurve
//purpose :
//=======================================================================
GeomLib_CheckBSplineCurve::GeomLib_CheckBSplineCurve(const Handle(Geom_BSplineCurve)& Curve,
const Standard_Real Tolerance,
const Standard_Real AngularTolerance)
:myCurve(Curve),
myDone(Standard_False),
myFixFirstTangent(Standard_False),
myFixLastTangent(Standard_False),
myAngularTolerance(Abs(AngularTolerance)),
myTolerance(Abs(Tolerance)),
myFirstPole(1.0,0.0e0,0.e0),
myLastPole(1.0e0,0.0e0,0.e0)
{
Standard_Integer ii,
num_poles ;
Standard_Real tangent_magnitude,
value,
angular_value,
factor,
vector_magnitude ;
num_poles = Curve->NbPoles() ;
if (( ! myCurve->IsPeriodic() )&& num_poles >= 4) {
gp_Vec tangent,
diff,
a_vector;
for (ii = 1 ; ii <= 3 ; ii++) {
tangent.SetCoord(ii,myCurve->Pole(2).Coord(ii) - myCurve->Pole(1).Coord(ii)) ;
a_vector.SetCoord(ii, myCurve->Pole(3).Coord(ii) - myCurve->Pole(1).Coord(ii)) ;
}
tangent_magnitude = tangent.Magnitude() ;
vector_magnitude = a_vector.Magnitude() ;
if (tangent_magnitude > myTolerance &&
vector_magnitude > myTolerance)
{
value = tangent.Dot(a_vector) ;
if ( value < 0.0e0) {
for (ii = 1 ; ii <= 3 ; ii++) {
diff.SetCoord(ii, (tangent.Coord(ii) / tangent_magnitude) + (a_vector.Coord(ii) / vector_magnitude)) ;
}
angular_value =
diff.Magnitude() ;
if (angular_value < myAngularTolerance) {
myFixFirstTangent = Standard_True ;
factor = 1.0e0 ;
if (tangent_magnitude > 0.5e0 * vector_magnitude) {
factor = 0.5e0 * vector_magnitude / tangent_magnitude ;
}
for (ii = 1 ; ii <= 3 ; ii++) {
myFirstPole.SetCoord(ii, myCurve->Pole(1).Coord(ii) - factor * tangent.Coord(ii)) ;
}
}
}
}
for (ii = 1 ; ii <= 3 ; ii++) {
tangent.SetCoord(ii,myCurve->Pole(num_poles-1).Coord(ii) - myCurve->Pole(num_poles).Coord(ii)) ;
a_vector.SetCoord(ii, myCurve->Pole(num_poles-2).Coord(ii) - myCurve->Pole(num_poles).Coord(ii)) ;
}
tangent_magnitude = tangent.Magnitude() ;
vector_magnitude = a_vector.Magnitude() ;
if (tangent_magnitude > myTolerance &&
vector_magnitude > myTolerance)
{
value = tangent.Dot(a_vector) ;
if (value < 0.0e0) {
for (ii = 1 ; ii <= 3 ; ii++) {
diff.SetCoord(ii, (tangent.Coord(ii) / tangent_magnitude) + (a_vector.Coord(ii) / vector_magnitude)) ;
}
angular_value =
diff.Magnitude() ;
if ( angular_value < myAngularTolerance) {
myFixLastTangent = Standard_True ;
factor = 1.0e0 ;
if (tangent_magnitude > 0.5e0 * vector_magnitude) {
factor = 0.5e0 * vector_magnitude / tangent_magnitude ;
}
for (ii = 1 ; ii <= 3 ; ii++) {
myLastPole.SetCoord(ii, myCurve->Pole(num_poles).Coord(ii) - factor * tangent.Coord(ii)) ;
}
}
}
}
}
else {
myDone = Standard_True ;
}
}
//=======================================================================
//function : NeedTangentFix
//purpose :
//=======================================================================
void GeomLib_CheckBSplineCurve::NeedTangentFix(Standard_Boolean & FirstFlag,
Standard_Boolean & LastFlag) const
{
FirstFlag = myFixFirstTangent ;
LastFlag = myFixLastTangent ;
}
//=======================================================================
//function : FixTangent
//purpose :
//=======================================================================
Handle(Geom_BSplineCurve) GeomLib_CheckBSplineCurve::FixedTangent(const Standard_Boolean FirstFlag,
const Standard_Boolean LastFlag)
{
Handle(Geom_BSplineCurve) new_curve ;
if ((myFixFirstTangent && FirstFlag) ||(myFixLastTangent && LastFlag)) {
new_curve =
Handle(Geom_BSplineCurve)::DownCast(myCurve->Copy()) ;
}
if (myFixFirstTangent && FirstFlag) {
new_curve->SetPole(2,
myFirstPole) ;
}
if (myFixLastTangent && LastFlag) {
Standard_Integer num_poles = myCurve->NbPoles() ;
new_curve->SetPole(num_poles-1,
myLastPole) ;
}
myDone = Standard_True ;
return new_curve ;
}
//=======================================================================
//function : FixTangent
//purpose :
//=======================================================================
void GeomLib_CheckBSplineCurve::FixTangent(const Standard_Boolean FirstFlag,
const Standard_Boolean LastFlag)
{
if (myFixFirstTangent && FirstFlag) {
myCurve->SetPole(2,
myFirstPole) ;
}
if (myFixLastTangent && LastFlag) {
Standard_Integer num_poles = myCurve->NbPoles() ;
myCurve->SetPole(num_poles-1,
myLastPole) ;
}
myDone = Standard_True ;
}

View File

@@ -0,0 +1,8 @@
// File: GeomLib_CheckBSplineCurve.lxx
// Created: Wed May 28 17:33:32 1997
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
inline Standard_Boolean GeomLib_CheckBSplineCurve::IsDone() const
{
return myDone ;
}

View File

@@ -0,0 +1,72 @@
-- File: GeomLib_DenominatorMultiplier.cdl
-- Created: Tue May 13 10:36:30 1997
-- Author: Stagiaire Francois DUMONT
-- <dum@brunox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1997
class DenominatorMultiplier from GeomLib
---Purpose: this class is used to construct the BSpline curve
-- from an Approximation ( ApproxAFunction from AdvApprox).
uses
BSplineSurface from Geom,
Array1OfReal from TColStd
raises
OutOfRange from Standard,
ConstructionError from Standard
is
Create( Surface : BSplineSurface from Geom ;
KnotVector : Array1OfReal from TColStd)
returns DenominatorMultiplier from GeomLib
raises
ConstructionError from Standard;
---Purpose: if the surface is rational this will define the evaluator
-- of a real function of 2 variables a(u,v) such that
-- if we define a new surface by :
-- a(u,v) * N(u,v)
-- NewF(u,v) = ----------------
-- a(u,v) * D(u,v)
Value(me; UParameter : in Real from Standard ;
VParameter : in Real from Standard)
returns Real from Standard
raises
OutOfRange from Standard
---Purpose: Returns the value of
-- a(UParameter,VParameter)=
--
-- H0(UParameter)/Denominator(Umin,Vparameter)
--
-- D Denominator(Umin,Vparameter)
-- - ------------------------------[H1(u)]/(Denominator(Umin,Vparameter)^2)
-- D U
--
-- + H3(UParameter)/Denominator(Umax,Vparameter)
--
-- D Denominator(Umax,Vparameter)
-- - ------------------------------[H2(u)]/(Denominator(Umax,Vparameter)^2)
-- D U
is static;
fields
mySurface : BSplineSurface from Geom ;
myKnotFlatVector : Array1OfReal from TColStd ;
end MakeCurvefromApprox;

View File

@@ -0,0 +1,195 @@
// File: GeomLib_DenominatorMultiplier.cxx
// Created: Tue May 13 11:48:12 1997
// Author: Stagiaire Francois DUMONT
// <dum@brunox.paris1.matra-dtv.fr>
#include <GeomLib_DenominatorMultiplier.ixx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <BSplSLib.hxx>
#include <math_Matrix.hxx>
//=======================================================================
//function :GeomLib_DenominatorMultiplier
//purpose :
//=======================================================================
GeomLib_DenominatorMultiplier::GeomLib_DenominatorMultiplier
(const Handle(Geom_BSplineSurface) & Surface,
const TColStd_Array1OfReal & KnotVector):mySurface(Surface),
myKnotFlatVector(1,KnotVector.Length())
{Standard_Integer i;
for (i=1;i<=KnotVector.Length();i++)
myKnotFlatVector.SetValue(i,KnotVector(i));
}
//=======================================================================
//function : value
//purpose : give the value of a(UParameter,VParameter)
//=======================================================================
Standard_Real GeomLib_DenominatorMultiplier::Value(const Standard_Real UParameter,
const Standard_Real VParameter)const
{Standard_Real Dumaxv,Duminv,dDduumaxv,dDduuminv,
Dv,Buv=0.0;
// gp_Pnt HermPnt;
gp_Pnt N;
gp_Vec Nu,Nv;
TColgp_Array2OfPnt surface_poles(1,mySurface->NbUPoles(),
1,mySurface->NbVPoles()) ;
TColStd_Array2OfReal surface_weights(1,mySurface->NbUPoles(),
1,mySurface->NbVPoles()) ;
TColStd_Array1OfReal surface_u_knots(1,mySurface->NbUKnots()) ;
TColStd_Array1OfInteger surface_u_mults(1,mySurface->NbUKnots()) ;
TColStd_Array1OfReal surface_v_knots(1,mySurface->NbVKnots()) ;
TColStd_Array1OfInteger surface_v_mults(1,mySurface->NbVKnots()) ;
Standard_Integer udegree,vdegree;
mySurface->UKnots(surface_u_knots) ;
mySurface->UMultiplicities(surface_u_mults) ;
mySurface->Poles(surface_poles) ;
mySurface->Weights(surface_weights) ;
mySurface->VKnots(surface_v_knots) ;
mySurface->VMultiplicities(surface_v_mults) ;
udegree=mySurface->UDegree();
vdegree=mySurface->VDegree();
BSplSLib::HomogeneousD1(mySurface->UKnot(mySurface->LastUKnotIndex()),VParameter,
0,0,
surface_poles,
surface_weights,
surface_u_knots,surface_v_knots,
surface_u_mults,surface_v_mults,
udegree,vdegree,
mySurface->IsURational(),mySurface->IsVRational(),
mySurface->IsUPeriodic(),mySurface->IsVPeriodic(),
N,Nu,Nv,
Dumaxv,
dDduumaxv,
Dv);
BSplSLib::HomogeneousD1(mySurface->UKnot(1),VParameter,
0,0,
surface_poles,
surface_weights,
surface_u_knots,surface_v_knots,
surface_u_mults,surface_v_mults,
udegree,vdegree,
mySurface->IsURational(),mySurface->IsVRational(),
mySurface->IsUPeriodic(),mySurface->IsVPeriodic(),
N,Nu,Nv,
Duminv,
dDduuminv,
Dv);
math_Matrix BSplineBasisDeriv(1,2,1,4,0.0);
Standard_Real B1prim0,Bprelastprim1,
lambda=(mySurface->Weight(1,1)/mySurface->Weight(mySurface->NbUPoles(),1));
Standard_Integer index,i;
BSplCLib::EvalBsplineBasis(1,
1,
4,
myKnotFlatVector,
0.0,
index,
BSplineBasisDeriv);
B1prim0=BSplineBasisDeriv(2,2);
BSplCLib::EvalBsplineBasis(1,
1,
4,
myKnotFlatVector,
1.0,
index,
BSplineBasisDeriv);
Bprelastprim1=BSplineBasisDeriv(2,3);
math_Matrix BSplineBasisValue(1,1,1,4,0.0);
BSplCLib::EvalBsplineBasis(1,
0,
4,
myKnotFlatVector,
UParameter,
index,
BSplineBasisValue);
TColStd_Array1OfReal value(0,5);
TColStd_Array1OfReal Polesenv(0,5); //poles of a(u,v)
for (i=0;i<=5;i++)
Polesenv(i)=0.0;
Polesenv(0)=Duminv;
Polesenv(1)=Duminv-dDduuminv/B1prim0;
Polesenv(4)=lambda*lambda*(Dumaxv-dDduumaxv/Bprelastprim1);
Polesenv(5)=lambda*lambda*Dumaxv;
if (myKnotFlatVector.Length()==8){
value(0)=BSplineBasisValue(1,1); //values of the basic functions
value(1)=BSplineBasisValue(1,2);
value(2)=0.0;
value(3)=0.0;
value(4)=BSplineBasisValue(1,3);
value(5)=BSplineBasisValue(1,4);
}
if (myKnotFlatVector.Length()==9){
if (index==1){
value(0)=BSplineBasisValue(1,1);
value(1)=BSplineBasisValue(1,2);
value(2)=BSplineBasisValue(1,3);
value(3)=0.0;
value(4)=BSplineBasisValue(1,4);
value(5)=0.0;
}
else{
value(0)=0.0;
value(1)=BSplineBasisValue(1,1);
value(2)=BSplineBasisValue(1,2);
value(3)=0.0;
value(4)=BSplineBasisValue(1,3);
value(5)=BSplineBasisValue(1,4);
}
Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
}
if (myKnotFlatVector.Length()==10){
if (index==1){
value(0)=BSplineBasisValue(1,1);
value(1)=BSplineBasisValue(1,2);
value(2)=BSplineBasisValue(1,3);
value(3)=BSplineBasisValue(1,4);
value(4)=0.0;
value(5)=0.0;
}
if (index==2){
value(0)=0.0;
value(1)=BSplineBasisValue(1,1);
value(2)=BSplineBasisValue(1,2);
value(3)=BSplineBasisValue(1,3);
value(4)=BSplineBasisValue(1,4);
value(5)=0.0;
}
if (index==3){
value(0)=0.0;
value(1)=0.0;
value(2)=BSplineBasisValue(1,1);
value(3)=BSplineBasisValue(1,2);
value(4)=BSplineBasisValue(1,3);
value(5)=BSplineBasisValue(1,4);
}
Polesenv(2)=(0.5*(Polesenv(0)+Polesenv(5)));
Polesenv(3)=Polesenv(2);
}
for (i=0;i<=5;i++)
Buv+=Polesenv(i)*value(i);
return Buv;
}

View File

@@ -0,0 +1,72 @@
-- File: GeomLib_Interpolate.cdl
-- Created: Fri Aug 30 11:57:12 1996
-- Author: Xavier BENVENISTE
-- <xab@zozox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class Interpolate from GeomLib
---Purpose: this class is used to construct a BSpline curve by
-- interpolation of points at given parameters The
-- continuity of the curve is degree - 1 and the
-- method used when boundary condition are not given
-- is to use odd degrees and null the derivatives on
-- both sides from degree -1 down to (degree+1) / 2
-- When even degree is given the returned curve is of
-- degree - 1 so that the degree of the curve is odd
uses
Array1OfPnt from TColgp,
Array1OfReal from TColStd,
InterpolationErrors from GeomLib,
BSplineCurve from Geom
raises
NotDone from StdFail,
OutOfRange from Standard
is
Create( Degree : Integer from Standard ;
NumPoints : Integer from Standard ;
Points : Array1OfPnt from TColgp ;
Parameters : Array1OfReal from TColStd)
returns Interpolate from GeomLib ;
IsDone(me) returns Boolean from Standard
---Purpose:
-- returns if everything went OK
---C++: inline
is static;
Error(me) returns InterpolationErrors from GeomLib
---Purpose: returns the error type if any
---C++: inline
--
is static ;
Curve(me)
---Purpose: returns the interpolated curve of the requested degree
returns BSplineCurve from Geom
raises
OutOfRange from Standard,
NotDone from StdFail
is static;
fields
myCurve : BSplineCurve from Geom ;
myIsDone : Boolean from Standard ;
myError : InterpolationErrors from GeomLib ;
end Interpolate ;

View File

@@ -0,0 +1,136 @@
// File: GeomLib_Interpolate.cxx
// Created: Fri Aug 30 18:03:15 1996
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
#include <GeomLib_Interpolate.ixx>
#include <Standard_ConstructionError.hxx>
#include <PLib.hxx>
#include <BSplCLib.hxx>
#include <gp_Vec.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_Array1OfBoolean.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <Handle_TColStd_HArray1OfBoolean.hxx>
//=======================================================================
//function : GeomLib_Interpolate
//purpose :
//=======================================================================
GeomLib_Interpolate::GeomLib_Interpolate
(const Standard_Integer Degree,
const Standard_Integer NumPoints,
const TColgp_Array1OfPnt& PointsArray,
const TColStd_Array1OfReal& ParametersArray)
{
Standard_Integer ii,
num_knots,
inversion_problem,
num_controls,
jj ;
if (NumPoints < Degree ||
PointsArray.Lower() != 1 ||
PointsArray.Upper() < NumPoints ||
ParametersArray.Lower() != 1 ||
ParametersArray.Upper() < NumPoints) {
myError = GeomLib_NotEnoughtPoints ;
}
else if (Degree < 3) {
myError = GeomLib_DegreeSmallerThan3 ;
}
else {
gp_Pnt null_point(0.0e0, 0.0e0, 0.0e0) ;
Standard_Integer order = Degree + 1,
half_order ;
if (order % 2) {
order -= 1 ;
}
half_order = order / 2 ;
num_knots = NumPoints + 2 * order - 2 ;
num_controls = num_knots - order ;
TColStd_Array1OfReal flat_knots(1,num_knots) ;
TColStd_Array1OfInteger contacts (1,num_controls) ;
TColStd_Array1OfInteger multiplicities(1, NumPoints) ;
TColStd_Array1OfReal parameters(1,num_controls) ;
TColgp_Array1OfPnt poles(1,num_controls) ;
for (ii = 1 ; ii <= NumPoints ; ii++) {
multiplicities(ii) = 1 ;
}
multiplicities(1) = order ;
multiplicities(NumPoints) = order ;
for (ii = 1,
jj = num_controls + 1 ; ii <= order ; ii++, jj++) {
flat_knots(ii) = ParametersArray(1) ;
flat_knots(jj) = ParametersArray(NumPoints) ;
}
jj = order + 1 ;
for (ii = 2 ; ii < NumPoints ; ii++) {
flat_knots(jj) = ParametersArray(ii) ;
jj+= 1 ;
}
for (ii = 1 ; ii <= num_controls ; ii++) {
contacts(ii) = 0 ;
}
jj = num_controls ;
for (ii = 1 ; ii <= half_order ; ii++) {
contacts(ii) = half_order + ii - 1 ;
parameters(ii) = ParametersArray(1) ;
poles(ii) = null_point ;
contacts(jj) = half_order + ii - 1 ;
parameters(jj) = ParametersArray(NumPoints) ;
poles(jj) = null_point ;
jj -= 1 ;
}
jj = half_order + 1 ;
for (ii = 2 ; ii < NumPoints ; ii++) {
parameters(jj) = ParametersArray(ii) ;
poles(jj) = PointsArray(ii) ;
jj += 1 ;
}
contacts(1) = 0 ;
contacts(num_controls) = 0 ;
poles(1) = PointsArray(1) ;
poles(num_controls) = PointsArray(NumPoints) ;
BSplCLib::Interpolate(order-1,
flat_knots,
parameters,
contacts,
poles,
inversion_problem) ;
if (!inversion_problem) {
myCurve =
new Geom_BSplineCurve(poles,
ParametersArray,
multiplicities,
order-1) ;
myIsDone = Standard_True ;
}
else {
myError = GeomLib_InversionProblem ;
}
}
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
Handle(Geom_BSplineCurve) GeomLib_Interpolate::Curve() const
{
return myCurve ;
}

View File

@@ -0,0 +1,18 @@
// File: GeomLib_Interpolate.lxx
// Created: Mon Sep 2 17:45:44 1996
// Author: Xavier BENVENISTE
// <xab@zozox.paris1.matra-dtv.fr>
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean GeomLib_Interpolate::IsDone() const
{ return myIsDone ; } ;
//=======================================================================
//function : Error
//purpose :
//=======================================================================
inline GeomLib_InterpolationErrors GeomLib_Interpolate::Error() const
{ return myError ; }

View File

@@ -0,0 +1,37 @@
-- File: GeomLib_IsPlanarSurface.cdl
-- Created: Mon Nov 23 11:01:50 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
class IsPlanarSurface from GeomLib
---Purpose: Find if a surface is a planar surface.
uses
Surface from Geom,
Pln from gp
raises
NotDone from StdFail
is
Create(S : Surface; Tol : Real = 1.0e-7)
returns IsPlanarSurface from GeomLib;
IsPlanar(me)
---Purpose: Return if the Surface is a plan
returns Boolean;
Plan(me)
---Purpose: Return the plan definition
---C++: return const &
returns Pln from gp
raises NotDone; -- if <me> is not Planar
fields
myPlan : Pln from gp;
IsPlan : Boolean;
end IsPlanarSurface;

View File

@@ -0,0 +1,314 @@
// File: GeomLib_IsPlanarSurface.cxx
// Created: Mon Nov 23 11:12:10 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <GeomLib_IsPlanarSurface.ixx>
#include <GeomLib.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <Geom_Curve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
static Standard_Boolean Controle(const TColgp_Array1OfPnt& P,
const gp_Pln& Plan,
const Standard_Real Tol)
{
Standard_Integer ii;
Standard_Boolean B=Standard_True;
for (ii=1; ii<=P.Length() && B; ii++)
B = (Plan.Distance(P(ii)) < Tol);
return B;
}
static Standard_Boolean Controle(const TColgp_Array1OfPnt& Poles,
const Standard_Real Tol,
const Handle(Geom_Surface)& S,
gp_Pln& Plan)
{
Standard_Boolean IsPlan = Standard_False;
Standard_Boolean Essai = Standard_True;
Standard_Real gx,gy,gz;
Standard_Integer Nb = Poles.Length();
gp_Pnt Bary;
gp_Dir DX, DY;
if (Nb > 10) {
// Test allege (pour une rejection rapide)
TColgp_Array1OfPnt Aux(1,5);
Aux(1) = Poles(1);
Aux(2) = Poles(Nb/3);
Aux(3) = Poles(Nb/2);
Aux(4) = Poles(Nb/2+Nb/3);
Aux(5) = Poles(Nb);
GeomLib::Inertia(Aux, Bary, DX, DY, gx, gy, gz);
Essai = (gz<Tol);
}
if (Essai) { // Test Grandeur nature...
GeomLib::Inertia(Poles, Bary, DX, DY, gx, gy, gz);
if (gz<Tol && gy>Tol) {
gp_Pnt P;
gp_Vec DU, DV;
Standard_Real umin, umax, vmin, vmax;
S->Bounds(umin, umax, vmin, vmax);
S->D1( (umin+umax)/2, (vmin+vmax)/2, P, DU, DV);
// On prend DX le plus proche possible de DU
gp_Dir du(DU);
Standard_Real Angle1 = du.Angle(DX);
Standard_Real Angle2 = du.Angle(DY);
if (Angle1 > PI/2) Angle1 = PI-Angle1;
if (Angle2 > PI/2) Angle2 = PI-Angle2;
if (Angle2 < Angle1) {
du = DY; DY = DX; DX = du;
}
if (DX.Angle(DU) > PI/2) DX.Reverse();
if (DY.Angle(DV) > PI/2) DY.Reverse();
gp_Ax3 axe(Bary, DX^DY, DX);
Plan.SetPosition(axe);
Plan.SetLocation(Bary);
IsPlan = Standard_True;
}
}
return IsPlan;
}
static Standard_Boolean Controle(const Handle(Geom_Curve)& C,
const gp_Pln& Plan,
const Standard_Real Tol)
{
Standard_Boolean B = Standard_True;
Standard_Integer ii, Nb;
GeomAbs_CurveType Type;
GeomAdaptor_Curve AC(C);
Type = AC.GetType();
Handle(TColgp_HArray1OfPnt) TabP;
TabP.Nullify();
switch (Type) {
case GeomAbs_Line :
{
Nb = 2;
break;
}
case GeomAbs_Circle:
{
Nb = 3;
break;
}
case GeomAbs_Ellipse:
case GeomAbs_Hyperbola:
case GeomAbs_Parabola:
{
Nb = 5;
break;
}
case GeomAbs_BezierCurve:
{
Nb = AC.NbPoles();
Handle (Geom_BezierCurve) BZ = AC.Bezier();
TabP = new (TColgp_HArray1OfPnt) (1, AC.NbPoles());
for (ii=1; ii<=Nb; ii++)
TabP->SetValue(ii, BZ->Pole(ii));
break;
}
case GeomAbs_BSplineCurve:
{
Nb = AC.NbPoles();
Handle (Geom_BSplineCurve) BZ = AC.BSpline();
TabP = new (TColgp_HArray1OfPnt) (1, AC.NbPoles());
for (ii=1; ii<=Nb; ii++)
TabP->SetValue(ii, BZ->Pole(ii));
break;
}
default :
{
Nb = 8 + 3*AC.NbIntervals(GeomAbs_CN);
}
}
if (TabP.IsNull()) {
Standard_Real u, du, f, l, d;
f = AC.FirstParameter();
l = AC.LastParameter();
du = (l-f)/(Nb-1);
for (ii=1; ii<=Nb && B ; ii++) {
u = (ii-1)*du + f;
d = Plan.Distance(C->Value(u));
B = (d < Tol);
}
}
else {
B = Controle(TabP->Array1(), Plan, Tol);
}
return B;
}
GeomLib_IsPlanarSurface::GeomLib_IsPlanarSurface(const Handle(Geom_Surface)& S,
const Standard_Real Tol)
{
GeomAdaptor_Surface AS(S);
GeomAbs_SurfaceType Type;
Type = AS.GetType();
switch (Type) {
case GeomAbs_Plane :
{
IsPlan = Standard_True;
myPlan = AS.Plane();
break;
}
case GeomAbs_Cylinder :
case GeomAbs_Cone :
case GeomAbs_Sphere :
case GeomAbs_Torus :
{
IsPlan = Standard_False;
break;
}
case GeomAbs_BezierSurface :
case GeomAbs_BSplineSurface :
{
Standard_Integer ii, jj, kk,
NbU = AS.NbUPoles(), NbV = AS.NbVPoles();
TColgp_Array1OfPnt Poles(1, NbU*NbV);
if (Type == GeomAbs_BezierSurface) {
Handle(Geom_BezierSurface) BZ;
BZ = AS.Bezier();
for(ii=1, kk=1; ii<=NbU; ii++)
for(jj=1; jj<=NbV; jj++,kk++)
Poles(kk) = BZ->Pole(ii,jj);
}
else {
Handle(Geom_BSplineSurface) BS;
BS = AS.BSpline();
for(ii=1, kk=1; ii<=NbU; ii++)
for(jj=1; jj<=NbV; jj++,kk++)
Poles(kk) = BS->Pole(ii,jj);
}
IsPlan = Controle(Poles, Tol, S, myPlan);
break;
}
case GeomAbs_SurfaceOfRevolution :
{
Standard_Boolean Essai = Standard_True;
gp_Pnt P;
gp_Vec DU, DV, Dn;
gp_Dir Dir = AS.AxeOfRevolution().Direction();
Standard_Real Umin, Umax, Vmin, Vmax;
S->Bounds(Umin, Umax, Vmin, Vmax);
S->D1((Umin+Umax)/2, (Vmin+Vmax)/2, P, DU, DV);
Dn = DU^DV;
if (Dn.Magnitude() > 1.e-7) {
Standard_Real angle = Dir.Angle(Dn);
if (angle > PI/2) {
angle = PI - angle;
Dir.Reverse();
}
Essai = (angle < 0.1);
}
if (Essai) {
gp_Ax3 axe(P, Dir);
axe.SetXDirection(DU);
myPlan.SetPosition(axe);
myPlan.SetLocation(P);
Handle(Geom_Curve) C;
C = S->UIso(Umin);
IsPlan = Controle(C, myPlan, Tol);
}
else
IsPlan = Standard_False;
break;
}
case GeomAbs_SurfaceOfExtrusion :
{
Standard_Boolean Essai = Standard_False;
Standard_Real Umin, Umax, Vmin, Vmax;
Standard_Real norm;
gp_Vec Du, Dv, Dn;
gp_Pnt P;
S->Bounds(Umin, Umax, Vmin, Vmax);
S->D1((Umin+Umax)/2, (Vmin+Vmax)/2, P, Du, Dv);
Dn = Du^Dv;
norm = Dn.Magnitude();
if (norm > 1.e-15) {
Dn /= norm;
Standard_Real angmax = Tol / (Vmax-Vmin);
gp_Dir D(Dn);
Essai = (D.IsNormal(AS.Direction(), angmax));
}
if (Essai) {
gp_Ax3 axe(P, Dn, Du);
myPlan.SetPosition(axe);
myPlan.SetLocation(P);
Handle(Geom_Curve) C;
C = S->VIso((Vmin+Vmax)/2);
IsPlan = Controle(C, myPlan, Tol);
}
else
IsPlan = Standard_False;
break;
}
default :
{
Standard_Integer NbU,NbV, ii, jj, kk;
NbU = 8 + 3*AS.NbUIntervals(GeomAbs_CN);
NbV = 8 + 3*AS.NbVIntervals(GeomAbs_CN);
Standard_Real Umin, Umax, Vmin, Vmax, du, dv, U, V;
S->Bounds(Umin, Umax, Vmin, Vmax);
du = (Umax-Umin)/(NbU-1);
dv = (Vmax-Vmin)/(NbV-1);
TColgp_Array1OfPnt Pnts(1, NbU*NbV);
for(ii=0, kk=1; ii<NbU; ii++) {
U = Umin + du*ii;
for(jj=0; jj<NbV; jj++,kk++) {
V = Vmin + dv*jj;
S->D0(U,V, Pnts(kk));
}
}
IsPlan = Controle(Pnts, Tol, S, myPlan);
}
}
}
Standard_Boolean GeomLib_IsPlanarSurface::IsPlanar() const
{
return IsPlan;
}
const gp_Pln& GeomLib_IsPlanarSurface::Plan() const
{
if (!IsPlan) StdFail_NotDone::Raise(" GeomLib_IsPlanarSurface");
return myPlan;
}

View File

@@ -0,0 +1,32 @@
-- File: GeomLib_LogSample.cdl
-- Created: Wed Sep 23 16:50:25 1998
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
private class LogSample from GeomLib inherits FunctionSample from math
---Purpose:
raises
OutOfRange from Standard
is
Create(A,B: Real; N: Integer)
returns LogSample from GeomLib;
GetParameter(me; Index: Integer)
---Purpose: Returns the value of parameter of the point of
-- range Index : A + ((Index-1)/(NbPoints-1))*B.
-- An exception is raised if Index<=0 or Index>NbPoints.
returns Real
raises OutOfRange
is redefined;
fields
myF : Real;
myexp : Real;
end LogSample;

View File

@@ -0,0 +1,36 @@
// File: GeomLib_LogSample.cxx
// Created: Wed Sep 23 16:56:07 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <GeomLib_LogSample.ixx>
#include <Standard_OutOfRange.hxx>
GeomLib_LogSample::GeomLib_LogSample(const Standard_Real A,
const Standard_Real B,
const Standard_Integer N)
:math_FunctionSample(A, B, N)
{
myF = A - 1;
myexp = Log(B-A)/N;
}
Standard_Real GeomLib_LogSample::GetParameter(const Standard_Integer Index) const
{
Standard_Integer n = NbPoints();
if ((Index >= n) || (Index <= 1)) {
Standard_Real a, b;
Bounds(a, b);
if (Index == 1) return a;
else if (Index == n) return b;
else Standard_OutOfRange::Raise("GeomLib_LogSample::GetParameter");
}
Standard_Real v = myF + Exp(myexp*Index);
return v;
}

View File

@@ -0,0 +1,117 @@
-- File: GeomLib_MakeCurvefromApprox.cdl
-- Created: Tue Jun 13 10:15:20 1995
-- Author: Bruno DUMORTIER
-- <dub@fuegox>
---Copyright: Matra Datavision 1995
class MakeCurvefromApprox from GeomLib
---Purpose: this class is used to construct the BSpline curve
-- from an Approximation ( ApproxAFunction from AdvApprox).
uses
ApproxAFunction from AdvApprox,
BSplineCurve from Geom,
BSplineCurve from Geom2d
raises
NotDone from StdFail,
OutOfRange from Standard
is
Create( Approx : ApproxAFunction from AdvApprox)
returns MakeCurvefromApprox from GeomLib;
IsDone(me) returns Boolean from Standard
---C++: inline
is static;
Nb1DSpaces(me) returns Integer from Standard
---Purpose: returns the number of 1D spaces of the Approx
is static;
Nb2DSpaces(me) returns Integer from Standard
---Purpose: returns the number of 3D spaces of the Approx
is static;
Nb3DSpaces(me) returns Integer from Standard
---Purpose: returns the number of 3D spaces of the Approx
is static;
Curve2d(me; Index2d : Integer from Standard)
---Purpose: returns a polynomial curve whose poles correspond to
-- the Index2d 2D space
returns BSplineCurve from Geom2d
raises
OutOfRange from Standard,
---Purpose: if Index2d not in the Range [1,Nb2dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
Curve2dFromTwo1d(me; Index1d : Integer from Standard;
Index2d : Integer from Standard)
---Purpose: returns a 2D curve building it from the 1D curve
-- in x at Index1d and y at Index2d amongst the
-- 1D curves
returns BSplineCurve from Geom2d
raises
OutOfRange from Standard,
---Purpose: if Index1d not in the Range [1,Nb1dSpaces]
-- if Index2d not in the Range [1,Nb1dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
Curve2d(me; Index1d : Integer from Standard;
Index2d : Integer from Standard)
---Purpose: returns a rational curve whose poles correspond to
-- the index2d of the 2D space and whose weights correspond
-- to one dimensional space of index 1d
returns BSplineCurve from Geom2d
raises
OutOfRange from Standard,
---Purpose: if Index1d not in the Range [1,Nb1dSpaces]
-- if Index2d not in the Range [1,Nb2dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
Curve(me; Index3d : Integer from Standard)
---Purpose: returns a polynomial curve whose poles correspond to
-- the Index3D 3D space
returns BSplineCurve from Geom
raises
OutOfRange from Standard,
---Purpose: if Index3D not in the Range [1,Nb3dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
Curve (me; Index1D : Integer from Standard;
Index3D : Integer from Standard)
---Purpose: returns a rational curve whose poles correspond to
-- the index3D of the 3D space and whose weights correspond
-- to the index1d 1D space.
returns BSplineCurve from Geom
raises
OutOfRange from Standard,
---Purpose: if Index1D not in the Range [1,Nb1dSpaces]
-- if Index3D not in the Range [1,Nb3dSpaces]
NotDone from StdFail
---Purpose: if the Approx is not Done
is static;
fields
myApprox : ApproxAFunction from AdvApprox;
end MakeCurvefromApprox;

View File

@@ -0,0 +1,240 @@
// File: GeomLib_MakeCurvefromApprox.cxx
// Created: Tue Jun 13 11:09:09 1995
// Author: Bruno DUMORTIER
// <dub@fuegox>
#include <GeomLib_MakeCurvefromApprox.ixx>
#include <gp_Pnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
//=======================================================================
//function : GeomLib_MakeCurvefromApprox
//purpose :
//=======================================================================
GeomLib_MakeCurvefromApprox::GeomLib_MakeCurvefromApprox
(const AdvApprox_ApproxAFunction& Approx)
:myApprox(Approx)
{
}
//=======================================================================
//function : Nb1DSpaces
//purpose :
//=======================================================================
Standard_Integer GeomLib_MakeCurvefromApprox::Nb1DSpaces() const
{
return myApprox.NumSubSpaces(1);
}
//=======================================================================
//function : Nb2DSpaces
//purpose :
//=======================================================================
Standard_Integer GeomLib_MakeCurvefromApprox::Nb2DSpaces() const
{
return myApprox.NumSubSpaces(2);
}
//=======================================================================
//function : Nb3DSpaces
//purpose :
//=======================================================================
Standard_Integer GeomLib_MakeCurvefromApprox::Nb3DSpaces() const
{
return myApprox.NumSubSpaces(3);
}
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) GeomLib_MakeCurvefromApprox::Curve2d
(const Standard_Integer Index2d) const
{
Standard_OutOfRange_Raise_if
( Index2d < 0 || Index2d > Nb2DSpaces(),
" GeomLib_MakeCurvefromApprox : Curve2d");
StdFail_NotDone_Raise_if
( !IsDone(),
" GeomLib_MakeCurvefromApprox : Curve2d");
TColgp_Array1OfPnt2d Poles( 1, myApprox.NbPoles());
TColStd_Array1OfReal Knots( 1, myApprox.NbKnots());
TColStd_Array1OfInteger Mults( 1, myApprox.NbKnots());
myApprox.Poles2d(Index2d, Poles);
Knots = myApprox.Knots()->Array1();
Mults = myApprox.Multiplicities()->Array1();
Handle(Geom2d_BSplineCurve) C =
new Geom2d_BSplineCurve( Poles, Knots, Mults, myApprox.Degree());
return C;
}
//=======================================================================
//function : Curve2d
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) GeomLib_MakeCurvefromApprox::Curve2d
(const Standard_Integer Index1d,
const Standard_Integer Index2d) const
{
Standard_OutOfRange_Raise_if
( Index1d < 0 || Index1d > Nb1DSpaces() ||
Index2d < 0 || Index2d > Nb2DSpaces(),
" GeomLib_MakeCurvefromApprox : Curve2d");
StdFail_NotDone_Raise_if
( !IsDone() && ! myApprox.HasResult(),
" GeomLib_MakeCurvefromApprox : Curve2d");
TColgp_Array1OfPnt2d Poles ( 1, myApprox.NbPoles());
TColStd_Array1OfReal Weigths( 1, myApprox.NbPoles());
TColStd_Array1OfReal Knots ( 1, myApprox.NbKnots());
TColStd_Array1OfInteger Mults ( 1, myApprox.NbKnots());
myApprox.Poles2d(Index2d, Poles);
myApprox.Poles1d(Index1d, Weigths);
Knots = myApprox.Knots()->Array1();
Mults = myApprox.Multiplicities()->Array1();
Standard_Real X,Y,W;
for ( Standard_Integer i = 1; i <= myApprox.NbPoles(); i++) {
W = Weigths(i);
Poles(i).Coord(X,Y);
Poles(i).SetCoord(X/W, Y/W);
}
Handle(Geom2d_BSplineCurve) C =
new Geom2d_BSplineCurve( Poles, Knots, Mults, myApprox.Degree());
return C;
}
//=======================================================================
//function : Curve2dFromTwo1d
//purpose :
//=======================================================================
Handle(Geom2d_BSplineCurve) GeomLib_MakeCurvefromApprox::Curve2dFromTwo1d
(const Standard_Integer Index1d,
const Standard_Integer Index2d) const
{
Standard_OutOfRange_Raise_if
( Index1d < 0 || Index1d > Nb1DSpaces() ||
Index2d < 0 || Index2d > Nb1DSpaces(),
" GeomLib_MakeCurvefromApprox : Curve2d");
StdFail_NotDone_Raise_if
( !IsDone() && ! myApprox.HasResult(),
" GeomLib_MakeCurvefromApprox : Curve2d");
TColgp_Array1OfPnt2d Poles ( 1, myApprox.NbPoles());
TColStd_Array1OfReal Poles1d1( 1, myApprox.NbPoles());
TColStd_Array1OfReal Poles1d2( 1, myApprox.NbPoles());
TColStd_Array1OfReal Knots ( 1, myApprox.NbKnots());
TColStd_Array1OfInteger Mults ( 1, myApprox.NbKnots());
myApprox.Poles1d(Index2d, Poles1d2);
myApprox.Poles1d(Index1d, Poles1d1);
Knots = myApprox.Knots()->Array1();
Mults = myApprox.Multiplicities()->Array1();
// Standard_Real X,Y,W;
for ( Standard_Integer i = 1; i <= myApprox.NbPoles(); i++) {
Poles(i).SetCoord(Poles1d1.Value(i),Poles1d2.Value(i));
}
Handle(Geom2d_BSplineCurve) C =
new Geom2d_BSplineCurve( Poles, Knots, Mults, myApprox.Degree());
return C;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
Handle(Geom_BSplineCurve) GeomLib_MakeCurvefromApprox::Curve
(const Standard_Integer Index3d) const
{
Standard_OutOfRange_Raise_if
( Index3d < 0 || Index3d > Nb3DSpaces(),
" GeomLib_MakeCurvefromApprox : Curve");
StdFail_NotDone_Raise_if
( !IsDone() && ! myApprox.HasResult(),
" GeomLib_MakeCurvefromApprox : Curve");
TColgp_Array1OfPnt Poles( 1, myApprox.NbPoles());
TColStd_Array1OfReal Knots( 1, myApprox.NbKnots());
TColStd_Array1OfInteger Mults( 1, myApprox.NbKnots());
myApprox.Poles(Index3d, Poles);
Knots = myApprox.Knots()->Array1();
Mults = myApprox.Multiplicities()->Array1();
Handle(Geom_BSplineCurve) C =
new Geom_BSplineCurve( Poles, Knots, Mults, myApprox.Degree());
return C;
}
//=======================================================================
//function : Curve
//purpose :
//=======================================================================
Handle(Geom_BSplineCurve) GeomLib_MakeCurvefromApprox::Curve
(const Standard_Integer Index1d,
const Standard_Integer Index3d) const
{
Standard_OutOfRange_Raise_if
( Index1d < 0 || Index1d > Nb1DSpaces() ||
Index3d < 0 || Index3d > Nb3DSpaces(),
" GeomLib_MakeCurvefromApprox : Curve3d");
StdFail_NotDone_Raise_if
( !IsDone(),
" GeomLib_MakeCurvefromApprox : Curve3d");
TColgp_Array1OfPnt Poles ( 1, myApprox.NbPoles());
TColStd_Array1OfReal Weigths( 1, myApprox.NbPoles());
TColStd_Array1OfReal Knots ( 1, myApprox.NbKnots());
TColStd_Array1OfInteger Mults ( 1, myApprox.NbKnots());
myApprox.Poles (Index3d, Poles);
myApprox.Poles1d(Index1d, Weigths);
Knots = myApprox.Knots()->Array1();
Mults = myApprox.Multiplicities()->Array1();
Standard_Real X,Y,Z,W;
for ( Standard_Integer i = 1; i <= myApprox.NbPoles(); i++) {
W = Weigths(i);
Poles(i).Coord(X,Y,Z);
Poles(i).SetCoord(X/W, Y/W, Z/W);
}
Handle(Geom_BSplineCurve) C =
new Geom_BSplineCurve( Poles, Knots, Mults, myApprox.Degree());
return C;
}

View File

@@ -0,0 +1,18 @@
// File: GeomLib_MakeCurvefromApprox.lxx
// Created: Tue Jun 13 11:11:23 1995
// Author: Bruno DUMORTIER
// <dub@fuegox>
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean GeomLib_MakeCurvefromApprox::IsDone() const
{
return myApprox.IsDone();
}

View File

@@ -0,0 +1,48 @@
-- File: GeomLib_PolyFunc.cdl
-- Created: Tue Sep 22 16:24:52 1998
-- Author: Philippe MANGINGeomLib_PolyFunc.c
-- <pmn@sgi29>
---Copyright: Matra Datavision 1998
private class PolyFunc from GeomLib inherits FunctionWithDerivative from math
---Purpose: Polynomial Function
uses
Vector from math
is
Create(Coeffs:Vector) returns PolyFunc from GeomLib;
Value(me: in out; X: Real; F: out Real)
---Purpose: computes the value <F>of the function for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is redefined;
Derivative(me: in out; X: Real; D: out Real)
---Purpose: computes the derivative <D> of the function
-- for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is redefined;
Values(me: in out; X: Real; F, D: out Real)
---Purpose: computes the value <F> and the derivative <D> of the
-- function for the variable <X>.
-- Returns True if the calculation were successfully done,
-- False otherwise.
returns Boolean
is redefined;
fields
myCoeffs : Vector;
end PolyFunc;

View File

@@ -0,0 +1,49 @@
// File: GeomLib_PolyFunc.cxx
// Created: Tue Sep 22 16:37:48 1998
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <GeomLib_PolyFunc.ixx>
#include <PLib.hxx>
#include <math_Vector.hxx>
GeomLib_PolyFunc::GeomLib_PolyFunc(const math_Vector& Coeffs)
:myCoeffs(1, Coeffs.Length()-1)
{ // On construit le polynome derive
for (Standard_Integer ii=1; ii<=myCoeffs.Length(); ii++)
myCoeffs(ii) = ii*Coeffs(ii+1);
}
Standard_Boolean GeomLib_PolyFunc::Value(const Standard_Real X,
Standard_Real& F)
{
Standard_Real * coeff = &myCoeffs(1);
Standard_Real * ff = &F;
PLib::EvalPolynomial(X, 0, myCoeffs.Length()-1, 1, coeff[0], ff[0]);
return Standard_True;
}
Standard_Boolean GeomLib_PolyFunc::Derivative(const Standard_Real X,
Standard_Real& D)
{
Standard_Real * coeff = &myCoeffs(1);
math_Vector Aux(1, 2);
Standard_Real * ff = &Aux(1);
PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1, coeff[0], ff[0]);
D = Aux(2);
return Standard_True;
}
Standard_Boolean GeomLib_PolyFunc::Values(const Standard_Real X,
Standard_Real& F,
Standard_Real& D)
{
Standard_Real * coeff = &myCoeffs(1);
math_Vector Aux(1, 2);
Standard_Real * ff = &Aux(1);
PLib::EvalPolynomial(X, 1, myCoeffs.Length()-1, 1, coeff[0], ff[0]);
F = Aux(1);
D = Aux(2);
return Standard_True;
}

54
src/GeomLib/GeomLib_Tool.cdl Executable file
View File

@@ -0,0 +1,54 @@
-- File: GeomLib_Tool.cdl
-- Created: Tue Mar 18 11:06:16 2003
-- Author: Oleg FEDYAEV
-- <ofv@merlox>
---Copyright: Open CASCADE 2003
class Tool from GeomLib
---Purpose: The methods of this class compute the parameter(s) of a given point on a
-- curve or a surface. The point must be located either
-- on the curve (surface) itself or relatively to the latter at
-- a distance less than the tolerance value.
-- Return FALSE if the point is beyond the tolerance
-- limit or if computation fails.
-- Max Tolerance value is currently limited to 1.e-4 for
-- geometrical curves and 1.e-3 for BSpline, Bezier and
-- other parametrical curves.
uses Surface from Geom,
Curve from Geom,
Curve from Geom2d,
Pnt from gp,
Pnt2d from gp,
Real from Standard,
Boolean from Standard
is
Parameter(myclass; Curve : in Curve from Geom;
Point : in Pnt from gp;
Tolerance : in Real from Standard;
U : out Real from Standard)
returns Boolean from Standard;
---Purpose:
-- Extracts the parameter of a 3D point lying on a 3D curve
-- or at a distance less than the tolerance value.
Parameters(myclass; Surface : in Surface from Geom;
Point : in Pnt from gp;
Tolerance : in Real from Standard;
U : out Real from Standard;
V : out Real from Standard)
returns Boolean from Standard;
---Purpose: Extracts the parameter of a 3D point lying on a surface
-- or at a distance less than the tolerance value.
Parameter(myclass; Curve : in Curve from Geom2d;
Point : in Pnt2d from gp;
Tolerance : in Real from Standard;
U : out Real from Standard)
returns Boolean from Standard;
---Purpose: Extracts the parameter of a 2D point lying on a 2D curve
-- or at a distance less than the tolerance value.
end Tool;

562
src/GeomLib/GeomLib_Tool.cxx Executable file
View File

@@ -0,0 +1,562 @@
// File: GeomLib_Tool.cxx
// Created: Tue Mar 18 11:06:16 2003
// Author: Oleg FEDYAEV
// <ofv@merlox>
// Copyright: Open CASCADE 2003
#include <GeomLib_Tool.ixx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Parabola.hxx>
#include <Geom_Hyperbola.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_OffsetCurve.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Geom_ConicalSurface.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_ToroidalSurface.hxx>
#include <Geom_BSplineSurface.hxx>
#include <Geom_BezierSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_OffsetSurface.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pln.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Cone.hxx>
#include <gp_Sphere.hxx>
#include <gp_Torus.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Parab.hxx>
#include <gp_Hypr.hxx>
#include <gp_Vec.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <ElSLib.hxx>
#include <ElCLib.hxx>
#include <Extrema_ExtPC.hxx>
#include <Extrema_ExtPS.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Circ2d.hxx>
#include <gp_Elips2d.hxx>
#include <gp_Parab2d.hxx>
#include <gp_Hypr2d.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <ElCLib.hxx>
#include <Extrema_ExtPC2d.hxx>
// The functions Parameter(s) are used to compute parameter(s) of point
// on curves and surfaces. The main rule is that tested point must lied
// on curves or surfaces otherwise the resulted parameter(s) may be wrong.
//
// To make search process more common the tolerance value is used to define
// the proximity of point to curve or surface. It is clear that this tolerance
// value can't be too high to be not in conflict with previous rule.
static const Standard_Real MAXTOLERANCEGEOM = 1.e-4;
static const Standard_Real MAXTOLERANCEPARM = 1.e-3;
static const Standard_Real UNKNOWNVALUE = 1.e+100;
static const Standard_Real PARTOLERANCE = 1.e-9;
//=======================================================================
//function : ProcessAnalyticalSurfaces
//purpose : Computes the coefficients of the implicit equation
// of the analytical surfaces in the absolute cartesian
// coordinate system and check given point
//=======================================================================
static Standard_Boolean ProcessAnalyticalSurfaces(const Handle(Geom_Surface)& Surface,
const gp_Pnt& Point,
Standard_Real& Delta)
{
Delta = UNKNOWNVALUE;
Handle(Standard_Type) KindOfSurface = Surface->DynamicType();
if( KindOfSurface == STANDARD_TYPE (Geom_Plane) )
{
Handle(Geom_Plane) aGP = Handle(Geom_Plane)::DownCast(Surface);
if( aGP.IsNull() ) return Standard_False;
gp_Pln aPlane = aGP->Pln();
Delta = aPlane.Distance(Point);
}
else if( KindOfSurface == STANDARD_TYPE (Geom_CylindricalSurface) )
{
Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(Surface);
if( aGC.IsNull() ) return Standard_False;
gp_Vec aVec(aGC->Cylinder().Location(),Point);
Standard_Real X = aVec.Dot(aGC->Cylinder().XAxis().Direction());
Standard_Real Y = aVec.Dot(aGC->Cylinder().YAxis().Direction());
Delta = X*X + Y*Y - aGC->Cylinder().Radius()*aGC->Cylinder().Radius();
}
else if( KindOfSurface == STANDARD_TYPE (Geom_ConicalSurface) )
{
Handle(Geom_ConicalSurface) aGC = Handle(Geom_ConicalSurface)::DownCast(Surface);
if( aGC.IsNull() ) return Standard_False;
gp_Vec aVec(aGC->Cone().Location(),Point);
Standard_Real X = aVec.Dot(aGC->Cone().XAxis().Direction());
Standard_Real Y = aVec.Dot(aGC->Cone().YAxis().Direction());
Standard_Real Z = aVec.Dot(aGC->Cone().Axis().Direction());
Standard_Real tZ = aGC->Cone().RefRadius() + Z * Tan(aGC->Cone().SemiAngle());
Delta = X*X + Y*Y - tZ*tZ;
}
else if( KindOfSurface == STANDARD_TYPE (Geom_SphericalSurface) )
{
Handle(Geom_SphericalSurface) aGS = Handle(Geom_SphericalSurface)::DownCast(Surface);
if( aGS.IsNull() ) return Standard_False;
gp_Vec aVec(aGS->Sphere().Location(),Point);
Standard_Real X = aVec.Dot(aGS->Sphere().XAxis().Direction());
Standard_Real Y = aVec.Dot(aGS->Sphere().YAxis().Direction());
gp_Dir Zdir = aGS->Sphere().XAxis().Direction().Crossed(aGS->Sphere().YAxis().Direction());
Standard_Real Z = aVec.Dot(Zdir);
Delta = X*X + Y*Y + Z*Z - aGS->Sphere().Radius() * aGS->Sphere().Radius();
}
else if( KindOfSurface == STANDARD_TYPE (Geom_ToroidalSurface) )
{
Handle(Geom_ToroidalSurface) aTS = Handle(Geom_ToroidalSurface)::DownCast(Surface);
if( aTS.IsNull() ) return Standard_False;
gp_Vec aVec(aTS->Torus().Location(),Point);
Standard_Real X = aVec.Dot(aTS->Torus().XAxis().Direction());
Standard_Real Y = aVec.Dot(aTS->Torus().YAxis().Direction());
Standard_Real Z = aVec.Dot(aTS->Torus().Axis().Direction());
Delta = X*X + Y*Y + Z*Z - 2.*aTS->Torus().MajorRadius()*Sqrt( X*X + Y*Y ) -
aTS->Torus().MinorRadius()*aTS->Torus().MinorRadius() +
aTS->Torus().MajorRadius()*aTS->Torus().MajorRadius();
}
else
{
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : ProcessAnalyticalCurves
//purpose : Computes the coefficients of the implicit equation
// of the analytical curves and check given point
//=======================================================================
static Standard_Boolean ProcessAnalyticalCurves(const Handle(Geom_Curve)& Curve,
const gp_Pnt& Point,
Standard_Real& Delta)
{
Delta = UNKNOWNVALUE;
Handle(Standard_Type) KindOfCurve = Curve->DynamicType();
if( KindOfCurve == STANDARD_TYPE (Geom_Line) )
{
Handle(Geom_Line) aGL = Handle(Geom_Line)::DownCast(Curve);
if( aGL.IsNull() ) return Standard_False;
gp_Lin aLin = aGL->Lin();
Delta = aLin.Distance(Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Circle) )
{
Handle(Geom_Circle) aGC = Handle(Geom_Circle)::DownCast(Curve);
if( aGC.IsNull() ) return Standard_False;
gp_Circ aCirc = aGC->Circ();
Delta = aCirc.Distance(Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Ellipse) )
{
Handle(Geom_Ellipse) aGE = Handle(Geom_Ellipse)::DownCast(Curve);
if( aGE.IsNull() ) return Standard_False;
gp_Elips anElips = aGE->Elips();
gp_Vec aVec(anElips.Location(),Point);
Standard_Real X = aVec.Dot(anElips.XAxis().Direction());
Standard_Real Y = aVec.Dot(anElips.YAxis().Direction());
Standard_Real Z = aVec.Dot(anElips.Axis().Direction());
Standard_Real AA = anElips.MajorRadius()*anElips.MajorRadius();
Standard_Real BB = anElips.MinorRadius()*anElips.MinorRadius();
Standard_Real tY = Sqrt( Abs( (1. - X*X/AA)*BB ) );
Delta = Max( Abs(Z), Abs( Y - tY ) );
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Parabola) )
{
Handle(Geom_Parabola) aGP = Handle(Geom_Parabola)::DownCast(Curve);
if( aGP.IsNull() ) return Standard_False;
gp_Parab aParab = aGP->Parab();
gp_Vec aVec(aParab.Location(),Point);
Standard_Real X = aVec.Dot(aParab.XAxis().Direction());
Standard_Real Y = aVec.Dot(aParab.YAxis().Direction());
Standard_Real Z = aVec.Dot(aParab.Axis().Direction());
Standard_Real tY = Sqrt( Abs(X*2.*aParab.Parameter()) );
Delta = Max( Abs(Z), Abs( Y - tY ) );
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Hyperbola) )
{
Handle(Geom_Hyperbola) aGH = Handle(Geom_Hyperbola)::DownCast(Curve);
if( aGH.IsNull() ) return Standard_False;
gp_Hypr aHypr = aGH->Hypr();
gp_Vec aVec(aHypr.Location(),Point);
Standard_Real X = aVec.Dot(aHypr.XAxis().Direction());
Standard_Real Y = aVec.Dot(aHypr.YAxis().Direction());
Standard_Real Z = aVec.Dot(aHypr.Axis().Direction());
Standard_Real AA = aHypr.MajorRadius()*aHypr.MajorRadius();
Standard_Real BB = aHypr.MinorRadius()*aHypr.MinorRadius();
Standard_Real tY1 = Sqrt( Abs( (X*X/AA - 1.)*BB ) );
Standard_Real tY2 = Sqrt( (X*X/AA + 1.)*BB );
Delta = Max( Abs(Z), Min( Abs( tY1 - Y ), Abs( tY2 - Y ) ) );
}
else return Standard_False;
return Standard_True;
}
//=======================================================================
//function : Parameter
//purpose : Get parameter on curve of given point
// return FALSE if point is far from curve than tolerance
// or computation fails
//=======================================================================
Standard_Boolean GeomLib_Tool::Parameter(const Handle(Geom_Curve)& Curve,
const gp_Pnt& Point,
const Standard_Real Tolerance,
Standard_Real& U)
{
U = 0.;
if( Curve.IsNull() ) return Standard_False;
Handle(Standard_Type) KindOfCurve = Curve->DynamicType();
// process analitical curves
if( KindOfCurve == STANDARD_TYPE (Geom_Line) ||
KindOfCurve == STANDARD_TYPE (Geom_Circle) ||
KindOfCurve == STANDARD_TYPE (Geom_Ellipse) ||
KindOfCurve == STANDARD_TYPE (Geom_Parabola) ||
KindOfCurve == STANDARD_TYPE (Geom_Hyperbola) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEGEOM) ? Tolerance : MAXTOLERANCEGEOM;
Standard_Real D = 0.;
Standard_Boolean isOk = ProcessAnalyticalCurves(Curve,Point,D);
if( !isOk ) return Standard_False;
if( Abs(D) > aTol ) return Standard_False;
if( KindOfCurve == STANDARD_TYPE (Geom_Line) )
{
Handle(Geom_Line) aGL = Handle(Geom_Line)::DownCast(Curve);
gp_Lin aLin = aGL->Lin();
U = ElCLib::Parameter(aLin,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Circle) )
{
Handle(Geom_Circle) aGC = Handle(Geom_Circle)::DownCast(Curve);
gp_Circ aCirc = aGC->Circ();
U = ElCLib::Parameter(aCirc,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Ellipse) )
{
Handle(Geom_Ellipse) aGE = Handle(Geom_Ellipse)::DownCast(Curve);
gp_Elips anElips = aGE->Elips();
U = ElCLib::Parameter(anElips,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Parabola) )
{
Handle(Geom_Parabola) aGP = Handle(Geom_Parabola)::DownCast(Curve);
gp_Parab aParab = aGP->Parab();
U = ElCLib::Parameter(aParab,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom_Hyperbola) )
{
Handle(Geom_Hyperbola) aGH = Handle(Geom_Hyperbola)::DownCast(Curve);
gp_Hypr aHypr = aGH->Hypr();
U = ElCLib::Parameter(aHypr,Point);
}
}
// process parametrical curves
else if( KindOfCurve == STANDARD_TYPE (Geom_BSplineCurve) ||
KindOfCurve == STANDARD_TYPE (Geom_BSplineCurve) ||
KindOfCurve == STANDARD_TYPE (Geom_TrimmedCurve) ||
KindOfCurve == STANDARD_TYPE (Geom_OffsetCurve) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEPARM) ? Tolerance : MAXTOLERANCEPARM;
GeomAdaptor_Curve aGAC(Curve);
Extrema_ExtPC extrema(Point,aGAC);
if( !extrema.IsDone() ) return Standard_False;
Standard_Integer n = extrema.NbExt();
if( n <= 0 ) return Standard_False;
Standard_Integer i = 0, iMin = 0;
Standard_Real Dist2Min = 1.e+100;
for( i = 1; i <= n; i++ )
{
if (extrema.SquareDistance(i) < Dist2Min)
{
iMin = i;
Dist2Min = extrema.SquareDistance(i);
}
}
if( iMin != 0 && Dist2Min <= aTol * aTol ) U = (extrema.Point(iMin)).Parameter();
}
else { return Standard_False; }
return Standard_True;
}
//=======================================================================
//function : Parameters
//purpose : Get parameters on surface of given point
// return FALSE if point is far from surface than tolerance
// or computation fails
//=======================================================================
Standard_Boolean GeomLib_Tool::Parameters(const Handle(Geom_Surface)& Surface,
const gp_Pnt& Point,
const Standard_Real Tolerance,
Standard_Real& U,
Standard_Real& V)
{
U = 0.;
V = 0.;
if( Surface.IsNull() ) return Standard_False;
Handle(Standard_Type) KindOfSurface = Surface->DynamicType();
// process analitical surfaces
if( KindOfSurface == STANDARD_TYPE (Geom_Plane) ||
KindOfSurface == STANDARD_TYPE (Geom_CylindricalSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_ConicalSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_SphericalSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_ToroidalSurface) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEGEOM) ? Tolerance : MAXTOLERANCEGEOM;
Standard_Real D = 0.;
Standard_Boolean isOk = ProcessAnalyticalSurfaces(Surface,Point,D);
if( !isOk ) return Standard_False;
if( Abs(D) > aTol ) return Standard_False;
if( KindOfSurface == STANDARD_TYPE (Geom_Plane) )
{
Handle(Geom_Plane) aGP = Handle(Geom_Plane)::DownCast(Surface);
gp_Pln aPlane = aGP->Pln();
ElSLib::Parameters (aPlane,Point,U,V);
}
else if( KindOfSurface == STANDARD_TYPE (Geom_CylindricalSurface) )
{
Handle(Geom_CylindricalSurface) aGC = Handle(Geom_CylindricalSurface)::DownCast(Surface);
gp_Cylinder aCylinder = aGC->Cylinder();
ElSLib::Parameters(aCylinder,Point,U,V);
}
else if( KindOfSurface == STANDARD_TYPE (Geom_ConicalSurface) )
{
Handle(Geom_ConicalSurface) aGC = Handle(Geom_ConicalSurface)::DownCast(Surface);
gp_Cone aCone = aGC->Cone();
ElSLib::Parameters(aCone,Point,U,V);
}
else if( KindOfSurface == STANDARD_TYPE (Geom_SphericalSurface) )
{
Handle(Geom_SphericalSurface) aGS = Handle(Geom_SphericalSurface)::DownCast(Surface);
gp_Sphere aSphere = aGS->Sphere();
ElSLib::Parameters(aSphere,Point,U,V);
}
else if( KindOfSurface == STANDARD_TYPE (Geom_ToroidalSurface) )
{
Handle(Geom_ToroidalSurface) aTS = Handle(Geom_ToroidalSurface)::DownCast(Surface);
gp_Torus aTorus = aTS->Torus();
ElSLib::Parameters(aTorus,Point,U,V);
}
else return Standard_False;
}
// process parametrical surfaces
else if( KindOfSurface == STANDARD_TYPE (Geom_BSplineSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_BezierSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_RectangularTrimmedSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_OffsetSurface) ||
KindOfSurface == STANDARD_TYPE (Geom_SurfaceOfLinearExtrusion) ||
KindOfSurface == STANDARD_TYPE (Geom_SurfaceOfRevolution) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEPARM) ? Tolerance : MAXTOLERANCEPARM;
GeomAdaptor_Surface aGAS(Surface);
Standard_Real aTolU = PARTOLERANCE, aTolV = PARTOLERANCE;
Extrema_ExtPS extrema(Point,aGAS,aTolU,aTolV);
if( !extrema.IsDone() ) return Standard_False;
Standard_Integer n = extrema.NbExt();
if( n <= 0 ) return Standard_False;
Standard_Real Dist2Min = 1.e+100;
Standard_Integer i = 0, iMin = 0;
for( i = 1; i <= n; i++ )
{
if( extrema.SquareDistance(i) < Dist2Min )
{
Dist2Min = extrema.SquareDistance(i);
iMin = i;
}
}
if( iMin != 0 && Dist2Min <= aTol * aTol ) extrema.Point(iMin).Parameter(U,V);
else return Standard_False;
}
else { return Standard_False; }
return Standard_True;
}
//=======================================================================
//function : ProcessAnalyticalCurves2d
//purpose : Computes the coefficients of the implicit equation
// of the analytical curves and check given point
//=======================================================================
static Standard_Boolean ProcessAnalyticalCurves2d(const Handle(Geom2d_Curve)& Curve,
const gp_Pnt2d& Point,
Standard_Real& Delta)
{
Delta = UNKNOWNVALUE;
Handle(Standard_Type) KindOfCurve = Curve->DynamicType();
if( KindOfCurve == STANDARD_TYPE (Geom2d_Line) )
{
Handle(Geom2d_Line) aGL = Handle(Geom2d_Line)::DownCast(Curve);
if( aGL.IsNull() ) return Standard_False;
gp_Lin2d aLin = aGL->Lin2d();
Delta = aLin.Distance(Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Circle) )
{
Handle(Geom2d_Circle) aGC = Handle(Geom2d_Circle)::DownCast(Curve);
if( aGC.IsNull() ) return Standard_False;
gp_Circ2d aCirc = aGC->Circ2d();
Delta = aCirc.Distance(Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Ellipse) )
{
Handle(Geom2d_Ellipse) aGE = Handle(Geom2d_Ellipse)::DownCast(Curve);
if( aGE.IsNull() ) return Standard_False;
gp_Elips2d anElips = aGE->Elips2d();
Standard_Real A=0., B=0., C=0., D=0., E=0., F=0.;
anElips.Coefficients(A,B,C,D,E,F);
Standard_Real X = Point.X(), Y = Point.Y();
Delta = A*X*X + B*Y*Y + 2.*C*X*Y + 2.*D*X + 2.*E*Y + F;
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Parabola) )
{
Handle(Geom2d_Parabola) aGP = Handle(Geom2d_Parabola)::DownCast(Curve);
if( aGP.IsNull() ) return Standard_False;
gp_Parab2d aParab = aGP->Parab2d();
Standard_Real A=0., B=0., C=0., D=0., E=0., F=0.;
aParab.Coefficients(A,B,C,D,E,F);
Standard_Real X = Point.X(), Y = Point.Y();
Delta = A*X*X + B*Y*Y + 2.*C*X*Y + 2.*D*X + 2.*E*Y + F;
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Hyperbola) )
{
Handle(Geom2d_Hyperbola) aGH = Handle(Geom2d_Hyperbola)::DownCast(Curve);
if( aGH.IsNull() ) return Standard_False;
gp_Hypr2d aHypr = aGH->Hypr2d();
Standard_Real A=0., B=0., C=0., D=0., E=0., F=0.;
aHypr.Coefficients(A,B,C,D,E,F);
Standard_Real X = Point.X(), Y = Point.Y();
Delta = A*X*X + B*Y*Y + 2.*C*X*Y + 2.*D*X + 2.*E*Y + F;
}
else return Standard_False;
return Standard_True;
}
//=======================================================================
//function : Parameter
//purpose : Get parameter on curve of given point
// return FALSE if point is far from curve than tolerance
// or computation fails
//=======================================================================
Standard_Boolean GeomLib_Tool::Parameter(const Handle(Geom2d_Curve)& Curve,
const gp_Pnt2d& Point,
const Standard_Real Tolerance,
Standard_Real& U)
{
U = 0.;
if( Curve.IsNull() ) return Standard_False;
Handle(Standard_Type) KindOfCurve = Curve->DynamicType();
// process analytical curves
if( KindOfCurve == STANDARD_TYPE (Geom2d_Line) ||
KindOfCurve == STANDARD_TYPE (Geom2d_Circle) ||
KindOfCurve == STANDARD_TYPE (Geom2d_Ellipse) ||
KindOfCurve == STANDARD_TYPE (Geom2d_Parabola) ||
KindOfCurve == STANDARD_TYPE (Geom2d_Hyperbola) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEGEOM) ? Tolerance : MAXTOLERANCEGEOM;
Standard_Real D = 0.;
Standard_Boolean isOk = ProcessAnalyticalCurves2d(Curve,Point,D);
if( !isOk ) return Standard_False;
if( Abs(D) > aTol ) return Standard_False;
if( KindOfCurve == STANDARD_TYPE (Geom2d_Line) )
{
Handle(Geom2d_Line) aGL = Handle(Geom2d_Line)::DownCast(Curve);
gp_Lin2d aLin = aGL->Lin2d();
U = ElCLib::Parameter(aLin,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Circle) )
{
Handle(Geom2d_Circle) aGC = Handle(Geom2d_Circle)::DownCast(Curve);
gp_Circ2d aCirc = aGC->Circ2d();
U = ElCLib::Parameter(aCirc,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Ellipse) )
{
Handle(Geom2d_Ellipse) aGE = Handle(Geom2d_Ellipse)::DownCast(Curve);
gp_Elips2d anElips = aGE->Elips2d();
U = ElCLib::Parameter(anElips,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Parabola) )
{
Handle(Geom2d_Parabola) aGP = Handle(Geom2d_Parabola)::DownCast(Curve);
gp_Parab2d aParab = aGP->Parab2d();
U = ElCLib::Parameter(aParab,Point);
}
else if( KindOfCurve == STANDARD_TYPE (Geom2d_Hyperbola) )
{
Handle(Geom2d_Hyperbola) aGH = Handle(Geom2d_Hyperbola)::DownCast(Curve);
gp_Hypr2d aHypr = aGH->Hypr2d();
U = ElCLib::Parameter(aHypr,Point);
}
else return Standard_False;
}
// process parametrical curves
else if( KindOfCurve == STANDARD_TYPE (Geom2d_BSplineCurve) ||
KindOfCurve == STANDARD_TYPE (Geom2d_BSplineCurve) ||
KindOfCurve == STANDARD_TYPE (Geom2d_TrimmedCurve) ||
KindOfCurve == STANDARD_TYPE (Geom2d_OffsetCurve) )
{
Standard_Real aTol = (Tolerance < MAXTOLERANCEPARM) ? Tolerance : MAXTOLERANCEPARM;
Geom2dAdaptor_Curve aGAC(Curve);
Extrema_ExtPC2d extrema(Point,aGAC);
if( !extrema.IsDone() ) return Standard_False;
Standard_Integer n = extrema.NbExt();
if( n <= 0 ) return Standard_False;
Standard_Integer i = 0, iMin = 0;
Standard_Real Dist2Min = 1.e+100;
for ( i = 1; i <= n; i++ )
{
if( extrema.SquareDistance(i) < Dist2Min )
{
Dist2Min = extrema.SquareDistance(i);
iMin = i;
}
}
if( iMin != 0 && Dist2Min <= aTol * aTol ) U = (extrema.Point(iMin)).Parameter();
else return Standard_False;
}
else { return Standard_False; }
return Standard_True;
}