From: isn Date: Tue, 7 Feb 2017 10:55:53 +0000 (+0300) Subject: refs #1119 X-Git-Tag: Salome_8_3_Hydro_1_1rc1~58^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f066ecc704ba16ea9156d7833106265ed013972c;p=modules%2Fhydro.git refs #1119 new RebuildCmp() func + test --- diff --git a/src/HYDROData/HYDROData_Region.cxx b/src/HYDROData/HYDROData_Region.cxx index daf99893..8d4f8d3b 100644 --- a/src/HYDROData/HYDROData_Region.cxx +++ b/src/HYDROData/HYDROData_Region.cxx @@ -363,6 +363,8 @@ TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Fused face edges:", aFuseShape, TopAbs_EDGE ); #endif + aFuseShape = HYDROData_Tool::RebuildCmp(aFuseShape); + BRep_Builder BB; TopoDS_Face DF; if (!IE.IsEmpty()) diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index 091b31d5..417b7156 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -42,6 +42,18 @@ #include #include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + static int aMaxNameId = std::numeric_limits::max(); void HYDROData_Tool::WriteStringsToFile( QFile& theFile, @@ -309,6 +321,119 @@ bool HYDROData_Tool::IsInf( double theValue ) #endif } +static void MakeShellG(const NCollection_Map& FG, + TopoDS_Shape& outSh) +{ + BRep_Builder bb; + NCollection_Map::Iterator itFG(FG); + if (FG.Extent() > 1) + { + //face nb > 1 => make shell + TopoDS_Shell outShell; + bb.MakeShell(outShell); + for (;itFG.More();itFG.Next()) + bb.Add(outShell, itFG.Value()); + outSh = outShell; + } + else if (FG.Extent() == 1) + { + outSh = itFG.Value(); //one face + } +} + +TopoDS_Shape HYDROData_Tool::RebuildCmp(const TopoDS_Shape& in) +{ + TopTools_IndexedDataMapOfShapeListOfShape mE2LF; + TopExp::MapShapesAndAncestors(in, TopAbs_EDGE, TopAbs_FACE, mE2LF); + if (mE2LF.IsEmpty()) + return TopoDS_Shape(); + NCollection_Map dfm; + //TopExp::MapShapes(aFuseShape, TopAbs_FACE, dfm); + TopExp_Explorer expf(in, TopAbs_FACE); + for (;expf.More(); expf.Next()) + dfm.Add(TopoDS::Face(expf.Current())); + + int nbF = dfm.Extent(); + TopExp_Explorer exp_f(in, TopAbs_FACE); + const TopoDS_Face& FF = TopoDS::Face(exp_f.Current()); + NCollection_List CurrFS; + NCollection_List NeighFS; + NCollection_Map PrF; + CurrFS.Append(FF); + NCollection_List> GL_F; + NCollection_Map OneGr; + bool end = false; + while (!end) + { + NCollection_List::Iterator it_currfs(CurrFS); + NeighFS.Clear(); + for (;it_currfs.More();it_currfs.Next()) + { + const TopoDS_Face& CF = it_currfs.Value(); + TopExp_Explorer exp_edge(CF, TopAbs_EDGE); + for (;exp_edge.More();exp_edge.Next()) + { + const TopoDS_Shape& CE = exp_edge.Current(); + const TopTools_ListOfShape& lsf = mE2LF.FindFromKey(CE); + TopTools_ListIteratorOfListOfShape ls_it(lsf); //always one face (since all faces are planar) + for (;ls_it.More();ls_it.Next()) + { + const TopoDS_Face& F = TopoDS::Face(ls_it.Value()); + if (F.IsSame(CF)) + continue; + if (!PrF.Contains(F)) + { + OneGr.Add(F); + NeighFS.Append(F); + PrF.Add(F); + } + } + } + OneGr.Add(CF); + PrF.Add(CF); + } + if (NeighFS.IsEmpty()) + { + GL_F.Append(OneGr); + OneGr.Clear(); + dfm.Subtract(PrF); + if (dfm.IsEmpty()) + end = true; + else + { + NCollection_Map::Iterator itDm(dfm); + const TopoDS_Face& nsh = itDm.Key(); + NeighFS.Append(nsh); + } + } + CurrFS = NeighFS; + } + + TopoDS_Shape sh; + + if (GL_F.Extent() > 1) + { + TopoDS_Compound cmp; + NCollection_List>::Iterator itGL_F(GL_F); + BRep_Builder bb; + bb.MakeCompound(cmp); + for (;itGL_F.More();itGL_F.Next()) + { + MakeShellG(itGL_F.Value(), sh); + if (!sh.IsNull()) + bb.Add(cmp, sh); + } + return cmp; + } + else if (GL_F.Extent() == 1) + { + MakeShellG(GL_F.First(), sh); + return sh; + } + +} + + std::ostream& operator<<( std::ostream& theStream, const QString& theText ) { theStream << theText.toStdString(); diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index 69afafa6..359ddf5b 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -123,6 +123,11 @@ public: static bool IsNan( double theValue ); static bool IsInf( double theValue ); + + /** + Rebuilds shape container (like compound/compsolid/shell) which contains faces (shared or nonshared with each other) + */ + static TopoDS_Shape RebuildCmp(const TopoDS_Shape& in); }; inline bool ValuesEquals( const double& theFirst, const double& theSecond ) diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 75c0c61f..639abbb8 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -21,7 +21,8 @@ set(PROJECT_HEADERS test_HYDROGUI_LandCoverMapDlg.h test_HYDROData_CalcCase.h test_HYDROData_Stream.h - + test_HYDROData_Tool.h + test_Dependencies.h test_HYDROData_DTM.h @@ -52,7 +53,8 @@ set(PROJECT_SOURCES test_HYDROData_CalcCase.cxx test_HYDROData_Stream.cxx test_Dependencies.cxx - + test_HYDROData_Tool.cxx + TestShape.cxx TestViewer.cxx TestLib_Listener.cxx diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index dedc104a..c0d9a719 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -117,6 +117,8 @@ SET(REFERENCE_DATA stream_dtm_2d.png stream_dtm_3d.png pb_1066.cbf + f_cmp.brep + rebuild_cmp_out.png ) # Application tests diff --git a/src/HYDRO_tests/reference_data/f_cmp.brep b/src/HYDRO_tests/reference_data/f_cmp.brep new file mode 100644 index 00000000..3e7cdb55 --- /dev/null +++ b/src/HYDRO_tests/reference_data/f_cmp.brep @@ -0,0 +1,991 @@ +DBRep_DrawableShape + +CASCADE Topology V1, (c) Matra-Datavision +Locations 0 +Curve2ds 90 +1 0 0 0 1 +1 1 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 1 1 0 +1 0 0 1 0 +1 0 0 0 -1 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 0 0 -1 +1 0 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 0 -1 +1 1 0 0 1 +1 0 0 0 -1 +1 0 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 1 0 +1 0 1 1 0 +1 1 0 0 -1 +1 0 0 0 1 +1 1 0 0 -1 +1 1 0 0 1 +1 1 0 0 1 +1 0 0 1 0 +1 0 0 0 -1 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 1 0 +1 0 0 0 -1 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 0 0 -1 +1 0 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 0 -1 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 0 0 -1 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 1 0 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 1 1 0 +1 0 0 1 0 +1 0 0 0 -1 +1 1 0 0 1 +1 0 0 0 1 +1 0 0 1 0 +1 0 0 0 1 +1 1 0 0 1 +1 0 0 0 1 +1 0 1 1 0 +1 0 0 0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1 -0 1 0 0 0 1 1 0 -0 +1 7 6 1 1 0 -0 0 0 1 0 -1 0 +1 5 6 1 1 0 -0 0 0 1 0 -1 0 +1 5 7 1 -0 1 0 0 0 1 1 0 -0 +1 10 6 1 0 0 1 1 0 -0 -0 1 0 +1 10 6 1 1 0 -0 0 0 1 0 -1 0 +1 10 7 1 -0 1 0 0 0 1 1 0 -0 +1 11 6 1 1 0 -0 0 0 1 0 -1 0 +1 10 6 1 -0 1 0 0 0 1 1 0 -0 +Triangulations 0 + +TShapes 112 +Ve +1e-007 +1 1 1 +0 0 + +0101101 +* +Ve +1e-007 +1 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 1 0 0 1 +2 1 1 0 0 1 +2 2 2 0 0 1 +0 + +0101000 ++112 0 -111 0 * +Ve +1e-007 +2 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 2 0 0 1 +2 3 3 0 0 1 +2 4 1 0 0 1 +0 + +0101000 +-109 0 +111 0 * +Ve +1e-007 +2 1 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 3 0 0 1 +2 5 1 0 0 1 +2 6 4 0 0 1 +0 + +0101000 ++107 0 -109 0 * +Ed + 1e-007 1 1 0 +1 4 0 0 1 +2 7 5 0 0 1 +2 8 1 0 0 1 +0 + +0101000 +-107 0 +112 0 * +Wi + +0101100 +-110 0 -108 0 +106 0 +105 0 * +Fa +0 1e-007 1 0 + +0101000 ++104 0 * +Ve +1e-007 +3 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 5 0 0 1 +2 9 4 0 0 1 +2 10 6 0 0 1 +0 + +0101000 ++109 0 -102 0 * +Ve +1e-007 +3 1 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 6 0 0 1 +2 11 7 0 0 1 +2 12 4 0 0 1 +0 + +0101000 +-102 0 +100 0 * +Ed + 1e-007 1 1 0 +1 7 0 0 1 +2 13 8 0 0 1 +2 14 4 0 0 1 +0 + +0101000 +-100 0 +107 0 * +Wi + +0101100 +-106 0 -101 0 +99 0 +98 0 * +Fa +0 1e-007 4 0 + +0111000 ++97 0 * +Ve +1e-007 +2 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 8 0 0 1 +2 15 9 0 0 1 +2 16 6 0 0 1 +0 + +0101000 +-95 0 +109 0 * +Ve +1e-007 +3 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 9 0 0 1 +2 17 10 0 0 1 +2 18 6 0 0 1 +0 + +0101000 +-93 0 +95 0 * +Ed + 1e-007 1 1 0 +1 10 0 0 1 +2 19 11 0 0 1 +2 20 6 0 0 1 +0 + +0101000 +-93 0 +102 0 * +Wi + +0101100 +-94 0 -92 0 +91 0 +101 0 * +Fa +0 1e-007 6 0 + +0111000 ++90 0 * +Ve +1e-007 +0 2 1 +0 0 + +0101101 +* +Ve +1e-007 +0 1 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 11 0 0 1 +2 21 12 0 0 1 +2 22 2 0 0 1 +0 + +0101000 +-88 0 +87 0 * +Ed + 1e-007 1 1 0 +1 12 0 0 1 +2 23 13 0 0 1 +2 24 2 0 0 1 +0 + +0101000 +-111 0 +88 0 * +Ed + 1e-007 1 1 0 +1 13 0 0 1 +2 25 2 0 0 1 +2 26 14 0 0 1 +0 + +0101000 ++87 0 -112 0 * +Wi + +0101100 +-86 0 -85 0 +110 0 +84 0 * +Fa +0 1e-007 2 0 + +0101000 ++83 0 * +Ve +1e-007 +0 0 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 14 0 0 1 +2 27 15 0 0 1 +2 28 14 0 0 1 +0 + +0101000 +-87 0 +81 0 * +Ve +1e-007 +1 0 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 15 0 0 1 +2 29 16 0 0 1 +2 30 14 0 0 1 +0 + +0101000 +-112 0 +79 0 * +Ed + 1e-007 1 1 0 +1 16 0 0 1 +2 31 17 0 0 1 +2 32 14 0 0 1 +0 + +0101000 +-79 0 +81 0 * +Wi + +0101100 +-80 0 -84 0 +78 0 +77 0 * +Fa +0 1e-007 14 0 + +0101000 ++76 0 * +Sh + +0101000 +-103 0 -96 0 -89 0 -82 0 -75 0 * +Ve +1e-007 +5 2 1 +0 0 + +0101101 +* +Ve +1e-007 +5 1 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 17 0 0 1 +2 33 19 0 0 1 +2 34 18 0 0 1 +0 + +0101000 +-73 0 +72 0 * +Ve +1e-007 +6 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 18 0 0 1 +2 35 18 0 0 1 +2 36 20 0 0 1 +0 + +0101000 ++73 0 -70 0 * +Ve +1e-007 +6 1 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 19 0 0 1 +2 37 21 0 0 1 +2 38 18 0 0 1 +0 + +0101000 +-70 0 +68 0 * +Ed + 1e-007 1 1 0 +1 20 0 0 1 +2 39 22 0 0 1 +2 40 18 0 0 1 +0 + +0101000 +-68 0 +72 0 * +Wi + +0101100 +-71 0 -69 0 +67 0 +66 0 * +Fa +0 1e-007 18 0 + +0111000 ++65 0 * +Ve +1e-007 +5 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 21 0 0 1 +2 41 23 0 0 1 +2 42 20 0 0 1 +0 + +0101000 +-63 0 +73 0 * +Ve +1e-007 +6 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 22 0 0 1 +2 43 24 0 0 1 +2 44 20 0 0 1 +0 + +0101000 +-61 0 +63 0 * +Ed + 1e-007 1 1 0 +1 23 0 0 1 +2 45 20 0 0 1 +2 46 25 0 0 1 +0 + +0101000 ++70 0 -61 0 * +Wi + +0101100 +-62 0 -60 0 +59 0 +69 0 * +Fa +0 1e-007 20 0 + +0111000 ++58 0 * +Ve +1e-007 +7 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 24 0 0 1 +2 47 26 0 0 1 +2 48 25 0 0 1 +0 + +0101000 +-56 0 +61 0 * +Ve +1e-007 +7 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 25 0 0 1 +2 49 25 0 0 1 +2 50 27 0 0 1 +0 + +0101000 ++54 0 -56 0 * +Ed + 1e-007 1 1 0 +1 26 0 0 1 +2 51 28 0 0 1 +2 52 25 0 0 1 +0 + +0101000 +-54 0 +70 0 * +Wi + +0101100 +-59 0 -55 0 +53 0 +52 0 * +Fa +0 1e-007 25 0 + +0111000 ++51 0 * +Ve +1e-007 +8 3 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 27 0 0 1 +2 53 29 0 0 1 +2 54 27 0 0 1 +0 + +0101000 +-49 0 +56 0 * +Ve +1e-007 +8 2 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 28 0 0 1 +2 55 30 0 0 1 +2 56 27 0 0 1 +0 + +0101000 +-49 0 +47 0 * +Ed + 1e-007 1 1 0 +1 29 0 0 1 +2 57 31 0 0 1 +2 58 27 0 0 1 +0 + +0101000 +-47 0 +54 0 * +Wi + +0101100 +-53 0 -48 0 +46 0 +45 0 * +Fa +0 1e-007 27 0 + +0111000 ++44 0 * +Sh + +0101000 +-64 0 -57 0 -50 0 -43 0 * +Ve +1e-007 +5 6 1 +0 0 + +0101101 +* +Ve +1e-007 +5 5 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 30 0 0 1 +2 59 33 0 0 1 +2 60 32 0 0 1 +0 + +0101000 +-41 0 +40 0 * +Ve +1e-007 +6 6 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 31 0 0 1 +2 61 32 0 0 1 +2 62 34 0 0 1 +0 + +0101000 ++41 0 -38 0 * +Ve +1e-007 +6 5 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 32 0 0 1 +2 63 32 0 0 1 +2 64 35 0 0 1 +0 + +0101000 ++36 0 -38 0 * +Ed + 1e-007 1 1 0 +1 33 0 0 1 +2 65 36 0 0 1 +2 66 32 0 0 1 +0 + +0101000 +-36 0 +40 0 * +Wi + +0101100 +-39 0 -37 0 +35 0 +34 0 * +Fa +0 1e-007 32 0 + +0111000 ++33 0 * +Ve +1e-007 +7 6 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 34 0 0 1 +2 67 35 0 0 1 +2 68 37 0 0 1 +0 + +0101000 ++38 0 -31 0 * +Ve +1e-007 +7 5 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 35 0 0 1 +2 69 38 0 0 1 +2 70 35 0 0 1 +0 + +0101000 +-31 0 +29 0 * +Ed + 1e-007 1 1 0 +1 36 0 0 1 +2 71 39 0 0 1 +2 72 35 0 0 1 +0 + +0101000 +-29 0 +36 0 * +Wi + +0101100 +-35 0 -30 0 +28 0 +27 0 * +Fa +0 1e-007 35 0 + +0111000 ++26 0 * +Ve +1e-007 +6 7 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 37 0 0 1 +2 73 37 0 0 1 +2 74 34 0 0 1 +0 + +0101000 ++38 0 -24 0 * +Ve +1e-007 +7 7 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 38 0 0 1 +2 75 40 0 0 1 +2 76 37 0 0 1 +0 + +0101000 +-22 0 +24 0 * +Ed + 1e-007 1 1 0 +1 39 0 0 1 +2 77 41 0 0 1 +2 78 37 0 0 1 +0 + +0101000 +-22 0 +31 0 * +Wi + +0101100 +-23 0 -21 0 +20 0 +30 0 * +Fa +0 1e-007 37 0 + +0111000 ++19 0 * +Ve +1e-007 +5 7 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 40 0 0 1 +2 79 42 0 0 1 +2 80 34 0 0 1 +0 + +0101000 +-17 0 +41 0 * +Ed + 1e-007 1 1 0 +1 41 0 0 1 +2 81 43 0 0 1 +2 82 34 0 0 1 +0 + +0101000 +-24 0 +17 0 * +Wi + +0101100 +-16 0 -15 0 +23 0 +37 0 * +Fa +0 1e-007 34 0 + +0111000 ++14 0 * +Sh + +0101000 +-32 0 -25 0 -18 0 -13 0 * +Ve +1e-007 +10 7 1 +0 0 + +0101101 +* +Ve +1e-007 +10 6 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 42 0 0 1 +2 83 45 0 0 1 +2 84 44 0 0 1 +0 + +0101000 +-11 0 +10 0 * +Ve +1e-007 +11 7 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 43 0 0 1 +2 85 46 0 0 1 +2 86 44 0 0 1 +0 + +0101000 +-8 0 +11 0 * +Ve +1e-007 +11 6 1 +0 0 + +0101101 +* +Ed + 1e-007 1 1 0 +1 44 0 0 1 +2 87 47 0 0 1 +2 88 44 0 0 1 +0 + +0101000 +-8 0 +6 0 * +Ed + 1e-007 1 1 0 +1 45 0 0 1 +2 89 48 0 0 1 +2 90 44 0 0 1 +0 + +0101000 +-6 0 +10 0 * +Wi + +0101100 +-9 0 -7 0 +5 0 +4 0 * +Fa +0 1e-007 44 0 + +0111000 ++3 0 * +Co + +1100000 ++74 0 +42 0 +12 0 -2 0 * + ++1 0 +0 + diff --git a/src/HYDRO_tests/reference_data/rebuild_cmp_out.png b/src/HYDRO_tests/reference_data/rebuild_cmp_out.png new file mode 100644 index 00000000..a2af7ec1 Binary files /dev/null and b/src/HYDRO_tests/reference_data/rebuild_cmp_out.png differ diff --git a/src/HYDRO_tests/test_HYDROData_Tool.cxx b/src/HYDRO_tests/test_HYDROData_Tool.cxx new file mode 100644 index 00000000..470e7c22 --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_Tool.cxx @@ -0,0 +1,87 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +void test_HYDROData_Tool::test_rebuild_cmp() +{ + QString RefPath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test"; + BRep_Builder bb; + { + TopoDS_Shape in, out; + + BRepTools::Read(in, (RefPath + "/f_cmp.brep").toStdString().c_str(), bb); + out = HYDROData_Tool::RebuildCmp(in); + + { + TopTools_IndexedMapOfShape dummy; + TopExp::MapShapes(out, TopAbs_COMPOUND, dummy); + CPPUNIT_ASSERT_EQUAL(1, dummy.Extent()); + + dummy.Clear(); + TopExp::MapShapes(out, TopAbs_SHELL, dummy); + CPPUNIT_ASSERT_EQUAL(3, dummy.Extent()); + + dummy.Clear(); + TopExp::MapShapes(out, TopAbs_FACE, dummy); + CPPUNIT_ASSERT_EQUAL(14, dummy.Extent()); + + std::multiset nbF, ndFref; + ndFref.insert(1); //one face + ndFref.insert(4); // one shell (contains 4 faces) + ndFref.insert(4); // one shell (contains 4 faces) + ndFref.insert(5); // one shell (contains 5 faces) + TopoDS_Iterator itS(out); + for (;itS.More();itS.Next()) + { + const TopoDS_Shape& CSH = itS.Value(); + dummy.Clear(); + TopExp::MapShapes(CSH, TopAbs_FACE, dummy); + nbF.insert(dummy.Extent()); + } + + CPPUNIT_ASSERT(ndFref == nbF); + + } + + TestViewer::show( out, AIS_Shaded, true, "rebuild_cmp_out" ); + CPPUNIT_ASSERT_IMAGES + } + +} + + + diff --git a/src/HYDRO_tests/test_HYDROData_Tool.h b/src/HYDRO_tests/test_HYDROData_Tool.h new file mode 100644 index 00000000..7c2962cf --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_Tool.h @@ -0,0 +1,42 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifdef WIN32 + #pragma warning( disable: 4251 ) +#endif + +#include + +class test_HYDROData_Tool : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( test_HYDROData_Tool ); + CPPUNIT_TEST( test_rebuild_cmp ); + + CPPUNIT_TEST_SUITE_END(); + +public: + void test_rebuild_cmp(); + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_Tool ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_Tool, "HYDROData_Tool" ); + +#ifdef WIN32 + #pragma warning( default: 4251 ) +#endif