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()
189 cout << "MULTIPR: Destructor: remove mObj" << endl;
196 CORBA::Boolean MULTIPR_Obj_i::isValidSequentialMEDFile()
197 throw (SALOME::SALOME_Exception)
199 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
201 return mObj->isValidSequentialMEDFile();
205 CORBA::Boolean MULTIPR_Obj_i::isValidDistributedMEDFile()
206 throw (SALOME::SALOME_Exception)
208 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
210 return mObj->isValidDistributedMEDFile();
214 char* MULTIPR_Obj_i::getFilename()
215 throw (SALOME::SALOME_Exception)
217 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
219 return CORBA::string_dup(mObj->getMEDFilename().c_str());
223 void MULTIPR_Obj_i::setMesh(const char* meshName)
224 throw (SALOME::SALOME_Exception)
226 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
230 mObj->setMesh(meshName);
232 cout << "Set mesh OK" << endl << endl;
234 catch (multipr::RuntimeException& e)
237 THROW_SALOME_CORBA_EXCEPTION("Unable to set mesh", SALOME::INTERNAL_ERROR);
242 void MULTIPR_Obj_i::setBoxing(CORBA::Long pBoxing)
243 throw (SALOME::SALOME_Exception)
245 if (mBoxing < 0) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be >= 1", SALOME::INTERNAL_ERROR);
246 if (mBoxing > 200) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be <= 200", SALOME::INTERNAL_ERROR);
252 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes()
253 throw (SALOME::SALOME_Exception)
255 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
257 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
261 std::vector<std::string> listMeshes = mObj->getMeshes();
262 mySeq->length(listMeshes.size());
264 for (int i = 0 ; i < listMeshes.size() ; i++)
266 mySeq[i] = CORBA::string_dup(listMeshes[i].c_str());
269 catch (multipr::RuntimeException& e)
272 THROW_SALOME_CORBA_EXCEPTION("Unable to get meshes", SALOME::INTERNAL_ERROR);
275 return mySeq._retn();
279 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields()
280 throw (SALOME::SALOME_Exception)
282 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
284 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
288 std::vector<std::string> listFields = mObj->getFields();
289 mySeq->length(listFields.size());
291 for (int i = 0 ; i < listFields.size() ; i++)
293 mySeq[i] = CORBA::string_dup(listFields[i].c_str());
296 catch (multipr::RuntimeException& e)
299 THROW_SALOME_CORBA_EXCEPTION("Unable to get fields", SALOME::INTERNAL_ERROR);
302 return mySeq._retn();
306 CORBA::Long MULTIPR_Obj_i::getTimeStamps(const char* fieldName)
307 throw (SALOME::SALOME_Exception)
309 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
313 return mObj->getTimeStamps(fieldName);
315 catch (multipr::RuntimeException& e)
318 THROW_SALOME_CORBA_EXCEPTION("Unable to get time stamps", SALOME::INTERNAL_ERROR);
323 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getParts()
324 throw (SALOME::SALOME_Exception)
326 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
328 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
332 std::vector<std::string> listParts = mObj->getParts();
333 mySeq->length(listParts.size());
335 for (int i = 0 ; i < listParts.size() ; i++)
337 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
340 catch (multipr::RuntimeException& e)
343 THROW_SALOME_CORBA_EXCEPTION("Unable to get parts", SALOME::INTERNAL_ERROR);
346 return mySeq._retn();
350 char* MULTIPR_Obj_i::getPartInfo(const char* pPartName)
351 throw (SALOME::SALOME_Exception)
353 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
355 return CORBA::string_dup(mObj->getPartInfo(pPartName).c_str());
359 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneDomaine()
360 throw (SALOME::SALOME_Exception)
362 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
364 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
368 std::vector<std::string> listParts = mObj->partitionneDomaine();
369 mySeq->length(listParts.size());
371 for (int i = 0 ; i < listParts.size() ; i++)
373 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
376 catch (multipr::RuntimeException& e)
379 THROW_SALOME_CORBA_EXCEPTION("Unable to partition mesh", SALOME::INTERNAL_ERROR);
382 return mySeq._retn();
386 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneGrain(
387 const char* pPartName,
388 CORBA::Long pNbParts,
389 CORBA::Long pPartitionner)
390 throw (SALOME::SALOME_Exception)
392 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
394 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
398 std::vector<std::string> listParts = mObj->partitionneGrain(
403 mySeq->length(listParts.size());
405 for (int i = 0 ; i < listParts.size() ; i++)
407 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
410 catch (multipr::RuntimeException& e)
413 THROW_SALOME_CORBA_EXCEPTION("Unable to partition group", SALOME::INTERNAL_ERROR);
416 return mySeq._retn();
420 MULTIPR_ORB::string_array* MULTIPR_Obj_i::decimePartition(
421 const char* pPartName,
422 const char* pFieldName,
423 CORBA::Long pFieldIt,
424 const char* pFilterName,
427 CORBA::Double pRadius)
428 throw (SALOME::SALOME_Exception)
430 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
432 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
436 std::vector<std::string> listParts = mObj->decimePartition(
446 mySeq->length(listParts.size());
448 for (int i = 0 ; i < listParts.size() ; i++)
450 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
453 catch (multipr::RuntimeException& e)
456 THROW_SALOME_CORBA_EXCEPTION("Unable to decimate", SALOME::INTERNAL_ERROR);
459 return mySeq._retn();
463 char* MULTIPR_Obj_i::evalDecimationParams(
464 const char* pPartName,
465 const char* pFieldName,
466 CORBA::Long pFieldIt,
467 const char* pFilterName,
468 const char* pFilterParams)
469 throw (SALOME::SALOME_Exception)
471 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
475 string res = mObj->evalDecimationParams(
482 return CORBA::string_dup(res.c_str());
485 catch (multipr::RuntimeException& e)
488 THROW_SALOME_CORBA_EXCEPTION("Unable to evaluate decimation parameters", SALOME::INTERNAL_ERROR);
493 void MULTIPR_Obj_i::removeParts(const char* pPrefixPartName)
494 throw (SALOME::SALOME_Exception)
496 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
498 mObj->removeParts(pPrefixPartName);
502 void MULTIPR_Obj_i::save(const char* pPath)
503 throw (SALOME::SALOME_Exception)
505 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
512 catch (multipr::RuntimeException& e)
515 THROW_SALOME_CORBA_EXCEPTION("Unable to save MED file", SALOME::INTERNAL_ERROR);
522 PortableServer::ObjectId* MULTIPREngine_factory(
524 PortableServer::POA_ptr poa,
525 PortableServer::ObjectId * contId,
526 const char* instanceName,
527 const char* interfaceName)
529 MESSAGE("PortableServer::ObjectId* MULTIPREngine_factory()");
530 SCRUTE(interfaceName);
531 MULTIPR_Gen_i* myMULTIPR = new MULTIPR_Gen_i(orb, poa, contId, instanceName, interfaceName);
532 return myMULTIPR->getId();