mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
53
src/CPnts/CPnts.cdl
Executable file
53
src/CPnts/CPnts.cdl
Executable file
@@ -0,0 +1,53 @@
|
||||
-- File: CPnts.cdl
|
||||
-- Created: Fri Feb 22 09:24:30 1991
|
||||
-- Author: Jean Claude Vauthier
|
||||
-- <jcv@topsn3>
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
|
||||
|
||||
package CPnts
|
||||
|
||||
--- Purpose :
|
||||
-- This package contains the definition of the geometric
|
||||
-- algorithms used to compute characteristic points on
|
||||
-- parametrized curves in 3d or 2d space.
|
||||
-- This package defines the external geometric entities, with
|
||||
-- their requirements, used in the algorithms.
|
||||
|
||||
uses math, gp, StdFail, Adaptor3d , Adaptor2d
|
||||
|
||||
is
|
||||
|
||||
|
||||
imported RealFunction;
|
||||
---Purpose: typedef Standard_Real (*CPnts_RealFunction)
|
||||
-- (const Standard_Real, const Standard_Address)
|
||||
--
|
||||
-- A pointer on a function for MyGaussFunction
|
||||
|
||||
private class MyGaussFunction;
|
||||
---Purpose: for implementation, compute values for Gauss
|
||||
|
||||
private class MyRootFunction;
|
||||
---Purpose: for implementation, compute Length and Derivative
|
||||
-- of the curve for Newton.
|
||||
|
||||
class AbscissaPoint;
|
||||
---Purpose:
|
||||
-- This algorithm computes a point and its parameter
|
||||
-- as the distance between this and a given point is the abscissa
|
||||
|
||||
class UniformDeflection;
|
||||
--- Purpose : This Algorithm computes a distribution of points
|
||||
-- with a given chordal deviation on a parametrized curve.
|
||||
|
||||
end CPnts;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
190
src/CPnts/CPnts_AbscissaPoint.cdl
Executable file
190
src/CPnts/CPnts_AbscissaPoint.cdl
Executable file
@@ -0,0 +1,190 @@
|
||||
-- File: AbscissaPoint.cdl
|
||||
-- Created: Mon Jul 15 15:18:50 1991
|
||||
-- Author: Isabelle GRIGNON
|
||||
-- <isg@topsn3>
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
class AbscissaPoint from CPnts
|
||||
|
||||
---Purpose: the algorithm computes a point on a curve at a given
|
||||
-- distance from another point on the curve
|
||||
--
|
||||
-- We can instantiates with
|
||||
-- Curve from Adaptor3d, Pnt from gp, Vec from gp
|
||||
--
|
||||
-- or
|
||||
-- Curve2d from Adaptor2d, Pnt2d from gp, Vec2d from gp
|
||||
|
||||
uses
|
||||
Curve2d from Adaptor2d,
|
||||
Curve from Adaptor3d,
|
||||
MyRootFunction from CPnts
|
||||
|
||||
raises NotDone from StdFail,
|
||||
ConstructionError from Standard
|
||||
|
||||
is
|
||||
|
||||
Length(myclass; C : Curve from Adaptor3d) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C>.
|
||||
|
||||
Length(myclass; C : Curve2d from Adaptor2d) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C>.
|
||||
|
||||
Length(myclass; C : Curve from Adaptor3d; Tol : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> with the given tolerance.
|
||||
|
||||
Length(myclass; C : Curve2d from Adaptor2d; Tol : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> with the given tolerance.
|
||||
|
||||
Length(myclass; C : Curve from Adaptor3d; U1, U2 : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> between <U1> and <U2>.
|
||||
|
||||
Length(myclass; C : Curve2d from Adaptor2d; U1, U2 : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> between <U1> and <U2>.
|
||||
|
||||
Length(myclass; C : Curve from Adaptor3d; U1, U2, Tol : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> between <U1> and <U2> with the given tolerance.
|
||||
|
||||
Length(myclass; C : Curve2d from Adaptor2d; U1, U2, Tol : Real) returns Real;
|
||||
---Purpose: Computes the length of the Curve <C> between <U1> and <U2> with the given tolerance.
|
||||
|
||||
Create
|
||||
---Purpose: creation of a indefinite AbscissaPoint.
|
||||
returns AbscissaPoint;
|
||||
|
||||
Create (C : Curve from Adaptor3d; Abscissa, U0, Resolution : Real)
|
||||
---Purpose: the algorithm computes a point on a curve <Curve> at the
|
||||
-- distance <Abscissa> from the point of parameter <U0>.
|
||||
-- <Resolution> is the error allowed in the computation.
|
||||
-- The computed point can be outside of the curve 's bounds.
|
||||
returns AbscissaPoint
|
||||
raises ConstructionError;
|
||||
-- raised when it is not possible to compute the curve's length or if
|
||||
-- the curve is null;
|
||||
|
||||
Create (C : Curve2d from Adaptor2d; Abscissa, U0, Resolution : Real)
|
||||
---Purpose: the algorithm computes a point on a curve <Curve> at the
|
||||
-- distance <Abscissa> from the point of parameter <U0>.
|
||||
-- <Resolution> is the error allowed in the computation.
|
||||
-- The computed point can be outside of the curve 's bounds.
|
||||
returns AbscissaPoint
|
||||
raises ConstructionError;
|
||||
-- raised when it is not possible to compute the curve's length or if
|
||||
-- the curve is null;
|
||||
|
||||
Create (C : Curve from Adaptor3d; Abscissa, U0, Ui, Resolution : Real)
|
||||
---Purpose: the algorithm computes a point on a curve <Curve> at the
|
||||
-- distance <Abscissa> from the point of parameter <U0>.
|
||||
-- <Ui> is the starting value used in the iterative process
|
||||
-- which find the solution, it must be closed to the final
|
||||
-- solution
|
||||
-- <Resolution> is the error allowed in the computation.
|
||||
-- The computed point can be outside of the curve 's bounds.
|
||||
returns AbscissaPoint
|
||||
raises ConstructionError;
|
||||
-- raised when it is not possible to compute the curve's length or if
|
||||
-- the curve is null;
|
||||
|
||||
Create (C : Curve2d from Adaptor2d; Abscissa, U0, Ui, Resolution : Real)
|
||||
---Purpose: the algorithm computes a point on a curve <Curve> at the
|
||||
-- distance <Abscissa> from the point of parameter <U0>.
|
||||
-- <Ui> is the starting value used in the iterative process
|
||||
-- which find the solution, it must be closed to the final
|
||||
-- solution
|
||||
-- <Resolution> is the error allowed in the computation.
|
||||
-- The computed point can be outside of the curve 's bounds.
|
||||
returns AbscissaPoint
|
||||
raises ConstructionError;
|
||||
-- raised when it is not possible to compute the curve's length or if
|
||||
-- the curve is null;
|
||||
|
||||
|
||||
Init(me: in out; C: Curve from Adaptor3d)
|
||||
---Purpose: Initializes the resolution function with <C>.
|
||||
is static;
|
||||
|
||||
Init(me: in out; C: Curve2d from Adaptor2d)
|
||||
---Purpose: Initializes the resolution function with <C>.
|
||||
is static;
|
||||
|
||||
-- these two methods are introduced by rbv to control the tolerance
|
||||
|
||||
Init(me: in out; C: Curve from Adaptor3d; Tol : Real)
|
||||
---Purpose: Initializes the resolution function with <C>.
|
||||
is static;
|
||||
|
||||
Init(me: in out; C: Curve2d from Adaptor2d; Tol : Real)
|
||||
---Purpose: Initializes the resolution function with <C>.
|
||||
is static;
|
||||
--
|
||||
|
||||
Init(me: in out; C: Curve from Adaptor3d; U1, U2: Real)
|
||||
---Purpose: Initializes the resolution function with <C>
|
||||
-- between U1 and U2.
|
||||
is static;
|
||||
|
||||
Init(me: in out; C: Curve2d from Adaptor2d; U1, U2: Real)
|
||||
---Purpose: Initializes the resolution function with <C>
|
||||
-- between U1 and U2.
|
||||
is static;
|
||||
|
||||
-- these two methods are introduced by rbv to control the tolerance
|
||||
Init(me: in out; C: Curve from Adaptor3d; U1, U2, Tol: Real)
|
||||
---Purpose: Initializes the resolution function with <C>
|
||||
-- between U1 and U2.
|
||||
is static;
|
||||
|
||||
Init(me: in out; C: Curve2d from Adaptor2d; U1, U2, Tol: Real)
|
||||
---Purpose: Initializes the resolution function with <C>
|
||||
-- between U1 and U2.
|
||||
is static;
|
||||
|
||||
Perform(me: in out; Abscissa, U0, Resolution : Real)
|
||||
---Purpose: Computes the point at the distance <Abscissa> of
|
||||
-- the curve.
|
||||
is static;
|
||||
|
||||
Perform(me: in out; Abscissa, U0, Ui, Resolution : Real)
|
||||
---Purpose: Computes the point at the distance <Abscissa> of
|
||||
-- the curve.
|
||||
is static;
|
||||
|
||||
AdvPerform(me: in out; Abscissa, U0, Ui, Resolution : Real)
|
||||
---Purpose: Computes the point at the distance <Abscissa> of
|
||||
-- the curve; performs more appropriate tolerance managment;
|
||||
-- to use this method in right way it is necessary to call
|
||||
-- empty consructor. then call method Init with
|
||||
-- Tolerance = Resolution, then call AdvPermorm.
|
||||
is static;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: True if the computation was successful, False otherwise.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
Parameter(me) returns Real
|
||||
---Purpose: Returns the parameter of the solution.
|
||||
--
|
||||
---C++: inline
|
||||
raises NotDone from StdFail;
|
||||
-- if the computation was not done.
|
||||
|
||||
|
||||
SetParameter(me : in out; P : Real);
|
||||
---Purpose: Enforce the solution, used by GCPnts.
|
||||
--
|
||||
---C++: inline
|
||||
|
||||
fields
|
||||
|
||||
myDone : Boolean;
|
||||
myL : Real;
|
||||
myParam : Real;
|
||||
myUMin : Real;
|
||||
myUMax : Real from Standard;
|
||||
myF : MyRootFunction from CPnts;
|
||||
|
||||
end AbscissaPoint;
|
526
src/CPnts/CPnts_AbscissaPoint.cxx
Executable file
526
src/CPnts/CPnts_AbscissaPoint.cxx
Executable file
@@ -0,0 +1,526 @@
|
||||
//------------------------------------------------------------------------
|
||||
// Calculer un point a abscisse donne a partir
|
||||
// d un point donne
|
||||
//
|
||||
// cas traites :segment de droite,arc de cercle courbe parametree
|
||||
// la courbe doit etre C1
|
||||
//
|
||||
// pour une courbe parametree:
|
||||
//
|
||||
// on calcule la longueur totale de la courbe
|
||||
// on calcule un point approche en assimilant la courbe a une droite
|
||||
// on calcule la longueur de la courbe entre le point de depart et
|
||||
// le point approche
|
||||
// par iteration succsessive on trouve le point et son parametre associe
|
||||
// appel a FunctionRoot
|
||||
//
|
||||
//
|
||||
|
||||
#include <CPnts_AbscissaPoint.ixx>
|
||||
|
||||
#include <math_GaussSingleIntegration.hxx>
|
||||
#include <math_FunctionRoot.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <Geom_BezierCurve.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
// auxiliary functions to compute the length of the derivative
|
||||
|
||||
static Standard_Real f3d(const Standard_Real X, const Standard_Address C)
|
||||
{
|
||||
gp_Vec V = ((Adaptor3d_Curve*)C)->DN(X,1);
|
||||
return V.Magnitude();
|
||||
}
|
||||
|
||||
static Standard_Real f2d(const Standard_Real X, const Standard_Address C)
|
||||
{
|
||||
gp_Vec2d V = ((Adaptor2d_Curve2d*)C)->DN(X,1);
|
||||
return V.Magnitude();
|
||||
}
|
||||
|
||||
static Standard_Integer order(const Adaptor3d_Curve& C)
|
||||
{
|
||||
switch (C.GetType()) {
|
||||
|
||||
case GeomAbs_Line :
|
||||
return 2;
|
||||
|
||||
case GeomAbs_Parabola :
|
||||
return 5;
|
||||
|
||||
case GeomAbs_BezierCurve :
|
||||
return Min(24, 2*C.Bezier()->Degree());
|
||||
|
||||
case GeomAbs_BSplineCurve :
|
||||
return Min(24, 2*C.BSpline()->NbPoles()-1);
|
||||
|
||||
default :
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Integer order(const Adaptor2d_Curve2d& C)
|
||||
{
|
||||
switch (C.GetType()) {
|
||||
|
||||
case GeomAbs_Line :
|
||||
return 2;
|
||||
|
||||
case GeomAbs_Parabola :
|
||||
return 5;
|
||||
|
||||
case GeomAbs_BezierCurve :
|
||||
return Min(24, 2*C.Bezier()->Degree());
|
||||
|
||||
case GeomAbs_BSplineCurve :
|
||||
return Min(24, 2*C.BSpline()->NbPoles()-1);
|
||||
|
||||
default :
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 3d
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor3d_Curve& C)
|
||||
{
|
||||
return CPnts_AbscissaPoint::Length(C, C.FirstParameter(),
|
||||
C.LastParameter());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 2d
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor2d_Curve2d& C)
|
||||
{
|
||||
return CPnts_AbscissaPoint::Length(C, C.FirstParameter(),
|
||||
C.LastParameter());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 3d with tolerance
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor3d_Curve& C, const Standard_Real Tol)
|
||||
{
|
||||
return CPnts_AbscissaPoint::Length(C, C.FirstParameter(),
|
||||
C.LastParameter(), Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 2d with tolerance
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor2d_Curve2d& C, const Standard_Real Tol)
|
||||
{
|
||||
return CPnts_AbscissaPoint::Length(C, C.FirstParameter(),
|
||||
C.LastParameter(), Tol);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 3d with parameters
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor3d_Curve& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2)
|
||||
{
|
||||
CPnts_MyGaussFunction FG;
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f3d;
|
||||
FG.Init(rf,(Standard_Address)&C);
|
||||
// FG.Init(f3d,(Standard_Address)&C);
|
||||
math_GaussSingleIntegration TheLength(FG, U1, U2, order(C));
|
||||
if (!TheLength.IsDone()) {
|
||||
Standard_ConstructionError::Raise();
|
||||
}
|
||||
return Abs(TheLength.Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 2d with parameters
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2)
|
||||
{
|
||||
CPnts_MyGaussFunction FG;
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f2d;
|
||||
FG.Init(rf,(Standard_Address)&C);
|
||||
// FG.Init(f2d,(Standard_Address)&C);
|
||||
math_GaussSingleIntegration TheLength(FG, U1, U2, order(C));
|
||||
if (!TheLength.IsDone()) {
|
||||
Standard_ConstructionError::Raise();
|
||||
}
|
||||
return Abs(TheLength.Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 3d with parameters and tolerance
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor3d_Curve& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
CPnts_MyGaussFunction FG;
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f3d;
|
||||
FG.Init(rf,(Standard_Address)&C);
|
||||
// FG.Init(f3d,(Standard_Address)&C);
|
||||
math_GaussSingleIntegration TheLength(FG, U1, U2, order(C), Tol);
|
||||
if (!TheLength.IsDone()) {
|
||||
Standard_ConstructionError::Raise();
|
||||
}
|
||||
return Abs(TheLength.Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Length
|
||||
//purpose : 2d with parameters and tolerance
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real CPnts_AbscissaPoint::Length(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
CPnts_MyGaussFunction FG;
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f2d;
|
||||
FG.Init(rf,(Standard_Address)&C);
|
||||
// FG.Init(f2d,(Standard_Address)&C);
|
||||
math_GaussSingleIntegration TheLength(FG, U1, U2, order(C), Tol);
|
||||
if (!TheLength.IsDone()) {
|
||||
Standard_ConstructionError::Raise();
|
||||
}
|
||||
return Abs(TheLength.Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_AbscissaPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_AbscissaPoint::CPnts_AbscissaPoint() : myDone(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_AbscissaPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_AbscissaPoint::CPnts_AbscissaPoint(const Adaptor3d_Curve& C,
|
||||
const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
// Init(C);
|
||||
Init(C, Resolution); //rbv's modification
|
||||
//
|
||||
Perform(Abscissa, U0, Resolution);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_AbscissaPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_AbscissaPoint::CPnts_AbscissaPoint(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
Init(C);
|
||||
Perform(Abscissa, U0, Resolution);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_AbscissaPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_AbscissaPoint::CPnts_AbscissaPoint(const Adaptor3d_Curve& C,
|
||||
const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Ui,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
Init(C);
|
||||
Perform(Abscissa, U0, Ui, Resolution);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_AbscissaPoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_AbscissaPoint::CPnts_AbscissaPoint(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Ui,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
Init(C);
|
||||
Perform(Abscissa, U0, Ui, Resolution);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor3d_Curve& C)
|
||||
{
|
||||
Init(C,C.FirstParameter(),C.LastParameter());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor2d_Curve2d& C)
|
||||
{
|
||||
Init(C,C.FirstParameter(),C.LastParameter());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : introduced by rbv for curvilinear parametrization
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor3d_Curve& C, const Standard_Real Tol)
|
||||
{
|
||||
Init(C,C.FirstParameter(),C.LastParameter(), Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor2d_Curve2d& C, const Standard_Real Tol)
|
||||
{
|
||||
Init(C,C.FirstParameter(),C.LastParameter(), Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor3d_Curve& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2)
|
||||
{
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f3d;
|
||||
myF.Init(rf,(Standard_Address)&C,order(C));
|
||||
// myF.Init(f3d,(Standard_Address)&C,order(C));
|
||||
myL = CPnts_AbscissaPoint::Length(C, U1, U2);
|
||||
myUMin = Min(U1, U2);
|
||||
myUMax = Max(U1, U2);
|
||||
Standard_Real DU = myUMax - myUMin;
|
||||
myUMin = myUMin - DU;
|
||||
myUMax = myUMax + DU;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2)
|
||||
{
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f2d;
|
||||
myF.Init(rf,(Standard_Address)&C,order(C));
|
||||
// myF.Init(f2d,(Standard_Address)&C,order(C));
|
||||
myL = CPnts_AbscissaPoint::Length(C, U1, U2);
|
||||
myUMin = Min(U1, U2);
|
||||
myUMax = Max(U1, U2);
|
||||
Standard_Real DU = myUMax - myUMin;
|
||||
myUMin = myUMin - DU;
|
||||
myUMax = myUMax + DU;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose : introduced by rbv for curvilinear parametrization
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor3d_Curve& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f3d;
|
||||
myF.Init(rf,(Standard_Address)&C,order(C));
|
||||
// myF.Init(f3d,(Standard_Address)&C,order(C));
|
||||
myL = CPnts_AbscissaPoint::Length(C, U1, U2, Tol);
|
||||
myUMin = Min(U1, U2);
|
||||
myUMax = Max(U1, U2);
|
||||
Standard_Real DU = myUMax - myUMin;
|
||||
myUMin = myUMin - DU;
|
||||
myUMax = myUMax + DU;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Init(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
//POP pout WNT
|
||||
CPnts_RealFunction rf = f2d;
|
||||
myF.Init(rf,(Standard_Address)&C,order(C));
|
||||
// myF.Init(f2d,(Standard_Address)&C,order(C));
|
||||
myL = CPnts_AbscissaPoint::Length(C, U1, U2, Tol);
|
||||
myUMin = Min(U1, U2);
|
||||
myUMax = Max(U1, U2);
|
||||
Standard_Real DU = myUMax - myUMin;
|
||||
myUMin = myUMin - DU;
|
||||
myUMax = myUMax + DU;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Perform(const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
if (myL < Precision::Confusion()) {
|
||||
//
|
||||
// on sort moins violemment : j'espere que l'on espere pas
|
||||
// un increment notable au niveau de myParam
|
||||
//
|
||||
myDone = Standard_True ;
|
||||
myParam = U0 ;
|
||||
|
||||
}
|
||||
else {
|
||||
Standard_Real Ui = U0 + (Abscissa / myL) * (myUMax - myUMin) / 3.;
|
||||
// exercice : why 3 ?
|
||||
Perform(Abscissa,U0,Ui,Resolution);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::Perform(const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Ui,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
if (myL < Precision::Confusion()) {
|
||||
//
|
||||
// on sort moins violemment :
|
||||
//
|
||||
myDone = Standard_True ;
|
||||
myParam = U0 ;
|
||||
}
|
||||
else {
|
||||
myDone = Standard_False;
|
||||
myF.Init(U0, Abscissa);
|
||||
|
||||
math_FunctionRoot Solution(myF, Ui, Resolution, myUMin, myUMax);
|
||||
|
||||
// Temporairement on vire le test de validite de la solution
|
||||
// Il faudra des que l on pourra faire du cdl, rendre un tolreached
|
||||
// lbo 21/03/97
|
||||
// if (Solution.IsDone()) {
|
||||
// Standard_Real D;
|
||||
// myF.Derivative(Solution.Root(),D);
|
||||
// if (Abs(Solution.Value()) < Resolution * D) {
|
||||
// myDone = Standard_True;
|
||||
// myParam = Solution.Root();
|
||||
// }
|
||||
// }
|
||||
if (Solution.IsDone()) {
|
||||
myDone = Standard_True;
|
||||
myParam = Solution.Root();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AdvPerform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_AbscissaPoint::AdvPerform(const Standard_Real Abscissa,
|
||||
const Standard_Real U0,
|
||||
const Standard_Real Ui,
|
||||
const Standard_Real Resolution)
|
||||
{
|
||||
if (myL < Precision::Confusion()) {
|
||||
//
|
||||
// on sort moins violemment :
|
||||
//
|
||||
myDone = Standard_True ;
|
||||
myParam = U0 ;
|
||||
}
|
||||
else {
|
||||
myDone = Standard_False;
|
||||
// myF.Init(U0, Abscissa);
|
||||
myF.Init(U0, Abscissa, Resolution/10); // rbv's modification
|
||||
|
||||
math_FunctionRoot Solution(myF, Ui, Resolution, myUMin, myUMax);
|
||||
|
||||
// Temporairement on vire le test de validite de la solution
|
||||
// Il faudra des que l on pourra faire du cdl, rendre un tolreached
|
||||
// lbo 21/03/97
|
||||
// if (Solution.IsDone()) {
|
||||
// Standard_Real D;
|
||||
// myF.Derivative(Solution.Root(),D);
|
||||
// if (Abs(Solution.Value()) < Resolution * D) {
|
||||
// myDone = Standard_True;
|
||||
// myParam = Solution.Root();
|
||||
// }
|
||||
// }
|
||||
if (Solution.IsDone()) {
|
||||
myDone = Standard_True;
|
||||
myParam = Solution.Root();
|
||||
}
|
||||
}
|
||||
}
|
33
src/CPnts/CPnts_AbscissaPoint.lxx
Executable file
33
src/CPnts/CPnts_AbscissaPoint.lxx
Executable file
@@ -0,0 +1,33 @@
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean CPnts_AbscissaPoint::IsDone() const
|
||||
{
|
||||
return myDone;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Parameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real CPnts_AbscissaPoint::Parameter() const
|
||||
{
|
||||
StdFail_NotDone_Raise_if(!myDone, "");
|
||||
return myParam;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetParameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void CPnts_AbscissaPoint::SetParameter(const Standard_Real P)
|
||||
{
|
||||
myParam = P;
|
||||
myDone = Standard_True;
|
||||
}
|
34
src/CPnts/CPnts_MyGaussFunction.cdl
Executable file
34
src/CPnts/CPnts_MyGaussFunction.cdl
Executable file
@@ -0,0 +1,34 @@
|
||||
-- File: MyGaussFunction.cdl
|
||||
-- Created: Fri Jul 19 16:42:31 1991
|
||||
-- Author: Isabelle GRIGNON
|
||||
-- <isg@topsn3>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
private class MyGaussFunction from CPnts
|
||||
inherits Function from math
|
||||
|
||||
uses
|
||||
RealFunction from CPnts
|
||||
|
||||
is
|
||||
|
||||
Create returns MyGaussFunction;
|
||||
---C++: inline
|
||||
|
||||
Init(me : in out;
|
||||
F : RealFunction from CPnts;
|
||||
D : Address from Standard);
|
||||
---Purpose: F is a pointer on a function D is a client data
|
||||
--
|
||||
-- Each value is computed with F(D)
|
||||
|
||||
Value(me: in out; X : Real; F : out Real)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myFunction : RealFunction from CPnts;
|
||||
myData : Address from Standard;
|
||||
|
||||
end MyGaussFunction;
|
26
src/CPnts/CPnts_MyGaussFunction.cxx
Executable file
26
src/CPnts/CPnts_MyGaussFunction.cxx
Executable file
@@ -0,0 +1,26 @@
|
||||
|
||||
#include <CPnts_MyGaussFunction.ixx>
|
||||
|
||||
void CPnts_MyGaussFunction::Init(const CPnts_RealFunction& F,
|
||||
const Standard_Address D)
|
||||
{
|
||||
myFunction = F;
|
||||
myData = D;
|
||||
}
|
||||
|
||||
Standard_Boolean CPnts_MyGaussFunction::Value(const Standard_Real X,
|
||||
Standard_Real& F)
|
||||
{
|
||||
F = myFunction(X,myData);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
7
src/CPnts/CPnts_MyGaussFunction.lxx
Executable file
7
src/CPnts/CPnts_MyGaussFunction.lxx
Executable file
@@ -0,0 +1,7 @@
|
||||
// File: CPnts_MyGaussFunction.lxx
|
||||
// Created: Thu May 4 17:36:53 1995
|
||||
// Author: Modelistation
|
||||
// <model@fuegox>
|
||||
|
||||
|
||||
inline CPnts_MyGaussFunction::CPnts_MyGaussFunction() {}
|
59
src/CPnts/CPnts_MyRootFunction.cdl
Executable file
59
src/CPnts/CPnts_MyRootFunction.cdl
Executable file
@@ -0,0 +1,59 @@
|
||||
-- File: MyRootFunction.cdl
|
||||
-- Created: Fri Jul 19 16:11:34 1991
|
||||
-- Author: Isabelle GRIGNON
|
||||
-- <isg@topsn3>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
private class MyRootFunction from CPnts
|
||||
|
||||
inherits FunctionWithDerivative from math
|
||||
|
||||
---Purpose: Implements a function for the Newton algorithm to find the
|
||||
-- solution of Integral(F) = L
|
||||
|
||||
uses
|
||||
MyGaussFunction from CPnts,
|
||||
RealFunction from CPnts
|
||||
|
||||
is
|
||||
|
||||
Create returns MyRootFunction from CPnts;
|
||||
---C++: inline
|
||||
|
||||
Init(me : in out;
|
||||
F : RealFunction from CPnts;
|
||||
D : Address from Standard;
|
||||
Order : Integer);
|
||||
---Purpose: F is a pointer on a function D is a client data
|
||||
-- Order is the order of integration to use
|
||||
--
|
||||
|
||||
Init(me : in out; X0,L : Real);
|
||||
---Purpose: We want to solve Integral(X0,X,F(X,D)) = L
|
||||
|
||||
Init(me : in out; X0,L,Tol : Real);
|
||||
---Purpose: We want to solve Integral(X0,X,F(X,D)) = L
|
||||
-- with given tolerance
|
||||
|
||||
Value(me:in out; X : Real; F : out Real)
|
||||
---Purpose: This is Integral(X0,X,F(X,D)) - L
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Derivative(me :in out; X: Real; Df : out Real)
|
||||
---Purpose: This is F(X,D)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Values(me:in out; X : Real; F, Df : out Real)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
fields
|
||||
myFunction : MyGaussFunction from CPnts;
|
||||
myX0 : Real;
|
||||
myL : Real;
|
||||
myOrder : Integer;
|
||||
myTol : Real; -- rbv's modification
|
||||
end MyRootFunction;
|
72
src/CPnts/CPnts_MyRootFunction.cxx
Executable file
72
src/CPnts/CPnts_MyRootFunction.cxx
Executable file
@@ -0,0 +1,72 @@
|
||||
#include <CPnts_MyRootFunction.ixx>
|
||||
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <math_GaussSingleIntegration.hxx>
|
||||
|
||||
|
||||
|
||||
void CPnts_MyRootFunction::Init(const CPnts_RealFunction& F,
|
||||
const Standard_Address D,
|
||||
const Standard_Integer Order)
|
||||
{
|
||||
myFunction.Init(F,D);
|
||||
myOrder = Order;
|
||||
}
|
||||
|
||||
void CPnts_MyRootFunction::Init(const Standard_Real X0,
|
||||
const Standard_Real L)
|
||||
{
|
||||
myX0 = X0;
|
||||
myL = L;
|
||||
myTol = -1; //to supress the tolerance
|
||||
}
|
||||
|
||||
void CPnts_MyRootFunction::Init(const Standard_Real X0,
|
||||
const Standard_Real L,
|
||||
const Standard_Real Tol)
|
||||
{
|
||||
myX0 = X0;
|
||||
myL = L;
|
||||
myTol = Tol;
|
||||
}
|
||||
|
||||
Standard_Boolean CPnts_MyRootFunction::Value(const Standard_Real X,
|
||||
Standard_Real& F)
|
||||
{
|
||||
math_GaussSingleIntegration Length;
|
||||
|
||||
if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
|
||||
else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);
|
||||
|
||||
if (Length.IsDone()){
|
||||
F= Length.Value() - myL;
|
||||
return Standard_True;
|
||||
}
|
||||
else {
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean CPnts_MyRootFunction::Derivative(const Standard_Real X,
|
||||
Standard_Real& Df)
|
||||
{
|
||||
return myFunction.Value(X,Df);
|
||||
}
|
||||
|
||||
Standard_Boolean CPnts_MyRootFunction::Values(const Standard_Real X,
|
||||
Standard_Real& F,
|
||||
Standard_Real& Df)
|
||||
{
|
||||
math_GaussSingleIntegration Length;
|
||||
|
||||
if (myTol <= 0) Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder);
|
||||
else Length = math_GaussSingleIntegration(myFunction, myX0, X, myOrder, myTol);
|
||||
|
||||
if (Length.IsDone()){
|
||||
F= Length.Value() - myL;
|
||||
return myFunction.Value(X,Df);
|
||||
}
|
||||
else {
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
6
src/CPnts/CPnts_MyRootFunction.lxx
Executable file
6
src/CPnts/CPnts_MyRootFunction.lxx
Executable file
@@ -0,0 +1,6 @@
|
||||
// File: CPnts_MyRootFunction.lxx
|
||||
// Created: Thu May 4 17:37:19 1995
|
||||
// Author: Modelistation
|
||||
// <model@fuegox>
|
||||
|
||||
inline CPnts_MyRootFunction::CPnts_MyRootFunction() {}
|
15
src/CPnts/CPnts_RealFunction.hxx
Executable file
15
src/CPnts/CPnts_RealFunction.hxx
Executable file
@@ -0,0 +1,15 @@
|
||||
// File: CPnts_RealFunction.hxx
|
||||
// Created: Thu May 4 16:30:39 1995
|
||||
// Author: Modelistation
|
||||
// <model@fuegox>
|
||||
|
||||
|
||||
#ifndef _CPnts_RealFunction_HeaderFile
|
||||
#define _CPnts_RealFunction_HeaderFile
|
||||
|
||||
#include <Standard_TypeDef.hxx>
|
||||
|
||||
typedef Standard_Real (*CPnts_RealFunction)(const Standard_Real,
|
||||
const Standard_Address);
|
||||
|
||||
#endif
|
181
src/CPnts/CPnts_UniformDeflection.cdl
Executable file
181
src/CPnts/CPnts_UniformDeflection.cdl
Executable file
@@ -0,0 +1,181 @@
|
||||
-- File: UniformDeflection.cdl
|
||||
-- Created: Wed Feb 27 13:01:27 1991
|
||||
-- Author: Jean Claude Vauthier
|
||||
-- <jcv@topsn3>
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
|
||||
class UniformDeflection from CPnts
|
||||
|
||||
---Purpose : This classe defines an algorithm to create a set of points at the
|
||||
-- positions of constant deflection of a given curve or a trimmed
|
||||
-- circle.
|
||||
-- The continuity of the curve must be at least C2.
|
||||
--
|
||||
-- the usage of the is the following.
|
||||
--
|
||||
-- class myUniformDFeflection instantiates
|
||||
-- UniformDeflection(Curve, Tool);
|
||||
--
|
||||
--
|
||||
-- Curve C; // Curve inherits from Curve or Curve2d from Adaptor2d
|
||||
-- myUniformDeflection Iter1;
|
||||
-- DefPntOfmyUniformDeflection P;
|
||||
--
|
||||
-- for(Iter1.Initialize(C, Deflection, EPSILON, True);
|
||||
-- Iter1.More();
|
||||
-- Iter1.Next()) {
|
||||
-- P = Iter1.Value();
|
||||
-- ... make something with P
|
||||
-- }
|
||||
-- if(!Iter1.IsAllDone()) {
|
||||
-- ... something wrong happened
|
||||
-- }
|
||||
uses
|
||||
Curve from Adaptor3d,
|
||||
Curve2d from Adaptor2d,
|
||||
Pnt from gp
|
||||
|
||||
raises DomainError from Standard,
|
||||
NotDone from StdFail,
|
||||
OutOfRange from Standard
|
||||
|
||||
is
|
||||
|
||||
|
||||
--
|
||||
|
||||
Create
|
||||
---Purpose: creation of a indefinite UniformDeflection
|
||||
returns UniformDeflection;
|
||||
|
||||
Create(C : Curve from Adaptor3d; Deflection, Resolution : Real;
|
||||
WithControl : Boolean )
|
||||
--- Purpose : Computes a uniform deflection distribution of points
|
||||
-- on the curve <C>.
|
||||
-- <Deflection> defines the constant deflection value.
|
||||
-- The algorithm computes the number of points and the points.
|
||||
-- The curve <C> must be at least C2 else the computation can fail.
|
||||
-- If just some parts of the curve is C2 it is better to give the
|
||||
-- parameters bounds and to use the below constructor .
|
||||
-- if <WithControl> is True, the algorithm controls the estimate
|
||||
-- deflection
|
||||
-- when the curve is singular at the point P(u),the algorithm
|
||||
-- computes the next point as
|
||||
-- P(u + Max(CurrentStep,Abs(LastParameter-FirstParameter)))
|
||||
-- if the singularity is at the first point ,the next point
|
||||
-- calculated is the P(LastParameter)
|
||||
returns UniformDeflection;
|
||||
|
||||
Create(C : Curve2d from Adaptor2d; Deflection, Resolution : Real;
|
||||
WithControl : Boolean )
|
||||
---Purpose: As above with 2d curve
|
||||
returns UniformDeflection;
|
||||
|
||||
Create(C : Curve from Adaptor3d; Deflection, U1, U2, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
--- Purpose :
|
||||
-- Computes an uniform deflection distribution of points on a part of
|
||||
-- the curve <C>. Deflection defines the step between the points.
|
||||
-- <U1> and <U2> define the distribution span.
|
||||
-- <U1> and <U2> must be in the parametric range of the curve.
|
||||
returns UniformDeflection
|
||||
raises DomainError;
|
||||
-- raised if U1 and U2 are not in the parametric bounds of the curve.
|
||||
|
||||
Create(C : Curve2d from Adaptor2d; Deflection, U1, U2, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
--- Purpose : As above with 2d curve
|
||||
returns UniformDeflection
|
||||
raises DomainError;
|
||||
-- raised if U1 and U2 are not in the parametric bounds of the curve.
|
||||
|
||||
Initialize(me : in out; C : Curve from Adaptor3d;
|
||||
Deflection, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>,
|
||||
-- <Resolution> and <WithControl>
|
||||
is static;
|
||||
|
||||
Initialize(me : in out; C : Curve2d from Adaptor2d;
|
||||
Deflection, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>,
|
||||
-- <Resolution> and <WithControl>
|
||||
is static;
|
||||
|
||||
Initialize(me : in out; C : Curve from Adaptor3d;
|
||||
Deflection, U1, U2, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>,
|
||||
-- <U1>, <U2> and <WithControl>
|
||||
raises DomainError
|
||||
is static;
|
||||
|
||||
Initialize(me : in out; C : Curve2d from Adaptor2d;
|
||||
Deflection, U1, U2, Resolution : Real;
|
||||
WithControl : Boolean)
|
||||
---Purpose: Initialize the algoritms with <C>, <Deflection>, <UStep>,
|
||||
-- <U1>, <U2> and <WithControl>
|
||||
raises DomainError
|
||||
is static;
|
||||
|
||||
IsAllDone (me)
|
||||
--- Purpose : To know if all the calculus were done successfully
|
||||
-- (ie all the points have been computed). The calculus can fail if
|
||||
-- the Curve is not C1 in the considered domain.
|
||||
-- Returns True if the calculus was successful.
|
||||
---C++: inline
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Next(me : in out)
|
||||
---Purpose: go to the next Point.
|
||||
---C++: inline
|
||||
raises OutOfRange
|
||||
is static;
|
||||
|
||||
More(me : in out)
|
||||
---Purpose: returns True if it exists a next Point.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Value(me) returns Real
|
||||
---Purpose : return the computed parameter
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
|
||||
Point(me) returns Pnt from gp
|
||||
---Purpose : return the computed parameter
|
||||
---C++: inline
|
||||
is static;
|
||||
|
||||
Perform (me : in out)
|
||||
---Purpose: algorithm
|
||||
is static private;
|
||||
|
||||
fields
|
||||
|
||||
myDone : Boolean;
|
||||
my3d : Boolean;
|
||||
myCurve : Address from Standard;
|
||||
myFinish : Boolean;
|
||||
myTolCur : Real;
|
||||
myControl : Boolean;
|
||||
myIPoint : Integer;
|
||||
myNbPoints : Integer;
|
||||
myParams : Real[3];
|
||||
myPoints : Pnt from gp [3] ;
|
||||
myDwmax : Real;
|
||||
myDeflection : Real;
|
||||
myFirstParam : Real;
|
||||
myLastParam : Real;
|
||||
myDu : Real;
|
||||
|
||||
end UniformDeflection;
|
||||
|
||||
|
||||
|
||||
|
||||
|
442
src/CPnts/CPnts_UniformDeflection.cxx
Executable file
442
src/CPnts/CPnts_UniformDeflection.cxx
Executable file
@@ -0,0 +1,442 @@
|
||||
//-------------------------------------------------------------------
|
||||
// algorihme lieu a fleche constante
|
||||
//
|
||||
// cas traites : courbe parametree
|
||||
// la courbe doit etre C2
|
||||
// on assure une fleche maxi
|
||||
//
|
||||
// algorithme courbe parametree:
|
||||
//
|
||||
//
|
||||
// le calcul du pas d avancement est
|
||||
// du = sqrt(8*fleche*||P'(u)||/||P'(u)^P''(u)||
|
||||
//
|
||||
// on calcule chaque point t.q. u+Du
|
||||
//
|
||||
// on verifie si la fleche est effectivement respectee ,si oui on continue
|
||||
// sinon on rectifie le pas
|
||||
//
|
||||
// si du ne peut etre calculer (courbure nulle ,singularite sur la courbe) on
|
||||
// prendra alors un pas constant pour atteindre le dernier point ou le depass// er
|
||||
//
|
||||
// le dernier point est reajuste selon les criteres suivants:
|
||||
//
|
||||
// si le dernier parametre calcule <2*resolution,on recadre le dernier
|
||||
// point trouve entre lui meme et le precedent et on rajoute le point
|
||||
// de fin (eviter une concentration a la fin)
|
||||
//
|
||||
// sinon si la distance (dernier point calcule ,point de fin)<fleche,on
|
||||
// remplace le dernier point calcule par le point de fin
|
||||
//
|
||||
// sinon on calcule une fleche max entre l avant dernier point calcule
|
||||
// et le point de fin ;si cette fleche est superieure a la fleche on
|
||||
// remplace le dernier point par celui ci et le point de fin
|
||||
//
|
||||
//
|
||||
// LES CONTROLES DE FLECHE ET DERNIER POINT NE SONT FAITS QUE SI
|
||||
// withControl=true
|
||||
//
|
||||
// chaque iteration calcule au maximum 3 points
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
#include <CPnts_UniformDeflection.ixx>
|
||||
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
|
||||
static inline void D03d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& P)
|
||||
{
|
||||
((Adaptor3d_Curve*)C)->D0(U,P);
|
||||
}
|
||||
|
||||
static void D02d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& PP)
|
||||
{
|
||||
gp_Pnt2d P;
|
||||
((Adaptor2d_Curve2d*)C)->D0(U,P);
|
||||
PP.SetCoord(P.X(),P.Y(),0.);
|
||||
}
|
||||
|
||||
static inline void D13d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& P, gp_Vec& V1)
|
||||
{
|
||||
((Adaptor3d_Curve*)C)->D1(U,P,V1);
|
||||
}
|
||||
|
||||
// Unused :
|
||||
#ifdef DEB
|
||||
static void D12d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& PP, gp_Vec& VV1)
|
||||
{
|
||||
gp_Pnt2d P;
|
||||
gp_Vec2d V1;
|
||||
((Adaptor2d_Curve2d*)C)->D1(U,P,V1);
|
||||
PP.SetCoord(P.X(),P.Y(),0.);
|
||||
VV1.SetCoord(V1.X(),V1.Y(),0.);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline void D23d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& P, gp_Vec& V1, gp_Vec& V2)
|
||||
{
|
||||
((Adaptor3d_Curve*)C)->D2(U,P,V1,V2);
|
||||
}
|
||||
|
||||
static void D22d(const Standard_Address C, const Standard_Real U,
|
||||
gp_Pnt& PP, gp_Vec& VV1, gp_Vec& VV2)
|
||||
{
|
||||
gp_Pnt2d P;
|
||||
gp_Vec2d V1,V2;
|
||||
((Adaptor2d_Curve2d*)C)->D2(U,P,V1,V2);
|
||||
PP.SetCoord(P.X(),P.Y(),0.);
|
||||
VV1.SetCoord(V1.X(),V1.Y(),0.);
|
||||
VV2.SetCoord(V2.X(),V2.Y(),0.);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Perform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_UniformDeflection::Perform()
|
||||
{
|
||||
gp_Pnt P, P1, P2;
|
||||
// gp_Vec V1, V2, VV1, VV2, VV;
|
||||
gp_Vec V1, V2, VV;
|
||||
Standard_Real Un1;
|
||||
Standard_Real NormD1, NormD2;
|
||||
|
||||
myIPoint = -1;
|
||||
myNbPoints = -1;
|
||||
|
||||
while ( (myNbPoints<2) && (!myFinish) ) {
|
||||
|
||||
myNbPoints = myNbPoints + 1;
|
||||
myParams[myNbPoints] = myFirstParam;
|
||||
|
||||
if (my3d)
|
||||
D23d(myCurve, myFirstParam, myPoints[myNbPoints], V1, V2);
|
||||
else
|
||||
D22d(myCurve, myFirstParam, myPoints[myNbPoints], V1, V2);
|
||||
P = myPoints[myNbPoints] ;
|
||||
NormD1 = V1.Magnitude();
|
||||
if (NormD1 < myTolCur || V2.Magnitude() < myTolCur) {
|
||||
// singularite sur la tangente ou courbure nulle
|
||||
myDu = Min(myDwmax, 1.5 * myDu);
|
||||
}
|
||||
else {
|
||||
NormD2 = V2.CrossMagnitude(V1);
|
||||
if (NormD2 / NormD1 < myDeflection) { // collinearite des derivees
|
||||
myDu = Min(myDwmax, 1.5 * myDu);
|
||||
}
|
||||
else {
|
||||
myDu = Sqrt(8.* myDeflection * NormD1 / NormD2 );
|
||||
myDu = Min(Max(myDu, myTolCur), myDwmax);
|
||||
}
|
||||
}
|
||||
|
||||
// verifier si la fleche est respectee si WithControl
|
||||
|
||||
if (myControl) {
|
||||
myDu = Min(myDu, myLastParam-myFirstParam);
|
||||
if (my3d) {
|
||||
|
||||
D03d(myCurve, myFirstParam + myDu,P);
|
||||
D03d(myCurve, myFirstParam + (myDu / 2.0),P1);
|
||||
}
|
||||
else {
|
||||
|
||||
D02d(myCurve, myFirstParam + myDu,P);
|
||||
D02d(myCurve, myFirstParam + (myDu / 2.0),P1);
|
||||
}
|
||||
V1= gp_Vec(myPoints[myNbPoints], P);
|
||||
NormD1 = V1.Magnitude();
|
||||
if (NormD1 >= myDeflection) {
|
||||
V2 = gp_Vec(myPoints[myNbPoints], P1);
|
||||
NormD2 = V2.CrossMagnitude(V1) / NormD1;
|
||||
|
||||
// le depassement de fleche a partir duquel on redivise est arbitraire
|
||||
// il faudra peut etre le reajuster (differencier le premier point des
|
||||
// autres) ce test ne marche pas sur les points d inflexion
|
||||
|
||||
if (NormD2 > myDeflection / 5.0) {
|
||||
NormD2 = Max(NormD2, 1.1 * myDeflection);
|
||||
myDu = myDu * Sqrt(myDeflection / NormD2);
|
||||
myDu = Min(Max(myDu, myTolCur), myDwmax);
|
||||
}
|
||||
}
|
||||
}
|
||||
myFirstParam = myFirstParam + myDu;
|
||||
myFinish = (myLastParam - myFirstParam < myTolCur) || (myDu == 0.);
|
||||
}
|
||||
if (myFinish) {
|
||||
// le dernier point est corrige si control
|
||||
if (myControl && (myNbPoints == 1) ) {
|
||||
Un1 = myParams[0];
|
||||
if (myLastParam - Un1 < 0.33*(myLastParam-myFirstParam)) {
|
||||
myFirstParam = (myLastParam + Un1) / 2.0;
|
||||
myParams[0]= myFirstParam;
|
||||
myParams[1]= myLastParam;
|
||||
if (my3d) {
|
||||
D03d(myCurve, myParams[0], myPoints[0]);
|
||||
D03d(myCurve, myParams[1], myPoints[1]);
|
||||
}
|
||||
else {
|
||||
D02d(myCurve, myParams[0], myPoints[0]);
|
||||
D02d(myCurve, myParams[1], myPoints[1]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (my3d) {
|
||||
D23d(myCurve, myLastParam, P1, V1, V2);
|
||||
}
|
||||
else {
|
||||
D22d(myCurve, myLastParam, P1, V1, V2);
|
||||
}
|
||||
P = myPoints[0] ;
|
||||
VV = gp_Vec(P1, P);
|
||||
NormD1 = VV.Magnitude();
|
||||
if ( NormD1 < myDeflection) {
|
||||
myParams[1]= myLastParam;
|
||||
myPoints[1]= P1 ;
|
||||
}
|
||||
else {
|
||||
myFirstParam = (myLastParam * (myParams[1] - Un1) + Un1 * myDu)
|
||||
/(myFirstParam -Un1);
|
||||
if (my3d)
|
||||
D03d(myCurve, myFirstParam, P2);
|
||||
else
|
||||
D02d(myCurve, myFirstParam, P2);
|
||||
|
||||
if ((VV.CrossMagnitude(gp_Vec(P2, P)) / NormD1 < myDeflection) &&
|
||||
(Un1 >= myLastParam - myDwmax) ) {
|
||||
// on supprime le point n
|
||||
myParams[1]= myLastParam;
|
||||
myPoints[1] = P1 ;
|
||||
}
|
||||
else {
|
||||
myParams[1]=myFirstParam;
|
||||
myPoints[1] = P2 ;
|
||||
myParams[2]=myLastParam;
|
||||
myPoints[2] = P1 ;
|
||||
myNbPoints = myNbPoints +1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
myNbPoints = myNbPoints +1 ;
|
||||
if (myNbPoints >= 3) myNbPoints = 2;
|
||||
myParams[myNbPoints]= myLastParam;
|
||||
if (my3d) {
|
||||
D03d(myCurve, myLastParam, myPoints[myNbPoints]);
|
||||
}
|
||||
else {
|
||||
D02d(myCurve, myLastParam, myPoints[myNbPoints]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_UniformDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_UniformDeflection::CPnts_UniformDeflection ()
|
||||
{
|
||||
myDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_UniformDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_UniformDeflection::CPnts_UniformDeflection
|
||||
(const Adaptor3d_Curve& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C, Deflection, Resolution, WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_UniformDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_UniformDeflection::CPnts_UniformDeflection
|
||||
(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C, Deflection, Resolution, WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_UniformDeflection::Initialize(const Adaptor3d_Curve& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C,Deflection,C.FirstParameter(),C.LastParameter(),
|
||||
Resolution,WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_UniformDeflection::Initialize(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C,Deflection,C.FirstParameter(),C.LastParameter(),
|
||||
Resolution,WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_UniformDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_UniformDeflection ::CPnts_UniformDeflection
|
||||
(const Adaptor3d_Curve& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C, Deflection, U1, U2, Resolution, WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CPnts_UniformDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
CPnts_UniformDeflection ::CPnts_UniformDeflection
|
||||
(const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
Initialize(C, Deflection, U1, U2, Resolution, WithControl);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_UniformDeflection::Initialize (const Adaptor3d_Curve& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
if (U1 > U2) {
|
||||
myFirstParam = U2;
|
||||
myLastParam = U1;
|
||||
}
|
||||
else {
|
||||
myFirstParam = U1;
|
||||
myLastParam = U2;
|
||||
}
|
||||
my3d = Standard_True;
|
||||
myDwmax = myLastParam-myFirstParam;
|
||||
myDu = myDwmax/2. ;
|
||||
myDone = Standard_True;
|
||||
myCurve = (Standard_Address) &C;
|
||||
myFinish = Standard_False;
|
||||
myTolCur = Resolution;
|
||||
myDeflection = Deflection;
|
||||
myControl = WithControl;
|
||||
Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void CPnts_UniformDeflection::Initialize (const Adaptor2d_Curve2d& C,
|
||||
const Standard_Real Deflection,
|
||||
const Standard_Real U1,
|
||||
const Standard_Real U2,
|
||||
const Standard_Real Resolution,
|
||||
const Standard_Boolean WithControl)
|
||||
{
|
||||
if (U1 > U2) {
|
||||
myFirstParam = U2;
|
||||
myLastParam = U1;
|
||||
}
|
||||
else {
|
||||
myFirstParam = U1;
|
||||
myLastParam = U2;
|
||||
}
|
||||
my3d = Standard_False;
|
||||
myDwmax = myLastParam-myFirstParam;
|
||||
myDu = myDwmax/2. ;
|
||||
myDone = Standard_True;
|
||||
myCurve = (Standard_Address) &C;
|
||||
myFinish = Standard_False;
|
||||
myTolCur = Resolution;
|
||||
myDeflection = Deflection;
|
||||
myControl = WithControl;
|
||||
Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean CPnts_UniformDeflection::More()
|
||||
{
|
||||
if(!myDone) {
|
||||
return Standard_False;
|
||||
}
|
||||
else if (myIPoint == myNbPoints) {
|
||||
if (myFinish) {
|
||||
return Standard_False;
|
||||
}
|
||||
else {
|
||||
Perform();
|
||||
return myDone;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return myIPoint < myNbPoints;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
44
src/CPnts/CPnts_UniformDeflection.lxx
Executable file
44
src/CPnts/CPnts_UniformDeflection.lxx
Executable file
@@ -0,0 +1,44 @@
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : IsAllDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean CPnts_UniformDeflection::IsAllDone () const
|
||||
{
|
||||
return myDone;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline void CPnts_UniformDeflection::Next()
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(myIPoint >= myNbPoints, "");
|
||||
myIPoint++;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Real CPnts_UniformDeflection::Value () const
|
||||
{
|
||||
StdFail_NotDone_Raise_if(!myDone, "");
|
||||
return myParams[myIPoint + 1];
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
inline gp_Pnt CPnts_UniformDeflection::Point () const
|
||||
{
|
||||
StdFail_NotDone_Raise_if(!myDone, "");
|
||||
return myPoints[myIPoint + 1];
|
||||
}
|
2
src/CPnts/FILES
Executable file
2
src/CPnts/FILES
Executable file
@@ -0,0 +1,2 @@
|
||||
CPnts_RealFunction.hxx
|
||||
|
Reference in New Issue
Block a user