]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPR/MULTIPR_i.hxx
Salome HOME
961b44d531fbf621a3db3415adb55cab104bfea8
[modules/multipr.git] / src / MULTIPR / MULTIPR_i.hxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_i.hxx
6  *
7  * \brief   C++ implementation of the CORBA interface of the MULTIPR module.
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13
14   
15 //*****************************************************************************
16 // Includes section
17 //*****************************************************************************
18  
19 #ifndef __MULTIPR_IMPLEMENTATION_CORBA__
20 #define __MULTIPR_IMPLEMENTATION_CORBA__
21
22 #include <SALOMEconfig.h>
23 #include CORBA_SERVER_HEADER(MULTIPR)
24 #include "SALOME_Component_i.hxx"
25 #include "Utils_CorbaException.hxx"
26
27 #include "MULTIPR_Obj.hxx"
28
29
30 //*****************************************************************************
31 // Class MULTIPR_Obj_i
32 // C++ implementation of the MULTIPR_Obj CORBA interface
33 // This class is a wrapper to encapsulate MULTIPR_Obj
34 //*****************************************************************************
35
36 class MULTIPR_Obj_i :
37         public POA_MULTIPR_ORB::MULTIPR_Obj
38 {
39
40 public:
41
42         /**
43          * Constructor.
44          * Associate a MED file (sequential or distributed) with this object.
45          * \param  pMEDFilename MED file to be associated with this object.
46          */
47     MULTIPR_Obj_i(const char* pMEDFilename)
48                 throw (SALOME::SALOME_Exception);
49             
50         /**
51          * Destructor.
52          */
53     virtual ~MULTIPR_Obj_i();
54         
55         //---------------------------------------------------------------------
56         // Basic accessors/mutators
57         //--------------------------------------------------------------------
58         
59         /**
60          * Returns true iff this obj represents a valid sequential MED file.
61          * \return true iff this obj represents a valid sequential MED file.
62          */
63         CORBA::Boolean isValidSequentialMEDFile()
64                 throw (SALOME::SALOME_Exception);
65         
66         /**
67          * Returns true iff this obj represents a valid distributed MED file.
68          * \return true iff this obj represents a valid distributed  MED file.
69          */
70         CORBA::Boolean isValidDistributedMEDFile()
71                 throw (SALOME::SALOME_Exception);
72         
73         /**
74          * Returns the name of the associated MED file.
75          * \return the name of the associated MED file.
76          */
77         char* getFilename()
78                 throw (SALOME::SALOME_Exception);
79         
80         /**
81          * Defines the mesh to be processed.
82          * \param  pMeshName name of the mesh to be partitionned.
83          */
84         void setMesh(const char* pMeshName)
85                 throw (SALOME::SALOME_Exception);
86         
87         /**
88          * Sets boxing parameters for decimation (100 by default).
89          * \param  pBoxing number of cells along each axis of the grid (= acceleration structure) ; should be in [1..200].
90          */
91         void setBoxing(CORBA::Long pBoxing)
92                 throw (SALOME::SALOME_Exception);
93
94         /**
95          * Returns the list of meshes contained in the sequential MED file.
96          * Assumes this object encapsulates a sequential MED file.
97          * \return the list of meshes contained in the sequential MED file.
98          */
99         MULTIPR_ORB::string_array* getMeshes() 
100                 throw (SALOME::SALOME_Exception);
101
102         /**
103          * Returns the list of fields contained in the sequential MED file.
104          * Assumes this object encapsulates a sequential MED file.
105          * \return the list of fields contained in the sequential MED file.
106          */
107         MULTIPR_ORB::string_array* getFields() 
108                 throw (SALOME::SALOME_Exception);
109         
110         /**
111          * Returns the number of timestamps for a given field.
112          * Assumes this object encapsulates a sequential MED file.
113          * \param  pFieldName name of any field.
114          * \return the number of timestamps for a given field; 0 if field not found.
115          */
116         CORBA::Long getTimeStamps(const char* pFieldName)
117                 throw (SALOME::SALOME_Exception);
118         
119         /**
120          * Returns the name of all partitions.
121          * Assumes this object encapsulates a distributed MED file.
122          * \return the name of all partitions.
123          */
124         MULTIPR_ORB::string_array* getParts()
125                 throw (SALOME::SALOME_Exception);
126
127         /**
128          * Returns all information abour a part.
129          * Assumes this object encapsulates a distributed MED file.
130          * \param  pPartName name of the part.
131          * \return information about a part.
132          */
133         char* getPartInfo(const char* pPartName)
134                 throw (SALOME::SALOME_Exception);
135         
136         //---------------------------------------------------------------------
137         // Algorithms
138         //---------------------------------------------------------------------
139         
140         /**
141          * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file.
142          *         Assumes:
143          *         - the file is in MED format and can be read using MED file v2.3.
144          *         - the file is sequential (not a distributed MED).
145          *         - the file only contains TETRA10 elements (dimension of space and mesh is 3).
146          *         - the file have no profil.
147          * \return the name of each part.
148          */
149         MULTIPR_ORB::string_array* partitionneDomaine()
150                 throw (SALOME::SALOME_Exception);
151         
152         /** 
153          * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
154          *         Assumes:
155          *         - the file is a distributed MED file, previously created by partitionneDomaine()
156          *           (=> each part only contain 1 mesh, TETRA10 elements only)
157          *         - nbPart > 1
158          * \param  pPartName     name of the part to be splitted.
159          * \param  pNbParts      number of parts; must be > 1.
160          * \param  pPartitionner use value 0=MULTIPR_METIS for Metis or 1=MULTIPR_SCOTCH for Scotch.
161          * \return the name of each part.
162          */
163         MULTIPR_ORB::string_array* partitionneGrain(
164                 const char* pPartName, 
165                 CORBA::Long pNbParts, 
166                 CORBA::Long pPartitionner)
167                 throw (SALOME::SALOME_Exception);
168         
169         /**
170          * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
171          *         Assumes:
172          *         - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
173          *           (=> each part only contain 1 mesh, TETRA10 elements only)
174          * \param  pPartName    name of the part to be decimated.
175          * \param  pFieldName   name of the field used for decimation.
176          * \param  pFieldIt     iteration (time step) of the field.
177          * \param  pFilterName  name of the filter to be used.
178          * \param  pTmed        threshold used for medium resolution.
179          * \param  pTlow        threshold used for low resolution; tmed must be less than tlow
180          * \param  pTadius      radius used to determine the neighbourhood.
181          * \return the name of each part.
182          */
183         MULTIPR_ORB::string_array* decimePartition(
184                 const char*   pPartName,
185                 const char*   pFieldName,
186                 CORBA::Long   pFieldIt,
187                 const char*   pFilterName,
188                 CORBA::Double pTmed,
189                 CORBA::Double pTlow,
190                 CORBA::Double pRadius)
191                 throw (SALOME::SALOME_Exception);
192                 
193         /**
194          * Returns useful information to configure decimation parameters.
195          * Depends on part, field and filter: generic operation.
196          * \param  pPartName     name of the part.
197          * \param  pFieldName    name of the field used for decimation.
198          * \param  pFieldIt      iteration (time step) of the field.
199          * \param  pFilterName   name of the filter to be used.
200          * \param  pFilterParams params to be used with the filter (depends on filter; this string will be parsed).
201          */
202         char* evalDecimationParams(
203                 const char* pPartName, 
204                 const char* pFieldName, 
205                 CORBA::Long pFieldIt, 
206                 const char* pFilterName,
207                 const char* pFilterParams)
208                 throw (SALOME::SALOME_Exception);
209                 
210         /*!
211          * Removes all the parts starting with "pPrefixPartName" from the distributed MED file.
212          * Example: if pPrefixPartName="PART_4" => remove "PART_4" and all sub-parts "PART_4_*", but not "PART41".
213          * Assume this object encapsulates a distributed MED file.
214          * \param  pPrefixPartName name of the part.
215          */
216         void removeParts(const char* pPrefixPartName)
217                 throw (SALOME::SALOME_Exception);
218         
219         //---------------------------------------------------------------------
220         // I/O
221         //---------------------------------------------------------------------
222         
223         /**
224          * Saves the associated MED file if necessary.
225          * \param  pPath path where to save the file.
226          */
227         void save(const char* pPath)
228                 throw (SALOME::SALOME_Exception);
229         
230 private:
231
232         /**
233          * The associated MULTIPR object.
234          */
235         multipr::Obj* mObj;
236         
237         /**
238          * Boxing paremeter: number of cells along each axis.
239          * E.g. if mBoxing=10 then total number of cells = 10*10*10 = 1000.
240          * By default, mBoxing=100.
241          */
242         int mBoxing;
243         
244 };
245
246
247 //*****************************************************************************
248 // Class MULTIPR_Gen_i
249 // C++ implementation of the MULTIPR_Gen CORBA interface
250 //*****************************************************************************
251
252 class MULTIPR_Gen_i :
253         public POA_MULTIPR_ORB::MULTIPR_Gen,
254         public Engines_Component_i 
255 {
256
257 public:
258
259         MULTIPR_Gen_i(
260                 CORBA::ORB_ptr orb,
261                 PortableServer::POA_ptr poa,
262                 PortableServer::ObjectId* contId, 
263                 const char* instanceName, 
264                 const char* interfaceName);
265         
266         virtual ~MULTIPR_Gen_i();
267         
268         char* getVersion()
269                 throw (SALOME::SALOME_Exception);
270         
271         void partitionneDomaine(
272                 const char* medFilename, 
273                 const char* meshName)
274                 throw (SALOME::SALOME_Exception);
275         
276         void partitionneGrain(
277                 const char* medFilename, 
278                 const char* partName, 
279                 CORBA::Long nbParts, 
280                 CORBA::Long partitionner)
281                 throw (SALOME::SALOME_Exception);
282         
283         void decimePartition(
284                 const char*   medFilename, 
285                 const char*   partName, 
286                 const char*   fieldName,
287                 CORBA::Long   fieldIt,
288                 const char*   filterName,
289                 CORBA::Double tmed,
290                 CORBA::Double tlow,
291                 CORBA::Double radius,
292                 CORBA::Long   boxing)
293                 throw (SALOME::SALOME_Exception);
294  
295         MULTIPR_ORB::MULTIPR_Obj_ptr getObject(const char* medFilename)
296                 throw (SALOME::SALOME_Exception);
297 };
298
299
300 extern "C" PortableServer::ObjectId* MULTIPREngine_factory(
301         CORBA::ORB_ptr orb,
302         PortableServer::POA_ptr poa,
303         PortableServer::ObjectId * contId,
304         const char* instanceName,
305         const char* interfaceName);
306
307 #endif // __MULTIPR_IMPLEMENTATION_CORBA__