#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge2d.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
+#include <Extrema_ExtCC.hxx>
#include <Extrema_ExtPC.hxx>
#include <NCollection_Vector.hxx>
#include <Precision.hxx>
theList[i] = theList2[j];
}
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
- const Handle( HYDROData_PolylineXY )& thePolyline,
- const gp_Pnt2d& thePoint,
- double theTolerance ) const
-{
- std::vector<gp_Pnt2d> aPointsList( 1 );
- aPointsList[0] = thePoint;
- std::vector<TopoDS_Wire> aCurves = GetWires( thePolyline );
- bool isOK = true;
- for( int i=0, n=aCurves.size(); i<n; i++ )
- {
- std::vector<TopoDS_Shape> aCurvesList = Split( aCurves[i], thePoint, theTolerance );
- bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList, true );
- isOK = isOK && isLocalOK;
- }
- return isOK;
-}
-
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
- const Handle( HYDROData_PolylineXY )& thePolyline,
- const Handle( HYDROData_PolylineXY )& theTool,
- double theTolerance ) const
-{
- HYDROData_SequenceOfObjects aSeq;
- aSeq.Append( theTool );
- return split( theDoc, thePolyline, aSeq, theTolerance, -1 );
-}
-
-bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
- const HYDROData_SequenceOfObjects& thePolylines,
- double theTolerance )
-{
- int f = thePolylines.Lower(), l = thePolylines.Upper();
- for( int i=f; i<=l; i++ )
- {
- Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
- if( !split( theDoc, aPolyline, thePolylines, theTolerance, i ) )
- return false;
- }
- return true;
-}
-
-bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theDoc,
- const QString& theName,
- const HYDROData_SequenceOfObjects& thePolylines,
- bool isConnectByNewSegment,
- double theTolerance )
-{
- TopoDS_Shape aMergedPolyline;
-
- int f = thePolylines.Lower(), l = thePolylines.Upper();
- for( int i=f; i<=l; i++ )
- {
- Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
- std::vector<TopoDS_Wire> aCurves = GetWires( aPolyline );
- for( int j=0, m=aCurves.size(); j<m; j++ )
- if( !Merge( aMergedPolyline, aCurves[j], isConnectByNewSegment, theTolerance ) )
- return false;
- }
-
- std::vector<TopoDS_Shape> aShapes( 1 );
- aShapes[0] = aMergedPolyline;
- CreatePolylines( theDoc, theName, aShapes, false );
-
- return true;
-}
-
-bool HYDROData_PolylineOperator::Merge( TopoDS_Shape& theShape, const TopoDS_Wire& theWire,
- bool isConnectByNewSegment, double theTolerance )
-{
- //TODO
- return true;
-}
-
-bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theDoc,
- const Handle( HYDROData_PolylineXY )& thePolyline,
- const HYDROData_SequenceOfObjects& theTools,
- double theTolerance,
- int theIgnoreIndex ) const
-{
- std::vector<TopoDS_Wire> aCurves = GetWires( thePolyline );
- std::vector<TopoDS_Wire> aToolCurves;
- for( int i=theTools.Lower(), n=theTools.Upper(); i<=n; i++ )
- if( i!=theIgnoreIndex )
- {
- Handle( HYDROData_PolylineXY ) aToolPolyline =
- Handle( HYDROData_PolylineXY )::DownCast( theTools.Value( i ) );
- append( aToolCurves, GetWires( aToolPolyline ) );
- }
-
- bool isOK = true;
-
- int n = aCurves.size();
- std::vector<TopoDS_Shape> aResults( n );
- for( int i=0; i<n; i++ )
- aResults[i] = aCurves[i];
-
- for( int j=0, m=aToolCurves.size(); j<m; j++ )
- {
- std::vector<TopoDS_Shape> aNewResults;
- for( int k=0, q=aResults.size(); k<q; k++ )
- {
- std::vector<TopoDS_Shape> aCurvesList = Split( TopoDS::Wire( aResults[k] ), aToolCurves[j], theTolerance );
- append( aNewResults, aCurvesList );
- }
- aResults = aNewResults;
- }
-
- CreatePolylines( theDoc, thePolyline->GetName(), aResults, true );
-
- return isOK;
-}
-
-std::vector<TopoDS_Wire> HYDROData_PolylineOperator::GetWires( const Handle( HYDROData_PolylineXY )& thePolyline )
-{
- std::vector<TopoDS_Wire> aResult;
-
- TopoDS_Shape aShape = thePolyline->GetShape();
-
- if( aShape.ShapeType()==TopAbs_WIRE )
- {
- aResult.push_back( TopoDS::Wire( aShape ) );
- }
- else
- {
- TopExp_Explorer anExp( aShape, TopAbs_WIRE );
- for( ; anExp.More(); anExp.Next() )
- {
- aResult.push_back( TopoDS::Wire( anExp.Current() ) );
- }
- }
- return aResult;
-}
-
-static Standard_Boolean OrderCurveEdges(
+static Standard_Boolean WireToCurve(
const TopoDS_Wire& theWire,
NCollection_Vector<TopoDS_Edge>& theEdges,
Standard_Boolean& theIsClosed)
(theIsClosed && theEdges.Size() == aVCount);
}
-static Standard_Real ProjectPointToEdge(
+static void CurveToWire(
+ const NCollection_Vector<TopoDS_Edge>& theEdges, TopoDS_Wire& theWire)
+{
+ BRep_Builder aBulder;
+ aBulder.MakeWire(theWire);
+ NCollection_Vector<TopoDS_Edge>::Iterator aEIt(theEdges);
+ for (; aEIt.More(); aEIt.Next())
+ {
+ aBulder.Add(theWire, aEIt.Value());
+ }
+}
+
+static void CurveToWire(
+ const NCollection_Vector<TopoDS_Edge>& theEdges1,
+ const NCollection_Vector<TopoDS_Edge>& theEdges2,
+ TopoDS_Wire& theWire)
+{
+ BRep_Builder aBulder;
+ aBulder.MakeWire(theWire);
+ const NCollection_Vector<TopoDS_Edge>* aEdges[] = {&theEdges1, &theEdges2};
+ for (Standard_Integer aEI = 0; aEI < 2; ++aEI)
+ {
+ NCollection_Vector<TopoDS_Edge>::Iterator aEIt(*aEdges[aEI]);
+ for (; aEIt.More(); aEIt.Next())
+ {
+ aBulder.Add(theWire, aEIt.Value());
+ }
+ }
+}
+
+static Standard_Real ProjectPointToCurve(
const gp_Pnt& thePoint,
- const TopoDS_Edge& theEdge,
+ const Adaptor3d_Curve& theCurve,
Standard_Real& theParameter)
{
- BRepAdaptor_Curve aECurve(theEdge);
- Extrema_ExtPC aAlgo(thePoint, aECurve);
+ Extrema_ExtPC aAlgo(thePoint, theCurve);
Standard_Integer aMinEN = -2;
Standard_Real aMinSqDist = DBL_MAX;
if (aAlgo.IsDone())
{
const Standard_Integer aECount = aAlgo.NbExt();
- if (aECount != 0)
+ for (Standard_Integer aEN = 1; aEN <= aECount; ++aEN)
{
- for (Standard_Integer aEN = 1; aEN <= aECount; ++aEN)
+ const gp_Pnt& aP = aAlgo.Point(aEN).Value();
+ const Standard_Real aSqDist = thePoint.SquareDistance(aP);
+ if (aMinSqDist > aSqDist)
{
- const gp_Pnt& aP = aAlgo.Point(aEN).Value();
- const Standard_Real aSqDist = thePoint.SquareDistance(aP);
- if (aMinSqDist > aSqDist)
- {
- aMinSqDist = aSqDist;
- aMinEN = aEN;
- }
+ aMinSqDist = aSqDist;
+ aMinEN = aEN;
}
}
}
const Standard_Real aParams[] =
- {aECurve.FirstParameter(), aECurve.LastParameter()};
- const gp_Pnt aEnds[] = {aECurve.Value(aParams[0]), aECurve.Value(aParams[1])};
+ {theCurve.FirstParameter(), theCurve.LastParameter()};
+ const gp_Pnt aEnds[] =
+ {theCurve.Value(aParams[0]), theCurve.Value(aParams[1])};
const Standard_Real aSqDists[] =
{thePoint.SquareDistance(aEnds[0]), thePoint.SquareDistance(aEnds[1])};
for (Standard_Integer aEI = 0; aEI < 2; ++aEI)
return aMinSqDist;
}
+static Standard_Real ProjectPointToEdge(
+ const gp_Pnt& thePoint,
+ const TopoDS_Edge& theEdge,
+ Standard_Real& theParameter)
+{
+ return ProjectPointToCurve(thePoint, BRepAdaptor_Curve(theEdge), theParameter);
+}
+
static void SplitCurveByPoint(
const NCollection_Vector<TopoDS_Edge>& theEdges,
const Standard_Integer theEdgeIndex,
}
const TopoDS_Edge& aEdge = theEdges(theEdgeIndex);
- BRepAdaptor_Curve aECurve(aEdge);
+ BRepAdaptor_Curve aCurve(aEdge);
Standard_Integer aParamI = -1;
const Standard_Real aEdgeEndParams[] =
- {aECurve.FirstParameter(), aECurve.LastParameter()};
+ {aCurve.FirstParameter(), aCurve.LastParameter()};
if (Abs(theParameter - aEdgeEndParams[0]) < Precision::PConfusion())
{
aParamI = 0;
aSATPP.SetMaxTolerance(Precision::Confusion());
TopoDS_Vertex aSplitV;
BRep_Builder().MakeVertex(
- aSplitV, aECurve.Value(theParameter), Precision::Confusion());
+ aSplitV, aCurve.Value(theParameter), Precision::Confusion());
TopoDS_Edge aEParts[] = {
ShapeBuild_Edge().CopyReplaceVertices(aFE, TopoDS_Vertex(),
}
}
-static void CollectCurveWire(
- const NCollection_Vector<TopoDS_Edge>& theEdges, TopoDS_Wire& theWire)
+static void SplitCurveByPoints(
+ const NCollection_Vector<TopoDS_Edge>& theCurve,
+ const NCollection_Vector<NCollection_Sequence<Standard_Real> >& theParameters,
+ NCollection_Vector<NCollection_Vector<TopoDS_Edge> >& theSplittedCurves)
{
- BRep_Builder aBulder;
- aBulder.MakeWire(theWire);
- NCollection_Vector<TopoDS_Edge>::Iterator aEIt(theEdges);
- for (; aEIt.More(); aEIt.Next())
+ NCollection_Vector<TopoDS_Edge> aCurves[3];
+ aCurves[0] = theCurve;
+ Standard_Integer aCI = 0, aEI = 0;
+ NCollection_Vector<TopoDS_Edge>::Iterator aEIt(theCurve);
+ for (NCollection_Vector<NCollection_Sequence<Standard_Real> >::Iterator
+ aPLIt(theParameters); aPLIt.More(); ++aEI, aEIt.Next(), aPLIt.Next())
{
- aBulder.Add(theWire, aEIt.Value());
+ const Standard_Boolean isForward =
+ (aEIt.Value().Orientation() != TopAbs_REVERSED);
+ for (NCollection_Sequence<Standard_Real>::Iterator
+ aPIt(aPLIt.Value(), isForward); aPIt.More(); aPIt.Next())
+ {
+ const Standard_Integer aCI1 = (aCI + 1) % 3, aCI2 = (aCI + 2) % 3;
+ SplitCurveByPoint(aCurves[aCI], aEI,
+ aPIt.Value(), aCurves[aCI1], aCurves[aCI2]);
+ if (!aCurves[aCI2].IsEmpty())
+ {
+ theSplittedCurves.Append(aCurves[aCI1]);
+ aCurves[aCI].Clear();
+ aCI = aCI2;
+ aEI = 0;
+ }
+ aCurves[aCI1].Clear();
+ }
}
+ theSplittedCurves.Append(aCurves[aCI]);
}
-static void CollectCurveWire(
- const NCollection_Vector<TopoDS_Edge>& theEdges1,
- const NCollection_Vector<TopoDS_Edge>& theEdges2,
- TopoDS_Wire& theWire)
+static Standard_Integer AppendIntersectionPoint(
+ const Adaptor3d_Curve& theCurve,
+ const Standard_Real theParameter,
+ NCollection_Sequence<Standard_Real>& theParameters)
{
- BRep_Builder aBulder;
- aBulder.MakeWire(theWire);
- const NCollection_Vector<TopoDS_Edge>* aEdges[] = {&theEdges1, &theEdges2};
- for (Standard_Integer aEI = 0; aEI < 2; ++aEI)
+ // Check the coincidence.
+ NCollection_Sequence<Standard_Real> aEndParams;
+ aEndParams.Append(theCurve.FirstParameter());
+ aEndParams.Append(theCurve.LastParameter());
+ NCollection_Sequence<Standard_Real>* aParams[] =
+ {&theParameters, &aEndParams};
+ const gp_Pnt aPoint = theCurve.Value(theParameter);
+ for (Standard_Integer aLI = 0; aLI < 2; ++aLI)
{
- NCollection_Vector<TopoDS_Edge>::Iterator aEIt(*aEdges[aEI]);
- for (; aEIt.More(); aEIt.Next())
+ NCollection_Sequence<Standard_Real>::Iterator aPIt(*aParams[aLI]);
+ for (Standard_Integer aPI = 0; aPIt.More(); aPIt.Next(), ++aPI)
{
- aBulder.Add(theWire, aEIt.Value());
+ const Standard_Real aParam = aPIt.Value();
+ if (Abs(theParameter - aParam) < Precision::PConfusion() ||
+ aPoint.SquareDistance(theCurve.Value(aParam)) <=
+ Precision::SquareConfusion())
+ {
+ Standard_Integer aIntCount = 0;
+ if (aLI != 0)
+ {
+ if (aPI == 0)
+ {
+ theParameters.Prepend(aEndParams.First());
+ }
+ else
+ {
+ theParameters.Append(aEndParams.Last());
+ }
+ ++aIntCount;
+ }
+ return aIntCount;
+ }
+ }
+ }
+
+ // Calculate the position to insert.
+ NCollection_Sequence<Standard_Real>::Iterator aPIt(theParameters);
+ if (aPIt.More() && aPIt.Value() < theParameter)
+ {
+ NCollection_Sequence<Standard_Real>::Iterator aPIt2 = aPIt;
+ aPIt2.Next();
+ for (; aPIt2.More() && aPIt2.Value() < theParameter;
+ aPIt.Next(), aPIt2.Next());
+ theParameters.InsertAfter(aPIt, theParameter);
+ }
+ else
+ {
+ theParameters.Prepend(theParameter);
+ }
+ return 1;
+}
+
+static Standard_Integer IntersectEdge(
+ const TopoDS_Edge& theEdge1,
+ const TopoDS_Edge& theEdge2,
+ NCollection_Sequence<Standard_Real>& theParameters)
+{
+ // Process the ends.
+ Standard_Integer aIntCount = 0;
+ BRepAdaptor_Curve aCurve1 = BRepAdaptor_Curve(theEdge1);
+ BRepAdaptor_Curve aCurve2 = BRepAdaptor_Curve(theEdge2);
+ const gp_Pnt aEndPs[] = {aCurve2.Value(aCurve2.FirstParameter()),
+ aCurve2.Value(aCurve2.LastParameter())};
+ for (Standard_Integer aPI = 0; aPI < 2; ++aPI)
+ {
+ Standard_Real aParameter;
+ if (ProjectPointToCurve(aEndPs[aPI], aCurve1, aParameter) <=
+ Precision::SquareConfusion())
+ {
+ AppendIntersectionPoint(aCurve1, aParameter, theParameters);
+ }
+ }
+
+ // Process the internal extrema.
+ Extrema_ExtCC aAlgo(aCurve1, aCurve2);
+ if (aAlgo.IsDone())
+ {
+ const Standard_Integer aECount = aAlgo.NbExt();
+ for (Standard_Integer aEN = 1; aEN <= aECount; ++aEN)
+ {
+ Extrema_POnCurv aP1, aP2;
+ aAlgo.Points(aEN, aP1, aP2);
+ if (aP1.Value().SquareDistance(aP2.Value()) <=
+ Precision::SquareConfusion())
+ {
+ AppendIntersectionPoint(aCurve1, aP1.Parameter(), theParameters);
+ }
+ }
+ }
+ return aIntCount;
+}
+
+static Standard_Integer IntersectCurve(
+ const NCollection_Vector<TopoDS_Edge>& theEdges,
+ const TopoDS_Wire& theWire,
+ NCollection_Vector<NCollection_Sequence<Standard_Real> >& theParameters)
+{
+ Standard_Integer aIntCount = 0;
+ const Standard_Integer aECount1 = theEdges.Size();
+ for (Standard_Integer aEI1 = 0; aEI1 < aECount1; ++aEI1)
+ {
+ const TopoDS_Edge& aEdge1 = theEdges(aEI1);
+ TopExp_Explorer aEIt2(theWire, TopAbs_EDGE);
+ for (; aEIt2.More(); aEIt2.Next())
+ {
+ aIntCount += IntersectEdge(aEdge1,
+ TopoDS::Edge(aEIt2.Current()), theParameters(aEI1));
+ }
+ }
+ return aIntCount;
+}
+
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
+ const gp_Pnt2d& thePoint,
+ double theTolerance ) const
+{
+ std::vector<gp_Pnt2d> aPointsList( 1 );
+ aPointsList[0] = thePoint;
+ std::vector<TopoDS_Wire> aCurves = GetWires( thePolyline );
+ bool isOK = true;
+ for( int i=0, n=aCurves.size(); i<n; i++ )
+ {
+ std::vector<TopoDS_Shape> aCurvesList = Split( aCurves[i], thePoint, theTolerance );
+ bool isLocalOK = CreatePolylines( theDoc, thePolyline->GetName(), aCurvesList, true );
+ isOK = isOK && isLocalOK;
+ }
+ return isOK;
+}
+
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
+ const Handle( HYDROData_PolylineXY )& theTool,
+ double theTolerance ) const
+{
+ HYDROData_SequenceOfObjects aSeq;
+ aSeq.Append( theTool );
+ return split( theDoc, thePolyline, aSeq, theTolerance, -1 );
+}
+
+bool HYDROData_PolylineOperator::Split( const Handle( HYDROData_Document )& theDoc,
+ const HYDROData_SequenceOfObjects& thePolylines,
+ double theTolerance )
+{
+ int f = thePolylines.Lower(), l = thePolylines.Upper();
+ for( int i=f; i<=l; i++ )
+ {
+ Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
+ if( !split( theDoc, aPolyline, thePolylines, theTolerance, i ) )
+ return false;
+ }
+ return true;
+}
+
+bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theDoc,
+ const QString& theName,
+ const HYDROData_SequenceOfObjects& thePolylines,
+ bool isConnectByNewSegment,
+ double theTolerance )
+{
+ TopoDS_Shape aMergedPolyline;
+
+ int f = thePolylines.Lower(), l = thePolylines.Upper();
+ for( int i=f; i<=l; i++ )
+ {
+ Handle( HYDROData_PolylineXY ) aPolyline = Handle( HYDROData_PolylineXY )::DownCast( thePolylines.Value( i ) );
+ std::vector<TopoDS_Wire> aCurves = GetWires( aPolyline );
+ for( int j=0, m=aCurves.size(); j<m; j++ )
+ if( !Merge( aMergedPolyline, aCurves[j], isConnectByNewSegment, theTolerance ) )
+ return false;
+ }
+
+ std::vector<TopoDS_Shape> aShapes( 1 );
+ aShapes[0] = aMergedPolyline;
+ CreatePolylines( theDoc, theName, aShapes, false );
+
+ return true;
+}
+
+bool HYDROData_PolylineOperator::Merge( TopoDS_Shape& theShape, const TopoDS_Wire& theWire,
+ bool isConnectByNewSegment, double theTolerance )
+{
+ //TODO
+ return true;
+}
+
+bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theDoc,
+ const Handle( HYDROData_PolylineXY )& thePolyline,
+ const HYDROData_SequenceOfObjects& theTools,
+ double theTolerance,
+ int theIgnoreIndex ) const
+{
+ std::vector<TopoDS_Wire> aCurves = GetWires( thePolyline );
+ std::vector<TopoDS_Wire> aToolCurves;
+ for( int i=theTools.Lower(), n=theTools.Upper(); i<=n; i++ )
+ if( i!=theIgnoreIndex )
+ {
+ Handle( HYDROData_PolylineXY ) aToolPolyline =
+ Handle( HYDROData_PolylineXY )::DownCast( theTools.Value( i ) );
+ append( aToolCurves, GetWires( aToolPolyline ) );
+ }
+
+ const int aPSCount = aCurves.size();
+ const int aTSCount = aToolCurves.size();
+ std::vector<TopoDS_Shape> aResult;
+ for (int aPSI = 0; aPSI < aPSCount; ++aPSI)
+ {
+ NCollection_Vector<TopoDS_Edge> aCurve;
+ Standard_Boolean aIsClosed;
+ if (!WireToCurve(aCurves[aPSI], aCurve, aIsClosed))
+ {
+ continue;
+ }
+
+ NCollection_Vector<NCollection_Sequence<Standard_Real> > aParams;
+ aParams.SetValue(aPSCount - 1, NCollection_Sequence<Standard_Real>());
+ for (int aTSI = 0; aTSI < aTSCount; ++aTSI)
+ {
+ IntersectCurve(aCurve, aToolCurves[aTSI], aParams);
+ }
+
+ NCollection_Vector<NCollection_Vector<TopoDS_Edge> > aSplittedCurves;
+ SplitCurveByPoints(aCurve, aParams, aSplittedCurves);
+
+ Standard_Boolean aIsClosed2 = aIsClosed;
+ if (aIsClosed2)
+ {
+ const NCollection_Sequence<Standard_Real>& aPs = aParams.First();
+ if (!aPs.IsEmpty())
+ {
+ const TopoDS_Edge& aEdge = aCurve.First();
+ const Standard_Boolean isForward =
+ (aEdge.Orientation() != TopAbs_REVERSED);
+ const Standard_Real aParam = isForward ? aPs.First() : aPs.Last();
+ BRepAdaptor_Curve aCurve(aEdge);
+ const Standard_Real aEndParam = isForward ?
+ aCurve.FirstParameter() : aCurve.LastParameter();
+ aIsClosed2 = (Abs(aParam - aEndParam) > Precision::PConfusion());
+ }
+
+ if (aIsClosed2)
+ {
+ const NCollection_Sequence<Standard_Real>& aPs = aParams.Last();
+ if (!aPs.IsEmpty())
+ {
+ const TopoDS_Edge& aEdge = aCurve.Last();
+ const Standard_Boolean isForward =
+ (aEdge.Orientation() != TopAbs_REVERSED);
+ const Standard_Real aParam = isForward ? aPs.Last() : aPs.First();
+ BRepAdaptor_Curve aCurve(aEdge);
+ const Standard_Real aEndParam = isForward ?
+ aCurve.LastParameter() : aCurve.FirstParameter();
+ aIsClosed2 = (Abs(aParam - aEndParam) >= Precision::PConfusion());
+ }
+ }
+ }
+
+ Standard_Integer aFSCI = 0, aLSCI = aSplittedCurves.Size() - 1;
+ if (aIsClosed2 && aFSCI < aLSCI)
+ {
+ TopoDS_Wire aWire;
+ CurveToWire(aSplittedCurves(aLSCI), aSplittedCurves(aFSCI), aWire);
+ aResult.push_back(aWire);
+ ++aFSCI;
+ --aLSCI;
+ }
+
+ for (Standard_Integer aSCI = aFSCI; aSCI <= aLSCI; ++aSCI)
+ {
+ TopoDS_Wire aWire;
+ CurveToWire(aSplittedCurves(aSCI), aWire);
+ aResult.push_back(aWire);
+ }
+ }
+
+ CreatePolylines(theDoc, thePolyline->GetName(), aResult, true);
+ return true;
+}
+
+std::vector<TopoDS_Wire> HYDROData_PolylineOperator::GetWires( const Handle( HYDROData_PolylineXY )& thePolyline )
+{
+ std::vector<TopoDS_Wire> aResult;
+
+ TopoDS_Shape aShape = thePolyline->GetShape();
+
+ if( aShape.ShapeType()==TopAbs_WIRE )
+ {
+ aResult.push_back( TopoDS::Wire( aShape ) );
+ }
+ else
+ {
+ TopExp_Explorer anExp( aShape, TopAbs_WIRE );
+ for( ; anExp.More(); anExp.Next() )
+ {
+ aResult.push_back( TopoDS::Wire( anExp.Current() ) );
}
}
+ return aResult;
}
std::vector<TopoDS_Shape> HYDROData_PolylineOperator::Split( const TopoDS_Wire& theWire,
std::vector<TopoDS_Shape> aResult;
NCollection_Vector<TopoDS_Edge> aEdges;
Standard_Boolean isClosed;
- if (!OrderCurveEdges(theWire, aEdges, isClosed))
+ if (!WireToCurve(theWire, aEdges, isClosed))
{
aResult.push_back(theWire);
return aResult;
TopoDS_Wire aWire;
if (!isClosed)
{
- CollectCurveWire(aEdges1, aWire);
+ CurveToWire(aEdges1, aWire);
if (!aEdges2.IsEmpty())
{
aResult.push_back(aWire);
- CollectCurveWire(aEdges2, aWire);
+ CurveToWire(aEdges2, aWire);
}
}
else
{
- CollectCurveWire(aEdges2, aEdges1, aWire);
+ if (!aEdges2.IsEmpty())
+ {
+ CurveToWire(aEdges2, aEdges1, aWire);
+ }
+ else
+ {
+ CurveToWire(aEdges1, aWire);
+ }
}
aResult.push_back(aWire);
return aResult;
double theTolerance )
{
std::vector<TopoDS_Shape> aResult;
+ NCollection_Vector<TopoDS_Edge> aWEdges, aTEdges;
+ Standard_Boolean aIsWClosed, aIsTClosed;
+ if (!WireToCurve(theWire, aWEdges, aIsWClosed) ||
+ !WireToCurve(theTool, aTEdges, aIsTClosed))
+ {
+ return aResult;
+ }
+
+
//TODO
return aResult;
}