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

Integration of OCCT 6.5.0 from SVN

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

80
src/LProp/LProp.cdl Executable file
View File

@@ -0,0 +1,80 @@
-- File: LProp.cdl
-- Created: Wed Mar 27 16:40:20 1991
-- Author: Michel CHAUVAT
-- <mca@topsn3>
---Copyright: Matra Datavision 1991, 1992
package LProp
---Purpose: Handles local properties of curves and surfaces.
-- Given a curve and a parameter value the following computations
-- are available :
-- - point,
-- - derivatives,
-- - tangent,
-- - normal,
-- - curvature,
-- - centre of curvature,
-- - Locals curvature's extremas,
-- - Points of inflection,
-- Given a surface and 2 parameters the following computations
-- are available :
-- - for each parameter:
-- - derivatives,
-- - tangent line,
-- - centre of curvature,
-- - point,
-- - normal line,
-- - maximum and minimum curvatures,
-- - principal directions of curvature,
-- - mean curvature,
-- - Gaussian curvature.
---Level : Public.
-- All methods of all classes will be public.
uses Standard, gp, math, TCollection, TColStd, GeomAbs
is
enumeration Status is Undecided , Undefined, Defined, Computed;
enumeration CIType is Inflection, MinCur , MaxCur;
---Purpose:
-- Identifies the type of a particular point on a curve:
-- - LProp_Inflection: a point of inflection
-- - LProp_MinCur: a minimum of curvature
-- - LProp_MaxCur: a maximum of curvature.
exception BadContinuity inherits Failure;
exception NotDefined inherits Failure;
deferred generic class CurveTool;
---Purpose: The template class used in CLProps.
deferred generic class SurfaceTool;
---Purpose: The template class used in SLProps.
generic class CLProps;
---Purpose: Computation of local properties of a curve.
generic class SLProps;
---Purpose: Computation of local properties of a surface.
class CurAndInf;
---Purpose: Stores the parameters of a curve 2d or 3d corresponding
-- to the curvature's extremas and the inflection's points.
class AnalyticCurInf;
---Purpose: Computes the locals extremas of curvature of a gp curve.
private generic class FuncCurExt;
private generic class FuncCurNul;
generic class NumericCurInf, FCurExt, FCurNul;
---Purpose: Computes the locals extremas of curvature and the
-- inflections of a bounded curve in 2d.
private class SequenceOfCIType instantiates Sequence from TCollection
(CIType from LProp);
end LProp;

View File

@@ -0,0 +1,26 @@
-- File: LProp_AnalyticCurInf.cdl
-- Created: Fri Sep 2 15:39:59 1994
-- Author: Yves FRICAUD
-- <yfr@phylox>
---Copyright: Matra Datavision 1994
class AnalyticCurInf from LProp
---Purpose: Computes the locals extremas of curvature of a gp curve
-- Remark : a gp curve has not inflection.
uses
CurveType from GeomAbs,
CurAndInf from LProp
is
Create;
Perform (me : in out;
T : CurveType from GeomAbs ;
UFirst : Real from Standard ;
ULast : Real from Standard ;
Result : in out CurAndInf from LProp)
is static;
end AnalyticCurInf;

View File

@@ -0,0 +1,70 @@
// File: LProp_AnalyticCurInf.cxx
// Created: Mon Sep 5 10:31:35 1994
// Author: Yves FRICAUD
// <yfr@ecolox>
#include <LProp_AnalyticCurInf.ixx>
#include <ElCLib.hxx>
//=======================================================================
//function : LProp_AnalyticCurInf
//purpose :
//=======================================================================
LProp_AnalyticCurInf::LProp_AnalyticCurInf()
{
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void LProp_AnalyticCurInf::Perform (const GeomAbs_CurveType CType,
const Standard_Real UFirst,
const Standard_Real ULast,
LProp_CurAndInf& Result)
{
Standard_Boolean IsMin = Standard_True;
Standard_Boolean IsMax = Standard_False;
switch (CType) {
case GeomAbs_Ellipse:
{
Standard_Real U1,U2,U3,U4;
Standard_Real UFPlus2PI = UFirst + 2*PI;
U1 = ElCLib::InPeriod(0.0 ,UFirst,UFPlus2PI);
U2 = ElCLib::InPeriod(PI/2. ,UFirst,UFPlus2PI);
U3 = ElCLib::InPeriod(PI ,UFirst,UFPlus2PI);
U4 = ElCLib::InPeriod(3.*PI/2.,UFirst,UFPlus2PI);
if (UFirst <= U1 && U1 <= ULast) {Result.AddExtCur(U1, IsMin);}
if (UFirst <= U2 && U2 <= ULast) {Result.AddExtCur(U2, IsMax);}
if (UFirst <= U3 && U3 <= ULast) {Result.AddExtCur(U3, IsMin);}
if (UFirst <= U4 && U4 <= ULast) {Result.AddExtCur(U4, IsMax);}
}
break;
case GeomAbs_Hyperbola:
if (UFirst <= 0.0 && ULast >= 0.0) {
Result.AddExtCur(0.0 , Standard_True);
}
break;
case GeomAbs_Parabola:
if (UFirst <= 0.0 && ULast >= 0.0) {
Result.AddExtCur(0.0 , Standard_True);
}
break;
#ifndef DEB
default:
break;
#endif
}
}

148
src/LProp/LProp_CLProps.cdl Executable file
View File

@@ -0,0 +1,148 @@
-- File: CLProps.cdl
-- Created: Mon Mar 25 16:30:42 1991
-- Author: Michel CHAUVAT
-- <mca@topsn3>
---Copyright: Matra Datavision 1991, 1992
generic class CLProps from LProp
(Curve as any;
Vec as any; -- as Vec or Vec2d
Pnt as any; -- as Pnt or Pnt2d
Dir as any; -- as Dir or Dir2d
Tool as any) -- as ToolCurve(Curve, Pnt, Vec)
---Purpose: Computation of Curve Local Properties:
-- - point,
-- - derivatives,
-- - tangent,
-- - normal plane,
-- - curvature,
-- - normal,
-- - centre of curvature,
uses Status from LProp
raises BadContinuity from LProp,
DomainError from Standard,
OutOfRange from Standard,
NotDefined from LProp
is
Create(C: Curve; N: Integer; Resolution: Real)
---Purpose: Initializes the local properties of the curve <C>
-- The current point and the derivatives are
-- computed at the same time, which allows an
-- optimization of the computation time.
-- <N> indicates the maximum number of derivations to
-- be done (0, 1, 2 or 3). For example, to compute
-- only the tangent, N should be equal to 1.
-- <Resolution> is the linear tolerance (it is used to test
-- if a vector is null).
returns CLProps
raises OutOfRange;
-- if N < 0 or N > 3.
Create(C: Curve; U : Real; N: Integer; Resolution: Real)
--- Purpose : Same as previous constructor but here the parameter is
-- set to the value <U>.
-- All the computations done will be related to <C> and <U>.
returns CLProps
raises OutOfRange;
-- if N < 0 or N > 3.
Create(N : Integer;Resolution:Real)
--- Purpose : Same as previous constructor but here the parameter is
-- set to the value <U> and the curve is set
-- with SetCurve.
-- the curve can have a empty constructor
-- All the computations done will be related to <C> and <U>
-- when the functions "set" will be done.
returns CLProps
raises OutOfRange;
SetParameter(me: in out; U : Real)
---Purpose: Initializes the local properties of the curve
-- for the parameter value <U>.
is static;
SetCurve(me: in out; C : Curve)
---Purpose: Initializes the local properties of the curve
-- for the new curve.
is static;
Value(me) returns Pnt is static;
---Purpose: Returns the Point.
---C++: return const &
D1(me: in out) returns Vec is static;
---Purpose: Returns the first derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
D2(me: in out) returns Vec is static;
---Purpose: Returns the second derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
D3(me: in out) returns Vec is static;
---Purpose: Returns the third derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
IsTangentDefined(me: in out) returns Boolean is static;
---Purpose: Returns True if the tangent is defined.
-- For example, the tangent is not defined if the
-- three first derivatives are all null.
Tangent(me: in out; D : out Dir)
---Purpose: output the tangent direction <D>
raises NotDefined
-- if IsTangentDefined(me)=False.
is static;
Curvature(me: in out)
---Purpose: Returns the curvature.
returns Real
raises NotDefined
-- if IsTangentDefined(me) == False.
is static;
Normal(me: in out; N : out Dir)
---Purpose: Returns the normal direction <N>.
raises NotDefined
-- if Curvature(me) < Resolution
is static;
CentreOfCurvature(me: in out; P : out Pnt)
---Purpose: Returns the centre of curvature <P>.
raises NotDefined
-- if Curvature(me) < Resolution
is static;
fields
myCurve : Curve; -- the Curve on which thw calculus are done
u : Real; -- the current value of the parameter
level : Integer; -- the order of derivation
cn : Real; -- the order of continuity of the Curve
linTol : Real; -- the tolerance for null Vector
pnt : Pnt; -- the current point value
d : Vec[3]; -- the current first, second and third derivative
-- value
tangent : Dir; -- the tangent value
curvature : Real; -- the curvature value
tangentStatus : Status from LProp;
-- the status of the tangent direction
significantFirstDerivativeOrder : Integer;
-- the order of the first non null derivative
--
end CLProps;

216
src/LProp/LProp_CLProps.gxx Executable file
View File

@@ -0,0 +1,216 @@
#include <LProp_Status.hxx>
#include <LProp_NotDefined.hxx>
#include <Standard_OutOfRange.hxx>
LProp_CLProps::LProp_CLProps (const Curve& C,
const Standard_Real U,
const Standard_Integer N,
const Standard_Real Resolution)
: myCurve(C),
level(N),
cn(4), // cn(Tool::Continuity(C)), RLE
linTol(Resolution),
tangentStatus (LProp_Undecided)
{
Standard_OutOfRange_Raise_if (N < 0 || N > 3,
"LProp_CLProps::LProp_CLProps()");
SetParameter(U);
}
LProp_CLProps::LProp_CLProps (const Curve& C,
const Standard_Integer N,
const Standard_Real Resolution)
: myCurve(C),
u(RealLast()),
level(N),
cn(4), // (Tool::Continuity(C)), RLE
linTol(Resolution),
tangentStatus (LProp_Undecided)
{
Standard_OutOfRange_Raise_if (N < 0 || N > 3, "");
}
LProp_CLProps::LProp_CLProps (const Standard_Integer N,
const Standard_Real Resolution)
: u(RealLast()),
level(N),
cn(0),
linTol(Resolution),
tangentStatus (LProp_Undecided)
{
Standard_OutOfRange_Raise_if (N < 0 || N > 3, "");
}
void LProp_CLProps::SetParameter(const Standard_Real U)
{
u = U;
switch (level) {
case 0:
Tool::Value(myCurve, u, pnt);
break;
case 1:
Tool::D1(myCurve, u, pnt, d[0]);
break;
case 2:
Tool::D2(myCurve, u, pnt, d[0], d[1]);
break;
case 3:
Tool::D3(myCurve, u, pnt, d[0], d[1], d[2]);
break;
}
tangentStatus = LProp_Undecided;
}
void LProp_CLProps::SetCurve(const Curve& C) {
myCurve = C ;
cn = 4; // Tool::Continuity(C); RLE
}
const Pnt& LProp_CLProps::Value () const
{
return pnt;
}
const Vec& LProp_CLProps::D1 ()
{
if (level < 1) {
level = 1;
Tool::D1(myCurve, u, pnt, d[0]);
}
return d[0];
}
const Vec& LProp_CLProps::D2 ()
{
if (level < 2) {
level = 2;
Tool::D2(myCurve, u, pnt, d[0], d[1]);
}
return d[1];
}
const Vec& LProp_CLProps::D3 ()
{
if (level < 3) {
level = 3;
Tool::D3(myCurve, u, pnt, d[0], d[1], d[2]);
}
return d[2];
}
Standard_Boolean LProp_CLProps::IsTangentDefined ()
{
if (tangentStatus == LProp_Undefined) {
return Standard_False;
}
else if (tangentStatus >= LProp_Defined) {
return Standard_True;
}
// tangentStatus == Lprop_Undecided
// we have to calculate the first non null derivative
Standard_Real Tol = linTol * linTol;
Vec V;
Standard_Integer Order = 0;
while (Order < 4) {
Order++;
if(cn >= Order) {
switch(Order) {
case 1 :
V = D1();
break;
case 2 :
V = D2();
break;
case 3 :
V = D3();
break;
};
if(V.SquareMagnitude() > Tol) {
significantFirstDerivativeOrder = Order;
tangentStatus = LProp_Defined;
return Standard_True;
}
}
else {
tangentStatus = LProp_Undefined;
return Standard_False;
}
}
return Standard_False;
}
void LProp_CLProps::Tangent (Dir& D)
{
if(!IsTangentDefined()) { LProp_NotDefined::Raise(); }
D = Dir(d[significantFirstDerivativeOrder - 1]);
}
Standard_Real LProp_CLProps::Curvature ()
{
Standard_Boolean isDefined = IsTangentDefined();
LProp_NotDefined_Raise_if(!isDefined,
"LProp_CLProps::CurvatureNotDefined()");
// if the first derivative is null the curvature is infinite.
if(significantFirstDerivativeOrder > 1) return RealLast();
Standard_Real Tol = linTol * linTol;
Standard_Real DD1 = d[0].SquareMagnitude();
Standard_Real DD2 = d[1].SquareMagnitude();
// if the second derivative is null the curvature is null.
if (DD2 <= Tol) {
curvature = 0.0;
}
else {
Standard_Real N = d[0].CrossSquareMagnitude(d[1]);
// if d[0] and d[1] are colinear the curvature is null.
Standard_Real t = N/(DD1*DD2);
if (t<=Tol) {
curvature = 0.0;
}
else {
curvature = sqrt(N) / (DD1*sqrt(DD1));
}
}
return curvature;
}
void LProp_CLProps::Normal (Dir& D)
{
Standard_Real c = Curvature();
if(c==RealLast() || Abs(c) <= linTol) { LProp_NotDefined::Raise(); }
// we used here the following vector relation
// a ^ (b ^ c) = b(ac) - c(ab)
// Norm = d[0] ^ (d[1] ^ d[0])
Vec Norm = d[1] * (d[0] * d[0]) - d[0] * (d[0] * d[1]);
D = Dir(Norm);
}
void LProp_CLProps::CentreOfCurvature (Pnt& P)
{
if(Abs(Curvature()) <= linTol) { LProp_NotDefined::Raise(); }
// we used here the following vector relation
// a ^ (b ^ c) = b(ac) - c(ab)
// Norm = d[0] ^ (d[1] ^ d[0])
Vec Norm = d[1] * (d[0] * d[0]) - d[0] * (d[0] * d[1]);
Norm.Normalize();
Norm.Divide(curvature);
P= pnt.Translated(Norm);
}

66
src/LProp/LProp_CurAndInf.cdl Executable file
View File

@@ -0,0 +1,66 @@
-- File: LProp_CurAndInf.cdl
-- Created: Fri Sep 2 11:27:40 1994
-- Author: Yves FRICAUD
-- <yfr@phylox>
---Copyright: Matra Datavision 1994
class CurAndInf from LProp
---Purpose: Stores the parameters of a curve 2d or 3d corresponding
-- to the curvature's extremas and the Inflection's Points.
uses
CIType from LProp,
SequenceOfReal from TColStd,
SequenceOfCIType from LProp
raises
OutOfRange from Standard
is
Create;
AddInflection (me : in out; Param : Real)
is static;
AddExtCur (me : in out; Param : Real; IsMin : Boolean)
is static;
Clear (me : in out)
is static;
IsEmpty (me) returns Boolean
is static;
NbPoints (me) returns Integer
---Purpose: Returns the number of points.
-- The Points are stored to increasing parameter.
is static;
Parameter (me; N : Integer) returns Real
---Purpose: Returns the parameter of the Nth point.
raises
OutOfRange from Standard
---Purpose: raises if N not in the range [1,NbPoints()]
is static;
Type (me; N : Integer) returns CIType
---Purpose: Returns
-- - MinCur if the Nth parameter corresponds to
-- a minimum of the radius of curvature.
-- - MaxCur if the Nth parameter corresponds to
-- a maximum of the radius of curvature.
-- - Inflection if the parameter corresponds to
-- a point of inflection.
raises
OutOfRange from Standard
---Purpose: raises if N not in the range [1,NbPoints()]
is static;
fields
theParams : SequenceOfReal from TColStd;
theTypes : SequenceOfCIType from LProp;
end CurAndInf;

136
src/LProp/LProp_CurAndInf.cxx Executable file
View File

@@ -0,0 +1,136 @@
// File: LProp_CurAndInf.cxx
// Created: Mon Sep 5 10:43:19 1994
// Author: Yves FRICAUD
// <yfr@ecolox>
#include <LProp_CurAndInf.ixx>
#include <Standard_OutOfRange.hxx>
#include <ElCLib.hxx>
//=======================================================================
//function : LProp_CurAndInf
//purpose :
//=======================================================================
LProp_CurAndInf::LProp_CurAndInf()
{
}
//=======================================================================
//function : AddInflection
//purpose :
//=======================================================================
void LProp_CurAndInf::AddInflection(const Standard_Real Param)
{
if (theParams.IsEmpty()) {
theParams.Append(Param);
theTypes .Append(LProp_Inflection);
return;
}
if (Param > theParams.Last()) {
theParams.Append(Param);
theTypes .Append(LProp_Inflection);
return;
}
for (Standard_Integer i = 1; i <= theParams.Length(); i++) {
if (theParams.Value(i) > Param) {
theParams.InsertBefore(i, Param);
theTypes .InsertBefore(i, LProp_Inflection);
break;
}
}
}
//=======================================================================
//function : AddExtCur
//purpose :
//=======================================================================
void LProp_CurAndInf::AddExtCur(const Standard_Real Param,
const Standard_Boolean IsMin)
{
LProp_CIType TypePoint;
if (IsMin ) TypePoint = LProp_MinCur; else TypePoint = LProp_MaxCur;
if (theParams.IsEmpty()) {
theParams.Append(Param);
theTypes .Append(TypePoint);
return;
}
if (Param > theParams.Last()) {
theParams.Append(Param);
theTypes .Append(TypePoint);
return;
}
for (Standard_Integer i = 1; i <= theParams.Length(); i++) {
if (theParams.Value(i) > Param) {
theParams.InsertBefore(i, Param);
theTypes .InsertBefore(i, TypePoint);
break;
}
}
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void LProp_CurAndInf::Clear()
{
theParams.Clear();
theTypes .Clear();
}
//=======================================================================
//function : IsEmpty
//purpose :
//=======================================================================
Standard_Boolean LProp_CurAndInf::IsEmpty() const
{
return theParams.IsEmpty();
}
//=======================================================================
//function : NbPoints
//purpose :
//=======================================================================
Standard_Integer LProp_CurAndInf::NbPoints() const
{
return theParams.Length();
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real LProp_CurAndInf::Parameter(const Standard_Integer N) const
{
if (N <1 || N > NbPoints ()) {Standard_OutOfRange::Raise();}
return theParams.Value(N);
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
LProp_CIType LProp_CurAndInf::Type(const Standard_Integer N) const
{
if (N <1 || N > NbPoints()) {Standard_OutOfRange::Raise();}
return theTypes.Value(N);
}

46
src/LProp/LProp_CurveTool.cdl Executable file
View File

@@ -0,0 +1,46 @@
-- File: CurveTool.cdl
-- Created: Tue Mar 3 18:07:18 1992
-- Author: Herve LEGRAND
-- <hl@topsn3>
---Copyright: Matra Datavision 1992
deferred generic class CurveTool from LProp (Curve as any;
Pnt as any;
Vec as any)
is
Value(myclass; C : Curve; U : Real; P : out Pnt);
---Purpose: Computes the point <P> of parameter <U> on the curve <C>.
D1 (myclass; C : Curve; U : Real; P : out Pnt; V1 : out Vec);
---Purpose: Computes the point <P> and first derivative <V1> of
-- parameter <U> on the curve <C>.
D2 (myclass; C : Curve; U : Real; P : out Pnt; V1, V2 : out Vec);
---Purpose: Computes the point <P>, the first derivative <V1> and second
-- derivative <V2> of parameter <U> on the curve <C>.
D3 (myclass; C : Curve; U : Real;
P : out Pnt; V1, V2, V3 : out Vec);
---Purpose: Computes the point <P>, the first derivative <V1>, the
-- second derivative <V2> and third derivative <V3> of
-- parameter <U> on the curve <C>.
Continuity(myclass; C : Curve) returns Integer;
---Purpose: returns the order of continuity of the curve <C>.
-- returns 1 : first derivative only is computable
-- returns 2 : first and second derivative only are computable.
-- returns 3 : first, second and third are computable.
FirstParameter(myclass; C : Curve) returns Real;
---Purpose: returns the first parameter bound of the curve.
--
LastParameter(myclass; C : Curve) returns Real;
---Purpose: returns the last parameter bound of the curve.
-- FirstParameter must be less than LastParamenter.
end CurveTool;

0
src/LProp/LProp_CurveTool.gxx Executable file
View File

42
src/LProp/LProp_FuncCurExt.cdl Executable file
View File

@@ -0,0 +1,42 @@
-- File: LProp_FuncCurExt.cdl
-- Created: Fri Sep 2 16:32:55 1994
-- Author: Yves FRICAUD
-- <yfr@phylox>
---Copyright: Matra Datavision 1994
private generic class FuncCurExt from LProp (Curve as any;
Vec as any; -- as Vec or Vec2d
Pnt as any; -- as Pnt or Pnt2d
Dir as any; -- as Dir or Dir2d Vec
Tool as any) -- as Tool(Curve, Pnt, Vec)
inherits FunctionWithDerivative from math
---Purpose: Function used to find the extremas of curvature in 2d.
is
Create ( C : Curve ; Tol : Real) returns FuncCurExt from LProp;
Value (me : in out; X : Real; F : out Real)
---Purpose: Returns the value for the variable <X>.
returns Boolean;
Derivative (me : in out; X : Real; D : out Real)
---Purpose: Returns the derivative for the variable <X>.
returns Boolean;
Values (me : in out ; X : Real; F : out Real; D : out Real)
---Purpose: Returns the value of the function and the derivative
-- for the variable <X>.
returns Boolean;
IsMinKC (me ; Param : Real)
---Purpose: True if Param corresponds to a minus
-- of the radius of curvature.
returns Boolean;
fields
theCurve : Curve;
epsX : Real from Standard;
end FuncCurExt;

116
src/LProp/LProp_FuncCurExt.gxx Executable file
View File

@@ -0,0 +1,116 @@
// File: LProp_FuncCurExt.gxx
// Created: Tue Sep 6 08:36:29 1994
// Author: Yves FRICAUD
// <yfr@ecolox>
#include <gp.hxx>
#include <Precision.hxx>
//=============================================================================
//function :
// purpose :
//=============================================================================
LProp_FuncCurExt::LProp_FuncCurExt(const Curve& C,
const Standard_Real Tol)
:theCurve(C)
{
epsX = Tol;
}
//=============================================================================
//function : Value
// purpose : KC = (V1^V2.Z) / ||V1||^3 avec V1 tangente etV2 derivee seconde.
// F = d KC/ dU.
//=============================================================================
Standard_Boolean LProp_FuncCurExt::Value (const Standard_Real X,
Standard_Real& F)
{
Pnt P1;
Vec V1,V2,V3;
Tool::D3(theCurve,X,P1,V1,V2,V3);
Standard_Real CPV1V2 = V1.Crossed(V2);
Standard_Real CPV1V3 = V1.Crossed(V3);
Standard_Real V1V2 = V1.Dot(V2);
Standard_Real V1V1 = V1.SquareMagnitude();
Standard_Real NV1 = Sqrt(V1V1);
Standard_Real V13 = V1V1*NV1;
Standard_Real V15 = V13*V1V1;
if (V15 < gp::Resolution()) {
return Standard_False;
}
F = CPV1V3/V13 - 3*CPV1V2*V1V2/V15;
return Standard_True;
}
//=============================================================================
//function : Derivative
// purpose :
//=============================================================================
Standard_Boolean LProp_FuncCurExt::Derivative(const Standard_Real X,
Standard_Real& D)
{
Standard_Real F;
return Values (X,F,D) ;
}
//=============================================================================
//function : Values
// purpose :
//=============================================================================
Standard_Boolean LProp_FuncCurExt::Values (const Standard_Real X,
Standard_Real& F,
Standard_Real& D)
{
Standard_Real F2;
Standard_Real Dx= epsX/100.;
if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;}
Value (X,F);
Value (X+Dx,F2);
D = (F2 - F)/Dx;
return Standard_True;
}
//=============================================================================
//function : IsMinKC
// purpose : Teste si le parametere coorespond a un minimum du rayon de courbure
// par comparaison avec un point voisin.
//=============================================================================
Standard_Boolean LProp_FuncCurExt::IsMinKC (const Standard_Real X) const
{
Pnt P1;
Vec V1,V2,V3;
Standard_Real Dx= epsX;
Standard_Real KC,KP;
Tool::D3(theCurve,X,P1,V1,V2,V3);
Standard_Real CPV1V2 = V1.Crossed(V2);
Standard_Real V1V1 = V1.SquareMagnitude();
Standard_Real NV1 = Sqrt(V1V1);
Standard_Real V13 = V1V1*NV1;
if (V13 < gp::Resolution()) {return Standard_False;}
KC = CPV1V2/V13;
if (X+Dx > Tool::LastParameter(theCurve)) {Dx = - Dx;}
Tool::D3(theCurve,X+Dx,P1,V1,V2,V3);
CPV1V2 = V1.Crossed(V2);
V1V1 = V1.SquareMagnitude();
NV1 = Sqrt(V1V1);
V13 = V1V1*NV1;
if (V13 < gp::Resolution()) { return Standard_False;}
KP = CPV1V2/V13;
if (Abs(KC) > Abs(KP)) {return Standard_True ;}
else {return Standard_False;}
}

36
src/LProp/LProp_FuncCurNul.cdl Executable file
View File

@@ -0,0 +1,36 @@
-- File: LProp_FuncCurNul.cdl
-- Created: Fri Sep 2 16:32:55 1994
-- Author: Yves FRICAUD
-- <yfr@phylox>
---Copyright: Matra Datavision 1994
private generic class FuncCurNul from LProp (Curve as any;
Vec as any; -- as Vec or Vec2d
Pnt as any; -- as Pnt or Pnt2d
Dir as any; -- as Dir or Dir2d Vec
Tool as any) -- as Tool(Curve, Pnt, Vec)
inherits FunctionWithDerivative from math
---Purpose: Function used to find the inflections in 2d.
is
Create ( C : Curve) returns FuncCurNul from LProp;
Value (me : in out; X : Real; F : out Real)
---Purpose: Returns the value for the variable <X>.
returns Boolean;
Derivative(me : in out; X : Real; D : out Real)
---Purpose: Returns the derivative for the variable <X>
returns Boolean;
Values(me : in out ; X : Real; F : out Real; D : out Real)
---Purpose: Returns the value of the function and the derivative
-- for the variable <X>.
returns Boolean;
fields
theCurve : Curve;
end FuncCurNul;

79
src/LProp/LProp_FuncCurNul.gxx Executable file
View File

@@ -0,0 +1,79 @@
// File: LProp_FuncCurNul.gxx
// Created: Mon Sep 5 14:53:57 1994
// Author: Yves FRICAUD
// <yfr@ecolox>
#include <gp.hxx>
#include <Precision.hxx>
//=============================================================================
//function :
// purpose :
//=============================================================================
LProp_FuncCurNul::LProp_FuncCurNul(const Curve& C)
:theCurve(C)
{
}
//=============================================================================
//function : Value
// purpose : F = (V1^V2.Z)/||V1||*||V2||
//=============================================================================
Standard_Boolean LProp_FuncCurNul::Value (const Standard_Real X,
Standard_Real& F)
{
Standard_Real D;
return Values(X,F,D);
}
//=============================================================================
//function : Derivative
// purpose :
//=============================================================================
Standard_Boolean LProp_FuncCurNul::Derivative(const Standard_Real X,
Standard_Real& D)
{
Standard_Real F;
return Values(X,F,D);
}
//=============================================================================
//function : Values
// purpose : F = (V1^V2.Z)/||V1||*||V2||
//=============================================================================
Standard_Boolean LProp_FuncCurNul::Values (const Standard_Real X,
Standard_Real& F,
Standard_Real& D)
{
Pnt P1;
Vec V1,V2,V3;
Tool::D3(theCurve,X,P1,V1,V2,V3);
Standard_Real CP1 = V1.Crossed(V2);
Standard_Real CP2 = V1.Crossed(V3);
Standard_Real V1V2 = V1.Dot(V2);
Standard_Real V2V3 = V2.Dot(V3);
Standard_Real NV1 = V1.Magnitude();
Standard_Real NV2 = V2.Magnitude();
F = 0. ;
D = 0. ;
/*
if (Abs(CP1) < 1.e-4) {
return Standard_True;
} else */
if (NV2 < 1.e-4) {
return Standard_True;
} else if (NV1*NV2 < gp::Resolution()) {
return Standard_False;
} else {
F = CP1/(NV1*NV2);
D = (CP2 - CP1*V1V2/(NV1*NV1) - CP1*V2V3/(NV2*NV2))/(NV1*NV2);
}
return Standard_True;
}

View File

@@ -0,0 +1,59 @@
-- File: LProp_NumericCurInf.cdl
-- Created: Fri Sep 2 15:56:00 1994
-- Author: Yves FRICAUD
-- <yfr@phylox>
---Copyright: Matra Datavision 1994
generic class NumericCurInf from LProp (Curve as any;
Vec as any; -- as Vec or Vec2d
Pnt as any; -- as Pnt or Pnt2d
Dir as any; -- as Dir or Dir2d Vec
Tool as any) -- as Tool(Curve, Pnt, Vec)
---Purpose: Computes the locals extremas of curvature and the
-- inflections of a bounded curve in 2d.
uses
CurAndInf from LProp
private class FCurExt instantiates FuncCurExt from LProp (Curve,Vec,Pnt,Dir,Tool);
private class FCurNul instantiates FuncCurNul from LProp (Curve,Vec,Pnt,Dir,Tool);
is
Create;
PerformCurExt (me : in out; C : Curve; Result : in out CurAndInf)
---Purpose: Computes the locals extremas of curvature.
is static;
PerformInf (me : in out; C : Curve; Result : in out CurAndInf)
---Purpose: Computes the inflections.
is static;
PerformCurExt (me : in out;
C : Curve ;
UMin : Real;
UMax : Real;
Result : in out CurAndInf)
---Purpose: Computes the locals extremas of curvature.
-- in the interval of parmeters [UMin,UMax].
is static;
PerformInf (me : in out;
C : Curve ;
UMin : Real;
UMax : Real;
Result : in out CurAndInf)
---Purpose: Computes the inflections in the interval of
-- parmeters [UMin,UMax].
is static;
IsDone (me) returns Boolean
---Purpose: True if the solutions are found.
is static;
fields
isDone : Boolean from Standard;
end NumericCurInf;

111
src/LProp/LProp_NumericCurInf.gxx Executable file
View File

@@ -0,0 +1,111 @@
// File: LProp_NumericCurInf.gxx
// Created: Mon Sep 5 18:01:59 1994
// Author: Yves FRICAUD
// <yfr@ecolox>
#include <math_FunctionRoots.hxx>
#include <math_BracketedRoot.hxx>
#include <Precision.hxx>
//=======================================================================
//function :
//purpose :
//=======================================================================
LProp_NumericCurInf::LProp_NumericCurInf()
{
}
//=======================================================================
//function : PerformCurExt
//purpose :
//=======================================================================
void LProp_NumericCurInf::PerformCurExt (const Curve& C,LProp_CurAndInf& Result)
{
PerformCurExt(C,Tool::FirstParameter(C),Tool::LastParameter(C),Result);
}
//=======================================================================
//function : PerformCurExt
//purpose :
//=======================================================================
void LProp_NumericCurInf::PerformCurExt (const Curve& C,
const Standard_Real UMin,
const Standard_Real UMax,
LProp_CurAndInf& Result)
{
isDone = Standard_True;
Standard_Real EpsH = 1.e-4*(UMax - UMin);
Standard_Real Tol = Precision::PConfusion();
// la premiere recherce se fait avec une tolerance assez grande
// car la derivee de la fonction est estimee assez grossierement.
LProp_FCurExt F(C,EpsH);
Standard_Integer NbSamples = 100;
Standard_Boolean SolType;
math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsH,EpsH,EpsH);
if (SolRoot.IsDone()) {
for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
Standard_Real Param = SolRoot.Value(j);
// la solution est affinee.
math_BracketedRoot BS (F,
Param - EpsH,
Param + EpsH,
Tol);
if (BS.IsDone()) {Param = BS.Root();}
SolType = F.IsMinKC(Param);
Result.AddExtCur(Param,SolType);
}
}
else {
isDone = Standard_False;
}
}
//=======================================================================
//function : PerformInf
//purpose :
//=======================================================================
void LProp_NumericCurInf::PerformInf(const Curve& C,LProp_CurAndInf& Result)
{
PerformInf(C,Tool::FirstParameter(C),Tool::LastParameter(C),Result);
}
//=======================================================================
//function : PerformInf
//purpose :
//=======================================================================
void LProp_NumericCurInf::PerformInf(const Curve& C,
const Standard_Real UMin,
const Standard_Real UMax,
LProp_CurAndInf& Result)
{
isDone = Standard_True;
LProp_FCurNul F(C);
Standard_Real EpsX = 1.e-6;
Standard_Real EpsF = 1.e-6;
Standard_Integer NbSamples = 30;
math_FunctionRoots SolRoot (F,UMin,UMax,NbSamples,EpsX,EpsF,EpsX);
if (SolRoot.IsDone()) {
for (Standard_Integer j = 1; j <= SolRoot.NbSolutions(); j++) {
Result.AddInflection(SolRoot.Value(j));
}
}
else {
isDone = Standard_False;
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean LProp_NumericCurInf::IsDone() const
{
return isDone;
}

216
src/LProp/LProp_SLProps.cdl Executable file
View File

@@ -0,0 +1,216 @@
-- File: SLProps.cdl
-- Created: Tue Mar 26 09:37:49 1991
-- Author: Michel CHAUVAT
-- <mca@topsn3>
---Copyright: Matra Datavision 1991, 1992
generic class SLProps from LProp (Surface as any;
Tool as any) -- as ToolSurface(Surface)
---Purpose: Computation of Surface Local Properties:
-- - point,
-- - derivatives,
-- - tangents,
-- - normal,
-- - tangent plane,
-- - principal curvatures and their associated direction,
-- - mean curvature,
-- - Gaussian curvature.
uses Dir from gp,
Pnt from gp,
Vec from gp,
Status from LProp
raises BadContinuity, DomainError, OutOfRange, NotDefined
is
Create(S: Surface; U, V: Real; N: Integer; Resolution: Real)
---Purpose: Initializes the local properties of the surface <S>
-- for the parameter values (<U>, <V>).
-- The current point and the derivatives are
-- computed at the same time, which allows an
-- optimization of the computation time.
-- <N> indicates the maximum number of derivations to
-- be done (0, 1, or 2). For example, to compute
-- only the tangent, N should be equal to 1.
-- <Resolution> is the linear tolerance (it is used to test
-- if a vector is null).
returns SLProps
raises OutOfRange;
-- if N < 0 or N > 2.
Create(S: Surface; N: Integer; Resolution: Real)
---Purpose: idem as previous constructor but without setting the value
-- of parameters <U> and <V>.
returns SLProps
raises OutOfRange;
-- if N < 0 or N > 2.
Create( N: Integer; Resolution: Real)
---Purpose: idem as previous constructor but without setting the value
-- of parameters <U> and <V> and the surface.
-- the surface can have an empty constructor.
returns SLProps
raises OutOfRange;
-- if N < 0 or N > 2.
SetSurface(me : in out;S : Surface)
---Purpose: Initializes the local properties of the surface S
-- for the new surface.
is static;
SetParameters(me: in out; U, V : Real)
---Purpose: Initializes the local properties of the surface S
-- for the new parameter values (<U>, <V>).
is static;
Value(me) returns Pnt
---Purpose: Returns the point.
---C++: return const &
is static;
D1U(me: in out) returns Vec is static;
---Purpose: Returns the first U derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
D1V(me: in out) returns Vec is static;
---Purpose: Returns the first V derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
D2U(me: in out) returns Vec is static;
---Purpose: Returns the second U derivatives
-- The derivative is computed if it has not been yet.
---C++: return const &
D2V(me: in out) returns Vec is static;
---Purpose: Returns the second V derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
DUV(me: in out) returns Vec is static;
---Purpose: Returns the second UV cross-derivative.
-- The derivative is computed if it has not been yet.
---C++: return const &
IsTangentUDefined(me: in out) returns Boolean is static;
---Purpose: returns True if the U tangent is defined.
-- For example, the tangent is not defined if the
-- two first U derivatives are null.
TangentU(me: in out; D : out Dir)
---Purpose: Returns the tangent direction <D> on the iso-V.
raises NotDefined
-- if IsTangentUDefined() == False.
is static;
IsTangentVDefined(me: in out) returns Boolean is static;
---Purpose: returns if the V tangent is defined.
-- For example, the tangent is not defined if the
-- two first V derivatives are null.
TangentV(me: in out; D : out Dir)
---Purpose: Returns the tangent direction <D> on the iso-V.
raises NotDefined
-- if IsTangentVDefined() == False.
is static;
IsNormalDefined(me: in out) returns Boolean is static;
---Purpose: Tells if the normal is defined.
Normal(me: in out) returns Dir
---Purpose: Returns the normal direction.
---C++: return const &
raises NotDefined
-- if IsNormalDefined() == False
is static;
IsCurvatureDefined(me: in out)
---Purpose: returns True if the curvature is defined.
returns Boolean
raises BadContinuity
-- if the surface is not C2.
is static;
IsUmbilic(me: in out)
---Purpose: returns True if the point is umbilic (i.e. if the
-- curvature is constant).
returns Boolean
raises NotDefined
-- if IsCurvatureDefined() == False
is static;
MaxCurvature(me : in out)
---Purpose: Returns the maximum curvature
returns Real
raises NotDefined
-- if IsCurvatureDefined() == False.
is static;
MinCurvature(me : in out)
---Purpose: Returns the minimum curvature
returns Real
raises NotDefined
-- if IsCurvatureDefined() == False.
is static;
CurvatureDirections(me: in out; MaxD, MinD : out Dir)
---Purpose: Returns the direction of the maximum and minimum curvature
-- <MaxD> and <MinD>
raises NotDefined
-- if IsCurvatureDefined() == False
-- or IsUmbilic() == True.
is static;
MeanCurvature(me: in out)
---Purpose: Returns the mean curvature.
returns Real
raises NotDefined
-- if IsCurvatureDefined() == False.
is static;
GaussianCurvature(me: in out)
---Purpose: Returns the Gaussian curvature
returns Real
raises NotDefined
-- if IsCurvatureDefined() == False.
is static;
fields
surf : Surface;
u : Real;
v : Real;
level : Integer;
cn : Integer;
linTol : Real;
pnt : Pnt from gp;
d1U : Vec from gp;
d1V : Vec from gp;
d2U : Vec from gp;
d2V : Vec from gp;
dUV : Vec from gp;
normal : Dir from gp;
minCurv : Real;
maxCurv : Real;
dirMinCurv : Dir from gp;
dirMaxCurv : Dir from gp;
meanCurv : Real;
gausCurv : Real;
significantFirstUDerivativeOrder : Integer;
significantFirstVDerivativeOrder : Integer;
uTangentStatus : Status from LProp;
vTangentStatus : Status from LProp;
normalStatus : Status from LProp;
curvatureStatus : Status from LProp;
end SLProps;

463
src/LProp/LProp_SLProps.gxx Executable file
View File

@@ -0,0 +1,463 @@
#include <LProp_Status.hxx>
#include <LProp_NotDefined.hxx>
#include <Standard_OutOfRange.hxx>
#include <Standard_DomainError.hxx>
#include <CSLib.hxx>
#include <CSLib_DerivativeStatus.hxx>
#include <CSLib_NormalStatus.hxx>
#include <TColgp_Array2OfVec.hxx>
#include <math_DirectPolynomialRoots.hxx>
static Standard_Boolean IsTangentDefined (LProp_SLProps& SProp,
const Standard_Integer cn,
const Standard_Real linTol,
const Standard_Integer Derivative,
Standard_Integer& Order,
LProp_Status& Status)
{
Standard_Real Tol = linTol * linTol;
gp_Vec V[2];
Order = 0;
while (Order < 3) {
Order++;
if(cn >= Order) {
switch(Order) {
case 1 :
V[0] = SProp.D1U();
V[1] = SProp.D1V();
break;
case 2 :
V[0] = SProp.D2U();
V[1] = SProp.D2V();
break;
};
if(V[Derivative].SquareMagnitude() > Tol) {
Status = LProp_Defined;
return Standard_True;
}
}
else {
Status = LProp_Undefined;
return Standard_False;
}
}
return Standard_False;
}
LProp_SLProps::LProp_SLProps (const Surface& S,
const Standard_Real U,
const Standard_Real V,
const Standard_Integer N,
const Standard_Real Resolution)
: surf(S),
level(N),
cn(4), // (Tool::Continuity(S)),
linTol(Resolution)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2,
"LProp_SLProps::LProp_SLProps()");
SetParameters(U, V);
}
LProp_SLProps::LProp_SLProps (const Surface& S,
const Standard_Integer N,
const Standard_Real Resolution)
: surf(S),
u(RealLast()), v(RealLast()),
level(N),
cn(4), // (Tool::Continuity(S)),
linTol(Resolution),
uTangentStatus (LProp_Undecided),
vTangentStatus (LProp_Undecided),
normalStatus (LProp_Undecided),
curvatureStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2,
"LProp_SLProps::LProp_SLProps()");
}
LProp_SLProps::LProp_SLProps (const Standard_Integer N,
const Standard_Real Resolution)
:u(RealLast()), v(RealLast()),
level(N),
cn(0),
linTol(Resolution),
uTangentStatus (LProp_Undecided),
vTangentStatus (LProp_Undecided),
normalStatus (LProp_Undecided),
curvatureStatus(LProp_Undecided)
{
Standard_OutOfRange_Raise_if(N < 0 || N > 2,
"LProp_SLProps::LProp_SLProps() bad level");
}
void LProp_SLProps::SetSurface (const Surface& S ) {
surf = S;
cn = 4; // =Tool::Continuity(S);
}
void LProp_SLProps::SetParameters (const Standard_Real U, const Standard_Real V)
{
u = U;
v = V;
switch (level) {
case 0:
Tool::Value(surf, u, v, pnt);
break;
case 1:
Tool::D1(surf, u, v, pnt, d1U, d1V);
break;
case 2:
Tool::D2(surf, u, v, pnt, d1U, d1V, d2U, d2V, dUV);
break;
};
uTangentStatus = LProp_Undecided;
vTangentStatus = LProp_Undecided;
normalStatus = LProp_Undecided;
curvatureStatus = LProp_Undecided;
}
const gp_Pnt& LProp_SLProps::Value() const
{
return pnt;
}
const gp_Vec& LProp_SLProps::D1U()
{
if (level < 1) {
level =1;
Tool::D1(surf,u,v,pnt,d1U,d1V);
}
return d1U;
}
const gp_Vec& LProp_SLProps::D1V()
{
if (level < 1) {
level =1;
Tool::D1(surf,u,v,pnt,d1U,d1V);
}
return d1V;
}
const gp_Vec& LProp_SLProps::D2U()
{
if (level < 2) {
level =2;
Tool::D2(surf,u,v,pnt,d1U,d1V,d2U,d2V,dUV);
}
return d2U;
}
const gp_Vec& LProp_SLProps::D2V()
{
if (level < 2) {
level =2;
Tool::D2(surf,u,v,pnt,d1U,d1V,d2U,d2V,dUV);
}
return d2V;
}
const gp_Vec& LProp_SLProps::DUV()
{
if (level < 2) {
level =2;
Tool::D2(surf,u,v,pnt,d1U,d1V,d2U,d2V,dUV);
}
return dUV;
}
Standard_Boolean LProp_SLProps::IsTangentUDefined ()
{
if (uTangentStatus == LProp_Undefined) {
return Standard_False;
}
else if (uTangentStatus >= LProp_Defined) {
return Standard_True;
}
// uTangentStatus == Lprop_Undecided
// we have to calculate the first non null U derivative
return IsTangentDefined(*this, cn, linTol, 0,
significantFirstUDerivativeOrder, uTangentStatus);
}
void LProp_SLProps::TangentU (gp_Dir& D) {
if(!IsTangentUDefined()) { LProp_NotDefined::Raise(); }
if(significantFirstUDerivativeOrder == 1) {
D = gp_Dir(d1U);
}
else {
D = gp_Dir(d2U);
}
}
Standard_Boolean LProp_SLProps::IsTangentVDefined ()
{
if (vTangentStatus == LProp_Undefined) {
return Standard_False;
}
else if (vTangentStatus >= LProp_Defined) {
return Standard_True;
}
// vTangentStatus == Lprop_Undecided
// we have to calculate the first non null V derivative
return IsTangentDefined(*this, cn, linTol, 1,
significantFirstVDerivativeOrder, vTangentStatus);
}
void LProp_SLProps::TangentV (gp_Dir& D) {
if(!IsTangentVDefined()) { LProp_NotDefined::Raise(); }
if(significantFirstVDerivativeOrder == 1) {
D = gp_Dir(d1V);
}
else {
D = gp_Dir(d2V);
}
}
Standard_Boolean LProp_SLProps::IsNormalDefined()
{
if (normalStatus == LProp_Undefined) {
return Standard_False;
}
else if (normalStatus >= LProp_Defined) {
return Standard_True;
}
// status = UnDecided
// first try the standard computation of the normal.
CSLib_DerivativeStatus Status;
CSLib::Normal(d1U, d1V, linTol, Status, normal);
if (Status == CSLib_Done ) {
normalStatus = LProp_Computed;
return Standard_True;
}
// else solve the degenerated case only if continuity >= 2
/* if (cn >= 2) {
if(level < 2) this->D2U();
Standard_Boolean Done;
CSLib_NormalStatus Stat;
CSLib::Normal(d1U, d1V, d2U, d2V, dUV, linTol, Done, Stat, normal);
if (Done) {
normalStatus = LProp_Computed;
return Standard_True;
}
}*/
/*
else {
Standard_Integer MaxOrder=3;
CSLib_NormalStatus Stat;
gp_Dir thenormal;
TColgp_Array2OfVec DerNUV(0,MaxOrder,0,MaxOrder);
TColgp_Array2OfVec DerSurf(0,MaxOrder+1,0,MaxOrder+1);
Standard_Integer i,j,OrderU,OrderV;
Standard_Real Umin,Umax,Vmin,Vmax;
Tool::Bounds(surf, Umin, Vmin, Umax, Vmax);
// Calcul des derivees
for(i=1;i<=MaxOrder+1;i++){
DerSurf.SetValue(i,0, Tool::DN(surf,u,v,i,0));
}
for(i=0;i<=MaxOrder+1;i++)
for(j=1;j<=MaxOrder+1;j++){
DerSurf.SetValue(i,j, Tool::DN(surf,u,v,i,j));
}
for(i=0;i<=MaxOrder;i++)
for(j=0;j<=MaxOrder;j++){
DerNUV.SetValue(i,j,CSLib::DNNUV(i,j,DerSurf));
}
CSLib::Normal(MaxOrder,DerNUV, 1.e-9, u,v,
Umin,Umax,Vmin,Vmax,
Stat, thenormal, OrderU, OrderV);
normal.SetXYZ(thenormal.XYZ());
if (Stat == CSLib_Defined) {
normalStatus = LProp_Computed;
return Standard_True;
}
}
*/
normalStatus = LProp_Undefined;
return Standard_False;
}
const gp_Dir& LProp_SLProps::Normal () {
if(!IsNormalDefined()) { LProp_NotDefined::Raise(); }
return normal;
}
Standard_Boolean LProp_SLProps::IsCurvatureDefined ()
{
if (curvatureStatus == LProp_Undefined) {
return Standard_False;
}
else if (curvatureStatus >= LProp_Defined) {
return Standard_True;
}
if(cn < 2) {
curvatureStatus = LProp_Undefined;
return Standard_False;
}
// status = UnDecided
if (!IsNormalDefined()) {
curvatureStatus = LProp_Undefined;
return Standard_False;
}
// pour eviter un plantage dans le cas du caro pointu
// en fait on doit pouvoir calculer les courbure
// avoir
if(!IsTangentUDefined() || !IsTangentVDefined()) {
curvatureStatus = LProp_Undefined;
return Standard_False;
}
// here we compute the curvature features of the surface
gp_Vec Norm (normal);
Standard_Real E = d1U.SquareMagnitude();
Standard_Real F = d1U.Dot(d1V);
Standard_Real G = d1V.SquareMagnitude();
if(level < 2) this->D2U();
Standard_Real L = Norm.Dot(d2U);
Standard_Real M = Norm.Dot(dUV);
Standard_Real N = Norm.Dot(d2V);
Standard_Real A = E * M - F * L;
Standard_Real B = E * N - G * L;
Standard_Real C = F * N - G * M;
Standard_Real MaxABC = Max(Max(Abs(A),Abs(B)),Abs(C));
if (MaxABC < RealEpsilon()) { // ombilic
minCurv = N / G;
maxCurv = minCurv;
dirMinCurv = gp_Dir (d1U);
dirMaxCurv = gp_Dir (d1U.Crossed(Norm));
meanCurv = minCurv; // (Cmin + Cmax) / 2.
gausCurv = minCurv * minCurv; // (Cmin * Cmax)
curvatureStatus = LProp_Computed;
return Standard_True;
}
A = A / MaxABC;
B = B / MaxABC;
C = C / MaxABC;
Standard_Real Curv1, Curv2, Root1, Root2;
gp_Vec VectCurv1, VectCurv2;
if (Abs(A) > RealEpsilon()) {
math_DirectPolynomialRoots Root (A, B, C);
if(Root.NbSolutions() != 2) {
curvatureStatus = LProp_Undefined;
return Standard_False;
}
else {
Root1 = Root.Value(1);
Root2 = Root.Value(2);
Curv1 = ((L * Root1 + 2. * M) * Root1 + N) /
((E * Root1 + 2. * F) * Root1 + G);
Curv2 = ((L * Root2 + 2. * M) * Root2 + N) /
((E * Root2 + 2. * F) * Root2 + G);
VectCurv1 = Root1 * d1U + d1V;
VectCurv2 = Root2 * d1U + d1V;
}
}
else if (Abs(C) > RealEpsilon()) {
math_DirectPolynomialRoots Root(C, B, A);
if((Root.NbSolutions() != 2)) {
curvatureStatus = LProp_Undefined;
return Standard_False;
}
else {
Root1 = Root.Value(1);
Root2 = Root.Value(2);
Curv1 = ((N * Root1 + 2. * M) * Root1 + L) /
((G * Root1 + 2. * F) * Root1 + E);
Curv2 = ((N * Root2 + 2. * M) * Root2 + L) /
((G * Root2 + 2. * F) * Root2 + E);
VectCurv1 = d1U + Root1 * d1V;
VectCurv2 = d1U + Root2 * d1V;
}
}
else {
Curv1 = L / E;
Curv2 = N / G;
VectCurv1 = d1U;
VectCurv2 = d1V;
}
if (Curv1 < Curv2) {
minCurv = Curv1;
maxCurv = Curv2;
dirMinCurv = gp_Dir (VectCurv1);
dirMaxCurv = gp_Dir (VectCurv2);
}
else {
minCurv = Curv2;
maxCurv = Curv1;
dirMinCurv = gp_Dir (VectCurv2);
dirMaxCurv = gp_Dir (VectCurv1);
}
meanCurv = ((N * E) - (2. * M * F) + (L * G)) // voir Farin p.282
/ (2. * ((E * G) - (F * F)));
gausCurv = ((L * N) - (M * M))
/ ((E * G) - (F * F));
curvatureStatus = LProp_Computed;
return Standard_True;
}
Standard_Boolean LProp_SLProps::IsUmbilic ()
{
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
return Abs(maxCurv - minCurv) < Abs(Epsilon(maxCurv));
}
Standard_Real LProp_SLProps::MaxCurvature ()
{
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
return maxCurv;
}
Standard_Real LProp_SLProps::MinCurvature ()
{
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
return minCurv;
}
void LProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
{
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
Max = dirMaxCurv;
Min = dirMinCurv;
}
Standard_Real LProp_SLProps::MeanCurvature () {
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
return meanCurv;
}
Standard_Real LProp_SLProps::GaussianCurvature () {
if(!IsCurvatureDefined()) { LProp_NotDefined::Raise(); }
return gausCurv;
}

40
src/LProp/LProp_SurfaceTool.cdl Executable file
View File

@@ -0,0 +1,40 @@
-- File: SurfaceTool.cdl
-- Created: Thu Mar 5 09:09:11 1992
-- Author: Herve LEGRAND
-- <hl@topsn3>
---Copyright: Matra Datavision 1992
deferred generic class SurfaceTool from LProp (Surface as any)
uses Pnt from gp,
Vec from gp
is
Value(myclass; S : Surface; U, V : Real; P : out Pnt);
---Purpose: Computes the point <P> of parameter <U> and <V> on the
-- Surface <C>.
D1 (myclass; S : Surface; U, V : Real; P : out Pnt; D1U, D1V : out Vec);
---Purpose: Computes the point <P> and first derivative <D1*> of
-- parameter <U> and <V> on the Surface <C>.
D2 (myclass; S : Surface; U, V : Real;
P : out Pnt; D1U, D1V, D2U, D2V, DUV : out Vec);
---Purpose: Computes the point <P>, the first derivative <D1*> and second
-- derivative <D2*> of parameter <U> and <V> on the Surface <C>.
DN (myclass; S : Surface; U, V : Real; IU, IV : Integer)
returns Vec;
Continuity(myclass; S : Surface) returns Integer;
---Purpose: returns the order of continuity of the Surface <C>.
-- returns 1 : first derivative only is computable
-- returns 2 : first and second derivative only are computable.
Bounds(myclass; S : Surface; U1, V1, U2, V2 : out Real);
---Purpose: returns the bounds of the Surface.
end SurfaceTool;

View File