Salome HOME
Update flag for calculation case during polyline changing.
[modules/hydro.git] / src / HYDROData / test_HYDROData_Polyline.cxx
1 #include<test_HYDROData_Polyline.h>
2
3 #include <HYDROData_Document.h>
4 #include <HYDROData_Polyline.h>
5
6 #include <QList>
7 #include <QPointF>
8
9 void test_HYDROData_Polyline::testPolyline()
10 {
11   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
12
13   Handle(HYDROData_Polyline) aPolyline = 
14     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
15   // empty image
16
17   int aDim = aPolyline->GetDimension();
18   CPPUNIT_ASSERT(aDim == 0 );
19
20   aPolyline->SetDimension(2);
21   aDim = aPolyline->GetDimension();
22   CPPUNIT_ASSERT( aDim == 2 );
23
24   aPolyline->SetDimension(3);
25   aDim = aPolyline->GetDimension();
26   CPPUNIT_ASSERT( aDim == 3 );
27
28   PolylineSection aSect1;
29   aSect1.mySectionName = "Section_1";
30   aSect1.myType = PolylineSection::SECTION_POLYLINE;
31   aSect1.myIsClosed = false;
32
33   QList<PolylineSection> aSections;
34   aSections << aSect1;
35
36   PolylineSection aSect2;
37   aSect1.mySectionName = "Section_2";
38   aSect1.myType = PolylineSection::SECTION_SPLINE;
39   aSect1.myIsClosed = true;
40   aSections << aSect2;
41
42   aPolyline->SetPolylineData( aSections );
43   QList<PolylineSection> aRestoredSect = aPolyline->GetPolylineData();
44   int aRestSize = aRestoredSect.size();
45   CPPUNIT_ASSERT( aRestSize == 2 );
46   
47 //  printf("Sect1.Name=%s RestName=%s\n", aSect1.mySectionName, aRestoredSect[0].mySectionName );
48   CPPUNIT_ASSERT( aRestoredSect[0].myType == PolylineSection::SECTION_POLYLINE );
49   CPPUNIT_ASSERT( aRestoredSect[0].myIsClosed == false );
50   CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsLess( aSect1.mySectionName ) == false );
51   CPPUNIT_ASSERT( aRestoredSect[0].mySectionName.IsGreater( aSect1.mySectionName ) == false );
52   CPPUNIT_ASSERT( aRestoredSect[0].myCoords.size() == 0 );
53
54   CPPUNIT_ASSERT( aRestoredSect[1].myType == PolylineSection::SECTION_SPLINE );
55   CPPUNIT_ASSERT( aRestoredSect[1].myIsClosed == true );
56   CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsLess( aSect2.mySectionName ) == false );
57   CPPUNIT_ASSERT( aRestoredSect[1].mySectionName.IsGreater( aSect2.mySectionName ) == false );
58   CPPUNIT_ASSERT( aRestoredSect[1].myCoords.size() == 0 );
59
60   aDoc->Close();
61 }
62
63
64 void test_HYDROData_Polyline::testCopy()
65 {
66   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
67   Handle(HYDROData_Polyline) aPolyline1 = 
68     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
69
70
71 //  aPolyline1->setPoints(aPoints);
72
73   Handle(HYDROData_Polyline) aPolyline2 = 
74     Handle(HYDROData_Polyline)::DownCast(aDoc->CreateObject(KIND_POLYLINE));
75
76   aPolyline1->CopyTo(aPolyline2);
77
78
79   aDoc->Close();
80 }