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 char* MULTIPR_Obj_i::getSeqFilename()
224 throw (SALOME::SALOME_Exception)
226 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
228 return CORBA::string_dup(mObj->getSequentialMEDFilename().c_str());
232 void MULTIPR_Obj_i::setMesh(const char* meshName)
233 throw (SALOME::SALOME_Exception)
235 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
239 mObj->setMesh(meshName);
241 cout << "Set mesh OK" << endl << endl;
243 catch (multipr::RuntimeException& e)
246 THROW_SALOME_CORBA_EXCEPTION("Unable to set mesh", SALOME::INTERNAL_ERROR);
251 void MULTIPR_Obj_i::setBoxing(CORBA::Long pBoxing)
252 throw (SALOME::SALOME_Exception)
254 if (mBoxing < 0) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be >= 1", SALOME::INTERNAL_ERROR);
255 if (mBoxing > 200) THROW_SALOME_CORBA_EXCEPTION("Invalid boxing parameter; should be <= 200", SALOME::INTERNAL_ERROR);
261 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getMeshes()
262 throw (SALOME::SALOME_Exception)
264 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
266 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
270 std::vector<std::string> listMeshes = mObj->getMeshes();
271 mySeq->length(listMeshes.size());
273 for (int i = 0 ; i < listMeshes.size() ; i++)
275 mySeq[i] = CORBA::string_dup(listMeshes[i].c_str());
278 catch (multipr::RuntimeException& e)
281 THROW_SALOME_CORBA_EXCEPTION("Unable to get meshes", SALOME::INTERNAL_ERROR);
284 return mySeq._retn();
288 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getFields()
289 throw (SALOME::SALOME_Exception)
291 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
293 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
297 std::vector<std::string> listFields = mObj->getFields();
298 mySeq->length(listFields.size());
300 for (int i = 0 ; i < listFields.size() ; i++)
302 mySeq[i] = CORBA::string_dup(listFields[i].c_str());
305 catch (multipr::RuntimeException& e)
308 THROW_SALOME_CORBA_EXCEPTION("Unable to get fields", SALOME::INTERNAL_ERROR);
311 return mySeq._retn();
315 CORBA::Long MULTIPR_Obj_i::getTimeStamps(const char* fieldName)
316 throw (SALOME::SALOME_Exception)
318 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
322 return mObj->getTimeStamps(fieldName);
324 catch (multipr::RuntimeException& e)
327 THROW_SALOME_CORBA_EXCEPTION("Unable to get time stamps", SALOME::INTERNAL_ERROR);
332 MULTIPR_ORB::string_array* MULTIPR_Obj_i::getParts()
333 throw (SALOME::SALOME_Exception)
335 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
337 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
341 std::vector<std::string> listParts = mObj->getParts();
342 mySeq->length(listParts.size());
344 for (int i = 0 ; i < listParts.size() ; i++)
346 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
349 catch (multipr::RuntimeException& e)
352 THROW_SALOME_CORBA_EXCEPTION("Unable to get parts", SALOME::INTERNAL_ERROR);
355 return mySeq._retn();
359 char* MULTIPR_Obj_i::getPartInfo(const char* pPartName)
360 throw (SALOME::SALOME_Exception)
362 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
364 return CORBA::string_dup(mObj->getPartInfo(pPartName).c_str());
368 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneDomaine()
369 throw (SALOME::SALOME_Exception)
371 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
373 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
377 std::vector<std::string> listParts = mObj->partitionneDomaine();
378 mySeq->length(listParts.size());
380 for (int i = 0 ; i < listParts.size() ; i++)
382 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
385 catch (multipr::RuntimeException& e)
388 THROW_SALOME_CORBA_EXCEPTION("Unable to partition mesh", SALOME::INTERNAL_ERROR);
391 return mySeq._retn();
395 MULTIPR_ORB::string_array* MULTIPR_Obj_i::partitionneGrain(
396 const char* pPartName,
397 CORBA::Long pNbParts,
398 CORBA::Long pPartitionner)
399 throw (SALOME::SALOME_Exception)
401 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
403 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
407 std::vector<std::string> listParts = mObj->partitionneGrain(
412 mySeq->length(listParts.size());
414 for (int i = 0 ; i < listParts.size() ; i++)
416 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
419 catch (multipr::RuntimeException& e)
422 THROW_SALOME_CORBA_EXCEPTION("Unable to partition group", SALOME::INTERNAL_ERROR);
425 return mySeq._retn();
429 MULTIPR_ORB::string_array* MULTIPR_Obj_i::decimePartition(
430 const char* pPartName,
431 const char* pFieldName,
432 CORBA::Long pFieldIt,
433 const char* pFilterName,
436 CORBA::Double pRadius)
437 throw (SALOME::SALOME_Exception)
439 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
441 MULTIPR_ORB::string_array_var mySeq = new MULTIPR_ORB::string_array();
445 std::vector<std::string> listParts = mObj->decimePartition(
455 mySeq->length(listParts.size());
457 for (int i = 0 ; i < listParts.size() ; i++)
459 mySeq[i] = CORBA::string_dup(listParts[i].c_str());
462 catch (multipr::RuntimeException& e)
465 THROW_SALOME_CORBA_EXCEPTION("Unable to decimate", SALOME::INTERNAL_ERROR);
468 return mySeq._retn();
472 char* MULTIPR_Obj_i::evalDecimationParams(
473 const char* pPartName,
474 const char* pFieldName,
475 CORBA::Long pFieldIt,
476 const char* pFilterName,
477 const char* pFilterParams)
478 throw (SALOME::SALOME_Exception)
480 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
484 string res = mObj->evalDecimationParams(
491 return CORBA::string_dup(res.c_str());
494 catch (multipr::RuntimeException& e)
497 THROW_SALOME_CORBA_EXCEPTION("Unable to evaluate decimation parameters", SALOME::INTERNAL_ERROR);
502 void MULTIPR_Obj_i::removeParts(const char* pPrefixPartName)
503 throw (SALOME::SALOME_Exception)
505 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
507 mObj->removeParts(pPrefixPartName);
511 void MULTIPR_Obj_i::save(const char* pPath)
512 throw (SALOME::SALOME_Exception)
514 if (mObj == NULL) THROW_SALOME_CORBA_EXCEPTION("No associated MED file", SALOME::INTERNAL_ERROR);
521 catch (multipr::RuntimeException& e)
524 THROW_SALOME_CORBA_EXCEPTION("Unable to save MED file", SALOME::INTERNAL_ERROR);
531 PortableServer::ObjectId* MULTIPREngine_factory(
533 PortableServer::POA_ptr poa,
534 PortableServer::ObjectId * contId,
535 const char* instanceName,
536 const char* interfaceName)
538 MESSAGE("PortableServer::ObjectId* MULTIPREngine_factory()");
539 SCRUTE(interfaceName);
540 MULTIPR_Gen_i* myMULTIPR = new MULTIPR_Gen_i(orb, poa, contId, instanceName, interfaceName);
541 return myMULTIPR->getId();