1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include "GEOM_IShapesOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
34 #include <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
37 //=============================================================================
41 //=============================================================================
42 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
43 GEOM::GEOM_Gen_ptr theEngine,
44 ::GEOMImpl_IShapesOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
47 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
50 //=============================================================================
54 //=============================================================================
55 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
57 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
61 //=============================================================================
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
67 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
69 GEOM::GEOM_Object_var aGEOMObject;
72 GetOperations()->SetNotDone();
74 //Get the reference points
75 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
76 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
78 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
81 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
82 if (!GetOperations()->IsDone() || anObject.IsNull())
83 return aGEOMObject._retn();
85 return GetObject(anObject);
88 //=============================================================================
90 * MakeEdgeOnCurveByLength
92 //=============================================================================
93 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
94 (GEOM::GEOM_Object_ptr theCurve,
95 CORBA::Double theLength,
96 GEOM::GEOM_Object_ptr theStartPoint)
98 GEOM::GEOM_Object_var aGEOMObject;
100 //Set a not done flag
101 GetOperations()->SetNotDone();
103 //Get the reference curve
104 Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
105 if (aRefCurve.IsNull()) return aGEOMObject._retn();
107 //Get the reference point (can be NULL)
108 Handle(GEOM_Object) aRefPoint;
109 if (!CORBA::is_nil(theStartPoint)) {
110 aRefPoint = GetObjectImpl(theStartPoint);
114 Handle(GEOM_Object) anObject =
115 GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
116 if (!GetOperations()->IsDone() || anObject.IsNull())
117 return aGEOMObject._retn();
119 return GetObject(anObject);
122 //=============================================================================
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
128 (GEOM::GEOM_Object_ptr theWire,
129 const CORBA::Double theLinearTolerance,
130 const CORBA::Double theAngularTolerance)
132 GEOM::GEOM_Object_var aGEOMObject;
134 //Set a not done flag
135 GetOperations()->SetNotDone();
137 //Get the source wire
138 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
140 if (aWire.IsNull()) return aGEOMObject._retn();
143 Handle(GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
144 if (!GetOperations()->IsDone() || anObject.IsNull())
145 return aGEOMObject._retn();
147 return GetObject(anObject);
150 //=============================================================================
154 //=============================================================================
155 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
156 (const GEOM::ListOfGO& theEdgesAndWires,
157 const CORBA::Double theTolerance)
159 GEOM::GEOM_Object_var aGEOMObject;
161 //Set a not done flag
162 GetOperations()->SetNotDone();
165 std::list<Handle(GEOM_Object)> aShapes;
168 aLen = theEdgesAndWires.length();
169 for (ind = 0; ind < aLen; ind++) {
170 Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
171 if (aSh.IsNull()) return aGEOMObject._retn();
172 aShapes.push_back(aSh);
176 Handle(GEOM_Object) anObject =
177 GetOperations()->MakeWire(aShapes, theTolerance);
178 if (!GetOperations()->IsDone() || anObject.IsNull())
179 return aGEOMObject._retn();
181 return GetObject(anObject);
184 //=============================================================================
188 //=============================================================================
189 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
190 (GEOM::GEOM_Object_ptr theWire,
191 const CORBA::Boolean isPlanarWanted)
193 GEOM::GEOM_Object_var aGEOMObject;
195 //Set a not done flag
196 GetOperations()->SetNotDone();
198 //Get the reference wire
199 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
200 if (aWire.IsNull()) return aGEOMObject._retn();
203 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
204 if (!GetOperations()->IsDone() || anObject.IsNull())
205 return aGEOMObject._retn();
207 return GetObject(anObject);
210 //=============================================================================
214 //=============================================================================
215 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
216 (const GEOM::ListOfGO& theWires,
217 const CORBA::Boolean isPlanarWanted)
219 GEOM::GEOM_Object_var aGEOMObject;
221 //Set a not done flag
222 GetOperations()->SetNotDone();
225 std::list<Handle(GEOM_Object)> aShapes;
228 aLen = theWires.length();
229 for (ind = 0; ind < aLen; ind++) {
230 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
231 if (aSh.IsNull()) return aGEOMObject._retn();
232 aShapes.push_back(aSh);
236 Handle(GEOM_Object) anObject =
237 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
238 if (!GetOperations()->IsDone() || anObject.IsNull())
239 return aGEOMObject._retn();
241 return GetObject(anObject);
244 //=============================================================================
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
250 (const GEOM::ListOfGO& theFacesAndShells)
252 GEOM::GEOM_Object_var aGEOMObject;
254 //Set a not done flag
255 GetOperations()->SetNotDone();
258 std::list<Handle(GEOM_Object)> aShapes;
261 aLen = theFacesAndShells.length();
262 for (ind = 0; ind < aLen; ind++) {
263 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
264 if (aSh.IsNull()) return aGEOMObject._retn();
265 aShapes.push_back(aSh);
269 Handle(GEOM_Object) anObject =
270 GetOperations()->MakeShell(aShapes);
271 if (!GetOperations()->IsDone() || anObject.IsNull())
272 return aGEOMObject._retn();
274 return GetObject(anObject);
277 //=============================================================================
281 //=============================================================================
282 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
283 (GEOM::GEOM_Object_ptr theShell)
285 GEOM::GEOM_Object_var aGEOMObject;
287 //Set a not done flag
288 GetOperations()->SetNotDone();
290 //Get the reference objects
291 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
292 if (aShell.IsNull()) return aGEOMObject._retn();
294 std::list<Handle(GEOM_Object)> aShapes;
295 aShapes.push_back(aShell);
298 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
299 if (!GetOperations()->IsDone() || anObject.IsNull())
300 return aGEOMObject._retn();
302 return GetObject(anObject);
305 //=============================================================================
309 //=============================================================================
310 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
311 (const GEOM::ListOfGO& theShells)
313 GEOM::GEOM_Object_var aGEOMObject;
315 //Set a not done flag
316 GetOperations()->SetNotDone();
319 std::list<Handle(GEOM_Object)> aShapes;
322 aLen = theShells.length();
323 for (ind = 0; ind < aLen; ind++) {
324 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
325 if (aSh.IsNull()) return aGEOMObject._retn();
326 aShapes.push_back(aSh);
330 Handle(GEOM_Object) anObject =
331 GetOperations()->MakeSolidShells(aShapes);
332 if (!GetOperations()->IsDone() || anObject.IsNull())
333 return aGEOMObject._retn();
335 return GetObject(anObject);
338 //=============================================================================
342 //=============================================================================
343 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
344 (const GEOM::ListOfGO& theShapes)
346 GEOM::GEOM_Object_var aGEOMObject;
348 //Set a not done flag
349 GetOperations()->SetNotDone();
352 std::list<Handle(GEOM_Object)> aShapes;
355 aLen = theShapes.length();
356 for (ind = 0; ind < aLen; ind++) {
357 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
358 if (aSh.IsNull()) return aGEOMObject._retn();
359 aShapes.push_back(aSh);
363 Handle(GEOM_Object) anObject =
364 GetOperations()->MakeCompound(aShapes);
365 if (!GetOperations()->IsDone() || anObject.IsNull())
366 return aGEOMObject._retn();
368 return GetObject(anObject);
371 //=============================================================================
375 //=============================================================================
376 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
377 (GEOM::GEOM_Object_ptr theShape,
378 CORBA::Double theTolerance,
379 CORBA::Boolean doKeepNonSolids)
381 GEOM::GEOM_Object_var aGEOMObject;
383 //Set a not done flag
384 GetOperations()->SetNotDone();
386 //Get the reference objects
387 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
388 if (aShape.IsNull()) return aGEOMObject._retn();
391 Handle(GEOM_Object) anObject =
392 GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
393 //if (!GetOperations()->IsDone() || anObject.IsNull())
395 if (anObject.IsNull())
396 return aGEOMObject._retn();
398 return GetObject(anObject);
401 //=============================================================================
405 //=============================================================================
406 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
407 (GEOM::GEOM_Object_ptr theShape,
408 const CORBA::Double theTolerance)
410 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
412 //Set a not done flag
413 GetOperations()->SetNotDone();
415 //Get the reference objects
416 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
417 if (aShape.IsNull()) return aSeq._retn();
419 Handle(TColStd_HSequenceOfTransient) aHSeq =
420 //GetOperations()->GetGlueFaces(aShape, theTolerance);
421 GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
423 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
428 Standard_Integer aLength = aHSeq->Length();
429 aSeq->length(aLength);
430 for (Standard_Integer i = 1; i <= aLength; i++)
431 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
436 //=============================================================================
438 * MakeGlueFacesByList
440 //=============================================================================
441 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
442 (GEOM::GEOM_Object_ptr theShape,
443 CORBA::Double theTolerance,
444 const GEOM::ListOfGO& theFaces,
445 CORBA::Boolean doKeepNonSolids)
447 GEOM::GEOM_Object_var aGEOMObject;
449 //Set a not done flag
450 GetOperations()->SetNotDone();
452 //Get the reference objects
453 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
454 if (aShape.IsNull()) return aGEOMObject._retn();
457 std::list<Handle(GEOM_Object)> aFaces;
459 aLen = theFaces.length();
460 for (ind = 0; ind < aLen; ind++) {
461 Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
462 if (aSh.IsNull()) return aGEOMObject._retn();
463 aFaces.push_back(aSh);
467 Handle(GEOM_Object) anObject =
468 GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
469 //if (!GetOperations()->IsDone() || anObject.IsNull())
471 if (anObject.IsNull())
472 return aGEOMObject._retn();
474 return GetObject(anObject);
477 //=============================================================================
481 //=============================================================================
482 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
483 (GEOM::GEOM_Object_ptr theShape,
484 CORBA::Double theTolerance)
486 GEOM::GEOM_Object_var aGEOMObject;
488 //Set a not done flag
489 GetOperations()->SetNotDone();
491 //Get the reference objects
492 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
493 if (aShape.IsNull()) return aGEOMObject._retn();
496 Handle(GEOM_Object) anObject =
497 GetOperations()->MakeGlueEdges(aShape, theTolerance);
498 //if (!GetOperations()->IsDone() || anObject.IsNull())
500 if (anObject.IsNull())
501 return aGEOMObject._retn();
503 return GetObject(anObject);
506 //=============================================================================
510 //=============================================================================
511 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
512 (GEOM::GEOM_Object_ptr theShape,
513 const CORBA::Double theTolerance)
515 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
517 //Set a not done flag
518 GetOperations()->SetNotDone();
520 //Get the reference objects
521 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
522 if (aShape.IsNull()) return aSeq._retn();
524 Handle(TColStd_HSequenceOfTransient) aHSeq =
525 GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_EDGE);
527 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
532 Standard_Integer aLength = aHSeq->Length();
533 aSeq->length(aLength);
534 for (Standard_Integer i = 1; i <= aLength; i++)
535 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
540 //=============================================================================
542 * MakeGlueEdgesByList
544 //=============================================================================
545 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
546 (GEOM::GEOM_Object_ptr theShape,
547 CORBA::Double theTolerance,
548 const GEOM::ListOfGO& theEdges)
550 GEOM::GEOM_Object_var aGEOMObject;
552 //Set a not done flag
553 GetOperations()->SetNotDone();
555 //Get the reference objects
556 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
557 if (aShape.IsNull()) return aGEOMObject._retn();
560 std::list<Handle(GEOM_Object)> anEdges;
562 aLen = theEdges.length();
563 for (ind = 0; ind < aLen; ind++) {
564 Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]);
565 if (aSh.IsNull()) return aGEOMObject._retn();
566 anEdges.push_back(aSh);
570 Handle(GEOM_Object) anObject =
571 GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges);
572 //if (!GetOperations()->IsDone() || anObject.IsNull())
574 if (anObject.IsNull())
575 return aGEOMObject._retn();
577 return GetObject(anObject);
580 //=============================================================================
582 * GetExistingSubObjects
584 //=============================================================================
585 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
586 CORBA::Boolean theGroupsOnly)
588 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
590 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
591 if (aShape.IsNull()) return aSeq._retn();
593 Handle(TColStd_HSequenceOfTransient) aHSeq =
594 GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
595 if (!GetOperations()->IsDone() || aHSeq.IsNull())
598 Standard_Integer aLength = aHSeq->Length();
599 aSeq->length(aLength);
600 for (Standard_Integer i = 1; i <= aLength; i++)
601 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
606 //=============================================================================
608 * MakeExplode (including theShape itself, bad sorting)
610 //=============================================================================
611 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
612 const CORBA::Long theShapeType,
613 const CORBA::Boolean isSorted)
615 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
617 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
618 if (aShape.IsNull()) return aSeq._retn();
620 Handle(TColStd_HSequenceOfTransient) aHSeq =
621 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
622 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
623 if (!GetOperations()->IsDone() || aHSeq.IsNull())
626 Standard_Integer aLength = aHSeq->Length();
627 aSeq->length(aLength);
628 for (Standard_Integer i = 1; i <= aLength; i++)
629 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
634 //=============================================================================
636 * MakeAllSubShapes (including theShape itself, good sorting)
638 //=============================================================================
639 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
640 const CORBA::Long theShapeType,
641 const CORBA::Boolean isSorted)
643 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
645 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
646 if (aShape.IsNull()) return aSeq._retn();
648 Handle(TColStd_HSequenceOfTransient) aHSeq =
649 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
650 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
651 if (!GetOperations()->IsDone() || aHSeq.IsNull())
654 Standard_Integer aLength = aHSeq->Length();
655 aSeq->length(aLength);
656 for (Standard_Integer i = 1; i <= aLength; i++)
657 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
662 //=============================================================================
664 * ExtractSubShapes (excluding theShape itself, good sorting)
666 //=============================================================================
667 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
668 const CORBA::Long theShapeType,
669 const CORBA::Boolean isSorted)
671 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
673 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
674 if (aShape.IsNull()) return aSeq._retn();
676 Handle(TColStd_HSequenceOfTransient) aHSeq =
677 // TODO: enum instead of bool for the last argument
678 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
679 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
680 if (!GetOperations()->IsDone() || aHSeq.IsNull())
683 Standard_Integer aLength = aHSeq->Length();
684 aSeq->length(aLength);
685 for (Standard_Integer i = 1; i <= aLength; i++)
686 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
691 //=============================================================================
695 //=============================================================================
696 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
697 const CORBA::Long theShapeType,
698 const CORBA::Boolean isSorted)
700 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
702 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
703 if (aShape.IsNull()) return aSeq._retn();
705 Handle(TColStd_HSequenceOfInteger) aHSeq =
706 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
707 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
708 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
710 Standard_Integer aLength = aHSeq->Length();
711 aSeq->length(aLength);
712 for (Standard_Integer i = 1; i <= aLength; i++)
713 aSeq[i-1] = aHSeq->Value(i);
718 //=============================================================================
722 //=============================================================================
723 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
724 const CORBA::Long theShapeType,
725 const CORBA::Boolean isSorted)
727 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
729 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
730 if (aShape.IsNull()) return aSeq._retn();
732 Handle(TColStd_HSequenceOfInteger) aHSeq =
733 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
734 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
735 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
737 Standard_Integer aLength = aHSeq->Length();
738 aSeq->length(aLength);
739 for (Standard_Integer i = 1; i <= aLength; i++)
740 aSeq[i-1] = aHSeq->Value(i);
745 //=============================================================================
749 //=============================================================================
750 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
751 (GEOM::GEOM_Object_ptr theMainShape,
752 const CORBA::Long theID)
754 GEOM::GEOM_Object_var aGEOMObject;
756 //Set a not done flag
757 GetOperations()->SetNotDone();
759 //Get the reference objects
760 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
761 if (aShape.IsNull()) return aGEOMObject._retn();
763 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
764 if (!GetOperations()->IsDone() || anObject.IsNull())
765 return aGEOMObject._retn();
767 return GetObject(anObject);
770 //=============================================================================
774 //=============================================================================
775 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
776 const GEOM::ListOfLong& theIndices)
778 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
781 //Set a not done flag
782 GetOperations()->SetNotDone();
784 if (theIndices.length() < 1)
787 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
788 if (aShape.IsNull()) return aSeq._retn();
790 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
791 for (i = 0; i < theIndices.length(); i++)
792 anArray->SetValue(i+1, theIndices[i]);
794 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
795 if (!GetOperations()->IsDone() || aHSeq.IsNull())
798 Standard_Integer aLength = aHSeq->Length();
799 aSeq->length(aLength);
800 for (i = 0; i < aLength; i++)
801 aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
806 //=============================================================================
810 //=============================================================================
811 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
812 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
814 //Get the reference shapes
815 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
816 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
818 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
820 //Get the unique ID of <theSubShape> inside <theMainShape>
821 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
822 if (!GetOperations()->IsDone())
828 //=============================================================================
832 //=============================================================================
833 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
834 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
836 //Get the reference shapes
837 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
838 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
840 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
842 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
843 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
844 if (!GetOperations()->IsDone())
850 //=============================================================================
854 //=============================================================================
855 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
857 //Get the reference shape
858 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
859 if (aShape.IsNull()) return NULL;
861 // Get shape parameters
862 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
863 return CORBA::string_dup(aDescription.ToCString());
866 //=============================================================================
870 //=============================================================================
871 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
873 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
876 //=============================================================================
880 //=============================================================================
881 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
883 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
886 //=============================================================================
890 //=============================================================================
891 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
892 const CORBA::Long theShapeType)
894 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
895 if (aShape.IsNull()) return -1;
897 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
898 if (!GetOperations()->IsDone()) return -1;
903 //=============================================================================
907 //=============================================================================
908 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
909 (GEOM::GEOM_Object_ptr theShape)
911 GEOM::GEOM_Object_var aGEOMObject;
913 //Set a not done flag
914 GetOperations()->SetNotDone();
916 //Get the reference objects
917 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
918 if (aShape.IsNull()) return aGEOMObject._retn();
921 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
922 if (!GetOperations()->IsDone() || anObject.IsNull())
923 return aGEOMObject._retn();
925 return GetObject(anObject);
928 //=============================================================================
932 //=============================================================================
933 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
935 //Set a not done flag
936 GetOperations()->SetNotDone();
938 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
940 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
941 if (aShape.IsNull()) return aSeq._retn();
943 Handle(TColStd_HSequenceOfInteger) aHSeq =
944 GetOperations()->GetFreeFacesIDs(aShape);
945 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
947 Standard_Integer aLength = aHSeq->Length();
948 aSeq->length(aLength);
949 for (Standard_Integer i = 1; i <= aLength; i++)
950 aSeq[i-1] = aHSeq->Value(i);
955 //=============================================================================
959 //=============================================================================
960 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
961 (GEOM::GEOM_Object_ptr theShape1,
962 GEOM::GEOM_Object_ptr theShape2,
963 const CORBA::Long theShapeType)
965 //Set a not done flag
966 GetOperations()->SetNotDone();
968 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
970 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
971 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
973 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
975 Handle(TColStd_HSequenceOfTransient) aHSeq =
976 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
977 if (!GetOperations()->IsDone() || aHSeq.IsNull())
980 Standard_Integer aLength = aHSeq->Length();
981 aSeq->length(aLength);
982 for (Standard_Integer i = 1; i <= aLength; i++)
983 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
988 //=============================================================================
990 * GetSharedShapesMulti
992 //=============================================================================
993 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
994 (const GEOM::ListOfGO& theShapes,
995 const CORBA::Long theShapeType)
997 //Set a not done flag
998 GetOperations()->SetNotDone();
1000 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1003 std::list<Handle(GEOM_Object)> aShapes;
1004 int aLen = theShapes.length();
1005 for (int ind = 0; ind < aLen; ind++) {
1006 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1007 if (aSh.IsNull()) return aSeq._retn();
1008 aShapes.push_back(aSh);
1011 Handle(TColStd_HSequenceOfTransient) aHSeq =
1012 GetOperations()->GetSharedShapes(aShapes, theShapeType);
1013 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1014 return aSeq._retn();
1016 Standard_Integer aLength = aHSeq->Length();
1017 aSeq->length(aLength);
1018 for (Standard_Integer i = 1; i <= aLength; i++)
1019 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1021 return aSeq._retn();
1024 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1026 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1030 aState = GEOMAlgo_ST_ON;
1033 aState = GEOMAlgo_ST_OUT;
1035 case GEOM::ST_ONOUT:
1036 aState = GEOMAlgo_ST_ONOUT;
1039 aState = GEOMAlgo_ST_IN;
1042 aState = GEOMAlgo_ST_ONIN;
1051 //=============================================================================
1055 //=============================================================================
1056 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1057 (GEOM::GEOM_Object_ptr theShape,
1058 const CORBA::Long theShapeType,
1059 GEOM::GEOM_Object_ptr theAx1,
1060 const GEOM::shape_state theState)
1062 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1064 //Set a not done flag
1065 GetOperations()->SetNotDone();
1067 //Get the reference objects
1068 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1069 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1071 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1073 //Get Shapes On Plane
1074 Handle(TColStd_HSequenceOfTransient) aHSeq =
1075 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1076 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1077 return aSeq._retn();
1079 Standard_Integer aLength = aHSeq->Length();
1080 aSeq->length(aLength);
1081 for (Standard_Integer i = 1; i <= aLength; i++)
1082 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1084 return aSeq._retn();
1087 //=============================================================================
1089 * GetShapesOnPlaneWithLocation
1091 //=============================================================================
1092 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1093 (GEOM::GEOM_Object_ptr theShape,
1094 const CORBA::Long theShapeType,
1095 GEOM::GEOM_Object_ptr theAx1,
1096 GEOM::GEOM_Object_ptr thePnt,
1097 const GEOM::shape_state theState)
1099 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1101 //Set a not done flag
1102 GetOperations()->SetNotDone();
1104 //Get the reference objects
1105 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1106 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1107 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1109 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1111 //Get Shapes On Plane
1112 Handle(TColStd_HSequenceOfTransient) aHSeq =
1113 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1114 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1115 return aSeq._retn();
1117 Standard_Integer aLength = aHSeq->Length();
1118 aSeq->length(aLength);
1119 for (Standard_Integer i = 1; i <= aLength; i++)
1120 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1122 return aSeq._retn();
1125 //=============================================================================
1127 * GetShapesOnCylinder
1129 //=============================================================================
1130 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1131 (GEOM::GEOM_Object_ptr theShape,
1132 const CORBA::Long theShapeType,
1133 GEOM::GEOM_Object_ptr theAxis,
1134 const CORBA::Double theRadius,
1135 const GEOM::shape_state theState)
1137 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1139 //Set a not done flag
1140 GetOperations()->SetNotDone();
1142 //Get the reference objects
1143 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1144 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1146 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1148 //Get Shapes On Cylinder
1149 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1150 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1151 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1152 return aSeq._retn();
1154 Standard_Integer aLength = aHSeq->Length();
1155 aSeq->length(aLength);
1156 for (Standard_Integer i = 1; i <= aLength; i++)
1157 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1159 return aSeq._retn();
1162 //=============================================================================
1164 * GetShapesOnCylinderWithLocation
1166 //=============================================================================
1167 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1168 (GEOM::GEOM_Object_ptr theShape,
1169 const CORBA::Long theShapeType,
1170 GEOM::GEOM_Object_ptr theAxis,
1171 GEOM::GEOM_Object_ptr thePnt,
1172 const CORBA::Double theRadius,
1173 const GEOM::shape_state theState)
1175 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1177 //Set a not done flag
1178 GetOperations()->SetNotDone();
1180 //Get the reference objects
1181 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1182 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1183 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1185 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1187 //Get Shapes On Cylinder
1188 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1189 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1190 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1191 return aSeq._retn();
1193 Standard_Integer aLength = aHSeq->Length();
1194 aSeq->length(aLength);
1195 for (Standard_Integer i = 1; i <= aLength; i++)
1196 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1198 return aSeq._retn();
1201 //=============================================================================
1205 //=============================================================================
1206 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1207 (GEOM::GEOM_Object_ptr theShape,
1208 const CORBA::Long theShapeType,
1209 GEOM::GEOM_Object_ptr theCenter,
1210 const CORBA::Double theRadius,
1211 const GEOM::shape_state theState)
1213 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1215 //Set a not done flag
1216 GetOperations()->SetNotDone();
1218 //Get the reference objects
1219 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1220 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1222 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1224 //Get Shapes On Sphere
1225 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1226 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1227 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1228 return aSeq._retn();
1230 Standard_Integer aLength = aHSeq->Length();
1231 aSeq->length(aLength);
1232 for (Standard_Integer i = 1; i <= aLength; i++)
1233 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1235 return aSeq._retn();
1238 //=============================================================================
1240 * GetShapesOnQuadrangle
1242 //=============================================================================
1243 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1244 (GEOM::GEOM_Object_ptr theShape,
1245 CORBA::Long theShapeType,
1246 GEOM::GEOM_Object_ptr theTopLeftPoint,
1247 GEOM::GEOM_Object_ptr theTopRigthPoint,
1248 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1249 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1250 GEOM::shape_state theState)
1252 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1254 //Set a not done flag
1255 GetOperations()->SetNotDone();
1257 //Get the reference objects
1258 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1259 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1260 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1261 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1262 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1264 if (aShape.IsNull() ||
1265 aTopLeftPoint.IsNull() ||
1266 aTopRigthPoint.IsNull() ||
1267 aBottomLeftPoint.IsNull() ||
1268 aBottomRigthPoint.IsNull())
1269 return aSeq._retn();
1271 //Get Shapes On Quadrangle
1272 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1273 (aShape, theShapeType,
1274 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1275 ShapeState(theState));
1276 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1277 return aSeq._retn();
1279 Standard_Integer aLength = aHSeq->Length();
1280 aSeq->length(aLength);
1281 for (Standard_Integer i = 1; i <= aLength; i++)
1282 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1284 return aSeq._retn();
1287 //=============================================================================
1289 * GetShapesOnPlaneIDs
1291 //=============================================================================
1292 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1293 (GEOM::GEOM_Object_ptr theShape,
1294 const CORBA::Long theShapeType,
1295 GEOM::GEOM_Object_ptr theAx1,
1296 const GEOM::shape_state theState)
1298 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1300 //Set a not done flag
1301 GetOperations()->SetNotDone();
1303 //Get the reference objects
1304 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1305 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1307 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1309 //Get Shapes On Plane
1310 Handle(TColStd_HSequenceOfInteger) aHSeq =
1311 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1312 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1313 return aSeq._retn();
1315 Standard_Integer aLength = aHSeq->Length();
1316 aSeq->length(aLength);
1317 for (Standard_Integer i = 1; i <= aLength; i++)
1318 aSeq[i-1] = aHSeq->Value(i);
1320 return aSeq._retn();
1323 //=============================================================================
1325 * GetShapesOnPlaneWithLocationIDs
1327 //=============================================================================
1328 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1329 (GEOM::GEOM_Object_ptr theShape,
1330 const CORBA::Long theShapeType,
1331 GEOM::GEOM_Object_ptr theAx1,
1332 GEOM::GEOM_Object_ptr thePnt,
1333 const GEOM::shape_state theState)
1335 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1337 //Set a not done flag
1338 GetOperations()->SetNotDone();
1340 //Get the reference objects
1341 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1342 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1343 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1345 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1347 //Get Shapes On Plane
1348 Handle(TColStd_HSequenceOfInteger) aHSeq =
1349 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1350 anAx1, anPnt, ShapeState(theState));
1351 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1352 return aSeq._retn();
1354 Standard_Integer aLength = aHSeq->Length();
1355 aSeq->length(aLength);
1356 for (Standard_Integer i = 1; i <= aLength; i++)
1357 aSeq[i-1] = aHSeq->Value(i);
1359 return aSeq._retn();
1362 //=============================================================================
1364 * GetShapesOnCylinderIDs
1366 //=============================================================================
1367 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1368 (GEOM::GEOM_Object_ptr theShape,
1369 const CORBA::Long theShapeType,
1370 GEOM::GEOM_Object_ptr theAxis,
1371 const CORBA::Double theRadius,
1372 const GEOM::shape_state theState)
1374 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1376 //Set a not done flag
1377 GetOperations()->SetNotDone();
1379 //Get the reference objects
1380 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1381 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1383 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1385 //Get Shapes On Cylinder
1386 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1387 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1388 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1389 return aSeq._retn();
1391 Standard_Integer aLength = aHSeq->Length();
1392 aSeq->length(aLength);
1393 for (Standard_Integer i = 1; i <= aLength; i++)
1394 aSeq[i-1] = aHSeq->Value(i);
1396 return aSeq._retn();
1399 //=============================================================================
1401 * GetShapesOnCylinderWithLocationIDs
1403 //=============================================================================
1404 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1405 (GEOM::GEOM_Object_ptr theShape,
1406 const CORBA::Long theShapeType,
1407 GEOM::GEOM_Object_ptr theAxis,
1408 GEOM::GEOM_Object_ptr thePnt,
1409 const CORBA::Double theRadius,
1410 const GEOM::shape_state theState)
1412 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1414 //Set a not done flag
1415 GetOperations()->SetNotDone();
1417 //Get the reference objects
1418 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1419 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1420 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1422 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1424 //Get Shapes On Cylinder
1425 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1426 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1427 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1428 return aSeq._retn();
1430 Standard_Integer aLength = aHSeq->Length();
1431 aSeq->length(aLength);
1432 for (Standard_Integer i = 1; i <= aLength; i++)
1433 aSeq[i-1] = aHSeq->Value(i);
1435 return aSeq._retn();
1438 //=============================================================================
1440 * GetShapesOnSphereIDs
1442 //=============================================================================
1443 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1444 (GEOM::GEOM_Object_ptr theShape,
1445 const CORBA::Long theShapeType,
1446 GEOM::GEOM_Object_ptr theCenter,
1447 const CORBA::Double theRadius,
1448 const GEOM::shape_state theState)
1450 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1452 //Set a not done flag
1453 GetOperations()->SetNotDone();
1455 //Get the reference objects
1456 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1457 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1459 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1461 //Get Shapes On Sphere
1462 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1463 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1464 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1465 return aSeq._retn();
1467 Standard_Integer aLength = aHSeq->Length();
1468 aSeq->length(aLength);
1469 for (Standard_Integer i = 1; i <= aLength; i++)
1470 aSeq[i-1] = aHSeq->Value(i);
1472 return aSeq._retn();
1475 //=============================================================================
1477 * GetShapesOnQuadrangleIDs
1479 //=============================================================================
1480 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1481 (GEOM::GEOM_Object_ptr theShape,
1482 CORBA::Long theShapeType,
1483 GEOM::GEOM_Object_ptr theTopLeftPoint,
1484 GEOM::GEOM_Object_ptr theTopRigthPoint,
1485 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1486 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1487 GEOM::shape_state theState)
1489 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1491 //Set a not done flag
1492 GetOperations()->SetNotDone();
1494 //Get the reference objects
1495 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1496 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1497 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1498 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1499 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1501 if (aShape.IsNull() ||
1502 aTopLeftPoint.IsNull() ||
1503 aTopRigthPoint.IsNull() ||
1504 aBottomLeftPoint.IsNull() ||
1505 aBottomRigthPoint.IsNull() )
1506 return aSeq._retn();
1508 //Get Shapes On Quadrangle
1509 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1510 (aShape, theShapeType,
1511 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1512 ShapeState(theState));
1513 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1514 return aSeq._retn();
1516 Standard_Integer aLength = aHSeq->Length();
1517 aSeq->length(aLength);
1518 for (Standard_Integer i = 1; i <= aLength; i++)
1519 aSeq[i-1] = aHSeq->Value(i);
1521 return aSeq._retn();
1524 //=============================================================================
1528 //=============================================================================
1529 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1530 (GEOM::GEOM_Object_ptr theBox,
1531 GEOM::GEOM_Object_ptr theShape,
1532 CORBA::Long theShapeType,
1533 GEOM::shape_state theState)
1535 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1537 //Set a not done flag
1538 GetOperations()->SetNotDone();
1540 //Get the reference objects
1541 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1542 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1544 if (aShape.IsNull() || aBox.IsNull() )
1545 return aSeq._retn();
1548 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1549 (aBox,aShape, theShapeType,ShapeState(theState));
1550 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1551 return aSeq._retn();
1553 Standard_Integer aLength = aHSeq->Length();
1554 aSeq->length(aLength);
1555 for (Standard_Integer i = 1; i <= aLength; i++)
1556 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1558 return aSeq._retn();
1561 //=============================================================================
1563 * GetShapesOnQuadrangleIDs
1565 //=============================================================================
1566 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1567 (GEOM::GEOM_Object_ptr theBox,
1568 GEOM::GEOM_Object_ptr theShape,
1569 CORBA::Long theShapeType,
1570 GEOM::shape_state theState)
1572 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1574 //Set a not done flag
1575 GetOperations()->SetNotDone();
1577 //Get the reference objects
1578 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1579 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1581 if (aShape.IsNull() || aBox.IsNull() )
1582 return aSeq._retn();
1585 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1586 (aBox,aShape, theShapeType,ShapeState(theState));
1587 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1588 return aSeq._retn();
1590 Standard_Integer aLength = aHSeq->Length();
1591 aSeq->length(aLength);
1592 for (Standard_Integer i = 1; i <= aLength; i++)
1593 aSeq[i-1] = aHSeq->Value(i);
1595 return aSeq._retn();
1599 //=============================================================================
1603 //=============================================================================
1604 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1605 (GEOM::GEOM_Object_ptr theCheckShape,
1606 GEOM::GEOM_Object_ptr theShape,
1607 CORBA::Short theShapeType,
1608 GEOM::shape_state theState)
1610 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1612 //Set a not done flag
1613 GetOperations()->SetNotDone();
1615 //Get the reference objects
1616 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1617 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1619 if (aShape.IsNull() || aCheckShape.IsNull() )
1620 return aSeq._retn();
1622 //Get Shapes On Shape
1623 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1624 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1626 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1627 return aSeq._retn();
1629 Standard_Integer aLength = aHSeq->Length();
1630 aSeq->length(aLength);
1631 for (Standard_Integer i = 1; i <= aLength; i++)
1632 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1634 return aSeq._retn();
1638 //=============================================================================
1640 * GetShapesOnShapeAsCompound
1642 //=============================================================================
1643 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1644 (GEOM::GEOM_Object_ptr theCheckShape,
1645 GEOM::GEOM_Object_ptr theShape,
1646 CORBA::Short theShapeType,
1647 GEOM::shape_state theState)
1649 GEOM::GEOM_Object_var aGEOMObject;
1651 //Set a not done flag
1652 GetOperations()->SetNotDone();
1654 //Get the reference objects
1655 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1656 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1658 if (aShape.IsNull() || aCheckShape.IsNull() )
1659 return aGEOMObject._retn();
1661 //Get Shapes On Shape
1662 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1663 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1665 if (anObject.IsNull())
1666 return aGEOMObject._retn();
1668 return GetObject(anObject);
1672 //=============================================================================
1674 * GetShapesOnShapeIDs
1676 //=============================================================================
1677 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1678 (GEOM::GEOM_Object_ptr theCheckShape,
1679 GEOM::GEOM_Object_ptr theShape,
1680 CORBA::Short theShapeType,
1681 GEOM::shape_state theState)
1683 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1685 //Set a not done flag
1686 GetOperations()->SetNotDone();
1688 //Get the reference objects
1689 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1690 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1692 if (aShape.IsNull() || aCheckShape.IsNull() )
1693 return aSeq._retn();
1695 //Get Shapes On Shape
1696 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1697 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1698 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1699 return aSeq._retn();
1701 Standard_Integer aLength = aHSeq->Length();
1702 aSeq->length(aLength);
1703 for (Standard_Integer i = 1; i <= aLength; i++)
1704 aSeq[i-1] = aHSeq->Value(i);
1706 return aSeq._retn();
1710 //=============================================================================
1714 //=============================================================================
1715 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1716 (GEOM::GEOM_Object_ptr theShapeWhere,
1717 GEOM::GEOM_Object_ptr theShapeWhat)
1719 GEOM::GEOM_Object_var aGEOMObject;
1721 //Set a not done flag
1722 GetOperations()->SetNotDone();
1724 //Get the reference objects
1725 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1726 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1728 if (aShapeWhere.IsNull() ||
1729 aShapeWhat.IsNull()) return aGEOMObject._retn();
1731 //Get Shapes in place of aShapeWhat
1732 Handle(GEOM_Object) anObject =
1733 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1734 if (!GetOperations()->IsDone() || anObject.IsNull())
1735 return aGEOMObject._retn();
1737 return GetObject(anObject);
1740 //=============================================================================
1742 * GetInPlaceByHistory
1744 //=============================================================================
1745 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1746 (GEOM::GEOM_Object_ptr theShapeWhere,
1747 GEOM::GEOM_Object_ptr theShapeWhat)
1749 GEOM::GEOM_Object_var aGEOMObject;
1751 //Set a not done flag
1752 GetOperations()->SetNotDone();
1754 //Get the reference objects
1755 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1756 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1758 if (aShapeWhere.IsNull() ||
1759 aShapeWhat.IsNull()) return aGEOMObject._retn();
1761 //Get Shapes in place of aShapeWhat
1762 Handle(GEOM_Object) anObject =
1763 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1764 if (!GetOperations()->IsDone() || anObject.IsNull())
1765 return aGEOMObject._retn();
1767 return GetObject(anObject);
1770 //=============================================================================
1774 //=============================================================================
1775 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1776 (GEOM::GEOM_Object_ptr theShapeWhere,
1777 GEOM::GEOM_Object_ptr theShapeWhat)
1779 GEOM::GEOM_Object_var aGEOMObject;
1781 //Set a not done flag
1782 GetOperations()->SetNotDone();
1784 //Get the reference objects
1785 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1786 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1788 if (aShapeWhere.IsNull() ||
1789 aShapeWhat.IsNull()) return aGEOMObject._retn();
1791 //Get Shapes in place of aShapeWhat
1792 Handle(GEOM_Object) anObject =
1793 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1794 if (!GetOperations()->IsDone() || anObject.IsNull())
1795 return aGEOMObject._retn();
1797 return GetObject(anObject);