Salome HOME
PR: synchro V6_main tag mergeto_V7_main_11Feb13
[modules/smesh.git] / src / SMESH_I / SMESH_MEDMesh_i.cxx
index b1b093770f8655c4dc95e7f2c125315f279cda88..ffde0e00fc947bb2e67e274f169807970f89b81d 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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-2007  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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
@@ -31,6 +31,9 @@
 #include "SMESHDS_Mesh.hxx"
 #include "SMESHDS_SubMesh.hxx"
 
+#include "SMESH_MEDSupport_i.hxx"
+#include "SMESH_MEDFamily_i.hxx"
+
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_MapOfShape.hxx>
 
-#include "utilities.h"
-#include "Utils_CorbaException.hxx"
-
-#include "SMESH_MEDSupport_i.hxx"
-#include "SMESH_MEDFamily_i.hxx"
+#include <utilities.h>
+#include <Utils_CorbaException.hxx>
 
-# include "Utils_ORB_INIT.hxx"
-# include "Utils_SINGLETON.hxx"
-# include "Utils_ExceptHandlers.hxx"
+#include <Utils_ORB_INIT.hxx>
+#include <Utils_SINGLETON.hxx>
+#include <Utils_ExceptHandlers.hxx>
+#include <SALOMEDS_wrap.hxx>
 
 extern "C"
 {
@@ -119,11 +120,12 @@ char *SMESH_MEDMesh_i::getName() throw(SALOME::SALOME_Exception)
   {
     SMESH_Gen_i*             gen = SMESH_Gen_i::GetSMESHGen();
     SALOMEDS::Study_var    study = gen->GetCurrentStudy();
-    SALOMEDS::SObject_var meshSO = gen->ObjectToSObject( study, _mesh_i->_this());
+    SALOMEDS::SObject_wrap meshSO = gen->ObjectToSObject( study, _mesh_i->_this());
     if ( meshSO->_is_nil() )
       return CORBA::string_dup("toto");
 
     CORBA::String_var name = meshSO->GetName();
+
     return CORBA::string_dup( name.in() );
   }
   catch(...)
@@ -248,13 +250,13 @@ char *SMESH_MEDMesh_i::getCoordinatesSystem() throw(SALOME::SALOME_Exception)
  * CORBA: Accessor for Coordinates
  */
 //=============================================================================
-SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates
+SALOME_TYPES::ListOfDouble * SMESH_MEDMesh_i::getCoordinates
 (SALOME_MED::medModeSwitch typeSwitch) throw(SALOME::SALOME_Exception)
 {
   if (_mesh_i == 0)
     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
                                  SALOME::INTERNAL_ERROR);
-  SALOME_MED::double_array_var myseq = new SALOME_MED::double_array;
+  SALOME_TYPES::ListOfDouble_var myseq = new SALOME_TYPES::ListOfDouble;
   try
   {
     // PN  : En dur
@@ -305,13 +307,13 @@ SALOME_MED::double_array * SMESH_MEDMesh_i::getCoordinates
  * CORBA: Accessor for Coordinates Names
  */
 //=============================================================================
-SALOME_MED::string_array *
+SALOME_TYPES::ListOfString *
 SMESH_MEDMesh_i::getCoordinatesNames()throw(SALOME::SALOME_Exception)
 {
   if (_mesh_i == 0)
     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
                                  SALOME::INTERNAL_ERROR);
-  SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
+  SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
   try
   {
     // PN : en dur
@@ -336,13 +338,13 @@ SMESH_MEDMesh_i::getCoordinatesNames()throw(SALOME::SALOME_Exception)
  * CORBA: Accessor for Coordinates Units
  */
 //=============================================================================
-SALOME_MED::string_array *
+SALOME_TYPES::ListOfString *
 SMESH_MEDMesh_i::getCoordinatesUnits()throw(SALOME::SALOME_Exception)
 {
   if (_mesh_i == 0)
     THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",
                                  SALOME::INTERNAL_ERROR);
-  SALOME_MED::string_array_var myseq = new SALOME_MED::string_array;
+  SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString;
   try
   {
     // PN : en dur
@@ -509,9 +511,8 @@ CORBA::Long SMESH_MEDMesh_i::getNumberOfElements(SALOME_MED::
  * CORBA: Accessor for connectivities
  */
 //=============================================================================
-SALOME_MED::long_array *
-SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
-                                 SALOME_MED::medConnectivity mode,
+SALOME_TYPES::ListOfLong *
+SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medConnectivity mode,
                                  SALOME_MED::medEntityMesh entity,
                                  SALOME_MED::medGeometryElement geomElement)
   throw(SALOME::SALOME_Exception)
@@ -521,8 +522,8 @@ SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
                                  SALOME::INTERNAL_ERROR);
   if (mode != SALOME_MED::MED_NODAL)
     THROW_SALOME_CORBA_EXCEPTION("Not Implemented", SALOME::BAD_PARAM);
-  if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
-    THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented", SALOME::BAD_PARAM);
+  /*if (typeSwitch == SALOME_MED::MED_NO_INTERLACE)
+    THROW_SALOME_CORBA_EXCEPTION("Not Yet Implemented", SALOME::BAD_PARAM);*/
   if (!_compte)
     calculeNbElts();
 
@@ -541,7 +542,7 @@ SMESH_MEDMesh_i::getConnectivity(SALOME_MED::medModeSwitch typeSwitch,
  * CORBA: Accessor for connectivities
  */
 //=============================================================================
-SALOME_MED::long_array *
+SALOME_TYPES::ListOfLong *
 SMESH_MEDMesh_i::getConnectivityIndex(SALOME_MED::medConnectivity mode,
                                       SALOME_MED::medEntityMesh entity)
   throw(SALOME::SALOME_Exception)
@@ -560,7 +561,7 @@ CORBA::Long
 SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
                                   SALOME_MED::medEntityMesh entity,
                                   SALOME_MED::medGeometryElement type,
-                                  const SALOME_MED::long_array & connectivity)
+                                  const SALOME_TYPES::ListOfLong & connectivity)
   throw(SALOME::SALOME_Exception)
 {
   const char *LOC = "getElementNumber ";
@@ -575,7 +576,7 @@ SMESH_MEDMesh_i::getElementNumber(SALOME_MED::medConnectivity mode,
  * not implemented for MED_ALL_ENTITIES and MED_MAILLE
  */
 //=============================================================================
-SALOME_MED::long_array *
+SALOME_TYPES::ListOfLong *
 SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::
                                         medConnectivity mode) throw(SALOME::SALOME_Exception)
 {
@@ -589,7 +590,7 @@ SMESH_MEDMesh_i::getReverseConnectivity(SALOME_MED::
  * CORBA: Accessor for connectivities
  */
 //=============================================================================
-SALOME_MED::long_array *
+SALOME_TYPES::ListOfLong *
 SMESH_MEDMesh_i::getReverseConnectivityIndex(SALOME_MED::
                                              medConnectivity mode) throw(SALOME::SALOME_Exception)
 {
@@ -708,7 +709,7 @@ SALOME_MED::GROUP_ptr SMESH_MEDMesh_i::getGroup(SALOME_MED::
  * CORBA: Returns references for the global numbering index
  */
 //=============================================================================
-SALOME_MED::long_array*
+SALOME_TYPES::ListOfLong*
 SMESH_MEDMesh_i::getGlobalNumberingIndex(SALOME_MED::medEntityMesh entity)
   throw (SALOME::SALOME_Exception)
 {
@@ -851,56 +852,14 @@ SALOME_MED::FIELD_ptr SMESH_MEDMesh_i::getNeighbourhood(SALOME_MED::
  */
 //=============================================================================
 void SMESH_MEDMesh_i::addInStudy(SALOMEDS::Study_ptr myStudy,
-                                 SALOME_MED::MESH_ptr myIor) throw(SALOME::SALOME_Exception)
+                                 SALOME_MED::GMESH_ptr myIor) throw(SALOME::SALOME_Exception)
 {
   BEGIN_OF("MED_Mesh_i::addInStudy");
   if (_meshId != "")
   {
     MESSAGE("Mesh already in Study");
-    THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study",
-                                 SALOME::BAD_PARAM);
-  };
-
-  /*
-   * SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder();
-   * 
-   * // Create SComponent labelled 'MED' if it doesn't already exit
-   * SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED");
-   * if ( CORBA::is_nil(medfather) ) 
-   * {
-   * MESSAGE("Add Component MED");
-   * medfather = myBuilder->NewComponent("MED");
-   * //myBuilder->AddAttribute (medfather,SALOMEDS::Name,"MED");
-   * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
-   * myBuilder->FindOrCreateAttribute(medfather, "AttributeName"));
-   * aName->SetValue("MED");
-   * 
-   * myBuilder->DefineComponentInstance(medfather,myIor);
-   * 
-   * } ;
-   * 
-   * MESSAGE("Add a mesh Object under MED");
-   * myBuilder->NewCommand();
-   * SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather);
-   * 
-   * ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
-   * ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
-   * CORBA::ORB_var &orb = init(0,0);
-   * 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());
-   * 
-   * //myBuilder->AddAttribute(newObj,SALOMEDS::Name,_mesh_i->getName().c_str());
-   * SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(
-   * myBuilder->FindOrCreateAttribute(newObj, "AttributeName"));
-   * aName->SetValue(_mesh_i->getName().c_str());
-   * 
-   * _meshId = newObj->GetID();
-   * myBuilder->CommitCommand();
-   * 
-   */
+    THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", SALOME::BAD_PARAM);
+  }
   END_OF("Mesh_i::addInStudy(SALOMEDS::Study_ptr myStudy)");
 }
 
@@ -1178,7 +1137,7 @@ void SMESH_MEDMesh_i::createFamilies() throw(SALOME::SALOME_Exception)
  * Gives informations of the considered mesh.
  */
 //=============================================================================
-SALOME_MED::MESH::meshInfos * SMESH_MEDMesh_i::getMeshGlobal()
+SALOME_MED::GMESH::meshInfos * SMESH_MEDMesh_i::getMeshGlobal()
   throw (SALOME::SALOME_Exception)
 {
   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
@@ -1187,12 +1146,28 @@ SALOME_MED::MESH::meshInfos * SMESH_MEDMesh_i::getMeshGlobal()
 
   return NULL;
 }
+
+//================================================================================
+/*!
+ * \brief Converts this GMESH into MESH
+ */
+//================================================================================
+
+SALOME_MED::MESH_ptr SMESH_MEDMesh_i::convertInMESH() throw (SALOME::SALOME_Exception)
+{
+  MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");
+
+  THROW_SALOME_CORBA_EXCEPTION("Unimplemented Method", SALOME::BAD_PARAM);
+
+  return NULL;
+}
+
 //=============================================================================
 /*!
  * Gives informations on coordinates of the considered mesh.
  */
 //=============================================================================
-SALOME_MED::MESH::coordinateInfos * SMESH_MEDMesh_i::getCoordGlobal()
+SALOME_MED::GMESH::coordinateInfos * SMESH_MEDMesh_i::getCoordGlobal()
   throw (SALOME::SALOME_Exception)
 {
   MESSAGE("!!!! NOT YET IMPLEMENTED !!!!!");