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_Dependencies.h>
20 #include <HYDROData_Bathymetry.h>
21 #include <HYDROData_CalculationCase.h>
22 #include <HYDROData_Channel.h>
23 #include <HYDROData_Document.h>
24 #include <HYDROData_ImmersibleZone.h>
25 #include <HYDROData_Polyline3D.h>
26 #include <HYDROData_PolylineXY.h>
28 #include <BRepBuilderAPI_MakeEdge.hxx>
29 #include <BRepBuilderAPI_MakeWire.hxx>
31 void test_Dependencies::test_dependencies_broad_cast()
33 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
35 Handle(HYDROData_Bathymetry) aBath =
36 Handle(HYDROData_Bathymetry)::DownCast( aDoc->CreateObject( KIND_BATHYMETRY ) );
38 Handle(HYDROData_PolylineXY) aPoly =
39 Handle(HYDROData_PolylineXY)::DownCast( aDoc->CreateObject( KIND_POLYLINEXY ) );
41 Handle(HYDROData_Polyline3D) aPoly3d =
42 Handle(HYDROData_Polyline3D)::DownCast( aDoc->CreateObject( KIND_POLYLINE ) );
44 Handle(HYDROData_ImmersibleZone) aZone =
45 Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
47 Handle(HYDROData_Channel) aChannel =
48 Handle(HYDROData_Channel)::DownCast( aDoc->CreateObject( KIND_CHANNEL ) );
50 Handle(HYDROData_CalculationCase) aCase =
51 Handle(HYDROData_CalculationCase)::DownCast( aDoc->CreateObject( KIND_CALCULATION ) );
53 aZone->SetPolyline( aPoly );
54 aZone->SetAltitudeObject( aBath );
57 aPoly3d->SetPolylineXY( aPoly );
58 aPoly3d->SetAltitudeObject( aBath );
61 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( gp_Pnt(), gp_Pnt( 1, 0, 0 ) ).Edge();
62 TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
63 aPoly3d->SetTopShape( aWire );
64 aPoly3d->SetShape3D( aWire );
65 CPPUNIT_ASSERT_EQUAL( true, aChannel->SetGuideLine( aPoly3d ) );
68 aCase->AddGeometryObject( aZone );
69 aCase->AddGeometryObject( aChannel );
70 aCase->ClearChanged();
72 // 1. Change only Z values of the bathymetry
73 aBath->SetAltitudesInverted( true );
75 CPPUNIT_ASSERT_EQUAL( false, aZone->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
76 CPPUNIT_ASSERT_EQUAL( false, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
77 CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) );
78 CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) );
79 CPPUNIT_ASSERT_EQUAL( false, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
80 CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) );
81 CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) );
82 CPPUNIT_ASSERT_EQUAL( false, aCase->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
84 aPoly3d->ClearChanged();
85 aChannel->ClearChanged();
87 // 2. "Change" the polyline 2d
88 aPoly->Changed( HYDROData_Entity::Geom_2d );
90 CPPUNIT_ASSERT_EQUAL( true, aZone->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
91 CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
92 CPPUNIT_ASSERT_EQUAL( false, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) );
93 CPPUNIT_ASSERT_EQUAL( true, aPoly3d->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) );
94 CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
95 CPPUNIT_ASSERT_EQUAL( false, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_Z ) );
96 CPPUNIT_ASSERT_EQUAL( true, aChannel->IsMustBeUpdated( HYDROData_Entity::Geom_3d ) );
97 CPPUNIT_ASSERT_EQUAL( true, aCase->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) );
102 void test_Dependencies::test_calc_case_ref_objects()
104 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
106 Handle(HYDROData_ImmersibleZone) aZone =
107 Handle(HYDROData_ImmersibleZone)::DownCast( aDoc->CreateObject( KIND_IMMERSIBLE_ZONE ) );
109 Handle(HYDROData_CalculationCase) aCase =
110 Handle(HYDROData_CalculationCase)::DownCast( aDoc->CreateObject( KIND_CALCULATION ) );
112 aCase->AddGeometryObject( aZone );
113 CPPUNIT_ASSERT_EQUAL( 1, aCase->GetAllReferenceObjects().Size() );
114 CPPUNIT_ASSERT_EQUAL( aZone->Label(), aCase->GetAllReferenceObjects().First()->Label() );