1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +03:00

Coding - Add clang-format configuration #246

New clang-format configuration added to determinate code style.
The default version is 16.
Extend CMake to copy config file to build root.
Method/function separator deprecation:
  In case if function/method has declaration in header,
    definition must not have related comment.
    Only //==== [100 chars] ==== is allowed as a not connected
    separator.
  In case if function/method has  NOT declaration in header,
    definition must have related comment in doxygen style:
    // Descriptions
    // @param
    // @return
    Or just function/method separator:
    //==== [100 chars] ====
  All old separators with no description must be replaced to
    //==== [100 chars] ====
This commit is contained in:
dpasukhi 2025-01-06 12:35:56 +00:00
parent e9855c9335
commit fe1382f3c2
49 changed files with 5690 additions and 5029 deletions

40
.clang-format Normal file
View File

@ -0,0 +1,40 @@
# clang-format configuration file trying to apply OCCT coding style
#
# Clang formatting rules: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
# The clang-format npm package (https://github.com/angular/clang-format) uses
# a pre-built clang-format.exe from http://llvm.org/builds/
#
# We use defaults from the Microsoft style
BasedOnStyle: Microsoft
#
# Style options
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: Inline
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeTernaryOperators: true
ColumnLimit: 100
ContinuationIndentWidth: 2
IndentCaseLabels: true
IndentPPDirectives: BeforeHash
IndentWidth: 2
IndentWrappedFunctionNames: true
PackConstructorInitializers: Never
PointerAlignment: Left
ReferenceAlignment: Left
SeparateDefinitionBlocks: Always
SortIncludes: true
UseTab: Never
#
# OCCT specific settings
StatementMacros:
- Standard_FALLTHROUGH
TypenameMacros:
- Handle

View File

@ -723,6 +723,9 @@ endif()
# the name of the project
project (OCCT)
# copying clang-format file to the root of the project
file(COPY ${CMAKE_SOURCE_DIR}/.clang-format DESTINATION ${CMAKE_SOURCE_DIR})
# Get all used variables: OS_WITH_BIT, COMPILER
OCCT_MAKE_OS_WITH_BITNESS()
OCCT_MAKE_COMPILER_SHORT_NAME()

View File

@ -22,5 +22,4 @@
typedef NCollection_Array1<Handle(Adaptor3d_Surface)> Approx_Array1OfAdHSurface;
#endif

View File

@ -17,10 +17,9 @@
#ifndef Approx_Array1OfGTrsf2d_HeaderFile
#define Approx_Array1OfGTrsf2d_HeaderFile
#include <gp_GTrsf2d.hxx>
#include <NCollection_Array1.hxx>
#include <gp_GTrsf2d.hxx>
typedef NCollection_Array1<gp_GTrsf2d> Approx_Array1OfGTrsf2d;
#endif

View File

@ -14,7 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Adaptor2d_Curve2d.hxx>
#include <AdvApprox_ApproxAFunction.hxx>
#include <AdvApprox_PrefAndRec.hxx>
@ -23,57 +22,63 @@
#include <Precision.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
//=======================================================================
//class : Approx_Curve2d_Eval
//purpose: evaluator class for approximation
//=======================================================================
//=================================================================================================
class Approx_Curve2d_Eval : public AdvApprox_EvaluatorFunction
{
public:
Approx_Curve2d_Eval (const Handle(Adaptor2d_Curve2d)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_Curve2d_Eval(const Handle(Adaptor2d_Curve2d)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Adaptor2d_Curve2d) fonct;
Standard_Real StartEndSav[2];
};
void Approx_Curve2d_Eval::Evaluate (Standard_Integer *Dimension,
void Approx_Curve2d_Eval::Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Param, // Parameter at which evaluation
Standard_Integer *Order, // Derivative Request
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Param, // Parameter at which evaluation
Standard_Integer* Order, // Derivative Request
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real par = *Param;
// Dimension is incorrect
if (*Dimension!=2) {
// Dimension is incorrect
if (*Dimension != 2)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if ( par < StartEnd[0] || par > StartEnd[1] ) {
// Parameter is incorrect
if (par < StartEnd[0] || par > StartEnd[1])
{
*ErrorCode = 2;
}
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct = fonct->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct = fonct->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
gp_Pnt2d pnt;
gp_Vec2d v1, v2;
switch (*Order) {
switch (*Order)
{
case 0:
pnt = fonct->Value(par);
Result[0] = pnt.X();
@ -96,45 +101,61 @@ void Approx_Curve2d_Eval::Evaluate (Standard_Integer *Dimension,
}
}
Approx_Curve2d::Approx_Curve2d(const Handle(Adaptor2d_Curve2d)& C2D,const Standard_Real First,const Standard_Real Last,const Standard_Real TolU,const Standard_Real TolV,const GeomAbs_Shape Continuity,const Standard_Integer MaxDegree,const Standard_Integer MaxSegments)
Approx_Curve2d::Approx_Curve2d(const Handle(Adaptor2d_Curve2d)& C2D,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real TolU,
const Standard_Real TolV,
const GeomAbs_Shape Continuity,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments)
{
C2D->Trim(First,Last,Precision::PConfusion());
C2D->Trim(First, Last, Precision::PConfusion());
Standard_Integer Num1DSS=2, Num2DSS=0, Num3DSS=0;
Standard_Integer Num1DSS = 2, Num2DSS = 0, Num3DSS = 0;
Handle(TColStd_HArray1OfReal) TwoDTolNul, ThreeDTolNul;
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1, Num1DSS);
OneDTol->ChangeValue(1) = TolU;
OneDTol->ChangeValue(2) = TolV;
Standard_Integer NbInterv_C2 = C2D->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
C2D->Intervals(CutPnts_C2, GeomAbs_C2);
Standard_Integer NbInterv_C3 = C2D->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
C2D->Intervals(CutPnts_C3, GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2, CutPnts_C3);
myMaxError2dU = 0;
myMaxError2dV = 0;
Approx_Curve2d_Eval ev (C2D, First, Last);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTolNul,
First, Last, Continuity,
MaxDegree, MaxSegments,
ev, CutTool);
Approx_Curve2d_Eval ev(C2D, First, Last);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTol,
TwoDTolNul,
ThreeDTolNul,
First,
Last,
Continuity,
MaxDegree,
MaxSegments,
ev,
CutTool);
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
if (myHasResult)
{
TColgp_Array1OfPnt2d Poles2d(1, aApprox.NbPoles());
TColStd_Array1OfReal Poles1dU(1, aApprox.NbPoles());
aApprox.Poles1d(1, Poles1dU);
TColStd_Array1OfReal Poles1dV(1,aApprox.NbPoles());
TColStd_Array1OfReal Poles1dV(1, aApprox.NbPoles());
aApprox.Poles1d(2, Poles1dV);
for(Standard_Integer i = 1; i <= aApprox.NbPoles(); i++)
for (Standard_Integer i = 1; i <= aApprox.NbPoles(); i++)
Poles2d.SetValue(i, gp_Pnt2d(Poles1dU.Value(i), Poles1dV.Value(i)));
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
@ -146,27 +167,27 @@ void Approx_Curve2d_Eval::Evaluate (Standard_Integer *Dimension,
}
}
Standard_Boolean Approx_Curve2d::IsDone() const
Standard_Boolean Approx_Curve2d::IsDone() const
{
return myIsDone;
}
Standard_Boolean Approx_Curve2d::HasResult() const
Standard_Boolean Approx_Curve2d::HasResult() const
{
return myHasResult;
}
Handle(Geom2d_BSplineCurve) Approx_Curve2d::Curve() const
Handle(Geom2d_BSplineCurve) Approx_Curve2d::Curve() const
{
return myCurve;
}
Standard_Real Approx_Curve2d::MaxError2dU() const
Standard_Real Approx_Curve2d::MaxError2dU() const
{
return myMaxError2dU;
}
Standard_Real Approx_Curve2d::MaxError2dV() const
Standard_Real Approx_Curve2d::MaxError2dV() const
{
return myMaxError2dV;
}

View File

@ -18,18 +18,23 @@
#define _Approx_Curve2d_HeaderFile
#include <Adaptor2d_Curve2d.hxx>
#include <GeomAbs_Shape.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <GeomAbs_Shape.hxx>
//! Makes an approximation for HCurve2d from Adaptor3d
class Approx_Curve2d
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT Approx_Curve2d(const Handle(Adaptor2d_Curve2d)& C2D, const Standard_Real First, const Standard_Real Last, const Standard_Real TolU, const Standard_Real TolV, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments);
Standard_EXPORT Approx_Curve2d(const Handle(Adaptor2d_Curve2d)& C2D,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real TolU,
const Standard_Real TolV,
const GeomAbs_Shape Continuity,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments);
Standard_EXPORT Standard_Boolean IsDone() const;
@ -42,13 +47,11 @@ public:
Standard_EXPORT Standard_Real MaxError2dV() const;
private:
Handle(Geom2d_BSplineCurve) myCurve;
Standard_Boolean myIsDone;
Standard_Boolean myHasResult;
Standard_Real myMaxError2dU;
Standard_Real myMaxError2dV;
};
#endif // _Approx_Curve2d_HeaderFile

View File

@ -19,63 +19,68 @@
#include <Adaptor3d_Curve.hxx>
#include <AdvApprox_ApproxAFunction.hxx>
#include <AdvApprox_PrefAndRec.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Precision.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_HArray1OfReal.hxx>
//=======================================================================
//class : Approx_Curve3d_Eval
//purpose: evaluator class for approximation
//=======================================================================
//=================================================================================================
class Approx_Curve3d_Eval : public AdvApprox_EvaluatorFunction
{
public:
Approx_Curve3d_Eval (const Handle(Adaptor3d_Curve)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_Curve3d_Eval(const Handle(Adaptor3d_Curve)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Adaptor3d_Curve) fonct;
Standard_Real StartEndSav[2];
};
void Approx_Curve3d_Eval::Evaluate (Standard_Integer *Dimension,
void Approx_Curve3d_Eval::Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Param, // Parameter at which evaluation
Standard_Integer *Order, // Derivative Request
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Param, // Parameter at which evaluation
Standard_Integer* Order, // Derivative Request
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real par = *Param;
// Dimension is incorrect
if (*Dimension!=3) {
// Dimension is incorrect
if (*Dimension != 3)
{
*ErrorCode = 1;
}
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct = fonct->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct = fonct->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
gp_Pnt pnt;
gp_Vec v1, v2;
switch (*Order) {
switch (*Order)
{
case 0:
pnt = fonct->Value(par);
Result[0] = pnt.X();
@ -109,39 +114,47 @@ Approx_Curve3d::Approx_Curve3d(const Handle(Adaptor3d_Curve)& Curve,
{
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=0, Num2DSS=0, Num3DSS=1;
Standard_Integer Num1DSS = 0, Num2DSS = 0, Num3DSS = 1;
Handle(TColStd_HArray1OfReal) OneDTolNul, TwoDTolNul;
Handle(TColStd_HArray1OfReal) ThreeDTol =
new TColStd_HArray1OfReal(1,Num3DSS);
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1, Num3DSS);
ThreeDTol->Init(Tol3d);
Standard_Real First = Curve->FirstParameter();
Standard_Real Last = Curve->LastParameter();
Standard_Integer NbInterv_C2 = Curve->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
Curve->Intervals(CutPnts_C2,GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
Curve->Intervals(CutPnts_C2, GeomAbs_C2);
Standard_Integer NbInterv_C3 = Curve->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
Curve->Intervals(CutPnts_C3,GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
Curve->Intervals(CutPnts_C3, GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2, CutPnts_C3);
myMaxError = 0;
Approx_Curve3d_Eval ev (Curve, First, Last);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTolNul, TwoDTolNul, ThreeDTol,
First, Last, Order,
MaxDegree, MaxSegments,
ev, CutTool);
Approx_Curve3d_Eval ev(Curve, First, Last);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTolNul,
TwoDTolNul,
ThreeDTol,
First,
Last,
Order,
MaxDegree,
MaxSegments,
ev,
CutTool);
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
aApprox.Poles(1,Poles);
if (myHasResult)
{
TColgp_Array1OfPnt Poles(1, aApprox.NbPoles());
aApprox.Poles(1, Poles);
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
Standard_Integer Degree = aApprox.Degree();
@ -150,27 +163,27 @@ Approx_Curve3d::Approx_Curve3d(const Handle(Adaptor3d_Curve)& Curve,
}
}
Handle(Geom_BSplineCurve) Approx_Curve3d::Curve() const
Handle(Geom_BSplineCurve) Approx_Curve3d::Curve() const
{
return myBSplCurve;
}
Standard_Boolean Approx_Curve3d::IsDone() const
Standard_Boolean Approx_Curve3d::IsDone() const
{
return myIsDone;
}
Standard_Boolean Approx_Curve3d::HasResult() const
Standard_Boolean Approx_Curve3d::HasResult() const
{
return myHasResult;
}
Standard_Real Approx_Curve3d::MaxError() const
Standard_Real Approx_Curve3d::MaxError() const
{
return myMaxError;
}
void Approx_Curve3d::Dump(Standard_OStream& o) const
void Approx_Curve3d::Dump(Standard_OStream& o) const
{
o << "******* Dump of ApproxCurve *******" << std::endl;
o << "*******Degree " << Curve()->Degree() << std::endl;

View File

@ -24,13 +24,15 @@
class Approx_Curve3d
{
public:
DEFINE_STANDARD_ALLOC
//! Approximation of a curve with respect of the
//! required tolerance Tol3D.
Standard_EXPORT Approx_Curve3d(const Handle(Adaptor3d_Curve)& Curve, const Standard_Real Tol3d, const GeomAbs_Shape Order, const Standard_Integer MaxSegments, const Standard_Integer MaxDegree);
Standard_EXPORT Approx_Curve3d(const Handle(Adaptor3d_Curve)& Curve,
const Standard_Real Tol3d,
const GeomAbs_Shape Order,
const Standard_Integer MaxSegments,
const Standard_Integer MaxDegree);
Standard_EXPORT Handle(Geom_BSplineCurve) Curve() const;
@ -48,15 +50,13 @@ public:
Standard_EXPORT Standard_Real MaxError() const;
//! Print on the stream o information about the object
Standard_EXPORT void Dump (Standard_OStream& o) const;
Standard_EXPORT void Dump(Standard_OStream& o) const;
private:
Standard_Boolean myIsDone;
Standard_Boolean myHasResult;
Handle(Geom_BSplineCurve) myBSplCurve;
Standard_Real myMaxError;
};
#endif // _Approx_Curve3d_HeaderFile

View File

@ -24,82 +24,84 @@
#include <AdvApprox_ApproxAFunction.hxx>
#include <AdvApprox_DichoCutting.hxx>
#include <AdvApprox_PrefAndRec.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomConvert.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Precision.hxx>
#include <Standard_ConstructionError.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <gp_Lin2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Precision.hxx>
#include <Standard_ConstructionError.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
//=======================================================================
//class : Approx_CurveOnSurface_Eval
//purpose: evaluator class for approximation of both 2d and 3d curves
//=======================================================================
//=================================================================================================
class Approx_CurveOnSurface_Eval : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurveOnSurface_Eval (const Handle(Adaptor3d_Curve)& theFunc,
public:
Approx_CurveOnSurface_Eval(const Handle(Adaptor3d_Curve)& theFunc,
const Handle(Adaptor2d_Curve2d)& theFunc2d,
Standard_Real First, Standard_Real Last)
: fonct(theFunc), fonct2d(theFunc2d)
{ StartEndSav[0] = First; StartEndSav[1] = Last; }
Standard_Real First,
Standard_Real Last)
: fonct(theFunc),
fonct2d(theFunc2d)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Adaptor3d_Curve) fonct;
Handle(Adaptor2d_Curve2d) fonct2d;
Standard_Real StartEndSav[2];
};
void Approx_CurveOnSurface_Eval::Evaluate (Standard_Integer *Dimension,
void Approx_CurveOnSurface_Eval::Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Param, // Parameter at which evaluation
Standard_Integer *Order, // Derivative Request
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Param, // Parameter at which evaluation
Standard_Integer* Order, // Derivative Request
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real par = *Param;
// Dimension is incorrect
if (*Dimension != 5) {
// Dimension is incorrect
if (*Dimension != 5)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
// Parameter is incorrect
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct = fonct->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
fonct2d = fonct2d->Trim(StartEnd[0],StartEnd[1],
Precision::PConfusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct = fonct->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
fonct2d = fonct2d->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
gp_Pnt pnt;
gp_Pnt2d pnt2d;
switch (*Order) {
case 0:
switch (*Order)
{
case 0: {
fonct2d->D0(par, pnt2d);
fonct->D0(par, pnt);
Result[0] = pnt2d.X();
@ -109,12 +111,11 @@ void Approx_CurveOnSurface_Eval::Evaluate (Standard_Integer *Dimension,
Result[4] = pnt.Z();
break;
}
case 1:
{
case 1: {
gp_Vec v1;
gp_Vec2d v21;
fonct2d->D1(par, pnt2d, v21);
fonct->D1(par,pnt, v1);
fonct->D1(par, pnt, v1);
Result[0] = v21.X();
Result[1] = v21.Y();
Result[2] = v1.X();
@ -122,8 +123,7 @@ void Approx_CurveOnSurface_Eval::Evaluate (Standard_Integer *Dimension,
Result[4] = v1.Z();
break;
}
case 2:
{
case 2: {
gp_Vec v1, v2;
gp_Vec2d v21, v22;
fonct2d->D2(par, pnt2d, v21, v22);
@ -142,64 +142,67 @@ void Approx_CurveOnSurface_Eval::Evaluate (Standard_Integer *Dimension,
}
}
//=======================================================================
//class : Approx_CurveOnSurface_Eval3d
//purpose: evaluator class for approximation of 3d curve
//=======================================================================
//=================================================================================================
class Approx_CurveOnSurface_Eval3d : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurveOnSurface_Eval3d (const Handle(Adaptor3d_Curve)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_CurveOnSurface_Eval3d(const Handle(Adaptor3d_Curve)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Adaptor3d_Curve) fonct;
Standard_Real StartEndSav[2];
};
void Approx_CurveOnSurface_Eval3d::Evaluate (Standard_Integer *Dimension,
void Approx_CurveOnSurface_Eval3d::Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Param, // Parameter at which evaluation
Standard_Integer *Order, // Derivative Request
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Param, // Parameter at which evaluation
Standard_Integer* Order, // Derivative Request
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real par = *Param;
// Dimension is incorrect
if (*Dimension != 3) {
// Dimension is incorrect
if (*Dimension != 3)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
// Parameter is incorrect
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct = fonct->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct = fonct->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
gp_Pnt pnt;
switch (*Order) {
switch (*Order)
{
case 0:
pnt = fonct->Value(par);
Result[0] = pnt.X();
Result[1] = pnt.Y();
Result[2] = pnt.Z();
break;
case 1:
{
case 1: {
gp_Vec v1;
fonct->D1(par, pnt, v1);
Result[0] = v1.X();
@ -207,8 +210,7 @@ void Approx_CurveOnSurface_Eval3d::Evaluate (Standard_Integer *Dimension,
Result[2] = v1.Z();
break;
}
case 2:
{
case 2: {
gp_Vec v1, v2;
fonct->D2(par, pnt, v1, v2);
Result[0] = v2.X();
@ -223,73 +225,74 @@ void Approx_CurveOnSurface_Eval3d::Evaluate (Standard_Integer *Dimension,
}
}
//=======================================================================
//class : Approx_CurveOnSurface_Eval2d
//purpose: evaluator class for approximation of 2d curve
//=======================================================================
//=================================================================================================
class Approx_CurveOnSurface_Eval2d : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurveOnSurface_Eval2d (const Handle(Adaptor2d_Curve2d)& theFunc2d,
Standard_Real First, Standard_Real Last)
: fonct2d(theFunc2d) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_CurveOnSurface_Eval2d(const Handle(Adaptor2d_Curve2d)& theFunc2d,
Standard_Real First,
Standard_Real Last)
: fonct2d(theFunc2d)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Adaptor2d_Curve2d) fonct2d;
Standard_Real StartEndSav[2];
};
void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
void Approx_CurveOnSurface_Eval2d::Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Param, // Parameter at which evaluation
Standard_Integer *Order, // Derivative Request
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Param, // Parameter at which evaluation
Standard_Integer* Order, // Derivative Request
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real par = *Param;
// Dimension is incorrect
if (*Dimension != 2) {
// Dimension is incorrect
if (*Dimension != 2)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
// Parameter is incorrect
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct2d = fonct2d->Trim(StartEnd[0],StartEnd[1],Precision::PConfusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct2d = fonct2d->Trim(StartEnd[0], StartEnd[1], Precision::PConfusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
gp_Pnt2d pnt;
switch (*Order) {
case 0:
switch (*Order)
{
case 0: {
pnt = fonct2d->Value(par);
Result[0] = pnt.X();
Result[1] = pnt.Y();
break;
}
case 1:
{
case 1: {
gp_Vec2d v1;
fonct2d->D1(par, pnt, v1);
Result[0] = v1.X();
Result[1] = v1.Y();
break;
}
case 2:
{
case 2: {
gp_Vec2d v1, v2;
fonct2d->D2(par, pnt, v1, v2);
Result[0] = v2.X();
@ -303,11 +306,9 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
}
}
//=============================================================================
//function : Approx_CurveOnSurface
//purpose : Constructor
//=============================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& C2D,
//=================================================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& Surf,
const Standard_Real First,
const Standard_Real Last,
@ -317,7 +318,7 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
const Standard_Integer MaxSegments,
const Standard_Boolean only3d,
const Standard_Boolean only2d)
: myC2D(C2D),
: myC2D(C2D),
mySurf(Surf),
myFirst(First),
myLast(Last),
@ -327,20 +328,18 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
myError3d(0.0),
myError2dU(0.0),
myError2dV(0.0)
{
{
Perform(MaxSegments, MaxDegree, S, only3d, only2d);
}
}
//=============================================================================
//function : Approx_CurveOnSurface
//purpose : Constructor
//=============================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& theC2D,
//=================================================================================================
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& theC2D,
const Handle(Adaptor3d_Surface)& theSurf,
const Standard_Real theFirst,
const Standard_Real theLast,
const Standard_Real theTol)
: myC2D(theC2D),
: myC2D(theC2D),
mySurf(theSurf),
myFirst(theFirst),
myLast(theLast),
@ -353,10 +352,8 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
{
}
//=============================================================================
//function : Perform
//purpose :
//=============================================================================
//=================================================================================================
void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
const Standard_Integer theMaxDegree,
const GeomAbs_Shape theContinuity,
@ -369,7 +366,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
myError2dV = 0.0;
myError3d = 0.0;
if(theOnly3d && theOnly2d) throw Standard_ConstructionError();
if (theOnly3d && theOnly2d)
throw Standard_ConstructionError();
GeomAbs_Shape aContinuity = theContinuity;
if (aContinuity == GeomAbs_G1)
@ -377,9 +375,9 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
else if (aContinuity == GeomAbs_G2)
aContinuity = GeomAbs_C2;
else if (aContinuity > GeomAbs_C2)
aContinuity = GeomAbs_C2; //Restriction of AdvApprox_ApproxAFunction
aContinuity = GeomAbs_C2; // Restriction of AdvApprox_ApproxAFunction
Handle( Adaptor2d_Curve2d ) TrimmedC2D = myC2D->Trim( myFirst, myLast, Precision::PConfusion() );
Handle(Adaptor2d_Curve2d) TrimmedC2D = myC2D->Trim(myFirst, myLast, Precision::PConfusion());
Standard_Boolean isU, isForward;
Standard_Real aParam;
@ -393,26 +391,30 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
}
}
Handle(Adaptor3d_CurveOnSurface) HCOnS = new Adaptor3d_CurveOnSurface (TrimmedC2D, mySurf);
Handle(Adaptor3d_CurveOnSurface) HCOnS = new Adaptor3d_CurveOnSurface(TrimmedC2D, mySurf);
Standard_Integer Num1DSS = 0, Num2DSS=0, Num3DSS=0;
Standard_Integer Num1DSS = 0, Num2DSS = 0, Num3DSS = 0;
Handle(TColStd_HArray1OfReal) OneDTol;
Handle(TColStd_HArray1OfReal) TwoDTolNul;
Handle(TColStd_HArray1OfReal) ThreeDTol;
// create evaluators and choose appropriate one
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, myFirst, myLast);
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, myFirst, myLast);
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, myFirst, myLast);
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf(HCOnS, myFirst, myLast);
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf(TrimmedC2D, myFirst, myLast);
Approx_CurveOnSurface_Eval EvalCvOnSurf(HCOnS, TrimmedC2D, myFirst, myLast);
AdvApprox_EvaluatorFunction* EvalPtr;
if ( theOnly3d ) EvalPtr = &Eval3dCvOnSurf;
else if ( theOnly2d ) EvalPtr = &Eval2dCvOnSurf;
else EvalPtr = &EvalCvOnSurf;
if (theOnly3d)
EvalPtr = &Eval3dCvOnSurf;
else if (theOnly2d)
EvalPtr = &Eval2dCvOnSurf;
else
EvalPtr = &EvalCvOnSurf;
// Initialization for 2d approximation
if(!theOnly3d) {
if (!theOnly3d)
{
Num1DSS = 2;
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
OneDTol = new TColStd_HArray1OfReal(1, Num1DSS);
Standard_Real TolU, TolV;
@ -435,21 +437,21 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
TolV = Min(1.e-3, 1.e2 * TolV);
}
OneDTol->SetValue(1,TolU);
OneDTol->SetValue(2,TolV);
OneDTol->SetValue(1, TolU);
OneDTol->SetValue(2, TolV);
}
if(!theOnly2d) {
Num3DSS=1;
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
ThreeDTol->Init(myTol/2);
if (!theOnly2d)
{
Num3DSS = 1;
ThreeDTol = new TColStd_HArray1OfReal(1, Num3DSS);
ThreeDTol->Init(myTol / 2);
}
AdvApprox_Cutting* CutTool;
if (aContinuity <= myC2D->Continuity() &&
aContinuity <= mySurf->UContinuity() &&
aContinuity <= mySurf->VContinuity())
if (aContinuity <= myC2D->Continuity() && aContinuity <= mySurf->UContinuity()
&& aContinuity <= mySurf->VContinuity())
{
CutTool = new AdvApprox_DichoCutting();
}
@ -462,7 +464,7 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
HCOnS->Intervals(CutPnts_C2, GeomAbs_C2);
CutTool = new AdvApprox_PrefAndRec (CutPnts_C1, CutPnts_C2);
CutTool = new AdvApprox_PrefAndRec(CutPnts_C1, CutPnts_C2);
}
else
{
@ -473,40 +475,49 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
HCOnS->Intervals(CutPnts_C3, GeomAbs_C3);
CutTool = new AdvApprox_PrefAndRec (CutPnts_C2, CutPnts_C3);
CutTool = new AdvApprox_PrefAndRec(CutPnts_C2, CutPnts_C3);
}
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTol,
myFirst, myLast, aContinuity,
theMaxDegree, theMaxSegments,
*EvalPtr, *CutTool);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTol,
TwoDTolNul,
ThreeDTol,
myFirst,
myLast,
aContinuity,
theMaxDegree,
theMaxSegments,
*EvalPtr,
*CutTool);
delete CutTool;
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
if (myHasResult)
{
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
Standard_Integer Degree = aApprox.Degree();
if(!theOnly2d)
if (!theOnly2d)
{
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
aApprox.Poles(1,Poles);
TColgp_Array1OfPnt Poles(1, aApprox.NbPoles());
aApprox.Poles(1, Poles);
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
myError3d = aApprox.MaxError(3, 1);
}
if(!theOnly3d)
if (!theOnly3d)
{
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
TColgp_Array1OfPnt2d Poles2d(1, aApprox.NbPoles());
TColStd_Array1OfReal Poles1dU(1, aApprox.NbPoles());
aApprox.Poles1d(1, Poles1dU);
TColStd_Array1OfReal Poles1dV(1,aApprox.NbPoles());
TColStd_Array1OfReal Poles1dV(1, aApprox.NbPoles());
aApprox.Poles1d(2, Poles1dV);
for(Standard_Integer i = 1; i <= aApprox.NbPoles(); i++)
for (Standard_Integer i = 1; i <= aApprox.NbPoles(); i++)
Poles2d.SetValue(i, gp_Pnt2d(Poles1dU.Value(i), Poles1dV.Value(i)));
myCurve2d = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree);
@ -514,48 +525,45 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
myError2dV = aApprox.MaxError(1, 2);
}
}
}
Standard_Boolean Approx_CurveOnSurface::IsDone() const
Standard_Boolean Approx_CurveOnSurface::IsDone() const
{
return myIsDone;
}
Standard_Boolean Approx_CurveOnSurface::HasResult() const
Standard_Boolean Approx_CurveOnSurface::HasResult() const
{
return myHasResult;
}
Handle(Geom_BSplineCurve) Approx_CurveOnSurface::Curve3d() const
Handle(Geom_BSplineCurve) Approx_CurveOnSurface::Curve3d() const
{
return myCurve3d;
}
Handle(Geom2d_BSplineCurve) Approx_CurveOnSurface::Curve2d() const
Handle(Geom2d_BSplineCurve) Approx_CurveOnSurface::Curve2d() const
{
return myCurve2d;
}
Standard_Real Approx_CurveOnSurface::MaxError3d() const
Standard_Real Approx_CurveOnSurface::MaxError3d() const
{
return myError3d;
}
Standard_Real Approx_CurveOnSurface::MaxError2dU() const
Standard_Real Approx_CurveOnSurface::MaxError2dU() const
{
return myError2dU;
}
Standard_Real Approx_CurveOnSurface::MaxError2dV() const
Standard_Real Approx_CurveOnSurface::MaxError2dV() const
{
return myError2dV;
}
//=============================================================================
//function : isIsoLine
//purpose :
//=============================================================================
//=================================================================================================
Standard_Boolean Approx_CurveOnSurface::isIsoLine(const Handle(Adaptor2d_Curve2d)& theC2D,
Standard_Boolean& theIsU,
Standard_Real& theParam,
@ -634,10 +642,8 @@ Standard_Boolean Approx_CurveOnSurface::isIsoLine(const Handle(Adaptor2d_Curve2d
#include <GeomLib.hxx>
//=============================================================================
//function : buildC3dOnIsoLine
//purpose :
//=============================================================================
//=================================================================================================
Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d_Curve2d)& theC2D,
const Standard_Boolean theIsU,
const Standard_Real theParam,
@ -740,7 +746,7 @@ Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d
const Standard_Real aParF = myFirst;
const Standard_Real aParL = myLast;
const Standard_Integer aNbPnt = 23;
for(Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
for (Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
{
const Standard_Real aPar = aParF + ((aParL - aParF) * anIdx) / aNbPnt;

View File

@ -28,12 +28,21 @@ class Geom2d_BSplineCurve;
class Approx_CurveOnSurface
{
public:
DEFINE_STANDARD_ALLOC
//! This constructor calls perform method. This constructor is deprecated.
Standard_DEPRECATED("This constructor is deprecated. Use other constructor and perform method instead.")
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& C2D, const Handle(Adaptor3d_Surface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
Standard_DEPRECATED(
"This constructor is deprecated. Use other constructor and perform method instead.")
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& Surf,
const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol,
const GeomAbs_Shape Continuity,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments,
const Standard_Boolean Only3d = Standard_False,
const Standard_Boolean Only2d = Standard_False);
//! This constructor does not call perform method.
//! @param theC2D 2D Curve to be approximated in 3D.
@ -77,7 +86,6 @@ public:
const Standard_Boolean theOnly2d = Standard_False);
protected:
//! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
//! or geometric line. This line should have natural parameterization.
//! @param theC2D Trimmed curve to be checked.
@ -103,10 +111,9 @@ protected:
const Standard_Boolean theIsForward);
private:
Approx_CurveOnSurface& operator= (const Approx_CurveOnSurface&);
Approx_CurveOnSurface& operator=(const Approx_CurveOnSurface&);
private:
//! Input curve.
const Handle(Adaptor2d_Curve2d) myC2D;
@ -129,7 +136,6 @@ private:
Standard_Real myError3d;
Standard_Real myError2dU;
Standard_Real myError2dV;
};
#endif // _Approx_CurveOnSurface_HeaderFile

View File

@ -23,101 +23,107 @@
#include <AdvApprox_PrefAndRec.hxx>
#include <Approx_CurvlinFunc.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <GeomAbs_Shape.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec.hxx>
#include <math_Vector.hxx>
#include <Precision.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#ifdef OCCT_DEBUG_CHRONO
#include <OSD_Timer.hxx>
#include <OSD_Timer.hxx>
static OSD_Chronometer chr_total, chr_init, chr_approx;
Standard_Real t_total, t_init, t_approx;
void InitChron(OSD_Chronometer& ch)
{
ch.Reset();
ch.Start();
}
void ResultChron( OSD_Chronometer & ch, Standard_Real & time)
void ResultChron(OSD_Chronometer& ch, Standard_Real& time)
{
Standard_Real tch ;
Standard_Real tch;
ch.Stop();
ch.Show(tch);
time=time +tch;
time = time + tch;
}
Standard_IMPORT Standard_Integer uparam_count;
Standard_IMPORT Standard_Real t_uparam;
#endif
//=======================================================================
//class : Approx_CurvilinearParameter_EvalCurv
//purpose : case of a free 3D curve
//=======================================================================
//=================================================================================================
class Approx_CurvilinearParameter_EvalCurv : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurvilinearParameter_EvalCurv (const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_CurvilinearParameter_EvalCurv(const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Approx_CurvlinFunc) fonct;
Standard_Real StartEndSav[2];
};
void Approx_CurvilinearParameter_EvalCurv::Evaluate (Standard_Integer * Dimension,
Standard_Real * StartEnd,
Standard_Real * Param,
Standard_Integer * Order,
Standard_Real * Result,
Standard_Integer * ErrorCode)
void Approx_CurvilinearParameter_EvalCurv::Evaluate(Standard_Integer* Dimension,
Standard_Real* StartEnd,
Standard_Real* Param,
Standard_Integer* Order,
Standard_Real* Result,
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real S = *Param;
TColStd_Array1OfReal Res(0, 2);
Standard_Integer i;
// Dimension is incorrect
if (*Dimension != 3) {
// Dimension is incorrect
if (*Dimension != 3)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if ( S < StartEnd[0] || S > StartEnd[1] ) {
// Parameter is incorrect
if (S < StartEnd[0] || S > StartEnd[1])
{
*ErrorCode = 2;
}
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct->Trim(StartEnd[0],StartEnd[1], Precision::Confusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct->Trim(StartEnd[0], StartEnd[1], Precision::Confusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
if(!fonct->EvalCase1(S, *Order, Res)) {
if (!fonct->EvalCase1(S, *Order, Res))
{
*ErrorCode = 3;
}
for(i = 0; i <= 2; i++)
for (i = 0; i <= 2; i++)
Result[i] = Res(i);
}
@ -126,7 +132,7 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_
const GeomAbs_Shape Order,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments)
: myMaxError2d1(0.0),
: myMaxError2d1(0.0),
myMaxError2d2(0.0)
{
#ifdef OCCT_DEBUG_CHRONO
@ -135,17 +141,17 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_
InitChron(chr_total);
#endif
myCase = 1;
// Initialisation of input parameters of AdvApprox
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=0, Num2DSS=0, Num3DSS=1;
Standard_Integer Num1DSS = 0, Num2DSS = 0, Num3DSS = 1;
Handle(TColStd_HArray1OfReal) OneDTolNul, TwoDTolNul;
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1, Num3DSS);
ThreeDTol->Init(Tol);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_init);
#endif
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C3D, Tol/10);
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C3D, Tol / 10);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_init, t_init);
#endif
@ -154,23 +160,31 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_
Standard_Real LastS = fonct->LastParameter();
Standard_Integer NbInterv_C2 = fonct->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
fonct->Intervals(CutPnts_C2,GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
fonct->Intervals(CutPnts_C2, GeomAbs_C2);
Standard_Integer NbInterv_C3 = fonct->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
fonct->Intervals(CutPnts_C3,GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
fonct->Intervals(CutPnts_C3, GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2, CutPnts_C3);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_approx);
#endif
Approx_CurvilinearParameter_EvalCurv evC (fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTolNul, TwoDTolNul, ThreeDTol,
FirstS, LastS, Order,
MaxDegree, MaxSegments,
evC, CutTool);
Approx_CurvilinearParameter_EvalCurv evC(fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTolNul,
TwoDTolNul,
ThreeDTol,
FirstS,
LastS,
Order,
MaxDegree,
MaxSegments,
evC,
CutTool);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_approx, t_approx);
@ -179,84 +193,90 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor3d_
myDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
aApprox.Poles(1,Poles);
if (myHasResult)
{
TColgp_Array1OfPnt Poles(1, aApprox.NbPoles());
aApprox.Poles(1, Poles);
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
Standard_Integer Degree = aApprox.Degree();
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
}
myMaxError3d = aApprox.MaxError(3,1);
myMaxError3d = aApprox.MaxError(3, 1);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_total, t_total);
std::cout<<" total reparametrization time = "<<t_total<<std::endl;
std::cout<<"initialization time = "<<t_init<<std::endl;
std::cout<<"approximation time = "<<t_approx<<std::endl;
std::cout<<"total time for uparam computation = "<<t_uparam<<std::endl;
std::cout<<"number uparam calls = "<<uparam_count<<std::endl;
std::cout << " total reparametrization time = " << t_total << std::endl;
std::cout << "initialization time = " << t_init << std::endl;
std::cout << "approximation time = " << t_approx << std::endl;
std::cout << "total time for uparam computation = " << t_uparam << std::endl;
std::cout << "number uparam calls = " << uparam_count << std::endl;
#endif
}
//=======================================================================
//class : Approx_CurvilinearParameter_EvalCurvOnSurf
//purpose : case of a curve on one surface
//=======================================================================
//=================================================================================================
class Approx_CurvilinearParameter_EvalCurvOnSurf : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurvilinearParameter_EvalCurvOnSurf (const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_CurvilinearParameter_EvalCurvOnSurf(const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Approx_CurvlinFunc) fonct;
Standard_Real StartEndSav[2];
};
void Approx_CurvilinearParameter_EvalCurvOnSurf::Evaluate (Standard_Integer * Dimension,
Standard_Real * StartEnd,
Standard_Real * Param,
Standard_Integer * Order,
Standard_Real * Result,
Standard_Integer * ErrorCode)
void Approx_CurvilinearParameter_EvalCurvOnSurf::Evaluate(Standard_Integer* Dimension,
Standard_Real* StartEnd,
Standard_Real* Param,
Standard_Integer* Order,
Standard_Real* Result,
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real S = *Param;
TColStd_Array1OfReal Res(0, 4);
Standard_Integer i;
// Dimension is incorrect
if (*Dimension != 5) {
// Dimension is incorrect
if (*Dimension != 5)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if ( S < StartEnd[0] || S > StartEnd[1] ) {
// Parameter is incorrect
if (S < StartEnd[0] || S > StartEnd[1])
{
*ErrorCode = 2;
}
if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
if (StartEnd[0] != StartEndSav[0] || StartEnd[1] != StartEndSav[1])
{
fonct->Trim(StartEnd[0],StartEnd[1], Precision::Confusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
fonct->Trim(StartEnd[0], StartEnd[1], Precision::Confusion());
StartEndSav[0] = StartEnd[0];
StartEndSav[1] = StartEnd[1];
}
if(!fonct->EvalCase2(S, *Order, Res)) {
if (!fonct->EvalCase2(S, *Order, Res))
{
*ErrorCode = 3;
}
for(i = 0; i <= 4; i++)
for (i = 0; i <= 4; i++)
Result[i] = Res(i);
}
@ -276,26 +296,26 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=2, Num2DSS=0, Num3DSS=1, i;
Standard_Integer Num1DSS = 2, Num2DSS = 0, Num3DSS = 1, i;
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
Standard_Real TolV,TolW;
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1, Num1DSS);
Standard_Real TolV, TolW;
ToleranceComputation(C2D,Surf,10,Tol,TolV,TolW);
OneDTol->SetValue(1,TolV);
OneDTol->SetValue(2,TolW);
ToleranceComputation(C2D, Surf, 10, Tol, TolV, TolW);
OneDTol->SetValue(1, TolV);
OneDTol->SetValue(2, TolW);
OneDTol->SetValue(1,Tol);
OneDTol->SetValue(2,Tol);
OneDTol->SetValue(1, Tol);
OneDTol->SetValue(2, Tol);
Handle(TColStd_HArray1OfReal) TwoDTolNul;
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
ThreeDTol->Init(Tol/2.);
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1, Num3DSS);
ThreeDTol->Init(Tol / 2.);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_init);
#endif
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D, Surf, Tol/20);
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D, Surf, Tol / 20);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_init, t_init);
#endif
@ -304,23 +324,31 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
Standard_Real LastS = fonct->LastParameter();
Standard_Integer NbInterv_C2 = fonct->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
fonct->Intervals(CutPnts_C2,GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
fonct->Intervals(CutPnts_C2, GeomAbs_C2);
Standard_Integer NbInterv_C3 = fonct->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
fonct->Intervals(CutPnts_C3,GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
fonct->Intervals(CutPnts_C3, GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2, CutPnts_C3);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_approx);
#endif
Approx_CurvilinearParameter_EvalCurvOnSurf evCOnS (fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTol,
FirstS, LastS, Order,
MaxDegree, MaxSegments,
evCOnS, CutTool);
Approx_CurvilinearParameter_EvalCurvOnSurf evCOnS(fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTol,
TwoDTolNul,
ThreeDTol,
FirstS,
LastS,
Order,
MaxDegree,
MaxSegments,
evCOnS,
CutTool);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_approx, t_approx);
@ -329,17 +357,18 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
myDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
if (myHasResult)
{
Standard_Integer NbPoles = aApprox.NbPoles();
TColgp_Array1OfPnt Poles (1,NbPoles);
TColgp_Array1OfPnt2d Poles2d(1,NbPoles);
TColStd_Array1OfReal Poles1d(1,NbPoles);
aApprox.Poles(1,Poles);
aApprox.Poles1d(1,Poles1d);
for (i=1; i<=NbPoles; i++)
TColgp_Array1OfPnt Poles(1, NbPoles);
TColgp_Array1OfPnt2d Poles2d(1, NbPoles);
TColStd_Array1OfReal Poles1d(1, NbPoles);
aApprox.Poles(1, Poles);
aApprox.Poles1d(1, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetX(Poles1d(i));
aApprox.Poles1d(2,Poles1d);
for (i=1; i<=NbPoles; i++)
aApprox.Poles1d(2, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetY(Poles1d(i));
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
@ -347,77 +376,82 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
myCurve2d1 = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree);
}
myMaxError2d1 = Max (aApprox.MaxError(1,1),aApprox.MaxError(1,2));
myMaxError3d = aApprox.MaxError(3,1);
myMaxError2d1 = Max(aApprox.MaxError(1, 1), aApprox.MaxError(1, 2));
myMaxError3d = aApprox.MaxError(3, 1);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_total, t_total);
std::cout<<" total reparametrization time = "<<t_total<<std::endl;
std::cout<<"initialization time = "<<t_init<<std::endl;
std::cout<<"approximation time = "<<t_approx<<std::endl;
std::cout<<"total time for uparam computation = "<<t_uparam<<std::endl;
std::cout<<"number uparam calls = "<<uparam_count<<std::endl;
std::cout << " total reparametrization time = " << t_total << std::endl;
std::cout << "initialization time = " << t_init << std::endl;
std::cout << "approximation time = " << t_approx << std::endl;
std::cout << "total time for uparam computation = " << t_uparam << std::endl;
std::cout << "number uparam calls = " << uparam_count << std::endl;
#endif
}
//=======================================================================
//function : Approx_CurvilinearParameter_EvalCurvOn2Surf
//purpose : case of a curve on two surfaces
//=======================================================================
//=================================================================================================
class Approx_CurvilinearParameter_EvalCurvOn2Surf : public AdvApprox_EvaluatorFunction
{
public:
Approx_CurvilinearParameter_EvalCurvOn2Surf (const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First, Standard_Real Last)
: fonct(theFunc) { StartEndSav[0] = First; StartEndSav[1] = Last; }
public:
Approx_CurvilinearParameter_EvalCurvOn2Surf(const Handle(Approx_CurvlinFunc)& theFunc,
Standard_Real First,
Standard_Real Last)
: fonct(theFunc)
{
StartEndSav[0] = First;
StartEndSav[1] = Last;
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
private:
Handle(Approx_CurvlinFunc) fonct;
Standard_Real StartEndSav[2];
};
void Approx_CurvilinearParameter_EvalCurvOn2Surf::Evaluate (Standard_Integer * Dimension,
Standard_Real * StartEnd,
Standard_Real * Param,
Standard_Integer * Order,
Standard_Real * Result,
Standard_Integer * ErrorCode)
void Approx_CurvilinearParameter_EvalCurvOn2Surf::Evaluate(Standard_Integer* Dimension,
Standard_Real* StartEnd,
Standard_Real* Param,
Standard_Integer* Order,
Standard_Real* Result,
Standard_Integer* ErrorCode)
{
*ErrorCode = 0;
Standard_Real S = *Param;
TColStd_Array1OfReal Res(0, 6);
Standard_Integer i;
// Dimension is incorrect
if (*Dimension != 7) {
// Dimension is incorrect
if (*Dimension != 7)
{
*ErrorCode = 1;
}
// Parameter is incorrect
if ( S < StartEnd[0] || S > StartEnd[1] ) {
// Parameter is incorrect
if (S < StartEnd[0] || S > StartEnd[1])
{
*ErrorCode = 2;
}
/* if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
/* if(StartEnd[0] != StartEndSav[0] || StartEnd[1]!= StartEndSav[1])
{
fonct->Trim(StartEnd[0],StartEnd[1], Precision::Confusion());
StartEndSav[0]=StartEnd[0];
StartEndSav[1]=StartEnd[1];
}
*/
if(!fonct->EvalCase3(S, *Order, Res)) {
*/
if (!fonct->EvalCase3(S, *Order, Res))
{
*ErrorCode = 3;
}
for(i = 0; i <= 6; i++)
for (i = 0; i <= 6; i++)
Result[i] = Res(i);
}
@ -441,26 +475,26 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=4, Num2DSS=0, Num3DSS=1;
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
Standard_Integer Num1DSS = 4, Num2DSS = 0, Num3DSS = 1;
Handle(TColStd_HArray1OfReal) OneDTol = new TColStd_HArray1OfReal(1, Num1DSS);
Standard_Real TolV,TolW;
ToleranceComputation(C2D1,Surf1,10,Tol,TolV,TolW);
OneDTol->SetValue(1,TolV);
OneDTol->SetValue(2,TolW);
Standard_Real TolV, TolW;
ToleranceComputation(C2D1, Surf1, 10, Tol, TolV, TolW);
OneDTol->SetValue(1, TolV);
OneDTol->SetValue(2, TolW);
ToleranceComputation(C2D2,Surf2,10,Tol,TolV,TolW);
OneDTol->SetValue(3,TolV);
OneDTol->SetValue(4,TolW);
ToleranceComputation(C2D2, Surf2, 10, Tol, TolV, TolW);
OneDTol->SetValue(3, TolV);
OneDTol->SetValue(4, TolW);
Handle(TColStd_HArray1OfReal) TwoDTolNul;
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
ThreeDTol->Init(Tol/2);
Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1, Num3DSS);
ThreeDTol->Init(Tol / 2);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_init);
#endif
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D1, C2D2, Surf1, Surf2, Tol/20);
Handle(Approx_CurvlinFunc) fonct = new Approx_CurvlinFunc(C2D1, C2D2, Surf1, Surf2, Tol / 20);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_init, t_init);
#endif
@ -469,23 +503,31 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
Standard_Real LastS = fonct->LastParameter();
Standard_Integer NbInterv_C2 = fonct->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
fonct->Intervals(CutPnts_C2,GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
fonct->Intervals(CutPnts_C2, GeomAbs_C2);
Standard_Integer NbInterv_C3 = fonct->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
fonct->Intervals(CutPnts_C3,GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
fonct->Intervals(CutPnts_C3, GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2, CutPnts_C3);
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_approx);
#endif
Approx_CurvilinearParameter_EvalCurvOn2Surf evCOn2S (fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTol,
FirstS, LastS, Order,
MaxDegree, MaxSegments,
evCOn2S, CutTool);
Approx_CurvilinearParameter_EvalCurvOn2Surf evCOn2S(fonct, FirstS, LastS);
AdvApprox_ApproxAFunction aApprox(Num1DSS,
Num2DSS,
Num3DSS,
OneDTol,
TwoDTolNul,
ThreeDTol,
FirstS,
LastS,
Order,
MaxDegree,
MaxSegments,
evCOn2S,
CutTool);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_approx, t_approx);
@ -494,170 +536,151 @@ Approx_CurvilinearParameter::Approx_CurvilinearParameter(const Handle(Adaptor2d_
myDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
if (myHasResult) {
if (myHasResult)
{
Standard_Integer NbPoles = aApprox.NbPoles();
TColgp_Array1OfPnt Poles (1,NbPoles);
TColgp_Array1OfPnt2d Poles2d(1,NbPoles);
TColStd_Array1OfReal Poles1d(1,NbPoles);
aApprox.Poles(1,Poles);
aApprox.Poles1d(1,Poles1d);
for (i=1; i<=NbPoles; i++)
TColgp_Array1OfPnt Poles(1, NbPoles);
TColgp_Array1OfPnt2d Poles2d(1, NbPoles);
TColStd_Array1OfReal Poles1d(1, NbPoles);
aApprox.Poles(1, Poles);
aApprox.Poles1d(1, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetX(Poles1d(i));
aApprox.Poles1d(2,Poles1d);
for (i=1; i<=NbPoles; i++)
aApprox.Poles1d(2, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetY(Poles1d(i));
Handle(TColStd_HArray1OfReal) Knots = aApprox.Knots();
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
Standard_Integer Degree = aApprox.Degree();
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
myCurve2d1 = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree);
aApprox.Poles1d(3,Poles1d);
for (i=1; i<=NbPoles; i++)
aApprox.Poles1d(3, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetX(Poles1d(i));
aApprox.Poles1d(4,Poles1d);
for (i=1; i<=NbPoles; i++)
aApprox.Poles1d(4, Poles1d);
for (i = 1; i <= NbPoles; i++)
Poles2d(i).SetY(Poles1d(i));
myCurve2d2 = new Geom2d_BSplineCurve(Poles2d, Knots->Array1(), Mults->Array1(), Degree);
}
myMaxError2d1 = Max (aApprox.MaxError(1,1),aApprox.MaxError(1,2));
myMaxError2d2 = Max (aApprox.MaxError(1,3),aApprox.MaxError(1,4));
myMaxError3d = aApprox.MaxError(3,1);
myMaxError2d1 = Max(aApprox.MaxError(1, 1), aApprox.MaxError(1, 2));
myMaxError2d2 = Max(aApprox.MaxError(1, 3), aApprox.MaxError(1, 4));
myMaxError3d = aApprox.MaxError(3, 1);
#ifdef OCCT_DEBUG_CHRONO
ResultChron(chr_total, t_total);
std::cout<<" total reparametrization time = "<<t_total<<std::endl;
std::cout<<"initialization time = "<<t_init<<std::endl;
std::cout<<"approximation time = "<<t_approx<<std::endl;
std::cout<<"total time for uparam computation = "<<t_uparam<<std::endl;
std::cout<<"number uparam calls = "<<uparam_count<<std::endl;
std::cout << " total reparametrization time = " << t_total << std::endl;
std::cout << "initialization time = " << t_init << std::endl;
std::cout << "approximation time = " << t_approx << std::endl;
std::cout << "total time for uparam computation = " << t_uparam << std::endl;
std::cout << "number uparam calls = " << uparam_count << std::endl;
#endif
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean Approx_CurvilinearParameter::IsDone() const
Standard_Boolean Approx_CurvilinearParameter::IsDone() const
{
return myDone;
}
//=======================================================================
//function : HasResult
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean Approx_CurvilinearParameter::HasResult() const
Standard_Boolean Approx_CurvilinearParameter::HasResult() const
{
return myHasResult;
}
//=======================================================================
//function : Curve3d
//purpose : returns the Bspline curve corresponding to the reparametrized 3D curve
//=======================================================================
//=================================================================================================
Handle(Geom_BSplineCurve) Approx_CurvilinearParameter::Curve3d() const
Handle(Geom_BSplineCurve) Approx_CurvilinearParameter::Curve3d() const
{
return myCurve3d;
}
//=======================================================================
//function : MaxError3d
//purpose : returns the maximum error on the reparametrized 3D curve
//=======================================================================
//=================================================================================================
Standard_Real Approx_CurvilinearParameter::MaxError3d() const
Standard_Real Approx_CurvilinearParameter::MaxError3d() const
{
return myMaxError3d;
}
//=======================================================================
//function : Curve2d1
//purpose : returns the BsplineCurve representing the reparametrized 2D curve on the
//=================================================================================================
// function : Curve2d1
// purpose : returns the BsplineCurve representing the reparametrized 2D curve on the
// first surface (case of a curve on one or two surfaces)
//=======================================================================
//=================================================================================================
Handle(Geom2d_BSplineCurve) Approx_CurvilinearParameter::Curve2d1() const
Handle(Geom2d_BSplineCurve) Approx_CurvilinearParameter::Curve2d1() const
{
return myCurve2d1;
}
//=======================================================================
//function : MaxError2d1
//purpose : returns the maximum error on the first reparametrized 2D curve
//=======================================================================
//=================================================================================================
Standard_Real Approx_CurvilinearParameter::MaxError2d1() const
Standard_Real Approx_CurvilinearParameter::MaxError2d1() const
{
return myMaxError2d1;
}
//=======================================================================
//function : Curve2d2
//purpose : returns the BsplineCurve representing the reparametrized 2D curve on the
//=================================================================================================
// function : Curve2d2
// purpose : returns the BsplineCurve representing the reparametrized 2D curve on the
// second surface (case of a curve on two surfaces)
//=======================================================================
//=================================================================================================
Handle(Geom2d_BSplineCurve) Approx_CurvilinearParameter::Curve2d2() const
Handle(Geom2d_BSplineCurve) Approx_CurvilinearParameter::Curve2d2() const
{
return myCurve2d2;
}
//=======================================================================
//function : MaxError2d2
//purpose : returns the maximum error on the second reparametrized 2D curve
//=======================================================================
//=================================================================================================
Standard_Real Approx_CurvilinearParameter::MaxError2d2() const
Standard_Real Approx_CurvilinearParameter::MaxError2d2() const
{
return myMaxError2d2;
}
//=======================================================================
//function : Dump
//purpose : print the maximum errors(s)
//=======================================================================
//=================================================================================================
// function : Dump
// purpose : print the maximum errors(s)
//=================================================================================================
void Approx_CurvilinearParameter::Dump(Standard_OStream& o) const
{
o << "Dump of Approx_CurvilinearParameter" << std::endl;
if (myCase==2 || myCase==3)
if (myCase == 2 || myCase == 3)
o << "myMaxError2d1 = " << myMaxError2d1 << std::endl;
if (myCase==3)
if (myCase == 3)
o << "myMaxError2d2 = " << myMaxError2d2 << std::endl;
o << "myMaxError3d = " << myMaxError3d << std::endl;
}
//=======================================================================
//function : ToleranceComputation
//purpose :
//=======================================================================
//=================================================================================================
void Approx_CurvilinearParameter::ToleranceComputation(const Handle(Adaptor2d_Curve2d) &C2D,
const Handle(Adaptor3d_Surface) &S,
void Approx_CurvilinearParameter::ToleranceComputation(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Integer MaxNumber,
const Standard_Real Tol,
Standard_Real &TolV, Standard_Real &TolW)
Standard_Real& TolV,
Standard_Real& TolW)
{
Standard_Real FirstU = C2D->FirstParameter(),
LastU = C2D->LastParameter();
// Standard_Real parU, Max_dS_dv=1.,Max_dS_dw=1.;
Standard_Real Max_dS_dv=1.,Max_dS_dw=1.;
Standard_Real FirstU = C2D->FirstParameter(), LastU = C2D->LastParameter();
// Standard_Real parU, Max_dS_dv=1.,Max_dS_dw=1.;
Standard_Real Max_dS_dv = 1., Max_dS_dw = 1.;
gp_Pnt P;
gp_Pnt2d pntVW;
gp_Vec dS_dv,dS_dw;
gp_Vec dS_dv, dS_dw;
for (Standard_Integer i=1; i<=MaxNumber; i++) {
pntVW = C2D->Value(FirstU + (i-1)*(LastU-FirstU)/(MaxNumber-1));
S->D1(pntVW.X(),pntVW.Y(),P,dS_dv,dS_dw);
Max_dS_dv = Max (Max_dS_dv, dS_dv.Magnitude());
Max_dS_dw = Max (Max_dS_dw, dS_dw.Magnitude());
for (Standard_Integer i = 1; i <= MaxNumber; i++)
{
pntVW = C2D->Value(FirstU + (i - 1) * (LastU - FirstU) / (MaxNumber - 1));
S->D1(pntVW.X(), pntVW.Y(), P, dS_dv, dS_dw);
Max_dS_dv = Max(Max_dS_dv, dS_dv.Magnitude());
Max_dS_dw = Max(Max_dS_dw, dS_dw.Magnitude());
}
TolV = Tol / (4.*Max_dS_dv);
TolW = Tol / (4.*Max_dS_dw);
TolV = Tol / (4. * Max_dS_dv);
TolW = Tol / (4. * Max_dS_dw);
#ifdef OCCT_DEBUG
std::cout << "TolV = " << TolV << std::endl;

View File

@ -36,18 +36,32 @@
class Approx_CurvilinearParameter
{
public:
DEFINE_STANDARD_ALLOC
//! case of a free 3D curve
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor3d_Curve)& C3D, const Standard_Real Tol, const GeomAbs_Shape Order, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments);
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor3d_Curve)& C3D,
const Standard_Real Tol,
const GeomAbs_Shape Order,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments);
//! case of a curve on one surface
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor2d_Curve2d)& C2D, const Handle(Adaptor3d_Surface)& Surf, const Standard_Real Tol, const GeomAbs_Shape Order, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments);
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& Surf,
const Standard_Real Tol,
const GeomAbs_Shape Order,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments);
//! case of a curve on two surfaces
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor2d_Curve2d)& C2D1, const Handle(Adaptor3d_Surface)& Surf1, const Handle(Adaptor2d_Curve2d)& C2D2, const Handle(Adaptor3d_Surface)& Surf2, const Standard_Real Tol, const GeomAbs_Shape Order, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments);
Standard_EXPORT Approx_CurvilinearParameter(const Handle(Adaptor2d_Curve2d)& C2D1,
const Handle(Adaptor3d_Surface)& Surf1,
const Handle(Adaptor2d_Curve2d)& C2D2,
const Handle(Adaptor3d_Surface)& Surf2,
const Standard_Real Tol,
const GeomAbs_Shape Order,
const Standard_Integer MaxDegree,
const Standard_Integer MaxSegments);
Standard_EXPORT Standard_Boolean IsDone() const;
@ -74,14 +88,17 @@ public:
Standard_EXPORT Standard_Real MaxError2d2() const;
//! print the maximum errors(s)
Standard_EXPORT void Dump (Standard_OStream& o) const;
Standard_EXPORT void Dump(Standard_OStream& o) const;
private:
Standard_EXPORT static void ToleranceComputation (const Handle(Adaptor2d_Curve2d)& C2D, const Handle(Adaptor3d_Surface)& S, const Standard_Integer MaxNumber, const Standard_Real Tol, Standard_Real& TolV, Standard_Real& TolW);
Standard_EXPORT static void ToleranceComputation(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Integer MaxNumber,
const Standard_Real Tol,
Standard_Real& TolV,
Standard_Real& TolW);
private:
Standard_Integer myCase;
Standard_Boolean myDone;
Standard_Boolean myHasResult;
@ -91,7 +108,6 @@ private:
Standard_Real myMaxError2d1;
Handle(Geom2d_BSplineCurve) myCurve2d2;
Standard_Real myMaxError2d2;
};
#endif // _Approx_CurvilinearParameter_HeaderFile

View File

@ -27,64 +27,72 @@
#include <Standard_Type.hxx>
#include <TColStd_SequenceOfReal.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Approx_CurvlinFunc,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Approx_CurvlinFunc, Standard_Transient)
#ifdef OCCT_DEBUG_CHRONO
#include <OSD_Timer.hxx>
#include <OSD_Timer.hxx>
static OSD_Chronometer chr_uparam;
Standard_EXPORT Standard_Integer uparam_count;
Standard_EXPORT Standard_Real t_uparam;
//Standard_IMPORT extern void InitChron(OSD_Chronometer& ch);
// Standard_IMPORT extern void InitChron(OSD_Chronometer& ch);
Standard_IMPORT void InitChron(OSD_Chronometer& ch);
//Standard_IMPORT extern void ResultChron( OSD_Chronometer & ch, Standard_Real & time);
Standard_IMPORT void ResultChron( OSD_Chronometer & ch, Standard_Real & time);
// Standard_IMPORT extern void ResultChron( OSD_Chronometer & ch, Standard_Real & time);
Standard_IMPORT void ResultChron(OSD_Chronometer& ch, Standard_Real& time);
#endif
static Standard_Real cubic(const Standard_Real X, const Standard_Real *Xi, const Standard_Real *Yi)
static Standard_Real cubic(const Standard_Real X, const Standard_Real* Xi, const Standard_Real* Yi)
{
Standard_Real I1, I2, I3, I21, I22, I31, Result;
I1 = (Yi[0] - Yi[1])/(Xi[0] - Xi[1]);
I2 = (Yi[1] - Yi[2])/(Xi[1] - Xi[2]);
I3 = (Yi[2] - Yi[3])/(Xi[2] - Xi[3]);
I1 = (Yi[0] - Yi[1]) / (Xi[0] - Xi[1]);
I2 = (Yi[1] - Yi[2]) / (Xi[1] - Xi[2]);
I3 = (Yi[2] - Yi[3]) / (Xi[2] - Xi[3]);
I21 = (I1 - I2)/(Xi[0] - Xi[2]);
I22 = (I2 - I3)/(Xi[1] - Xi[3]);
I21 = (I1 - I2) / (Xi[0] - Xi[2]);
I22 = (I2 - I3) / (Xi[1] - Xi[3]);
I31 = (I21 - I22)/(Xi[0] - Xi[3]);
I31 = (I21 - I22) / (Xi[0] - Xi[3]);
Result = Yi[0] + (X - Xi[0])*(I1 + (X - Xi[1])*(I21 + (X - Xi[2])*I31));
Result = Yi[0] + (X - Xi[0]) * (I1 + (X - Xi[1]) * (I21 + (X - Xi[2]) * I31));
return Result;
}
//static void findfourpoints(const Standard_Real S,
static void findfourpoints(const Standard_Real ,
// static void findfourpoints(const Standard_Real S,
static void findfourpoints(const Standard_Real,
Standard_Integer NInterval,
const Handle(TColStd_HArray1OfReal)& Si,
Handle(TColStd_HArray1OfReal)& Ui,
const Standard_Real prevS,
const Standard_Real prevU, Standard_Real *Xi,
Standard_Real *Yi)
const Standard_Real prevU,
Standard_Real* Xi,
Standard_Real* Yi)
{
Standard_Integer i, j;
Standard_Integer NbInt = Si->Length() - 1;
if (NbInt < 3) throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter");
if (NbInt < 3)
throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter");
if(NInterval < 1) NInterval = 1;
else if(NInterval > NbInt - 2) NInterval = NbInt - 2;
if (NInterval < 1)
NInterval = 1;
else if (NInterval > NbInt - 2)
NInterval = NbInt - 2;
for(i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
Xi[i] = Si->Value(NInterval - 1 + i);
Yi[i] = Ui->Value(NInterval - 1 + i);
}
// try to insert (S, U)
for(i = 0; i < 3; i++) {
if(Xi[i] < prevS && prevS < Xi[i+1]) {
for(j = 0; j < i; j++) {
Xi[j] = Xi[j+1];
Yi[j] = Yi[j+1];
// try to insert (S, U)
for (i = 0; i < 3; i++)
{
if (Xi[i] < prevS && prevS < Xi[i + 1])
{
for (j = 0; j < i; j++)
{
Xi[j] = Xi[j + 1];
Yi[j] = Yi[j + 1];
}
Xi[i] = prevS;
Yi[i] = prevU;
@ -110,32 +118,39 @@ static void findfourpoints(const Standard_Real ,
}
*/
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor3d_Curve)& C, const Standard_Real Tol) : myC3D(C),
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor3d_Curve)& C, const Standard_Real Tol)
: myC3D(C),
myCase(1),
myFirstS(0),
myLastS(1),
myTolLen(Tol),
myPrevS (0.0),
myPrevU (0.0)
myPrevS(0.0),
myPrevU(0.0)
{
Init();
}
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D, const Handle(Adaptor3d_Surface)& S, const Standard_Real Tol) :
myC2D1(C2D),
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Real Tol)
: myC2D1(C2D),
mySurf1(S),
myCase(2),
myFirstS(0),
myLastS(1),
myTolLen(Tol),
myPrevS (0.0),
myPrevU (0.0)
myPrevS(0.0),
myPrevU(0.0)
{
Init();
}
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D1, const Handle(Adaptor2d_Curve2d)& C2D2, const Handle(Adaptor3d_Surface)& S1, const Handle(Adaptor3d_Surface)& S2, const Standard_Real Tol) :
myC2D1(C2D1),
Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D1,
const Handle(Adaptor2d_Curve2d)& C2D2,
const Handle(Adaptor3d_Surface)& S1,
const Handle(Adaptor3d_Surface)& S2,
const Standard_Real Tol)
: myC2D1(C2D1),
myC2D2(C2D2),
mySurf1(S1),
mySurf2(S2),
@ -143,8 +158,8 @@ Approx_CurvlinFunc::Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D1, co
myFirstS(0),
myLastS(1),
myTolLen(Tol),
myPrevS (0.0),
myPrevU (0.0)
myPrevS(0.0),
myPrevU(0.0)
{
Init();
}
@ -153,9 +168,10 @@ void Approx_CurvlinFunc::Init()
{
Adaptor3d_CurveOnSurface CurOnSur;
switch(myCase) {
switch (myCase)
{
case 1:
Init (*myC3D, mySi_1, myUi_1);
Init(*myC3D, mySi_1, myUi_1);
myFirstU1 = myC3D->FirstParameter();
myLastU1 = myC3D->LastParameter();
myFirstU2 = myLastU2 = 0;
@ -184,13 +200,14 @@ void Approx_CurvlinFunc::Init()
Length();
}
//=================================================================================================
// function : Init
// purpose : Init the values
// history : 23/10/1998 PMN : Cut at curve's discontinuities
//=================================================================================================
//=======================================================================
//function : Init
//purpose : Init the values
//history : 23/10/1998 PMN : Cut at curve's discontinuities
//=======================================================================
void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C, Handle(TColStd_HArray1OfReal)& Si,
void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C,
Handle(TColStd_HArray1OfReal)& Si,
Handle(TColStd_HArray1OfReal)& Ui) const
{
Standard_Real Step, FirstU, LastU;
@ -200,32 +217,36 @@ void Approx_CurvlinFunc::Init(Adaptor3d_Curve& C, Handle(TColStd_HArray1OfReal)&
NbInt = 10;
NbIntC3 = C.NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal Disc(1, NbIntC3+1);
TColStd_Array1OfReal Disc(1, NbIntC3 + 1);
if (NbIntC3 >1) {
if (NbIntC3 > 1)
{
C.Intervals(Disc, GeomAbs_C3);
}
else {
else
{
Disc(1) = FirstU;
Disc(2) = LastU;
}
Ui = new TColStd_HArray1OfReal (0,NbIntC3*NbInt);
Si = new TColStd_HArray1OfReal (0,NbIntC3*NbInt);
Ui = new TColStd_HArray1OfReal(0, NbIntC3 * NbInt);
Si = new TColStd_HArray1OfReal(0, NbIntC3 * NbInt);
Ui->SetValue(0, FirstU);
Si->SetValue(0, 0);
for(j = 1, i=1; j<=NbIntC3; j++) {
Step = (Disc(j+1) - Disc(j))/NbInt;
for(k = 1; k <= NbInt; k++, i++) {
Ui->ChangeValue(i) = Ui->Value(i-1) + Step;
Si->ChangeValue(i) = Si->Value(i-1) + Length(C, Ui->Value(i-1), Ui->Value(i));
for (j = 1, i = 1; j <= NbIntC3; j++)
{
Step = (Disc(j + 1) - Disc(j)) / NbInt;
for (k = 1; k <= NbInt; k++, i++)
{
Ui->ChangeValue(i) = Ui->Value(i - 1) + Step;
Si->ChangeValue(i) = Si->Value(i - 1) + Length(C, Ui->Value(i - 1), Ui->Value(i));
}
}
Standard_Real Len = Si->Value(Si->Upper());
for(i = Si->Lower(); i<= Si->Upper(); i++)
for (i = Si->Lower(); i <= Si->Upper(); i++)
Si->ChangeValue(i) /= Len;
// TODO - fields should be mutable
@ -252,7 +273,8 @@ Standard_Integer Approx_CurvlinFunc::NbIntervals(const GeomAbs_Shape S) const
{
Adaptor3d_CurveOnSurface CurOnSur;
switch(myCase) {
switch (myCase)
{
case 1:
return myC3D->NbIntervals(S);
case 2:
@ -264,12 +286,12 @@ Standard_Integer Approx_CurvlinFunc::NbIntervals(const GeomAbs_Shape S) const
CurOnSur.Load(myC2D1);
CurOnSur.Load(mySurf1);
NbInt = CurOnSur.NbIntervals(S);
TColStd_Array1OfReal T1(1, NbInt+1);
TColStd_Array1OfReal T1(1, NbInt + 1);
CurOnSur.Intervals(T1, S);
CurOnSur.Load(myC2D2);
CurOnSur.Load(mySurf2);
NbInt = CurOnSur.NbIntervals(S);
TColStd_Array1OfReal T2(1, NbInt+1);
TColStd_Array1OfReal T2(1, NbInt + 1);
CurOnSur.Intervals(T2, S);
TColStd_SequenceOfReal Fusion;
@ -277,7 +299,7 @@ Standard_Integer Approx_CurvlinFunc::NbIntervals(const GeomAbs_Shape S) const
return Fusion.Length() - 1;
}
//POP pour WNT
// POP pour WNT
return 1;
}
@ -286,7 +308,8 @@ void Approx_CurvlinFunc::Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape
Adaptor3d_CurveOnSurface CurOnSur;
Standard_Integer i;
switch(myCase) {
switch (myCase)
{
case 1:
myC3D->Intervals(T, S);
break;
@ -300,12 +323,12 @@ void Approx_CurvlinFunc::Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape
CurOnSur.Load(myC2D1);
CurOnSur.Load(mySurf1);
NbInt = CurOnSur.NbIntervals(S);
TColStd_Array1OfReal T1(1, NbInt+1);
TColStd_Array1OfReal T1(1, NbInt + 1);
CurOnSur.Intervals(T1, S);
CurOnSur.Load(myC2D2);
CurOnSur.Load(mySurf2);
NbInt = CurOnSur.NbIntervals(S);
TColStd_Array1OfReal T2(1, NbInt+1);
TColStd_Array1OfReal T2(1, NbInt + 1);
CurOnSur.Intervals(T2, S);
TColStd_SequenceOfReal Fusion;
@ -315,30 +338,36 @@ void Approx_CurvlinFunc::Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape
T.ChangeValue(i) = Fusion.Value(i);
}
for(i = 1; i <= T.Length(); i++)
for (i = 1; i <= T.Length(); i++)
T.ChangeValue(i) = GetSParameter(T.Value(i));
}
void Approx_CurvlinFunc::Trim(const Standard_Real First, const Standard_Real Last, const Standard_Real Tol)
void Approx_CurvlinFunc::Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol)
{
if (First < 0 || Last >1) throw Standard_OutOfRange("Approx_CurvlinFunc::Trim");
if ((Last - First) < Tol) return;
if (First < 0 || Last > 1)
throw Standard_OutOfRange("Approx_CurvlinFunc::Trim");
if ((Last - First) < Tol)
return;
Standard_Real FirstU, LastU;
Adaptor3d_CurveOnSurface CurOnSur;
Handle(Adaptor3d_CurveOnSurface) HCurOnSur;
switch(myCase) {
switch (myCase)
{
case 1:
myC3D = myC3D->Trim(myFirstU1, myLastU1, Tol);
FirstU = GetUParameter(*myC3D, First, 1);
LastU = GetUParameter (*myC3D, Last, 1);
LastU = GetUParameter(*myC3D, Last, 1);
myC3D = myC3D->Trim(FirstU, LastU, Tol);
break;
case 3:
CurOnSur.Load(myC2D2);
CurOnSur.Load(mySurf2);
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast (CurOnSur.Trim(myFirstU2, myLastU2, Tol));
HCurOnSur =
Handle(Adaptor3d_CurveOnSurface)::DownCast(CurOnSur.Trim(myFirstU2, myLastU2, Tol));
myC2D2 = HCurOnSur->GetCurve();
mySurf2 = HCurOnSur->GetSurface();
CurOnSur.Load(myC2D2);
@ -346,7 +375,7 @@ void Approx_CurvlinFunc::Trim(const Standard_Real First, const Standard_Real Las
FirstU = GetUParameter(CurOnSur, First, 1);
LastU = GetUParameter(CurOnSur, Last, 1);
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast (CurOnSur.Trim(FirstU, LastU, Tol));
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast(CurOnSur.Trim(FirstU, LastU, Tol));
myC2D2 = HCurOnSur->GetCurve();
mySurf2 = HCurOnSur->GetSurface();
@ -354,7 +383,8 @@ void Approx_CurvlinFunc::Trim(const Standard_Real First, const Standard_Real Las
case 2:
CurOnSur.Load(myC2D1);
CurOnSur.Load(mySurf1);
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast (CurOnSur.Trim(myFirstU1, myLastU1, Tol));
HCurOnSur =
Handle(Adaptor3d_CurveOnSurface)::DownCast(CurOnSur.Trim(myFirstU1, myLastU1, Tol));
myC2D1 = HCurOnSur->GetCurve();
mySurf1 = HCurOnSur->GetSurface();
CurOnSur.Load(myC2D1);
@ -362,7 +392,7 @@ void Approx_CurvlinFunc::Trim(const Standard_Real First, const Standard_Real Las
FirstU = GetUParameter(CurOnSur, First, 1);
LastU = GetUParameter(CurOnSur, Last, 1);
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast (CurOnSur.Trim(FirstU, LastU, Tol));
HCurOnSur = Handle(Adaptor3d_CurveOnSurface)::DownCast(CurOnSur.Trim(FirstU, LastU, Tol));
myC2D1 = HCurOnSur->GetCurve();
mySurf1 = HCurOnSur->GetSurface();
}
@ -375,11 +405,12 @@ void Approx_CurvlinFunc::Length()
Adaptor3d_CurveOnSurface CurOnSur;
Standard_Real FirstU, LastU;
switch(myCase){
switch (myCase)
{
case 1:
FirstU = myC3D->FirstParameter();
LastU = myC3D->LastParameter();
myLength = Length (*myC3D, FirstU, LastU);
myLength = Length(*myC3D, FirstU, LastU);
myLength1 = myLength2 = 0;
break;
case 2:
@ -401,12 +432,13 @@ void Approx_CurvlinFunc::Length()
FirstU = CurOnSur.FirstParameter();
LastU = CurOnSur.LastParameter();
myLength2 = Length(CurOnSur, FirstU, LastU);
myLength = (myLength1 + myLength2)/2;
myLength = (myLength1 + myLength2) / 2;
}
}
Standard_Real Approx_CurvlinFunc::Length(Adaptor3d_Curve& C, const Standard_Real FirstU, const Standard_Real LastU) const
Standard_Real Approx_CurvlinFunc::Length(Adaptor3d_Curve& C,
const Standard_Real FirstU,
const Standard_Real LastU) const
{
Standard_Real Length;
@ -414,7 +446,6 @@ Standard_Real Approx_CurvlinFunc::Length(Adaptor3d_Curve& C, const Standard_Real
return Length;
}
Standard_Real Approx_CurvlinFunc::GetLength() const
{
return myLength;
@ -422,12 +453,13 @@ Standard_Real Approx_CurvlinFunc::GetLength() const
Standard_Real Approx_CurvlinFunc::GetSParameter(const Standard_Real U) const
{
Standard_Real S=0, S1, S2;
Standard_Real S = 0, S1, S2;
Adaptor3d_CurveOnSurface CurOnSur;
switch (myCase) {
switch (myCase)
{
case 1:
S = GetSParameter (*myC3D, U, myLength);
S = GetSParameter(*myC3D, U, myLength);
break;
case 2:
CurOnSur.Load(myC2D1);
@ -441,13 +473,11 @@ Standard_Real Approx_CurvlinFunc::GetSParameter(const Standard_Real U) const
CurOnSur.Load(myC2D2);
CurOnSur.Load(mySurf2);
S2 = GetSParameter(CurOnSur, U, myLength2);
S = (S1 + S2)/2;
S = (S1 + S2) / 2;
}
return S;
}
Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
const Standard_Real S,
const Standard_Integer NumberOfCurve) const
@ -458,17 +488,20 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
#ifdef OCCT_DEBUG_CHRONO
InitChron(chr_uparam);
#endif
if(S < 0 || S > 1) throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter");
if (S < 0 || S > 1)
throw Standard_ConstructionError("Approx_CurvlinFunc::GetUParameter");
if(NumberOfCurve == 1) {
if (NumberOfCurve == 1)
{
InitUArray = myUi_1;
InitSArray = mySi_1;
if(myCase == 3)
if (myCase == 3)
Length = myLength1;
else
Length = myLength;
}
else {
else
{
InitUArray = myUi_2;
InitSArray = mySi_2;
Length = myLength2;
@ -476,28 +509,33 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
NbInt = InitUArray->Length() - 1;
if(S == 1) NInterval = NbInt - 1;
else {
for(i = 0; i < NbInt; i++) {
if((InitSArray->Value(i) <= S && S < InitSArray->Value(i+1)))
if (S == 1)
NInterval = NbInt - 1;
else
{
for (i = 0; i < NbInt; i++)
{
if ((InitSArray->Value(i) <= S && S < InitSArray->Value(i + 1)))
break;
}
NInterval = i;
}
if(S==InitSArray->Value(NInterval)) {
if (S == InitSArray->Value(NInterval))
{
return InitUArray->Value(NInterval);
}
if(S==InitSArray->Value(NInterval+1)) {
return InitUArray->Value(NInterval+1);
if (S == InitSArray->Value(NInterval + 1))
{
return InitUArray->Value(NInterval + 1);
}
base = InitUArray->Value(NInterval);
deltaS = (S - InitSArray->Value(NInterval))*Length;
deltaS = (S - InitSArray->Value(NInterval)) * Length;
// to find an initial point
// to find an initial point
Standard_Real Xi[4], Yi[4], UGuess;
findfourpoints(S, NInterval, InitSArray, InitUArray, myPrevS, myPrevU, Xi, Yi);
UGuess = cubic(S , Xi, Yi);
UGuess = cubic(S, Xi, Yi);
U = GCPnts_AbscissaPoint(C, deltaS, base, UGuess, myTolLen).Parameter();
@ -513,26 +551,32 @@ Standard_Real Approx_CurvlinFunc::GetUParameter(Adaptor3d_Curve& C,
return U;
}
Standard_Real Approx_CurvlinFunc::GetSParameter(Adaptor3d_Curve& C, const Standard_Real U, const Standard_Real Len) const
Standard_Real Approx_CurvlinFunc::GetSParameter(Adaptor3d_Curve& C,
const Standard_Real U,
const Standard_Real Len) const
{
Standard_Real S, Origin;
Origin = C.FirstParameter();
S = myFirstS + Length(C, Origin, U)/Len;
S = myFirstS + Length(C, Origin, U) / Len;
return S;
}
Standard_Boolean Approx_CurvlinFunc::EvalCase1(const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result) const
Standard_Boolean Approx_CurvlinFunc::EvalCase1(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result) const
{
if(myCase != 1) throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase1");
if (myCase != 1)
throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase1");
gp_Pnt C;
gp_Vec dC_dU, dC_dS, d2C_dU2, d2C_dS2;
Standard_Real U, Mag, dU_dS, d2U_dS2;
U = GetUParameter (*myC3D, S, 1);
U = GetUParameter(*myC3D, S, 1);
switch(Order) {
switch (Order)
{
case 0:
myC3D->D0(U, C);
@ -545,8 +589,8 @@ Standard_Boolean Approx_CurvlinFunc::EvalCase1(const Standard_Real S, const Stan
case 1:
myC3D->D1(U, C, dC_dU);
Mag = dC_dU.Magnitude();
dU_dS = myLength/Mag;
dC_dS = dC_dU*dU_dS;
dU_dS = myLength / Mag;
dC_dS = dC_dU * dU_dS;
Result(0) = dC_dS.X();
Result(1) = dC_dS.Y();
@ -556,24 +600,28 @@ Standard_Boolean Approx_CurvlinFunc::EvalCase1(const Standard_Real S, const Stan
case 2:
myC3D->D2(U, C, dC_dU, d2C_dU2);
Mag = dC_dU.Magnitude();
dU_dS = myLength/Mag;
d2U_dS2 = -myLength*dC_dU.Dot(d2C_dU2)*dU_dS/(Mag*Mag*Mag);
d2C_dS2 = d2C_dU2*dU_dS*dU_dS + dC_dU*d2U_dS2;
dU_dS = myLength / Mag;
d2U_dS2 = -myLength * dC_dU.Dot(d2C_dU2) * dU_dS / (Mag * Mag * Mag);
d2C_dS2 = d2C_dU2 * dU_dS * dU_dS + dC_dU * d2U_dS2;
Result(0) = d2C_dS2.X();
Result(1) = d2C_dS2.Y();
Result(2) = d2C_dS2.Z();
break;
default: Result(0) = Result(1) = Result(2) = 0;
default:
Result(0) = Result(1) = Result(2) = 0;
return Standard_False;
}
return Standard_True;
}
Standard_Boolean Approx_CurvlinFunc::EvalCase2(const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result) const
Standard_Boolean Approx_CurvlinFunc::EvalCase2(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result) const
{
if(myCase != 2) throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase2");
if (myCase != 2)
throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase2");
Standard_Boolean Done;
@ -582,9 +630,12 @@ Standard_Boolean Approx_CurvlinFunc::EvalCase2(const Standard_Real S, const Stan
return Done;
}
Standard_Boolean Approx_CurvlinFunc::EvalCase3(const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result)
Standard_Boolean Approx_CurvlinFunc::EvalCase3(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result)
{
if(myCase != 3) throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase3");
if (myCase != 3)
throw Standard_ConstructionError("Approx_CurvlinFunc::EvalCase3");
TColStd_Array1OfReal tmpRes1(0, 4), tmpRes2(0, 4);
Standard_Boolean Done;
@ -597,28 +648,35 @@ Standard_Boolean Approx_CurvlinFunc::EvalCase3(const Standard_Real S, const Stan
Result(1) = tmpRes1(1);
Result(2) = tmpRes2(0);
Result(3) = tmpRes2(1);
Result(4) = 0.5*(tmpRes1(2) + tmpRes2(2));
Result(5) = 0.5*(tmpRes1(3) + tmpRes2(3));
Result(6) = 0.5*(tmpRes1(4) + tmpRes2(4));
Result(4) = 0.5 * (tmpRes1(2) + tmpRes2(2));
Result(5) = 0.5 * (tmpRes1(3) + tmpRes2(3));
Result(6) = 0.5 * (tmpRes1(4) + tmpRes2(4));
return Done;
}
Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result, const Standard_Integer NumberOfCurve) const
Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result,
const Standard_Integer NumberOfCurve) const
{
Handle(Adaptor2d_Curve2d) Cur2D;
Handle(Adaptor3d_Surface) Surf;
Standard_Real U=0, Length=0;
Standard_Real U = 0, Length = 0;
if (NumberOfCurve == 1) {
if (NumberOfCurve == 1)
{
Cur2D = myC2D1;
Surf = mySurf1;
Adaptor3d_CurveOnSurface CurOnSur(myC2D1, mySurf1);
U = GetUParameter(CurOnSur, S, 1);
if(myCase == 3) Length = myLength1;
else Length = myLength;
if (myCase == 3)
Length = myLength1;
else
Length = myLength;
}
else if (NumberOfCurve == 2) {
else if (NumberOfCurve == 2)
{
Cur2D = myC2D2;
Surf = mySurf2;
Adaptor3d_CurveOnSurface CurOnSur(myC2D2, mySurf2);
@ -634,7 +692,8 @@ Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S, const S
gp_Vec2d dC2D_dU, d2C2D_dU2;
gp_Vec dC_dU, d2C_dU2, dC_dS, d2C_dS2, dS_dV, dS_dW, d2S_dV2, d2S_dW2, d2S_dVdW;
switch(Order) {
switch (Order)
{
case 0:
Cur2D->D0(U, C2D);
Surf->D0(C2D.X(), C2D.Y(), C);
@ -651,13 +710,13 @@ Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S, const S
dV_dU = dC2D_dU.X();
dW_dU = dC2D_dU.Y();
Surf->D1(C2D.X(), C2D.Y(), C, dS_dV, dS_dW);
dC_dU = dS_dV*dV_dU + dS_dW*dW_dU;
dC_dU = dS_dV * dV_dU + dS_dW * dW_dU;
Mag = dC_dU.Magnitude();
dU_dS = Length/Mag;
dU_dS = Length / Mag;
dV_dS = dV_dU*dU_dS;
dW_dS = dW_dU*dU_dS;
dC_dS = dC_dU*dU_dS;
dV_dS = dV_dU * dU_dS;
dW_dS = dW_dU * dU_dS;
dC_dS = dC_dU * dU_dS;
Result(0) = dV_dS;
Result(1) = dW_dS;
@ -673,21 +732,21 @@ Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S, const S
d2V_dU2 = d2C2D_dU2.X();
d2W_dU2 = d2C2D_dU2.Y();
Surf->D2(C2D.X(), C2D.Y(), C, dS_dV, dS_dW, d2S_dV2, d2S_dW2, d2S_dVdW);
dC_dU = dS_dV*dV_dU + dS_dW*dW_dU;
d2C_dU2 = (d2S_dV2*dV_dU + d2S_dVdW*dW_dU)*dV_dU + dS_dV*d2V_dU2 +
(d2S_dVdW*dV_dU + d2S_dW2*dW_dU)*dW_dU + dS_dW*d2W_dU2;
dC_dU = dS_dV * dV_dU + dS_dW * dW_dU;
d2C_dU2 = (d2S_dV2 * dV_dU + d2S_dVdW * dW_dU) * dV_dU + dS_dV * d2V_dU2
+ (d2S_dVdW * dV_dU + d2S_dW2 * dW_dU) * dW_dU + dS_dW * d2W_dU2;
Mag = dC_dU.Magnitude();
dU_dS = Length/Mag;
d2U_dS2 = -Length*dC_dU.Dot(d2C_dU2)*dU_dS/(Mag*Mag*Mag);
dU_dS = Length / Mag;
d2U_dS2 = -Length * dC_dU.Dot(d2C_dU2) * dU_dS / (Mag * Mag * Mag);
dV_dS = dV_dU * dU_dS;
dW_dS = dW_dU * dU_dS;
d2V_dS2 = d2V_dU2*dU_dS*dU_dS + dV_dU*d2U_dS2;
d2W_dS2 = d2W_dU2*dU_dS*dU_dS + dW_dU*d2U_dS2;
d2V_dS2 = d2V_dU2 * dU_dS * dU_dS + dV_dU * d2U_dS2;
d2W_dS2 = d2W_dU2 * dU_dS * dU_dS + dW_dU * d2U_dS2;
d2U_dS2 = -dC_dU.Dot(d2C_dU2)*dU_dS/(Mag*Mag);
d2C_dS2 = (d2S_dV2 * dV_dS + d2S_dVdW * dW_dS) * dV_dS + dS_dV * d2V_dS2 +
(d2S_dW2 * dW_dS + d2S_dVdW * dV_dS) * dW_dS + dS_dW * d2W_dS2;
d2U_dS2 = -dC_dU.Dot(d2C_dU2) * dU_dS / (Mag * Mag);
d2C_dS2 = (d2S_dV2 * dV_dS + d2S_dVdW * dW_dS) * dV_dS + dS_dV * d2V_dS2
+ (d2S_dW2 * dW_dS + d2S_dVdW * dV_dS) * dW_dS + dS_dW * d2W_dS2;
Result(0) = d2V_dS2;
Result(1) = d2W_dS2;
@ -696,7 +755,8 @@ Standard_Boolean Approx_CurvlinFunc::EvalCurOnSur(const Standard_Real S, const S
Result(4) = d2C_dS2.Z();
break;
default: Result(0) = Result(1) = Result(2) = Result(3) = Result(4) = 0;
default:
Result(0) = Result(1) = Result(2) = Result(3) = Result(4) = 0;
return Standard_False;
}
return Standard_True;

View File

@ -31,16 +31,20 @@ class Approx_CurvlinFunc : public Standard_Transient
{
public:
Standard_EXPORT Approx_CurvlinFunc(const Handle(Adaptor3d_Curve)& C, const Standard_Real Tol);
Standard_EXPORT Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D, const Handle(Adaptor3d_Surface)& S, const Standard_Real Tol);
Standard_EXPORT Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Real Tol);
Standard_EXPORT Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D1, const Handle(Adaptor2d_Curve2d)& C2D2, const Handle(Adaptor3d_Surface)& S1, const Handle(Adaptor3d_Surface)& S2, const Standard_Real Tol);
Standard_EXPORT Approx_CurvlinFunc(const Handle(Adaptor2d_Curve2d)& C2D1,
const Handle(Adaptor2d_Curve2d)& C2D2,
const Handle(Adaptor3d_Surface)& S1,
const Handle(Adaptor3d_Surface)& S2,
const Standard_Real Tol);
//! ---Purpose Update the tolerance to used
Standard_EXPORT void SetTol (const Standard_Real Tol);
Standard_EXPORT void SetTol(const Standard_Real Tol);
Standard_EXPORT Standard_Real FirstParameter() const;
@ -48,64 +52,74 @@ public:
//! Returns the number of intervals for continuity
//! <S>. May be one if Continuity(me) >= <S>
Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const;
Standard_EXPORT Standard_Integer NbIntervals(const GeomAbs_Shape S) const;
//! Stores in <T> the parameters bounding the intervals
//! of continuity <S>.
//!
//! The array must provide enough room to accommodate
//! for the parameters. i.e. T.Length() > NbIntervals()
Standard_EXPORT void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const;
Standard_EXPORT void Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const;
//! if First < 0 or Last > 1
Standard_EXPORT void Trim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol);
Standard_EXPORT void Trim(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol);
//! Computes length of the curve.
Standard_EXPORT void Length();
//! Computes length of the curve segment.
Standard_EXPORT Standard_Real Length (Adaptor3d_Curve& C, const Standard_Real FirstU, const Standard_Real LasrU) const;
Standard_EXPORT Standard_Real Length(Adaptor3d_Curve& C,
const Standard_Real FirstU,
const Standard_Real LasrU) const;
Standard_EXPORT Standard_Real GetLength() const;
//! returns original parameter corresponding S. if
//! Case == 1 computation is performed on myC2D1 and mySurf1,
//! otherwise it is done on myC2D2 and mySurf2.
Standard_EXPORT Standard_Real GetUParameter (Adaptor3d_Curve& C, const Standard_Real S, const Standard_Integer NumberOfCurve) const;
Standard_EXPORT Standard_Real GetUParameter(Adaptor3d_Curve& C,
const Standard_Real S,
const Standard_Integer NumberOfCurve) const;
//! returns original parameter corresponding S.
Standard_EXPORT Standard_Real GetSParameter (const Standard_Real U) const;
Standard_EXPORT Standard_Real GetSParameter(const Standard_Real U) const;
//! if myCase != 1
Standard_EXPORT Standard_Boolean EvalCase1 (const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result) const;
Standard_EXPORT Standard_Boolean EvalCase1(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result) const;
//! if myCase != 2
Standard_EXPORT Standard_Boolean EvalCase2 (const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result) const;
Standard_EXPORT Standard_Boolean EvalCase2(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result) const;
//! if myCase != 3
Standard_EXPORT Standard_Boolean EvalCase3 (const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result);
Standard_EXPORT Standard_Boolean EvalCase3(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result);
DEFINE_STANDARD_RTTIEXT(Approx_CurvlinFunc,Standard_Transient)
DEFINE_STANDARD_RTTIEXT(Approx_CurvlinFunc, Standard_Transient)
protected:
private:
Standard_EXPORT void Init();
Standard_EXPORT void Init (Adaptor3d_Curve& C, Handle(TColStd_HArray1OfReal)& Si, Handle(TColStd_HArray1OfReal)& Ui) const;
Standard_EXPORT void Init(Adaptor3d_Curve& C,
Handle(TColStd_HArray1OfReal)& Si,
Handle(TColStd_HArray1OfReal)& Ui) const;
//! returns curvilinear parameter corresponding U.
Standard_EXPORT Standard_Real GetSParameter (Adaptor3d_Curve& C, const Standard_Real U, const Standard_Real Length) const;
Standard_EXPORT Standard_Real GetSParameter(Adaptor3d_Curve& C,
const Standard_Real U,
const Standard_Real Length) const;
Standard_EXPORT Standard_Boolean EvalCurOnSur (const Standard_Real S, const Standard_Integer Order, TColStd_Array1OfReal& Result, const Standard_Integer NumberOfCurve) const;
Standard_EXPORT Standard_Boolean EvalCurOnSur(const Standard_Real S,
const Standard_Integer Order,
TColStd_Array1OfReal& Result,
const Standard_Integer NumberOfCurve) const;
Handle(Adaptor3d_Curve) myC3D;
Handle(Adaptor2d_Curve2d) myC2D1;
@ -129,14 +143,6 @@ private:
Handle(TColStd_HArray1OfReal) mySi_1;
Handle(TColStd_HArray1OfReal) myUi_2;
Handle(TColStd_HArray1OfReal) mySi_2;
};
#endif // _Approx_CurvlinFunc_HeaderFile

View File

@ -20,46 +20,60 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <AppParCurves_SequenceOfMultiCurve.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <Standard_Integer.hxx>
#include <AppParCurves_Constraint.hxx>
#include <AppCont_Function.hxx>
#include <AppParCurves_Constraint.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <AppParCurves_SequenceOfMultiCurve.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_SequenceOfReal.hxx>
class AppParCurves_MultiCurve;
class Approx_FitAndDivide
{
public:
DEFINE_STANDARD_ALLOC
//! The MultiLine <Line> will be approximated until tolerances
//! will be reached.
//! The approximation will be done from degreemin to degreemax
//! with a cutting if the corresponding boolean is True.
Standard_EXPORT Approx_FitAndDivide(const AppCont_Function& Line, const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-5, const Standard_Real Tolerance2d = 1.0e-5, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
Standard_EXPORT Approx_FitAndDivide(
const AppCont_Function& Line,
const Standard_Integer degreemin = 3,
const Standard_Integer degreemax = 8,
const Standard_Real Tolerance3d = 1.0e-5,
const Standard_Real Tolerance2d = 1.0e-5,
const Standard_Boolean cutting = Standard_False,
const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint,
const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
//! Initializes the fields of the algorithm.
Standard_EXPORT Approx_FitAndDivide(const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-05, const Standard_Real Tolerance2d = 1.0e-05, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
Standard_EXPORT Approx_FitAndDivide(
const Standard_Integer degreemin = 3,
const Standard_Integer degreemax = 8,
const Standard_Real Tolerance3d = 1.0e-05,
const Standard_Real Tolerance2d = 1.0e-05,
const Standard_Boolean cutting = Standard_False,
const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint,
const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
//! runs the algorithm after having initialized the fields.
Standard_EXPORT void Perform (const AppCont_Function& Line);
Standard_EXPORT void Perform(const AppCont_Function& Line);
//! changes the degrees of the approximation.
Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
Standard_EXPORT void SetDegrees(const Standard_Integer degreemin,
const Standard_Integer degreemax);
//! Changes the tolerances of the approximation.
Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
Standard_EXPORT void SetTolerances(const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d);
//! Changes the constraints of the approximation.
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint FirstC, const AppParCurves_Constraint LastC);
Standard_EXPORT void SetConstraints(const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC);
//! Changes the max number of segments, which is allowed for cutting.
Standard_EXPORT void SetMaxSegments (const Standard_Integer theMaxSegments);
Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments);
//! Set inverse order of degree selection:
//! if theInvOrdr = true, current degree is chosen by inverse order -
@ -82,32 +96,29 @@ public:
Standard_EXPORT Standard_Boolean IsToleranceReached() const;
//! returns the tolerances 2d and 3d of the <Index> MultiCurve.
Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
Standard_EXPORT void Error(const Standard_Integer Index,
Standard_Real& tol3d,
Standard_Real& tol2d) const;
//! Returns the number of MultiCurve doing the approximation
//! of the MultiLine.
Standard_EXPORT Standard_Integer NbMultiCurves() const;
//! returns the approximation MultiCurve of range <Index>.
Standard_EXPORT AppParCurves_MultiCurve Value (const Standard_Integer Index = 1) const;
Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& firstp, Standard_Real& lastp) const;
Standard_EXPORT AppParCurves_MultiCurve Value(const Standard_Integer Index = 1) const;
Standard_EXPORT void Parameters(const Standard_Integer Index,
Standard_Real& firstp,
Standard_Real& lastp) const;
protected:
private:
//! is internally used by the algorithms.
Standard_EXPORT Standard_Boolean Compute (const AppCont_Function& Line, const Standard_Real Ufirst, const Standard_Real Ulast, Standard_Real& TheTol3d, Standard_Real& TheTol2d);
Standard_EXPORT Standard_Boolean Compute(const AppCont_Function& Line,
const Standard_Real Ufirst,
const Standard_Real Ulast,
Standard_Real& TheTol3d,
Standard_Real& TheTol2d);
AppParCurves_SequenceOfMultiCurve myMultiCurves;
TColStd_SequenceOfReal myfirstparam;
@ -129,14 +140,6 @@ private:
Standard_Integer myMaxSegments;
Standard_Boolean myInvOrder;
Standard_Boolean myHangChecking;
};
#endif // _Approx_FitAndDivide_HeaderFile

View File

@ -20,46 +20,60 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <AppParCurves_SequenceOfMultiCurve.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <Standard_Integer.hxx>
#include <AppParCurves_Constraint.hxx>
#include <AppCont_Function.hxx>
#include <AppParCurves_Constraint.hxx>
#include <AppParCurves_MultiCurve.hxx>
#include <AppParCurves_SequenceOfMultiCurve.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_SequenceOfReal.hxx>
class AppParCurves_MultiCurve;
class Approx_FitAndDivide2d
{
public:
DEFINE_STANDARD_ALLOC
//! The MultiLine <Line> will be approximated until tolerances
//! will be reached.
//! The approximation will be done from degreemin to degreemax
//! with a cutting if the corresponding boolean is True.
Standard_EXPORT Approx_FitAndDivide2d(const AppCont_Function& Line, const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-5, const Standard_Real Tolerance2d = 1.0e-5, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
Standard_EXPORT Approx_FitAndDivide2d(
const AppCont_Function& Line,
const Standard_Integer degreemin = 3,
const Standard_Integer degreemax = 8,
const Standard_Real Tolerance3d = 1.0e-5,
const Standard_Real Tolerance2d = 1.0e-5,
const Standard_Boolean cutting = Standard_False,
const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint,
const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
//! Initializes the fields of the algorithm.
Standard_EXPORT Approx_FitAndDivide2d(const Standard_Integer degreemin = 3, const Standard_Integer degreemax = 8, const Standard_Real Tolerance3d = 1.0e-05, const Standard_Real Tolerance2d = 1.0e-05, const Standard_Boolean cutting = Standard_False, const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint, const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
Standard_EXPORT Approx_FitAndDivide2d(
const Standard_Integer degreemin = 3,
const Standard_Integer degreemax = 8,
const Standard_Real Tolerance3d = 1.0e-05,
const Standard_Real Tolerance2d = 1.0e-05,
const Standard_Boolean cutting = Standard_False,
const AppParCurves_Constraint FirstC = AppParCurves_TangencyPoint,
const AppParCurves_Constraint LastC = AppParCurves_TangencyPoint);
//! runs the algorithm after having initialized the fields.
Standard_EXPORT void Perform (const AppCont_Function& Line);
Standard_EXPORT void Perform(const AppCont_Function& Line);
//! changes the degrees of the approximation.
Standard_EXPORT void SetDegrees (const Standard_Integer degreemin, const Standard_Integer degreemax);
Standard_EXPORT void SetDegrees(const Standard_Integer degreemin,
const Standard_Integer degreemax);
//! Changes the tolerances of the approximation.
Standard_EXPORT void SetTolerances (const Standard_Real Tolerance3d, const Standard_Real Tolerance2d);
Standard_EXPORT void SetTolerances(const Standard_Real Tolerance3d,
const Standard_Real Tolerance2d);
//! Changes the constraints of the approximation.
Standard_EXPORT void SetConstraints (const AppParCurves_Constraint FirstC, const AppParCurves_Constraint LastC);
Standard_EXPORT void SetConstraints(const AppParCurves_Constraint FirstC,
const AppParCurves_Constraint LastC);
//! Changes the max number of segments, which is allowed for cutting.
Standard_EXPORT void SetMaxSegments (const Standard_Integer theMaxSegments);
Standard_EXPORT void SetMaxSegments(const Standard_Integer theMaxSegments);
//! Set inverse order of degree selection:
//! if theInvOrdr = true, current degree is chosen by inverse order -
@ -82,32 +96,29 @@ public:
Standard_EXPORT Standard_Boolean IsToleranceReached() const;
//! returns the tolerances 2d and 3d of the <Index> MultiCurve.
Standard_EXPORT void Error (const Standard_Integer Index, Standard_Real& tol3d, Standard_Real& tol2d) const;
Standard_EXPORT void Error(const Standard_Integer Index,
Standard_Real& tol3d,
Standard_Real& tol2d) const;
//! Returns the number of MultiCurve doing the approximation
//! of the MultiLine.
Standard_EXPORT Standard_Integer NbMultiCurves() const;
//! returns the approximation MultiCurve of range <Index>.
Standard_EXPORT AppParCurves_MultiCurve Value (const Standard_Integer Index = 1) const;
Standard_EXPORT void Parameters (const Standard_Integer Index, Standard_Real& firstp, Standard_Real& lastp) const;
Standard_EXPORT AppParCurves_MultiCurve Value(const Standard_Integer Index = 1) const;
Standard_EXPORT void Parameters(const Standard_Integer Index,
Standard_Real& firstp,
Standard_Real& lastp) const;
protected:
private:
//! is internally used by the algorithms.
Standard_EXPORT Standard_Boolean Compute (const AppCont_Function& Line, const Standard_Real Ufirst, const Standard_Real Ulast, Standard_Real& TheTol3d, Standard_Real& TheTol2d);
Standard_EXPORT Standard_Boolean Compute(const AppCont_Function& Line,
const Standard_Real Ufirst,
const Standard_Real Ulast,
Standard_Real& TheTol3d,
Standard_Real& TheTol2d);
AppParCurves_SequenceOfMultiCurve myMultiCurves;
TColStd_SequenceOfReal myfirstparam;
@ -129,13 +140,6 @@ private:
Standard_Integer myMaxSegments;
Standard_Boolean myInvOrder;
Standard_Boolean myHangChecking;
};
#endif // _Approx_FitAndDivide2d_HeaderFile

View File

@ -18,10 +18,8 @@
#include <AppParCurves_MultiCurve.hxx>
#define MultiLine AppCont_Function
#define MultiLine_hxx <AppCont_Function.hxx>
#define Approx_ComputeCLine Approx_FitAndDivide2d
#define Approx_ComputeCLine_hxx <Approx_FitAndDivide2d.hxx>
#include "../Approx/Approx_ComputeCLine.gxx"

View File

@ -18,10 +18,8 @@
#include <AppParCurves_MultiCurve.hxx>
#define MultiLine AppCont_Function
#define MultiLine_hxx <AppCont_Function.hxx>
#define Approx_ComputeCLine Approx_FitAndDivide
#define Approx_ComputeCLine_hxx <Approx_FitAndDivide.hxx>
#include "../Approx/Approx_ComputeCLine.gxx"

View File

@ -23,5 +23,4 @@
DEFINE_HARRAY1(Approx_HArray1OfAdHSurface, Approx_Array1OfAdHSurface)
#endif

View File

@ -22,5 +22,4 @@
DEFINE_HARRAY1(Approx_HArray1OfGTrsf2d, Approx_Array1OfGTrsf2d)
#endif

View File

@ -12,46 +12,49 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AppParCurves_MultiPoint.hxx>
#include <Approx_MCurvesToBSpCurve.hxx>
#include <BSplCLib.hxx>
#include <Convert_CompBezierCurves2dToBSplineCurve2d.hxx>
#include <Convert_CompBezierCurvesToBSplineCurve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#ifdef OCCT_DEBUG
static void DEBUG(const AppParCurves_MultiCurve& MC) {
static void DEBUG(const AppParCurves_MultiCurve& MC)
{
Standard_Integer i, j;
Standard_Integer nbcu = MC.NbCurves();
Standard_Integer nbpoles = MC.NbPoles();
TColgp_Array1OfPnt Poles(1, nbpoles);
TColgp_Array1OfPnt2d Poles2d(1, nbpoles);
for (i = 1; i <= nbcu; i++) {
for (i = 1; i <= nbcu; i++)
{
std::cout << " Curve No. " << i << std::endl;
if (MC.Dimension(i) == 3) {
if (MC.Dimension(i) == 3)
{
MC.Curve(i, Poles);
for (j = 1; j <= nbpoles; j++) {
std::cout<< " Pole = " << Poles(j).X() <<" "<<Poles(j).Y()<<" "<<Poles(j).Z()<< std::endl;
for (j = 1; j <= nbpoles; j++)
{
std::cout << " Pole = " << Poles(j).X() << " " << Poles(j).Y() << " " << Poles(j).Z()
<< std::endl;
}
}
else {
else
{
MC.Curve(i, Poles2d);
for (j = 1; j <= nbpoles; j++) {
std::cout<< " Pole = " << Poles2d(j).X() <<" "<<Poles2d(j).Y()<< std::endl;
for (j = 1; j <= nbpoles; j++)
{
std::cout << " Pole = " << Poles2d(j).X() << " " << Poles2d(j).Y() << std::endl;
}
}
}
}
#endif
Approx_MCurvesToBSpCurve::Approx_MCurvesToBSpCurve()
{
myDone = Standard_False;
@ -68,35 +71,35 @@ void Approx_MCurvesToBSpCurve::Append(const AppParCurves_MultiCurve& MC)
myCurves.Append(MC);
}
void Approx_MCurvesToBSpCurve::Perform()
{
Perform(myCurves);
}
void Approx_MCurvesToBSpCurve::Perform
(const AppParCurves_SequenceOfMultiCurve& TheSeq)
void Approx_MCurvesToBSpCurve::Perform(const AppParCurves_SequenceOfMultiCurve& TheSeq)
{
Standard_Integer i, j, deg=0;
Standard_Integer i, j, deg = 0;
Standard_Integer nbcu = TheSeq.Length();
AppParCurves_MultiCurve CU;
Standard_Integer nbpolesspl=0, nbknots=0;
Standard_Integer nbpolesspl = 0, nbknots = 0;
#ifdef OCCT_DEBUG
Standard_Boolean debug = Standard_False;
#endif
if (nbcu == 1) {
if (nbcu == 1)
{
CU = TheSeq.Value(1);
deg = CU.Degree();
TColStd_Array1OfReal Knots(1, 2);
TColStd_Array1OfInteger Mults(1, 2);
Knots(1) = 0.0;
Knots(2) = 1.0;
Mults(1) = Mults(2) = deg+1;
mySpline = AppParCurves_MultiBSpCurve (CU, Knots, Mults);
Mults(1) = Mults(2) = deg + 1;
mySpline = AppParCurves_MultiBSpCurve(CU, Knots, Mults);
}
else {
else
{
AppParCurves_MultiPoint P = TheSeq.Value(nbcu).Value(1);
Standard_Integer nb3d = P.NbPoints();
@ -105,8 +108,10 @@ void Approx_MCurvesToBSpCurve::Perform
Convert_CompBezierCurvesToBSplineCurve conv;
Convert_CompBezierCurves2dToBSplineCurve2d conv2d;
if (nb3d != 0) {
for (i = 1; i <= nbcu; i++) {
if (nb3d != 0)
{
for (i = 1; i <= nbcu; i++)
{
CU = TheSeq.Value(i);
TColgp_Array1OfPnt ThePoles3d(1, CU.NbPoles());
CU.Curve(1, ThePoles3d);
@ -115,24 +120,26 @@ void Approx_MCurvesToBSpCurve::Perform
conv.Perform();
}
else if (nb2d != 0) {
for (i = 1; i <= nbcu; i++) {
else if (nb2d != 0)
{
for (i = 1; i <= nbcu; i++)
{
CU = TheSeq.Value(i);
TColgp_Array1OfPnt2d ThePoles2d(1, CU.NbPoles());
CU.Curve(1+nb3d, ThePoles2d);
CU.Curve(1 + nb3d, ThePoles2d);
conv2d.AddCurve(ThePoles2d);
}
conv2d.Perform();
}
// Recuperation:
if (nb3d != 0) {
if (nb3d != 0)
{
nbpolesspl = conv.NbPoles();
nbknots = conv.NbKnots();
}
else if (nb2d != 0) {
else if (nb2d != 0)
{
nbpolesspl = conv2d.NbPoles();
nbknots = conv2d.NbKnots();
}
@ -143,82 +150,110 @@ void Approx_MCurvesToBSpCurve::Perform
TColStd_Array1OfInteger TheMults(1, nbknots);
TColStd_Array1OfReal TheKnots(1, nbknots);
if (nb3d != 0) {
if (nb3d != 0)
{
conv.KnotsAndMults(TheKnots, TheMults);
conv.Poles(PolesSpl);
deg = conv.Degree();
}
else if (nb2d != 0) {
else if (nb2d != 0)
{
conv2d.KnotsAndMults(TheKnots, TheMults);
conv2d.Poles(PolesSpl2d);
deg = conv2d.Degree();
}
for (j = 1; j <= nbpolesspl; j++) {
for (j = 1; j <= nbpolesspl; j++)
{
AppParCurves_MultiPoint MP(nb3d, nb2d);
if (nb3d!=0) {
if (nb3d != 0)
{
MP.SetPoint(1, PolesSpl(j));
}
else if (nb2d!=0) {
MP.SetPoint2d(1+nb3d, PolesSpl2d(j));
else if (nb2d != 0)
{
MP.SetPoint2d(1 + nb3d, PolesSpl2d(j));
}
tabMU.SetValue(j, MP);
}
Standard_Integer kpol = 1, kpoles3d=1, kpoles2d=1;
Standard_Integer kpol = 1, kpoles3d = 1, kpoles2d = 1;
Standard_Integer mydegre, k;
Standard_Integer first, last, Inc, thefirst;
if (nb3d != 0) thefirst = 1;
else thefirst = 2;
if (nb3d != 0)
thefirst = 1;
else
thefirst = 2;
for (i = 1; i <= nbcu; i++) {
for (i = 1; i <= nbcu; i++)
{
CU = TheSeq.Value(i);
mydegre = CU.Degree();
if (TheMults(i+1) == deg) last = deg+1; // Continuite C0
else last = deg; // Continuite C1
if (i==nbcu) {last = deg+1;}
if (TheMults(i + 1) == deg)
last = deg + 1; // Continuite C0
else
last = deg; // Continuite C1
if (i == nbcu)
{
last = deg + 1;
}
first = 1;
if (i==1) first = 1;
else if ((TheMults(i)== deg-1) || (TheMults(i)==deg)) first = 2;
if (i == 1)
first = 1;
else if ((TheMults(i) == deg - 1) || (TheMults(i) == deg))
first = 2;
for (j = 2; j <= nb3d; j++) {
for (j = 2; j <= nb3d; j++)
{
kpol = kpoles3d;
TColgp_Array1OfPnt ThePoles(1, CU.NbPoles());
CU.Curve(j, ThePoles);
Inc = deg-mydegre;
TColgp_Array1OfPnt Points(1, deg+1);
if (Inc > 0) {
BSplCLib::IncreaseDegree(deg, ThePoles, BSplCLib::NoWeights(),
Points, BSplCLib::NoWeights());
Inc = deg - mydegre;
TColgp_Array1OfPnt Points(1, deg + 1);
if (Inc > 0)
{
BSplCLib::IncreaseDegree(deg,
ThePoles,
BSplCLib::NoWeights(),
Points,
BSplCLib::NoWeights());
}
else {
else
{
Points = ThePoles;
}
for (k = first; k <= last; k++) {
for (k = first; k <= last; k++)
{
tabMU.ChangeValue(kpol++).SetPoint(j, Points(k));
}
}
kpoles3d = kpol;
for (j = thefirst; j <= nb2d; j++) {
for (j = thefirst; j <= nb2d; j++)
{
kpol = kpoles2d;
TColgp_Array1OfPnt2d ThePoles2d(1, CU.NbPoles());
CU.Curve(j+nb3d, ThePoles2d);
CU.Curve(j + nb3d, ThePoles2d);
Inc = deg-mydegre;
TColgp_Array1OfPnt2d Points2d(1, deg+1);
if (Inc > 0) {
BSplCLib::IncreaseDegree(deg, ThePoles2d, BSplCLib::NoWeights(),
Points2d, BSplCLib::NoWeights());
Inc = deg - mydegre;
TColgp_Array1OfPnt2d Points2d(1, deg + 1);
if (Inc > 0)
{
BSplCLib::IncreaseDegree(deg,
ThePoles2d,
BSplCLib::NoWeights(),
Points2d,
BSplCLib::NoWeights());
}
else {
else
{
Points2d = ThePoles2d;
}
for (k = first; k <= last; k++) {
tabMU.ChangeValue(kpol++).SetPoint2d(j+nb3d, Points2d(k));
for (k = first; k <= last; k++)
{
tabMU.ChangeValue(kpol++).SetPoint2d(j + nb3d, Points2d(k));
}
}
kpoles2d = kpol;
@ -227,22 +262,19 @@ void Approx_MCurvesToBSpCurve::Perform
mySpline = AppParCurves_MultiBSpCurve(tabMU, TheKnots, TheMults);
}
#ifdef OCCT_DEBUG
if(debug) DEBUG(mySpline);
if (debug)
DEBUG(mySpline);
#endif
myDone = Standard_True;
}
const AppParCurves_MultiBSpCurve& Approx_MCurvesToBSpCurve::Value() const
{
return mySpline;
}
const AppParCurves_MultiBSpCurve& Approx_MCurvesToBSpCurve::ChangeValue()
{
return mySpline;
}

View File

@ -24,24 +24,20 @@
#include <AppParCurves_SequenceOfMultiCurve.hxx>
class AppParCurves_MultiCurve;
class Approx_MCurvesToBSpCurve
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT Approx_MCurvesToBSpCurve();
Standard_EXPORT void Reset();
Standard_EXPORT void Append (const AppParCurves_MultiCurve& MC);
Standard_EXPORT void Append(const AppParCurves_MultiCurve& MC);
Standard_EXPORT void Perform();
Standard_EXPORT void Perform (const AppParCurves_SequenceOfMultiCurve& TheSeq);
Standard_EXPORT void Perform(const AppParCurves_SequenceOfMultiCurve& TheSeq);
//! return the composite MultiCurves as a MultiBSpCurve.
Standard_EXPORT const AppParCurves_MultiBSpCurve& Value() const;
@ -49,30 +45,11 @@ public:
//! return the composite MultiCurves as a MultiBSpCurve.
Standard_EXPORT const AppParCurves_MultiBSpCurve& ChangeValue();
protected:
private:
AppParCurves_MultiBSpCurve mySpline;
Standard_Boolean myDone;
AppParCurves_SequenceOfMultiCurve myCurves;
};
#endif // _Approx_MCurvesToBSpCurve_HeaderFile

View File

@ -17,11 +17,11 @@
#ifndef _Approx_ParametrizationType_HeaderFile
#define _Approx_ParametrizationType_HeaderFile
enum Approx_ParametrizationType
{
Approx_ChordLength, //!< parameters of points are proportionate to distances between them
Approx_Centripetal, //!< parameters of points are proportionate to square roots of distances between them
Approx_Centripetal, //!< parameters of points are proportionate to square roots of distances
//!< between them
Approx_IsoParametric //!< parameters of points are distributed uniformly
};

View File

@ -17,41 +17,41 @@
#include <Approx_SameParameter.hxx>
#include <Adaptor2d_Curve2d.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_Surface.hxx>
#include <Extrema_ExtPC.hxx>
#include <Extrema_LocateExtPC.hxx>
#include <Geom2dAdaptor.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomLib_MakeCurvefromApprox.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Geom2dAdaptor.hxx>
//=======================================================================
//class : Approx_SameParameter_Evaluator
//purpose : Used in same parameterization curve approximation.
//=======================================================================
//=================================================================================================
class Approx_SameParameter_Evaluator : public AdvApprox_EvaluatorFunction
{
public:
Approx_SameParameter_Evaluator (const TColStd_Array1OfReal& theFlatKnots,
Approx_SameParameter_Evaluator(const TColStd_Array1OfReal& theFlatKnots,
const TColStd_Array1OfReal& thePoles,
const Handle(Adaptor2d_Curve2d)& theHCurve2d)
: FlatKnots(theFlatKnots),
Poles(thePoles),
HCurve2d(theHCurve2d) {}
HCurve2d(theHCurve2d)
{
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
const TColStd_Array1OfReal& FlatKnots;
@ -59,21 +59,19 @@ private:
Handle(Adaptor2d_Curve2d) HCurve2d;
};
//=======================================================================
//function : Evaluate
//purpose :
//=======================================================================
void Approx_SameParameter_Evaluator::Evaluate (Standard_Integer *,/*Dimension*/
//=================================================================================================
void Approx_SameParameter_Evaluator::Evaluate(Standard_Integer*, /*Dimension*/
Standard_Real /*StartEnd*/[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result,
Standard_Integer *ReturnCode)
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result,
Standard_Integer* ReturnCode)
{
const Standard_Integer aDegree = 3;
Standard_Integer extrap_mode[2] = {aDegree, aDegree};
Standard_Real eval_result[2];
Standard_Real *PolesArray = (Standard_Real *) &Poles(Poles.Lower()) ;
Standard_Real* PolesArray = (Standard_Real*)&Poles(Poles.Lower());
// Evaluate the 1D B-Spline that represents the change in parameterization.
BSplCLib::Eval(*Parameter,
@ -91,22 +89,20 @@ void Approx_SameParameter_Evaluator::Evaluate (Standard_Integer *,/*Dimension*/
if (*DerivativeRequest == 0)
{
HCurve2d->D0(eval_result[0], aPoint);
aPoint.Coord(Result[0],Result[1]);
aPoint.Coord(Result[0], Result[1]);
}
else if (*DerivativeRequest == 1)
{
HCurve2d->D1(eval_result[0], aPoint, aVector);
aVector.Multiply(eval_result[1]);
aVector.Coord(Result[0],Result[1]);
aVector.Coord(Result[0], Result[1]);
}
ReturnCode[0] = 0;
}
//=======================================================================
//function : ProjectPointOnCurve
//purpose :
//=======================================================================
//=================================================================================================
static void ProjectPointOnCurve(const Standard_Real InitValue,
const gp_Pnt& APoint,
const Standard_Real Tolerance,
@ -119,17 +115,16 @@ static void ProjectPointOnCurve(const Standard_Real InitValue,
gp_Pnt a_point;
gp_Vec vector, d1, d2;
Standard_Real func, func_derivative,
param = InitValue;
Standard_Real func, func_derivative, param = InitValue;
Status = Standard_False;
do
{
num_iter++;
Curve.D2(param, a_point, d1, d2);
vector = gp_Vec(a_point,APoint);
vector = gp_Vec(a_point, APoint);
func = vector.Dot(d1);
if ( Abs(func) < Tolerance * d1.Magnitude())
if (Abs(func) < Tolerance * d1.Magnitude())
{
not_done = 0;
Status = Standard_True;
@ -140,21 +135,19 @@ static void ProjectPointOnCurve(const Standard_Real InitValue,
// Avoid division by zero.
const Standard_Real Toler = 1.0e-12;
if( Abs(func_derivative) > Toler )
if (Abs(func_derivative) > Toler)
param -= func / func_derivative;
param = Max(param,Curve.FirstParameter());
param = Min(param,Curve.LastParameter());
param = Max(param, Curve.FirstParameter());
param = Min(param, Curve.LastParameter());
}
} while (not_done && num_iter <= NumIteration);
Result = param;
}
//=======================================================================
//function : ComputeTolReached
//purpose :
//=======================================================================
//=================================================================================================
static Standard_Real ComputeTolReached(const Handle(Adaptor3d_Curve)& c3d,
const Adaptor3d_CurveOnSurface& cons,
const Standard_Integer nbp)
@ -162,7 +155,7 @@ static Standard_Real ComputeTolReached(const Handle(Adaptor3d_Curve)& c3d,
Standard_Real d2 = 0.0; // Square max discrete deviation.
const Standard_Real first = c3d->FirstParameter();
const Standard_Real last = c3d->LastParameter();
for(Standard_Integer i = 0; i <= nbp; i++)
for (Standard_Integer i = 0; i <= nbp; i++)
{
Standard_Real t = IntToReal(i) / IntToReal(nbp);
Standard_Real u = first * (1.0 - t) + last * t;
@ -177,11 +170,10 @@ static Standard_Real ComputeTolReached(const Handle(Adaptor3d_Curve)& c3d,
d2 = Precision::Infinite();
break;
}
if (Precision::IsInfinite(Pcons.X()) ||
Precision::IsInfinite(Pcons.Y()) ||
Precision::IsInfinite(Pcons.Z()))
if (Precision::IsInfinite(Pcons.X()) || Precision::IsInfinite(Pcons.Y())
|| Precision::IsInfinite(Pcons.Z()))
{
d2=Precision::Infinite();
d2 = Precision::Infinite();
break;
}
d2 = Max(d2, Pc3d.SquareDistance(Pcons));
@ -193,14 +185,12 @@ static Standard_Real ComputeTolReached(const Handle(Adaptor3d_Curve)& c3d,
return aDeviation;
}
//=======================================================================
//function : Check
//purpose : Check current interpolation for validity.
//=======================================================================
//=================================================================================================
static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
const TColStd_Array1OfReal& Poles,
const Standard_Integer nbp,
const Standard_Real *pc3d,
const Standard_Real* pc3d,
const Handle(Adaptor3d_Curve)& c3d,
const Adaptor3d_CurveOnSurface& cons,
Standard_Real& tol,
@ -229,19 +219,25 @@ static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
const Standard_Integer nn = 2 * nbp;
const Standard_Real unsurnn = 1.0 / nn;
Standard_Real tprev = aParamFirst;
for(Standard_Integer i = 0; i <= nn; i++)
for (Standard_Integer i = 0; i <= nn; i++)
{
// Compute corresponding parameter on 2d curve.
// It should be inside of 3d curve parameter space.
Standard_Real t = unsurnn*i;
Standard_Real tc3d = pc3d[0]*(1.0 - t) + pc3d[nbp - 1] * t; // weight function.
Standard_Real t = unsurnn * i;
Standard_Real tc3d = pc3d[0] * (1.0 - t) + pc3d[nbp - 1] * t; // weight function.
gp_Pnt Pc3d = c3d->Value(tc3d);
Standard_Real tcons;
BSplCLib::Eval(tc3d, Standard_False, 0, extrap_mode[0],
aDegree, FlatKnots, 1, (Standard_Real&)Poles(1), tcons);
BSplCLib::Eval(tc3d,
Standard_False,
0,
extrap_mode[0],
aDegree,
FlatKnots,
1,
(Standard_Real&)Poles(1),
tcons);
if (tcons < tprev ||
tcons > aParamLast)
if (tcons < tprev || tcons > aParamLast)
{
tol = Precision::Infinite();
return Standard_False;
@ -249,12 +245,13 @@ static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
tprev = tcons;
gp_Pnt Pcons = cons.Value(tcons);
Standard_Real temp = Pc3d.SquareDistance(Pcons);
if(temp > d2) d2 = temp;
if (temp > d2)
d2 = temp;
}
tol = sqrt(d2);
// Check poles parameters to be ordered.
for(Standard_Integer i = Poles.Lower() + 1; i <= Poles.Upper(); ++i)
for (Standard_Integer i = Poles.Lower() + 1; i <= Poles.Upper(); ++i)
{
const Standard_Real aPreviousParam = Poles(i - 1);
const Standard_Real aCurrentParam = Poles(i);
@ -266,15 +263,13 @@ static Standard_Boolean Check(const TColStd_Array1OfReal& FlatKnots,
return (tol <= d || tol > 0.8 * oldtol);
}
//=======================================================================
//function : Approx_SameParameter
//purpose :
//=======================================================================
//=================================================================================================
Approx_SameParameter::Approx_SameParameter(const Handle(Geom_Curve)& C3D,
const Handle(Geom2d_Curve)& C2D,
const Handle(Geom_Surface)& S,
const Standard_Real Tol)
: myDeltaMin(Precision::PConfusion()),
: myDeltaMin(Precision::PConfusion()),
mySameParameter(Standard_True),
myDone(Standard_False)
{
@ -284,15 +279,13 @@ Approx_SameParameter::Approx_SameParameter(const Handle(Geom_Curve)& C3D,
Build(Tol);
}
//=======================================================================
//function : Approx_SameParameter
//purpose :
//=======================================================================
//=================================================================================================
Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
const Handle(Geom2d_Curve)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Real Tol)
: myDeltaMin(Precision::PConfusion()),
: myDeltaMin(Precision::PConfusion()),
mySameParameter(Standard_True),
myDone(Standard_False)
{
@ -302,15 +295,13 @@ Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
Build(Tol);
}
//=======================================================================
//function : Approx_SameParameter
//purpose :
//=======================================================================
//=================================================================================================
Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
const Handle(Adaptor2d_Curve2d)& C2D,
const Handle(Adaptor3d_Surface)& S,
const Standard_Real Tol)
: myDeltaMin(Precision::PConfusion()),
: myDeltaMin(Precision::PConfusion()),
mySameParameter(Standard_True),
myDone(Standard_False)
{
@ -320,10 +311,8 @@ Approx_SameParameter::Approx_SameParameter(const Handle(Adaptor3d_Curve)& C3D,
Build(Tol);
}
//=======================================================================
//function : Build
//purpose :
//=======================================================================
//=================================================================================================
void Approx_SameParameter::Build(const Standard_Real Tolerance)
{
// Algorithm:
@ -332,12 +321,12 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
// 2.2) Compute parameters in 2d space if not same parameter.
// 3) Loop over poles number and try to interpolate 2d curve.
// 4) If loop is failed build 2d curve forcibly or use original pcurve.
Standard_Real qpcons[myMaxArraySize], qnewpcons[myMaxArraySize],
qpc3d[myMaxArraySize], qnewpc3d[myMaxArraySize];
Standard_Real qpcons[myMaxArraySize], qnewpcons[myMaxArraySize], qpc3d[myMaxArraySize],
qnewpc3d[myMaxArraySize];
// Create and fill data structure.
Approx_SameParameter_Data aData;
aData.myCOnS = Adaptor3d_CurveOnSurface(myHCurve2d,mySurf);
aData.myCOnS = Adaptor3d_CurveOnSurface(myHCurve2d, mySurf);
aData.myC2dPF = aData.myCOnS.FirstParameter();
aData.myC2dPL = aData.myCOnS.LastParameter();
aData.myC3dPF = myC3d->FirstParameter();
@ -362,7 +351,7 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
const Standard_Real aPercentOfBadProj = 0.3;
Standard_Integer aNbPnt = aData.myNbPnt - RealToInt(aPercentOfBadProj * aData.myNbPnt);
mySameParameter = CheckSameParameter(aData, aMaxSqDeviation);
if(mySameParameter)
if (mySameParameter)
{
myTolReached = ComputeTolReached(myC3d, aData.myCOnS, 2 * myNbSamples);
myDone = Standard_True;
@ -373,10 +362,10 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
// Control number of sample points after checking sameparameter
// If number of points is less then initial one, it means that there are
// problems with projection
if(aData.myNbPnt < aNbPnt )
if (aData.myNbPnt < aNbPnt)
{
myTolReached = ComputeTolReached(myC3d,aData.myCOnS, 2 * myNbSamples);
myCurve2d = Geom2dAdaptor::MakeCurve (*myHCurve2d);
myTolReached = ComputeTolReached(myC3d, aData.myCOnS, 2 * myNbSamples);
myCurve2d = Geom2dAdaptor::MakeCurve(*myHCurve2d);
myDone = Standard_False;
return;
}
@ -385,8 +374,8 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
// Control tangents at the extremities to know if the
// reparametring is possible and calculate the tangents
// at the extremities of the function of change of variable.
Standard_Real tangent[2] = { 0.0, 0.0 };
if(!ComputeTangents(aData.myCOnS, tangent[0], tangent[1]))
Standard_Real tangent[2] = {0.0, 0.0};
if (!ComputeTangents(aData.myCOnS, tangent[0], tangent[1]))
{
// Cannot compute tangents.
mySameParameter = Standard_False;
@ -399,19 +388,18 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
// Try to build B-spline approximation curve using interpolation with degree 3.
// The loop is organized over number of poles.
GeomAbs_Shape aContinuity = myHCurve2d->Continuity();
if(aContinuity > GeomAbs_C1) aContinuity = GeomAbs_C1;
if (aContinuity > GeomAbs_C1)
aContinuity = GeomAbs_C1;
Standard_Real besttol2 = aData.myTol * aData.myTol,
tolsov = Precision::Infinite();
Standard_Boolean interpolok = Standard_False,
hasCountChanged = Standard_False;
Standard_Real besttol2 = aData.myTol * aData.myTol, tolsov = Precision::Infinite();
Standard_Boolean interpolok = Standard_False, hasCountChanged = Standard_False;
do
{
// Interpolation data.
Standard_Integer num_knots = aData.myNbPnt + 7;
Standard_Integer num_poles = aData.myNbPnt + 3;
TColStd_Array1OfReal Poles(1, num_poles);
TColStd_Array1OfReal FlatKnots(1 ,num_knots);
TColStd_Array1OfReal FlatKnots(1, num_knots);
if (!Interpolate(aData, tangent[0], tangent[1], Poles, FlatKnots))
{
@ -423,43 +411,53 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
}
Standard_Real algtol = sqrt(besttol2);
interpolok = Check (FlatKnots, Poles, aData.myNbPnt+1, aData.myPC3d,
myC3d, aData.myCOnS, algtol, tolsov);
interpolok =
Check(FlatKnots, Poles, aData.myNbPnt + 1, aData.myPC3d, myC3d, aData.myCOnS, algtol, tolsov);
tolsov = algtol;
// Try to build 2d curve and check it for validity.
if(interpolok)
if (interpolok)
{
Standard_Real besttol = sqrt(besttol2);
Handle(TColStd_HArray1OfReal) tol1d,tol2d,tol3d;
tol1d = new TColStd_HArray1OfReal(1,2);
Handle(TColStd_HArray1OfReal) tol1d, tol2d, tol3d;
tol1d = new TColStd_HArray1OfReal(1, 2);
tol1d->SetValue(1, mySurf->UResolution(besttol));
tol1d->SetValue(2, mySurf->VResolution(besttol));
Approx_SameParameter_Evaluator ev (FlatKnots, Poles, myHCurve2d);
Approx_SameParameter_Evaluator ev(FlatKnots, Poles, myHCurve2d);
Standard_Integer aMaxDeg = 11, aMaxSeg = 1000;
AdvApprox_ApproxAFunction anApproximator(2,0,0,tol1d,tol2d,tol3d,aData.myC3dPF,aData.myC3dPL,
aContinuity,aMaxDeg,aMaxSeg,ev);
AdvApprox_ApproxAFunction anApproximator(2,
0,
0,
tol1d,
tol2d,
tol3d,
aData.myC3dPF,
aData.myC3dPL,
aContinuity,
aMaxDeg,
aMaxSeg,
ev);
if (anApproximator.IsDone() || anApproximator.HasResult())
{
Adaptor3d_CurveOnSurface ACS = aData.myCOnS;
GeomLib_MakeCurvefromApprox aCurveBuilder(anApproximator);
Handle(Geom2d_BSplineCurve) aC2d = aCurveBuilder.Curve2dFromTwo1d(1,2);
Handle(Geom2d_BSplineCurve) aC2d = aCurveBuilder.Curve2dFromTwo1d(1, 2);
Handle(Adaptor2d_Curve2d) aHCurve2d = new Geom2dAdaptor_Curve(aC2d);
aData.myCOnS.Load(aHCurve2d);
myTolReached = ComputeTolReached(myC3d,aData.myCOnS, 2 * myNbSamples);
myTolReached = ComputeTolReached(myC3d, aData.myCOnS, 2 * myNbSamples);
const Standard_Real aMult = 250.0; // To be tolerant with discrete tolerance.
if (myTolReached < aMult * besttol )
if (myTolReached < aMult * besttol)
{
myCurve2d = aC2d;
myHCurve2d = aHCurve2d;
myDone = Standard_True;
break;
}
else if(aData.myNbPnt < myMaxArraySize - 1)
else if (aData.myNbPnt < myMaxArraySize - 1)
{
interpolok = Standard_False;
aData.myCOnS = ACS;
@ -473,51 +471,59 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
if (!interpolok)
hasCountChanged = IncreaseNbPoles(Poles, FlatKnots, aData, besttol2);
} while(!interpolok && hasCountChanged);
} while (!interpolok && hasCountChanged);
if (!myDone)
{
// Loop is finished unsuccessfully. Fix tolerance by maximal deviation,
// using data from the last loop iteration or initial data. Use data set with minimal deflection.
// using data from the last loop iteration or initial data. Use data set with minimal
// deflection.
// Original 2d curve.
aData.myCOnS.Load(myHCurve2d);
myTolReached = ComputeTolReached(myC3d,aData.myCOnS, 2 * myNbSamples);
myCurve2d = Geom2dAdaptor::MakeCurve (*myHCurve2d);
myTolReached = ComputeTolReached(myC3d, aData.myCOnS, 2 * myNbSamples);
myCurve2d = Geom2dAdaptor::MakeCurve(*myHCurve2d);
// Approximation curve.
Standard_Integer num_knots = aData.myNbPnt + 7;
Standard_Integer num_poles = aData.myNbPnt + 3;
TColStd_Array1OfReal Poles(1, num_poles);
TColStd_Array1OfReal FlatKnots(1 ,num_knots);
TColStd_Array1OfReal FlatKnots(1, num_knots);
Interpolate(aData, tangent[0], tangent[1],
Poles, FlatKnots);
Interpolate(aData, tangent[0], tangent[1], Poles, FlatKnots);
Standard_Real besttol = sqrt(besttol2);
Handle(TColStd_HArray1OfReal) tol1d,tol2d,tol3d;
tol1d = new TColStd_HArray1OfReal(1,2) ;
Handle(TColStd_HArray1OfReal) tol1d, tol2d, tol3d;
tol1d = new TColStd_HArray1OfReal(1, 2);
tol1d->SetValue(1, mySurf->UResolution(besttol));
tol1d->SetValue(2, mySurf->VResolution(besttol));
Approx_SameParameter_Evaluator ev(FlatKnots, Poles, myHCurve2d);
AdvApprox_ApproxAFunction anApproximator(2,0,0,tol1d,tol2d,tol3d,aData.myC3dPF,aData.myC3dPL,
aContinuity,11,40,ev);
AdvApprox_ApproxAFunction anApproximator(2,
0,
0,
tol1d,
tol2d,
tol3d,
aData.myC3dPF,
aData.myC3dPL,
aContinuity,
11,
40,
ev);
if (!anApproximator.IsDone() &&
!anApproximator.HasResult() )
if (!anApproximator.IsDone() && !anApproximator.HasResult())
{
myDone = Standard_False;
return;
}
GeomLib_MakeCurvefromApprox aCurveBuilder(anApproximator);
Handle(Geom2d_BSplineCurve) aC2d = aCurveBuilder.Curve2dFromTwo1d(1,2);
Handle(Geom2d_BSplineCurve) aC2d = aCurveBuilder.Curve2dFromTwo1d(1, 2);
Handle(Adaptor2d_Curve2d) aHCurve2d = new Geom2dAdaptor_Curve(aC2d);
aData.myCOnS.Load(aHCurve2d);
Standard_Real anApproxTol = ComputeTolReached(myC3d,aData.myCOnS,2 * myNbSamples);
Standard_Real anApproxTol = ComputeTolReached(myC3d, aData.myCOnS, 2 * myNbSamples);
if (anApproxTol < myTolReached)
{
myTolReached = anApproxTol;
@ -530,11 +536,13 @@ void Approx_SameParameter::Build(const Standard_Real Tolerance)
myCurveOnSurface = Handle(Adaptor3d_CurveOnSurface)::DownCast(aData.myCOnS.ShallowCopy());
}
//=======================================================================
//function : BuildInitialDistribution
//purpose : Sub-method in Build.
//=======================================================================
Standard_Boolean Approx_SameParameter::BuildInitialDistribution(Approx_SameParameter_Data &theData) const
//=================================================================================================
// function : BuildInitialDistribution
// purpose : Sub-method in Build.
//=================================================================================================
Standard_Boolean Approx_SameParameter::BuildInitialDistribution(
Approx_SameParameter_Data& theData) const
{
// Take a multiple of the sample pof CheckShape,
// at least the control points will be correct.
@ -544,7 +552,7 @@ Standard_Boolean Approx_SameParameter::BuildInitialDistribution(Approx_SameParam
const Standard_Real deltac3d = (theData.myC3dPL - theData.myC3dPF) / myNbSamples;
Standard_Real wcons = theData.myC2dPF;
Standard_Real wc3d = theData.myC3dPF;
for (Standard_Integer ii = 0 ; ii < myNbSamples; ii++)
for (Standard_Integer ii = 0; ii < myNbSamples; ii++)
{
theData.myPC2d[ii] = wcons;
theData.myPC3d[ii] = wc3d;
@ -557,7 +565,7 @@ Standard_Boolean Approx_SameParameter::BuildInitialDistribution(Approx_SameParam
// Change number of points in case of C0 continuity.
GeomAbs_Shape Continuity = myHCurve2d->Continuity();
if(Continuity < GeomAbs_C1)
if (Continuity < GeomAbs_C1)
{
if (!IncreaseInitialNbSamples(theData))
{
@ -569,34 +577,38 @@ Standard_Boolean Approx_SameParameter::BuildInitialDistribution(Approx_SameParam
return Standard_True;
}
//=======================================================================
//function : IncreaseInitialNbSamples
//purpose : Get number of C1 intervals and build new distribution on them.
//=================================================================================================
// function : IncreaseInitialNbSamples
// purpose : Get number of C1 intervals and build new distribution on them.
// Sub-method in BuildInitialDistribution.
//=======================================================================
Standard_Boolean Approx_SameParameter::IncreaseInitialNbSamples(Approx_SameParameter_Data &theData) const
//=================================================================================================
Standard_Boolean Approx_SameParameter::IncreaseInitialNbSamples(
Approx_SameParameter_Data& theData) const
{
Standard_Integer NbInt = myHCurve2d->NbIntervals(GeomAbs_C1) + 1;
TColStd_Array1OfReal aC1Intervals (1, NbInt);
TColStd_Array1OfReal aC1Intervals(1, NbInt);
myHCurve2d->Intervals(aC1Intervals, GeomAbs_C1);
Standard_Integer inter = 1;
while(inter <= NbInt && aC1Intervals(inter) <= theData.myC3dPF + myDeltaMin) inter++;
while(NbInt > 0 && aC1Intervals(NbInt) >= theData.myC3dPL - myDeltaMin) NbInt--;
while (inter <= NbInt && aC1Intervals(inter) <= theData.myC3dPF + myDeltaMin)
inter++;
while (NbInt > 0 && aC1Intervals(NbInt) >= theData.myC3dPL - myDeltaMin)
NbInt--;
// Compute new parameters.
TColStd_SequenceOfReal aNewPar;
aNewPar.Append(theData.myC3dPF);
Standard_Integer ii = 1;
while(inter <= NbInt || (ii < myNbSamples && inter <= aC1Intervals.Length()) )
while (inter <= NbInt || (ii < myNbSamples && inter <= aC1Intervals.Length()))
{
if(aC1Intervals(inter) < theData.myPC2d[ii])
if (aC1Intervals(inter) < theData.myPC2d[ii])
{
aNewPar.Append(aC1Intervals(inter));
if((theData.myPC2d[ii] - aC1Intervals(inter)) <= myDeltaMin)
if ((theData.myPC2d[ii] - aC1Intervals(inter)) <= myDeltaMin)
{
ii++;
if(ii > myNbSamples)
if (ii > myNbSamples)
{
ii = myNbSamples;
}
@ -605,7 +617,7 @@ Standard_Boolean Approx_SameParameter::IncreaseInitialNbSamples(Approx_SameParam
}
else
{
if((aC1Intervals(inter) - theData.myPC2d[ii]) > myDeltaMin)
if ((aC1Intervals(inter) - theData.myPC2d[ii]) > myDeltaMin)
{
aNewPar.Append(theData.myPC2d[ii]);
}
@ -620,7 +632,7 @@ Standard_Boolean Approx_SameParameter::IncreaseInitialNbSamples(Approx_SameParam
return Standard_False;
}
for(ii = 1; ii < theData.myNbPnt; ii++)
for (ii = 1; ii < theData.myNbPnt; ii++)
{
// Copy only internal points.
theData.myPC2d[ii] = theData.myPC3d[ii] = aNewPar.Value(ii + 1);
@ -631,12 +643,13 @@ Standard_Boolean Approx_SameParameter::IncreaseInitialNbSamples(Approx_SameParam
return Standard_True;
}
//=======================================================================
//function : CheckSameParameter
//purpose : Sub-method in Build.
//=======================================================================
Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_Data &theData,
Standard_Real &theSqDist) const
//=================================================================================================
// function : CheckSameParameter
// purpose : Sub-method in Build.
//=================================================================================================
Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_Data& theData,
Standard_Real& theSqDist) const
{
const Standard_Real Tol2 = theData.myTol * theData.myTol;
Standard_Boolean isSameParam = Standard_True;
@ -654,24 +667,26 @@ Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_D
dmax2 = Max(dmax2, dist2);
Extrema_LocateExtPC Projector;
Projector.Initialize (*myC3d, theData.myC3dPF, theData.myC3dPL, theData.myTol);
Projector.Initialize(*myC3d, theData.myC3dPF, theData.myC3dPL, theData.myTol);
Standard_Integer count = 1;
Standard_Real previousp = theData.myC3dPF, initp=0, curp;
Standard_Real previousp = theData.myC3dPF, initp = 0, curp;
Standard_Real bornesup = theData.myC3dPL - myDeltaMin;
Standard_Boolean isProjOk = Standard_False;
for (Standard_Integer ii = 1; ii < theData.myNbPnt; ii++)
{
theData.myCOnS.D0(theData.myPC2d[ii],Pcons);
myC3d->D0(theData.myPC3d[ii],Pc3d);
theData.myCOnS.D0(theData.myPC2d[ii], Pcons);
myC3d->D0(theData.myPC3d[ii], Pc3d);
dist2 = Pcons.SquareDistance(Pc3d);
// Same parameter point.
Standard_Boolean isUseParam = (dist2 <= Tol2 && // Good distance.
(theData.myPC3d[ii] > theData.myPC3d[count-1] + myDeltaMin)); // Point is separated from previous.
if(isUseParam)
Standard_Boolean isUseParam =
(dist2 <= Tol2 && // Good distance.
(theData.myPC3d[ii]
> theData.myPC3d[count - 1] + myDeltaMin)); // Point is separated from previous.
if (isUseParam)
{
if(dmax2 < dist2)
if (dmax2 < dist2)
dmax2 = dist2;
initp = previousp = theData.myPC3d[count] = theData.myPC3d[ii];
theData.myPC2d[count] = theData.myPC2d[ii];
@ -680,7 +695,7 @@ Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_D
}
// Local search: local extrema and iterative projection algorithm.
if(!isProjOk)
if (!isProjOk)
initp = theData.myPC3d[ii];
isProjOk = isSameParam = Standard_False;
Projector.Perform(Pcons, initp);
@ -692,12 +707,12 @@ Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_D
}
else
{
ProjectPointOnCurve(initp,Pcons,theData.myTol,30, *myC3d,isProjOk,curp);
ProjectPointOnCurve(initp, Pcons, theData.myTol, 30, *myC3d, isProjOk, curp);
}
isProjOk = isProjOk && // Good projection.
curp > previousp + myDeltaMin && // Point is separated from previous.
curp < bornesup; // Inside of parameter space.
if(isProjOk)
if (isProjOk)
{
initp = previousp = theData.myPC3d[count] = curp;
theData.myPC2d[count] = theData.myPC2d[ii];
@ -713,20 +728,20 @@ Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_D
const Standard_Integer aNbExt = PR.NbExt();
Standard_Integer anIndMin = 0;
Standard_Real aCurDistMin = RealLast();
for(Standard_Integer i = 1; i <= aNbExt; i++)
for (Standard_Integer i = 1; i <= aNbExt; i++)
{
const gp_Pnt &aP = PR.Point(i).Value();
const gp_Pnt& aP = PR.Point(i).Value();
Standard_Real aDist2 = aP.SquareDistance(Pcons);
if(aDist2 < aCurDistMin)
if (aDist2 < aCurDistMin)
{
aCurDistMin = aDist2;
anIndMin = i;
}
}
if(anIndMin)
if (anIndMin)
{
curp = PR.Point(anIndMin).Parameter();
if( curp > previousp + myDeltaMin && curp < bornesup)
if (curp > previousp + myDeltaMin && curp < bornesup)
{
initp = previousp = theData.myPC3d[count] = curp;
theData.myPC2d[count] = theData.myPC2d[ii];
@ -743,13 +758,14 @@ Standard_Boolean Approx_SameParameter::CheckSameParameter(Approx_SameParameter_D
return isSameParam;
}
//=======================================================================
//function : ComputeTangents
//purpose : Sub-method in Build.
//=======================================================================
Standard_Boolean Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSurface & theCOnS,
Standard_Real &theFirstTangent,
Standard_Real &theLastTangent) const
//=================================================================================================
// function : ComputeTangents
// purpose : Sub-method in Build.
//=================================================================================================
Standard_Boolean Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSurface& theCOnS,
Standard_Real& theFirstTangent,
Standard_Real& theLastTangent) const
{
const Standard_Real aSmallMagnitude = 1.0e-12;
// Check tangency on curve border.
@ -768,7 +784,7 @@ Standard_Boolean Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSu
// Last point.
const Standard_Real aParamLast = myC3d->LastParameter();
theCOnS.D1(aParamLast,aPntCOnS,aVecConS);
theCOnS.D1(aParamLast, aPntCOnS, aVecConS);
myC3d->D1(aParamLast, aPnt, aVec);
aMagnitude = aVecConS.Magnitude();
@ -780,18 +796,19 @@ Standard_Boolean Approx_SameParameter::ComputeTangents(const Adaptor3d_CurveOnSu
return Standard_True;
}
//=======================================================================
//function : Interpolate
//purpose : Sub-method in Build.
//=======================================================================
Standard_Boolean Approx_SameParameter::Interpolate(const Approx_SameParameter_Data & theData,
//=================================================================================================
// function : Interpolate
// purpose : Sub-method in Build.
//=================================================================================================
Standard_Boolean Approx_SameParameter::Interpolate(const Approx_SameParameter_Data& theData,
const Standard_Real aTangFirst,
const Standard_Real aTangLast,
TColStd_Array1OfReal & thePoles,
TColStd_Array1OfReal & theFlatKnots) const
TColStd_Array1OfReal& thePoles,
TColStd_Array1OfReal& theFlatKnots) const
{
Standard_Integer num_poles = theData.myNbPnt + 3;
TColStd_Array1OfInteger ContactOrder(1,num_poles);
TColStd_Array1OfInteger ContactOrder(1, num_poles);
TColStd_Array1OfReal aParameters(1, num_poles);
// Fill tables taking attention to end values.
@ -799,11 +816,13 @@ Standard_Boolean Approx_SameParameter::Interpolate(const Approx_SameParameter_Da
ContactOrder(2) = ContactOrder(num_poles - 1) = 1;
theFlatKnots(1) = theFlatKnots(2) = theFlatKnots(3) = theFlatKnots(4) = theData.myC3dPF;
theFlatKnots(num_poles + 1) = theFlatKnots(num_poles + 2) =
theFlatKnots(num_poles + 3) = theFlatKnots(num_poles + 4) = theData.myC3dPL;
theFlatKnots(num_poles + 1) = theFlatKnots(num_poles + 2) = theFlatKnots(num_poles + 3) =
theFlatKnots(num_poles + 4) = theData.myC3dPL;
thePoles(1) = theData.myC2dPF; thePoles(num_poles) = theData.myC2dPL;
thePoles(2) = aTangFirst; thePoles(num_poles - 1) = aTangLast;
thePoles(1) = theData.myC2dPF;
thePoles(num_poles) = theData.myC2dPL;
thePoles(2) = aTangFirst;
thePoles(num_poles - 1) = aTangLast;
aParameters(1) = aParameters(2) = theData.myC3dPF;
aParameters(num_poles - 1) = aParameters(num_poles) = theData.myC3dPL;
@ -811,12 +830,17 @@ Standard_Boolean Approx_SameParameter::Interpolate(const Approx_SameParameter_Da
for (Standard_Integer ii = 3; ii <= num_poles - 2; ii++)
{
thePoles(ii) = theData.myPC2d[ii - 2];
aParameters(ii) = theFlatKnots(ii+2) = theData.myPC3d[ii - 2];
aParameters(ii) = theFlatKnots(ii + 2) = theData.myPC3d[ii - 2];
}
Standard_Integer inversion_problem;
BSplCLib::Interpolate(3,theFlatKnots,aParameters,ContactOrder,
1,thePoles(1),inversion_problem);
if(inversion_problem)
BSplCLib::Interpolate(3,
theFlatKnots,
aParameters,
ContactOrder,
1,
thePoles(1),
inversion_problem);
if (inversion_problem)
{
return Standard_False;
}
@ -824,17 +848,18 @@ Standard_Boolean Approx_SameParameter::Interpolate(const Approx_SameParameter_Da
return Standard_True;
}
//=======================================================================
//function : IncreaseNbPoles
//purpose : Sub-method in Build.
//=======================================================================
Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfReal & thePoles,
const TColStd_Array1OfReal & theFlatKnots,
Approx_SameParameter_Data & theData,
Standard_Real &theBestSqTol) const
//=================================================================================================
// function : IncreaseNbPoles
// purpose : Sub-method in Build.
//=================================================================================================
Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfReal& thePoles,
const TColStd_Array1OfReal& theFlatKnots,
Approx_SameParameter_Data& theData,
Standard_Real& theBestSqTol) const
{
Extrema_LocateExtPC Projector;
Projector.Initialize (*myC3d, myC3d->FirstParameter(), myC3d->LastParameter(), theData.myTol);
Projector.Initialize(*myC3d, myC3d->FirstParameter(), myC3d->LastParameter(), theData.myTol);
Standard_Real curp = 0.0;
Standard_Boolean projok = Standard_False;
@ -843,7 +868,7 @@ Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfRea
const Standard_Integer DerivativeRequest = 0;
Standard_Integer extrap_mode[2] = {aDegree, aDegree};
Standard_Real eval_result;
Standard_Real *PolesArray = (Standard_Real *) &thePoles(thePoles.Lower());
Standard_Real* PolesArray = (Standard_Real*)&thePoles(thePoles.Lower());
Standard_Integer newcount = 0;
for (Standard_Integer ii = 0; ii < theData.myNbPnt; ii++)
{
@ -851,37 +876,46 @@ Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfRea
theData.myNewPC3d[newcount] = theData.myPC3d[ii];
newcount++;
if(theData.myNbPnt - ii + newcount == myMaxArraySize) continue;
if (theData.myNbPnt - ii + newcount == myMaxArraySize)
continue;
BSplCLib::Eval(0.5*(theData.myPC3d[ii]+theData.myPC3d[ii+1]), Standard_False, DerivativeRequest,
extrap_mode[0], 3, theFlatKnots, 1, PolesArray[0], eval_result);
BSplCLib::Eval(0.5 * (theData.myPC3d[ii] + theData.myPC3d[ii + 1]),
Standard_False,
DerivativeRequest,
extrap_mode[0],
3,
theFlatKnots,
1,
PolesArray[0],
eval_result);
if(eval_result < theData.myPC2d[ii] || eval_result > theData.myPC2d[ii+1])
if (eval_result < theData.myPC2d[ii] || eval_result > theData.myPC2d[ii + 1])
{
Standard_Real ucons = 0.5*(theData.myPC2d[ii]+theData.myPC2d[ii+1]);
Standard_Real uc3d = 0.5*(theData.myPC3d[ii]+theData.myPC3d[ii+1]);
Standard_Real ucons = 0.5 * (theData.myPC2d[ii] + theData.myPC2d[ii + 1]);
Standard_Real uc3d = 0.5 * (theData.myPC3d[ii] + theData.myPC3d[ii + 1]);
gp_Pnt Pcons;
theData.myCOnS.D0(ucons,Pcons);
theData.myCOnS.D0(ucons, Pcons);
Projector.Perform(Pcons, uc3d);
if (Projector.IsDone())
{
curp = Projector.Point().Parameter();
Standard_Real dist_2 = Projector.SquareDistance();
if(dist_2 > theBestSqTol) theBestSqTol = dist_2;
if (dist_2 > theBestSqTol)
theBestSqTol = dist_2;
projok = 1;
}
else
{
ProjectPointOnCurve(uc3d,Pcons,theData.myTol,30, *myC3d,projok,curp);
ProjectPointOnCurve(uc3d, Pcons, theData.myTol, 30, *myC3d, projok, curp);
}
if(projok)
if (projok)
{
if(curp > theData.myPC3d[ii] + myDeltaMin && curp < theData.myPC3d[ii+1] - myDeltaMin)
if (curp > theData.myPC3d[ii] + myDeltaMin && curp < theData.myPC3d[ii + 1] - myDeltaMin)
{
theData.myNewPC3d[newcount] = curp;
theData.myNewPC2d[newcount] = ucons;
newcount ++;
newcount++;
}
}
}
@ -889,7 +923,7 @@ Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfRea
theData.myNewPC3d[newcount] = theData.myPC3d[theData.myNbPnt];
theData.myNewPC2d[newcount] = theData.myPC2d[theData.myNbPnt];
if((theData.myNbPnt != newcount) && newcount < myMaxArraySize - 1)
if ((theData.myNbPnt != newcount) && newcount < myMaxArraySize - 1)
{
// Distribution is changed.
theData.Swap(newcount);
@ -898,45 +932,47 @@ Standard_Boolean Approx_SameParameter::IncreaseNbPoles(const TColStd_Array1OfRea
// Increase number of samples in two times.
newcount = 0;
for(Standard_Integer n = 0; n < theData.myNbPnt; n++)
for (Standard_Integer n = 0; n < theData.myNbPnt; n++)
{
theData.myNewPC3d[newcount] = theData.myPC3d[n];
theData.myNewPC2d[newcount] = theData.myPC2d[n];
newcount ++;
newcount++;
if(theData.myNbPnt - n + newcount == myMaxArraySize) continue;
if (theData.myNbPnt - n + newcount == myMaxArraySize)
continue;
Standard_Real ucons = 0.5*(theData.myPC2d[n]+theData.myPC2d[n+1]);
Standard_Real uc3d = 0.5*(theData.myPC3d[n]+theData.myPC3d[n+1]);
Standard_Real ucons = 0.5 * (theData.myPC2d[n] + theData.myPC2d[n + 1]);
Standard_Real uc3d = 0.5 * (theData.myPC3d[n] + theData.myPC3d[n + 1]);
gp_Pnt Pcons;
theData.myCOnS.D0(ucons,Pcons);
theData.myCOnS.D0(ucons, Pcons);
Projector.Perform(Pcons, uc3d);
if (Projector.IsDone())
{
curp = Projector.Point().Parameter();
Standard_Real dist_2 = Projector.SquareDistance();
if(dist_2 > theBestSqTol) theBestSqTol = dist_2;
if (dist_2 > theBestSqTol)
theBestSqTol = dist_2;
projok = 1;
}
else
{
ProjectPointOnCurve(uc3d,Pcons,theData.myTol,30, *myC3d,projok,curp);
ProjectPointOnCurve(uc3d, Pcons, theData.myTol, 30, *myC3d, projok, curp);
}
if(projok)
if (projok)
{
if(curp > theData.myPC3d[n] + myDeltaMin && curp < theData.myPC3d[n+1] - myDeltaMin)
if (curp > theData.myPC3d[n] + myDeltaMin && curp < theData.myPC3d[n + 1] - myDeltaMin)
{
theData.myNewPC3d[newcount] = curp;
theData.myNewPC2d[newcount] = ucons;
newcount ++;
newcount++;
}
}
}
theData.myNewPC3d[newcount] = theData.myPC3d[theData.myNbPnt];
theData.myNewPC2d[newcount] = theData.myPC2d[theData.myNbPnt];
if(theData.myNbPnt != newcount)
if (theData.myNbPnt != newcount)
{
// Distribution is changed.
theData.Swap(newcount);

View File

@ -30,7 +30,6 @@ class Geom_Surface;
class Approx_SameParameter
{
public:
DEFINE_STANDARD_ALLOC
//! Warning: the C3D and C2D must have the same parametric domain.
@ -53,51 +52,32 @@ public:
//!@Returns .false. if calculations failed,
//! .true. if calculations succeed
Standard_Boolean IsDone() const
{
return myDone;
}
Standard_Boolean IsDone() const { return myDone; }
//!@Returns tolerance (maximal distance) between 3d curve
//! and curve on surface, generated by 2d curve and surface.
Standard_Real TolReached() const
{
return myTolReached;
}
Standard_Real TolReached() const { return myTolReached; }
//! Tells whether the original data had already the same
//! parameter up to the tolerance : in that case nothing
//! is done.
Standard_Boolean IsSameParameter() const
{
return mySameParameter;
}
Standard_Boolean IsSameParameter() const { return mySameParameter; }
//! Returns the 2D curve that has the same parameter as
//! the 3D curve once evaluated on the surface up to the
//! specified tolerance.
Handle(Geom2d_Curve) Curve2d() const
{
return myCurve2d;
}
Handle(Geom2d_Curve) Curve2d() const { return myCurve2d; }
//! Returns the 3D curve that has the same parameter as
//! the 3D curve once evaluated on the surface up to the
//! specified tolerance.
Handle(Adaptor3d_Curve) Curve3d() const
{
return myC3d;
}
Handle(Adaptor3d_Curve) Curve3d() const { return myC3d; }
//! Returns the 3D curve on surface that has the same parameter as
//! the 3D curve up to the specified tolerance.
Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const
{
return myCurveOnSurface;
}
Handle(Adaptor3d_CurveOnSurface) CurveOnSurface() const { return myCurveOnSurface; }
private:
//! Internal data structure to unify access to the most actively used data.
//! This structure is not intended to be class field since
//! a lot of memory is used in intermediate computations.
@ -105,12 +85,12 @@ private:
{
Adaptor3d_CurveOnSurface myCOnS; // Curve on surface.
Standard_Integer myNbPnt; // Number of points.
Standard_Real *myPC3d; // Parameters on 3d curve.
Standard_Real *myPC2d; // Parameters on 2d curve.
Standard_Real* myPC3d; // Parameters on 3d curve.
Standard_Real* myPC2d; // Parameters on 2d curve.
// Second data arrays. Used in loop over poles.
Standard_Real *myNewPC3d; // Parameters on 3d curve.
Standard_Real *myNewPC2d; // Parameters on 2d curve.
Standard_Real* myNewPC3d; // Parameters on 3d curve.
Standard_Real* myNewPC2d; // Parameters on 2d curve.
// Parameters ranges.
Standard_Real myC3dPF; // Curve 3d Parameter First.
@ -124,7 +104,7 @@ private:
void Swap(const Standard_Integer theNewNbPoints)
{
myNbPnt = theNewNbPoints;
Standard_Real * temp;
Standard_Real* temp;
// 3-D
temp = myPC3d;
@ -138,47 +118,46 @@ private:
}
};
Approx_SameParameter(const Approx_SameParameter &);
Approx_SameParameter& operator=(const Approx_SameParameter &);
Approx_SameParameter(const Approx_SameParameter&);
Approx_SameParameter& operator=(const Approx_SameParameter&);
//! Computes the pcurve (internal use only).
Standard_EXPORT void Build (const Standard_Real Tol);
Standard_EXPORT void Build(const Standard_Real Tol);
//! Computes initial point distribution.
Standard_Boolean BuildInitialDistribution(Approx_SameParameter_Data &theData) const;
Standard_Boolean BuildInitialDistribution(Approx_SameParameter_Data& theData) const;
//! Increases initial number of samples in case of the C0 continuity.
//! Return new number of points and corresponding data arrays.
//@return true if new number of samples is good and false otherwise.
Standard_Boolean IncreaseInitialNbSamples(Approx_SameParameter_Data &theData) const;
Standard_Boolean IncreaseInitialNbSamples(Approx_SameParameter_Data& theData) const;
//! Computes tangents on boundary points.
//@return true if tangents are not null and false otherwise.
Standard_Boolean ComputeTangents(const Adaptor3d_CurveOnSurface & theCOnS,
Standard_Real &theFirstTangent,
Standard_Real &theLastTangent) const;
Standard_Boolean ComputeTangents(const Adaptor3d_CurveOnSurface& theCOnS,
Standard_Real& theFirstTangent,
Standard_Real& theLastTangent) const;
//! Method to check same parameter state
//! and build dependency between 2d and 3d curves.
//@return true if 2d and 3d curves have same parameter state and false otherwise.
Standard_Boolean CheckSameParameter(Approx_SameParameter_Data &theData,
Standard_Real &theSqDist) const;
Standard_Boolean CheckSameParameter(Approx_SameParameter_Data& theData,
Standard_Real& theSqDist) const;
//! Computes interpolated values.
//!@Returns .false. if computations failed;
Standard_Boolean Interpolate(const Approx_SameParameter_Data & theData,
Standard_Boolean Interpolate(const Approx_SameParameter_Data& theData,
const Standard_Real aTangFirst,
const Standard_Real aTangLast,
TColStd_Array1OfReal & thePoles,
TColStd_Array1OfReal & theFlatKnots) const;
TColStd_Array1OfReal& thePoles,
TColStd_Array1OfReal& theFlatKnots) const;
//! Increases number of poles in poles loop.
//@return true if poles is changed and false otherwise.
Standard_Boolean IncreaseNbPoles(const TColStd_Array1OfReal & thePoles,
const TColStd_Array1OfReal & theFlatKnots,
Approx_SameParameter_Data & theData,
Standard_Real &theBestSqTol) const;
Standard_Boolean IncreaseNbPoles(const TColStd_Array1OfReal& thePoles,
const TColStd_Array1OfReal& theFlatKnots,
Approx_SameParameter_Data& theData,
Standard_Real& theBestSqTol) const;
static const Standard_Integer myNbSamples = 22; // To be consistent with "checkshape".
static const Standard_Integer myMaxArraySize = 1000;

View File

@ -17,10 +17,9 @@
#ifndef Approx_SequenceOfHArray1OfReal_HeaderFile
#define Approx_SequenceOfHArray1OfReal_HeaderFile
#include <TColStd_HArray1OfReal.hxx>
#include <NCollection_Sequence.hxx>
#include <TColStd_HArray1OfReal.hxx>
typedef NCollection_Sequence<Handle(TColStd_HArray1OfReal)> Approx_SequenceOfHArray1OfReal;
#endif

View File

@ -20,9 +20,9 @@
//! It is an auxiliary flag being used in inner computations
enum Approx_Status
{
Approx_PointsAdded,
Approx_NoPointsAdded,
Approx_NoApproximation
Approx_PointsAdded,
Approx_NoPointsAdded,
Approx_NoApproximation
};
#endif // _Approx_Status_HeaderFile

View File

@ -14,59 +14,57 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <AdvApprox_ApproxAFunction.hxx>
#include <AdvApprox_DichoCutting.hxx>
#include <AdvApprox_PrefAndRec.hxx>
#include <Approx_SweepApproximation.hxx>
#include <Approx_SweepFunction.hxx>
#include <BSplCLib.hxx>
#include <gp_XYZ.hxx>
#include <Standard_DomainError.hxx>
#include <StdFail_NotDone.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <gp_XYZ.hxx>
//=================================================================================================
//=======================================================================
//class : Approx_SweepApproximation_Eval
//purpose: evaluator class for approximation
//=======================================================================
class Approx_SweepApproximation_Eval : public AdvApprox_EvaluatorFunction
{
public:
Approx_SweepApproximation_Eval (Approx_SweepApproximation& theTool)
: Tool(theTool) {}
public:
Approx_SweepApproximation_Eval(Approx_SweepApproximation& theTool)
: Tool(theTool)
{
}
virtual void Evaluate (Standard_Integer *Dimension,
virtual void Evaluate(Standard_Integer* Dimension,
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result, // [Dimension]
Standard_Integer *ErrorCode);
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode);
private:
Approx_SweepApproximation &Tool;
private:
Approx_SweepApproximation& Tool;
};
void Approx_SweepApproximation_Eval::Evaluate (Standard_Integer *,/*Dimension*/
void Approx_SweepApproximation_Eval::Evaluate(Standard_Integer*, /*Dimension*/
Standard_Real StartEnd[2],
Standard_Real *Parameter,
Standard_Integer *DerivativeRequest,
Standard_Real *Result,// [Dimension]
Standard_Integer *ErrorCode)
Standard_Real* Parameter,
Standard_Integer* DerivativeRequest,
Standard_Real* Result, // [Dimension]
Standard_Integer* ErrorCode)
{
*ErrorCode = Tool.Eval (*Parameter, *DerivativeRequest,
StartEnd[0], StartEnd[1], Result[0]);
*ErrorCode = Tool.Eval(*Parameter, *DerivativeRequest, StartEnd[0], StartEnd[1], Result[0]);
}
Approx_SweepApproximation::
Approx_SweepApproximation(const Handle(Approx_SweepFunction)& Func)
Approx_SweepApproximation::Approx_SweepApproximation(const Handle(Approx_SweepFunction)& Func)
{
myFunc = Func;
// Init of variables of control
myParam = 0;
myOrder = -1;
first = 1.e100; last = -1.e100;
first = 1.e100;
last = -1.e100;
done = Standard_False;
}
@ -81,75 +79,85 @@ void Approx_SweepApproximation::Perform(const Standard_Real First,
const Standard_Integer Segmax)
{
Standard_Integer NbPolSect, NbKnotSect, ii;
Standard_Real Tol, Tol3dMin = Tol3d, The3D2DTol=0 ;
Standard_Real Tol, Tol3dMin = Tol3d, The3D2DTol = 0;
GeomAbs_Shape continuity = Continuity;
// (1) Characteristics of a section
// (1) Characteristics of a section
myFunc->SectionShape(NbPolSect, NbKnotSect, udeg);
Num2DSS = myFunc->Nb2dCurves();
tabUKnots = new (TColStd_HArray1OfReal) (1, NbKnotSect);
tabUMults = new (TColStd_HArray1OfInteger) (1, NbKnotSect);
tabUKnots = new (TColStd_HArray1OfReal)(1, NbKnotSect);
tabUMults = new (TColStd_HArray1OfInteger)(1, NbKnotSect);
myFunc->Knots(tabUKnots->ChangeArray1());
myFunc->Mults(tabUMults->ChangeArray1());
// (2) Decompositition into sub-spaces
// (2) Decompositition into sub-spaces
Handle(TColStd_HArray1OfReal) OneDTol, TwoDTol, ThreeDTol;
Num3DSS = NbPolSect;
// (2.1) Tolerance 3d and 1d
OneDTol = new (TColStd_HArray1OfReal) (1, Num3DSS);
ThreeDTol = new (TColStd_HArray1OfReal) (1, Num3DSS);
// (2.1) Tolerance 3d and 1d
OneDTol = new (TColStd_HArray1OfReal)(1, Num3DSS);
ThreeDTol = new (TColStd_HArray1OfReal)(1, Num3DSS);
myFunc->GetTolerance(BoundTol, Tol3d, TolAngular,
ThreeDTol->ChangeArray1());
myFunc->GetTolerance(BoundTol, Tol3d, TolAngular, ThreeDTol->ChangeArray1());
for (ii=1; ii<=Num3DSS; ii++)
if (ThreeDTol->Value(ii) < Tol3dMin) Tol3dMin = ThreeDTol->Value(ii);
for (ii = 1; ii <= Num3DSS; ii++)
if (ThreeDTol->Value(ii) < Tol3dMin)
Tol3dMin = ThreeDTol->Value(ii);
if (myFunc->IsRational()) {
if (myFunc->IsRational())
{
Standard_Real Size;
Num1DSS = NbPolSect;
TColStd_Array1OfReal Wmin(1, Num1DSS);
myFunc->GetMinimalWeight(Wmin);
Size = myFunc->MaximalSection();
Translation.SetXYZ
(myFunc->BarycentreOfSurf().XYZ());
for (ii=1; ii<=Num3DSS; ii++) {
Tol = ThreeDTol->Value(ii)/2; // To take account of the error on the final result.
Translation.SetXYZ(myFunc->BarycentreOfSurf().XYZ());
for (ii = 1; ii <= Num3DSS; ii++)
{
Tol = ThreeDTol->Value(ii) / 2; // To take account of the error on the final result.
OneDTol->SetValue(ii, Tol * Wmin(ii) / Size);
Tol *= Wmin(ii); //Factor of projection
ThreeDTol->SetValue(ii, Max(Tol, 1.e-20) );
Tol *= Wmin(ii); // Factor of projection
ThreeDTol->SetValue(ii, Max(Tol, 1.e-20));
}
}
else { Num1DSS = 0; }
else
{
Num1DSS = 0;
}
// (2.2) Tolerance and Transformation 2d.
if (Num2DSS == 0) {TwoDTol.Nullify();}
else {
// (2.2) Tolerance and Transformation 2d.
if (Num2DSS == 0)
{
TwoDTol.Nullify();
}
else
{
// for 2d define affinity using resolutions, to
// avoid homogeneous tolerance of approximation (u/v and 2d/3d)
Standard_Real res, tolu, tolv;
TwoDTol = new (TColStd_HArray1OfReal) (1, Num2DSS);
AAffin = new (Approx_HArray1OfGTrsf2d) (1, Num2DSS);
The3D2DTol= 0.9*BoundTol; // 10% of security
for (ii=1; ii<=Num2DSS; ii++) {
TwoDTol = new (TColStd_HArray1OfReal)(1, Num2DSS);
AAffin = new (Approx_HArray1OfGTrsf2d)(1, Num2DSS);
The3D2DTol = 0.9 * BoundTol; // 10% of security
for (ii = 1; ii <= Num2DSS; ii++)
{
myFunc->Resolution(ii, The3D2DTol, tolu, tolv);
if ( tolu> tolv ) {
if (tolu > tolv)
{
res = tolv;
AAffin->ChangeValue(ii).SetValue(1,1, tolv/tolu);
AAffin->ChangeValue(ii).SetValue(1, 1, tolv / tolu);
}
else {
else
{
res = tolu;
AAffin->ChangeValue(ii).SetValue(2,2, tolu/tolv);
AAffin->ChangeValue(ii).SetValue(2, 2, tolu / tolv);
}
TwoDTol->SetValue(ii, Min( Tol2d, res));
TwoDTol->SetValue(ii, Min(Tol2d, res));
}
}
// (3) Approximation
// (3) Approximation
// Init
// Init
myPoles = new (TColgp_HArray1OfPnt)(1, Num3DSS);
myDPoles = new (TColgp_HArray1OfVec)(1, Num3DSS);
myD2Poles = new (TColgp_HArray1OfVec)(1, Num3DSS);
@ -158,7 +166,7 @@ void Approx_SweepApproximation::Perform(const Standard_Real First,
myDWeigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
myD2Weigths = new (TColStd_HArray1OfReal)(1, Num3DSS);
if (Num2DSS>0)
if (Num2DSS > 0)
{
myPoles2d = new (TColgp_HArray1OfPnt2d)(1, Num2DSS);
myDPoles2d = new (TColgp_HArray1OfVec2d)(1, Num2DSS);
@ -173,79 +181,103 @@ void Approx_SweepApproximation::Perform(const Standard_Real First,
COnSurfErr = new TColStd_HArray1OfReal();
}
// Checks if myFunc->D2 is implemented
if (continuity >= GeomAbs_C2) {
// Checks if myFunc->D2 is implemented
if (continuity >= GeomAbs_C2)
{
Standard_Boolean B;
B = myFunc->D2(First, First, Last,
myPoles->ChangeArray1(), myDPoles->ChangeArray1(),
B = myFunc->D2(First,
First,
Last,
myPoles->ChangeArray1(),
myDPoles->ChangeArray1(),
myD2Poles->ChangeArray1(),
myPoles2d->ChangeArray1(), myDPoles2d->ChangeArray1(),
myPoles2d->ChangeArray1(),
myDPoles2d->ChangeArray1(),
myD2Poles2d->ChangeArray1(),
myWeigths->ChangeArray1(), myDWeigths->ChangeArray1(),
myWeigths->ChangeArray1(),
myDWeigths->ChangeArray1(),
myD2Weigths->ChangeArray1());
if (!B) continuity = GeomAbs_C1;
if (!B)
continuity = GeomAbs_C1;
}
// Checks if myFunc->D1 is implemented
if (continuity == GeomAbs_C1) {
// Checks if myFunc->D1 is implemented
if (continuity == GeomAbs_C1)
{
Standard_Boolean B;
B = myFunc->D1(First, First, Last,
myPoles->ChangeArray1(), myDPoles->ChangeArray1(),
myPoles2d->ChangeArray1(), myDPoles2d->ChangeArray1(),
myWeigths->ChangeArray1(), myDWeigths->ChangeArray1());
if (!B) continuity = GeomAbs_C0;
B = myFunc->D1(First,
First,
Last,
myPoles->ChangeArray1(),
myDPoles->ChangeArray1(),
myPoles2d->ChangeArray1(),
myDPoles2d->ChangeArray1(),
myWeigths->ChangeArray1(),
myDWeigths->ChangeArray1());
if (!B)
continuity = GeomAbs_C0;
}
// So that F was at least 20 times more exact than its approx
myFunc->SetTolerance(Tol3dMin/20, Tol2d/20);
// So that F was at least 20 times more exact than its approx
myFunc->SetTolerance(Tol3dMin / 20, Tol2d / 20);
Standard_Integer NbIntervalC2 = myFunc->NbIntervals(GeomAbs_C2);
Standard_Integer NbIntervalC3 = myFunc->NbIntervals(GeomAbs_C3);
if (NbIntervalC3 > 1) {
// (3.1) Approximation with preferential cut
TColStd_Array1OfReal Param_de_decoupeC2 (1, NbIntervalC2+1);
if (NbIntervalC3 > 1)
{
// (3.1) Approximation with preferential cut
TColStd_Array1OfReal Param_de_decoupeC2(1, NbIntervalC2 + 1);
myFunc->Intervals(Param_de_decoupeC2, GeomAbs_C2);
TColStd_Array1OfReal Param_de_decoupeC3 (1, NbIntervalC3+1);
TColStd_Array1OfReal Param_de_decoupeC3(1, NbIntervalC3 + 1);
myFunc->Intervals(Param_de_decoupeC3, GeomAbs_C3);
AdvApprox_PrefAndRec Preferentiel(Param_de_decoupeC2, Param_de_decoupeC3);
AdvApprox_PrefAndRec Preferentiel(Param_de_decoupeC2,
Param_de_decoupeC3);
Approx_SweepApproximation_Eval ev (*this);
Approximation(OneDTol, TwoDTol, ThreeDTol,
Approx_SweepApproximation_Eval ev(*this);
Approximation(OneDTol,
TwoDTol,
ThreeDTol,
The3D2DTol,
First, Last,
First,
Last,
continuity,
Degmax, Segmax,
Degmax,
Segmax,
ev,
Preferentiel);
}
else {
// (3.2) Approximation without preferential cut
else
{
// (3.2) Approximation without preferential cut
AdvApprox_DichoCutting Dichotomie;
Approx_SweepApproximation_Eval ev (*this);
Approximation(OneDTol, TwoDTol, ThreeDTol,
Approx_SweepApproximation_Eval ev(*this);
Approximation(OneDTol,
TwoDTol,
ThreeDTol,
The3D2DTol,
First, Last,
First,
Last,
continuity,
Degmax, Segmax,
Degmax,
Segmax,
ev,
Dichotomie);
}
}
//========================================================================
//function : Approximation
//purpose : Call F(t) and store the results
//========================================================================
void Approx_SweepApproximation::
Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
//=================================================================================================
// function : Approximation
// purpose : Call F(t) and store the results
//=================================================================================================
void Approx_SweepApproximation::Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
const Handle(TColStd_HArray1OfReal)& TwoDTol,
const Handle(TColStd_HArray1OfReal)& ThreeDTol,
const Standard_Real BoundTol,
const Standard_Real First,const Standard_Real Last,
const GeomAbs_Shape Continuity,const Standard_Integer Degmax,
const Standard_Real First,
const Standard_Real Last,
const GeomAbs_Shape Continuity,
const Standard_Integer Degmax,
const Standard_Integer Segmax,
const AdvApprox_EvaluatorFunction& TheApproxFunction,
const AdvApprox_Cutting& TheCuttingTool)
@ -265,7 +297,8 @@ Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
TheCuttingTool);
done = Approx.HasResult();
if (done) {
if (done)
{
// --> Fill Champs of the surface ----
Standard_Integer ii, jj;
@ -273,30 +306,34 @@ Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
// Unfortunately Adv_Approx stores the transposition of the required
// so, writing tabPoles = Approx.Poles() will give an erroneous result
// It is only possible to allocate and recopy term by term...
tabPoles = new (TColgp_HArray2OfPnt)
(1, Num3DSS, 1, Approx.NbPoles());
tabWeights = new (TColStd_HArray2OfReal)
(1, Num3DSS, 1, Approx.NbPoles());
tabPoles = new (TColgp_HArray2OfPnt)(1, Num3DSS, 1, Approx.NbPoles());
tabWeights = new (TColStd_HArray2OfReal)(1, Num3DSS, 1, Approx.NbPoles());
if (Num1DSS == Num3DSS) {
if (Num1DSS == Num3DSS)
{
Standard_Real wpoid;
gp_Pnt P;
for (ii=1; ii <=Num3DSS; ii++) {
for (jj=1; jj <=Approx.NbPoles() ; jj++) {
P = Approx.Poles()->Value(jj,ii);
wpoid = Approx.Poles1d()->Value(jj,ii);
for (ii = 1; ii <= Num3DSS; ii++)
{
for (jj = 1; jj <= Approx.NbPoles(); jj++)
{
P = Approx.Poles()->Value(jj, ii);
wpoid = Approx.Poles1d()->Value(jj, ii);
P.ChangeCoord() /= wpoid; // It is necessary to divide poles by weight
P.Translate(Translation);
tabPoles->SetValue (ii, jj, P);
tabWeights->SetValue(ii, jj, wpoid );
tabPoles->SetValue(ii, jj, P);
tabWeights->SetValue(ii, jj, wpoid);
}
}
}
else {
else
{
tabWeights->Init(1);
for (ii=1; ii <=Num3DSS; ii++) {
for (jj=1; jj <=Approx.NbPoles() ; jj++) {
tabPoles->SetValue (ii, jj, Approx.Poles ()->Value(jj,ii) );
for (ii = 1; ii <= Num3DSS; ii++)
{
for (jj = 1; jj <= Approx.NbPoles(); jj++)
{
tabPoles->SetValue(ii, jj, Approx.Poles()->Value(jj, ii));
}
}
}
@ -305,52 +342,56 @@ Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
tabVKnots = Approx.Knots();
tabVMults = Approx.Multiplicities();
// --> Filling of curves 2D ----------
if (Num2DSS>0) {
if (Num2DSS > 0)
{
gp_GTrsf2d TrsfInv;
deg2d = vdeg;
tab2dKnots = Approx.Knots();
tab2dMults = Approx.Multiplicities();
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
TrsfInv = AAffin->Value(ii).Inverted();
Handle(TColgp_HArray1OfPnt2d) P2d =
new (TColgp_HArray1OfPnt2d) (1, Approx.NbPoles());
Approx.Poles2d( ii, P2d->ChangeArray1() );
Handle(TColgp_HArray1OfPnt2d) P2d = new (TColgp_HArray1OfPnt2d)(1, Approx.NbPoles());
Approx.Poles2d(ii, P2d->ChangeArray1());
// do not forget to apply inverted homothety.
for (jj=1; jj<=Approx.NbPoles(); jj++) {
for (jj = 1; jj <= Approx.NbPoles(); jj++)
{
TrsfInv.Transforms(P2d->ChangeValue(jj).ChangeCoord());
}
seqPoles2d.Append(P2d);
}
}
// ---> Filling of errors
MError3d = new (TColStd_HArray1OfReal) (1,Num3DSS);
AError3d = new (TColStd_HArray1OfReal) (1,Num3DSS);
for (ii=1; ii<=Num3DSS; ii++) {
MError3d = new (TColStd_HArray1OfReal)(1, Num3DSS);
AError3d = new (TColStd_HArray1OfReal)(1, Num3DSS);
for (ii = 1; ii <= Num3DSS; ii++)
{
MError3d->SetValue(ii, Approx.MaxError(3, ii));
AError3d->SetValue(ii, Approx.AverageError(3, ii));
}
if (myFunc->IsRational()) {
MError1d = new (TColStd_HArray1OfReal) (1,Num3DSS);
AError1d = new (TColStd_HArray1OfReal) (1,Num3DSS);
for (ii=1; ii<=Num1DSS; ii++) {
if (myFunc->IsRational())
{
MError1d = new (TColStd_HArray1OfReal)(1, Num3DSS);
AError1d = new (TColStd_HArray1OfReal)(1, Num3DSS);
for (ii = 1; ii <= Num1DSS; ii++)
{
MError1d->SetValue(ii, Approx.MaxError(1, ii));
AError1d->SetValue(ii, Approx.AverageError(1, ii));
}
}
if (Num2DSS>0) {
tab2dError = new (TColStd_HArray1OfReal) (1,Num2DSS);
Ave2dError = new (TColStd_HArray1OfReal) (1,Num2DSS);
for (ii=1; ii<=Num2DSS; ii++) {
if (Num2DSS > 0)
{
tab2dError = new (TColStd_HArray1OfReal)(1, Num2DSS);
Ave2dError = new (TColStd_HArray1OfReal)(1, Num2DSS);
for (ii = 1; ii <= Num2DSS; ii++)
{
tab2dError->SetValue(ii, Approx.MaxError(2, ii));
Ave2dError->SetValue(ii, Approx.AverageError(2, ii));
COnSurfErr->SetValue(ii,
(tab2dError->Value(ii)/TwoDTol->Value(ii))*BoundTol);
COnSurfErr->SetValue(ii, (tab2dError->Value(ii) / TwoDTol->Value(ii)) * BoundTol);
}
}
}
@ -362,18 +403,19 @@ Standard_Integer Approx_SweepApproximation::Eval(const Standard_Real Parameter,
const Standard_Real Last,
Standard_Real& Result)
{
Standard_Integer ier=0;
switch (DerivativeRequest) {
case 0 :
ier = ( ! D0(Parameter, First, Last, Result));
Standard_Integer ier = 0;
switch (DerivativeRequest)
{
case 0:
ier = (!D0(Parameter, First, Last, Result));
break;
case 1 :
ier = ( ! D1(Parameter, First, Last, Result));
case 1:
ier = (!D1(Parameter, First, Last, Result));
break;
case 2 :
ier = ( ! D2(Parameter, First, Last,Result));
case 2:
ier = (!D2(Parameter, First, Last, Result));
break;
default :
default:
ier = 2;
}
return ier;
@ -385,32 +427,35 @@ Standard_Boolean Approx_SweepApproximation::D0(const Standard_Real Param,
Standard_Real& Result)
{
Standard_Integer index, ii;
Standard_Boolean Ok=Standard_True;
Standard_Real * LocalResult = &Result;
Standard_Boolean Ok = Standard_True;
Standard_Real* LocalResult = &Result;
// Management of limits
if ((first!=First) || (Last!=last)) {
if ((first != First) || (Last != last))
{
myFunc->SetInterval(First, Last);
}
if (! ( (Param==myParam) && (myOrder>=0)
&& (first==First) && (Last==last)) ) {
if (!((Param == myParam) && (myOrder >= 0) && (first == First) && (Last == last)))
{
// Positioning in case when the last operation is not repeated.
Ok = myFunc->D0(Param, First, Last,
Ok = myFunc->D0(Param,
First,
Last,
myPoles->ChangeArray1(),
myPoles2d->ChangeArray1(),
myWeigths->ChangeArray1());
// poles3d are multiplied by weight after translation.
for (ii=1; ii<=Num1DSS; ii++) {
myPoles->ChangeValue(ii).ChangeCoord()
-= Translation.XYZ();
myPoles->ChangeValue(ii).ChangeCoord()
*= myWeigths->Value(ii);
for (ii = 1; ii <= Num1DSS; ii++)
{
myPoles->ChangeValue(ii).ChangeCoord() -= Translation.XYZ();
myPoles->ChangeValue(ii).ChangeCoord() *= myWeigths->Value(ii);
}
// The transformation is applied to poles 2d.
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
AAffin->Value(ii).Transforms(myPoles2d->ChangeValue(ii).ChangeCoord());
}
@ -423,19 +468,22 @@ Standard_Boolean Approx_SweepApproximation::D0(const Standard_Real Param,
// Extraction of results
index = 0;
for (ii=1; ii<=Num1DSS; ii++) {
for (ii = 1; ii <= Num1DSS; ii++)
{
LocalResult[index] = myWeigths->Value(ii);
index++;
}
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
LocalResult[index] = myPoles2d->Value(ii).X();
LocalResult[index+1] = myPoles2d->Value(ii).Y();
LocalResult[index + 1] = myPoles2d->Value(ii).Y();
index += 2;
}
for (ii=1; ii<=Num3DSS; ii++, index+=3) {
for (ii = 1; ii <= Num3DSS; ii++, index += 3)
{
LocalResult[index] = myPoles->Value(ii).X();
LocalResult[index+1] = myPoles->Value(ii).Y();
LocalResult[index+2] = myPoles->Value(ii).Z();
LocalResult[index + 1] = myPoles->Value(ii).Y();
LocalResult[index + 2] = myPoles->Value(ii).Z();
}
return Ok;
@ -449,19 +497,21 @@ Standard_Boolean Approx_SweepApproximation::D1(const Standard_Real Param,
gp_XY Vcoord;
gp_Vec Vaux;
Standard_Integer index, ii;
Standard_Boolean Ok=Standard_True;
Standard_Real * LocalResult = &Result;
Standard_Boolean Ok = Standard_True;
Standard_Real* LocalResult = &Result;
if ((first!=First) || (Last!=last)) {
if ((first != First) || (Last != last))
{
myFunc->SetInterval(First, Last);
}
if (! ( (Param==myParam) && (myOrder>=1)
&& (first==First) && (Last==last)) ){
if (!((Param == myParam) && (myOrder >= 1) && (first == First) && (Last == last)))
{
// Positioning
Ok = myFunc->D1(Param, First, Last,
Ok = myFunc->D1(Param,
First,
Last,
myPoles->ChangeArray1(),
myDPoles->ChangeArray1(),
myPoles2d->ChangeArray1(),
@ -471,21 +521,21 @@ Standard_Boolean Approx_SweepApproximation::D1(const Standard_Real Param,
// Take into account the multiplication of poles3d by weights.
// and the translation.
for ( ii=1; ii<=Num1DSS; ii++) {
//Translation on the section
myPoles->ChangeValue(ii).ChangeCoord()
-= Translation.XYZ();
for (ii = 1; ii <= Num1DSS; ii++)
{
// Translation on the section
myPoles->ChangeValue(ii).ChangeCoord() -= Translation.XYZ();
// Homothety on all.
const Standard_Real aWeight = myWeigths->Value(ii);
myDPoles->ChangeValue(ii) *= aWeight;
Vaux.SetXYZ( myPoles->Value(ii).Coord());
myDPoles->ChangeValue(ii) += myDWeigths->Value(ii)*Vaux;
Vaux.SetXYZ(myPoles->Value(ii).Coord());
myDPoles->ChangeValue(ii) += myDWeigths->Value(ii) * Vaux;
myPoles->ChangeValue(ii).ChangeCoord() *= aWeight; // for the cash
}
// Apply transformation 2d to suitable vectors
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
Vcoord = myDPoles2d->Value(ii).XY();
AAffin->Value(ii).Transforms(Vcoord);
myDPoles2d->ChangeValue(ii).SetXY(Vcoord);
@ -501,19 +551,22 @@ Standard_Boolean Approx_SweepApproximation::D1(const Standard_Real Param,
// Extraction of results
index = 0;
for (ii=1; ii<=Num1DSS; ii++) {
for (ii = 1; ii <= Num1DSS; ii++)
{
LocalResult[index] = myDWeigths->Value(ii);
index++;
}
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
LocalResult[index] = myDPoles2d->Value(ii).X();
LocalResult[index+1] = myDPoles2d->Value(ii).Y();
LocalResult[index + 1] = myDPoles2d->Value(ii).Y();
index += 2;
}
for (ii=1; ii<=Num3DSS; ii++, index+=3) {
for (ii = 1; ii <= Num3DSS; ii++, index += 3)
{
LocalResult[index] = myDPoles->Value(ii).X();
LocalResult[index+1] = myDPoles->Value(ii).Y();
LocalResult[index+2] = myDPoles->Value(ii).Z();
LocalResult[index + 1] = myDPoles->Value(ii).Y();
LocalResult[index + 2] = myDPoles->Value(ii).Z();
}
return Ok;
}
@ -526,18 +579,21 @@ Standard_Boolean Approx_SweepApproximation::D2(const Standard_Real Param,
gp_XY Vcoord;
gp_Vec Vaux;
Standard_Integer index, ii;
Standard_Boolean Ok=Standard_True;
Standard_Real * LocalResult = &Result;
Standard_Boolean Ok = Standard_True;
Standard_Real* LocalResult = &Result;
// management of limits
if ((first!=First) || (Last!=last)) {
if ((first != First) || (Last != last))
{
myFunc->SetInterval(First, Last);
}
if (! ( (Param==myParam) && (myOrder>=2)
&& (first==First) && (Last==last)) ) {
if (!((Param == myParam) && (myOrder >= 2) && (first == First) && (Last == last)))
{
// Positioning in case when the last operation is not repeated
Ok = myFunc->D2(Param, First, Last,
Ok = myFunc->D2(Param,
First,
Last,
myPoles->ChangeArray1(),
myDPoles->ChangeArray1(),
myD2Poles->ChangeArray1(),
@ -549,28 +605,28 @@ Standard_Boolean Approx_SweepApproximation::D2(const Standard_Real Param,
myD2Weigths->ChangeArray1());
// Multiply poles3d by the weight after translations.
for (ii=1; ii<=Num1DSS; ii++) {
for (ii = 1; ii <= Num1DSS; ii++)
{
// First translate
myPoles->ChangeValue(ii).ChangeCoord()
-= Translation.XYZ();
myPoles->ChangeValue(ii).ChangeCoord() -= Translation.XYZ();
//Calculate the second derivative
// Calculate the second derivative
myD2Poles->ChangeValue(ii) *= myWeigths->Value(ii);
Vaux.SetXYZ( myDPoles->Value(ii).XYZ());
myD2Poles->ChangeValue(ii) += (2*myDWeigths->Value(ii))*Vaux;
Vaux.SetXYZ( myPoles->Value(ii).Coord());
myD2Poles->ChangeValue(ii) += myD2Weigths->Value(ii)*Vaux;
Vaux.SetXYZ(myDPoles->Value(ii).XYZ());
myD2Poles->ChangeValue(ii) += (2 * myDWeigths->Value(ii)) * Vaux;
Vaux.SetXYZ(myPoles->Value(ii).Coord());
myD2Poles->ChangeValue(ii) += myD2Weigths->Value(ii) * Vaux;
//Then the remainder for the cash
// Then the remainder for the cash
myDPoles->ChangeValue(ii) *= myWeigths->Value(ii);
Vaux.SetXYZ( myPoles->Value(ii).Coord());
myDPoles->ChangeValue(ii) += myDWeigths->Value(ii)*Vaux;
myPoles->ChangeValue(ii).ChangeCoord()
*= myWeigths->Value(ii);
Vaux.SetXYZ(myPoles->Value(ii).Coord());
myDPoles->ChangeValue(ii) += myDWeigths->Value(ii) * Vaux;
myPoles->ChangeValue(ii).ChangeCoord() *= myWeigths->Value(ii);
}
// Apply transformation to poles 2d.
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
Vcoord = myD2Poles2d->Value(ii).XY();
AAffin->Value(ii).Transforms(Vcoord);
myD2Poles2d->ChangeValue(ii).SetXY(Vcoord);
@ -589,32 +645,38 @@ Standard_Boolean Approx_SweepApproximation::D2(const Standard_Real Param,
// Extraction of results
index = 0;
for (ii=1; ii<=Num1DSS; ii++) {
for (ii = 1; ii <= Num1DSS; ii++)
{
LocalResult[index] = myD2Weigths->Value(ii);
index++;
}
for (ii=1; ii<=Num2DSS; ii++) {
for (ii = 1; ii <= Num2DSS; ii++)
{
LocalResult[index] = myD2Poles2d->Value(ii).X();
LocalResult[index+1] = myD2Poles2d->Value(ii).Y();
LocalResult[index + 1] = myD2Poles2d->Value(ii).Y();
index += 2;
}
for (ii=1; ii<=Num3DSS; ii++, index+=3) {
for (ii = 1; ii <= Num3DSS; ii++, index += 3)
{
LocalResult[index] = myD2Poles->Value(ii).X();
LocalResult[index+1] = myD2Poles->Value(ii).Y();
LocalResult[index+2] = myD2Poles->Value(ii).Z();
LocalResult[index + 1] = myD2Poles->Value(ii).Y();
LocalResult[index + 2] = myD2Poles->Value(ii).Z();
}
return Ok;
}
void Approx_SweepApproximation::
SurfShape(Standard_Integer& UDegree,
Standard_Integer& VDegree,Standard_Integer& NbUPoles,
void Approx_SweepApproximation::SurfShape(Standard_Integer& UDegree,
Standard_Integer& VDegree,
Standard_Integer& NbUPoles,
Standard_Integer& NbVPoles,
Standard_Integer& NbUKnots,
Standard_Integer& NbVKnots) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
UDegree = udeg;
VDegree = vdeg;
NbUPoles = tabPoles->ColLength();
@ -623,15 +685,17 @@ SurfShape(Standard_Integer& UDegree,
NbVKnots = tabVKnots->Length();
}
void Approx_SweepApproximation::
Surface(TColgp_Array2OfPnt& TPoles,
void Approx_SweepApproximation::Surface(TColgp_Array2OfPnt& TPoles,
TColStd_Array2OfReal& TWeights,
TColStd_Array1OfReal& TUKnots,
TColStd_Array1OfReal& TVKnots,
TColStd_Array1OfInteger& TUMults,
TColStd_Array1OfInteger& TVMults) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
TPoles = tabPoles->Array2();
TWeights = tabWeights->Array2();
TUKnots = tabUKnots->Array1();
@ -644,57 +708,78 @@ Standard_Real Approx_SweepApproximation::MaxErrorOnSurf() const
{
Standard_Integer ii;
Standard_Real MaxError = 0, err;
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
if (myFunc->IsRational()) {
if (myFunc->IsRational())
{
TColStd_Array1OfReal Wmin(1, Num1DSS);
myFunc->GetMinimalWeight(Wmin);
Standard_Real Size = myFunc->MaximalSection();
for (ii=1; ii<=Num3DSS; ii++) {
err = (Size*MError1d->Value(ii) + MError3d->Value(ii)) / Wmin(ii);
if (err>MaxError) MaxError = err;
for (ii = 1; ii <= Num3DSS; ii++)
{
err = (Size * MError1d->Value(ii) + MError3d->Value(ii)) / Wmin(ii);
if (err > MaxError)
MaxError = err;
}
}
else {
for (ii=1; ii<=Num3DSS; ii++) {
else
{
for (ii = 1; ii <= Num3DSS; ii++)
{
err = MError3d->Value(ii);
if (err>MaxError) MaxError = err;
if (err > MaxError)
MaxError = err;
}
}
return MaxError;
}
Standard_Real Approx_SweepApproximation::AverageErrorOnSurf() const
Standard_Real Approx_SweepApproximation::AverageErrorOnSurf() const
{
Standard_Integer ii;
Standard_Real MoyError = 0, err;
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
if (myFunc->IsRational()) {
if (myFunc->IsRational())
{
TColStd_Array1OfReal Wmin(1, Num1DSS);
myFunc->GetMinimalWeight(Wmin);
Standard_Real Size = myFunc->MaximalSection();
for (ii=1; ii<=Num3DSS; ii++) {
err = (Size*AError1d->Value(ii) + AError3d->Value(ii)) / Wmin(ii);
for (ii = 1; ii <= Num3DSS; ii++)
{
err = (Size * AError1d->Value(ii) + AError3d->Value(ii)) / Wmin(ii);
MoyError += err;
}
}
else {
for (ii=1; ii<=Num3DSS; ii++) {
else
{
for (ii = 1; ii <= Num3DSS; ii++)
{
err = AError3d->Value(ii);
MoyError += err;
}
}
return MoyError/Num3DSS;
return MoyError / Num3DSS;
}
void Approx_SweepApproximation::Curves2dShape(Standard_Integer& Degree,
Standard_Integer& NbPoles,
Standard_Integer& NbKnots) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError("Approx_SweepApproximation");
}
Degree = deg2d;
NbPoles = seqPoles2d(1)->Length();
NbKnots = tab2dKnots->Length();
@ -705,46 +790,66 @@ void Approx_SweepApproximation::Curve2d(const Standard_Integer Index,
TColStd_Array1OfReal& TKnots,
TColStd_Array1OfInteger& TMults) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError("Approx_SweepApproximation");
}
TPoles = seqPoles2d(Index)->Array1();
TKnots = tab2dKnots->Array1();
TMults = tab2dMults->Array1();
}
Standard_Real Approx_SweepApproximation::Max2dError(const Standard_Integer Index) const
Standard_Real Approx_SweepApproximation::Max2dError(const Standard_Integer Index) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
return tab2dError->Value(Index);
}
Standard_Real Approx_SweepApproximation::Average2dError(const Standard_Integer Index) const
Standard_Real Approx_SweepApproximation::Average2dError(const Standard_Integer Index) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
return Ave2dError->Value(Index);
}
Standard_Real Approx_SweepApproximation::TolCurveOnSurf(const Standard_Integer Index) const
{
if (!done) {throw StdFail_NotDone("Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone("Approx_SweepApproximation");
}
return COnSurfErr->Value(Index);
}
void Approx_SweepApproximation::Dump(Standard_OStream& o) const
void Approx_SweepApproximation::Dump(Standard_OStream& o) const
{
o << "Dump of SweepApproximation" << std::endl;
if (done) {
if (done)
{
o << "Error 3d = " << MaxErrorOnSurf() << std::endl;
if (Num2DSS>0) {
if (Num2DSS > 0)
{
o << "Error 2d = ";
for (Standard_Integer ii=1; ii<=Num2DSS; ii++)
{ o << Max2dError(ii);
if (ii < Num2DSS) o << " , " << std::endl;
for (Standard_Integer ii = 1; ii <= Num2DSS; ii++)
{
o << Max2dError(ii);
if (ii < Num2DSS)
o << " , " << std::endl;
}
std::cout << std::endl;
}
o << tabVKnots->Length()-1 <<" Segment(s) of degree " << vdeg << std::endl;
o << tabVKnots->Length() - 1 << " Segment(s) of degree " << vdeg << std::endl;
}
else std::cout << " Not Done " << std::endl;
else
std::cout << " Not Done " << std::endl;
}

View File

@ -21,30 +21,29 @@
#include <Standard_DefineAlloc.hxx>
#include <Standard_Handle.hxx>
#include <Standard_Integer.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColgp_SequenceOfArray1OfPnt2d.hxx>
#include <AdvApprox_EvaluatorFunction.hxx>
#include <Approx_HArray1OfGTrsf2d.hxx>
#include <gp_Vec.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Integer.hxx>
#include <Standard_OStream.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColgp_HArray1OfVec.hxx>
#include <TColgp_HArray1OfVec2d.hxx>
#include <GeomAbs_Shape.hxx>
#include <AdvApprox_EvaluatorFunction.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <Standard_OStream.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColgp_SequenceOfArray1OfPnt2d.hxx>
#include <gp_Vec.hxx>
class Approx_SweepFunction;
class AdvApprox_Cutting;
//! Approximation of an Surface S(u,v)
//! (and eventually associate 2d Curves) defined
//! by section's law.
@ -57,10 +56,8 @@ class AdvApprox_Cutting;
class Approx_SweepApproximation
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT Approx_SweepApproximation(const Handle(Approx_SweepFunction)& Func);
//! Perform the Approximation
@ -78,17 +75,39 @@ public:
//! Segmax : The maximum number of span in v required on
//! the surface
//! Warning : The continuity ci can be obtained only if Ft is Ci
Standard_EXPORT void Perform (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol3d, const Standard_Real BoundTol, const Standard_Real Tol2d, const Standard_Real TolAngular, const GeomAbs_Shape Continuity = GeomAbs_C0, const Standard_Integer Degmax = 11, const Standard_Integer Segmax = 50);
Standard_EXPORT void Perform(const Standard_Real First,
const Standard_Real Last,
const Standard_Real Tol3d,
const Standard_Real BoundTol,
const Standard_Real Tol2d,
const Standard_Real TolAngular,
const GeomAbs_Shape Continuity = GeomAbs_C0,
const Standard_Integer Degmax = 11,
const Standard_Integer Segmax = 50);
//! The EvaluatorFunction from AdvApprox;
Standard_EXPORT Standard_Integer Eval (const Standard_Real Parameter, const Standard_Integer DerivativeRequest, const Standard_Real First, const Standard_Real Last, Standard_Real& Result);
Standard_EXPORT Standard_Integer Eval(const Standard_Real Parameter,
const Standard_Integer DerivativeRequest,
const Standard_Real First,
const Standard_Real Last,
Standard_Real& Result);
//! returns if we have an result
Standard_Boolean IsDone() const;
Standard_EXPORT void SurfShape (Standard_Integer& UDegree, Standard_Integer& VDegree, Standard_Integer& NbUPoles, Standard_Integer& NbVPoles, Standard_Integer& NbUKnots, Standard_Integer& NbVKnots) const;
Standard_EXPORT void SurfShape(Standard_Integer& UDegree,
Standard_Integer& VDegree,
Standard_Integer& NbUPoles,
Standard_Integer& NbVPoles,
Standard_Integer& NbUKnots,
Standard_Integer& NbVKnots) const;
Standard_EXPORT void Surface (TColgp_Array2OfPnt& TPoles, TColStd_Array2OfReal& TWeights, TColStd_Array1OfReal& TUKnots, TColStd_Array1OfReal& TVKnots, TColStd_Array1OfInteger& TUMults, TColStd_Array1OfInteger& TVMults) const;
Standard_EXPORT void Surface(TColgp_Array2OfPnt& TPoles,
TColStd_Array2OfReal& TWeights,
TColStd_Array1OfReal& TUKnots,
TColStd_Array1OfReal& TVKnots,
TColStd_Array1OfInteger& TUMults,
TColStd_Array1OfInteger& TVMults) const;
Standard_Integer UDegree() const;
@ -114,13 +133,18 @@ public:
Standard_Integer NbCurves2d() const;
Standard_EXPORT void Curves2dShape (Standard_Integer& Degree, Standard_Integer& NbPoles, Standard_Integer& NbKnots) const;
Standard_EXPORT void Curves2dShape(Standard_Integer& Degree,
Standard_Integer& NbPoles,
Standard_Integer& NbKnots) const;
Standard_EXPORT void Curve2d (const Standard_Integer Index, TColgp_Array1OfPnt2d& TPoles, TColStd_Array1OfReal& TKnots, TColStd_Array1OfInteger& TMults) const;
Standard_EXPORT void Curve2d(const Standard_Integer Index,
TColgp_Array1OfPnt2d& TPoles,
TColStd_Array1OfReal& TKnots,
TColStd_Array1OfInteger& TMults) const;
Standard_Integer Curves2dDegree() const;
const TColgp_Array1OfPnt2d& Curve2dPoles (const Standard_Integer Index) const;
const TColgp_Array1OfPnt2d& Curve2dPoles(const Standard_Integer Index) const;
const TColStd_Array1OfReal& Curves2dKnots() const;
@ -128,39 +152,47 @@ public:
//! returns the maximum error of the <Index>
//! 2d curve approximation.
Standard_EXPORT Standard_Real Max2dError (const Standard_Integer Index) const;
Standard_EXPORT Standard_Real Max2dError(const Standard_Integer Index) const;
//! returns the average error of the <Index>
//! 2d curve approximation.
Standard_EXPORT Standard_Real Average2dError (const Standard_Integer Index) const;
Standard_EXPORT Standard_Real Average2dError(const Standard_Integer Index) const;
//! returns the maximum 3d error of the <Index>
//! 2d curve approximation on the Surface.
Standard_EXPORT Standard_Real TolCurveOnSurf (const Standard_Integer Index) const;
Standard_EXPORT Standard_Real TolCurveOnSurf(const Standard_Integer Index) const;
//! display information on approximation.
Standard_EXPORT void Dump (Standard_OStream& o) const;
Standard_EXPORT void Dump(Standard_OStream& o) const;
protected:
private:
Standard_EXPORT void Approximation(const Handle(TColStd_HArray1OfReal)& OneDTol,
const Handle(TColStd_HArray1OfReal)& TwoDTol,
const Handle(TColStd_HArray1OfReal)& ThreeDTol,
const Standard_Real BounTol,
const Standard_Real First,
const Standard_Real Last,
const GeomAbs_Shape Continuity,
const Standard_Integer Degmax,
const Standard_Integer Segmax,
const AdvApprox_EvaluatorFunction& TheApproxFunction,
const AdvApprox_Cutting& TheCuttingTool);
Standard_EXPORT Standard_Boolean D0(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
Standard_Real& Result);
Standard_EXPORT void Approximation (const Handle(TColStd_HArray1OfReal)& OneDTol, const Handle(TColStd_HArray1OfReal)& TwoDTol, const Handle(TColStd_HArray1OfReal)& ThreeDTol, const Standard_Real BounTol, const Standard_Real First, const Standard_Real Last, const GeomAbs_Shape Continuity, const Standard_Integer Degmax, const Standard_Integer Segmax, const AdvApprox_EvaluatorFunction& TheApproxFunction, const AdvApprox_Cutting& TheCuttingTool);
Standard_EXPORT Standard_Boolean D0 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, Standard_Real& Result);
Standard_EXPORT Standard_Boolean D1 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, Standard_Real& Result);
Standard_EXPORT Standard_Boolean D2 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, Standard_Real& Result);
Standard_EXPORT Standard_Boolean D1(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
Standard_Real& Result);
Standard_EXPORT Standard_Boolean D2(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
Standard_Real& Result);
Handle(Approx_SweepFunction) myFunc;
Standard_Boolean done;
@ -201,15 +233,8 @@ private:
Standard_Real myParam;
Standard_Real first;
Standard_Real last;
};
#include <Approx_SweepApproximation.lxx>
#endif // _Approx_SweepApproximation_HeaderFile

View File

@ -15,109 +15,148 @@
// commercial license or contractual agreement.
#include <StdFail_NotDone.hxx>
#include <TColgp_HArray2OfPnt.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TColStd_HArray2OfReal.hxx>
#include <TColgp_HArray1OfPnt2d.hxx>
#include <TColgp_HArray2OfPnt.hxx>
inline Standard_Boolean Approx_SweepApproximation::IsDone() const
{
return done;
}
inline Standard_Integer Approx_SweepApproximation::UDegree() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return udeg;
}
inline Standard_Integer Approx_SweepApproximation::VDegree() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return vdeg;
}
inline const TColgp_Array2OfPnt& Approx_SweepApproximation::SurfPoles() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabPoles->Array2();
}
inline const TColStd_Array2OfReal& Approx_SweepApproximation::SurfWeights() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabWeights->Array2();
}
inline const TColStd_Array1OfReal& Approx_SweepApproximation::SurfUKnots() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabUKnots->Array1();
}
inline const TColStd_Array1OfReal& Approx_SweepApproximation::SurfVKnots() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabVKnots->Array1();
}
inline const TColStd_Array1OfInteger& Approx_SweepApproximation::SurfUMults() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabUMults->Array1();
}
inline const TColStd_Array1OfInteger& Approx_SweepApproximation::SurfVMults() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return tabVMults->Array1();
}
inline Standard_Integer Approx_SweepApproximation::NbCurves2d() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
return Num2DSS;
}
inline Standard_Integer Approx_SweepApproximation::Curves2dDegree() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError();
}
return deg2d;
}
inline const TColgp_Array1OfPnt2d& Approx_SweepApproximation::Curve2dPoles(const Standard_Integer Index) const
inline const TColgp_Array1OfPnt2d& Approx_SweepApproximation::Curve2dPoles(
const Standard_Integer Index) const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError();
}
return seqPoles2d(Index)->Array1();
}
inline const TColStd_Array1OfReal& Approx_SweepApproximation::Curves2dKnots() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError();
}
return tab2dKnots->Array1();
}
inline const TColStd_Array1OfInteger& Approx_SweepApproximation::Curves2dMults() const
{
if (!done) {throw StdFail_NotDone(" Approx_SweepApproximation");}
if (seqPoles2d.Length() == 0) {throw Standard_DomainError();}
if (!done)
{
throw StdFail_NotDone(" Approx_SweepApproximation");
}
if (seqPoles2d.Length() == 0)
{
throw Standard_DomainError();
}
return tab2dMults->Array1();
}

View File

@ -14,44 +14,73 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Approx_SweepFunction.hxx>
#include <gp_Pnt.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_Type.hxx>
#include <gp_Pnt.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Approx_SweepFunction,Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Approx_SweepFunction, Standard_Transient)
// Standard_Boolean Approx_SweepFunction::D1(const Standard_Real Param,const Standard_Real First,const Standard_Real Last,TColgp_Array1OfPnt& Poles,TColgp_Array1OfVec& DPoles,TColgp_Array1OfPnt2d& Poles2d,TColgp_Array1OfVec2d& DPoles2d,TColStd_Array1OfReal& Weigths,TColStd_Array1OfReal& DWeigths)
Standard_Boolean Approx_SweepFunction::D1(const Standard_Real ,const Standard_Real ,const Standard_Real ,TColgp_Array1OfPnt& ,TColgp_Array1OfVec& ,TColgp_Array1OfPnt2d& ,TColgp_Array1OfVec2d& ,TColStd_Array1OfReal& ,TColStd_Array1OfReal& )
// Standard_Boolean Approx_SweepFunction::D1(const Standard_Real Param,const Standard_Real
// First,const Standard_Real Last,TColgp_Array1OfPnt& Poles,TColgp_Array1OfVec&
// DPoles,TColgp_Array1OfPnt2d& Poles2d,TColgp_Array1OfVec2d& DPoles2d,TColStd_Array1OfReal&
// Weigths,TColStd_Array1OfReal& DWeigths)
Standard_Boolean Approx_SweepFunction::D1(const Standard_Real,
const Standard_Real,
const Standard_Real,
TColgp_Array1OfPnt&,
TColgp_Array1OfVec&,
TColgp_Array1OfPnt2d&,
TColgp_Array1OfVec2d&,
TColStd_Array1OfReal&,
TColStd_Array1OfReal&)
{
throw Standard_NotImplemented("Approx_SweepFunction::D1");
}
// Standard_Boolean Approx_SweepFunction::D2(const Standard_Real Param,const Standard_Real First,const Standard_Real Last,TColgp_Array1OfPnt& Poles,TColgp_Array1OfVec& DPoles,TColgp_Array1OfVec& D2Poles,TColgp_Array1OfPnt2d& Poles2d,TColgp_Array1OfVec2d& DPoles2d,TColgp_Array1OfVec2d& D2Poles2d,TColStd_Array1OfReal& Weigths,TColStd_Array1OfReal& DWeigths,TColStd_Array1OfReal& D2Weigths)
Standard_Boolean Approx_SweepFunction::D2(const Standard_Real ,const Standard_Real ,const Standard_Real ,TColgp_Array1OfPnt& ,TColgp_Array1OfVec& ,TColgp_Array1OfVec& ,TColgp_Array1OfPnt2d& ,TColgp_Array1OfVec2d& ,TColgp_Array1OfVec2d& ,TColStd_Array1OfReal& ,TColStd_Array1OfReal& ,TColStd_Array1OfReal& )
// Standard_Boolean Approx_SweepFunction::D2(const Standard_Real Param,const Standard_Real
// First,const Standard_Real Last,TColgp_Array1OfPnt& Poles,TColgp_Array1OfVec&
// DPoles,TColgp_Array1OfVec& D2Poles,TColgp_Array1OfPnt2d& Poles2d,TColgp_Array1OfVec2d&
// DPoles2d,TColgp_Array1OfVec2d& D2Poles2d,TColStd_Array1OfReal& Weigths,TColStd_Array1OfReal&
// DWeigths,TColStd_Array1OfReal& D2Weigths)
Standard_Boolean Approx_SweepFunction::D2(const Standard_Real,
const Standard_Real,
const Standard_Real,
TColgp_Array1OfPnt&,
TColgp_Array1OfVec&,
TColgp_Array1OfVec&,
TColgp_Array1OfPnt2d&,
TColgp_Array1OfVec2d&,
TColgp_Array1OfVec2d&,
TColStd_Array1OfReal&,
TColStd_Array1OfReal&,
TColStd_Array1OfReal&)
{
throw Standard_NotImplemented("Approx_SweepFunction::D2");
}
// void Approx_SweepFunction::Resolution(const Standard_Integer Index,const Standard_Real Tol,Standard_Real& TolU,Standard_Real& TolV) const
void Approx_SweepFunction::Resolution(const Standard_Integer ,const Standard_Real ,Standard_Real& ,Standard_Real& ) const
// void Approx_SweepFunction::Resolution(const Standard_Integer Index,const Standard_Real
// Tol,Standard_Real& TolU,Standard_Real& TolV) const
void Approx_SweepFunction::Resolution(const Standard_Integer,
const Standard_Real,
Standard_Real&,
Standard_Real&) const
{
throw Standard_NotImplemented("Approx_SweepFunction::Resolution");
}
gp_Pnt Approx_SweepFunction::BarycentreOfSurf() const
gp_Pnt Approx_SweepFunction::BarycentreOfSurf() const
{
throw Standard_NotImplemented("Approx_SweepFunction::BarycentreOfSurf");
}
Standard_Real Approx_SweepFunction::MaximalSection() const
Standard_Real Approx_SweepFunction::MaximalSection() const
{
throw Standard_NotImplemented("Approx_SweepFunction::MaximalSection()");
}
// void Approx_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& Weigths) const
void Approx_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal& ) const
void Approx_SweepFunction::GetMinimalWeight(TColStd_Array1OfReal&) const
{
throw Standard_NotImplemented("Approx_SweepFunction::GetMinimalWeight");
}

View File

@ -19,19 +19,18 @@
#include <Standard.hxx>
#include <Standard_Transient.hxx>
#include <GeomAbs_Shape.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Real.hxx>
#include <Standard_Transient.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <GeomAbs_Shape.hxx>
class gp_Pnt;
class Approx_SweepFunction;
DEFINE_STANDARD_HANDLE(Approx_SweepFunction, Standard_Transient)
@ -41,32 +40,56 @@ class Approx_SweepFunction : public Standard_Transient
{
public:
//! compute the section for v = param
Standard_EXPORT virtual Standard_Boolean D0 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, TColgp_Array1OfPnt& Poles, TColgp_Array1OfPnt2d& Poles2d, TColStd_Array1OfReal& Weigths) = 0;
Standard_EXPORT virtual Standard_Boolean D0(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColStd_Array1OfReal& Weigths) = 0;
//! compute the first derivative in v direction of the
//! section for v = param
//! Warning : It used only for C1 or C2 approximation
Standard_EXPORT virtual Standard_Boolean D1 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths);
Standard_EXPORT virtual Standard_Boolean D1(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfVec& DPoles,
TColgp_Array1OfPnt2d& Poles2d,
TColgp_Array1OfVec2d& DPoles2d,
TColStd_Array1OfReal& Weigths,
TColStd_Array1OfReal& DWeigths);
//! compute the second derivative in v direction of the
//! section for v = param
//! Warning : It used only for C2 approximation
Standard_EXPORT virtual Standard_Boolean D2 (const Standard_Real Param, const Standard_Real First, const Standard_Real Last, TColgp_Array1OfPnt& Poles, TColgp_Array1OfVec& DPoles, TColgp_Array1OfVec& D2Poles, TColgp_Array1OfPnt2d& Poles2d, TColgp_Array1OfVec2d& DPoles2d, TColgp_Array1OfVec2d& D2Poles2d, TColStd_Array1OfReal& Weigths, TColStd_Array1OfReal& DWeigths, TColStd_Array1OfReal& D2Weigths);
Standard_EXPORT virtual Standard_Boolean D2(const Standard_Real Param,
const Standard_Real First,
const Standard_Real Last,
TColgp_Array1OfPnt& Poles,
TColgp_Array1OfVec& DPoles,
TColgp_Array1OfVec& D2Poles,
TColgp_Array1OfPnt2d& Poles2d,
TColgp_Array1OfVec2d& DPoles2d,
TColgp_Array1OfVec2d& D2Poles2d,
TColStd_Array1OfReal& Weigths,
TColStd_Array1OfReal& DWeigths,
TColStd_Array1OfReal& D2Weigths);
//! get the number of 2d curves to approximate.
Standard_EXPORT virtual Standard_Integer Nb2dCurves() const = 0;
//! get the format of an section
Standard_EXPORT virtual void SectionShape (Standard_Integer& NbPoles, Standard_Integer& NbKnots, Standard_Integer& Degree) const = 0;
Standard_EXPORT virtual void SectionShape(Standard_Integer& NbPoles,
Standard_Integer& NbKnots,
Standard_Integer& Degree) const = 0;
//! get the Knots of the section
Standard_EXPORT virtual void Knots (TColStd_Array1OfReal& TKnots) const = 0;
Standard_EXPORT virtual void Knots(TColStd_Array1OfReal& TKnots) const = 0;
//! get the Multplicities of the section
Standard_EXPORT virtual void Mults (TColStd_Array1OfInteger& TMults) const = 0;
Standard_EXPORT virtual void Mults(TColStd_Array1OfInteger& TMults) const = 0;
//! Returns if the sections are rational or not
Standard_EXPORT virtual Standard_Boolean IsRational() const = 0;
@ -74,35 +97,42 @@ public:
//! Returns the number of intervals for continuity
//! <S>.
//! May be one if Continuity(me) >= <S>
Standard_EXPORT virtual Standard_Integer NbIntervals (const GeomAbs_Shape S) const = 0;
Standard_EXPORT virtual Standard_Integer NbIntervals(const GeomAbs_Shape S) const = 0;
//! Stores in <T> the parameters bounding the intervals
//! of continuity <S>.
//!
//! The array must provide enough room to accommodate
//! for the parameters. i.e. T.Length() > NbIntervals()
Standard_EXPORT virtual void Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const = 0;
Standard_EXPORT virtual void Intervals(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const = 0;
//! Sets the bounds of the parametric interval on
//! the fonction
//! This determines the derivatives in these values if the
//! function is not Cn.
Standard_EXPORT virtual void SetInterval (const Standard_Real First, const Standard_Real Last) = 0;
Standard_EXPORT virtual void SetInterval(const Standard_Real First, const Standard_Real Last) = 0;
//! Returns the resolutions in the sub-space 2d <Index>
//! This information is usfull to find an good tolerance in
//! 2d approximation.
Standard_EXPORT virtual void Resolution (const Standard_Integer Index, const Standard_Real Tol, Standard_Real& TolU, Standard_Real& TolV) const;
Standard_EXPORT virtual void Resolution(const Standard_Integer Index,
const Standard_Real Tol,
Standard_Real& TolU,
Standard_Real& TolV) const;
//! Returns the tolerance to reach in approximation
//! to satisfy.
//! BoundTol error at the Boundary
//! AngleTol tangent error at the Boundary (in radian)
//! SurfTol error inside the surface.
Standard_EXPORT virtual void GetTolerance (const Standard_Real BoundTol, const Standard_Real SurfTol, const Standard_Real AngleTol, TColStd_Array1OfReal& Tol3d) const = 0;
Standard_EXPORT virtual void GetTolerance(const Standard_Real BoundTol,
const Standard_Real SurfTol,
const Standard_Real AngleTol,
TColStd_Array1OfReal& Tol3d) const = 0;
//! Is useful, if (me) have to run numerical algorithm to perform D0, D1 or D2
Standard_EXPORT virtual void SetTolerance (const Standard_Real Tol3d, const Standard_Real Tol2d) = 0;
Standard_EXPORT virtual void SetTolerance(const Standard_Real Tol3d,
const Standard_Real Tol2d) = 0;
//! Get the barycentre of Surface.
//! An very poor estimation is sufficient.
@ -118,29 +148,12 @@ public:
//! Compute the minimal value of weight for each poles in all sections.
//! This information is useful to control error in rational approximation.
//! Warning: Used only if <me> IsRational
Standard_EXPORT virtual void GetMinimalWeight (TColStd_Array1OfReal& Weigths) const;
Standard_EXPORT virtual void GetMinimalWeight(TColStd_Array1OfReal& Weigths) const;
DEFINE_STANDARD_RTTIEXT(Approx_SweepFunction,Standard_Transient)
DEFINE_STANDARD_RTTIEXT(Approx_SweepFunction, Standard_Transient)
protected:
private:
};
#endif // _Approx_SweepFunction_HeaderFile

View File

@ -15,25 +15,23 @@
// commercial license or contractual agreement.
#include <AppParCurves_Constraint.hxx>
#include <ApproxInt_KnotTools.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <IntSurf_PntOn2S.hxx>
#include <IntSurf_Quadric.hxx>
#include <Precision.hxx>
#include <gp_Trsf.hxx>
#include <gp_Trsf2d.hxx>
#include <IntSurf_PntOn2S.hxx>
#include <Precision.hxx>
#include <ApproxInt_KnotTools.hxx>
// If quantity of points is less than aMinNbPointsForApprox
// then interpolation is used.
const Standard_Integer aMinNbPointsForApprox = 5;
// This constant should be removed in the future.
const Standard_Real RatioTol = 1.5 ;
const Standard_Real RatioTol = 1.5;
//=================================================================================================
//=======================================================================
//function : ComputeTrsf3d
//purpose :
//=======================================================================
static void ComputeTrsf3d(const Handle(TheWLine)& theline,
Standard_Real& theXo,
Standard_Real& theYo,
@ -41,7 +39,7 @@ static void ComputeTrsf3d(const Handle(TheWLine)& theline,
{
const Standard_Integer aNbPnts = theline->NbPnts();
Standard_Real aXmin = RealLast(), aYmin = RealLast(), aZmin = RealLast();
for(Standard_Integer i=1;i<=aNbPnts;i++)
for (Standard_Integer i = 1; i <= aNbPnts; i++)
{
const gp_Pnt P = theline->Point(i).Value();
aXmin = Min(P.X(), aXmin);
@ -54,10 +52,8 @@ static void ComputeTrsf3d(const Handle(TheWLine)& theline,
theZo = -aZmin;
}
//=======================================================================
//function : ComputeTrsf2d
//purpose :
//=======================================================================
//=================================================================================================
static void ComputeTrsf2d(const Handle(TheWLine)& theline,
const Standard_Boolean onFirst,
Standard_Real& theUo,
@ -67,18 +63,18 @@ static void ComputeTrsf2d(const Handle(TheWLine)& theline,
Standard_Real aUmin = RealLast(), aVmin = RealLast();
// pointer to a member-function
void (IntSurf_PntOn2S::* pfunc)(Standard_Real&,Standard_Real&) const;
void (IntSurf_PntOn2S::*pfunc)(Standard_Real&, Standard_Real&) const;
if (onFirst)
pfunc = &IntSurf_PntOn2S::ParametersOnS1;
else
pfunc = &IntSurf_PntOn2S::ParametersOnS2;
for(Standard_Integer i=1; i<=aNbPnts; i++)
for (Standard_Integer i = 1; i <= aNbPnts; i++)
{
const IntSurf_PntOn2S POn2S = theline->Point(i);
Standard_Real U,V;
(POn2S.*pfunc)(U,V);
Standard_Real U, V;
(POn2S.*pfunc)(U, V);
aUmin = Min(U, aUmin);
aVmin = Min(V, aVmin);
}
@ -87,10 +83,8 @@ static void ComputeTrsf2d(const Handle(TheWLine)& theline,
theVo = -aVmin;
}
//=======================================================================
//function : Parameters
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::Parameters(const ApproxInt_TheMultiLine& Line,
const Standard_Integer firstP,
const Standard_Integer lastP,
@ -100,12 +94,15 @@ void ApproxInt_Approx::Parameters(const ApproxInt_TheMultiLine& Line,
Standard_Integer i, j, nbP2d, nbP3d;
Standard_Real dist;
if (Par == Approx_ChordLength || Par == Approx_Centripetal) {
if (Par == Approx_ChordLength || Par == Approx_Centripetal)
{
nbP3d = ApproxInt_TheMultiLineTool::NbP3d(Line);
nbP2d = ApproxInt_TheMultiLineTool::NbP2d(Line);
Standard_Integer mynbP3d=nbP3d, mynbP2d=nbP2d;
if (nbP3d == 0) mynbP3d = 1;
if (nbP2d == 0) mynbP2d = 1;
Standard_Integer mynbP3d = nbP3d, mynbP2d = nbP2d;
if (nbP3d == 0)
mynbP3d = 1;
if (nbP2d == 0)
mynbP2d = 1;
TheParameters(firstP) = 0.0;
dist = 0.0;
@ -114,52 +111,60 @@ void ApproxInt_Approx::Parameters(const ApproxInt_TheMultiLine& Line,
TColgp_Array1OfPnt2d tabP2d(1, mynbP2d);
TColgp_Array1OfPnt2d tabPP2d(1, mynbP2d);
for (i = firstP+1; i <= lastP; i++) {
if (nbP3d != 0 && nbP2d != 0) ApproxInt_TheMultiLineTool::Value(Line, i-1, tabP, tabP2d);
else if (nbP2d != 0) ApproxInt_TheMultiLineTool::Value(Line, i-1, tabP2d);
else if (nbP3d != 0) ApproxInt_TheMultiLineTool::Value(Line, i-1, tabP);
for (i = firstP + 1; i <= lastP; i++)
{
if (nbP3d != 0 && nbP2d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i - 1, tabP, tabP2d);
else if (nbP2d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i - 1, tabP2d);
else if (nbP3d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i - 1, tabP);
if (nbP3d != 0 && nbP2d != 0) ApproxInt_TheMultiLineTool::Value(Line, i, tabPP, tabPP2d);
else if (nbP2d != 0) ApproxInt_TheMultiLineTool::Value(Line, i, tabPP2d);
else if (nbP3d != 0) ApproxInt_TheMultiLineTool::Value(Line, i, tabPP);
if (nbP3d != 0 && nbP2d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i, tabPP, tabPP2d);
else if (nbP2d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i, tabPP2d);
else if (nbP3d != 0)
ApproxInt_TheMultiLineTool::Value(Line, i, tabPP);
dist = 0;
for (j = 1; j <= nbP3d; j++) {
const gp_Pnt &aP1 = tabP(j),
&aP2 = tabPP(j);
for (j = 1; j <= nbP3d; j++)
{
const gp_Pnt &aP1 = tabP(j), &aP2 = tabPP(j);
dist += aP2.SquareDistance(aP1);
}
for (j = 1; j <= nbP2d; j++) {
const gp_Pnt2d &aP12d = tabP2d(j),
&aP22d = tabPP2d(j);
for (j = 1; j <= nbP2d; j++)
{
const gp_Pnt2d &aP12d = tabP2d(j), &aP22d = tabPP2d(j);
dist += aP22d.SquareDistance(aP12d);
}
dist = Sqrt(dist);
if(Par == Approx_ChordLength)
if (Par == Approx_ChordLength)
{
TheParameters(i) = TheParameters(i - 1) + dist;
}
else
{// Par == Approx_Centripetal
{ // Par == Approx_Centripetal
TheParameters(i) = TheParameters(i - 1) + Sqrt(dist);
}
}
for (i = firstP; i <= lastP; i++) TheParameters(i) /= TheParameters(lastP);
for (i = firstP; i <= lastP; i++)
TheParameters(i) /= TheParameters(lastP);
}
else {
for (i = firstP; i <= lastP; i++) {
TheParameters(i) = (Standard_Real(i)-firstP)/
(Standard_Real(lastP)-Standard_Real(firstP));
else
{
for (i = firstP; i <= lastP; i++)
{
TheParameters(i) =
(Standard_Real(i) - firstP) / (Standard_Real(lastP) - Standard_Real(firstP));
}
}
}
//=======================================================================
//function : Default constructor
//purpose :
//=======================================================================
ApproxInt_Approx::ApproxInt_Approx():
//=================================================================================================
ApproxInt_Approx::ApproxInt_Approx() :
myComputeLine(4, 8, 0.001, 0.001, 5),
myComputeLineBezier(4, 8, 0.001, 0.001, 5),
myWithTangency(Standard_True),
@ -172,13 +177,11 @@ ApproxInt_Approx::ApproxInt_Approx():
myTolReached2d(0.0)
{
myComputeLine.SetContinuity(2);
//myComputeLineBezier.SetContinuity(2);
// myComputeLineBezier.SetContinuity(2);
}
//=======================================================================
//function : Perform
//purpose : Build without surfaces information.
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::Perform(const Handle(TheWLine)& theline,
const Standard_Boolean ApproxXYZ,
const Standard_Boolean ApproxU1V1,
@ -190,7 +193,7 @@ void ApproxInt_Approx::Perform(const Handle(TheWLine)& theline,
prepareDS(ApproxXYZ, ApproxU1V1, ApproxU2V2, indicemin, indicemax);
const Standard_Integer nbpntbez = myData.indicemax - myData.indicemin;
if(nbpntbez < aMinNbPointsForApprox)
if (nbpntbez < aMinNbPointsForApprox)
myData.myBezierApprox = Standard_False;
else
myData.myBezierApprox = Standard_True;
@ -200,25 +203,27 @@ void ApproxInt_Approx::Perform(const Handle(TheWLine)& theline,
// Build knots.
buildKnots(theline, NULL);
if (myKnots.Length() == 2 &&
indicemax - indicemin > 2 * myData.myNbPntMax)
if (myKnots.Length() == 2 && indicemax - indicemin > 2 * myData.myNbPntMax)
{
// At least 3 knots for BrepApprox.
myKnots.ChangeLast() = (indicemax - indicemin) / 2;
myKnots.Append(indicemax);
}
myComputeLine.Init (myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, myData.parametrization);
myComputeLineBezier.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, myData.parametrization);
myComputeLine
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, myData.parametrization);
myComputeLineBezier
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, myData.parametrization);
buildCurve(theline, NULL);
}
//=======================================================================
//function : Perform
//purpose : Definition of next steps according to surface types
//=================================================================================================
// function : Perform
// purpose : Definition of next steps according to surface types
// (i.e. coordination algorithm).
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
const ThePSurface& Surf2,
const Handle(TheWLine)& theline,
@ -234,19 +239,15 @@ void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
const GeomAbs_SurfaceType typeS1 = ThePSurfaceTool::GetType(Surf1);
const GeomAbs_SurfaceType typeS2 = ThePSurfaceTool::GetType(Surf2);
const Standard_Boolean isQuadric = ((typeS1 == GeomAbs_Plane) ||
(typeS1 == GeomAbs_Cylinder) ||
(typeS1 == GeomAbs_Sphere) ||
(typeS1 == GeomAbs_Cone) ||
(typeS2 == GeomAbs_Plane) ||
(typeS2 == GeomAbs_Cylinder) ||
(typeS2 == GeomAbs_Sphere) ||
(typeS2 == GeomAbs_Cone));
const Standard_Boolean isQuadric =
((typeS1 == GeomAbs_Plane) || (typeS1 == GeomAbs_Cylinder) || (typeS1 == GeomAbs_Sphere) ||
(typeS1 == GeomAbs_Cone) || (typeS2 == GeomAbs_Plane) || (typeS2 == GeomAbs_Cylinder) ||
(typeS2 == GeomAbs_Sphere) || (typeS2 == GeomAbs_Cone));
if(isQuadric)
if (isQuadric)
{
IntSurf_Quadric Quad;
Standard_Boolean SecondIsImplicit=Standard_False;
Standard_Boolean SecondIsImplicit = Standard_False;
switch (typeS1)
{
case GeomAbs_Plane:
@ -265,8 +266,7 @@ void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
Quad.SetValue(ThePSurfaceTool::Cone(Surf1));
break;
default:
{
default: {
SecondIsImplicit = Standard_True;
switch (typeS2)
{
@ -288,15 +288,21 @@ void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
default:
break;
}//switch (typeS2)
} // switch (typeS2)
}
break;
}//switch (typeS1)
} // switch (typeS1)
Perform(Quad, (SecondIsImplicit? Surf1: Surf2), theline,
ApproxXYZ, ApproxU1V1, ApproxU2V2,
indicemin, indicemax, !SecondIsImplicit);
Perform(Quad,
(SecondIsImplicit ? Surf1 : Surf2),
theline,
ApproxXYZ,
ApproxU1V1,
ApproxU2V2,
indicemin,
indicemax,
!SecondIsImplicit);
return;
}
@ -307,11 +313,11 @@ void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
prepareDS(ApproxXYZ, ApproxU1V1, ApproxU2V2, indicemin, indicemax);
// Non-analytical case: Param-Param perform.
ApproxInt_ThePrmPrmSvSurfaces myPrmPrmSvSurfaces(Surf1,Surf2);
ApproxInt_ThePrmPrmSvSurfaces myPrmPrmSvSurfaces(Surf1, Surf2);
Standard_Integer nbpntbez = indicemax-indicemin;
Standard_Integer nbpntbez = indicemax - indicemin;
if(nbpntbez < aMinNbPointsForApprox)
if (nbpntbez < aMinNbPointsForApprox)
{
myData.myBezierApprox = Standard_False;
}
@ -329,18 +335,19 @@ void ApproxInt_Approx::Perform(const ThePSurface& Surf1,
// Build knots.
buildKnots(theline, ptrsvsurf);
myComputeLine.Init ( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, cut, myData.parametrization);
myComputeLineBezier.Init( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, cut, myData.parametrization);
myComputeLine
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, cut, myData.parametrization);
myComputeLineBezier
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, cut, myData.parametrization);
buildCurve(theline, ptrsvsurf);
}
//=======================================================================
//function : Perform
//purpose : Analytic-Param perform.
//=======================================================================
//=================================================================================================
// function : Perform
// purpose : Analytic-Param perform.
//=================================================================================================
void ApproxInt_Approx::Perform(const TheISurface& ISurf,
const ThePSurface& PSurf,
const Handle(TheWLine)& theline,
@ -356,13 +363,13 @@ void ApproxInt_Approx::Perform(const TheISurface& ISurf,
// Non-analytical case: Analytic-Param perform.
ApproxInt_TheImpPrmSvSurfaces myImpPrmSvSurfaces =
isTheQuadFirst? ApproxInt_TheImpPrmSvSurfaces(ISurf, PSurf):
ApproxInt_TheImpPrmSvSurfaces(PSurf, ISurf);
isTheQuadFirst ? ApproxInt_TheImpPrmSvSurfaces(ISurf, PSurf)
: ApproxInt_TheImpPrmSvSurfaces(PSurf, ISurf);
myImpPrmSvSurfaces.SetUseSolver(Standard_False);
const Standard_Integer nbpntbez = indicemax-indicemin;
if(nbpntbez < aMinNbPointsForApprox)
const Standard_Integer nbpntbez = indicemax - indicemin;
if (nbpntbez < aMinNbPointsForApprox)
{
myData.myBezierApprox = Standard_False;
}
@ -380,19 +387,17 @@ void ApproxInt_Approx::Perform(const TheISurface& ISurf,
// Build knots.
buildKnots(theline, ptrsvsurf);
myComputeLine.Init ( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, cut, myData.parametrization);
myComputeLineBezier.Init( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, cut, myData.parametrization);
myComputeLine
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, cut, myData.parametrization);
myComputeLineBezier
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, cut, myData.parametrization);
buildCurve(theline, ptrsvsurf);
}
//=======================================================================
//function : SetParameters
//purpose :
//=======================================================================
void ApproxInt_Approx::SetParameters( const Standard_Real Tol3d,
//=================================================================================================
void ApproxInt_Approx::SetParameters(const Standard_Real Tol3d,
const Standard_Real Tol2d,
const Standard_Integer DegMin,
const Standard_Integer DegMax,
@ -403,134 +408,118 @@ void ApproxInt_Approx::SetParameters( const Standard_Real Tol3d,
{
myData.myNbPntMax = NbPntMax;
myWithTangency = ApproxWithTangency;
myTol3d = Tol3d/RatioTol;
myTol2d = Tol2d/RatioTol;
myTol3d = Tol3d / RatioTol;
myTol2d = Tol2d / RatioTol;
myDegMin = DegMin;
myDegMax = DegMax;
myNbIterMax = NbIterMax;
myComputeLine.Init ( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, Standard_True, Parametrization);
myComputeLineBezier.Init( myDegMin, myDegMax, myTol3d, myTol2d,
myNbIterMax, Standard_True, Parametrization);
myComputeLine
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, Parametrization);
myComputeLineBezier
.Init(myDegMin, myDegMax, myTol3d, myTol2d, myNbIterMax, Standard_True, Parametrization);
if(!ApproxWithTangency)
if (!ApproxWithTangency)
{
myComputeLine.SetConstraints(AppParCurves_PassPoint,AppParCurves_PassPoint);
myComputeLineBezier.SetConstraints(AppParCurves_PassPoint,AppParCurves_PassPoint);
myComputeLine.SetConstraints(AppParCurves_PassPoint, AppParCurves_PassPoint);
myComputeLineBezier.SetConstraints(AppParCurves_PassPoint, AppParCurves_PassPoint);
}
myData.myBezierApprox = Standard_True;
}
//=======================================================================
//function : NbMultiCurves
//purpose :
//=======================================================================
//=================================================================================================
Standard_Integer ApproxInt_Approx::NbMultiCurves() const
{
return 1;
}
//=======================================================================
//function : UpdateTolReached
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::UpdateTolReached()
{
if (myData.myBezierApprox)
{
const Standard_Integer NbCurves = myComputeLineBezier.NbMultiCurves() ;
for (Standard_Integer ICur = 1 ; ICur <= NbCurves ; ICur++)
const Standard_Integer NbCurves = myComputeLineBezier.NbMultiCurves();
for (Standard_Integer ICur = 1; ICur <= NbCurves; ICur++)
{
Standard_Real Tol3D, Tol2D ;
myComputeLineBezier.Error (ICur, Tol3D, Tol2D) ;
Standard_Real Tol3D, Tol2D;
myComputeLineBezier.Error(ICur, Tol3D, Tol2D);
myTolReached3d = Max(myTolReached3d, Tol3D);
myTolReached2d = Max(myTolReached2d, Tol2D);
}
}
else
{
myComputeLine.Error (myTolReached3d, myTolReached2d);
myComputeLine.Error(myTolReached3d, myTolReached2d);
}
}
//=======================================================================
//function : TolReached3d
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real ApproxInt_Approx::TolReached3d() const
{
return myTolReached3d * RatioTol;
}
//=======================================================================
//function : TolReached2d
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real ApproxInt_Approx::TolReached2d() const
{
return myTolReached2d * RatioTol;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean ApproxInt_Approx::IsDone() const
{
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
return(myComputeLineBezier.NbMultiCurves() > 0);
return (myComputeLineBezier.NbMultiCurves() > 0);
}
else
{
return(myComputeLine.IsToleranceReached());
return (myComputeLine.IsToleranceReached());
}
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
const AppParCurves_MultiBSpCurve& ApproxInt_Approx::Value(const Standard_Integer ) const
//=================================================================================================
const AppParCurves_MultiBSpCurve& ApproxInt_Approx::Value(const Standard_Integer) const
{
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
return(myBezToBSpl.Value());
return (myBezToBSpl.Value());
}
else
{
return(myComputeLine.Value());
return (myComputeLine.Value());
}
}
//=======================================================================
//function : fillData
//purpose : Fill ApproxInt data structure.
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::fillData(const Handle(TheWLine)& theline)
{
if(myData.ApproxXYZ)
if (myData.ApproxXYZ)
ComputeTrsf3d(theline, myData.Xo, myData.Yo, myData.Zo);
else
myData.Xo = myData.Yo = myData.Zo = 0.0;
if(myData.ApproxU1V1)
if (myData.ApproxU1V1)
ComputeTrsf2d(theline, Standard_True, myData.U1o, myData.V1o);
else
myData.U1o = myData.V1o = 0.0;
if(myData.ApproxU2V2)
if (myData.ApproxU2V2)
ComputeTrsf2d(theline, Standard_False, myData.U2o, myData.V2o);
else
myData.U2o = myData.V2o = 0.0;
}
//=======================================================================
//function : prepareDS
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::prepareDS(const Standard_Boolean theApproxXYZ,
const Standard_Boolean theApproxU1V1,
const Standard_Boolean theApproxU2V2,
@ -546,56 +535,65 @@ void ApproxInt_Approx::prepareDS(const Standard_Boolean theApproxXYZ,
myData.parametrization = myComputeLineBezier.Parametrization();
}
//=======================================================================
//function : buildKnots
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::buildKnots(const Handle(TheWLine)& theline,
const Standard_Address thePtrSVSurf)
{
myKnots.Clear();
if(!myData.myBezierApprox)
if (!myData.myBezierApprox)
{
myKnots.Append(myData.indicemin);
myKnots.Append(myData.indicemax);
return;
}
const ApproxInt_TheMultiLine aTestLine( theline, thePtrSVSurf,
((myData.ApproxXYZ)? 1 : 0),
((myData.ApproxU1V1)? 1: 0) + ((myData.ApproxU2V2)? 1: 0),
myData.ApproxU1V1, myData.ApproxU2V2,
myData.Xo, myData.Yo, myData.Zo,
myData.U1o, myData.V1o, myData.U2o, myData.V2o,
const ApproxInt_TheMultiLine aTestLine(theline,
thePtrSVSurf,
((myData.ApproxXYZ) ? 1 : 0),
((myData.ApproxU1V1) ? 1 : 0) +
((myData.ApproxU2V2) ? 1 : 0),
myData.ApproxU1V1,
myData.indicemin, myData.indicemax);
myData.ApproxU2V2,
myData.Xo,
myData.Yo,
myData.Zo,
myData.U1o,
myData.V1o,
myData.U2o,
myData.V2o,
myData.ApproxU1V1,
myData.indicemin,
myData.indicemax);
const Standard_Integer nbp3d = aTestLine.NbP3d(),
nbp2d = aTestLine.NbP2d();
const Standard_Integer nbp3d = aTestLine.NbP3d(), nbp2d = aTestLine.NbP2d();
TColgp_Array1OfPnt aTabPnt3d(1, Max(1, nbp3d));
TColgp_Array1OfPnt2d aTabPnt2d(1, Max(1, nbp2d));
TColgp_Array1OfPnt aPntXYZ(myData.indicemin, myData.indicemax);
TColgp_Array1OfPnt2d aPntU1V1(myData.indicemin, myData.indicemax);
TColgp_Array1OfPnt2d aPntU2V2(myData.indicemin, myData.indicemax);
for(Standard_Integer i = myData.indicemin; i <= myData.indicemax; ++i)
for (Standard_Integer i = myData.indicemin; i <= myData.indicemax; ++i)
{
if (nbp3d != 0 && nbp2d != 0) aTestLine.Value(i, aTabPnt3d, aTabPnt2d);
else if (nbp2d != 0) aTestLine.Value(i, aTabPnt2d);
else if (nbp3d != 0) aTestLine.Value(i, aTabPnt3d);
if (nbp3d != 0 && nbp2d != 0)
aTestLine.Value(i, aTabPnt3d, aTabPnt2d);
else if (nbp2d != 0)
aTestLine.Value(i, aTabPnt2d);
else if (nbp3d != 0)
aTestLine.Value(i, aTabPnt3d);
//
if(nbp3d > 0)
if (nbp3d > 0)
{
aPntXYZ(i) = aTabPnt3d(1);
}
if(nbp2d > 1)
if (nbp2d > 1)
{
aPntU1V1(i) = aTabPnt2d(1);
aPntU2V2(i) = aTabPnt2d(2);
}
else if(nbp2d > 0)
else if (nbp2d > 0)
{
if(myData.ApproxU1V1)
if (myData.ApproxU1V1)
{
aPntU1V1(i) = aTabPnt2d(1);
}
@ -612,18 +610,23 @@ void ApproxInt_Approx::buildKnots(const Handle(TheWLine)& theline,
math_Vector aPars(myData.indicemin, myData.indicemax);
Parameters(aTestLine, myData.indicemin, myData.indicemax, myData.parametrization, aPars);
ApproxInt_KnotTools::BuildKnots(aPntXYZ, aPntU1V1, aPntU2V2, aPars,
myData.ApproxXYZ, myData.ApproxU1V1, myData.ApproxU2V2, aMinNbPnts, myKnots);
ApproxInt_KnotTools::BuildKnots(aPntXYZ,
aPntU1V1,
aPntU2V2,
aPars,
myData.ApproxXYZ,
myData.ApproxU1V1,
myData.ApproxU2V2,
aMinNbPnts,
myKnots);
}
//=======================================================================
//function : buildCurve
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_Approx::buildCurve(const Handle(TheWLine)& theline,
const Standard_Address thePtrSVSurf)
{
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
myBezToBSpl.Reset();
}
@ -635,15 +638,26 @@ void ApproxInt_Approx::buildCurve(const Handle(TheWLine)& theline,
{
// Base cycle: iterate over knots.
imin = myKnots(kind);
imax = myKnots(kind+1);
ApproxInt_TheMultiLine myMultiLine(theline, thePtrSVSurf,
((myData.ApproxXYZ)? 1 : 0),
((myData.ApproxU1V1)? 1: 0) + ((myData.ApproxU2V2)? 1: 0),
myData.ApproxU1V1, myData.ApproxU2V2,
myData.Xo, myData.Yo, myData.Zo, myData.U1o, myData.V1o,
myData.U2o, myData.V2o, myData.ApproxU1V1, imin, imax);
imax = myKnots(kind + 1);
ApproxInt_TheMultiLine myMultiLine(theline,
thePtrSVSurf,
((myData.ApproxXYZ) ? 1 : 0),
((myData.ApproxU1V1) ? 1 : 0) +
((myData.ApproxU2V2) ? 1 : 0),
myData.ApproxU1V1,
myData.ApproxU2V2,
myData.Xo,
myData.Yo,
myData.Zo,
myData.U1o,
myData.V1o,
myData.U2o,
myData.V2o,
myData.ApproxU1V1,
imin,
imax);
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
myComputeLineBezier.Perform(myMultiLine);
if (myComputeLineBezier.NbMultiCurves() == 0)
@ -657,28 +671,42 @@ void ApproxInt_Approx::buildCurve(const Handle(TheWLine)& theline,
UpdateTolReached();
Standard_Integer indice3d = 1, indice2d1 = 2, indice2d2 = 3;
if(!myData.ApproxXYZ) { indice2d1--; indice2d2--; }
if(!myData.ApproxU1V1) { indice2d2--; }
if(myData.ApproxXYZ)
if (!myData.ApproxXYZ)
{
if(myData.myBezierApprox)
indice2d1--;
indice2d2--;
}
if (!myData.ApproxU1V1)
{
for(Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves() ; nbmc>=1; nbmc--)
indice2d2--;
}
if (myData.ApproxXYZ)
{
myComputeLineBezier.ChangeValue(nbmc).Transform(indice3d, -myData.Xo, 1.0, -myData.Yo, 1.0, -myData.Zo, 1.0);
if (myData.myBezierApprox)
{
for (Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves(); nbmc >= 1; nbmc--)
{
myComputeLineBezier.ChangeValue(nbmc)
.Transform(indice3d, -myData.Xo, 1.0, -myData.Yo, 1.0, -myData.Zo, 1.0);
}
}
else
{
myComputeLine.ChangeValue().Transform(indice3d, -myData.Xo, 1.0, -myData.Yo, 1.0, -myData.Zo, 1.0);
myComputeLine.ChangeValue()
.Transform(indice3d, -myData.Xo, 1.0, -myData.Yo, 1.0, -myData.Zo, 1.0);
}
}
if(myData.ApproxU1V1)
if (myData.ApproxU1V1)
{
if(myData.myBezierApprox) {
for(Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves() ; nbmc>=1; nbmc--)
if (myData.myBezierApprox)
{
myComputeLineBezier.ChangeValue(nbmc).Transform2d(indice2d1, -myData.U1o, 1.0, -myData.V1o, 1.0);
for (Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves(); nbmc >= 1; nbmc--)
{
myComputeLineBezier.ChangeValue(nbmc).Transform2d(indice2d1,
-myData.U1o,
1.0,
-myData.V1o,
1.0);
}
}
else
@ -686,13 +714,17 @@ void ApproxInt_Approx::buildCurve(const Handle(TheWLine)& theline,
myComputeLine.ChangeValue().Transform2d(indice2d1, -myData.U1o, 1.0, -myData.V1o, 1.0);
}
}
if(myData.ApproxU2V2)
if (myData.ApproxU2V2)
{
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
for(Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves() ; nbmc>=1; nbmc--)
for (Standard_Integer nbmc = myComputeLineBezier.NbMultiCurves(); nbmc >= 1; nbmc--)
{
myComputeLineBezier.ChangeValue(nbmc).Transform2d(indice2d2, -myData.U2o, 1.0, -myData.V2o, 1.0);
myComputeLineBezier.ChangeValue(nbmc).Transform2d(indice2d2,
-myData.U2o,
1.0,
-myData.V2o,
1.0);
}
}
else
@ -702,24 +734,21 @@ void ApproxInt_Approx::buildCurve(const Handle(TheWLine)& theline,
}
OtherInter = Standard_False;
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
for(Standard_Integer nbmc = 1;
nbmc <= myComputeLineBezier.NbMultiCurves();
nbmc++)
for (Standard_Integer nbmc = 1; nbmc <= myComputeLineBezier.NbMultiCurves(); nbmc++)
{
myBezToBSpl.Append(myComputeLineBezier.Value(nbmc));
}
kind++;
if(kind < myKnots.Upper())
if (kind < myKnots.Upper())
{
OtherInter = Standard_True;
}
}
}
while(OtherInter);
} while (OtherInter);
if(myData.myBezierApprox)
if (myData.myBezierApprox)
{
myBezToBSpl.Perform();
}

File diff suppressed because it is too large Load Diff

View File

@ -12,28 +12,29 @@
// commercial license or contractual agreement.
#include <ApproxInt_KnotTools.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <math_Vector.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <GeomInt_TheMultiLineOfWLApprox.hxx>
#include <GeomInt_WLApprox.hxx>
#include <Geom_BSplineCurve.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_Vector.hxx>
#include <PLib.hxx>
#include <Precision.hxx>
#include <NCollection_Vector.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <GeomInt_WLApprox.hxx>
#include <GeomInt_TheMultiLineOfWLApprox.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <math_Vector.hxx>
// (Sqrt(5.0) - 1.0) / 4.0
//static const Standard_Real aSinCoeff = 0.30901699437494742410229341718282;
// static const Standard_Real aSinCoeff = 0.30901699437494742410229341718282;
static const Standard_Real aSinCoeff2 = 0.09549150281252627; // aSinCoeff^2 = (3. - Sqrt(5.)) / 8.
static const Standard_Integer aMaxPntCoeff = 15;
//=======================================================================
//function : EvalCurv
//purpose : Evaluate curvature in dim-dimension point.
//=======================================================================
//=================================================================================================
// function : EvalCurv
// purpose : Evaluate curvature in dim-dimension point.
//=================================================================================================
static Standard_Real EvalCurv(const Standard_Real dim,
const Standard_Real* V1,
const Standard_Real* V2)
@ -47,19 +48,19 @@ static Standard_Real EvalCurv(const Standard_Real dim,
Standard_Real mp = 0.;
Standard_Integer i, j;
Standard_Real p;
for(i = 1; i < dim; ++i)
for (i = 1; i < dim; ++i)
{
for(j = 0; j < i; ++j)
for (j = 0; j < i; ++j)
{
p = V1[i]*V2[j] - V1[j]*V2[i];
mp += p*p;
p = V1[i] * V2[j] - V1[j] * V2[i];
mp += p * p;
}
}
//
Standard_Real q = 0.;
for(i = 0; i < dim; ++i)
for (i = 0; i < dim; ++i)
{
q += V1[i]*V1[i];
q += V1[i] * V1[i];
}
if (q < 1 / Precision::Infinite())
@ -78,7 +79,7 @@ static Standard_Real EvalCurv(const Standard_Real dim,
}
q = Min(q, Precision::Infinite());
q *= q*q;
q *= q * q;
//
Standard_Real curv = Sqrt(mp / q);
@ -86,13 +87,9 @@ static Standard_Real EvalCurv(const Standard_Real dim,
return curv;
}
//=======================================================================
//function : BuildCurvature
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_KnotTools::BuildCurvature(
const NCollection_LocalArray<Standard_Real>& theCoords,
void ApproxInt_KnotTools::BuildCurvature(const NCollection_LocalArray<Standard_Real>& theCoords,
const Standard_Integer theDim,
const math_Vector& thePars,
TColStd_Array1OfReal& theCurv,
@ -114,7 +111,7 @@ void ApproxInt_KnotTools::BuildCurvature(
{
Standard_Integer k = i + j;
ic = (k - theCurv.Lower()) * dim;
Standard_Integer l = dim*j;
Standard_Integer l = dim * j;
for (m = 0; m < dim; ++m)
{
Val[l + m] = theCoords[ic + m];
@ -136,7 +133,7 @@ void ApproxInt_KnotTools::BuildCurvature(
{
Standard_Integer k = i + j - 1;
ic = (k - theCurv.Lower()) * dim;
Standard_Integer l = dim*j;
Standard_Integer l = dim * j;
for (m = 0; m < dim; ++m)
{
Val[l + m] = theCoords[ic + m];
@ -157,7 +154,7 @@ void ApproxInt_KnotTools::BuildCurvature(
{
Standard_Integer k = i + j - 2;
ic = (k - theCurv.Lower()) * dim;
Standard_Integer l = dim*j;
Standard_Integer l = dim * j;
for (m = 0; m < dim; ++m)
{
Val[l + m] = theCoords[ic + m];
@ -171,19 +168,16 @@ void ApproxInt_KnotTools::BuildCurvature(
{
theMaxCurv = theCurv(i);
}
}
//=======================================================================
//function : ComputeKnotInds
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_Real>& theCoords,
const Standard_Integer theDim,
const math_Vector& thePars,
NCollection_Sequence<Standard_Integer>& theInds)
{
//I: Create discrete curvature.
// I: Create discrete curvature.
NCollection_Sequence<Standard_Integer> aFeatureInds;
TColStd_Array1OfReal aCurv(thePars.Lower(), thePars.Upper());
Standard_Real aMaxCurv = 0.;
@ -192,14 +186,14 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
Standard_Integer i, j, dim = theDim;
#ifdef APPROXINT_KNOTTOOLS_DEBUG
std::cout << "Discrete curvature array is" << std::endl;
for(i = aCurv.Lower(); i <= aCurv.Upper(); ++i)
for (i = aCurv.Lower(); i <= aCurv.Upper(); ++i)
{
std::cout << i << " " << aCurv(i) << std::endl;
}
#endif
theInds.Append(aCurv.Lower());
if(aMaxCurv <= Precision::Confusion())
if (aMaxCurv <= Precision::Confusion())
{
// Linear case.
theInds.Append(aCurv.Upper());
@ -208,32 +202,30 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
// II: Find extremas of curvature.
// Not used Precision::PConfusion, by different from "param space" eps nature.
Standard_Real eps = 1.0e-9,
eps1 = 1.0e3 * eps;
for(i = aCurv.Lower() + 1; i < aCurv.Upper(); ++i)
Standard_Real eps = 1.0e-9, eps1 = 1.0e3 * eps;
for (i = aCurv.Lower() + 1; i < aCurv.Upper(); ++i)
{
Standard_Real d1 = aCurv(i) - aCurv(i - 1),
d2 = aCurv(i) - aCurv(i + 1),
ad1 = Abs(d1), ad2 = Abs(d2);
Standard_Real d1 = aCurv(i) - aCurv(i - 1), d2 = aCurv(i) - aCurv(i + 1), ad1 = Abs(d1),
ad2 = Abs(d2);
if(d1*d2 > 0. && ad1 > eps && ad2 > eps)
if (d1 * d2 > 0. && ad1 > eps && ad2 > eps)
{
if(i != theInds.Last())
if (i != theInds.Last())
{
theInds.Append(i);
aFeatureInds.Append(i);
}
}
else if((ad1 < eps && ad2 > eps1) || (ad1 > eps1 && ad2 < eps))
else if ((ad1 < eps && ad2 > eps1) || (ad1 > eps1 && ad2 < eps))
{
if(i != theInds.Last())
if (i != theInds.Last())
{
theInds.Append(i);
aFeatureInds.Append(i);
}
}
}
if(aCurv.Upper() != theInds.Last())
if (aCurv.Upper() != theInds.Last())
{
theInds.Append(aCurv.Upper());
}
@ -242,14 +234,14 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
{
std::cout << "Feature indices new: " << std::endl;
i;
for(i = theInds.Lower(); i <= theInds.Upper(); ++i)
for (i = theInds.Lower(); i <= theInds.Upper(); ++i)
{
std::cout << i << " : " << theInds(i) << std::endl;
}
}
#endif
//III: Put knots in monotone intervals of curvature.
// III: Put knots in monotone intervals of curvature.
Standard_Boolean Ok;
i = 1;
do
@ -257,57 +249,56 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
i++;
//
Ok = InsKnotBefI(i, aCurv, theCoords, dim, theInds, Standard_True);
if(Ok)
if (Ok)
{
i--;
}
}
while(i < theInds.Length());
} while (i < theInds.Length());
//IV: Checking feature points.
// IV: Checking feature points.
j = 2;
for(i = 1; i <= aFeatureInds.Length(); ++i)
for (i = 1; i <= aFeatureInds.Length(); ++i)
{
Standard_Integer anInd = aFeatureInds(i);
for(; j <= theInds.Length() - 1;)
for (; j <= theInds.Length() - 1;)
{
if(theInds(j) == anInd)
if (theInds(j) == anInd)
{
Standard_Integer anIndPrev = theInds(j-1);
Standard_Integer anIndNext = theInds(j+1);
Standard_Integer anIndPrev = theInds(j - 1);
Standard_Integer anIndNext = theInds(j + 1);
Standard_Integer ici = (anIndPrev - aCurv.Lower()) * theDim,
ici1 = (anIndNext - aCurv.Lower()) * theDim,
icm = (anInd - aCurv.Lower()) * theDim;
NCollection_LocalArray<Standard_Real> V1(theDim), V2(theDim);
Standard_Real mp = 0., m1 = 0., m2 = 0.;
Standard_Real p;
for(Standard_Integer k = 0; k < theDim; ++k)
for (Standard_Integer k = 0; k < theDim; ++k)
{
V1[k] = theCoords[icm + k] - theCoords[ici + k];
m1 += V1[k]*V1[k];
m1 += V1[k] * V1[k];
V2[k] = theCoords[ici1 + k] - theCoords[icm + k];
m2 += V2[k]*V2[k];
m2 += V2[k] * V2[k];
}
for(Standard_Integer k = 1; k < theDim; ++k)
for (Standard_Integer k = 1; k < theDim; ++k)
{
for(Standard_Integer l = 0; l < k; ++l)
for (Standard_Integer l = 0; l < k; ++l)
{
p = V1[k]*V2[l] - V1[l]*V2[k];
mp += p*p;
p = V1[k] * V2[l] - V1[l] * V2[k];
mp += p * p;
}
}
//mp *= 2.; //P(j,i) = -P(i,j);
// mp *= 2.; //P(j,i) = -P(i,j);
//
if(mp > aSinCoeff2 * m1 * m2) // Sqrt (mp/(m1*m2)) > aSinCoeff
if (mp > aSinCoeff2 * m1 * m2) // Sqrt (mp/(m1*m2)) > aSinCoeff
{
//Insert new knots
// Insert new knots
Standard_Real d1 = Abs(aCurv(anInd) - aCurv(anIndPrev));
Standard_Real d2 = Abs(aCurv(anInd) - aCurv(anIndNext));
if(d1 > d2)
if (d1 > d2)
{
Ok = InsKnotBefI(j, aCurv, theCoords, dim, theInds, Standard_False);
if(Ok)
if (Ok)
{
j++;
}
@ -318,8 +309,8 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
}
else
{
Ok = InsKnotBefI(j+1, aCurv, theCoords, dim, theInds, Standard_False);
if(!Ok)
Ok = InsKnotBefI(j + 1, aCurv, theCoords, dim, theInds, Standard_False);
if (!Ok)
{
break;
}
@ -340,25 +331,22 @@ void ApproxInt_KnotTools::ComputeKnotInds(const NCollection_LocalArray<Standard_
//
}
//=================================================================================================
//=======================================================================
//function : FilterKnots
//purpose :
//=======================================================================
void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& theInds,
const Standard_Integer theMinNbPnts,
NCollection_Vector<Standard_Integer>& theLKnots)
{
// Maximum number of points per knot interval.
Standard_Integer aMaxNbPnts = aMaxPntCoeff*theMinNbPnts;
Standard_Integer aMaxNbPnts = aMaxPntCoeff * theMinNbPnts;
Standard_Integer i = 1;
Standard_Integer aMinNbStep = theMinNbPnts / 2;
// I: Filter too big number of points per knot interval.
while(i < theInds.Length())
while (i < theInds.Length())
{
Standard_Integer nbint = theInds(i + 1) - theInds(i) + 1;
if(nbint <= aMaxNbPnts)
if (nbint <= aMaxNbPnts)
{
++i;
continue;
@ -374,14 +362,14 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& th
i = 1;
theLKnots.Append(theInds(i));
Standard_Integer anIndsPrev = theInds(i);
for(i = 2; i <= theInds.Length(); ++i)
for (i = 2; i <= theInds.Length(); ++i)
{
if(theInds(i) - anIndsPrev <= theMinNbPnts)
if (theInds(i) - anIndsPrev <= theMinNbPnts)
{
if (i != theInds.Length())
{
Standard_Integer anIdx = i + 1;
for( ; anIdx <= theInds.Length(); ++anIdx)
for (; anIdx <= theInds.Length(); ++anIdx)
{
if (theInds(anIdx) - anIndsPrev >= theMinNbPnts)
break;
@ -389,9 +377,8 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& th
anIdx--;
Standard_Integer aMidIdx = (theInds(anIdx) + anIndsPrev) / 2;
if (aMidIdx - anIndsPrev < theMinNbPnts &&
aMidIdx - theInds(anIdx) < theMinNbPnts &&
theInds(anIdx) - anIndsPrev >= aMinNbStep)
if (aMidIdx - anIndsPrev < theMinNbPnts && aMidIdx - theInds(anIdx) < theMinNbPnts
&& theInds(anIdx) - anIndsPrev >= aMinNbStep)
{
if (theInds(anIdx) - anIndsPrev > 2 * theMinNbPnts)
{
@ -411,7 +398,7 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& th
if (theInds(anIdx) - theInds(anIdx - 1) <= theMinNbPnts / 2)
{
theLKnots.SetValue(theLKnots.Upper(), theInds(anIdx));
anIndsPrev = theInds(anIdx );
anIndsPrev = theInds(anIdx);
i = anIdx;
}
}
@ -431,7 +418,7 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& th
// Trying to add knot to divide sequence on two parts:
// Last good index -> Last index - theMinNbPnts -> Last index
Standard_Integer aLastGoodIdx = theLKnots.Value(theLKnots.Upper() - 1);
if ( theInds.Last() - 2 * theMinNbPnts >= aLastGoodIdx)
if (theInds.Last() - 2 * theMinNbPnts >= aLastGoodIdx)
{
theLKnots(theLKnots.Upper()) = theInds.Last() - theMinNbPnts;
theLKnots.Append(theInds.Last());
@ -450,23 +437,23 @@ void ApproxInt_KnotTools::FilterKnots(NCollection_Sequence<Standard_Integer>& th
}
// III: Fill Last Knot.
if(theLKnots.Length() < 2)
if (theLKnots.Length() < 2)
{
theLKnots.Append(theInds.Last());
}
else
{
if(theLKnots.Last() < theInds.Last())
if (theLKnots.Last() < theInds.Last())
{
theLKnots(theLKnots.Upper()) = theInds.Last();
}
}
}
//=======================================================================
//function : InsKnotBefI
//purpose :
//=======================================================================
Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
//=================================================================================================
Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(
const Standard_Integer theI,
const TColStd_Array1OfReal& theCurv,
const NCollection_LocalArray<Standard_Real>& theCoords,
const Standard_Integer theDim,
@ -476,25 +463,24 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
Standard_Integer anInd1 = theInds(theI);
Standard_Integer anInd = theInds(theI - 1);
//
if((anInd1-anInd) == 1)
if ((anInd1 - anInd) == 1)
{
return Standard_False;
}
//
Standard_Real curv = 0.5*(theCurv(anInd) + theCurv(anInd1));
Standard_Real curv = 0.5 * (theCurv(anInd) + theCurv(anInd1));
Standard_Integer mid = 0, j, jj;
const Standard_Real aLimitCurvatureChange = 3.0;
for(j = anInd+1; j < anInd1; ++j)
for (j = anInd + 1; j < anInd1; ++j)
{
mid = 0;
// I: Curvature change criteria:
// Non-null curvature.
if (theCurv(j) > Precision::Confusion() &&
theCurv(anInd) > Precision::Confusion() )
if (theCurv(j) > Precision::Confusion() && theCurv(anInd) > Precision::Confusion())
{
if (theCurv(j) / theCurv(anInd) > aLimitCurvatureChange ||
theCurv(j) / theCurv(anInd) < 1.0 / aLimitCurvatureChange)
if (theCurv(j) / theCurv(anInd) > aLimitCurvatureChange
|| theCurv(j) / theCurv(anInd) < 1.0 / aLimitCurvatureChange)
{
// Curvature on current interval changed more than 3 times.
mid = j;
@ -505,9 +491,9 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
// II: Angular criteria:
Standard_Real ac = theCurv(j - 1), ac1 = theCurv(j);
if((curv >= ac && curv <= ac1) || (curv >= ac1 && curv <= ac))
if ((curv >= ac && curv <= ac1) || (curv >= ac1 && curv <= ac))
{
if(Abs(curv - ac) < Abs(curv - ac1))
if (Abs(curv - ac) < Abs(curv - ac1))
{
mid = j - 1;
}
@ -516,17 +502,17 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
mid = j;
}
}
if(mid == anInd)
if (mid == anInd)
{
mid++;
}
if(mid == anInd1)
if (mid == anInd1)
{
mid--;
}
if(mid > 0)
if (mid > 0)
{
if(ChkCurv)
if (ChkCurv)
{
Standard_Integer ici = (anInd - theCurv.Lower()) * theDim,
ici1 = (anInd1 - theCurv.Lower()) * theDim,
@ -535,22 +521,22 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
Standard_Integer i;
Standard_Real mp = 0., m1 = 0., m2 = 0.;
Standard_Real p;
for(i = 0; i < theDim; ++i)
for (i = 0; i < theDim; ++i)
{
V1[i] = theCoords[icm + i] - theCoords[ici + i];
m1 += V1[i]*V1[i];
m1 += V1[i] * V1[i];
V2[i] = theCoords[ici1 + i] - theCoords[icm + i];
m2 += V2[i]*V2[i];
m2 += V2[i] * V2[i];
}
for(i = 1; i < theDim; ++i)
for (i = 1; i < theDim; ++i)
{
for(jj = 0; jj < i; ++jj)
for (jj = 0; jj < i; ++jj)
{
p = V1[i]*V2[jj] - V1[jj]*V2[i];
mp += p*p;
p = V1[i] * V2[jj] - V1[jj] * V2[i];
mp += p * p;
}
}
//mp *= 2.; //P(j,i) = -P(i,j);
// mp *= 2.; //P(j,i) = -P(i,j);
//
if (mp > aSinCoeff2 * m1 * m2) // Sqrt (mp / m1m2) > aSinCoeff
@ -570,10 +556,8 @@ Standard_Boolean ApproxInt_KnotTools::InsKnotBefI(const Standard_Integer theI,
return Standard_False;
}
//=======================================================================
//function : BuildKnots
//purpose :
//=======================================================================
//=================================================================================================
void ApproxInt_KnotTools::BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
const TColgp_Array1OfPnt2d& thePntsU1V1,
const TColgp_Array1OfPnt2d& thePntsU2V2,
@ -588,19 +572,19 @@ void ApproxInt_KnotTools::BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
Standard_Integer aDim = 0;
// I: Convert input data to the corresponding format.
if(theApproxXYZ)
if (theApproxXYZ)
aDim += 3;
if(theApproxU1V1)
if (theApproxU1V1)
aDim += 2;
if(theApproxU2V2)
if (theApproxU2V2)
aDim += 2;
NCollection_LocalArray<Standard_Real> aCoords(thePars.Length()*aDim);
NCollection_LocalArray<Standard_Real> aCoords(thePars.Length() * aDim);
Standard_Integer i, j;
for(i = thePars.Lower(); i <= thePars.Upper(); ++i)
for (i = thePars.Lower(); i <= thePars.Upper(); ++i)
{
j = (i - thePars.Lower()) * aDim;
if(theApproxXYZ)
if (theApproxXYZ)
{
aCoords[j] = thePntsXYZ.Value(i).X();
++j;
@ -609,14 +593,14 @@ void ApproxInt_KnotTools::BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
aCoords[j] = thePntsXYZ.Value(i).Z();
++j;
}
if(theApproxU1V1)
if (theApproxU1V1)
{
aCoords[j] = thePntsU1V1.Value(i).X();
++j;
aCoords[j] = thePntsU1V1.Value(i).Y();
++j;
}
if(theApproxU2V2)
if (theApproxU2V2)
{
aCoords[j] = thePntsU2V2.Value(i).X();
++j;
@ -630,7 +614,7 @@ void ApproxInt_KnotTools::BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
#if defined(APPROXINT_KNOTTOOLS_DEBUG)
std::cout << "Draft knot sequence: " << std::endl;
for(i = aKnots.Lower(); i <= aKnots.Upper(); ++i)
for (i = aKnots.Lower(); i <= aKnots.Upper(); ++i)
{
std::cout << i << " : " << aKnots(i) << std::endl;
}
@ -641,17 +625,15 @@ void ApproxInt_KnotTools::BuildKnots(const TColgp_Array1OfPnt& thePntsXYZ,
#if defined(APPROXINT_KNOTTOOLS_DEBUG)
std::cout << "Result knot sequence: " << std::endl;
for(i = theKnots.Lower(); i <= theKnots.Upper(); ++i)
for (i = theKnots.Lower(); i <= theKnots.Upper(); ++i)
{
std::cout << i << " : " << theKnots(i) << std::endl;
}
#endif
}
//=======================================================================
//function : MaxParamRatio
//purpose :
//=======================================================================
//=================================================================================================
static Standard_Real MaxParamRatio(const math_Vector& thePars)
{
Standard_Integer i;
@ -667,17 +649,15 @@ static Standard_Real MaxParamRatio(const math_Vector& thePars)
}
return aMaxRatio;
}
//=======================================================================
//function : DefineParType
//purpose :
//=======================================================================
Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
const Handle(IntPatch_WLine)& theWL,
const Standard_Integer theFpar, const Standard_Integer theLpar,
//=================================================================================================
Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(const Handle(IntPatch_WLine)& theWL,
const Standard_Integer theFpar,
const Standard_Integer theLpar,
const Standard_Boolean theApproxXYZ,
const Standard_Boolean theApproxU1V1,
const Standard_Boolean theApproxU2V2
)
const Standard_Boolean theApproxU2V2)
{
if (theLpar - theFpar == 1)
return Approx_IsoParametric;
@ -685,8 +665,21 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
const Standard_Integer nbp3d = theApproxXYZ ? 1 : 0,
nbp2d = (theApproxU1V1 ? 1 : 0) + (theApproxU2V2 ? 1 : 0);
GeomInt_TheMultiLineOfWLApprox aTestLine(theWL, nbp3d, nbp2d, theApproxU1V1, theApproxU2V2,
0., 0., 0., 0., 0., 0., 0., theApproxU1V1, theFpar, theLpar);
GeomInt_TheMultiLineOfWLApprox aTestLine(theWL,
nbp3d,
nbp2d,
theApproxU1V1,
theApproxU2V2,
0.,
0.,
0.,
0.,
0.,
0.,
0.,
theApproxU1V1,
theFpar,
theLpar);
TColgp_Array1OfPnt aTabPnt3d(1, Max(1, nbp3d));
TColgp_Array1OfPnt2d aTabPnt2d(1, Max(1, nbp2d));
@ -698,9 +691,12 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
for (i = theFpar; i <= theLpar; ++i)
{
if (nbp3d != 0 && nbp2d != 0) aTestLine.Value(i, aTabPnt3d, aTabPnt2d);
else if (nbp2d != 0) aTestLine.Value(i, aTabPnt2d);
else if (nbp3d != 0) aTestLine.Value(i, aTabPnt3d);
if (nbp3d != 0 && nbp2d != 0)
aTestLine.Value(i, aTabPnt3d, aTabPnt2d);
else if (nbp2d != 0)
aTestLine.Value(i, aTabPnt2d);
else if (nbp3d != 0)
aTestLine.Value(i, aTabPnt3d);
//
if (nbp3d > 0)
{
@ -763,7 +759,7 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
}
}
//Analysis of curvature
// Analysis of curvature
const Standard_Real aCritRat = 500.;
const Standard_Real aCritParRat = 100.;
math_Vector aPars(theFpar, theLpar);
@ -773,10 +769,9 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
Standard_Real aMaxCurv = 0.;
BuildCurvature(aCoords, aDim, aPars, aCurv, aMaxCurv);
if (aMaxCurv < Precision::PConfusion()
|| Precision::IsPositiveInfinite(aMaxCurv))
if (aMaxCurv < Precision::PConfusion() || Precision::IsPositiveInfinite(aMaxCurv))
{
//Linear case
// Linear case
return aParType;
}
@ -805,7 +800,7 @@ Approx_ParametrizationType ApproxInt_KnotTools::DefineParType(
if (aRat > aCritRat)
{
if(aRat > 5.*aCritRat)
if (aRat > 5. * aCritRat)
aParType = Approx_Centripetal;
else
{

View File

@ -14,28 +14,29 @@
#ifndef _ApproxInt_KnotTools_HeaderFile
#define _ApproxInt_KnotTools_HeaderFile
#include <Standard_DefineAlloc.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Real.hxx>
#include <Standard_Integer.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_List.hxx>
#include <math_Vector.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <NCollection_LocalArray.hxx>
#include <NCollection_Vector.hxx>
#include <Approx_ParametrizationType.hxx>
#include <NCollection_List.hxx>
#include <NCollection_LocalArray.hxx>
#include <NCollection_Sequence.hxx>
#include <NCollection_Vector.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_DefineAlloc.hxx>
#include <Standard_Integer.hxx>
#include <Standard_Macro.hxx>
#include <Standard_Real.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <math_Vector.hxx>
class IntPatch_WLine;
// Corresponds for debug information output.
// Debug information is also printed when OCCT_DEBUG defined.
//#define APPROXINT_KNOTTOOLS_DEBUG
// #define APPROXINT_KNOTTOOLS_DEBUG
//! This class intended to build knots sequence on discrete set of points for further approximation into bspline curve.
//! This class intended to build knots sequence on discrete set of points for further approximation
//! into bspline curve.
//!
//! Short description of algorithm:
//! 1) Build discrete curvature on points set.
@ -47,7 +48,6 @@ class IntPatch_WLine;
class ApproxInt_KnotTools
{
public:
DEFINE_STANDARD_ALLOC
//! Main function to build optimal knot sequence.
@ -72,23 +72,22 @@ public:
NCollection_Vector<Standard_Integer>& theKnots);
//! Builds discrete curvature
Standard_EXPORT static void BuildCurvature(
const NCollection_LocalArray<Standard_Real>& theCoords,
Standard_EXPORT static void BuildCurvature(const NCollection_LocalArray<Standard_Real>& theCoords,
const Standard_Integer theDim,
const math_Vector& thePars,
TColStd_Array1OfReal& theCurv,
Standard_Real& theMaxCurv);
//! Defines preferable parametrization type for theWL
Standard_EXPORT static Approx_ParametrizationType DefineParType(const Handle(IntPatch_WLine)& theWL,
const Standard_Integer theFpar, const Standard_Integer theLpar,
Standard_EXPORT static Approx_ParametrizationType DefineParType(
const Handle(IntPatch_WLine)& theWL,
const Standard_Integer theFpar,
const Standard_Integer theLpar,
const Standard_Boolean theApproxXYZ,
const Standard_Boolean theApproxU1V1,
const Standard_Boolean theApproxU2V2);
private:
//! Compute indices of knots:
//!
//! I: Build discrete curvature in points set,

View File

@ -23,110 +23,163 @@
#include <Approx_Status.hxx>
//================================================================================
inline Standard_Integer ApproxInt_MultiLineTool::NbP2d(const TheMultiLine& ML) {
return(ML.NbP2d());
}
//--------------------------------------------------------------------------------
inline Standard_Integer ApproxInt_MultiLineTool::NbP3d(const TheMultiLine& ML) {
return(ML.NbP3d());
}
//--------------------------------------------------------------------------------
inline Standard_Integer ApproxInt_MultiLineTool::FirstPoint(const TheMultiLine& ML) {
return(ML.FirstPoint());
}
//--------------------------------------------------------------------------------
inline Standard_Integer ApproxInt_MultiLineTool::LastPoint(const TheMultiLine& ML) {
return(ML.LastPoint());
}
//--------------------------------------------------------------------------------
inline void ApproxInt_MultiLineTool::Value( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfPnt& TabPnt) {
ML.Value(Index,TabPnt);
}
//--------------------------------------------------------------------------------
inline void ApproxInt_MultiLineTool::Value( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfPnt2d& TabPnt2d) {
ML.Value(Index,TabPnt2d);
}
//--------------------------------------------------------------------------------
inline void ApproxInt_MultiLineTool::Value( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfPnt& TabPnt
,TColgp_Array1OfPnt2d& TabPnt2d) {
ML.Value(Index,TabPnt,TabPnt2d);
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfVec& TabVec) {
return(ML.Tangency(Index,TabVec));
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfVec2d& TabVec2d) {
return(ML.Tangency(Index,TabVec2d));
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency( const TheMultiLine& ML
,const Standard_Integer Index
,TColgp_Array1OfVec& TabVec
,TColgp_Array1OfVec2d& TabVec2d) {
return(ML.Tangency(Index,TabVec,TabVec2d));
//=================================================================================================
inline Standard_Integer ApproxInt_MultiLineTool::NbP2d(const TheMultiLine& ML)
{
return (ML.NbP2d());
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature( const TheMultiLine& //ML
,const Standard_Integer //Index
,TColgp_Array1OfVec& ) { //TabVec
//=================================================================================================
inline Standard_Integer ApproxInt_MultiLineTool::NbP3d(const TheMultiLine& ML)
{
return (ML.NbP3d());
}
//=================================================================================================
inline Standard_Integer ApproxInt_MultiLineTool::FirstPoint(const TheMultiLine& ML)
{
return (ML.FirstPoint());
}
//=================================================================================================
inline Standard_Integer ApproxInt_MultiLineTool::LastPoint(const TheMultiLine& ML)
{
return (ML.LastPoint());
}
//=================================================================================================
inline void ApproxInt_MultiLineTool::Value(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfPnt& TabPnt)
{
ML.Value(Index, TabPnt);
}
//=================================================================================================
inline void ApproxInt_MultiLineTool::Value(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfPnt2d& TabPnt2d)
{
ML.Value(Index, TabPnt2d);
}
//=================================================================================================
inline void ApproxInt_MultiLineTool::Value(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfPnt& TabPnt,
TColgp_Array1OfPnt2d& TabPnt2d)
{
ML.Value(Index, TabPnt, TabPnt2d);
}
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfVec& TabVec)
{
return (ML.Tangency(Index, TabVec));
}
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfVec2d& TabVec2d)
{
return (ML.Tangency(Index, TabVec2d));
}
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Tangency(const TheMultiLine& ML,
const Standard_Integer Index,
TColgp_Array1OfVec& TabVec,
TColgp_Array1OfVec2d& TabVec2d)
{
return (ML.Tangency(Index, TabVec, TabVec2d));
}
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature(const TheMultiLine& // ML
,
const Standard_Integer // Index
,
TColgp_Array1OfVec&)
{ // TabVec
return Standard_False;
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature( const TheMultiLine& //ML
,const Standard_Integer //Index
,TColgp_Array1OfVec2d& ) { //TabVec2d
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature(const TheMultiLine& // ML
,
const Standard_Integer // Index
,
TColgp_Array1OfVec2d&)
{ // TabVec2d
return Standard_False;
}
//--------------------------------------------------------------------------------
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature( const TheMultiLine& //ML
,const Standard_Integer //Index
,TColgp_Array1OfVec& //TabVec
,TColgp_Array1OfVec2d& ) { //TabVec2d
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::Curvature(const TheMultiLine& // ML
,
const Standard_Integer // Index
,
TColgp_Array1OfVec& // TabVec
,
TColgp_Array1OfVec2d&)
{ // TabVec2d
return Standard_False;
}
//--------------------------------------------------------------------------------
inline Approx_Status ApproxInt_MultiLineTool::WhatStatus(const TheMultiLine& ML
,const Standard_Integer
,const Standard_Integer) {
//=================================================================================================
inline Approx_Status ApproxInt_MultiLineTool::WhatStatus(const TheMultiLine& ML,
const Standard_Integer,
const Standard_Integer)
{
//-- PointsAdded,
//-- NoPointsAdded,
//-- NoApproximation
//-- Approx_PointsAdded
return(ML.WhatStatus());
return (ML.WhatStatus());
}
//--------------------------------------------------------------------------------
//=================================================================================================
inline TheMultiLine ApproxInt_MultiLineTool::MakeMLBetween(const TheMultiLine& ML,
const Standard_Integer I1,
const Standard_Integer I2,
const Standard_Integer NbPMin) {
const Standard_Integer NbPMin)
{
return(ML.MakeMLBetween(I1,I2,NbPMin));
return (ML.MakeMLBetween(I1, I2, NbPMin));
}
//--------------------------------------------------------------------------------
//=================================================================================================
inline Standard_Boolean ApproxInt_MultiLineTool::MakeMLOneMorePoint(const TheMultiLine& ML,
const Standard_Integer I1,
const Standard_Integer I2,
const Standard_Integer indbad,
TheMultiLine& OtherLine)
{
return (ML.MakeMLOneMorePoint(I1,I2,indbad,OtherLine));
return (ML.MakeMLOneMorePoint(I1, I2, indbad, OtherLine));
}
inline void ApproxInt_MultiLineTool::Dump(const TheMultiLine& ML)
{
ML.Dump();
}
//================================================================================
//=================================================================================================

View File

@ -12,13 +12,11 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <ApproxInt_SvSurfaces.hxx>
//=======================================================================
//function : ~ApproxInt_SvSurfaces
//purpose : Destructor
//=======================================================================
ApproxInt_SvSurfaces::~ApproxInt_SvSurfaces()
{
}
//=================================================================================================
// function : ~ApproxInt_SvSurfaces
// purpose : Destructor
//=================================================================================================
ApproxInt_SvSurfaces::~ApproxInt_SvSurfaces() {}

View File

@ -36,64 +36,66 @@ class IntSurf_PntOn2S;
//! if myUseSolver = true, input parameters u1, v1, u2, v2 are considered as first approximation of
//! exact intersection point, then coordinates u1, v1, u2, v2 are refined with help of
//! the solver used in intersection algorithm and required values are calculated.
//! if myUseSolver = false, u1, v1, u2, v2 are considered as "exact" intersection points on two surfaces
//! and required values are calculated directly using u1, v1, u2, v2
//! if myUseSolver = false, u1, v1, u2, v2 are considered as "exact" intersection points on two
//! surfaces and required values are calculated directly using u1, v1, u2, v2
class ApproxInt_SvSurfaces
{
public:
DEFINE_STANDARD_ALLOC
ApproxInt_SvSurfaces() : myUseSolver (false) {}
ApproxInt_SvSurfaces()
: myUseSolver(false)
{
}
//! returns True if Tg,Tguv1 Tguv2 can be computed.
Standard_EXPORT virtual Standard_Boolean Compute (Standard_Real& u1, Standard_Real& v1,
Standard_Real& u2, Standard_Real& v2,
Standard_EXPORT virtual Standard_Boolean Compute(Standard_Real& u1,
Standard_Real& v1,
Standard_Real& u2,
Standard_Real& v2,
gp_Pnt& Pt,
gp_Vec& Tg,
gp_Vec2d& Tguv1,
gp_Vec2d& Tguv2) = 0;
Standard_EXPORT virtual void Pnt (const Standard_Real u1, const Standard_Real v1,
const Standard_Real u2, const Standard_Real v2,
Standard_EXPORT virtual void Pnt(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
gp_Pnt& P) = 0;
//! computes point on curve and parameters on the surfaces
Standard_EXPORT virtual Standard_Boolean SeekPoint(const Standard_Real u1, const Standard_Real v1,
const Standard_Real u2, const Standard_Real v2,
Standard_EXPORT virtual Standard_Boolean SeekPoint(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
IntSurf_PntOn2S& Point) = 0;
Standard_EXPORT virtual Standard_Boolean Tangency (const Standard_Real u1, const Standard_Real v1,
const Standard_Real u2, const Standard_Real v2,
Standard_EXPORT virtual Standard_Boolean Tangency(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
gp_Vec& Tg) = 0;
Standard_EXPORT virtual Standard_Boolean TangencyOnSurf1 (const Standard_Real u1,
Standard_EXPORT virtual Standard_Boolean TangencyOnSurf1(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
gp_Vec2d& Tg) = 0;
Standard_EXPORT virtual Standard_Boolean TangencyOnSurf2 (const Standard_Real u1,
Standard_EXPORT virtual Standard_Boolean TangencyOnSurf2(const Standard_Real u1,
const Standard_Real v1,
const Standard_Real u2,
const Standard_Real v2,
gp_Vec2d& Tg) = 0;
Standard_EXPORT virtual ~ApproxInt_SvSurfaces();
void SetUseSolver (const Standard_Boolean theUseSol)
{
myUseSolver = theUseSol;
}
void SetUseSolver(const Standard_Boolean theUseSol) { myUseSolver = theUseSol; }
virtual Standard_Boolean GetUseSolver() const
{
return myUseSolver;
}
virtual Standard_Boolean GetUseSolver() const { return myUseSolver; }
private:
Standard_Boolean myUseSolver;
};
#endif // _ApproxInt_SvSurfaces_HeaderFile

View File

@ -15,9 +15,9 @@
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_StreamBuffer.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <OSD_StreamBuffer.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
@ -34,12 +34,10 @@ enum DE_ConfigurationContext_KindOfLine
namespace
{
//=======================================================================
//function : GetLine
//purpose :
//=======================================================================
static Standard_Boolean GetLine(OSD_File& theFile, TCollection_AsciiString& theLine)
{
//=================================================================================================
static Standard_Boolean GetLine(OSD_File& theFile, TCollection_AsciiString& theLine)
{
TCollection_AsciiString aBuffer;
Standard_Integer aBufSize = 10;
Standard_Integer aLen;
@ -61,22 +59,21 @@ namespace
}
} while (theLine.Value(theLine.Length()) != '\n');
return Standard_True;
}
}
//=======================================================================
//function : WhatKindOfLine
//purpose :
//=======================================================================
static DE_ConfigurationContext_KindOfLine WhatKindOfLine(const TCollection_AsciiString& theLine,
//=================================================================================================
static DE_ConfigurationContext_KindOfLine WhatKindOfLine(const TCollection_AsciiString& theLine,
TCollection_AsciiString& theToken1,
TCollection_AsciiString& theToken2)
{
{
static const TCollection_AsciiString aWhiteSpace = " \t\r\n";
Standard_Integer aPos1 = 0, aPos2 = 0, aPos = 0;
TCollection_AsciiString aLine(theLine);
aLine.LeftAdjust();
aLine.RightAdjust();
if (!aLine.EndsWith(':') && (!aLine.EndsWith(' ') || !aLine.EndsWith('\t') || !aLine.EndsWith('\n')))
if (!aLine.EndsWith(':')
&& (!aLine.EndsWith(' ') || !aLine.EndsWith('\t') || !aLine.EndsWith('\n')))
{
aLine.InsertAfter(aLine.Length(), " ");
}
@ -97,10 +94,11 @@ namespace
return DE_ConfigurationContext_KindOfLine_Error;
}
for (aPos = aPos2 - 1; aLine.Value(aPos) == '\t' || aLine.Value(aPos) == ' '; aPos--);
for (aPos = aPos2 - 1; aLine.Value(aPos) == '\t' || aLine.Value(aPos) == ' '; aPos--)
;
theToken1 = aLine.SubString(aPos1, aPos);
if(aPos2 != aLine.Length())
if (aPos2 != aLine.Length())
{
aPos2++;
}
@ -130,15 +128,13 @@ namespace
theToken2 = aLine;
}
return DE_ConfigurationContext_KindOfLine_Resource;
}
}
//=======================================================================
//function : MakeName
//purpose :
//=======================================================================
static TCollection_AsciiString MakeName(const TCollection_AsciiString& theScope,
//=================================================================================================
static TCollection_AsciiString MakeName(const TCollection_AsciiString& theScope,
const TCollection_AsciiString& theParam)
{
{
TCollection_AsciiString aStr(theScope);
if (!aStr.IsEmpty())
{
@ -146,20 +142,15 @@ namespace
}
aStr += theParam;
return aStr;
}
}
} // namespace
//=======================================================================
//function : DE_ConfigurationContext
//purpose :
//=======================================================================
DE_ConfigurationContext::DE_ConfigurationContext()
{}
//=================================================================================================
DE_ConfigurationContext::DE_ConfigurationContext() {}
//=================================================================================================
//=======================================================================
//function : Load
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::Load(const TCollection_AsciiString& theConfiguration)
{
OSD_Path aPath = theConfiguration;
@ -181,10 +172,8 @@ Standard_Boolean DE_ConfigurationContext::Load(const TCollection_AsciiString& th
return true;
}
//=======================================================================
//function : LoadFile
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::LoadFile(const TCollection_AsciiString& theFile)
{
myResource.Clear();
@ -209,10 +198,8 @@ Standard_Boolean DE_ConfigurationContext::LoadFile(const TCollection_AsciiString
return Standard_True;
}
//=======================================================================
//function : LoadStr
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::LoadStr(const TCollection_AsciiString& theResource)
{
myResource.Clear();
@ -236,10 +223,8 @@ Standard_Boolean DE_ConfigurationContext::LoadStr(const TCollection_AsciiString&
return Standard_True;
}
//=======================================================================
//function : IsParamSet
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::IsParamSet(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theScope) const
{
@ -247,10 +232,8 @@ Standard_Boolean DE_ConfigurationContext::IsParamSet(const TCollection_AsciiStri
return myResource.IsBound(aResource);
}
//=======================================================================
//function : RealVal
//purpose :
//=======================================================================
//=================================================================================================
Standard_Real DE_ConfigurationContext::RealVal(const TCollection_AsciiString& theParam,
const Standard_Real theDefValue,
const TCollection_AsciiString& theScope) const
@ -259,10 +242,8 @@ Standard_Real DE_ConfigurationContext::RealVal(const TCollection_AsciiString& th
return GetReal(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : IntegerVal
//purpose :
//=======================================================================
//=================================================================================================
Standard_Integer DE_ConfigurationContext::IntegerVal(const TCollection_AsciiString& theParam,
const Standard_Integer theDefValue,
const TCollection_AsciiString& theScope) const
@ -271,10 +252,8 @@ Standard_Integer DE_ConfigurationContext::IntegerVal(const TCollection_AsciiStri
return GetInteger(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : BooleanVal
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::BooleanVal(const TCollection_AsciiString& theParam,
const Standard_Boolean theDefValue,
const TCollection_AsciiString& theScope) const
@ -283,11 +262,10 @@ Standard_Boolean DE_ConfigurationContext::BooleanVal(const TCollection_AsciiStri
return GetBoolean(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : StringVal
//purpose :
//=======================================================================
TCollection_AsciiString DE_ConfigurationContext::StringVal(const TCollection_AsciiString& theParam,
//=================================================================================================
TCollection_AsciiString DE_ConfigurationContext::StringVal(
const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theDefValue,
const TCollection_AsciiString& theScope) const
{
@ -295,10 +273,8 @@ TCollection_AsciiString DE_ConfigurationContext::StringVal(const TCollection_Asc
return GetString(theParam, aVal, theScope) ? aVal : theDefValue;
}
//=======================================================================
//function : GetReal
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::GetReal(const TCollection_AsciiString& theParam,
Standard_Real& theValue,
const TCollection_AsciiString& theScope) const
@ -316,10 +292,8 @@ Standard_Boolean DE_ConfigurationContext::GetReal(const TCollection_AsciiString&
return Standard_False;
}
//=======================================================================
//function : GetInteger
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::GetInteger(const TCollection_AsciiString& theParam,
Standard_Integer& theValue,
const TCollection_AsciiString& theScope) const
@ -337,10 +311,8 @@ Standard_Boolean DE_ConfigurationContext::GetInteger(const TCollection_AsciiStri
return Standard_False;
}
//=======================================================================
//function : GetBoolean
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::GetBoolean(const TCollection_AsciiString& theParam,
Standard_Boolean& theValue,
const TCollection_AsciiString& theScope) const
@ -358,10 +330,8 @@ Standard_Boolean DE_ConfigurationContext::GetBoolean(const TCollection_AsciiStri
return Standard_False;
}
//=======================================================================
//function : GetString
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::GetString(const TCollection_AsciiString& theParam,
TCollection_AsciiString& theStr,
const TCollection_AsciiString& theScope) const
@ -370,11 +340,10 @@ Standard_Boolean DE_ConfigurationContext::GetString(const TCollection_AsciiStrin
return myResource.Find(aResource, theStr);
}
//=======================================================================
//function : GetStringSeq
//purpose :
//=======================================================================
Standard_Boolean DE_ConfigurationContext::GetStringSeq(const TCollection_AsciiString& theParam,
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::GetStringSeq(
const TCollection_AsciiString& theParam,
TColStd_ListOfAsciiString& theValue,
const TCollection_AsciiString& theScope) const
{
@ -401,10 +370,8 @@ Standard_Boolean DE_ConfigurationContext::GetStringSeq(const TCollection_AsciiSt
return Standard_True;
}
//=======================================================================
//function : load
//purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_ConfigurationContext::load(const TCollection_AsciiString& theResourceLine)
{
if (theResourceLine.IsEmpty())

View File

@ -135,7 +135,8 @@ public:
//! @param[in] theDefValue value by default if param is not found or has wrong type
//! @param[in] theScope base parameter name
//! @return specific type value
Standard_EXPORT TCollection_AsciiString StringVal(const TCollection_AsciiString& theParam,
Standard_EXPORT TCollection_AsciiString
StringVal(const TCollection_AsciiString& theParam,
const TCollection_AsciiString& theDefValue,
const TCollection_AsciiString& theScope = "") const;
@ -144,16 +145,13 @@ public:
Standard_EXPORT const DE_ResourceMap& GetInternalMap() const { return myResource; }
protected:
//! Update the resource with param value from the line
//! @paramp[in] theResourceLine line contains the parameter
//! @return true if theResourceLine has loaded correctly
Standard_Boolean load(const TCollection_AsciiString& theResourceLine);
private:
DE_ResourceMap myResource; //!< Internal parameters map
};
#endif // _DE_ConfigurationContext_HeaderFile

View File

@ -13,9 +13,9 @@
#include <DE_ConfigurationNode.hxx>
#include <DE_ConfigurationContext.hxx>
#include <DE_Provider.hxx>
#include <DE_Wrapper.hxx>
#include <DE_ConfigurationContext.hxx>
#include <Message.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
@ -23,28 +23,23 @@
IMPLEMENT_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
//=======================================================================
// function : DE_ConfigurationNode
// purpose :
//=======================================================================
DE_ConfigurationNode::DE_ConfigurationNode() :
myIsEnabled(Standard_True)
{}
//=================================================================================================
DE_ConfigurationNode::DE_ConfigurationNode()
: myIsEnabled(Standard_True)
{
}
//=================================================================================================
//=======================================================================
// function : DE_ConfigurationNode
// purpose :
//=======================================================================
DE_ConfigurationNode::DE_ConfigurationNode(const Handle(DE_ConfigurationNode)& theConfigurationNode)
{
GlobalParameters = theConfigurationNode->GlobalParameters;
myIsEnabled = theConfigurationNode->IsEnabled();
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::Load(const TCollection_AsciiString& theResourcePath)
{
Handle(DE_ConfigurationContext) aResource = new DE_ConfigurationContext();
@ -52,10 +47,8 @@ bool DE_ConfigurationNode::Load(const TCollection_AsciiString& theResourcePath)
return Load(aResource);
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::Save(const TCollection_AsciiString& theResourcePath) const
{
OSD_Path aPath = theResourcePath;
@ -84,10 +77,8 @@ bool DE_ConfigurationNode::Save(const TCollection_AsciiString& theResourcePath)
return true;
}
//=======================================================================
// function : UpdateLoad
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::UpdateLoad(const Standard_Boolean theToImport,
const Standard_Boolean theToKeep)
{
@ -96,28 +87,22 @@ bool DE_ConfigurationNode::UpdateLoad(const Standard_Boolean theToImport,
return true;
}
//=======================================================================
// function : IsImportSupported
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::IsImportSupported() const
{
return false;
}
//=======================================================================
// function : IsExportSupported
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::IsExportSupported() const
{
return false;
}
//=======================================================================
// function : CheckForSupport
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::CheckExtension(const TCollection_AsciiString& theExtension) const
{
TCollection_AsciiString anExtension(theExtension);
@ -130,8 +115,7 @@ bool DE_ConfigurationNode::CheckExtension(const TCollection_AsciiString& theExte
anExtension.Remove(1);
}
const TColStd_ListOfAsciiString& anExtensions = GetExtensions();
for (TColStd_ListOfAsciiString::Iterator anIter(anExtensions);
anIter.More(); anIter.Next())
for (TColStd_ListOfAsciiString::Iterator anIter(anExtensions); anIter.More(); anIter.Next())
{
if (TCollection_AsciiString::IsSameString(anIter.Value(), anExtension, Standard_False))
{
@ -141,10 +125,8 @@ bool DE_ConfigurationNode::CheckExtension(const TCollection_AsciiString& theExte
return false;
}
//=======================================================================
// function : CheckForSupport
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ConfigurationNode::CheckContent(const Handle(NCollection_Buffer)& theBuffer) const
{
(void)theBuffer;

View File

@ -50,7 +50,6 @@ class DE_ConfigurationNode : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(DE_ConfigurationNode, Standard_Transient)
public:
//! Initializes all field by default
Standard_EXPORT DE_ConfigurationNode();
@ -93,7 +92,6 @@ public:
const Standard_Boolean theToKeep);
public:
//! Checks the import supporting
//! @return Standard_True if import is support
Standard_EXPORT virtual bool IsImportSupported() const;
@ -125,20 +123,13 @@ public:
Standard_EXPORT virtual bool CheckContent(const Handle(NCollection_Buffer)& theBuffer) const;
public:
//! Gets the provider loading status
//! @return Standard_True if the load is correct
Standard_Boolean IsEnabled() const
{
return myIsEnabled;
}
Standard_Boolean IsEnabled() const { return myIsEnabled; }
//! Sets the provider loading status
//! @param[in] theIsLoaded input load status
void SetEnabled(const Standard_Boolean theIsLoaded)
{
myIsEnabled = theIsLoaded;
}
void SetEnabled(const Standard_Boolean theIsLoaded) { myIsEnabled = theIsLoaded; }
//! Custom function to activate commercial DE component.
//! The input is special sequence of values that described in
@ -150,18 +141,18 @@ public:
Standard_EXPORT virtual void CustomActivation(const TColStd_ListOfAsciiString&) {};
public:
//!< Internal parameters for transfer process
struct DE_SectionGlobal
{
Standard_Real LengthUnit = 1.0; //!< Target Unit (scaling based on MM) for the transfer process, default 1.0 (MM)
Standard_Real SystemUnit = 1.0; //!< System Unit (scaling based on MM) to be used when initial unit is unknown, default 1.0 (MM)
Standard_Real LengthUnit =
1.0; //!< Target Unit (scaling based on MM) for the transfer process, default 1.0 (MM)
Standard_Real SystemUnit = 1.0; //!< System Unit (scaling based on MM) to be used when initial
//!< unit is unknown, default 1.0 (MM)
} GlobalParameters;
private:
Standard_Boolean myIsEnabled; //!< Flag to use a current provider for Read or Write process via DE_Wrapper
Standard_Boolean
myIsEnabled; //!< Flag to use a current provider for Read or Write process via DE_Wrapper
};
#endif // _DE_ConfigurationNode_HeaderFile

View File

@ -18,25 +18,19 @@
IMPLEMENT_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
//=======================================================================
// function : DE_Provider
// purpose :
//=======================================================================
DE_Provider::DE_Provider()
{}
//=================================================================================================
DE_Provider::DE_Provider() {}
//=================================================================================================
//=======================================================================
// function : DE_Provider
// purpose :
//=======================================================================
DE_Provider::DE_Provider(const Handle(DE_ConfigurationNode)& theNode)
:myNode(theNode)
{}
: myNode(theNode)
{
}
//=================================================================================================
//=======================================================================
// function : Read
// purpose :
//=======================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
@ -46,15 +40,13 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
(void)theDocument;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() <<" doesn't support read operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
@ -64,15 +56,13 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
(void)theDocument;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
@ -80,15 +70,13 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
(void)thePath;
(void)theDocument;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
@ -96,15 +84,13 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
(void)thePath;
(void)theDocument;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
@ -114,15 +100,13 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
(void)theShape;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
@ -132,15 +116,13 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
(void)theShape;
(void)theWS;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support write operation";
return Standard_False;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
@ -148,15 +130,13 @@ Standard_Boolean DE_Provider::Read(const TCollection_AsciiString& thePath,
(void)thePath;
(void)theShape;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support read operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support read operation";
return Standard_False;
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
@ -164,7 +144,7 @@ Standard_Boolean DE_Provider::Write(const TCollection_AsciiString& thePath,
(void)thePath;
(void)theShape;
(void)theProgress;
Message::SendFail() << "Error: provider " << GetFormat() <<
" " << GetVendor() << " doesn't support write operation";
Message::SendFail() << "Error: provider " << GetFormat() << " " << GetVendor()
<< " doesn't support write operation";
return Standard_False;
}

View File

@ -44,7 +44,6 @@ public:
DEFINE_STANDARD_RTTIEXT(DE_Provider, Standard_Transient)
public:
//! Default constructor
//! Configure translation process with global configuration
Standard_EXPORT DE_Provider();
@ -54,14 +53,14 @@ public:
Standard_EXPORT DE_Provider(const Handle(DE_ConfigurationNode)& theNode);
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Read(
const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -72,7 +71,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Write(
const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -82,7 +82,8 @@ public:
//! @param[out] theDocument document to save result
//! @param[in] theProgress progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Read(
const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -91,7 +92,8 @@ public:
//! @param[out] theDocument document to export
//! @param[in] theProgress progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Write(
const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -101,7 +103,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Read(
const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -112,7 +115,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Write(
const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -122,7 +126,8 @@ public:
//! @param[out] theShape shape to save result
//! @param[in] theProgress progress indicator
//! @return True if Read was successful
Standard_EXPORT virtual Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Read(
const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -131,12 +136,12 @@ public:
//! @param[out] theShape shape to export
//! @param[in] theProgress progress indicator
//! @return True if Write was successful
Standard_EXPORT virtual Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT virtual Standard_Boolean Write(
const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! Gets CAD format name of associated provider
//! @return provider CAD format
Standard_EXPORT virtual TCollection_AsciiString GetFormat() const = 0;
@ -147,20 +152,13 @@ public:
//! Gets internal configuration node
//! @return configuration node object
Handle(DE_ConfigurationNode) GetNode() const
{
return myNode;
}
Handle(DE_ConfigurationNode) GetNode() const { return myNode; }
//! Sets internal configuration node
//! @param[in] theNode configuration node to set
void SetNode(const Handle(DE_ConfigurationNode)& theNode)
{
myNode = theNode;
}
void SetNode(const Handle(DE_ConfigurationNode)& theNode) { myNode = theNode; }
private:
Handle(DE_ConfigurationNode) myNode; //!< Internal configuration for the own format
};

View File

@ -21,151 +21,260 @@ IMPLEMENT_STANDARD_RTTIEXT(DE_ShapeFixConfigurationNode, DE_ConfigurationNode)
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope = "provider";
return aScope;
}
}
} // namespace
//=================================================================================================
//=======================================================================
// function : DE_ShapeFixConfigurationNode
// purpose :
//=======================================================================
DE_ShapeFixConfigurationNode::DE_ShapeFixConfigurationNode()
: DE_ConfigurationNode()
{}
{
}
//=======================================================================
// function : DE_ShapeFixConfigurationNode
// purpose :
//=======================================================================
DE_ShapeFixConfigurationNode::DE_ShapeFixConfigurationNode(const Handle(DE_ShapeFixConfigurationNode)& theNode)
//=================================================================================================
DE_ShapeFixConfigurationNode::DE_ShapeFixConfigurationNode(
const Handle(DE_ShapeFixConfigurationNode)& theNode)
: DE_ConfigurationNode(theNode)
{
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
//=================================================================================================
bool DE_ShapeFixConfigurationNode::Load(const Handle(DE_ConfigurationContext)& theResource)
{
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".healing";
TCollection_AsciiString aScope =
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".healing";
HealingParameters.Tolerance3d = theResource->RealVal("tolerance3d", HealingParameters.Tolerance3d, aScope);
HealingParameters.MaxTolerance3d = theResource->RealVal("max.tolerance3d", HealingParameters.MaxTolerance3d, aScope);
HealingParameters.MinTolerance3d = theResource->RealVal("min.tolerance3d", HealingParameters.MinTolerance3d, aScope);
HealingParameters.FixFreeShellMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("free.shell", (int)HealingParameters.FixFreeShellMode, aScope);
HealingParameters.FixFreeFaceMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("free.face", (int)HealingParameters.FixFreeFaceMode, aScope);
HealingParameters.FixFreeWireMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("free.wire", (int)HealingParameters.FixFreeWireMode, aScope);
HealingParameters.FixSameParameterMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("same.parameter", (int)HealingParameters.FixSameParameterMode, aScope);
HealingParameters.FixSolidMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("solid", (int)HealingParameters.FixSolidMode, aScope);
HealingParameters.FixShellOrientationMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("shell.orientation", (int)HealingParameters.FixShellOrientationMode, aScope);
HealingParameters.CreateOpenSolidMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("create.open.solid", (int)HealingParameters.CreateOpenSolidMode, aScope);
HealingParameters.FixShellMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("shell", (int)HealingParameters.FixShellMode, aScope);
HealingParameters.FixFaceOrientationMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("face.orientation", (int)HealingParameters.FixFaceOrientationMode, aScope);
HealingParameters.FixFaceMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("face", (int)HealingParameters.FixFaceMode, aScope);
HealingParameters.FixWireMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("wire", (int)HealingParameters.FixWireMode, aScope);
HealingParameters.FixOrientationMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("orientation", (int)HealingParameters.FixOrientationMode, aScope);
HealingParameters.FixAddNaturalBoundMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("add.natural.bound", (int)HealingParameters.FixAddNaturalBoundMode, aScope);
HealingParameters.FixMissingSeamMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("missing.seam", (int)HealingParameters.FixMissingSeamMode, aScope);
HealingParameters.FixSmallAreaWireMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("small.area.wire", (int)HealingParameters.FixSmallAreaWireMode, aScope);
HealingParameters.RemoveSmallAreaFaceMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("remove.small.area.face", (int)HealingParameters.RemoveSmallAreaFaceMode, aScope);
HealingParameters.FixIntersectingWiresMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("intersecting.wires", (int)HealingParameters.FixIntersectingWiresMode, aScope);
HealingParameters.FixLoopWiresMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("loop.wires", (int)HealingParameters.FixLoopWiresMode, aScope);
HealingParameters.FixSplitFaceMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("split.face", (int)HealingParameters.FixSplitFaceMode, aScope);
HealingParameters.AutoCorrectPrecisionMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("auto.correct.precision", (int)HealingParameters.AutoCorrectPrecisionMode, aScope);
HealingParameters.ModifyTopologyMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("modify.topology", (int)HealingParameters.ModifyTopologyMode, aScope);
HealingParameters.ModifyGeometryMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("modify.geometry", (int)HealingParameters.ModifyGeometryMode, aScope);
HealingParameters.ClosedWireMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("closed.wire", (int)HealingParameters.ClosedWireMode, aScope);
HealingParameters.PreferencePCurveMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("preference.pcurve", (int)HealingParameters.PreferencePCurveMode, aScope);
HealingParameters.FixReorderMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("reorder.edges", (int)HealingParameters.FixReorderMode, aScope);
HealingParameters.FixSmallMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("remove.small.edges", (int)HealingParameters.FixSmallMode, aScope);
HealingParameters.FixConnectedMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("connected.edges", (int)HealingParameters.FixConnectedMode, aScope);
HealingParameters.FixEdgeCurvesMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("edge.curves", (int)HealingParameters.FixEdgeCurvesMode, aScope);
HealingParameters.FixDegeneratedMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("add.degenerated.edges", (int)HealingParameters.FixDegeneratedMode, aScope);
HealingParameters.FixLackingMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("add.lacking.edges", (int)HealingParameters.FixLackingMode, aScope);
HealingParameters.FixSelfIntersectionMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("selfintersection", (int)HealingParameters.FixSelfIntersectionMode, aScope);
HealingParameters.RemoveLoopMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("remove.loop", (int)HealingParameters.RemoveLoopMode, aScope);
HealingParameters.FixReversed2dMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("reversed2d", (int)HealingParameters.FixReversed2dMode, aScope);
HealingParameters.FixRemovePCurveMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("remove.pcurve", (int)HealingParameters.FixRemovePCurveMode, aScope);
HealingParameters.FixRemoveCurve3dMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("remove.curve3d", (int)HealingParameters.FixRemoveCurve3dMode, aScope);
HealingParameters.FixAddPCurveMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("add.pcurve", (int)HealingParameters.FixAddPCurveMode, aScope);
HealingParameters.FixAddCurve3dMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("add.curve3d", (int)HealingParameters.FixAddCurve3dMode, aScope);
HealingParameters.FixSeamMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("correct.order.in.seam", (int)HealingParameters.FixSeamMode, aScope);
HealingParameters.FixShiftedMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("shifted", (int)HealingParameters.FixShiftedMode, aScope);
HealingParameters.FixEdgeSameParameterMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("edge.same.parameter", (int)HealingParameters.FixEdgeSameParameterMode, aScope);
HealingParameters.FixNotchedEdgesMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("notched.edges", (int)HealingParameters.FixNotchedEdgesMode, aScope);
HealingParameters.FixTailMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("tail", (int)HealingParameters.FixTailMode, aScope);
HealingParameters.MaxTailAngle = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("max.tail.angle", (int)HealingParameters.MaxTailAngle, aScope);
HealingParameters.MaxTailWidth = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("max.tail.width", (int)HealingParameters.MaxTailWidth, aScope);
HealingParameters.FixSelfIntersectingEdgeMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("selfintersecting.edge", (int)HealingParameters.FixSelfIntersectingEdgeMode, aScope);
HealingParameters.FixIntersectingEdgesMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("intersecting.edges", (int)HealingParameters.FixIntersectingEdgesMode, aScope);
HealingParameters.FixNonAdjacentIntersectingEdgesMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("nonadjacent.intersecting.edges", (int)HealingParameters.FixNonAdjacentIntersectingEdgesMode, aScope);
HealingParameters.FixVertexPositionMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("vertex.position", (int)HealingParameters.FixVertexPositionMode, aScope);
HealingParameters.FixVertexToleranceMode = (DE_ShapeFixParameters::FixMode)
theResource->IntegerVal("vertex.tolerance", (int)HealingParameters.FixVertexToleranceMode, aScope);
HealingParameters.Tolerance3d =
theResource->RealVal("tolerance3d", HealingParameters.Tolerance3d, aScope);
HealingParameters.MaxTolerance3d =
theResource->RealVal("max.tolerance3d", HealingParameters.MaxTolerance3d, aScope);
HealingParameters.MinTolerance3d =
theResource->RealVal("min.tolerance3d", HealingParameters.MinTolerance3d, aScope);
HealingParameters.FixFreeShellMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("free.shell",
(int)HealingParameters.FixFreeShellMode,
aScope);
HealingParameters.FixFreeFaceMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("free.face",
(int)HealingParameters.FixFreeFaceMode,
aScope);
HealingParameters.FixFreeWireMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("free.wire",
(int)HealingParameters.FixFreeWireMode,
aScope);
HealingParameters.FixSameParameterMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"same.parameter",
(int)HealingParameters.FixSameParameterMode,
aScope);
HealingParameters.FixSolidMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("solid",
(int)HealingParameters.FixSolidMode,
aScope);
HealingParameters.FixShellOrientationMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"shell.orientation",
(int)HealingParameters.FixShellOrientationMode,
aScope);
HealingParameters.CreateOpenSolidMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"create.open.solid",
(int)HealingParameters.CreateOpenSolidMode,
aScope);
HealingParameters.FixShellMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("shell",
(int)HealingParameters.FixShellMode,
aScope);
HealingParameters.FixFaceOrientationMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"face.orientation",
(int)HealingParameters.FixFaceOrientationMode,
aScope);
HealingParameters.FixFaceMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("face",
(int)HealingParameters.FixFaceMode,
aScope);
HealingParameters.FixWireMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("wire",
(int)HealingParameters.FixWireMode,
aScope);
HealingParameters.FixOrientationMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"orientation",
(int)HealingParameters.FixOrientationMode,
aScope);
HealingParameters.FixAddNaturalBoundMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"add.natural.bound",
(int)HealingParameters.FixAddNaturalBoundMode,
aScope);
HealingParameters.FixMissingSeamMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"missing.seam",
(int)HealingParameters.FixMissingSeamMode,
aScope);
HealingParameters.FixSmallAreaWireMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"small.area.wire",
(int)HealingParameters.FixSmallAreaWireMode,
aScope);
HealingParameters.RemoveSmallAreaFaceMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"remove.small.area.face",
(int)HealingParameters.RemoveSmallAreaFaceMode,
aScope);
HealingParameters.FixIntersectingWiresMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"intersecting.wires",
(int)HealingParameters.FixIntersectingWiresMode,
aScope);
HealingParameters.FixLoopWiresMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("loop.wires",
(int)HealingParameters.FixLoopWiresMode,
aScope);
HealingParameters.FixSplitFaceMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("split.face",
(int)HealingParameters.FixSplitFaceMode,
aScope);
HealingParameters.AutoCorrectPrecisionMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"auto.correct.precision",
(int)HealingParameters.AutoCorrectPrecisionMode,
aScope);
HealingParameters.ModifyTopologyMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"modify.topology",
(int)HealingParameters.ModifyTopologyMode,
aScope);
HealingParameters.ModifyGeometryMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"modify.geometry",
(int)HealingParameters.ModifyGeometryMode,
aScope);
HealingParameters.ClosedWireMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("closed.wire",
(int)HealingParameters.ClosedWireMode,
aScope);
HealingParameters.PreferencePCurveMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"preference.pcurve",
(int)HealingParameters.PreferencePCurveMode,
aScope);
HealingParameters.FixReorderMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("reorder.edges",
(int)HealingParameters.FixReorderMode,
aScope);
HealingParameters.FixSmallMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("remove.small.edges",
(int)HealingParameters.FixSmallMode,
aScope);
HealingParameters.FixConnectedMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("connected.edges",
(int)HealingParameters.FixConnectedMode,
aScope);
HealingParameters.FixEdgeCurvesMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"edge.curves",
(int)HealingParameters.FixEdgeCurvesMode,
aScope);
HealingParameters.FixDegeneratedMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"add.degenerated.edges",
(int)HealingParameters.FixDegeneratedMode,
aScope);
HealingParameters.FixLackingMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("add.lacking.edges",
(int)HealingParameters.FixLackingMode,
aScope);
HealingParameters.FixSelfIntersectionMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"selfintersection",
(int)HealingParameters.FixSelfIntersectionMode,
aScope);
HealingParameters.RemoveLoopMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("remove.loop",
(int)HealingParameters.RemoveLoopMode,
aScope);
HealingParameters.FixReversed2dMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"reversed2d",
(int)HealingParameters.FixReversed2dMode,
aScope);
HealingParameters.FixRemovePCurveMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"remove.pcurve",
(int)HealingParameters.FixRemovePCurveMode,
aScope);
HealingParameters.FixRemoveCurve3dMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"remove.curve3d",
(int)HealingParameters.FixRemoveCurve3dMode,
aScope);
HealingParameters.FixAddPCurveMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("add.pcurve",
(int)HealingParameters.FixAddPCurveMode,
aScope);
HealingParameters.FixAddCurve3dMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"add.curve3d",
(int)HealingParameters.FixAddCurve3dMode,
aScope);
HealingParameters.FixSeamMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("correct.order.in.seam",
(int)HealingParameters.FixSeamMode,
aScope);
HealingParameters.FixShiftedMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("shifted",
(int)HealingParameters.FixShiftedMode,
aScope);
HealingParameters.FixEdgeSameParameterMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"edge.same.parameter",
(int)HealingParameters.FixEdgeSameParameterMode,
aScope);
HealingParameters.FixNotchedEdgesMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"notched.edges",
(int)HealingParameters.FixNotchedEdgesMode,
aScope);
HealingParameters.FixTailMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("tail",
(int)HealingParameters.FixTailMode,
aScope);
HealingParameters.MaxTailAngle =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("max.tail.angle",
(int)HealingParameters.MaxTailAngle,
aScope);
HealingParameters.MaxTailWidth =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal("max.tail.width",
(int)HealingParameters.MaxTailWidth,
aScope);
HealingParameters.FixSelfIntersectingEdgeMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"selfintersecting.edge",
(int)HealingParameters.FixSelfIntersectingEdgeMode,
aScope);
HealingParameters.FixIntersectingEdgesMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"intersecting.edges",
(int)HealingParameters.FixIntersectingEdgesMode,
aScope);
HealingParameters.FixNonAdjacentIntersectingEdgesMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"nonadjacent.intersecting.edges",
(int)HealingParameters.FixNonAdjacentIntersectingEdgesMode,
aScope);
HealingParameters.FixVertexPositionMode = (DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"vertex.position",
(int)HealingParameters.FixVertexPositionMode,
aScope);
HealingParameters.FixVertexToleranceMode =
(DE_ShapeFixParameters::FixMode)theResource->IntegerVal(
"vertex.tolerance",
(int)HealingParameters.FixVertexToleranceMode,
aScope);
return true;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
//=================================================================================================
TCollection_AsciiString DE_ShapeFixConfigurationNode::Save() const
{
TCollection_AsciiString aResult;
TCollection_AsciiString aScope = THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".healing";
TCollection_AsciiString aScope =
THE_CONFIGURATION_SCOPE() + "." + GetFormat() + "." + GetVendor() + ".healing";
aResult += "!\n";
aResult += "!Shape healing parameters:\n";
@ -191,301 +300,376 @@ TCollection_AsciiString DE_ShapeFixConfigurationNode::Save() const
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Shell for ShapeFix_Shape\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "free.shell :\t " + (int)HealingParameters.FixFreeShellMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Face for ShapeFix_Shape\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "free.face :\t " + (int)HealingParameters.FixFreeFaceMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Wire for ShapeFix_Shape\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "free.wire :\t " + (int)HealingParameters.FixFreeWireMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying ShapeFix::SameParameter after all fixes\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "same.parameter :\t " + (int)HealingParameters.FixSameParameterMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Solid\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "solid :\t " + (int)HealingParameters.FixSolidMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying analysis and fixes of orientation of shells in the solid\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "shell.orientation :\t " + (int)HealingParameters.FixShellOrientationMode + "\n";
aResult +=
"!Defines the mode for applying analysis and fixes of orientation of shells in the solid\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "shell.orientation :\t " + (int)HealingParameters.FixShellOrientationMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for creation of solids. If operation is executed then solids are created from open shells ";
aResult += "!Defines the mode for creation of solids. If operation is executed then solids are "
"created from open shells ";
aResult += "else solids are created from closed shells only\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "create.open.solid :\t " + (int)HealingParameters.CreateOpenSolidMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Shell for ShapeFix_Solid\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "shell :\t " + (int)HealingParameters.FixShellMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying analysis and fixes of orientation of faces in the shell\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "face.orientation :\t " + (int)HealingParameters.FixFaceOrientationMode + "\n";
aResult +=
"!Defines the mode for applying analysis and fixes of orientation of faces in the shell\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "face.orientation :\t " + (int)HealingParameters.FixFaceOrientationMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Face\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "face :\t " + (int)HealingParameters.FixFaceMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying fixes of ShapeFix_Wire\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "wire :\t " + (int)HealingParameters.FixWireMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying a fix for the orientation of faces in the shell\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "orientation :\t " + (int)HealingParameters.FixOrientationMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the add natural bound mode. If operation is executed then natural boundary is added on faces that miss them\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "add.natural.bound :\t " + (int)HealingParameters.FixAddNaturalBoundMode + "\n";
aResult += "!Defines the add natural bound mode. If operation is executed then natural boundary "
"is added on faces that miss them\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "add.natural.bound :\t " + (int)HealingParameters.FixAddNaturalBoundMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the fix missing seam mode (tries to insert seam is missed)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "missing.seam :\t " + (int)HealingParameters.FixMissingSeamMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the fix small area wire mode (drops small wires)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "small.area.wire :\t " + (int)HealingParameters.FixSmallAreaWireMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the remove face with small area (drops faces with small outer wires)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "remove.small.area.face :\t " + (int)HealingParameters.RemoveSmallAreaFaceMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "remove.small.area.face :\t " + (int)HealingParameters.RemoveSmallAreaFaceMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the fix intersecting wires mode in ShapeFix_Face\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "intersecting.wires :\t " + (int)HealingParameters.FixIntersectingWiresMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "intersecting.wires :\t " + (int)HealingParameters.FixIntersectingWiresMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the fix loop wires mode in ShapeFix_Face\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "loop.wires :\t " + (int)HealingParameters.FixLoopWiresMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the fix split face mode in ShapeFix_Face\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "split.face :\t " + (int)HealingParameters.FixSplitFaceMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the auto-correct precision mode in ShapeFix_Face\n";
aResult += "!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "auto.correct.precision :\t " + (int)HealingParameters.AutoCorrectPrecisionMode + "\n";
aResult +=
"!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
aScope + "auto.correct.precision :\t " + (int)HealingParameters.AutoCorrectPrecisionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to modify topology of the wire during fixing (adding/removing edges etc.)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Defines the mode allowed to modify topology of the wire during fixing "
"(adding/removing edges etc.)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "modify.topology :\t " + (int)HealingParameters.ModifyTopologyMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to modify geometry of the edges and vertices\n";
aResult += "!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
"!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "modify.geometry :\t " + (int)HealingParameters.ModifyGeometryMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to defines whether the wire is to be closed (by calling methods like FixDegenerated() ";
aResult += "!Defines the mode allowed to defines whether the wire is to be closed (by calling "
"methods like FixDegenerated() ";
aResult += "!and FixConnected() for lastand first edges\n";
aResult += "!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
"!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "closed.wire :\t " + (int)HealingParameters.ClosedWireMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to defines the 2d representation of the wire is preferable over 3d one ";
aResult += "!Defines the mode allowed to defines the 2d representation of the wire is preferable "
"over 3d one ";
aResult += "(in the case of ambiguity in FixEdgeCurves)\n";
aResult += "!and FixConnected() for lastand first edges\n";
aResult += "!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
"!Default value: \"Fix\"(1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "preference.pcurve :\t " + (int)HealingParameters.PreferencePCurveMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to reorder edges in the wire\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "reorder.edges :\t " + (int)HealingParameters.FixReorderMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to remove small edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "remove.small.edges :\t " + (int)HealingParameters.FixSmallMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix connecting edges in the wire\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "connected.edges :\t " + (int)HealingParameters.FixConnectedMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix edges (3Dcurves and 2D curves)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "edge.curves :\t " + (int)HealingParameters.FixEdgeCurvesMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for add degenerated edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "add.degenerated.edges :\t " + (int)HealingParameters.FixDegeneratedMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "add.degenerated.edges :\t " + (int)HealingParameters.FixDegeneratedMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for add lacking edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "add.lacking.edges :\t " + (int)HealingParameters.FixLackingMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix selfintersection edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "selfintersection :\t " + (int)HealingParameters.FixSelfIntersectionMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "selfintersection :\t " + (int)HealingParameters.FixSelfIntersectionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to remove loop\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "remove.loop :\t " + (int)HealingParameters.RemoveLoopMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to fix edge if pcurve is directed opposite to 3d curve\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "reversed2d :\t " + (int)HealingParameters.FixReversed2dMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to remove the pcurve(s) of the edge if it does not match the vertices\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Defines the mode allowed to remove the pcurve(s) of the edge if it does not match "
"the vertices\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "remove.pcurve :\t " + (int)HealingParameters.FixRemovePCurveMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to remove 3d curve of the edge if it does not match the vertices\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
"!Defines the mode allowed to remove 3d curve of the edge if it does not match the vertices\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "remove.curve3d :\t " + (int)HealingParameters.FixRemoveCurve3dMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to add pcurve(s) of the edge if missing (by projecting 3d curve)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult +=
"!Defines the mode allowed to add pcurve(s) of the edge if missing (by projecting 3d curve)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "add.pcurve :\t " + (int)HealingParameters.FixAddPCurveMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to build 3d curve of the edge if missing\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "add.curve3d :\t " + (int)HealingParameters.FixAddCurve3dMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to correct order of pcurves in the seam edge depends on its orientation\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Defines the mode allowed to correct order of pcurves in the seam edge depends on "
"its orientation\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "correct.order.in.seam :\t " + (int)HealingParameters.FixSeamMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode allowed to shifts wrong 2D curves back, ensuring that the 2D curves of the edges in the wire are connected\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Defines the mode allowed to shifts wrong 2D curves back, ensuring that the 2D "
"curves of the edges in the wire are connected\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "shifted :\t " + (int)HealingParameters.FixShiftedMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying EdgeSameParameter\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "edge.same.parameter :\t " + (int)HealingParameters.FixEdgeSameParameterMode + "\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "edge.same.parameter :\t " + (int)HealingParameters.FixEdgeSameParameterMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix notched edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "notched.edges :\t " + (int)HealingParameters.FixNotchedEdgesMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix tail in wire\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "tail :\t " + (int)HealingParameters.FixTailMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for max angle of the tails\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "max.tail.angle :\t " + (int)HealingParameters.MaxTailAngle + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for max tail width\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "max.tail.width :\t " + (int)HealingParameters.MaxTailWidth + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix selfintersecting of edge\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "selfintersecting.edge :\t " + (int)HealingParameters.FixSelfIntersectingEdgeMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "selfintersecting.edge :\t "
+ (int)HealingParameters.FixSelfIntersectingEdgeMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix intersecting edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "intersecting.edges :\t " + (int)HealingParameters.FixIntersectingEdgesMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "intersecting.edges :\t " + (int)HealingParameters.FixIntersectingEdgesMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for fix non adjacent intersecting edges\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "nonadjacent.intersecting.edges :\t " + (int)HealingParameters.FixNonAdjacentIntersectingEdgesMode + "\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "nonadjacent.intersecting.edges :\t "
+ (int)HealingParameters.FixNonAdjacentIntersectingEdgesMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for applying ShapeFix::FixVertexPosition before all fixes\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += "!Default value: \"NotFix\"(0). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult += aScope + "vertex.position :\t " + (int)HealingParameters.FixVertexPositionMode + "\n";
aResult += "!\n";
aResult += "!\n";
aResult += "!Defines the mode for increases the tolerances of the edge vertices to comprise ";
aResult += "!the ends of 3d curve and pcurve on the given face (first method) or all pcurves stored in an edge (second one)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), \"Fix\"(1)\n";
aResult += aScope + "vertex.tolerance :\t " + (int)HealingParameters.FixVertexToleranceMode + "\n";
aResult += "!the ends of 3d curve and pcurve on the given face (first method) or all pcurves "
"stored in an edge (second one)\n";
aResult += "!Default value: \"FixOrNot\"(-1). Available values: \"FixOrNot\"(-1), \"NotFix\"(0), "
"\"Fix\"(1)\n";
aResult +=
aScope + "vertex.tolerance :\t " + (int)HealingParameters.FixVertexToleranceMode + "\n";
aResult += "!\n";
return aResult;

View File

@ -25,27 +25,26 @@ class DE_ShapeFixConfigurationNode : public DE_ConfigurationNode
{
DEFINE_STANDARD_RTTIEXT(DE_ShapeFixConfigurationNode, DE_ConfigurationNode)
public:
//! Initializes all field by default
Standard_EXPORT DE_ShapeFixConfigurationNode();
//! Copies values of all fields
//! @param[in] theConfigurationNode object to copy
Standard_EXPORT DE_ShapeFixConfigurationNode(const Handle(DE_ShapeFixConfigurationNode)& theConfigurationNode);
Standard_EXPORT DE_ShapeFixConfigurationNode(
const Handle(DE_ShapeFixConfigurationNode)& theConfigurationNode);
//! Updates values according the resource
//! @param[in] theResource input resource to use
//! @return True if Load was successful
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource) Standard_OVERRIDE;
Standard_EXPORT virtual bool Load(const Handle(DE_ConfigurationContext)& theResource)
Standard_OVERRIDE;
//! Writes configuration to the string
//! @return result resource string
Standard_EXPORT virtual TCollection_AsciiString Save() const Standard_OVERRIDE;
public:
DE_ShapeFixParameters HealingParameters; //!< Shape healing parameters
};
#endif // _DE_ShapeFixConfigurationNode_HeaderFile

View File

@ -19,8 +19,8 @@
#include <Message_ProgressRange.hxx>
#include <NCollection_Buffer.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
#include <OSD_FileSystem.hxx>
#include <OSD_Path.hxx>
#include <OSD_Protection.hxx>
#include <Standard_ErrorHandler.hxx>
#include <TopoDS_Shape.hxx>
@ -29,31 +29,28 @@ IMPLEMENT_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
namespace
{
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope ("global");
static const TCollection_AsciiString& THE_CONFIGURATION_SCOPE()
{
static const TCollection_AsciiString aScope("global");
return aScope;
}
static Handle(DE_Wrapper)& THE_GLOBAL_CONFIGURATION()
{
static Handle(DE_Wrapper) aConf = new DE_Wrapper();
return aConf;
}
}
//=======================================================================
// function : DE_Wrapper
// purpose :
//=======================================================================
DE_Wrapper::DE_Wrapper()
:myKeepUpdates(Standard_False)
{}
static Handle(DE_Wrapper)& THE_GLOBAL_CONFIGURATION()
{
static Handle(DE_Wrapper) aConf = new DE_Wrapper();
return aConf;
}
} // namespace
//=================================================================================================
DE_Wrapper::DE_Wrapper()
: myKeepUpdates(Standard_False)
{
}
//=================================================================================================
//=======================================================================
// function : DE_Wrapper
// purpose :
//=======================================================================
DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
: DE_Wrapper()
{
@ -62,11 +59,11 @@ DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
return;
}
GlobalParameters = theWrapper->GlobalParameters;
for (DE_ConfigurationFormatMap::Iterator aFormatIter(theWrapper->Nodes());
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(theWrapper->Nodes()); aFormatIter.More();
aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
Bind(aVendorIter.Value());
}
@ -74,19 +71,15 @@ DE_Wrapper::DE_Wrapper(const Handle(DE_Wrapper)& theWrapper)
theWrapper->myKeepUpdates = myKeepUpdates;
}
//=======================================================================
// function : GlobalWrapper
// purpose :
//=======================================================================
//=================================================================================================
const Handle(DE_Wrapper)& DE_Wrapper::GlobalWrapper()
{
return THE_GLOBAL_CONFIGURATION();
}
//=======================================================================
// function : SetGlobalWrapper
// purpose :
//=======================================================================
//=================================================================================================
void DE_Wrapper::SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper)
{
if (!theWrapper.IsNull())
@ -95,20 +88,16 @@ void DE_Wrapper::SetGlobalWrapper(const Handle(DE_Wrapper)& theWrapper)
}
}
//=======================================================================
// function : GlobalLoadMutex
// purpose :
//=======================================================================
//=================================================================================================
Standard_Mutex& DE_Wrapper::GlobalLoadMutex()
{
static Standard_Mutex THE_GLOBAL_LOAD_MUTEX;
return THE_GLOBAL_LOAD_MUTEX;
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
@ -130,10 +119,8 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
return aProvider->Read(thePath, theDocument, theWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
@ -155,10 +142,8 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theDocument, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
@ -175,10 +160,8 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
return aProvider->Read(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress)
@ -195,10 +178,8 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theDocument, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
@ -216,10 +197,8 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
return aProvider->Read(thePath, theShape, theWS, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
@ -237,10 +216,8 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theShape, theWS, theProgress);
}
//=======================================================================
// function : Read
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
@ -254,10 +231,8 @@ Standard_Boolean DE_Wrapper::Read(const TCollection_AsciiString& thePath,
return aProvider->Read(thePath, theShape, theProgress);
}
//=======================================================================
// function : Write
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress)
@ -270,10 +245,8 @@ Standard_Boolean DE_Wrapper::Write(const TCollection_AsciiString& thePath,
return aProvider->Write(thePath, theShape, theProgress);
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Load(const TCollection_AsciiString& theResource,
const Standard_Boolean theIsRecursive)
{
@ -282,22 +255,24 @@ Standard_Boolean DE_Wrapper::Load(const TCollection_AsciiString& theResource,
return Load(aResource, theIsRecursive);
}
//=======================================================================
// function : Load
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Load(const Handle(DE_ConfigurationContext)& theResource,
const Standard_Boolean theIsRecursive)
{
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit", GlobalParameters.LengthUnit, THE_CONFIGURATION_SCOPE());
GlobalParameters.SystemUnit = theResource->RealVal("general.system.unit", GlobalParameters.SystemUnit, THE_CONFIGURATION_SCOPE());
GlobalParameters.LengthUnit = theResource->RealVal("general.length.unit",
GlobalParameters.LengthUnit,
THE_CONFIGURATION_SCOPE());
GlobalParameters.SystemUnit = theResource->RealVal("general.system.unit",
GlobalParameters.SystemUnit,
THE_CONFIGURATION_SCOPE());
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
aVendorIter.Value()->Load(theResource);
}
@ -307,10 +282,8 @@ Standard_Boolean DE_Wrapper::Load(const Handle(DE_ConfigurationContext)& theReso
return Standard_True;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Save(const TCollection_AsciiString& theResourcePath,
const Standard_Boolean theIsRecursive,
const TColStd_ListOfAsciiString& theFormats,
@ -340,10 +313,8 @@ Standard_Boolean DE_Wrapper::Save(const TCollection_AsciiString& theResourcePath
return Standard_True;
}
//=======================================================================
// function : Save
// purpose :
//=======================================================================
//=================================================================================================
TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
const TColStd_ListOfAsciiString& theFormats,
const TColStd_ListOfAsciiString& theVendors)
@ -359,13 +330,13 @@ TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
aResult += "!*****************************************************************************\n";
aResult += "!DE_Wrapper\n";
aResult += "!Priority vendor list. For every CAD format set indexed list of vendors\n";
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
const TCollection_AsciiString& aFormat = aFormatIter.Key();
aResult += THE_CONFIGURATION_SCOPE() + '.' + "priority" + '.' + aFormat + " :\t ";
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
const TCollection_AsciiString& aVendorName = aVendorIter.Value()->GetVendor();
aResult += aVendorName + " ";
@ -374,20 +345,22 @@ TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
}
aResult += "!Global parameters. Used for all providers\n";
aResult += "!Length scale unit value. Should be more than 0. Default value: 1.0(MM)\n";
aResult += THE_CONFIGURATION_SCOPE() + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
aResult +=
THE_CONFIGURATION_SCOPE() + ".general.length.unit :\t " + GlobalParameters.LengthUnit + "\n";
aResult += "!System unit value. Should be more than 0. Default value: 1.0(MM)\n";
aResult += THE_CONFIGURATION_SCOPE() + ".general.system.unit :\t " + GlobalParameters.SystemUnit + "\n";
aResult +=
THE_CONFIGURATION_SCOPE() + ".general.system.unit :\t " + GlobalParameters.SystemUnit + "\n";
if (theIsRecursive)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
if (!theFormats.IsEmpty() && !theFormats.Contains(aFormatIter.Key()))
{
continue;
}
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
if (!theVendors.IsEmpty() && !theVendors.Contains(aVendorIter.Key()))
{
@ -403,10 +376,8 @@ TCollection_AsciiString DE_Wrapper::Save(const Standard_Boolean theIsRecursive,
return aResult;
}
//=======================================================================
// function : Bind
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Bind(const Handle(DE_ConfigurationNode)& theNode)
{
if (theNode.IsNull())
@ -424,10 +395,8 @@ Standard_Boolean DE_Wrapper::Bind(const Handle(DE_ConfigurationNode)& theNode)
return aVendorMap->Add(aVendorName, theNode) > 0;
}
//=======================================================================
// function : UnBind
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::UnBind(const Handle(DE_ConfigurationNode)& theNode)
{
if (theNode.IsNull())
@ -446,10 +415,8 @@ Standard_Boolean DE_Wrapper::UnBind(const Handle(DE_ConfigurationNode)& theNode)
return aVendorMap->Size() != aPrevSize;
}
//=======================================================================
// function : Find
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::Find(const TCollection_AsciiString& theFormat,
const TCollection_AsciiString& theVendor,
Handle(DE_ConfigurationNode)& theNode) const
@ -458,10 +425,8 @@ Standard_Boolean DE_Wrapper::Find(const TCollection_AsciiString& theFormat,
return aVendorMap != nullptr && aVendorMap->FindFromKey(theVendor, theNode);
}
//=======================================================================
// function : ChangePriority
// purpose :
//=======================================================================
//=================================================================================================
void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable)
@ -473,8 +438,8 @@ void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
}
DE_ConfigurationVendorMap aNewVendorMap;
// Sets according to the input priority
for (TColStd_ListOfAsciiString::Iterator aPriorIter(theVendorPriority);
aPriorIter.More(); aPriorIter.Next())
for (TColStd_ListOfAsciiString::Iterator aPriorIter(theVendorPriority); aPriorIter.More();
aPriorIter.Next())
{
const TCollection_AsciiString& aVendorName = aPriorIter.Value();
Handle(DE_ConfigurationNode) aNode;
@ -485,8 +450,8 @@ void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
}
}
// Sets not used elements
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aVendorMap);
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aVendorMap); aVendorIter.More();
aVendorIter.Next())
{
const TCollection_AsciiString& aVendorName = aVendorIter.Key();
if (!theVendorPriority.Contains(aVendorName))
@ -502,42 +467,34 @@ void DE_Wrapper::ChangePriority(const TCollection_AsciiString& theFormat,
myConfiguration.Bind(theFormat, aNewVendorMap);
}
//=======================================================================
// function : ChangePriority
// purpose :
//=======================================================================
//=================================================================================================
void DE_Wrapper::ChangePriority(const TColStd_ListOfAsciiString& theVendorPriority,
const Standard_Boolean theToDisable)
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
ChangePriority(aFormatIter.Key(), theVendorPriority, theToDisable);
}
}
//=======================================================================
// function : Nodes
// purpose :
//=======================================================================
//=================================================================================================
const DE_ConfigurationFormatMap& DE_Wrapper::Nodes() const
{
return myConfiguration;
}
//=======================================================================
// function : Copy
// purpose :
//=======================================================================
//=================================================================================================
Handle(DE_Wrapper) DE_Wrapper::Copy() const
{
return new DE_Wrapper(*this);
}
//=======================================================================
// function : FindProvider
// purpose :
//=======================================================================
//=================================================================================================
Standard_Boolean DE_Wrapper::FindProvider(const TCollection_AsciiString& thePath,
const Standard_Boolean theToImport,
Handle(DE_Provider)& theProvider) const
@ -546,7 +503,8 @@ Standard_Boolean DE_Wrapper::FindProvider(const TCollection_AsciiString& thePath
if (theToImport)
{
const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
std::shared_ptr<std::istream> aStream =
aFileSystem->OpenIStream(thePath, std::ios::in | std::ios::binary);
if (aStream.get() != nullptr)
{
aBuffer = new NCollection_Buffer(NCollection_BaseAllocator::CommonBaseAllocator(), 2048);
@ -556,19 +514,18 @@ Standard_Boolean DE_Wrapper::FindProvider(const TCollection_AsciiString& thePath
}
OSD_Path aPath(thePath);
const TCollection_AsciiString anExtr = aPath.Extension();
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
const Handle(DE_ConfigurationNode)& aNode = aVendorIter.Value();
if (aNode->IsEnabled() &&
((theToImport && aNode->IsImportSupported()) ||
(!theToImport && aNode->IsExportSupported())) &&
(aNode->CheckExtension(anExtr) ||
(theToImport && aNode->CheckContent(aBuffer))) &&
aNode->UpdateLoad(theToImport, myKeepUpdates))
if (aNode->IsEnabled()
&& ((theToImport && aNode->IsImportSupported())
|| (!theToImport && aNode->IsExportSupported()))
&& (aNode->CheckExtension(anExtr) || (theToImport && aNode->CheckContent(aBuffer)))
&& aNode->UpdateLoad(theToImport, myKeepUpdates))
{
theProvider = aNode->BuildProvider();
aNode->GlobalParameters = GlobalParameters;
@ -579,17 +536,15 @@ Standard_Boolean DE_Wrapper::FindProvider(const TCollection_AsciiString& thePath
return Standard_False;
}
//=======================================================================
// function : UpdateLoad
// purpose :
//=======================================================================
//=================================================================================================
Standard_EXPORT void DE_Wrapper::UpdateLoad(const Standard_Boolean theToForceUpdate) const
{
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value());
aVendorIter.More(); aVendorIter.Next())
for (DE_ConfigurationVendorMap::Iterator aVendorIter(aFormatIter.Value()); aVendorIter.More();
aVendorIter.Next())
{
const Handle(DE_ConfigurationNode)& aNode = aVendorIter.Value();
aNode->UpdateLoad(Standard_True, Standard_True);
@ -601,15 +556,13 @@ Standard_EXPORT void DE_Wrapper::UpdateLoad(const Standard_Boolean theToForceUpd
}
}
//=======================================================================
// function : sort
// purpose :
//=======================================================================
//=================================================================================================
void DE_Wrapper::sort(const Handle(DE_ConfigurationContext)& theResource)
{
const TCollection_AsciiString aScope(THE_CONFIGURATION_SCOPE() + '.' + "priority");
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration);
aFormatIter.More(); aFormatIter.Next())
for (DE_ConfigurationFormatMap::Iterator aFormatIter(myConfiguration); aFormatIter.More();
aFormatIter.Next())
{
TColStd_ListOfAsciiString aVendorPriority;
if (!theResource->GetStringSeq(aFormatIter.Key(), aVendorPriority, aScope))

View File

@ -25,8 +25,10 @@ class TopoDS_Shape;
class XSControl_WorkSession;
class TDocStd_Document;
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode)> DE_ConfigurationVendorMap;
typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap> DE_ConfigurationFormatMap;
typedef NCollection_IndexedDataMap<TCollection_AsciiString, Handle(DE_ConfigurationNode)>
DE_ConfigurationVendorMap;
typedef NCollection_DataMap<TCollection_AsciiString, DE_ConfigurationVendorMap>
DE_ConfigurationFormatMap;
//! The main class for working with CAD file exchange.
//! Loads and Saves special CAD transfer property.
@ -54,7 +56,6 @@ class DE_Wrapper : public Standard_Transient
DEFINE_STANDARD_RTTIEXT(DE_Wrapper, Standard_Transient)
public:
//! Initializes all field by default
Standard_EXPORT DE_Wrapper();
@ -74,14 +75,14 @@ public:
Standard_EXPORT static Standard_Mutex& GlobalLoadMutex();
public:
//! Reads a CAD file, according internal configuration
//! @param[in] thePath path to the import CAD file
//! @param[out] theDocument document to save result
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -92,7 +93,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -102,7 +104,8 @@ public:
//! @param[out] theDocument document to save result
//! @param[in] theProgress progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Read(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -111,7 +114,8 @@ public:
//! @param[out] theDocument document to export
//! @param[in] theProgress progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Write(const TCollection_AsciiString& thePath,
const Handle(TDocStd_Document)& theDocument,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -121,7 +125,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -132,7 +137,8 @@ public:
//! @param[in] theWS current work session
//! @param[in] theProgress progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
Handle(XSControl_WorkSession)& theWS,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -142,7 +148,8 @@ public:
//! @param[out] theShape shape to save result
//! @param[in] theProgress progress indicator
//! @return true if Read operation has ended correctly
Standard_EXPORT Standard_Boolean Read(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Read(const TCollection_AsciiString& thePath,
TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
@ -151,12 +158,12 @@ public:
//! @param[out] theShape shape to export
//! @param[in] theProgress progress indicator
//! @return true if Write operation has ended correctly
Standard_EXPORT Standard_Boolean Write(const TCollection_AsciiString& thePath,
Standard_EXPORT Standard_Boolean
Write(const TCollection_AsciiString& thePath,
const TopoDS_Shape& theShape,
const Message_ProgressRange& theProgress = Message_ProgressRange());
public:
//! Updates values according the resource file
//! @param[in] theResource file path to resource or resource value
//! @param[in] theIsRecursive flag to update all nodes
@ -177,7 +184,8 @@ public:
//! @param[in] theFormats list of formats to save. If empty, saves all available
//! @param[in] theVendors list of providers to save. If empty, saves all available
//! @return true if the Configuration has saved correctly
Standard_EXPORT Standard_Boolean Save(const TCollection_AsciiString& theResourcePath,
Standard_EXPORT Standard_Boolean
Save(const TCollection_AsciiString& theResourcePath,
const Standard_Boolean theIsRecursive = Standard_True,
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
@ -187,7 +195,8 @@ public:
//! @param[in] theFormats list of formats to save. If empty, saves all available
//! @param[in] theVendors list of providers to save. If empty, saves all available
//! @return result resource string
Standard_EXPORT TCollection_AsciiString Save(const Standard_Boolean theIsRecursive = Standard_True,
Standard_EXPORT TCollection_AsciiString
Save(const Standard_Boolean theIsRecursive = Standard_True,
const TColStd_ListOfAsciiString& theFormats = TColStd_ListOfAsciiString(),
const TColStd_ListOfAsciiString& theVendors = TColStd_ListOfAsciiString());
@ -235,7 +244,8 @@ public:
Handle(DE_Provider)& theProvider) const;
//! Updates all registered nodes, all changes will be saved in nodes
//! @param[in] theToForceUpdate flag that turns on/of nodes, according to updated ability to import/export
//! @param[in] theToForceUpdate flag that turns on/of nodes, according to updated ability to
//! import/export
Standard_EXPORT void UpdateLoad(const Standard_Boolean theToForceUpdate = Standard_False) const;
//! Gets flag that keeps changes on configuration nodes which are being updated, false by default
@ -253,7 +263,6 @@ public:
Standard_EXPORT virtual Handle(DE_Wrapper) Copy() const;
protected:
//! Sorts the vendors according to the priority to work
//! Formats omitted from the resource are not modified
//! Vendors omitted from the format scope are disabled
@ -261,12 +270,12 @@ protected:
void sort(const Handle(DE_ConfigurationContext)& theResource);
public:
DE_ConfigurationNode::DE_SectionGlobal GlobalParameters; //!< Internal parameters for the all translators
DE_ConfigurationNode::DE_SectionGlobal
GlobalParameters; //!< Internal parameters for the all translators
private:
Standard_Boolean myKeepUpdates; //!< Flag that keeps changes on configuration nodes which are being updated
Standard_Boolean
myKeepUpdates; //!< Flag that keeps changes on configuration nodes which are being updated
DE_ConfigurationFormatMap myConfiguration; //!< Internal map of formats
};