1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IShapesOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
35 #include <TColStd_HSequenceOfTransient.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
38 //=============================================================================
42 //=============================================================================
43 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
44 GEOM::GEOM_Gen_ptr theEngine,
45 ::GEOMImpl_IShapesOperations* theImpl)
46 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
48 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
51 //=============================================================================
55 //=============================================================================
56 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
58 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
62 //=============================================================================
66 //=============================================================================
67 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
68 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
70 GEOM::GEOM_Object_var aGEOMObject;
73 GetOperations()->SetNotDone();
75 //Get the reference points
76 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
77 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
79 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
82 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
83 if (!GetOperations()->IsDone() || anObject.IsNull())
84 return aGEOMObject._retn();
86 return GetObject(anObject);
89 //=============================================================================
91 * MakeEdgeOnCurveByLength
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
95 (GEOM::GEOM_Object_ptr theCurve,
96 CORBA::Double theLength,
97 GEOM::GEOM_Object_ptr theStartPoint)
99 GEOM::GEOM_Object_var aGEOMObject;
101 //Set a not done flag
102 GetOperations()->SetNotDone();
104 //Get the reference curve
105 Handle(GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
106 if (aRefCurve.IsNull()) return aGEOMObject._retn();
108 //Get the reference point (can be NULL)
109 Handle(GEOM_Object) aRefPoint;
110 if (!CORBA::is_nil(theStartPoint)) {
111 aRefPoint = GetObjectImpl(theStartPoint);
115 Handle(GEOM_Object) anObject =
116 GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
117 if (!GetOperations()->IsDone() || anObject.IsNull())
118 return aGEOMObject._retn();
120 return GetObject(anObject);
123 //=============================================================================
127 //=============================================================================
128 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
129 (GEOM::GEOM_Object_ptr theWire,
130 const CORBA::Double theLinearTolerance,
131 const CORBA::Double theAngularTolerance)
133 GEOM::GEOM_Object_var aGEOMObject;
135 //Set a not done flag
136 GetOperations()->SetNotDone();
138 //Get the source wire
139 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
141 if (aWire.IsNull()) return aGEOMObject._retn();
144 Handle(GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
145 if (!GetOperations()->IsDone() || anObject.IsNull())
146 return aGEOMObject._retn();
148 return GetObject(anObject);
151 //=============================================================================
155 //=============================================================================
156 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
157 (const GEOM::ListOfGO& theEdgesAndWires,
158 const CORBA::Double theTolerance)
160 GEOM::GEOM_Object_var aGEOMObject;
162 //Set a not done flag
163 GetOperations()->SetNotDone();
166 std::list<Handle(GEOM_Object)> aShapes;
169 aLen = theEdgesAndWires.length();
170 for (ind = 0; ind < aLen; ind++) {
171 Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
172 if (aSh.IsNull()) return aGEOMObject._retn();
173 aShapes.push_back(aSh);
177 Handle(GEOM_Object) anObject =
178 GetOperations()->MakeWire(aShapes, theTolerance);
179 if (!GetOperations()->IsDone() || anObject.IsNull())
180 return aGEOMObject._retn();
182 return GetObject(anObject);
185 //=============================================================================
189 //=============================================================================
190 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
191 (GEOM::GEOM_Object_ptr theWire,
192 const CORBA::Boolean isPlanarWanted)
194 GEOM::GEOM_Object_var aGEOMObject;
196 //Set a not done flag
197 GetOperations()->SetNotDone();
199 //Get the reference wire
200 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
201 if (aWire.IsNull()) return aGEOMObject._retn();
204 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
205 //if (!GetOperations()->IsDone() || anObject.IsNull())
206 // enable warning status
207 if (anObject.IsNull())
208 return aGEOMObject._retn();
210 return GetObject(anObject);
213 //=============================================================================
217 //=============================================================================
218 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
219 (const GEOM::ListOfGO& theWires,
220 const CORBA::Boolean isPlanarWanted)
222 GEOM::GEOM_Object_var aGEOMObject;
224 //Set a not done flag
225 GetOperations()->SetNotDone();
228 std::list<Handle(GEOM_Object)> aShapes;
231 aLen = theWires.length();
232 for (ind = 0; ind < aLen; ind++) {
233 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
234 if (aSh.IsNull()) return aGEOMObject._retn();
235 aShapes.push_back(aSh);
239 Handle(GEOM_Object) anObject =
240 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
241 //if (!GetOperations()->IsDone() || anObject.IsNull())
242 // enable warning status
243 if (anObject.IsNull())
244 return aGEOMObject._retn();
246 return GetObject(anObject);
249 //=============================================================================
251 * MakeFaceFromSurface
253 //=============================================================================
254 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceFromSurface
255 (GEOM::GEOM_Object_ptr theFace,
256 GEOM::GEOM_Object_ptr theWire)
258 GEOM::GEOM_Object_var aGEOMObject;
260 //Set a not done flag
261 GetOperations()->SetNotDone();
263 //Get the reference face and wire
264 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
265 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
267 if (aFace.IsNull() || aWire.IsNull()) {
268 return aGEOMObject._retn();
272 Handle(GEOM_Object) anObject =
273 GetOperations()->MakeFaceFromSurface(aFace, aWire);
275 if (anObject.IsNull()) {
276 return aGEOMObject._retn();
279 return GetObject(anObject);
282 //=============================================================================
286 //=============================================================================
287 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
288 (const GEOM::ListOfGO& theFacesAndShells)
290 GEOM::GEOM_Object_var aGEOMObject;
292 //Set a not done flag
293 GetOperations()->SetNotDone();
296 std::list<Handle(GEOM_Object)> aShapes;
299 aLen = theFacesAndShells.length();
300 for (ind = 0; ind < aLen; ind++) {
301 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
302 if (aSh.IsNull()) return aGEOMObject._retn();
303 aShapes.push_back(aSh);
307 Handle(GEOM_Object) anObject =
308 GetOperations()->MakeShell(aShapes);
309 if (!GetOperations()->IsDone() || anObject.IsNull())
310 return aGEOMObject._retn();
312 return GetObject(anObject);
315 //=============================================================================
319 //=============================================================================
320 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
321 (GEOM::GEOM_Object_ptr theShell)
323 GEOM::GEOM_Object_var aGEOMObject;
325 //Set a not done flag
326 GetOperations()->SetNotDone();
328 //Get the reference objects
329 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
330 if (aShell.IsNull()) return aGEOMObject._retn();
332 std::list<Handle(GEOM_Object)> aShapes;
333 aShapes.push_back(aShell);
336 Handle(GEOM_Object) anObject = 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::MakeSolidShells
349 (const GEOM::ListOfGO& theShells)
351 GEOM::GEOM_Object_var aGEOMObject;
353 //Set a not done flag
354 GetOperations()->SetNotDone();
357 std::list<Handle(GEOM_Object)> aShapes;
360 aLen = theShells.length();
361 for (ind = 0; ind < aLen; ind++) {
362 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
363 if (aSh.IsNull()) return aGEOMObject._retn();
364 aShapes.push_back(aSh);
368 Handle(GEOM_Object) anObject =
369 GetOperations()->MakeSolidShells(aShapes);
370 if (!GetOperations()->IsDone() || anObject.IsNull())
371 return aGEOMObject._retn();
373 return GetObject(anObject);
376 //=============================================================================
380 //=============================================================================
381 GEOM::GEOM_Object_ptr
382 GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
384 GEOM::GEOM_Object_var aGEOMObject;
386 //Set a not done flag
387 GetOperations()->SetNotDone();
390 std::list<Handle(GEOM_Object)> aShapes;
393 aLen = theShapes.length();
394 for (ind = 0; ind < aLen; ind++) {
395 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
396 if (aSh.IsNull()) return aGEOMObject._retn();
397 aShapes.push_back(aSh);
401 Handle(GEOM_Object) anObject =
402 GetOperations()->MakeCompound(aShapes);
403 if (!GetOperations()->IsDone() || anObject.IsNull())
404 return aGEOMObject._retn();
406 return GetObject(anObject);
409 //=============================================================================
411 * MakeSolidFromConnectedFaces
413 //=============================================================================
414 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidFromConnectedFaces
415 (const GEOM::ListOfGO& theFacesOrShells,
416 const CORBA::Boolean isIntersect)
418 GEOM::GEOM_Object_var aGEOMObject;
420 //Set a not done flag
421 GetOperations()->SetNotDone();
424 std::list<Handle(GEOM_Object)> aShapes;
427 aLen = theFacesOrShells.length();
428 for (ind = 0; ind < aLen; ind++) {
429 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesOrShells[ind]);
430 if (aSh.IsNull()) return aGEOMObject._retn();
431 aShapes.push_back(aSh);
435 Handle(GEOM_Object) anObject =
436 GetOperations()->MakeSolidFromConnectedFaces(aShapes, isIntersect);
437 if (!GetOperations()->IsDone() || anObject.IsNull())
438 return aGEOMObject._retn();
440 return GetObject(anObject);
443 //=============================================================================
447 //=============================================================================
448 GEOM::GEOM_Object_ptr
449 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
450 CORBA::Double theTolerance,
451 CORBA::Boolean doKeepNonSolids)
453 GEOM::GEOM_Object_var aGEOMObject;
455 //Set a not done flag
456 GetOperations()->SetNotDone();
458 //Get the reference objects
459 std::list< Handle(GEOM_Object) > aShapes;
460 if (! GetListOfObjectsImpl( theShapes, aShapes ))
461 return aGEOMObject._retn();
464 Handle(GEOM_Object) anObject =
465 GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
466 //if (!GetOperations()->IsDone() || anObject.IsNull())
468 if (anObject.IsNull())
469 return aGEOMObject._retn();
471 return GetObject(anObject);
474 //=============================================================================
478 //=============================================================================
480 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
481 const CORBA::Double theTolerance)
483 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
485 //Set a not done flag
486 GetOperations()->SetNotDone();
488 //Get the reference objects
489 std::list< Handle(GEOM_Object) > aShapes;
490 if (! GetListOfObjectsImpl( theShapes, aShapes ))
493 Handle(TColStd_HSequenceOfTransient) aHSeq =
494 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
496 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
501 Standard_Integer aLength = aHSeq->Length();
502 aSeq->length(aLength);
503 for (Standard_Integer i = 1; i <= aLength; i++)
504 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
509 //=============================================================================
511 * MakeGlueFacesByList
513 //=============================================================================
514 GEOM::GEOM_Object_ptr
515 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
516 CORBA::Double theTolerance,
517 const GEOM::ListOfGO& theFaces,
518 CORBA::Boolean doKeepNonSolids,
519 CORBA::Boolean doGlueAllEdges)
521 GEOM::GEOM_Object_var aGEOMObject;
523 //Set a not done flag
524 GetOperations()->SetNotDone();
526 //Get the reference objects
527 std::list< Handle(GEOM_Object) > aShapes;
528 if (! GetListOfObjectsImpl( theShapes, aShapes ))
529 return aGEOMObject._retn();
532 std::list<Handle(GEOM_Object)> aFaces;
533 if (! GetListOfObjectsImpl( theFaces, aFaces ))
534 return aGEOMObject._retn();
537 Handle(GEOM_Object) anObject =
538 GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
539 doKeepNonSolids, doGlueAllEdges);
540 //if (!GetOperations()->IsDone() || anObject.IsNull())
542 if (anObject.IsNull())
543 return aGEOMObject._retn();
545 return GetObject(anObject);
548 //=============================================================================
552 //=============================================================================
553 GEOM::GEOM_Object_ptr
554 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
555 CORBA::Double theTolerance)
557 GEOM::GEOM_Object_var aGEOMObject;
559 //Set a not done flag
560 GetOperations()->SetNotDone();
562 //Get the reference objects
563 std::list< Handle(GEOM_Object) > aShapes;
564 if (! GetListOfObjectsImpl( theShapes, aShapes ))
565 return aGEOMObject._retn();
568 Handle(GEOM_Object) anObject =
569 GetOperations()->MakeGlueEdges(aShapes, theTolerance);
570 //if (!GetOperations()->IsDone() || anObject.IsNull())
572 if (anObject.IsNull())
573 return aGEOMObject._retn();
575 return GetObject(anObject);
578 //=============================================================================
582 //=============================================================================
584 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
585 const CORBA::Double theTolerance)
587 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
589 //Set a not done flag
590 GetOperations()->SetNotDone();
592 //Get the reference objects
593 std::list< Handle(GEOM_Object) > aShapes;
594 if (! GetListOfObjectsImpl( theShapes, aShapes ))
597 Handle(TColStd_HSequenceOfTransient) aHSeq =
598 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
600 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
605 Standard_Integer aLength = aHSeq->Length();
606 aSeq->length(aLength);
607 for (Standard_Integer i = 1; i <= aLength; i++)
608 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
613 //=============================================================================
615 * MakeGlueEdgesByList
617 //=============================================================================
618 GEOM::GEOM_Object_ptr
619 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
620 CORBA::Double theTolerance,
621 const GEOM::ListOfGO& theEdges)
623 GEOM::GEOM_Object_var aGEOMObject;
625 //Set a not done flag
626 GetOperations()->SetNotDone();
628 //Get the reference objects
629 std::list< Handle(GEOM_Object) > aShapes;
630 if (! GetListOfObjectsImpl( theShapes, aShapes ))
631 return aGEOMObject._retn();
634 std::list<Handle(GEOM_Object)> anEdges;
635 if (! GetListOfObjectsImpl( theEdges, anEdges ))
636 return aGEOMObject._retn();
639 Handle(GEOM_Object) anObject =
640 GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
641 //if (!GetOperations()->IsDone() || anObject.IsNull())
643 if (anObject.IsNull())
644 return aGEOMObject._retn();
646 return GetObject(anObject);
649 //=============================================================================
651 * GetExistingSubObjects
653 //=============================================================================
655 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
656 CORBA::Boolean theGroupsOnly)
658 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
660 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
661 if (aShape.IsNull()) return aSeq._retn();
663 Handle(TColStd_HSequenceOfTransient) aHSeq =
664 GetOperations()->GetExistingSubObjects(aShape, theGroupsOnly);
665 if (!GetOperations()->IsDone() || aHSeq.IsNull())
668 Standard_Integer aLength = aHSeq->Length();
669 aSeq->length(aLength);
670 for (Standard_Integer i = 1; i <= aLength; i++)
671 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
676 //=============================================================================
678 * MakeExplode (including theShape itself, bad sorting)
680 //=============================================================================
681 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
682 const CORBA::Long theShapeType,
683 const CORBA::Boolean isSorted)
685 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
687 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
688 if (aShape.IsNull()) return aSeq._retn();
690 Handle(TColStd_HSequenceOfTransient) aHSeq =
691 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
692 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
693 if (!GetOperations()->IsDone() || aHSeq.IsNull())
696 Standard_Integer aLength = aHSeq->Length();
697 aSeq->length(aLength);
698 for (Standard_Integer i = 1; i <= aLength; i++)
699 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
704 //=============================================================================
706 * MakeAllSubShapes (including theShape itself, good sorting)
708 //=============================================================================
709 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
710 const CORBA::Long theShapeType,
711 const CORBA::Boolean isSorted)
713 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
715 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
716 if (aShape.IsNull()) return aSeq._retn();
718 Handle(TColStd_HSequenceOfTransient) aHSeq =
719 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
720 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
721 if (!GetOperations()->IsDone() || aHSeq.IsNull())
724 Standard_Integer aLength = aHSeq->Length();
725 aSeq->length(aLength);
726 for (Standard_Integer i = 1; i <= aLength; i++)
727 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
732 //=============================================================================
734 * ExtractSubShapes (excluding theShape itself, good sorting)
736 //=============================================================================
737 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
738 const CORBA::Long theShapeType,
739 const CORBA::Boolean isSorted)
741 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
743 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
744 if (aShape.IsNull()) return aSeq._retn();
746 Handle(TColStd_HSequenceOfTransient) aHSeq =
747 // TODO: enum instead of bool for the last argument
748 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
749 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
750 if (!GetOperations()->IsDone() || aHSeq.IsNull())
753 Standard_Integer aLength = aHSeq->Length();
754 aSeq->length(aLength);
755 for (Standard_Integer i = 1; i <= aLength; i++)
756 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
761 //=============================================================================
765 //=============================================================================
766 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
767 const CORBA::Long theShapeType,
768 const CORBA::Boolean isSorted)
770 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
772 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
773 if (aShape.IsNull()) return aSeq._retn();
775 Handle(TColStd_HSequenceOfInteger) aHSeq =
776 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
777 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
778 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
780 Standard_Integer aLength = aHSeq->Length();
781 aSeq->length(aLength);
782 for (Standard_Integer i = 1; i <= aLength; i++)
783 aSeq[i-1] = aHSeq->Value(i);
788 //=============================================================================
792 //=============================================================================
793 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
794 const CORBA::Long theShapeType,
795 const CORBA::Boolean isSorted)
797 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
799 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
800 if (aShape.IsNull()) return aSeq._retn();
802 Handle(TColStd_HSequenceOfInteger) aHSeq =
803 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
804 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
805 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
807 Standard_Integer aLength = aHSeq->Length();
808 aSeq->length(aLength);
809 for (Standard_Integer i = 1; i <= aLength; i++)
810 aSeq[i-1] = aHSeq->Value(i);
815 //=============================================================================
819 //=============================================================================
820 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
821 (GEOM::GEOM_Object_ptr theMainShape,
822 const CORBA::Long theID)
824 GEOM::GEOM_Object_var aGEOMObject;
826 //Set a not done flag
827 GetOperations()->SetNotDone();
829 //Get the reference objects
830 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
831 if (aShape.IsNull()) return aGEOMObject._retn();
833 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
834 if (!GetOperations()->IsDone() || anObject.IsNull())
835 return aGEOMObject._retn();
837 return GetObject(anObject);
840 //=============================================================================
844 //=============================================================================
845 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
846 const GEOM::ListOfLong& theIndices)
848 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
851 //Set a not done flag
852 GetOperations()->SetNotDone();
854 if (theIndices.length() < 1)
857 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
858 if (aShape.IsNull()) return aSeq._retn();
860 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
861 for (i = 0; i < theIndices.length(); i++)
862 anArray->SetValue(i+1, theIndices[i]);
864 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
865 if (!GetOperations()->IsDone() || aHSeq.IsNull())
868 Standard_Integer aLength = aHSeq->Length();
869 aSeq->length(aLength);
870 for (i = 0; i < aLength; i++)
871 aSeq[i] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i+1)));
876 //=============================================================================
880 //=============================================================================
881 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
882 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
884 //Get the reference shapes
885 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
886 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
888 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
890 //Get the unique ID of <theSubShape> inside <theMainShape>
891 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
892 if (!GetOperations()->IsDone())
898 //=============================================================================
900 * GetSubShapesIndices
902 //=============================================================================
903 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
904 (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
906 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
908 //Get the reference main shape
909 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
910 if (aMainShapeRef.IsNull()) return aSeq._retn();
913 std::list<Handle(GEOM_Object)> aShapes;
914 int aLen = theSubShapes.length();
915 for (int ind = 0; ind < aLen; ind++) {
916 Handle(GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
919 MESSAGE("NULL shape")
922 aShapes.push_back(aSh);
925 //Get the IDs of <theSubShapes> inside <theMainShape>
926 Handle(TColStd_HSequenceOfInteger) aHSeq =
927 GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
929 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
931 Standard_Integer aLength = aHSeq->Length();
932 aSeq->length(aLength);
934 for (Standard_Integer i = 1; i <= aLength; i++)
935 aSeq[i-1] = aHSeq->Value(i);
941 //=============================================================================
945 //=============================================================================
946 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
947 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
949 //Get the reference shapes
950 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
951 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
953 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
955 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
956 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
957 if (!GetOperations()->IsDone())
963 //=============================================================================
967 //=============================================================================
968 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
970 //Get the reference shape
971 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
972 if (aShape.IsNull()) return NULL;
974 // Get shape parameters
975 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
976 return CORBA::string_dup(aDescription.ToCString());
979 //=============================================================================
983 //=============================================================================
984 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
986 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
989 //=============================================================================
993 //=============================================================================
994 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
996 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
999 //=============================================================================
1003 //=============================================================================
1004 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
1005 const CORBA::Long theShapeType)
1007 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1008 if (aShape.IsNull()) return -1;
1010 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
1011 if (!GetOperations()->IsDone()) return -1;
1016 //=============================================================================
1020 //=============================================================================
1021 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
1022 (GEOM::GEOM_Object_ptr theShape)
1024 GEOM::GEOM_Object_var aGEOMObject;
1026 //Set a not done flag
1027 GetOperations()->SetNotDone();
1029 //Get the reference objects
1030 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1031 if (aShape.IsNull()) return aGEOMObject._retn();
1034 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
1035 if (!GetOperations()->IsDone() || anObject.IsNull())
1036 return aGEOMObject._retn();
1038 return GetObject(anObject);
1041 //=============================================================================
1045 //=============================================================================
1046 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
1048 //Set a not done flag
1049 GetOperations()->SetNotDone();
1051 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1053 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1054 if (aShape.IsNull()) return aSeq._retn();
1056 Handle(TColStd_HSequenceOfInteger) aHSeq =
1057 GetOperations()->GetFreeFacesIDs(aShape);
1058 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1060 Standard_Integer aLength = aHSeq->Length();
1061 aSeq->length(aLength);
1062 for (Standard_Integer i = 1; i <= aLength; i++)
1063 aSeq[i-1] = aHSeq->Value(i);
1065 return aSeq._retn();
1068 //=============================================================================
1072 //=============================================================================
1073 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1074 (GEOM::GEOM_Object_ptr theShape1,
1075 GEOM::GEOM_Object_ptr theShape2,
1076 const CORBA::Long theShapeType)
1078 //Set a not done flag
1079 GetOperations()->SetNotDone();
1081 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1083 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1084 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1086 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1088 Handle(TColStd_HSequenceOfTransient) aHSeq =
1089 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1090 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1091 return aSeq._retn();
1093 Standard_Integer aLength = aHSeq->Length();
1094 aSeq->length(aLength);
1095 for (Standard_Integer i = 1; i <= aLength; i++)
1096 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1098 return aSeq._retn();
1101 //=============================================================================
1103 * GetSharedShapesMulti
1105 //=============================================================================
1106 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1107 (const GEOM::ListOfGO& theShapes,
1108 const CORBA::Long theShapeType)
1110 //Set a not done flag
1111 GetOperations()->SetNotDone();
1113 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1116 std::list<Handle(GEOM_Object)> aShapes;
1117 if (! GetListOfObjectsImpl( theShapes, aShapes ))
1118 return aSeq._retn();
1120 Handle(TColStd_HSequenceOfTransient) aHSeq =
1121 GetOperations()->GetSharedShapes(aShapes, theShapeType);
1122 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1123 return aSeq._retn();
1125 Standard_Integer aLength = aHSeq->Length();
1126 aSeq->length(aLength);
1127 for (Standard_Integer i = 1; i <= aLength; i++)
1128 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1130 return aSeq._retn();
1133 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1135 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1139 aState = GEOMAlgo_ST_ON;
1142 aState = GEOMAlgo_ST_OUT;
1144 case GEOM::ST_ONOUT:
1145 aState = GEOMAlgo_ST_ONOUT;
1148 aState = GEOMAlgo_ST_IN;
1151 aState = GEOMAlgo_ST_ONIN;
1160 //=============================================================================
1164 //=============================================================================
1165 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1166 (GEOM::GEOM_Object_ptr theShape,
1167 const CORBA::Long theShapeType,
1168 GEOM::GEOM_Object_ptr theAx1,
1169 const GEOM::shape_state theState)
1171 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1173 //Set a not done flag
1174 GetOperations()->SetNotDone();
1176 //Get the reference objects
1177 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1178 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1180 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1182 //Get Shapes On Plane
1183 Handle(TColStd_HSequenceOfTransient) aHSeq =
1184 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1185 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1186 return aSeq._retn();
1188 Standard_Integer aLength = aHSeq->Length();
1189 aSeq->length(aLength);
1190 for (Standard_Integer i = 1; i <= aLength; i++)
1191 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1193 return aSeq._retn();
1196 //=============================================================================
1198 * GetShapesOnPlaneWithLocation
1200 //=============================================================================
1201 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1202 (GEOM::GEOM_Object_ptr theShape,
1203 const CORBA::Long theShapeType,
1204 GEOM::GEOM_Object_ptr theAx1,
1205 GEOM::GEOM_Object_ptr thePnt,
1206 const GEOM::shape_state theState)
1208 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1210 //Set a not done flag
1211 GetOperations()->SetNotDone();
1213 //Get the reference objects
1214 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1215 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1216 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1218 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1220 //Get Shapes On Plane
1221 Handle(TColStd_HSequenceOfTransient) aHSeq =
1222 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1223 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1224 return aSeq._retn();
1226 Standard_Integer aLength = aHSeq->Length();
1227 aSeq->length(aLength);
1228 for (Standard_Integer i = 1; i <= aLength; i++)
1229 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1231 return aSeq._retn();
1234 //=============================================================================
1236 * GetShapesOnCylinder
1238 //=============================================================================
1239 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1240 (GEOM::GEOM_Object_ptr theShape,
1241 const CORBA::Long theShapeType,
1242 GEOM::GEOM_Object_ptr theAxis,
1243 const CORBA::Double theRadius,
1244 const GEOM::shape_state theState)
1246 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1248 //Set a not done flag
1249 GetOperations()->SetNotDone();
1251 //Get the reference objects
1252 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1253 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1255 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1257 //Get Shapes On Cylinder
1258 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1259 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1260 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1261 return aSeq._retn();
1263 Standard_Integer aLength = aHSeq->Length();
1264 aSeq->length(aLength);
1265 for (Standard_Integer i = 1; i <= aLength; i++)
1266 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1268 return aSeq._retn();
1271 //=============================================================================
1273 * GetShapesOnCylinderWithLocation
1275 //=============================================================================
1276 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1277 (GEOM::GEOM_Object_ptr theShape,
1278 const CORBA::Long theShapeType,
1279 GEOM::GEOM_Object_ptr theAxis,
1280 GEOM::GEOM_Object_ptr thePnt,
1281 const CORBA::Double theRadius,
1282 const GEOM::shape_state theState)
1284 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1286 //Set a not done flag
1287 GetOperations()->SetNotDone();
1289 //Get the reference objects
1290 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1291 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1292 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1294 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1296 //Get Shapes On Cylinder
1297 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1298 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1299 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1300 return aSeq._retn();
1302 Standard_Integer aLength = aHSeq->Length();
1303 aSeq->length(aLength);
1304 for (Standard_Integer i = 1; i <= aLength; i++)
1305 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1307 return aSeq._retn();
1310 //=============================================================================
1314 //=============================================================================
1315 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1316 (GEOM::GEOM_Object_ptr theShape,
1317 const CORBA::Long theShapeType,
1318 GEOM::GEOM_Object_ptr theCenter,
1319 const CORBA::Double theRadius,
1320 const GEOM::shape_state theState)
1322 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1324 //Set a not done flag
1325 GetOperations()->SetNotDone();
1327 //Get the reference objects
1328 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1329 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1331 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1333 //Get Shapes On Sphere
1334 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1335 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1336 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1337 return aSeq._retn();
1339 Standard_Integer aLength = aHSeq->Length();
1340 aSeq->length(aLength);
1341 for (Standard_Integer i = 1; i <= aLength; i++)
1342 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1344 return aSeq._retn();
1347 //=============================================================================
1349 * GetShapesOnQuadrangle
1351 //=============================================================================
1352 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1353 (GEOM::GEOM_Object_ptr theShape,
1354 CORBA::Long theShapeType,
1355 GEOM::GEOM_Object_ptr theTopLeftPoint,
1356 GEOM::GEOM_Object_ptr theTopRigthPoint,
1357 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1358 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1359 GEOM::shape_state theState)
1361 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1363 //Set a not done flag
1364 GetOperations()->SetNotDone();
1366 //Get the reference objects
1367 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1368 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1369 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1370 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1371 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1373 if (aShape.IsNull() ||
1374 aTopLeftPoint.IsNull() ||
1375 aTopRigthPoint.IsNull() ||
1376 aBottomLeftPoint.IsNull() ||
1377 aBottomRigthPoint.IsNull())
1378 return aSeq._retn();
1380 //Get Shapes On Quadrangle
1381 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1382 (aShape, theShapeType,
1383 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1384 ShapeState(theState));
1385 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1386 return aSeq._retn();
1388 Standard_Integer aLength = aHSeq->Length();
1389 aSeq->length(aLength);
1390 for (Standard_Integer i = 1; i <= aLength; i++)
1391 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1393 return aSeq._retn();
1396 //=============================================================================
1398 * GetShapesOnPlaneIDs
1400 //=============================================================================
1401 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1402 (GEOM::GEOM_Object_ptr theShape,
1403 const CORBA::Long theShapeType,
1404 GEOM::GEOM_Object_ptr theAx1,
1405 const GEOM::shape_state theState)
1407 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1409 //Set a not done flag
1410 GetOperations()->SetNotDone();
1412 //Get the reference objects
1413 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1414 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1416 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1418 //Get Shapes On Plane
1419 Handle(TColStd_HSequenceOfInteger) aHSeq =
1420 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1421 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1422 return aSeq._retn();
1424 Standard_Integer aLength = aHSeq->Length();
1425 aSeq->length(aLength);
1426 for (Standard_Integer i = 1; i <= aLength; i++)
1427 aSeq[i-1] = aHSeq->Value(i);
1429 return aSeq._retn();
1432 //=============================================================================
1434 * GetShapesOnPlaneWithLocationIDs
1436 //=============================================================================
1437 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1438 (GEOM::GEOM_Object_ptr theShape,
1439 const CORBA::Long theShapeType,
1440 GEOM::GEOM_Object_ptr theAx1,
1441 GEOM::GEOM_Object_ptr thePnt,
1442 const GEOM::shape_state theState)
1444 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1446 //Set a not done flag
1447 GetOperations()->SetNotDone();
1449 //Get the reference objects
1450 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1451 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1452 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
1454 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1456 //Get Shapes On Plane
1457 Handle(TColStd_HSequenceOfInteger) aHSeq =
1458 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1459 anAx1, anPnt, ShapeState(theState));
1460 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1461 return aSeq._retn();
1463 Standard_Integer aLength = aHSeq->Length();
1464 aSeq->length(aLength);
1465 for (Standard_Integer i = 1; i <= aLength; i++)
1466 aSeq[i-1] = aHSeq->Value(i);
1468 return aSeq._retn();
1471 //=============================================================================
1473 * GetShapesOnCylinderIDs
1475 //=============================================================================
1476 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1477 (GEOM::GEOM_Object_ptr theShape,
1478 const CORBA::Long theShapeType,
1479 GEOM::GEOM_Object_ptr theAxis,
1480 const CORBA::Double theRadius,
1481 const GEOM::shape_state theState)
1483 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1485 //Set a not done flag
1486 GetOperations()->SetNotDone();
1488 //Get the reference objects
1489 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1490 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1492 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1494 //Get Shapes On Cylinder
1495 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1496 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1497 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1498 return aSeq._retn();
1500 Standard_Integer aLength = aHSeq->Length();
1501 aSeq->length(aLength);
1502 for (Standard_Integer i = 1; i <= aLength; i++)
1503 aSeq[i-1] = aHSeq->Value(i);
1505 return aSeq._retn();
1508 //=============================================================================
1510 * GetShapesOnCylinderWithLocationIDs
1512 //=============================================================================
1513 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1514 (GEOM::GEOM_Object_ptr theShape,
1515 const CORBA::Long theShapeType,
1516 GEOM::GEOM_Object_ptr theAxis,
1517 GEOM::GEOM_Object_ptr thePnt,
1518 const CORBA::Double theRadius,
1519 const GEOM::shape_state theState)
1521 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1523 //Set a not done flag
1524 GetOperations()->SetNotDone();
1526 //Get the reference objects
1527 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1528 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
1529 Handle(GEOM_Object) aPnt = GetObjectImpl(thePnt);
1531 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1533 //Get Shapes On Cylinder
1534 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1535 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1536 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1537 return aSeq._retn();
1539 Standard_Integer aLength = aHSeq->Length();
1540 aSeq->length(aLength);
1541 for (Standard_Integer i = 1; i <= aLength; i++)
1542 aSeq[i-1] = aHSeq->Value(i);
1544 return aSeq._retn();
1547 //=============================================================================
1549 * GetShapesOnSphereIDs
1551 //=============================================================================
1552 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1553 (GEOM::GEOM_Object_ptr theShape,
1554 const CORBA::Long theShapeType,
1555 GEOM::GEOM_Object_ptr theCenter,
1556 const CORBA::Double theRadius,
1557 const GEOM::shape_state theState)
1559 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1561 //Set a not done flag
1562 GetOperations()->SetNotDone();
1564 //Get the reference objects
1565 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1566 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1568 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1570 //Get Shapes On Sphere
1571 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1572 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1573 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1574 return aSeq._retn();
1576 Standard_Integer aLength = aHSeq->Length();
1577 aSeq->length(aLength);
1578 for (Standard_Integer i = 1; i <= aLength; i++)
1579 aSeq[i-1] = aHSeq->Value(i);
1581 return aSeq._retn();
1584 //=============================================================================
1586 * GetShapesOnQuadrangleIDs
1588 //=============================================================================
1589 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1590 (GEOM::GEOM_Object_ptr theShape,
1591 CORBA::Long theShapeType,
1592 GEOM::GEOM_Object_ptr theTopLeftPoint,
1593 GEOM::GEOM_Object_ptr theTopRigthPoint,
1594 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1595 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1596 GEOM::shape_state theState)
1598 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1600 //Set a not done flag
1601 GetOperations()->SetNotDone();
1603 //Get the reference objects
1604 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1605 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1606 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1607 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1608 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1610 if (aShape.IsNull() ||
1611 aTopLeftPoint.IsNull() ||
1612 aTopRigthPoint.IsNull() ||
1613 aBottomLeftPoint.IsNull() ||
1614 aBottomRigthPoint.IsNull() )
1615 return aSeq._retn();
1617 //Get Shapes On Quadrangle
1618 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1619 (aShape, theShapeType,
1620 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1621 ShapeState(theState));
1622 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1623 return aSeq._retn();
1625 Standard_Integer aLength = aHSeq->Length();
1626 aSeq->length(aLength);
1627 for (Standard_Integer i = 1; i <= aLength; i++)
1628 aSeq[i-1] = aHSeq->Value(i);
1630 return aSeq._retn();
1633 //=============================================================================
1637 //=============================================================================
1638 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1639 (GEOM::GEOM_Object_ptr theBox,
1640 GEOM::GEOM_Object_ptr theShape,
1641 CORBA::Long theShapeType,
1642 GEOM::shape_state theState)
1644 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1646 //Set a not done flag
1647 GetOperations()->SetNotDone();
1649 //Get the reference objects
1650 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1651 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1653 if (aShape.IsNull() || aBox.IsNull() )
1654 return aSeq._retn();
1657 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1658 (aBox,aShape, theShapeType,ShapeState(theState));
1659 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1660 return aSeq._retn();
1662 Standard_Integer aLength = aHSeq->Length();
1663 aSeq->length(aLength);
1664 for (Standard_Integer i = 1; i <= aLength; i++)
1665 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1667 return aSeq._retn();
1670 //=============================================================================
1672 * GetShapesOnQuadrangleIDs
1674 //=============================================================================
1675 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1676 (GEOM::GEOM_Object_ptr theBox,
1677 GEOM::GEOM_Object_ptr theShape,
1678 CORBA::Long theShapeType,
1679 GEOM::shape_state theState)
1681 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1683 //Set a not done flag
1684 GetOperations()->SetNotDone();
1686 //Get the reference objects
1687 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1688 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1690 if (aShape.IsNull() || aBox.IsNull() )
1691 return aSeq._retn();
1694 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1695 (aBox,aShape, theShapeType,ShapeState(theState));
1696 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1697 return aSeq._retn();
1699 Standard_Integer aLength = aHSeq->Length();
1700 aSeq->length(aLength);
1701 for (Standard_Integer i = 1; i <= aLength; i++)
1702 aSeq[i-1] = aHSeq->Value(i);
1704 return aSeq._retn();
1708 //=============================================================================
1712 //=============================================================================
1713 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1714 (GEOM::GEOM_Object_ptr theCheckShape,
1715 GEOM::GEOM_Object_ptr theShape,
1716 CORBA::Short theShapeType,
1717 GEOM::shape_state theState)
1719 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1721 //Set a not done flag
1722 GetOperations()->SetNotDone();
1724 //Get the reference objects
1725 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1726 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1728 if (aShape.IsNull() || aCheckShape.IsNull() )
1729 return aSeq._retn();
1731 //Get Shapes On Shape
1732 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1733 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1735 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1736 return aSeq._retn();
1738 Standard_Integer aLength = aHSeq->Length();
1739 aSeq->length(aLength);
1740 for (Standard_Integer i = 1; i <= aLength; i++)
1741 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1743 return aSeq._retn();
1747 //=============================================================================
1749 * GetShapesOnShapeAsCompound
1751 //=============================================================================
1752 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1753 (GEOM::GEOM_Object_ptr theCheckShape,
1754 GEOM::GEOM_Object_ptr theShape,
1755 CORBA::Short theShapeType,
1756 GEOM::shape_state theState)
1758 GEOM::GEOM_Object_var aGEOMObject;
1760 //Set a not done flag
1761 GetOperations()->SetNotDone();
1763 //Get the reference objects
1764 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1765 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1767 if (aShape.IsNull() || aCheckShape.IsNull() )
1768 return aGEOMObject._retn();
1770 //Get Shapes On Shape
1771 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1772 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1774 if (anObject.IsNull())
1775 return aGEOMObject._retn();
1777 return GetObject(anObject);
1781 //=============================================================================
1783 * GetShapesOnShapeIDs
1785 //=============================================================================
1786 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1787 (GEOM::GEOM_Object_ptr theCheckShape,
1788 GEOM::GEOM_Object_ptr theShape,
1789 CORBA::Short theShapeType,
1790 GEOM::shape_state theState)
1792 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1794 //Set a not done flag
1795 GetOperations()->SetNotDone();
1797 //Get the reference objects
1798 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1799 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1801 if (aShape.IsNull() || aCheckShape.IsNull() )
1802 return aSeq._retn();
1804 //Get Shapes On Shape
1805 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1806 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1807 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1808 return aSeq._retn();
1810 Standard_Integer aLength = aHSeq->Length();
1811 aSeq->length(aLength);
1812 for (Standard_Integer i = 1; i <= aLength; i++)
1813 aSeq[i-1] = aHSeq->Value(i);
1815 return aSeq._retn();
1819 //=============================================================================
1823 //=============================================================================
1824 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1825 (GEOM::GEOM_Object_ptr theShapeWhere,
1826 GEOM::GEOM_Object_ptr theShapeWhat)
1828 GEOM::GEOM_Object_var aGEOMObject;
1830 //Set a not done flag
1831 GetOperations()->SetNotDone();
1833 //Get the reference objects
1834 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1835 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1837 if (aShapeWhere.IsNull() ||
1838 aShapeWhat.IsNull()) return aGEOMObject._retn();
1840 //Get Shapes in place of aShapeWhat
1841 Handle(GEOM_Object) anObject =
1842 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1843 if (!GetOperations()->IsDone() || anObject.IsNull())
1844 return aGEOMObject._retn();
1846 return GetObject(anObject);
1849 //=============================================================================
1853 //=============================================================================
1854 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1855 (GEOM::GEOM_Object_ptr theShapeWhere,
1856 GEOM::GEOM_Object_ptr theShapeWhat)
1858 GEOM::GEOM_Object_var aGEOMObject;
1860 //Set a not done flag
1861 GetOperations()->SetNotDone();
1863 //Get the reference objects
1864 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1865 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1867 if (aShapeWhere.IsNull() ||
1868 aShapeWhat.IsNull()) return aGEOMObject._retn();
1870 //Get Shapes in place of aShapeWhat
1871 Handle(GEOM_Object) anObject =
1872 GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1873 if (!GetOperations()->IsDone() || anObject.IsNull())
1874 return aGEOMObject._retn();
1876 return GetObject(anObject);
1879 //=============================================================================
1881 * GetInPlaceByHistory
1883 //=============================================================================
1884 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1885 (GEOM::GEOM_Object_ptr theShapeWhere,
1886 GEOM::GEOM_Object_ptr theShapeWhat)
1888 GEOM::GEOM_Object_var aGEOMObject;
1890 //Set a not done flag
1891 GetOperations()->SetNotDone();
1893 //Get the reference objects
1894 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1895 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1897 if (aShapeWhere.IsNull() ||
1898 aShapeWhat.IsNull()) return aGEOMObject._retn();
1900 //Get Shapes in place of aShapeWhat
1901 Handle(GEOM_Object) anObject =
1902 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1903 if (!GetOperations()->IsDone() || anObject.IsNull())
1904 return aGEOMObject._retn();
1906 return GetObject(anObject);
1909 //=============================================================================
1913 //=============================================================================
1914 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1915 (GEOM::GEOM_Object_ptr theShapeWhere,
1916 GEOM::GEOM_Object_ptr theShapeWhat)
1918 GEOM::GEOM_Object_var aGEOMObject;
1920 //Set a not done flag
1921 GetOperations()->SetNotDone();
1923 //Get the reference objects
1924 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1925 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1927 if (aShapeWhere.IsNull() ||
1928 aShapeWhat.IsNull()) return aGEOMObject._retn();
1930 //Get Shapes in place of aShapeWhat
1931 Handle(GEOM_Object) anObject =
1932 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1933 if (!GetOperations()->IsDone() || anObject.IsNull())
1934 return aGEOMObject._retn();
1936 return GetObject(anObject);
1939 //=============================================================================
1943 //=============================================================================
1944 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
1945 (GEOM::GEOM_Object_ptr theShapeWhere,
1946 GEOM::GEOM_Object_ptr theShapeWhat) {
1947 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1949 //Get the reference objects
1950 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1951 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1953 if (aShapeWhere.IsNull() ||
1954 aShapeWhat.IsNull()) return aSeq._retn();
1957 Handle(TColStd_HSequenceOfInteger) aHSeq =
1958 GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
1960 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1962 Standard_Integer aLength = aHSeq->Length();
1963 aSeq->length(aLength);
1964 for (Standard_Integer i = 1; i <= aLength; i++)
1965 aSeq[i-1] = aHSeq->Value(i);
1967 return aSeq._retn();
1970 //=============================================================================
1974 //=============================================================================
1975 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
1976 (GEOM::GEOM_Object_ptr theEdge,
1977 CORBA::Double theMin,
1978 CORBA::Double theMax)
1980 GEOM::GEOM_Object_var aGEOMObject;
1982 //Set a not done flag
1983 GetOperations()->SetNotDone();
1985 //Get the reference objects
1986 Handle(GEOM_Object) anEdge = GetObjectImpl(theEdge);
1988 if (anEdge.IsNull()) {
1989 return aGEOMObject._retn();
1992 //Get Shapes in place of aShapeWhat
1993 Handle(GEOM_Object) aNewEdge =
1994 GetOperations()->ExtendEdge(anEdge, theMin, theMax);
1996 if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
1997 return aGEOMObject._retn();
2000 return GetObject(aNewEdge);
2003 //=============================================================================
2007 //=============================================================================
2008 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
2009 (GEOM::GEOM_Object_ptr theFace,
2010 CORBA::Double theUMin,
2011 CORBA::Double theUMax,
2012 CORBA::Double theVMin,
2013 CORBA::Double theVMax)
2015 GEOM::GEOM_Object_var aGEOMObject;
2017 //Set a not done flag
2018 GetOperations()->SetNotDone();
2020 //Get the reference objects
2021 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2023 if (aFace.IsNull()) {
2024 return aGEOMObject._retn();
2027 //Get Shapes in place of aShapeWhat
2028 Handle(GEOM_Object) aNewFace =
2029 GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
2031 if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2032 return aGEOMObject._retn();
2035 return GetObject(aNewFace);
2038 //=============================================================================
2040 * MakeSurfaceFromFace
2042 //=============================================================================
2043 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
2044 (GEOM::GEOM_Object_ptr theFace)
2046 GEOM::GEOM_Object_var aGEOMObject;
2048 //Set a not done flag
2049 GetOperations()->SetNotDone();
2051 //Get the reference object
2052 Handle(GEOM_Object) aFace = GetObjectImpl(theFace);
2054 if (aFace.IsNull()) {
2055 return aGEOMObject._retn();
2058 //Get Shapes in place of aShapeWhat
2059 Handle(GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
2061 if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2062 return aGEOMObject._retn();
2065 return GetObject(aNewFace);