]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #634: check type of split polyline
authorasl <asl@opencascade.com>
Mon, 26 Oct 2015 11:51:51 +0000 (14:51 +0300)
committerasl <asl@opencascade.com>
Mon, 26 Oct 2015 11:51:51 +0000 (14:51 +0300)
src/HYDRO_tests/reference_data/Split_Straight.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx
src/HYDRO_tests/test_HYDROData_PolylineXY.h

diff --git a/src/HYDRO_tests/reference_data/Split_Straight.png b/src/HYDRO_tests/reference_data/Split_Straight.png
new file mode 100644 (file)
index 0000000..c93ac46
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Split_Straight.png differ
index f89a11ae28e9591fb297a81919e968e249cb271c..9ec336c1c6f70693c60f38104b8c93b01d2dd349 100644 (file)
@@ -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();
+}
index 588fd7dd61b95d23c7c524d117f15caf14de4eb2..d51b20f51f101aaf9bcb08cefe67c6ecbc286c8e 100644 (file)
@@ -29,6 +29,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture {
   CPPUNIT_TEST( test_extraction_channel_refs_611 );
   CPPUNIT_TEST( test_custom_polylines );
   CPPUNIT_TEST( test_merge_refs_630 );
+  CPPUNIT_TEST( test_split_straight_refs_634 );
   CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -53,6 +54,7 @@ public:
   void test_presentation();
   void test_custom_polylines();
   void test_merge_refs_630();
+  void test_split_straight_refs_634();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);