X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2Ftest_HYDROData_Polyline.cxx;h=8899ee2929170663f86691491ecd8e78b0e99d85;hb=deed826b2d6c39ba2ed410108cdf54d64cded321;hp=66f214f4f7ad654d911aa2237ebcf11d7c3cec0e;hpb=b58558f56e97ff01757710155cd9a8429b34ae46;p=modules%2Fhydro.git diff --git a/src/HYDROData/test_HYDROData_Polyline.cxx b/src/HYDROData/test_HYDROData_Polyline.cxx index 66f214f4..8899ee29 100755 --- a/src/HYDROData/test_HYDROData_Polyline.cxx +++ b/src/HYDROData/test_HYDROData_Polyline.cxx @@ -13,31 +13,50 @@ void test_HYDROData_Polyline::testPolyline() Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE)); // empty image - QList 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 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 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 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 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 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(); }