]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #751: automatic test for bug
authorasl <asl@opencascade.com>
Mon, 7 Dec 2015 05:57:21 +0000 (08:57 +0300)
committerasl <asl@opencascade.com>
Mon, 7 Dec 2015 05:57:21 +0000 (08:57 +0300)
src/HYDRO_tests/reference_data/Channel.png [deleted file]
src/HYDRO_tests/test_HYDROData_Channel.cxx
src/HYDRO_tests/test_HYDROData_Channel.h

diff --git a/src/HYDRO_tests/reference_data/Channel.png b/src/HYDRO_tests/reference_data/Channel.png
deleted file mode 100644 (file)
index f30b494..0000000
Binary files a/src/HYDRO_tests/reference_data/Channel.png and /dev/null differ
index 82ca4336beaabee7002007650ee25737fbe47d5e..c80b0da3c356626d86e999e08668d5589480a4ea 100644 (file)
@@ -22,6 +22,7 @@
 #include <HYDROData_PolylineXY.h>
 #include <HYDROData_Polyline3D.h>
 #include <HYDROData_Profile.h>
+#include <HYDROGUI_Polyline.h>
 
 #include <TestShape.h>
 #include <TestViewer.h>
 
 TopoDS_Edge Spline( const QList<double>& theXYList, bool isClosed = false );
 
-void test_HYDROData_Channel::test_2d_prs()
+void test_HYDROData_Channel::test_channel_prs_refs_751()
 {
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
-  Handle(HYDROData_PolylineXY) aPolyline2d = 
+  Handle(HYDROData_PolylineXY) Polyline_2 = 
     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
-  aPolyline2d->SetName( "polyline2d_1" );
-  aPolyline2d->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+  Polyline_2->SetName( "polyline2d_1" );
+  Polyline_2->AddSection( "", HYDROData_IPolyline::SECTION_SPLINE, false );
+  Polyline_2->AddPoint( 0, gp_XY( -192.40, 397.86 ) );
+  Polyline_2->AddPoint( 0, gp_XY( -53.44, 293.35 ) );
+  Polyline_2->AddPoint( 0, gp_XY( 102.14, 225.65 ) );
+  Polyline_2->AddPoint( 0, gp_XY( 251.78, 108.08 ) );
+  Polyline_2->Update();
+
+  CPPUNIT_ASSERT_EQUAL( false, (bool)Polyline_2->GetShape().IsNull() );
+
+  Handle(HYDROData_Profile) aProfile0 = 
+    Handle(HYDROData_Profile)::DownCast( aDoc->CreateObject( KIND_PROFILE ) );
+  aProfile0->SetName( "profile_0" );
+
+  HYDROData_IPolyline::PointsList aPoints;
+  aPoints.Append( gp_XY( 0.0, 0.0 ) );
+  aPoints.Append( gp_XY( 1.0, 0.0 ) );
+  aProfile0->GetProfileUZ( true );
+  aProfile0->SetParametricPoints( aPoints );
+  aProfile0->Update();
 
   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 );
+  aPolyline3d->SetPolylineXY( Polyline_2 );
+  aPolyline3d->SetProfileUZ( aProfile0->GetProfileUZ() );
+  aPolyline3d->Update();
 
   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 );
+  aPoints.Clear();
+  aPoints.Append( gp_XY( 0.0, 0.1 ) );
+  aPoints.Append( gp_XY( 12.5, 0.0 ) );
+  aPoints.Append( gp_XY( 25.0, 0.1 ) );
+  aProfile->GetProfileUZ( true );
+  aProfile->SetParametricPoints( aPoints );
+  aProfile->GetProfileUZ()->SetSectionType( 0, HYDROData_IPolyline::SECTION_SPLINE );
+  aProfile->Update();
 
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aProfile->GetShape3D().IsNull() );
+  CPPUNIT_ASSERT_EQUAL( false, (bool)aPolyline3d->GetShape3D().IsNull() );
 
   Handle(HYDROData_Channel) aChannel = 
     Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) );
@@ -77,8 +98,10 @@ void test_HYDROData_Channel::test_2d_prs()
   TestViewer::show( aChannel->GetTopShape(), AIS_Shaded, true, "Channel" );
   TestViewer::show( aChannel->GetLeftShape(), AIS_WireFrame, true, Qt::red );
   TestViewer::show( aChannel->GetRightShape(), AIS_WireFrame, true, Qt::red );
-  //TestViewer::show( aWire, AIS_Shaded, true, "Channel" );
+  Handle(HYDROGUI_Polyline) Polyline_Prs = new HYDROGUI_Polyline( aPolyline3d->GetShape3D() );
+  Polyline_Prs->SetColor( Quantity_NOC_WHITE );
+  TestViewer::show( Polyline_Prs, AIS_WireFrame, 0, true, "" );
   CPPUNIT_ASSERT_IMAGES
-
   aDoc->Close();
 }
index c4e22a89b89e85963201f28f926c8cab660261ff..0d66258f822805a37f72238da87e4e9cd1948775 100644 (file)
 
 class test_HYDROData_Channel : public CppUnit::TestFixture {
   CPPUNIT_TEST_SUITE( test_HYDROData_Channel );
-  CPPUNIT_TEST( test_2d_prs );
+  CPPUNIT_TEST( test_channel_prs_refs_751 );
   CPPUNIT_TEST_SUITE_END();
 
 private:
 
 public:
-  void test_2d_prs();
+  void test_channel_prs_refs_751();
 };
 
 CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Channel );