Salome HOME
The data model has been rolled back to previous version.
[modules/hydro.git] / src / HYDROData / test_HYDROData_Polyline.cxx
index 66f214f4f7ad654d911aa2237ebcf11d7c3cec0e..8899ee2929170663f86691491ecd8e78b0e99d85 100755 (executable)
@@ -13,31 +13,50 @@ void test_HYDROData_Polyline::testPolyline()
   Handle(HYDROData_Polyline) aPolyline = 
     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
   // empty image
-  QList<QPointF> aPoints = aPolyline->points();
-  CPPUNIT_ASSERT(aPoints.size() == 0 );
 
-  for( int i = 0 ; i < 10 ; i++ ){
-    double anX = ((double)i)*0.1;
-    double anY = ((double)(i-5))*10.;
-    QPointF aPoint(anX,anY);
-    aPoints.append(aPoint);
-  }
+  int aDim = aPolyline->GetDimension();
+  CPPUNIT_ASSERT(aDim == 0 );
 
-  aPolyline->setPoints( aPoints );
-  
-  QList<QPointF> aRes = aPolyline->points();
+  aPolyline->SetDimension(2);
+  aDim = aPolyline->GetDimension();
+  CPPUNIT_ASSERT( aDim == 2 );
+
+  aPolyline->SetDimension(3);
+  aDim = aPolyline->GetDimension();
+  CPPUNIT_ASSERT( aDim == 3 );
+
+  PolylineSection aSect1;
+  aSect1.mySectionName = "Section_1";
+  aSect1.myType = PolylineSection::SECTION_POLYLINE;
+  aSect1.myIsClosed = false;
+
+  QList<PolylineSection> aSections;
+  aSections << aSect1;
 
-  CPPUNIT_ASSERT( aRes.size() == 10 );
+  PolylineSection aSect2;
+  aSect1.mySectionName = "Section_2";
+  aSect1.myType = PolylineSection::SECTION_SPLINE;
+  aSect1.myIsClosed = true;
+  aSections << aSect2;
+
+  aPolyline->SetPolylineData( aSections );
+  QList<PolylineSection> aRestoredSect = aPolyline->GetPolylineData();
+  int aRestSize = aRestoredSect.size();
+  CPPUNIT_ASSERT( aRestSize == 2 );
   
-  for( int i = 0 ; i < 10 ; i++ ){
-    double anX = aRes[i].x();
-    double anY = aRes[i].y();
-    double aRefX = ((double)i)*0.1;
-    double aRefY = ((double)(i-5))*10.;
-    CPPUNIT_ASSERT( anX == aRefX );
-    CPPUNIT_ASSERT( anY == aRefY );
-     
-  }
+//  printf("Sect1.Name=%s RestName=%s\n", aSect1.mySectionName, aRestoredSect[0].mySectionName );
+  CPPUNIT_ASSERT( aRestoredSect[0].myType == PolylineSection::SECTION_POLYLINE );
+  CPPUNIT_ASSERT( aRestoredSect[0].myIsClosed == false );
+  CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsLess( aSect1.mySectionName ) == false );
+  CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsGreater( aSect1.mySectionName ) == false );
+  CPPUNIT_ASSERT( aRestoredSect[0].myCoords.size() == 0 );
+
+  CPPUNIT_ASSERT( aRestoredSect[1].myType == PolylineSection::SECTION_SPLINE );
+  CPPUNIT_ASSERT( aRestoredSect[1].myIsClosed == true );
+  CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsLess( aSect2.mySectionName ) == false );
+  CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsGreater( aSect2.mySectionName ) == false );
+  CPPUNIT_ASSERT( aRestoredSect[1].myCoords.size() == 0 );
+
   aDoc->Close();
 }
 
@@ -48,34 +67,14 @@ void test_HYDROData_Polyline::testCopy()
   Handle(HYDROData_Polyline) aPolyline1 = 
     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
 
-  QList<QPointF> aPoints;
-  for( int i = 0 ; i < 10 ; i++ ){
-    double anX = ((double)i)*0.1;
-    double anY = ((double)(i-5))*10.;
-    QPointF aPoint(anX,anY);
-    aPoints.append(aPoint);
-  }
 
-  aPolyline1->setPoints(aPoints);
+//  aPolyline1->setPoints(aPoints);
 
   Handle(HYDROData_Polyline) aPolyline2 = 
     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
 
   aPolyline1->CopyTo(aPolyline2);
 
-  QList<QPointF> aRes = aPolyline2->points();
-
-  CPPUNIT_ASSERT( aRes.size() == 10 );
-  
-  for( int i = 0 ; i < 10 ; i++ ){
-    double anX = aRes[i].x();
-    double anY = aRes[i].y();
-    double aRefX = ((double)i)*0.1;
-    double aRefY = ((double)(i-5))*10.;
-    CPPUNIT_ASSERT( anX == aRefX );
-    CPPUNIT_ASSERT( anY == aRefY );
-     
-  }
 
   aDoc->Close();
 }