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

0026838: Using GeomEvaluators for calculation of values of curves

1. Implemented evaluators for 2D and 3D offset curves
2. Removed obsolete namespace CSLib_Offset

Update of UDLIST (adding no-cdl-pack Geom2dEvaluator)

Update TKG2d/CMakeLists.txt after rebase

Correction compilation in debug mode
This commit is contained in:
azv
2015-11-06 08:49:50 +03:00
committed by bugmaster
parent badc9305ae
commit d660a72aca
22 changed files with 1693 additions and 2084 deletions

View File

@@ -25,7 +25,6 @@
#include <Adaptor3d_HCurve.hxx>
#include <BSplCLib.hxx>
#include <BSplCLib_Cache.hxx>
#include <CSLib_Offset.hxx>
#include <Geom_BezierCurve.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom_Circle.hxx>
@@ -40,6 +39,7 @@
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomEvaluator_OffsetCurve.hxx>
#include <gp_Circ.hxx>
#include <gp_Elips.hxx>
#include <gp_Hypr.hxx>
@@ -62,16 +62,6 @@
//#include <GeomConvert_BSplineCurveKnotSplitting.hxx>
static const Standard_Real PosTol = Precision::PConfusion() / 2;
static const Standard_Integer maxDerivOrder = 3;
static const Standard_Real MinStep = 1e-7;
static gp_Vec dummyDerivative; // used as empty value for unused derivatives in AdjustDerivative
// Recalculate derivatives in the singular point
// Returns true if the direction of derivatives is changed
static Standard_Boolean AdjustDerivative(
const Handle(Adaptor3d_HCurve)& theAdaptor, Standard_Integer theMaxDerivative, Standard_Real theU, gp_Vec& theD1,
gp_Vec& theD2 = dummyDerivative, gp_Vec& theD3 = dummyDerivative, gp_Vec& theD4 = dummyDerivative);
//=======================================================================
//function : LocalContinuity
@@ -153,6 +143,7 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
if ( myCurve != C) {
myCurve = C;
myCurveCache = Handle(BSplCLib_Cache)();
myNestedEvaluator = Handle(GeomEvaluator_Curve)();
const Handle(Standard_Type)& TheType = C->DynamicType();
if ( TheType == STANDARD_TYPE(Geom_TrimmedCurve)) {
@@ -191,9 +182,12 @@ void GeomAdaptor_Curve::load(const Handle(Geom_Curve)& C,
}
else if ( TheType == STANDARD_TYPE(Geom_OffsetCurve)) {
myTypeCurve = GeomAbs_OffsetCurve;
Handle(Geom_OffsetCurve) anOffsetCurve = Handle(Geom_OffsetCurve)::DownCast(myCurve);
// Create nested adaptor for base curve
Handle(Geom_Curve) aBase = Handle(Geom_OffsetCurve)::DownCast(myCurve)->BasisCurve();
myOffsetBaseCurveAdaptor = new GeomAdaptor_HCurve(aBase);
Handle(Geom_Curve) aBaseCurve = anOffsetCurve->BasisCurve();
Handle(GeomAdaptor_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve);
myNestedEvaluator = new GeomEvaluator_OffsetCurve(
aBaseAdaptor, anOffsetCurve->Offset(), anOffsetCurve->Direction());
}
else {
myTypeCurve = GeomAbs_OtherCurve;
@@ -570,6 +564,38 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const
}
}
//=======================================================================
//function : IsBoundary
//purpose :
//=======================================================================
Standard_Boolean GeomAdaptor_Curve::IsBoundary(const Standard_Real theU,
Standard_Integer& theSpanStart,
Standard_Integer& theSpanFinish) const
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
if (!aBspl.IsNull() && (theU == myFirst || theU == myLast))
{
if (theU == myFirst)
{
aBspl->LocateU(myFirst, PosTol, theSpanStart, theSpanFinish);
if (theSpanStart < 1)
theSpanStart = 1;
if (theSpanStart >= theSpanFinish)
theSpanFinish = theSpanStart + 1;
}
else if (theU == myLast)
{
aBspl->LocateU(myLast, PosTol, theSpanStart, theSpanFinish);
if (theSpanFinish > aBspl->NbKnots())
theSpanFinish = aBspl->NbKnots();
if (theSpanStart >= theSpanFinish)
theSpanStart = theSpanFinish - 1;
}
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Value
//purpose :
@@ -577,71 +603,9 @@ void GeomAdaptor_Curve::RebuildCache(const Standard_Real theParameter) const
gp_Pnt GeomAdaptor_Curve::Value(const Standard_Real U) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
return ValueBSpline(U);
else if (myTypeCurve == GeomAbs_OffsetCurve)
return ValueOffset(U);
else if (myTypeCurve == GeomAbs_BezierCurve)
{ // use cached data
gp_Pnt aRes;
myCurveCache->D0(U, aRes);
return aRes;
}
return myCurve->Value(U);
}
//=======================================================================
//function : ValueBSpline
//purpose :
//=======================================================================
gp_Pnt GeomAdaptor_Curve::ValueBSpline(const Standard_Real theU) const
{
if (theU == myFirst || theU == myLast)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (theU == myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (theU == myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
return aBspl->LocalValue(theU, Ideb, Ifin);
}
else if (!myCurveCache.IsNull()) // use cached B-spline data
{
if (!myCurveCache->IsCacheValid(theU))
RebuildCache(theU);
gp_Pnt aRes;
myCurveCache->D0(theU, aRes);
return aRes;
}
return myCurve->Value(theU);
}
//=======================================================================
//function : ValueOffset
//purpose :
//=======================================================================
gp_Pnt GeomAdaptor_Curve::ValueOffset(const Standard_Real theU) const
{
gp_Pnt aP;
gp_Vec aV;
myOffsetBaseCurveAdaptor->D1(theU, aP, aV);
Standard_Boolean IsDirectionChange = Standard_False;
if(aV.SquareMagnitude() <= gp::Resolution())
IsDirectionChange = AdjustDerivative(myOffsetBaseCurveAdaptor, 1, theU, aV);
Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(myCurve);
Standard_Real anOffsetVal = anOffC->Offset();
const gp_Dir& anOffsetDir = anOffC->Direction();
CSLib_Offset::D0(aP, aV, anOffsetDir, anOffsetVal, IsDirectionChange, aP);
return aP;
gp_Pnt aValue;
D0(U, aValue);
return aValue;
}
//=======================================================================
@@ -651,56 +615,35 @@ gp_Pnt GeomAdaptor_Curve::ValueOffset(const Standard_Real theU) const
void GeomAdaptor_Curve::D0(const Standard_Real U, gp_Pnt& P) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
D0BSpline(U, P);
else if (myTypeCurve == GeomAbs_OffsetCurve)
D0Offset(U, P);
else if (myTypeCurve == GeomAbs_BezierCurve) // use cached data
myCurveCache->D0(U, P);
else
switch (myTypeCurve)
{
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
{
Standard_Integer aStart = 0, aFinish = 0;
if (IsBoundary(U, aStart, aFinish))
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
aBspl->LocalD0(U, aStart, aFinish, P);
}
else if (!myCurveCache.IsNull()) // use cached data
{
if (!myCurveCache->IsCacheValid(U))
RebuildCache(U);
myCurveCache->D0(U, P);
}
else
myCurve->D0(U, P);
break;
}
case GeomAbs_OffsetCurve:
myNestedEvaluator->D0(U, P);
break;
default:
myCurve->D0(U, P);
}
//=======================================================================
//function : D0BSpline
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D0BSpline(const Standard_Real theU, gp_Pnt& theP) const
{
if (theU == myFirst || theU == myLast)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (theU == myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (theU == myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
aBspl->LocalD0(theU, Ideb, Ifin, theP);
return;
}
else if (!myCurveCache.IsNull()) // use cached B-spline data
{
if (!myCurveCache->IsCacheValid(theU))
RebuildCache(theU);
myCurveCache->D0(theU, theP);
return;
}
myCurve->D0(theU, theP);
}
//=======================================================================
//function : D0Offset
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D0Offset(const Standard_Real theU, gp_Pnt& theP) const
{
theP = ValueOffset(theU);
}
//=======================================================================
@@ -710,69 +653,37 @@ void GeomAdaptor_Curve::D0Offset(const Standard_Real theU, gp_Pnt& theP) const
void GeomAdaptor_Curve::D1(const Standard_Real U, gp_Pnt& P, gp_Vec& V) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
D1BSpline(U, P, V);
else if (myTypeCurve == GeomAbs_OffsetCurve)
D1Offset(U, P, V);
else if (myTypeCurve == GeomAbs_BezierCurve) // use cached data
myCurveCache->D1(U, P, V);
else
switch (myTypeCurve)
{
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
{
Standard_Integer aStart = 0, aFinish = 0;
if (IsBoundary(U, aStart, aFinish))
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
aBspl->LocalD1(U, aStart, aFinish, P, V);
}
else if (!myCurveCache.IsNull()) // use cached data
{
if (!myCurveCache->IsCacheValid(U))
RebuildCache(U);
myCurveCache->D1(U, P, V);
}
else
myCurve->D1(U, P, V);
break;
}
case GeomAbs_OffsetCurve:
myNestedEvaluator->D1(U, P, V);
break;
default:
myCurve->D1(U, P, V);
}
//=======================================================================
//function : D1BSpline
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D1BSpline(const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const
{
if (theU == myFirst || theU == myLast)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (theU == myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (theU == myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
aBspl->LocalD1(theU, Ideb, Ifin, theP, theV);
return;
}
else if (!myCurveCache.IsNull()) // use cached B-spline data
{
if (!myCurveCache->IsCacheValid(theU))
RebuildCache(theU);
myCurveCache->D1(theU, theP, theV);
return;
}
myCurve->D1(theU, theP, theV);
}
//=======================================================================
//function : D1Offset
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D1Offset(const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const
{
gp_Vec aV2;
myOffsetBaseCurveAdaptor->D2 (theU, theP, theV, aV2);
Standard_Boolean IsDirectionChange = Standard_False;
if(theV.SquareMagnitude() <= gp::Resolution())
IsDirectionChange = AdjustDerivative(myOffsetBaseCurveAdaptor, 2, theU, theV, aV2);
Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(myCurve);
Standard_Real anOffsetVal = anOffC->Offset();
const gp_Dir& anOffsetDir = anOffC->Direction();
CSLib_Offset::D1(theP, theV, aV2, anOffsetDir, anOffsetVal, IsDirectionChange, theP, theV);
}
//=======================================================================
//function : D2
//purpose :
@@ -781,68 +692,35 @@ void GeomAdaptor_Curve::D1Offset(const Standard_Real theU, gp_Pnt& theP, gp_Vec&
void GeomAdaptor_Curve::D2(const Standard_Real U,
gp_Pnt& P, gp_Vec& V1, gp_Vec& V2) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
D2BSpline(U, P, V1, V2);
else if (myTypeCurve == GeomAbs_OffsetCurve)
D2Offset(U, P, V1, V2);
else if (myTypeCurve == GeomAbs_BezierCurve) // use cached data
myCurveCache->D2(U, P, V1, V2);
else
switch (myTypeCurve)
{
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
{
Standard_Integer aStart = 0, aFinish = 0;
if (IsBoundary(U, aStart, aFinish))
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
aBspl->LocalD2(U, aStart, aFinish, P, V1, V2);
}
else if (!myCurveCache.IsNull()) // use cached data
{
if (!myCurveCache->IsCacheValid(U))
RebuildCache(U);
myCurveCache->D2(U, P, V1, V2);
}
else
myCurve->D2(U, P, V1, V2);
break;
}
case GeomAbs_OffsetCurve:
myNestedEvaluator->D2(U, P, V1, V2);
break;
default:
myCurve->D2(U, P, V1, V2);
}
//=======================================================================
//function : D2BSpline
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D2BSpline(const Standard_Real theU, gp_Pnt& theP,
gp_Vec& theV1, gp_Vec& theV2) const
{
if (theU == myFirst || theU == myLast)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (theU == myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (theU == myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
aBspl->LocalD2(theU, Ideb, Ifin, theP, theV1, theV2);
return;
}
else if (!myCurveCache.IsNull()) // use cached B-spline data
{
if (!myCurveCache->IsCacheValid(theU))
RebuildCache(theU);
myCurveCache->D2(theU, theP, theV1, theV2);
return;
}
myCurve->D2(theU, theP, theV1, theV2);
}
//=======================================================================
//function : D2Offset
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D2Offset(const Standard_Real theU, gp_Pnt& theP,
gp_Vec& theV1, gp_Vec& theV2) const
{
gp_Vec V3;
myOffsetBaseCurveAdaptor->D3 (theU, theP, theV1, theV2, V3);
Standard_Boolean IsDirectionChange = Standard_False;
if(theV1.SquareMagnitude() <= gp::Resolution())
IsDirectionChange = AdjustDerivative(myOffsetBaseCurveAdaptor, 3, theU, theV1, theV2, V3);
Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(myCurve);
Standard_Real anOffsetVal = anOffC->Offset();
const gp_Dir& anOffsetDir = anOffC->Direction();
CSLib_Offset::D2(theP, theV1, theV2, V3, anOffsetDir, anOffsetVal, IsDirectionChange, theP, theV1, theV2);
}
//=======================================================================
@@ -854,71 +732,35 @@ void GeomAdaptor_Curve::D3(const Standard_Real U,
gp_Pnt& P, gp_Vec& V1,
gp_Vec& V2, gp_Vec& V3) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
D3BSpline(U, P, V1, V2, V3);
else if (myTypeCurve == GeomAbs_OffsetCurve)
D3Offset(U, P, V1, V2, V3);
else if (myTypeCurve == GeomAbs_BezierCurve) // use cached data
myCurveCache->D3(U, P, V1, V2, V3);
else
switch (myTypeCurve)
{
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
{
Standard_Integer aStart = 0, aFinish = 0;
if (IsBoundary(U, aStart, aFinish))
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
aBspl->LocalD3(U, aStart, aFinish, P, V1, V2, V3);
}
else if (!myCurveCache.IsNull()) // use cached data
{
if (!myCurveCache->IsCacheValid(U))
RebuildCache(U);
myCurveCache->D3(U, P, V1, V2, V3);
}
else
myCurve->D3(U, P, V1, V2, V3);
break;
}
case GeomAbs_OffsetCurve:
myNestedEvaluator->D3(U, P, V1, V2, V3);
break;
default:
myCurve->D3(U, P, V1, V2, V3);
}
//=======================================================================
//function : D3BSpline
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D3BSpline(const Standard_Real theU,
gp_Pnt& theP, gp_Vec& theV1,
gp_Vec& theV2, gp_Vec& theV3) const
{
if (theU == myFirst || theU == myLast)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (theU == myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
}
if (theU == myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
aBspl->LocalD3(theU, Ideb, Ifin, theP, theV1, theV2, theV3);
return;
}
else if (!myCurveCache.IsNull()) // use cached B-spline data
{
if (!myCurveCache->IsCacheValid(theU))
RebuildCache(theU);
myCurveCache->D3(theU, theP, theV1, theV2, theV3);
return;
}
myCurve->D3(theU, theP, theV1, theV2, theV3);
}
//=======================================================================
//function : D3Offset
//purpose :
//=======================================================================
void GeomAdaptor_Curve::D3Offset(const Standard_Real theU,
gp_Pnt& theP, gp_Vec& theV1,
gp_Vec& theV2, gp_Vec& theV3) const
{
myOffsetBaseCurveAdaptor->D3 (theU, theP, theV1, theV2, theV3);
gp_Vec V4 = myOffsetBaseCurveAdaptor->DN(theU, 4);
Standard_Boolean IsDirectionChange = Standard_False;
if(theV1.SquareMagnitude() <= gp::Resolution())
IsDirectionChange = AdjustDerivative(myOffsetBaseCurveAdaptor, 4, theU, theV1, theV2, theV3, V4);
Handle(Geom_OffsetCurve) anOffC = Handle(Geom_OffsetCurve)::DownCast(myCurve);
Standard_Real anOffsetVal = anOffC->Offset();
const gp_Dir& anOffsetDir = anOffC->Direction();
CSLib_Offset::D3(theP, theV1, theV2, theV3, V4, anOffsetDir, anOffsetVal, IsDirectionChange,
theP, theV1, theV2, theV3);
}
//=======================================================================
@@ -929,57 +771,30 @@ void GeomAdaptor_Curve::D3Offset(const Standard_Real theU,
gp_Vec GeomAdaptor_Curve::DN(const Standard_Real U,
const Standard_Integer N) const
{
if (myTypeCurve == GeomAbs_BSplineCurve)
return DNBSpline(U, N);
else if (myTypeCurve == GeomAbs_OffsetCurve)
return DNOffset(U, N);
return myCurve->DN(U, N);
}
gp_Vec GeomAdaptor_Curve::DNBSpline(const Standard_Real U,
const Standard_Integer N) const
{
if ((U==myFirst || U==myLast))
switch (myTypeCurve)
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
Standard_Integer Ideb = 0, Ifin = 0;
if (U==myFirst) {
aBspl->LocateU(myFirst, PosTol, Ideb, Ifin);
if (Ideb<1) Ideb=1;
if (Ideb>=Ifin) Ifin = Ideb+1;
case GeomAbs_BezierCurve:
case GeomAbs_BSplineCurve:
{
Standard_Integer aStart = 0, aFinish = 0;
if (IsBoundary(U, aStart, aFinish))
{
Handle(Geom_BSplineCurve) aBspl = Handle(Geom_BSplineCurve)::DownCast(myCurve);
return aBspl->LocalDN(U, aStart, aFinish, N);
}
if (U==myLast) {
aBspl->LocateU(myLast, PosTol, Ideb, Ifin);
if (Ifin > aBspl->NbKnots()) Ifin = aBspl->NbKnots();
if (Ideb>=Ifin) Ideb = Ifin-1;
}
return aBspl->LocalDN( U, Ideb, Ifin, N);
else
return myCurve->DN(U, N);
break;
}
return myCurve->DN( U, N);
}
gp_Vec GeomAdaptor_Curve::DNOffset(const Standard_Real U,
const Standard_Integer N) const
{
gp_Pnt aPnt;
gp_Vec aVec, aVN;
case GeomAbs_OffsetCurve:
return myNestedEvaluator->DN(U, N);
break;
switch (N)
{
case 1:
D1Offset(U, aPnt, aVN);
default: // to eliminate gcc warning
break;
case 2:
D2Offset(U, aPnt, aVec, aVN);
break;
case 3:
D3Offset(U, aPnt, aVec, aVec, aVN);
break;
default:
aVN = myCurve->DN(U, N);
}
return aVN;
return myCurve->DN(U, N);
}
//=======================================================================
@@ -1164,57 +979,3 @@ Handle(Geom_BSplineCurve) GeomAdaptor_Curve::BSpline() const
return Handle(Geom_BSplineCurve)::DownCast (myCurve);
}
// ============= Auxiliary functions ===================
Standard_Boolean AdjustDerivative(const Handle(Adaptor3d_HCurve)& theAdaptor, Standard_Integer theMaxDerivative,
Standard_Real theU, gp_Vec& theD1, gp_Vec& theD2,
gp_Vec& theD3, gp_Vec& theD4)
{
static const Standard_Real aTol = gp::Resolution();
Standard_Boolean IsDirectionChange = Standard_False;
const Standard_Real anUinfium = theAdaptor->FirstParameter();
const Standard_Real anUsupremum = theAdaptor->LastParameter();
const Standard_Real DivisionFactor = 1.e-3;
Standard_Real du;
if((anUsupremum >= RealLast()) || (anUinfium <= RealFirst()))
du = 0.0;
else
du = anUsupremum - anUinfium;
const Standard_Real aDelta = Max(du * DivisionFactor, MinStep);
//Derivative is approximated by Taylor-series
Standard_Integer anIndex = 1; //Derivative order
gp_Vec V;
do
{
V = theAdaptor->DN(theU, ++anIndex);
}
while((V.SquareMagnitude() <= aTol) && anIndex < maxDerivOrder);
Standard_Real u;
if(theU-anUinfium < aDelta)
u = theU+aDelta;
else
u = theU-aDelta;
gp_Pnt P1, P2;
theAdaptor->D0(Min(theU, u), P1);
theAdaptor->D0(Max(theU, u), P2);
gp_Vec V1(P1, P2);
IsDirectionChange = V.Dot(V1) < 0.0;
Standard_Real aSign = IsDirectionChange ? -1.0 : 1.0;
theD1 = V * aSign;
gp_Vec* aDeriv[3] = {&theD2, &theD3, &theD4};
for (Standard_Integer i = 1; i < theMaxDerivative; i++)
*(aDeriv[i-1]) = theAdaptor->DN(theU, anIndex + i) * aSign;
return IsDirectionChange;
}

View File

@@ -29,6 +29,8 @@
#include <Standard_Integer.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <Standard_Boolean.hxx>
#include <GeomEvaluator_Curve.hxx>
class Geom_Curve;
class Adaptor3d_HCurve;
class Standard_NoSuchObject;
@@ -213,68 +215,24 @@ protected:
private:
//! Computes the point of parameter U on the B-spline curve
Standard_EXPORT gp_Pnt ValueBSpline (const Standard_Real U) const;
//! Computes the point of parameter U on the offset curve
Standard_EXPORT gp_Pnt ValueOffset (const Standard_Real U) const;
//! Computes the point of parameter U on the B-spline curve
Standard_EXPORT void D0BSpline (const Standard_Real theU, gp_Pnt& theP) const;
//! Computes the point of parameter U on the offset curve
Standard_EXPORT void D0Offset (const Standard_Real theU, gp_Pnt& theP) const;
//! Computes the point of parameter U on the B-spline curve
//! and its derivative
Standard_EXPORT void D1BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const;
//! Computes the point of parameter U on the offset curve
//! and its derivative
Standard_EXPORT void D1Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV) const;
//! Computes the point of parameter U on the B-spline curve
//! and its first and second derivatives
Standard_EXPORT void D2BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2) const;
//! Computes the point of parameter U on the offset curve
//! and its first and second derivatives
Standard_EXPORT void D2Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2) const;
//! Computes the point of parameter U on the B-spline curve
//! and its first, second and third derivatives
Standard_EXPORT void D3BSpline (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2, gp_Vec& theV3) const;
//! Computes the point of parameter U on the offset curve
//! and its first, second and third derivatives
Standard_EXPORT void D3Offset (const Standard_Real theU, gp_Pnt& theP, gp_Vec& theV1, gp_Vec& theV2, gp_Vec& theV3) const;
//! The returned vector gives the value of the derivative for the
//! order of derivation N.
Standard_EXPORT gp_Vec DNBSpline (const Standard_Real theU, const Standard_Integer N) const;
//! The returned vector gives the value of the derivative for the
//! order of derivation N.
Standard_EXPORT gp_Vec DNOffset (const Standard_Real theU, const Standard_Integer N) const;
Standard_EXPORT GeomAbs_Shape LocalContinuity (const Standard_Real U1, const Standard_Real U2) const;
Standard_EXPORT void load (const Handle(Geom_Curve)& C, const Standard_Real UFirst, const Standard_Real ULast);
//! Check theU relates to start or finish point of B-spline curve and return indices of span the point is located
Standard_Boolean IsBoundary(const Standard_Real theU, Standard_Integer& theSpanStart, Standard_Integer& theSpanFinish) const;
//! Rebuilds B-spline cache
//! \param theParameter the value on the knot axis which identifies the caching span
Standard_EXPORT void RebuildCache (const Standard_Real theParameter) const;
void RebuildCache (const Standard_Real theParameter) const;
Handle(Geom_Curve) myCurve;
GeomAbs_CurveType myTypeCurve;
Standard_Real myFirst;
Standard_Real myLast;
Handle(BSplCLib_Cache) myCurveCache;
Handle(Adaptor3d_HCurve) myOffsetBaseCurveAdaptor;
Handle(BSplCLib_Cache) myCurveCache; ///< Cached data for B-spline or Bezier curve
Handle(GeomEvaluator_Curve) myNestedEvaluator; ///< Calculates value of offset curve
};

View File

@@ -266,7 +266,7 @@ private:
Standard_Real myVLast;
Standard_Real myTolU;
Standard_Real myTolV;
Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline surface
Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline or Bezier surface
protected:
GeomAbs_SurfaceType mySurfaceType;