3 #include "GEOM_IGroupOperations_i.hh"
7 #include "Utils_ExceptHandlers.hxx"
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
12 #include <TColStd_HArray1OfInteger.hxx>
15 //=============================================================================
19 //=============================================================================
20 GEOM_IGroupOperations_i::GEOM_IGroupOperations_i (PortableServer::POA_ptr thePOA,
21 GEOM::GEOM_Gen_ptr theEngine,
22 ::GEOMImpl_IGroupOperations* theImpl)
23 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
25 MESSAGE("GEOM_IGroupOperations_i::GEOM_IGroupOperations_i");
28 //=============================================================================
32 //=============================================================================
33 GEOM_IGroupOperations_i::~GEOM_IGroupOperations_i()
35 MESSAGE("GEOM_IGroupOperations_i::~GEOM_IGroupOperations_i");
39 //=============================================================================
43 //=============================================================================
44 GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::CreateGroup(GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theShapeType)
46 GEOM::GEOM_Object_var aGEOMObject;
49 GetOperations()->SetNotDone();
51 if (theMainShape == NULL || theShapeType < 0) return aGEOMObject._retn();
53 //Get the reference shape
54 Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject(theMainShape->GetStudyID(), theMainShape->GetEntry());
56 if (aShapeRef.IsNull()) return aGEOMObject._retn();
59 Handle(GEOM_Object) anObject = GetOperations()->CreateGroup(aShapeRef, (TopAbs_ShapeEnum)theShapeType);
60 if (!GetOperations()->IsDone() || anObject.IsNull())
61 return aGEOMObject._retn();
63 return GetObject(anObject);
66 //=============================================================================
70 //=============================================================================
71 void GEOM_IGroupOperations_i::AddObject(GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId)
74 GetOperations()->SetNotDone();
76 if (theGroup == NULL) return;
78 //Get the reference group
79 Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry());
80 if (aGroupRef.IsNull()) return;
82 GetOperations()->AddObject(aGroupRef, theSubShapeId);
86 //=============================================================================
90 //=============================================================================
91 void GEOM_IGroupOperations_i::RemoveObject(GEOM::GEOM_Object_ptr theGroup, CORBA::Long theSubShapeId)
94 GetOperations()->SetNotDone();
96 if (theGroup == NULL) return;
98 //Get the reference group
99 Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry());
100 if (aGroupRef.IsNull()) return;
102 GetOperations()->RemoveObject(aGroupRef, theSubShapeId);
107 //=============================================================================
111 //=============================================================================
112 CORBA::Long GEOM_IGroupOperations_i::GetType(GEOM::GEOM_Object_ptr theGroup)
114 //Set a not done flag
115 GetOperations()->SetNotDone();
117 if (theGroup == NULL) return -1;
119 //Get the reference group
120 Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry());
122 if (aGroupRef.IsNull()) return -1;
124 return GetOperations()->GetType(aGroupRef);
127 //=============================================================================
131 //=============================================================================
132 GEOM::GEOM_Object_ptr GEOM_IGroupOperations_i::GetMainShape(GEOM::GEOM_Object_ptr theGroup)
134 GEOM::GEOM_Object_var aGEOMObject;
136 //Set a not done flag
137 GetOperations()->SetNotDone();
139 if (theGroup == NULL) return aGEOMObject._retn();
141 //Get the reference group
142 Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry());
143 if (aGroupRef.IsNull()) return aGEOMObject._retn();
145 Handle(GEOM_Object) anObject = GetOperations()->GetMainShape(aGroupRef);
146 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
148 return GetObject(anObject);
151 //=============================================================================
155 //=============================================================================
156 GEOM::ListOfLong* GEOM_IGroupOperations_i::GetObjects(GEOM::GEOM_Object_ptr theGroup)
158 GEOM::ListOfLong_var aList;
160 //Set a not done flag
161 GetOperations()->SetNotDone();
163 if (theGroup == NULL) return aList._retn();
165 //Get the reference group
166 Handle(GEOM_Object) aGroupRef = GetOperations()->GetEngine()->GetObject(theGroup->GetStudyID(), theGroup->GetEntry());
167 if (aGroupRef.IsNull()) return aList._retn();
169 aList = new GEOM::ListOfLong;
171 Handle(TColStd_HArray1OfInteger) aSeq = GetOperations()->GetObjects(aGroupRef);
172 if (!GetOperations()->IsDone() || aSeq.IsNull()) return aList._retn();
174 aList->length(aSeq->Length());
175 for(int i = 1; i<=aSeq->Length(); i++) aList[i-1] = aSeq->Value(i);
177 return aList._retn();