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 #ifndef HYDROData_CalculationCase_HeaderFile
20 #define HYDROData_CalculationCase_HeaderFile
22 #include <HYDROData_ShapesGroup.h>
23 #include <HYDROData_SplitToZonesTool.h>
24 #include <HYDROData_PriorityQueue.h>
25 #include <HYDROData_Zone.h>
26 #include <HYDROData_Warning.h>
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(GEOM_Gen)
38 class TopTools_ListOfShape;
40 class Handle(HYDROData_Object);
41 class Handle(HYDROData_Region);
42 class Handle(HYDROData_Zone);
43 class Handle(HYDROData_PolylineXY);
44 class Handle(HYDROData_ShapesGroup);
45 class Handle(HYDROData_SplittedShapesGroup);
46 class Handle(HYDROData_Document);
47 class Handle(HYDROData_StricklerTable);
49 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
52 /**\class HYDROData_CalculationCase
53 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
56 class HYDROData_CalculationCase : public HYDROData_Entity
60 enum PointClassification
62 POINT_OUT, ///< point is out of zone face
63 POINT_IN, ///< point is inside of zone face
64 POINT_ON ///< point is on the edge of zone face
76 * Enumeration of tags corresponding to the persistent object parameters.
80 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
81 DataTag_GeometryObject, ///< reference geometry objects
82 DataTag_ChildRegion, ///< child regions
83 DataTag_Region, ///< reference regions
84 DataTag_Polyline, ///< reference boundary polyline
85 DataTag_GeometryGroup, ///< reference geometry groups
86 DataTag_SplittedGroups, ///< reference splitted groups
87 DataTag_CustomRules, ///< custom rules
88 DataTag_AssignmentMode, ///< assignment mode
89 DataTag_StricklerTable, ///< reference Strickler table
91 DataTag_LandCover_Obsolete, ///< reference land covers
92 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
93 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
94 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
95 DataTag_LandCoverRegion_Obsolete ///< reference land cover regions
101 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
104 * Returns the kind of this object. Must be redefined in all objects of known type.
106 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
109 * Updates the name of this object.
110 * Reimplemented to update the names of regions, zones and splitted groups.
112 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
115 * Dump Calculation object to Python script representation.
117 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
120 * Update the calcualtion case object.
121 * Call this method whenever you made changes for object data.
123 HYDRODATA_EXPORT virtual void Update();
126 * Returns the list of all reference objects of this object.
128 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
131 // Public methods to work with Calculation
134 * Add new one reference geometry object for calculation case.
136 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
139 * Returns all reference geometry objects of calculation case.
141 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
144 * Removes reference geometry object from calculation case.
145 * \param theObject the object to remove
147 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
150 * Removes all reference geometry objects from calculation case.
152 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
156 * Add new one reference geometry group for calculation case.
157 * \param theGroup the group to add
159 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
162 * Returns all reference geometry groups of calculation case.
164 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
167 * Removes reference geometry group from calculation case.
168 * \param theGroup the group to remove
170 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
173 * Removes all reference geometry groups from calculation case.
175 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
179 * Sets reference boundary polyline object for calculation case.
181 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
184 * Returns reference boundary polyline object of calculation case.
186 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
189 * Remove reference boundary polyline object from calculation case.
191 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
195 * Sets reference Strickler table for calculation case.
197 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
200 * Returns reference Strickler table of calculation case.
202 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
205 * Remove reference Strickler table from calculation case.
207 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
210 * Add new one child region for calculation case.
211 * The new region is added into the list of reference regions.
212 * The label of theZone is changed during this operation
213 * because of new region becomes the new parent for this zone.
214 * \return the created region
216 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
220 * Add new one reference region for calculation case.
221 * The label of theRegion is changed in case if old parent is not this calculation.
222 * \return true in case of success
224 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
227 * Returns all reference regions of calculation case.
228 * \return the list of reference regions
230 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
233 * Updates names of regions to correct order.
235 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
238 * Removes reference region from calculation case.
239 * \param theRegion the region to remove
241 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
244 * Removes all reference regions from calculation case.
246 HYDRODATA_EXPORT virtual void RemoveRegions();
249 * Returns all reference geometry groups of calculation case.
251 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
254 * Removes all reference geometry groups from calculation case.
256 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
259 * Exports the calculation case data (shell and groups) to GEOM module.
260 * \param theStudyId the id of the study where the GEOM module should be used for export
261 * \return the entry of the GEOM object (empty string in the case of error)
263 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
266 * Exports the calculation case data (shell and groups) to GEOM module.
267 * \param theGeomEngine GEOM module engine
268 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
269 * \param theGeomObjEntry the published GEOM object entry
270 * \param theErrorMsg the error message
271 * \return true in case of success
274 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
275 SALOMEDS::Study_ptr theStudy,
276 QString& theGeomObjEntry,
277 QString& theErrorMsg ) const;
281 // Public methods to work with Calculation services
284 * Returns altitude for given point.
285 * \param thePoint the point to examine
286 * \return result altitude value
288 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
291 * Returns altitude for given point on given region.
292 * \param thePoint the point to examine
293 * \param theRegion reference region to check
294 * \return result altitude value
296 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
297 const Handle(HYDROData_Region)& theRegion ) const;
300 * Returns altitude for given point on given zone.
301 * \param thePoint the point to examine
302 * \param theZone reference zone to check
303 * \return result altitude value
305 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
306 const Handle(HYDROData_Zone)& theZone ) const;
309 * Returns strickler coefficient for given point.
310 * \param thePoint the point to examine
311 * \return result strickler coefficient
313 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
316 * Returns altitudes for given points on given region.
317 * \param thePoints the points to examine
318 * \param theRegion reference region to check
319 * \return result altitude value
321 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
322 const NCollection_Sequence<gp_XY>& thePoints,
323 const Handle(HYDROData_Region)& theRegion ) const;
326 * Returns altitudes for given points on given zone.
327 * \param thePoints the points to examine
328 * \param theZone reference zone to check
329 * \return result altitude value
331 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
332 const NCollection_Sequence<gp_XY>& thePoints,
333 const Handle(HYDROData_Zone)& theZone ) const;
336 * Returns region to which the point is belongs.
337 * \param thePoint the point to examine
338 * if it is needed to search Land Cover region
339 * \return result region
341 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
344 * Returns zone to which the point is belongs.
345 * \param thePoint the point to examine
346 * if it is needed to search Land Cover zone
347 * \return result zone
349 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
352 * Returns classification of point for given zone.
353 * \param thePoint the point to examine
354 * \param theZone the zone to examine
355 * \return result classification
357 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
358 const gp_XY& thePoint,
359 const Handle(HYDROData_Zone)& theZone ) const;
361 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
362 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
364 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
365 const bool theIsSetToUpdate = true );
366 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
367 HYDROData_PriorityType thePriority,
368 const Handle(HYDROData_Entity)& theObject2,
369 HYDROData_Zone::MergeType theMergeType,
370 HYDROData_CalculationCase::DataTag theDataTag );
371 HYDRODATA_EXPORT bool GetRule( int theIndex,
372 Handle(HYDROData_Entity)& theObject1,
373 HYDROData_PriorityType& thePriority,
374 Handle(HYDROData_Entity)& theObject2,
375 HYDROData_Zone::MergeType& theMergeType,
376 HYDROData_CalculationCase::DataTag& theDataTag ) const;
378 HYDRODATA_EXPORT QString DumpRules() const;
380 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
385 * Add new one region for calculation case.
386 * The new region is added into the list of reference regions.
388 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
389 const QString& thePrefixOrName,
390 bool isPrefix = true );
393 * Add new one splitted edges group for calculation case.
395 Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
398 * Exports the given faces as shell and the given groups to GEOM module.
399 * \param theGeomEngine GEOM module engine
400 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
401 * \param theFaces the list of faces to make shell
402 * \param theSplittedGroups the list of groups
403 * \return true in case of success
406 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
407 SALOMEDS::Study_ptr theStudy,
408 const TopTools_ListOfShape& theFaces,
409 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
410 QString& theGeomObjEntry ) const;
413 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
414 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
415 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
416 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
418 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
419 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
421 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
423 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
425 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
426 const QString& theOldCaseName,
427 const QString& theName );
429 void DumpRegionsToPython( QStringList& theResList,
430 MapOfTreatedObjects& theTreatedObjects,
431 const HYDROData_SequenceOfObjects& theRegions ) const;
434 friend class HYDROData_Iterator;
437 * Creates new object in the internal data structure. Use higher level objects
438 * to create objects with real content.
440 HYDRODATA_EXPORT HYDROData_CalculationCase();
443 * Destructs properties of the object and object itself, removes it from the document.
445 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
447 void DumpSampleMeshing( QStringList& theScript,
448 const QString& theStudyName,
449 const QString& theGeomShapeName,
450 const QString& theMeshName ) const;
453 HYDROData_Warning myLastWarning;