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 <HYDROData_LISM.h>
20 #include <HYDROData_Profile.h>
21 #include <HYDROData_StreamLinearInterpolation.h>
22 #include <TopoDS_Face.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT( HYDROData_LISM, HYDROData_Bathymetry )
29 HYDROData_LISM::HYDROData_LISM()
33 HYDROData_LISM::~HYDROData_LISM()
38 HYDROData_SequenceOfObjects HYDROData_LISM::GetProfiles() const
40 return GetReferenceObjects( DataTag_Profiles );
43 void HYDROData_LISM::SetProfiles( const HYDROData_SequenceOfObjects& theProfiles )
45 SetReferenceObjects( theProfiles, DataTag_Profiles );
50 bool HYDROData_LISM::SetLeftBank( const Handle(HYDROData_PolylineXY)& theBank )
55 if ( !HYDROData_Stream::IsValidAsAxis( theBank ) )
58 Handle(HYDROData_PolylineXY) aPrevBank = GetLeftBank();
59 if ( IsEqual( aPrevBank, theBank ) )
62 SetReferenceObject( theBank, DataTag_LeftBank );
67 Handle(HYDROData_PolylineXY) HYDROData_LISM::GetLeftBank() const
69 return Handle(HYDROData_PolylineXY)::DownCast(GetReferenceObject( DataTag_LeftBank ) );
72 bool HYDROData_LISM::SetRightBank( const Handle(HYDROData_PolylineXY)& theBank )
77 if ( !HYDROData_Stream::IsValidAsAxis( theBank ) )
80 Handle(HYDROData_PolylineXY) aPrevBank = GetRightBank();
81 if ( IsEqual( aPrevBank, theBank ) )
84 SetReferenceObject( theBank, DataTag_RightBank );
89 bool HYDROData_LISM::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
91 if ( !HYDROData_Stream::IsValidAsAxis( theAxis ) )
94 Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
95 if ( IsEqual( aPrevAxis, theAxis ) )
98 SetReferenceObject( theAxis, DataTag_HydraulicAxis );
104 Handle(HYDROData_PolylineXY) HYDROData_LISM::GetHydraulicAxis() const
106 return Handle(HYDROData_PolylineXY)::DownCast( GetReferenceObject( DataTag_HydraulicAxis ) );
110 Handle(HYDROData_PolylineXY) HYDROData_LISM::GetRightBank() const
112 return Handle(HYDROData_PolylineXY)::DownCast(GetReferenceObject( DataTag_RightBank ) );
115 int HYDROData_LISM::GetNbProfilePoints() const
117 return GetInteger( DataTag_NbProfilePoints );
120 void HYDROData_LISM::SetNbProfilePoints( int theNbProints )
122 SetInteger( DataTag_NbProfilePoints, theNbProints );
126 double HYDROData_LISM::GetHaxStep() const
128 return GetDouble( DataTag_HaxStep );
131 void HYDROData_LISM::SetHaxStep( double theHaxStep )
133 SetDouble( DataTag_HaxStep, theHaxStep );
137 void HYDROData_LISM::Update()
139 AltitudePoints anOutPoints;
140 HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
141 int nbprofilepoints = GetNbProfilePoints();
142 double step = GetHaxStep();
143 Handle(HYDROData_PolylineXY) aHAX = GetHydraulicAxis();
144 Handle(HYDROData_PolylineXY) aLB = GetLeftBank();
145 Handle(HYDROData_PolylineXY) aRB = GetRightBank();
147 std::vector<std::string> warnings;
148 HYDROData_Stream::PrsDefinition prsDef;
149 HYDROData_StreamLinearInterpolation::Perform(aRefProfiles, nbprofilepoints, step, aHAX, aLB, aRB, anOutPoints, true, false, prsDef, &warnings);
151 SetAltitudePoints( anOutPoints );
153 SetShape( DataTag_LeftBankShape, prsDef.myLeftBank);
154 SetShape( DataTag_RightBankShape, prsDef.myRightBank);
155 SetShape( DataTag_InletShape, prsDef.myInlet);
156 SetShape( DataTag_OutletShape, prsDef.myOutlet );
157 SetShape( DataTag_3DShape, prsDef.myPrs3D );
158 SetShape( DataTag_2DShape, prsDef.myPrs2D );
160 HYDROData_Bathymetry::Update();
164 void HYDROData_LISM::GetShapePresentations( HYDROData_Stream::PrsDefinition& prsDef)
166 prsDef.myLeftBank = GetShape( DataTag_LeftBankShape);
167 prsDef.myRightBank = GetShape( DataTag_RightBankShape);
168 prsDef.myInlet = GetShape( DataTag_InletShape);
169 prsDef.myOutlet = GetShape( DataTag_OutletShape );
170 prsDef.myPrs3D = GetShape( DataTag_3DShape );
171 prsDef.myPrs2D = GetShape( DataTag_2DShape );
175 /*void HYDROData_LISM::GetWarnings(NCollection_DataMap<Handle(HYDROData_Profile), QSet<QString>>& warnings)
177 warnings = myWarnings;