]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #611: test for polylines extraction on immersible zone
authorasl <asl@opencascade.com>
Wed, 21 Oct 2015 13:20:00 +0000 (16:20 +0300)
committerasl <asl@opencascade.com>
Wed, 21 Oct 2015 13:20:00 +0000 (16:20 +0300)
src/HYDRO_tests/reference_data/Extraction_ImmZone.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/Extraction_ImmZone.png b/src/HYDRO_tests/reference_data/Extraction_ImmZone.png
new file mode 100644 (file)
index 0000000..9e91978
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Extraction_ImmZone.png differ
index ff966ddcf3297bfd18cd3055af23334df5b8a714..cb3a5592513fab887e5152978f2e3fc2bd86494c 100644 (file)
@@ -22,6 +22,7 @@
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_PolylineOperator.h>
 #include <HYDROData_Iterator.h>
+#include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
 
 #include <QColor>
@@ -116,3 +117,36 @@ void test_HYDROData_PolylineXY::testSplit_refs_624()
   aDoc->Close();
 }
 
+void test_HYDROData_PolylineXY::test_extraction_immersible_zone()
+{
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 );
+
+  Handle(HYDROData_PolylineXY) aPolyline = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline->SetName( "test" );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, true );
+  aPolyline->SetShape( aWire );
+
+  Handle(HYDROData_ImmersibleZone) aZone = 
+    Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
+  aZone->SetName( "zone" );
+  aZone->SetPolyline( aPolyline );
+  aZone->Update();
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aZone->GetTopShape().IsNull() );
+
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Extract( aDoc, aZone ) );
+
+  Handle(HYDROData_PolylineXY) anOuter = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "zone_Outer_1", KIND_POLYLINEXY ) );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)anOuter.IsNull() );
+
+  TestViewer::show( aZone->GetTopShape(), 1, true, "Extraction_ImmZone" );
+  TestViewer::show( anOuter->GetShape(), 0, true, Qt::red );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
index e67e36f3aa4b322e178f6bf5d4b15534e7214881..829d7f3b7166c6ab1dbbeaf8284080b7d003d9d6 100644 (file)
@@ -23,6 +23,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture {
   CPPUNIT_TEST( testPolyline );
   CPPUNIT_TEST( testCopy );
   CPPUNIT_TEST( testSplit_refs_624 );
+  CPPUNIT_TEST( test_extraction_immersible_zone );
   CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -40,6 +41,8 @@ public:
   void testCopy();
 
   void testSplit_refs_624();
+
+  void test_extraction_immersible_zone();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);