Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/hydro
[modules/hydro.git] / src / HYDROData / HYDROData_TopoCurve.cxx
index abe49f37865a10e5c4d88a03a67c2cb828485c1b..c58da31f3d95520e991c45f20a39c3ccf4aae12e 100644 (file)
@@ -1,8 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015  EDF-R&D
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
@@ -469,11 +465,13 @@ TopoDS_Wire HYDROData_TopoCurve::Wire() const
   return aWire;
 }
 
-void HYDROData_TopoCurve::Cut(
+bool HYDROData_TopoCurve::Cut(
   const std::list<TopoDS_Edge>::iterator& theEdgePosition,
   const double theParameter,
   HYDROData_TopoCurve& theCurve)
 {
+  bool aResult = false;
+
   // Locate the edge.
   std::list<TopoDS_Edge>::iterator aFirstEIt = myEdges.begin();
   std::list<TopoDS_Edge>::iterator aEIt = aFirstEIt;
@@ -530,6 +528,8 @@ void HYDROData_TopoCurve::Cut(
     *aEIt = aEParts[aFirstPI];
     InsertAfter(aEIt, aEParts[1 - aFirstPI], myEdges);
     ++aEIt;
+
+    aResult = true;
   }
   else
   {
@@ -538,6 +538,19 @@ void HYDROData_TopoCurve::Cut(
     if (aParamI > 0)
     {
       ++aEIt;
+
+      std::list<TopoDS_Edge>::iterator aEdgePosition = theEdgePosition;
+      if (isClosed || ++aEdgePosition != myEdges.end())
+      {
+        aResult = true;
+      }
+    }
+    else
+    {
+      if (isClosed || theEdgePosition != aFirstEIt)
+      {
+        aResult = true;
+      }
     }
   }
 
@@ -548,6 +561,8 @@ void HYDROData_TopoCurve::Cut(
     std::list<TopoDS_Edge>* aEdges = !isClosed ? &theCurve.myEdges : &myEdges;
     aEdges->splice(aEdges->begin(), myEdges, aEIt, aLastEIt);
   }
+
+  return aResult;
 }
 
 void HYDROData_TopoCurve::Cut(
@@ -563,10 +578,11 @@ void HYDROData_TopoCurve::Cut(
   theCurve1.Cut(aEPos1, theParameter, theCurve2);
 }
 
-void HYDROData_TopoCurve::Cut(
+bool HYDROData_TopoCurve::Cut(
   const std::deque<std::list<double> >& theParameters,
   std::deque<HYDROData_TopoCurve>& theCurves) const
 {
+  bool aResult = false;
   HYDROData_TopoCurve aCurves[2];
   aCurves[0] = *this;
   int aCI = 0;
@@ -589,7 +605,7 @@ void HYDROData_TopoCurve::Cut(
       *aPLIt, (aEIt->Orientation() != TopAbs_REVERSED)); aPIt.More(); ++aPIt)
     {
       const int aCI1 = 1 - aCI;
-      aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]);
+      aResult |= aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]);
       if (!aCurves[aCI1].IsEmpty())
       {
         theCurves.push_back(HYDROData_TopoCurve());
@@ -609,6 +625,7 @@ void HYDROData_TopoCurve::Cut(
     }
   }
   theCurves.push_back(aCurves[aCI]);
+  return aResult;
 }
 
 double HYDROData_TopoCurve::Project(