Salome HOME
size of image is limited by 7000 pixels
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_CurveCreatorProfile.cxx
index 8468d483137494b0b1bf5596c668dd94d0381e85..8ea0425935f15f77409397104cffd02be36995eb 100644 (file)
@@ -19,6 +19,7 @@
 #include <HYDROGUI_CurveCreatorProfile.h>
 #include <CurveCreator_Displayer.hxx>
 #include <CurveCreator_Section.hxx>
+#include <QVector>
 
 HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
 : CurveCreator_Curve( CurveCreator::Dim2d )
@@ -29,6 +30,7 @@ HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
   aSection->myIsClosed = false;
 
   mySections.push_back( aSection );
+  mySkipSorting = true;
 }
 
 HYDROGUI_CurveCreatorProfile::~HYDROGUI_CurveCreatorProfile()
@@ -54,7 +56,7 @@ bool HYDROGUI_CurveCreatorProfile::clearInternal()
     myDisplayer->eraseAll( true );
 
   // Delete all allocated data.
-  CurveCreator_Section* aSection = getSection( 0 );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( 0 );
   if ( aSection )
     aSection->myPoints.clear();
 
@@ -118,7 +120,7 @@ bool HYDROGUI_CurveCreatorProfile::addPointsInternal( const CurveCreator::Sectio
 {
   bool res = false;
 
-  CurveCreator_Section* aSection = getSection( 0 );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( 0 );
   if( !aSection )
     return res;
 
@@ -192,7 +194,7 @@ bool HYDROGUI_CurveCreatorProfile::setPointInternal( const CurveCreator::Section
   }
 
   int anISection = 0;
-  CurveCreator_Section* aSection = getSection( anISection );
+  CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( anISection );
   if( !aSection )
     return aRes;
 
@@ -229,7 +231,7 @@ void HYDROGUI_CurveCreatorProfile::convert( const CurveCreator::PosPointsList& t
 
 bool HYDROGUI_CurveCreatorProfile::canPointsBeSorted()
 {
-  return true;
+  return false;
 }
 
 /**
@@ -259,3 +261,26 @@ bool HYDROGUI_CurveCreatorProfile::addPoints( const CurveCreator::Coordinates& t
   
   return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt );
 }
+
+bool ULess( const gp_Pnt& p1, const gp_Pnt& p2 )
+{
+  return p1.X() < p2.X();
+}
+
+Handle(TColgp_HArray1OfPnt) HYDROGUI_CurveCreatorProfile::GetDifferentPoints( int theISection ) const
+{
+  Handle(TColgp_HArray1OfPnt) points = CurveCreator_Curve::GetDifferentPoints( theISection );
+  if( points.IsNull() )
+    return points;
+
+  QVector<gp_Pnt> vpoints( points->Size() );
+  for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+    vpoints[j] = points->Value( i );
+
+  qSort( vpoints.begin(), vpoints.end(), ULess );
+
+  for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+    points->SetValue( i, vpoints[j] );
+
+  return points;
+}