#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 )
{
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 );
+ TestViewer::AssertEqual( "cs11" );
+ 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 );
+ TestViewer::AssertEqual( "cs12" );
+ 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 );
+ TestViewer::AssertEqual( "cs13" );
+ 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 );
+ TestViewer::AssertEqual( "cs14" );
+ 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 );
+ TestViewer::AssertEqual( "cs21" );
+ 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 );
+ TestViewer::AssertEqual( "cs22" );
+ 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 );
+ TestViewer::AssertEqual( "cs23" );
+ 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 );
+ TestViewer::AssertEqual( "cs24" );
+ CPPUNIT_ASSERT(aMergedFace.ShapeType() == TopAbs_SHELL);
+ }
}