1 // Copyright (C) 2007-2014 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, or (at your option) any later version.
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
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IShapesOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
35 #include <TColStd_HSequenceOfTransient.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
38 //=============================================================================
42 //=============================================================================
43 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
44 GEOM::GEOM_Gen_ptr theEngine,
45 ::GEOMImpl_IShapesOperations* theImpl)
46 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
48 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
51 //=============================================================================
55 //=============================================================================
56 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
58 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
62 //=============================================================================
66 //=============================================================================
67 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
68 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
70 GEOM::GEOM_Object_var aGEOMObject;
73 GetOperations()->SetNotDone();
75 //Get the reference points
76 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
77 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
79 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
82 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
83 if (!GetOperations()->IsDone() || anObject.IsNull())
84 return aGEOMObject._retn();
86 return GetObject(anObject);
89 //=============================================================================
91 * MakeEdgeOnCurveByLength
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
95 (GEOM::GEOM_Object_ptr theCurve,
96 CORBA::Double theLength,
97 GEOM::GEOM_Object_ptr theStartPoint)
99 GEOM::GEOM_Object_var aGEOMObject;
101 //Set a not done flag
102 GetOperations()->SetNotDone();
104 //Get the reference curve
105 Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
106 if (aRefCurve.IsNull()) return aGEOMObject._retn();
108 //Get the reference point (can be NULL)
109 Handle(GEOM_Object) aRefPoint;
110 if (!CORBA::is_nil(theStartPoint)) {
111 aRefPoint = GetObjectImpl(theStartPoint);
115 Handle(GEOM_Object) anObject =
116 GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
117 if (!GetOperations()->IsDone() || anObject.IsNull())
118 return aGEOMObject._retn();
120 return GetObject(anObject);
123 //=============================================================================
127 //=============================================================================
128 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
129 (GEOM::GEOM_Object_ptr theWire,
130 const CORBA::Double theLinearTolerance,
131 const CORBA::Double theAngularTolerance)
133 GEOM::GEOM_Object_var aGEOMObject;
135 //Set a not done flag
136 GetOperations()->SetNotDone();
138 //Get the source wire
139 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
141 if (aWire.IsNull()) return aGEOMObject._retn();
144 Handle(GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
145 if (!GetOperations()->IsDone() || anObject.IsNull())
146 return aGEOMObject._retn();
148 return GetObject(anObject);
151 //=============================================================================
155 //=============================================================================
156 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
157 (const GEOM::ListOfGO& theEdgesAndWires,
158 const CORBA::Double theTolerance)
160 GEOM::GEOM_Object_var aGEOMObject;
162 //Set a not done flag
163 GetOperations()->SetNotDone();
166 std::list<Handle(GEOM_Object)> aShapes;
169 aLen = theEdgesAndWires.length();
170 for (ind = 0; ind < aLen; ind++) {
171 Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
172 if (aSh.IsNull()) return aGEOMObject._retn();
173 aShapes.push_back(aSh);
177 Handle(GEOM_Object) anObject =
178 GetOperations()->MakeWire(aShapes, theTolerance);
179 if (!GetOperations()->IsDone() || anObject.IsNull())
180 return aGEOMObject._retn();
182 return GetObject(anObject);
185 //=============================================================================
189 //=============================================================================
190 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
191 (GEOM::GEOM_Object_ptr theWire,
192 const CORBA::Boolean isPlanarWanted)
194 GEOM::GEOM_Object_var aGEOMObject;
196 //Set a not done flag
197 GetOperations()->SetNotDone();
199 //Get the reference wire
200 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
201 if (aWire.IsNull()) return aGEOMObject._retn();
204 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
205 //if (!GetOperations()->IsDone() || anObject.IsNull())
206 // enable warning status
207 if (anObject.IsNull())
208 return aGEOMObject._retn();
210 return GetObject(anObject);
213 //=============================================================================
217 //=============================================================================
218 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
219 (const GEOM::ListOfGO& theWires,
220 const CORBA::Boolean isPlanarWanted)
222 GEOM::GEOM_Object_var aGEOMObject;
224 //Set a not done flag
225 GetOperations()->SetNotDone();
228 std::list<Handle(GEOM_Object)> aShapes;
231 aLen = theWires.length();
232 for (ind = 0; ind < aLen; ind++) {
233 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
234 if (aSh.IsNull()) return aGEOMObject._retn();
235 aShapes.push_back(aSh);
239 Handle(GEOM_Object) anObject =
240 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
241 //if (!GetOperations()->IsDone() || anObject.IsNull())
242 // enable warning status
243 if (anObject.IsNull())
244 return aGEOMObject._retn();
246 return GetObject(anObject);
249 //=============================================================================
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
255 (const GEOM::ListOfGO& theFacesAndShells)
257 GEOM::GEOM_Object_var aGEOMObject;
259 //Set a not done flag
260 GetOperations()->SetNotDone();
263 std::list<Handle(GEOM_Object)> aShapes;
266 aLen = theFacesAndShells.length();
267 for (ind = 0; ind < aLen; ind++) {
268 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
269 if (aSh.IsNull()) return aGEOMObject._retn();
270 aShapes.push_back(aSh);
274 Handle(GEOM_Object) anObject =
275 GetOperations()->MakeShell(aShapes);
276 if (!GetOperations()->IsDone() || anObject.IsNull())
277 return aGEOMObject._retn();
279 return GetObject(anObject);
282 //=============================================================================
286 //=============================================================================
287 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
288 (GEOM::GEOM_Object_ptr theShell)
290 GEOM::GEOM_Object_var aGEOMObject;
292 //Set a not done flag
293 GetOperations()->SetNotDone();
295 //Get the reference objects
296 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
297 if (aShell.IsNull()) return aGEOMObject._retn();
299 std::list<Handle(GEOM_Object)> aShapes;
300 aShapes.push_back(aShell);
303 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
304 if (!GetOperations()->IsDone() || anObject.IsNull())
305 return aGEOMObject._retn();
307 return GetObject(anObject);
310 //=============================================================================
314 //=============================================================================
315 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
316 (const GEOM::ListOfGO& theShells)
318 GEOM::GEOM_Object_var aGEOMObject;
320 //Set a not done flag
321 GetOperations()->SetNotDone();
324 std::list<Handle(GEOM_Object)> aShapes;
327 aLen = theShells.length();
328 for (ind = 0; ind < aLen; ind++) {
329 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
330 if (aSh.IsNull()) return aGEOMObject._retn();
331 aShapes.push_back(aSh);
335 Handle(GEOM_Object) anObject =
336 GetOperations()->MakeSolidShells(aShapes);
337 if (!GetOperations()->IsDone() || anObject.IsNull())
338 return aGEOMObject._retn();
340 return GetObject(anObject);
343 //=============================================================================
347 //=============================================================================
348 GEOM::GEOM_Object_ptr
349 GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
351 GEOM::GEOM_Object_var aGEOMObject;
353 //Set a not done flag
354 GetOperations()->SetNotDone();
357 std::list<Handle(GEOM_Object)> aShapes;
360 aLen = theShapes.length();
361 for (ind = 0; ind < aLen; ind++) {
362 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
363 if (aSh.IsNull()) return aGEOMObject._retn();
364 aShapes.push_back(aSh);
368 Handle(GEOM_Object) anObject =
369 GetOperations()->MakeCompound(aShapes);
370 if (!GetOperations()->IsDone() || anObject.IsNull())
371 return aGEOMObject._retn();
373 return GetObject(anObject);
376 //=============================================================================
380 //=============================================================================
381 GEOM::GEOM_Object_ptr
382 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
383 CORBA::Double theTolerance,
384 CORBA::Boolean doKeepNonSolids)
386 GEOM::GEOM_Object_var aGEOMObject;
388 //Set a not done flag
389 GetOperations()->SetNotDone();
391 //Get the reference objects
392 std::list< Handle(GEOM_Object) > aShapes;
393 if (! GetListOfObjectsImpl( theShapes, aShapes ))
394 return aGEOMObject._retn();
397 Handle(GEOM_Object) anObject =
398 GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
399 //if (!GetOperations()->IsDone() || anObject.IsNull())
401 if (anObject.IsNull())
402 return aGEOMObject._retn();
404 return GetObject(anObject);
407 //=============================================================================
411 //=============================================================================
413 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
414 const CORBA::Double theTolerance)
416 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
418 //Set a not done flag
419 GetOperations()->SetNotDone();
421 //Get the reference objects
422 std::list< Handle(GEOM_Object) > aShapes;
423 if (! GetListOfObjectsImpl( theShapes, aShapes ))
426 Handle(TColStd_HSequenceOfTransient) aHSeq =
427 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
429 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
434 Standard_Integer aLength = aHSeq->Length();
435 aSeq->length(aLength);
436 for (Standard_Integer i = 1; i <= aLength; i++)
437 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
442 //=============================================================================
444 * MakeGlueFacesByList
446 //=============================================================================
447 GEOM::GEOM_Object_ptr
448 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
449 CORBA::Double theTolerance,
450 const GEOM::ListOfGO& theFaces,
451 CORBA::Boolean doKeepNonSolids,
452 CORBA::Boolean doGlueAllEdges)
454 GEOM::GEOM_Object_var aGEOMObject;
456 //Set a not done flag
457 GetOperations()->SetNotDone();
459 //Get the reference objects
460 std::list< Handle(GEOM_Object) > aShapes;
461 if (! GetListOfObjectsImpl( theShapes, aShapes ))
462 return aGEOMObject._retn();
465 std::list<Handle(GEOM_Object)> aFaces;
466 if (! GetListOfObjectsImpl( theFaces, aFaces ))
467 return aGEOMObject._retn();
470 Handle(GEOM_Object) anObject =
471 GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
472 doKeepNonSolids, doGlueAllEdges);
473 //if (!GetOperations()->IsDone() || anObject.IsNull())
475 if (anObject.IsNull())
476 return aGEOMObject._retn();
478 return GetObject(anObject);
481 //=============================================================================
485 //=============================================================================
486 GEOM::GEOM_Object_ptr
487 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
488 CORBA::Double theTolerance)
490 GEOM::GEOM_Object_var aGEOMObject;
492 //Set a not done flag
493 GetOperations()->SetNotDone();
495 //Get the reference objects
496 std::list< Handle(GEOM_Object) > aShapes;
497 if (! GetListOfObjectsImpl( theShapes, aShapes ))
498 return aGEOMObject._retn();
501 Handle(GEOM_Object) anObject =
502 GetOperations()->MakeGlueEdges(aShapes, theTolerance);
503 //if (!GetOperations()->IsDone() || anObject.IsNull())
505 if (anObject.IsNull())
506 return aGEOMObject._retn();
508 return GetObject(anObject);
511 //=============================================================================
515 //=============================================================================
517 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
518 const CORBA::Double theTolerance)
520 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
522 //Set a not done flag
523 GetOperations()->SetNotDone();
525 //Get the reference objects
526 std::list< Handle(GEOM_Object) > aShapes;
527 if (! GetListOfObjectsImpl( theShapes, aShapes ))
530 Handle(TColStd_HSequenceOfTransient) aHSeq =
531 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
533 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
538 Standard_Integer aLength = aHSeq->Length();
539 aSeq->length(aLength);
540 for (Standard_Integer i = 1; i <= aLength; i++)
541 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
546 //=============================================================================
548 * MakeGlueEdgesByList
550 //=============================================================================
551 GEOM::GEOM_Object_ptr
552 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
553 CORBA::Double theTolerance,
554 const GEOM::ListOfGO& theEdges)
556 GEOM::GEOM_Object_var aGEOMObject;
558 //Set a not done flag
559 GetOperations()->SetNotDone();
561 //Get the reference objects
562 std::list< Handle(GEOM_Object) > aShapes;
563 if (! GetListOfObjectsImpl( theShapes, aShapes ))
564 return aGEOMObject._retn();
567 std::list<Handle(GEOM_Object)> anEdges;
568 if (! GetListOfObjectsImpl( theEdges, anEdges ))
569 return aGEOMObject._retn();
572 Handle(GEOM_Object) anObject =
573 GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
574 //if (!GetOperations()->IsDone() || anObject.IsNull())
576 if (anObject.IsNull())
577 return aGEOMObject._retn();
579 return GetObject(anObject);
582 //=============================================================================
584 * GetExistingSubObjects
586 //=============================================================================
588 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
589 CORBA::Boolean theGroupsOnly)
591 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
593 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
594 if (aShape.IsNull()) return aSeq._retn();
596 Handle(TColStd_HSequenceOfTransient) aHSeq =
597 GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
598 if (!GetOperations()->IsDone() || aHSeq.IsNull())
601 Standard_Integer aLength = aHSeq->Length();
602 aSeq->length(aLength);
603 for (Standard_Integer i = 1; i <= aLength; i++)
604 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
609 //=============================================================================
611 * MakeExplode (including theShape itself, bad sorting)
613 //=============================================================================
614 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
615 const CORBA::Long theShapeType,
616 const CORBA::Boolean isSorted)
618 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
620 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
621 if (aShape.IsNull()) return aSeq._retn();
623 Handle(TColStd_HSequenceOfTransient) aHSeq =
624 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
625 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
626 if (!GetOperations()->IsDone() || aHSeq.IsNull())
629 Standard_Integer aLength = aHSeq->Length();
630 aSeq->length(aLength);
631 for (Standard_Integer i = 1; i <= aLength; i++)
632 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
637 //=============================================================================
639 * MakeAllSubShapes (including theShape itself, good sorting)
641 //=============================================================================
642 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
643 const CORBA::Long theShapeType,
644 const CORBA::Boolean isSorted)
646 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
648 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
649 if (aShape.IsNull()) return aSeq._retn();
651 Handle(TColStd_HSequenceOfTransient) aHSeq =
652 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
653 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
654 if (!GetOperations()->IsDone() || aHSeq.IsNull())
657 Standard_Integer aLength = aHSeq->Length();
658 aSeq->length(aLength);
659 for (Standard_Integer i = 1; i <= aLength; i++)
660 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
665 //=============================================================================
667 * ExtractSubShapes (excluding theShape itself, good sorting)
669 //=============================================================================
670 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
671 const CORBA::Long theShapeType,
672 const CORBA::Boolean isSorted)
674 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
676 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
677 if (aShape.IsNull()) return aSeq._retn();
679 Handle(TColStd_HSequenceOfTransient) aHSeq =
680 // TODO: enum instead of bool for the last argument
681 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
682 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
683 if (!GetOperations()->IsDone() || aHSeq.IsNull())
686 Standard_Integer aLength = aHSeq->Length();
687 aSeq->length(aLength);
688 for (Standard_Integer i = 1; i <= aLength; i++)
689 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
694 //=============================================================================
698 //=============================================================================
699 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
700 const CORBA::Long theShapeType,
701 const CORBA::Boolean isSorted)
703 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
705 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
706 if (aShape.IsNull()) return aSeq._retn();
708 Handle(TColStd_HSequenceOfInteger) aHSeq =
709 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
710 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
711 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
713 Standard_Integer aLength = aHSeq->Length();
714 aSeq->length(aLength);
715 for (Standard_Integer i = 1; i <= aLength; i++)
716 aSeq[i-1] = aHSeq->Value(i);
721 //=============================================================================
725 //=============================================================================
726 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
727 const CORBA::Long theShapeType,
728 const CORBA::Boolean isSorted)
730 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
732 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
733 if (aShape.IsNull()) return aSeq._retn();
735 Handle(TColStd_HSequenceOfInteger) aHSeq =
736 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
737 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
738 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
740 Standard_Integer aLength = aHSeq->Length();
741 aSeq->length(aLength);
742 for (Standard_Integer i = 1; i <= aLength; i++)
743 aSeq[i-1] = aHSeq->Value(i);
748 //=============================================================================
752 //=============================================================================
753 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
754 (GEOM::GEOM_Object_ptr theMainShape,
755 const CORBA::Long theID)
757 GEOM::GEOM_Object_var aGEOMObject;
759 //Set a not done flag
760 GetOperations()->SetNotDone();
762 //Get the reference objects
763 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
764 if (aShape.IsNull()) return aGEOMObject._retn();
766 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
767 if (!GetOperations()->IsDone() || anObject.IsNull())
768 return aGEOMObject._retn();
770 return GetObject(anObject);
773 //=============================================================================
777 //=============================================================================
778 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
779 const GEOM::ListOfLong& theIndices)
781 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
784 //Set a not done flag
785 GetOperations()->SetNotDone();
787 if (theIndices.length() < 1)
790 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
791 if (aShape.IsNull()) return aSeq._retn();
793 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
794 for (i = 0; i < theIndices.length(); i++)
795 anArray->SetValue(i+1, theIndices[i]);
797 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
798 if (!GetOperations()->IsDone() || aHSeq.IsNull())
801 Standard_Integer aLength = aHSeq->Length();
802 aSeq->length(aLength);
803 for (i = 0; i < aLength; i++)
804 aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
809 //=============================================================================
813 //=============================================================================
814 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
815 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
817 //Get the reference shapes
818 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
819 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
821 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
823 //Get the unique ID of <theSubShape> inside <theMainShape>
824 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
825 if (!GetOperations()->IsDone())
831 //=============================================================================
833 * GetSubShapesIndices
835 //=============================================================================
836 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
837 (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
839 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
841 //Get the reference main shape
842 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
843 if (aMainShapeRef.IsNull()) return aSeq._retn();
846 std::list<Handle(GEOM_Object)> aShapes;
847 int aLen = theSubShapes.length();
848 for (int ind = 0; ind < aLen; ind++) {
849 Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
852 MESSAGE("NULL shape")
855 aShapes.push_back(aSh);
858 //Get the IDs of <theSubShapes> inside <theMainShape>
859 Handle(TColStd_HSequenceOfInteger) aHSeq =
860 GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
862 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
864 Standard_Integer aLength = aHSeq->Length();
865 aSeq->length(aLength);
867 for (Standard_Integer i = 1; i <= aLength; i++)
868 aSeq[i-1] = aHSeq->Value(i);
874 //=============================================================================
878 //=============================================================================
879 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
880 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
882 //Get the reference shapes
883 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
884 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
886 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
888 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
889 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
890 if (!GetOperations()->IsDone())
896 //=============================================================================
900 //=============================================================================
901 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
903 //Get the reference shape
904 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
905 if (aShape.IsNull()) return NULL;
907 // Get shape parameters
908 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
909 return CORBA::string_dup(aDescription.ToCString());
912 //=============================================================================
916 //=============================================================================
917 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
919 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
922 //=============================================================================
926 //=============================================================================
927 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
929 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
932 //=============================================================================
936 //=============================================================================
937 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
938 const CORBA::Long theShapeType)
940 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
941 if (aShape.IsNull()) return -1;
943 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
944 if (!GetOperations()->IsDone()) return -1;
949 //=============================================================================
953 //=============================================================================
954 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
955 (GEOM::GEOM_Object_ptr theShape)
957 GEOM::GEOM_Object_var aGEOMObject;
959 //Set a not done flag
960 GetOperations()->SetNotDone();
962 //Get the reference objects
963 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
964 if (aShape.IsNull()) return aGEOMObject._retn();
967 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
968 if (!GetOperations()->IsDone() || anObject.IsNull())
969 return aGEOMObject._retn();
971 return GetObject(anObject);
974 //=============================================================================
978 //=============================================================================
979 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
981 //Set a not done flag
982 GetOperations()->SetNotDone();
984 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
986 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
987 if (aShape.IsNull()) return aSeq._retn();
989 Handle(TColStd_HSequenceOfInteger) aHSeq =
990 GetOperations()->GetFreeFacesIDs(aShape);
991 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
993 Standard_Integer aLength = aHSeq->Length();
994 aSeq->length(aLength);
995 for (Standard_Integer i = 1; i <= aLength; i++)
996 aSeq[i-1] = aHSeq->Value(i);
1001 //=============================================================================
1005 //=============================================================================
1006 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1007 (GEOM::GEOM_Object_ptr theShape1,
1008 GEOM::GEOM_Object_ptr theShape2,
1009 const CORBA::Long theShapeType)
1011 //Set a not done flag
1012 GetOperations()->SetNotDone();
1014 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1016 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1017 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1019 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1021 Handle(TColStd_HSequenceOfTransient) aHSeq =
1022 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1023 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1024 return aSeq._retn();
1026 Standard_Integer aLength = aHSeq->Length();
1027 aSeq->length(aLength);
1028 for (Standard_Integer i = 1; i <= aLength; i++)
1029 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1031 return aSeq._retn();
1034 //=============================================================================
1036 * GetSharedShapesMulti
1038 //=============================================================================
1039 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1040 (const GEOM::ListOfGO& theShapes,
1041 const CORBA::Long theShapeType)
1043 //Set a not done flag
1044 GetOperations()->SetNotDone();
1046 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1049 std::list<Handle(GEOM_Object)> aShapes;
1050 if (! GetListOfObjectsImpl( theShapes, aShapes ))
1051 return aSeq._retn();
1053 Handle(TColStd_HSequenceOfTransient) aHSeq =
1054 GetOperations()->GetSharedShapes(aShapes, theShapeType);
1055 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1056 return aSeq._retn();
1058 Standard_Integer aLength = aHSeq->Length();
1059 aSeq->length(aLength);
1060 for (Standard_Integer i = 1; i <= aLength; i++)
1061 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1063 return aSeq._retn();
1066 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1068 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1072 aState = GEOMAlgo_ST_ON;
1075 aState = GEOMAlgo_ST_OUT;
1077 case GEOM::ST_ONOUT:
1078 aState = GEOMAlgo_ST_ONOUT;
1081 aState = GEOMAlgo_ST_IN;
1084 aState = GEOMAlgo_ST_ONIN;
1093 //=============================================================================
1097 //=============================================================================
1098 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1099 (GEOM::GEOM_Object_ptr theShape,
1100 const CORBA::Long theShapeType,
1101 GEOM::GEOM_Object_ptr theAx1,
1102 const GEOM::shape_state theState)
1104 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1106 //Set a not done flag
1107 GetOperations()->SetNotDone();
1109 //Get the reference objects
1110 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1111 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1113 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1115 //Get Shapes On Plane
1116 Handle(TColStd_HSequenceOfTransient) aHSeq =
1117 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1118 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1119 return aSeq._retn();
1121 Standard_Integer aLength = aHSeq->Length();
1122 aSeq->length(aLength);
1123 for (Standard_Integer i = 1; i <= aLength; i++)
1124 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1126 return aSeq._retn();
1129 //=============================================================================
1131 * GetShapesOnPlaneWithLocation
1133 //=============================================================================
1134 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1135 (GEOM::GEOM_Object_ptr theShape,
1136 const CORBA::Long theShapeType,
1137 GEOM::GEOM_Object_ptr theAx1,
1138 GEOM::GEOM_Object_ptr thePnt,
1139 const GEOM::shape_state theState)
1141 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1143 //Set a not done flag
1144 GetOperations()->SetNotDone();
1146 //Get the reference objects
1147 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1148 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1149 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1151 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1153 //Get Shapes On Plane
1154 Handle(TColStd_HSequenceOfTransient) aHSeq =
1155 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1156 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1157 return aSeq._retn();
1159 Standard_Integer aLength = aHSeq->Length();
1160 aSeq->length(aLength);
1161 for (Standard_Integer i = 1; i <= aLength; i++)
1162 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1164 return aSeq._retn();
1167 //=============================================================================
1169 * GetShapesOnCylinder
1171 //=============================================================================
1172 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1173 (GEOM::GEOM_Object_ptr theShape,
1174 const CORBA::Long theShapeType,
1175 GEOM::GEOM_Object_ptr theAxis,
1176 const CORBA::Double theRadius,
1177 const GEOM::shape_state theState)
1179 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1181 //Set a not done flag
1182 GetOperations()->SetNotDone();
1184 //Get the reference objects
1185 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1186 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1188 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1190 //Get Shapes On Cylinder
1191 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1192 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1193 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1194 return aSeq._retn();
1196 Standard_Integer aLength = aHSeq->Length();
1197 aSeq->length(aLength);
1198 for (Standard_Integer i = 1; i <= aLength; i++)
1199 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1201 return aSeq._retn();
1204 //=============================================================================
1206 * GetShapesOnCylinderWithLocation
1208 //=============================================================================
1209 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1210 (GEOM::GEOM_Object_ptr theShape,
1211 const CORBA::Long theShapeType,
1212 GEOM::GEOM_Object_ptr theAxis,
1213 GEOM::GEOM_Object_ptr thePnt,
1214 const CORBA::Double theRadius,
1215 const GEOM::shape_state theState)
1217 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1219 //Set a not done flag
1220 GetOperations()->SetNotDone();
1222 //Get the reference objects
1223 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1224 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1225 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1227 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1229 //Get Shapes On Cylinder
1230 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1231 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1232 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1233 return aSeq._retn();
1235 Standard_Integer aLength = aHSeq->Length();
1236 aSeq->length(aLength);
1237 for (Standard_Integer i = 1; i <= aLength; i++)
1238 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1240 return aSeq._retn();
1243 //=============================================================================
1247 //=============================================================================
1248 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1249 (GEOM::GEOM_Object_ptr theShape,
1250 const CORBA::Long theShapeType,
1251 GEOM::GEOM_Object_ptr theCenter,
1252 const CORBA::Double theRadius,
1253 const GEOM::shape_state theState)
1255 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1257 //Set a not done flag
1258 GetOperations()->SetNotDone();
1260 //Get the reference objects
1261 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1262 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1264 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1266 //Get Shapes On Sphere
1267 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1268 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1269 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1270 return aSeq._retn();
1272 Standard_Integer aLength = aHSeq->Length();
1273 aSeq->length(aLength);
1274 for (Standard_Integer i = 1; i <= aLength; i++)
1275 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1277 return aSeq._retn();
1280 //=============================================================================
1282 * GetShapesOnQuadrangle
1284 //=============================================================================
1285 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1286 (GEOM::GEOM_Object_ptr theShape,
1287 CORBA::Long theShapeType,
1288 GEOM::GEOM_Object_ptr theTopLeftPoint,
1289 GEOM::GEOM_Object_ptr theTopRigthPoint,
1290 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1291 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1292 GEOM::shape_state theState)
1294 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1296 //Set a not done flag
1297 GetOperations()->SetNotDone();
1299 //Get the reference objects
1300 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1301 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1302 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1303 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1304 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1306 if (aShape.IsNull() ||
1307 aTopLeftPoint.IsNull() ||
1308 aTopRigthPoint.IsNull() ||
1309 aBottomLeftPoint.IsNull() ||
1310 aBottomRigthPoint.IsNull())
1311 return aSeq._retn();
1313 //Get Shapes On Quadrangle
1314 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1315 (aShape, theShapeType,
1316 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1317 ShapeState(theState));
1318 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1319 return aSeq._retn();
1321 Standard_Integer aLength = aHSeq->Length();
1322 aSeq->length(aLength);
1323 for (Standard_Integer i = 1; i <= aLength; i++)
1324 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1326 return aSeq._retn();
1329 //=============================================================================
1331 * GetShapesOnPlaneIDs
1333 //=============================================================================
1334 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1335 (GEOM::GEOM_Object_ptr theShape,
1336 const CORBA::Long theShapeType,
1337 GEOM::GEOM_Object_ptr theAx1,
1338 const GEOM::shape_state theState)
1340 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1342 //Set a not done flag
1343 GetOperations()->SetNotDone();
1345 //Get the reference objects
1346 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1347 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1349 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1351 //Get Shapes On Plane
1352 Handle(TColStd_HSequenceOfInteger) aHSeq =
1353 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1354 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1355 return aSeq._retn();
1357 Standard_Integer aLength = aHSeq->Length();
1358 aSeq->length(aLength);
1359 for (Standard_Integer i = 1; i <= aLength; i++)
1360 aSeq[i-1] = aHSeq->Value(i);
1362 return aSeq._retn();
1365 //=============================================================================
1367 * GetShapesOnPlaneWithLocationIDs
1369 //=============================================================================
1370 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1371 (GEOM::GEOM_Object_ptr theShape,
1372 const CORBA::Long theShapeType,
1373 GEOM::GEOM_Object_ptr theAx1,
1374 GEOM::GEOM_Object_ptr thePnt,
1375 const GEOM::shape_state theState)
1377 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1379 //Set a not done flag
1380 GetOperations()->SetNotDone();
1382 //Get the reference objects
1383 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1384 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1385 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1387 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1389 //Get Shapes On Plane
1390 Handle(TColStd_HSequenceOfInteger) aHSeq =
1391 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1392 anAx1, anPnt, ShapeState(theState));
1393 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1394 return aSeq._retn();
1396 Standard_Integer aLength = aHSeq->Length();
1397 aSeq->length(aLength);
1398 for (Standard_Integer i = 1; i <= aLength; i++)
1399 aSeq[i-1] = aHSeq->Value(i);
1401 return aSeq._retn();
1404 //=============================================================================
1406 * GetShapesOnCylinderIDs
1408 //=============================================================================
1409 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1410 (GEOM::GEOM_Object_ptr theShape,
1411 const CORBA::Long theShapeType,
1412 GEOM::GEOM_Object_ptr theAxis,
1413 const CORBA::Double theRadius,
1414 const GEOM::shape_state theState)
1416 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1418 //Set a not done flag
1419 GetOperations()->SetNotDone();
1421 //Get the reference objects
1422 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1423 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1425 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1427 //Get Shapes On Cylinder
1428 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1429 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1430 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1431 return aSeq._retn();
1433 Standard_Integer aLength = aHSeq->Length();
1434 aSeq->length(aLength);
1435 for (Standard_Integer i = 1; i <= aLength; i++)
1436 aSeq[i-1] = aHSeq->Value(i);
1438 return aSeq._retn();
1441 //=============================================================================
1443 * GetShapesOnCylinderWithLocationIDs
1445 //=============================================================================
1446 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1447 (GEOM::GEOM_Object_ptr theShape,
1448 const CORBA::Long theShapeType,
1449 GEOM::GEOM_Object_ptr theAxis,
1450 GEOM::GEOM_Object_ptr thePnt,
1451 const CORBA::Double theRadius,
1452 const GEOM::shape_state theState)
1454 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1456 //Set a not done flag
1457 GetOperations()->SetNotDone();
1459 //Get the reference objects
1460 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1461 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1462 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1464 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1466 //Get Shapes On Cylinder
1467 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1468 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1469 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1470 return aSeq._retn();
1472 Standard_Integer aLength = aHSeq->Length();
1473 aSeq->length(aLength);
1474 for (Standard_Integer i = 1; i <= aLength; i++)
1475 aSeq[i-1] = aHSeq->Value(i);
1477 return aSeq._retn();
1480 //=============================================================================
1482 * GetShapesOnSphereIDs
1484 //=============================================================================
1485 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1486 (GEOM::GEOM_Object_ptr theShape,
1487 const CORBA::Long theShapeType,
1488 GEOM::GEOM_Object_ptr theCenter,
1489 const CORBA::Double theRadius,
1490 const GEOM::shape_state theState)
1492 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1494 //Set a not done flag
1495 GetOperations()->SetNotDone();
1497 //Get the reference objects
1498 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1499 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1501 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1503 //Get Shapes On Sphere
1504 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1505 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1506 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1507 return aSeq._retn();
1509 Standard_Integer aLength = aHSeq->Length();
1510 aSeq->length(aLength);
1511 for (Standard_Integer i = 1; i <= aLength; i++)
1512 aSeq[i-1] = aHSeq->Value(i);
1514 return aSeq._retn();
1517 //=============================================================================
1519 * GetShapesOnQuadrangleIDs
1521 //=============================================================================
1522 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1523 (GEOM::GEOM_Object_ptr theShape,
1524 CORBA::Long theShapeType,
1525 GEOM::GEOM_Object_ptr theTopLeftPoint,
1526 GEOM::GEOM_Object_ptr theTopRigthPoint,
1527 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1528 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1529 GEOM::shape_state theState)
1531 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1533 //Set a not done flag
1534 GetOperations()->SetNotDone();
1536 //Get the reference objects
1537 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1538 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1539 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1540 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1541 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1543 if (aShape.IsNull() ||
1544 aTopLeftPoint.IsNull() ||
1545 aTopRigthPoint.IsNull() ||
1546 aBottomLeftPoint.IsNull() ||
1547 aBottomRigthPoint.IsNull() )
1548 return aSeq._retn();
1550 //Get Shapes On Quadrangle
1551 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1552 (aShape, theShapeType,
1553 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1554 ShapeState(theState));
1555 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1556 return aSeq._retn();
1558 Standard_Integer aLength = aHSeq->Length();
1559 aSeq->length(aLength);
1560 for (Standard_Integer i = 1; i <= aLength; i++)
1561 aSeq[i-1] = aHSeq->Value(i);
1563 return aSeq._retn();
1566 //=============================================================================
1570 //=============================================================================
1571 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1572 (GEOM::GEOM_Object_ptr theBox,
1573 GEOM::GEOM_Object_ptr theShape,
1574 CORBA::Long theShapeType,
1575 GEOM::shape_state theState)
1577 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1579 //Set a not done flag
1580 GetOperations()->SetNotDone();
1582 //Get the reference objects
1583 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1584 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1586 if (aShape.IsNull() || aBox.IsNull() )
1587 return aSeq._retn();
1590 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1591 (aBox,aShape, theShapeType,ShapeState(theState));
1592 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1593 return aSeq._retn();
1595 Standard_Integer aLength = aHSeq->Length();
1596 aSeq->length(aLength);
1597 for (Standard_Integer i = 1; i <= aLength; i++)
1598 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1600 return aSeq._retn();
1603 //=============================================================================
1605 * GetShapesOnQuadrangleIDs
1607 //=============================================================================
1608 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1609 (GEOM::GEOM_Object_ptr theBox,
1610 GEOM::GEOM_Object_ptr theShape,
1611 CORBA::Long theShapeType,
1612 GEOM::shape_state theState)
1614 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1616 //Set a not done flag
1617 GetOperations()->SetNotDone();
1619 //Get the reference objects
1620 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1621 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1623 if (aShape.IsNull() || aBox.IsNull() )
1624 return aSeq._retn();
1627 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1628 (aBox,aShape, theShapeType,ShapeState(theState));
1629 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1630 return aSeq._retn();
1632 Standard_Integer aLength = aHSeq->Length();
1633 aSeq->length(aLength);
1634 for (Standard_Integer i = 1; i <= aLength; i++)
1635 aSeq[i-1] = aHSeq->Value(i);
1637 return aSeq._retn();
1641 //=============================================================================
1645 //=============================================================================
1646 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1647 (GEOM::GEOM_Object_ptr theCheckShape,
1648 GEOM::GEOM_Object_ptr theShape,
1649 CORBA::Short theShapeType,
1650 GEOM::shape_state theState)
1652 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1654 //Set a not done flag
1655 GetOperations()->SetNotDone();
1657 //Get the reference objects
1658 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1659 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1661 if (aShape.IsNull() || aCheckShape.IsNull() )
1662 return aSeq._retn();
1664 //Get Shapes On Shape
1665 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1666 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1668 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1669 return aSeq._retn();
1671 Standard_Integer aLength = aHSeq->Length();
1672 aSeq->length(aLength);
1673 for (Standard_Integer i = 1; i <= aLength; i++)
1674 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1676 return aSeq._retn();
1680 //=============================================================================
1682 * GetShapesOnShapeAsCompound
1684 //=============================================================================
1685 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1686 (GEOM::GEOM_Object_ptr theCheckShape,
1687 GEOM::GEOM_Object_ptr theShape,
1688 CORBA::Short theShapeType,
1689 GEOM::shape_state theState)
1691 GEOM::GEOM_Object_var aGEOMObject;
1693 //Set a not done flag
1694 GetOperations()->SetNotDone();
1696 //Get the reference objects
1697 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1698 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1700 if (aShape.IsNull() || aCheckShape.IsNull() )
1701 return aGEOMObject._retn();
1703 //Get Shapes On Shape
1704 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1705 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1707 if (anObject.IsNull())
1708 return aGEOMObject._retn();
1710 return GetObject(anObject);
1714 //=============================================================================
1716 * GetShapesOnShapeIDs
1718 //=============================================================================
1719 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1720 (GEOM::GEOM_Object_ptr theCheckShape,
1721 GEOM::GEOM_Object_ptr theShape,
1722 CORBA::Short theShapeType,
1723 GEOM::shape_state theState)
1725 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1727 //Set a not done flag
1728 GetOperations()->SetNotDone();
1730 //Get the reference objects
1731 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1732 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1734 if (aShape.IsNull() || aCheckShape.IsNull() )
1735 return aSeq._retn();
1737 //Get Shapes On Shape
1738 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1739 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1740 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1741 return aSeq._retn();
1743 Standard_Integer aLength = aHSeq->Length();
1744 aSeq->length(aLength);
1745 for (Standard_Integer i = 1; i <= aLength; i++)
1746 aSeq[i-1] = aHSeq->Value(i);
1748 return aSeq._retn();
1752 //=============================================================================
1756 //=============================================================================
1757 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1758 (GEOM::GEOM_Object_ptr theShapeWhere,
1759 GEOM::GEOM_Object_ptr theShapeWhat)
1761 GEOM::GEOM_Object_var aGEOMObject;
1763 //Set a not done flag
1764 GetOperations()->SetNotDone();
1766 //Get the reference objects
1767 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1768 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1770 if (aShapeWhere.IsNull() ||
1771 aShapeWhat.IsNull()) return aGEOMObject._retn();
1773 //Get Shapes in place of aShapeWhat
1774 Handle(GEOM_Object) anObject =
1775 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1776 if (!GetOperations()->IsDone() || anObject.IsNull())
1777 return aGEOMObject._retn();
1779 return GetObject(anObject);
1782 //=============================================================================
1786 //=============================================================================
1787 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1788 (GEOM::GEOM_Object_ptr theShapeWhere,
1789 GEOM::GEOM_Object_ptr theShapeWhat)
1791 GEOM::GEOM_Object_var aGEOMObject;
1793 //Set a not done flag
1794 GetOperations()->SetNotDone();
1796 //Get the reference objects
1797 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1798 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1800 if (aShapeWhere.IsNull() ||
1801 aShapeWhat.IsNull()) return aGEOMObject._retn();
1803 //Get Shapes in place of aShapeWhat
1804 Handle(GEOM_Object) anObject =
1805 GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1806 if (!GetOperations()->IsDone() || anObject.IsNull())
1807 return aGEOMObject._retn();
1809 return GetObject(anObject);
1812 //=============================================================================
1814 * GetInPlaceByHistory
1816 //=============================================================================
1817 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1818 (GEOM::GEOM_Object_ptr theShapeWhere,
1819 GEOM::GEOM_Object_ptr theShapeWhat)
1821 GEOM::GEOM_Object_var aGEOMObject;
1823 //Set a not done flag
1824 GetOperations()->SetNotDone();
1826 //Get the reference objects
1827 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1828 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1830 if (aShapeWhere.IsNull() ||
1831 aShapeWhat.IsNull()) return aGEOMObject._retn();
1833 //Get Shapes in place of aShapeWhat
1834 Handle(GEOM_Object) anObject =
1835 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1836 if (!GetOperations()->IsDone() || anObject.IsNull())
1837 return aGEOMObject._retn();
1839 return GetObject(anObject);
1842 //=============================================================================
1846 //=============================================================================
1847 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1848 (GEOM::GEOM_Object_ptr theShapeWhere,
1849 GEOM::GEOM_Object_ptr theShapeWhat)
1851 GEOM::GEOM_Object_var aGEOMObject;
1853 //Set a not done flag
1854 GetOperations()->SetNotDone();
1856 //Get the reference objects
1857 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1858 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1860 if (aShapeWhere.IsNull() ||
1861 aShapeWhat.IsNull()) return aGEOMObject._retn();
1863 //Get Shapes in place of aShapeWhat
1864 Handle(GEOM_Object) anObject =
1865 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1866 if (!GetOperations()->IsDone() || anObject.IsNull())
1867 return aGEOMObject._retn();
1869 return GetObject(anObject);
1872 //=============================================================================
1876 //=============================================================================
1877 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1878 (GEOM::GEOM_Object_ptr theShapeWhere,
1879 GEOM::GEOM_Object_ptr theShapeWhat) {
1880 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1882 //Get the reference objects
1883 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1884 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1886 if (aShapeWhere.IsNull() ||
1887 aShapeWhat.IsNull()) return aSeq._retn();
1890 Handle(TColStd_HSequenceOfInteger) aHSeq =
1891 GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1893 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1895 Standard_Integer aLength = aHSeq->Length();
1896 aSeq->length(aLength);
1897 for (Standard_Integer i = 1; i <= aLength; i++)
1898 aSeq[i-1] = aHSeq->Value(i);
1900 return aSeq._retn();