]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#refs 611: test on polylines extraction from the channel
authorasl <asl@opencascade.com>
Wed, 21 Oct 2015 13:25:31 +0000 (16:25 +0300)
committerasl <asl@opencascade.com>
Wed, 21 Oct 2015 13:25:31 +0000 (16:25 +0300)
src/HYDRO_tests/reference_data/Extraction_Channel.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_Channel.png b/src/HYDRO_tests/reference_data/Extraction_Channel.png
new file mode 100644 (file)
index 0000000..f30b494
Binary files /dev/null and b/src/HYDRO_tests/reference_data/Extraction_Channel.png differ
index cb3a5592513fab887e5152978f2e3fc2bd86494c..a311e48d3761a2533297ce4317f6b5998617ab58 100644 (file)
 
 #include<test_HYDROData_PolylineXY.h>
 
+#include <HYDROData_Channel.h>
 #include <HYDROData_Document.h>
 #include <HYDROData_PolylineXY.h>
+#include <HYDROData_Polyline3D.h>
 #include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Profile.h>
 #include <HYDROData_Iterator.h>
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
 
+#include <AIS_DisplayMode.hxx>
 #include <QColor>
 #include <QList>
 #include <QPointF>
@@ -150,3 +154,60 @@ void test_HYDROData_PolylineXY::test_extraction_immersible_zone()
 
   aDoc->Close();
 }
+
+void test_HYDROData_PolylineXY::test_extraction_channel_refs_611()
+{
+Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  Handle(HYDROData_PolylineXY) aPolyline2d = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
+  aPolyline2d->SetName( "polyline2d_1" );
+  aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+
+  Handle(HYDROData_Polyline3D) aPolyline3d = 
+    Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
+  aPolyline3d->SetName( "polyline3d_1" );
+  aPolyline3d->SetPolylineXY( aPolyline2d );
+
+  QList<double> aCoords = QList<double>() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20;
+  TopoDS_Wire aWire = Wire( aCoords, false );
+  aPolyline2d->SetShape( aWire );
+  aPolyline3d->SetTopShape( aWire );
+  aPolyline3d->SetShape3D( aWire );
+
+  Handle(HYDROData_Profile) aProfile = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile->SetName( "profile_1" );
+
+  QList<double> aCoordsPr = QList<double>() << 0.0 << 0.1 << 0.5 << 0.0 << 1.0 << 0.1;
+  TopoDS_Wire aWirePr = Wire( aCoordsPr, false );
+  aProfile->SetTopShape( aWirePr );
+  aProfile->SetShape3D( aWirePr );
+
+
+  Handle(HYDROData_Channel) aChannel = 
+    Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) );
+  aChannel->SetName( "channel_1" );
+  
+  aChannel->SetGuideLine( aPolyline3d );
+  aChannel->SetProfile( aProfile );
+  aChannel->Update();
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetTopShape().IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aChannel->GetShape3D().IsNull() );
+
+  HYDROData_PolylineOperator anOp;
+  CPPUNIT_ASSERT_EQUAL( true, anOp.Extract( aDoc, aChannel ) );
+
+  Handle(HYDROData_PolylineXY) aLeft = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Left_Bank_1", KIND_POLYLINEXY ) );
+  Handle(HYDROData_PolylineXY) aRight = 
+    Handle(HYDROData_PolylineXY)::DownCast( aDoc->FindObjectByName( "channel_1_Right_Bank_1", KIND_POLYLINEXY ) );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aRight.IsNull() );
+
+  TestViewer::show( aChannel->GetTopShape(), 1, true, "Extraction_Channel" );
+  TestViewer::show( aLeft->GetShape(), 0, true, Qt::red );
+  TestViewer::show( aRight->GetShape(), 0, true, Qt::red );
+  CPPUNIT_ASSERT_IMAGES
+
+  aDoc->Close();
+}
index 829d7f3b7166c6ab1dbbeaf8284080b7d003d9d6..cf58c980de2a663995b2d92e3f7fccb35e0475e1 100644 (file)
@@ -24,6 +24,7 @@ class test_HYDROData_PolylineXY : public CppUnit::TestFixture {
   CPPUNIT_TEST( testCopy );
   CPPUNIT_TEST( testSplit_refs_624 );
   CPPUNIT_TEST( test_extraction_immersible_zone );
+  CPPUNIT_TEST( test_extraction_channel_refs_611 );
   CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -43,6 +44,7 @@ public:
   void testSplit_refs_624();
 
   void test_extraction_immersible_zone();
+  void test_extraction_channel_refs_611();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);