#include "MEDMEM_define.hxx"
#include "MEDMEM_Support.hxx"
+#include "MEDMEM_Mesh.hxx"
#include "MEDMEM_Support_i.hxx"
#include "MEDMEM_Mesh_i.hxx"
//=============================================================================
SALOME_MED::SUPPORT::supportInfos * SUPPORT_i::getSupportGlobal()
-throw (SALOME::SALOME_Exception)
+ throw (SALOME::SALOME_Exception)
{
- if (_support==NULL)
- THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
- SALOME::INTERNAL_ERROR);
- SALOME_MED::SUPPORT::supportInfos_var all = new SALOME_MED::SUPPORT::supportInfos;
- try
- {
- all->name = CORBA::string_dup(_support->getName().c_str());
- all->description = CORBA::string_dup(_support->getDescription().c_str());
- const int numberOfTypes = _support->getNumberOfTypes();
- all->numberOfGeometricType = numberOfTypes;
- all->entity = _support->getEntity();
- all->isOnAllElements = _support->isOnAllElements();
- all->types.length(numberOfTypes);
- all->nbEltTypes.length(numberOfTypes);
- const medGeometryElement * elemts = _support->getTypes();
- for (int i=0;i<numberOfTypes;i++)
- {
- all->types[i] = convertMedEltToIdlElt(elemts[i]);
- all->nbEltTypes[i] = _support->getNumberOfElements(elemts[i]);
- }
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::SUPPORT::supportInfos_var all = new SALOME_MED::SUPPORT::supportInfos;
+ try
+ {
+ all->name = CORBA::string_dup(_support->getName().c_str());
+ all->description = CORBA::string_dup(_support->getDescription().c_str());
+ const int numberOfTypes = _support->getNumberOfTypes();
+ all->numberOfGeometricType = numberOfTypes;
+ all->entity = _support->getEntity();
+ all->isOnAllElements = _support->isOnAllElements();
+ all->types.length(numberOfTypes);
+ all->nbEltTypes.length(numberOfTypes);
+ all->nodalConnectivityLength.length(numberOfTypes);
+ const medGeometryElement * types = _support->getTypes();
+ for (int i=0;i<numberOfTypes;i++)
+ {
+ int nbelements = _support->getNumberOfElements(types[i]);
+ int connLength = 0;
+ MESH* mesh = _support->getMesh();
+ switch ( types[i] )
+ {
+ case MED_EN::MED_POLYGON: {
+ if (_support->isOnAllElements() ) {
+ connLength = mesh->getPolygonsConnectivityLength(MED_EN::MED_NODAL,
+ _support->getEntity());
}
- catch (MEDEXCEPTION &ex)
- {
- MESSAGE("Unable to access the description of the support ");
- THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ else {
+ const int * index = mesh->getPolygonsConnectivityIndex(MED_EN::MED_NODAL,
+ _support->getEntity());
+ const int * numbers=_support->getNumber(types[i]);
+ int canonicNb = mesh->getNumberOfElements(_support->getEntity(),
+ MED_EN::MED_ALL_ELEMENTS);
+ for (int j=0;j<nbelements;j++)
+ {
+ int elem = numbers[j]-canonicNb-1;
+ connLength += index[ elem+1 ] - index[ elem ];
+ }
+ }
+ break;
+ }
+ case MED_EN::MED_POLYHEDRA: {
+ if (_support->isOnAllElements() ) {
+ connLength = mesh->getPolyhedronConnectivityLength(MED_EN::MED_NODAL);
}
- return all._retn();
+ else {
+ const int * index = mesh->getPolyhedronIndex(MED_EN::MED_NODAL);
+ const int * faceIndex = mesh->getPolyhedronFacesIndex();
+ const int * numbers=_support->getNumber(types[i]);
+ int canonicNb = mesh->getNumberOfElements(_support->getEntity(),
+ MED_EN::MED_ALL_ELEMENTS);
+ for (int j=0;j<nbelements;j++)
+ {
+ int elem = numbers[j]-canonicNb-1 ;
+ int f1 = index[ elem ]-1, f2 = index[ elem+1 ]-2;
+ int i1 = faceIndex[ f1 ]-1, i2 = faceIndex[ f2+1 ]-1;
+ connLength += i2 - i1;
+ }
+ }
+ break;
+ }
+ default:
+ connLength = nbelements * ( types[i] % 100 );
+ }
+ all->types[i] = convertMedEltToIdlElt(types[i]);
+ all->nbEltTypes[i] = nbelements;
+ all->nodalConnectivityLength[i] = connLength;
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to access the description of the support ");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return all._retn();
}
SCRUTE(mesh) ;
MESH_i * m1 = new MESH_i(mesh);
- SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this();
+ SALOME_MED::MESH_ptr m2 = m1->_this();
MESSAGE("SALOME_MED::MESH_ptr SUPPORT_i::getMesh() checking des pointeurs CORBA");
SCRUTE(m1);
}
+//=============================================================================
+/*!
+ * CORBA: get Nodes from file
+ */
+//=============================================================================
+SALOME_MED::long_array * SUPPORT_i::getNumberFromFile(SALOME_MED::medGeometryElement geomElement)
+throw (SALOME::SALOME_Exception)
+{
+ SCRUTE(_support);
+ SCRUTE(geomElement);
+ SCRUTE(convertIdlEltToMedElt(geomElement));
+
+ if (_support==NULL)
+ THROW_SALOME_CORBA_EXCEPTION("No associated Support", \
+ SALOME::INTERNAL_ERROR);
+ SALOME_MED::long_array_var myseq= new SALOME_MED::long_array;
+ try
+ {
+ int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement));
+ myseq->length(nbelements);
+SCRUTE(_support->getName());
+SCRUTE(nbelements);
+SCRUTE(convertIdlEltToMedElt(geomElement));
+ const int * numbers=_support->getNumberFromFile(convertIdlEltToMedElt(geomElement));
+ for (int i=0;i<nbelements;i++)
+ {
+ myseq[i]=numbers[i];
+SCRUTE(numbers[i]);
+ }
+ }
+ catch (MEDEXCEPTION &ex)
+ {
+ MESSAGE("Unable to access the support optionnal index");
+ THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR);
+ }
+ return myseq._retn();
+
+}
+
//=============================================================================
/*!
* CORBA: 2nd get Nodes
{
(const_cast< ::SUPPORT *>(_support))->getBoundaryElements();
}
- catch (MEDEXCEPTION &ex)
+ catch (MEDEXCEPTION &)
{
MESSAGE("Unable to access elements");
THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\
,SALOME::INTERNAL_ERROR);
}
}
-
//=============================================================================
/*!
* CORBA: add the Support in the StudyManager
}
MESSAGE(LOC << " Find SObject MESH (represent mesh in support)");
- string meshName = getMesh()->getName() ;
+ string meshName = _support->getMesh()->getName() ;
string meshNameStudy = meshName;
for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR);
// perhaps add MESH automatically ?
- MESSAGE("Add a support Object under /MED/MESH/MESHNAME");
+ MESSAGE("Add a support Object under /Med/MESH/MESHNAME");
char * medsupfatherName;
int lenName = 15 + strlen(meshName.c_str()) + 1;
//myBuilder->NewCommand();
- string supportName = _support->getName();
-
- SCRUTE(supportName);
-
- SCRUTE(meshNameStudy);
+ string supportEntryPath = getEntryPath( _support );
- char * supportEntryPath;
- lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str())+1;
- supportEntryPath = new char[lenName];
- supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/");
- supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_");
- supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str());
- supportEntryPath = strcat(supportEntryPath,"/");
- supportEntryPath = strcat(supportEntryPath,supportName.c_str());
+ SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str());
- //SCRUTE(supportEntryPath);
- MESSAGE("supportEntryPath in support " << supportEntryPath << " length " << lenName);
-
-// SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str());
- // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!!
- SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath);
if ( CORBA::is_nil(supportEntry) )
{
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
CORBA::ORB_var &orb = init(0,0);
- string iorStr = orb->object_to_string(myIor);
+ CORBA::String_var iorStr = orb->object_to_string(myIor);
anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- aIOR->SetValue(iorStr.c_str());
+ aIOR->SetValue(iorStr.in());
anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName");
aName = SALOMEDS::AttributeName::_narrow(anAttr);
aName->SetValue(_support->getName().c_str());
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
CORBA::ORB_var &orb = init(0,0);
- string iorStr = orb->object_to_string(myIor);
+ CORBA::String_var iorStr = orb->object_to_string(myIor);
anAttr = myBuilder->FindOrCreateAttribute(supportEntry, "AttributeIOR");
aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- aIOR->SetValue(iorStr.c_str());
+ aIOR->SetValue(iorStr.in());
}
myBuilder->CommitCommand();
- SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath);
+ SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str());
MESSAGE("Just for checking, reuse of the corba pointer");
}
delete [] medsupfatherName;
- delete [] supportEntryPath;
+
// register the Corba pointer: increase the referrence count
MESSAGE("Registering of the Corba Support pointer");
END_OF(LOC);
}
+
+//=======================================================================
+//function : getEntryPath
+//purpose :
+//=======================================================================
+
+string SUPPORT_i::getEntryPath(const ::MEDMEM::SUPPORT * aSupport)
+{
+ string meshNameStudy( aSupport->getMeshName() );
+ for (string::size_type pos=0; pos<meshNameStudy.size();++pos)
+ if (isspace(meshNameStudy[pos])) meshNameStudy[pos] = '_';
+
+ string supportName = aSupport->getName();
+ string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() ));
+ string supportEntryPath =
+ "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy;
+ SCRUTE( supportEntryPath );
+
+ return supportEntryPath;
+}