mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-06-05 03:47:46 +08:00
Modeling Data - Modernize LProp .gxx templates into .pxx utilities (#1155)
Replace legacy .gxx generic class templates (LProp_CLProps.gxx, LProp_SLProps.gxx) with modern C++ .pxx template utilities (LProp_CurveUtils.pxx, LProp_SurfaceUtils.pxx) using namespaced template functions and access policies. Remove obsolete CurveTool/SurfaceTool intermediary classes (GeomLProp_CurveTool, GeomLProp_SurfaceTool, LProp3d_CurveTool, LProp3d_SurfaceTool, BRepLProp_CurveTool) that are no longer needed with the new direct/tool access policy design. Replace per-instantiation _0.cxx files with standalone .cxx implementations that delegate to the shared .pxx utilities. Fix myCN field type from double to int in all CLProps headers to match SLProps convention and actual usage (values 0 or 4). Add default member initializers for uninitialized fields (myCurvature, mySignificantFirstDerivativeOrder, myMinCurv, myMaxCurv, myMeanCurv, myGausCurv) across all CLProps/SLProps classes. Fix theSigOrder pass-by-value bug in Tangent/Curvature wrappers. Fix typos: anUinfium/anVinfium -> anUinfimum/anVinfimum.
This commit is contained in:
173
src/ModelingData/TKBRep/BRepLProp/BRepLProp_CLProps.cxx
Normal file
173
src/ModelingData/TKBRep/BRepLProp/BRepLProp_CLProps.cxx
Normal file
@@ -0,0 +1,173 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <BRepLProp_CLProps.hxx>
|
||||
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_CurveUtils.pxx>
|
||||
|
||||
using Access = LProp_CurveUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_CLProps::BRepLProp_CLProps(const BRepAdaptor_Curve& C,
|
||||
const double U,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps::BRepLProp_CLProps()");
|
||||
SetParameter(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_CLProps::BRepLProp_CLProps(const BRepAdaptor_Curve& C,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps::BRepLProp_CLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_CLProps::BRepLProp_CLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "BRepLProp_CLProps() - invalid input");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CLProps::SetParameter(const double U)
|
||||
{
|
||||
LProp_CurveUtils::SetParameter<Access>(myCurve,
|
||||
U,
|
||||
myU,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myDerivArr,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CLProps::SetCurve(const BRepAdaptor_Curve& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& BRepLProp_CLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_CLProps::D1()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 1, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_CLProps::D2()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 2, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_CLProps::D3()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 3, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_CLProps::IsTangentDefined()
|
||||
{
|
||||
return LProp_CurveUtils::IsTangentDefined<gp_Vec>(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CLProps::Tangent(gp_Dir& D)
|
||||
{
|
||||
LProp_CurveUtils::Tangent<Access>(*this,
|
||||
myCurve,
|
||||
myU,
|
||||
myDerivArr,
|
||||
myPnt,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_CLProps::Curvature()
|
||||
{
|
||||
return LProp_CurveUtils::Curvature(*this,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myCurvature);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CLProps::Normal(gp_Dir& N)
|
||||
{
|
||||
LProp_CurveUtils::Normal(*this, myDerivArr[0], myDerivArr[1], myLinTol, N);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CLProps::CentreOfCurvature(gp_Pnt& P)
|
||||
{
|
||||
LProp_CurveUtils::CentreOfCurvature(*this,
|
||||
myPnt,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
myCurvature,
|
||||
P);
|
||||
}
|
||||
@@ -33,7 +33,6 @@ class BRepAdaptor_Curve;
|
||||
class gp_Vec;
|
||||
class gp_Pnt;
|
||||
class gp_Dir;
|
||||
class BRepLProp_CurveTool;
|
||||
|
||||
class BRepLProp_CLProps
|
||||
{
|
||||
@@ -113,14 +112,14 @@ private:
|
||||
BRepAdaptor_Curve myCurve;
|
||||
double myU;
|
||||
int myDerOrder;
|
||||
double myCN;
|
||||
int myCN;
|
||||
double myLinTol;
|
||||
gp_Pnt myPnt;
|
||||
gp_Vec myDerivArr[3];
|
||||
gp_Dir myTangent;
|
||||
double myCurvature;
|
||||
double myCurvature = 0.0;
|
||||
LProp_Status myTangentStatus;
|
||||
int mySignificantFirstDerivativeOrder;
|
||||
int mySignificantFirstDerivativeOrder = 0;
|
||||
};
|
||||
|
||||
#endif // _BRepLProp_CLProps_HeaderFile
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <BRepLProp_CLProps.hxx>
|
||||
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
|
||||
#define Curve BRepAdaptor_Curve
|
||||
#define Curve_hxx <BRepAdaptor_Curve.hxx>
|
||||
#define Vec gp_Vec
|
||||
#define Vec_hxx <gp_Vec.hxx>
|
||||
#define Pnt gp_Pnt
|
||||
#define Pnt_hxx <gp_Pnt.hxx>
|
||||
#define Dir gp_Dir
|
||||
#define Dir_hxx <gp_Dir.hxx>
|
||||
#define Tool BRepLProp_CurveTool
|
||||
#define Tool_hxx <BRepLProp_CurveTool.hxx>
|
||||
#define LProp_CLProps BRepLProp_CLProps
|
||||
#define LProp_CLProps_hxx <BRepLProp_CLProps.hxx>
|
||||
#include <LProp_CLProps.gxx>
|
||||
@@ -1,96 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CurveTool::Value(const BRepAdaptor_Curve& C, const double U, gp_Pnt& P)
|
||||
{
|
||||
P = C.Value(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CurveTool::D1(const BRepAdaptor_Curve& C, const double U, gp_Pnt& P, gp_Vec& V1)
|
||||
{
|
||||
C.D1(U, P, V1);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CurveTool::D2(const BRepAdaptor_Curve& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2)
|
||||
{
|
||||
C.D2(U, P, V1, V2);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_CurveTool::D3(const BRepAdaptor_Curve& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3)
|
||||
{
|
||||
C.D3(U, P, V1, V2, V3);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
int BRepLProp_CurveTool::Continuity(const BRepAdaptor_Curve& C)
|
||||
{
|
||||
GeomAbs_Shape s = C.Continuity();
|
||||
switch (s)
|
||||
{
|
||||
case GeomAbs_C0:
|
||||
return 0;
|
||||
case GeomAbs_C1:
|
||||
return 1;
|
||||
case GeomAbs_C2:
|
||||
return 2;
|
||||
case GeomAbs_C3:
|
||||
return 3;
|
||||
case GeomAbs_G1:
|
||||
return 0;
|
||||
case GeomAbs_G2:
|
||||
return 0;
|
||||
case GeomAbs_CN:
|
||||
return 3;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_CurveTool::FirstParameter(const BRepAdaptor_Curve& C)
|
||||
{
|
||||
return C.FirstParameter();
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_CurveTool::LastParameter(const BRepAdaptor_Curve& C)
|
||||
{
|
||||
return C.LastParameter();
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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.
|
||||
|
||||
#ifndef _BRepLProp_CurveTool_HeaderFile
|
||||
#define _BRepLProp_CurveTool_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
class BRepAdaptor_Curve;
|
||||
class gp_Pnt;
|
||||
class gp_Vec;
|
||||
|
||||
class BRepLProp_CurveTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Computes the point <P> of parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void Value(const BRepAdaptor_Curve& C, const double U, gp_Pnt& P);
|
||||
|
||||
//! Computes the point <P> and first derivative <V1> of
|
||||
//! parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D1(const BRepAdaptor_Curve& C, const double U, gp_Pnt& P, gp_Vec& V1);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1> and second
|
||||
//! derivative <V2> of parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D2(const BRepAdaptor_Curve& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1>, the
|
||||
//! second derivative <V2> and third derivative <V3> of
|
||||
//! parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D3(const BRepAdaptor_Curve& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3);
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT static int Continuity(const BRepAdaptor_Curve& C);
|
||||
|
||||
//! returns the first parameter bound of the curve.
|
||||
Standard_EXPORT static double FirstParameter(const BRepAdaptor_Curve& C);
|
||||
|
||||
//! returns the last parameter bound of the curve.
|
||||
//! FirstParameter must be less than LastParamenter.
|
||||
Standard_EXPORT static double LastParameter(const BRepAdaptor_Curve& C);
|
||||
};
|
||||
|
||||
#endif // _BRepLProp_CurveTool_HeaderFile
|
||||
281
src/ModelingData/TKBRep/BRepLProp/BRepLProp_SLProps.cxx
Normal file
281
src/ModelingData/TKBRep/BRepLProp/BRepLProp_SLProps.cxx
Normal file
@@ -0,0 +1,281 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <BRepLProp_SLProps.hxx>
|
||||
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_SurfaceUtils.pxx>
|
||||
|
||||
using Access = LProp_SurfaceUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_SLProps::BRepLProp_SLProps(const BRepAdaptor_Surface& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps()");
|
||||
SetParameters(U, V);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_SLProps::BRepLProp_SLProps(const BRepAdaptor_Surface& S,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
BRepLProp_SLProps::BRepLProp_SLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "BRepLProp_SLProps::BRepLProp_SLProps() bad level");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_SLProps::SetSurface(const BRepAdaptor_Surface& S)
|
||||
{
|
||||
mySurf = S;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_SLProps::SetParameters(const double U, const double V)
|
||||
{
|
||||
LProp_SurfaceUtils::SetParameters<Access>(mySurf,
|
||||
U,
|
||||
V,
|
||||
myU,
|
||||
myV,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myUTangentStatus,
|
||||
myVTangentStatus,
|
||||
myNormalStatus,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& BRepLProp_SLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_SLProps::D1U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_SLProps::D1V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_SLProps::D2U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_SLProps::D2V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& BRepLProp_SLProps::DUV()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myDuv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_SLProps::IsTangentUDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentUDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
myUTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_SLProps::TangentU(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentU<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1u,
|
||||
myD2u,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_SLProps::IsTangentVDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentVDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
myVTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_SLProps::TangentV(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentV<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1v,
|
||||
myD2v,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_SLProps::IsNormalDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsNormalDefined(myD1u, myD1v, myLinTol, myNormal, myNormalStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Dir& BRepLProp_SLProps::Normal()
|
||||
{
|
||||
return LProp_SurfaceUtils::Normal(*this, myNormal);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_SLProps::IsCurvatureDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsCurvatureDefined(*this,
|
||||
myCN,
|
||||
myDerOrder,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myNormal,
|
||||
myMinCurv,
|
||||
myMaxCurv,
|
||||
myDirMinCurv,
|
||||
myDirMaxCurv,
|
||||
myMeanCurv,
|
||||
myGausCurv,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool BRepLProp_SLProps::IsUmbilic()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsUmbilic(*this, myMaxCurv, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_SLProps::MaxCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMaxCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_SLProps::MinCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void BRepLProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
|
||||
{
|
||||
LProp_SurfaceUtils::CurvatureDirections(*this, myDirMaxCurv, myDirMinCurv, Max, Min);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_SLProps::MeanCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMeanCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double BRepLProp_SLProps::GaussianCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myGausCurv);
|
||||
}
|
||||
@@ -158,14 +158,14 @@ private:
|
||||
gp_Vec myD2v;
|
||||
gp_Vec myDuv;
|
||||
gp_Dir myNormal;
|
||||
double myMinCurv;
|
||||
double myMaxCurv;
|
||||
double myMinCurv = 0.0;
|
||||
double myMaxCurv = 0.0;
|
||||
gp_Dir myDirMinCurv;
|
||||
gp_Dir myDirMaxCurv;
|
||||
double myMeanCurv;
|
||||
double myGausCurv;
|
||||
int mySignificantFirstDerivativeOrderU;
|
||||
int mySignificantFirstDerivativeOrderV;
|
||||
double myMeanCurv = 0.0;
|
||||
double myGausCurv = 0.0;
|
||||
int mySignificantFirstDerivativeOrderU = 0;
|
||||
int mySignificantFirstDerivativeOrderV = 0;
|
||||
LProp_Status myUTangentStatus;
|
||||
LProp_Status myVTangentStatus;
|
||||
LProp_Status myNormalStatus;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <BRepLProp_SLProps.hxx>
|
||||
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepLProp_SurfaceTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
#define Surface BRepAdaptor_Surface
|
||||
#define Surface_hxx <BRepAdaptor_Surface.hxx>
|
||||
#define Tool BRepLProp_SurfaceTool
|
||||
#define Tool_hxx <BRepLProp_SurfaceTool.hxx>
|
||||
#define LProp_SLProps BRepLProp_SLProps
|
||||
#define LProp_SLProps_hxx <BRepLProp_SLProps.hxx>
|
||||
#include <LProp_SLProps.gxx>
|
||||
@@ -5,11 +5,9 @@ set(OCCT_BRepLProp_FILES
|
||||
BRepLProp.cxx
|
||||
BRepLProp.hxx
|
||||
BRepLProp_CLProps.hxx
|
||||
BRepLProp_CLProps_0.cxx
|
||||
BRepLProp_CurveTool.cxx
|
||||
BRepLProp_CurveTool.hxx
|
||||
BRepLProp_CLProps.cxx
|
||||
BRepLProp_SLProps.hxx
|
||||
BRepLProp_SLProps_0.cxx
|
||||
BRepLProp_SLProps.cxx
|
||||
BRepLProp_SurfaceTool.cxx
|
||||
BRepLProp_SurfaceTool.hxx
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ set(OCCT_Geom2dLProp_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_Geom2dLProp_FILES
|
||||
Geom2dLProp_CLProps2d.hxx
|
||||
Geom2dLProp_CLProps2d_0.cxx
|
||||
Geom2dLProp_CLProps2d.cxx
|
||||
Geom2dLProp_CurAndInf2d.cxx
|
||||
Geom2dLProp_CurAndInf2d.hxx
|
||||
Geom2dLProp_Curve2dTool.cxx
|
||||
|
||||
173
src/ModelingData/TKG2d/Geom2dLProp/Geom2dLProp_CLProps2d.cxx
Normal file
173
src/ModelingData/TKG2d/Geom2dLProp/Geom2dLProp_CLProps2d.cxx
Normal file
@@ -0,0 +1,173 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <Geom2dLProp_CLProps2d.hxx>
|
||||
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_CurveUtils.pxx>
|
||||
|
||||
using Access = LProp_CurveUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Geom2dLProp_CLProps2d::Geom2dLProp_CLProps2d(const occ::handle<Geom2d_Curve>& C,
|
||||
const double U,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "Geom2dLProp_CLProps2d::Geom2dLProp_CLProps2d()");
|
||||
SetParameter(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Geom2dLProp_CLProps2d::Geom2dLProp_CLProps2d(const occ::handle<Geom2d_Curve>& C,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "Geom2dLProp_CLProps2d::Geom2dLProp_CLProps2d()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Geom2dLProp_CLProps2d::Geom2dLProp_CLProps2d(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "Geom2dLProp_CLProps2d() - invalid input");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void Geom2dLProp_CLProps2d::SetParameter(const double U)
|
||||
{
|
||||
LProp_CurveUtils::SetParameter<Access>(myCurve,
|
||||
U,
|
||||
myU,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myDerivArr,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void Geom2dLProp_CLProps2d::SetCurve(const occ::handle<Geom2d_Curve>& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt2d& Geom2dLProp_CLProps2d::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec2d& Geom2dLProp_CLProps2d::D1()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 1, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec2d& Geom2dLProp_CLProps2d::D2()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 2, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec2d& Geom2dLProp_CLProps2d::D3()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 3, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool Geom2dLProp_CLProps2d::IsTangentDefined()
|
||||
{
|
||||
return LProp_CurveUtils::IsTangentDefined<gp_Vec2d>(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void Geom2dLProp_CLProps2d::Tangent(gp_Dir2d& D)
|
||||
{
|
||||
LProp_CurveUtils::Tangent<Access>(*this,
|
||||
myCurve,
|
||||
myU,
|
||||
myDerivArr,
|
||||
myPnt,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double Geom2dLProp_CLProps2d::Curvature()
|
||||
{
|
||||
return LProp_CurveUtils::Curvature(*this,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myCurvature);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void Geom2dLProp_CLProps2d::Normal(gp_Dir2d& N)
|
||||
{
|
||||
LProp_CurveUtils::Normal(*this, myDerivArr[0], myDerivArr[1], myLinTol, N);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void Geom2dLProp_CLProps2d::CentreOfCurvature(gp_Pnt2d& P)
|
||||
{
|
||||
LProp_CurveUtils::CentreOfCurvature(*this,
|
||||
myPnt,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
myCurvature,
|
||||
P);
|
||||
}
|
||||
@@ -116,14 +116,14 @@ private:
|
||||
occ::handle<Geom2d_Curve> myCurve;
|
||||
double myU;
|
||||
int myDerOrder;
|
||||
double myCN;
|
||||
int myCN;
|
||||
double myLinTol;
|
||||
gp_Pnt2d myPnt;
|
||||
gp_Vec2d myDerivArr[3];
|
||||
gp_Dir2d myTangent;
|
||||
double myCurvature;
|
||||
double myCurvature = 0.0;
|
||||
LProp_Status myTangentStatus;
|
||||
int mySignificantFirstDerivativeOrder;
|
||||
int mySignificantFirstDerivativeOrder = 0;
|
||||
};
|
||||
|
||||
#endif // _Geom2dLProp_CLProps2d_HeaderFile
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <Geom2dLProp_CLProps2d.hxx>
|
||||
|
||||
#include <Geom2d_Curve.hxx>
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Dir2d.hxx>
|
||||
#include <Geom2dLProp_Curve2dTool.hxx>
|
||||
|
||||
#define Curve occ::handle<Geom2d_Curve>
|
||||
#define Curve_hxx <Geom2d_Curve.hxx>
|
||||
#define Vec gp_Vec2d
|
||||
#define Vec_hxx <gp_Vec2d.hxx>
|
||||
#define Pnt gp_Pnt2d
|
||||
#define Pnt_hxx <gp_Pnt2d.hxx>
|
||||
#define Dir gp_Dir2d
|
||||
#define Dir_hxx <gp_Dir2d.hxx>
|
||||
#define Tool Geom2dLProp_Curve2dTool
|
||||
#define Tool_hxx <Geom2dLProp_Curve2dTool.hxx>
|
||||
#define LProp_CLProps Geom2dLProp_CLProps2d
|
||||
#define LProp_CLProps_hxx <Geom2dLProp_CLProps2d.hxx>
|
||||
#include <LProp_CLProps.gxx>
|
||||
@@ -6,11 +6,10 @@ set(OCCT_LProp_FILES
|
||||
LProp_AnalyticCurInf.hxx
|
||||
LProp_BadContinuity.hxx
|
||||
LProp_CIType.hxx
|
||||
LProp_CLProps.gxx
|
||||
LProp_CurAndInf.cxx
|
||||
LProp_CurAndInf.hxx
|
||||
LProp_CurveUtils.pxx
|
||||
LProp_NotDefined.hxx
|
||||
|
||||
LProp_SLProps.gxx
|
||||
LProp_SurfaceUtils.pxx
|
||||
LProp_Status.hxx
|
||||
)
|
||||
|
||||
@@ -1,285 +0,0 @@
|
||||
// Copyright (c) 1995-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 <LProp_Status.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
static const double MinStep = 1.0e-7;
|
||||
|
||||
LProp_CLProps::LProp_CLProps(const Curve& C, const double U, const int N, const double Resolution)
|
||||
: myCurve(C),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps::LProp_CLProps()");
|
||||
|
||||
SetParameter(U);
|
||||
}
|
||||
|
||||
LProp_CLProps::LProp_CLProps(const Curve& C, const int N, const double Resolution)
|
||||
: myCurve(C),
|
||||
myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps::LProp_CLProps()");
|
||||
}
|
||||
|
||||
LProp_CLProps::LProp_CLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp_CLProps() - invalid input");
|
||||
}
|
||||
|
||||
void LProp_CLProps::SetParameter(const double U)
|
||||
{
|
||||
myU = U;
|
||||
switch (myDerOrder)
|
||||
{
|
||||
case 0:
|
||||
Tool::Value(myCurve, myU, myPnt);
|
||||
break;
|
||||
case 1:
|
||||
Tool::D1(myCurve, myU, myPnt, myDerivArr[0]);
|
||||
break;
|
||||
case 2:
|
||||
Tool::D2(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1]);
|
||||
break;
|
||||
case 3:
|
||||
Tool::D3(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1], myDerivArr[2]);
|
||||
break;
|
||||
}
|
||||
|
||||
myTangentStatus = LProp_Undecided;
|
||||
}
|
||||
|
||||
void LProp_CLProps::SetCurve(const Curve& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myCN = 4; // Tool::Continuity(C); RLE
|
||||
}
|
||||
|
||||
const Pnt& LProp_CLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
const Vec& LProp_CLProps::D1()
|
||||
{
|
||||
if (myDerOrder < 1)
|
||||
{
|
||||
myDerOrder = 1;
|
||||
Tool::D1(myCurve, myU, myPnt, myDerivArr[0]);
|
||||
}
|
||||
|
||||
return myDerivArr[0];
|
||||
}
|
||||
|
||||
const Vec& LProp_CLProps::D2()
|
||||
{
|
||||
if (myDerOrder < 2)
|
||||
{
|
||||
myDerOrder = 2;
|
||||
Tool::D2(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1]);
|
||||
}
|
||||
|
||||
return myDerivArr[1];
|
||||
}
|
||||
|
||||
const Vec& LProp_CLProps::D3()
|
||||
{
|
||||
if (myDerOrder < 3)
|
||||
{
|
||||
myDerOrder = 3;
|
||||
Tool::D3(myCurve, myU, myPnt, myDerivArr[0], myDerivArr[1], myDerivArr[2]);
|
||||
}
|
||||
|
||||
return myDerivArr[2];
|
||||
}
|
||||
|
||||
bool LProp_CLProps::IsTangentDefined()
|
||||
{
|
||||
if (myTangentStatus == LProp_Undefined)
|
||||
return false;
|
||||
else if (myTangentStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
// tangentStatus == Lprop_Undecided
|
||||
// we have to calculate the first non null derivative
|
||||
const double Tol = myLinTol * myLinTol;
|
||||
|
||||
Vec V;
|
||||
|
||||
int Order = 0;
|
||||
while (Order++ < 4)
|
||||
{
|
||||
if (myCN >= Order)
|
||||
{
|
||||
switch (Order)
|
||||
{
|
||||
case 1:
|
||||
V = D1();
|
||||
break;
|
||||
case 2:
|
||||
V = D2();
|
||||
break;
|
||||
case 3:
|
||||
V = D3();
|
||||
break;
|
||||
} // switch(Order)
|
||||
|
||||
if (V.SquareMagnitude() > Tol)
|
||||
{
|
||||
mySignificantFirstDerivativeOrder = Order;
|
||||
myTangentStatus = LProp_Defined;
|
||||
return true;
|
||||
} // if(V.SquareMagnitude() > Tol)
|
||||
} // if(cn >= Order)
|
||||
else
|
||||
{
|
||||
myTangentStatus = LProp_Undefined;
|
||||
return false;
|
||||
} // else of "if(cn >= Order)" condition
|
||||
} // while (Order < 4)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LProp_CLProps::Tangent(Dir& D)
|
||||
{
|
||||
if (!IsTangentDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
if (mySignificantFirstDerivativeOrder == 1)
|
||||
D = Dir(myDerivArr[0]);
|
||||
else if (mySignificantFirstDerivativeOrder > 1)
|
||||
{
|
||||
const double DivisionFactor = 1.e-3;
|
||||
const double anUsupremum = Tool::LastParameter(myCurve),
|
||||
anUinfium = Tool::FirstParameter(myCurve);
|
||||
|
||||
double du;
|
||||
if ((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
|
||||
du = 0.0;
|
||||
else
|
||||
du = anUsupremum - anUinfium;
|
||||
|
||||
const double aDelta = std::max(du * DivisionFactor, MinStep);
|
||||
|
||||
Vec V = myDerivArr[mySignificantFirstDerivativeOrder - 1];
|
||||
|
||||
double u;
|
||||
|
||||
if (myU - anUinfium < aDelta)
|
||||
u = myU + aDelta;
|
||||
else
|
||||
u = myU - aDelta;
|
||||
|
||||
Pnt P1, P2;
|
||||
Tool::Value(myCurve, std::min(myU, u), P1);
|
||||
Tool::Value(myCurve, std::max(myU, u), P2);
|
||||
|
||||
Vec V1(P1, P2);
|
||||
double aDirFactor = V.Dot(V1);
|
||||
|
||||
if (aDirFactor < 0.0)
|
||||
V = -V;
|
||||
|
||||
D = Dir(V);
|
||||
} // else if (mySignificantFirstDerivativeOrder > 1)
|
||||
}
|
||||
|
||||
double LProp_CLProps::Curvature()
|
||||
{
|
||||
bool isDefined = IsTangentDefined();
|
||||
(void)isDefined; // trick to avoid compiler warning on variable unised in Release mode; note that
|
||||
// IsTangentDefined() must be called always
|
||||
LProp_NotDefined_Raise_if(!isDefined, "LProp_CLProps::CurvatureNotDefined()");
|
||||
|
||||
// if the first derivative is null the curvature is infinite.
|
||||
if (mySignificantFirstDerivativeOrder > 1)
|
||||
return RealLast();
|
||||
|
||||
double Tol = myLinTol * myLinTol;
|
||||
double DD1 = myDerivArr[0].SquareMagnitude();
|
||||
double DD2 = myDerivArr[1].SquareMagnitude();
|
||||
|
||||
// if the second derivative is null the curvature is null.
|
||||
if (DD2 <= Tol)
|
||||
{
|
||||
myCurvature = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
double N = myDerivArr[0].CrossSquareMagnitude(myDerivArr[1]);
|
||||
// if d[0] and d[1] are colinear the curvature is null.
|
||||
// double t = N/(DD1*DD2);
|
||||
double t = N / DD1 / DD2;
|
||||
if (t <= Tol)
|
||||
{
|
||||
myCurvature = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
myCurvature = sqrt(N) / DD1 / sqrt(DD1);
|
||||
}
|
||||
}
|
||||
|
||||
return myCurvature;
|
||||
}
|
||||
|
||||
void LProp_CLProps::Normal(Dir& D)
|
||||
{
|
||||
double c = Curvature();
|
||||
if (c == RealLast() || std::abs(c) <= myLinTol)
|
||||
{
|
||||
throw LProp_NotDefined("LProp_CLProps::Normal(...):"
|
||||
"Curvature is null or infinity");
|
||||
}
|
||||
|
||||
// we used here the following vector relation
|
||||
// a ^ (b ^ c) = b(ac) - c(ab)
|
||||
// Norm = d[0] ^ (d[1] ^ d[0])
|
||||
|
||||
Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0])
|
||||
- myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
|
||||
D = Dir(Norm);
|
||||
}
|
||||
|
||||
void LProp_CLProps::CentreOfCurvature(Pnt& P)
|
||||
{
|
||||
if (std::abs(Curvature()) <= myLinTol)
|
||||
{
|
||||
throw LProp_NotDefined();
|
||||
}
|
||||
|
||||
// we used here the following vector relation
|
||||
// a ^ (b ^ c) = b(ac) - c(ab)
|
||||
// Norm = d[0] ^ (d[1] ^ d[0])
|
||||
|
||||
Vec Norm = myDerivArr[1] * (myDerivArr[0] * myDerivArr[0])
|
||||
- myDerivArr[0] * (myDerivArr[0] * myDerivArr[1]);
|
||||
Norm.Normalize();
|
||||
Norm.Divide(myCurvature);
|
||||
P = myPnt.Translated(Norm);
|
||||
}
|
||||
465
src/ModelingData/TKG2d/LProp/LProp_CurveUtils.pxx
Normal file
465
src/ModelingData/TKG2d/LProp/LProp_CurveUtils.pxx
Normal file
@@ -0,0 +1,465 @@
|
||||
// Copyright (c) 2025 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.
|
||||
|
||||
#ifndef _LProp_CurveUtils_HeaderFile
|
||||
#define _LProp_CurveUtils_HeaderFile
|
||||
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <LProp_Status.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//! Template utility functions for CLProps curve local property computation.
|
||||
//! Provides access policies (DirectAccess, ToolAccess) and shared algorithms
|
||||
//! for evaluating derivatives, tangents, curvature, normals, and centres of curvature.
|
||||
namespace LProp_CurveUtils
|
||||
{
|
||||
|
||||
// ==================== Deref helpers ====================
|
||||
|
||||
//! Dereference by-value or reference types (identity).
|
||||
template <typename T>
|
||||
T& Deref(T& theObj)
|
||||
{
|
||||
return theObj;
|
||||
}
|
||||
|
||||
//! Dereference occ::handle types.
|
||||
template <typename T>
|
||||
T& Deref(occ::handle<T>& theHandle)
|
||||
{
|
||||
return *theHandle;
|
||||
}
|
||||
|
||||
//! Dereference const occ::handle types.
|
||||
template <typename T>
|
||||
const T& Deref(const occ::handle<T>& theHandle)
|
||||
{
|
||||
return *theHandle;
|
||||
}
|
||||
|
||||
// ==================== Access Policies ====================
|
||||
|
||||
//! Direct access policy: calls D0/D1/D2/D3 methods on the curve object.
|
||||
//! Works with occ::handle<T> and by-value curve types.
|
||||
struct DirectAccess
|
||||
{
|
||||
template <typename C, typename P>
|
||||
static void D0(C& theCurve, double theU, P& thePnt)
|
||||
{
|
||||
Deref(theCurve).D0(theU, thePnt);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D1(C& theCurve, double theU, P& thePnt, V& theV1)
|
||||
{
|
||||
Deref(theCurve).D1(theU, thePnt, theV1);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D2(C& theCurve, double theU, P& thePnt, V& theV1, V& theV2)
|
||||
{
|
||||
Deref(theCurve).D2(theU, thePnt, theV1, theV2);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D3(C& theCurve, double theU, P& thePnt, V& theV1, V& theV2, V& theV3)
|
||||
{
|
||||
Deref(theCurve).D3(theU, thePnt, theV1, theV2, theV3);
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
static double FirstParameter(C& theCurve)
|
||||
{
|
||||
return Deref(theCurve).FirstParameter();
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
static double LastParameter(C& theCurve)
|
||||
{
|
||||
return Deref(theCurve).LastParameter();
|
||||
}
|
||||
};
|
||||
|
||||
//! Tool-based access policy: delegates to static Tool methods.
|
||||
//! Used for HLRBRep types where Tool class provides the interface.
|
||||
template <typename Tool>
|
||||
struct ToolAccess
|
||||
{
|
||||
template <typename C, typename P>
|
||||
static void D0(C& theCurve, double theU, P& thePnt)
|
||||
{
|
||||
Tool::Value(theCurve, theU, thePnt);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D1(C& theCurve, double theU, P& thePnt, V& theV1)
|
||||
{
|
||||
Tool::D1(theCurve, theU, thePnt, theV1);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D2(C& theCurve, double theU, P& thePnt, V& theV1, V& theV2)
|
||||
{
|
||||
Tool::D2(theCurve, theU, thePnt, theV1, theV2);
|
||||
}
|
||||
|
||||
template <typename C, typename P, typename V>
|
||||
static void D3(C& theCurve, double theU, P& thePnt, V& theV1, V& theV2, V& theV3)
|
||||
{
|
||||
Tool::D3(theCurve, theU, thePnt, theV1, theV2, theV3);
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
static double FirstParameter(C& theCurve)
|
||||
{
|
||||
return Tool::FirstParameter(theCurve);
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
static double LastParameter(C& theCurve)
|
||||
{
|
||||
return Tool::LastParameter(theCurve);
|
||||
}
|
||||
};
|
||||
|
||||
// ==================== Algorithm Utilities ====================
|
||||
|
||||
//! Evaluate curve derivatives at parameter theU up to specified order.
|
||||
//! @param[in,out] theCurve curve object
|
||||
//! @param[in] theU parameter value
|
||||
//! @param[in] theOrder maximum derivative order (0-3)
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theDerivArr derivative array (size >= theOrder)
|
||||
template <typename Access, typename Curve, typename Pnt, typename Vec>
|
||||
void EvalDerivatives(Curve& theCurve, double theU, int theOrder, Pnt& thePnt, Vec* theDerivArr)
|
||||
{
|
||||
switch (theOrder)
|
||||
{
|
||||
case 0:
|
||||
Access::D0(theCurve, theU, thePnt);
|
||||
break;
|
||||
case 1:
|
||||
Access::D1(theCurve, theU, thePnt, theDerivArr[0]);
|
||||
break;
|
||||
case 2:
|
||||
Access::D2(theCurve, theU, thePnt, theDerivArr[0], theDerivArr[1]);
|
||||
break;
|
||||
case 3:
|
||||
Access::D3(theCurve, theU, thePnt, theDerivArr[0], theDerivArr[1], theDerivArr[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//! Compute tangent direction with sign correction for higher-order derivatives.
|
||||
//! When the first significant derivative has order > 1, the sign of the tangent
|
||||
//! is determined by comparing with the chord direction near the point.
|
||||
//! @param[in,out] theCurve curve object
|
||||
//! @param[in] theU current parameter
|
||||
//! @param[in] theDerivArr derivative array
|
||||
//! @param[in] theRefPnt reference point (used only for type deduction)
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[out] theDir computed tangent direction
|
||||
template <typename Access, typename Curve, typename Vec, typename Pnt, typename Dir>
|
||||
void ComputeTangent(Curve& theCurve,
|
||||
double theU,
|
||||
const Vec* theDerivArr,
|
||||
const Pnt& /*theRefPnt*/,
|
||||
int theSigOrder,
|
||||
Dir& theDir)
|
||||
{
|
||||
if (theSigOrder == 1)
|
||||
{
|
||||
theDir = Dir(theDerivArr[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr double THE_DIVISION_FACTOR = 1.0e-3;
|
||||
constexpr double THE_MIN_STEP = 1.0e-7;
|
||||
|
||||
const double anUsupremum = Access::LastParameter(theCurve);
|
||||
const double anUinfimum = Access::FirstParameter(theCurve);
|
||||
|
||||
double aDu;
|
||||
if ((anUsupremum >= RealLast()) || (anUinfimum <= RealFirst()))
|
||||
aDu = 0.0;
|
||||
else
|
||||
aDu = anUsupremum - anUinfimum;
|
||||
|
||||
const double aDelta = std::max(aDu * THE_DIVISION_FACTOR, THE_MIN_STEP);
|
||||
|
||||
Vec aV = theDerivArr[theSigOrder - 1];
|
||||
|
||||
double anOtherU;
|
||||
if (theU - anUinfimum < aDelta)
|
||||
anOtherU = theU + aDelta;
|
||||
else
|
||||
anOtherU = theU - aDelta;
|
||||
|
||||
Pnt aP1, aP2;
|
||||
Access::D0(theCurve, std::min(theU, anOtherU), aP1);
|
||||
Access::D0(theCurve, std::max(theU, anOtherU), aP2);
|
||||
|
||||
Vec aChord(aP1, aP2);
|
||||
if (aV.Dot(aChord) < 0.0)
|
||||
aV = -aV;
|
||||
|
||||
theDir = Dir(aV);
|
||||
}
|
||||
|
||||
//! Compute curvature from first and second derivatives.
|
||||
//! Returns |D1 x D2| / |D1|^3, or 0 if derivatives are collinear or D2 is null.
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[in] theTolSq squared linear tolerance
|
||||
//! @return curvature value
|
||||
template <typename Vec>
|
||||
double ComputeCurvature(const Vec& theD1, const Vec& theD2, double theTolSq)
|
||||
{
|
||||
const double aDD1 = theD1.SquareMagnitude();
|
||||
const double aDD2 = theD2.SquareMagnitude();
|
||||
|
||||
if (aDD2 <= theTolSq)
|
||||
return 0.0;
|
||||
|
||||
const double aN = theD1.CrossSquareMagnitude(theD2);
|
||||
const double aT = aN / aDD1 / aDD2;
|
||||
if (aT <= theTolSq)
|
||||
return 0.0;
|
||||
|
||||
return sqrt(aN) / aDD1 / sqrt(aDD1);
|
||||
}
|
||||
|
||||
//! Compute normal direction from first and second derivatives.
|
||||
//! Normal = D2*(D1*D1) - D1*(D1*D2), using the vector triple product identity.
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[out] theDir computed normal direction
|
||||
template <typename Vec, typename Dir>
|
||||
void ComputeNormal(const Vec& theD1, const Vec& theD2, Dir& theDir)
|
||||
{
|
||||
Vec aNorm = theD2 * (theD1 * theD1) - theD1 * (theD1 * theD2);
|
||||
theDir = Dir(aNorm);
|
||||
}
|
||||
|
||||
//! Compute centre of curvature from point, derivatives, and curvature.
|
||||
//! Centre = Point + Normal / Curvature.
|
||||
//! @param[in] thePnt current point
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[in] theCurvature curvature value (must be non-zero)
|
||||
//! @param[out] theCentre computed centre of curvature
|
||||
template <typename Vec, typename Pnt>
|
||||
void ComputeCentreOfCurvature(const Pnt& thePnt,
|
||||
const Vec& theD1,
|
||||
const Vec& theD2,
|
||||
double theCurvature,
|
||||
Pnt& theCentre)
|
||||
{
|
||||
Vec aNorm = theD2 * (theD1 * theD1) - theD1 * (theD1 * theD2);
|
||||
aNorm.Normalize();
|
||||
aNorm.Divide(theCurvature);
|
||||
theCentre = thePnt.Translated(aNorm);
|
||||
}
|
||||
|
||||
// ==================== Higher-Level Method Wrappers ====================
|
||||
|
||||
//! SetParameter wrapper: sets parameter, evaluates derivatives, resets tangent status.
|
||||
//! @param[in,out] theCurve curve object
|
||||
//! @param[in] theU parameter value
|
||||
//! @param[out] theStoredU stored parameter field
|
||||
//! @param[in] theDerOrder current derivative order
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theDerivArr derivative array
|
||||
//! @param[out] theTanStatus tangent status field
|
||||
template <typename Access, typename Curve, typename Pnt, typename Vec>
|
||||
void SetParameter(Curve& theCurve,
|
||||
double theU,
|
||||
double& theStoredU,
|
||||
int theDerOrder,
|
||||
Pnt& thePnt,
|
||||
Vec* theDerivArr,
|
||||
LProp_Status& theTanStatus)
|
||||
{
|
||||
theStoredU = theU;
|
||||
EvalDerivatives<Access>(theCurve, theU, theDerOrder, thePnt, theDerivArr);
|
||||
theTanStatus = LProp_Undecided;
|
||||
}
|
||||
|
||||
//! Ensure derivatives up to the required order are computed.
|
||||
//! @param[in,out] theCurve curve object
|
||||
//! @param[in] theU parameter value
|
||||
//! @param[in,out] theDerOrder current derivative order (upgraded if needed)
|
||||
//! @param[in] theRequired required derivative order
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theDerivArr derivative array
|
||||
//! @return reference to theDerivArr[theRequired-1]
|
||||
template <typename Access, typename Curve, typename Pnt, typename Vec>
|
||||
const Vec& EnsureDeriv(Curve& theCurve,
|
||||
double theU,
|
||||
int& theDerOrder,
|
||||
int theRequired,
|
||||
Pnt& thePnt,
|
||||
Vec* theDerivArr)
|
||||
{
|
||||
if (theDerOrder < theRequired)
|
||||
{
|
||||
theDerOrder = theRequired;
|
||||
EvalDerivatives<Access>(theCurve, theU, theDerOrder, thePnt, theDerivArr);
|
||||
}
|
||||
return theDerivArr[theRequired - 1];
|
||||
}
|
||||
|
||||
//! IsTangentDefined: searches for first non-null derivative.
|
||||
//! Calls theProps.D1(), theProps.D2(), theProps.D3() to upgrade derivatives as needed.
|
||||
//! @param[in,out] theProps CLProps object
|
||||
//! @param[in] theCN continuity order
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theSigOrder order of first significant derivative
|
||||
//! @param[in,out] theTanStatus tangent status field
|
||||
//! @return true if tangent is defined
|
||||
template <typename Vec, typename Props>
|
||||
bool IsTangentDefined(Props& theProps,
|
||||
int theCN,
|
||||
double theLinTol,
|
||||
int& theSigOrder,
|
||||
LProp_Status& theTanStatus)
|
||||
{
|
||||
if (theTanStatus == LProp_Undefined)
|
||||
return false;
|
||||
if (theTanStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
const double aTolSq = theLinTol * theLinTol;
|
||||
int anOrder = 0;
|
||||
while (anOrder++ < 4)
|
||||
{
|
||||
if (theCN >= anOrder)
|
||||
{
|
||||
Vec aV;
|
||||
switch (anOrder)
|
||||
{
|
||||
case 1:
|
||||
aV = theProps.D1();
|
||||
break;
|
||||
case 2:
|
||||
aV = theProps.D2();
|
||||
break;
|
||||
case 3:
|
||||
aV = theProps.D3();
|
||||
break;
|
||||
}
|
||||
if (aV.SquareMagnitude() > aTolSq)
|
||||
{
|
||||
theSigOrder = anOrder;
|
||||
theTanStatus = LProp_Defined;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
theTanStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Tangent: checks IsTangentDefined, then computes tangent direction.
|
||||
//! @param[in,out] theProps CLProps object
|
||||
//! @param[in,out] theCurve curve object
|
||||
//! @param[in] theU current parameter
|
||||
//! @param[in] theDerivArr derivative array
|
||||
//! @param[in] theRefPnt reference point (for type deduction)
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[out] theDir computed tangent direction
|
||||
template <typename Access, typename Props, typename Curve, typename Vec, typename Pnt, typename Dir>
|
||||
void Tangent(Props& theProps,
|
||||
Curve& theCurve,
|
||||
double theU,
|
||||
const Vec* theDerivArr,
|
||||
const Pnt& theRefPnt,
|
||||
const int& theSigOrder,
|
||||
Dir& theDir)
|
||||
{
|
||||
if (!theProps.IsTangentDefined())
|
||||
throw LProp_NotDefined();
|
||||
ComputeTangent<Access>(theCurve, theU, theDerivArr, theRefPnt, theSigOrder, theDir);
|
||||
}
|
||||
|
||||
//! Curvature: checks IsTangentDefined, returns RealLast if higher-order, else computes.
|
||||
//! @param[in,out] theProps CLProps object
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[out] theCurvature curvature value field
|
||||
//! @return computed curvature
|
||||
template <typename Props, typename Vec>
|
||||
double Curvature(Props& theProps,
|
||||
const Vec& theD1,
|
||||
const Vec& theD2,
|
||||
double theLinTol,
|
||||
const int& theSigOrder,
|
||||
double& theCurvature)
|
||||
{
|
||||
const bool anIsDefined = theProps.IsTangentDefined();
|
||||
(void)anIsDefined;
|
||||
LProp_NotDefined_Raise_if(!anIsDefined, "CLProps::Curvature()");
|
||||
if (theSigOrder > 1)
|
||||
return RealLast();
|
||||
theCurvature = ComputeCurvature(theD1, theD2, theLinTol * theLinTol);
|
||||
return theCurvature;
|
||||
}
|
||||
|
||||
//! Normal: checks curvature, then computes normal direction.
|
||||
//! @param[in,out] theProps CLProps object
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theDir computed normal direction
|
||||
template <typename Props, typename Vec, typename Dir>
|
||||
void Normal(Props& theProps, const Vec& theD1, const Vec& theD2, double theLinTol, Dir& theDir)
|
||||
{
|
||||
const double aCurvature = theProps.Curvature();
|
||||
if (aCurvature == RealLast() || std::abs(aCurvature) <= theLinTol)
|
||||
throw LProp_NotDefined("CLProps::Normal(): Curvature is null or infinity");
|
||||
ComputeNormal(theD1, theD2, theDir);
|
||||
}
|
||||
|
||||
//! CentreOfCurvature: checks curvature, then computes centre.
|
||||
//! @param[in,out] theProps CLProps object
|
||||
//! @param[in] thePnt current point
|
||||
//! @param[in] theD1 first derivative
|
||||
//! @param[in] theD2 second derivative
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[in,out] theCurvature curvature value field
|
||||
//! @param[out] theCentre computed centre of curvature
|
||||
template <typename Props, typename Vec, typename Pnt>
|
||||
void CentreOfCurvature(Props& theProps,
|
||||
const Pnt& thePnt,
|
||||
const Vec& theD1,
|
||||
const Vec& theD2,
|
||||
double theLinTol,
|
||||
double& theCurvature,
|
||||
Pnt& theCentre)
|
||||
{
|
||||
if (std::abs(theProps.Curvature()) <= theLinTol)
|
||||
throw LProp_NotDefined();
|
||||
ComputeCentreOfCurvature(thePnt, theD1, theD2, theCurvature, theCentre);
|
||||
}
|
||||
|
||||
} // namespace LProp_CurveUtils
|
||||
|
||||
#endif // _LProp_CurveUtils_HeaderFile
|
||||
@@ -1,542 +0,0 @@
|
||||
// Copyright (c) 1995-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 <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 <gp_Vec.hxx>
|
||||
#include <NCollection_Array2.hxx>
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
|
||||
static const double MinStep = 1.0e-7;
|
||||
|
||||
static bool IsTangentDefined(LProp_SLProps& SProp,
|
||||
const int cn,
|
||||
const double linTol,
|
||||
const int Derivative,
|
||||
int& Order,
|
||||
LProp_Status& theStatus)
|
||||
{
|
||||
double 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;
|
||||
} // switch(Order)
|
||||
|
||||
if (V[Derivative].SquareMagnitude() > Tol)
|
||||
{
|
||||
theStatus = LProp_Defined;
|
||||
return true;
|
||||
}
|
||||
} // if(cn >= Order)
|
||||
else
|
||||
{
|
||||
theStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
LProp_SLProps::LProp_SLProps(const Surface& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myDerOrder(N),
|
||||
myCN(4), // (Tool::Continuity(S)),
|
||||
myLinTol(Resolution)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps()");
|
||||
|
||||
SetParameters(U, V);
|
||||
}
|
||||
|
||||
LProp_SLProps::LProp_SLProps(const Surface& S, const int N, const double Resolution)
|
||||
: mySurf(S),
|
||||
myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4), // (Tool::Continuity(S))
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps()");
|
||||
}
|
||||
|
||||
LProp_SLProps::LProp_SLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp_SLProps::LProp_SLProps() bad level");
|
||||
}
|
||||
|
||||
void LProp_SLProps::SetSurface(const Surface& S)
|
||||
{
|
||||
mySurf = S;
|
||||
myCN = 4; // =Tool::Continuity(S);
|
||||
}
|
||||
|
||||
void LProp_SLProps::SetParameters(const double U, const double V)
|
||||
{
|
||||
myU = U;
|
||||
myV = V;
|
||||
switch (myDerOrder)
|
||||
{
|
||||
case 0:
|
||||
Tool::Value(mySurf, myU, myV, myPnt);
|
||||
break;
|
||||
case 1:
|
||||
Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
|
||||
break;
|
||||
case 2:
|
||||
Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
|
||||
break;
|
||||
}
|
||||
|
||||
myUTangentStatus = LProp_Undecided;
|
||||
myVTangentStatus = LProp_Undecided;
|
||||
myNormalStatus = LProp_Undecided;
|
||||
myCurvatureStatus = LProp_Undecided;
|
||||
}
|
||||
|
||||
const gp_Pnt& LProp_SLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
const gp_Vec& LProp_SLProps::D1U()
|
||||
{
|
||||
if (myDerOrder < 1)
|
||||
{
|
||||
myDerOrder = 1;
|
||||
Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
|
||||
}
|
||||
|
||||
return myD1u;
|
||||
}
|
||||
|
||||
const gp_Vec& LProp_SLProps::D1V()
|
||||
{
|
||||
if (myDerOrder < 1)
|
||||
{
|
||||
myDerOrder = 1;
|
||||
Tool::D1(mySurf, myU, myV, myPnt, myD1u, myD1v);
|
||||
}
|
||||
|
||||
return myD1v;
|
||||
}
|
||||
|
||||
const gp_Vec& LProp_SLProps::D2U()
|
||||
{
|
||||
if (myDerOrder < 2)
|
||||
{
|
||||
myDerOrder = 2;
|
||||
Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
|
||||
}
|
||||
|
||||
return myD2u;
|
||||
}
|
||||
|
||||
const gp_Vec& LProp_SLProps::D2V()
|
||||
{
|
||||
if (myDerOrder < 2)
|
||||
{
|
||||
myDerOrder = 2;
|
||||
Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
|
||||
}
|
||||
|
||||
return myD2v;
|
||||
}
|
||||
|
||||
const gp_Vec& LProp_SLProps::DUV()
|
||||
{
|
||||
if (myDerOrder < 2)
|
||||
{
|
||||
myDerOrder = 2;
|
||||
Tool::D2(mySurf, myU, myV, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv);
|
||||
}
|
||||
|
||||
return myDuv;
|
||||
}
|
||||
|
||||
bool LProp_SLProps::IsTangentUDefined()
|
||||
{
|
||||
if (myUTangentStatus == LProp_Undefined)
|
||||
return false;
|
||||
else if (myUTangentStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
// uTangentStatus == Lprop_Undecided
|
||||
// we have to calculate the first non null U derivative
|
||||
return IsTangentDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
0,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
myUTangentStatus);
|
||||
}
|
||||
|
||||
void LProp_SLProps::TangentU(gp_Dir& D)
|
||||
{
|
||||
if (!IsTangentUDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
if (mySignificantFirstDerivativeOrderU == 1)
|
||||
D = gp_Dir(myD1u);
|
||||
else
|
||||
{
|
||||
const double DivisionFactor = 1.e-3;
|
||||
double anUsupremum, anUinfium;
|
||||
double anVsupremum, anVinfium;
|
||||
Tool::Bounds(mySurf, anUinfium, anVinfium, anUsupremum, anVsupremum);
|
||||
double du;
|
||||
if ((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
|
||||
du = 0.0;
|
||||
else
|
||||
du = anUsupremum - anUinfium;
|
||||
|
||||
const double aDeltaU = std::max(du * DivisionFactor, MinStep);
|
||||
|
||||
gp_Vec V = myD2u;
|
||||
|
||||
double u;
|
||||
|
||||
if (myU - anUinfium < aDeltaU)
|
||||
u = myU + aDeltaU;
|
||||
else
|
||||
u = myU - aDeltaU;
|
||||
|
||||
gp_Pnt P1, P2;
|
||||
Tool::Value(mySurf, std::min(myU, u), myV, P1);
|
||||
Tool::Value(mySurf, std::max(myU, u), myV, P2);
|
||||
|
||||
gp_Vec V1(P1, P2);
|
||||
double aDirFactor = V.Dot(V1);
|
||||
|
||||
if (aDirFactor < 0.0)
|
||||
V = -V;
|
||||
|
||||
D = gp_Dir(V);
|
||||
}
|
||||
}
|
||||
|
||||
bool LProp_SLProps::IsTangentVDefined()
|
||||
{
|
||||
if (myVTangentStatus == LProp_Undefined)
|
||||
return false;
|
||||
else if (myVTangentStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
// vTangentStatus == Lprop_Undecided
|
||||
// we have to calculate the first non null V derivative
|
||||
return IsTangentDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
1,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
myVTangentStatus);
|
||||
}
|
||||
|
||||
void LProp_SLProps::TangentV(gp_Dir& D)
|
||||
{
|
||||
if (!IsTangentVDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
if (mySignificantFirstDerivativeOrderV == 1)
|
||||
D = gp_Dir(myD1v);
|
||||
else
|
||||
{
|
||||
const double DivisionFactor = 1.e-3;
|
||||
double anUsupremum, anUinfium;
|
||||
double anVsupremum, anVinfium;
|
||||
Tool::Bounds(mySurf, anUinfium, anVinfium, anUsupremum, anVsupremum);
|
||||
|
||||
double dv;
|
||||
if ((anVsupremum >= RealLast()) || (anVinfium <= RealFirst()))
|
||||
dv = 0.0;
|
||||
else
|
||||
dv = anVsupremum - anVinfium;
|
||||
|
||||
const double aDeltaV = std::max(dv * DivisionFactor, MinStep);
|
||||
|
||||
gp_Vec V = myD2v;
|
||||
|
||||
double v;
|
||||
|
||||
if (myV - anVinfium < aDeltaV)
|
||||
v = myV + aDeltaV;
|
||||
else
|
||||
v = myV - aDeltaV;
|
||||
|
||||
gp_Pnt P1, P2;
|
||||
Tool::Value(mySurf, myU, std::min(myV, v), P1);
|
||||
Tool::Value(mySurf, myU, std::max(myV, v), P2);
|
||||
|
||||
gp_Vec V1(P1, P2);
|
||||
double aDirFactor = V.Dot(V1);
|
||||
|
||||
if (aDirFactor < 0.0)
|
||||
V = -V;
|
||||
|
||||
D = gp_Dir(V);
|
||||
}
|
||||
}
|
||||
|
||||
bool LProp_SLProps::IsNormalDefined()
|
||||
{
|
||||
if (myNormalStatus == LProp_Undefined)
|
||||
return false;
|
||||
else if (myNormalStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
// status = UnDecided
|
||||
// first try the standard computation of the normal.
|
||||
CSLib_DerivativeStatus aStatus = CSLib_Done;
|
||||
CSLib::Normal(myD1u, myD1v, myLinTol, aStatus, myNormal);
|
||||
if (aStatus == CSLib_Done)
|
||||
{
|
||||
myNormalStatus = LProp_Computed;
|
||||
return true;
|
||||
}
|
||||
|
||||
// else solve the degenerated case only if continuity >= 2
|
||||
|
||||
myNormalStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
const gp_Dir& LProp_SLProps::Normal()
|
||||
{
|
||||
if (!IsNormalDefined())
|
||||
{
|
||||
throw LProp_NotDefined();
|
||||
}
|
||||
|
||||
return myNormal;
|
||||
}
|
||||
|
||||
bool LProp_SLProps::IsCurvatureDefined()
|
||||
{
|
||||
if (myCurvatureStatus == LProp_Undefined)
|
||||
return false;
|
||||
else if (myCurvatureStatus >= LProp_Defined)
|
||||
return true;
|
||||
|
||||
if (myCN < 2)
|
||||
{
|
||||
myCurvatureStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
// status = UnDecided
|
||||
if (!IsNormalDefined())
|
||||
{
|
||||
myCurvatureStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
// to avoid a crash in the case of a pointed patch
|
||||
// in fact we should be able to compute the curvatures
|
||||
// see
|
||||
if (!IsTangentUDefined() || !IsTangentVDefined())
|
||||
{
|
||||
myCurvatureStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
// here we compute the curvature features of the surface
|
||||
|
||||
gp_Vec Norm(myNormal);
|
||||
|
||||
double E = myD1u.SquareMagnitude();
|
||||
double F = myD1u.Dot(myD1v);
|
||||
double G = myD1v.SquareMagnitude();
|
||||
|
||||
if (myDerOrder < 2)
|
||||
this->D2U();
|
||||
|
||||
double L = Norm.Dot(myD2u);
|
||||
double M = Norm.Dot(myDuv);
|
||||
double N = Norm.Dot(myD2v);
|
||||
|
||||
double A = E * M - F * L;
|
||||
double B = E * N - G * L;
|
||||
double C = F * N - G * M;
|
||||
|
||||
double MaxABC = std::max(std::max(std::abs(A), std::abs(B)), std::abs(C));
|
||||
if (MaxABC < RealEpsilon()) // ombilic
|
||||
{
|
||||
myMinCurv = N / G;
|
||||
myMaxCurv = myMinCurv;
|
||||
myDirMinCurv = gp_Dir(myD1u);
|
||||
myDirMaxCurv = gp_Dir(myD1u.Crossed(Norm));
|
||||
myMeanCurv = myMinCurv; // (Cmin + Cmax) / 2.
|
||||
myGausCurv = myMinCurv * myMinCurv; // (Cmin * Cmax)
|
||||
myCurvatureStatus = LProp_Computed;
|
||||
return true;
|
||||
}
|
||||
|
||||
A = A / MaxABC;
|
||||
B = B / MaxABC;
|
||||
C = C / MaxABC;
|
||||
double Curv1, Curv2, Root1, Root2;
|
||||
gp_Vec VectCurv1, VectCurv2;
|
||||
|
||||
if (std::abs(A) > RealEpsilon())
|
||||
{
|
||||
math_DirectPolynomialRoots Root(A, B, C);
|
||||
if (Root.NbSolutions() != 2)
|
||||
{
|
||||
myCurvatureStatus = LProp_Undefined;
|
||||
return 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 * myD1u + myD1v;
|
||||
VectCurv2 = Root2 * myD1u + myD1v;
|
||||
}
|
||||
}
|
||||
else if (std::abs(C) > RealEpsilon())
|
||||
{
|
||||
math_DirectPolynomialRoots Root(C, B, A);
|
||||
|
||||
if ((Root.NbSolutions() != 2))
|
||||
{
|
||||
myCurvatureStatus = LProp_Undefined;
|
||||
return 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 = myD1u + Root1 * myD1v;
|
||||
VectCurv2 = myD1u + Root2 * myD1v;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Curv1 = L / E;
|
||||
Curv2 = N / G;
|
||||
VectCurv1 = myD1u;
|
||||
VectCurv2 = myD1v;
|
||||
}
|
||||
|
||||
if (Curv1 < Curv2)
|
||||
{
|
||||
myMinCurv = Curv1;
|
||||
myMaxCurv = Curv2;
|
||||
myDirMinCurv = gp_Dir(VectCurv1);
|
||||
myDirMaxCurv = gp_Dir(VectCurv2);
|
||||
}
|
||||
else
|
||||
{
|
||||
myMinCurv = Curv2;
|
||||
myMaxCurv = Curv1;
|
||||
myDirMinCurv = gp_Dir(VectCurv2);
|
||||
myDirMaxCurv = gp_Dir(VectCurv1);
|
||||
}
|
||||
|
||||
myMeanCurv = ((N * E) - (2. * M * F) + (L * G)) // voir Farin p.282
|
||||
/ (2. * ((E * G) - (F * F)));
|
||||
myGausCurv = ((L * N) - (M * M)) / ((E * G) - (F * F));
|
||||
myCurvatureStatus = LProp_Computed;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LProp_SLProps::IsUmbilic()
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
return std::abs(myMaxCurv - myMinCurv) < std::abs(Epsilon(myMaxCurv));
|
||||
}
|
||||
|
||||
double LProp_SLProps::MaxCurvature()
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
return myMaxCurv;
|
||||
}
|
||||
|
||||
double LProp_SLProps::MinCurvature()
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
return myMinCurv;
|
||||
}
|
||||
|
||||
void LProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
Max = myDirMaxCurv;
|
||||
Min = myDirMinCurv;
|
||||
}
|
||||
|
||||
double LProp_SLProps::MeanCurvature()
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
return myMeanCurv;
|
||||
}
|
||||
|
||||
double LProp_SLProps::GaussianCurvature()
|
||||
{
|
||||
if (!IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
|
||||
return myGausCurv;
|
||||
}
|
||||
823
src/ModelingData/TKG2d/LProp/LProp_SurfaceUtils.pxx
Normal file
823
src/ModelingData/TKG2d/LProp/LProp_SurfaceUtils.pxx
Normal file
@@ -0,0 +1,823 @@
|
||||
// Copyright (c) 2025 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.
|
||||
|
||||
#ifndef _LProp_SurfaceUtils_HeaderFile
|
||||
#define _LProp_SurfaceUtils_HeaderFile
|
||||
|
||||
#include <Adaptor3d_Surface.hxx>
|
||||
#include <CSLib.hxx>
|
||||
#include <CSLib_DerivativeStatus.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <LProp_Status.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <math_DirectPolynomialRoots.hxx>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//! Template utility functions for SLProps surface local property computation.
|
||||
//! Provides access policies (DirectAccess, ToolAccess), surface bounds helpers,
|
||||
//! and shared algorithms for evaluating derivatives, tangents, normals, and curvatures.
|
||||
namespace LProp_SurfaceUtils
|
||||
{
|
||||
|
||||
// ==================== Deref helpers ====================
|
||||
|
||||
//! Dereference by-value or reference types (identity).
|
||||
template <typename T>
|
||||
T& Deref(T& theObj)
|
||||
{
|
||||
return theObj;
|
||||
}
|
||||
|
||||
//! Dereference occ::handle types.
|
||||
template <typename T>
|
||||
T& Deref(occ::handle<T>& theHandle)
|
||||
{
|
||||
return *theHandle;
|
||||
}
|
||||
|
||||
//! Dereference const occ::handle types.
|
||||
template <typename T>
|
||||
const T& Deref(const occ::handle<T>& theHandle)
|
||||
{
|
||||
return *theHandle;
|
||||
}
|
||||
|
||||
// ==================== Surface Bounds Helpers ====================
|
||||
|
||||
//! Get bounds from Geom_Surface (uses Bounds method with U1, U2, V1, V2 order).
|
||||
inline void GetSurfBounds(const Geom_Surface& theSurf,
|
||||
double& theU1,
|
||||
double& theV1,
|
||||
double& theU2,
|
||||
double& theV2)
|
||||
{
|
||||
theSurf.Bounds(theU1, theU2, theV1, theV2);
|
||||
}
|
||||
|
||||
//! Get bounds from Adaptor3d_Surface (uses individual parameter methods).
|
||||
//! Also works for BRepAdaptor_Surface which inherits from Adaptor3d_Surface.
|
||||
inline void GetSurfBounds(const Adaptor3d_Surface& theSurf,
|
||||
double& theU1,
|
||||
double& theV1,
|
||||
double& theU2,
|
||||
double& theV2)
|
||||
{
|
||||
theU1 = theSurf.FirstUParameter();
|
||||
theV1 = theSurf.FirstVParameter();
|
||||
theU2 = theSurf.LastUParameter();
|
||||
theV2 = theSurf.LastVParameter();
|
||||
}
|
||||
|
||||
// ==================== Access Policies ====================
|
||||
|
||||
//! Direct access policy: calls D0/D1/D2 methods on the surface object.
|
||||
//! Works with occ::handle<T> and by-value surface types.
|
||||
struct DirectAccess
|
||||
{
|
||||
template <typename S>
|
||||
static void D0(S& theSurf, double theU, double theV, gp_Pnt& thePnt)
|
||||
{
|
||||
Deref(theSurf).D0(theU, theV, thePnt);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void D1(S& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v)
|
||||
{
|
||||
Deref(theSurf).D1(theU, theV, thePnt, theD1u, theD1v);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void D2(S& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v,
|
||||
gp_Vec& theD2u,
|
||||
gp_Vec& theD2v,
|
||||
gp_Vec& theDuv)
|
||||
{
|
||||
Deref(theSurf).D2(theU, theV, thePnt, theD1u, theD1v, theD2u, theD2v, theDuv);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void Bounds(S& theSurf, double& theU1, double& theV1, double& theU2, double& theV2)
|
||||
{
|
||||
GetSurfBounds(Deref(theSurf), theU1, theV1, theU2, theV2);
|
||||
}
|
||||
};
|
||||
|
||||
//! Tool-based access policy: delegates to static Tool methods.
|
||||
//! Used for HLRBRep types where Tool class provides the interface.
|
||||
template <typename Tool>
|
||||
struct ToolAccess
|
||||
{
|
||||
template <typename S>
|
||||
static void D0(S& theSurf, double theU, double theV, gp_Pnt& thePnt)
|
||||
{
|
||||
Tool::Value(theSurf, theU, theV, thePnt);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void D1(S& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v)
|
||||
{
|
||||
Tool::D1(theSurf, theU, theV, thePnt, theD1u, theD1v);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void D2(S& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v,
|
||||
gp_Vec& theD2u,
|
||||
gp_Vec& theD2v,
|
||||
gp_Vec& theDuv)
|
||||
{
|
||||
Tool::D2(theSurf, theU, theV, thePnt, theD1u, theD1v, theD2u, theD2v, theDuv);
|
||||
}
|
||||
|
||||
template <typename S>
|
||||
static void Bounds(S& theSurf, double& theU1, double& theV1, double& theU2, double& theV2)
|
||||
{
|
||||
Tool::Bounds(theSurf, theU1, theV1, theU2, theV2);
|
||||
}
|
||||
};
|
||||
|
||||
// ==================== Algorithm Utilities ====================
|
||||
|
||||
//! Evaluate surface derivatives at parameters (theU, theV) up to specified order.
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU U parameter value
|
||||
//! @param[in] theV V parameter value
|
||||
//! @param[in] theOrder maximum derivative order (0-2)
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theD1u first U derivative
|
||||
//! @param[out] theD1v first V derivative
|
||||
//! @param[out] theD2u second U derivative
|
||||
//! @param[out] theD2v second V derivative
|
||||
//! @param[out] theDuv mixed UV derivative
|
||||
template <typename Access, typename Surface>
|
||||
void EvalSurfDerivatives(Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
int theOrder,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v,
|
||||
gp_Vec& theD2u,
|
||||
gp_Vec& theD2v,
|
||||
gp_Vec& theDuv)
|
||||
{
|
||||
switch (theOrder)
|
||||
{
|
||||
case 0:
|
||||
Access::D0(theSurf, theU, theV, thePnt);
|
||||
break;
|
||||
case 1:
|
||||
Access::D1(theSurf, theU, theV, thePnt, theD1u, theD1v);
|
||||
break;
|
||||
case 2:
|
||||
Access::D2(theSurf, theU, theV, thePnt, theD1u, theD1v, theD2u, theD2v, theDuv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//! Check if the surface tangent is defined for a given derivative direction.
|
||||
//! Searches for the first non-null derivative in either U or V direction.
|
||||
//! @param[in] theD1 first derivative (D1U for U direction, D1V for V direction)
|
||||
//! @param[in] theD2 second derivative (D2U for U direction, D2V for V direction)
|
||||
//! @param[in] theCN continuity order
|
||||
//! @param[in] theTolSq squared linear tolerance
|
||||
//! @param[out] theOrder order of first significant derivative
|
||||
//! @param[out] theStatus resulting tangent status
|
||||
//! @return true if tangent is defined
|
||||
inline bool FindSurfTangentOrder(const gp_Vec& theD1,
|
||||
const gp_Vec& theD2,
|
||||
int theCN,
|
||||
double theTolSq,
|
||||
int& theOrder,
|
||||
LProp_Status& theStatus)
|
||||
{
|
||||
const gp_Vec* aDerivs[2] = {&theD1, &theD2};
|
||||
theOrder = 0;
|
||||
|
||||
while (theOrder < 3)
|
||||
{
|
||||
theOrder++;
|
||||
if (theCN >= theOrder)
|
||||
{
|
||||
if (theOrder <= 2 && aDerivs[theOrder - 1]->SquareMagnitude() > theTolSq)
|
||||
{
|
||||
theStatus = LProp_Defined;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Compute surface tangent direction with sign correction for higher-order derivatives.
|
||||
//! When the first significant derivative has order > 1, the sign is determined
|
||||
//! by comparing with the chord direction near the point.
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU current U parameter
|
||||
//! @param[in] theV current V parameter
|
||||
//! @param[in] theFirstDeriv first derivative in this direction (D1U or D1V)
|
||||
//! @param[in] theSecDeriv second derivative in this direction (D2U or D2V)
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[in] theIsU true for U direction, false for V direction
|
||||
//! @param[out] theDir computed tangent direction
|
||||
template <typename Access, typename Surface>
|
||||
void ComputeSurfTangent(Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
const gp_Vec& theFirstDeriv,
|
||||
const gp_Vec& theSecDeriv,
|
||||
int theSigOrder,
|
||||
bool theIsU,
|
||||
gp_Dir& theDir)
|
||||
{
|
||||
if (theSigOrder == 1)
|
||||
{
|
||||
theDir = gp_Dir(theFirstDeriv);
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr double THE_DIVISION_FACTOR = 1.0e-3;
|
||||
constexpr double THE_MIN_STEP = 1.0e-7;
|
||||
|
||||
double anUinfimum, anVinfimum, anUsupremum, anVsupremum;
|
||||
Access::Bounds(theSurf, anUinfimum, anVinfimum, anUsupremum, anVsupremum);
|
||||
|
||||
if (theIsU)
|
||||
{
|
||||
double aDu;
|
||||
if ((anUsupremum >= RealLast()) || (anUinfimum <= RealFirst()))
|
||||
aDu = 0.0;
|
||||
else
|
||||
aDu = anUsupremum - anUinfimum;
|
||||
|
||||
const double aDelta = std::max(aDu * THE_DIVISION_FACTOR, THE_MIN_STEP);
|
||||
|
||||
gp_Vec aV = theSecDeriv;
|
||||
|
||||
double anOtherU;
|
||||
if (theU - anUinfimum < aDelta)
|
||||
anOtherU = theU + aDelta;
|
||||
else
|
||||
anOtherU = theU - aDelta;
|
||||
|
||||
gp_Pnt aP1, aP2;
|
||||
Access::D0(theSurf, std::min(theU, anOtherU), theV, aP1);
|
||||
Access::D0(theSurf, std::max(theU, anOtherU), theV, aP2);
|
||||
|
||||
gp_Vec aChord(aP1, aP2);
|
||||
if (aV.Dot(aChord) < 0.0)
|
||||
aV = -aV;
|
||||
|
||||
theDir = gp_Dir(aV);
|
||||
}
|
||||
else
|
||||
{
|
||||
double aDv;
|
||||
if ((anVsupremum >= RealLast()) || (anVinfimum <= RealFirst()))
|
||||
aDv = 0.0;
|
||||
else
|
||||
aDv = anVsupremum - anVinfimum;
|
||||
|
||||
const double aDelta = std::max(aDv * THE_DIVISION_FACTOR, THE_MIN_STEP);
|
||||
|
||||
gp_Vec aV = theSecDeriv;
|
||||
|
||||
double anOtherV;
|
||||
if (theV - anVinfimum < aDelta)
|
||||
anOtherV = theV + aDelta;
|
||||
else
|
||||
anOtherV = theV - aDelta;
|
||||
|
||||
gp_Pnt aP1, aP2;
|
||||
Access::D0(theSurf, theU, std::min(theV, anOtherV), aP1);
|
||||
Access::D0(theSurf, theU, std::max(theV, anOtherV), aP2);
|
||||
|
||||
gp_Vec aChord(aP1, aP2);
|
||||
if (aV.Dot(aChord) < 0.0)
|
||||
aV = -aV;
|
||||
|
||||
theDir = gp_Dir(aV);
|
||||
}
|
||||
}
|
||||
|
||||
//! Check if surface normal is defined, and compute it via CSLib::Normal.
|
||||
//! @param[in] theD1u first U derivative
|
||||
//! @param[in] theD1v first V derivative
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theNormal computed normal direction (if defined)
|
||||
//! @return true if normal is defined
|
||||
inline bool ComputeSurfNormal(const gp_Vec& theD1u,
|
||||
const gp_Vec& theD1v,
|
||||
double theLinTol,
|
||||
gp_Dir& theNormal)
|
||||
{
|
||||
CSLib_DerivativeStatus aStatus = CSLib_Done;
|
||||
CSLib::Normal(theD1u, theD1v, theLinTol, aStatus, theNormal);
|
||||
return aStatus == CSLib_Done;
|
||||
}
|
||||
|
||||
//! Compute principal curvatures and directions via fundamental forms.
|
||||
//! Solves the eigenvalue problem for the shape operator using
|
||||
//! first and second fundamental form coefficients.
|
||||
//! @param[in] theD1u first U derivative
|
||||
//! @param[in] theD1v first V derivative
|
||||
//! @param[in] theD2u second U derivative
|
||||
//! @param[in] theD2v second V derivative
|
||||
//! @param[in] theDuv mixed UV derivative
|
||||
//! @param[in] theNormal surface normal direction
|
||||
//! @param[out] theMinCurv minimum principal curvature
|
||||
//! @param[out] theMaxCurv maximum principal curvature
|
||||
//! @param[out] theDirMin direction of minimum curvature
|
||||
//! @param[out] theDirMax direction of maximum curvature
|
||||
//! @param[out] theMeanCurv mean curvature
|
||||
//! @param[out] theGausCurv Gaussian curvature
|
||||
//! @return true if curvatures are successfully computed
|
||||
inline bool ComputeSurfCurvatures(const gp_Vec& theD1u,
|
||||
const gp_Vec& theD1v,
|
||||
const gp_Vec& theD2u,
|
||||
const gp_Vec& theD2v,
|
||||
const gp_Vec& theDuv,
|
||||
const gp_Dir& theNormal,
|
||||
double& theMinCurv,
|
||||
double& theMaxCurv,
|
||||
gp_Dir& theDirMin,
|
||||
gp_Dir& theDirMax,
|
||||
double& theMeanCurv,
|
||||
double& theGausCurv)
|
||||
{
|
||||
const gp_Vec aNorm(theNormal);
|
||||
|
||||
const double anE = theD1u.SquareMagnitude();
|
||||
const double anF = theD1u.Dot(theD1v);
|
||||
const double aG = theD1v.SquareMagnitude();
|
||||
|
||||
const double aL = aNorm.Dot(theD2u);
|
||||
const double aM = aNorm.Dot(theDuv);
|
||||
const double aN = aNorm.Dot(theD2v);
|
||||
|
||||
const double anA0 = anE * aM - anF * aL;
|
||||
const double aB0 = anE * aN - aG * aL;
|
||||
const double aC0 = anF * aN - aG * aM;
|
||||
|
||||
const double aMaxABC = std::max(std::max(std::abs(anA0), std::abs(aB0)), std::abs(aC0));
|
||||
if (aMaxABC < RealEpsilon())
|
||||
{
|
||||
// Umbilic point
|
||||
theMinCurv = aN / aG;
|
||||
theMaxCurv = theMinCurv;
|
||||
theDirMin = gp_Dir(theD1u);
|
||||
theDirMax = gp_Dir(theD1u.Crossed(aNorm));
|
||||
theMeanCurv = theMinCurv;
|
||||
theGausCurv = theMinCurv * theMinCurv;
|
||||
return true;
|
||||
}
|
||||
|
||||
const double anA = anA0 / aMaxABC;
|
||||
const double aB = aB0 / aMaxABC;
|
||||
const double aC = aC0 / aMaxABC;
|
||||
|
||||
double aCurv1, aCurv2;
|
||||
gp_Vec aVectCurv1, aVectCurv2;
|
||||
|
||||
if (std::abs(anA) > RealEpsilon())
|
||||
{
|
||||
math_DirectPolynomialRoots aRoot(anA, aB, aC);
|
||||
if (aRoot.NbSolutions() != 2)
|
||||
return false;
|
||||
|
||||
const double aRoot1 = aRoot.Value(1);
|
||||
const double aRoot2 = aRoot.Value(2);
|
||||
aCurv1 = ((aL * aRoot1 + 2.0 * aM) * aRoot1 + aN) / ((anE * aRoot1 + 2.0 * anF) * aRoot1 + aG);
|
||||
aCurv2 = ((aL * aRoot2 + 2.0 * aM) * aRoot2 + aN) / ((anE * aRoot2 + 2.0 * anF) * aRoot2 + aG);
|
||||
aVectCurv1 = aRoot1 * theD1u + theD1v;
|
||||
aVectCurv2 = aRoot2 * theD1u + theD1v;
|
||||
}
|
||||
else if (std::abs(aC) > RealEpsilon())
|
||||
{
|
||||
math_DirectPolynomialRoots aRoot(aC, aB, anA);
|
||||
if (aRoot.NbSolutions() != 2)
|
||||
return false;
|
||||
|
||||
const double aRoot1 = aRoot.Value(1);
|
||||
const double aRoot2 = aRoot.Value(2);
|
||||
aCurv1 = ((aN * aRoot1 + 2.0 * aM) * aRoot1 + aL) / ((aG * aRoot1 + 2.0 * anF) * aRoot1 + anE);
|
||||
aCurv2 = ((aN * aRoot2 + 2.0 * aM) * aRoot2 + aL) / ((aG * aRoot2 + 2.0 * anF) * aRoot2 + anE);
|
||||
aVectCurv1 = theD1u + aRoot1 * theD1v;
|
||||
aVectCurv2 = theD1u + aRoot2 * theD1v;
|
||||
}
|
||||
else
|
||||
{
|
||||
aCurv1 = aL / anE;
|
||||
aCurv2 = aN / aG;
|
||||
aVectCurv1 = theD1u;
|
||||
aVectCurv2 = theD1v;
|
||||
}
|
||||
|
||||
if (aCurv1 < aCurv2)
|
||||
{
|
||||
theMinCurv = aCurv1;
|
||||
theMaxCurv = aCurv2;
|
||||
theDirMin = gp_Dir(aVectCurv1);
|
||||
theDirMax = gp_Dir(aVectCurv2);
|
||||
}
|
||||
else
|
||||
{
|
||||
theMinCurv = aCurv2;
|
||||
theMaxCurv = aCurv1;
|
||||
theDirMin = gp_Dir(aVectCurv2);
|
||||
theDirMax = gp_Dir(aVectCurv1);
|
||||
}
|
||||
|
||||
const double anEG_FF = (anE * aG) - (anF * anF);
|
||||
theMeanCurv = ((aN * anE) - (2.0 * aM * anF) + (aL * aG)) / (2.0 * anEG_FF);
|
||||
theGausCurv = ((aL * aN) - (aM * aM)) / anEG_FF;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ==================== Higher-Level Method Wrappers ====================
|
||||
|
||||
//! SetParameters: sets parameters, evaluates derivatives, resets all statuses.
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU U parameter value
|
||||
//! @param[in] theV V parameter value
|
||||
//! @param[out] theStoredU stored U parameter field
|
||||
//! @param[out] theStoredV stored V parameter field
|
||||
//! @param[in] theDerOrder current derivative order
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theD1u first U derivative
|
||||
//! @param[out] theD1v first V derivative
|
||||
//! @param[out] theD2u second U derivative
|
||||
//! @param[out] theD2v second V derivative
|
||||
//! @param[out] theDuv mixed UV derivative
|
||||
//! @param[out] theUTanSt U tangent status
|
||||
//! @param[out] theVTanSt V tangent status
|
||||
//! @param[out] theNormSt normal status
|
||||
//! @param[out] theCurvSt curvature status
|
||||
template <typename Access, typename Surface>
|
||||
void SetParameters(Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
double& theStoredU,
|
||||
double& theStoredV,
|
||||
int theDerOrder,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v,
|
||||
gp_Vec& theD2u,
|
||||
gp_Vec& theD2v,
|
||||
gp_Vec& theDuv,
|
||||
LProp_Status& theUTanSt,
|
||||
LProp_Status& theVTanSt,
|
||||
LProp_Status& theNormSt,
|
||||
LProp_Status& theCurvSt)
|
||||
{
|
||||
theStoredU = theU;
|
||||
theStoredV = theV;
|
||||
EvalSurfDerivatives<
|
||||
Access>(theSurf, theU, theV, theDerOrder, thePnt, theD1u, theD1v, theD2u, theD2v, theDuv);
|
||||
theUTanSt = LProp_Undecided;
|
||||
theVTanSt = LProp_Undecided;
|
||||
theNormSt = LProp_Undecided;
|
||||
theCurvSt = LProp_Undecided;
|
||||
}
|
||||
|
||||
//! Ensure surface derivatives up to the required order. Returns the specified result field.
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU U parameter value
|
||||
//! @param[in] theV V parameter value
|
||||
//! @param[in,out] theDerOrder current derivative order (upgraded if needed)
|
||||
//! @param[in] theRequired required derivative order
|
||||
//! @param[out] thePnt evaluated point
|
||||
//! @param[out] theD1u first U derivative
|
||||
//! @param[out] theD1v first V derivative
|
||||
//! @param[out] theD2u second U derivative
|
||||
//! @param[out] theD2v second V derivative
|
||||
//! @param[out] theDuv mixed UV derivative
|
||||
//! @param[in] theResult reference to the specific derivative field to return
|
||||
//! @return const reference to theResult
|
||||
template <typename Access, typename Surface>
|
||||
const gp_Vec& EnsureSurfDeriv(Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
int& theDerOrder,
|
||||
int theRequired,
|
||||
gp_Pnt& thePnt,
|
||||
gp_Vec& theD1u,
|
||||
gp_Vec& theD1v,
|
||||
gp_Vec& theD2u,
|
||||
gp_Vec& theD2v,
|
||||
gp_Vec& theDuv,
|
||||
const gp_Vec& theResult)
|
||||
{
|
||||
if (theDerOrder < theRequired)
|
||||
{
|
||||
theDerOrder = theRequired;
|
||||
EvalSurfDerivatives<
|
||||
Access>(theSurf, theU, theV, theDerOrder, thePnt, theD1u, theD1v, theD2u, theD2v, theDuv);
|
||||
}
|
||||
return theResult;
|
||||
}
|
||||
|
||||
//! IsTangentUDefined: checks U tangent status, then searches via D1U/D2U.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theCN continuity order
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theSigOrder order of first significant derivative
|
||||
//! @param[in,out] theTanStatus U tangent status field
|
||||
//! @return true if U tangent is defined
|
||||
template <typename Props>
|
||||
bool IsTangentUDefined(Props& theProps,
|
||||
int theCN,
|
||||
double theLinTol,
|
||||
int& theSigOrder,
|
||||
LProp_Status& theTanStatus)
|
||||
{
|
||||
if (theTanStatus == LProp_Undefined)
|
||||
return false;
|
||||
if (theTanStatus >= LProp_Defined)
|
||||
return true;
|
||||
return FindSurfTangentOrder(theProps.D1U(),
|
||||
theProps.D2U(),
|
||||
theCN,
|
||||
theLinTol * theLinTol,
|
||||
theSigOrder,
|
||||
theTanStatus);
|
||||
}
|
||||
|
||||
//! IsTangentVDefined: checks V tangent status, then searches via D1V/D2V.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theCN continuity order
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theSigOrder order of first significant derivative
|
||||
//! @param[in,out] theTanStatus V tangent status field
|
||||
//! @return true if V tangent is defined
|
||||
template <typename Props>
|
||||
bool IsTangentVDefined(Props& theProps,
|
||||
int theCN,
|
||||
double theLinTol,
|
||||
int& theSigOrder,
|
||||
LProp_Status& theTanStatus)
|
||||
{
|
||||
if (theTanStatus == LProp_Undefined)
|
||||
return false;
|
||||
if (theTanStatus >= LProp_Defined)
|
||||
return true;
|
||||
return FindSurfTangentOrder(theProps.D1V(),
|
||||
theProps.D2V(),
|
||||
theCN,
|
||||
theLinTol * theLinTol,
|
||||
theSigOrder,
|
||||
theTanStatus);
|
||||
}
|
||||
|
||||
//! TangentU: checks IsTangentUDefined, then computes U tangent direction.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU current U parameter
|
||||
//! @param[in] theV current V parameter
|
||||
//! @param[in] theD1u first U derivative
|
||||
//! @param[in] theD2u second U derivative
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[out] theDir computed tangent direction
|
||||
template <typename Access, typename Props, typename Surface>
|
||||
void TangentU(Props& theProps,
|
||||
Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
const gp_Vec& theD1u,
|
||||
const gp_Vec& theD2u,
|
||||
int theSigOrder,
|
||||
gp_Dir& theDir)
|
||||
{
|
||||
if (!theProps.IsTangentUDefined())
|
||||
throw LProp_NotDefined();
|
||||
ComputeSurfTangent<Access>(theSurf, theU, theV, theD1u, theD2u, theSigOrder, true, theDir);
|
||||
}
|
||||
|
||||
//! TangentV: checks IsTangentVDefined, then computes V tangent direction.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in,out] theSurf surface object
|
||||
//! @param[in] theU current U parameter
|
||||
//! @param[in] theV current V parameter
|
||||
//! @param[in] theD1v first V derivative
|
||||
//! @param[in] theD2v second V derivative
|
||||
//! @param[in] theSigOrder order of first significant derivative
|
||||
//! @param[out] theDir computed tangent direction
|
||||
template <typename Access, typename Props, typename Surface>
|
||||
void TangentV(Props& theProps,
|
||||
Surface& theSurf,
|
||||
double theU,
|
||||
double theV,
|
||||
const gp_Vec& theD1v,
|
||||
const gp_Vec& theD2v,
|
||||
int theSigOrder,
|
||||
gp_Dir& theDir)
|
||||
{
|
||||
if (!theProps.IsTangentVDefined())
|
||||
throw LProp_NotDefined();
|
||||
ComputeSurfTangent<Access>(theSurf, theU, theV, theD1v, theD2v, theSigOrder, false, theDir);
|
||||
}
|
||||
|
||||
//! IsNormalDefined: checks normal status, then computes via CSLib.
|
||||
//! @param[in] theD1u first U derivative
|
||||
//! @param[in] theD1v first V derivative
|
||||
//! @param[in] theLinTol linear tolerance
|
||||
//! @param[out] theNormal computed normal direction
|
||||
//! @param[in,out] theNormStatus normal status field
|
||||
//! @return true if normal is defined
|
||||
inline bool IsNormalDefined(const gp_Vec& theD1u,
|
||||
const gp_Vec& theD1v,
|
||||
double theLinTol,
|
||||
gp_Dir& theNormal,
|
||||
LProp_Status& theNormStatus)
|
||||
{
|
||||
if (theNormStatus == LProp_Undefined)
|
||||
return false;
|
||||
if (theNormStatus >= LProp_Defined)
|
||||
return true;
|
||||
if (ComputeSurfNormal(theD1u, theD1v, theLinTol, theNormal))
|
||||
{
|
||||
theNormStatus = LProp_Computed;
|
||||
return true;
|
||||
}
|
||||
theNormStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Normal: checks IsNormalDefined (via theProps), then returns normal.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theNormal normal direction field
|
||||
//! @return const reference to theNormal
|
||||
template <typename Props>
|
||||
const gp_Dir& Normal(Props& theProps, const gp_Dir& theNormal)
|
||||
{
|
||||
if (!theProps.IsNormalDefined())
|
||||
throw LProp_NotDefined();
|
||||
return theNormal;
|
||||
}
|
||||
|
||||
//! IsCurvatureDefined: full check including continuity, normal, tangents, and curvature
|
||||
//! computation.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theCN continuity order
|
||||
//! @param[in,out] theDerOrder current derivative order
|
||||
//! @param[in] theD1u first U derivative
|
||||
//! @param[in] theD1v first V derivative
|
||||
//! @param[in] theD2u second U derivative
|
||||
//! @param[in] theD2v second V derivative
|
||||
//! @param[in] theDuv mixed UV derivative
|
||||
//! @param[in] theNormal surface normal
|
||||
//! @param[out] theMinCurv minimum principal curvature
|
||||
//! @param[out] theMaxCurv maximum principal curvature
|
||||
//! @param[out] theDirMin direction of minimum curvature
|
||||
//! @param[out] theDirMax direction of maximum curvature
|
||||
//! @param[out] theMeanCurv mean curvature
|
||||
//! @param[out] theGausCurv Gaussian curvature
|
||||
//! @param[in,out] theCurvStatus curvature status field
|
||||
//! @return true if curvature is defined
|
||||
template <typename Props>
|
||||
bool IsCurvatureDefined(Props& theProps,
|
||||
int theCN,
|
||||
int& theDerOrder,
|
||||
const gp_Vec& theD1u,
|
||||
const gp_Vec& theD1v,
|
||||
const gp_Vec& theD2u,
|
||||
const gp_Vec& theD2v,
|
||||
const gp_Vec& theDuv,
|
||||
const gp_Dir& theNormal,
|
||||
double& theMinCurv,
|
||||
double& theMaxCurv,
|
||||
gp_Dir& theDirMin,
|
||||
gp_Dir& theDirMax,
|
||||
double& theMeanCurv,
|
||||
double& theGausCurv,
|
||||
LProp_Status& theCurvStatus)
|
||||
{
|
||||
if (theCurvStatus == LProp_Undefined)
|
||||
return false;
|
||||
if (theCurvStatus >= LProp_Defined)
|
||||
return true;
|
||||
if (theCN < 2)
|
||||
{
|
||||
theCurvStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
if (!theProps.IsNormalDefined())
|
||||
{
|
||||
theCurvStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
if (!theProps.IsTangentUDefined() || !theProps.IsTangentVDefined())
|
||||
{
|
||||
theCurvStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
if (theDerOrder < 2)
|
||||
theProps.D2U();
|
||||
if (ComputeSurfCurvatures(theD1u,
|
||||
theD1v,
|
||||
theD2u,
|
||||
theD2v,
|
||||
theDuv,
|
||||
theNormal,
|
||||
theMinCurv,
|
||||
theMaxCurv,
|
||||
theDirMin,
|
||||
theDirMax,
|
||||
theMeanCurv,
|
||||
theGausCurv))
|
||||
{
|
||||
theCurvStatus = LProp_Computed;
|
||||
return true;
|
||||
}
|
||||
theCurvStatus = LProp_Undefined;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Require curvature to be defined, throw if not. Returns the given value.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theValue curvature value to return
|
||||
//! @return theValue if curvature is defined
|
||||
template <typename Props>
|
||||
double RequireCurvature(Props& theProps, double theValue)
|
||||
{
|
||||
if (!theProps.IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
return theValue;
|
||||
}
|
||||
|
||||
//! IsUmbilic: checks curvature, then compares min/max.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theMaxCurv maximum curvature value
|
||||
//! @param[in] theMinCurv minimum curvature value
|
||||
//! @return true if the point is umbilic
|
||||
template <typename Props>
|
||||
bool IsUmbilic(Props& theProps, double theMaxCurv, double theMinCurv)
|
||||
{
|
||||
if (!theProps.IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
return std::abs(theMaxCurv - theMinCurv) < std::abs(Epsilon(theMaxCurv));
|
||||
}
|
||||
|
||||
//! CurvatureDirections: checks curvature, then returns max/min directions.
|
||||
//! @param[in,out] theProps SLProps object
|
||||
//! @param[in] theDirMax direction of maximum curvature field
|
||||
//! @param[in] theDirMin direction of minimum curvature field
|
||||
//! @param[out] theMax output maximum curvature direction
|
||||
//! @param[out] theMin output minimum curvature direction
|
||||
template <typename Props>
|
||||
void CurvatureDirections(Props& theProps,
|
||||
const gp_Dir& theDirMax,
|
||||
const gp_Dir& theDirMin,
|
||||
gp_Dir& theMax,
|
||||
gp_Dir& theMin)
|
||||
{
|
||||
if (!theProps.IsCurvatureDefined())
|
||||
throw LProp_NotDefined();
|
||||
theMax = theDirMax;
|
||||
theMin = theDirMin;
|
||||
}
|
||||
|
||||
} // namespace LProp_SurfaceUtils
|
||||
|
||||
#endif // _LProp_SurfaceUtils_HeaderFile
|
||||
@@ -5,11 +5,7 @@ set(OCCT_GeomLProp_FILES
|
||||
GeomLProp.cxx
|
||||
GeomLProp.hxx
|
||||
GeomLProp_CLProps.hxx
|
||||
GeomLProp_CLProps_0.cxx
|
||||
GeomLProp_CurveTool.cxx
|
||||
GeomLProp_CurveTool.hxx
|
||||
GeomLProp_CLProps.cxx
|
||||
GeomLProp_SLProps.hxx
|
||||
GeomLProp_SLProps_0.cxx
|
||||
GeomLProp_SurfaceTool.cxx
|
||||
GeomLProp_SurfaceTool.hxx
|
||||
GeomLProp_SLProps.cxx
|
||||
)
|
||||
|
||||
173
src/ModelingData/TKG3d/GeomLProp/GeomLProp_CLProps.cxx
Normal file
173
src/ModelingData/TKG3d/GeomLProp/GeomLProp_CLProps.cxx
Normal file
@@ -0,0 +1,173 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <GeomLProp_CLProps.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_CurveUtils.pxx>
|
||||
|
||||
using Access = LProp_CurveUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_CLProps::GeomLProp_CLProps(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "GeomLProp_CLProps::GeomLProp_CLProps()");
|
||||
SetParameter(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_CLProps::GeomLProp_CLProps(const occ::handle<Geom_Curve>& C,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "GeomLProp_CLProps::GeomLProp_CLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_CLProps::GeomLProp_CLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "GeomLProp_CLProps() - invalid input");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_CLProps::SetParameter(const double U)
|
||||
{
|
||||
LProp_CurveUtils::SetParameter<Access>(myCurve,
|
||||
U,
|
||||
myU,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myDerivArr,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_CLProps::SetCurve(const occ::handle<Geom_Curve>& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& GeomLProp_CLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_CLProps::D1()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 1, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_CLProps::D2()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 2, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_CLProps::D3()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 3, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_CLProps::IsTangentDefined()
|
||||
{
|
||||
return LProp_CurveUtils::IsTangentDefined<gp_Vec>(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_CLProps::Tangent(gp_Dir& D)
|
||||
{
|
||||
LProp_CurveUtils::Tangent<Access>(*this,
|
||||
myCurve,
|
||||
myU,
|
||||
myDerivArr,
|
||||
myPnt,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double GeomLProp_CLProps::Curvature()
|
||||
{
|
||||
return LProp_CurveUtils::Curvature(*this,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myCurvature);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_CLProps::Normal(gp_Dir& N)
|
||||
{
|
||||
LProp_CurveUtils::Normal(*this, myDerivArr[0], myDerivArr[1], myLinTol, N);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_CLProps::CentreOfCurvature(gp_Pnt& P)
|
||||
{
|
||||
LProp_CurveUtils::CentreOfCurvature(*this,
|
||||
myPnt,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
myCurvature,
|
||||
P);
|
||||
}
|
||||
@@ -36,7 +36,6 @@ class LProp_NotDefined;
|
||||
class gp_Vec;
|
||||
class gp_Pnt;
|
||||
class gp_Dir;
|
||||
class GeomLProp_CurveTool;
|
||||
|
||||
class GeomLProp_CLProps
|
||||
{
|
||||
@@ -116,14 +115,14 @@ private:
|
||||
occ::handle<Geom_Curve> myCurve;
|
||||
double myU;
|
||||
int myDerOrder;
|
||||
double myCN;
|
||||
int myCN;
|
||||
double myLinTol;
|
||||
gp_Pnt myPnt;
|
||||
gp_Vec myDerivArr[3];
|
||||
gp_Dir myTangent;
|
||||
double myCurvature;
|
||||
double myCurvature = 0.0;
|
||||
LProp_Status myTangentStatus;
|
||||
int mySignificantFirstDerivativeOrder;
|
||||
int mySignificantFirstDerivativeOrder = 0;
|
||||
};
|
||||
|
||||
#endif // _GeomLProp_CLProps_HeaderFile
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <GeomLProp_CLProps.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <GeomLProp_CurveTool.hxx>
|
||||
|
||||
#define Curve occ::handle<Geom_Curve>
|
||||
#define Curve_hxx <Geom_Curve.hxx>
|
||||
#define Vec gp_Vec
|
||||
#define Vec_hxx <gp_Vec.hxx>
|
||||
#define Pnt gp_Pnt
|
||||
#define Pnt_hxx <gp_Pnt.hxx>
|
||||
#define Dir gp_Dir
|
||||
#define Dir_hxx <gp_Dir.hxx>
|
||||
#define Tool GeomLProp_CurveTool
|
||||
#define Tool_hxx <GeomLProp_CurveTool.hxx>
|
||||
#define LProp_CLProps GeomLProp_CLProps
|
||||
#define LProp_CLProps_hxx <GeomLProp_CLProps.hxx>
|
||||
#include <LProp_CLProps.gxx>
|
||||
@@ -1,86 +0,0 @@
|
||||
// Created on: 1992-08-18
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <Geom_Curve.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <GeomLProp_CurveTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
void GeomLProp_CurveTool::Value(const occ::handle<Geom_Curve>& C, const double U, gp_Pnt& P)
|
||||
{
|
||||
P = C->Value(U);
|
||||
}
|
||||
|
||||
void GeomLProp_CurveTool::D1(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1)
|
||||
{
|
||||
C->D1(U, P, V1);
|
||||
}
|
||||
|
||||
void GeomLProp_CurveTool::D2(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2)
|
||||
{
|
||||
C->D2(U, P, V1, V2);
|
||||
}
|
||||
|
||||
void GeomLProp_CurveTool::D3(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3)
|
||||
{
|
||||
C->D3(U, P, V1, V2, V3);
|
||||
}
|
||||
|
||||
int GeomLProp_CurveTool::Continuity(const occ::handle<Geom_Curve>& C)
|
||||
{
|
||||
GeomAbs_Shape s = C->Continuity();
|
||||
switch (s)
|
||||
{
|
||||
case GeomAbs_C0:
|
||||
return 0;
|
||||
case GeomAbs_C1:
|
||||
return 1;
|
||||
case GeomAbs_C2:
|
||||
return 2;
|
||||
case GeomAbs_C3:
|
||||
return 3;
|
||||
case GeomAbs_G1:
|
||||
return 0;
|
||||
case GeomAbs_G2:
|
||||
return 0;
|
||||
case GeomAbs_CN:
|
||||
return 3;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
double GeomLProp_CurveTool::FirstParameter(const occ::handle<Geom_Curve>& C)
|
||||
{
|
||||
return C->FirstParameter();
|
||||
}
|
||||
|
||||
double GeomLProp_CurveTool::LastParameter(const occ::handle<Geom_Curve>& C)
|
||||
{
|
||||
return C->LastParameter();
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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.
|
||||
|
||||
#ifndef _GeomLProp_CurveTool_HeaderFile
|
||||
#define _GeomLProp_CurveTool_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
class Geom_Curve;
|
||||
class gp_Pnt;
|
||||
class gp_Vec;
|
||||
|
||||
class GeomLProp_CurveTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Computes the point <P> of parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void Value(const occ::handle<Geom_Curve>& C, const double U, gp_Pnt& P);
|
||||
|
||||
//! Computes the point <P> and first derivative <V1> of
|
||||
//! parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D1(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1> and second
|
||||
//! derivative <V2> of parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D2(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1>, the
|
||||
//! second derivative <V2> and third derivative <V3> of
|
||||
//! parameter <U> on the curve <C>.
|
||||
Standard_EXPORT static void D3(const occ::handle<Geom_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3);
|
||||
|
||||
//! 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.
|
||||
Standard_EXPORT static int Continuity(const occ::handle<Geom_Curve>& C);
|
||||
|
||||
//! returns the first parameter bound of the curve.
|
||||
Standard_EXPORT static double FirstParameter(const occ::handle<Geom_Curve>& C);
|
||||
|
||||
//! returns the last parameter bound of the curve.
|
||||
//! FirstParameter must be less than LastParamenter.
|
||||
Standard_EXPORT static double LastParameter(const occ::handle<Geom_Curve>& C);
|
||||
};
|
||||
|
||||
#endif // _GeomLProp_CurveTool_HeaderFile
|
||||
281
src/ModelingData/TKG3d/GeomLProp/GeomLProp_SLProps.cxx
Normal file
281
src/ModelingData/TKG3d/GeomLProp/GeomLProp_SLProps.cxx
Normal file
@@ -0,0 +1,281 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <GeomLProp_SLProps.hxx>
|
||||
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_SurfaceUtils.pxx>
|
||||
|
||||
using Access = LProp_SurfaceUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_SLProps::GeomLProp_SLProps(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "GeomLProp_SLProps::GeomLProp_SLProps()");
|
||||
SetParameters(U, V);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_SLProps::GeomLProp_SLProps(const occ::handle<Geom_Surface>& S,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "GeomLProp_SLProps::GeomLProp_SLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
GeomLProp_SLProps::GeomLProp_SLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "GeomLProp_SLProps::GeomLProp_SLProps() bad level");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_SLProps::SetSurface(const occ::handle<Geom_Surface>& S)
|
||||
{
|
||||
mySurf = S;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_SLProps::SetParameters(const double U, const double V)
|
||||
{
|
||||
LProp_SurfaceUtils::SetParameters<Access>(mySurf,
|
||||
U,
|
||||
V,
|
||||
myU,
|
||||
myV,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myUTangentStatus,
|
||||
myVTangentStatus,
|
||||
myNormalStatus,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& GeomLProp_SLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_SLProps::D1U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_SLProps::D1V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_SLProps::D2U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_SLProps::D2V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& GeomLProp_SLProps::DUV()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myDuv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_SLProps::IsTangentUDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentUDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
myUTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_SLProps::TangentU(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentU<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1u,
|
||||
myD2u,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_SLProps::IsTangentVDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentVDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
myVTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_SLProps::TangentV(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentV<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1v,
|
||||
myD2v,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_SLProps::IsNormalDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsNormalDefined(myD1u, myD1v, myLinTol, myNormal, myNormalStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Dir& GeomLProp_SLProps::Normal()
|
||||
{
|
||||
return LProp_SurfaceUtils::Normal(*this, myNormal);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_SLProps::IsCurvatureDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsCurvatureDefined(*this,
|
||||
myCN,
|
||||
myDerOrder,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myNormal,
|
||||
myMinCurv,
|
||||
myMaxCurv,
|
||||
myDirMinCurv,
|
||||
myDirMaxCurv,
|
||||
myMeanCurv,
|
||||
myGausCurv,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool GeomLProp_SLProps::IsUmbilic()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsUmbilic(*this, myMaxCurv, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double GeomLProp_SLProps::MaxCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMaxCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double GeomLProp_SLProps::MinCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void GeomLProp_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
|
||||
{
|
||||
LProp_SurfaceUtils::CurvatureDirections(*this, myDirMaxCurv, myDirMinCurv, Max, Min);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double GeomLProp_SLProps::MeanCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMeanCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double GeomLProp_SLProps::GaussianCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myGausCurv);
|
||||
}
|
||||
@@ -31,7 +31,6 @@ class LProp_BadContinuity;
|
||||
class Standard_DomainError;
|
||||
class Standard_OutOfRange;
|
||||
class LProp_NotDefined;
|
||||
class GeomLProp_SurfaceTool;
|
||||
class gp_Pnt;
|
||||
class gp_Vec;
|
||||
class gp_Dir;
|
||||
@@ -158,14 +157,14 @@ private:
|
||||
gp_Vec myD2v;
|
||||
gp_Vec myDuv;
|
||||
gp_Dir myNormal;
|
||||
double myMinCurv;
|
||||
double myMaxCurv;
|
||||
double myMinCurv = 0.0;
|
||||
double myMaxCurv = 0.0;
|
||||
gp_Dir myDirMinCurv;
|
||||
gp_Dir myDirMaxCurv;
|
||||
double myMeanCurv;
|
||||
double myGausCurv;
|
||||
int mySignificantFirstDerivativeOrderU;
|
||||
int mySignificantFirstDerivativeOrderV;
|
||||
double myMeanCurv = 0.0;
|
||||
double myGausCurv = 0.0;
|
||||
int mySignificantFirstDerivativeOrderU = 0;
|
||||
int mySignificantFirstDerivativeOrderV = 0;
|
||||
LProp_Status myUTangentStatus;
|
||||
LProp_Status myVTangentStatus;
|
||||
LProp_Status myNormalStatus;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <GeomLProp_SLProps.hxx>
|
||||
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <GeomLProp_SurfaceTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
#define Surface occ::handle<Geom_Surface>
|
||||
#define Surface_hxx <Geom_Surface.hxx>
|
||||
#define Tool GeomLProp_SurfaceTool
|
||||
#define Tool_hxx <GeomLProp_SurfaceTool.hxx>
|
||||
#define LProp_SLProps GeomLProp_SLProps
|
||||
#define LProp_SLProps_hxx <GeomLProp_SLProps.hxx>
|
||||
#include <LProp_SLProps.gxx>
|
||||
@@ -1,95 +0,0 @@
|
||||
// Created on: 1992-08-18
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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 <Geom_Surface.hxx>
|
||||
#include <GeomAbs_Shape.hxx>
|
||||
#include <GeomLProp_SurfaceTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
void GeomLProp_SurfaceTool::Value(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P)
|
||||
{
|
||||
P = S->Value(U, V);
|
||||
}
|
||||
|
||||
void GeomLProp_SurfaceTool::D1(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V)
|
||||
{
|
||||
S->D1(U, V, P, D1U, D1V);
|
||||
}
|
||||
|
||||
void GeomLProp_SurfaceTool::D2(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V,
|
||||
gp_Vec& D2U,
|
||||
gp_Vec& D2V,
|
||||
gp_Vec& DUV)
|
||||
{
|
||||
S->D2(U, V, P, D1U, D1V, D2U, D2V, DUV);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
gp_Vec GeomLProp_SurfaceTool::DN(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int IU,
|
||||
const int IV)
|
||||
{
|
||||
return S->DN(U, V, IU, IV);
|
||||
}
|
||||
|
||||
int GeomLProp_SurfaceTool::Continuity(const occ::handle<Geom_Surface>& S)
|
||||
{
|
||||
GeomAbs_Shape s = S->Continuity();
|
||||
switch (s)
|
||||
{
|
||||
case GeomAbs_C0:
|
||||
return 0;
|
||||
case GeomAbs_C1:
|
||||
return 1;
|
||||
case GeomAbs_C2:
|
||||
return 2;
|
||||
case GeomAbs_C3:
|
||||
return 3;
|
||||
case GeomAbs_G1:
|
||||
return 0;
|
||||
case GeomAbs_G2:
|
||||
return 0;
|
||||
case GeomAbs_CN:
|
||||
return 3;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GeomLProp_SurfaceTool::Bounds(const occ::handle<Geom_Surface>& S,
|
||||
double& U1,
|
||||
double& V1,
|
||||
double& U2,
|
||||
double& V2)
|
||||
{
|
||||
S->Bounds(U1, U2, V1, V2);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
// Created on: 1992-03-26
|
||||
// Created by: Herve LEGRAND
|
||||
// Copyright (c) 1992-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.
|
||||
|
||||
#ifndef _GeomLProp_SurfaceTool_HeaderFile
|
||||
#define _GeomLProp_SurfaceTool_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Integer.hxx>
|
||||
class Geom_Surface;
|
||||
class gp_Pnt;
|
||||
class gp_Vec;
|
||||
|
||||
class GeomLProp_SurfaceTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Computes the point <P> of parameter <U> and <V> on the
|
||||
//! Surface <S>.
|
||||
Standard_EXPORT static void Value(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P);
|
||||
|
||||
//! Computes the point <P> and first derivative <D1*> of
|
||||
//! parameter <U> and <V> on the Surface <S>.
|
||||
Standard_EXPORT static void D1(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V);
|
||||
|
||||
//! Computes the point <P>, the first derivative <D1*> and second
|
||||
//! derivative <D2*> of parameter <U> and <V> on the Surface <S>.
|
||||
Standard_EXPORT static void D2(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V,
|
||||
gp_Vec& D2U,
|
||||
gp_Vec& D2V,
|
||||
gp_Vec& DUV);
|
||||
|
||||
Standard_EXPORT static gp_Vec DN(const occ::handle<Geom_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int IU,
|
||||
const int IV);
|
||||
|
||||
//! returns the order of continuity of the Surface <S>.
|
||||
//! returns 1 : first derivative only is computable
|
||||
//! returns 2 : first and second derivative only are computable.
|
||||
Standard_EXPORT static int Continuity(const occ::handle<Geom_Surface>& S);
|
||||
|
||||
//! returns the bounds of the Surface.
|
||||
Standard_EXPORT static void Bounds(const occ::handle<Geom_Surface>& S,
|
||||
double& U1,
|
||||
double& V1,
|
||||
double& U2,
|
||||
double& V2);
|
||||
};
|
||||
|
||||
#endif // _GeomLProp_SurfaceTool_HeaderFile
|
||||
@@ -3,11 +3,7 @@ set(OCCT_LProp3d_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_LProp3d_FILES
|
||||
LProp3d_CLProps.hxx
|
||||
LProp3d_CLProps_0.cxx
|
||||
LProp3d_CurveTool.cxx
|
||||
LProp3d_CurveTool.hxx
|
||||
LProp3d_CLProps.cxx
|
||||
LProp3d_SLProps.hxx
|
||||
LProp3d_SLProps_0.cxx
|
||||
LProp3d_SurfaceTool.cxx
|
||||
LProp3d_SurfaceTool.hxx
|
||||
LProp3d_SLProps.cxx
|
||||
)
|
||||
|
||||
172
src/ModelingData/TKG3d/LProp3d/LProp3d_CLProps.cxx
Normal file
172
src/ModelingData/TKG3d/LProp3d/LProp3d_CLProps.cxx
Normal file
@@ -0,0 +1,172 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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 <LProp3d_CLProps.hxx>
|
||||
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_CurveUtils.pxx>
|
||||
|
||||
using Access = LProp_CurveUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_CLProps::LProp3d_CLProps(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp3d_CLProps::LProp3d_CLProps()");
|
||||
SetParameter(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_CLProps::LProp3d_CLProps(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: myCurve(C),
|
||||
myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp3d_CLProps::LProp3d_CLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_CLProps::LProp3d_CLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myTangentStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 3, "LProp3d_CLProps() - invalid input");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CLProps::SetParameter(const double U)
|
||||
{
|
||||
LProp_CurveUtils::SetParameter<Access>(myCurve,
|
||||
U,
|
||||
myU,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myDerivArr,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CLProps::SetCurve(const occ::handle<Adaptor3d_Curve>& C)
|
||||
{
|
||||
myCurve = C;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& LProp3d_CLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_CLProps::D1()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 1, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_CLProps::D2()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 2, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_CLProps::D3()
|
||||
{
|
||||
return LProp_CurveUtils::EnsureDeriv<Access>(myCurve, myU, myDerOrder, 3, myPnt, myDerivArr);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_CLProps::IsTangentDefined()
|
||||
{
|
||||
return LProp_CurveUtils::IsTangentDefined<gp_Vec>(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CLProps::Tangent(gp_Dir& D)
|
||||
{
|
||||
LProp_CurveUtils::Tangent<Access>(*this,
|
||||
myCurve,
|
||||
myU,
|
||||
myDerivArr,
|
||||
myPnt,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_CLProps::Curvature()
|
||||
{
|
||||
return LProp_CurveUtils::Curvature(*this,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrder,
|
||||
myCurvature);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CLProps::Normal(gp_Dir& N)
|
||||
{
|
||||
LProp_CurveUtils::Normal(*this, myDerivArr[0], myDerivArr[1], myLinTol, N);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CLProps::CentreOfCurvature(gp_Pnt& P)
|
||||
{
|
||||
LProp_CurveUtils::CentreOfCurvature(*this,
|
||||
myPnt,
|
||||
myDerivArr[0],
|
||||
myDerivArr[1],
|
||||
myLinTol,
|
||||
myCurvature,
|
||||
P);
|
||||
}
|
||||
@@ -29,7 +29,6 @@ class LProp_NotDefined;
|
||||
class gp_Vec;
|
||||
class gp_Pnt;
|
||||
class gp_Dir;
|
||||
class LProp3d_CurveTool;
|
||||
|
||||
class LProp3d_CLProps
|
||||
{
|
||||
@@ -109,14 +108,14 @@ private:
|
||||
occ::handle<Adaptor3d_Curve> myCurve;
|
||||
double myU;
|
||||
int myDerOrder;
|
||||
double myCN;
|
||||
int myCN;
|
||||
double myLinTol;
|
||||
gp_Pnt myPnt;
|
||||
gp_Vec myDerivArr[3];
|
||||
gp_Dir myTangent;
|
||||
double myCurvature;
|
||||
double myCurvature = 0.0;
|
||||
LProp_Status myTangentStatus;
|
||||
int mySignificantFirstDerivativeOrder;
|
||||
int mySignificantFirstDerivativeOrder = 0;
|
||||
};
|
||||
|
||||
#endif // _LProp3d_CLProps_HeaderFile
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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 <LProp3d_CLProps.hxx>
|
||||
|
||||
#include <Adaptor3d_Curve.hxx>
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <LProp3d_CurveTool.hxx>
|
||||
|
||||
#define Curve occ::handle<Adaptor3d_Curve>
|
||||
#define Curve_hxx <Adaptor3d_Curve.hxx>
|
||||
#define Vec gp_Vec
|
||||
#define Vec_hxx <gp_Vec.hxx>
|
||||
#define Pnt gp_Pnt
|
||||
#define Pnt_hxx <gp_Pnt.hxx>
|
||||
#define Dir gp_Dir
|
||||
#define Dir_hxx <gp_Dir.hxx>
|
||||
#define Tool LProp3d_CurveTool
|
||||
#define Tool_hxx <LProp3d_CurveTool.hxx>
|
||||
#define LProp_CLProps LProp3d_CLProps
|
||||
#define LProp_CLProps_hxx <LProp3d_CLProps.hxx>
|
||||
#include <LProp_CLProps.gxx>
|
||||
@@ -1,99 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <Adaptor3d_Curve.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <LProp3d_CurveTool.hxx>
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CurveTool::Value(const occ::handle<Adaptor3d_Curve>& C, const double U, gp_Pnt& P)
|
||||
{
|
||||
P = C->Value(U);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CurveTool::D1(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1)
|
||||
{
|
||||
C->D1(U, P, V1);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CurveTool::D2(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2)
|
||||
{
|
||||
C->D2(U, P, V1, V2);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_CurveTool::D3(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3)
|
||||
{
|
||||
C->D3(U, P, V1, V2, V3);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
int LProp3d_CurveTool::Continuity(const occ::handle<Adaptor3d_Curve>& C)
|
||||
{
|
||||
GeomAbs_Shape s = C->Continuity();
|
||||
switch (s)
|
||||
{
|
||||
case GeomAbs_C0:
|
||||
return 0;
|
||||
case GeomAbs_C1:
|
||||
return 1;
|
||||
case GeomAbs_C2:
|
||||
return 2;
|
||||
case GeomAbs_C3:
|
||||
return 3;
|
||||
case GeomAbs_G1:
|
||||
return 0;
|
||||
case GeomAbs_G2:
|
||||
return 0;
|
||||
case GeomAbs_CN:
|
||||
return 3;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_CurveTool::FirstParameter(const occ::handle<Adaptor3d_Curve>& C)
|
||||
{
|
||||
return C->FirstParameter();
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_CurveTool::LastParameter(const occ::handle<Adaptor3d_Curve>& C)
|
||||
{
|
||||
return C->LastParameter();
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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.
|
||||
|
||||
#ifndef _LProp3d_CurveTool_HeaderFile
|
||||
#define _LProp3d_CurveTool_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
|
||||
class gp_Pnt;
|
||||
class gp_Vec;
|
||||
|
||||
class LProp3d_CurveTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Computes the point <P> of parameter <U> on the HCurve <C>.
|
||||
Standard_EXPORT static void Value(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P);
|
||||
|
||||
//! Computes the point <P> and first derivative <V1> of
|
||||
//! parameter <U> on the HCurve <C>.
|
||||
Standard_EXPORT static void D1(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1> and second
|
||||
//! derivative <V2> of parameter <U> on the HCurve <C>.
|
||||
Standard_EXPORT static void D2(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2);
|
||||
|
||||
//! Computes the point <P>, the first derivative <V1>, the
|
||||
//! second derivative <V2> and third derivative <V3> of
|
||||
//! parameter <U> on the HCurve <C>.
|
||||
Standard_EXPORT static void D3(const occ::handle<Adaptor3d_Curve>& C,
|
||||
const double U,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& V1,
|
||||
gp_Vec& V2,
|
||||
gp_Vec& V3);
|
||||
|
||||
//! returns the order of continuity of the HCurve <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.
|
||||
Standard_EXPORT static int Continuity(const occ::handle<Adaptor3d_Curve>& C);
|
||||
|
||||
//! returns the first parameter bound of the HCurve.
|
||||
Standard_EXPORT static double FirstParameter(const occ::handle<Adaptor3d_Curve>& C);
|
||||
|
||||
//! returns the last parameter bound of the HCurve.
|
||||
//! FirstParameter must be less than LastParamenter.
|
||||
Standard_EXPORT static double LastParameter(const occ::handle<Adaptor3d_Curve>& C);
|
||||
};
|
||||
|
||||
#endif // _LProp3d_CurveTool_HeaderFile
|
||||
280
src/ModelingData/TKG3d/LProp3d/LProp3d_SLProps.cxx
Normal file
280
src/ModelingData/TKG3d/LProp3d/LProp3d_SLProps.cxx
Normal file
@@ -0,0 +1,280 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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 <LProp3d_SLProps.hxx>
|
||||
|
||||
#include <Adaptor3d_Surface.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
|
||||
#include <LProp_SurfaceUtils.pxx>
|
||||
|
||||
using Access = LProp_SurfaceUtils::DirectAccess;
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_SLProps::LProp3d_SLProps(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp3d_SLProps::LProp3d_SLProps()");
|
||||
SetParameters(U, V);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_SLProps::LProp3d_SLProps(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const int N,
|
||||
const double Resolution)
|
||||
: mySurf(S),
|
||||
myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(4),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp3d_SLProps::LProp3d_SLProps()");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
LProp3d_SLProps::LProp3d_SLProps(const int N, const double Resolution)
|
||||
: myU(RealLast()),
|
||||
myV(RealLast()),
|
||||
myDerOrder(N),
|
||||
myCN(0),
|
||||
myLinTol(Resolution),
|
||||
myUTangentStatus(LProp_Undecided),
|
||||
myVTangentStatus(LProp_Undecided),
|
||||
myNormalStatus(LProp_Undecided),
|
||||
myCurvatureStatus(LProp_Undecided)
|
||||
{
|
||||
Standard_OutOfRange_Raise_if(N < 0 || N > 2, "LProp3d_SLProps::LProp3d_SLProps() bad level");
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SLProps::SetSurface(const occ::handle<Adaptor3d_Surface>& S)
|
||||
{
|
||||
mySurf = S;
|
||||
myCN = 4;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SLProps::SetParameters(const double U, const double V)
|
||||
{
|
||||
LProp_SurfaceUtils::SetParameters<Access>(mySurf,
|
||||
U,
|
||||
V,
|
||||
myU,
|
||||
myV,
|
||||
myDerOrder,
|
||||
myPnt,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myUTangentStatus,
|
||||
myVTangentStatus,
|
||||
myNormalStatus,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Pnt& LProp3d_SLProps::Value() const
|
||||
{
|
||||
return myPnt;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_SLProps::D1U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_SLProps::D1V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 1, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD1v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_SLProps::D2U()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2u);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_SLProps::D2V()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myD2v);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Vec& LProp3d_SLProps::DUV()
|
||||
{
|
||||
return LProp_SurfaceUtils::EnsureSurfDeriv<
|
||||
Access>(mySurf, myU, myV, myDerOrder, 2, myPnt, myD1u, myD1v, myD2u, myD2v, myDuv, myDuv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_SLProps::IsTangentUDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentUDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
myUTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SLProps::TangentU(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentU<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1u,
|
||||
myD2u,
|
||||
mySignificantFirstDerivativeOrderU,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_SLProps::IsTangentVDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsTangentVDefined(*this,
|
||||
myCN,
|
||||
myLinTol,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
myVTangentStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SLProps::TangentV(gp_Dir& D)
|
||||
{
|
||||
LProp_SurfaceUtils::TangentV<Access>(*this,
|
||||
mySurf,
|
||||
myU,
|
||||
myV,
|
||||
myD1v,
|
||||
myD2v,
|
||||
mySignificantFirstDerivativeOrderV,
|
||||
D);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_SLProps::IsNormalDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsNormalDefined(myD1u, myD1v, myLinTol, myNormal, myNormalStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
const gp_Dir& LProp3d_SLProps::Normal()
|
||||
{
|
||||
return LProp_SurfaceUtils::Normal(*this, myNormal);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_SLProps::IsCurvatureDefined()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsCurvatureDefined(*this,
|
||||
myCN,
|
||||
myDerOrder,
|
||||
myD1u,
|
||||
myD1v,
|
||||
myD2u,
|
||||
myD2v,
|
||||
myDuv,
|
||||
myNormal,
|
||||
myMinCurv,
|
||||
myMaxCurv,
|
||||
myDirMinCurv,
|
||||
myDirMaxCurv,
|
||||
myMeanCurv,
|
||||
myGausCurv,
|
||||
myCurvatureStatus);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
bool LProp3d_SLProps::IsUmbilic()
|
||||
{
|
||||
return LProp_SurfaceUtils::IsUmbilic(*this, myMaxCurv, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_SLProps::MaxCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMaxCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_SLProps::MinCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMinCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SLProps::CurvatureDirections(gp_Dir& Max, gp_Dir& Min)
|
||||
{
|
||||
LProp_SurfaceUtils::CurvatureDirections(*this, myDirMaxCurv, myDirMinCurv, Max, Min);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_SLProps::MeanCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myMeanCurv);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
double LProp3d_SLProps::GaussianCurvature()
|
||||
{
|
||||
return LProp_SurfaceUtils::RequireCurvature(*this, myGausCurv);
|
||||
}
|
||||
@@ -141,14 +141,14 @@ private:
|
||||
gp_Vec myD2v;
|
||||
gp_Vec myDuv;
|
||||
gp_Dir myNormal;
|
||||
double myMinCurv;
|
||||
double myMaxCurv;
|
||||
double myMinCurv = 0.0;
|
||||
double myMaxCurv = 0.0;
|
||||
gp_Dir myDirMinCurv;
|
||||
gp_Dir myDirMaxCurv;
|
||||
double myMeanCurv;
|
||||
double myGausCurv;
|
||||
int mySignificantFirstDerivativeOrderU;
|
||||
int mySignificantFirstDerivativeOrderV;
|
||||
double myMeanCurv = 0.0;
|
||||
double myGausCurv = 0.0;
|
||||
int mySignificantFirstDerivativeOrderU = 0;
|
||||
int mySignificantFirstDerivativeOrderV = 0;
|
||||
LProp_Status myUTangentStatus;
|
||||
LProp_Status myVTangentStatus;
|
||||
LProp_Status myNormalStatus;
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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 <LProp3d_SLProps.hxx>
|
||||
|
||||
#include <Adaptor3d_Surface.hxx>
|
||||
#include <LProp_BadContinuity.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
#include <LProp_NotDefined.hxx>
|
||||
#include <LProp3d_SurfaceTool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
|
||||
#define Surface occ::handle<Adaptor3d_Surface>
|
||||
#define Surface_hxx <Adaptor3d_Surface.hxx>
|
||||
#define Tool LProp3d_SurfaceTool
|
||||
#define Tool_hxx <LProp3d_SurfaceTool.hxx>
|
||||
#define LProp_SLProps LProp3d_SLProps
|
||||
#define LProp_SLProps_hxx <LProp3d_SLProps.hxx>
|
||||
#include <LProp_SLProps.gxx>
|
||||
@@ -1,106 +0,0 @@
|
||||
// Created on: 1994-02-24
|
||||
// Created by: Laurent BOURESCHE
|
||||
// Copyright (c) 1994-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 <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <LProp3d_SurfaceTool.hxx>
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SurfaceTool::Value(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P)
|
||||
{
|
||||
P = S->Value(U, V);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SurfaceTool::D1(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V)
|
||||
{
|
||||
S->D1(U, V, P, D1U, D1V);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SurfaceTool::D2(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V,
|
||||
gp_Vec& D2U,
|
||||
gp_Vec& D2V,
|
||||
gp_Vec& DUV)
|
||||
{
|
||||
S->D2(U, V, P, D1U, D1V, D2U, D2V, DUV);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
gp_Vec LProp3d_SurfaceTool::DN(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int IU,
|
||||
const int IV)
|
||||
{
|
||||
return S->DN(U, V, IU, IV);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
int LProp3d_SurfaceTool::Continuity(const occ::handle<Adaptor3d_Surface>& S)
|
||||
{
|
||||
GeomAbs_Shape s = (GeomAbs_Shape)std::min(S->UContinuity(), S->VContinuity());
|
||||
switch (s)
|
||||
{
|
||||
case GeomAbs_C0:
|
||||
return 0;
|
||||
case GeomAbs_C1:
|
||||
return 1;
|
||||
case GeomAbs_C2:
|
||||
return 2;
|
||||
case GeomAbs_C3:
|
||||
return 3;
|
||||
case GeomAbs_G1:
|
||||
return 0;
|
||||
case GeomAbs_G2:
|
||||
return 0;
|
||||
case GeomAbs_CN:
|
||||
return 3;
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
void LProp3d_SurfaceTool::Bounds(const occ::handle<Adaptor3d_Surface>& S,
|
||||
double& U1,
|
||||
double& V1,
|
||||
double& U2,
|
||||
double& V2)
|
||||
{
|
||||
U1 = S->FirstUParameter();
|
||||
V1 = S->FirstVParameter();
|
||||
U2 = S->LastUParameter();
|
||||
V2 = S->LastVParameter();
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
// Created on: 2002-08-02
|
||||
// Created by: Alexander KARTOMIN (akm)
|
||||
// Copyright (c) 2002-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.
|
||||
|
||||
#ifndef _LProp3d_SurfaceTool_HeaderFile
|
||||
#define _LProp3d_SurfaceTool_HeaderFile
|
||||
|
||||
#include <Adaptor3d_Surface.hxx>
|
||||
|
||||
class LProp3d_SurfaceTool
|
||||
{
|
||||
public:
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
//! Computes the point <P> of parameter <U> and <V> on the
|
||||
//! HSurface <S>.
|
||||
Standard_EXPORT static void Value(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P);
|
||||
|
||||
//! Computes the point <P> and first derivative <D1*> of
|
||||
//! parameter <U> and <V> on the HSurface <S>.
|
||||
Standard_EXPORT static void D1(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V);
|
||||
|
||||
//! Computes the point <P>, the first derivative <D1*> and second
|
||||
//! derivative <D2*> of parameter <U> and <V> on the HSurface <S>.
|
||||
Standard_EXPORT static void D2(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
gp_Pnt& P,
|
||||
gp_Vec& D1U,
|
||||
gp_Vec& D1V,
|
||||
gp_Vec& D2U,
|
||||
gp_Vec& D2V,
|
||||
gp_Vec& DUV);
|
||||
|
||||
Standard_EXPORT static gp_Vec DN(const occ::handle<Adaptor3d_Surface>& S,
|
||||
const double U,
|
||||
const double V,
|
||||
const int IU,
|
||||
const int IV);
|
||||
|
||||
//! returns the order of continuity of the HSurface <S>.
|
||||
//! returns 1 : first derivative only is computable
|
||||
//! returns 2 : first and second derivative only are computable.
|
||||
Standard_EXPORT static int Continuity(const occ::handle<Adaptor3d_Surface>& S);
|
||||
|
||||
//! returns the bounds of the HSurface.
|
||||
Standard_EXPORT static void Bounds(const occ::handle<Adaptor3d_Surface>& S,
|
||||
double& U1,
|
||||
double& V1,
|
||||
double& U2,
|
||||
double& V2);
|
||||
};
|
||||
|
||||
#endif // _LProp3d_SurfaceTool_HeaderFile
|
||||
Reference in New Issue
Block a user