From: asl Date: Wed, 21 Oct 2015 10:43:04 +0000 (+0300) Subject: refs #624: test for split polylines X-Git-Tag: v1.5~75^2~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f6a67a5b0ca7be95649a25ed3632217ac9fd35d;p=modules%2Fhydro.git refs #624: test for split polylines --- diff --git a/src/HYDRO_tests/TestViewer.cxx b/src/HYDRO_tests/TestViewer.cxx index f54fdfc0..f3bd5105 100644 --- a/src/HYDRO_tests/TestViewer.cxx +++ b/src/HYDRO_tests/TestViewer.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,8 @@ void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject, void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor ) { Handle(AIS_Shape) aShape = new AIS_Shape( theShape ); + if( theShape.ShapeType()==TopAbs_VERTEX ) + aShape->Attributes()->PointAspect()->SetTypeOfMarker( Aspect_TOM_X ); aShape->SetMaterial( Graphic3d_NOM_PLASTIC ); aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) ); context()->Display( aShape, theMode, 0, Standard_False ); diff --git a/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png b/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png new file mode 100644 index 00000000..98c5e924 Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png differ diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx index 95a89ee8..ee08e8bb 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.cxx @@ -20,10 +20,26 @@ #include #include +#include +#include +#include +#include #include #include +#include +#include +#include +#include +#include +#include + +TopoDS_Edge Spline( const QList& theXYList, bool isClosed = false ); + + + + void test_HYDROData_PolylineXY::testPolyline() { Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); @@ -72,3 +88,37 @@ void test_HYDROData_PolylineXY::testCopy() aDoc->Close(); } + +void test_HYDROData_PolylineXY::testSplit_refs_624() +{ + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( 1 ); + + Handle(HYDROData_PolylineXY) aPolyline = + Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) ); + aPolyline->SetName( "test" ); + + QList aCoords = QList() << 10 << 10 << 20 << 10 << 20 << 20 << 10 << 20; + TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( Spline( aCoords, true ) ).Wire(); + aPolyline->SetShape( aWire ); + + gp_Pnt2d aPnt( 20, 20 ); + + TestViewer::show( aPolyline->GetShape(), 0, true, "LandCoverMap_Split_Polyline" ); + //TestViewer::show( BRepBuilderAPI_MakeVertex( aPnt ).Vertex(), 1, true, Qt::green ); + CPPUNIT_ASSERT_IMAGES + + HYDROData_PolylineOperator anOp; + CPPUNIT_ASSERT_EQUAL( true, anOp.Split( aDoc, aPolyline, aPnt, 1E-3 ) ); + + HYDROData_Iterator anIt( aDoc, KIND_POLYLINEXY ); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test" ), anIt.Current()->GetName() ); + anIt.Next(); + CPPUNIT_ASSERT_EQUAL( true, anIt.More() ); + CPPUNIT_ASSERT_EQUAL( QString( "test_1" ), anIt.Current()->GetName() ); + anIt.Next(); + CPPUNIT_ASSERT_EQUAL( false, anIt.More() ); + + aDoc->Close(); +} + diff --git a/src/HYDRO_tests/test_HYDROData_PolylineXY.h b/src/HYDRO_tests/test_HYDROData_PolylineXY.h index 24623b3c..e67e36f3 100644 --- a/src/HYDRO_tests/test_HYDROData_PolylineXY.h +++ b/src/HYDRO_tests/test_HYDROData_PolylineXY.h @@ -19,9 +19,10 @@ #include class test_HYDROData_PolylineXY : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(test_HYDROData_PolylineXY); - CPPUNIT_TEST(testPolyline); - CPPUNIT_TEST(testCopy); + CPPUNIT_TEST_SUITE( test_HYDROData_PolylineXY ); + CPPUNIT_TEST( testPolyline ); + CPPUNIT_TEST( testCopy ); + CPPUNIT_TEST( testSplit_refs_624 ); CPPUNIT_TEST_SUITE_END(); private: @@ -37,6 +38,8 @@ public: // checks the image properties copy/paste void testCopy(); + + void testSplit_refs_624(); }; CPPUNIT_TEST_SUITE_REGISTRATION(test_HYDROData_PolylineXY);