1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/
20 #include <Standard_Stream.hxx>
22 #include <GEOMImpl_IGroupOperations.hxx>
24 #include <GEOMImpl_Types.hxx>
26 #include <GEOM_Function.hxx>
27 #include <GEOM_ISubShape.hxx>
28 #include <GEOM_PythonDump.hxx>
30 #include "utilities.h"
32 #include <Utils_ExceptHandlers.hxx>
34 #include <TFunction_DriverTable.hxx>
35 #include <TFunction_Driver.hxx>
36 #include <TFunction_Logbook.hxx>
37 #include <TDF_Tool.hxx>
38 #include <TDataStd_Integer.hxx>
41 #include <TopTools_IndexedMapOfShape.hxx>
43 #include <TColStd_HArray1OfInteger.hxx>
44 #include <TColStd_MapOfInteger.hxx>
45 #include <TColStd_ListOfInteger.hxx>
46 #include <TColStd_ListIteratorOfListOfInteger.hxx>
48 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
50 //=============================================================================
54 //=============================================================================
55 GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID)
56 : GEOM_IOperations(theEngine, theDocID)
58 MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations");
61 //=============================================================================
65 //=============================================================================
66 GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
68 MESSAGE("GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations");
72 //=============================================================================
76 //=============================================================================
77 Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
78 (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
82 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
83 anArray->SetValue(1, -1);
85 //Add a new Fillet object
86 Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray);
89 aGroup->SetType(GEOM_GROUP);
91 //Set a sub shape type
92 TDF_Label aFreeLabel = aGroup->GetFreeLabel();
93 TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
95 //Make a Python command
96 Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
98 GEOM::TPythonDump(aFunction) << aGroup
99 << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
105 //=============================================================================
109 //=============================================================================
110 void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID)
113 if(theGroup.IsNull()) return;
115 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
116 if(aFunction.IsNull()) return;
118 GEOM_ISubShape aSSI (aFunction);
120 // Check sub-shape index validity
121 TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
122 if (aLabel.IsRoot()) return;
123 Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
124 if (anObj.IsNull()) return;
125 TopoDS_Shape aMainShape = anObj->GetValue();
126 if (aMainShape.IsNull()) return;
128 TopTools_IndexedMapOfShape aMapOfShapes;
129 TopExp::MapShapes(aMainShape, aMapOfShapes);
131 if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) {
132 SetErrorCode("Invalid sub-shape index: out of range");
136 // Add sub-shape index
137 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
138 if(aSeq.IsNull()) return;
139 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
140 aSeq->SetValue(1, theSubShapeID);
143 Standard_Integer aLength = aSeq->Length();
144 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength+1);
145 for(Standard_Integer i = 1; i<=aLength; i++) {
146 aNewSeq->SetValue(i, aSeq->Value(i));
147 if(aSeq->Value(i) == theSubShapeID) {
148 SetErrorCode(ALREADY_PRESENT);
152 aNewSeq->SetValue(aLength+1, theSubShapeID);
153 aSSI.SetIndices(aNewSeq);
156 //Make a Python command
157 GEOM::TPythonDump(aFunction, /*append=*/true)
158 << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
164 //=============================================================================
168 //=============================================================================
169 void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int theSubShapeID)
172 if(theGroup.IsNull()) return;
174 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
175 if(aFunction.IsNull()) return;
177 GEOM_ISubShape aSSI(aFunction);
178 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
179 if(aSeq.IsNull()) return;
180 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
181 SetErrorCode(NOT_EXISTS);
185 Handle(TColStd_HArray1OfInteger) aNewSeq;
186 Standard_Integer aLength = aSeq->Length();
188 if(aSeq->Value(1) != theSubShapeID) {
189 SetErrorCode(NOT_EXISTS);
192 aNewSeq = new TColStd_HArray1OfInteger(1,1);
193 aNewSeq->SetValue(1, -1);
196 aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
197 Standard_Boolean isFound = Standard_False;
198 for(Standard_Integer i = 1, k=1; i<=aLength; i++) {
199 if(i == aLength && !isFound) {
200 SetErrorCode(NOT_EXISTS);
203 if(aSeq->Value(i) == theSubShapeID) {
204 isFound = Standard_True;
207 aNewSeq->SetValue(k, aSeq->Value(i));
212 SetErrorCode(NOT_EXISTS);
217 aSSI.SetIndices(aNewSeq);
220 //Make a Python command
221 GEOM::TPythonDump(aFunction, /*append=*/true)
222 << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
228 //=============================================================================
232 //=============================================================================
233 void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
234 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
237 if (theGroup.IsNull()) return;
239 Standard_Integer aLen = theSubShapes->Length();
241 SetErrorCode("The list is empty");
245 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
246 if (aFunction.IsNull()) return;
248 GEOM_ISubShape aSSI (aFunction);
250 // New contents of the group
251 TColStd_ListOfInteger aNewIDs;
252 TColStd_MapOfInteger mapIDs;
254 // Add current IDs to the list
255 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
256 if (aSeq.IsNull()) return;
257 Standard_Integer val_j, aLength = aSeq->Length();
259 for (Standard_Integer j = 1; j <= aLength; j++) {
260 val_j = aSeq->Value(j);
261 if (val_j > 0 && mapIDs.Add(val_j)) {
262 aNewIDs.Append(val_j);
267 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
268 if (aMainShapeFunc.IsNull()) return;
269 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
270 if (aLabel.IsRoot()) return;
271 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
272 if (aMainObj.IsNull()) return;
273 TopoDS_Shape aMainShape = aMainObj->GetValue();
274 if (aMainShape.IsNull()) return;
276 TopTools_IndexedMapOfShape mapIndices;
277 TopExp::MapShapes(aMainShape, mapIndices);
279 // Get IDs of sub-shapes to add
280 Standard_Integer i, new_id;
281 for (i = 1; i <= aLen; i++) {
282 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
284 if (anObj_i->IsMainShape()) {
285 TopoDS_Shape aShape_i = anObj_i->GetValue();
286 if (mapIndices.Contains(aShape_i)) {
287 new_id = mapIndices.FindIndex(aShape_i);
288 if (mapIDs.Add(new_id)) {
289 aNewIDs.Append(new_id);
292 SetErrorCode("One of given objects can not be added to the group, because it is not a sub-shape of the group's main shape");
296 // Check main shape of sub-shape to add
297 Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
298 if (aFunc_i.IsNull()) return;
300 GEOM_ISubShape aSSI_i (aFunc_i);
302 Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
303 if (aMainShapeFunc_i.IsNull()) return;
304 TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
305 if (aLabel_i.IsRoot()) return;
306 Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
307 if (aMainObj_i.IsNull()) return;
308 TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
309 if (aMainShape_i.IsNull()) return;
311 if (aMainShape_i.IsSame(aMainShape)) {
312 // add all sub-shape IDs to the list
315 Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
316 if (aSeq_i.IsNull()) return;
317 Standard_Integer aLength_i = aSeq_i->Length();
319 for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
320 new_id = aSeq_i->Value(i_j);
322 if (mapIDs.Add(new_id)) {
323 aNewIDs.Append(new_id);
328 } else if (mapIndices.Contains(aMainShape_i)) {
329 // compute new IDs and add them to the list
330 TopTools_IndexedMapOfShape mapIndices_i;
331 TopExp::MapShapes(aMainShape_i, mapIndices_i);
334 Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
335 if (aSeq_i.IsNull()) return;
336 Standard_Integer aLength_i = aSeq_i->Length();
338 for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
339 if (aSeq_i->Value(i_j) > 0) {
340 TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
341 new_id = mapIndices.FindIndex(aShape_i_j);
342 if (mapIDs.Add(new_id)) {
343 aNewIDs.Append(new_id);
349 SetErrorCode("One of given objects can not be added to the group, because it is not a sub-shape of the group's main shape");
355 if (aNewIDs.Extent() > 0) {
356 Standard_Integer k = 1;
357 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
358 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
359 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
360 aNewSeq->SetValue(k, aNewIDsIter.Value());
363 aSSI.SetIndices(aNewSeq);
366 //Make a Python command
367 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
368 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
369 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
371 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
372 pd << "geompy.UnionList(" << theGroup << ", [";
374 for (i = 1; i <= aLen; i++) {
375 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
376 pd << anObj_i << (( i < aLen ) ? ", " : "])");
382 //=============================================================================
386 //=============================================================================
387 void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
388 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
391 if (theGroup.IsNull()) return;
393 Standard_Integer aLen = theSubShapes->Length();
395 SetErrorCode("The list is empty");
399 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
400 if (aFunction.IsNull()) return;
402 GEOM_ISubShape aSSI (aFunction);
404 // Map of IDs to be removed
405 TColStd_MapOfInteger mapIDsToRemove;
407 // Map of current IDs
408 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
409 if (aSeq.IsNull()) return;
410 Standard_Integer aLength = aSeq->Length();
412 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
415 TColStd_MapOfInteger mapIDsCurrent;
416 Standard_Integer j = 1;
417 for (; j <= aLength; j++) {
418 mapIDsCurrent.Add(aSeq->Value(j));
422 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
423 if (aMainShapeFunc.IsNull()) return;
424 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
425 if (aLabel.IsRoot()) return;
426 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
427 if (aMainObj.IsNull()) return;
428 TopoDS_Shape aMainShape = aMainObj->GetValue();
429 if (aMainShape.IsNull()) return;
431 TopTools_IndexedMapOfShape mapIndices;
432 TopExp::MapShapes(aMainShape, mapIndices);
434 // Get IDs of sub-shapes to be removed
435 Standard_Integer i, rem_id;
436 for (i = 1; i <= aLen; i++) {
437 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
439 if (anObj_i->IsMainShape()) {
440 TopoDS_Shape aShape_i = anObj_i->GetValue();
441 if (mapIndices.Contains(aShape_i)) {
442 rem_id = mapIndices.FindIndex(aShape_i);
443 if (mapIDsCurrent.Contains(rem_id)) {
444 mapIDsToRemove.Add(rem_id);
447 SetErrorCode("One of given objects can not be removed from the group, because it is not a sub-shape of the group's main shape");
451 // Check main shape of sub-shape to be removed
452 Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
453 if (aFunc_i.IsNull()) return;
455 GEOM_ISubShape aSSI_i (aFunc_i);
457 Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
458 if (aMainShapeFunc_i.IsNull()) return;
459 TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
460 if (aLabel_i.IsRoot()) return;
461 Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
462 if (aMainObj_i.IsNull()) return;
463 TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
464 if (aMainShape_i.IsNull()) return;
466 if (aMainShape_i.IsSame(aMainShape)) {
467 // remove all sub-shapes
470 Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
471 if (aSeq_i.IsNull()) return;
472 Standard_Integer aLength_i = aSeq_i->Length();
474 for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
475 rem_id = aSeq_i->Value(i_j);
477 if (mapIDsCurrent.Contains(rem_id)) {
478 mapIDsToRemove.Add(rem_id);
483 } else if (mapIndices.Contains(aMainShape_i)) {
484 // compute new IDs and add them to the map of ids to be removed
485 TopTools_IndexedMapOfShape mapIndices_i;
486 TopExp::MapShapes(aMainShape_i, mapIndices_i);
489 Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
490 if (aSeq_i.IsNull()) return;
491 Standard_Integer aLength_i = aSeq_i->Length();
493 for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
494 if (aSeq_i->Value(i_j) > 0) {
495 TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
496 rem_id = mapIndices.FindIndex(aShape_i_j);
497 if (mapIDsCurrent.Contains(rem_id)) {
498 mapIDsToRemove.Add(rem_id);
504 SetErrorCode("One of given objects can not be removed from the group, because it is not a sub-shape of the group's main shape");
510 if (mapIDsToRemove.Extent() > 0) {
511 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
512 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
514 for (j = 1; j <= aLength; j++) {
515 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
516 aNewSeq->SetValue(k, aSeq->Value(j));
521 aSSI.SetIndices(aNewSeq);
524 //Make a Python command
525 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
526 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
527 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
529 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
530 pd << "geompy.DifferenceList(" << theGroup << ", [";
532 for (i = 1; i <= aLen; i++) {
533 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
534 pd << anObj_i << (( i < aLen ) ? ", " : "])");
540 //=============================================================================
544 //=============================================================================
545 void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
546 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
549 if (theGroup.IsNull()) return;
551 Standard_Integer aLen = theSubShapes->Length();
553 SetErrorCode("The list is empty");
557 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
558 if (aFunction.IsNull()) return;
560 GEOM_ISubShape aSSI (aFunction);
562 // New contents of the group
563 TColStd_ListOfInteger aNewIDs;
564 TColStd_MapOfInteger mapIDs;
566 // Add current IDs to the list
567 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
568 if (aSeq.IsNull()) return;
569 Standard_Integer val_j, aLength = aSeq->Length();
571 for (Standard_Integer j = 1; j <= aLength; j++) {
572 val_j = aSeq->Value(j);
573 if (val_j > 0 && mapIDs.Add(val_j)) {
574 aNewIDs.Append(val_j);
579 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
580 if (aMainShapeFunc.IsNull()) return;
581 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
582 if (aLabel.IsRoot()) return;
583 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
584 if (aMainObj.IsNull()) return;
585 TopoDS_Shape aMainShape = aMainObj->GetValue();
586 if (aMainShape.IsNull()) return;
588 TopTools_IndexedMapOfShape mapIndices;
589 TopExp::MapShapes(aMainShape, mapIndices);
591 // Get IDs of sub-shapes to add
592 Standard_Integer i, new_id;
593 for (i = 1; i <= aLen; i++) {
594 new_id = theSubShapes->Value(i);
596 if (0 < new_id && new_id <= mapIndices.Extent()) {
597 if (mapIDs.Add(new_id)) {
598 aNewIDs.Append(new_id);
603 if (aNewIDs.Extent() > 0) {
604 Standard_Integer k = 1;
605 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
606 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
607 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
608 aNewSeq->SetValue(k, aNewIDsIter.Value());
611 aSSI.SetIndices(aNewSeq);
614 //Make a Python command
615 GEOM::TPythonDump pd (aFunction, /*append=*/true);
616 pd << "geompy.UnionIDs(" << theGroup << ", [";
617 for (i = 1; i < aLen; i++)
618 pd << theSubShapes->Value(i) << ", ";
619 pd << theSubShapes->Value(aLen) << "])";
624 //=============================================================================
628 //=============================================================================
629 void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
630 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
633 if (theGroup.IsNull()) return;
635 Standard_Integer aLen = theSubShapes->Length();
637 SetErrorCode("The list is empty");
641 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
642 if (aFunction.IsNull()) return;
644 GEOM_ISubShape aSSI (aFunction);
646 // Map of IDs to be removed
647 TColStd_MapOfInteger mapIDsToRemove;
649 // Map of current IDs
650 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
651 if (aSeq.IsNull()) return;
652 Standard_Integer aLength = aSeq->Length();
654 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
657 TColStd_MapOfInteger mapIDsCurrent;
658 Standard_Integer j = 1;
659 for (; j <= aLength; j++) {
660 mapIDsCurrent.Add(aSeq->Value(j));
664 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
665 if (aMainShapeFunc.IsNull()) return;
666 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
667 if (aLabel.IsRoot()) return;
668 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
669 if (aMainObj.IsNull()) return;
670 TopoDS_Shape aMainShape = aMainObj->GetValue();
671 if (aMainShape.IsNull()) return;
673 TopTools_IndexedMapOfShape mapIndices;
674 TopExp::MapShapes(aMainShape, mapIndices);
676 // Get IDs of sub-shapes to be removed
677 Standard_Integer i, rem_id;
678 for (i = 1; i <= aLen; i++) {
679 rem_id = theSubShapes->Value(i);
680 if (mapIDsCurrent.Contains(rem_id)) {
681 mapIDsToRemove.Add(rem_id);
685 if (mapIDsToRemove.Extent() > 0) {
686 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
687 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
689 for (j = 1; j <= aLength; j++) {
690 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
691 aNewSeq->SetValue(k, aSeq->Value(j));
696 aSSI.SetIndices(aNewSeq);
699 //Make a Python command
700 GEOM::TPythonDump pd (aFunction, /*append=*/true);
701 pd << "geompy.DifferenceIDs(" << theGroup << ", [";
702 for (i = 1; i < aLen; i++)
703 pd << theSubShapes->Value(i) << ", ";
704 pd << theSubShapes->Value(aLen) << "])";
709 //=============================================================================
713 //=============================================================================
714 TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup)
718 TDF_Label aFreeLabel = theGroup->GetFreeLabel();
719 Handle(TDataStd_Integer) anAttrib;
720 if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE;
723 return (TopAbs_ShapeEnum) anAttrib->Get();
726 //=============================================================================
730 //=============================================================================
731 Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object) theGroup)
735 if(theGroup.IsNull()) return NULL;
737 Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1);
738 if (aGroupFunction.IsNull()) return NULL;
740 GEOM_ISubShape aSSI (aGroupFunction);
741 Handle(GEOM_Function) aMainShapeFunction = aSSI.GetMainShape();
742 if (aMainShapeFunction.IsNull()) return NULL;
744 TDF_Label aLabel = aMainShapeFunction->GetOwnerEntry();
745 Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel);
746 if (aMainShape.IsNull()) return NULL;
748 //Make a Python command
749 GEOM::TPythonDump(aGroupFunction, /*append=*/true)
750 << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
756 //=============================================================================
760 //=============================================================================
761 Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
765 if(theGroup.IsNull()) return NULL;
767 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
768 if(aFunction.IsNull()) return NULL;
770 GEOM_ISubShape aSSI(aFunction);
771 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
772 if(aSeq.IsNull()) return NULL;
774 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {