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();
}
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();
}