X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_PolylineXY.cxx;h=c44a9f5b574b70317c4af030a187dd0df868fd29;hb=9c947f35615e69e9e54a8c4b074dd1f2be13689c;hp=e11b3a2366559564159ae82d72547512f3f98a01;hpb=73c6183c872b9bef4db51730512666316f055553;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index e11b3a23..c44a9f5b 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -43,6 +43,7 @@ #include #include #include +#include void test_HYDROData_PolylineXY::testPolyline() { @@ -263,3 +264,109 @@ void test_HYDROData_PolylineXY::test_presentation() aDoc->Close(); } + +void test_HYDROData_PolylineXY::testSplit_refs_627() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + aPolyline->SetName( "test" ); + + QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; + TopoDS_Wire aWire = Wire( aCoords, false ); + aPolyline->SetShape( aWire ); + aPolyline->SetWireColor( Qt::red ); + + gp_Pnt2d aPnt( 20, 20 ); + + HYDROData_PolylineOperator anOp; + CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) ); + + TestViewer::show( TopoDS_Shape(), 0, true, "Split_Polylines_Colors" ); + HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); + for( ; anIt.More(); anIt.Next() ) + { + Handle(HYDROData_PolylineXY) anObj = Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + if( aPolyline->Label() != anObj->Label() ) + TestViewer::show( anObj->GetShape(), 0, true, anObj->GetWireColor() ); + } + CPPUNIT_ASSERT_IMAGES + + HYDROData_Iterator anIt2( aDoc, KIND_POLYLINEXY ); + CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test" ), anIt2.Current()->GetName() ); + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + anIt2.Next(); + CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test_1" ), anIt2.Current()->GetName() ); + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + anIt2.Next(); + CPPUNIT_ASSERT_EQUAL( true, anIt2.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test_2" ), anIt2.Current()->GetName() ); + CPPUNIT_ASSERT_EQUAL( QColor( Qt::red ), + Handle(HYDROData_PolylineXY)::DownCast( anIt2.Current() )->GetWireColor() ); + anIt2.Next(); + CPPUNIT_ASSERT_EQUAL( false, anIt2.More() ); + anIt2.Next(); + + aDoc->Close(); +} + +void test_HYDROData_PolylineXY::test_custom_polylines() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + + Handle(HYDROData_PolylineXY) aPolyline1 = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) aPolyline2 = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + Handle(HYDROData_PolylineXY) aPolyline3 = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + + aPolyline1->SetName( "test1" ); + aPolyline2->SetName( "test2" ); + aPolyline3->SetName( "test3" ); + + CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); + aPolyline1->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false ); + aPolyline1->Update(); + CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); + aPolyline1->AddPoint( 0, gp_XY( 0, 0 ) ); + aPolyline1->Update(); + CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); + + CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); + aPolyline2->SetShape( Wire( QList() << 0 << 0 << 1 << 1 << 2 << 0 ) ); + CPPUNIT_ASSERT_EQUAL( true, aPolyline2->IsCustom() ); + HYDROData_PolylineXY::PointsList aPointsList = aPolyline2->GetPoints( 0 ); + + CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); + CPPUNIT_ASSERT_EQUAL( 33, aPointsList.Size() ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 0, 0 ), aPointsList.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 0.5625, 0.808594 ), aPointsList.Value( 10 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 1.1875, 0.964844 ), aPointsList.Value( 20 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 2, 0 ), aPointsList.Value( 33 ) ); + + + CPPUNIT_ASSERT_EQUAL( false, aPolyline3->IsCustom() ); + aPolyline3->SetShape( WireCirc( gp_Pnt(), 1.0 ) ); + CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsCustom() ); + aPointsList = aPolyline3->GetPoints( 0 ); + + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_SPLINE, aPolyline3->GetSectionType( 0 ) ); + CPPUNIT_ASSERT_EQUAL( true, aPolyline3->IsClosedSection( 0 ) ); + CPPUNIT_ASSERT_EQUAL( 71, aPointsList.Size() ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 1, 0 ), aPointsList.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 0.699242, 0.714885 ), aPointsList.Value( 10 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -0.110394, 0.993888 ), aPointsList.Value( 20 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -0.839072, 0.54402 ), aPointsList.Value( 30 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -0.952415, -0.304806 ), aPointsList.Value( 40 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -0.367302, -0.930102 ), aPointsList.Value( 50 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 0.487173, -0.873306 ), aPointsList.Value( 60 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 0.996087, -0.0883801 ), aPointsList.Value( 71 ) ); + + aDoc->Close(); +}