1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include <Standard_Stream.hxx>
24 #include "GEOM_IShapesOperations_i.hh"
26 #include "utilities.h"
28 #include "Utils_ExceptHandlers.hxx"
30 #include "GEOM_Engine.hxx"
31 #include "GEOM_Object.hxx"
33 #include <TColStd_HSequenceOfTransient.hxx>
34 #include <TColStd_HArray1OfInteger.hxx>
36 //=============================================================================
40 //=============================================================================
41 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
42 GEOM::GEOM_Gen_ptr theEngine,
43 ::GEOMImpl_IShapesOperations* theImpl)
44 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
46 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
49 //=============================================================================
53 //=============================================================================
54 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
56 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
60 //=============================================================================
64 //=============================================================================
65 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
66 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
68 GEOM::GEOM_Object_var aGEOMObject;
71 GetOperations()->SetNotDone();
73 //Get the reference points
74 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
75 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
77 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
80 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
81 if (!GetOperations()->IsDone() || anObject.IsNull())
82 return aGEOMObject._retn();
84 return GetObject(anObject);
87 //=============================================================================
91 //=============================================================================
92 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
93 (const GEOM::ListOfGO& theEdgesAndWires)
95 GEOM::GEOM_Object_var aGEOMObject;
98 GetOperations()->SetNotDone();
101 list<Handle(GEOM_Object)> aShapes;
104 aLen = theEdgesAndWires.length();
105 for (ind = 0; ind < aLen; ind++) {
106 Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
107 if (aSh.IsNull()) return aGEOMObject._retn();
108 aShapes.push_back(aSh);
112 Handle(GEOM_Object) anObject =
113 GetOperations()->MakeWire(aShapes);
114 if (!GetOperations()->IsDone() || anObject.IsNull())
115 return aGEOMObject._retn();
117 return GetObject(anObject);
120 //=============================================================================
124 //=============================================================================
125 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
126 (GEOM::GEOM_Object_ptr theWire,
127 const CORBA::Boolean isPlanarWanted)
129 GEOM::GEOM_Object_var aGEOMObject;
131 //Set a not done flag
132 GetOperations()->SetNotDone();
134 //Get the reference wire
135 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
136 if (aWire.IsNull()) return aGEOMObject._retn();
139 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
140 if (!GetOperations()->IsDone() || anObject.IsNull())
141 return aGEOMObject._retn();
143 return GetObject(anObject);
146 //=============================================================================
150 //=============================================================================
151 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
152 (const GEOM::ListOfGO& theWires,
153 const CORBA::Boolean isPlanarWanted)
155 GEOM::GEOM_Object_var aGEOMObject;
157 //Set a not done flag
158 GetOperations()->SetNotDone();
161 list<Handle(GEOM_Object)> aShapes;
164 aLen = theWires.length();
165 for (ind = 0; ind < aLen; ind++) {
166 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
167 if (aSh.IsNull()) return aGEOMObject._retn();
168 aShapes.push_back(aSh);
172 Handle(GEOM_Object) anObject =
173 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
174 if (!GetOperations()->IsDone() || anObject.IsNull())
175 return aGEOMObject._retn();
177 return GetObject(anObject);
180 //=============================================================================
184 //=============================================================================
185 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
186 (const GEOM::ListOfGO& theFacesAndShells)
188 GEOM::GEOM_Object_var aGEOMObject;
190 //Set a not done flag
191 GetOperations()->SetNotDone();
194 list<Handle(GEOM_Object)> aShapes;
197 aLen = theFacesAndShells.length();
198 for (ind = 0; ind < aLen; ind++) {
199 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
200 if (aSh.IsNull()) return aGEOMObject._retn();
201 aShapes.push_back(aSh);
205 Handle(GEOM_Object) anObject =
206 GetOperations()->MakeShell(aShapes);
207 if (!GetOperations()->IsDone() || anObject.IsNull())
208 return aGEOMObject._retn();
210 return GetObject(anObject);
213 //=============================================================================
217 //=============================================================================
218 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
219 (GEOM::GEOM_Object_ptr theShell)
221 GEOM::GEOM_Object_var aGEOMObject;
223 //Set a not done flag
224 GetOperations()->SetNotDone();
226 //Get the reference objects
227 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
228 if (aShell.IsNull()) return aGEOMObject._retn();
231 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
232 if (!GetOperations()->IsDone() || anObject.IsNull())
233 return aGEOMObject._retn();
235 return GetObject(anObject);
238 //=============================================================================
242 //=============================================================================
243 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
244 (const GEOM::ListOfGO& theShells)
246 GEOM::GEOM_Object_var aGEOMObject;
248 //Set a not done flag
249 GetOperations()->SetNotDone();
252 list<Handle(GEOM_Object)> aShapes;
255 aLen = theShells.length();
256 for (ind = 0; ind < aLen; ind++) {
257 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
258 if (aSh.IsNull()) return aGEOMObject._retn();
259 aShapes.push_back(aSh);
263 Handle(GEOM_Object) anObject =
264 GetOperations()->MakeSolidShells(aShapes);
265 if (!GetOperations()->IsDone() || anObject.IsNull())
266 return aGEOMObject._retn();
268 return GetObject(anObject);
271 //=============================================================================
275 //=============================================================================
276 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
277 (const GEOM::ListOfGO& theShapes)
279 GEOM::GEOM_Object_var aGEOMObject;
281 //Set a not done flag
282 GetOperations()->SetNotDone();
285 list<Handle(GEOM_Object)> aShapes;
288 aLen = theShapes.length();
289 for (ind = 0; ind < aLen; ind++) {
290 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
291 if (aSh.IsNull()) return aGEOMObject._retn();
292 aShapes.push_back(aSh);
296 Handle(GEOM_Object) anObject =
297 GetOperations()->MakeCompound(aShapes);
298 if (!GetOperations()->IsDone() || anObject.IsNull())
299 return aGEOMObject._retn();
301 return GetObject(anObject);
304 //=============================================================================
308 //=============================================================================
309 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
310 (GEOM::GEOM_Object_ptr theShape,
311 CORBA::Double theTolerance,
312 CORBA::Boolean doKeepNonSolids)
314 GEOM::GEOM_Object_var aGEOMObject;
316 //Set a not done flag
317 GetOperations()->SetNotDone();
319 //Get the reference objects
320 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
321 if (aShape.IsNull()) return aGEOMObject._retn();
324 Handle(GEOM_Object) anObject =
325 GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
326 //if (!GetOperations()->IsDone() || anObject.IsNull())
328 if (anObject.IsNull())
329 return aGEOMObject._retn();
331 return GetObject(anObject);
335 //=============================================================================
339 //=============================================================================
340 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
341 (GEOM::GEOM_Object_ptr theShape,
342 const CORBA::Double theTolerance)
344 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
346 //Set a not done flag
347 GetOperations()->SetNotDone();
349 //Get the reference objects
350 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
351 if (aShape.IsNull()) return aSeq._retn();
353 Handle(TColStd_HSequenceOfTransient) aHSeq =
354 GetOperations()->GetGlueFaces(aShape, theTolerance);
356 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
361 Standard_Integer aLength = aHSeq->Length();
362 aSeq->length(aLength);
363 for (Standard_Integer i = 1; i <= aLength; i++)
364 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
370 //=============================================================================
372 * MakeGlueFacesByList
374 //=============================================================================
375 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
376 (GEOM::GEOM_Object_ptr theShape,
377 CORBA::Double theTolerance,
378 const GEOM::ListOfGO& theFaces,
379 CORBA::Boolean doKeepNonSolids)
381 GEOM::GEOM_Object_var aGEOMObject;
383 //Set a not done flag
384 GetOperations()->SetNotDone();
386 //Get the reference objects
387 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
388 if (aShape.IsNull()) return aGEOMObject._retn();
391 list<Handle(GEOM_Object)> aFaces;
393 aLen = theFaces.length();
394 for (ind = 0; ind < aLen; ind++) {
395 Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
396 if (aSh.IsNull()) return aGEOMObject._retn();
397 aFaces.push_back(aSh);
401 Handle(GEOM_Object) anObject =
402 GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
403 //if (!GetOperations()->IsDone() || anObject.IsNull())
405 if (anObject.IsNull())
406 return aGEOMObject._retn();
408 return GetObject(anObject);
412 //=============================================================================
416 //=============================================================================
417 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
418 const CORBA::Long theShapeType,
419 const CORBA::Boolean isSorted)
421 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
423 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
424 if (aShape.IsNull()) return aSeq._retn();
426 Handle(TColStd_HSequenceOfTransient) aHSeq =
427 GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
428 if (!GetOperations()->IsDone() || aHSeq.IsNull())
431 Standard_Integer aLength = aHSeq->Length();
432 aSeq->length(aLength);
433 for (Standard_Integer i = 1; i <= aLength; i++)
434 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
439 //=============================================================================
443 //=============================================================================
444 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
445 const CORBA::Long theShapeType,
446 const CORBA::Boolean isSorted)
448 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
450 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
451 if (aShape.IsNull()) return aSeq._retn();
453 Handle(TColStd_HSequenceOfInteger) aHSeq =
454 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
455 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
457 Standard_Integer aLength = aHSeq->Length();
458 aSeq->length(aLength);
459 for (Standard_Integer i = 1; i <= aLength; i++)
460 aSeq[i-1] = aHSeq->Value(i);
465 //=============================================================================
469 //=============================================================================
470 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
471 (GEOM::GEOM_Object_ptr theMainShape,
472 const CORBA::Long theID)
474 GEOM::GEOM_Object_var aGEOMObject;
476 //Set a not done flag
477 GetOperations()->SetNotDone();
479 //Get the reference objects
480 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
481 if (aShape.IsNull()) return aGEOMObject._retn();
483 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
484 if (!GetOperations()->IsDone() || anObject.IsNull())
485 return aGEOMObject._retn();
487 return GetObject(anObject);
490 //=============================================================================
494 //=============================================================================
495 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
496 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
498 //Get the reference shapes
499 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
500 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
502 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
504 //Get the unique ID of <theSubShape> inside <theMainShape>
505 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
506 if (!GetOperations()->IsDone())
512 //=============================================================================
516 //=============================================================================
517 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
518 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
520 //Get the reference shapes
521 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
522 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
524 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
526 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
527 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
528 if (!GetOperations()->IsDone())
534 //=============================================================================
538 //=============================================================================
539 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
541 //Get the reference shape
542 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
543 if (aShape.IsNull()) return NULL;
545 // Get shape parameters
546 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
547 return CORBA::string_dup(aDescription.ToCString());
550 //=============================================================================
554 //=============================================================================
555 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
557 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
558 if (aShape.IsNull()) return -1;
560 CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
561 if (!GetOperations()->IsDone()) return -1;
566 //=============================================================================
570 //=============================================================================
571 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
573 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
574 if (aShape.IsNull()) return -1;
576 CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
577 if (!GetOperations()->IsDone()) return -1;
582 //=============================================================================
586 //=============================================================================
587 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
588 (GEOM::GEOM_Object_ptr theShape)
590 GEOM::GEOM_Object_var aGEOMObject;
592 //Set a not done flag
593 GetOperations()->SetNotDone();
595 //Get the reference objects
596 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
597 if (aShape.IsNull()) return aGEOMObject._retn();
600 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
601 if (!GetOperations()->IsDone() || anObject.IsNull())
602 return aGEOMObject._retn();
604 return GetObject(anObject);
607 //=============================================================================
611 //=============================================================================
612 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
614 //Set a not done flag
615 GetOperations()->SetNotDone();
617 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
619 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
620 if (aShape.IsNull()) return aSeq._retn();
622 Handle(TColStd_HSequenceOfInteger) aHSeq =
623 GetOperations()->GetFreeFacesIDs(aShape);
624 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
626 Standard_Integer aLength = aHSeq->Length();
627 aSeq->length(aLength);
628 for (Standard_Integer i = 1; i <= aLength; i++)
629 aSeq[i-1] = aHSeq->Value(i);
634 //=============================================================================
638 //=============================================================================
639 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
640 (GEOM::GEOM_Object_ptr theShape1,
641 GEOM::GEOM_Object_ptr theShape2,
642 const CORBA::Long theShapeType)
644 //Set a not done flag
645 GetOperations()->SetNotDone();
647 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
649 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
650 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
652 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
654 Handle(TColStd_HSequenceOfTransient) aHSeq =
655 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
656 if (!GetOperations()->IsDone() || aHSeq.IsNull())
659 Standard_Integer aLength = aHSeq->Length();
660 aSeq->length(aLength);
661 for (Standard_Integer i = 1; i <= aLength; i++)
662 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
667 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
669 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
673 aState = GEOMAlgo_ST_ON;
676 aState = GEOMAlgo_ST_OUT;
679 aState = GEOMAlgo_ST_ONOUT;
682 aState = GEOMAlgo_ST_IN;
685 aState = GEOMAlgo_ST_ONIN;
694 //=============================================================================
698 //=============================================================================
699 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
700 (GEOM::GEOM_Object_ptr theShape,
701 const CORBA::Long theShapeType,
702 GEOM::GEOM_Object_ptr theAx1,
703 const GEOM::shape_state theState)
705 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
707 //Set a not done flag
708 GetOperations()->SetNotDone();
710 //Get the reference objects
711 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
712 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
714 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
716 //Get Shapes On Plane
717 Handle(TColStd_HSequenceOfTransient) aHSeq =
718 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
719 if (!GetOperations()->IsDone() || aHSeq.IsNull())
722 Standard_Integer aLength = aHSeq->Length();
723 aSeq->length(aLength);
724 for (Standard_Integer i = 1; i <= aLength; i++)
725 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
730 //=============================================================================
732 * GetShapesOnPlaneWithLocation
734 //=============================================================================
735 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
736 (GEOM::GEOM_Object_ptr theShape,
737 const CORBA::Long theShapeType,
738 GEOM::GEOM_Object_ptr theAx1,
739 GEOM::GEOM_Object_ptr thePnt,
740 const GEOM::shape_state theState)
742 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
744 //Set a not done flag
745 GetOperations()->SetNotDone();
747 //Get the reference objects
748 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
749 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
750 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
752 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
754 //Get Shapes On Plane
755 Handle(TColStd_HSequenceOfTransient) aHSeq =
756 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
757 if (!GetOperations()->IsDone() || aHSeq.IsNull())
760 Standard_Integer aLength = aHSeq->Length();
761 aSeq->length(aLength);
762 for (Standard_Integer i = 1; i <= aLength; i++)
763 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
768 //=============================================================================
770 * GetShapesOnCylinder
772 //=============================================================================
773 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
774 (GEOM::GEOM_Object_ptr theShape,
775 const CORBA::Long theShapeType,
776 GEOM::GEOM_Object_ptr theAxis,
777 const CORBA::Double theRadius,
778 const GEOM::shape_state theState)
780 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
782 //Set a not done flag
783 GetOperations()->SetNotDone();
785 //Get the reference objects
786 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
787 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
789 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
791 //Get Shapes On Cylinder
792 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
793 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
794 if (!GetOperations()->IsDone() || aHSeq.IsNull())
797 Standard_Integer aLength = aHSeq->Length();
798 aSeq->length(aLength);
799 for (Standard_Integer i = 1; i <= aLength; i++)
800 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
805 //=============================================================================
809 //=============================================================================
810 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
811 (GEOM::GEOM_Object_ptr theShape,
812 const CORBA::Long theShapeType,
813 GEOM::GEOM_Object_ptr theCenter,
814 const CORBA::Double theRadius,
815 const GEOM::shape_state theState)
817 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
819 //Set a not done flag
820 GetOperations()->SetNotDone();
822 //Get the reference objects
823 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
824 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
826 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
828 //Get Shapes On Sphere
829 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
830 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
831 if (!GetOperations()->IsDone() || aHSeq.IsNull())
834 Standard_Integer aLength = aHSeq->Length();
835 aSeq->length(aLength);
836 for (Standard_Integer i = 1; i <= aLength; i++)
837 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
842 //=============================================================================
844 * GetShapesOnQuadrangle
846 //=============================================================================
847 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
848 (GEOM::GEOM_Object_ptr theShape,
849 CORBA::Long theShapeType,
850 GEOM::GEOM_Object_ptr theTopLeftPoint,
851 GEOM::GEOM_Object_ptr theTopRigthPoint,
852 GEOM::GEOM_Object_ptr theBottomLeftPoint,
853 GEOM::GEOM_Object_ptr theBottomRigthPoint,
854 GEOM::shape_state theState)
856 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
858 //Set a not done flag
859 GetOperations()->SetNotDone();
861 //Get the reference objects
862 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
863 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
864 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
865 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
866 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
868 if (aShape.IsNull() ||
869 aTopLeftPoint.IsNull() ||
870 aTopRigthPoint.IsNull() ||
871 aBottomLeftPoint.IsNull() ||
872 aBottomRigthPoint.IsNull())
875 //Get Shapes On Quadrangle
876 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
877 (aShape, theShapeType,
878 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
879 ShapeState(theState));
880 if (!GetOperations()->IsDone() || aHSeq.IsNull())
883 Standard_Integer aLength = aHSeq->Length();
884 aSeq->length(aLength);
885 for (Standard_Integer i = 1; i <= aLength; i++)
886 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
891 //=============================================================================
893 * GetShapesOnPlaneIDs
895 //=============================================================================
896 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
897 (GEOM::GEOM_Object_ptr theShape,
898 const CORBA::Long theShapeType,
899 GEOM::GEOM_Object_ptr theAx1,
900 const GEOM::shape_state theState)
902 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
904 //Set a not done flag
905 GetOperations()->SetNotDone();
907 //Get the reference objects
908 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
909 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
911 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
913 //Get Shapes On Plane
914 Handle(TColStd_HSequenceOfInteger) aHSeq =
915 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
916 if (!GetOperations()->IsDone() || aHSeq.IsNull())
919 Standard_Integer aLength = aHSeq->Length();
920 aSeq->length(aLength);
921 for (Standard_Integer i = 1; i <= aLength; i++)
922 aSeq[i-1] = aHSeq->Value(i);
927 //=============================================================================
929 * GetShapesOnPlaneWithLocationIDs
931 //=============================================================================
932 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
933 (GEOM::GEOM_Object_ptr theShape,
934 const CORBA::Long theShapeType,
935 GEOM::GEOM_Object_ptr theAx1,
936 GEOM::GEOM_Object_ptr thePnt,
937 const GEOM::shape_state theState)
939 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
941 //Set a not done flag
942 GetOperations()->SetNotDone();
944 //Get the reference objects
945 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
946 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
947 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
949 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
951 //Get Shapes On Plane
952 Handle(TColStd_HSequenceOfInteger) aHSeq =
953 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
954 anAx1, anPnt, ShapeState(theState));
955 if (!GetOperations()->IsDone() || aHSeq.IsNull())
958 Standard_Integer aLength = aHSeq->Length();
959 aSeq->length(aLength);
960 for (Standard_Integer i = 1; i <= aLength; i++)
961 aSeq[i-1] = aHSeq->Value(i);
966 //=============================================================================
968 * GetShapesOnCylinderIDs
970 //=============================================================================
971 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
972 (GEOM::GEOM_Object_ptr theShape,
973 const CORBA::Long theShapeType,
974 GEOM::GEOM_Object_ptr theAxis,
975 const CORBA::Double theRadius,
976 const GEOM::shape_state theState)
978 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
980 //Set a not done flag
981 GetOperations()->SetNotDone();
983 //Get the reference objects
984 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
985 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
987 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
989 //Get Shapes On Cylinder
990 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
991 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
992 if (!GetOperations()->IsDone() || aHSeq.IsNull())
995 Standard_Integer aLength = aHSeq->Length();
996 aSeq->length(aLength);
997 for (Standard_Integer i = 1; i <= aLength; i++)
998 aSeq[i-1] = aHSeq->Value(i);
1000 return aSeq._retn();
1003 //=============================================================================
1005 * GetShapesOnSphereIDs
1007 //=============================================================================
1008 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1009 (GEOM::GEOM_Object_ptr theShape,
1010 const CORBA::Long theShapeType,
1011 GEOM::GEOM_Object_ptr theCenter,
1012 const CORBA::Double theRadius,
1013 const GEOM::shape_state theState)
1015 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1017 //Set a not done flag
1018 GetOperations()->SetNotDone();
1020 //Get the reference objects
1021 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1022 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1024 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1026 //Get Shapes On Sphere
1027 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1028 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1029 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1030 return aSeq._retn();
1032 Standard_Integer aLength = aHSeq->Length();
1033 aSeq->length(aLength);
1034 for (Standard_Integer i = 1; i <= aLength; i++)
1035 aSeq[i-1] = aHSeq->Value(i);
1037 return aSeq._retn();
1040 //=============================================================================
1042 * GetShapesOnQuadrangleIDs
1044 //=============================================================================
1045 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1046 (GEOM::GEOM_Object_ptr theShape,
1047 CORBA::Long theShapeType,
1048 GEOM::GEOM_Object_ptr theTopLeftPoint,
1049 GEOM::GEOM_Object_ptr theTopRigthPoint,
1050 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1051 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1052 GEOM::shape_state theState)
1054 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1056 //Set a not done flag
1057 GetOperations()->SetNotDone();
1059 //Get the reference objects
1060 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1061 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1062 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1063 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1064 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1066 if (aShape.IsNull() ||
1067 aTopLeftPoint.IsNull() ||
1068 aTopRigthPoint.IsNull() ||
1069 aBottomLeftPoint.IsNull() ||
1070 aBottomRigthPoint.IsNull() )
1071 return aSeq._retn();
1073 //Get Shapes On Quadrangle
1074 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1075 (aShape, theShapeType,
1076 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1077 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] = aHSeq->Value(i);
1086 return aSeq._retn();
1089 //=============================================================================
1093 //=============================================================================
1094 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1095 (GEOM::GEOM_Object_ptr theBox,
1096 GEOM::GEOM_Object_ptr theShape,
1097 CORBA::Long theShapeType,
1098 GEOM::shape_state theState)
1100 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1102 //Set a not done flag
1103 GetOperations()->SetNotDone();
1105 //Get the reference objects
1106 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1107 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1109 if (aShape.IsNull() || aBox.IsNull() )
1110 return aSeq._retn();
1113 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1114 (aBox,aShape, theShapeType,ShapeState(theState));
1115 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1116 return aSeq._retn();
1118 Standard_Integer aLength = aHSeq->Length();
1119 aSeq->length(aLength);
1120 for (Standard_Integer i = 1; i <= aLength; i++)
1121 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1123 return aSeq._retn();
1126 //=============================================================================
1128 * GetShapesOnQuadrangleIDs
1130 //=============================================================================
1131 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1132 (GEOM::GEOM_Object_ptr theBox,
1133 GEOM::GEOM_Object_ptr theShape,
1134 CORBA::Long theShapeType,
1135 GEOM::shape_state theState)
1137 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1139 //Set a not done flag
1140 GetOperations()->SetNotDone();
1142 //Get the reference objects
1143 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1144 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1146 if (aShape.IsNull() || aBox.IsNull() )
1147 return aSeq._retn();
1150 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1151 (aBox,aShape, theShapeType,ShapeState(theState));
1152 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1153 return aSeq._retn();
1155 Standard_Integer aLength = aHSeq->Length();
1156 aSeq->length(aLength);
1157 for (Standard_Integer i = 1; i <= aLength; i++)
1158 aSeq[i-1] = aHSeq->Value(i);
1160 return aSeq._retn();
1164 //=============================================================================
1168 //=============================================================================
1169 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1170 (GEOM::GEOM_Object_ptr theCheckShape,
1171 GEOM::GEOM_Object_ptr theShape,
1172 CORBA::Short theShapeType,
1173 GEOM::shape_state theState)
1175 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1177 //Set a not done flag
1178 GetOperations()->SetNotDone();
1180 //Get the reference objects
1181 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1182 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1184 if (aShape.IsNull() || aCheckShape.IsNull() )
1185 return aSeq._retn();
1187 //Get Shapes On Shape
1188 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1189 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1191 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1192 return aSeq._retn();
1194 Standard_Integer aLength = aHSeq->Length();
1195 aSeq->length(aLength);
1196 for (Standard_Integer i = 1; i <= aLength; i++)
1197 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1199 return aSeq._retn();
1203 //=============================================================================
1205 * GetShapesOnShapeAsCompound
1207 //=============================================================================
1208 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1209 (GEOM::GEOM_Object_ptr theCheckShape,
1210 GEOM::GEOM_Object_ptr theShape,
1211 CORBA::Short theShapeType,
1212 GEOM::shape_state theState)
1214 GEOM::GEOM_Object_var aGEOMObject;
1216 //Set a not done flag
1217 GetOperations()->SetNotDone();
1219 //Get the reference objects
1220 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1221 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1223 if (aShape.IsNull() || aCheckShape.IsNull() )
1224 return aGEOMObject._retn();
1226 //Get Shapes On Shape
1227 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1228 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1230 if (anObject.IsNull())
1231 return aGEOMObject._retn();
1233 return GetObject(anObject);
1237 //=============================================================================
1239 * GetShapesOnShapeIDs
1241 //=============================================================================
1242 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1243 (GEOM::GEOM_Object_ptr theCheckShape,
1244 GEOM::GEOM_Object_ptr theShape,
1245 CORBA::Short theShapeType,
1246 GEOM::shape_state theState)
1248 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1250 //Set a not done flag
1251 GetOperations()->SetNotDone();
1253 //Get the reference objects
1254 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1255 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1257 if (aShape.IsNull() || aCheckShape.IsNull() )
1258 return aSeq._retn();
1260 //Get Shapes On Shape
1261 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1262 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1263 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1264 return aSeq._retn();
1266 Standard_Integer aLength = aHSeq->Length();
1267 aSeq->length(aLength);
1268 for (Standard_Integer i = 1; i <= aLength; i++)
1269 aSeq[i-1] = aHSeq->Value(i);
1271 return aSeq._retn();
1275 //=============================================================================
1279 //=============================================================================
1280 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1281 (GEOM::GEOM_Object_ptr theShapeWhere,
1282 GEOM::GEOM_Object_ptr theShapeWhat)
1284 GEOM::GEOM_Object_var aGEOMObject;
1286 //Set a not done flag
1287 GetOperations()->SetNotDone();
1289 //Get the reference objects
1290 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1291 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1293 if (aShapeWhere.IsNull() ||
1294 aShapeWhat.IsNull()) return aGEOMObject._retn();
1296 //Get Shapes in place of aShapeWhat
1297 Handle(GEOM_Object) anObject =
1298 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1299 if (!GetOperations()->IsDone() || anObject.IsNull())
1300 return aGEOMObject._retn();
1302 return GetObject(anObject);
1305 //=============================================================================
1307 * GetInPlaceByHistory
1309 //=============================================================================
1310 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1311 (GEOM::GEOM_Object_ptr theShapeWhere,
1312 GEOM::GEOM_Object_ptr theShapeWhat)
1314 GEOM::GEOM_Object_var aGEOMObject;
1316 //Set a not done flag
1317 GetOperations()->SetNotDone();
1319 //Get the reference objects
1320 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1321 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1323 if (aShapeWhere.IsNull() ||
1324 aShapeWhat.IsNull()) return aGEOMObject._retn();
1326 //Get Shapes in place of aShapeWhat
1327 Handle(GEOM_Object) anObject =
1328 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1329 if (!GetOperations()->IsDone() || anObject.IsNull())
1330 return aGEOMObject._retn();
1332 return GetObject(anObject);
1335 //=============================================================================
1339 //=============================================================================
1340 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1341 (GEOM::GEOM_Object_ptr theShapeWhere,
1342 GEOM::GEOM_Object_ptr theShapeWhat)
1344 GEOM::GEOM_Object_var aGEOMObject;
1346 //Set a not done flag
1347 GetOperations()->SetNotDone();
1349 //Get the reference objects
1350 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1351 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1353 if (aShapeWhere.IsNull() ||
1354 aShapeWhat.IsNull()) return aGEOMObject._retn();
1356 //Get Shapes in place of aShapeWhat
1357 Handle(GEOM_Object) anObject =
1358 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1359 if (!GetOperations()->IsDone() || anObject.IsNull())
1360 return aGEOMObject._retn();
1362 return GetObject(anObject);