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