1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +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

69
src/AdvApprox/AdvApprox.cdl Executable file
View File

@@ -0,0 +1,69 @@
-- File: AdvApprox.cdl
-- Created: Tue Jan 26 11:16:41 1993
-- Author: Laurent PAINNOT
-- <lpa@sdsun1>
---Copyright: Matra Datavision 1993
package AdvApprox
---Purpose: This package provides algorithms approximating a function
-- that can be multidimensional creating in the end a
-- BSpline function with the required continuity
--
uses gp,
math,
GeomAbs,
TColStd,
TColgp,
TCollection,
Standard,
StdFail,
PLib
is
class ApproxAFunction from AdvApprox ;
---Purpose:
-- this approximate a given function
class SimpleApprox;
-- class ApproxAFunction;
imported EvaluatorFunction ;
---Purpose:
-- typedef void (*EvaluatorFunction) (
-- Standard_Integer *
-- Standard_Real *
-- Standard_Real *
-- Standard_Integer *
-- Standard_Real *
-- Standard_Integer *) ;
deferred class Cutting;
---Purpose :
-- this class is used to choose the way of cutting if needed
class DichoCutting;
---Purpose :
-- inherits class Cutting;
-- if Cutting is necessary in [a,b], we cut at (a+b) / 2.
--
class PrefCutting;
---Purpose :
-- inherits class Cutting; contains a list of preferential points (di)i
-- if Cutting is necessary in [a,b], we cut at the di nearest from (a+b)/2.
class PrefAndRec;
---Purpose :
-- inherits class Cutting; contains two lists of preferential points to
-- manage to level of preferential cutting.
-- if Cutting is necessary in [a,b], we cut at the di nearest from (a+b)/2
end AdvApprox;

View File

@@ -0,0 +1,266 @@
-- File: Approx_AFunction.cdl
-- Created: Mon May 29 13:16:08 1995
-- Author: Xavier BENVENISTE
-- <xab@nonox>
---Copyright: Matra Datavision 1995
class ApproxAFunction from AdvApprox
uses Array1OfInteger from TColStd,
Vector from math,
HArray1OfInteger from TColStd,
Array1OfReal from TColStd,
Array1OfPnt2d from TColgp,
Array1OfPnt from TColgp,
HArray1OfReal from TColStd,
HArray1OfPnt2d from TColgp,
HArray1OfPnt from TColgp,
HArray2OfReal from TColStd,
HArray2OfPnt2d from TColgp,
HArray2OfPnt from TColgp,
Pnt from gp,
Pnt2d from gp,
Shape from GeomAbs,
EvaluatorFunction from AdvApprox,
Cutting from AdvApprox
raises
OutOfRange from Standard,
ConstructionError from Standard
is
Create(Num1DSS : Integer ;
Num2DSS : Integer ;
Num3DSS : Integer ;
OneDTol : HArray1OfReal from TColStd ;
TwoDTol : HArray1OfReal from TColStd ;
ThreeDTol : HArray1OfReal from TColStd ;
First : Real ;
Last : Real ;
Continuity : Shape from GeomAbs ;
MaxDeg : Integer ;
MaxSeg : Integer ;
Func : EvaluatorFunction from AdvApprox)
returns ApproxAFunction from AdvApprox
raises ConstructionError;
---Purpose: Constructs approximator tool.
--
-- Warning:
-- the Func should be valid reference to object of type
-- inherited from class EvaluatorFunction from Approx
-- with life time longer than that of the approximator tool;
--
-- the result should be formatted in the following way :
-- <--Num1DSS--> <--2 * Num2DSS--> <--3 * Num3DSS-->
-- R[0] .... R[Num1DSS]..... R[Dimension-1]
--
-- the order in which each Subspace appears should be consistent
-- with the tolerances given in the create function and the
-- results will be given in that order as well that is :
-- Curve2d(n) will correspond to the nth entry
-- described by Num2DSS, Curve(n) will correspond to
-- the nth entry described by Num3DSS
-- The same type of schema applies to the Poles1d, Poles2d and
-- Poles.
Create(Num1DSS : Integer ;
Num2DSS : Integer ;
Num3DSS : Integer ;
OneDTol : HArray1OfReal from TColStd ;
TwoDTol : HArray1OfReal from TColStd ;
ThreeDTol : HArray1OfReal from TColStd ;
First : Real ;
Last : Real ;
Continuity : Shape from GeomAbs ;
MaxDeg : Integer ;
MaxSeg : Integer ;
Func : EvaluatorFunction from AdvApprox;
CutTool : Cutting from AdvApprox)
---Purpose: Approximation with user methode of cutting
returns ApproxAFunction from AdvApprox
raises ConstructionError;
Perform(me:in out;
Num1DSS : Integer ;
Num2DSS : Integer ;
Num3DSS : Integer ;
CutTool : Cutting from AdvApprox)
is private;
Approximation(myclass;
TotalDimension : Integer;
TotalNumSS : Integer;
LocalDimension : Array1OfInteger;
First : Real;
Last : Real;
Evaluator : in out EvaluatorFunction;
CutTool : Cutting from AdvApprox;
ContinuityOrder : Integer;
NumMaxCoeffs : Integer;
MaxSegments : Integer;
TolerancesArray : Array1OfReal;
code_precis : Integer;
NumCurves : in out Integer;
NumCoeffPerCurveArray : in out Array1OfInteger;
LocalCoefficientArray : in out Array1OfReal;
IntervalsArray : in out Array1OfReal;
ErrorMaxArray : in out Array1OfReal;
AverageErrorArray : in out Array1OfReal;
ErrorCode : in out Integer);
IsDone(me) returns Boolean
---C++: inline
;
-- True if the approximation succeeded within the imposed
-- tolerances
HasResult(me) returns Boolean
---C++: inline
;
-- True if the approximation did come out with a result that
-- is not NECESSARELY within the required tolerance
--
Poles1d (me)
---C++: inline
---Purpose: returns the poles from the algorithms as is
returns HArray2OfReal from TColStd ;
Poles2d (me)
---Purpose: returns the poles from the algorithms as is
---C++: inline
returns HArray2OfPnt2d from TColgp ;
Poles (me)
---Purpose: -- returns the poles from the algorithms as is
---C++: inline
returns HArray2OfPnt from TColgp ;
NbPoles(me) returns Integer
---Purpose: as the name says
;
Poles1d (me; Index : Integer ;
P : in out Array1OfReal from TColStd)
---Purpose: returns the poles at Index from the 1d subspace
raises OutOfRange ;
Poles2d (me; Index : Integer ;
P : in out Array1OfPnt2d from TColgp)
---Purpose: returns the poles at Index from the 2d subspace
raises OutOfRange ;
Poles (me; Index : Integer ;
P : in out Array1OfPnt from TColgp)
---Purpose: returns the poles at Index from the 3d subspace
raises OutOfRange ;
Degree(me) returns Integer
---C++: inline
;
NbKnots(me) returns Integer
---C++: inline
;
NumSubSpaces(me; Dimension : Integer) returns Integer
---C++: inline
;
Knots(me)
---C++: inline
returns HArray1OfReal from TColStd ;
Multiplicities(me)
---C++: inline
returns HArray1OfInteger from TColStd ;
MaxError (me; Dimension : Integer)
---Purpose: returns the error as is in the algorithms
returns HArray1OfReal from TColStd ;
AverageError(me; Dimension : Integer)
---Purpose: returns the error as is in the algorithms
returns HArray1OfReal from TColStd ;
MaxError (me; Dimension : Integer ;
Index : Integer) returns Real
;
AverageError(me; Dimension : Integer;
Index : Integer) returns Real
;
Dump(me; o: in out OStream);
---Purpose: diplay information on approximation.
fields
-- Input fields
--
myNumSubSpaces : Integer[3] ;
-- Number of subspaces [0] = number of 1 dimensional subspaces
-- [1] = number of 2 dimensional subspaces
-- [2] = number of 3 dimensional subspaces
my1DTolerances : HArray1OfReal from TColStd ;
my2DTolerances : HArray1OfReal from TColStd ;
my3DTolerances : HArray1OfReal from TColStd ;
-- -- self explanatory : one tolerance per subspace
myFirst : Real ;
-- first parameter for the approximation
myLast : Real ;
-- last parameter for the approximation
myContinuity : Shape from GeomAbs ;
-- continuity requested for the approximation
---Warning:
-- The evaluator of the function to approximate
-- must provide the derivatives up to the requested
-- order otherwise this will NOT WORK
myMaxDegree : Integer ;
-- maximum degree for the approximation
---Warning:
-- Because of the unstable evaluation after degree 14
-- this is limited to 14
myMaxSegments : Integer ;
-- maximum of segment allowed
-- Output fields
--
myDone : Boolean ;
-- tells if the approximation succeeded within the requested
-- tolerance
myHasResult : Boolean ;
-- tells if the approximation returned a result although
-- it might not be within the requested tolerance. In
-- that case myDone will be false
--
my1DPoles : HArray2OfReal from TColStd ;
-- 1D poles if myNumSubSpaces[0] > 0
my2DPoles : HArray2OfPnt2d from TColgp ;
-- 2D poles if myNumSubSpaces[1] > 0
my3DPoles : HArray2OfPnt from TColgp ;
-- 3D poles if myNumSubSpaces[2] > 0
myKnots : HArray1OfReal from TColStd ;
myMults : HArray1OfInteger from TColStd ;
myDegree : Integer ;
myEvaluator : Address from Standard;
--
-- The Errors
--
my1DMaxError : HArray1OfReal from TColStd ;
my1DAverageError : HArray1OfReal from TColStd ;
my2DMaxError : HArray1OfReal from TColStd ;
my2DAverageError : HArray1OfReal from TColStd ;
my3DMaxError : HArray1OfReal from TColStd ;
my3DAverageError : HArray1OfReal from TColStd ;
end ApproxAFunction ;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
// File: AdvApprox_ApproxAFunction.lxx
// Created: Wed May 31 15:27:05 1995
// Author: Xavier BENVENISTE
// <xab@nonox>
#include <Standard_ConstructionError.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean AdvApprox_ApproxAFunction::HasResult() const
{ return myHasResult ; }
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
inline Standard_Boolean AdvApprox_ApproxAFunction::IsDone() const
{ return myDone ; }
//=======================================================================
//function : Poles1d
//purpose :
//=======================================================================
inline Handle(TColStd_HArray2OfReal) AdvApprox_ApproxAFunction::Poles1d()
const
{ return my1DPoles ; }
//=======================================================================
//function : Poles2d
//purpose :
//=======================================================================
inline Handle(TColgp_HArray2OfPnt2d) AdvApprox_ApproxAFunction::Poles2d()
const
{ return my2DPoles ; }
//=======================================================================
//function : Poles
//purpose :
//=======================================================================
inline Handle(TColgp_HArray2OfPnt) AdvApprox_ApproxAFunction::Poles()
const
{ return my3DPoles ; }
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
inline Standard_Integer AdvApprox_ApproxAFunction::Degree() const
{ return myDegree ; }
//=======================================================================
//function : NbKnots
//purpose :
//=======================================================================
inline Standard_Integer AdvApprox_ApproxAFunction::NbKnots() const
{ return myKnots->Length() ; }
//=======================================================================
//function : Knots
//purpose :
//=======================================================================
inline Handle(TColStd_HArray1OfReal) AdvApprox_ApproxAFunction::Knots() const
{ return myKnots ; }
//=======================================================================
//function : Multiplicities
//purpose :
//=======================================================================
inline Handle(TColStd_HArray1OfInteger)
AdvApprox_ApproxAFunction::Multiplicities() const
{ return myMults ;}
//=======================================================================
//function : NumSubSpaces
//purpose :
//=======================================================================
inline Standard_Integer AdvApprox_ApproxAFunction::NumSubSpaces(const Standard_Integer Dimension) const
{ if (Dimension < 1 || Dimension > 3) Standard_ConstructionError::Raise() ;
return myNumSubSpaces[Dimension-1] ; }

View File

@@ -0,0 +1,21 @@
-- File: AdvApprox_Cutting.cdl
-- Created: Fri Apr 5 15:58:26 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
---Copyright: Matra Datavision 1996
---Purpose: to choose the way of cutting in approximation
deferred class Cutting from AdvApprox
is
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~AdvApprox_Cutting(){Delete();}"
Value(me; a,b : Real;
cuttingvalue : out Real)
returns Boolean
is deferred;
end Cutting;

View File

@@ -0,0 +1,10 @@
// File: AdvApprox_Cutting.cxx
// Created: Thu Apr 18 10:21:50 1996
// Author: Joelle CHAUVET
// <jct@sgi38>
#include <AdvApprox_Cutting.ixx>
void AdvApprox_Cutting::Delete()
{}

View File

@@ -0,0 +1,21 @@
-- File: AdvApprox_DichoCutting.cdl
-- Created: Fri Apr 5 17:08:30 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
---Copyright: Matra Datavision 1996
---Purpose :
-- if Cutting is necessary in [a,b], we cut at (a+b) / 2.
class DichoCutting from AdvApprox inherits Cutting from AdvApprox
uses Real from Standard
is
Create returns DichoCutting;
Value(me; a,b : Real;
cuttingvalue : out Real)
returns Boolean
is redefined;
end DichoCutting;

View File

@@ -0,0 +1,23 @@
// File: AdvApprox_DichoCutting.cxx
// Created: Wed Jul 3 15:34:08 1996
// Author: Joelle CHAUVET
// <jct@sgi38>
#include <AdvApprox_DichoCutting.ixx>
#include <Precision.hxx>
AdvApprox_DichoCutting::AdvApprox_DichoCutting()
{
}
Standard_Boolean AdvApprox_DichoCutting::Value(const Standard_Real a,
const Standard_Real b,
Standard_Real& cuttingvalue) const
{
// longueur minimum d'un intervalle pour F(U,V) : EPS1=1.e-9 (cf.MEPS1)
Standard_Real lgmin = 10*Precision::PConfusion();
cuttingvalue = (a+b) / 2;
return (Abs(b-a)>=2*lgmin);
}

View File

@@ -0,0 +1,59 @@
// File: AdvApprox_EvaluatorFunction.hxx
// Created: Mon May 29 17:04:50 1995
// Author: Xavier BENVENISTE
// <xab@nonox>
#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_PrimitiveTypes_HeaderFile
#include <Standard_PrimitiveTypes.hxx>
#endif
#ifndef _AdvApprox_EvaluatorFunction_HeaderFile
#define _AdvApprox_EvaluatorFunction_HeaderFile
// abv 01.04.2009: the C function pointer converted to a virtual class
// in order to get rid of usage of static functions and static data
//! Interface for a class implementing a function to be approximated
//! by AdvApprox_ApproxAFunction
class AdvApprox_EvaluatorFunction
{
public:
//! Empty constructor
AdvApprox_EvaluatorFunction () {}
//! Destructor should be declared as virtual
virtual ~AdvApprox_EvaluatorFunction () {}
//! Function evaluation method to be defined by descendant
virtual void Evaluate (Standard_Integer *Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode) = 0;
//! Shortcut for function-call style usage
void operator () (Standard_Integer *Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode)
{ Evaluate (Dimension, StartEnd, Parameter, DerivativeRequest, Result, ErrorCode); }
private:
//! Copy constructor is declared private to forbid copying
AdvApprox_EvaluatorFunction (const AdvApprox_EvaluatorFunction&) {}
//! Assignment operator is declared private to forbid copying
void operator = (const AdvApprox_EvaluatorFunction&) {}
};
#endif

View File

@@ -0,0 +1,44 @@
-- File: AdvApprox_PrefAndRec.cdl
-- Created: Thu Nov 14 11:29:36 1996
-- Author: Philippe MANGIN
-- <pmn@sgi29>
---Copyright: Matra Datavision 1996
class PrefAndRec from AdvApprox inherits Cutting from AdvApprox
---Purpose :
-- inherits class Cutting; contains a list of preferential points (pi)i
-- and a list of Recommended points used in cutting management.
uses Array1OfReal from TColStd
raises DomainError from Standard
is
Create(RecomendedCut : Array1OfReal;
PrefferedCut : Array1OfReal;
Weight : Real = 5 )
returns PrefAndRec
raises DomainError; -- if Weight <= 1
Value(me; a,b : Real;
cuttingvalue : out Real)
returns Boolean
---Purpose:
-- cuting value is
-- - the recommended point nerest of (a+b)/2
-- if pi is in ]a,b[ or else
-- - the preferential point nearest of (a+b) / 2
-- if pi is in ](r*a+b)/(r+1) , (a+r*b)/(r+1)[ where r = Weight
-- - or (a+b)/2 else.
is redefined;
fields
myRecCutting : Array1OfReal from TColStd;
myPrefCutting: Array1OfReal from TColStd;
myWeight : Real;
end PrefAndRec;

View File

@@ -0,0 +1,57 @@
// File: AdvApprox_PrefAndRec.cxx
// Created: Thu Nov 14 13:29:18 1996
// Author: Philippe MANGIN
// <pmn@sgi29>
#include <AdvApprox_PrefAndRec.ixx>
#include <Precision.hxx>
#include <Standard_DomainError.hxx>
AdvApprox_PrefAndRec::AdvApprox_PrefAndRec(const TColStd_Array1OfReal& RecCut,
const TColStd_Array1OfReal& PrefCut,
const Standard_Real Weight):
myRecCutting(1, RecCut.Length()),
myPrefCutting(1, PrefCut.Length()),
myWeight(Weight)
{
myRecCutting = RecCut;
myPrefCutting = PrefCut;
if (myWeight <= 1) { Standard_DomainError::Raise("PrefAndRec : Weight is too small");}
}
Standard_Boolean AdvApprox_PrefAndRec::Value(const Standard_Real a,
const Standard_Real b,
Standard_Real& cuttingvalue) const
{
// longueur minimum d'un intervalle parametrique : 10*PConfusion()
Standard_Real lgmin = 10 * Precision::PConfusion();
Standard_Integer i;
Standard_Real cut, mil=(a+b)/2, dist;
cut = mil;
// Recheche d'une decoupe preferentiel
dist = Abs( (a*myWeight+b)/(1+myWeight) - mil ) ;
for ( i=1; i<=myPrefCutting.Length(); i++) {
if ( dist > Abs(mil-myPrefCutting.Value(i))) {
cut = myPrefCutting.Value(i);
dist = Abs(mil-cut);
}
}
// Recheche d'une decoupe recommende
dist = Abs((a-b)/2);
for ( i=1; i<=myRecCutting.Length(); i++) {
if ((dist-lgmin) > Abs(mil-myRecCutting.Value(i))) {
cut = myRecCutting.Value(i);
dist = Abs(mil-cut);
}
}
// Resultat
cuttingvalue = cut;
return (Abs(cut-a)>=lgmin && Abs(b-cut)>=lgmin);
}

View File

@@ -0,0 +1,60 @@
-- File: AdvApprox_PrefCutting.cdl
-- Created: Fri Apr 5 17:15:04 1996
-- Author: Joelle CHAUVET
-- <jct@sgi38>
---Copyright: Matra Datavision 1996
--
---Purpose :
-- inherits class Cutting; contains a list of preferential points (di)i
-- if Cutting is necessary in [a,b], we cut at the di nearest from (a+b)/2.
class PrefCutting from AdvApprox inherits Cutting from AdvApprox
uses Array1OfReal from TColStd
is
Create(CutPnts : Array1OfReal) returns PrefCutting;
Value(me; a,b : Real;
cuttingvalue : out Real)
returns Boolean
is redefined;
fields
myPntOfCutting : Array1OfReal from TColStd;
end PrefCutting;

View File

@@ -0,0 +1,35 @@
// File: AdvApprox_PrefCutting.cxx
// Created: Wed Jul 3 15:34:08 1996
// Author: Joelle CHAUVET
// <jct@sgi38>
#include <AdvApprox_PrefCutting.ixx>
#include <Precision.hxx>
AdvApprox_PrefCutting::AdvApprox_PrefCutting(const TColStd_Array1OfReal& CutPnts):
myPntOfCutting(1, CutPnts.Length())
{
myPntOfCutting = CutPnts;
}
Standard_Boolean AdvApprox_PrefCutting::Value(const Standard_Real a,
const Standard_Real b,
Standard_Real& cuttingvalue) const
{
// longueur minimum d'un intervalle parametrique : PConfusion()
// pour F(U,V) : EPS1=1.e-9 (cf.MMEPS1)
Standard_Real lgmin = 10 * Precision::PConfusion();
Standard_Integer i;
Standard_Real cut, mil=(a+b)/2,
dist = Abs((a-b)/2);
cut = mil;
for ( i=myPntOfCutting.Lower(); i<= myPntOfCutting.Upper(); i++) {
if ((dist-lgmin) > Abs(mil-myPntOfCutting.Value(i))) {
cut = myPntOfCutting.Value(i);
dist = Abs(mil-myPntOfCutting.Value(i));
}
}
cuttingvalue = cut;
return (Abs(cut-a)>=lgmin && Abs(b-cut)>=lgmin);
}

View File

@@ -0,0 +1,113 @@
-- File: AdvApprox_SimpleApprox.cdl
-- Created: Mon Oct 14 18:05:03 1996
-- Author: Jeannine PANTIATICI
-- <jpi@sgi64>
---Copyright: Matra Datavision 1996
class SimpleApprox from AdvApprox
---Purpose: Approximate a function on an intervall [First,Last]
-- The result is a simple polynomial whose degree is as low as
-- possible to satisfy the required tolerance and the
-- maximum degree. The maximum error and the averrage error
-- resulting from approximating the function by the polynomial are computed
uses HArray1OfReal from TColStd,
HArray2OfReal from TColStd,
Array1OfReal from TColStd,
Array1OfInteger from TColStd,
Shape from GeomAbs,
Vector from math,
EvaluatorFunction from AdvApprox,
JacobiPolynomial from PLib
raises
OutOfRange from Standard,
ConstructionError from Standard
is
Create(TotalDimension : Integer ;
TotalNumSS : Integer ;
Continuity : Shape from GeomAbs ;
WorkDegree : Integer ;
NbGaussPoints : Integer ;
JacobiBase : JacobiPolynomial from PLib;
Func : EvaluatorFunction from AdvApprox)
returns SimpleApprox from AdvApprox
raises ConstructionError;
Perform(me:in out ;
LocalDimension : Array1OfInteger from TColStd;
LocalTolerancesArray: Array1OfReal from TColStd ;
First : Real ;
Last : Real ;
MaxDegree : Integer)
raises ConstructionError;
---Purpose: Constructs approximator tool.
--
-- Warning:
-- the Func should be valid reference to object of type
-- inherited from class EvaluatorFunction from Approx
-- with life time longer than that of the approximator tool;
--
IsDone(me)
returns Boolean;
Degree (me)
returns Integer;
Coefficients (me)
---Purpose: returns the coefficients in the Jacobi Base
returns HArray1OfReal from TColStd;
FirstConstr (me)
---Purpose: returns the constraints at First
returns HArray2OfReal from TColStd;
LastConstr (me)
---Purpose: returns the constraints at Last
returns HArray2OfReal from TColStd;
SomTab (me)
returns HArray1OfReal from TColStd;
DifTab (me)
returns HArray1OfReal from TColStd;
MaxError (me; Index : Integer)
returns Real;
AverageError (me; Index : Integer)
returns Real;
Dump(me; o: in out OStream);
---Purpose: display information on approximation
fields
myTotalNumSS : Integer;
myTotalDimension : Integer;
myNbGaussPoints : Integer;
myWorkDegree : Integer;
myNivConstr : Integer ;
myJacPol : JacobiPolynomial from PLib;
myTabPoints : HArray1OfReal from TColStd;
myTabWeights : HArray2OfReal from TColStd;
myEvaluator : Address from Standard;
myDegree : Integer;
myCoeff : HArray1OfReal from TColStd;
myFirstConstr : HArray2OfReal from TColStd;
myLastConstr : HArray2OfReal from TColStd;
mySomTab : HArray1OfReal from TColStd;
myDifTab : HArray1OfReal from TColStd;
myMaxError : HArray1OfReal from TColStd;
myAverageError : HArray1OfReal from TColStd;
done : Boolean;
end SimpleApprox;

View File

@@ -0,0 +1,375 @@
#define No_Standard_RangeError
#define No_Standard_OutOfRange
#include <AdvApprox_SimpleApprox.ixx>
#include <Standard_ConstructionError.hxx>
#include <AdvApprox_EvaluatorFunction.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <math_Vector.hxx>
#include <PLib.hxx>
#include <PLib_JacobiPolynomial.hxx>
//=======================================================================
//function : AdvApprox_SimpleApprox
//purpose :
//=======================================================================
AdvApprox_SimpleApprox::
AdvApprox_SimpleApprox(const Standard_Integer TotalDimension,
const Standard_Integer TotalNumSS,
const GeomAbs_Shape Continuity,
const Standard_Integer WorkDegree,
const Standard_Integer NbGaussPoints,
const Handle(PLib_JacobiPolynomial)& JacobiBase,
const AdvApprox_EvaluatorFunction& Func) :
myTotalNumSS(TotalNumSS),
myTotalDimension(TotalDimension),
myNbGaussPoints(NbGaussPoints),
myWorkDegree(WorkDegree),
myJacPol(JacobiBase),
myEvaluator((Standard_Address)&Func)
{
// the Check of input parameters
switch (Continuity) {
case GeomAbs_C0: myNivConstr = 0; break;
case GeomAbs_C1: myNivConstr = 1; break;
case GeomAbs_C2: myNivConstr = 2; break;
default:
Standard_ConstructionError::Raise("Invalid Continuity");
}
Standard_Integer DegreeQ = myWorkDegree - 2*(myNivConstr+1);
// the extraction of the Legendre roots
myTabPoints = new TColStd_HArray1OfReal(0,NbGaussPoints/2);
JacobiBase->Points(NbGaussPoints, myTabPoints->ChangeArray1());
// the extraction of the Gauss Weights
myTabWeights = new TColStd_HArray2OfReal(0,NbGaussPoints/2, 0,DegreeQ);
JacobiBase->Weights(NbGaussPoints, myTabWeights->ChangeArray2());
myCoeff = new TColStd_HArray1OfReal(0,(myWorkDegree+1)*myTotalDimension-1);
myFirstConstr = new TColStd_HArray2OfReal(1,myTotalDimension, 0,myNivConstr);
myLastConstr = new TColStd_HArray2OfReal(1,myTotalDimension, 0,myNivConstr);
mySomTab = new TColStd_HArray1OfReal(0,(myNbGaussPoints/2+1)*myTotalDimension-1);
myDifTab = new TColStd_HArray1OfReal(0,(myNbGaussPoints/2+1)*myTotalDimension-1);
done = Standard_False;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void AdvApprox_SimpleApprox::Perform(const TColStd_Array1OfInteger& LocalDimension,
const TColStd_Array1OfReal& LocalTolerancesArray,
const Standard_Real First,
const Standard_Real Last,
const Standard_Integer MaxDegree)
{
// ======= the computation of Pp(t) = Rr(t) + W(t)*Qq(t) =======
done = Standard_False;
Standard_Integer i,idim,k,numss;
Standard_Integer Dimension = myTotalDimension;
AdvApprox_EvaluatorFunction& Evaluator =
*(AdvApprox_EvaluatorFunction*)myEvaluator;
// ===== the computation of Rr(t) (the first part of Pp) ======
Standard_Integer DegreeR = 2*myNivConstr+1;
Standard_Integer DegreeQ = myWorkDegree - 2*(myNivConstr+1);
Standard_Real FirstLast[2];
FirstLast[0] = First;
FirstLast[1] = Last;
math_Vector Result(1,myTotalDimension);
Standard_Integer ErrorCode,derive,i_idim;
Standard_Real Fact=(Last-First)/2;
Standard_Real *pResult = (Standard_Real*) &Result.Value(1);
Standard_Real param;
for (param = First, derive = myNivConstr;
derive >= 0 ; derive--) {
Evaluator(&Dimension, FirstLast, &param, &derive, pResult, &ErrorCode);
if (ErrorCode != 0)
return; // Evaluation error
if (derive>=1) Result *= Fact;
if (derive==2) Result *= Fact;
for (idim=1; idim<=myTotalDimension; idim++) {
myFirstConstr->SetValue (idim,derive,Result(idim));
}
}
for (param = Last, derive = myNivConstr;
derive >= 0 ; derive--) {
Evaluator(&Dimension, FirstLast, &param, &derive, pResult, &ErrorCode);
if (ErrorCode != 0)
return; // Evaluation error
if (derive>=1) Result *= Fact;
if (derive==2) Result *= Fact;
for (idim=1; idim<=myTotalDimension; idim++) {
myLastConstr->SetValue (idim,derive,Result(idim));
}
}
PLib::HermiteInterpolate(myTotalDimension, -1., 1., myNivConstr, myNivConstr,
myFirstConstr->Array2(), myLastConstr->Array2(),
myCoeff->ChangeArray1());
// ===== the computation of the coefficients of Qq(t) (the second part of Pp) ======
math_Vector Fti (1,myTotalDimension);
math_Vector Rpti (1,myTotalDimension);
math_Vector Rmti (1,myTotalDimension);
Standard_Real *pFti = (Standard_Real*) &Fti.Value(1);
Standard_Real* Coef1 = (Standard_Real*) &(myCoeff->ChangeArray1().Value(0));
derive = 0;
Standard_Real ti, tip, tin, alin = (Last-First)/2, blin = (Last+First)/2.;
i_idim = myTotalDimension;
for (i=1; i<=myNbGaussPoints/2; i++) {
ti = myTabPoints->Value(i);
tip = alin*ti+blin;
Evaluator(&Dimension, FirstLast, &tip, &derive, pFti, &ErrorCode);
if (ErrorCode != 0)
return; // Evaluation error
for (idim=1; idim<=myTotalDimension; idim++) {
mySomTab->SetValue(i_idim,Fti(idim));
myDifTab->SetValue(i_idim,Fti(idim));
i_idim++;
}
}
i_idim = myTotalDimension;
for (i=1; i<=myNbGaussPoints/2; i++) {
ti = myTabPoints->Value(i);
tin = -alin*ti+blin;
Evaluator(&Dimension, FirstLast, &tin, &derive, pFti, &ErrorCode);
if (ErrorCode != 0)
return; // Evaluation error
PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension,
Coef1[0], Rpti(1));
ti = -ti;
PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension,
Coef1[0], Rmti(1));
for (idim=1; idim<=myTotalDimension; idim++) {
mySomTab->SetValue(i_idim, mySomTab->Value(i_idim) +
Fti(idim)- Rpti(idim) - Rmti(idim));
myDifTab->SetValue(i_idim, myDifTab->Value(i_idim) -
Fti(idim)- Rpti(idim) + Rmti(idim));
i_idim++;
}
}
// for odd NbGaussPoints - the computation of [ F(0) - R(0) ]
if (myNbGaussPoints % 2 == 1) {
ti = myTabPoints->Value(0);
tip = blin;
Evaluator(&Dimension, FirstLast, &tip, &derive, pFti, &ErrorCode);
if (ErrorCode != 0)
return; // Evaluation error
PLib::EvalPolynomial(ti, derive, DegreeR, myTotalDimension,
Coef1[0], Rpti(1));
for (idim=1; idim<=myTotalDimension; idim++) {
mySomTab->SetValue(idim-1, Fti(idim) - Rpti(idim));
myDifTab->SetValue(idim-1, Fti(idim) - Rpti(idim));
}
}
// the computation of Qq(t)
Standard_Real Sum;
for (k=0; k<=DegreeQ; k+=2) {
for (idim=1; idim<=myTotalDimension; idim++) {
Sum=0.;
for (i=1; i<=myNbGaussPoints/2; i++) {
Sum += myTabWeights->Value(i,k) * mySomTab->Value(i*myTotalDimension+idim-1);
}
myCoeff->SetValue((k+DegreeR+1)*myTotalDimension+idim-1,Sum);
}
}
for (k=1; k<=DegreeQ; k+=2) {
for (idim=1; idim<=myTotalDimension; idim++) {
Sum=0.;
for (i=1; i<=myNbGaussPoints/2; i++) {
Sum += myTabWeights->Value(i,k) * myDifTab->Value(i*myTotalDimension+idim-1);
}
myCoeff->SetValue((k+DegreeR+1)*myTotalDimension+idim-1,Sum);
}
}
if (myNbGaussPoints % 2 == 1) {
for (idim=1; idim<=myTotalDimension; idim++) {
for (k=0; k<=DegreeQ; k+=2) {
Sum += myTabWeights->Value(0,k) * mySomTab->Value(0*myTotalDimension+idim-1);
myCoeff->SetValue((k+DegreeR+1)*myTotalDimension+idim-1,Sum);
}
}
}
// for (i=0; i<(WorkDegree+1)*TotalDimension; i++)
// cout << " Coeff(" << i << ") = " << Coeff(i) << endl;
// the computing of NewDegree
TColStd_Array1OfReal JacCoeff(0, myTotalDimension*(myWorkDegree+1)-1);
Standard_Real MaxErr,AverageErr;
Standard_Integer Dim, RangSS, RangCoeff, RangJacCoeff, RangDim, NewDegree, NewDegreeMax = 0;
myMaxError = new TColStd_HArray1OfReal (1,myTotalNumSS);
myAverageError = new TColStd_HArray1OfReal (1,myTotalNumSS);
RangSS =0;
RangJacCoeff = 0 ;
for (numss=1; numss<=myTotalNumSS; numss++) {
Dim=LocalDimension(numss);
RangCoeff = 0;
RangDim = 0;
for (k=0; k<=myWorkDegree; k++) {
for (idim=1; idim<=Dim; idim++) {
JacCoeff(RangJacCoeff+RangDim+idim-1) =
myCoeff->Value(RangCoeff+ RangSS +idim-1);
}
RangDim =RangDim + Dim ;
RangCoeff = RangCoeff+myTotalDimension;
}
Standard_Real* JacSS = (Standard_Real*) &JacCoeff.Value(RangJacCoeff) ;
myJacPol->ReduceDegree(Dim,MaxDegree,LocalTolerancesArray(numss),
JacSS [0], NewDegree,MaxErr);
if (NewDegree > NewDegreeMax) NewDegreeMax = NewDegree;
RangSS = RangSS + Dim;
RangJacCoeff = RangJacCoeff + (myWorkDegree+1)* Dim;
}
// the computing of MaxError and AverageError
RangSS =0;
RangJacCoeff = 0 ;
for (numss=1; numss<=myTotalNumSS; numss++) {
Dim=LocalDimension(numss);
Standard_Real* JacSS = (Standard_Real*) &JacCoeff.Value(RangJacCoeff) ;
MaxErr=myJacPol->MaxError(LocalDimension(numss),JacSS [0],NewDegreeMax);
myMaxError->SetValue(numss,MaxErr);
AverageErr=myJacPol->AverageError(LocalDimension(numss),JacSS [0],NewDegreeMax);
myAverageError->SetValue(numss,AverageErr);
RangSS = RangSS + Dim;
RangJacCoeff = RangJacCoeff + (myWorkDegree+1)* Dim;
}
myDegree = NewDegreeMax;
done = Standard_True;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean AdvApprox_SimpleApprox::IsDone() const
{
return done;
}
//=======================================================================
//function : Degree
//purpose :
//=======================================================================
Standard_Integer AdvApprox_SimpleApprox::Degree() const
{
return myDegree;
}
//=======================================================================
//function : Coefficients
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) AdvApprox_SimpleApprox::Coefficients() const
{
return myCoeff;
}
//=======================================================================
//function : FirstConstr
//purpose :
//=======================================================================
Handle(TColStd_HArray2OfReal) AdvApprox_SimpleApprox::FirstConstr() const
{
return myFirstConstr;
}
//=======================================================================
//function : LastConstr
//purpose :
//=======================================================================
Handle(TColStd_HArray2OfReal) AdvApprox_SimpleApprox::LastConstr() const
{
return myLastConstr;
}
//=======================================================================
//function : SomTab
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) AdvApprox_SimpleApprox::SomTab() const
{
return mySomTab;
}
//=======================================================================
//function : DifTab
//purpose :
//=======================================================================
Handle(TColStd_HArray1OfReal) AdvApprox_SimpleApprox::DifTab() const
{
return myDifTab;
}
//=======================================================================
//function : MaxError
//purpose :
//=======================================================================
Standard_Real AdvApprox_SimpleApprox::MaxError(const Standard_Integer Index) const
{
return myMaxError->Value(Index);
}
//=======================================================================
//function : AverageError
//purpose :
//=======================================================================
Standard_Real AdvApprox_SimpleApprox::AverageError(const Standard_Integer Index) const
{
return myAverageError->Value(Index);
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void AdvApprox_SimpleApprox::Dump(Standard_OStream& o) const
{
Standard_Integer ii;
o << "Dump of SimpleApprox " << endl;
for (ii=1; ii <= myTotalNumSS; ii++) {
o << "Error " << MaxError(ii) << endl;
}
}

1
src/AdvApprox/FILES Executable file
View File

@@ -0,0 +1 @@
AdvApprox_EvaluatorFunction.hxx