1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
7 * \brief see MULTIPR_i.hxx
9 * \author Olivier LE ROUX - CS, Virtual Reality Dpt
15 //*****************************************************************************
17 //*****************************************************************************
21 #include "MULTIPR_i.hxx"
22 #include "utilities.h"
26 #include "MULTIPR_API.hxx"
27 #include "MULTIPR_Exceptions.hxx"
30 //*****************************************************************************
31 // Class MULTIPR_Gen_i implementation
32 //*****************************************************************************
34 MULTIPR_Gen_i::MULTIPR_Gen_i(
36 PortableServer::POA_ptr poa,
37 PortableServer::ObjectId* contId,
38 const char* instanceName,
39 const char* interfaceName) :
40 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
42 MESSAGE("activate object");
44 _id = _poa->activate_object(_thisObj);
48 MULTIPR_Gen_i::~MULTIPR_Gen_i()
53 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
57 char* MULTIPR_Gen_i::getVersion()
58 throw (SALOME::SALOME_Exception)
60 return CORBA::string_dup(multipr::getVersion());
64 void MULTIPR_Gen_i::partitionneDomaine(
65 const char* medFilename,
67 throw (SALOME::SALOME_Exception)
71 multipr::partitionneDomaine(medFilename, meshName);
73 catch (multipr::RuntimeException& e)
76 THROW_SALOME_CORBA_EXCEPTION("partitionneDomaine() failed", SALOME::INTERNAL_ERROR);
81 void MULTIPR_Gen_i::partitionneGrain(
82 const char* medFilename,
85 CORBA::Long partitionner)
86 throw (SALOME::SALOME_Exception)
90 multipr::partitionneGrain(
96 catch (multipr::RuntimeException& e)
99 THROW_SALOME_CORBA_EXCEPTION("partitionneGrain() failed", SALOME::INTERNAL_ERROR);
104 void MULTIPR_Gen_i::decimePartition(
105 const char* medFilename,
106 const char* partName,
107 const char* fieldName,
109 const char* filterName,
112 CORBA::Double radius,
114 throw (SALOME::SALOME_Exception)
118 cout << "File : " << medFilename << endl;
119 cout << "Part : " << partName << endl;
120 cout << "Field : " << fieldName << endl;
121 cout << "It : " << fieldIt << endl;
122 cout << "Filter: " << filterName << endl;
123 cout << "Med : " << tmed << endl;
124 cout << "Low : " << tlow << endl;
125 cout << "Rad : " << radius << endl;
126 cout << "Box : " << boxing << endl;
132 multipr::decimePartition(
143 catch (multipr::RuntimeException& e)
146 THROW_SALOME_CORBA_EXCEPTION("decimePartition() failed", SALOME::INTERNAL_ERROR);
151 //-----------------------------------------------------------------------------
153 //-----------------------------------------------------------------------------
155 MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_Gen_i::getObject(const char* medFilename)
156 throw (SALOME::SALOME_Exception)
158 MULTIPR_Obj_i* obj = new MULTIPR_Obj_i(medFilename);
159 return obj->POA_MULTIPR_ORB::MULTIPR_Obj::_this();
163 MULTIPR_Obj_i::MULTIPR_Obj_i(const char* medFilename)
164 throw (SALOME::SALOME_Exception)
166 mObj = new multipr::Obj();
171 cout << "Load " << medFilename << endl;
172 mObj->create(medFilename);
175 catch (multipr::RuntimeException& e)
180 THROW_SALOME_CORBA_EXCEPTION("Unable to create object", SALOME::INTERNAL_ERROR);
185 MULTIPR_Obj_i::~MULTIPR_Obj_i()
195 CORBA::Boolean MULTIPR_Obj_i::isValidSequentialMEDFile()
196 throw (SALOME::SALOME_Exception)
198 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
200 return mObj->isValidSequentialMEDFile();
204 CORBA::Boolean MULTIPR_Obj_i::isValidDistributedMEDFile()
205 throw (SALOME::SALOME_Exception)
207 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
209 return mObj->isValidDistributedMEDFile();
213 void MULTIPR_Obj_i::setMesh(const char* meshName)
214 throw (SALOME::SALOME_Exception)
216 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
220 mObj->setMesh(meshName);
222 cout << "Set mesh OK" << endl << endl;
224 catch (multipr::RuntimeException& e)
227 THROW_SALOME_CORBA_EXCEPTION("Unable to set mesh", SALOME::INTERNAL_ERROR);
232 void MULTIPR_Obj_i::setBoxing(CORBA::Long pBoxing)
233 throw (SALOME::SALOME_Exception)
235 if (mBoxing < 0) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be >= 1", SALOME::INTERNAL_ERROR);
236 if (mBoxing > 200) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be <= 200", SALOME::INTERNAL_ERROR);
242 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes()
243 throw (SALOME::SALOME_Exception)
245 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
247 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
251 std::vector<std::string> listMeshes = mObj->getMeshes();
252 mySeq->length(listMeshes.size());
254 for (int i = 0 ; i < listMeshes.size() ; i++)
256 mySeq[i] = CORBA::string_dup(listMeshes[i].c_str());
259 catch (multipr::RuntimeException& e)
262 THROW_SALOME_CORBA_EXCEPTION("Unable to get meshes", SALOME::INTERNAL_ERROR);
265 return mySeq._retn();
269 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields()
270 throw (SALOME::SALOME_Exception)
272 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
274 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
278 std::vector<std::string> listFields = mObj->getFields();
279 mySeq->length(listFields.size());
281 for (int i = 0 ; i < listFields.size() ; i++)
283 mySeq[i] = CORBA::string_dup(listFields[i].c_str());
286 catch (multipr::RuntimeException& e)
289 THROW_SALOME_CORBA_EXCEPTION("Unable to get fields", SALOME::INTERNAL_ERROR);
292 return mySeq._retn();
296 CORBA::Long MULTIPR_Obj_i::getTimeStamps(const char* fieldName)
297 throw (SALOME::SALOME_Exception)
299 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
303 return mObj->getTimeStamps(fieldName);
305 catch (multipr::RuntimeException& e)
308 THROW_SALOME_CORBA_EXCEPTION("Unable to get time stamps", SALOME::INTERNAL_ERROR);
313 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getParts()
314 throw (SALOME::SALOME_Exception)
316 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
318 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
322 std::vector<std::string> listParts = mObj->getParts();
323 mySeq->length(listParts.size());
325 for (int i = 0 ; i < listParts.size() ; i++)
327 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
330 catch (multipr::RuntimeException& e)
333 THROW_SALOME_CORBA_EXCEPTION("Unable to get parts", SALOME::INTERNAL_ERROR);
336 return mySeq._retn();
340 char* MULTIPR_Obj_i::getPartInfo(const char* pPartName)
341 throw (SALOME::SALOME_Exception)
343 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
345 return CORBA::string_dup(mObj->getPartInfo(pPartName).c_str());
349 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneDomaine()
350 throw (SALOME::SALOME_Exception)
352 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
354 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
358 std::vector<std::string> listParts = mObj->partitionneDomaine();
359 mySeq->length(listParts.size());
361 for (int i = 0 ; i < listParts.size() ; i++)
363 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
366 catch (multipr::RuntimeException& e)
369 THROW_SALOME_CORBA_EXCEPTION("Unable to partition mesh", SALOME::INTERNAL_ERROR);
372 return mySeq._retn();
376 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneGrain(
377 const char* pPartName,
378 CORBA::Long pNbParts,
379 CORBA::Long pPartitionner)
380 throw (SALOME::SALOME_Exception)
382 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
384 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
388 std::vector<std::string> listParts = mObj->partitionneGrain(
393 mySeq->length(listParts.size());
395 for (int i = 0 ; i < listParts.size() ; i++)
397 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
400 catch (multipr::RuntimeException& e)
403 THROW_SALOME_CORBA_EXCEPTION("Unable to partition group", SALOME::INTERNAL_ERROR);
406 return mySeq._retn();
410 MULTIPR_ORB::string_array* MULTIPR_Obj_i::decimePartition(
411 const char* pPartName,
412 const char* pFieldName,
413 CORBA::Long pFieldIt,
414 const char* pFilterName,
417 CORBA::Double pRadius)
418 throw (SALOME::SALOME_Exception)
420 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
422 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
426 std::vector<std::string> listParts = mObj->decimePartition(
436 mySeq->length(listParts.size());
438 for (int i = 0 ; i < listParts.size() ; i++)
440 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
443 catch (multipr::RuntimeException& e)
446 THROW_SALOME_CORBA_EXCEPTION("Unable to decimate", SALOME::INTERNAL_ERROR);
449 return mySeq._retn();
453 char* MULTIPR_Obj_i::evalDecimationParams(
454 const char* pPartName,
455 const char* pFieldName,
456 CORBA::Long pFieldIt,
457 const char* pFilterName,
458 const char* pFilterParams)
459 throw (SALOME::SALOME_Exception)
461 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
465 string res = mObj->evalDecimationParams(
472 return CORBA::string_dup(res.c_str());
475 catch (multipr::RuntimeException& e)
478 THROW_SALOME_CORBA_EXCEPTION("Unable to evaluate decimation parameters", SALOME::INTERNAL_ERROR);
483 void MULTIPR_Obj_i::removeParts(const char* pPrefixPartName)
484 throw (SALOME::SALOME_Exception)
486 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
488 mObj->removeParts(pPrefixPartName);
492 void MULTIPR_Obj_i::save()
493 throw (SALOME::SALOME_Exception)
495 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
502 catch (multipr::RuntimeException& e)
505 THROW_SALOME_CORBA_EXCEPTION("Unable to save MED file", SALOME::INTERNAL_ERROR);
512 PortableServer::ObjectId* MULTIPREngine_factory(
514 PortableServer::POA_ptr poa,
515 PortableServer::ObjectId * contId,
516 const char* instanceName,
517 const char* interfaceName)
519 MESSAGE("PortableServer::ObjectId* MULTIPREngine_factory()");
520 SCRUTE(interfaceName);
521 MULTIPR_Gen_i* myMULTIPR = new MULTIPR_Gen_i(orb, poa, contId, instanceName, interfaceName);
522 return myMULTIPR->getId();