1 // Copyright (C) 2007-2011 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 return aGEOMObject._retn();
208 return GetObject(anObject);
211 //=============================================================================
215 //=============================================================================
216 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
217 (const GEOM::ListOfGO& theWires,
218 const CORBA::Boolean isPlanarWanted)
220 GEOM::GEOM_Object_var aGEOMObject;
222 //Set a not done flag
223 GetOperations()->SetNotDone();
226 std::list<Handle(GEOM_Object)> aShapes;
229 aLen = theWires.length();
230 for (ind = 0; ind < aLen; ind++) {
231 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
232 if (aSh.IsNull()) return aGEOMObject._retn();
233 aShapes.push_back(aSh);
237 Handle(GEOM_Object) anObject =
238 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
239 if (!GetOperations()->IsDone() || anObject.IsNull())
240 return aGEOMObject._retn();
242 return GetObject(anObject);
245 //=============================================================================
249 //=============================================================================
250 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
251 (const GEOM::ListOfGO& theFacesAndShells)
253 GEOM::GEOM_Object_var aGEOMObject;
255 //Set a not done flag
256 GetOperations()->SetNotDone();
259 std::list<Handle(GEOM_Object)> aShapes;
262 aLen = theFacesAndShells.length();
263 for (ind = 0; ind < aLen; ind++) {
264 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
265 if (aSh.IsNull()) return aGEOMObject._retn();
266 aShapes.push_back(aSh);
270 Handle(GEOM_Object) anObject =
271 GetOperations()->MakeShell(aShapes);
272 if (!GetOperations()->IsDone() || anObject.IsNull())
273 return aGEOMObject._retn();
275 return GetObject(anObject);
278 //=============================================================================
282 //=============================================================================
283 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
284 (GEOM::GEOM_Object_ptr theShell)
286 GEOM::GEOM_Object_var aGEOMObject;
288 //Set a not done flag
289 GetOperations()->SetNotDone();
291 //Get the reference objects
292 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
293 if (aShell.IsNull()) return aGEOMObject._retn();
295 std::list<Handle(GEOM_Object)> aShapes;
296 aShapes.push_back(aShell);
299 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
300 if (!GetOperations()->IsDone() || anObject.IsNull())
301 return aGEOMObject._retn();
303 return GetObject(anObject);
306 //=============================================================================
310 //=============================================================================
311 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
312 (const GEOM::ListOfGO& theShells)
314 GEOM::GEOM_Object_var aGEOMObject;
316 //Set a not done flag
317 GetOperations()->SetNotDone();
320 std::list<Handle(GEOM_Object)> aShapes;
323 aLen = theShells.length();
324 for (ind = 0; ind < aLen; ind++) {
325 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
326 if (aSh.IsNull()) return aGEOMObject._retn();
327 aShapes.push_back(aSh);
331 Handle(GEOM_Object) anObject =
332 GetOperations()->MakeSolidShells(aShapes);
333 if (!GetOperations()->IsDone() || anObject.IsNull())
334 return aGEOMObject._retn();
336 return GetObject(anObject);
339 //=============================================================================
343 //=============================================================================
344 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
345 (const GEOM::ListOfGO& theShapes)
347 GEOM::GEOM_Object_var aGEOMObject;
349 //Set a not done flag
350 GetOperations()->SetNotDone();
353 std::list<Handle(GEOM_Object)> aShapes;
356 aLen = theShapes.length();
357 for (ind = 0; ind < aLen; ind++) {
358 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
359 if (aSh.IsNull()) return aGEOMObject._retn();
360 aShapes.push_back(aSh);
364 Handle(GEOM_Object) anObject =
365 GetOperations()->MakeCompound(aShapes);
366 if (!GetOperations()->IsDone() || anObject.IsNull())
367 return aGEOMObject._retn();
369 return GetObject(anObject);
372 //=============================================================================
376 //=============================================================================
377 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
378 (GEOM::GEOM_Object_ptr theShape,
379 CORBA::Double theTolerance,
380 CORBA::Boolean doKeepNonSolids)
382 GEOM::GEOM_Object_var aGEOMObject;
384 //Set a not done flag
385 GetOperations()->SetNotDone();
387 //Get the reference objects
388 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
389 if (aShape.IsNull()) return aGEOMObject._retn();
392 Handle(GEOM_Object) anObject =
393 GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
394 //if (!GetOperations()->IsDone() || anObject.IsNull())
396 if (anObject.IsNull())
397 return aGEOMObject._retn();
399 return GetObject(anObject);
402 //=============================================================================
406 //=============================================================================
407 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
408 (GEOM::GEOM_Object_ptr theShape,
409 const CORBA::Double theTolerance)
411 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
413 //Set a not done flag
414 GetOperations()->SetNotDone();
416 //Get the reference objects
417 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
418 if (aShape.IsNull()) return aSeq._retn();
420 Handle(TColStd_HSequenceOfTransient) aHSeq =
421 //GetOperations()->GetGlueFaces(aShape, theTolerance);
422 GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_FACE);
424 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
429 Standard_Integer aLength = aHSeq->Length();
430 aSeq->length(aLength);
431 for (Standard_Integer i = 1; i <= aLength; i++)
432 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
437 //=============================================================================
439 * MakeGlueFacesByList
441 //=============================================================================
442 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
443 (GEOM::GEOM_Object_ptr theShape,
444 CORBA::Double theTolerance,
445 const GEOM::ListOfGO& theFaces,
446 CORBA::Boolean doKeepNonSolids,
447 CORBA::Boolean doGlueAllEdges)
449 GEOM::GEOM_Object_var aGEOMObject;
451 //Set a not done flag
452 GetOperations()->SetNotDone();
454 //Get the reference objects
455 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
456 if (aShape.IsNull()) return aGEOMObject._retn();
459 std::list<Handle(GEOM_Object)> aFaces;
461 aLen = theFaces.length();
462 for (ind = 0; ind < aLen; ind++) {
463 Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
464 if (aSh.IsNull()) return aGEOMObject._retn();
465 aFaces.push_back(aSh);
469 Handle(GEOM_Object) anObject =
470 GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids, doGlueAllEdges);
471 //if (!GetOperations()->IsDone() || anObject.IsNull())
473 if (anObject.IsNull())
474 return aGEOMObject._retn();
476 return GetObject(anObject);
479 //=============================================================================
483 //=============================================================================
484 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdges
485 (GEOM::GEOM_Object_ptr theShape,
486 CORBA::Double theTolerance)
488 GEOM::GEOM_Object_var aGEOMObject;
490 //Set a not done flag
491 GetOperations()->SetNotDone();
493 //Get the reference objects
494 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
495 if (aShape.IsNull()) return aGEOMObject._retn();
498 Handle(GEOM_Object) anObject =
499 GetOperations()->MakeGlueEdges(aShape, theTolerance);
500 //if (!GetOperations()->IsDone() || anObject.IsNull())
502 if (anObject.IsNull())
503 return aGEOMObject._retn();
505 return GetObject(anObject);
508 //=============================================================================
512 //=============================================================================
513 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueEdges
514 (GEOM::GEOM_Object_ptr theShape,
515 const CORBA::Double theTolerance)
517 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
519 //Set a not done flag
520 GetOperations()->SetNotDone();
522 //Get the reference objects
523 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
524 if (aShape.IsNull()) return aSeq._retn();
526 Handle(TColStd_HSequenceOfTransient) aHSeq =
527 GetOperations()->GetGlueShapes(aShape, theTolerance, TopAbs_EDGE);
529 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
534 Standard_Integer aLength = aHSeq->Length();
535 aSeq->length(aLength);
536 for (Standard_Integer i = 1; i <= aLength; i++)
537 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
542 //=============================================================================
544 * MakeGlueEdgesByList
546 //=============================================================================
547 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueEdgesByList
548 (GEOM::GEOM_Object_ptr theShape,
549 CORBA::Double theTolerance,
550 const GEOM::ListOfGO& theEdges)
552 GEOM::GEOM_Object_var aGEOMObject;
554 //Set a not done flag
555 GetOperations()->SetNotDone();
557 //Get the reference objects
558 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
559 if (aShape.IsNull()) return aGEOMObject._retn();
562 std::list<Handle(GEOM_Object)> anEdges;
564 aLen = theEdges.length();
565 for (ind = 0; ind < aLen; ind++) {
566 Handle(GEOM_Object) aSh = GetObjectImpl(theEdges[ind]);
567 if (aSh.IsNull()) return aGEOMObject._retn();
568 anEdges.push_back(aSh);
572 Handle(GEOM_Object) anObject =
573 GetOperations()->MakeGlueEdgesByList(aShape, theTolerance, anEdges);
574 //if (!GetOperations()->IsDone() || anObject.IsNull())
576 if (anObject.IsNull())
577 return aGEOMObject._retn();
579 return GetObject(anObject);
582 //=============================================================================
584 * GetExistingSubObjects
586 //=============================================================================
587 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
588 CORBA::Boolean theGroupsOnly)
590 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
592 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
593 if (aShape.IsNull()) return aSeq._retn();
595 Handle(TColStd_HSequenceOfTransient) aHSeq =
596 GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
597 if (!GetOperations()->IsDone() || aHSeq.IsNull())
600 Standard_Integer aLength = aHSeq->Length();
601 aSeq->length(aLength);
602 for (Standard_Integer i = 1; i <= aLength; i++)
603 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
608 //=============================================================================
610 * MakeExplode (including theShape itself, bad sorting)
612 //=============================================================================
613 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
614 const CORBA::Long theShapeType,
615 const CORBA::Boolean isSorted)
617 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
619 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
620 if (aShape.IsNull()) return aSeq._retn();
622 Handle(TColStd_HSequenceOfTransient) aHSeq =
623 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
624 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
625 if (!GetOperations()->IsDone() || aHSeq.IsNull())
628 Standard_Integer aLength = aHSeq->Length();
629 aSeq->length(aLength);
630 for (Standard_Integer i = 1; i <= aLength; i++)
631 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
636 //=============================================================================
638 * MakeAllSubShapes (including theShape itself, good sorting)
640 //=============================================================================
641 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
642 const CORBA::Long theShapeType,
643 const CORBA::Boolean isSorted)
645 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
647 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
648 if (aShape.IsNull()) return aSeq._retn();
650 Handle(TColStd_HSequenceOfTransient) aHSeq =
651 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
652 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
653 if (!GetOperations()->IsDone() || aHSeq.IsNull())
656 Standard_Integer aLength = aHSeq->Length();
657 aSeq->length(aLength);
658 for (Standard_Integer i = 1; i <= aLength; i++)
659 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
664 //=============================================================================
666 * ExtractSubShapes (excluding theShape itself, good sorting)
668 //=============================================================================
669 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
670 const CORBA::Long theShapeType,
671 const CORBA::Boolean isSorted)
673 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
675 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
676 if (aShape.IsNull()) return aSeq._retn();
678 Handle(TColStd_HSequenceOfTransient) aHSeq =
679 // TODO: enum instead of bool for the last argument
680 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
681 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
682 if (!GetOperations()->IsDone() || aHSeq.IsNull())
685 Standard_Integer aLength = aHSeq->Length();
686 aSeq->length(aLength);
687 for (Standard_Integer i = 1; i <= aLength; i++)
688 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
693 //=============================================================================
697 //=============================================================================
698 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
699 const CORBA::Long theShapeType,
700 const CORBA::Boolean isSorted)
702 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
704 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
705 if (aShape.IsNull()) return aSeq._retn();
707 Handle(TColStd_HSequenceOfInteger) aHSeq =
708 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
709 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
710 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
712 Standard_Integer aLength = aHSeq->Length();
713 aSeq->length(aLength);
714 for (Standard_Integer i = 1; i <= aLength; i++)
715 aSeq[i-1] = aHSeq->Value(i);
720 //=============================================================================
724 //=============================================================================
725 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
726 const CORBA::Long theShapeType,
727 const CORBA::Boolean isSorted)
729 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
731 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
732 if (aShape.IsNull()) return aSeq._retn();
734 Handle(TColStd_HSequenceOfInteger) aHSeq =
735 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
736 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
737 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
739 Standard_Integer aLength = aHSeq->Length();
740 aSeq->length(aLength);
741 for (Standard_Integer i = 1; i <= aLength; i++)
742 aSeq[i-1] = aHSeq->Value(i);
747 //=============================================================================
751 //=============================================================================
752 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
753 (GEOM::GEOM_Object_ptr theMainShape,
754 const CORBA::Long theID)
756 GEOM::GEOM_Object_var aGEOMObject;
758 //Set a not done flag
759 GetOperations()->SetNotDone();
761 //Get the reference objects
762 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
763 if (aShape.IsNull()) return aGEOMObject._retn();
765 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
766 if (!GetOperations()->IsDone() || anObject.IsNull())
767 return aGEOMObject._retn();
769 return GetObject(anObject);
772 //=============================================================================
776 //=============================================================================
777 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
778 const GEOM::ListOfLong& theIndices)
780 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
783 //Set a not done flag
784 GetOperations()->SetNotDone();
786 if (theIndices.length() < 1)
789 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
790 if (aShape.IsNull()) return aSeq._retn();
792 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
793 for (i = 0; i < theIndices.length(); i++)
794 anArray->SetValue(i+1, theIndices[i]);
796 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
797 if (!GetOperations()->IsDone() || aHSeq.IsNull())
800 Standard_Integer aLength = aHSeq->Length();
801 aSeq->length(aLength);
802 for (i = 0; i < aLength; i++)
803 aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
808 //=============================================================================
812 //=============================================================================
813 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
814 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
816 //Get the reference shapes
817 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
818 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
820 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
822 //Get the unique ID of <theSubShape> inside <theMainShape>
823 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
824 if (!GetOperations()->IsDone())
830 //=============================================================================
834 //=============================================================================
835 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
836 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
838 //Get the reference shapes
839 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
840 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
842 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
844 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
845 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
846 if (!GetOperations()->IsDone())
852 //=============================================================================
856 //=============================================================================
857 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
859 //Get the reference shape
860 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
861 if (aShape.IsNull()) return NULL;
863 // Get shape parameters
864 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
865 return CORBA::string_dup(aDescription.ToCString());
868 //=============================================================================
872 //=============================================================================
873 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
875 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
878 //=============================================================================
882 //=============================================================================
883 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
885 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
888 //=============================================================================
892 //=============================================================================
893 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
894 const CORBA::Long theShapeType)
896 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
897 if (aShape.IsNull()) return -1;
899 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
900 if (!GetOperations()->IsDone()) return -1;
905 //=============================================================================
909 //=============================================================================
910 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
911 (GEOM::GEOM_Object_ptr theShape)
913 GEOM::GEOM_Object_var aGEOMObject;
915 //Set a not done flag
916 GetOperations()->SetNotDone();
918 //Get the reference objects
919 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
920 if (aShape.IsNull()) return aGEOMObject._retn();
923 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
924 if (!GetOperations()->IsDone() || anObject.IsNull())
925 return aGEOMObject._retn();
927 return GetObject(anObject);
930 //=============================================================================
934 //=============================================================================
935 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
937 //Set a not done flag
938 GetOperations()->SetNotDone();
940 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
942 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
943 if (aShape.IsNull()) return aSeq._retn();
945 Handle(TColStd_HSequenceOfInteger) aHSeq =
946 GetOperations()->GetFreeFacesIDs(aShape);
947 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
949 Standard_Integer aLength = aHSeq->Length();
950 aSeq->length(aLength);
951 for (Standard_Integer i = 1; i <= aLength; i++)
952 aSeq[i-1] = aHSeq->Value(i);
957 //=============================================================================
961 //=============================================================================
962 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
963 (GEOM::GEOM_Object_ptr theShape1,
964 GEOM::GEOM_Object_ptr theShape2,
965 const CORBA::Long theShapeType)
967 //Set a not done flag
968 GetOperations()->SetNotDone();
970 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
972 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
973 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
975 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
977 Handle(TColStd_HSequenceOfTransient) aHSeq =
978 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
979 if (!GetOperations()->IsDone() || aHSeq.IsNull())
982 Standard_Integer aLength = aHSeq->Length();
983 aSeq->length(aLength);
984 for (Standard_Integer i = 1; i <= aLength; i++)
985 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
990 //=============================================================================
992 * GetSharedShapesMulti
994 //=============================================================================
995 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
996 (const GEOM::ListOfGO& theShapes,
997 const CORBA::Long theShapeType)
999 //Set a not done flag
1000 GetOperations()->SetNotDone();
1002 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1005 std::list<Handle(GEOM_Object)> aShapes;
1006 int aLen = theShapes.length();
1007 for (int ind = 0; ind < aLen; ind++) {
1008 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
1009 if (aSh.IsNull()) return aSeq._retn();
1010 aShapes.push_back(aSh);
1013 Handle(TColStd_HSequenceOfTransient) aHSeq =
1014 GetOperations()->GetSharedShapes(aShapes, theShapeType);
1015 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1016 return aSeq._retn();
1018 Standard_Integer aLength = aHSeq->Length();
1019 aSeq->length(aLength);
1020 for (Standard_Integer i = 1; i <= aLength; i++)
1021 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1023 return aSeq._retn();
1026 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1028 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1032 aState = GEOMAlgo_ST_ON;
1035 aState = GEOMAlgo_ST_OUT;
1037 case GEOM::ST_ONOUT:
1038 aState = GEOMAlgo_ST_ONOUT;
1041 aState = GEOMAlgo_ST_IN;
1044 aState = GEOMAlgo_ST_ONIN;
1053 //=============================================================================
1057 //=============================================================================
1058 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1059 (GEOM::GEOM_Object_ptr theShape,
1060 const CORBA::Long theShapeType,
1061 GEOM::GEOM_Object_ptr theAx1,
1062 const GEOM::shape_state theState)
1064 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1066 //Set a not done flag
1067 GetOperations()->SetNotDone();
1069 //Get the reference objects
1070 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1071 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1073 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1075 //Get Shapes On Plane
1076 Handle(TColStd_HSequenceOfTransient) aHSeq =
1077 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1078 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1079 return aSeq._retn();
1081 Standard_Integer aLength = aHSeq->Length();
1082 aSeq->length(aLength);
1083 for (Standard_Integer i = 1; i <= aLength; i++)
1084 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1086 return aSeq._retn();
1089 //=============================================================================
1091 * GetShapesOnPlaneWithLocation
1093 //=============================================================================
1094 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1095 (GEOM::GEOM_Object_ptr theShape,
1096 const CORBA::Long theShapeType,
1097 GEOM::GEOM_Object_ptr theAx1,
1098 GEOM::GEOM_Object_ptr thePnt,
1099 const GEOM::shape_state theState)
1101 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1103 //Set a not done flag
1104 GetOperations()->SetNotDone();
1106 //Get the reference objects
1107 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1108 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1109 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1111 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1113 //Get Shapes On Plane
1114 Handle(TColStd_HSequenceOfTransient) aHSeq =
1115 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1116 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1117 return aSeq._retn();
1119 Standard_Integer aLength = aHSeq->Length();
1120 aSeq->length(aLength);
1121 for (Standard_Integer i = 1; i <= aLength; i++)
1122 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1124 return aSeq._retn();
1127 //=============================================================================
1129 * GetShapesOnCylinder
1131 //=============================================================================
1132 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1133 (GEOM::GEOM_Object_ptr theShape,
1134 const CORBA::Long theShapeType,
1135 GEOM::GEOM_Object_ptr theAxis,
1136 const CORBA::Double theRadius,
1137 const GEOM::shape_state theState)
1139 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1141 //Set a not done flag
1142 GetOperations()->SetNotDone();
1144 //Get the reference objects
1145 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1146 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1148 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1150 //Get Shapes On Cylinder
1151 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1152 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1153 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1154 return aSeq._retn();
1156 Standard_Integer aLength = aHSeq->Length();
1157 aSeq->length(aLength);
1158 for (Standard_Integer i = 1; i <= aLength; i++)
1159 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1161 return aSeq._retn();
1164 //=============================================================================
1166 * GetShapesOnCylinderWithLocation
1168 //=============================================================================
1169 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1170 (GEOM::GEOM_Object_ptr theShape,
1171 const CORBA::Long theShapeType,
1172 GEOM::GEOM_Object_ptr theAxis,
1173 GEOM::GEOM_Object_ptr thePnt,
1174 const CORBA::Double theRadius,
1175 const GEOM::shape_state theState)
1177 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1179 //Set a not done flag
1180 GetOperations()->SetNotDone();
1182 //Get the reference objects
1183 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1184 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1185 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1187 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1189 //Get Shapes On Cylinder
1190 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1191 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1192 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1193 return aSeq._retn();
1195 Standard_Integer aLength = aHSeq->Length();
1196 aSeq->length(aLength);
1197 for (Standard_Integer i = 1; i <= aLength; i++)
1198 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1200 return aSeq._retn();
1203 //=============================================================================
1207 //=============================================================================
1208 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1209 (GEOM::GEOM_Object_ptr theShape,
1210 const CORBA::Long theShapeType,
1211 GEOM::GEOM_Object_ptr theCenter,
1212 const CORBA::Double theRadius,
1213 const GEOM::shape_state theState)
1215 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1217 //Set a not done flag
1218 GetOperations()->SetNotDone();
1220 //Get the reference objects
1221 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1222 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1224 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1226 //Get Shapes On Sphere
1227 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1228 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1229 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1230 return aSeq._retn();
1232 Standard_Integer aLength = aHSeq->Length();
1233 aSeq->length(aLength);
1234 for (Standard_Integer i = 1; i <= aLength; i++)
1235 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1237 return aSeq._retn();
1240 //=============================================================================
1242 * GetShapesOnQuadrangle
1244 //=============================================================================
1245 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1246 (GEOM::GEOM_Object_ptr theShape,
1247 CORBA::Long theShapeType,
1248 GEOM::GEOM_Object_ptr theTopLeftPoint,
1249 GEOM::GEOM_Object_ptr theTopRigthPoint,
1250 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1251 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1252 GEOM::shape_state theState)
1254 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1256 //Set a not done flag
1257 GetOperations()->SetNotDone();
1259 //Get the reference objects
1260 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1261 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1262 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1263 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1264 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1266 if (aShape.IsNull() ||
1267 aTopLeftPoint.IsNull() ||
1268 aTopRigthPoint.IsNull() ||
1269 aBottomLeftPoint.IsNull() ||
1270 aBottomRigthPoint.IsNull())
1271 return aSeq._retn();
1273 //Get Shapes On Quadrangle
1274 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1275 (aShape, theShapeType,
1276 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1277 ShapeState(theState));
1278 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1279 return aSeq._retn();
1281 Standard_Integer aLength = aHSeq->Length();
1282 aSeq->length(aLength);
1283 for (Standard_Integer i = 1; i <= aLength; i++)
1284 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1286 return aSeq._retn();
1289 //=============================================================================
1291 * GetShapesOnPlaneIDs
1293 //=============================================================================
1294 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1295 (GEOM::GEOM_Object_ptr theShape,
1296 const CORBA::Long theShapeType,
1297 GEOM::GEOM_Object_ptr theAx1,
1298 const GEOM::shape_state theState)
1300 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1302 //Set a not done flag
1303 GetOperations()->SetNotDone();
1305 //Get the reference objects
1306 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1307 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1309 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1311 //Get Shapes On Plane
1312 Handle(TColStd_HSequenceOfInteger) aHSeq =
1313 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1314 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1315 return aSeq._retn();
1317 Standard_Integer aLength = aHSeq->Length();
1318 aSeq->length(aLength);
1319 for (Standard_Integer i = 1; i <= aLength; i++)
1320 aSeq[i-1] = aHSeq->Value(i);
1322 return aSeq._retn();
1325 //=============================================================================
1327 * GetShapesOnPlaneWithLocationIDs
1329 //=============================================================================
1330 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1331 (GEOM::GEOM_Object_ptr theShape,
1332 const CORBA::Long theShapeType,
1333 GEOM::GEOM_Object_ptr theAx1,
1334 GEOM::GEOM_Object_ptr thePnt,
1335 const GEOM::shape_state theState)
1337 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1339 //Set a not done flag
1340 GetOperations()->SetNotDone();
1342 //Get the reference objects
1343 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1344 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1345 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1347 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1349 //Get Shapes On Plane
1350 Handle(TColStd_HSequenceOfInteger) aHSeq =
1351 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1352 anAx1, anPnt, ShapeState(theState));
1353 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1354 return aSeq._retn();
1356 Standard_Integer aLength = aHSeq->Length();
1357 aSeq->length(aLength);
1358 for (Standard_Integer i = 1; i <= aLength; i++)
1359 aSeq[i-1] = aHSeq->Value(i);
1361 return aSeq._retn();
1364 //=============================================================================
1366 * GetShapesOnCylinderIDs
1368 //=============================================================================
1369 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1370 (GEOM::GEOM_Object_ptr theShape,
1371 const CORBA::Long theShapeType,
1372 GEOM::GEOM_Object_ptr theAxis,
1373 const CORBA::Double theRadius,
1374 const GEOM::shape_state theState)
1376 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1378 //Set a not done flag
1379 GetOperations()->SetNotDone();
1381 //Get the reference objects
1382 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1383 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1385 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1387 //Get Shapes On Cylinder
1388 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1389 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1390 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1391 return aSeq._retn();
1393 Standard_Integer aLength = aHSeq->Length();
1394 aSeq->length(aLength);
1395 for (Standard_Integer i = 1; i <= aLength; i++)
1396 aSeq[i-1] = aHSeq->Value(i);
1398 return aSeq._retn();
1401 //=============================================================================
1403 * GetShapesOnCylinderWithLocationIDs
1405 //=============================================================================
1406 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1407 (GEOM::GEOM_Object_ptr theShape,
1408 const CORBA::Long theShapeType,
1409 GEOM::GEOM_Object_ptr theAxis,
1410 GEOM::GEOM_Object_ptr thePnt,
1411 const CORBA::Double theRadius,
1412 const GEOM::shape_state theState)
1414 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1416 //Set a not done flag
1417 GetOperations()->SetNotDone();
1419 //Get the reference objects
1420 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1421 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1422 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1424 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1426 //Get Shapes On Cylinder
1427 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1428 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1429 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1430 return aSeq._retn();
1432 Standard_Integer aLength = aHSeq->Length();
1433 aSeq->length(aLength);
1434 for (Standard_Integer i = 1; i <= aLength; i++)
1435 aSeq[i-1] = aHSeq->Value(i);
1437 return aSeq._retn();
1440 //=============================================================================
1442 * GetShapesOnSphereIDs
1444 //=============================================================================
1445 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1446 (GEOM::GEOM_Object_ptr theShape,
1447 const CORBA::Long theShapeType,
1448 GEOM::GEOM_Object_ptr theCenter,
1449 const CORBA::Double theRadius,
1450 const GEOM::shape_state theState)
1452 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1454 //Set a not done flag
1455 GetOperations()->SetNotDone();
1457 //Get the reference objects
1458 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1459 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1461 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1463 //Get Shapes On Sphere
1464 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1465 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1466 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1467 return aSeq._retn();
1469 Standard_Integer aLength = aHSeq->Length();
1470 aSeq->length(aLength);
1471 for (Standard_Integer i = 1; i <= aLength; i++)
1472 aSeq[i-1] = aHSeq->Value(i);
1474 return aSeq._retn();
1477 //=============================================================================
1479 * GetShapesOnQuadrangleIDs
1481 //=============================================================================
1482 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1483 (GEOM::GEOM_Object_ptr theShape,
1484 CORBA::Long theShapeType,
1485 GEOM::GEOM_Object_ptr theTopLeftPoint,
1486 GEOM::GEOM_Object_ptr theTopRigthPoint,
1487 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1488 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1489 GEOM::shape_state theState)
1491 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1493 //Set a not done flag
1494 GetOperations()->SetNotDone();
1496 //Get the reference objects
1497 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1498 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1499 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1500 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1501 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1503 if (aShape.IsNull() ||
1504 aTopLeftPoint.IsNull() ||
1505 aTopRigthPoint.IsNull() ||
1506 aBottomLeftPoint.IsNull() ||
1507 aBottomRigthPoint.IsNull() )
1508 return aSeq._retn();
1510 //Get Shapes On Quadrangle
1511 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1512 (aShape, theShapeType,
1513 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1514 ShapeState(theState));
1515 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1516 return aSeq._retn();
1518 Standard_Integer aLength = aHSeq->Length();
1519 aSeq->length(aLength);
1520 for (Standard_Integer i = 1; i <= aLength; i++)
1521 aSeq[i-1] = aHSeq->Value(i);
1523 return aSeq._retn();
1526 //=============================================================================
1530 //=============================================================================
1531 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1532 (GEOM::GEOM_Object_ptr theBox,
1533 GEOM::GEOM_Object_ptr theShape,
1534 CORBA::Long theShapeType,
1535 GEOM::shape_state theState)
1537 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1539 //Set a not done flag
1540 GetOperations()->SetNotDone();
1542 //Get the reference objects
1543 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1544 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1546 if (aShape.IsNull() || aBox.IsNull() )
1547 return aSeq._retn();
1550 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1551 (aBox,aShape, theShapeType,ShapeState(theState));
1552 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1553 return aSeq._retn();
1555 Standard_Integer aLength = aHSeq->Length();
1556 aSeq->length(aLength);
1557 for (Standard_Integer i = 1; i <= aLength; i++)
1558 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1560 return aSeq._retn();
1563 //=============================================================================
1565 * GetShapesOnQuadrangleIDs
1567 //=============================================================================
1568 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1569 (GEOM::GEOM_Object_ptr theBox,
1570 GEOM::GEOM_Object_ptr theShape,
1571 CORBA::Long theShapeType,
1572 GEOM::shape_state theState)
1574 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1576 //Set a not done flag
1577 GetOperations()->SetNotDone();
1579 //Get the reference objects
1580 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1581 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1583 if (aShape.IsNull() || aBox.IsNull() )
1584 return aSeq._retn();
1587 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1588 (aBox,aShape, theShapeType,ShapeState(theState));
1589 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1590 return aSeq._retn();
1592 Standard_Integer aLength = aHSeq->Length();
1593 aSeq->length(aLength);
1594 for (Standard_Integer i = 1; i <= aLength; i++)
1595 aSeq[i-1] = aHSeq->Value(i);
1597 return aSeq._retn();
1601 //=============================================================================
1605 //=============================================================================
1606 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1607 (GEOM::GEOM_Object_ptr theCheckShape,
1608 GEOM::GEOM_Object_ptr theShape,
1609 CORBA::Short theShapeType,
1610 GEOM::shape_state theState)
1612 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1614 //Set a not done flag
1615 GetOperations()->SetNotDone();
1617 //Get the reference objects
1618 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1619 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1621 if (aShape.IsNull() || aCheckShape.IsNull() )
1622 return aSeq._retn();
1624 //Get Shapes On Shape
1625 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1626 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1628 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1629 return aSeq._retn();
1631 Standard_Integer aLength = aHSeq->Length();
1632 aSeq->length(aLength);
1633 for (Standard_Integer i = 1; i <= aLength; i++)
1634 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1636 return aSeq._retn();
1640 //=============================================================================
1642 * GetShapesOnShapeAsCompound
1644 //=============================================================================
1645 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1646 (GEOM::GEOM_Object_ptr theCheckShape,
1647 GEOM::GEOM_Object_ptr theShape,
1648 CORBA::Short theShapeType,
1649 GEOM::shape_state theState)
1651 GEOM::GEOM_Object_var aGEOMObject;
1653 //Set a not done flag
1654 GetOperations()->SetNotDone();
1656 //Get the reference objects
1657 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1658 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1660 if (aShape.IsNull() || aCheckShape.IsNull() )
1661 return aGEOMObject._retn();
1663 //Get Shapes On Shape
1664 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1665 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1667 if (anObject.IsNull())
1668 return aGEOMObject._retn();
1670 return GetObject(anObject);
1674 //=============================================================================
1676 * GetShapesOnShapeIDs
1678 //=============================================================================
1679 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1680 (GEOM::GEOM_Object_ptr theCheckShape,
1681 GEOM::GEOM_Object_ptr theShape,
1682 CORBA::Short theShapeType,
1683 GEOM::shape_state theState)
1685 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1687 //Set a not done flag
1688 GetOperations()->SetNotDone();
1690 //Get the reference objects
1691 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1692 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1694 if (aShape.IsNull() || aCheckShape.IsNull() )
1695 return aSeq._retn();
1697 //Get Shapes On Shape
1698 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1699 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1700 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1701 return aSeq._retn();
1703 Standard_Integer aLength = aHSeq->Length();
1704 aSeq->length(aLength);
1705 for (Standard_Integer i = 1; i <= aLength; i++)
1706 aSeq[i-1] = aHSeq->Value(i);
1708 return aSeq._retn();
1712 //=============================================================================
1716 //=============================================================================
1717 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1718 (GEOM::GEOM_Object_ptr theShapeWhere,
1719 GEOM::GEOM_Object_ptr theShapeWhat)
1721 GEOM::GEOM_Object_var aGEOMObject;
1723 //Set a not done flag
1724 GetOperations()->SetNotDone();
1726 //Get the reference objects
1727 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1728 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1730 if (aShapeWhere.IsNull() ||
1731 aShapeWhat.IsNull()) return aGEOMObject._retn();
1733 //Get Shapes in place of aShapeWhat
1734 Handle(GEOM_Object) anObject =
1735 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1736 if (!GetOperations()->IsDone() || anObject.IsNull())
1737 return aGEOMObject._retn();
1739 return GetObject(anObject);
1742 //=============================================================================
1746 //=============================================================================
1747 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1748 (GEOM::GEOM_Object_ptr theShapeWhere,
1749 GEOM::GEOM_Object_ptr theShapeWhat)
1751 GEOM::GEOM_Object_var aGEOMObject;
1753 //Set a not done flag
1754 GetOperations()->SetNotDone();
1756 //Get the reference objects
1757 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1758 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1760 if (aShapeWhere.IsNull() ||
1761 aShapeWhat.IsNull()) return aGEOMObject._retn();
1763 //Get Shapes in place of aShapeWhat
1764 Handle(GEOM_Object) anObject =
1765 GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1766 if (!GetOperations()->IsDone() || anObject.IsNull())
1767 return aGEOMObject._retn();
1769 return GetObject(anObject);
1772 //=============================================================================
1774 * GetInPlaceByHistory
1776 //=============================================================================
1777 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1778 (GEOM::GEOM_Object_ptr theShapeWhere,
1779 GEOM::GEOM_Object_ptr theShapeWhat)
1781 GEOM::GEOM_Object_var aGEOMObject;
1783 //Set a not done flag
1784 GetOperations()->SetNotDone();
1786 //Get the reference objects
1787 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1788 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1790 if (aShapeWhere.IsNull() ||
1791 aShapeWhat.IsNull()) return aGEOMObject._retn();
1793 //Get Shapes in place of aShapeWhat
1794 Handle(GEOM_Object) anObject =
1795 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1796 if (!GetOperations()->IsDone() || anObject.IsNull())
1797 return aGEOMObject._retn();
1799 return GetObject(anObject);
1802 //=============================================================================
1806 //=============================================================================
1807 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1808 (GEOM::GEOM_Object_ptr theShapeWhere,
1809 GEOM::GEOM_Object_ptr theShapeWhat)
1811 GEOM::GEOM_Object_var aGEOMObject;
1813 //Set a not done flag
1814 GetOperations()->SetNotDone();
1816 //Get the reference objects
1817 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1818 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1820 if (aShapeWhere.IsNull() ||
1821 aShapeWhat.IsNull()) return aGEOMObject._retn();
1823 //Get Shapes in place of aShapeWhat
1824 Handle(GEOM_Object) anObject =
1825 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1826 if (!GetOperations()->IsDone() || anObject.IsNull())
1827 return aGEOMObject._retn();
1829 return GetObject(anObject);