]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
Remove internal edges
authorisn <isn@opencascade.com>
Thu, 12 Nov 2015 14:41:25 +0000 (17:41 +0300)
committerisn <isn@opencascade.com>
Thu, 12 Nov 2015 14:41:25 +0000 (17:41 +0300)
src/HYDROData/HYDROData_LandCoverMap.cxx
src/HYDROData/HYDROData_LandCoverMap.h
src/HYDRO_tests/reference_data/LCM_split_2a.png
src/HYDRO_tests/reference_data/LCM_split_2b.png
src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx

index bc0f1551e9f3193c5bc0cbf9faca4394a591f827..f3d2873a7ec9433d8d6b4bf9b0a6ce42a47fd601 100644 (file)
 #include <TopoDS_Shell.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <BOPAlgo_PaveFiller.hxx>
 #include <BRepTools.hxx>
 #include <TopExp_Explorer.hxx>
 #include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <TopExp.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
+#include <ShapeBuild_ReShape.hxx>
+#include <ShapeFix_Shape.hxx>
+
 
 #include <QFile>
 #include <QString>
@@ -794,6 +800,8 @@ void HYDROData_LandCoverMap::StoreLandCovers( const HYDROData_MapOfFaceToStrickl
   else if( aListOfFaces.Extent() > 1 )
     aResult = MergeFaces( aListOfFaces, false );
 
+  //remove internal edges
+  aResult = RemoveInternal(aResult);
   SetShape( aResult );
 }
 
@@ -841,3 +849,30 @@ QStringList HYDROData_LandCoverMap::DumpToPython( MapOfTreatedObjects& theTreate
 
   return aResList;
 }
+
+TopoDS_Shape HYDROData_LandCoverMap::RemoveInternal(const TopoDS_Shape& InSh)
+{
+  //Shape must be topologically correct
+  TopExp_Explorer anExp(InSh, TopAbs_EDGE);
+  TopTools_ListOfShape anEdgesToRemove;
+
+  for(; anExp.More(); anExp.Next() )
+  {
+    TopoDS_Edge CurEdge = TopoDS::Edge(anExp.Current());
+    if (CurEdge.Orientation() == TopAbs_INTERNAL)
+      anEdgesToRemove.Append(CurEdge);
+  }
+  Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
+  TopoDS_Shape OutSh = aReshape->Apply(InSh);
+  TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
+  for (; aIt.More(); aIt.Next()) 
+    aReshape->Remove(aIt.Value());
+  OutSh = aReshape->Apply(InSh);
+
+  Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+  sfs->Init(OutSh);
+  sfs->Perform();
+  return sfs->Shape();
+
+}
index 9ab0276ca002a1c80995644357afe2f8b1d11055..24eeae197d0a042c4bda5d133dbf384762c7c01e 100644 (file)
@@ -120,6 +120,8 @@ public:
 
   HYDRODATA_EXPORT void StoreLandCovers( const HYDROData_MapOfFaceToStricklerType& );
 
+  HYDRODATA_EXPORT TopoDS_Shape RemoveInternal(const TopoDS_Shape& InSh);
+
 protected:
   void SetShape( const TopoDS_Shape& );
 
index 51cf6e0e3fe183d2e88f66bfc38450b7ac3a0611..59aa5163219e449d87fe8e903bae2e92d5170298 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/LCM_split_2a.png and b/src/HYDRO_tests/reference_data/LCM_split_2a.png differ
index 2f054f8920e09debc55e8fea1ff18da1e76efc43..f175c5ee0c14f030b29224cb0f87dba5e844d216 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/LCM_split_2b.png and b/src/HYDRO_tests/reference_data/LCM_split_2b.png differ
index 2f9896cf45f3ff9ba3065e286768014dc25389bc..60b21ae904dc1e0b9449df83a50d0dabd325aac8 100644 (file)
@@ -914,8 +914,13 @@ void test_HYDROData_LandCoverMap::test_split_2()
     Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
   Polyline_9->AddSection( "Section_1", HYDROData_PolylineXY::SECTION_POLYLINE, false );
   Polyline_9->AddPoint( 0, gp_XY( -103.92, 288.40 ) );
+  Polyline_9->AddPoint( 0, gp_XY( -100.09, 285.22 ) );
+  Polyline_9->AddPoint( 0, gp_XY( -96.10, 281.90 ) );
+  Polyline_9->AddPoint( 0, gp_XY( -90.43, 277.19 ) );
   Polyline_9->AddPoint( 0, gp_XY( -53.41, 246.43 ) );
   Polyline_9->AddPoint( 0, gp_XY( 10.62, 245.01 ) );
+
+
   Polyline_9->Update();
 
 
@@ -926,14 +931,14 @@ void test_HYDROData_LandCoverMap::test_split_2()
 
   CPPUNIT_ASSERT_EQUAL( true, LCM->Split( Polyline_9 ) );
 
-  Handle(HYDROGUI_LandCoverMapPrs) aPrs1 = new HYDROGUI_LandCoverMapPrs( LCM );
-  TestViewer::show( aPrs1, AIS_Shaded, 0, true, "LCM_split_2a" );
+  //Handle(HYDROGUI_LandCoverMapPrs) aPrs1 = new HYDROGUI_LandCoverMapPrs( LCM );
+  TestViewer::show( LCM->GetShape(), AIS_Shaded, /*0,*/ true, "LCM_split_2a" );
   CPPUNIT_ASSERT_IMAGES
 
   CPPUNIT_ASSERT_EQUAL( true, LCM->Split( Polyline_8 ) );
 
-  Handle(HYDROGUI_LandCoverMapPrs) aPrs2 = new HYDROGUI_LandCoverMapPrs( LCM );
-  TestViewer::show( aPrs2, AIS_Shaded, 0, true, "LCM_split_2b" );
+  // Handle(HYDROGUI_LandCoverMapPrs) aPrs2 = new HYDROGUI_LandCoverMapPrs( LCM );
+  TestViewer::show( LCM->GetShape(), AIS_Shaded, /*0,*/ true, "LCM_split_2b" );
   CPPUNIT_ASSERT_IMAGES
 
   aDoc->Close();