mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
Compare commits
1 Commits
CR31498_74
...
CR0-Intera
Author | SHA1 | Date | |
---|---|---|---|
|
961713db52 |
@@ -27,11 +27,8 @@
|
|||||||
#include <Geom2d_BSplineCurve.hxx>
|
#include <Geom2d_BSplineCurve.hxx>
|
||||||
#include <Geom2dAdaptor_HCurve.hxx>
|
#include <Geom2dAdaptor_HCurve.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
#include <Geom_RectangularTrimmedSurface.hxx>
|
|
||||||
#include <Geom_TrimmedCurve.hxx>
|
|
||||||
#include <GeomAdaptor_HCurve.hxx>
|
#include <GeomAdaptor_HCurve.hxx>
|
||||||
#include <GeomAdaptor_HSurface.hxx>
|
#include <GeomAdaptor_HSurface.hxx>
|
||||||
#include <GeomConvert.hxx>
|
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <gp_Vec.hxx>
|
#include <gp_Vec.hxx>
|
||||||
#include <Precision.hxx>
|
#include <Precision.hxx>
|
||||||
@@ -303,10 +300,6 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Approx_CurveOnSurface
|
|
||||||
//purpose : Constructor
|
|
||||||
//=============================================================================
|
|
||||||
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D,
|
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D,
|
||||||
const Handle(Adaptor3d_HSurface)& Surf,
|
const Handle(Adaptor3d_HSurface)& Surf,
|
||||||
const Standard_Real First,
|
const Standard_Real First,
|
||||||
@@ -317,75 +310,14 @@ void Approx_CurveOnSurface_Eval2d::Evaluate (Standard_Integer *Dimension,
|
|||||||
const Standard_Integer MaxSegments,
|
const Standard_Integer MaxSegments,
|
||||||
const Standard_Boolean only3d,
|
const Standard_Boolean only3d,
|
||||||
const Standard_Boolean only2d)
|
const Standard_Boolean only2d)
|
||||||
: myC2D(C2D),
|
|
||||||
mySurf(Surf),
|
|
||||||
myFirst(First),
|
|
||||||
myLast(Last),
|
|
||||||
myTol(Tol),
|
|
||||||
myIsDone(Standard_False),
|
|
||||||
myHasResult(Standard_False),
|
|
||||||
myError3d(0.0),
|
|
||||||
myError2dU(0.0),
|
|
||||||
myError2dV(0.0)
|
|
||||||
{
|
|
||||||
Perform(MaxSegments, MaxDegree, S, only3d, only2d);
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Approx_CurveOnSurface
|
|
||||||
//purpose : Constructor
|
|
||||||
//=============================================================================
|
|
||||||
Approx_CurveOnSurface::Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface)& theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTol)
|
|
||||||
: myC2D(theC2D),
|
|
||||||
mySurf(theSurf),
|
|
||||||
myFirst(theFirst),
|
|
||||||
myLast(theLast),
|
|
||||||
myTol(theTol),
|
|
||||||
myIsDone(Standard_False),
|
|
||||||
myHasResult(Standard_False),
|
|
||||||
myError3d(0.0),
|
|
||||||
myError2dU(0.0),
|
|
||||||
myError2dV(0.0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : Perform
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|
||||||
const Standard_Integer theMaxDegree,
|
|
||||||
const GeomAbs_Shape theContinuity,
|
|
||||||
const Standard_Boolean theOnly3d,
|
|
||||||
const Standard_Boolean theOnly2d)
|
|
||||||
{
|
{
|
||||||
myIsDone = Standard_False;
|
myIsDone = Standard_False;
|
||||||
myHasResult = Standard_False;
|
if(only3d && only2d) throw Standard_ConstructionError();
|
||||||
myError2dU = 0.0;
|
GeomAbs_Shape Order = S;
|
||||||
myError2dV = 0.0;
|
|
||||||
myError3d = 0.0;
|
|
||||||
|
|
||||||
if(theOnly3d && theOnly2d) throw Standard_ConstructionError();
|
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = C2D->Trim( First, Last, Precision::PConfusion() );
|
||||||
|
|
||||||
Handle( Adaptor2d_HCurve2d ) TrimmedC2D = myC2D->Trim( myFirst, myLast, Precision::PConfusion() );
|
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, Surf );
|
||||||
|
|
||||||
Standard_Boolean isU, isForward;
|
|
||||||
Standard_Real aParam;
|
|
||||||
if (theOnly3d && isIsoLine(TrimmedC2D, isU, aParam, isForward))
|
|
||||||
{
|
|
||||||
if (buildC3dOnIsoLine(TrimmedC2D, isU, aParam, isForward))
|
|
||||||
{
|
|
||||||
myIsDone = Standard_True;
|
|
||||||
myHasResult = Standard_True;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Adaptor3d_CurveOnSurface COnS( TrimmedC2D, mySurf );
|
|
||||||
Handle(Adaptor3d_HCurveOnSurface) HCOnS = new Adaptor3d_HCurveOnSurface();
|
Handle(Adaptor3d_HCurveOnSurface) HCOnS = new Adaptor3d_HCurveOnSurface();
|
||||||
HCOnS->Set(COnS);
|
HCOnS->Set(COnS);
|
||||||
|
|
||||||
@@ -395,34 +327,37 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
Handle(TColStd_HArray1OfReal) ThreeDTol;
|
Handle(TColStd_HArray1OfReal) ThreeDTol;
|
||||||
|
|
||||||
// create evaluators and choose appropriate one
|
// create evaluators and choose appropriate one
|
||||||
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, myFirst, myLast);
|
Approx_CurveOnSurface_Eval3d Eval3dCvOnSurf (HCOnS, First, Last);
|
||||||
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, myFirst, myLast);
|
Approx_CurveOnSurface_Eval2d Eval2dCvOnSurf ( TrimmedC2D, First, Last);
|
||||||
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, myFirst, myLast);
|
Approx_CurveOnSurface_Eval EvalCvOnSurf (HCOnS, TrimmedC2D, First, Last);
|
||||||
AdvApprox_EvaluatorFunction* EvalPtr;
|
AdvApprox_EvaluatorFunction* EvalPtr;
|
||||||
if ( theOnly3d ) EvalPtr = &Eval3dCvOnSurf;
|
if ( only3d ) EvalPtr = &Eval3dCvOnSurf;
|
||||||
else if ( theOnly2d ) EvalPtr = &Eval2dCvOnSurf;
|
else if ( only2d ) EvalPtr = &Eval2dCvOnSurf;
|
||||||
else EvalPtr = &EvalCvOnSurf;
|
else EvalPtr = &EvalCvOnSurf;
|
||||||
|
|
||||||
// Initialization for 2d approximation
|
// Initialization for 2d approximation
|
||||||
if(!theOnly3d) {
|
if(!only3d) {
|
||||||
Num1DSS = 2;
|
Num1DSS = 2;
|
||||||
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
|
OneDTol = new TColStd_HArray1OfReal(1,Num1DSS);
|
||||||
|
|
||||||
Standard_Real TolU, TolV;
|
Standard_Real TolU, TolV;
|
||||||
|
|
||||||
TolU = mySurf->UResolution(myTol)/2;
|
TolU = Surf->UResolution(Tol)/2;
|
||||||
TolV = mySurf->VResolution(myTol)/2;
|
TolV = Surf->VResolution(Tol)/2;
|
||||||
|
|
||||||
OneDTol->SetValue(1,TolU);
|
OneDTol->SetValue(1,TolU);
|
||||||
OneDTol->SetValue(2,TolV);
|
OneDTol->SetValue(2,TolV);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!theOnly2d) {
|
if(!only2d) {
|
||||||
Num3DSS=1;
|
Num3DSS=1;
|
||||||
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
|
ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
|
||||||
ThreeDTol->Init(myTol/2);
|
ThreeDTol->Init(Tol/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
myError2dU = 0;
|
||||||
|
myError2dV = 0;
|
||||||
|
myError3d = 0;
|
||||||
|
|
||||||
Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
|
Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
|
||||||
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
|
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
|
||||||
@@ -434,8 +369,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
|
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
|
||||||
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
|
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
|
||||||
OneDTol, TwoDTolNul, ThreeDTol,
|
OneDTol, TwoDTolNul, ThreeDTol,
|
||||||
myFirst, myLast, theContinuity,
|
First, Last, Order,
|
||||||
theMaxDegree, theMaxSegments,
|
MaxDegree, MaxSegments,
|
||||||
*EvalPtr, CutTool);
|
*EvalPtr, CutTool);
|
||||||
|
|
||||||
myIsDone = aApprox.IsDone();
|
myIsDone = aApprox.IsDone();
|
||||||
@@ -446,14 +381,14 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
|
Handle(TColStd_HArray1OfInteger) Mults = aApprox.Multiplicities();
|
||||||
Standard_Integer Degree = aApprox.Degree();
|
Standard_Integer Degree = aApprox.Degree();
|
||||||
|
|
||||||
if(!theOnly2d)
|
if(!only2d)
|
||||||
{
|
{
|
||||||
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
|
TColgp_Array1OfPnt Poles(1,aApprox.NbPoles());
|
||||||
aApprox.Poles(1,Poles);
|
aApprox.Poles(1,Poles);
|
||||||
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
|
myCurve3d = new Geom_BSplineCurve(Poles, Knots->Array1(), Mults->Array1(), Degree);
|
||||||
myError3d = aApprox.MaxError(3, 1);
|
myError3d = aApprox.MaxError(3, 1);
|
||||||
}
|
}
|
||||||
if(!theOnly3d)
|
if(!only3d)
|
||||||
{
|
{
|
||||||
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
|
TColgp_Array1OfPnt2d Poles2d(1,aApprox.NbPoles());
|
||||||
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
|
TColStd_Array1OfReal Poles1dU(1,aApprox.NbPoles());
|
||||||
@@ -469,6 +404,8 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::IsDone() const
|
Standard_Boolean Approx_CurveOnSurface::IsDone() const
|
||||||
@@ -506,215 +443,3 @@ void Approx_CurveOnSurface::Perform(const Standard_Integer theMaxSegments,
|
|||||||
return myError2dV;
|
return myError2dV;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : isIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward) const
|
|
||||||
{
|
|
||||||
// These variables are used to check line state (vertical or horizontal).
|
|
||||||
Standard_Boolean isAppropriateType = Standard_False;
|
|
||||||
gp_Pnt2d aLoc2d;
|
|
||||||
gp_Dir2d aDir2d;
|
|
||||||
|
|
||||||
// Test type.
|
|
||||||
const GeomAbs_CurveType aType = theC2D->GetType();
|
|
||||||
if (aType == GeomAbs_Line)
|
|
||||||
{
|
|
||||||
gp_Lin2d aLin2d = theC2D->Line();
|
|
||||||
aLoc2d = aLin2d.Location();
|
|
||||||
aDir2d = aLin2d.Direction();
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BSplineCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BSplineCurve) aBSpline2d = theC2D->BSpline();
|
|
||||||
if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBSpline2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BezierCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BezierCurve) aBezier2d = theC2D->Bezier();
|
|
||||||
if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBezier2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAppropriateType)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
// Check line to be vertical or horizontal.
|
|
||||||
if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Horizontal line. V = const.
|
|
||||||
theIsU = Standard_False;
|
|
||||||
theParam = aLoc2d.Y();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DX2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
else if (aDir2d.IsParallel(gp::DY2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Vertical line. U = const.
|
|
||||||
theIsU = Standard_True;
|
|
||||||
theParam = aLoc2d.X();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DY2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <GeomLib.hxx>
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : buildC3dOnIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Standard_Boolean Approx_CurveOnSurface::buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward)
|
|
||||||
{
|
|
||||||
// Convert adapter to the appropriate type.
|
|
||||||
Handle(GeomAdaptor_HSurface) aGeomAdapter = Handle(GeomAdaptor_HSurface)::DownCast(mySurf);
|
|
||||||
if (aGeomAdapter.IsNull())
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
if (mySurf->GetType() == GeomAbs_Sphere)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
// Extract isoline
|
|
||||||
Handle(Geom_Surface) aSurf = aGeomAdapter->ChangeSurface().Surface();
|
|
||||||
Handle(Geom_Curve) aC3d;
|
|
||||||
|
|
||||||
gp_Pnt2d aF2d = theC2D->Value(theC2D->FirstParameter());
|
|
||||||
gp_Pnt2d aL2d = theC2D->Value(theC2D->LastParameter());
|
|
||||||
|
|
||||||
Standard_Boolean isToTrim = Standard_True;
|
|
||||||
Standard_Real U1, U2, V1, V2;
|
|
||||||
aSurf->Bounds(U1, U2, V1, V2);
|
|
||||||
|
|
||||||
if (theIsU)
|
|
||||||
{
|
|
||||||
Standard_Real aV1Param = Min(aF2d.Y(), aL2d.Y());
|
|
||||||
Standard_Real aV2Param = Max(aF2d.Y(), aL2d.Y());
|
|
||||||
if (aV2Param < V1 - myTol || aV1Param > V2 + myTol)
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
else if (Precision::IsInfinite(V1) || Precision::IsInfinite(V2))
|
|
||||||
{
|
|
||||||
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
aSurf = new Geom_RectangularTrimmedSurface(aSurf, U1, U2, aV1Param, aV2Param);
|
|
||||||
isToTrim = Standard_False;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aV1Param = Max(aV1Param, V1);
|
|
||||||
aV2Param = Min(aV2Param, V2);
|
|
||||||
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aC3d = aSurf->UIso(theParam);
|
|
||||||
if (isToTrim)
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aV1Param, aV2Param);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Standard_Real aU1Param = Min(aF2d.X(), aL2d.X());
|
|
||||||
Standard_Real aU2Param = Max(aF2d.X(), aL2d.X());
|
|
||||||
if (aU2Param < U1 - myTol || aU1Param > U2 + myTol)
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
else if (Precision::IsInfinite(U1) || Precision::IsInfinite(U2))
|
|
||||||
{
|
|
||||||
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
aSurf = new Geom_RectangularTrimmedSurface(aSurf, aU1Param, aU2Param, V1, V2);
|
|
||||||
isToTrim = Standard_False;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aU1Param = Max(aU1Param, U1);
|
|
||||||
aU2Param = Min(aU2Param, U2);
|
|
||||||
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aC3d = aSurf->VIso(theParam);
|
|
||||||
if (isToTrim)
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aU1Param, aU2Param);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert arbitrary curve type to the b-spline.
|
|
||||||
myCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular);
|
|
||||||
if (!theIsForward)
|
|
||||||
myCurve3d->Reverse();
|
|
||||||
|
|
||||||
// Rebuild parameterization for the 3d curve to have the same parameterization with
|
|
||||||
// a two-dimensional curve.
|
|
||||||
TColStd_Array1OfReal aKnots = myCurve3d->Knots();
|
|
||||||
BSplCLib::Reparametrize(theC2D->FirstParameter(), theC2D->LastParameter(), aKnots);
|
|
||||||
myCurve3d->SetKnots(aKnots);
|
|
||||||
|
|
||||||
// Evaluate error.
|
|
||||||
myError3d = 0.0;
|
|
||||||
|
|
||||||
const Standard_Real aParF = myFirst;
|
|
||||||
const Standard_Real aParL = myLast;
|
|
||||||
const Standard_Integer aNbPnt = 23;
|
|
||||||
for(Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
|
|
||||||
{
|
|
||||||
const Standard_Real aPar = aParF + ((aParL - aParF) * anIdx) / aNbPnt;
|
|
||||||
|
|
||||||
const gp_Pnt2d aPnt2d = theC2D->Value(aPar);
|
|
||||||
|
|
||||||
const gp_Pnt aPntC3D = myCurve3d->Value(aPar);
|
|
||||||
const gp_Pnt aPntC2D = mySurf->Value(aPnt2d.X(), aPnt2d.Y());
|
|
||||||
|
|
||||||
const Standard_Real aSqDeviation = aPntC3D.SquareDistance(aPntC2D);
|
|
||||||
myError3d = Max(aSqDeviation, myError3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
myError3d = Sqrt(myError3d);
|
|
||||||
|
|
||||||
// Target tolerance is not obtained. This situation happens for isolines on the sphere.
|
|
||||||
// OCCT is unable to convert it keeping original parameterization, while the geometric
|
|
||||||
// form of the result is entirely identical. In that case, it is better to utilize
|
|
||||||
// a general-purpose approach.
|
|
||||||
if (myError3d > myTol)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
@@ -40,22 +40,9 @@ public:
|
|||||||
|
|
||||||
DEFINE_STANDARD_ALLOC
|
DEFINE_STANDARD_ALLOC
|
||||||
|
|
||||||
//! This constructor calls perform method. This constructor is deprecated.
|
|
||||||
Standard_DEPRECATED("This constructor is deprecated. Use other constructor and perform method instead.")
|
|
||||||
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D, const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
|
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& C2D, const Handle(Adaptor3d_HSurface)& Surf, const Standard_Real First, const Standard_Real Last, const Standard_Real Tol, const GeomAbs_Shape Continuity, const Standard_Integer MaxDegree, const Standard_Integer MaxSegments, const Standard_Boolean Only3d = Standard_False, const Standard_Boolean Only2d = Standard_False);
|
||||||
|
|
||||||
//! This constructor does not call perform method.
|
|
||||||
//! @param theC2D 2D Curve to be approximated in 3D.
|
|
||||||
//! @param theSurf Surface where 2D curve is located.
|
|
||||||
//! @param theFirst First parameter of resulting curve.
|
|
||||||
//! @param theFirst Last parameter of resulting curve.
|
|
||||||
//! @param theTol Computation tolerance.
|
|
||||||
Standard_EXPORT Approx_CurveOnSurface(const Handle(Adaptor2d_HCurve2d)& theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface)& theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTol);
|
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean IsDone() const;
|
Standard_EXPORT Standard_Boolean IsDone() const;
|
||||||
|
|
||||||
Standard_EXPORT Standard_Boolean HasResult() const;
|
Standard_EXPORT Standard_Boolean HasResult() const;
|
||||||
@@ -72,64 +59,18 @@ public:
|
|||||||
//! 2d Curve
|
//! 2d Curve
|
||||||
Standard_EXPORT Standard_Real MaxError2dV() const;
|
Standard_EXPORT Standard_Real MaxError2dV() const;
|
||||||
|
|
||||||
//! Constructs the 3d curve. Input parameters are ignored when the input curve is
|
|
||||||
//! U-isoline or V-isoline.
|
|
||||||
//! @param theMaxSegments Maximal number of segments in the resulting spline.
|
|
||||||
//! @param theMaxDegree Maximal degree of the result.
|
|
||||||
//! @param theContinuity Resulting continuity.
|
|
||||||
//! @param theOnly3d Determines building only 3D curve.
|
|
||||||
//! @param theOnly2d Determines building only 2D curve.
|
|
||||||
Standard_EXPORT void Perform(const Standard_Integer theMaxSegments,
|
|
||||||
const Standard_Integer theMaxDegree,
|
|
||||||
const GeomAbs_Shape theContinuity,
|
|
||||||
const Standard_Boolean theOnly3d = Standard_False,
|
|
||||||
const Standard_Boolean theOnly2d = Standard_False);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
|
|
||||||
//! or geometric line. This line should have natural parameterization.
|
|
||||||
//! @param theC2D Trimmed curve to be checked.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 2d curve is a line and Standard_False otherwise.
|
|
||||||
Standard_Boolean isIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward) const;
|
|
||||||
|
|
||||||
//! Builds 3D curve for a isoline. This method takes corresponding isoline from
|
|
||||||
//! the input surface.
|
|
||||||
//! @param theC2D Trimmed curve to be approximated.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 3d curve is built and Standard_False otherwise.
|
|
||||||
Standard_Boolean buildC3dOnIsoLine(const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Approx_CurveOnSurface& operator= (const Approx_CurveOnSurface&);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Input curve.
|
|
||||||
const Handle(Adaptor2d_HCurve2d) myC2D;
|
|
||||||
|
|
||||||
//! Input surface.
|
|
||||||
const Handle(Adaptor3d_HSurface) mySurf;
|
|
||||||
|
|
||||||
//! First parameter of the result.
|
|
||||||
const Standard_Real myFirst;
|
|
||||||
|
|
||||||
//! Last parameter of the result.
|
|
||||||
const Standard_Real myLast;
|
|
||||||
|
|
||||||
//! Tolerance.
|
|
||||||
Standard_Real myTol;
|
|
||||||
|
|
||||||
Handle(Geom2d_BSplineCurve) myCurve2d;
|
Handle(Geom2d_BSplineCurve) myCurve2d;
|
||||||
Handle(Geom_BSplineCurve) myCurve3d;
|
Handle(Geom_BSplineCurve) myCurve3d;
|
||||||
|
@@ -363,8 +363,9 @@ void BRepAlgo_NormalProjection::SetDefaultParams()
|
|||||||
#ifdef OCCT_DEBUG_CHRONO
|
#ifdef OCCT_DEBUG_CHRONO
|
||||||
InitChron(chr_approx);
|
InitChron(chr_approx);
|
||||||
#endif
|
#endif
|
||||||
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
|
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
|
||||||
appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
|
myContinuity, myMaxDegree, myMaxSeg,
|
||||||
|
Only3d, Only2d);
|
||||||
#ifdef OCCT_DEBUG_CHRONO
|
#ifdef OCCT_DEBUG_CHRONO
|
||||||
ResultChron(chr_approx,t_approx);
|
ResultChron(chr_approx,t_approx);
|
||||||
approx_count++;
|
approx_count++;
|
||||||
|
@@ -330,9 +330,8 @@ static Standard_Boolean SameParameter(TopoDS_Edge& E,
|
|||||||
if (!HasPCurves(E))
|
if (!HasPCurves(E))
|
||||||
{
|
{
|
||||||
Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( Pcurv );
|
Handle(Geom2dAdaptor_HCurve) HC2d = new Geom2dAdaptor_HCurve( Pcurv );
|
||||||
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
|
Approx_CurveOnSurface AppCurve(HC2d, S, HC2d->FirstParameter(), HC2d->LastParameter(),
|
||||||
Precision::Confusion());
|
Precision::Confusion(), GeomAbs_C1, 10, 10, Standard_True);
|
||||||
AppCurve.Perform(10, 10, GeomAbs_C1, Standard_True);
|
|
||||||
if (AppCurve.IsDone() && AppCurve.HasResult())
|
if (AppCurve.IsDone() && AppCurve.HasResult())
|
||||||
{
|
{
|
||||||
C3d = AppCurve.Curve3d();
|
C3d = AppCurve.Curve3d();
|
||||||
|
@@ -2169,8 +2169,9 @@ static Standard_Real SmartParameter(Draft_EdgeInfo& Einf,
|
|||||||
Standard_Real Udeb, Ufin;
|
Standard_Real Udeb, Ufin;
|
||||||
ProjCurve.Bounds(1, Udeb, Ufin);
|
ProjCurve.Bounds(1, Udeb, Ufin);
|
||||||
Standard_Integer MaxSeg = 20 + HProjector->NbIntervals(GeomAbs_C3);
|
Standard_Integer MaxSeg = 20 + HProjector->NbIntervals(GeomAbs_C3);
|
||||||
Approx_CurveOnSurface appr(HProjector, hsur2, Udeb, Ufin, Tol);
|
Approx_CurveOnSurface appr( HProjector, hsur2, Udeb, Ufin, Tol,
|
||||||
appr.Perform(MaxSeg, 10, GeomAbs_C1, Standard_False, Standard_False);
|
GeomAbs_C1, 10, MaxSeg,
|
||||||
|
Standard_False, Standard_False );
|
||||||
Einf.ChangeSecondPC() = appr.Curve2d();
|
Einf.ChangeSecondPC() = appr.Curve2d();
|
||||||
Einf.ChangeGeometry() = appr.Curve3d();
|
Einf.ChangeGeometry() = appr.Curve3d();
|
||||||
Einf.SetNewGeometry( Standard_True );
|
Einf.SetNewGeometry( Standard_True );
|
||||||
|
@@ -1031,8 +1031,9 @@ void GeomInt_IntSS::TreatRLine(const Handle(IntPatch_RLine)& theRL,
|
|||||||
//approximation of curve on surface.
|
//approximation of curve on surface.
|
||||||
Standard_Integer aMaxDeg = 8;
|
Standard_Integer aMaxDeg = 8;
|
||||||
Standard_Integer aMaxSeg = 1000;
|
Standard_Integer aMaxSeg = 1000;
|
||||||
Approx_CurveOnSurface anApp(anAHC2d, aGAHS, tf, tl, Precision::Confusion());
|
Approx_CurveOnSurface anApp(anAHC2d, aGAHS, tf, tl, Precision::Confusion(),
|
||||||
anApp.Perform(aMaxSeg, aMaxDeg, GeomAbs_C1, Standard_True, Standard_False);
|
GeomAbs_C1, aMaxDeg, aMaxSeg,
|
||||||
|
Standard_True, Standard_False);
|
||||||
if(!anApp.HasResult())
|
if(!anApp.HasResult())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -48,7 +48,6 @@
|
|||||||
#include <Adaptor3d_HSurface.hxx>
|
#include <Adaptor3d_HSurface.hxx>
|
||||||
#include <AdvApprox_ApproxAFunction.hxx>
|
#include <AdvApprox_ApproxAFunction.hxx>
|
||||||
#include <AdvApprox_PrefAndRec.hxx>
|
#include <AdvApprox_PrefAndRec.hxx>
|
||||||
#include <Approx_CurveOnSurface.hxx>
|
|
||||||
#include <BSplCLib.hxx>
|
#include <BSplCLib.hxx>
|
||||||
#include <BSplSLib.hxx>
|
#include <BSplSLib.hxx>
|
||||||
#include <CSLib.hxx>
|
#include <CSLib.hxx>
|
||||||
@@ -1096,6 +1095,7 @@ void GeomLib::BuildCurve3d(const Standard_Real Tolerance,
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
Standard_Integer curve_not_computed = 1 ;
|
||||||
MaxDeviation = 0.0e0 ;
|
MaxDeviation = 0.0e0 ;
|
||||||
AverageDeviation = 0.0e0 ;
|
AverageDeviation = 0.0e0 ;
|
||||||
Handle(GeomAdaptor_HSurface) geom_adaptor_surface_ptr (Handle(GeomAdaptor_HSurface)::DownCast(Curve.GetSurface()) );
|
Handle(GeomAdaptor_HSurface) geom_adaptor_surface_ptr (Handle(GeomAdaptor_HSurface)::DownCast(Curve.GetSurface()) );
|
||||||
@@ -1126,23 +1126,11 @@ void GeomLib::BuildCurve3d(const Standard_Real Tolerance,
|
|||||||
NewCurvePtr =
|
NewCurvePtr =
|
||||||
GeomLib::To3d(axes,
|
GeomLib::To3d(axes,
|
||||||
geom2d_curve.Curve());
|
geom2d_curve.Curve());
|
||||||
return;
|
curve_not_computed = 0 ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle(Adaptor2d_HCurve2d) TrimmedC2D = geom_adaptor_curve_ptr->Trim (FirstParameter, LastParameter, Precision::PConfusion());
|
|
||||||
|
|
||||||
Standard_Boolean isU, isForward;
|
|
||||||
Standard_Real aParam;
|
|
||||||
if (isIsoLine(TrimmedC2D, isU, aParam, isForward))
|
|
||||||
{
|
|
||||||
NewCurvePtr = buildC3dOnIsoLine (TrimmedC2D, geom_adaptor_surface_ptr, FirstParameter, LastParameter, Tolerance, isU, aParam, isForward);
|
|
||||||
if (!NewCurvePtr.IsNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (curve_not_computed) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Entree
|
// Entree
|
||||||
@@ -1194,6 +1182,7 @@ void GeomLib::BuildCurve3d(const Standard_Real Tolerance,
|
|||||||
AverageDeviation = anApproximator.AverageError(3,1) ;
|
AverageDeviation = anApproximator.AverageError(3,1) ;
|
||||||
NewCurvePtr = aCurvePtr ;
|
NewCurvePtr = aCurvePtr ;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -2794,218 +2783,3 @@ static Standard_Boolean CompareWeightPoles(const TColgp_Array1OfPnt& thePoles1,
|
|||||||
//
|
//
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : isIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Standard_Boolean GeomLib::isIsoLine (const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward)
|
|
||||||
{
|
|
||||||
// These variables are used to check line state (vertical or horizontal).
|
|
||||||
Standard_Boolean isAppropriateType = Standard_False;
|
|
||||||
gp_Pnt2d aLoc2d;
|
|
||||||
gp_Dir2d aDir2d;
|
|
||||||
|
|
||||||
// Test type.
|
|
||||||
const GeomAbs_CurveType aType = theC2D->GetType();
|
|
||||||
if (aType == GeomAbs_Line)
|
|
||||||
{
|
|
||||||
gp_Lin2d aLin2d = theC2D->Line();
|
|
||||||
aLoc2d = aLin2d.Location();
|
|
||||||
aDir2d = aLin2d.Direction();
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BSplineCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BSplineCurve) aBSpline2d = theC2D->BSpline();
|
|
||||||
if (aBSpline2d->Degree() != 1 || aBSpline2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBSpline2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBSpline2d->Pole(1), aBSpline2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
else if (aType == GeomAbs_BezierCurve)
|
|
||||||
{
|
|
||||||
Handle(Geom2d_BezierCurve) aBezier2d = theC2D->Bezier();
|
|
||||||
if (aBezier2d->Degree() != 1 || aBezier2d->NbPoles() != 2)
|
|
||||||
return Standard_False; // Not a line or uneven parameterization.
|
|
||||||
|
|
||||||
aLoc2d = aBezier2d->Pole(1);
|
|
||||||
|
|
||||||
// Vector should be non-degenerated.
|
|
||||||
gp_Vec2d aVec2d(aBezier2d->Pole(1), aBezier2d->Pole(2));
|
|
||||||
if (aVec2d.SquareMagnitude() < Precision::Confusion())
|
|
||||||
return Standard_False; // Degenerated spline.
|
|
||||||
aDir2d = aVec2d;
|
|
||||||
|
|
||||||
isAppropriateType = Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isAppropriateType)
|
|
||||||
return Standard_False;
|
|
||||||
|
|
||||||
// Check line to be vertical or horizontal.
|
|
||||||
if (aDir2d.IsParallel(gp::DX2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Horizontal line. V = const.
|
|
||||||
theIsU = Standard_False;
|
|
||||||
theParam = aLoc2d.Y();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DX2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
else if (aDir2d.IsParallel(gp::DY2d(), Precision::Angular()))
|
|
||||||
{
|
|
||||||
// Vertical line. U = const.
|
|
||||||
theIsU = Standard_True;
|
|
||||||
theParam = aLoc2d.X();
|
|
||||||
theIsForward = aDir2d.Dot(gp::DY2d()) > 0.0;
|
|
||||||
return Standard_True;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard_False;
|
|
||||||
}
|
|
||||||
|
|
||||||
//=============================================================================
|
|
||||||
//function : buildC3dOnIsoLine
|
|
||||||
//purpose :
|
|
||||||
//=============================================================================
|
|
||||||
Handle(Geom_Curve) GeomLib::buildC3dOnIsoLine (const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface) theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTolerance,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward)
|
|
||||||
{
|
|
||||||
// Convert adapter to the appropriate type.
|
|
||||||
Handle(GeomAdaptor_HSurface) aGeomAdapter = Handle(GeomAdaptor_HSurface)::DownCast(theSurf);
|
|
||||||
if (aGeomAdapter.IsNull())
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
|
|
||||||
if (theSurf->GetType() == GeomAbs_Sphere)
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
|
|
||||||
// Extract isoline
|
|
||||||
Handle(Geom_Surface) aSurf = aGeomAdapter->ChangeSurface().Surface();
|
|
||||||
Handle(Geom_Curve) aC3d;
|
|
||||||
|
|
||||||
gp_Pnt2d aF2d = theC2D->Value(theC2D->FirstParameter());
|
|
||||||
gp_Pnt2d aL2d = theC2D->Value(theC2D->LastParameter());
|
|
||||||
|
|
||||||
Standard_Boolean isToTrim = Standard_True;
|
|
||||||
Standard_Real U1, U2, V1, V2;
|
|
||||||
aSurf->Bounds(U1, U2, V1, V2);
|
|
||||||
|
|
||||||
if (theIsU)
|
|
||||||
{
|
|
||||||
Standard_Real aV1Param = Min(aF2d.Y(), aL2d.Y());
|
|
||||||
Standard_Real aV2Param = Max(aF2d.Y(), aL2d.Y());
|
|
||||||
if (aV2Param < V1 - theTolerance || aV1Param > V2 + theTolerance)
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
else if (Precision::IsInfinite(V1) || Precision::IsInfinite(V2))
|
|
||||||
{
|
|
||||||
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
aSurf = new Geom_RectangularTrimmedSurface(aSurf, U1, U2, aV1Param, aV2Param);
|
|
||||||
isToTrim = Standard_False;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aV1Param = Max(aV1Param, V1);
|
|
||||||
aV2Param = Min(aV2Param, V2);
|
|
||||||
if (Abs(aV2Param - aV1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aC3d = aSurf->UIso(theParam);
|
|
||||||
if (isToTrim)
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aV1Param, aV2Param);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Standard_Real aU1Param = Min(aF2d.X(), aL2d.X());
|
|
||||||
Standard_Real aU2Param = Max(aF2d.X(), aL2d.X());
|
|
||||||
if (aU2Param < U1 - theTolerance || aU1Param > U2 + theTolerance)
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
else if (Precision::IsInfinite(U1) || Precision::IsInfinite(U2))
|
|
||||||
{
|
|
||||||
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
aSurf = new Geom_RectangularTrimmedSurface(aSurf, aU1Param, aU2Param, V1, V2);
|
|
||||||
isToTrim = Standard_False;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
aU1Param = Max(aU1Param, U1);
|
|
||||||
aU2Param = Min(aU2Param, U2);
|
|
||||||
if (Abs(aU2Param - aU1Param) < Precision::PConfusion())
|
|
||||||
{
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
aC3d = aSurf->VIso(theParam);
|
|
||||||
if (isToTrim)
|
|
||||||
aC3d = new Geom_TrimmedCurve(aC3d, aU1Param, aU2Param);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert arbitrary curve type to the b-spline.
|
|
||||||
Handle(Geom_BSplineCurve) aCurve3d = GeomConvert::CurveToBSplineCurve(aC3d, Convert_QuasiAngular);
|
|
||||||
if (!theIsForward)
|
|
||||||
aCurve3d->Reverse();
|
|
||||||
|
|
||||||
// Rebuild parameterization for the 3d curve to have the same parameterization with
|
|
||||||
// a two-dimensional curve.
|
|
||||||
TColStd_Array1OfReal aKnots = aCurve3d->Knots();
|
|
||||||
BSplCLib::Reparametrize(theC2D->FirstParameter(), theC2D->LastParameter(), aKnots);
|
|
||||||
aCurve3d->SetKnots(aKnots);
|
|
||||||
|
|
||||||
// Evaluate error.
|
|
||||||
Standard_Real anError3d = 0.0;
|
|
||||||
|
|
||||||
const Standard_Real aParF = theFirst;
|
|
||||||
const Standard_Real aParL = theLast;
|
|
||||||
const Standard_Integer aNbPnt = 23;
|
|
||||||
for (Standard_Integer anIdx = 0; anIdx <= aNbPnt; ++anIdx)
|
|
||||||
{
|
|
||||||
const Standard_Real aPar = aParF + ((aParL - aParF) * anIdx) / aNbPnt;
|
|
||||||
|
|
||||||
const gp_Pnt2d aPnt2d = theC2D->Value(aPar);
|
|
||||||
|
|
||||||
const gp_Pnt aPntC3D = aCurve3d->Value(aPar);
|
|
||||||
const gp_Pnt aPntC2D = theSurf->Value(aPnt2d.X(), aPnt2d.Y());
|
|
||||||
|
|
||||||
const Standard_Real aSqDeviation = aPntC3D.SquareDistance(aPntC2D);
|
|
||||||
anError3d = Max (aSqDeviation, anError3d);
|
|
||||||
}
|
|
||||||
|
|
||||||
anError3d = Sqrt(anError3d);
|
|
||||||
|
|
||||||
// Target tolerance is not obtained. This situation happens for isolines on the sphere.
|
|
||||||
// OCCT is unable to convert it keeping original parameterization, while the geometric
|
|
||||||
// form of the result is entirely identical. In that case, it is better to utilize
|
|
||||||
// a general-purpose approach.
|
|
||||||
if (anError3d > theTolerance)
|
|
||||||
return Handle(Geom_Curve)();
|
|
||||||
|
|
||||||
return aCurve3d;
|
|
||||||
}
|
|
||||||
|
@@ -34,8 +34,6 @@ class gp_Ax2;
|
|||||||
class Geom2d_Curve;
|
class Geom2d_Curve;
|
||||||
class gp_GTrsf2d;
|
class gp_GTrsf2d;
|
||||||
class Adaptor3d_CurveOnSurface;
|
class Adaptor3d_CurveOnSurface;
|
||||||
class Adaptor2d_HCurve2d;
|
|
||||||
class Adaptor3d_HSurface;
|
|
||||||
class Geom_BoundedCurve;
|
class Geom_BoundedCurve;
|
||||||
class gp_Pnt;
|
class gp_Pnt;
|
||||||
class gp_Vec;
|
class gp_Vec;
|
||||||
@@ -225,37 +223,12 @@ public:
|
|||||||
const Standard_Real V2,
|
const Standard_Real V2,
|
||||||
const Standard_Real Tol);
|
const Standard_Real Tol);
|
||||||
|
|
||||||
//! Checks whether the 2d curve is a isoline. It can be represented by b-spline, bezier,
|
|
||||||
//! or geometric line. This line should have natural parameterization.
|
|
||||||
//! @param theC2D Trimmed curve to be checked.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 2d curve is a line and Standard_False otherwise.
|
|
||||||
Standard_EXPORT static Standard_Boolean isIsoLine (const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
Standard_Boolean& theIsU,
|
|
||||||
Standard_Real& theParam,
|
|
||||||
Standard_Boolean& theIsForward);
|
|
||||||
|
|
||||||
//! Builds 3D curve for a isoline. This method takes corresponding isoline from
|
|
||||||
//! the input surface.
|
|
||||||
//! @param theC2D Trimmed curve to be approximated.
|
|
||||||
//! @param theIsU Flag indicating that line is u const.
|
|
||||||
//! @param theParam Line parameter.
|
|
||||||
//! @param theIsForward Flag indicating forward parameterization on a isoline.
|
|
||||||
//! @return Standard_True when 3d curve is built and Standard_False otherwise.
|
|
||||||
Standard_EXPORT static Handle(Geom_Curve) buildC3dOnIsoLine (const Handle(Adaptor2d_HCurve2d) theC2D,
|
|
||||||
const Handle(Adaptor3d_HSurface) theSurf,
|
|
||||||
const Standard_Real theFirst,
|
|
||||||
const Standard_Real theLast,
|
|
||||||
const Standard_Real theTolerance,
|
|
||||||
const Standard_Boolean theIsU,
|
|
||||||
const Standard_Real theParam,
|
|
||||||
const Standard_Boolean theIsForward);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
@@ -300,9 +300,10 @@ Handle(Geom2d_Curve) GeomPlate_BuildPlateSurface::ProjectCurve(const Handle(Ada
|
|||||||
Projector.Bounds(1, Udeb, Ufin);
|
Projector.Bounds(1, Udeb, Ufin);
|
||||||
|
|
||||||
MaxSeg = 20 + HProjector->NbIntervals(GeomAbs_C3);
|
MaxSeg = 20 + HProjector->NbIntervals(GeomAbs_C3);
|
||||||
Approx_CurveOnSurface appr(HProjector, hsur, Udeb, Ufin, myTol3d);
|
Approx_CurveOnSurface appr(HProjector, hsur, Udeb, Ufin, myTol3d,
|
||||||
appr.Perform(MaxSeg, MaxDegree, Continuity, Standard_False, Standard_True);
|
Continuity, MaxDegree, MaxSeg,
|
||||||
|
Standard_False, Standard_True);
|
||||||
|
|
||||||
Curve2d = appr.Curve2d();
|
Curve2d = appr.Curve2d();
|
||||||
}
|
}
|
||||||
#if DRAW
|
#if DRAW
|
||||||
|
@@ -340,8 +340,8 @@ Handle(Geom_Curve) GeomProjLib::Project( const Handle(Geom_Curve)& C,
|
|||||||
Standard_Real f,l;
|
Standard_Real f,l;
|
||||||
Proj.Bounds(1,f,l);
|
Proj.Bounds(1,f,l);
|
||||||
Handle(Adaptor2d_HCurve2d) HC2d = Proj.Trim(f,l,TolU);
|
Handle(Adaptor2d_HCurve2d) HC2d = Proj.Trim(f,l,TolU);
|
||||||
Approx_CurveOnSurface Approx(HC2d, HS, f, l, Tol);
|
Approx_CurveOnSurface Approx(HC2d, HS, f, l, Tol,
|
||||||
Approx.Perform(16, 14, GeomAbs_C2, Standard_True);
|
GeomAbs_C2,14,16,Standard_True);
|
||||||
|
|
||||||
// ici, on a toujours un type BSpline.
|
// ici, on a toujours un type BSpline.
|
||||||
if (Approx.IsDone() && Approx.HasResult())
|
if (Approx.IsDone() && Approx.HasResult())
|
||||||
|
@@ -367,8 +367,9 @@ static Standard_Integer gproject(Draw_Interpretor& di, Standard_Integer n, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d);
|
Approx_CurveOnSurface appr(HPCur, hsur, Udeb, Ufin, myTol3d,
|
||||||
appr.Perform(myMaxSeg, myMaxDegree, myContinuity, Only3d, Only2d);
|
myContinuity, myMaxDegree, myMaxSeg,
|
||||||
|
Only3d, Only2d);
|
||||||
if(!Only3d) {
|
if(!Only3d) {
|
||||||
PCur2d = appr.Curve2d();
|
PCur2d = appr.Curve2d();
|
||||||
di << " Error in 2d is " << appr.MaxError2dU()
|
di << " Error in 2d is " << appr.MaxError2dU()
|
||||||
|
@@ -1552,8 +1552,9 @@ static Standard_Integer approxcurveonsurf(Draw_Interpretor& di, Standard_Integer
|
|||||||
Handle(Geom2dAdaptor_HCurve) A2d = new (Geom2dAdaptor_HCurve)(curve2d);
|
Handle(Geom2dAdaptor_HCurve) A2d = new (Geom2dAdaptor_HCurve)(curve2d);
|
||||||
Handle(GeomAdaptor_HSurface) AS = new (GeomAdaptor_HSurface)(Surf);
|
Handle(GeomAdaptor_HSurface) AS = new (GeomAdaptor_HSurface)(Surf);
|
||||||
|
|
||||||
Approx_CurveOnSurface App(A2d, AS, A2d->FirstParameter(), A2d->LastParameter(), Tol);
|
Approx_CurveOnSurface App(A2d, AS, A2d->FirstParameter(), A2d->LastParameter(),
|
||||||
App.Perform(MaxSeg, MaxDeg, Continuity, Standard_True, Standard_False);
|
Tol, Continuity, MaxDeg, MaxSeg,
|
||||||
|
Standard_True, Standard_False);
|
||||||
|
|
||||||
if(App.HasResult()) {
|
if(App.HasResult()) {
|
||||||
Handle(Geom_BSplineCurve) BSCurve = App.Curve3d();
|
Handle(Geom_BSplineCurve) BSCurve = App.Curve3d();
|
||||||
|
@@ -685,8 +685,9 @@ void ProjLib_ProjectedCurve::Perform(const Handle(Adaptor3d_HCurve)& C)
|
|||||||
MaxSeg = myMaxSegments;
|
MaxSeg = myMaxSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
Approx_CurveOnSurface appr(HProjector, mySurface, Udeb, Ufin, myTolerance);
|
Approx_CurveOnSurface appr(HProjector, mySurface, Udeb, Ufin,
|
||||||
appr.Perform(MaxSeg, MaxDegree, Continuity, Only3d, Only2d);
|
myTolerance, Continuity, MaxDegree, MaxSeg,
|
||||||
|
Only3d, Only2d);
|
||||||
|
|
||||||
Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d();
|
Handle(Geom2d_BSplineCurve) aRes = appr.Curve2d();
|
||||||
|
|
||||||
|
@@ -97,9 +97,25 @@ namespace
|
|||||||
return aPoly;
|
return aPoly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Add new solid
|
||||||
|
virtual void AddSolid() Standard_OVERRIDE
|
||||||
|
{
|
||||||
|
Handle(Poly_Triangulation) aCurrentTri = GetTriangulation();
|
||||||
|
myTriangulationList.Append(aCurrentTri);
|
||||||
|
myNodes.Clear();
|
||||||
|
myTriangles.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
NCollection_Sequence<Handle(Poly_Triangulation)> GetTriangulationList()
|
||||||
|
{
|
||||||
|
return myTriangulationList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NCollection_Vector<gp_XYZ> myNodes;
|
NCollection_Vector<gp_XYZ> myNodes;
|
||||||
NCollection_Vector<Poly_Triangle> myTriangles;
|
NCollection_Vector<Poly_Triangle> myTriangles;
|
||||||
|
NCollection_Sequence<Handle(Poly_Triangulation)> myTriangulationList;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -118,6 +134,17 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const Standard_CString theFile,
|
|||||||
return aReader.GetTriangulation();
|
return aReader.GetTriangulation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
//function : ReadFile
|
||||||
|
//purpose :
|
||||||
|
//=============================================================================
|
||||||
|
void RWStl::ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList)
|
||||||
|
{
|
||||||
|
Reader aReader;
|
||||||
|
aReader.Read(theFile, Handle(Message_ProgressIndicator)(), true);
|
||||||
|
theTriangList = aReader.GetTriangulationList();
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//function : ReadFile
|
//function : ReadFile
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@@ -50,6 +50,8 @@ public:
|
|||||||
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
|
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
|
||||||
const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
|
const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
|
||||||
|
|
||||||
|
Standard_EXPORT static void ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList);
|
||||||
|
|
||||||
//! Read triangulation from a binary STL file
|
//! Read triangulation from a binary STL file
|
||||||
//! In case of error, returns Null handle.
|
//! In case of error, returns Null handle.
|
||||||
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,
|
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,
|
||||||
|
@@ -126,7 +126,8 @@ namespace
|
|||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
Standard_Boolean RWStl_Reader::Read (const char* theFile,
|
Standard_Boolean RWStl_Reader::Read (const char* theFile,
|
||||||
const Handle(Message_ProgressIndicator)& theProgress)
|
const Handle(Message_ProgressIndicator)& theProgress,
|
||||||
|
bool IsMultiSolid)
|
||||||
{
|
{
|
||||||
std::filebuf aBuf;
|
std::filebuf aBuf;
|
||||||
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
|
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
|
||||||
@@ -165,6 +166,8 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
aStream >> std::ws; // skip any white spaces
|
aStream >> std::ws; // skip any white spaces
|
||||||
|
if (IsMultiSolid)
|
||||||
|
AddSolid();
|
||||||
}
|
}
|
||||||
return ! aStream.fail();
|
return ! aStream.fail();
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,8 @@ public:
|
|||||||
//! Format is recognized automatically by analysis of the file header.
|
//! Format is recognized automatically by analysis of the file header.
|
||||||
//! Returns true if success, false on error or user break.
|
//! Returns true if success, false on error or user break.
|
||||||
Standard_EXPORT Standard_Boolean Read (const char* theFile,
|
Standard_EXPORT Standard_Boolean Read (const char* theFile,
|
||||||
const Handle(Message_ProgressIndicator)& theProgress);
|
const Handle(Message_ProgressIndicator)& theProgress,
|
||||||
|
bool IsMultiSolid = false);
|
||||||
|
|
||||||
//! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200).
|
//! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200).
|
||||||
//! The function attempts to put back the read symbols to the stream which thus must support ungetc().
|
//! The function attempts to put back the read symbols to the stream which thus must support ungetc().
|
||||||
@@ -74,6 +75,8 @@ public:
|
|||||||
//! Should create new triangle built on specified nodes in the target model.
|
//! Should create new triangle built on specified nodes in the target model.
|
||||||
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
|
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
|
||||||
|
|
||||||
|
virtual void AddSolid() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -411,6 +411,22 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
|
|||||||
{
|
{
|
||||||
aFilePath = theArgVec[anArgIter];
|
aFilePath = theArgVec[anArgIter];
|
||||||
}
|
}
|
||||||
|
else if (theArgc == 4 && strcmp("multi", theArgv[3]) == 0)
|
||||||
|
{
|
||||||
|
NCollection_Sequence<Handle(Poly_Triangulation)> theTriangList;
|
||||||
|
RWStl::ReadFile(theArgv[2], theTriangList);
|
||||||
|
BRep_Builder aB;
|
||||||
|
TopoDS_Compound aCmp;
|
||||||
|
aB.MakeCompound(aCmp);
|
||||||
|
for (int i = 1; i <= theTriangList.Length(); i++)
|
||||||
|
{
|
||||||
|
TopoDS_Face aFace;
|
||||||
|
aB.MakeFace(aFace);
|
||||||
|
aB.UpdateFace(aFace, theTriangList(i));
|
||||||
|
aB.Add(aCmp, aFace);
|
||||||
|
}
|
||||||
|
DBRep::Set(theArgv[1], aCmp);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||||
|
@@ -20,9 +20,9 @@ vsetdispmode result 1
|
|||||||
vdisplay result
|
vdisplay result
|
||||||
vfit
|
vfit
|
||||||
|
|
||||||
checktrinfo result -tri 5812 -nod 5809
|
checktrinfo result -tri 5810 -nod 5806
|
||||||
|
|
||||||
checkmaxtol result -ref 0.92213088179312575
|
checkmaxtol result -ref 0.92213088179312575
|
||||||
checknbshapes result -shell 1
|
checknbshapes result -shell 1
|
||||||
checkfreebounds result 239
|
checkfreebounds result 265
|
||||||
checkview -display result -3d -path ${imagedir}/${test_image}.png
|
checkview -display result -3d -path ${imagedir}/${test_image}.png
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
puts "================"
|
|
||||||
puts "0030932: Modeling Algorithms - Invalid result on 2d curve on surface approximation"
|
|
||||||
puts "================"
|
|
||||||
puts ""
|
|
||||||
|
|
||||||
# Prepare data.
|
|
||||||
restore [locate_data_file bug30932_c2d] c2d
|
|
||||||
restore [locate_data_file bug30932_sur] sur
|
|
||||||
|
|
||||||
# Approximate.
|
|
||||||
approxcurveonsurf res c2d sur
|
|
||||||
|
|
||||||
# Length check.
|
|
||||||
checklength res -l 150.02782767924231
|
|
||||||
|
|
||||||
# Visual check.
|
|
||||||
axo;
|
|
||||||
don res;
|
|
||||||
fit;
|
|
||||||
checkview -screenshot -2d -path ${imagedir}/${test_image}.png
|
|
@@ -1,11 +1,9 @@
|
|||||||
# !!!! This file is generated automatically, do not edit manually! See end script
|
# !!!! This file is generated automatically, do not edit manually! See end script
|
||||||
puts "TODO CR30889 ALL: TPSTAT : Faulty"
|
|
||||||
|
|
||||||
set filename CTS21866.igs
|
set filename CTS21866.igs
|
||||||
|
|
||||||
set ref_data {
|
set ref_data {
|
||||||
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 11531 ) Summary = 0 ( 11531 )
|
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 11531 ) Summary = 0 ( 11531 )
|
||||||
TPSTAT : Faulties = 0 ( 0 ) Warnings = 92 ( 91 ) Summary = 92 ( 91 )
|
TPSTAT : Faulties = 0 ( 0 ) Warnings = 89 ( 91 ) Summary = 89 ( 91 )
|
||||||
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
||||||
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1459 ( 1459 )
|
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1459 ( 1459 )
|
||||||
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1459 ( 1459 ) FreeWire = 0 ( 0 )
|
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1459 ( 1459 ) FreeWire = 0 ( 0 )
|
||||||
|
@@ -6,4 +6,4 @@ set OffsetValue 10.0
|
|||||||
|
|
||||||
# Reference data.
|
# Reference data.
|
||||||
set ExpectedMass 178976
|
set ExpectedMass 178976
|
||||||
set ExpectedMaxTol 0.470985
|
set ExpectedMaxTol 0.479111
|
||||||
|
Reference in New Issue
Block a user