Salome HOME
code revision for Linux
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_LandCoverMap.cxx
index 721070bcb8f5616105b2ac832af3e3f5b7a5817e..e1589b7b13e913c608eb996b7b91eacb58460908 100644 (file)
@@ -36,6 +36,9 @@
 #include <QColor>
 
 #include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+
+const QString REF_DATA_PATH = qgetenv( "HYDRO_REFERENCE_DATA" );
 
 TopoDS_Edge Spline( const QList<double>& theXYList, bool isClosed = false )
 {
@@ -249,3 +252,101 @@ void test_HYDROData_LandCoverMap::test_remove()
 
   aDoc->Close();
 }
+
+void test_HYDROData_LandCoverMap::test_merge_faces()
+{
+  TopoDS_Shape pp1, pp2, pp3, pp4;
+  BRep_Builder BB;
+  BRepTools::Read(pp1, (REF_DATA_PATH + "/pp1.brep").toStdString().c_str(), BB);
+  BRepTools::Read(pp2, (REF_DATA_PATH + "/pp2.brep").toStdString().c_str(), BB);
+  BRepTools::Read(pp3, (REF_DATA_PATH + "/pp3.brep").toStdString().c_str(), BB);
+  BRepTools::Read(pp4, (REF_DATA_PATH + "/pp4.brep").toStdString().c_str(), BB);
+
+  CPPUNIT_ASSERT(!pp1.IsNull());
+  CPPUNIT_ASSERT(!pp2.IsNull());
+  CPPUNIT_ASSERT(!pp3.IsNull());
+  CPPUNIT_ASSERT(!pp4.IsNull());
+
+  //Test mergeFaces() func; USD == true
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp2);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs11" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp3);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs12" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp2);
+    Faces.Append(pp4);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs13" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp3);
+    Faces.Append(pp4);
+    Faces.Append(pp2);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, true );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs14" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_FACE);
+  }
+  //
+
+  //Test mergeFaces() func; USD == false
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp2);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs21" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp3);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs22" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp2);
+    Faces.Append(pp4);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs23" );
+   CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+  {
+    TopTools_ListOfShape Faces;
+    Faces.Append(pp1);
+    Faces.Append(pp3);
+    Faces.Append(pp4);
+    Faces.Append(pp2);
+    TopoDS_Shape aMergedFace = HYDROData_LandCoverMap::MergeFaces( Faces, false );
+    TestViewer::show( aMergedFace, AIS_Shaded, true, "cs24" );
+    CPPUNIT_ASSERT_IMAGES
+    CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+  }
+}