{
if (aDEdge->GetCurve()->ParametersNb() == 2)
{
- if (splitEdge (aDEdge, Abs (getConeStep (aDFace))))
+ if (splitEdge (aDEdge, aDFace, Abs (getConeStep (aDFace))))
{
TopLoc_Location aLoc;
const Handle (Poly_Triangulation)& aTriangulation =
}
//! Splits 3D and all pcurves accordingly using the specified step.
- Standard_Boolean splitEdge(const IMeshData::IEdgePtr& theDEdge,
- const Standard_Real theDU) const
+ Standard_Boolean splitEdge(const IMeshData::IEdgePtr& theDEdge,
+ const IMeshData::IFaceHandle& theDFace,
+ const Standard_Real theDU) const
{
- if (!splitCurve<gp_XYZ> (theDEdge->GetCurve (), theDU))
+ TopoDS_Edge aE = theDEdge->GetEdge();
+ const TopoDS_Face& aF = theDFace->GetFace();
+
+ Standard_Real aFParam, aLParam;
+
+ Handle(Geom_Curve) aHC = BRep_Tool::Curve (aE, aFParam, aLParam);
+
+ const IMeshData::IPCurveHandle& aIPC1 = theDEdge->GetPCurve(0);
+ const IMeshData::IPCurveHandle& aIPC2 = theDEdge->GetPCurve(1);
+
+ // Calculate the step by parameter of the curve.
+ const gp_Pnt2d& aFPntOfIPC1 = aIPC1->GetPoint (0);
+ const gp_Pnt2d& aLPntOfIPC1 = aIPC1->GetPoint (aIPC1->ParametersNb() - 1);
+ const Standard_Real aMod = Abs (aFPntOfIPC1.Y() - aLPntOfIPC1.Y());
+
+ if (aMod < gp::Resolution())
+ {
+ return Standard_False;
+ }
+
+ const Standard_Real aDT = Abs (aLParam - aFParam) / aMod * theDU;
+
+ if (!splitCurve<gp_Pnt> (aHC, theDEdge->GetCurve(), aDT))
+ {
+ return Standard_False;
+ }
+
+ // Define two pcurves of the seam-edge.
+ Handle(Geom2d_Curve) aPC1, aPC2;
+ Standard_Real af, al;
+
+ aE.Orientation (TopAbs_FORWARD);
+ aPC1 = BRep_Tool::CurveOnSurface (aE, aF, af, al);
+
+ aE.Orientation (TopAbs_REVERSED);
+ aPC2 = BRep_Tool::CurveOnSurface (aE, aF, af, al);
+
+ if (aPC1.IsNull() || aPC2.IsNull())
{
return Standard_False;
}
- for (Standard_Integer aPCurveIdx = 0; aPCurveIdx < theDEdge->PCurvesNb(); ++aPCurveIdx)
+ // Select the correct pcurve of the seam-edge.
+ const gp_Pnt2d& aFPntOfPC1 = aPC1->Value (aPC1->FirstParameter());
+
+ if (Abs (aLPntOfIPC1.X() - aFPntOfPC1.X()) > Precision::Confusion())
{
- splitCurve<gp_XY> (theDEdge->GetPCurve (aPCurveIdx), theDU);
+ std::swap (aPC1, aPC2);
}
+ splitCurve<gp_Pnt2d> (aPC1, aIPC1, aDT);
+ splitCurve<gp_Pnt2d> (aPC2, aIPC2, aDT);
+
return Standard_True;
}
//! Splits the given curve using the specified step.
- template<class PointType, class Curve>
- Standard_Boolean splitCurve(Curve& theCurve, const Standard_Real theDU) const
+ template<class PointType, class GeomCurve, class Curve>
+ Standard_Boolean splitCurve(GeomCurve& theGeomCurve,
+ Curve& theCurve,
+ const Standard_Real theDT) const
{
Standard_Boolean isUpdated = Standard_False;
- PointType aDir = theCurve->GetPoint(theCurve->ParametersNb() - 1).Coord() - theCurve->GetPoint(0).Coord();
- const Standard_Real aModulus = aDir.Modulus();
- if (aModulus < gp::Resolution())
- {
- return isUpdated;
- }
- aDir /= aModulus;
- const Standard_Real aLastParam = theCurve->GetParameter(theCurve->ParametersNb() - 1);
- const Standard_Boolean isReversed = theCurve->GetParameter(0) > aLastParam;
+ const Standard_Real aFirstParam = theCurve->GetParameter (0);
+ const Standard_Real aLastParam = theCurve->GetParameter (theCurve->ParametersNb() - 1);
+ const Standard_Boolean isReversed = aFirstParam > aLastParam;
+
for (Standard_Integer aPointIdx = 1; ; ++aPointIdx)
{
- const Standard_Real aCurrParam = theCurve->GetParameter(0) + aPointIdx * theDU * (isReversed ? -1.0 : 1.0);
- if (( isReversed && (aCurrParam < aLastParam)) ||
- (!isReversed && !(aCurrParam < aLastParam)))
+ const Standard_Real aCurrParam = aFirstParam + aPointIdx * theDT * (isReversed ? -1.0 : 1.0);
+ if (( isReversed && (aCurrParam - aLastParam < Precision::PConfusion())) ||
+ (!isReversed && !(aCurrParam - aLastParam < - Precision::PConfusion())))
{
break;
}
- theCurve->InsertPoint(theCurve->ParametersNb() - 1,
- theCurve->GetPoint(0).Translated (aDir * aPointIdx * theDU),
+ theCurve->InsertPoint (theCurve->ParametersNb() - 1,
+ theGeomCurve->Value (aCurrParam),
aCurrParam);
isUpdated = Standard_True;