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.
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.
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
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
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>
25 #include <TestViewer.h>
26 #include <TestShape.h>
27 #include <TopTools_ListOfShape.hxx>
28 #include <AIS_DisplayMode.hxx>
31 #include <BRep_Builder.hxx>
32 #include <BRepTools.hxx>
34 #include <TopTools_IndexedMapOfShape.hxx>
35 #include <TopoDS_Iterator.hxx>
37 extern QString REF_DATA_PATH;
39 void test_HYDROData_Tool::test_rebuild_cmp()
41 QString RefPath = REF_DATA_PATH;
46 BRepTools::Read(in, (RefPath + "/f_cmp.brep").toStdString().c_str(), bb);
47 out = HYDROData_Tool::RebuildCmp(in);
50 TopTools_IndexedMapOfShape dummy;
51 TopExp::MapShapes(out, TopAbs_COMPOUND, dummy);
52 CPPUNIT_ASSERT_EQUAL(1, dummy.Extent());
55 TopExp::MapShapes(out, TopAbs_SHELL, dummy);
56 CPPUNIT_ASSERT_EQUAL(3, dummy.Extent());
59 TopExp::MapShapes(out, TopAbs_FACE, dummy);
60 CPPUNIT_ASSERT_EQUAL(14, dummy.Extent());
62 std::multiset<int> nbF, ndFref;
63 ndFref.insert(1); //one face
64 ndFref.insert(4); // one shell (contains 4 faces)
65 ndFref.insert(4); // one shell (contains 4 faces)
66 ndFref.insert(5); // one shell (contains 5 faces)
67 TopoDS_Iterator itS(out);
68 for (;itS.More();itS.Next())
70 const TopoDS_Shape& CSH = itS.Value();
72 TopExp::MapShapes(CSH, TopAbs_FACE, dummy);
73 nbF.insert(dummy.Extent());
76 CPPUNIT_ASSERT(ndFref == nbF);
80 TestViewer::show( out, AIS_Shaded, true, "rebuild_cmp_out" );