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