Salome HOME
Mantis issue 0021565: [CEA 557] Opposite of the pipe
[modules/geom.git] / src / GEOM_I / GEOM_Gen_i.cc
index 2c869cbffe330c24a1b99891b87b588dd82e3178..3dec744598d0d66bea80c39edcbf6df1f18dc184 100644 (file)
@@ -1,23 +1,24 @@
-//  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
 
 #ifdef WNT
 #pragma warning( disable:4786 )
@@ -27,6 +28,7 @@
 
 #include "GEOM_Gen_i.hh"
 #include "GEOM_Object_i.hh"
+#include "GEOM_version.h"
 
 #include <set>
 #include <sstream>
@@ -344,7 +346,7 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
   aFather->UnRegister();
 
   //Set a name of the GEOM object
-  aShape->SetName(theName);
+  aShape->SetName(aShapeName.ToCString());
 
   return aResultSO._retn();
 }
@@ -752,12 +754,16 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::AddInStudy (SALOMEDS::Study_ptr theStudy,
   if(aLength < 1) return aResultSO._retn();
 
   //Publish the arguments
+  TCollection_AsciiString aPrevID; // to avoid multiple references to same object
   for(Standard_Integer i = 0; i< aLength; i++) {
     GEOM::GEOM_Object_var anObject = aList[i];
     if(anObject->_is_nil()) continue;
     IOR = _orb->object_to_string(anObject);
     SALOMEDS::SObject_var aSO =  theStudy->FindObjectIOR(IOR.in());
     if(aSO->_is_nil()) continue;
+    CORBA::String_var anID = aSO->GetID();
+    if ( aPrevID == anID.in() ) continue;
+    aPrevID = anID.in();
     SALOMEDS::SObject_var aSubSO = aStudyBuilder->NewObject(aResultSO);
     aStudyBuilder->Addreference(aSubSO, aSO);
     aSO->UnRegister();
@@ -2308,13 +2314,13 @@ GEOM::GEOM_Object_ptr GEOM_Gen_i::AddSubShape (GEOM::GEOM_Object_ptr theMainShap
   if (CORBA::is_nil(theMainShape) || theIndices.length() < 1)
     return GEOM::GEOM_Object::_nil();
   CORBA::String_var entry = theMainShape->GetEntry();
-  Handle(GEOM_Object) aMainsShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
-  if (aMainsShape.IsNull()) return GEOM::GEOM_Object::_nil();
+  Handle(GEOM_Object) aMainShape = _impl->GetObject(theMainShape->GetStudyID(), entry);
+  if (aMainShape.IsNull()) return GEOM::GEOM_Object::_nil();
 
   Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theIndices.length());
   for(Standard_Integer i = 0; i<theIndices.length(); i++) anArray->SetValue(i+1, theIndices[i]);
 
-  Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainsShape, anArray, true);
+  Handle(GEOM_Object) anObject = _impl->AddSubShape(aMainShape, anArray, true);
   if(anObject.IsNull()) return GEOM::GEOM_Object::_nil();
 
   TCollection_AsciiString anEntry;
@@ -2546,6 +2552,16 @@ char* GEOM_Gen_i::getObjectInfo(CORBA::Long studyId, const char* entry)
   return ret;
 }
 
+// Version information
+char* GEOM_Gen_i::getVersion()
+{
+#if GEOM_DEVELOPMENT
+  return CORBA::string_dup(GEOM_VERSION_STR"dev");
+#else
+  return CORBA::string_dup(GEOM_VERSION_STR);
+#endif
+}
+
 //=====================================================================================
 // EXPORTED METHODS
 //=====================================================================================