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>
29 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(GEOM_Gen)
36 class TopTools_ListOfShape;
38 class Handle(HYDROData_Object);
39 class Handle(HYDROData_Region);
40 class Handle(HYDROData_Zone);
41 class Handle(HYDROData_PolylineXY);
42 class Handle(HYDROData_ShapesGroup);
43 class Handle(HYDROData_SplittedShapesGroup);
44 class Handle(HYDROData_Document);
45 class Handle(HYDROData_StricklerTable);
46 class Handle(HYDROData_LandCover);
48 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
51 /**\class HYDROData_CalculationCase
52 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
55 class HYDROData_CalculationCase : public HYDROData_Entity
59 enum PointClassification
61 POINT_OUT, ///< point is out of zone face
62 POINT_IN, ///< point is inside of zone face
63 POINT_ON ///< point is on the edge of zone face
75 * Enumeration of tags corresponding to the persistent object parameters.
79 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
80 DataTag_GeometryObject, ///< reference geometry objects
81 DataTag_ChildRegion, ///< child regions
82 DataTag_Region, ///< reference regions
83 DataTag_Polyline, ///< reference boundary polyline
84 DataTag_GeometryGroup, ///< reference geometry groups
85 DataTag_SplittedGroups, ///< reference splitted groups
86 DataTag_CustomRules, ///< custom rules
87 DataTag_AssignmentMode, ///< assignment mode
88 DataTag_StricklerTable, ///< reference Strickler table
89 DataTag_LandCover, ///< reference land covers
90 DataTag_CustomLandCoverRules, ///< custom rules for land covers priority
91 DataTag_AssignmentLandCoverMode ///< assignment mode of land covers priority
96 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
99 * Returns the kind of this object. Must be redefined in all objects of known type.
101 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
104 * Updates the name of this object.
105 * Reimplemented to update the names of regions, zones and splitted groups.
107 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
110 * Dump Calculation object to Python script representation.
112 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
115 * Update the calcualtion case object.
116 * Call this method whenever you made changes for object data.
118 HYDRODATA_EXPORT virtual void Update();
121 * Returns the list of all reference objects of this object.
123 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
126 // Public methods to work with Calculation
129 * Add new one reference geometry object for calculation case.
131 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
134 * Returns all reference geometry objects of calculation case.
136 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
139 * Removes reference geometry object from calculation case.
141 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
144 * Removes all reference geometry objects from calculation case.
146 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
150 * Add new one reference geometry group for calculation case.
152 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
155 * Returns all reference geometry groups of calculation case.
157 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
160 * Removes reference geometry group from calculation case.
162 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
165 * Removes all reference geometry groups from calculation case.
167 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
171 * Sets reference boundary polyline object for calculation case.
173 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
176 * Returns reference boundary polyline object of calculation case.
178 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
181 * Remove reference boundary polyline object from calculation case.
183 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
187 * Sets reference Strickler table for calculation case.
189 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
192 * Returns reference Strickler table of calculation case.
194 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
197 * Remove reference Strickler table from calculation case.
199 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
203 * Add new one reference land cover for calculation case.
205 HYDRODATA_EXPORT virtual bool AddLandCover( const Handle(HYDROData_LandCover)& theLandCover );
208 * Returns all reference land covers of calculation case.
210 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetLandCovers() const;
213 * Removes reference land cover from calculation case.
215 HYDRODATA_EXPORT virtual void RemoveLandCover( const Handle(HYDROData_LandCover)& theLandCover );
218 * Removes all reference land covers from calculation case.
220 HYDRODATA_EXPORT virtual void RemoveLandCovers();
224 * Add new one child region for calculation case.
225 * The new region is added into the list of reference regions.
226 * The label of theZone is changed during this operation
227 * because of new region becomes the new parent for this zone.
229 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
233 * Add new one reference region for calculation case.
234 * The label of theRegion is changed in case if old parent is not this calculation.
236 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
239 * Returns all reference regions of calculation case.
241 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
244 * Updates names of regions to correct order.
246 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
249 * Removes reference region from calculation case.
251 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
254 * Removes all reference regions from calculation case.
256 HYDRODATA_EXPORT virtual void RemoveRegions();
260 * Returns all reference geometry groups of calculation case.
262 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
265 * Removes all reference geometry groups from calculation case.
267 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
270 * Exports the calculation case data (shell and groups) to GEOM module.
271 * \param theStudyId the id of the study where the GEOM module should be used for export
272 * \return the entry of the GEOM object (empty string in the case of error)
274 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
277 * Exports the calculation case data (shell and groups) to GEOM module.
278 * \param theGeomEngine GEOM module engine
279 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
280 * \return true in case of success
282 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
283 SALOMEDS::Study_ptr theStudy,
284 QString& theGeomObjEntry ) const;
287 // Public methods to work with Calculation services
290 * Returns altitude for given point.
291 * \param thePoint the point to examine
292 * \return result altitude value
294 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
297 * Returns altitude for given point on given region.
298 * \param thePoint the point to examine
299 * \param theRegion reference region to check
300 * \return result altitude value
302 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
303 const Handle(HYDROData_Region)& theRegion ) const;
306 * Returns altitude for given point on given zone.
307 * \param thePoint the point to examine
308 * \param theZone reference zone to check
309 * \return result altitude value
311 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
312 const Handle(HYDROData_Zone)& theZone ) const;
315 * Returns altitudes for given points on given region.
316 * \param thePoints the points to examine
317 * \param theRegion reference region to check
318 * \return result altitude value
320 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
321 const NCollection_Sequence<gp_XY>& thePoints,
322 const Handle(HYDROData_Region)& theRegion ) const;
325 * Returns altitudes for given points on given zone.
326 * \param thePoints the points to examine
327 * \param theZone reference zone to check
328 * \return result altitude value
330 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
331 const NCollection_Sequence<gp_XY>& thePoints,
332 const Handle(HYDROData_Zone)& theZone ) const;
335 * Returns region to which the point is belongs.
336 * \param thePoint the point to examine
337 * \return result region
339 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
342 * Returns zone to which the point is belongs.
343 * \param thePoint the point to examine
344 * \return result zone
346 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
349 * Returns classification of point for given zone.
350 * \param thePoint the point to examine
351 * \param theZone the zone to examine
352 * \return result classification
354 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
355 const gp_XY& thePoint,
356 const Handle(HYDROData_Zone)& theZone ) const;
358 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
359 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
361 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
362 const bool theIsSetToUpdate = true );
363 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
364 HYDROData_PriorityType thePriority,
365 const Handle(HYDROData_Entity)& theObject2,
366 HYDROData_Zone::MergeAltitudesType theMergeType,
367 HYDROData_CalculationCase::DataTag theDataTag );
368 HYDRODATA_EXPORT bool GetRule( int theIndex,
369 Handle(HYDROData_Entity)& theObject1,
370 HYDROData_PriorityType& thePriority,
371 Handle(HYDROData_Entity)& theObject2,
372 HYDROData_Zone::MergeAltitudesType& theMergeType,
373 HYDROData_CalculationCase::DataTag& theDataTag ) const;
375 HYDRODATA_EXPORT void SetAssignmentLandCoverMode( AssignmentMode theMode );
376 HYDRODATA_EXPORT AssignmentMode GetAssignmentLandCoverMode() 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
405 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
406 SALOMEDS::Study_ptr theStudy,
407 const TopTools_ListOfShape& theFaces,
408 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
409 QString& theGeomObjEntry ) const;
411 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
412 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
413 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
414 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
416 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
417 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
419 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
421 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
424 friend class HYDROData_Iterator;
427 * Creates new object in the internal data structure. Use higher level objects
428 * to create objects with real content.
430 HYDRODATA_EXPORT HYDROData_CalculationCase();
433 * Destructs properties of the object and object itself, removes it from the document.
435 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
437 void DumpSampleMeshing( QStringList& theScript,
438 const QString& theStudyName,
439 const QString& theGeomShapeName,
440 const QString& theMeshName ) const;
443 HYDROData_Warning myLastWarning;