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/ or email : webmaster.salome@opencascade.com
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 <TopExp_Explorer.hxx>
42 #include <TopTools_IndexedMapOfShape.hxx>
44 #include <TColStd_HArray1OfInteger.hxx>
45 #include <TColStd_MapOfInteger.hxx>
46 #include <TColStd_ListOfInteger.hxx>
47 #include <TColStd_ListIteratorOfListOfInteger.hxx>
49 //=============================================================================
53 //=============================================================================
54 GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID)
55 : GEOM_IOperations(theEngine, theDocID)
57 MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations");
60 //=============================================================================
64 //=============================================================================
65 GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
67 MESSAGE("GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations");
71 //=============================================================================
75 //=============================================================================
76 Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
77 (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
81 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
82 anArray->SetValue(1, -1);
84 //Add a new Fillet object
85 Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray);
88 aGroup->SetType(GEOM_GROUP);
90 //Set a sub shape type
91 TDF_Label aFreeLabel = aGroup->GetFreeLabel();
92 TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
94 //Make a Python command
95 Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
97 GEOM::TPythonDump(aFunction) << aGroup
98 << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
104 //=============================================================================
108 //=============================================================================
109 void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID)
112 if(theGroup.IsNull()) return;
114 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
115 if(aFunction.IsNull()) return;
117 GEOM_ISubShape aSSI (aFunction);
119 // Check sub-shape index validity
120 TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
121 if (aLabel.IsRoot()) return;
122 Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
123 if (anObj.IsNull()) return;
124 TopoDS_Shape aMainShape = anObj->GetValue();
125 if (aMainShape.IsNull()) return;
127 TopTools_IndexedMapOfShape aMapOfShapes;
128 TopExp::MapShapes(aMainShape, aMapOfShapes);
130 if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) {
131 SetErrorCode("Invalid sub-shape index: out of range");
135 // Add sub-shape index
136 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
137 if(aSeq.IsNull()) return;
138 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
139 aSeq->SetValue(1, theSubShapeID);
142 Standard_Integer aLength = aSeq->Length();
143 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength+1);
144 for(Standard_Integer i = 1; i<=aLength; i++) {
145 aNewSeq->SetValue(i, aSeq->Value(i));
146 if(aSeq->Value(i) == theSubShapeID) {
147 SetErrorCode(ALREADY_PRESENT);
151 aNewSeq->SetValue(aLength+1, theSubShapeID);
152 aSSI.SetIndices(aNewSeq);
155 //Make a Python command
156 GEOM::TPythonDump(aFunction, /*append=*/true)
157 << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
163 //=============================================================================
167 //=============================================================================
168 void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int theSubShapeID)
171 if(theGroup.IsNull()) return;
173 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
174 if(aFunction.IsNull()) return;
176 GEOM_ISubShape aSSI(aFunction);
177 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
178 if(aSeq.IsNull()) return;
179 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
180 SetErrorCode(NOT_EXISTS);
184 Handle(TColStd_HArray1OfInteger) aNewSeq;
185 Standard_Integer aLength = aSeq->Length();
187 if(aSeq->Value(1) != theSubShapeID) {
188 SetErrorCode(NOT_EXISTS);
191 aNewSeq = new TColStd_HArray1OfInteger(1,1);
192 aNewSeq->SetValue(1, -1);
195 aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
196 Standard_Boolean isFound = Standard_False;
197 for (Standard_Integer i = 1, k = 1; i <= aLength; i++) {
198 if (aSeq->Value(i) == theSubShapeID) {
199 isFound = Standard_True;
201 if (k < aLength) { // this check is to avoid sequence <aNewSeq> overflow
202 aNewSeq->SetValue(k, aSeq->Value(i));
209 SetErrorCode(NOT_EXISTS);
214 aSSI.SetIndices(aNewSeq);
217 //Make a Python command
218 GEOM::TPythonDump(aFunction, /*append=*/true)
219 << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
225 //=============================================================================
229 //=============================================================================
230 void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
231 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
234 if (theGroup.IsNull()) return;
236 Standard_Integer aLen = theSubShapes->Length();
238 SetErrorCode("The list is empty");
242 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
243 if (aFunction.IsNull()) return;
245 GEOM_ISubShape aSSI (aFunction);
247 // New contents of the group
248 TColStd_ListOfInteger aNewIDs;
249 TColStd_MapOfInteger mapIDs;
251 // Add current IDs to the list
252 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
253 if (aSeq.IsNull()) return;
254 Standard_Integer val_j, aLength = aSeq->Length();
256 for (Standard_Integer j = 1; j <= aLength; j++) {
257 val_j = aSeq->Value(j);
258 if (val_j > 0 && mapIDs.Add(val_j)) {
259 aNewIDs.Append(val_j);
264 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
265 if (aMainShapeFunc.IsNull()) return;
266 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
267 if (aLabel.IsRoot()) return;
268 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
269 if (aMainObj.IsNull()) return;
270 TopoDS_Shape aMainShape = aMainObj->GetValue();
271 if (aMainShape.IsNull()) return;
273 TopTools_IndexedMapOfShape mapIndices;
274 TopExp::MapShapes(aMainShape, mapIndices);
277 TopAbs_ShapeEnum aType = GetType(theGroup);
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 TopoDS_Shape aShape_i = anObj_i->GetValue();
285 TopAbs_ShapeEnum aType_i = aShape_i.ShapeType();
287 // 1. If aShape_i is sub-shape of aMainShape - add it
288 if (anObj_i->IsMainShape()) {
289 if (aType_i != aType && aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
290 SetErrorCode("Operation aborted: one of given objects has a wrong type");
293 if (!mapIndices.Contains(aShape_i)) {
294 SetErrorCode("Operation aborted: not a sub-shape given");
297 new_id = mapIndices.FindIndex(aShape_i);
298 if (mapIDs.Add(new_id)) {
299 aNewIDs.Append(new_id);
302 // 2. If type of group is not defined - add all sub-shapes of aShape_i
303 else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
304 TopTools_IndexedMapOfShape mapIndices_i;
305 TopExp::MapShapes(aShape_i, mapIndices_i);
306 Standard_Integer ii = 1, nbSubSh = mapIndices_i.Extent();
307 Standard_Boolean someGood = Standard_False;
308 for (; ii <= nbSubSh; ii++) {
309 TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
310 if (mapIndices.Contains(aSubShape_i)) {
311 someGood = Standard_True;
312 new_id = mapIndices.FindIndex(aSubShape_i);
313 if (mapIDs.Add(new_id)) {
314 aNewIDs.Append(new_id);
319 SetErrorCode("Operation aborted: not a sub-shape given");
323 // 3. If type of group is defined - add all sub-shapes of aShape_i of that type
325 TopExp_Explorer aSubShapes_i (aShape_i, aType);
326 for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
327 TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
328 if (!mapIndices.Contains(aSubShape_i)) {
329 SetErrorCode("Operation aborted: not a sub-shape given");
332 new_id = mapIndices.FindIndex(aSubShape_i);
333 if (mapIDs.Add(new_id)) {
334 aNewIDs.Append(new_id);
340 if (aNewIDs.Extent() > 0) {
341 Standard_Integer k = 1;
342 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
343 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
344 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
345 aNewSeq->SetValue(k, aNewIDsIter.Value());
348 aSSI.SetIndices(aNewSeq);
351 //Make a Python command
352 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
353 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
354 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
356 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
357 pd << "geompy.UnionList(" << theGroup << ", [";
359 for (i = 1; i <= aLen; i++) {
360 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
361 pd << anObj_i << (( i < aLen ) ? ", " : "])");
367 //=============================================================================
371 //=============================================================================
372 void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
373 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
376 if (theGroup.IsNull()) return;
378 Standard_Integer aLen = theSubShapes->Length();
380 SetErrorCode("The list is empty");
384 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
385 if (aFunction.IsNull()) return;
387 GEOM_ISubShape aSSI (aFunction);
389 // Map of IDs to be removed
390 TColStd_MapOfInteger mapIDsToRemove;
392 // Map of current IDs
393 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
394 if (aSeq.IsNull()) return;
395 Standard_Integer aLength = aSeq->Length();
397 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
400 TColStd_MapOfInteger mapIDsCurrent;
401 Standard_Integer j = 1;
402 for (; j <= aLength; j++) {
403 mapIDsCurrent.Add(aSeq->Value(j));
407 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
408 if (aMainShapeFunc.IsNull()) return;
409 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
410 if (aLabel.IsRoot()) return;
411 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
412 if (aMainObj.IsNull()) return;
413 TopoDS_Shape aMainShape = aMainObj->GetValue();
414 if (aMainShape.IsNull()) return;
416 TopTools_IndexedMapOfShape mapIndices;
417 TopExp::MapShapes(aMainShape, mapIndices);
420 TopAbs_ShapeEnum aType = GetType(theGroup);
422 // Get IDs of sub-shapes to be removed
423 Standard_Integer i, rem_id;
424 for (i = 1; i <= aLen; i++) {
425 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
427 TopoDS_Shape aShape_i = anObj_i->GetValue();
429 // 1. If aShape_i is sub-shape of aMainShape - remove it
430 if (mapIndices.Contains(aShape_i)) {
431 rem_id = mapIndices.FindIndex(aShape_i);
432 if (mapIDsCurrent.Contains(rem_id)) {
433 mapIDsToRemove.Add(rem_id);
436 // 2. If type of group is not defined - remove all sub-shapes of aShape_i
437 else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
438 TopTools_IndexedMapOfShape mapIndices_i;
439 TopExp::MapShapes(aShape_i, mapIndices_i);
440 Standard_Integer nbSubSh = mapIndices_i.Extent();
441 Standard_Integer ii = 1;
442 for (; ii <= nbSubSh; ii++) {
443 TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
444 if (mapIndices.Contains(aSubShape_i)) {
445 rem_id = mapIndices.FindIndex(aSubShape_i);
446 if (mapIDsCurrent.Contains(rem_id)) {
447 mapIDsToRemove.Add(rem_id);
452 // 3. If type of group is defined - remove all sub-shapes of aShape_i of that type
454 TopExp_Explorer aSubShapes_i (aShape_i, aType);
455 for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
456 TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
457 if (mapIndices.Contains(aSubShape_i)) {
458 rem_id = mapIndices.FindIndex(aSubShape_i);
459 if (mapIDsCurrent.Contains(rem_id)) {
460 mapIDsToRemove.Add(rem_id);
467 if (mapIDsToRemove.Extent() > 0) {
468 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
469 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
471 for (j = 1; j <= aLength; j++) {
472 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
473 aNewSeq->SetValue(k, aSeq->Value(j));
478 aSSI.SetIndices(aNewSeq);
481 //Make a Python command
482 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
483 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
484 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
486 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
487 pd << "geompy.DifferenceList(" << theGroup << ", [";
489 for (i = 1; i <= aLen; i++) {
490 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
491 pd << anObj_i << (( i < aLen ) ? ", " : "])");
497 //=============================================================================
501 //=============================================================================
502 void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
503 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
506 if (theGroup.IsNull()) return;
508 Standard_Integer aLen = theSubShapes->Length();
510 SetErrorCode("The list is empty");
514 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
515 if (aFunction.IsNull()) return;
517 GEOM_ISubShape aSSI (aFunction);
519 // New contents of the group
520 TColStd_ListOfInteger aNewIDs;
521 TColStd_MapOfInteger mapIDs;
523 // Add current IDs to the list
524 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
525 if (aSeq.IsNull()) return;
526 Standard_Integer val_j, aLength = aSeq->Length();
528 for (Standard_Integer j = 1; j <= aLength; j++) {
529 val_j = aSeq->Value(j);
530 if (val_j > 0 && mapIDs.Add(val_j)) {
531 aNewIDs.Append(val_j);
536 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
537 if (aMainShapeFunc.IsNull()) return;
538 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
539 if (aLabel.IsRoot()) return;
540 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
541 if (aMainObj.IsNull()) return;
542 TopoDS_Shape aMainShape = aMainObj->GetValue();
543 if (aMainShape.IsNull()) return;
545 TopTools_IndexedMapOfShape mapIndices;
546 TopExp::MapShapes(aMainShape, mapIndices);
548 // Get IDs of sub-shapes to add
549 Standard_Integer i, new_id;
550 for (i = 1; i <= aLen; i++) {
551 new_id = theSubShapes->Value(i);
553 if (0 < new_id && new_id <= mapIndices.Extent()) {
554 if (mapIDs.Add(new_id)) {
555 aNewIDs.Append(new_id);
560 if (aNewIDs.Extent() > 0) {
561 Standard_Integer k = 1;
562 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
563 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
564 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
565 aNewSeq->SetValue(k, aNewIDsIter.Value());
568 aSSI.SetIndices(aNewSeq);
571 //Make a Python command
572 GEOM::TPythonDump pd (aFunction, /*append=*/true);
573 pd << "geompy.UnionIDs(" << theGroup << ", [";
574 for (i = 1; i < aLen; i++)
575 pd << theSubShapes->Value(i) << ", ";
576 pd << theSubShapes->Value(aLen) << "])";
581 //=============================================================================
585 //=============================================================================
586 void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
587 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
590 if (theGroup.IsNull()) return;
592 Standard_Integer aLen = theSubShapes->Length();
594 SetErrorCode("The list is empty");
598 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
599 if (aFunction.IsNull()) return;
601 GEOM_ISubShape aSSI (aFunction);
603 // Map of IDs to be removed
604 TColStd_MapOfInteger mapIDsToRemove;
606 // Map of current IDs
607 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
608 if (aSeq.IsNull()) return;
609 Standard_Integer aLength = aSeq->Length();
611 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
614 TColStd_MapOfInteger mapIDsCurrent;
615 Standard_Integer j = 1;
616 for (; j <= aLength; j++) {
617 mapIDsCurrent.Add(aSeq->Value(j));
621 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
622 if (aMainShapeFunc.IsNull()) return;
623 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
624 if (aLabel.IsRoot()) return;
625 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
626 if (aMainObj.IsNull()) return;
627 TopoDS_Shape aMainShape = aMainObj->GetValue();
628 if (aMainShape.IsNull()) return;
630 TopTools_IndexedMapOfShape mapIndices;
631 TopExp::MapShapes(aMainShape, mapIndices);
633 // Get IDs of sub-shapes to be removed
634 Standard_Integer i, rem_id;
635 for (i = 1; i <= aLen; i++) {
636 rem_id = theSubShapes->Value(i);
637 if (mapIDsCurrent.Contains(rem_id)) {
638 mapIDsToRemove.Add(rem_id);
642 if (mapIDsToRemove.Extent() > 0) {
643 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
644 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
646 for (j = 1; j <= aLength; j++) {
647 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
648 aNewSeq->SetValue(k, aSeq->Value(j));
653 aSSI.SetIndices(aNewSeq);
656 //Make a Python command
657 GEOM::TPythonDump pd (aFunction, /*append=*/true);
658 pd << "geompy.DifferenceIDs(" << theGroup << ", [";
659 for (i = 1; i < aLen; i++)
660 pd << theSubShapes->Value(i) << ", ";
661 pd << theSubShapes->Value(aLen) << "])";
666 //=============================================================================
670 //=============================================================================
671 TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup)
675 TDF_Label aFreeLabel = theGroup->GetFreeLabel();
676 Handle(TDataStd_Integer) anAttrib;
677 if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE;
680 return (TopAbs_ShapeEnum) anAttrib->Get();
683 //=============================================================================
687 //=============================================================================
688 Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object) theGroup)
692 if(theGroup.IsNull()) return NULL;
694 Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1);
695 if (aGroupFunction.IsNull()) return NULL;
697 GEOM_ISubShape aSSI (aGroupFunction);
698 Handle(GEOM_Function) aMainShapeFunction = aSSI.GetMainShape();
699 if (aMainShapeFunction.IsNull()) return NULL;
701 TDF_Label aLabel = aMainShapeFunction->GetOwnerEntry();
702 Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel);
703 if (aMainShape.IsNull()) return NULL;
705 //Make a Python command
706 GEOM::TPythonDump(aGroupFunction, /*append=*/true)
707 << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
713 //=============================================================================
717 //=============================================================================
718 Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
722 if(theGroup.IsNull()) return NULL;
724 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
725 if(aFunction.IsNull()) return NULL;
727 GEOM_ISubShape aSSI(aFunction);
728 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
729 if(aSeq.IsNull()) return NULL;
731 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {