mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024708: Convertation of the generic classes to the non-generic. Part 2
Generic classes from "AppParCurves" package: "AppDef_SmoothCriterion", "AppDef_LinearCriteria" and "AppDef_Variational" moved to the corresponding non-generic classes "AppDef_SmoothCriterion", "AppDef_LinearCriteria" and "AppDef_Variational" to "AppDef" package. Also several "*.cxx" files of "AppDef_Variational" class merged to one ".cxx". Generic class from "IntImp" package: "IntImp_ZerCOnSSParFunc" moved to the corresponding non-generic class "IntPatch_CSFunction" to "IntPatch" package. Next unused generic classes were removed: - IntCurveSurface_SurfaceTool - Intf_InterferencePolygon3d And some other minor changes.
This commit is contained in:
@@ -37,7 +37,7 @@ package AppDef
|
||||
-- Note: a CurvaturePoint is also a PassPoint and a TangencyPoint.
|
||||
-- A TangencyPoint is also a PassPoint.
|
||||
|
||||
uses AppParCurves, Approx, gp, TColgp, TCollection, Standard, MMgt
|
||||
uses AppParCurves, Approx, gp, TColgp, TCollection, Standard, MMgt, math, FEmTool, TColStd, GeomAbs, PLib
|
||||
|
||||
|
||||
is
|
||||
@@ -55,7 +55,13 @@ class MyLineTool;
|
||||
-- AppParCurves and Approx. For Approx, the tool will not addd points
|
||||
-- if the algorithms want some.
|
||||
|
||||
deferred class SmoothCriterion;
|
||||
|
||||
class LinearCriteria;
|
||||
|
||||
class Variational;
|
||||
---Purpose: computes the approximation of a Multiline by
|
||||
-- Variational optimization.
|
||||
|
||||
|
||||
--- Classes instanciees:
|
||||
@@ -64,10 +70,7 @@ class MyLineTool;
|
||||
class TheLeastSquares instantiates LeastSquare from AppParCurves
|
||||
(MultiLine from AppDef,
|
||||
MyLineTool from AppDef);
|
||||
|
||||
class TheVariational instantiates Variational from AppParCurves
|
||||
(MultiLine from AppDef,
|
||||
MyLineTool from AppDef);
|
||||
|
||||
|
||||
class TheResol instantiates ResolConstraint from AppParCurves
|
||||
(MultiLine from AppDef,
|
||||
|
130
src/AppDef/AppDef_LinearCriteria.cdl
Normal file
130
src/AppDef/AppDef_LinearCriteria.cdl
Normal file
@@ -0,0 +1,130 @@
|
||||
-- Created on: 1997-09-11
|
||||
-- Created by: Philippe MANGIN
|
||||
-- Copyright (c) 1997-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
class LinearCriteria from AppDef inherits SmoothCriterion from AppDef
|
||||
|
||||
---Purpose: defined an Linear Criteria to used in variational
|
||||
-- Smoothing of points.
|
||||
|
||||
|
||||
uses
|
||||
Vector from math,
|
||||
Matrix from math,
|
||||
Curve from FEmTool,
|
||||
HAssemblyTable from FEmTool,
|
||||
ElementaryCriterion from FEmTool,
|
||||
HArray2OfInteger from TColStd,
|
||||
HArray1OfReal from TColStd,
|
||||
Array1OfReal from TColStd,
|
||||
MultiLine from AppDef,
|
||||
MyLineTool from AppDef
|
||||
|
||||
raises
|
||||
NotImplemented,
|
||||
DomainError
|
||||
|
||||
|
||||
|
||||
is
|
||||
Create(SSP: MultiLine from AppDef;
|
||||
FirstPoint, LastPoint: Integer) returns LinearCriteria;
|
||||
|
||||
SetParameters(me : mutable; Parameters : HArray1OfReal);
|
||||
|
||||
SetCurve(me : mutable; C :Curve from FEmTool)
|
||||
is static;
|
||||
|
||||
GetCurve(me; C : out Curve from FEmTool)
|
||||
is static;
|
||||
|
||||
SetEstimation(me : mutable; E1, E2, E3 : Real)
|
||||
is static;
|
||||
|
||||
EstLength(me : mutable)
|
||||
---C++: return &
|
||||
returns Real is static;
|
||||
|
||||
GetEstimation(me; E1, E2, E3 : out Real)
|
||||
is static;
|
||||
|
||||
AssemblyTable(me)
|
||||
returns HAssemblyTable from FEmTool
|
||||
is static;
|
||||
|
||||
DependenceTable(me)
|
||||
returns HArray2OfInteger from TColStd
|
||||
is static;
|
||||
|
||||
|
||||
QualityValues (me : mutable; J1min, J2min, J3min : Real;
|
||||
J1, J2, J3 : out Real)
|
||||
returns Integer is static;
|
||||
|
||||
ErrorValues(me : mutable;
|
||||
MaxError, QuadraticError, AverageError : out Real)
|
||||
is static;
|
||||
|
||||
Hessian(me : mutable ;
|
||||
Element : Integer;
|
||||
Dimension1 : Integer;
|
||||
Dimension2 : Integer;
|
||||
H : out Matrix from math)
|
||||
raises DomainError -- If DependenceTable(Dimension1,Dimension2) is False
|
||||
is static;
|
||||
|
||||
|
||||
Gradient(me : mutable;
|
||||
Element : Integer;
|
||||
Dimension : Integer;
|
||||
G : out Vector from math)
|
||||
is static;
|
||||
|
||||
InputVector(me : mutable; X : Vector from math;
|
||||
AssTable : HAssemblyTable from FEmTool)
|
||||
---Purpose: Convert the assembly Vector in an Curve;
|
||||
--
|
||||
raises DomainError;
|
||||
|
||||
SetWeight(me: mutable;
|
||||
QuadraticWeight, QualityWeight : Real;
|
||||
percentJ1, percentJ2, percentJ3 : Real)
|
||||
is static;
|
||||
|
||||
GetWeight(me; QuadraticWeight, QualityWeight : out Real)
|
||||
is static;
|
||||
|
||||
SetWeight(me: mutable;
|
||||
Weight : Array1OfReal)
|
||||
is static;
|
||||
|
||||
BuildCache(me: mutable; E : Integer) is private;
|
||||
|
||||
fields
|
||||
mySSP : MultiLine from AppDef;
|
||||
myParameters : HArray1OfReal;
|
||||
myCache : HArray1OfReal;
|
||||
myCriteria : ElementaryCriterion from FEmTool[3];
|
||||
myEstimation: Real[3];
|
||||
myQuadraticWeight, myQualityWeight : Real;
|
||||
myPercent : Real[3];
|
||||
myPntWeight : Array1OfReal;
|
||||
myCurve : Curve from FEmTool;
|
||||
myLength : Real;
|
||||
myE : Integer;
|
||||
IF, IL : Integer;
|
||||
end LinearCriteria;
|
||||
|
||||
|
760
src/AppDef/AppDef_LinearCriteria.cxx
Normal file
760
src/AppDef/AppDef_LinearCriteria.cxx
Normal file
@@ -0,0 +1,760 @@
|
||||
// Created on: 1998-11-30
|
||||
// Created by: Igor FEOKTISTOV
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <AppDef_LinearCriteria.ixx>
|
||||
|
||||
#include <PLib_Base.hxx>
|
||||
#include <PLib_JacobiPolynomial.hxx>
|
||||
#include <PLib_HermitJacobi.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <TColStd_HArray2OfReal.hxx>
|
||||
#include <FEmTool_LinearTension.hxx>
|
||||
#include <FEmTool_LinearFlexion.hxx>
|
||||
#include <FEmTool_LinearJerk.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Gauss.hxx>
|
||||
#include <AppDef_MyLineTool.hxx>
|
||||
|
||||
static Standard_Integer order(const Handle(PLib_Base)& B)
|
||||
{
|
||||
return (*( Handle(PLib_HermitJacobi)*)&B)->NivConstr();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
AppDef_LinearCriteria::AppDef_LinearCriteria(const AppDef_MultiLine& SSP,
|
||||
const Standard_Integer FirstPoint,
|
||||
const Standard_Integer LastPoint):
|
||||
mySSP(SSP),
|
||||
myPntWeight(FirstPoint, LastPoint),
|
||||
myE(0)
|
||||
{
|
||||
myPntWeight.Init(1.);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AppDef_LinearCriteria::SetParameters(const Handle(TColStd_HArray1OfReal)& Parameters)
|
||||
{
|
||||
myParameters = Parameters;
|
||||
myE = 0; // Cache become invalid.
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AppDef_LinearCriteria::SetCurve(const Handle(FEmTool_Curve)& C)
|
||||
{
|
||||
|
||||
if(myCurve.IsNull()) {
|
||||
myCurve = C;
|
||||
|
||||
Standard_Integer MxDeg = myCurve->Base()->WorkDegree(),
|
||||
NbDim = myCurve->Dimension(),
|
||||
Order = order(myCurve->Base());
|
||||
|
||||
GeomAbs_Shape ConstraintOrder=GeomAbs_C0;
|
||||
switch (Order) {
|
||||
case 0 : ConstraintOrder = GeomAbs_C0;
|
||||
break;
|
||||
case 1 : ConstraintOrder = GeomAbs_C1;
|
||||
break;
|
||||
case 2 : ConstraintOrder = GeomAbs_C2;
|
||||
}
|
||||
|
||||
myCriteria[0] = new FEmTool_LinearTension(MxDeg, ConstraintOrder);
|
||||
myCriteria[1] = new FEmTool_LinearFlexion(MxDeg, ConstraintOrder);
|
||||
myCriteria[2] = new FEmTool_LinearJerk (MxDeg, ConstraintOrder);
|
||||
|
||||
Handle(TColStd_HArray2OfReal) Coeff = new TColStd_HArray2OfReal(0, 0, 1, NbDim);
|
||||
|
||||
myCriteria[0]->Set(Coeff);
|
||||
myCriteria[1]->Set(Coeff);
|
||||
myCriteria[2]->Set(Coeff);
|
||||
}
|
||||
else if (myCurve != C) {
|
||||
|
||||
Standard_Integer OldMxDeg = myCurve->Base()->WorkDegree(),
|
||||
OldNbDim = myCurve->Dimension(),
|
||||
OldOrder = order(myCurve->Base());
|
||||
|
||||
myCurve = C;
|
||||
|
||||
Standard_Integer MxDeg = myCurve->Base()->WorkDegree(),
|
||||
NbDim = myCurve->Dimension(),
|
||||
Order = order(myCurve->Base());
|
||||
|
||||
if(MxDeg != OldMxDeg || Order != OldOrder) {
|
||||
|
||||
GeomAbs_Shape ConstraintOrder=GeomAbs_C0;
|
||||
switch (Order) {
|
||||
case 0 : ConstraintOrder = GeomAbs_C0;
|
||||
break;
|
||||
case 1 : ConstraintOrder = GeomAbs_C1;
|
||||
break;
|
||||
case 2 : ConstraintOrder = GeomAbs_C2;
|
||||
}
|
||||
|
||||
myCriteria[0] = new FEmTool_LinearTension(MxDeg, ConstraintOrder);
|
||||
myCriteria[1] = new FEmTool_LinearFlexion(MxDeg, ConstraintOrder);
|
||||
myCriteria[2] = new FEmTool_LinearJerk (MxDeg, ConstraintOrder);
|
||||
|
||||
Handle(TColStd_HArray2OfReal) Coeff = new TColStd_HArray2OfReal(0, 0, 1, NbDim);
|
||||
|
||||
myCriteria[0]->Set(Coeff);
|
||||
myCriteria[1]->Set(Coeff);
|
||||
myCriteria[2]->Set(Coeff);
|
||||
}
|
||||
else if(NbDim != OldNbDim) {
|
||||
|
||||
Handle(TColStd_HArray2OfReal) Coeff = new TColStd_HArray2OfReal(0, 0, 1, NbDim);
|
||||
|
||||
myCriteria[0]->Set(Coeff);
|
||||
myCriteria[1]->Set(Coeff);
|
||||
myCriteria[2]->Set(Coeff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetCurve
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::GetCurve(Handle(FEmTool_Curve)& C) const
|
||||
{
|
||||
C = myCurve;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetEstimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::SetEstimation(const Standard_Real E1,
|
||||
const Standard_Real E2,
|
||||
const Standard_Real E3)
|
||||
{
|
||||
myEstimation[0] = E1;
|
||||
myEstimation[1] = E2;
|
||||
myEstimation[2] = E3;
|
||||
}
|
||||
|
||||
Standard_Real& AppDef_LinearCriteria::EstLength()
|
||||
{
|
||||
return myLength;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetEstimation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::GetEstimation(Standard_Real& E1,
|
||||
Standard_Real& E2,
|
||||
Standard_Real& E3) const
|
||||
{
|
||||
E1 = myEstimation[0];
|
||||
E2 = myEstimation[1];
|
||||
E3 = myEstimation[2];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AssemblyTable
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(FEmTool_HAssemblyTable) AppDef_LinearCriteria::AssemblyTable() const
|
||||
{
|
||||
if(myCurve.IsNull()) Standard_DomainError::Raise("AppDef_LinearCriteria::AssemblyTable");
|
||||
|
||||
Standard_Integer NbDim = myCurve->Dimension(),
|
||||
NbElm = myCurve->NbElements(),
|
||||
nc1 = order(myCurve->Base()) + 1;
|
||||
Standard_Integer MxDeg = myCurve->Base()->WorkDegree() ;
|
||||
|
||||
Handle(FEmTool_HAssemblyTable) AssTable = new FEmTool_HAssemblyTable(1, NbDim, 1, NbElm);
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GlobIndex, Aux;
|
||||
|
||||
Standard_Integer i, el = 1, dim = 1, NbGlobVar = 0, gi0;
|
||||
|
||||
// For dim = 1
|
||||
// For first element (el = 1)
|
||||
GlobIndex = new TColStd_HArray1OfInteger(0, MxDeg);
|
||||
|
||||
for(i = 0; i < nc1; i++) {
|
||||
NbGlobVar++;
|
||||
GlobIndex->SetValue(i, NbGlobVar);
|
||||
}
|
||||
gi0 = MxDeg - 2 * nc1 + 1;
|
||||
for(i = nc1; i < 2*nc1; i++) {
|
||||
NbGlobVar++;
|
||||
GlobIndex->SetValue(i, NbGlobVar + gi0);
|
||||
}
|
||||
for(i = 2*nc1; i <= MxDeg; i++) {
|
||||
NbGlobVar++;
|
||||
GlobIndex->SetValue(i, NbGlobVar - nc1);
|
||||
}
|
||||
gi0 = NbGlobVar - nc1 + 1;
|
||||
AssTable->SetValue(dim, el, GlobIndex);
|
||||
|
||||
// For rest elements
|
||||
for(el = 2; el <= NbElm; el++) {
|
||||
GlobIndex = new TColStd_HArray1OfInteger(0, MxDeg);
|
||||
for(i = 0; i < nc1; i++) GlobIndex->SetValue(i, gi0 + i);
|
||||
|
||||
gi0 = MxDeg - 2 * nc1 + 1;
|
||||
for(i = nc1; i < 2*nc1; i++) {
|
||||
NbGlobVar++;
|
||||
GlobIndex->SetValue(i, NbGlobVar + gi0);
|
||||
}
|
||||
for(i = 2*nc1; i <= MxDeg; i++) {
|
||||
NbGlobVar++;
|
||||
GlobIndex->SetValue(i, NbGlobVar - nc1);
|
||||
}
|
||||
gi0 = NbGlobVar - nc1 + 1;
|
||||
AssTable->SetValue(dim, el, GlobIndex);
|
||||
}
|
||||
|
||||
// For other dimensions
|
||||
gi0 = NbGlobVar;
|
||||
for(dim = 2; dim <= NbDim; dim++) {
|
||||
for(el = 1; el <= NbElm; el++) {
|
||||
Aux = AssTable->Value(1, el);
|
||||
GlobIndex = new TColStd_HArray1OfInteger(0, MxDeg);
|
||||
for(i = 0; i <= MxDeg; i++) GlobIndex->SetValue(i, Aux->Value(i) + NbGlobVar);
|
||||
AssTable->SetValue(dim, el, GlobIndex);
|
||||
}
|
||||
NbGlobVar += gi0;
|
||||
}
|
||||
|
||||
return AssTable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TColStd_HArray2OfInteger) AppDef_LinearCriteria::DependenceTable() const
|
||||
{
|
||||
if(myCurve.IsNull()) Standard_DomainError::Raise("AppDef_LinearCriteria::DependenceTable");
|
||||
|
||||
Standard_Integer Dim = myCurve->Dimension();
|
||||
|
||||
Handle(TColStd_HArray2OfInteger) DepTab =
|
||||
new TColStd_HArray2OfInteger(1, Dim, 1, Dim, 0);
|
||||
Standard_Integer i;
|
||||
for(i=1; i <= Dim; i++) DepTab->SetValue(i,i,1);
|
||||
|
||||
return DepTab;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : QualityValues
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer AppDef_LinearCriteria::QualityValues(const Standard_Real J1min,
|
||||
const Standard_Real J2min,
|
||||
const Standard_Real J3min,
|
||||
Standard_Real& J1,
|
||||
Standard_Real& J2,
|
||||
Standard_Real& J3)
|
||||
{
|
||||
if(myCurve.IsNull()) Standard_DomainError::Raise("AppDef_LinearCriteria::QualityValues");
|
||||
|
||||
Standard_Integer NbDim = myCurve->Dimension(),
|
||||
NbElm = myCurve->NbElements();
|
||||
|
||||
TColStd_Array1OfReal& Knots = myCurve->Knots();
|
||||
Handle(TColStd_HArray2OfReal) Coeff;
|
||||
|
||||
Standard_Integer el, deg = 0, curdeg, i;
|
||||
Standard_Real UFirst, ULast;
|
||||
|
||||
J1 = J2 = J3 = 0.;
|
||||
for(el = 1; el <= NbElm; el++) {
|
||||
|
||||
curdeg = myCurve->Degree(el);
|
||||
if(deg != curdeg) {
|
||||
deg = curdeg;
|
||||
Coeff = new TColStd_HArray2OfReal(0, deg, 1, NbDim);
|
||||
}
|
||||
|
||||
myCurve->GetElement(el, Coeff->ChangeArray2());
|
||||
|
||||
UFirst = Knots(el); ULast = Knots(el + 1);
|
||||
|
||||
myCriteria[0]->Set(Coeff);
|
||||
myCriteria[0]->Set(UFirst, ULast);
|
||||
J1 = J1 + myCriteria[0]->Value();
|
||||
|
||||
myCriteria[1]->Set(Coeff);
|
||||
myCriteria[1]->Set(UFirst, ULast);
|
||||
J2 = J2 + myCriteria[1]->Value();
|
||||
|
||||
myCriteria[2]->Set(Coeff);
|
||||
myCriteria[2]->Set(UFirst, ULast);
|
||||
J3 = J3 + myCriteria[2]->Value();
|
||||
|
||||
}
|
||||
|
||||
// Calculation of ICDANA - see MOTEST.f
|
||||
// Standard_Real JEsMin[3] = {.01, .001, .001}; // from MOTLIS.f
|
||||
Standard_Real JEsMin[3]; JEsMin[0] = J1min; JEsMin[1] = J2min; JEsMin[2] = J3min;
|
||||
Standard_Real ValCri[3]; ValCri[0] = J1; ValCri[1] = J2; ValCri[2] = J3;
|
||||
|
||||
Standard_Integer ICDANA = 0;
|
||||
|
||||
// (2) Test l'amelioration des estimations
|
||||
// (critere sureleve => Non minimisation )
|
||||
|
||||
for(i = 0; i <= 2; i++)
|
||||
if((ValCri[i] < 0.8 * myEstimation[i]) && (myEstimation[i] > JEsMin[i])) {
|
||||
if(ICDANA < 1) ICDANA = 1;
|
||||
if(ValCri[i] < 0.1 * myEstimation[i]) ICDANA = 2;
|
||||
myEstimation[i] = Max(1.05*ValCri[i], JEsMin[i]);
|
||||
}
|
||||
|
||||
|
||||
// (3) Mise a jours des Estimation
|
||||
// (critere sous-estimer => mauvais conditionement)
|
||||
|
||||
if (ValCri[0] > myEstimation[0] * 2) {
|
||||
myEstimation[0] += ValCri[0] * .1;
|
||||
if (ICDANA == 0) {
|
||||
if (ValCri[0] > myEstimation[0] * 10) {
|
||||
ICDANA = 2;
|
||||
}
|
||||
else ICDANA = 1;
|
||||
}
|
||||
else {
|
||||
ICDANA = 2;
|
||||
}
|
||||
}
|
||||
if (ValCri[1] > myEstimation[1] * 20) {
|
||||
myEstimation[1] += ValCri[1] * .1;
|
||||
if (ICDANA == 0) {
|
||||
if (ValCri[1] > myEstimation[1] * 100) {
|
||||
ICDANA = 2;
|
||||
}
|
||||
else ICDANA = 1;
|
||||
}
|
||||
else {
|
||||
ICDANA = 2;
|
||||
}
|
||||
}
|
||||
if (ValCri[2] > myEstimation[2] * 20) {
|
||||
myEstimation[2] += ValCri[2] * .05;
|
||||
if (ICDANA == 0) {
|
||||
if (ValCri[2] > myEstimation[2] * 100) {
|
||||
ICDANA = 2;
|
||||
}
|
||||
else ICDANA = 1;
|
||||
}
|
||||
else {
|
||||
ICDANA = 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ICDANA;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ErrorValues
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AppDef_LinearCriteria::ErrorValues(Standard_Real& MaxError,
|
||||
Standard_Real& QuadraticError,
|
||||
Standard_Real& AverageError)
|
||||
{
|
||||
if(myCurve.IsNull()) Standard_DomainError::Raise("AppDef_LinearCriteria::ErrorValues");
|
||||
|
||||
Standard_Integer NbDim = myCurve->Dimension();
|
||||
|
||||
Standard_Integer myNbP2d = AppDef_MyLineTool::NbP2d(mySSP), myNbP3d = AppDef_MyLineTool::NbP3d(mySSP);
|
||||
|
||||
if(NbDim != (2*myNbP2d + 3*myNbP3d)) Standard_DomainError::Raise("AppDef_LinearCriteria::ErrorValues");
|
||||
|
||||
TColgp_Array1OfPnt TabP3d(1, Max(1,myNbP3d));
|
||||
TColgp_Array1OfPnt2d TabP2d(1, Max(1,myNbP2d));
|
||||
TColStd_Array1OfReal BasePoint(1,NbDim);
|
||||
gp_Pnt2d P2d;
|
||||
gp_Pnt P3d;
|
||||
|
||||
Standard_Integer i, ipnt, c0 = 0;
|
||||
Standard_Real SqrDist, Dist;
|
||||
|
||||
MaxError = QuadraticError = AverageError = 0.;
|
||||
|
||||
for(i = myParameters->Lower(); i <= myParameters->Upper(); i++) {
|
||||
|
||||
myCurve->D0(myParameters->Value(i), BasePoint);
|
||||
|
||||
|
||||
c0 = 0;
|
||||
AppDef_MyLineTool::Value(mySSP, i, TabP3d);
|
||||
for(ipnt = 1; ipnt <= myNbP3d; ipnt++) {
|
||||
P3d.SetCoord(BasePoint(c0+1), BasePoint(c0+2), BasePoint(c0+3));
|
||||
SqrDist = P3d.SquareDistance(TabP3d(ipnt)); Dist = Sqrt(SqrDist);
|
||||
MaxError = Max(MaxError, Dist);
|
||||
QuadraticError += SqrDist;
|
||||
AverageError += Dist;
|
||||
c0 += 3;
|
||||
}
|
||||
|
||||
if(myNbP3d == 0) AppDef_MyLineTool::Value(mySSP, i, TabP2d);
|
||||
else AppDef_MyLineTool::Value(mySSP, i, TabP3d, TabP2d);
|
||||
for(ipnt = 1; ipnt <= myNbP2d; ipnt++) {
|
||||
P2d.SetCoord(BasePoint(c0+1), BasePoint(c0+2));
|
||||
SqrDist = P2d.SquareDistance(TabP2d(ipnt)); Dist = Sqrt(SqrDist);
|
||||
MaxError = Max(MaxError, Dist);
|
||||
QuadraticError += SqrDist;
|
||||
AverageError += Dist;
|
||||
c0 += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Hessian
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void AppDef_LinearCriteria::Hessian(const Standard_Integer Element,
|
||||
const Standard_Integer Dimension1,
|
||||
const Standard_Integer Dimension2,
|
||||
math_Matrix& H)
|
||||
{
|
||||
if(myCurve.IsNull()) Standard_DomainError::Raise("AppDef_LinearCriteria::Hessian");
|
||||
|
||||
if(DependenceTable()->Value(Dimension1, Dimension2) == 0)
|
||||
Standard_DomainError::Raise("AppDef_LinearCriteria::Hessian");
|
||||
|
||||
Standard_Integer //NbDim = myCurve->Dimension(),
|
||||
MxDeg = myCurve->Base()->WorkDegree(),
|
||||
// Deg = myCurve->Degree(Element),
|
||||
Order = order(myCurve->Base());
|
||||
|
||||
|
||||
math_Matrix AuxH(0, H.RowNumber()-1, 0, H.ColNumber()-1, 0.);
|
||||
|
||||
TColStd_Array1OfReal& Knots = myCurve->Knots();
|
||||
Standard_Real UFirst, ULast;
|
||||
|
||||
UFirst = Knots(Element); ULast = Knots(Element + 1);
|
||||
|
||||
Standard_Integer icrit;
|
||||
|
||||
// Quality criterion part of Hessian
|
||||
|
||||
H.Init(0);
|
||||
|
||||
for(icrit = 0; icrit <= 2; icrit++) {
|
||||
myCriteria[icrit]->Set(UFirst, ULast);
|
||||
myCriteria[icrit]->Hessian(Dimension1, Dimension2, AuxH);
|
||||
H += (myQualityWeight*myPercent[icrit]/myEstimation[icrit]) * AuxH;
|
||||
}
|
||||
|
||||
// Least square part of Hessian
|
||||
|
||||
AuxH.Init(0.);
|
||||
|
||||
Standard_Real coeff = (ULast - UFirst)/2., curcoeff, poid;
|
||||
Standard_Integer ipnt, ii, degH = 2 * Order+1;
|
||||
|
||||
|
||||
Handle(PLib_Base) myBase = myCurve->Base();
|
||||
Standard_Integer k1, k2, i, j, i0 = H.LowerRow(), j0 = H.LowerCol(), i1, j1,
|
||||
di = myPntWeight.Lower() - myParameters->Lower();
|
||||
|
||||
//BuilCache
|
||||
if (myE != Element) BuildCache(Element);
|
||||
|
||||
// Compute the least square Hessian
|
||||
for(ii=1, ipnt = IF; ipnt <= IL; ipnt++, ii+=(MxDeg+1)) {
|
||||
poid = myPntWeight(di + ipnt) * 2.;
|
||||
const Standard_Real * BV = &myCache->Value(ii);
|
||||
|
||||
// Hermite*Hermite part of matrix
|
||||
for(i = 0; i <= degH; i++) {
|
||||
k1 = (i <= Order)? i : i - Order - 1;
|
||||
curcoeff = Pow(coeff, k1) * poid * BV[i];
|
||||
|
||||
// Hermite*Hermite part of matrix
|
||||
for(j = i; j <= degH; j++) {
|
||||
k2 = (j <= Order)? j : j - Order - 1;
|
||||
AuxH(i, j) += curcoeff * Pow(coeff, k2) * BV[j];
|
||||
}
|
||||
// Hermite*Jacobi part of matrix
|
||||
for(j = degH + 1; j <= MxDeg; j++) {
|
||||
AuxH(i, j) += curcoeff * BV[j];
|
||||
}
|
||||
}
|
||||
|
||||
// Jacoby*Jacobi part of matrix
|
||||
for(i = degH+1; i <= MxDeg; i++) {
|
||||
curcoeff = BV[i] * poid;
|
||||
for(j = i; j <= MxDeg; j++) {
|
||||
AuxH(i, j) += curcoeff * BV[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i1 = i0;
|
||||
for(i = 0; i <= MxDeg; i++) {
|
||||
j1 = j0 + i;
|
||||
for(j = i; j <= MxDeg; j++) {
|
||||
H(i1, j1) += myQuadraticWeight * AuxH(i, j);
|
||||
H(j1, i1) = H(i1, j1);
|
||||
j1++;
|
||||
}
|
||||
i1++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Gradient
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::Gradient(const Standard_Integer Element,
|
||||
const Standard_Integer Dimension,
|
||||
math_Vector& G)
|
||||
{
|
||||
if(myCurve.IsNull())
|
||||
Standard_DomainError::Raise("AppDef_LinearCriteria::ErrorValues");
|
||||
|
||||
Standard_Integer myNbP2d = AppDef_MyLineTool::NbP2d(mySSP), myNbP3d = AppDef_MyLineTool::NbP3d(mySSP);
|
||||
|
||||
if(Dimension > (2*myNbP2d + 3*myNbP3d))
|
||||
Standard_DomainError::Raise("AppDef_LinearCriteria::ErrorValues");
|
||||
|
||||
TColgp_Array1OfPnt TabP3d(1, Max(1,myNbP3d));
|
||||
TColgp_Array1OfPnt2d TabP2d(1, Max(1,myNbP2d));
|
||||
|
||||
Standard_Boolean In3d;
|
||||
Standard_Integer IndPnt, IndCrd;
|
||||
|
||||
if(Dimension <= 3*myNbP3d) {
|
||||
In3d = Standard_True;
|
||||
IndCrd = Dimension % 3;
|
||||
IndPnt = Dimension / 3;
|
||||
if(IndCrd == 0) IndCrd = 3;
|
||||
else IndPnt++;
|
||||
}
|
||||
else {
|
||||
In3d = Standard_False;
|
||||
IndCrd = (Dimension - 3*myNbP3d) % 2;
|
||||
IndPnt = (Dimension - 3*myNbP3d) / 2;
|
||||
if(IndCrd == 0) IndCrd = 2;
|
||||
else IndPnt++;
|
||||
}
|
||||
|
||||
TColStd_Array1OfReal& Knots = myCurve->Knots();
|
||||
Standard_Real UFirst, ULast, Pnt;
|
||||
UFirst = Knots(Element); ULast = Knots(Element + 1);
|
||||
Standard_Real coeff = (ULast-UFirst)/2;
|
||||
|
||||
Standard_Integer //Deg = myCurve->Degree(Element),
|
||||
Order = order(myCurve->Base());
|
||||
|
||||
Handle(PLib_Base) myBase = myCurve->Base();
|
||||
Standard_Integer MxDeg = myBase->WorkDegree();
|
||||
|
||||
Standard_Real curcoeff;
|
||||
Standard_Integer degH = 2 * Order + 1;
|
||||
Standard_Integer ipnt, k, i, ii, i0 = G.Lower(),
|
||||
di = myPntWeight.Lower() - myParameters->Lower();
|
||||
|
||||
if (myE != Element) BuildCache(Element);
|
||||
const Standard_Real * BV = &myCache->Value(1);
|
||||
BV--;
|
||||
|
||||
G.Init(0.);
|
||||
|
||||
for(ii=1,ipnt = IF; ipnt <= IL; ipnt++) {
|
||||
if(In3d) {
|
||||
AppDef_MyLineTool::Value(mySSP, ipnt, TabP3d);
|
||||
Pnt = TabP3d(IndPnt).Coord(IndCrd);
|
||||
}
|
||||
else {
|
||||
if(myNbP3d == 0) AppDef_MyLineTool::Value(mySSP, ipnt, TabP2d);
|
||||
else AppDef_MyLineTool::Value(mySSP, ipnt, TabP3d, TabP2d);
|
||||
Pnt = TabP2d(IndPnt).Coord(IndCrd);
|
||||
}
|
||||
|
||||
curcoeff = Pnt * myPntWeight(di + ipnt);
|
||||
for(i = 0; i <= MxDeg; i++,ii++)
|
||||
G(i0 + i) += BV[ii] * curcoeff;
|
||||
}
|
||||
|
||||
|
||||
G *= 2. * myQuadraticWeight;
|
||||
|
||||
for(i = 0; i <= degH; i++) {
|
||||
k = (i <= Order)? i : i - Order - 1;
|
||||
curcoeff = Pow(coeff, k);
|
||||
G(i0 + i) *= curcoeff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : InputVector
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::InputVector(const math_Vector& X,
|
||||
const Handle(FEmTool_HAssemblyTable)& AssTable)
|
||||
{
|
||||
Standard_Integer NbDim = myCurve->Dimension(),
|
||||
NbElm = myCurve->NbElements() ;
|
||||
Standard_Integer MxDeg = 0 ;
|
||||
MxDeg = myCurve->Base()->WorkDegree();
|
||||
TColStd_Array2OfReal CoeffEl(0, MxDeg, 1, NbDim);
|
||||
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) GlobIndex;
|
||||
|
||||
Standard_Integer el, dim, i, i0 = X.Lower() - 1;
|
||||
|
||||
for(el = 1; el <= NbElm; el++) {
|
||||
for(dim = 1; dim <= NbDim; dim++) {
|
||||
GlobIndex = AssTable->Value(dim, el);
|
||||
for(i = 0; i <= MxDeg; i++) CoeffEl(i, dim) = X(i0 + GlobIndex->Value(i));
|
||||
}
|
||||
myCurve->SetDegree(el, MxDeg);
|
||||
myCurve->SetElement(el, CoeffEl);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWeight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::SetWeight(const Standard_Real QuadraticWeight,
|
||||
const Standard_Real QualityWeight,
|
||||
const Standard_Real percentJ1,
|
||||
const Standard_Real percentJ2,
|
||||
const Standard_Real percentJ3)
|
||||
{
|
||||
if (QuadraticWeight < 0. || QualityWeight < 0.)
|
||||
Standard_DomainError::Raise("AppDef_LinearCriteria::SetWeight");
|
||||
if (percentJ1 < 0. || percentJ2 < 0. || percentJ3 < 0.)
|
||||
Standard_DomainError::Raise("AppDef_LinearCriteria::SetWeight");
|
||||
|
||||
myQuadraticWeight = QuadraticWeight; myQualityWeight = QualityWeight;
|
||||
|
||||
Standard_Real Total = percentJ1 + percentJ2 + percentJ3;
|
||||
myPercent[0] = percentJ1 / Total;
|
||||
myPercent[1] = percentJ2 / Total;
|
||||
myPercent[2] = percentJ3 / Total;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetWeight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::GetWeight(Standard_Real& QuadraticWeight,
|
||||
Standard_Real& QualityWeight) const
|
||||
{
|
||||
|
||||
QuadraticWeight = myQuadraticWeight; QualityWeight = myQualityWeight;
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetWeight
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::SetWeight(const TColStd_Array1OfReal& Weight)
|
||||
{
|
||||
myPntWeight = Weight;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BuildCache
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void AppDef_LinearCriteria::BuildCache(const Standard_Integer Element)
|
||||
{
|
||||
Standard_Real t;
|
||||
Standard_Real UFirst, ULast;
|
||||
Standard_Integer ipnt;
|
||||
|
||||
UFirst = myCurve->Knots()(Element);
|
||||
ULast = myCurve->Knots()(Element + 1);
|
||||
|
||||
IF = 0;
|
||||
for(ipnt = myParameters->Lower(); ipnt <= myParameters->Upper(); ipnt++) {
|
||||
t = myParameters->Value(ipnt);
|
||||
if((t > UFirst && t <= ULast) || (Element == 1 && t == UFirst)) {
|
||||
if (IF == 0) IF=ipnt;
|
||||
IL = ipnt;
|
||||
}
|
||||
else if (t>ULast) break;
|
||||
}
|
||||
|
||||
if (IF != 0) {
|
||||
Handle(PLib_Base) myBase = myCurve->Base();
|
||||
Standard_Integer order = myBase->WorkDegree()+1, ii;
|
||||
myCache = new TColStd_HArray1OfReal (1, (IL-IF+1)*(order));
|
||||
|
||||
ii =1;
|
||||
for(ipnt = IF, ii=1; ipnt <= IL; ipnt++, ii+=order) {
|
||||
Standard_Real * cache = &myCache->ChangeValue(ii);
|
||||
TColStd_Array1OfReal BasicValue(cache[0], 0, order-1);
|
||||
t = myParameters->Value(ipnt);
|
||||
Standard_Real coeff = 2./(ULast - UFirst), c0 = -(ULast + UFirst)/2., s;
|
||||
s = (t + c0) * coeff;
|
||||
myBase->D0(s, BasicValue);
|
||||
}
|
||||
}
|
||||
else { //pas de points dans l'interval.
|
||||
IF = IL;
|
||||
IL--;
|
||||
}
|
||||
myE = Element;
|
||||
}
|
109
src/AppDef/AppDef_SmoothCriterion.cdl
Normal file
109
src/AppDef/AppDef_SmoothCriterion.cdl
Normal file
@@ -0,0 +1,109 @@
|
||||
-- Created on: 1997-09-11
|
||||
-- Created by: Philippe MANGIN
|
||||
-- Copyright (c) 1997-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
deferred class SmoothCriterion from AppDef
|
||||
inherits TShared from MMgt
|
||||
|
||||
---Purpose: defined criterion to smooth points in curve
|
||||
|
||||
|
||||
uses
|
||||
Vector from math,
|
||||
Matrix from math,
|
||||
Curve from FEmTool,
|
||||
HAssemblyTable from FEmTool,
|
||||
HArray2OfInteger from TColStd,
|
||||
HArray1OfReal from TColStd,
|
||||
Array1OfReal from TColStd
|
||||
|
||||
raises
|
||||
NotImplemented,
|
||||
DomainError
|
||||
|
||||
|
||||
|
||||
is
|
||||
SetParameters(me : mutable; Parameters : HArray1OfReal)
|
||||
is deferred;
|
||||
|
||||
SetCurve(me : mutable; C :Curve from FEmTool)
|
||||
is deferred;
|
||||
|
||||
GetCurve(me; C : out Curve from FEmTool)
|
||||
is deferred;
|
||||
|
||||
SetEstimation(me : mutable; E1, E2, E3 : Real)
|
||||
is deferred;
|
||||
|
||||
EstLength(me : mutable)
|
||||
---C++: return &
|
||||
returns Real is deferred;
|
||||
|
||||
GetEstimation(me; E1, E2, E3 : out Real)
|
||||
is deferred;
|
||||
|
||||
AssemblyTable(me)
|
||||
returns HAssemblyTable from FEmTool
|
||||
is deferred;
|
||||
|
||||
DependenceTable(me)
|
||||
returns HArray2OfInteger from TColStd
|
||||
is deferred;
|
||||
|
||||
QualityValues (me : mutable; J1min, J2min, J3min : Real;
|
||||
J1, J2, J3 : out Real)
|
||||
returns Integer is deferred;
|
||||
|
||||
ErrorValues(me : mutable;
|
||||
MaxError, QuadraticError, AverageError : out Real)
|
||||
is deferred;
|
||||
|
||||
Hessian(me : mutable ;
|
||||
Element : Integer;
|
||||
Dimension1 : Integer;
|
||||
Dimension2 : Integer;
|
||||
H : out Matrix from math)
|
||||
raises DomainError -- If DependenceTable(Dimension1,Dimension2) is False
|
||||
is deferred;
|
||||
|
||||
|
||||
Gradient(me : mutable;
|
||||
Element : Integer;
|
||||
Dimension : Integer;
|
||||
G : out Vector from math)
|
||||
is deferred;
|
||||
|
||||
InputVector(me : mutable; X : Vector from math;
|
||||
AssTable : HAssemblyTable from FEmTool)
|
||||
---Purpose: Convert the assembly Vector in an Curve;
|
||||
--
|
||||
raises DomainError is deferred;
|
||||
|
||||
SetWeight(me: mutable;
|
||||
QuadraticWeight, QualityWeight : Real;
|
||||
percentJ1, percentJ2, percentJ3 : Real)
|
||||
is deferred;
|
||||
|
||||
GetWeight(me; QuadraticWeight, QualityWeight : out Real)
|
||||
is deferred;
|
||||
|
||||
SetWeight(me: mutable;
|
||||
Weight : Array1OfReal)
|
||||
is deferred;
|
||||
|
||||
end SmoothCriterion;
|
||||
|
||||
|
17
src/AppDef/AppDef_SmoothCriterion.cxx
Normal file
17
src/AppDef/AppDef_SmoothCriterion.cxx
Normal file
@@ -0,0 +1,17 @@
|
||||
// Created on: 1998-11-30
|
||||
// Created by: Igor FEOKTISTOV
|
||||
// Copyright (c) 1998-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or modify it under
|
||||
// the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
// by the Free Software Foundation, with special exception defined in the file
|
||||
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
// distribution for complete text of the license and disclaimer of any warranty.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <AppDef_SmoothCriterion.ixx>
|
440
src/AppDef/AppDef_Variational.cdl
Normal file
440
src/AppDef/AppDef_Variational.cdl
Normal file
@@ -0,0 +1,440 @@
|
||||
-- Created on: 1996-05-14
|
||||
-- Created by: Philippe MANGIN / Jeannine PANCIATICI
|
||||
-- Copyright (c) 1996-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2014 OPEN CASCADE SAS
|
||||
--
|
||||
-- This file is part of Open CASCADE Technology software library.
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the GNU Lesser General Public License version 2.1 as published
|
||||
-- by the Free Software Foundation, with special exception defined in the file
|
||||
-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
|
||||
-- distribution for complete text of the license and disclaimer of any warranty.
|
||||
--
|
||||
-- Alternatively, this file may be used under the terms of Open CASCADE
|
||||
-- commercial license or contractual agreement.
|
||||
|
||||
-- Igor FEOKTISTOV - correction 14/12/98
|
||||
|
||||
|
||||
class Variational from AppDef
|
||||
|
||||
|
||||
---Purpose: This class is used to smooth N points with constraints
|
||||
-- by minimization of quadratic criterium but also
|
||||
-- variational criterium in order to obtain " fair Curve "
|
||||
--
|
||||
|
||||
uses Matrix from math,
|
||||
Vector from math,
|
||||
HArray1OfReal from TColStd,
|
||||
Array1OfReal from TColStd,
|
||||
HArray1OfInteger from TColStd,
|
||||
Shape from GeomAbs,
|
||||
HArray1OfConstraintCouple from AppParCurves,
|
||||
MultiBSpCurve from AppParCurves,
|
||||
SmoothCriterion from AppDef,
|
||||
Curve from FEmTool,
|
||||
Assembly from FEmTool,
|
||||
Base from PLib,
|
||||
Constraint from AppParCurves,
|
||||
MultiLine from AppDef,
|
||||
MyLineTool from AppDef
|
||||
|
||||
raises OutOfRange from Standard,
|
||||
DimensionError from Standard,
|
||||
DomainError from Standard,
|
||||
ConstructionError from Standard,
|
||||
NotDone from StdFail,
|
||||
VectorWithNullMagnitude from gp
|
||||
|
||||
|
||||
is
|
||||
Create(SSP: MultiLine from AppDef;
|
||||
FirstPoint, LastPoint: Integer;
|
||||
TheConstraints: HArray1OfConstraintCouple;
|
||||
MaxDegree: Integer = 14;
|
||||
MaxSegment: Integer = 100;
|
||||
Continuity : Shape from GeomAbs = GeomAbs_C2;
|
||||
WithMinMax : Boolean = Standard_False;
|
||||
WithCutting: Boolean = Standard_True;
|
||||
Tolerance : Real = 1.0;
|
||||
NbIterations: Integer = 2)
|
||||
---Purpose: Constructor.
|
||||
-- Initialization of the fields.
|
||||
-- warning : Nc0 : number of PassagePoint consraints
|
||||
-- Nc2 : number of TangencyPoint constraints
|
||||
-- Nc3 : number of CurvaturePoint constraints
|
||||
-- if
|
||||
-- ((MaxDegree-Continuity)*MaxSegment -Nc0 - 2*Nc1
|
||||
-- -3*Nc2)
|
||||
-- is negative
|
||||
-- The problem is over-constrained.
|
||||
--
|
||||
-- Limitation : The MultiLine from AppDef has to be composed by
|
||||
-- only one Line ( Dimension 2 or 3).
|
||||
|
||||
returns Variational from AppDef;
|
||||
|
||||
|
||||
Approximate(me : in out)
|
||||
---Purpose: Makes the approximation with the current fields.
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
|
||||
-- ==================== The Selectors ===========================
|
||||
|
||||
IsCreated(me)
|
||||
---Purpose: returns True if the creation is done
|
||||
-- and correspond to the current fields.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: returns True if the approximation is ok
|
||||
-- and correspond to the current fields.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
IsOverConstrained(me)
|
||||
---Purpose: returns True if the problem is overconstrained
|
||||
-- in this case, approximation cannot be done.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Value(me)
|
||||
---Purpose: returns all the BSpline curves approximating the
|
||||
-- MultiLine from AppDef SSP after minimization of the parameter.
|
||||
|
||||
returns MultiBSpCurve from AppParCurves
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
MaxError(me)
|
||||
---Purpose: returns the maximum of the distances between
|
||||
-- the points of the multiline and the approximation
|
||||
-- curves.
|
||||
returns Real
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
MaxErrorIndex(me)
|
||||
---Purpose: returns the index of the MultiPoint of ErrorMax
|
||||
returns Integer
|
||||
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
|
||||
QuadraticError(me)
|
||||
---Purpose: returns the quadratic average of the distances between
|
||||
-- the points of the multiline and the approximation
|
||||
-- curves.
|
||||
returns Real
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Distance(me : in out ; mat : out Matrix from math)
|
||||
---Purpose: returns the distances between the points of the
|
||||
-- multiline and the approximation curves.
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
AverageError(me)
|
||||
---Purpose: returns the average error between
|
||||
-- the MultiLine from AppDef and the approximation.
|
||||
|
||||
returns Real
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Parameters(me)
|
||||
---Purpose: returns the parameters uses to the approximations
|
||||
---C++: return const&
|
||||
|
||||
returns HArray1OfReal
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Knots(me)
|
||||
---Purpose: returns the knots uses to the approximations
|
||||
---C++: return const&
|
||||
returns HArray1OfReal
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
Criterium(me; VFirstOrder,
|
||||
VSecondOrder,
|
||||
VThirdOrder : out Real)
|
||||
---Purpose: returns the values of the quality criterium.
|
||||
raises NotDone from StdFail
|
||||
is static;
|
||||
|
||||
CriteriumWeight(me ;
|
||||
Percent1, Percent2, Percent3 : out Real)
|
||||
---Purpose: returns the Weights (as percent) associed to the criterium used in
|
||||
-- the optimization.
|
||||
is static;
|
||||
|
||||
MaxDegree(me)
|
||||
---Purpose: returns the Maximum Degree used in the approximation
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
MaxSegment(me)
|
||||
---Purpose: returns the Maximum of segment used in the approximation
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
Continuity(me)
|
||||
---Purpose: returns the Continuity used in the approximation
|
||||
returns Shape from GeomAbs
|
||||
is static;
|
||||
|
||||
|
||||
WithMinMax(me)
|
||||
---Purpose: returns if the approximation search to minimize the
|
||||
-- maximum Error or not.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
WithCutting(me)
|
||||
---Purpose: returns if the approximation can insert new Knots or not.
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Tolerance(me)
|
||||
---Purpose: returns the tolerance used in the approximation.
|
||||
returns Real
|
||||
is static;
|
||||
|
||||
NbIterations(me)
|
||||
---Purpose: returns the number of iterations used in the approximation.
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
Dump(me ; o : in out OStream)
|
||||
---Purpose: Prints on the stream o information on the current state
|
||||
-- of the object.
|
||||
-- MaxError,MaxErrorIndex,AverageError,QuadraticError,Criterium
|
||||
-- Distances,Degre,Nombre de poles, parametres, noeuds
|
||||
is static;
|
||||
|
||||
SetConstraints(me:in out; aConstrainst:HArray1OfConstraintCouple)
|
||||
---Purpose: Define the constraints to approximate
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
SetParameters(me:in out; param : HArray1OfReal)
|
||||
---Purpose: Defines the parameters used by the approximations.
|
||||
raises DimensionError
|
||||
is static;
|
||||
|
||||
SetKnots(me:in out; knots : HArray1OfReal)
|
||||
---Purpose: Defines the knots used by the approximations
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
raises DimensionError,
|
||||
DomainError
|
||||
is static;
|
||||
|
||||
SetMaxDegree(me: in out; Degree : Integer)
|
||||
---Purpose: Define the Maximum Degree used in the approximation
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
SetMaxSegment(me: in out; NbSegment : Integer)
|
||||
---Purpose: Define the maximum number of segments used in the approximation
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
SetContinuity(me: in out; C : Shape from GeomAbs)
|
||||
---Purpose: Define the Continuity used in the approximation
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
raises ConstructionError from Standard
|
||||
is static;
|
||||
|
||||
|
||||
SetWithMinMax(me: in out; MinMax : Boolean)
|
||||
---Purpose: Define if the approximation search to minimize the
|
||||
-- maximum Error or not.
|
||||
is static;
|
||||
|
||||
SetWithCutting(me : in out; Cutting : Boolean )
|
||||
---Purpose: Define if the approximation can insert new Knots or not.
|
||||
-- If this value is incompatible with the others fields
|
||||
-- this method modify nothing and returns false
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
SetCriteriumWeight(me : in out;
|
||||
Percent1, Percent2, Percent3 : Real)
|
||||
---Purpose: define the Weights (as percent) associed to the criterium used in
|
||||
-- the optimization.
|
||||
--
|
||||
raises DomainError -- if Percent <= 0
|
||||
is static;
|
||||
|
||||
SetCriteriumWeight(me : in out;
|
||||
Order : Integer;
|
||||
Percent : Real)
|
||||
---Purpose: define the Weight (as percent) associed to the
|
||||
-- criterium Order used in the optimization : Others
|
||||
-- weights are updated.
|
||||
raises DomainError, -- if Percent < 0
|
||||
OutOfRange -- if Order < 1 or Order > 3
|
||||
is static;
|
||||
|
||||
SetTolerance(me:in out; Tol : Real)
|
||||
---Purpose: define the tolerance used in the approximation.
|
||||
is static;
|
||||
|
||||
SetNbIterations(me:in out; Iter : Integer)
|
||||
---Purpose: define the number of iterations used in the approximation.
|
||||
raises DomainError -- if Iter < 1
|
||||
is static;
|
||||
|
||||
|
||||
-- ====================== The Private methods ======================
|
||||
|
||||
TheMotor(me : in out;
|
||||
J : in out SmoothCriterion from AppDef;
|
||||
WQuadratic, WQuality : Real;
|
||||
TheCurve : in out Curve from FEmTool;
|
||||
Ecarts : out Array1OfReal from TColStd) is private;
|
||||
|
||||
Adjusting(me : in out;
|
||||
J : in out SmoothCriterion from AppDef;
|
||||
WQuadratic, WQuality : in out Real;
|
||||
TheCurve : in out Curve from FEmTool;
|
||||
Ecarts : out Array1OfReal from TColStd) is private;
|
||||
|
||||
Optimization(me;
|
||||
J : in out SmoothCriterion from AppDef;
|
||||
A : in out Assembly from FEmTool;
|
||||
ToAssemble : in Boolean;
|
||||
EpsDeg : Real;
|
||||
Curve : out Curve from FEmTool;
|
||||
Parameters : Array1OfReal from TColStd) is private;
|
||||
|
||||
Project(me; C : Curve from FEmTool;
|
||||
Ti : Array1OfReal from TColStd;
|
||||
ProjTi : out Array1OfReal from TColStd;
|
||||
Distance : out Array1OfReal from TColStd;
|
||||
NumPoints : out Integer;
|
||||
MaxErr, QuaErr, AveErr : out Real;
|
||||
NbIterations: Integer=2) is private;
|
||||
|
||||
ACR(me; Curve : in out Curve from FEmTool;
|
||||
Ti : in out Array1OfReal from TColStd;
|
||||
Decima: Integer) is private;
|
||||
|
||||
SplitCurve(me; InCurve : Curve from FEmTool;
|
||||
Ti : Array1OfReal from TColStd;
|
||||
CurveTol: Real;
|
||||
OutCurve: out Curve from FEmTool;
|
||||
iscut : out Boolean) is private;
|
||||
|
||||
Init(me : in out)
|
||||
raises NotDone from StdFail,
|
||||
ConstructionError from Standard,
|
||||
DimensionError from Standard
|
||||
is private;
|
||||
|
||||
InitSmoothCriterion(me : in out)
|
||||
is private;
|
||||
|
||||
InitParameters(me : in out; Length : out Real)
|
||||
raises ConstructionError from Standard
|
||||
is private;
|
||||
|
||||
InitCriterionEstimations(me; Length : Real; J1, J2, J3 : out Real)
|
||||
is private;
|
||||
|
||||
EstTangent(me; ipnt : Integer; VTang : out Vector from math)
|
||||
is private;
|
||||
|
||||
EstSecnd(me; ipnt : Integer; VTang1, VTang2 : Vector from math;
|
||||
Length : Real; VScnd : out Vector from math)
|
||||
is private;
|
||||
|
||||
InitCutting(me; aBase : Base from PLib; CurvTol : Real;
|
||||
aCurve : out Curve from FEmTool)
|
||||
raises ConstructionError from Standard
|
||||
is private;
|
||||
|
||||
AssemblingConstraints(me; Curve : Curve from FEmTool;
|
||||
Parameters : Array1OfReal from TColStd;
|
||||
CBLONG : Real from Standard;
|
||||
A : out Assembly from FEmTool)
|
||||
is private;
|
||||
|
||||
InitTthetaF(me : in out; ndimen : Integer from Standard;
|
||||
typcon : Constraint from AppParCurves;
|
||||
begin : Integer from Standard;
|
||||
jndex : Integer from Standard)
|
||||
returns Boolean
|
||||
is private;
|
||||
|
||||
|
||||
fields
|
||||
-- Description of the points to smooth and the constraints
|
||||
mySSP : MultiLine from AppDef;
|
||||
myNbP3d : Integer;
|
||||
myNbP2d : Integer;
|
||||
myDimension : Integer;
|
||||
myFirstPoint : Integer;
|
||||
myLastPoint : Integer;
|
||||
myNbPoints : Integer;
|
||||
myTabPoints : HArray1OfReal;
|
||||
myConstraints : HArray1OfConstraintCouple;
|
||||
myNbConstraints : Integer;
|
||||
myTabConstraints : HArray1OfReal;
|
||||
myNbPassPoints : Integer;
|
||||
myNbTangPoints : Integer;
|
||||
myNbCurvPoints : Integer;
|
||||
myTypConstraints : HArray1OfInteger;
|
||||
myTtheta : HArray1OfReal;
|
||||
myTfthet : HArray1OfReal;
|
||||
|
||||
-- Context parameters
|
||||
myMaxDegree : Integer;
|
||||
myMaxSegment : Integer;
|
||||
myNbIterations: Integer;
|
||||
myTolerance : Real;
|
||||
|
||||
-- Options
|
||||
myContinuity : Shape from GeomAbs;
|
||||
myNivCont : Integer;
|
||||
myWithMinMax : Boolean;
|
||||
myWithCutting: Boolean;
|
||||
myPercent : Real[3];
|
||||
myCriterium : Real[4];
|
||||
mySmoothCriterion : SmoothCriterion from AppDef;
|
||||
|
||||
-- output
|
||||
myParameters : HArray1OfReal;
|
||||
myKnots : HArray1OfReal;
|
||||
myMBSpCurve : MultiBSpCurve;
|
||||
|
||||
myMaxError : Real;
|
||||
myMaxErrorIndex: Integer;
|
||||
myAverageError : Real;
|
||||
myIsCreated : Boolean;
|
||||
myIsDone : Boolean;
|
||||
myIsOverConstr : Boolean;
|
||||
|
||||
end Variational;
|
3040
src/AppDef/AppDef_Variational.cxx
Normal file
3040
src/AppDef/AppDef_Variational.cxx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user