]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #624: test for split polylines
authorasl <asl@opencascade.com>
Wed, 21 Oct 2015 10:43:04 +0000 (13:43 +0300)
committerasl <asl@opencascade.com>
Wed, 21 Oct 2015 10:43:04 +0000 (13:43 +0300)
src/HYDRO_tests/TestViewer.cxx
src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_PolylineXY.cxx
src/HYDRO_tests/test_HYDROData_PolylineXY.h

index f54fdfc064a7b80137e9c1de65fa5c1f91a484cf..f3bd5105943fd80eb84d17a7ab30e685c943d209 100644 (file)
@@ -20,6 +20,7 @@
 #include <AIS_InteractiveContext.hxx>
 #include <AIS_Shape.hxx>
 #include <Aspect_ColorScale.hxx>
+#include <Prs3d_PointAspect.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <QDir>
 #include <QPainter>
@@ -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 (file)
index 0000000..98c5e92
Binary files /dev/null and b/src/HYDRO_tests/reference_data/LandCoverMap_Split_Polyline.png differ
index 95a89ee86bb8bc1074e2554fb872a164a8b19e2b..ee08e8bb0efb9bb80f8e64287b5c96f795869ab9 100644 (file)
 
 #include <HYDROData_Document.h>
 #include <HYDROData_PolylineXY.h>
+#include <HYDROData_PolylineOperator.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Tool.h>
 
+#include <QColor>
 #include <QList>
 #include <QPointF>
 
+#include <TestViewer.h>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+
+TopoDS_Edge Spline( const QList<double>& 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<double> aCoords = QList<double>() << 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();
+}
+
index 24623b3c5e200da6e4ae4ddc71676353d874596e..e67e36f3aa4b322e178f6bf5d4b15534e7214881 100644 (file)
 #include <cppunit/extensions/HelperMacros.h>
 
 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);