Salome HOME
NPAL16559: EDF507: Implementation of a more advanced system of measurement.
[modules/geom.git] / src / GEOM_I / GEOM_IGroupOperations_i.cc
index 3ff5c9bb63aac078e1641152ce09829468f09d5c..e99524c98cb46379d9672be8085e1a3614824c28 100644 (file)
@@ -1,4 +1,23 @@
-using namespace std; 
+// Copyright (C) 2005  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include <Standard_Stream.hxx>
 
 #include "GEOM_IGroupOperations_i.hh"
 
@@ -104,6 +123,138 @@ void GEOM_IGroupOperations_i::RemoveObject(GEOM::GEOM_Object_ptr theGroup, CORBA
   return;
 }
 
+//=============================================================================
+/*!
+ *  UnionList
+ */
+//=============================================================================
+void GEOM_IGroupOperations_i::UnionList (GEOM::GEOM_Object_ptr theGroup,
+                                        const GEOM::ListOfGO& theSubShapes) 
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theGroup == NULL) return;
+
+  //Get the reference group
+  Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject
+    (theGroup->GetStudyID(), theGroup->GetEntry());
+  if (aGroupRef.IsNull()) return;
+
+  //Get sub-shape to add
+  Handle(TColStd_HSequenceOfTransient) aSubShapes = new TColStd_HSequenceOfTransient;
+
+  int ind, aLen = theSubShapes.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theSubShapes[ind] == NULL) return;
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theSubShapes[ind]->GetStudyID(), theSubShapes[ind]->GetEntry());
+    if (aSh.IsNull()) return;
+    aSubShapes->Append(aSh);
+  }
+
+  //Perform the operation
+  GetOperations()->UnionList(aGroupRef, aSubShapes);
+  return;
+}
+
+//=============================================================================
+/*!
+ *  DifferenceList
+ */
+//=============================================================================
+void GEOM_IGroupOperations_i::DifferenceList (GEOM::GEOM_Object_ptr theGroup,
+                                             const GEOM::ListOfGO& theSubShapes) 
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theGroup == NULL) return;
+
+  //Get the reference group
+  Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject
+    (theGroup->GetStudyID(), theGroup->GetEntry());
+  if (aGroupRef.IsNull()) return;
+
+  //Get sub-shape to remove
+  Handle(TColStd_HSequenceOfTransient) aSubShapes = new TColStd_HSequenceOfTransient;
+
+  int ind, aLen = theSubShapes.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theSubShapes[ind] == NULL) return;
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theSubShapes[ind]->GetStudyID(), theSubShapes[ind]->GetEntry());
+    if (aSh.IsNull()) return;
+    aSubShapes->Append(aSh);
+  }
+
+  //Perform the operation
+  GetOperations()->DifferenceList(aGroupRef, aSubShapes);
+  return;
+}
+
+//=============================================================================
+/*!
+ *  UnionIDs
+ */
+//=============================================================================
+void GEOM_IGroupOperations_i::UnionIDs (GEOM::GEOM_Object_ptr   theGroup,
+                                       const GEOM::ListOfLong& theSubShapes) 
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theGroup == NULL) return;
+
+  //Get the reference group
+  Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject
+    (theGroup->GetStudyID(), theGroup->GetEntry());
+  if (aGroupRef.IsNull()) return;
+
+  //Get sub-shape to add
+  Handle(TColStd_HSequenceOfInteger) aSubShapes = new TColStd_HSequenceOfInteger;
+
+  int ind, aLen = theSubShapes.length();
+  for (ind = 0; ind < aLen; ind++) {
+    aSubShapes->Append(theSubShapes[ind]);
+  }
+
+  //Perform the operation
+  GetOperations()->UnionIDs(aGroupRef, aSubShapes);
+  return;
+}
+
+//=============================================================================
+/*!
+ *  DifferenceIDs
+ */
+//=============================================================================
+void GEOM_IGroupOperations_i::DifferenceIDs (GEOM::GEOM_Object_ptr   theGroup,
+                                            const GEOM::ListOfLong& theSubShapes) 
+{
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  if (theGroup == NULL) return;
+
+  //Get the reference group
+  Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject
+    (theGroup->GetStudyID(), theGroup->GetEntry());
+  if (aGroupRef.IsNull()) return;
+
+  //Get sub-shape to remove
+  Handle(TColStd_HSequenceOfInteger) aSubShapes = new TColStd_HSequenceOfInteger;
+
+  int ind, aLen = theSubShapes.length();
+  for (ind = 0; ind < aLen; ind++) {
+    aSubShapes->Append(theSubShapes[ind]);
+  }
+
+  //Perform the operation
+  GetOperations()->DifferenceIDs(aGroupRef, aSubShapes);
+  return;
+}
+
 //=============================================================================
 /*!
  *  GetType