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"
34 #include <TColStd_HSequenceOfTransient.hxx>
35 #include <TColStd_HArray1OfInteger.hxx>
37 //=============================================================================
41 //=============================================================================
42 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
43 GEOM::GEOM_Gen_ptr theEngine,
44 ::GEOMImpl_IShapesOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
47 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
50 //=============================================================================
54 //=============================================================================
55 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
57 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
61 //=============================================================================
65 //=============================================================================
66 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
67 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
69 GEOM::GEOM_Object_var aGEOMObject;
72 GetOperations()->SetNotDone();
74 //Get the reference points
75 Handle(GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
76 Handle(GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
78 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
81 Handle(GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
82 if (!GetOperations()->IsDone() || anObject.IsNull())
83 return aGEOMObject._retn();
85 return GetObject(anObject);
88 //=============================================================================
92 //=============================================================================
93 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
94 (const GEOM::ListOfGO& theEdgesAndWires,
95 const CORBA::Double theTolerance)
97 GEOM::GEOM_Object_var aGEOMObject;
100 GetOperations()->SetNotDone();
103 list<Handle(GEOM_Object)> aShapes;
106 aLen = theEdgesAndWires.length();
107 for (ind = 0; ind < aLen; ind++) {
108 Handle(GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
109 if (aSh.IsNull()) return aGEOMObject._retn();
110 aShapes.push_back(aSh);
114 Handle(GEOM_Object) anObject =
115 GetOperations()->MakeWire(aShapes, theTolerance);
116 if (!GetOperations()->IsDone() || anObject.IsNull())
117 return aGEOMObject._retn();
119 return GetObject(anObject);
122 //=============================================================================
126 //=============================================================================
127 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
128 (GEOM::GEOM_Object_ptr theWire,
129 const CORBA::Boolean isPlanarWanted)
131 GEOM::GEOM_Object_var aGEOMObject;
133 //Set a not done flag
134 GetOperations()->SetNotDone();
136 //Get the reference wire
137 Handle(GEOM_Object) aWire = GetObjectImpl(theWire);
138 if (aWire.IsNull()) return aGEOMObject._retn();
141 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
142 if (!GetOperations()->IsDone() || anObject.IsNull())
143 return aGEOMObject._retn();
145 return GetObject(anObject);
148 //=============================================================================
152 //=============================================================================
153 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
154 (const GEOM::ListOfGO& theWires,
155 const CORBA::Boolean isPlanarWanted)
157 GEOM::GEOM_Object_var aGEOMObject;
159 //Set a not done flag
160 GetOperations()->SetNotDone();
163 list<Handle(GEOM_Object)> aShapes;
166 aLen = theWires.length();
167 for (ind = 0; ind < aLen; ind++) {
168 Handle(GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
169 if (aSh.IsNull()) return aGEOMObject._retn();
170 aShapes.push_back(aSh);
174 Handle(GEOM_Object) anObject =
175 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
176 if (!GetOperations()->IsDone() || anObject.IsNull())
177 return aGEOMObject._retn();
179 return GetObject(anObject);
182 //=============================================================================
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
188 (const GEOM::ListOfGO& theFacesAndShells)
190 GEOM::GEOM_Object_var aGEOMObject;
192 //Set a not done flag
193 GetOperations()->SetNotDone();
196 list<Handle(GEOM_Object)> aShapes;
199 aLen = theFacesAndShells.length();
200 for (ind = 0; ind < aLen; ind++) {
201 Handle(GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
202 if (aSh.IsNull()) return aGEOMObject._retn();
203 aShapes.push_back(aSh);
207 Handle(GEOM_Object) anObject =
208 GetOperations()->MakeShell(aShapes);
209 if (!GetOperations()->IsDone() || anObject.IsNull())
210 return aGEOMObject._retn();
212 return GetObject(anObject);
215 //=============================================================================
219 //=============================================================================
220 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
221 (GEOM::GEOM_Object_ptr theShell)
223 GEOM::GEOM_Object_var aGEOMObject;
225 //Set a not done flag
226 GetOperations()->SetNotDone();
228 //Get the reference objects
229 Handle(GEOM_Object) aShell = GetObjectImpl(theShell);
230 if (aShell.IsNull()) return aGEOMObject._retn();
233 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
234 if (!GetOperations()->IsDone() || anObject.IsNull())
235 return aGEOMObject._retn();
237 return GetObject(anObject);
240 //=============================================================================
244 //=============================================================================
245 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
246 (const GEOM::ListOfGO& theShells)
248 GEOM::GEOM_Object_var aGEOMObject;
250 //Set a not done flag
251 GetOperations()->SetNotDone();
254 list<Handle(GEOM_Object)> aShapes;
257 aLen = theShells.length();
258 for (ind = 0; ind < aLen; ind++) {
259 Handle(GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
260 if (aSh.IsNull()) return aGEOMObject._retn();
261 aShapes.push_back(aSh);
265 Handle(GEOM_Object) anObject =
266 GetOperations()->MakeSolidShells(aShapes);
267 if (!GetOperations()->IsDone() || anObject.IsNull())
268 return aGEOMObject._retn();
270 return GetObject(anObject);
273 //=============================================================================
277 //=============================================================================
278 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
279 (const GEOM::ListOfGO& theShapes)
281 GEOM::GEOM_Object_var aGEOMObject;
283 //Set a not done flag
284 GetOperations()->SetNotDone();
287 list<Handle(GEOM_Object)> aShapes;
290 aLen = theShapes.length();
291 for (ind = 0; ind < aLen; ind++) {
292 Handle(GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
293 if (aSh.IsNull()) return aGEOMObject._retn();
294 aShapes.push_back(aSh);
298 Handle(GEOM_Object) anObject =
299 GetOperations()->MakeCompound(aShapes);
300 if (!GetOperations()->IsDone() || anObject.IsNull())
301 return aGEOMObject._retn();
303 return GetObject(anObject);
306 //=============================================================================
310 //=============================================================================
311 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
312 (GEOM::GEOM_Object_ptr theShape,
313 CORBA::Double theTolerance,
314 CORBA::Boolean doKeepNonSolids)
316 GEOM::GEOM_Object_var aGEOMObject;
318 //Set a not done flag
319 GetOperations()->SetNotDone();
321 //Get the reference objects
322 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
323 if (aShape.IsNull()) return aGEOMObject._retn();
326 Handle(GEOM_Object) anObject =
327 GetOperations()->MakeGlueFaces(aShape, theTolerance, doKeepNonSolids);
328 //if (!GetOperations()->IsDone() || anObject.IsNull())
330 if (anObject.IsNull())
331 return aGEOMObject._retn();
333 return GetObject(anObject);
337 //=============================================================================
341 //=============================================================================
342 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetGlueFaces
343 (GEOM::GEOM_Object_ptr theShape,
344 const CORBA::Double theTolerance)
346 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
348 //Set a not done flag
349 GetOperations()->SetNotDone();
351 //Get the reference objects
352 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
353 if (aShape.IsNull()) return aSeq._retn();
355 Handle(TColStd_HSequenceOfTransient) aHSeq =
356 GetOperations()->GetGlueFaces(aShape, theTolerance);
358 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
363 Standard_Integer aLength = aHSeq->Length();
364 aSeq->length(aLength);
365 for (Standard_Integer i = 1; i <= aLength; i++)
366 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
372 //=============================================================================
374 * MakeGlueFacesByList
376 //=============================================================================
377 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFacesByList
378 (GEOM::GEOM_Object_ptr theShape,
379 CORBA::Double theTolerance,
380 const GEOM::ListOfGO& theFaces,
381 CORBA::Boolean doKeepNonSolids)
383 GEOM::GEOM_Object_var aGEOMObject;
385 //Set a not done flag
386 GetOperations()->SetNotDone();
388 //Get the reference objects
389 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
390 if (aShape.IsNull()) return aGEOMObject._retn();
393 list<Handle(GEOM_Object)> aFaces;
395 aLen = theFaces.length();
396 for (ind = 0; ind < aLen; ind++) {
397 Handle(GEOM_Object) aSh = GetObjectImpl(theFaces[ind]);
398 if (aSh.IsNull()) return aGEOMObject._retn();
399 aFaces.push_back(aSh);
403 Handle(GEOM_Object) anObject =
404 GetOperations()->MakeGlueFacesByList(aShape, theTolerance, aFaces, doKeepNonSolids);
405 //if (!GetOperations()->IsDone() || anObject.IsNull())
407 if (anObject.IsNull())
408 return aGEOMObject._retn();
410 return GetObject(anObject);
414 //=============================================================================
418 //=============================================================================
419 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
420 const CORBA::Long theShapeType,
421 const CORBA::Boolean isSorted)
423 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
425 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
426 if (aShape.IsNull()) return aSeq._retn();
428 Handle(TColStd_HSequenceOfTransient) aHSeq =
429 GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
430 if (!GetOperations()->IsDone() || aHSeq.IsNull())
433 Standard_Integer aLength = aHSeq->Length();
434 aSeq->length(aLength);
435 for (Standard_Integer i = 1; i <= aLength; i++)
436 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
441 //=============================================================================
445 //=============================================================================
446 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
447 const CORBA::Long theShapeType,
448 const CORBA::Boolean isSorted)
450 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
452 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
453 if (aShape.IsNull()) return aSeq._retn();
455 Handle(TColStd_HSequenceOfInteger) aHSeq =
456 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
457 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
459 Standard_Integer aLength = aHSeq->Length();
460 aSeq->length(aLength);
461 for (Standard_Integer i = 1; i <= aLength; i++)
462 aSeq[i-1] = aHSeq->Value(i);
467 //=============================================================================
471 //=============================================================================
472 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
473 (GEOM::GEOM_Object_ptr theMainShape,
474 const CORBA::Long theID)
476 GEOM::GEOM_Object_var aGEOMObject;
478 //Set a not done flag
479 GetOperations()->SetNotDone();
481 //Get the reference objects
482 Handle(GEOM_Object) aShape = GetObjectImpl(theMainShape);
483 if (aShape.IsNull()) return aGEOMObject._retn();
485 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
486 if (!GetOperations()->IsDone() || anObject.IsNull())
487 return aGEOMObject._retn();
489 return GetObject(anObject);
492 //=============================================================================
496 //=============================================================================
497 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
498 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
500 //Get the reference shapes
501 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
502 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
504 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
506 //Get the unique ID of <theSubShape> inside <theMainShape>
507 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
508 if (!GetOperations()->IsDone())
514 //=============================================================================
518 //=============================================================================
519 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
520 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
522 //Get the reference shapes
523 Handle(GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
524 Handle(GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
526 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
528 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
529 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
530 if (!GetOperations()->IsDone())
536 //=============================================================================
540 //=============================================================================
541 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
543 //Get the reference shape
544 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
545 if (aShape.IsNull()) return NULL;
547 // Get shape parameters
548 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
549 return CORBA::string_dup(aDescription.ToCString());
552 //=============================================================================
556 //=============================================================================
557 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
559 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
562 //=============================================================================
566 //=============================================================================
567 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
569 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
572 //=============================================================================
576 //=============================================================================
577 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
578 const CORBA::Long theShapeType)
580 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
581 if (aShape.IsNull()) return -1;
583 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
584 if (!GetOperations()->IsDone()) return -1;
589 //=============================================================================
593 //=============================================================================
594 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
595 (GEOM::GEOM_Object_ptr theShape)
597 GEOM::GEOM_Object_var aGEOMObject;
599 //Set a not done flag
600 GetOperations()->SetNotDone();
602 //Get the reference objects
603 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
604 if (aShape.IsNull()) return aGEOMObject._retn();
607 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
608 if (!GetOperations()->IsDone() || anObject.IsNull())
609 return aGEOMObject._retn();
611 return GetObject(anObject);
614 //=============================================================================
618 //=============================================================================
619 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
621 //Set a not done flag
622 GetOperations()->SetNotDone();
624 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
626 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
627 if (aShape.IsNull()) return aSeq._retn();
629 Handle(TColStd_HSequenceOfInteger) aHSeq =
630 GetOperations()->GetFreeFacesIDs(aShape);
631 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
633 Standard_Integer aLength = aHSeq->Length();
634 aSeq->length(aLength);
635 for (Standard_Integer i = 1; i <= aLength; i++)
636 aSeq[i-1] = aHSeq->Value(i);
641 //=============================================================================
645 //=============================================================================
646 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
647 (GEOM::GEOM_Object_ptr theShape1,
648 GEOM::GEOM_Object_ptr theShape2,
649 const CORBA::Long theShapeType)
651 //Set a not done flag
652 GetOperations()->SetNotDone();
654 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
656 Handle(GEOM_Object) aShape1 = GetObjectImpl(theShape1);
657 Handle(GEOM_Object) aShape2 = GetObjectImpl(theShape2);
659 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
661 Handle(TColStd_HSequenceOfTransient) aHSeq =
662 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
663 if (!GetOperations()->IsDone() || aHSeq.IsNull())
666 Standard_Integer aLength = aHSeq->Length();
667 aSeq->length(aLength);
668 for (Standard_Integer i = 1; i <= aLength; i++)
669 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
674 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
676 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
680 aState = GEOMAlgo_ST_ON;
683 aState = GEOMAlgo_ST_OUT;
686 aState = GEOMAlgo_ST_ONOUT;
689 aState = GEOMAlgo_ST_IN;
692 aState = GEOMAlgo_ST_ONIN;
701 //=============================================================================
705 //=============================================================================
706 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
707 (GEOM::GEOM_Object_ptr theShape,
708 const CORBA::Long theShapeType,
709 GEOM::GEOM_Object_ptr theAx1,
710 const GEOM::shape_state theState)
712 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
714 //Set a not done flag
715 GetOperations()->SetNotDone();
717 //Get the reference objects
718 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
719 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
721 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
723 //Get Shapes On Plane
724 Handle(TColStd_HSequenceOfTransient) aHSeq =
725 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
726 if (!GetOperations()->IsDone() || aHSeq.IsNull())
729 Standard_Integer aLength = aHSeq->Length();
730 aSeq->length(aLength);
731 for (Standard_Integer i = 1; i <= aLength; i++)
732 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
737 //=============================================================================
739 * GetShapesOnPlaneWithLocation
741 //=============================================================================
742 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
743 (GEOM::GEOM_Object_ptr theShape,
744 const CORBA::Long theShapeType,
745 GEOM::GEOM_Object_ptr theAx1,
746 GEOM::GEOM_Object_ptr thePnt,
747 const GEOM::shape_state theState)
749 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
751 //Set a not done flag
752 GetOperations()->SetNotDone();
754 //Get the reference objects
755 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
756 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
757 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
759 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
761 //Get Shapes On Plane
762 Handle(TColStd_HSequenceOfTransient) aHSeq =
763 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
764 if (!GetOperations()->IsDone() || aHSeq.IsNull())
767 Standard_Integer aLength = aHSeq->Length();
768 aSeq->length(aLength);
769 for (Standard_Integer i = 1; i <= aLength; i++)
770 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
775 //=============================================================================
777 * GetShapesOnCylinder
779 //=============================================================================
780 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
781 (GEOM::GEOM_Object_ptr theShape,
782 const CORBA::Long theShapeType,
783 GEOM::GEOM_Object_ptr theAxis,
784 const CORBA::Double theRadius,
785 const GEOM::shape_state theState)
787 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
789 //Set a not done flag
790 GetOperations()->SetNotDone();
792 //Get the reference objects
793 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
794 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
796 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
798 //Get Shapes On Cylinder
799 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
800 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
801 if (!GetOperations()->IsDone() || aHSeq.IsNull())
804 Standard_Integer aLength = aHSeq->Length();
805 aSeq->length(aLength);
806 for (Standard_Integer i = 1; i <= aLength; i++)
807 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
812 //=============================================================================
816 //=============================================================================
817 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
818 (GEOM::GEOM_Object_ptr theShape,
819 const CORBA::Long theShapeType,
820 GEOM::GEOM_Object_ptr theCenter,
821 const CORBA::Double theRadius,
822 const GEOM::shape_state theState)
824 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
826 //Set a not done flag
827 GetOperations()->SetNotDone();
829 //Get the reference objects
830 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
831 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
833 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
835 //Get Shapes On Sphere
836 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
837 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
838 if (!GetOperations()->IsDone() || aHSeq.IsNull())
841 Standard_Integer aLength = aHSeq->Length();
842 aSeq->length(aLength);
843 for (Standard_Integer i = 1; i <= aLength; i++)
844 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
849 //=============================================================================
851 * GetShapesOnQuadrangle
853 //=============================================================================
854 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
855 (GEOM::GEOM_Object_ptr theShape,
856 CORBA::Long theShapeType,
857 GEOM::GEOM_Object_ptr theTopLeftPoint,
858 GEOM::GEOM_Object_ptr theTopRigthPoint,
859 GEOM::GEOM_Object_ptr theBottomLeftPoint,
860 GEOM::GEOM_Object_ptr theBottomRigthPoint,
861 GEOM::shape_state theState)
863 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
865 //Set a not done flag
866 GetOperations()->SetNotDone();
868 //Get the reference objects
869 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
870 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
871 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
872 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
873 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
875 if (aShape.IsNull() ||
876 aTopLeftPoint.IsNull() ||
877 aTopRigthPoint.IsNull() ||
878 aBottomLeftPoint.IsNull() ||
879 aBottomRigthPoint.IsNull())
882 //Get Shapes On Quadrangle
883 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
884 (aShape, theShapeType,
885 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
886 ShapeState(theState));
887 if (!GetOperations()->IsDone() || aHSeq.IsNull())
890 Standard_Integer aLength = aHSeq->Length();
891 aSeq->length(aLength);
892 for (Standard_Integer i = 1; i <= aLength; i++)
893 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
898 //=============================================================================
900 * GetShapesOnPlaneIDs
902 //=============================================================================
903 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
904 (GEOM::GEOM_Object_ptr theShape,
905 const CORBA::Long theShapeType,
906 GEOM::GEOM_Object_ptr theAx1,
907 const GEOM::shape_state theState)
909 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
911 //Set a not done flag
912 GetOperations()->SetNotDone();
914 //Get the reference objects
915 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
916 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
918 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
920 //Get Shapes On Plane
921 Handle(TColStd_HSequenceOfInteger) aHSeq =
922 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
923 if (!GetOperations()->IsDone() || aHSeq.IsNull())
926 Standard_Integer aLength = aHSeq->Length();
927 aSeq->length(aLength);
928 for (Standard_Integer i = 1; i <= aLength; i++)
929 aSeq[i-1] = aHSeq->Value(i);
934 //=============================================================================
936 * GetShapesOnPlaneWithLocationIDs
938 //=============================================================================
939 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
940 (GEOM::GEOM_Object_ptr theShape,
941 const CORBA::Long theShapeType,
942 GEOM::GEOM_Object_ptr theAx1,
943 GEOM::GEOM_Object_ptr thePnt,
944 const GEOM::shape_state theState)
946 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
948 //Set a not done flag
949 GetOperations()->SetNotDone();
951 //Get the reference objects
952 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
953 Handle(GEOM_Object) anAx1 = GetObjectImpl(theAx1);
954 Handle(GEOM_Object) anPnt = GetObjectImpl(thePnt);
956 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
958 //Get Shapes On Plane
959 Handle(TColStd_HSequenceOfInteger) aHSeq =
960 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
961 anAx1, anPnt, ShapeState(theState));
962 if (!GetOperations()->IsDone() || aHSeq.IsNull())
965 Standard_Integer aLength = aHSeq->Length();
966 aSeq->length(aLength);
967 for (Standard_Integer i = 1; i <= aLength; i++)
968 aSeq[i-1] = aHSeq->Value(i);
973 //=============================================================================
975 * GetShapesOnCylinderIDs
977 //=============================================================================
978 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
979 (GEOM::GEOM_Object_ptr theShape,
980 const CORBA::Long theShapeType,
981 GEOM::GEOM_Object_ptr theAxis,
982 const CORBA::Double theRadius,
983 const GEOM::shape_state theState)
985 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
987 //Set a not done flag
988 GetOperations()->SetNotDone();
990 //Get the reference objects
991 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
992 Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
994 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
996 //Get Shapes On Cylinder
997 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
998 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
999 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1000 return aSeq._retn();
1002 Standard_Integer aLength = aHSeq->Length();
1003 aSeq->length(aLength);
1004 for (Standard_Integer i = 1; i <= aLength; i++)
1005 aSeq[i-1] = aHSeq->Value(i);
1007 return aSeq._retn();
1010 //=============================================================================
1012 * GetShapesOnSphereIDs
1014 //=============================================================================
1015 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1016 (GEOM::GEOM_Object_ptr theShape,
1017 const CORBA::Long theShapeType,
1018 GEOM::GEOM_Object_ptr theCenter,
1019 const CORBA::Double theRadius,
1020 const GEOM::shape_state theState)
1022 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1024 //Set a not done flag
1025 GetOperations()->SetNotDone();
1027 //Get the reference objects
1028 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1029 Handle(GEOM_Object) aCenter = GetObjectImpl(theCenter);
1031 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1033 //Get Shapes On Sphere
1034 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1035 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1036 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1037 return aSeq._retn();
1039 Standard_Integer aLength = aHSeq->Length();
1040 aSeq->length(aLength);
1041 for (Standard_Integer i = 1; i <= aLength; i++)
1042 aSeq[i-1] = aHSeq->Value(i);
1044 return aSeq._retn();
1047 //=============================================================================
1049 * GetShapesOnQuadrangleIDs
1051 //=============================================================================
1052 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1053 (GEOM::GEOM_Object_ptr theShape,
1054 CORBA::Long theShapeType,
1055 GEOM::GEOM_Object_ptr theTopLeftPoint,
1056 GEOM::GEOM_Object_ptr theTopRigthPoint,
1057 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1058 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1059 GEOM::shape_state theState)
1061 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1063 //Set a not done flag
1064 GetOperations()->SetNotDone();
1066 //Get the reference objects
1067 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1068 Handle(GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1069 Handle(GEOM_Object) aTopRigthPoint = GetObjectImpl(theTopRigthPoint);
1070 Handle(GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1071 Handle(GEOM_Object) aBottomRigthPoint = GetObjectImpl(theBottomRigthPoint);
1073 if (aShape.IsNull() ||
1074 aTopLeftPoint.IsNull() ||
1075 aTopRigthPoint.IsNull() ||
1076 aBottomLeftPoint.IsNull() ||
1077 aBottomRigthPoint.IsNull() )
1078 return aSeq._retn();
1080 //Get Shapes On Quadrangle
1081 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1082 (aShape, theShapeType,
1083 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1084 ShapeState(theState));
1085 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1086 return aSeq._retn();
1088 Standard_Integer aLength = aHSeq->Length();
1089 aSeq->length(aLength);
1090 for (Standard_Integer i = 1; i <= aLength; i++)
1091 aSeq[i-1] = aHSeq->Value(i);
1093 return aSeq._retn();
1096 //=============================================================================
1100 //=============================================================================
1101 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1102 (GEOM::GEOM_Object_ptr theBox,
1103 GEOM::GEOM_Object_ptr theShape,
1104 CORBA::Long theShapeType,
1105 GEOM::shape_state theState)
1107 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1109 //Set a not done flag
1110 GetOperations()->SetNotDone();
1112 //Get the reference objects
1113 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1114 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1116 if (aShape.IsNull() || aBox.IsNull() )
1117 return aSeq._retn();
1120 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1121 (aBox,aShape, theShapeType,ShapeState(theState));
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 //=============================================================================
1135 * GetShapesOnQuadrangleIDs
1137 //=============================================================================
1138 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1139 (GEOM::GEOM_Object_ptr theBox,
1140 GEOM::GEOM_Object_ptr theShape,
1141 CORBA::Long theShapeType,
1142 GEOM::shape_state theState)
1144 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1146 //Set a not done flag
1147 GetOperations()->SetNotDone();
1149 //Get the reference objects
1150 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1151 Handle(GEOM_Object) aBox = GetObjectImpl(theBox);
1153 if (aShape.IsNull() || aBox.IsNull() )
1154 return aSeq._retn();
1157 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1158 (aBox,aShape, theShapeType,ShapeState(theState));
1159 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1160 return aSeq._retn();
1162 Standard_Integer aLength = aHSeq->Length();
1163 aSeq->length(aLength);
1164 for (Standard_Integer i = 1; i <= aLength; i++)
1165 aSeq[i-1] = aHSeq->Value(i);
1167 return aSeq._retn();
1171 //=============================================================================
1175 //=============================================================================
1176 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1177 (GEOM::GEOM_Object_ptr theCheckShape,
1178 GEOM::GEOM_Object_ptr theShape,
1179 CORBA::Short theShapeType,
1180 GEOM::shape_state theState)
1182 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1184 //Set a not done flag
1185 GetOperations()->SetNotDone();
1187 //Get the reference objects
1188 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1189 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1191 if (aShape.IsNull() || aCheckShape.IsNull() )
1192 return aSeq._retn();
1194 //Get Shapes On Shape
1195 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1196 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1198 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1199 return aSeq._retn();
1201 Standard_Integer aLength = aHSeq->Length();
1202 aSeq->length(aLength);
1203 for (Standard_Integer i = 1; i <= aLength; i++)
1204 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1206 return aSeq._retn();
1210 //=============================================================================
1212 * GetShapesOnShapeAsCompound
1214 //=============================================================================
1215 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1216 (GEOM::GEOM_Object_ptr theCheckShape,
1217 GEOM::GEOM_Object_ptr theShape,
1218 CORBA::Short theShapeType,
1219 GEOM::shape_state theState)
1221 GEOM::GEOM_Object_var aGEOMObject;
1223 //Set a not done flag
1224 GetOperations()->SetNotDone();
1226 //Get the reference objects
1227 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1228 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1230 if (aShape.IsNull() || aCheckShape.IsNull() )
1231 return aGEOMObject._retn();
1233 //Get Shapes On Shape
1234 Handle(GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1235 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1237 if (anObject.IsNull())
1238 return aGEOMObject._retn();
1240 return GetObject(anObject);
1244 //=============================================================================
1246 * GetShapesOnShapeIDs
1248 //=============================================================================
1249 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1250 (GEOM::GEOM_Object_ptr theCheckShape,
1251 GEOM::GEOM_Object_ptr theShape,
1252 CORBA::Short theShapeType,
1253 GEOM::shape_state theState)
1255 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1257 //Set a not done flag
1258 GetOperations()->SetNotDone();
1260 //Get the reference objects
1261 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
1262 Handle(GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1264 if (aShape.IsNull() || aCheckShape.IsNull() )
1265 return aSeq._retn();
1267 //Get Shapes On Shape
1268 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1269 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1270 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1271 return aSeq._retn();
1273 Standard_Integer aLength = aHSeq->Length();
1274 aSeq->length(aLength);
1275 for (Standard_Integer i = 1; i <= aLength; i++)
1276 aSeq[i-1] = aHSeq->Value(i);
1278 return aSeq._retn();
1282 //=============================================================================
1286 //=============================================================================
1287 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1288 (GEOM::GEOM_Object_ptr theShapeWhere,
1289 GEOM::GEOM_Object_ptr theShapeWhat)
1291 GEOM::GEOM_Object_var aGEOMObject;
1293 //Set a not done flag
1294 GetOperations()->SetNotDone();
1296 //Get the reference objects
1297 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1298 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1300 if (aShapeWhere.IsNull() ||
1301 aShapeWhat.IsNull()) return aGEOMObject._retn();
1303 //Get Shapes in place of aShapeWhat
1304 Handle(GEOM_Object) anObject =
1305 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1306 if (!GetOperations()->IsDone() || anObject.IsNull())
1307 return aGEOMObject._retn();
1309 return GetObject(anObject);
1312 //=============================================================================
1314 * GetInPlaceByHistory
1316 //=============================================================================
1317 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1318 (GEOM::GEOM_Object_ptr theShapeWhere,
1319 GEOM::GEOM_Object_ptr theShapeWhat)
1321 GEOM::GEOM_Object_var aGEOMObject;
1323 //Set a not done flag
1324 GetOperations()->SetNotDone();
1326 //Get the reference objects
1327 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1328 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1330 if (aShapeWhere.IsNull() ||
1331 aShapeWhat.IsNull()) return aGEOMObject._retn();
1333 //Get Shapes in place of aShapeWhat
1334 Handle(GEOM_Object) anObject =
1335 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1336 if (!GetOperations()->IsDone() || anObject.IsNull())
1337 return aGEOMObject._retn();
1339 return GetObject(anObject);
1342 //=============================================================================
1346 //=============================================================================
1347 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1348 (GEOM::GEOM_Object_ptr theShapeWhere,
1349 GEOM::GEOM_Object_ptr theShapeWhat)
1351 GEOM::GEOM_Object_var aGEOMObject;
1353 //Set a not done flag
1354 GetOperations()->SetNotDone();
1356 //Get the reference objects
1357 Handle(GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1358 Handle(GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1360 if (aShapeWhere.IsNull() ||
1361 aShapeWhat.IsNull()) return aGEOMObject._retn();
1363 //Get Shapes in place of aShapeWhat
1364 Handle(GEOM_Object) anObject =
1365 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1366 if (!GetOperations()->IsDone() || anObject.IsNull())
1367 return aGEOMObject._retn();
1369 return GetObject(anObject);