Salome HOME
merge master
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineOperator.cxx
index 0bc2d326069380329d9f92e0bb4d15626c24eff5..b991bf7f6992a0728f13c55e2e93e11940eb3cea 100644 (file)
@@ -163,7 +163,10 @@ bool HYDROData_PolylineOperator::Merge( const Handle( HYDROData_Document )& theD
 
   std::vector<TopoDS_Shape> aPolylines(1);
   aPolylines[0] = aWireSet;
-  CreatePolylines( theDoc, theName, aPolylines, false, QColor() );
+  QString aName = theName;
+  if( aName.isEmpty() )
+    aName = "merged";
+  CreatePolylines( theDoc, aName, aPolylines, true, QColor() );
   return true;
 }
 
@@ -219,12 +222,12 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD
       aCurve.Intersect(aToolCurves[aTSI], aParams);
     }
 
-    std::deque<HYDROData_TopoCurve> aSplittedCurves;
-    theIsIntersected |= aCurve.Cut(aParams, aSplittedCurves);
+    std::deque<HYDROData_TopoCurve> aSplitCurves;
+    theIsIntersected |= aCurve.Cut(aParams, aSplitCurves);
     std::deque<HYDROData_TopoCurve>::const_iterator aCIt =
-      aSplittedCurves.begin();
+      aSplitCurves.begin();
     std::deque<HYDROData_TopoCurve>::const_iterator aLastCIt =
-      aSplittedCurves.end();
+      aSplitCurves.end();
     for (; aCIt != aLastCIt; ++aCIt)
     {
       aResult.push_back(aCIt->Wire());
@@ -303,9 +306,12 @@ bool HYDROData_PolylineOperator::CreatePolylines( const Handle( HYDROData_Docume
     if( isUseIndices )
     {
       QString aNewName = theNamePrefix + "_" + QString::number( anIndex );
-      if( theDoc->FindObjectByName( aNewName ).IsNull() )  // the object with such a name is not found
-        aPolyline->SetName( aNewName );
-      anIndex++;
+      while( !theDoc->FindObjectByName( aNewName ).IsNull() )  // the object with such a name is not found
+      {
+        anIndex++;
+        aNewName = theNamePrefix + "_" + QString::number( anIndex );
+      }
+      aPolyline->SetName( aNewName );
     }
     else
     {