From: isn Date: Thu, 12 Nov 2015 14:41:25 +0000 (+0300) Subject: Remove internal edges X-Git-Tag: v1.5~44^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=813d1f383dd56fe4451e7c7eb60e7384975007c6;p=modules%2Fhydro.git Remove internal edges --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index bc0f1551..f3d2873a 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -39,10 +39,16 @@ #include #include #include +#include #include #include #include #include +#include +#include +#include +#include + #include #include @@ -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(); + +} diff --git a/src/HYDROData/HYDROData_LandCoverMap.h b/src/HYDROData/HYDROData_LandCoverMap.h index 9ab0276c..24eeae19 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.h +++ b/src/HYDROData/HYDROData_LandCoverMap.h @@ -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& ); diff --git a/src/HYDRO_tests/reference_data/LCM_split_2a.png b/src/HYDRO_tests/reference_data/LCM_split_2a.png index 51cf6e0e..59aa5163 100644 Binary files a/src/HYDRO_tests/reference_data/LCM_split_2a.png and b/src/HYDRO_tests/reference_data/LCM_split_2a.png differ diff --git a/src/HYDRO_tests/reference_data/LCM_split_2b.png b/src/HYDRO_tests/reference_data/LCM_split_2b.png index 2f054f89..f175c5ee 100644 Binary files a/src/HYDRO_tests/reference_data/LCM_split_2b.png and b/src/HYDRO_tests/reference_data/LCM_split_2b.png differ diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index 2f9896cf..60b21ae9 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -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();