Salome HOME
PAL13456 : change default values for Vertex Maker style and size.
[modules/geom.git] / src / GEOM_I / GEOM_IBooleanOperations_i.cc
index 56726b072f230ba5db61a3869bd19b577de20658..c7a594259d8ae63c97c649ad2ab0adc87ef9deff 100644 (file)
@@ -1,22 +1,23 @@
 // 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 
+// 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 
+//
+// 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 
+// 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_IBooleanOperations_i.hh"
@@ -57,7 +58,7 @@ GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i()
 /*!
  *  MakeBoolean
  */
-//============================================================================= 
+//=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
                                                  (GEOM::GEOM_Object_ptr theShape1,
                                                  GEOM::GEOM_Object_ptr theShape2,
@@ -90,14 +91,100 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean
 /*!
  *  MakePartition
  */
-//============================================================================= 
+//=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
                                       (const GEOM::ListOfGO&   theShapes,
                                       const GEOM::ListOfGO&   theTools,
                                       const GEOM::ListOfGO&   theKeepIns,
                                       const GEOM::ListOfGO&   theRemoveIns,
-                                      const CORBA::Short      theLimit,
-                                      const CORBA::Boolean    theRemoveWebs,
+                                      CORBA::Short            theLimit,
+                                      CORBA::Boolean          theRemoveWebs,
+                                      const GEOM::ListOfLong& theMaterials)
+{
+  GEOM::GEOM_Object_var aGEOMObject;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  int ind, aLen;
+  Handle(TColStd_HSequenceOfTransient) aShapes  = new TColStd_HSequenceOfTransient;
+  Handle(TColStd_HSequenceOfTransient) aTools   = new TColStd_HSequenceOfTransient;
+  Handle(TColStd_HSequenceOfTransient) aKeepIns = new TColStd_HSequenceOfTransient;
+  Handle(TColStd_HSequenceOfTransient) aRemIns  = new TColStd_HSequenceOfTransient;
+  Handle(TColStd_HArray1OfInteger) aMaterials;
+
+  //Get the shapes
+  aLen = theShapes.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theShapes[ind] == NULL) return aGEOMObject._retn();
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
+    if (aSh.IsNull()) return aGEOMObject._retn();
+    aShapes->Append(aSh);
+  }
+
+  //Get the tools
+  aLen = theTools.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theTools[ind] == NULL) return aGEOMObject._retn();
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theTools[ind]->GetStudyID(), theTools[ind]->GetEntry());
+    if (aSh.IsNull()) return aGEOMObject._retn();
+    aTools->Append(aSh);
+  }
+
+  //Get the keep inside shapes
+  aLen = theKeepIns.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theKeepIns[ind] == NULL) return aGEOMObject._retn();
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theKeepIns[ind]->GetStudyID(), theKeepIns[ind]->GetEntry());
+    if (aSh.IsNull()) return aGEOMObject._retn();
+    aKeepIns->Append(aSh);
+  }
+
+  //Get the remove inside shapes
+  aLen = theRemoveIns.length();
+  for (ind = 0; ind < aLen; ind++) {
+    if (theRemoveIns[ind] == NULL) return aGEOMObject._retn();
+    Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
+      (theRemoveIns[ind]->GetStudyID(), theRemoveIns[ind]->GetEntry());
+    if (aSh.IsNull()) return aGEOMObject._retn();
+    aRemIns->Append(aSh);
+  }
+
+  //Get the materials
+  aLen = theMaterials.length();
+  if ( aLen ) {
+    aMaterials = new TColStd_HArray1OfInteger (1, aLen);
+    for (ind = 0; ind < aLen; ind++) {
+      aMaterials->SetValue(ind+1, theMaterials[ind]);
+    }
+  }
+
+  // Make Partition
+  Handle(GEOM_Object) anObject =
+    GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
+                                  theLimit, theRemoveWebs, aMaterials,
+                                  /*PerformSelfIntersections*/Standard_True);
+  if (!GetOperations()->IsDone() || anObject.IsNull())
+    return aGEOMObject._retn();
+
+  return GetObject(anObject);
+}
+
+//=============================================================================
+/*!
+ *  MakePartitionNonSelfIntersectedShape
+ */
+//=============================================================================
+GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersectedShape
+                                      (const GEOM::ListOfGO&   theShapes,
+                                      const GEOM::ListOfGO&   theTools,
+                                      const GEOM::ListOfGO&   theKeepIns,
+                                      const GEOM::ListOfGO&   theRemoveIns,
+                                      CORBA::Short            theLimit,
+                                      CORBA::Boolean          theRemoveWebs,
                                       const GEOM::ListOfLong& theMaterials)
 {
   GEOM::GEOM_Object_var aGEOMObject;
@@ -164,7 +251,8 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
   // Make Partition
   Handle(GEOM_Object) anObject =
     GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns,
-                                  theLimit, theRemoveWebs, aMaterials);
+                                  theLimit, theRemoveWebs, aMaterials,
+                                  /*PerformSelfIntersections*/Standard_False);
   if (!GetOperations()->IsDone() || anObject.IsNull())
     return aGEOMObject._retn();
 
@@ -175,7 +263,7 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition
 /*!
  *  MakeHalfPartition
  */
-//============================================================================= 
+//=============================================================================
 GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition
                                                  (GEOM::GEOM_Object_ptr theShape,
                                                  GEOM::GEOM_Object_ptr thePlane)