X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOM_I%2FGEOM_IBooleanOperations_i.cc;h=0a38cd145cc5fb2c9b3d4d8c793283e6ff982273;hb=89e60b0cd04dc7c92a7ffd545a3d83c23ac222f4;hp=cceef3727226aa55577f05f58f1f5ab3c65b82bf;hpb=392885c1a8d50369708bbe5e6b44033ed8b8ba51;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_IBooleanOperations_i.cc b/src/GEOM_I/GEOM_IBooleanOperations_i.cc index cceef3727..0a38cd145 100644 --- a/src/GEOM_I/GEOM_IBooleanOperations_i.cc +++ b/src/GEOM_I/GEOM_IBooleanOperations_i.cc @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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, or (at your option) any later version. // -// 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 // + #include #include "GEOM_IBooleanOperations_i.hh" @@ -37,8 +38,8 @@ */ //============================================================================= GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i (PortableServer::POA_ptr thePOA, - GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IBooleanOperations* theImpl) + GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IBooleanOperations* theImpl) :GEOM_IOperations_i(thePOA, theEngine, theImpl) { MESSAGE("GEOM_IBooleanOperations_i::GEOM_IBooleanOperations_i"); @@ -61,29 +62,57 @@ GEOM_IBooleanOperations_i::~GEOM_IBooleanOperations_i() */ //============================================================================= GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean - (GEOM::GEOM_Object_ptr theShape1, - GEOM::GEOM_Object_ptr theShape2, - CORBA::Long theOp) + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Long theOp, + CORBA::Boolean IsCheckSelfInte) { GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag GetOperations()->SetNotDone(); - if (theShape1 == NULL || theShape2 == NULL) return aGEOMObject._retn(); + //Get the reference shapes + Handle(::GEOM_Object) aSh1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aSh2 = GetObjectImpl(theShape2); + + if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn(); + + // Make Boolean + Handle(::GEOM_Object) anObject = + GetOperations()->MakeBoolean(aSh1, aSh2, theOp, IsCheckSelfInte); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeFuse + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuse + (GEOM::GEOM_Object_ptr theShape1, + GEOM::GEOM_Object_ptr theShape2, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); //Get the reference shapes - CORBA::String_var entry=theShape1->GetEntry(); - Handle(GEOM_Object) aSh1 = GetOperations()->GetEngine()->GetObject - (theShape1->GetStudyID(), entry); - entry=theShape2->GetEntry(); - Handle(GEOM_Object) aSh2 = GetOperations()->GetEngine()->GetObject - (theShape2->GetStudyID(), entry); + Handle(::GEOM_Object) aSh1 = GetObjectImpl(theShape1); + Handle(::GEOM_Object) aSh2 = GetObjectImpl(theShape2); if (aSh1.IsNull() || aSh2.IsNull()) return aGEOMObject._retn(); // Make Boolean - Handle(GEOM_Object) anObject = GetOperations()->MakeBoolean(aSh1, aSh2, theOp); + Handle(::GEOM_Object) anObject = GetOperations()->MakeFuse + (aSh1, aSh2, IsCheckSelfInte, IsRmExtraEdges); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -92,73 +121,139 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeBoolean //============================================================================= /*! - * MakePartition + * MakeFuseList */ //============================================================================= -GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition - (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, - CORBA::Short theKeepNonlimitShapes) +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeFuseList + (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte, + CORBA::Boolean IsRmExtraEdges) { 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; + Handle(TColStd_HSequenceOfTransient) aShapes = + GetListOfObjectsImpl(theShapes); - //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); + if (aShapes.IsNull()) { + return aGEOMObject._retn(); } - //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); + // Make fusion + Handle(::GEOM_Object) anObject = + GetOperations()->MakeFuseList(aShapes, IsCheckSelfInte, IsRmExtraEdges); + + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCommonList + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCommonList + (const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + Handle(TColStd_HSequenceOfTransient) aShapes = + GetListOfObjectsImpl(theShapes); + + if (aShapes.IsNull()) { + return aGEOMObject._retn(); + } + + // Make fusion + Handle(::GEOM_Object) anObject = + GetOperations()->MakeCommonList(aShapes, IsCheckSelfInte); + + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * MakeCutList + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeCutList + (GEOM::GEOM_Object_ptr theMainShape, + const GEOM::ListOfGO& theShapes, + CORBA::Boolean IsCheckSelfInte) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + Handle(::GEOM_Object) aMainShape = GetObjectImpl(theMainShape); + + if (aMainShape.IsNull()) { + return aGEOMObject._retn(); } - //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); + Handle(TColStd_HSequenceOfTransient) aShapes = + GetListOfObjectsImpl(theShapes); + + if (aShapes.IsNull()) { + return aGEOMObject._retn(); } - //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); + // Make fusion + Handle(::GEOM_Object) anObject = + GetOperations()->MakeCutList(aMainShape, aShapes, IsCheckSelfInte); + + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * 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, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + Handle(TColStd_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes); + Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools); + Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns); + Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns); + Handle(TColStd_HArray1OfInteger) aMaterials; + + if (aShapes.IsNull() || aTools.IsNull() || + aKeepIns.IsNull() || aRemIns.IsNull()) { + return aGEOMObject._retn(); } //Get the materials - aLen = theMaterials.length(); + int ind; + int aLen = theMaterials.length(); if ( aLen ) { aMaterials = new TColStd_HArray1OfInteger (1, aLen); for (ind = 0; ind < aLen; ind++) { @@ -167,11 +262,12 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition } // Make Partition - Handle(GEOM_Object) anObject = + Handle(::GEOM_Object) anObject = GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns, - theLimit, theRemoveWebs, aMaterials, - theKeepNonlimitShapes, - /*PerformSelfIntersections*/Standard_True); + theLimit, theRemoveWebs, aMaterials, + theKeepNonlimitShapes, + /*PerformSelfIntersections*/Standard_True, + /*IsCheckSelfInte*/Standard_False); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -185,68 +281,34 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartition //============================================================================= 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, - CORBA::Short theKeepNonlimitShapes) + const GEOM::ListOfGO& theTools, + const GEOM::ListOfGO& theKeepIns, + const GEOM::ListOfGO& theRemoveIns, + CORBA::Short theLimit, + CORBA::Boolean theRemoveWebs, + const GEOM::ListOfLong& theMaterials, + CORBA::Short theKeepNonlimitShapes, + CORBA::Boolean IsCheckSelfInte) { 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_HSequenceOfTransient) aShapes = GetListOfObjectsImpl(theShapes); + Handle(TColStd_HSequenceOfTransient) aTools = GetListOfObjectsImpl(theTools); + Handle(TColStd_HSequenceOfTransient) aKeepIns = GetListOfObjectsImpl(theKeepIns); + Handle(TColStd_HSequenceOfTransient) aRemIns = GetListOfObjectsImpl(theRemoveIns); 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); + if (aShapes.IsNull() || aTools.IsNull() || + aKeepIns.IsNull() || aRemIns.IsNull()) { + return aGEOMObject._retn(); } //Get the materials - aLen = theMaterials.length(); + int ind; + int aLen = theMaterials.length(); if ( aLen ) { aMaterials = new TColStd_HArray1OfInteger (1, aLen); for (ind = 0; ind < aLen; ind++) { @@ -255,11 +317,12 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected } // Make Partition - Handle(GEOM_Object) anObject = + Handle(::GEOM_Object) anObject = GetOperations()->MakePartition(aShapes, aTools, aKeepIns, aRemIns, - theLimit, theRemoveWebs, aMaterials, - theKeepNonlimitShapes, - /*PerformSelfIntersections*/Standard_False); + theLimit, theRemoveWebs, aMaterials, + theKeepNonlimitShapes, + /*PerformSelfIntersections*/Standard_False, + IsCheckSelfInte); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -273,25 +336,22 @@ GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakePartitionNonSelfIntersected //============================================================================= GEOM::GEOM_Object_ptr GEOM_IBooleanOperations_i::MakeHalfPartition (GEOM::GEOM_Object_ptr theShape, - GEOM::GEOM_Object_ptr thePlane) + GEOM::GEOM_Object_ptr thePlane) { GEOM::GEOM_Object_var aGEOMObject; //Set a not done flag GetOperations()->SetNotDone(); - if (theShape == NULL || thePlane == NULL) return aGEOMObject._retn(); - //Get the reference shapes - Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject - (theShape->GetStudyID(), theShape->GetEntry()); - Handle(GEOM_Object) aPl = GetOperations()->GetEngine()->GetObject - (thePlane->GetStudyID(), thePlane->GetEntry()); + Handle(::GEOM_Object) aSh = GetObjectImpl(theShape); + Handle(::GEOM_Object) aPl = GetObjectImpl(thePlane); if (aSh.IsNull() || aPl.IsNull()) return aGEOMObject._retn(); // Make Half Partition - Handle(GEOM_Object) anObject = GetOperations()->MakeHalfPartition(aSh, aPl); + Handle(::GEOM_Object) anObject = + GetOperations()->MakeHalfPartition(aSh, aPl); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();