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 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
51 //=============================================================================
55 //=============================================================================
56 GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID)
57 : GEOM_IOperations(theEngine, theDocID)
59 MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations");
62 //=============================================================================
66 //=============================================================================
67 GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
69 MESSAGE("GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations");
73 //=============================================================================
77 //=============================================================================
78 Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup
79 (Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
83 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
84 anArray->SetValue(1, -1);
86 //Add a new Fillet object
87 Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray);
90 aGroup->SetType(GEOM_GROUP);
92 //Set a sub shape type
93 TDF_Label aFreeLabel = aGroup->GetFreeLabel();
94 TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
96 //Make a Python command
97 Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
99 GEOM::TPythonDump(aFunction) << aGroup
100 << " = geompy.CreateGroup(" << theMainShape << ", " << theShapeType << ")";
106 //=============================================================================
110 //=============================================================================
111 void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID)
114 if(theGroup.IsNull()) return;
116 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
117 if(aFunction.IsNull()) return;
119 GEOM_ISubShape aSSI (aFunction);
121 // Check sub-shape index validity
122 TDF_Label aLabel = aSSI.GetMainShape()->GetOwnerEntry();
123 if (aLabel.IsRoot()) return;
124 Handle(GEOM_Object) anObj = GEOM_Object::GetObject(aLabel);
125 if (anObj.IsNull()) return;
126 TopoDS_Shape aMainShape = anObj->GetValue();
127 if (aMainShape.IsNull()) return;
129 TopTools_IndexedMapOfShape aMapOfShapes;
130 TopExp::MapShapes(aMainShape, aMapOfShapes);
132 if (theSubShapeID < 1 || aMapOfShapes.Extent() < theSubShapeID) {
133 SetErrorCode("Invalid sub-shape index: out of range");
137 // Add sub-shape index
138 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
139 if(aSeq.IsNull()) return;
140 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
141 aSeq->SetValue(1, theSubShapeID);
144 Standard_Integer aLength = aSeq->Length();
145 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength+1);
146 for(Standard_Integer i = 1; i<=aLength; i++) {
147 aNewSeq->SetValue(i, aSeq->Value(i));
148 if(aSeq->Value(i) == theSubShapeID) {
149 SetErrorCode(ALREADY_PRESENT);
153 aNewSeq->SetValue(aLength+1, theSubShapeID);
154 aSSI.SetIndices(aNewSeq);
157 //Make a Python command
158 GEOM::TPythonDump(aFunction, /*append=*/true)
159 << "geompy.AddObject(" << theGroup << ", " << theSubShapeID << ")";
165 //=============================================================================
169 //=============================================================================
170 void GEOMImpl_IGroupOperations::RemoveObject (Handle(GEOM_Object) theGroup, int theSubShapeID)
173 if(theGroup.IsNull()) return;
175 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
176 if(aFunction.IsNull()) return;
178 GEOM_ISubShape aSSI(aFunction);
179 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
180 if(aSeq.IsNull()) return;
181 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
182 SetErrorCode(NOT_EXISTS);
186 Handle(TColStd_HArray1OfInteger) aNewSeq;
187 Standard_Integer aLength = aSeq->Length();
189 if(aSeq->Value(1) != theSubShapeID) {
190 SetErrorCode(NOT_EXISTS);
193 aNewSeq = new TColStd_HArray1OfInteger(1,1);
194 aNewSeq->SetValue(1, -1);
197 aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
198 Standard_Boolean isFound = Standard_False;
199 for(Standard_Integer i = 1, k=1; i<=aLength; i++) {
200 if(i == aLength && !isFound) {
201 SetErrorCode(NOT_EXISTS);
204 if(aSeq->Value(i) == theSubShapeID) {
205 isFound = Standard_True;
208 aNewSeq->SetValue(k, aSeq->Value(i));
213 SetErrorCode(NOT_EXISTS);
218 aSSI.SetIndices(aNewSeq);
221 //Make a Python command
222 GEOM::TPythonDump(aFunction, /*append=*/true)
223 << "geompy.RemoveObject(" << theGroup << ", " << theSubShapeID << ")";
229 //=============================================================================
233 //=============================================================================
234 void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
235 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
238 if (theGroup.IsNull()) return;
240 Standard_Integer aLen = theSubShapes->Length();
242 SetErrorCode("The list is empty");
246 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
247 if (aFunction.IsNull()) return;
249 GEOM_ISubShape aSSI (aFunction);
251 // New contents of the group
252 TColStd_ListOfInteger aNewIDs;
253 TColStd_MapOfInteger mapIDs;
255 // Add current IDs to the list
256 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
257 if (aSeq.IsNull()) return;
258 Standard_Integer val_j, aLength = aSeq->Length();
260 for (Standard_Integer j = 1; j <= aLength; j++) {
261 val_j = aSeq->Value(j);
262 if (val_j > 0 && mapIDs.Add(val_j)) {
263 aNewIDs.Append(val_j);
268 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
269 if (aMainShapeFunc.IsNull()) return;
270 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
271 if (aLabel.IsRoot()) return;
272 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
273 if (aMainObj.IsNull()) return;
274 TopoDS_Shape aMainShape = aMainObj->GetValue();
275 if (aMainShape.IsNull()) return;
277 TopTools_IndexedMapOfShape mapIndices;
278 TopExp::MapShapes(aMainShape, mapIndices);
281 TopAbs_ShapeEnum aType = GetType(theGroup);
283 // Get IDs of sub-shapes to add
284 Standard_Integer i, new_id;
285 for (i = 1; i <= aLen; i++) {
286 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
288 TopoDS_Shape aShape_i = anObj_i->GetValue();
289 TopAbs_ShapeEnum aType_i = aShape_i.ShapeType();
291 // 1. If aShape_i is sub-shape of aMainShape - add it
292 if (anObj_i->IsMainShape()) {
293 if (aType_i != aType && aType != TopAbs_SHAPE && aType != TopAbs_COMPOUND) {
294 SetErrorCode("Operation aborted: one of given objects has a wrong type");
297 if (!mapIndices.Contains(aShape_i)) {
298 SetErrorCode("Operation aborted: not a sub-shape given");
301 new_id = mapIndices.FindIndex(aShape_i);
302 if (mapIDs.Add(new_id)) {
303 aNewIDs.Append(new_id);
306 // 2. If type of group is not defined - add all sub-shapes of aShape_i
307 else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
308 TopTools_IndexedMapOfShape mapIndices_i;
309 TopExp::MapShapes(aShape_i, mapIndices_i);
310 Standard_Integer ii = 1, nbSubSh = mapIndices_i.Extent();
311 Standard_Boolean someGood = Standard_False;
312 for (; ii <= nbSubSh; ii++) {
313 TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
314 if (mapIndices.Contains(aSubShape_i)) {
315 someGood = Standard_True;
316 new_id = mapIndices.FindIndex(aSubShape_i);
317 if (mapIDs.Add(new_id)) {
318 aNewIDs.Append(new_id);
323 SetErrorCode("Operation aborted: not a sub-shape given");
327 // 3. If type of group is defined - add all sub-shapes of aShape_i of that type
329 TopExp_Explorer aSubShapes_i (aShape_i, aType);
330 for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
331 TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
332 if (!mapIndices.Contains(aSubShape_i)) {
333 SetErrorCode("Operation aborted: not a sub-shape given");
336 new_id = mapIndices.FindIndex(aSubShape_i);
337 if (mapIDs.Add(new_id)) {
338 aNewIDs.Append(new_id);
344 if (aNewIDs.Extent() > 0) {
345 Standard_Integer k = 1;
346 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
347 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
348 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
349 aNewSeq->SetValue(k, aNewIDsIter.Value());
352 aSSI.SetIndices(aNewSeq);
355 //Make a Python command
356 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
357 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
358 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
360 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
361 pd << "geompy.UnionList(" << theGroup << ", [";
363 for (i = 1; i <= aLen; i++) {
364 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
365 pd << anObj_i << (( i < aLen ) ? ", " : "])");
371 //=============================================================================
375 //=============================================================================
376 void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
377 const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
380 if (theGroup.IsNull()) return;
382 Standard_Integer aLen = theSubShapes->Length();
384 SetErrorCode("The list is empty");
388 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
389 if (aFunction.IsNull()) return;
391 GEOM_ISubShape aSSI (aFunction);
393 // Map of IDs to be removed
394 TColStd_MapOfInteger mapIDsToRemove;
396 // Map of current IDs
397 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
398 if (aSeq.IsNull()) return;
399 Standard_Integer aLength = aSeq->Length();
401 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
404 TColStd_MapOfInteger mapIDsCurrent;
405 Standard_Integer j = 1;
406 for (; j <= aLength; j++) {
407 mapIDsCurrent.Add(aSeq->Value(j));
411 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
412 if (aMainShapeFunc.IsNull()) return;
413 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
414 if (aLabel.IsRoot()) return;
415 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
416 if (aMainObj.IsNull()) return;
417 TopoDS_Shape aMainShape = aMainObj->GetValue();
418 if (aMainShape.IsNull()) return;
420 TopTools_IndexedMapOfShape mapIndices;
421 TopExp::MapShapes(aMainShape, mapIndices);
424 TopAbs_ShapeEnum aType = GetType(theGroup);
426 // Get IDs of sub-shapes to be removed
427 Standard_Integer i, rem_id;
428 for (i = 1; i <= aLen; i++) {
429 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
431 TopoDS_Shape aShape_i = anObj_i->GetValue();
433 // 1. If aShape_i is sub-shape of aMainShape - remove it
434 if (mapIndices.Contains(aShape_i)) {
435 rem_id = mapIndices.FindIndex(aShape_i);
436 if (mapIDsCurrent.Contains(rem_id)) {
437 mapIDsToRemove.Add(rem_id);
440 // 2. If type of group is not defined - remove all sub-shapes of aShape_i
441 else if (aType == TopAbs_SHAPE || aType == TopAbs_COMPOUND) {
442 TopTools_IndexedMapOfShape mapIndices_i;
443 TopExp::MapShapes(aShape_i, mapIndices_i);
444 Standard_Integer nbSubSh = mapIndices_i.Extent();
445 Standard_Integer ii = 1;
446 for (; ii <= nbSubSh; ii++) {
447 TopoDS_Shape aSubShape_i = mapIndices_i.FindKey(ii);
448 if (mapIndices.Contains(aSubShape_i)) {
449 rem_id = mapIndices.FindIndex(aSubShape_i);
450 if (mapIDsCurrent.Contains(rem_id)) {
451 mapIDsToRemove.Add(rem_id);
456 // 3. If type of group is defined - remove all sub-shapes of aShape_i of that type
458 TopExp_Explorer aSubShapes_i (aShape_i, aType);
459 for (; aSubShapes_i.More(); aSubShapes_i.Next()) {
460 TopoDS_Shape aSubShape_i = aSubShapes_i.Current();
461 if (mapIndices.Contains(aSubShape_i)) {
462 rem_id = mapIndices.FindIndex(aSubShape_i);
463 if (mapIDsCurrent.Contains(rem_id)) {
464 mapIDsToRemove.Add(rem_id);
471 if (mapIDsToRemove.Extent() > 0) {
472 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
473 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
475 for (j = 1; j <= aLength; j++) {
476 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
477 aNewSeq->SetValue(k, aSeq->Value(j));
482 aSSI.SetIndices(aNewSeq);
485 //Make a Python command
486 Handle(GEOM_Object) aLatest = GEOM::GetCreatedLast(theSubShapes);
487 aLatest = GEOM::GetCreatedLast(aLatest, theGroup);
488 Handle(GEOM_Function) aLastFunc = aLatest->GetLastFunction();
490 GEOM::TPythonDump pd (aLastFunc, /*append=*/true);
491 pd << "geompy.DifferenceList(" << theGroup << ", [";
493 for (i = 1; i <= aLen; i++) {
494 Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
495 pd << anObj_i << (( i < aLen ) ? ", " : "])");
501 //=============================================================================
505 //=============================================================================
506 void GEOMImpl_IGroupOperations::UnionIDs (Handle(GEOM_Object) theGroup,
507 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
510 if (theGroup.IsNull()) return;
512 Standard_Integer aLen = theSubShapes->Length();
514 SetErrorCode("The list is empty");
518 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
519 if (aFunction.IsNull()) return;
521 GEOM_ISubShape aSSI (aFunction);
523 // New contents of the group
524 TColStd_ListOfInteger aNewIDs;
525 TColStd_MapOfInteger mapIDs;
527 // Add current IDs to the list
528 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
529 if (aSeq.IsNull()) return;
530 Standard_Integer val_j, aLength = aSeq->Length();
532 for (Standard_Integer j = 1; j <= aLength; j++) {
533 val_j = aSeq->Value(j);
534 if (val_j > 0 && mapIDs.Add(val_j)) {
535 aNewIDs.Append(val_j);
540 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
541 if (aMainShapeFunc.IsNull()) return;
542 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
543 if (aLabel.IsRoot()) return;
544 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
545 if (aMainObj.IsNull()) return;
546 TopoDS_Shape aMainShape = aMainObj->GetValue();
547 if (aMainShape.IsNull()) return;
549 TopTools_IndexedMapOfShape mapIndices;
550 TopExp::MapShapes(aMainShape, mapIndices);
552 // Get IDs of sub-shapes to add
553 Standard_Integer i, new_id;
554 for (i = 1; i <= aLen; i++) {
555 new_id = theSubShapes->Value(i);
557 if (0 < new_id && new_id <= mapIndices.Extent()) {
558 if (mapIDs.Add(new_id)) {
559 aNewIDs.Append(new_id);
564 if (aNewIDs.Extent() > 0) {
565 Standard_Integer k = 1;
566 TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
567 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
568 for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
569 aNewSeq->SetValue(k, aNewIDsIter.Value());
572 aSSI.SetIndices(aNewSeq);
575 //Make a Python command
576 GEOM::TPythonDump pd (aFunction, /*append=*/true);
577 pd << "geompy.UnionIDs(" << theGroup << ", [";
578 for (i = 1; i < aLen; i++)
579 pd << theSubShapes->Value(i) << ", ";
580 pd << theSubShapes->Value(aLen) << "])";
585 //=============================================================================
589 //=============================================================================
590 void GEOMImpl_IGroupOperations::DifferenceIDs (Handle(GEOM_Object) theGroup,
591 const Handle(TColStd_HSequenceOfInteger)& theSubShapes)
594 if (theGroup.IsNull()) return;
596 Standard_Integer aLen = theSubShapes->Length();
598 SetErrorCode("The list is empty");
602 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
603 if (aFunction.IsNull()) return;
605 GEOM_ISubShape aSSI (aFunction);
607 // Map of IDs to be removed
608 TColStd_MapOfInteger mapIDsToRemove;
610 // Map of current IDs
611 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
612 if (aSeq.IsNull()) return;
613 Standard_Integer aLength = aSeq->Length();
615 if (aLength == 1 && aSeq->Value(1) == -1) // empty group
618 TColStd_MapOfInteger mapIDsCurrent;
619 Standard_Integer j = 1;
620 for (; j <= aLength; j++) {
621 mapIDsCurrent.Add(aSeq->Value(j));
625 Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
626 if (aMainShapeFunc.IsNull()) return;
627 TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
628 if (aLabel.IsRoot()) return;
629 Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
630 if (aMainObj.IsNull()) return;
631 TopoDS_Shape aMainShape = aMainObj->GetValue();
632 if (aMainShape.IsNull()) return;
634 TopTools_IndexedMapOfShape mapIndices;
635 TopExp::MapShapes(aMainShape, mapIndices);
637 // Get IDs of sub-shapes to be removed
638 Standard_Integer i, rem_id;
639 for (i = 1; i <= aLen; i++) {
640 rem_id = theSubShapes->Value(i);
641 if (mapIDsCurrent.Contains(rem_id)) {
642 mapIDsToRemove.Add(rem_id);
646 if (mapIDsToRemove.Extent() > 0) {
647 Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
648 Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
650 for (j = 1; j <= aLength; j++) {
651 if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
652 aNewSeq->SetValue(k, aSeq->Value(j));
657 aSSI.SetIndices(aNewSeq);
660 //Make a Python command
661 GEOM::TPythonDump pd (aFunction, /*append=*/true);
662 pd << "geompy.DifferenceIDs(" << theGroup << ", [";
663 for (i = 1; i < aLen; i++)
664 pd << theSubShapes->Value(i) << ", ";
665 pd << theSubShapes->Value(aLen) << "])";
670 //=============================================================================
674 //=============================================================================
675 TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup)
679 TDF_Label aFreeLabel = theGroup->GetFreeLabel();
680 Handle(TDataStd_Integer) anAttrib;
681 if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE;
684 return (TopAbs_ShapeEnum) anAttrib->Get();
687 //=============================================================================
691 //=============================================================================
692 Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape (Handle(GEOM_Object) theGroup)
696 if(theGroup.IsNull()) return NULL;
698 Handle(GEOM_Function) aGroupFunction = theGroup->GetFunction(1);
699 if (aGroupFunction.IsNull()) return NULL;
701 GEOM_ISubShape aSSI (aGroupFunction);
702 Handle(GEOM_Function) aMainShapeFunction = aSSI.GetMainShape();
703 if (aMainShapeFunction.IsNull()) return NULL;
705 TDF_Label aLabel = aMainShapeFunction->GetOwnerEntry();
706 Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel);
707 if (aMainShape.IsNull()) return NULL;
709 //Make a Python command
710 GEOM::TPythonDump(aGroupFunction, /*append=*/true)
711 << aMainShape << " = geompy.GetMainShape(" << theGroup << ")";
717 //=============================================================================
721 //=============================================================================
722 Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
726 if(theGroup.IsNull()) return NULL;
728 Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
729 if(aFunction.IsNull()) return NULL;
731 GEOM_ISubShape aSSI(aFunction);
732 Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
733 if(aSeq.IsNull()) return NULL;
735 if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {