1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
7 * \brief C++ implementation of the CORBA interface of the MULTIPR module.
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
15 //*****************************************************************************
17 //*****************************************************************************
19 #ifndef __MULTIPR_IMPLEMENTATION_CORBA__
20 #define __MULTIPR_IMPLEMENTATION_CORBA__
22 #include <SALOMEconfig.h>
23 #include CORBA_SERVER_HEADER(MULTIPR)
24 #include "SALOME_Component_i.hxx"
25 #include "Utils_CorbaException.hxx"
27 #include "SALOME_GenericObj_i.hh"
29 #include "MULTIPR_Obj.hxx"
37 //*****************************************************************************
38 // Class MULTIPR_Obj_i
39 // C++ implementation of the MULTIPR_Obj CORBA interface
40 // This class is a wrapper to encapsulate MULTIPR_Obj
41 //*****************************************************************************
44 public POA_MULTIPR_ORB::MULTIPR_Obj,
45 public virtual SALOME::GenericObj_i
52 * Associate a MED file (sequential or distributed) with this object.
53 * \param pMEDFilename MED file to be associated with this object.
55 MULTIPR_Obj_i (PortableServer::POA_ptr thePOA,
56 const char* pMEDFilename,
57 bool isPersistence = false,
58 bool isMultifile = false)
59 throw (SALOME::SALOME_Exception);
64 virtual ~MULTIPR_Obj_i();
66 //---------------------------------------------------------------------
67 // Basic accessors/mutators
68 //--------------------------------------------------------------------
74 throw (SALOME::SALOME_Exception);
77 * Returns true iff this obj represents a valid sequential MED file.
78 * \return true iff this obj represents a valid sequential MED file.
80 CORBA::Boolean isValidSequentialMEDFile()
81 throw (SALOME::SALOME_Exception);
84 * Returns true iff this obj represents a valid distributed MED file.
85 * \return true iff this obj represents a valid distributed MED file.
87 CORBA::Boolean isValidDistributedMEDFile()
88 throw (SALOME::SALOME_Exception);
91 * Returns the name of the associated MED file.
92 * \return the name of the associated MED file.
95 throw (SALOME::SALOME_Exception);
98 * Returns the name of the associated sequential MED file (for a distributed MED file).
99 * \return the name of the associated sequential MED file (for a distributed MED file).
101 char* getSeqFilename()
102 throw (SALOME::SALOME_Exception);
105 * Defines the mesh to be processed.
106 * \param pMeshName name of the mesh to be partitionned.
108 void setMesh(const char* pMeshName)
109 throw (SALOME::SALOME_Exception);
112 * Returns a name of the mesh to be processed.
113 * \return a name of the mesh to be processed.
115 std::string getMeshName() const
116 throw (SALOME::SALOME_Exception);
119 * Sets boxing parameters for decimation (100 by default).
120 * \param pBoxing number of cells along each axis of the grid
121 * (= acceleration structure) ; should be in [1..200].
123 void setBoxing(CORBA::Long pBoxing)
124 throw (SALOME::SALOME_Exception);
127 * Returns currently set boxing parameter for decimation.
128 * \return currently set boxing parameter for decimation.
130 int getBoxing() const { return mBoxing; }
133 * Returns the list of meshes contained in the sequential MED file.
134 * Assumes this object encapsulates a sequential MED file.
135 * \return the list of meshes contained in the sequential MED file.
137 MULTIPR_ORB::string_array* getMeshes()
138 throw (SALOME::SALOME_Exception);
141 * Returns the list of fields contained in the sequential MED file.
142 * Assumes this object encapsulates a sequential MED file.
143 * \param pPartList The list of parts to get the fields from (separator is '|').
144 * \return the list of fields contained in the sequential MED file.
146 MULTIPR_ORB::string_array* getFields(const char* pPartList)
147 throw (SALOME::SALOME_Exception);
150 * Returns the number of timestamps for a given field.
151 * Assumes this object encapsulates a sequential MED file.
152 * \param pPartList The list of parts to get the fields from (separator is '|').
153 * \param pFieldName name of any field.
154 * \return the number of timestamps for a given field; 0 if field not found.
156 CORBA::Long getTimeStamps(const char* pPartList, const char* pFieldName)
157 throw (SALOME::SALOME_Exception);
160 * Get the minimum and maximum value of a part's field.
161 * \param pPartName The name of the part.
162 * \param pFieldName The name of the field.
163 * \param pMin The mininum value to fill.
164 * \param pMax The maxinum value to fill.
166 void getFieldMinMax(const char* pPartName, const char* pFieldName, CORBA::Float& pMin, CORBA::Float& pMax)
167 throw (SALOME::SALOME_Exception);
170 * Returns the name of all partitions.
171 * Assumes this object encapsulates a distributed MED file.
172 * \return the name of all partitions.
174 MULTIPR_ORB::string_array* getParts()
175 throw (SALOME::SALOME_Exception);
178 * Returns all information abour a part.
179 * Assumes this object encapsulates a distributed MED file.
180 * \param pPartName name of the part.
181 * \return information about a part.
183 char* getPartInfo(const char* pPartName)
184 throw (SALOME::SALOME_Exception);
186 //---------------------------------------------------------------------
188 //---------------------------------------------------------------------
191 * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file.
193 * - the file is in MED format and can be read using MED file v2.3.
194 * - the file is sequential (not a distributed MED).
195 * - the file only contains TETRA10 elements (dimension of space and mesh is 3).
196 * - the file have no profil.
197 * \return the name of each part.
199 MULTIPR_ORB::string_array* partitionneDomaine()
200 throw (SALOME::SALOME_Exception);
203 * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
205 * - the file is a distributed MED file, previously created by partitionneDomaine()
206 * (=> each part only contain 1 mesh, TETRA10 elements only)
208 * \param pPartName name of the part to be splitted.
209 * \param pNbParts number of parts; must be > 1.
210 * \param pPartitionner use value 0=MULTIPR_METIS for Metis or 1=MULTIPR_SCOTCH for Scotch.
211 * \return the name of each part.
213 MULTIPR_ORB::string_array* partitionneGroupe(
214 const char* pPartName,
215 CORBA::Long pNbParts,
216 CORBA::Long pPartitionner)
217 throw (SALOME::SALOME_Exception);
220 * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
222 * - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
223 * (=> each part only contain 1 mesh, TETRA10 elements only)
224 * \param pPartName name of the part to be decimated.
225 * \param pFieldName name of the field used for decimation.
226 * \param pFieldIt iteration (time step) of the field.
227 * \param pFilterName name of the filter to be used.
228 * \param pTmed threshold used for medium resolution.
229 * \param pTlow threshold used for low resolution; tmed must be less than tlow
230 * \param pTadius radius used to determine the neighbourhood.
231 * \return the name of each part.
233 MULTIPR_ORB::string_array* decimePartition(
234 const char* pPartName,
235 const char* pFieldName,
236 CORBA::Long pFieldIt,
237 const char* pFilterName,
238 const char* pFilterParams)
239 throw (SALOME::SALOME_Exception);
242 * Works exactly like the above method, but returns not a list
243 * of all parts, but a list of empty obtained resolutions.
244 * \return the list of empty resolutions.
247 MULTIPR_ORB::string_array* decimatePart(
248 const char* pPartName,
249 const char* pFieldName,
250 CORBA::Long pFieldIt,
251 const char* pFilterName,
252 const char* pFilterParams)
253 throw (SALOME::SALOME_Exception);
257 * Returns useful information to configure decimation parameters.
258 * Depends on part, field and filter: generic operation.
259 * \param pPartName name of the part.
260 * \param pFieldName name of the field used for decimation.
261 * \param pFieldIt iteration (time step) of the field.
262 * \param pFilterName name of the filter to be used.
263 * \param pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
265 char* evalDecimationParams(
266 const char* pPartName,
267 const char* pFieldName,
268 CORBA::Long pFieldIt,
269 const char* pFilterName,
270 const char* pFilterParams)
271 throw (SALOME::SALOME_Exception);
274 * Removes all the parts starting with "pPrefixPartName" from the distributed MED file.
275 * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
276 * Assume this object encapsulates a distributed MED file.
277 * \param pPrefixPartName name of the part.
279 void removeParts(const char* pPrefixPartName)
280 throw (SALOME::SALOME_Exception);
283 * Get mesh statistics.
284 * \return Mesh statistics !
286 char* getMEDInfo(const char* pPartName)
287 throw (SALOME::SALOME_Exception);
289 //---------------------------------------------------------------------
291 //---------------------------------------------------------------------
294 * Saves the associated MED file if necessary.
295 * \param pPath path where to save the file.
297 void save(const char* pPath)
298 throw (SALOME::SALOME_Exception);
301 * Check save progress.
302 * \return current save progress in percents.
304 CORBA::Long getSaveProgress();
307 * Reset save progress to zero.
309 void resetSaveProgress();
311 //---------------------------------------------------------------------
312 // Persistence and Dump Python
313 //---------------------------------------------------------------------
316 * Saves the associated MED file to the given location.
317 * \note To be used only for persistence.
318 * \param pPath path where to save the file.
320 void savePersistent (const char* pPath)
321 throw (SALOME::SALOME_Exception);
326 //void setEngine (MULTIPR_ORB::MULTIPR_Gen_ptr theEngine);
327 void setEngine (MULTIPR_Gen_i* theEngine);
332 * The associated MULTIPR object.
337 * Boxing paremeter: number of cells along each axis.
338 * E.g. if mBoxing=10 then total number of cells = 10*10*10 = 1000.
339 * By default, mBoxing=100.
346 MULTIPR_Gen_i* _engine;
349 * Is restored MED file (Used by Persistence to remove temporary files).
355 //*****************************************************************************
356 // Class MULTIPR_Gen_i
357 // C++ implementation of the MULTIPR_Gen CORBA interface
358 //*****************************************************************************
360 class MULTIPR_Gen_i :
361 public POA_MULTIPR_ORB::MULTIPR_Gen,
362 public Engines_Component_i
369 PortableServer::POA_ptr poa,
370 PortableServer::ObjectId* contId,
371 const char* instanceName,
372 const char* interfaceName);
374 virtual ~MULTIPR_Gen_i();
377 throw (SALOME::SALOME_Exception);
379 void partitionneDomaine(
380 const char* medFilename,
381 const char* meshName)
382 throw (SALOME::SALOME_Exception);
384 void partitionneGroupe(
385 const char* medFilename,
386 const char* partName,
388 CORBA::Long partitionner)
389 throw (SALOME::SALOME_Exception);
391 void decimePartition(
392 const char* medFilename,
393 const char* partName,
394 const char* fieldName,
396 const char* filterName,
397 const char* filterParams)
398 throw (SALOME::SALOME_Exception);
400 MULTIPR_ORB::MULTIPR_Obj_ptr getObject(const char* medFilename)
401 throw (SALOME::SALOME_Exception);
403 // ****************************************************
404 // Set/Get current study for Persistence and Dump Python
405 // ****************************************************
408 void SetCurrentStudy (SALOMEDS::Study_ptr theStudy);
410 SALOMEDS::Study_ptr GetCurrentStudy();
412 // Mark current study as modified, if theObj is published in it
413 void ObjModified (MULTIPR_ORB::MULTIPR_Obj_ptr theObj);
415 // ****************************************************
416 // Interface inherited methods (from SALOMEDS::Driver)
417 // ****************************************************
420 SALOMEDS::TMPFile* Save (SALOMEDS::SComponent_ptr theComponent,
424 bool Load (SALOMEDS::SComponent_ptr theComponent,
425 const SALOMEDS::TMPFile& theStream,
429 // Save SMESH data in ASCII format
430 SALOMEDS::TMPFile* SaveASCII (SALOMEDS::SComponent_ptr theComponent,
433 // Load SMESH data in ASCII format
434 bool LoadASCII (SALOMEDS::SComponent_ptr theComponent,
435 const SALOMEDS::TMPFile& theStream,
439 // Clears study-connected data when it is closed
440 void Close (SALOMEDS::SComponent_ptr theComponent);
442 // Get component data type
443 char* ComponentDataType();
445 // Transform data from transient form to persistent
446 char* IORToLocalPersistentID (SALOMEDS::SObject_ptr theSObject,
447 const char* IORString,
448 CORBA::Boolean isMultiFile,
449 CORBA::Boolean isASCII);
450 // Transform data from persistent form to transient
451 char* LocalPersistentIDToIOR (SALOMEDS::SObject_ptr theSObject,
452 const char* aLocalPersistentID,
453 CORBA::Boolean isMultiFile,
454 CORBA::Boolean isASCII);
456 // Returns true if object can be published in the study
457 bool CanPublishInStudy (CORBA::Object_ptr theIOR);
458 // Publish object in the study
459 SALOMEDS::SObject_ptr PublishInStudy (SALOMEDS::Study_ptr theStudy,
460 SALOMEDS::SObject_ptr theSObject,
461 CORBA::Object_ptr theObject,
463 throw (SALOME::SALOME_Exception);
465 // Copy-paste methods - returns true if object can be copied to the clipboard
466 CORBA::Boolean CanCopy (SALOMEDS::SObject_ptr theObject) { return false; }
467 // Copy-paste methods - copy object to the clipboard
468 SALOMEDS::TMPFile* CopyFrom (SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) { return false; }
469 // Copy-paste methods - returns true if object can be pasted from the clipboard
470 CORBA::Boolean CanPaste (const char* theComponentName, CORBA::Long theObjectID) { return false; }
471 // Copy-paste methods - paste object from the clipboard
472 SALOMEDS::SObject_ptr PasteInto (const SALOMEDS::TMPFile& theStream,
473 CORBA::Long theObjectID,
474 SALOMEDS::SObject_ptr theObject)
476 SALOMEDS::SObject_var aResultSO;
477 return aResultSO._retn();
484 virtual Engines::TMPFile* DumpPython (CORBA::Object_ptr theStudy,
485 CORBA::Boolean isPublished,
486 CORBA::Boolean& isValidScript);
488 void AddToPythonScript (int theStudyID, std::string theString);
491 std::string DumpPython_impl (int theStudyID,
494 std::string theSavedTrace);
496 std::string GetNewPythonLines (int theStudyID);
497 void CleanPythonTrace (int theStudyID);
498 void SavePython (SALOMEDS::Study_ptr theStudy);
502 SALOMEDS::Study_var myCurrentStudy;
503 // Dump Python: trace of API methods calls
504 std::map < int, std::vector <std::string> > myPythonScripts;
505 // Tmp directory. Used by Persistence.
506 std::string myTmpDir;
510 extern "C" PortableServer::ObjectId* MULTIPREngine_factory(
512 PortableServer::POA_ptr poa,
513 PortableServer::ObjectId * contId,
514 const char* instanceName,
515 const char* interfaceName);
517 #endif // __MULTIPR_IMPLEMENTATION_CORBA__