X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2Ftest_HYDROData_PolylineXY.cxx;h=57d6435fcfd3cc192ab2167e50cea74e5cf22722;hb=3874a2c420b60f4cdcfe90d3286472165ed93405;hp=f89a11ae28e9591fb297a81919e968e249cb271c;hpb=7801bb11d9c4c98c23459286b4434df65f362009;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index f89a11ae..57d6435f 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -102,7 +102,7 @@ void test_HYDROData_PolylineXY::test_split_refs_624() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, true ); + TopoDS_Wire aWire = Wire2d( aCoords, true ); aPolyline->SetShape( aWire ); gp_Pnt2d aPnt( 20, 20 ); @@ -135,7 +135,7 @@ void test_HYDROData_PolylineXY::test_extraction_immersible_zone() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, true ); + TopoDS_Wire aWire = Wire2d( aCoords, true ); aPolyline->SetShape( aWire ); Handle(HYDROData_ImmersibleZone) aZone = @@ -175,7 +175,7 @@ void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() aPolyline3d->SetPolylineXY( aPolyline2d ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, false ); + TopoDS_Wire aWire = Wire2d( aCoords, false ); aPolyline2d->SetShape( aWire ); aPolyline3d->SetTopShape( aWire ); aPolyline3d->SetShape3D( aWire ); @@ -184,8 +184,8 @@ void test_HYDROData_PolylineXY::test_extraction_channel_refs_611() Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) ); aProfile->SetName( "profile_1" ); - QList aCoordsPr = QList() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1; - TopoDS_Wire aWirePr = Wire( aCoordsPr, false ); + QList aCoordsPr = QList() << 0.0 << 0.1 << 0.0 << 0.0 << 1.0 << 0.0; + TopoDS_Wire aWirePr = Wire3d( aCoordsPr, false ); aProfile->SetTopShape( aWirePr ); aProfile->SetShape3D( aWirePr ); @@ -273,7 +273,7 @@ void test_HYDROData_PolylineXY::test_split_refs_627() aPolyline->SetName( "test" ); QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; - TopoDS_Wire aWire = Wire( aCoords, false ); + TopoDS_Wire aWire = Wire2d( aCoords, false ); aPolyline->SetShape( aWire ); aPolyline->SetWireColor( Qt::red ); @@ -338,34 +338,34 @@ void test_HYDROData_PolylineXY::test_custom_polylines() CPPUNIT_ASSERT_EQUAL( false, aPolyline1->IsCustom() ); CPPUNIT_ASSERT_EQUAL( false, aPolyline2->IsCustom() ); - aPolyline2->SetShape( Wire( QList() << 0 << 0 << 1 << 1 << 2 << 0 ) ); + aPolyline2->SetShape( Wire2d( QList() << 0 << 0 << 10 << 10 << 20 << 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( 5, 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( gp_XY( 5, 7.5 ), aPointsList.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 10, 10 ), aPointsList.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 15, 7.5 ), aPointsList.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 20, 0 ), aPointsList.Value( 5 ) ); CPPUNIT_ASSERT_EQUAL( false, aPolyline3->IsCustom() ); - aPolyline3->SetShape( WireCirc( gp_Pnt(), 1.0 ) ); + aPolyline3->SetShape( WireCirc( gp_Pnt(), 10.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 ) ); + CPPUNIT_ASSERT_EQUAL( 7, aPointsList.Size() ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 10, 0 ), aPointsList.Value( 1 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 6.2349, 7.81831 ), aPointsList.Value( 2 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -2.225, 9.749 ), aPointsList.Value( 3 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -9.01, 4.339 ), aPointsList.Value( 4 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -9.01, -4.339 ), aPointsList.Value( 5 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( -2.225, -9.749 ), aPointsList.Value( 6 ) ); + CPPUNIT_ASSERT_EQUAL( gp_XY( 6.2349, -7.81831 ), aPointsList.Value( 7 ) ); aDoc->Close(); } @@ -419,3 +419,74 @@ void test_HYDROData_PolylineXY::test_merge_refs_630() aDoc->Close(); } + +void test_HYDROData_PolylineXY::test_split_straight_refs_634() +{ + 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 ) ); + + aPolyline1->SetName( "test1" ); + aPolyline1->AddSection( "", HYDROData_PolylineXY::SECTION_POLYLINE, false ); + aPolyline1->AddPoint( 0, gp_XY( 0, 0 ) ); + aPolyline1->AddPoint( 0, gp_XY( 10, 20 ) ); + aPolyline1->AddPoint( 0, gp_XY( 30, 10 ) ); + aPolyline1->Update(); + + aPolyline2->SetName( "test2" ); + aPolyline2->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, false ); + aPolyline2->AddPoint( 0, gp_XY( 0, 30 ) ); + aPolyline2->AddPoint( 0, gp_XY( 10, 10 ) ); + aPolyline2->AddPoint( 0, gp_XY( 30, 20 ) ); + aPolyline2->Update(); + + HYDROData_PolylineOperator anOp; + HYDROData_SequenceOfObjects aPolylines; + aPolylines.Append( aPolyline1 ); + aPolylines.Append( aPolyline2 ); + bool isIntersected; + CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline1, aPolyline2, 1E-3, isIntersected ) ); + CPPUNIT_ASSERT_EQUAL( true, isIntersected ); + + HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1" ), anIt.Current()->GetName() ); + anIt.Next(); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test2" ), anIt.Current()->GetName() ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_1" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart1 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart1->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_2" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart2 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart2->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test1_3" ), anIt.Current()->GetName() ); + Handle(HYDROData_PolylineXY) aPart3 = + Handle(HYDROData_PolylineXY)::DownCast( anIt.Current() ); + CPPUNIT_ASSERT_EQUAL( HYDROData_PolylineXY::SECTION_POLYLINE, aPart3->GetSectionType( 0 ) ); + anIt.Next(); + + CPPUNIT_ASSERT_EQUAL( false, anIt.More() ); + + TestViewer::show( aPart1->GetShape(), 0, true, "Split_Straight" ); + TestViewer::show( aPart2->GetShape(), 0, true, Qt::red ); + TestViewer::show( aPart3->GetShape(), 0, true, Qt::green ); + TestViewer::show( aPolyline2->GetShape(), 0, true, Qt::darkGreen ); + CPPUNIT_ASSERT_IMAGES + + aDoc->Close(); +}