1 // Copyright (C) 2007-2012 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
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 GEOM_IShapesOperations_i::MakeCompound
349 (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 GEOM_IShapesOperations_i::MakeGlueFaces
382 (GEOM::GEOM_Object_ptr theShape,
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 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
393 if (aShape.IsNull()) return aGEOMObject._retn();
396 Handle(GEOM_Object) anObject =
397 GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
398 //if (!GetOperations()->IsDone() || anObject.IsNull())
400 if (anObject.IsNull())
401 return aGEOMObject._retn();
403 return GetObject(anObject);
406 //=============================================================================
410 //=============================================================================
411 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
412 (GEOM::GEOM_Object_ptr theShape,
413 const CORBA::Double theTolerance)
415 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
417 //Set a not done flag
418 GetOperations()->SetNotDone();
420 //Get the reference objects
421 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
422 if (aShape.IsNull()) return aSeq._retn();
424 Handle(TColStd_HSequenceOfTransient) aHSeq =
425 //GetOperations()->GetGlueFaces(aShape, theTolerance);
426 GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
428 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
433 Standard_Integer aLength = aHSeq->Length();
434 aSeq->length(aLength);
435 for (Standard_Integer i = 1; i <= aLength; i++)
436 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
441 //=============================================================================
443 * MakeGlueFacesByList
445 //=============================================================================
446 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
447 (GEOM::GEOM_Object_ptr theShape,
448 CORBA::Double theTolerance,
449 const GEOM::ListOfGO& theFaces,
450 CORBA::Boolean doKeepNonSolids,
451 CORBA::Boolean doGlueAllEdges)
453 GEOM::GEOM_Object_var aGEOMObject;
455 //Set a not done flag
456 GetOperations()->SetNotDone();
458 //Get the reference objects
459 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
460 if (aShape.IsNull()) return aGEOMObject._retn();
463 std::list<Handle(GEOM_Object)> aFaces;
465 aLen = theFaces.length();
466 for (ind = 0; ind < aLen; ind++) {
467 Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
468 if (aSh.IsNull()) return aGEOMObject._retn();
469 aFaces.push_back(aSh);
473 Handle(GEOM_Object) anObject =
474 GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids, doGlueAllEdges);
475 //if (!GetOperations()->IsDone() || anObject.IsNull())
477 if (anObject.IsNull())
478 return aGEOMObject._retn();
480 return GetObject(anObject);
483 //=============================================================================
487 //=============================================================================
488 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
489 (GEOM::GEOM_Object_ptr theShape,
490 CORBA::Double theTolerance)
492 GEOM::GEOM_Object_var aGEOMObject;
494 //Set a not done flag
495 GetOperations()->SetNotDone();
497 //Get the reference objects
498 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
499 if (aShape.IsNull()) return aGEOMObject._retn();
502 Handle(GEOM_Object) anObject =
503 GetOperations()->MakeGlueEdges(aShape, theTolerance);
504 //if (!GetOperations()->IsDone() || anObject.IsNull())
506 if (anObject.IsNull())
507 return aGEOMObject._retn();
509 return GetObject(anObject);
512 //=============================================================================
516 //=============================================================================
517 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
518 (GEOM::GEOM_Object_ptr theShape,
519 const CORBA::Double theTolerance)
521 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
523 //Set a not done flag
524 GetOperations()->SetNotDone();
526 //Get the reference objects
527 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
528 if (aShape.IsNull()) return aSeq._retn();
530 Handle(TColStd_HSequenceOfTransient) aHSeq =
531 GetOperations()->GetGlueShapes(aShape, 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 GEOM_IShapesOperations_i::MakeGlueEdgesByList
552 (GEOM::GEOM_Object_ptr theShape,
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 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
563 if (aShape.IsNull()) return aGEOMObject._retn();
566 std::list<Handle(GEOM_Object)> anEdges;
568 aLen = theEdges.length();
569 for (ind = 0; ind < aLen; ind++) {
570 Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]);
571 if (aSh.IsNull()) return aGEOMObject._retn();
572 anEdges.push_back(aSh);
576 Handle(GEOM_Object) anObject =
577 GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges);
578 //if (!GetOperations()->IsDone() || anObject.IsNull())
580 if (anObject.IsNull())
581 return aGEOMObject._retn();
583 return GetObject(anObject);
586 //=============================================================================
588 * GetExistingSubObjects
590 //=============================================================================
591 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
592 CORBA::Boolean theGroupsOnly)
594 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
596 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
597 if (aShape.IsNull()) return aSeq._retn();
599 Handle(TColStd_HSequenceOfTransient) aHSeq =
600 GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
601 if (!GetOperations()->IsDone() || aHSeq.IsNull())
604 Standard_Integer aLength = aHSeq->Length();
605 aSeq->length(aLength);
606 for (Standard_Integer i = 1; i <= aLength; i++)
607 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
612 //=============================================================================
614 * MakeExplode (including theShape itself, bad sorting)
616 //=============================================================================
617 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
618 const CORBA::Long theShapeType,
619 const CORBA::Boolean isSorted)
621 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
623 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
624 if (aShape.IsNull()) return aSeq._retn();
626 Handle(TColStd_HSequenceOfTransient) aHSeq =
627 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
628 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
629 if (!GetOperations()->IsDone() || aHSeq.IsNull())
632 Standard_Integer aLength = aHSeq->Length();
633 aSeq->length(aLength);
634 for (Standard_Integer i = 1; i <= aLength; i++)
635 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
640 //=============================================================================
642 * MakeAllSubShapes (including theShape itself, good sorting)
644 //=============================================================================
645 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
646 const CORBA::Long theShapeType,
647 const CORBA::Boolean isSorted)
649 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
651 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
652 if (aShape.IsNull()) return aSeq._retn();
654 Handle(TColStd_HSequenceOfTransient) aHSeq =
655 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
656 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
657 if (!GetOperations()->IsDone() || aHSeq.IsNull())
660 Standard_Integer aLength = aHSeq->Length();
661 aSeq->length(aLength);
662 for (Standard_Integer i = 1; i <= aLength; i++)
663 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
668 //=============================================================================
670 * ExtractSubShapes (excluding theShape itself, good sorting)
672 //=============================================================================
673 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
674 const CORBA::Long theShapeType,
675 const CORBA::Boolean isSorted)
677 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
679 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
680 if (aShape.IsNull()) return aSeq._retn();
682 Handle(TColStd_HSequenceOfTransient) aHSeq =
683 // TODO: enum instead of bool for the last argument
684 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
685 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
686 if (!GetOperations()->IsDone() || aHSeq.IsNull())
689 Standard_Integer aLength = aHSeq->Length();
690 aSeq->length(aLength);
691 for (Standard_Integer i = 1; i <= aLength; i++)
692 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
697 //=============================================================================
701 //=============================================================================
702 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
703 const CORBA::Long theShapeType,
704 const CORBA::Boolean isSorted)
706 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
708 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
709 if (aShape.IsNull()) return aSeq._retn();
711 Handle(TColStd_HSequenceOfInteger) aHSeq =
712 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
713 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
714 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
716 Standard_Integer aLength = aHSeq->Length();
717 aSeq->length(aLength);
718 for (Standard_Integer i = 1; i <= aLength; i++)
719 aSeq[i-1] = aHSeq->Value(i);
724 //=============================================================================
728 //=============================================================================
729 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
730 const CORBA::Long theShapeType,
731 const CORBA::Boolean isSorted)
733 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
735 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
736 if (aShape.IsNull()) return aSeq._retn();
738 Handle(TColStd_HSequenceOfInteger) aHSeq =
739 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
740 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
741 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
743 Standard_Integer aLength = aHSeq->Length();
744 aSeq->length(aLength);
745 for (Standard_Integer i = 1; i <= aLength; i++)
746 aSeq[i-1] = aHSeq->Value(i);
751 //=============================================================================
755 //=============================================================================
756 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
757 (GEOM::GEOM_Object_ptr theMainShape,
758 const CORBA::Long theID)
760 GEOM::GEOM_Object_var aGEOMObject;
762 //Set a not done flag
763 GetOperations()->SetNotDone();
765 //Get the reference objects
766 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
767 if (aShape.IsNull()) return aGEOMObject._retn();
769 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
770 if (!GetOperations()->IsDone() || anObject.IsNull())
771 return aGEOMObject._retn();
773 return GetObject(anObject);
776 //=============================================================================
780 //=============================================================================
781 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
782 const GEOM::ListOfLong& theIndices)
784 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
787 //Set a not done flag
788 GetOperations()->SetNotDone();
790 if (theIndices.length() < 1)
793 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
794 if (aShape.IsNull()) return aSeq._retn();
796 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
797 for (i = 0; i < theIndices.length(); i++)
798 anArray->SetValue(i+1, theIndices[i]);
800 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
801 if (!GetOperations()->IsDone() || aHSeq.IsNull())
804 Standard_Integer aLength = aHSeq->Length();
805 aSeq->length(aLength);
806 for (i = 0; i < aLength; i++)
807 aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
812 //=============================================================================
816 //=============================================================================
817 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
818 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
820 //Get the reference shapes
821 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
822 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
824 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
826 //Get the unique ID of <theSubShape> inside <theMainShape>
827 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
828 if (!GetOperations()->IsDone())
834 //=============================================================================
838 //=============================================================================
839 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
840 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
842 //Get the reference shapes
843 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
844 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
846 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
848 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
849 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
850 if (!GetOperations()->IsDone())
856 //=============================================================================
860 //=============================================================================
861 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
863 //Get the reference shape
864 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
865 if (aShape.IsNull()) return NULL;
867 // Get shape parameters
868 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
869 return CORBA::string_dup(aDescription.ToCString());
872 //=============================================================================
876 //=============================================================================
877 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
879 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
882 //=============================================================================
886 //=============================================================================
887 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
889 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
892 //=============================================================================
896 //=============================================================================
897 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
898 const CORBA::Long theShapeType)
900 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
901 if (aShape.IsNull()) return -1;
903 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
904 if (!GetOperations()->IsDone()) return -1;
909 //=============================================================================
913 //=============================================================================
914 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
915 (GEOM::GEOM_Object_ptr theShape)
917 GEOM::GEOM_Object_var aGEOMObject;
919 //Set a not done flag
920 GetOperations()->SetNotDone();
922 //Get the reference objects
923 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
924 if (aShape.IsNull()) return aGEOMObject._retn();
927 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
928 if (!GetOperations()->IsDone() || anObject.IsNull())
929 return aGEOMObject._retn();
931 return GetObject(anObject);
934 //=============================================================================
938 //=============================================================================
939 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
941 //Set a not done flag
942 GetOperations()->SetNotDone();
944 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
946 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
947 if (aShape.IsNull()) return aSeq._retn();
949 Handle(TColStd_HSequenceOfInteger) aHSeq =
950 GetOperations()->GetFreeFacesIDs(aShape);
951 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
953 Standard_Integer aLength = aHSeq->Length();
954 aSeq->length(aLength);
955 for (Standard_Integer i = 1; i <= aLength; i++)
956 aSeq[i-1] = aHSeq->Value(i);
961 //=============================================================================
965 //=============================================================================
966 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
967 (GEOM::GEOM_Object_ptr theShape1,
968 GEOM::GEOM_Object_ptr theShape2,
969 const CORBA::Long theShapeType)
971 //Set a not done flag
972 GetOperations()->SetNotDone();
974 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
976 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
977 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
979 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
981 Handle(TColStd_HSequenceOfTransient) aHSeq =
982 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
983 if (!GetOperations()->IsDone() || aHSeq.IsNull())
986 Standard_Integer aLength = aHSeq->Length();
987 aSeq->length(aLength);
988 for (Standard_Integer i = 1; i <= aLength; i++)
989 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
994 //=============================================================================
996 * GetSharedShapesMulti
998 //=============================================================================
999 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1000 (const GEOM::ListOfGO& theShapes,
1001 const CORBA::Long theShapeType)
1003 //Set a not done flag
1004 GetOperations()->SetNotDone();
1006 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1009 std::list<Handle(GEOM_Object)> aShapes;
1010 int aLen = theShapes.length();
1011 for (int ind = 0; ind < aLen; ind++) {
1012 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1013 if (aSh.IsNull()) return aSeq._retn();
1014 aShapes.push_back(aSh);
1017 Handle(TColStd_HSequenceOfTransient) aHSeq =
1018 GetOperations()->GetSharedShapes(aShapes, theShapeType);
1019 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1020 return aSeq._retn();
1022 Standard_Integer aLength = aHSeq->Length();
1023 aSeq->length(aLength);
1024 for (Standard_Integer i = 1; i <= aLength; i++)
1025 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1027 return aSeq._retn();
1030 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1032 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1036 aState = GEOMAlgo_ST_ON;
1039 aState = GEOMAlgo_ST_OUT;
1041 case GEOM::ST_ONOUT:
1042 aState = GEOMAlgo_ST_ONOUT;
1045 aState = GEOMAlgo_ST_IN;
1048 aState = GEOMAlgo_ST_ONIN;
1057 //=============================================================================
1061 //=============================================================================
1062 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1063 (GEOM::GEOM_Object_ptr theShape,
1064 const CORBA::Long theShapeType,
1065 GEOM::GEOM_Object_ptr theAx1,
1066 const GEOM::shape_state theState)
1068 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1070 //Set a not done flag
1071 GetOperations()->SetNotDone();
1073 //Get the reference objects
1074 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1075 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1077 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1079 //Get Shapes On Plane
1080 Handle(TColStd_HSequenceOfTransient) aHSeq =
1081 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1082 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1083 return aSeq._retn();
1085 Standard_Integer aLength = aHSeq->Length();
1086 aSeq->length(aLength);
1087 for (Standard_Integer i = 1; i <= aLength; i++)
1088 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1090 return aSeq._retn();
1093 //=============================================================================
1095 * GetShapesOnPlaneWithLocation
1097 //=============================================================================
1098 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1099 (GEOM::GEOM_Object_ptr theShape,
1100 const CORBA::Long theShapeType,
1101 GEOM::GEOM_Object_ptr theAx1,
1102 GEOM::GEOM_Object_ptr thePnt,
1103 const GEOM::shape_state theState)
1105 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1107 //Set a not done flag
1108 GetOperations()->SetNotDone();
1110 //Get the reference objects
1111 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1112 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1113 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1115 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1117 //Get Shapes On Plane
1118 Handle(TColStd_HSequenceOfTransient) aHSeq =
1119 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1120 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1121 return aSeq._retn();
1123 Standard_Integer aLength = aHSeq->Length();
1124 aSeq->length(aLength);
1125 for (Standard_Integer i = 1; i <= aLength; i++)
1126 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1128 return aSeq._retn();
1131 //=============================================================================
1133 * GetShapesOnCylinder
1135 //=============================================================================
1136 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1137 (GEOM::GEOM_Object_ptr theShape,
1138 const CORBA::Long theShapeType,
1139 GEOM::GEOM_Object_ptr theAxis,
1140 const CORBA::Double theRadius,
1141 const GEOM::shape_state theState)
1143 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1145 //Set a not done flag
1146 GetOperations()->SetNotDone();
1148 //Get the reference objects
1149 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1150 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1152 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1154 //Get Shapes On Cylinder
1155 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1156 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1157 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1158 return aSeq._retn();
1160 Standard_Integer aLength = aHSeq->Length();
1161 aSeq->length(aLength);
1162 for (Standard_Integer i = 1; i <= aLength; i++)
1163 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1165 return aSeq._retn();
1168 //=============================================================================
1170 * GetShapesOnCylinderWithLocation
1172 //=============================================================================
1173 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1174 (GEOM::GEOM_Object_ptr theShape,
1175 const CORBA::Long theShapeType,
1176 GEOM::GEOM_Object_ptr theAxis,
1177 GEOM::GEOM_Object_ptr thePnt,
1178 const CORBA::Double theRadius,
1179 const GEOM::shape_state theState)
1181 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1183 //Set a not done flag
1184 GetOperations()->SetNotDone();
1186 //Get the reference objects
1187 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1188 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1189 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1191 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1193 //Get Shapes On Cylinder
1194 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1195 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1196 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1197 return aSeq._retn();
1199 Standard_Integer aLength = aHSeq->Length();
1200 aSeq->length(aLength);
1201 for (Standard_Integer i = 1; i <= aLength; i++)
1202 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1204 return aSeq._retn();
1207 //=============================================================================
1211 //=============================================================================
1212 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1213 (GEOM::GEOM_Object_ptr theShape,
1214 const CORBA::Long theShapeType,
1215 GEOM::GEOM_Object_ptr theCenter,
1216 const CORBA::Double theRadius,
1217 const GEOM::shape_state theState)
1219 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1221 //Set a not done flag
1222 GetOperations()->SetNotDone();
1224 //Get the reference objects
1225 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1226 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1228 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1230 //Get Shapes On Sphere
1231 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1232 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1233 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1234 return aSeq._retn();
1236 Standard_Integer aLength = aHSeq->Length();
1237 aSeq->length(aLength);
1238 for (Standard_Integer i = 1; i <= aLength; i++)
1239 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1241 return aSeq._retn();
1244 //=============================================================================
1246 * GetShapesOnQuadrangle
1248 //=============================================================================
1249 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1250 (GEOM::GEOM_Object_ptr theShape,
1251 CORBA::Long theShapeType,
1252 GEOM::GEOM_Object_ptr theTopLeftPoint,
1253 GEOM::GEOM_Object_ptr theTopRigthPoint,
1254 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1255 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1256 GEOM::shape_state theState)
1258 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1260 //Set a not done flag
1261 GetOperations()->SetNotDone();
1263 //Get the reference objects
1264 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1265 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1266 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1267 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1268 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1270 if (aShape.IsNull() ||
1271 aTopLeftPoint.IsNull() ||
1272 aTopRigthPoint.IsNull() ||
1273 aBottomLeftPoint.IsNull() ||
1274 aBottomRigthPoint.IsNull())
1275 return aSeq._retn();
1277 //Get Shapes On Quadrangle
1278 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1279 (aShape, theShapeType,
1280 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1281 ShapeState(theState));
1282 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1283 return aSeq._retn();
1285 Standard_Integer aLength = aHSeq->Length();
1286 aSeq->length(aLength);
1287 for (Standard_Integer i = 1; i <= aLength; i++)
1288 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1290 return aSeq._retn();
1293 //=============================================================================
1295 * GetShapesOnPlaneIDs
1297 //=============================================================================
1298 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1299 (GEOM::GEOM_Object_ptr theShape,
1300 const CORBA::Long theShapeType,
1301 GEOM::GEOM_Object_ptr theAx1,
1302 const GEOM::shape_state theState)
1304 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1306 //Set a not done flag
1307 GetOperations()->SetNotDone();
1309 //Get the reference objects
1310 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1311 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1313 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1315 //Get Shapes On Plane
1316 Handle(TColStd_HSequenceOfInteger) aHSeq =
1317 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, 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] = aHSeq->Value(i);
1326 return aSeq._retn();
1329 //=============================================================================
1331 * GetShapesOnPlaneWithLocationIDs
1333 //=============================================================================
1334 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1335 (GEOM::GEOM_Object_ptr theShape,
1336 const CORBA::Long theShapeType,
1337 GEOM::GEOM_Object_ptr theAx1,
1338 GEOM::GEOM_Object_ptr thePnt,
1339 const GEOM::shape_state theState)
1341 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1343 //Set a not done flag
1344 GetOperations()->SetNotDone();
1346 //Get the reference objects
1347 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1348 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1349 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1351 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1353 //Get Shapes On Plane
1354 Handle(TColStd_HSequenceOfInteger) aHSeq =
1355 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1356 anAx1, anPnt, ShapeState(theState));
1357 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1358 return aSeq._retn();
1360 Standard_Integer aLength = aHSeq->Length();
1361 aSeq->length(aLength);
1362 for (Standard_Integer i = 1; i <= aLength; i++)
1363 aSeq[i-1] = aHSeq->Value(i);
1365 return aSeq._retn();
1368 //=============================================================================
1370 * GetShapesOnCylinderIDs
1372 //=============================================================================
1373 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1374 (GEOM::GEOM_Object_ptr theShape,
1375 const CORBA::Long theShapeType,
1376 GEOM::GEOM_Object_ptr theAxis,
1377 const CORBA::Double theRadius,
1378 const GEOM::shape_state theState)
1380 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1382 //Set a not done flag
1383 GetOperations()->SetNotDone();
1385 //Get the reference objects
1386 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1387 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1389 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1391 //Get Shapes On Cylinder
1392 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1393 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1394 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1395 return aSeq._retn();
1397 Standard_Integer aLength = aHSeq->Length();
1398 aSeq->length(aLength);
1399 for (Standard_Integer i = 1; i <= aLength; i++)
1400 aSeq[i-1] = aHSeq->Value(i);
1402 return aSeq._retn();
1405 //=============================================================================
1407 * GetShapesOnCylinderWithLocationIDs
1409 //=============================================================================
1410 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1411 (GEOM::GEOM_Object_ptr theShape,
1412 const CORBA::Long theShapeType,
1413 GEOM::GEOM_Object_ptr theAxis,
1414 GEOM::GEOM_Object_ptr thePnt,
1415 const CORBA::Double theRadius,
1416 const GEOM::shape_state theState)
1418 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1420 //Set a not done flag
1421 GetOperations()->SetNotDone();
1423 //Get the reference objects
1424 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1425 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1426 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1428 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1430 //Get Shapes On Cylinder
1431 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1432 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1433 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1434 return aSeq._retn();
1436 Standard_Integer aLength = aHSeq->Length();
1437 aSeq->length(aLength);
1438 for (Standard_Integer i = 1; i <= aLength; i++)
1439 aSeq[i-1] = aHSeq->Value(i);
1441 return aSeq._retn();
1444 //=============================================================================
1446 * GetShapesOnSphereIDs
1448 //=============================================================================
1449 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1450 (GEOM::GEOM_Object_ptr theShape,
1451 const CORBA::Long theShapeType,
1452 GEOM::GEOM_Object_ptr theCenter,
1453 const CORBA::Double theRadius,
1454 const GEOM::shape_state theState)
1456 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1458 //Set a not done flag
1459 GetOperations()->SetNotDone();
1461 //Get the reference objects
1462 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1463 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1465 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1467 //Get Shapes On Sphere
1468 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1469 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1470 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1471 return aSeq._retn();
1473 Standard_Integer aLength = aHSeq->Length();
1474 aSeq->length(aLength);
1475 for (Standard_Integer i = 1; i <= aLength; i++)
1476 aSeq[i-1] = aHSeq->Value(i);
1478 return aSeq._retn();
1481 //=============================================================================
1483 * GetShapesOnQuadrangleIDs
1485 //=============================================================================
1486 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1487 (GEOM::GEOM_Object_ptr theShape,
1488 CORBA::Long theShapeType,
1489 GEOM::GEOM_Object_ptr theTopLeftPoint,
1490 GEOM::GEOM_Object_ptr theTopRigthPoint,
1491 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1492 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1493 GEOM::shape_state theState)
1495 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1497 //Set a not done flag
1498 GetOperations()->SetNotDone();
1500 //Get the reference objects
1501 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1502 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1503 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1504 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1505 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1507 if (aShape.IsNull() ||
1508 aTopLeftPoint.IsNull() ||
1509 aTopRigthPoint.IsNull() ||
1510 aBottomLeftPoint.IsNull() ||
1511 aBottomRigthPoint.IsNull() )
1512 return aSeq._retn();
1514 //Get Shapes On Quadrangle
1515 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1516 (aShape, theShapeType,
1517 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1518 ShapeState(theState));
1519 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1520 return aSeq._retn();
1522 Standard_Integer aLength = aHSeq->Length();
1523 aSeq->length(aLength);
1524 for (Standard_Integer i = 1; i <= aLength; i++)
1525 aSeq[i-1] = aHSeq->Value(i);
1527 return aSeq._retn();
1530 //=============================================================================
1534 //=============================================================================
1535 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1536 (GEOM::GEOM_Object_ptr theBox,
1537 GEOM::GEOM_Object_ptr theShape,
1538 CORBA::Long theShapeType,
1539 GEOM::shape_state theState)
1541 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1543 //Set a not done flag
1544 GetOperations()->SetNotDone();
1546 //Get the reference objects
1547 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1548 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1550 if (aShape.IsNull() || aBox.IsNull() )
1551 return aSeq._retn();
1554 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1555 (aBox,aShape, theShapeType,ShapeState(theState));
1556 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1557 return aSeq._retn();
1559 Standard_Integer aLength = aHSeq->Length();
1560 aSeq->length(aLength);
1561 for (Standard_Integer i = 1; i <= aLength; i++)
1562 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1564 return aSeq._retn();
1567 //=============================================================================
1569 * GetShapesOnQuadrangleIDs
1571 //=============================================================================
1572 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1573 (GEOM::GEOM_Object_ptr theBox,
1574 GEOM::GEOM_Object_ptr theShape,
1575 CORBA::Long theShapeType,
1576 GEOM::shape_state theState)
1578 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1580 //Set a not done flag
1581 GetOperations()->SetNotDone();
1583 //Get the reference objects
1584 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1585 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1587 if (aShape.IsNull() || aBox.IsNull() )
1588 return aSeq._retn();
1591 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1592 (aBox,aShape, theShapeType,ShapeState(theState));
1593 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1594 return aSeq._retn();
1596 Standard_Integer aLength = aHSeq->Length();
1597 aSeq->length(aLength);
1598 for (Standard_Integer i = 1; i <= aLength; i++)
1599 aSeq[i-1] = aHSeq->Value(i);
1601 return aSeq._retn();
1605 //=============================================================================
1609 //=============================================================================
1610 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1611 (GEOM::GEOM_Object_ptr theCheckShape,
1612 GEOM::GEOM_Object_ptr theShape,
1613 CORBA::Short theShapeType,
1614 GEOM::shape_state theState)
1616 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1618 //Set a not done flag
1619 GetOperations()->SetNotDone();
1621 //Get the reference objects
1622 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1623 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1625 if (aShape.IsNull() || aCheckShape.IsNull() )
1626 return aSeq._retn();
1628 //Get Shapes On Shape
1629 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1630 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1632 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1633 return aSeq._retn();
1635 Standard_Integer aLength = aHSeq->Length();
1636 aSeq->length(aLength);
1637 for (Standard_Integer i = 1; i <= aLength; i++)
1638 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1640 return aSeq._retn();
1644 //=============================================================================
1646 * GetShapesOnShapeAsCompound
1648 //=============================================================================
1649 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1650 (GEOM::GEOM_Object_ptr theCheckShape,
1651 GEOM::GEOM_Object_ptr theShape,
1652 CORBA::Short theShapeType,
1653 GEOM::shape_state theState)
1655 GEOM::GEOM_Object_var aGEOMObject;
1657 //Set a not done flag
1658 GetOperations()->SetNotDone();
1660 //Get the reference objects
1661 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1662 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1664 if (aShape.IsNull() || aCheckShape.IsNull() )
1665 return aGEOMObject._retn();
1667 //Get Shapes On Shape
1668 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1669 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1671 if (anObject.IsNull())
1672 return aGEOMObject._retn();
1674 return GetObject(anObject);
1678 //=============================================================================
1680 * GetShapesOnShapeIDs
1682 //=============================================================================
1683 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1684 (GEOM::GEOM_Object_ptr theCheckShape,
1685 GEOM::GEOM_Object_ptr theShape,
1686 CORBA::Short theShapeType,
1687 GEOM::shape_state theState)
1689 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1691 //Set a not done flag
1692 GetOperations()->SetNotDone();
1694 //Get the reference objects
1695 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1696 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1698 if (aShape.IsNull() || aCheckShape.IsNull() )
1699 return aSeq._retn();
1701 //Get Shapes On Shape
1702 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1703 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1704 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1705 return aSeq._retn();
1707 Standard_Integer aLength = aHSeq->Length();
1708 aSeq->length(aLength);
1709 for (Standard_Integer i = 1; i <= aLength; i++)
1710 aSeq[i-1] = aHSeq->Value(i);
1712 return aSeq._retn();
1716 //=============================================================================
1720 //=============================================================================
1721 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1722 (GEOM::GEOM_Object_ptr theShapeWhere,
1723 GEOM::GEOM_Object_ptr theShapeWhat)
1725 GEOM::GEOM_Object_var aGEOMObject;
1727 //Set a not done flag
1728 GetOperations()->SetNotDone();
1730 //Get the reference objects
1731 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1732 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1734 if (aShapeWhere.IsNull() ||
1735 aShapeWhat.IsNull()) return aGEOMObject._retn();
1737 //Get Shapes in place of aShapeWhat
1738 Handle(GEOM_Object) anObject =
1739 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1740 if (!GetOperations()->IsDone() || anObject.IsNull())
1741 return aGEOMObject._retn();
1743 return GetObject(anObject);
1746 //=============================================================================
1750 //=============================================================================
1751 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1752 (GEOM::GEOM_Object_ptr theShapeWhere,
1753 GEOM::GEOM_Object_ptr theShapeWhat)
1755 GEOM::GEOM_Object_var aGEOMObject;
1757 //Set a not done flag
1758 GetOperations()->SetNotDone();
1760 //Get the reference objects
1761 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1762 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1764 if (aShapeWhere.IsNull() ||
1765 aShapeWhat.IsNull()) return aGEOMObject._retn();
1767 //Get Shapes in place of aShapeWhat
1768 Handle(GEOM_Object) anObject =
1769 GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1770 if (!GetOperations()->IsDone() || anObject.IsNull())
1771 return aGEOMObject._retn();
1773 return GetObject(anObject);
1776 //=============================================================================
1778 * GetInPlaceByHistory
1780 //=============================================================================
1781 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1782 (GEOM::GEOM_Object_ptr theShapeWhere,
1783 GEOM::GEOM_Object_ptr theShapeWhat)
1785 GEOM::GEOM_Object_var aGEOMObject;
1787 //Set a not done flag
1788 GetOperations()->SetNotDone();
1790 //Get the reference objects
1791 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1792 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1794 if (aShapeWhere.IsNull() ||
1795 aShapeWhat.IsNull()) return aGEOMObject._retn();
1797 //Get Shapes in place of aShapeWhat
1798 Handle(GEOM_Object) anObject =
1799 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1800 if (!GetOperations()->IsDone() || anObject.IsNull())
1801 return aGEOMObject._retn();
1803 return GetObject(anObject);
1806 //=============================================================================
1810 //=============================================================================
1811 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1812 (GEOM::GEOM_Object_ptr theShapeWhere,
1813 GEOM::GEOM_Object_ptr theShapeWhat)
1815 GEOM::GEOM_Object_var aGEOMObject;
1817 //Set a not done flag
1818 GetOperations()->SetNotDone();
1820 //Get the reference objects
1821 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1822 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1824 if (aShapeWhere.IsNull() ||
1825 aShapeWhat.IsNull()) return aGEOMObject._retn();
1827 //Get Shapes in place of aShapeWhat
1828 Handle(GEOM_Object) anObject =
1829 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1830 if (!GetOperations()->IsDone() || anObject.IsNull())
1831 return aGEOMObject._retn();
1833 return GetObject(anObject);
1836 //=============================================================================
1840 //=============================================================================
1841 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1842 (GEOM::GEOM_Object_ptr theShapeWhere,
1843 GEOM::GEOM_Object_ptr theShapeWhat) {
1844 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1846 //Get the reference objects
1847 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1848 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1850 if (aShapeWhere.IsNull() ||
1851 aShapeWhat.IsNull()) return aSeq._retn();
1854 Handle(TColStd_HSequenceOfInteger) aHSeq =
1855 GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1857 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1859 Standard_Integer aLength = aHSeq->Length();
1860 aSeq->length(aLength);
1861 for (Standard_Integer i = 1; i <= aLength; i++)
1862 aSeq[i-1] = aHSeq->Value(i);
1864 return aSeq._retn();