Salome HOME
debug of tests
[modules/hydro.git] / src / HYDRO_tests / test_HYDROData_CalcCase.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_CalcCase.h>
20 #include <HYDROData_CalculationCase.h>
21 #include <HYDROData_Document.h>
22 #include <HYDROData_Tool.h>
23 #include <TopoDS_Edge.hxx>
24 #include <TopoDS_Wire.hxx>
25 #include <TopoDS_Face.hxx>
26 #include <TopoDS.hxx>
27 #include <TestViewer.h>
28 #include <TestShape.h>
29 #include <TopTools_ListOfShape.hxx>
30 #include <AIS_DisplayMode.hxx>
31 #include <QString>
32 #include <QColor>
33 #include <BRep_Builder.hxx>
34 #include <BRepTools.hxx>
35
36 extern QString REF_DATA_PATH;
37
38 void test_HYDROData_CalcCase::test_add_int_wires()
39 {
40   {
41     TopoDS_Shape out;
42     TopTools_ListOfShape Wires;
43
44     BRep_Builder B;
45     TopoDS_Shape InF;
46     TopoDS_Shape InP;
47     BRepTools::Read(InP, (REF_DATA_PATH + "/p1.brep").toStdString().c_str(), B);
48     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
49     Wires.Append(InP);
50
51     TopTools_ListOfShape OutSh;
52     TopTools_IndexedDataMapOfShapeShape ls;
53     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
54
55     CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
56     TopoDS_Compound cmp;
57     B.MakeCompound(cmp);
58     B.Add(cmp, OutSh.First());
59     B.Add(cmp, OutSh.Last());
60     TestViewer::show( cmp, AIS_Shaded, true, "cc_int_w_1" );
61     //CPPUNIT_ASSERT_IMAGES
62   }
63
64   {
65     TopoDS_Shape out;
66     TopTools_ListOfShape Wires;
67
68     BRep_Builder B;
69     TopoDS_Shape InF;
70     TopoDS_Shape InP;
71     BRepTools::Read(InP, (REF_DATA_PATH + "/p2.brep").toStdString().c_str(), B);
72     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
73     Wires.Append(InP);
74
75     TopTools_ListOfShape OutSh;
76     TopTools_IndexedDataMapOfShapeShape ls;
77     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
78     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
79     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
80     //CPPUNIT_ASSERT_IMAGES
81   }
82
83   {
84     TopoDS_Shape out;
85     TopTools_ListOfShape Wires;
86
87     BRep_Builder B;
88     TopoDS_Shape InF;
89     TopoDS_Shape InP;
90     BRepTools::Read(InP, (REF_DATA_PATH + "/p3.brep").toStdString().c_str(), B);
91     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
92     Wires.Append(InP);
93
94     TopTools_ListOfShape OutSh;
95     TopTools_IndexedDataMapOfShapeShape ls;
96     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
97     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
98     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3", 1, 1 );
99     CPPUNIT_ASSERT_IMAGES
100   }
101
102 }
103
104
105