Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESH_I / SMESH_MEDMesh_i.cxx
index cfbea781a3c1db8d1154be8a7d15b10914170120..9ee46fda3c0c8b9b17b6e94f1e037aaed5c7c42c 100644 (file)
@@ -1,30 +1,28 @@
-//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
 //
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
 //  File   : SMESH_MEDMesh_i.cxx
 //  Module : SMESH
-
-using namespace std;
+//
 #include "SMESH_MEDMesh_i.hxx"
 #include "SMESH_Mesh_i.hxx"
 
@@ -54,11 +52,15 @@ using namespace std;
 
 # include "Utils_ORB_INIT.hxx"
 # include "Utils_SINGLETON.hxx"
+# include "Utils_ExceptHandlers.hxx"
+
 extern "C"
 {
 #include <stdio.h>
 }
 
+using namespace std;
+
 //=============================================================================
 /*!
  * Default constructor
@@ -86,13 +88,17 @@ SMESH_MEDMesh_i::~SMESH_MEDMesh_i()
  */
 //=============================================================================
 SMESH_MEDMesh_i::SMESH_MEDMesh_i(::SMESH_Mesh_i * m_i):_meshId(""),
-_compte(false),
-_creeFamily(false), _famIdent(0), _indexElts(0), _indexEnts(0)
+                                                      _compte(false),
+                                                      _creeFamily(false),
+                                                      _famIdent(0),
+                                                      _indexElts(0),
+                                                      _indexEnts(0)
 {
+       BEGIN_OF("Constructor SMESH_MEDMesh_i");
+
        _mesh_i = m_i;
        _meshDS = _mesh_i->GetImpl().GetMeshDS();
 
-       BEGIN_OF("Constructor SMESH_MEDMesh_i");
        END_OF("Constructor SMESH_MEDMesh_i");
 }
 
@@ -250,7 +256,7 @@ SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates(
                myseq->length(nbNodes * spaceDimension);
                int i = 0;
 
-               SMDS_Iterator<const SMDS_MeshNode *> * itNodes=_meshDS->nodesIterator();
+               SMDS_NodeIteratorPtr itNodes=_meshDS->nodesIterator();
                while(itNodes->more())
                {
                        const SMDS_MeshNode* node = itNodes->next();
@@ -276,7 +282,6 @@ SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates(
                        }
                        i++;
                }
-               delete itNodes;
        }
        catch(...)
        {
@@ -478,13 +483,14 @@ CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::
                if (_mapIndToSeqElts.find(geomElement) != _mapIndToSeqElts.end())
                {
                        int index = _mapIndToSeqElts[geomElement];
+
                        retour = _seq_elemId[index]->length();
                }
                return retour;
        }
        catch(...)
        {
-               MESSAGE("Exception en accedant au nombre d élements");
+               MESSAGE("Exception en accedant au nombre d élements");
                THROW_SALOME_CORBA_EXCEPTION("Unable to acces Mesh C++ Object",
                        SALOME::INTERNAL_ERROR);
        }
@@ -518,6 +524,7 @@ SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
                        SALOME::BAD_PARAM);
 
        int index = _mapIndToSeqElts[geomElement];
+
        return _seq_elemId[index]._retn();
 }
 
@@ -720,6 +727,22 @@ SMESH_MEDMesh_i::getBoundaryElements(SALOME_MED::medEntityMesh entity)
   return NULL;
 }
 //=============================================================================
+/*!
+ * CORBA:  Method return a reference on a support define on all the element of
+ *         an entity.
+ */
+//=============================================================================
+SALOME_MED::SUPPORT_ptr
+SMESH_MEDMesh_i::getSupportOnAll(SALOME_MED::medEntityMesh entity)
+  throw (SALOME::SALOME_Exception)
+{
+  MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
+
+  THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
+
+  return NULL;
+}
+//=============================================================================
 /*!
  * CORBA: Returns references for the support of the skin of the support
  * mySupport3D
@@ -855,8 +878,8 @@ void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
         * 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);
-        * //myBuilder->AddAttribute(newObj,SALOMEDS::IOR,iorStr.c_str());
+        * CORBA::String_var iorStr = orb->object_to_string(myIor);
+        * //myBuilder->AddAttribute(newObj,SALOMEDS::IOR,iorStr.in());
         * SALOMEDS::AttributeIOR_var aIOR = SALOMEDS::AttributeIOR::_narrow(
         * myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"));
         * aIOR->SetValue(iorStr.c_str());
@@ -943,7 +966,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                int trouveSeg3 = 0;
                SALOME_MED::medGeometryElement medElement;
 
-               SMDS_Iterator<const SMDS_MeshEdge*> * itEdges=_meshDS->edgesIterator();
+               SMDS_EdgeIteratorPtr itEdges=_meshDS->edgesIterator();
                while(itEdges->more())
                {
                        const SMDS_MeshEdge* elem = itEdges->next();
@@ -977,16 +1000,15 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        int index = _mapIndToSeqElts[medElement];
                        SCRUTE(index);
                        // Traitement de l arete
+
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
 
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                }
-               delete itEdges;
 
                _mapNbTypes[SALOME_MED::MED_EDGE] = trouveSeg2 + trouveSeg3;
 
@@ -1001,7 +1023,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                _mapIndToSeqElts[SALOME_MED::MED_QUAD4] = _indexElts++;
                _mapIndToVectTypes[SALOME_MED::MED_FACE] = _indexEnts++;
 
-               SMDS_Iterator<const SMDS_MeshFace*> * itFaces=_meshDS->facesIterator();
+               SMDS_FaceIteratorPtr itFaces=_meshDS->facesIterator();
                while(itFaces->more())
                {
                        const SMDS_MeshFace * elem = itFaces->next();
@@ -1047,18 +1069,16 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        SCRUTE(index);
 
                        // Traitement de la face
-                       // Attention La numérotation des noeuds Med commence a 1
+                       // Attention La numérotation des noeuds Med commence a 1
 
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
 
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                } //itFaces
-               delete itFaces;
 
                _mapNbTypes[SALOME_MED::MED_FACE] =
                        trouveTria3 + trouveTria6 + trouveQuad4;
@@ -1069,14 +1089,14 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
 
                int trouveHexa8 = 0;
 
-               SMDS_Iterator<const SMDS_MeshVolume*> * itVolumes=_meshDS->volumesIterator();
+               SMDS_VolumeIteratorPtr itVolumes=_meshDS->volumesIterator();
                while(itVolumes->more())
                {
                        const SMDS_MeshVolume * elem = itVolumes->next();
 
                        int nb_of_nodes = elem->NbNodes();
                        medElement = SALOME_MED::MED_HEXA8;
-                       ASSERT(nb_of_nodes = 8);
+                       ASSERT(nb_of_nodes == 8);
 
                        if (trouveHexa8 == 0)
                        {
@@ -1087,12 +1107,10 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
                        int longueur = _seq_elemId[index]->length();
                        _seq_elemId[index]->length(longueur + nb_of_nodes);
 
-                       SMDS_Iterator<const SMDS_MeshNode*> * itn=_meshDS->nodesIterator();
+                       SMDS_NodeIteratorPtr itn=_meshDS->nodesIterator();
                        for(int k=0; itn->more(); k++)
                                _seq_elemId[index][longueur + k] = itn->next()->GetID()+1;
-                       delete itn;
                }
-               delete itVolumes;
 
                _mapNbTypes[SALOME_MED::MED_CELL] = trouveHexa8;
                _mapNbTypes[SALOME_MED::MED_ALL_ENTITIES]
@@ -1109,6 +1127,7 @@ void SMESH_MEDMesh_i::calculeNbElts() throw(SALOME::SALOME_Exception)
 //=============================================================================
 void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
 {
+  Unexpect aCatch(SALOME_SalomeException);
        string famDes = ("Je ne sais pas");
        string famName0 = "Famille_";
        string famName;
@@ -1117,7 +1136,7 @@ void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
        if (_creeFamily == false)
        {
                _creeFamily = true;
-               SMESH_subMesh_i *subMeshServant;
+               //SMESH_subMesh_i *subMeshServant;
 
                map < int, SMESH_subMesh_i * >::iterator it;
                for (it = _mesh_i->_mapSubMesh_i.begin();
@@ -1133,9 +1152,15 @@ void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
                        SMESH_MEDFamily_i *famservant =
                                new SMESH_MEDFamily_i(famIdent, submesh_i,
                                famName, famDes, SALOME_MED::MED_NODE);
-                       SALOME_MED::FAMILY_ptr famille =
-                               SALOME_MED::FAMILY::_narrow(famservant->
-                               POA_SALOME_MED::FAMILY::_this());
+#ifdef WNT
+      SALOME_MED::FAMILY_ptr famille = SALOME_MED::FAMILY::_nil();
+      POA_SALOME_MED::FAMILY* servantbase = dynamic_cast<POA_SALOME_MED::FAMILY*>(famservant);
+      if ( servantbase )
+        famille = SALOME_MED::FAMILY::_narrow( servantbase->_this() );
+#else 
+               SALOME_MED::FAMILY_ptr famille = 
+        SALOME_MED::FAMILY::_narrow( famservant->POA_SALOME_MED::FAMILY::_this() );
+#endif
                        _families.push_back(famille);
                }
        }
@@ -1198,5 +1223,5 @@ SMESH_MEDMesh_i::getElementType(SALOME_MED::medEntityMesh entity,
 
   THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
 
-  return 0;
+  return (SALOME_MED::medGeometryElement) 0;
 }