X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGEOM_I%2FGEOM_IGroupOperations_i.cc;h=e18b88f8b3251b5ceb478483cad8cea4fe4d079d;hb=9f730900596e9412f431c23b2bd985063814a750;hp=3a8cef597d2d833c0ae93d92d2682e1c2c1cd1aa;hpb=73555c78ebf12a1fdb85157b8e7934ad566ae90a;p=modules%2Fgeom.git diff --git a/src/GEOM_I/GEOM_IGroupOperations_i.cc b/src/GEOM_I/GEOM_IGroupOperations_i.cc index 3a8cef597..e18b88f8b 100644 --- a/src/GEOM_I/GEOM_IGroupOperations_i.cc +++ b/src/GEOM_I/GEOM_IGroupOperations_i.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 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 @@ -6,7 +6,7 @@ // 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. +// 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 @@ -74,11 +74,11 @@ GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CreateGroup(GEOM::GEOM_Object_ptr if (theShapeType < 0) return aGEOMObject._retn(); //Get the reference shape - Handle(GEOM_Object) aShapeRef = GetObjectImpl(theMainShape); + Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theMainShape); if (aShapeRef.IsNull()) return aGEOMObject._retn(); //Create the Fillet - Handle(GEOM_Object) anObject = GetOperations()->CreateGroup(aShapeRef, (TopAbs_ShapeEnum)theShapeType); + Handle(::GEOM_Object) anObject = GetOperations()->CreateGroup(aShapeRef, (TopAbs_ShapeEnum)theShapeType); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); @@ -96,10 +96,13 @@ void GEOM_IGroupOperations_i::AddObject(GEOM::GEOM_Object_ptr theGroup, CORBA::L GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; GetOperations()->AddObject(aGroupRef, theSubShapeId); + + // Update GUI. + UpdateGUIForObject(theGroup); } //============================================================================= @@ -113,10 +116,13 @@ void GEOM_IGroupOperations_i::RemoveObject(GEOM::GEOM_Object_ptr theGroup, CORBA GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; GetOperations()->RemoveObject(aGroupRef, theSubShapeId); + + // Update GUI. + UpdateGUIForObject(theGroup); } //============================================================================= @@ -131,7 +137,7 @@ void GEOM_IGroupOperations_i::UnionList (GEOM::GEOM_Object_ptr theGroup, GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; //Get sub-shape to add @@ -139,7 +145,7 @@ void GEOM_IGroupOperations_i::UnionList (GEOM::GEOM_Object_ptr theGroup, int ind, aLen = theSubShapes.length(); for (ind = 0; ind < aLen; ind++) { - Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]); + Handle(::GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]); if (aSh.IsNull()) return; aSubShapes->Append(aSh); } @@ -160,7 +166,7 @@ void GEOM_IGroupOperations_i::DifferenceList (GEOM::GEOM_Object_ptr theGroup, GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; //Get sub-shape to remove @@ -168,7 +174,7 @@ void GEOM_IGroupOperations_i::DifferenceList (GEOM::GEOM_Object_ptr theGroup, int ind, aLen = theSubShapes.length(); for (ind = 0; ind < aLen; ind++) { - Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]); + Handle(::GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]); if (aSh.IsNull()) return; aSubShapes->Append(aSh); } @@ -189,7 +195,7 @@ void GEOM_IGroupOperations_i::UnionIDs (GEOM::GEOM_Object_ptr theGroup, GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; //Get sub-shape to add @@ -202,7 +208,6 @@ void GEOM_IGroupOperations_i::UnionIDs (GEOM::GEOM_Object_ptr theGroup, //Perform the operation GetOperations()->UnionIDs(aGroupRef, aSubShapes); - return; } //============================================================================= @@ -217,7 +222,7 @@ void GEOM_IGroupOperations_i::DifferenceIDs (GEOM::GEOM_Object_ptr theGroup, GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return; //Get sub-shape to remove @@ -230,7 +235,176 @@ void GEOM_IGroupOperations_i::DifferenceIDs (GEOM::GEOM_Object_ptr theGroup, //Perform the operation GetOperations()->DifferenceIDs(aGroupRef, aSubShapes); - return; +} + +//============================================================================= +/*! + * UnionGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::UnionGroups (GEOM::GEOM_Object_ptr theGroup1, + GEOM::GEOM_Object_ptr theGroup2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(::GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1); + Handle(::GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2); + if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn(); + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->UnionGroups(aGroupRef1, aGroupRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * IntersectGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::IntersectGroups (GEOM::GEOM_Object_ptr theGroup1, + GEOM::GEOM_Object_ptr theGroup2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(::GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1); + Handle(::GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2); + if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn(); + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->IntersectGroups(aGroupRef1, aGroupRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * CutGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CutGroups (GEOM::GEOM_Object_ptr theGroup1, + GEOM::GEOM_Object_ptr theGroup2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(::GEOM_Object) aGroupRef1 = GetObjectImpl(theGroup1); + Handle(::GEOM_Object) aGroupRef2 = GetObjectImpl(theGroup2); + if (aGroupRef1.IsNull() || aGroupRef2.IsNull()) return aGEOMObject._retn(); + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->CutGroups(aGroupRef1, aGroupRef2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * UnionListOfGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::UnionListOfGroups (const GEOM::ListOfGO& theGList) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(TColStd_HSequenceOfTransient) aGroups = new TColStd_HSequenceOfTransient; + + int ind, aLen = theGList.length(); + for (ind = 0; ind < aLen; ind++) { + Handle(::GEOM_Object) aGr = GetObjectImpl(theGList[ind]); + if (aGr.IsNull()) return aGEOMObject._retn(); + aGroups->Append(aGr); + } + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->UnionListOfGroups(aGroups); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * IntersectListOfGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::IntersectListOfGroups (const GEOM::ListOfGO& theGList) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(TColStd_HSequenceOfTransient) aGroups = new TColStd_HSequenceOfTransient; + + int ind, aLen = theGList.length(); + for (ind = 0; ind < aLen; ind++) { + Handle(::GEOM_Object) aGr = GetObjectImpl(theGList[ind]); + if (aGr.IsNull()) return aGEOMObject._retn(); + aGroups->Append(aGr); + } + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->IntersectListOfGroups(aGroups); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); +} + +//============================================================================= +/*! + * CutListOfGroups + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CutListOfGroups (const GEOM::ListOfGO& theGList1, + const GEOM::ListOfGO& theGList2) +{ + GEOM::GEOM_Object_var aGEOMObject; + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference groups + Handle(TColStd_HSequenceOfTransient) aGroups1 = new TColStd_HSequenceOfTransient; + Handle(TColStd_HSequenceOfTransient) aGroups2 = new TColStd_HSequenceOfTransient; + + int ind, aLen = theGList1.length(); + for (ind = 0; ind < aLen; ind++) { + Handle(::GEOM_Object) aGr = GetObjectImpl(theGList1[ind]); + if (aGr.IsNull()) return aGEOMObject._retn(); + aGroups1->Append(aGr); + } + aLen = theGList2.length(); + for (ind = 0; ind < aLen; ind++) { + Handle(::GEOM_Object) aGr = GetObjectImpl(theGList2[ind]); + if (aGr.IsNull()) return aGEOMObject._retn(); + aGroups2->Append(aGr); + } + + //Perform the operation + Handle(::GEOM_Object) anObject = GetOperations()->CutListOfGroups(aGroups1, aGroups2); + if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); + + return GetObject(anObject); } //============================================================================= @@ -244,7 +418,7 @@ CORBA::Long GEOM_IGroupOperations_i::GetType(GEOM::GEOM_Object_ptr theGroup) GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return -1; return GetOperations()->GetType(aGroupRef); @@ -263,10 +437,10 @@ GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::GetMainShape(GEOM::GEOM_Object_pt GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return aGEOMObject._retn(); - Handle(GEOM_Object) anObject = GetOperations()->GetMainShape(aGroupRef); + Handle(::GEOM_Object) anObject = GetOperations()->GetMainShape(aGroupRef); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); return GetObject(anObject); @@ -285,7 +459,7 @@ GEOM::ListOfLong* GEOM_IGroupOperations_i::GetObjects(GEOM::GEOM_Object_ptr theG GetOperations()->SetNotDone(); //Get the reference group - Handle(GEOM_Object) aGroupRef = GetObjectImpl(theGroup); + Handle(::GEOM_Object) aGroupRef = GetObjectImpl(theGroup); if (aGroupRef.IsNull()) return aList._retn(); aList = new GEOM::ListOfLong;