Salome HOME
af0c74278e8e383dce12396c7daa4523e97474d3
[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
37 QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test";
38
39
40 void test_HYDROData_CalcCase::test_add_int_wires()
41 {
42   {
43     TopoDS_Shape out;
44     TopTools_ListOfShape Wires;
45
46     BRep_Builder B;
47     TopoDS_Shape InF;
48     TopoDS_Shape InP;
49     BRepTools::Read(InP, (REF_DATA_PATH + "/p1.brep").toStdString().c_str(), B);
50     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
51     Wires.Append(InP);
52
53     TopTools_ListOfShape OutSh;
54     TopTools_IndexedDataMapOfShapeShape ls;
55     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
56
57     CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
58     TopoDS_Compound cmp;
59     B.MakeCompound(cmp);
60     B.Add(cmp, OutSh.First());
61     B.Add(cmp, OutSh.Last());
62     TestViewer::show( cmp, AIS_Shaded, true, "cc_int_w_1" );
63     //CPPUNIT_ASSERT_IMAGES
64   }
65
66   {
67     TopoDS_Shape out;
68     TopTools_ListOfShape Wires;
69
70     BRep_Builder B;
71     TopoDS_Shape InF;
72     TopoDS_Shape InP;
73     BRepTools::Read(InP, (REF_DATA_PATH + "/p2.brep").toStdString().c_str(), B);
74     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
75     Wires.Append(InP);
76
77     TopTools_ListOfShape OutSh;
78     TopTools_IndexedDataMapOfShapeShape ls;
79     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
80     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
81     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
82     //CPPUNIT_ASSERT_IMAGES
83   }
84
85   {
86     TopoDS_Shape out;
87     TopTools_ListOfShape Wires;
88
89     BRep_Builder B;
90     TopoDS_Shape InF;
91     TopoDS_Shape InP;
92     BRepTools::Read(InP, (REF_DATA_PATH + "/p3.brep").toStdString().c_str(), B);
93     BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B);
94     Wires.Append(InP);
95
96     TopTools_ListOfShape OutSh;
97     TopTools_IndexedDataMapOfShapeShape ls;
98     HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL);
99     CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
100     TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" );
101     CPPUNIT_ASSERT_IMAGES
102   }
103
104 }
105
106
107