3 #include "GEOM_IShapesOperations_i.hh"
7 #include "Utils_ExceptHandlers.hxx"
9 #include "GEOM_Engine.hxx"
10 #include "GEOM_Object.hxx"
12 #include <TColStd_HSequenceOfTransient.hxx>
13 #include <TColStd_HArray1OfInteger.hxx>
15 //=============================================================================
19 //=============================================================================
20 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
21 GEOM::GEOM_Gen_ptr theEngine,
22 ::GEOMImpl_IShapesOperations* theImpl)
23 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
25 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
28 //=============================================================================
32 //=============================================================================
33 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
35 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
39 //=============================================================================
43 //=============================================================================
44 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
45 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
47 GEOM::GEOM_Object_var aGEOMObject;
50 GetOperations()->SetNotDone();
52 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
54 //Get the reference points
55 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
56 (thePnt1->GetStudyID(), thePnt1->GetEntry());
57 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
58 (thePnt2->GetStudyID(), thePnt2->GetEntry());
60 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
63 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
64 if (!GetOperations()->IsDone() || anObject.IsNull())
65 return aGEOMObject._retn();
67 return GetObject(anObject);
70 //=============================================================================
74 //=============================================================================
75 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
76 (const GEOM::ListOfGO& theEdgesAndWires)
78 GEOM::GEOM_Object_var aGEOMObject;
81 GetOperations()->SetNotDone();
84 list<Handle(GEOM_Object)> aShapes;
87 aLen = theEdgesAndWires.length();
88 for (ind = 0; ind < aLen; ind++) {
89 if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn();
90 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
91 (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry());
92 if (aSh.IsNull()) return aGEOMObject._retn();
93 aShapes.push_back(aSh);
97 Handle(GEOM_Object) anObject =
98 GetOperations()->MakeWire(aShapes);
99 if (!GetOperations()->IsDone() || anObject.IsNull())
100 return aGEOMObject._retn();
102 return GetObject(anObject);
105 //=============================================================================
109 //=============================================================================
110 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
111 (GEOM::GEOM_Object_ptr theWire, CORBA::Boolean isPlanarWanted)
113 GEOM::GEOM_Object_var aGEOMObject;
115 //Set a not done flag
116 GetOperations()->SetNotDone();
118 if (theWire == NULL) return aGEOMObject._retn();
120 //Get the reference wire
121 Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject
122 (theWire->GetStudyID(), theWire->GetEntry());
124 if (aWire.IsNull()) return aGEOMObject._retn();
127 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
128 if (!GetOperations()->IsDone() || anObject.IsNull())
129 return aGEOMObject._retn();
131 return GetObject(anObject);
134 //=============================================================================
138 //=============================================================================
139 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
140 (const GEOM::ListOfGO& theWires,
141 CORBA::Boolean isPlanarWanted)
143 GEOM::GEOM_Object_var aGEOMObject;
145 //Set a not done flag
146 GetOperations()->SetNotDone();
149 list<Handle(GEOM_Object)> aShapes;
152 aLen = theWires.length();
153 for (ind = 0; ind < aLen; ind++) {
154 if (theWires[ind] == NULL) return aGEOMObject._retn();
155 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
156 (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry());
157 if (aSh.IsNull()) return aGEOMObject._retn();
158 aShapes.push_back(aSh);
162 Handle(GEOM_Object) anObject =
163 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
164 if (!GetOperations()->IsDone() || anObject.IsNull())
165 return aGEOMObject._retn();
167 return GetObject(anObject);
170 //=============================================================================
174 //=============================================================================
175 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
176 (const GEOM::ListOfGO& theFacesAndShells)
178 GEOM::GEOM_Object_var aGEOMObject;
180 //Set a not done flag
181 GetOperations()->SetNotDone();
184 list<Handle(GEOM_Object)> aShapes;
187 aLen = theFacesAndShells.length();
188 for (ind = 0; ind < aLen; ind++) {
189 if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn();
190 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
191 (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry());
192 if (aSh.IsNull()) return aGEOMObject._retn();
193 aShapes.push_back(aSh);
197 Handle(GEOM_Object) anObject =
198 GetOperations()->MakeShell(aShapes);
199 if (!GetOperations()->IsDone() || anObject.IsNull())
200 return aGEOMObject._retn();
202 return GetObject(anObject);
205 //=============================================================================
209 //=============================================================================
210 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
211 (GEOM::GEOM_Object_ptr theShell)
213 GEOM::GEOM_Object_var aGEOMObject;
215 //Set a not done flag
216 GetOperations()->SetNotDone();
218 if (theShell == NULL) return aGEOMObject._retn();
220 //Get the reference objects
221 Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject
222 (theShell->GetStudyID(), theShell->GetEntry());
224 if (aShell.IsNull()) return aGEOMObject._retn();
227 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
228 if (!GetOperations()->IsDone() || anObject.IsNull())
229 return aGEOMObject._retn();
231 return GetObject(anObject);
234 //=============================================================================
238 //=============================================================================
239 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
240 (const GEOM::ListOfGO& theShells)
242 GEOM::GEOM_Object_var aGEOMObject;
244 //Set a not done flag
245 GetOperations()->SetNotDone();
248 list<Handle(GEOM_Object)> aShapes;
251 aLen = theShells.length();
252 for (ind = 0; ind < aLen; ind++) {
253 if (theShells[ind] == NULL) return aGEOMObject._retn();
254 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
255 (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry());
256 if (aSh.IsNull()) return aGEOMObject._retn();
257 aShapes.push_back(aSh);
261 Handle(GEOM_Object) anObject =
262 GetOperations()->MakeSolidShells(aShapes);
263 if (!GetOperations()->IsDone() || anObject.IsNull())
264 return aGEOMObject._retn();
266 return GetObject(anObject);
269 //=============================================================================
273 //=============================================================================
274 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
275 (const GEOM::ListOfGO& theShapes)
277 GEOM::GEOM_Object_var aGEOMObject;
279 //Set a not done flag
280 GetOperations()->SetNotDone();
283 list<Handle(GEOM_Object)> aShapes;
286 aLen = theShapes.length();
287 for (ind = 0; ind < aLen; ind++) {
288 if (theShapes[ind] == NULL) return aGEOMObject._retn();
289 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
290 (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
291 if (aSh.IsNull()) return aGEOMObject._retn();
292 aShapes.push_back(aSh);
296 Handle(GEOM_Object) anObject =
297 GetOperations()->MakeCompound(aShapes);
298 if (!GetOperations()->IsDone() || anObject.IsNull())
299 return aGEOMObject._retn();
301 return GetObject(anObject);
304 //=============================================================================
308 //=============================================================================
309 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
310 (GEOM::GEOM_Object_ptr theShape,
311 const CORBA::Double theTolerance)
313 GEOM::GEOM_Object_var aGEOMObject;
315 //Set a not done flag
316 GetOperations()->SetNotDone();
318 if (theShape == NULL) return aGEOMObject._retn();
320 //Get the reference objects
321 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
322 (theShape->GetStudyID(), theShape->GetEntry());
324 if (aShape.IsNull()) return aGEOMObject._retn();
326 //Perform the glueing
327 Handle(GEOM_Object) anObject =
328 GetOperations()->MakeGlueFaces(aShape, theTolerance);
329 if (!GetOperations()->IsDone() || anObject.IsNull())
330 return aGEOMObject._retn();
332 return GetObject(anObject);
335 //=============================================================================
339 //=============================================================================
340 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
341 const CORBA::Long theShapeType,
342 const CORBA::Boolean isSorted)
344 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
345 if (theShape == NULL) return aSeq._retn();
346 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject(theShape->GetStudyID(), theShape->GetEntry());
347 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
348 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
350 Standard_Integer aLength = aHSeq->Length();
351 aSeq->length(aLength);
352 for (Standard_Integer i = 1; i <= aLength; i++)
353 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
358 //=============================================================================
362 //=============================================================================
363 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
364 (GEOM::GEOM_Object_ptr theMainShape,
365 const CORBA::Long theID)
367 GEOM::GEOM_Object_var aGEOMObject;
369 //Set a not done flag
370 GetOperations()->SetNotDone();
372 if (theMainShape == NULL) return aGEOMObject._retn();
374 //Get the reference objects
375 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
376 (theMainShape->GetStudyID(), theMainShape->GetEntry());
378 if (aShape.IsNull()) return aGEOMObject._retn();
380 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
381 if (!GetOperations()->IsDone() || anObject.IsNull())
382 return aGEOMObject._retn();
384 return GetObject(anObject);
387 //=============================================================================
391 //=============================================================================
392 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
394 if (theShape == NULL) return -1;
396 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
397 (theShape->GetStudyID(), theShape->GetEntry());
399 CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
400 if (!GetOperations()->IsDone()) return -1;
405 //=============================================================================
409 //=============================================================================
410 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
412 if (theShape == NULL) return -1;
414 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
415 (theShape->GetStudyID(), theShape->GetEntry());
417 CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
418 if (!GetOperations()->IsDone()) return -1;
423 //=============================================================================
427 //=============================================================================
428 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
429 (GEOM::GEOM_Object_ptr theShape)
431 GEOM::GEOM_Object_var aGEOMObject;
433 //Set a not done flag
434 GetOperations()->SetNotDone();
436 if (theShape == NULL) return aGEOMObject._retn();
438 //Get the reference objects
439 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
440 (theShape->GetStudyID(), theShape->GetEntry());
442 if (aShape.IsNull()) return aGEOMObject._retn();
445 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
446 if (!GetOperations()->IsDone() || anObject.IsNull())
447 return aGEOMObject._retn();
449 return GetObject(anObject);