Salome HOME
refs #1327: debug of automatic tests
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_Tool.cxx
1 // Copyright (C) 2014-2015  EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
6 //
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
10 // Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include <test_HYDROData_Tool.h>
20 #include <HYDROData_Tool.h>
21 #include <TopoDS_Edge.hxx>
22 #include <TopoDS_Wire.hxx>
23 #include <TopoDS_Face.hxx>
24 #include <TopoDS.hxx>
25 #include <TestViewer.h>
26 #include <TestShape.h>
27 #include <TopTools_ListOfShape.hxx>
28 #include <AIS_DisplayMode.hxx>
29 #include <QString>
30 #include <QColor>
31 #include <BRep_Builder.hxx>
32 #include <BRepTools.hxx>
33 #include <TopExp.hxx>
34 #include <TopTools_IndexedMapOfShape.hxx>
35 #include <TopoDS_Iterator.hxx>
36
37
38 void test_HYDROData_Tool::test_rebuild_cmp()
39 {
40   QString RefPath = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test";
41   BRep_Builder bb;
42   {
43     TopoDS_Shape in, out;
44
45     BRepTools::Read(in, (RefPath + "/f_cmp.brep").toStdString().c_str(), bb);
46     out = HYDROData_Tool::RebuildCmp(in);
47
48     {
49       TopTools_IndexedMapOfShape dummy;
50       TopExp::MapShapes(out, TopAbs_COMPOUND, dummy);
51       CPPUNIT_ASSERT_EQUAL(1, dummy.Extent());
52
53       dummy.Clear();
54       TopExp::MapShapes(out, TopAbs_SHELL, dummy);
55       CPPUNIT_ASSERT_EQUAL(3, dummy.Extent());
56
57       dummy.Clear();
58       TopExp::MapShapes(out, TopAbs_FACE, dummy);
59       CPPUNIT_ASSERT_EQUAL(14, dummy.Extent());
60
61       std::multiset<int> nbF, ndFref;
62       ndFref.insert(1); //one face
63       ndFref.insert(4); // one shell (contains 4 faces)
64       ndFref.insert(4); // one shell (contains 4 faces)
65       ndFref.insert(5); // one shell (contains 5 faces)
66       TopoDS_Iterator itS(out);
67       for (;itS.More();itS.Next())
68       {
69         const TopoDS_Shape& CSH = itS.Value();
70         dummy.Clear();
71         TopExp::MapShapes(CSH, TopAbs_FACE, dummy);
72         nbF.insert(dummy.Extent());
73       }
74
75       CPPUNIT_ASSERT(ndFref == nbF); 
76
77     }
78
79     TestViewer::show( out, AIS_Shaded, true, "rebuild_cmp_out" );
80     CPPUNIT_ASSERT_IMAGES
81   }
82
83 }
84
85
86