Salome HOME
*** empty log message ***
[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          * Defines the mesh to be processed.
75          * \param  pMeshName name of the mesh to be partitionned.
76          */
77         void setMesh(const char* pMeshName)
78                 throw (SALOME::SALOME_Exception);
79         
80         /**
81          * Sets boxing parameters for decimation (100 by default).
82          * \param  pBoxing number of cells along each axis of the grid (= acceleration structure) ; should be in [1..200].
83          */
84         void setBoxing(CORBA::Long pBoxing)
85                 throw (SALOME::SALOME_Exception);
86
87         /**
88          * Returns the list of meshes contained in the sequential MED file.
89          * Assumes this object encapsulates a sequential MED file.
90          * \return the list of meshes contained in the sequential MED file.
91          */
92         MULTIPR_ORB::string_array* getMeshes() 
93                 throw (SALOME::SALOME_Exception);
94
95         /**
96          * Returns the list of fields contained in the sequential MED file.
97          * Assumes this object encapsulates a sequential MED file.
98          * \return the list of fields contained in the sequential MED file.
99          */
100         MULTIPR_ORB::string_array* getFields() 
101                 throw (SALOME::SALOME_Exception);
102         
103         /**
104          * Returns the number of timestamps for a given field.
105          * Assumes this object encapsulates a sequential MED file.
106          * \param  pFieldName name of any field.
107          * \return the number of timestamps for a given field; 0 if field not found.
108          */
109         CORBA::Long getTimeStamps(const char* pFieldName)
110                 throw (SALOME::SALOME_Exception);
111         
112         /**
113          * Returns the name of all partitions.
114          * Assumes this object encapsulates a distributed MED file.
115          * \return the name of all partitions.
116          */
117         MULTIPR_ORB::string_array* getParts()
118                 throw (SALOME::SALOME_Exception);
119
120         /**
121          * Returns all information abour a part.
122          * Assumes this object encapsulates a distributed MED file.
123          * \param  pPartName name of the part.
124          * \return information about a part.
125          */
126         char* getPartInfo(const char* pPartName)
127                 throw (SALOME::SALOME_Exception);
128
129         /*!
130          * Removes the given part from the distributed MED file.
131          * Assume this object encapsulates a distributed MED file.
132          * \param  pPartName name of the part.
133          */
134         void removePart(const char* pPartName)
135                 throw (SALOME::SALOME_Exception);
136         
137         
138         //---------------------------------------------------------------------
139         // Algorithms
140         //---------------------------------------------------------------------
141         
142         /**
143          * Creates a distributed MED file (v2.3) by extracting all the groups from the current mesh of the current MED sequential MED file.
144          *         Assumes:
145          *         - the file is in MED format and can be read using MED file v2.3.
146          *         - the file is sequential (not a distributed MED).
147          *         - the file only contains TETRA10 elements (dimension of space and mesh is 3).
148          *         - the file have no profil.
149          * \return the name of each part.
150          */
151         MULTIPR_ORB::string_array* partitionneDomaine()
152                 throw (SALOME::SALOME_Exception);
153         
154         /** 
155          * Creates a distributed MED file (V2.3) by splitting a group of a MED file previously created by partitionneDomaine.
156          *         Assumes:
157          *         - the file is a distributed MED file, previously created by partitionneDomaine()
158          *           (=> each part only contain 1 mesh, TETRA10 elements only)
159          *         - nbPart > 1
160          * \param  pPartName     name of the part to be splitted.
161          * \param  pNbParts      number of parts; must be > 1.
162          * \param  pPartitionner use value 0=MULTIPR_METIS for Metis or 1=MULTIPR_SCOTCH for Scotch.
163          * \return the name of each part.
164          */
165         MULTIPR_ORB::string_array* partitionneGrain(
166                 const char* pPartName, 
167                 CORBA::Long pNbParts, 
168                 CORBA::Long pPartitionner)
169                 throw (SALOME::SALOME_Exception);
170         
171         /**
172          * Creates 3 resolutions of the given part of a distributed MED file (V2.3).
173          *         Assumes:
174          *         - the file is a distributed MED file, previously created by partitionneDomaine() or partitionneGrain()
175          *           (=> each part only contain 1 mesh, TETRA10 elements only)
176          * \param  pPartName    name of the part to be decimated.
177          * \param  pFieldName   name of the field used for decimation.
178          * \param  pFieldIt     iteration (time step) of the field.
179          * \param  pFilterName  name of the filter to be used.
180          * \param  pTmed        threshold used for medium resolution.
181          * \param  pTlow        threshold used for low resolution; tmed must be less than tlow
182          * \param  pTadius      radius used to determine the neighbourhood.
183          * \return the name of each part.
184          */
185         MULTIPR_ORB::string_array* decimePartition(
186                 const char*   pPartName,
187                 const char*   pFieldName,
188                 CORBA::Long   pFieldIt,
189                 const char*   pFilterName,
190                 CORBA::Double pTmed,
191                 CORBA::Double pTlow,
192                 CORBA::Double pRadius)
193                 throw (SALOME::SALOME_Exception);
194
195         //---------------------------------------------------------------------
196         // I/O
197         //---------------------------------------------------------------------
198         
199         /**
200          * Saves the associated MED file if necessary.
201          */
202         void save()
203                 throw (SALOME::SALOME_Exception);
204         
205 private:
206
207         /**
208          * The associated MULTIPR object.
209          */
210         multipr::Obj* mObj;
211         
212         /**
213          * Boxing paremeter: number of cells along each axis.
214          * E.g. if mBoxing=10 then total number of cells = 10*10*10 = 1000.
215          * By default, mBoxing=100.
216          */
217         int mBoxing;
218         
219 };
220
221
222 //*****************************************************************************
223 // Class MULTIPR_Gen_i
224 // C++ implementation of the MULTIPR_Gen CORBA interface
225 //*****************************************************************************
226
227 class MULTIPR_Gen_i :
228         public POA_MULTIPR_ORB::MULTIPR_Gen,
229         public Engines_Component_i 
230 {
231
232 public:
233
234         MULTIPR_Gen_i(
235                 CORBA::ORB_ptr orb,
236                 PortableServer::POA_ptr poa,
237                 PortableServer::ObjectId* contId, 
238                 const char* instanceName, 
239                 const char* interfaceName);
240         
241         virtual ~MULTIPR_Gen_i();
242         
243         char* getVersion()
244                 throw (SALOME::SALOME_Exception);
245         
246         void partitionneDomaine(
247                 const char* medFilename, 
248                 const char* meshName)
249                 throw (SALOME::SALOME_Exception);
250         
251         void partitionneGrain(
252                 const char* medFilename, 
253                 const char* partName, 
254                 CORBA::Long nbParts, 
255                 CORBA::Long partitionner)
256                 throw (SALOME::SALOME_Exception);
257         
258         void decimePartition(
259                 const char*   medFilename, 
260                 const char*   partName, 
261                 const char*   fieldName,
262                 CORBA::Long   fieldIt,
263                 const char*   filterName,
264                 CORBA::Double tmed,
265                 CORBA::Double tlow,
266                 CORBA::Double radius,
267                 CORBA::Long   boxing)
268                 throw (SALOME::SALOME_Exception);
269  
270         MULTIPR_ORB::MULTIPR_Obj_ptr getObject(const char* medFilename)
271                 throw (SALOME::SALOME_Exception);
272 };
273
274
275 extern "C" PortableServer::ObjectId* MULTIPREngine_factory(
276         CORBA::ORB_ptr orb,
277         PortableServer::POA_ptr poa,
278         PortableServer::ObjectId * contId,
279         const char* instanceName,
280         const char* interfaceName);
281
282 #endif // __MULTIPR_IMPLEMENTATION_CORBA__