#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_Surface.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
#include <Geom_BezierSurface.hxx>
+#include <Geom_BSplineCurve.hxx>
#include <Geom_BSplineSurface.hxx>
+#include <Geom_OffsetCurve.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <Standard_NoSuchObject.hxx>
}
return n;
}
+
+Standard_Boolean Adaptor3d_HSurfaceTool::IsSurfG1(const Handle(Adaptor3d_Surface)& theSurf,
+ const Standard_Boolean theAlongU,
+ const Standard_Real theAngTol)
+{
+ Standard_Real aUf, aUl, aVf, aVl;
+ aUf = theSurf->FirstUParameter();
+ aUl = theSurf->LastUParameter();
+ aVf = theSurf->FirstVParameter();
+ aVl = theSurf->LastVParameter();
+
+ Handle(Adaptor3d_Surface) aS = theSurf;
+ Handle(Adaptor3d_Curve) aC;
+
+ Handle(Geom_BSplineSurface) aBS;
+ Handle(Geom_BSplineCurve) aBC;
+
+ if (aS->GetType() == GeomAbs_OffsetSurface)
+ {
+ aS = aS->BasisSurface();
+ }
+
+ if (aS->GetType() == GeomAbs_SurfaceOfRevolution ||
+ aS->GetType() == GeomAbs_SurfaceOfExtrusion)
+ {
+ aC = aS->BasisCurve();
+ }
+
+ if (!aC.IsNull())
+ {
+ if (aC->GetType() == GeomAbs_OffsetCurve)
+ {
+ Handle(Geom_OffsetCurve) aOC = aC->OffsetCurve();
+ aC = new GeomAdaptor_Curve(aOC->BasisCurve());
+ }
+
+ if (aC->GetType() == GeomAbs_BSplineCurve)
+ {
+ if ((theAlongU && aS->GetType() == GeomAbs_SurfaceOfExtrusion) ||
+ (!theAlongU && aS->GetType() == GeomAbs_SurfaceOfRevolution))
+ {
+ aBC = aC->BSpline();
+ }
+ }
+ }
+
+ if (aS->GetType() == GeomAbs_BSplineSurface)
+ {
+ aBS = aS->BSpline();
+
+ if (theAlongU)
+ {
+ const Standard_Real anIsoPar = (aVf + aVl) / 2.0;
+ aBC = Handle(Geom_BSplineCurve)::DownCast(aBS->VIso(anIsoPar));
+ }
+ else
+ {
+ const Standard_Real anIsoPar = (aUf + aUl) / 2.0;
+ aBC = Handle(Geom_BSplineCurve)::DownCast(aBS->UIso(anIsoPar));
+ }
+ }
+
+ if(!aBC.IsNull())
+ {
+ if (theAlongU)
+ {
+ return aBC->IsG1(aUf, aUl, theAngTol);
+ }
+ else
+ {
+ return aBC->IsG1(aVf, aVl, theAngTol);
+ }
+ }
+
+ return Standard_False;
+}
static Standard_Real OffsetValue (const Handle(Adaptor3d_Surface)& theSurf) { return theSurf->OffsetValue(); }
+ Standard_EXPORT static Standard_Boolean IsSurfG1 (const Handle(Adaptor3d_Surface)& theSurf,
+ const Standard_Boolean theAlongU,
+ const Standard_Real theAngTol = Precision::Angular());
+
Standard_EXPORT static Standard_Integer NbSamplesU (const Handle(Adaptor3d_Surface)& S);
Standard_EXPORT static Standard_Integer NbSamplesV (const Handle(Adaptor3d_Surface)& S);
Standard_Real lgmin = 10 * Precision::PConfusion();
Standard_Integer i;
Standard_Real cut, mil=(a+b)/2, dist;
+ Standard_Boolean isfound = Standard_False;
cut = mil;
if ( dist > Abs(mil-myPrefCutting.Value(i))) {
cut = myPrefCutting.Value(i);
dist = Abs(mil-cut);
+ isfound = Standard_True;
}
}
// Recheche d'une decoupe recommende
- dist = Abs((a-b)/2);
- for ( i=1; i<=myRecCutting.Length(); i++) {
- if ((dist-lgmin) > Abs(mil-myRecCutting.Value(i))) {
- cut = myRecCutting.Value(i);
- dist = Abs(mil-cut);
+ if (!isfound)
+ {
+ dist = Abs((a-b)/2);
+ for ( i=1; i<=myRecCutting.Length(); i++) {
+ if ((dist-lgmin) > Abs(mil-myRecCutting.Value(i))) {
+ cut = myRecCutting.Value(i);
+ dist = Abs(mil-cut);
+ }
}
}
#include <Adaptor3d_CurveOnSurface.hxx>
#include <Adaptor3d_Curve.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
+#include <Adaptor3d_HSurfaceTool.hxx>
#include <Adaptor3d_Surface.hxx>
#include <AdvApprox_ApproxAFunction.hxx>
#include <AdvApprox_DichoCutting.hxx>
if(theOnly3d && theOnly2d) throw Standard_ConstructionError();
+ GeomAbs_Shape aContinuity = theContinuity;
+ if (aContinuity == GeomAbs_G1)
+ aContinuity = GeomAbs_C1;
+ else if (aContinuity == GeomAbs_G2)
+ aContinuity = GeomAbs_C2;
+ else if (aContinuity > GeomAbs_C2)
+ aContinuity = GeomAbs_C2; //Restriction of AdvApprox_ApproxAFunction
+
Handle( Adaptor2d_Curve2d ) TrimmedC2D = myC2D->Trim( myFirst, myLast, Precision::PConfusion() );
Standard_Boolean isU, isForward;
Standard_Real TolU, TolV;
- TolU = mySurf->UResolution(myTol)/2;
- TolV = mySurf->VResolution(myTol)/2;
+ TolU = mySurf->UResolution(myTol) / 2.;
+ TolV = mySurf->VResolution(myTol) / 2.;
+
+ if (mySurf->UContinuity() == GeomAbs_C0)
+ {
+ if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, Standard_True, Precision::Angular()))
+ TolU = Min(1.e-3, 1.e3 * TolU);
+ if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, Standard_True, Precision::Confusion()))
+ TolU = Min(1.e-3, 1.e2 * TolU);
+ }
+
+ if (mySurf->VContinuity() == GeomAbs_C0)
+ {
+ if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, Standard_False, Precision::Angular()))
+ TolV = Min(1.e-3, 1.e3 * TolV);
+ if (!Adaptor3d_HSurfaceTool::IsSurfG1(mySurf, Standard_False, Precision::Confusion()))
+ TolV = Min(1.e-3, 1.e2 * TolV);
+ }
OneDTol->SetValue(1,TolU);
OneDTol->SetValue(2,TolV);
ThreeDTol->Init(myTol/2);
}
+ AdvApprox_Cutting* CutTool;
+
+ if (aContinuity <= myC2D->Continuity() &&
+ aContinuity <= mySurf->UContinuity() &&
+ aContinuity <= mySurf->VContinuity())
+ {
+ CutTool = new AdvApprox_DichoCutting();
+ }
+ else if (aContinuity == GeomAbs_C1)
+ {
+ Standard_Integer NbInterv_C1 = HCOnS->NbIntervals(GeomAbs_C1);
+ TColStd_Array1OfReal CutPnts_C1(1, NbInterv_C1 + 1);
+ HCOnS->Intervals(CutPnts_C1, GeomAbs_C1);
+ Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
+ TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
+ HCOnS->Intervals(CutPnts_C2, GeomAbs_C2);
+
+ CutTool = new AdvApprox_PrefAndRec (CutPnts_C1, CutPnts_C2);
+ }
+ else
+ {
+ Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
+ TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
+ HCOnS->Intervals(CutPnts_C2, GeomAbs_C2);
+ Standard_Integer NbInterv_C3 = HCOnS->NbIntervals(GeomAbs_C3);
+ TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
+ HCOnS->Intervals(CutPnts_C3, GeomAbs_C3);
+
+ CutTool = new AdvApprox_PrefAndRec (CutPnts_C2, CutPnts_C3);
+ }
- Standard_Integer NbInterv_C2 = HCOnS->NbIntervals(GeomAbs_C2);
- TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2 + 1);
- HCOnS->Intervals(CutPnts_C2, GeomAbs_C2);
- Standard_Integer NbInterv_C3 = HCOnS->NbIntervals(GeomAbs_C3);
- TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3 + 1);
- HCOnS->Intervals(CutPnts_C3, GeomAbs_C3);
-
- AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
OneDTol, TwoDTolNul, ThreeDTol,
- myFirst, myLast, theContinuity,
+ myFirst, myLast, aContinuity,
theMaxDegree, theMaxSegments,
- *EvalPtr, CutTool);
+ *EvalPtr, *CutTool);
+
+ delete CutTool;
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
{
myTol3d = 1.e-4;
myTol2d = Pow(myTol3d, 2./3);
- myContinuity = GeomAbs_C2;
+ myContinuity = GeomAbs_C1;
myMaxDegree = 14;
myMaxSeg = 16;
}
Standard_Real Tol = 1.e-4;
Standard_Real Tol2d;
Standard_Real MaxDistance = 1.e-3;
- GeomAbs_Shape Continuity = GeomAbs_C2;
+ GeomAbs_Shape Continuity = GeomAbs_C1;
Standard_Integer MaxDeg = 14;
Standard_Integer MaxSeg = 16;
if(n > arg) {
if (Draw::Atoi(a[arg]) == 0) Continuity = GeomAbs_C0;
- else if (Draw::Atoi(a[arg]) == 1) Continuity = GeomAbs_C1;
+ else if (Draw::Atoi(a[arg]) == 2) Continuity = GeomAbs_C2;
arg++;
}
return myCurve->LastParameter();
}
+//=======================================================================
+//function : Continuity
+//purpose :
+//=======================================================================
+
+GeomAbs_Shape ProjLib_CompProjectedCurve::Continuity() const
+{
+ GeomAbs_Shape ContC = myCurve->Continuity();
+ GeomAbs_Shape ContSu = mySurface->UContinuity();
+ if ( ContSu < ContC) ContC = ContSu;
+ GeomAbs_Shape ContSv = mySurface->VContinuity();
+ if ( ContSv < ContC) ContC = ContSv;
+
+ return ContC;
+}
+
//=======================================================================
//function : MaxDistance
//purpose :
//! which has a projection on S.
Standard_EXPORT Standard_Real LastParameter() const Standard_OVERRIDE;
+ //! Returns the Continuity used in the approximation.
+ Standard_EXPORT GeomAbs_Shape Continuity() const Standard_OVERRIDE;
+
//! Returns the number of intervals which define
//! an S continuous part of the projected curve
Standard_EXPORT Standard_Integer NbIntervals (const GeomAbs_Shape S) const Standard_OVERRIDE;
--- /dev/null
+puts "================"
+puts "0030272: Modeling Algorithms - Incorrect work of gproject"
+puts "================"
+puts ""
+
+set BugNumber OCC30272
+
+set tol_abs 1.0e-4
+set tol_rel 0.0001
+
+restore [locate_data_file bug30272_cur.brep] c
+restore [locate_data_file bug30272_sur.brep] s
+
+set result_C0 [gproject result_C0 c s 1.0e-3 -3d 1 -c C0]
+regexp {2d is ([-0-9.+eE]+);..([-0-9.+eE]+)} $result_C0 full 2dUError_C0 2dVError_C0
+regexp {3d is ([-0-9.+eE]+)} $result_C0 full 3dError_C0
+
+set expected_2dUError_C0 8.5166415968648575e-06
+set expected_2dVError_C0 1.9383641349197776e-07
+set expected_3dError_C0 0.00039481100189762405
+
+checkreal "2dUError_C0" ${2dUError_C0} ${expected_2dUError_C0} ${tol_abs} ${tol_rel}
+checkreal "2dVError_C0" ${2dVError_C0} ${expected_2dVError_C0} ${tol_abs} ${tol_rel}
+checkreal "3dError_C0" ${3dError_C0} ${expected_3dError_C0} ${tol_abs} ${tol_rel}
+
+set result_C1 [gproject result_C1 c s 1.0e-3 -3d 1 -c C1]
+regexp {2d is ([-0-9.+eE]+);..([-0-9.+eE]+)} $result_C1 full 2dUError_C1 2dVError_C1
+regexp {3d is ([-0-9.+eE]+)} $result_C1 full 3dError_C1
+
+set expected_2dUError_C1 1.1207913216250422e-05
+set expected_2dVError_C1 1.9546900926719333e-07
+set expected_3dError_C1 0.00029305148512110709
+
+checkreal "2dUError_C1" ${2dUError_C1} ${expected_2dUError_C1} ${tol_abs} ${tol_rel}
+checkreal "2dVError_C1" ${2dVError_C1} ${expected_2dVError_C1} ${tol_abs} ${tol_rel}
+checkreal "3dError_C1" ${3dError_C1} ${expected_3dError_C1} ${tol_abs} ${tol_rel}
+
+set result_C2 [gproject result_C2 c s 1.0e-3 -3d 1 -c C2]
+regexp {2d is ([-0-9.+eE]+);..([-0-9.+eE]+)} $result_C2 full 2dUError_C2 2dVError_C2
+regexp {3d is ([-0-9.+eE]+)} $result_C2 full 3dError_C2
+
+set expected_2dUError_C2 1.1368572775344132e-05
+set expected_2dVError_C2 1.8525211887318316e-07
+set expected_3dError_C2 0.00024049581776618967
+
+checkreal "2dUError_C2" ${2dUError_C2} ${expected_2dUError_C2} ${tol_abs} ${tol_rel}
+checkreal "2dVError_C2" ${2dVError_C2} ${expected_2dVError_C2} ${tol_abs} ${tol_rel}
+checkreal "3dError_C2" ${3dError_C2} ${expected_3dError_C2} ${tol_abs} ${tol_rel}