Salome HOME
refs #249 - Undo after Join selected sections operation works not properly
[modules/hydro.git] / src / HYDROCurveCreator / CurveCreator_Profile.cxx
index c9b349f834aed41eb46b29a02ba0831db1d14039..69e60486ed65e3cc66c7913f42db6a1be7b12c3c 100644 (file)
@@ -133,18 +133,6 @@ bool CurveCreator_Profile::setClosed( const int theISection,
   return false;
 }
 
-bool CurveCreator_Profile::setSectionTypeInternal( const int theISection, 
-                                                   const CurveCreator::SectionType theType )
-{
-  return CurveCreator_Curve::setSectionTypeInternal( theISection, theType );
-}
-
-bool CurveCreator_Profile::setSectionType( const int theISection, 
-                                           const CurveCreator::SectionType theType )
-{
-  return CurveCreator_Curve::setSectionType( theISection, theType );
-}
-
 bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap )
 {
   bool res = false;
@@ -179,7 +167,7 @@ bool CurveCreator_Profile::addPointsInternal( const CurveCreator::SectionsMap &t
         if ( !aSection->myPoints.empty() )
           aC = *(aSection->myPoints.end() - 2);
 
-        if ( aSection->myPoints.empty() || aCoordU > aC )
+        if ( aSection->myPoints.empty() || aCoordU >= aC )
         {
           aSection->myPoints.push_back( aCoordU );
           aSection->myPoints.push_back( aCoordZ );
@@ -218,6 +206,10 @@ bool CurveCreator_Profile::setPointInternal( const CurveCreator::SectionsMap &th
 {
   bool aRes = false;
 
+  if ( mySkipSorting ) {
+    return CurveCreator_Curve::setPointInternal( theSectionsMap );
+  }
+
   int anISection = 0;
   CurveCreator_Section* aSection = mySections.at( anISection );
   if( !aSection )
@@ -253,3 +245,36 @@ void CurveCreator_Profile::convert( const CurveCreator::PosPointsList& thePoints
     theConvPoints.push_back( anIPnt );
   }
 }
+
+bool CurveCreator_Profile::canPointsBeSorted()
+{
+  return true;
+}
+
+/**
+ *  Add one point to the specified section starting from the given theIPnt index
+ *  (or at the end of points if \a theIPnt is -1).
+ */
+bool CurveCreator_Profile::addPoints( const CurveCreator::Coordinates& theCoords,
+                                      const int theISection,
+                                      const int theIPnt )
+{
+  int anIPnt = theIPnt;
+
+  if ( anIPnt == - 1 && theCoords.size() > 1 ) {
+    CurveCreator::Coordinates aCoords;
+    for ( int i = 0, aNb = getNbPoints( theISection ); i < aNb; i++ ) {
+      aCoords = getPoint( theISection, i );
+      if ( aCoords.size() < 2 ) {
+        continue;
+      }
+
+      if ( theCoords[0] < aCoords[0] ) {
+        anIPnt = i;
+        break;
+      }
+    }
+  }
+  
+  return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt );
+}
\ No newline at end of file