2004-12-01 15:39:14 +05:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "GEOMImpl_IGroupOperations.hxx"
|
|
|
|
|
2005-02-04 11:55:40 +05:00
|
|
|
#include "GEOMImpl_Types.hxx"
|
|
|
|
|
|
|
|
#include "GEOM_Function.hxx"
|
|
|
|
#include "GEOM_ISubShape.hxx"
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "utilities.h"
|
|
|
|
#include "OpUtil.hxx"
|
|
|
|
#include "Utils_ExceptHandlers.hxx"
|
|
|
|
|
|
|
|
#include <TFunction_DriverTable.hxx>
|
|
|
|
#include <TFunction_Driver.hxx>
|
|
|
|
#include <TFunction_Logbook.hxx>
|
|
|
|
#include <TDF_Tool.hxx>
|
|
|
|
#include <TDataStd_Integer.hxx>
|
|
|
|
|
|
|
|
#include <TopExp.hxx>
|
|
|
|
#include <TopTools_IndexedMapOfShape.hxx>
|
2005-02-04 11:55:40 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <TColStd_HArray1OfInteger.hxx>
|
2005-02-04 11:55:40 +05:00
|
|
|
#include <TColStd_MapOfInteger.hxx>
|
|
|
|
#include <TColStd_ListOfInteger.hxx>
|
|
|
|
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* constructor:
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations (GEOM_Engine* theEngine, int theDocID)
|
|
|
|
: GEOM_IOperations(theEngine, theDocID)
|
|
|
|
{
|
|
|
|
MESSAGE("GEOMImpl_IGroupOperations::GEOMImpl_IGroupOperations");
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* destructor
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations()
|
|
|
|
{
|
|
|
|
MESSAGE("GEOMImpl_IGroupOperations::~GEOMImpl_IGroupOperations");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* CreateGroup
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Handle(GEOM_Object) GEOMImpl_IGroupOperations::CreateGroup(Handle(GEOM_Object) theMainShape, TopAbs_ShapeEnum theShapeType)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
|
|
|
|
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
|
|
|
|
anArray->SetValue(1, -1);
|
|
|
|
|
|
|
|
//Add a new Fillet object
|
|
|
|
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theMainShape, anArray);
|
|
|
|
|
|
|
|
//Set a GROUP type
|
|
|
|
aGroup->SetType(GEOM_GROUP);
|
|
|
|
|
|
|
|
//Set a sub shape type
|
|
|
|
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
|
|
|
|
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
|
|
|
|
|
|
|
|
//Make a Python command
|
|
|
|
TCollection_AsciiString anEntry, aDescr("");
|
|
|
|
TDF_Tool::Entry(aGroup->GetEntry(), anEntry);
|
|
|
|
aDescr = anEntry + " = IGroupOperations.CreateGroup(";
|
|
|
|
TDF_Tool::Entry(theMainShape->GetEntry(), anEntry);
|
|
|
|
aDescr += (anEntry+", ");
|
|
|
|
aDescr += (TCollection_AsciiString((int)theShapeType)+")");
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1);
|
|
|
|
aFunction->SetDescription(aDescr);
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return aGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* AddObject
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOMImpl_IGroupOperations::AddObject(Handle(GEOM_Object) theGroup, int theSubShapeID)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
2005-02-04 11:55:40 +05:00
|
|
|
if(theGroup.IsNull()) return;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
|
|
|
if(aFunction.IsNull()) return;
|
2005-02-04 11:55:40 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM_ISubShape aSSI(aFunction);
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
|
|
|
|
if(aSeq.IsNull()) return;
|
|
|
|
if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
|
|
|
|
aSeq->SetValue(1, theSubShapeID);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Standard_Integer aLength = aSeq->Length();
|
|
|
|
Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength+1);
|
|
|
|
for(Standard_Integer i = 1; i<=aLength; i++) {
|
|
|
|
aNewSeq->SetValue(i, aSeq->Value(i));
|
|
|
|
if(aSeq->Value(i) == theSubShapeID) {
|
|
|
|
SetErrorCode(ALREADY_PRESENT);
|
|
|
|
return; //
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aNewSeq->SetValue(aLength+1, theSubShapeID);
|
|
|
|
aSSI.SetIndices(aNewSeq);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* RemoveObject
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOMImpl_IGroupOperations::RemoveObject(Handle(GEOM_Object) theGroup, int theSubShapeID)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
2005-02-04 11:55:40 +05:00
|
|
|
if(theGroup.IsNull()) return;
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-02-04 11:55:40 +05:00
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
2004-12-01 15:39:14 +05:00
|
|
|
if(aFunction.IsNull()) return;
|
2005-02-04 11:55:40 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
GEOM_ISubShape aSSI(aFunction);
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
|
|
|
|
if(aSeq.IsNull()) return;
|
|
|
|
if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
|
|
|
|
SetErrorCode(NOT_EXISTS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Handle(TColStd_HArray1OfInteger) aNewSeq;
|
|
|
|
Standard_Integer aLength = aSeq->Length();
|
|
|
|
if(aLength == 1) {
|
|
|
|
if(aSeq->Value(1) != theSubShapeID) {
|
|
|
|
SetErrorCode(NOT_EXISTS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
aNewSeq = new TColStd_HArray1OfInteger(1,1);
|
|
|
|
aNewSeq->SetValue(1, -1);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aNewSeq = new TColStd_HArray1OfInteger(1, aLength-1);
|
|
|
|
Standard_Boolean isFound = Standard_False;
|
|
|
|
for(Standard_Integer i = 1, k=1; i<=aLength; i++) {
|
|
|
|
if(i == aLength && !isFound) {
|
|
|
|
SetErrorCode(NOT_EXISTS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(aSeq->Value(i) == theSubShapeID) {
|
|
|
|
isFound = Standard_True;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
aNewSeq->SetValue(k, aSeq->Value(i));
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!isFound) {
|
|
|
|
SetErrorCode(NOT_EXISTS);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aSSI.SetIndices(aNewSeq);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-02-04 11:55:40 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* UnionList
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOMImpl_IGroupOperations::UnionList (Handle(GEOM_Object) theGroup,
|
|
|
|
const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
if (theGroup.IsNull()) return;
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
|
|
|
if (aFunction.IsNull()) return;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI (aFunction);
|
|
|
|
|
|
|
|
// New contents of the group
|
|
|
|
TColStd_ListOfInteger aNewIDs;
|
|
|
|
TColStd_MapOfInteger mapIDs;
|
|
|
|
|
|
|
|
// Add current IDs to the list
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
|
|
|
|
if (aSeq.IsNull()) return;
|
|
|
|
Standard_Integer val_j, aLength = aSeq->Length();
|
|
|
|
|
|
|
|
for (Standard_Integer j = 1; j <= aLength; j++) {
|
|
|
|
val_j = aSeq->Value(j);
|
|
|
|
if (val_j > 0 && mapIDs.Add(val_j)) {
|
|
|
|
aNewIDs.Append(val_j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get Main Shape
|
|
|
|
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
|
|
|
|
if (aMainShapeFunc.IsNull()) return;
|
|
|
|
TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
|
|
|
|
if (aLabel.IsRoot()) return;
|
|
|
|
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
|
|
|
|
if (aMainObj.IsNull()) return;
|
|
|
|
TopoDS_Shape aMainShape = aMainObj->GetValue();
|
|
|
|
if (aMainShape.IsNull()) return;
|
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape mapIndices;
|
|
|
|
TopExp::MapShapes(aMainShape, mapIndices);
|
|
|
|
|
|
|
|
// Get IDs of sub-shapes to add
|
|
|
|
Standard_Integer i, new_id, aLen = theSubShapes->Length();
|
|
|
|
for (i = 1; i <= aLen; i++) {
|
|
|
|
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
|
|
|
|
|
|
|
|
if (anObj_i->IsMainShape()) {
|
|
|
|
TopoDS_Shape aShape_i = anObj_i->GetValue();
|
|
|
|
if (mapIndices.Contains(aShape_i)) {
|
|
|
|
new_id = mapIndices.FindIndex(aShape_i);
|
|
|
|
if (mapIDs.Add(new_id)) {
|
|
|
|
aNewIDs.Append(new_id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Check main shape of sub-shape to add
|
|
|
|
Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
|
|
|
|
if (aFunc_i.IsNull()) return;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI_i (aFunc_i);
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
|
|
|
|
if (aMainShapeFunc_i.IsNull()) return;
|
|
|
|
TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
|
|
|
|
if (aLabel_i.IsRoot()) return;
|
|
|
|
Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
|
|
|
|
if (aMainObj_i.IsNull()) return;
|
|
|
|
TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
|
|
|
|
if (aMainShape_i.IsNull()) return;
|
|
|
|
|
|
|
|
if (aMainShape_i.IsSame(aMainShape)) {
|
|
|
|
// add all sub-shape IDs to the list
|
|
|
|
|
|
|
|
// Get IDs
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
|
|
|
|
if (aSeq_i.IsNull()) return;
|
|
|
|
Standard_Integer aLength_i = aSeq_i->Length();
|
|
|
|
|
|
|
|
for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
|
|
|
|
new_id = aSeq_i->Value(i_j);
|
|
|
|
if (new_id > 0) {
|
|
|
|
if (mapIDs.Add(new_id)) {
|
|
|
|
aNewIDs.Append(new_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (mapIndices.Contains(aMainShape_i)) {
|
|
|
|
// compute new IDs and add them to the list
|
|
|
|
TopTools_IndexedMapOfShape mapIndices_i;
|
|
|
|
TopExp::MapShapes(aMainShape_i, mapIndices_i);
|
|
|
|
|
|
|
|
// Get IDs
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
|
|
|
|
if (aSeq_i.IsNull()) return;
|
|
|
|
Standard_Integer aLength_i = aSeq_i->Length();
|
|
|
|
|
|
|
|
for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
|
|
|
|
if (aSeq_i->Value(i_j) > 0) {
|
|
|
|
TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
|
|
|
|
new_id = mapIndices.FindIndex(aShape_i_j);
|
|
|
|
if (mapIDs.Add(new_id)) {
|
|
|
|
aNewIDs.Append(new_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
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");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aNewIDs.Extent() > 0) {
|
|
|
|
Standard_Integer k = 1;
|
|
|
|
TColStd_ListIteratorOfListOfInteger aNewIDsIter (aNewIDs);
|
|
|
|
Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aNewIDs.Extent());
|
|
|
|
for (; aNewIDsIter.More(); aNewIDsIter.Next(), k++) {
|
|
|
|
aNewSeq->SetValue(k, aNewIDsIter.Value());
|
|
|
|
}
|
|
|
|
|
|
|
|
aSSI.SetIndices(aNewSeq);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* DifferenceList
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
void GEOMImpl_IGroupOperations::DifferenceList (Handle(GEOM_Object) theGroup,
|
|
|
|
const Handle(TColStd_HSequenceOfTransient)& theSubShapes)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
if (theGroup.IsNull()) return;
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
|
|
|
if (aFunction.IsNull()) return;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI (aFunction);
|
|
|
|
|
|
|
|
// Map of IDs to be removed
|
|
|
|
TColStd_MapOfInteger mapIDsToRemove;
|
|
|
|
|
|
|
|
// Map of current IDs
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
|
|
|
|
if (aSeq.IsNull()) return;
|
|
|
|
Standard_Integer aLength = aSeq->Length();
|
|
|
|
|
|
|
|
if (aLength == 1 && aSeq->Value(1) == -1) // empty group
|
|
|
|
return;
|
|
|
|
|
|
|
|
TColStd_MapOfInteger mapIDsCurrent;
|
|
|
|
Standard_Integer j = 1;
|
|
|
|
for (; j <= aLength; j++) {
|
|
|
|
mapIDsCurrent.Add(aSeq->Value(j));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get Main Shape
|
|
|
|
Handle(GEOM_Function) aMainShapeFunc = aSSI.GetMainShape();
|
|
|
|
if (aMainShapeFunc.IsNull()) return;
|
|
|
|
TDF_Label aLabel = aMainShapeFunc->GetOwnerEntry();
|
|
|
|
if (aLabel.IsRoot()) return;
|
|
|
|
Handle(GEOM_Object) aMainObj = GEOM_Object::GetObject(aLabel);
|
|
|
|
if (aMainObj.IsNull()) return;
|
|
|
|
TopoDS_Shape aMainShape = aMainObj->GetValue();
|
|
|
|
if (aMainShape.IsNull()) return;
|
|
|
|
|
|
|
|
TopTools_IndexedMapOfShape mapIndices;
|
|
|
|
TopExp::MapShapes(aMainShape, mapIndices);
|
|
|
|
|
|
|
|
// Get IDs of sub-shapes to be removed
|
|
|
|
Standard_Integer i, rem_id, aLen = theSubShapes->Length();
|
|
|
|
for (i = 1; i <= aLen; i++) {
|
|
|
|
Handle(GEOM_Object) anObj_i = Handle(GEOM_Object)::DownCast(theSubShapes->Value(i));
|
|
|
|
|
|
|
|
if (anObj_i->IsMainShape()) {
|
|
|
|
TopoDS_Shape aShape_i = anObj_i->GetValue();
|
|
|
|
if (mapIndices.Contains(aShape_i)) {
|
|
|
|
rem_id = mapIndices.FindIndex(aShape_i);
|
|
|
|
if (mapIDsCurrent.Contains(rem_id)) {
|
|
|
|
mapIDsToRemove.Add(rem_id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
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");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Check main shape of sub-shape to be removed
|
|
|
|
Handle(GEOM_Function) aFunc_i = anObj_i->GetFunction(1);
|
|
|
|
if (aFunc_i.IsNull()) return;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI_i (aFunc_i);
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aMainShapeFunc_i = aSSI_i.GetMainShape();
|
|
|
|
if (aMainShapeFunc_i.IsNull()) return;
|
|
|
|
TDF_Label aLabel_i = aMainShapeFunc_i->GetOwnerEntry();
|
|
|
|
if (aLabel_i.IsRoot()) return;
|
|
|
|
Handle(GEOM_Object) aMainObj_i = GEOM_Object::GetObject(aLabel);
|
|
|
|
if (aMainObj_i.IsNull()) return;
|
|
|
|
TopoDS_Shape aMainShape_i = aMainObj_i->GetValue();
|
|
|
|
if (aMainShape_i.IsNull()) return;
|
|
|
|
|
|
|
|
if (aMainShape_i.IsSame(aMainShape)) {
|
|
|
|
// remove all sub-shapes
|
|
|
|
|
|
|
|
// Get IDs
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
|
|
|
|
if (aSeq_i.IsNull()) return;
|
|
|
|
Standard_Integer aLength_i = aSeq_i->Length();
|
|
|
|
|
|
|
|
for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
|
|
|
|
rem_id = aSeq_i->Value(i_j);
|
|
|
|
if (rem_id > 0) {
|
|
|
|
if (mapIDsCurrent.Contains(rem_id)) {
|
|
|
|
mapIDsToRemove.Add(rem_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if (mapIndices.Contains(aMainShape_i)) {
|
|
|
|
// compute new IDs and add them to the map of ids to be removed
|
|
|
|
TopTools_IndexedMapOfShape mapIndices_i;
|
|
|
|
TopExp::MapShapes(aMainShape_i, mapIndices_i);
|
|
|
|
|
|
|
|
// Get IDs
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq_i = aSSI_i.GetIndices();
|
|
|
|
if (aSeq_i.IsNull()) return;
|
|
|
|
Standard_Integer aLength_i = aSeq_i->Length();
|
|
|
|
|
|
|
|
for (Standard_Integer i_j = 1; i_j <= aLength_i; i_j++) {
|
|
|
|
if (aSeq_i->Value(i_j) > 0) {
|
|
|
|
TopoDS_Shape aShape_i_j = mapIndices_i.FindKey(i_j);
|
|
|
|
rem_id = mapIndices.FindIndex(aShape_i_j);
|
|
|
|
if (mapIDsCurrent.Contains(rem_id)) {
|
|
|
|
mapIDsToRemove.Add(rem_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
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");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mapIDsToRemove.Extent() > 0) {
|
|
|
|
Standard_Integer k = 1, aRemLength = mapIDsToRemove.Extent();
|
|
|
|
Handle(TColStd_HArray1OfInteger) aNewSeq = new TColStd_HArray1OfInteger(1, aLength - aRemLength);
|
|
|
|
|
|
|
|
for (j = 1; j <= aLength; j++) {
|
|
|
|
if (!mapIDsToRemove.Contains(aSeq->Value(j))) {
|
|
|
|
aNewSeq->SetValue(k, aSeq->Value(j));
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aSSI.SetIndices(aNewSeq);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetType
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
TopAbs_ShapeEnum GEOMImpl_IGroupOperations::GetType(Handle(GEOM_Object) theGroup)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
|
|
|
|
TDF_Label aFreeLabel = theGroup->GetFreeLabel();
|
|
|
|
Handle(TDataStd_Integer) anAttrib;
|
|
|
|
if(!aFreeLabel.FindAttribute(TDataStd_Integer::GetID(), anAttrib)) return TopAbs_SHAPE;
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return (TopAbs_ShapeEnum) anAttrib->Get();
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetMainShape
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Handle(GEOM_Object) GEOMImpl_IGroupOperations::GetMainShape(Handle(GEOM_Object) theGroup)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
|
|
|
|
if(theGroup.IsNull()) return NULL;
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
|
|
|
if(aFunction.IsNull()) return NULL;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI(aFunction);
|
|
|
|
aFunction = aSSI.GetMainShape();
|
|
|
|
if(aFunction.IsNull()) return NULL;
|
|
|
|
|
|
|
|
TDF_Label aLabel = aFunction->GetOwnerEntry();
|
|
|
|
Handle(GEOM_Object) aMainShape = GEOM_Object::GetObject(aLabel);
|
|
|
|
if(aMainShape.IsNull()) return NULL;
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return aMainShape;
|
|
|
|
}
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*!
|
|
|
|
* GetObjects
|
|
|
|
*/
|
|
|
|
//=============================================================================
|
|
|
|
Handle(TColStd_HArray1OfInteger) GEOMImpl_IGroupOperations::GetObjects(Handle(GEOM_Object) theGroup)
|
|
|
|
{
|
|
|
|
SetErrorCode(KO);
|
|
|
|
|
|
|
|
if(theGroup.IsNull()) return NULL;
|
|
|
|
|
|
|
|
Handle(GEOM_Function) aFunction = theGroup->GetFunction(1);
|
|
|
|
if(aFunction.IsNull()) return NULL;
|
|
|
|
|
|
|
|
GEOM_ISubShape aSSI(aFunction);
|
|
|
|
Handle(TColStd_HArray1OfInteger) aSeq = aSSI.GetIndices();
|
|
|
|
if(aSeq.IsNull()) return NULL;
|
|
|
|
|
|
|
|
if(aSeq->Length() == 1 && aSeq->Value(1) == -1) {
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
SetErrorCode(OK);
|
|
|
|
return aSeq;
|
|
|
|
}
|