1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <Standard_Stream.hxx>
22 #include "GEOM_IShapesOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include "GEOM_Engine.hxx"
29 #include "GEOM_Object.hxx"
31 #include <TColStd_HSequenceOfTransient.hxx>
32 #include <TColStd_HArray1OfInteger.hxx>
34 //=============================================================================
38 //=============================================================================
39 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
40 GEOM::GEOM_Gen_ptr theEngine,
41 ::GEOMImpl_IShapesOperations* theImpl)
42 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
44 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
47 //=============================================================================
51 //=============================================================================
52 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
54 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
58 //=============================================================================
62 //=============================================================================
63 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
64 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
66 GEOM::GEOM_Object_var aGEOMObject;
69 GetOperations()->SetNotDone();
71 if (thePnt1 == NULL || thePnt2 == NULL) return aGEOMObject._retn();
73 //Get the reference points
74 Handle(GEOM_Object) aPnt1 = GetOperations()->GetEngine()->GetObject
75 (thePnt1->GetStudyID(), thePnt1->GetEntry());
76 Handle(GEOM_Object) aPnt2 = GetOperations()->GetEngine()->GetObject
77 (thePnt2->GetStudyID(), thePnt2->GetEntry());
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 //=============================================================================
93 //=============================================================================
94 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
95 (const GEOM::ListOfGO& theEdgesAndWires)
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 if (theEdgesAndWires[ind] == NULL) return aGEOMObject._retn();
109 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
110 (theEdgesAndWires[ind]->GetStudyID(), theEdgesAndWires[ind]->GetEntry());
111 if (aSh.IsNull()) return aGEOMObject._retn();
112 aShapes.push_back(aSh);
116 Handle(GEOM_Object) anObject =
117 GetOperations()->MakeWire(aShapes);
118 if (!GetOperations()->IsDone() || anObject.IsNull())
119 return aGEOMObject._retn();
121 return GetObject(anObject);
124 //=============================================================================
128 //=============================================================================
129 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
130 (GEOM::GEOM_Object_ptr theWire,
131 const CORBA::Boolean isPlanarWanted)
133 GEOM::GEOM_Object_var aGEOMObject;
135 //Set a not done flag
136 GetOperations()->SetNotDone();
138 if (theWire == NULL) return aGEOMObject._retn();
140 //Get the reference wire
141 Handle(GEOM_Object) aWire = GetOperations()->GetEngine()->GetObject
142 (theWire->GetStudyID(), theWire->GetEntry());
144 if (aWire.IsNull()) return aGEOMObject._retn();
147 Handle(GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
148 if (!GetOperations()->IsDone() || anObject.IsNull())
149 return aGEOMObject._retn();
151 return GetObject(anObject);
154 //=============================================================================
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
160 (const GEOM::ListOfGO& theWires,
161 const CORBA::Boolean isPlanarWanted)
163 GEOM::GEOM_Object_var aGEOMObject;
165 //Set a not done flag
166 GetOperations()->SetNotDone();
169 list<Handle(GEOM_Object)> aShapes;
172 aLen = theWires.length();
173 for (ind = 0; ind < aLen; ind++) {
174 if (theWires[ind] == NULL) return aGEOMObject._retn();
175 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
176 (theWires[ind]->GetStudyID(), theWires[ind]->GetEntry());
177 if (aSh.IsNull()) return aGEOMObject._retn();
178 aShapes.push_back(aSh);
182 Handle(GEOM_Object) anObject =
183 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
184 if (!GetOperations()->IsDone() || anObject.IsNull())
185 return aGEOMObject._retn();
187 return GetObject(anObject);
190 //=============================================================================
194 //=============================================================================
195 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
196 (const GEOM::ListOfGO& theFacesAndShells)
198 GEOM::GEOM_Object_var aGEOMObject;
200 //Set a not done flag
201 GetOperations()->SetNotDone();
204 list<Handle(GEOM_Object)> aShapes;
207 aLen = theFacesAndShells.length();
208 for (ind = 0; ind < aLen; ind++) {
209 if (theFacesAndShells[ind] == NULL) return aGEOMObject._retn();
210 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
211 (theFacesAndShells[ind]->GetStudyID(), theFacesAndShells[ind]->GetEntry());
212 if (aSh.IsNull()) return aGEOMObject._retn();
213 aShapes.push_back(aSh);
217 Handle(GEOM_Object) anObject =
218 GetOperations()->MakeShell(aShapes);
219 if (!GetOperations()->IsDone() || anObject.IsNull())
220 return aGEOMObject._retn();
222 return GetObject(anObject);
225 //=============================================================================
229 //=============================================================================
230 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
231 (GEOM::GEOM_Object_ptr theShell)
233 GEOM::GEOM_Object_var aGEOMObject;
235 //Set a not done flag
236 GetOperations()->SetNotDone();
238 if (theShell == NULL) return aGEOMObject._retn();
240 //Get the reference objects
241 Handle(GEOM_Object) aShell = GetOperations()->GetEngine()->GetObject
242 (theShell->GetStudyID(), theShell->GetEntry());
244 if (aShell.IsNull()) return aGEOMObject._retn();
247 Handle(GEOM_Object) anObject = GetOperations()->MakeSolidShell(aShell);
248 if (!GetOperations()->IsDone() || anObject.IsNull())
249 return aGEOMObject._retn();
251 return GetObject(anObject);
254 //=============================================================================
258 //=============================================================================
259 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
260 (const GEOM::ListOfGO& theShells)
262 GEOM::GEOM_Object_var aGEOMObject;
264 //Set a not done flag
265 GetOperations()->SetNotDone();
268 list<Handle(GEOM_Object)> aShapes;
271 aLen = theShells.length();
272 for (ind = 0; ind < aLen; ind++) {
273 if (theShells[ind] == NULL) return aGEOMObject._retn();
274 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
275 (theShells[ind]->GetStudyID(), theShells[ind]->GetEntry());
276 if (aSh.IsNull()) return aGEOMObject._retn();
277 aShapes.push_back(aSh);
281 Handle(GEOM_Object) anObject =
282 GetOperations()->MakeSolidShells(aShapes);
283 if (!GetOperations()->IsDone() || anObject.IsNull())
284 return aGEOMObject._retn();
286 return GetObject(anObject);
289 //=============================================================================
293 //=============================================================================
294 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeCompound
295 (const GEOM::ListOfGO& theShapes)
297 GEOM::GEOM_Object_var aGEOMObject;
299 //Set a not done flag
300 GetOperations()->SetNotDone();
303 list<Handle(GEOM_Object)> aShapes;
306 aLen = theShapes.length();
307 for (ind = 0; ind < aLen; ind++) {
308 if (theShapes[ind] == NULL) return aGEOMObject._retn();
309 Handle(GEOM_Object) aSh = GetOperations()->GetEngine()->GetObject
310 (theShapes[ind]->GetStudyID(), theShapes[ind]->GetEntry());
311 if (aSh.IsNull()) return aGEOMObject._retn();
312 aShapes.push_back(aSh);
316 Handle(GEOM_Object) anObject =
317 GetOperations()->MakeCompound(aShapes);
318 if (!GetOperations()->IsDone() || anObject.IsNull())
319 return aGEOMObject._retn();
321 return GetObject(anObject);
324 //=============================================================================
328 //=============================================================================
329 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeGlueFaces
330 (GEOM::GEOM_Object_ptr theShape,
331 const CORBA::Double theTolerance)
333 GEOM::GEOM_Object_var aGEOMObject;
335 //Set a not done flag
336 GetOperations()->SetNotDone();
338 if (theShape == NULL) return aGEOMObject._retn();
340 //Get the reference objects
341 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
342 (theShape->GetStudyID(), theShape->GetEntry());
344 if (aShape.IsNull()) return aGEOMObject._retn();
347 Handle(GEOM_Object) anObject =
348 GetOperations()->MakeGlueFaces(aShape, theTolerance);
349 //if (!GetOperations()->IsDone() || anObject.IsNull())
351 if (anObject.IsNull())
352 return aGEOMObject._retn();
354 return GetObject(anObject);
357 //=============================================================================
361 //=============================================================================
362 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
363 const CORBA::Long theShapeType,
364 const CORBA::Boolean isSorted)
366 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
367 if (theShape == NULL) return aSeq._retn();
369 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
370 (theShape->GetStudyID(), theShape->GetEntry());
372 Handle(TColStd_HSequenceOfTransient) aHSeq =
373 GetOperations()->MakeExplode(aShape, theShapeType, isSorted);
374 if (!GetOperations()->IsDone() || aHSeq.IsNull())
377 Standard_Integer aLength = aHSeq->Length();
378 aSeq->length(aLength);
379 for (Standard_Integer i = 1; i <= aLength; i++)
380 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
385 //=============================================================================
389 //=============================================================================
390 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
391 const CORBA::Long theShapeType,
392 const CORBA::Boolean isSorted)
394 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
395 if (theShape == NULL) return aSeq._retn();
397 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
398 (theShape->GetStudyID(), theShape->GetEntry());
400 Handle(TColStd_HSequenceOfInteger) aHSeq =
401 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted);
402 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
404 Standard_Integer aLength = aHSeq->Length();
405 aSeq->length(aLength);
406 for (Standard_Integer i = 1; i <= aLength; i++)
407 aSeq[i-1] = aHSeq->Value(i);
412 //=============================================================================
416 //=============================================================================
417 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
418 (GEOM::GEOM_Object_ptr theMainShape,
419 const CORBA::Long theID)
421 GEOM::GEOM_Object_var aGEOMObject;
423 //Set a not done flag
424 GetOperations()->SetNotDone();
426 if (theMainShape == NULL) return aGEOMObject._retn();
428 //Get the reference objects
429 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
430 (theMainShape->GetStudyID(), theMainShape->GetEntry());
432 if (aShape.IsNull()) return aGEOMObject._retn();
434 Handle(GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
435 if (!GetOperations()->IsDone() || anObject.IsNull())
436 return aGEOMObject._retn();
438 return GetObject(anObject);
441 //=============================================================================
445 //=============================================================================
446 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
447 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
449 if (theMainShape == NULL || theSubShape == NULL) return -1;
451 //Get the reference shapes
452 Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
453 (theMainShape->GetStudyID(), theMainShape->GetEntry());
454 Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
455 (theSubShape->GetStudyID(), theSubShape->GetEntry());
456 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
458 //Get the unique ID of <theSubShape> inside <theMainShape>
459 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
460 if (!GetOperations()->IsDone())
466 //=============================================================================
470 //=============================================================================
471 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
472 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
474 if (theMainShape == NULL || theSubShape == NULL) return -1;
476 //Get the reference shapes
477 Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject
478 (theMainShape->GetStudyID(), theMainShape->GetEntry());
479 Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject
480 (theSubShape->GetStudyID(), theSubShape->GetEntry());
481 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
483 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
484 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
485 if (!GetOperations()->IsDone())
491 //=============================================================================
495 //=============================================================================
496 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
498 if (theShape == NULL) return NULL;
500 //Get the reference shape
501 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
502 (theShape->GetStudyID(), theShape->GetEntry());
504 if (aShape.IsNull()) return NULL;
506 // Get shape parameters
507 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
508 return CORBA::string_dup(aDescription.ToCString());
511 //=============================================================================
515 //=============================================================================
516 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
518 if (theShape == NULL) return -1;
520 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
521 (theShape->GetStudyID(), theShape->GetEntry());
523 CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
524 if (!GetOperations()->IsDone()) return -1;
529 //=============================================================================
533 //=============================================================================
534 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
536 if (theShape == NULL) return -1;
538 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
539 (theShape->GetStudyID(), theShape->GetEntry());
541 CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
542 if (!GetOperations()->IsDone()) return -1;
547 //=============================================================================
551 //=============================================================================
552 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
553 (GEOM::GEOM_Object_ptr theShape)
555 GEOM::GEOM_Object_var aGEOMObject;
557 //Set a not done flag
558 GetOperations()->SetNotDone();
560 if (theShape == NULL) return aGEOMObject._retn();
562 //Get the reference objects
563 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
564 (theShape->GetStudyID(), theShape->GetEntry());
566 if (aShape.IsNull()) return aGEOMObject._retn();
569 Handle(GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
570 if (!GetOperations()->IsDone() || anObject.IsNull())
571 return aGEOMObject._retn();
573 return GetObject(anObject);
576 //=============================================================================
580 //=============================================================================
581 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
583 //Set a not done flag
584 GetOperations()->SetNotDone();
586 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
587 if (theShape == NULL) return aSeq._retn();
589 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
590 (theShape->GetStudyID(), theShape->GetEntry());
592 Handle(TColStd_HSequenceOfInteger) aHSeq =
593 GetOperations()->GetFreeFacesIDs(aShape);
594 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
596 Standard_Integer aLength = aHSeq->Length();
597 aSeq->length(aLength);
598 for (Standard_Integer i = 1; i <= aLength; i++)
599 aSeq[i-1] = aHSeq->Value(i);
604 //=============================================================================
608 //=============================================================================
609 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
610 (GEOM::GEOM_Object_ptr theShape1,
611 GEOM::GEOM_Object_ptr theShape2,
612 const CORBA::Long theShapeType)
614 //Set a not done flag
615 GetOperations()->SetNotDone();
617 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
618 if (theShape1 == NULL ||
619 theShape2 == NULL) return aSeq._retn();
621 Handle(GEOM_Object) aShape1 = GetOperations()->GetEngine()->GetObject
622 (theShape1->GetStudyID(), theShape1->GetEntry());
623 Handle(GEOM_Object) aShape2 = GetOperations()->GetEngine()->GetObject
624 (theShape2->GetStudyID(), theShape2->GetEntry());
626 if (aShape1.IsNull() ||
627 aShape2.IsNull()) return aSeq._retn();
629 Handle(TColStd_HSequenceOfTransient) aHSeq =
630 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
631 if (!GetOperations()->IsDone() || aHSeq.IsNull())
634 Standard_Integer aLength = aHSeq->Length();
635 aSeq->length(aLength);
636 for (Standard_Integer i = 1; i <= aLength; i++)
637 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
642 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
644 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
648 aState = GEOMAlgo_ST_ON;
651 aState = GEOMAlgo_ST_OUT;
654 aState = GEOMAlgo_ST_ONOUT;
657 aState = GEOMAlgo_ST_IN;
660 aState = GEOMAlgo_ST_ONIN;
669 //=============================================================================
673 //=============================================================================
674 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
675 (GEOM::GEOM_Object_ptr theShape,
676 const CORBA::Long theShapeType,
677 GEOM::GEOM_Object_ptr theAx1,
678 const GEOM::shape_state theState)
680 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
682 //Set a not done flag
683 GetOperations()->SetNotDone();
685 if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
687 //Get the reference objects
688 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
689 (theShape->GetStudyID(), theShape->GetEntry());
690 Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
691 (theAx1->GetStudyID(), theAx1->GetEntry());
693 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
695 //Get Shapes On Plane
696 Handle(TColStd_HSequenceOfTransient) aHSeq =
697 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
698 if (!GetOperations()->IsDone() || aHSeq.IsNull())
701 Standard_Integer aLength = aHSeq->Length();
702 aSeq->length(aLength);
703 for (Standard_Integer i = 1; i <= aLength; i++)
704 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
709 //=============================================================================
711 * GetShapesOnCylinder
713 //=============================================================================
714 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
715 (GEOM::GEOM_Object_ptr theShape,
716 const CORBA::Long theShapeType,
717 GEOM::GEOM_Object_ptr theAxis,
718 const CORBA::Double theRadius,
719 const GEOM::shape_state theState)
721 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
723 //Set a not done flag
724 GetOperations()->SetNotDone();
726 if (theShape == NULL || theAxis == NULL) return aSeq._retn();
728 //Get the reference objects
729 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
730 (theShape->GetStudyID(), theShape->GetEntry());
731 Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
732 (theAxis->GetStudyID(), theAxis->GetEntry());
734 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
736 //Get Shapes On Cylinder
737 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
738 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
739 if (!GetOperations()->IsDone() || aHSeq.IsNull())
742 Standard_Integer aLength = aHSeq->Length();
743 aSeq->length(aLength);
744 for (Standard_Integer i = 1; i <= aLength; i++)
745 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
750 //=============================================================================
754 //=============================================================================
755 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
756 (GEOM::GEOM_Object_ptr theShape,
757 const CORBA::Long theShapeType,
758 GEOM::GEOM_Object_ptr theCenter,
759 const CORBA::Double theRadius,
760 const GEOM::shape_state theState)
762 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
764 //Set a not done flag
765 GetOperations()->SetNotDone();
767 if (theShape == NULL || theCenter == NULL) return aSeq._retn();
769 //Get the reference objects
770 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
771 (theShape->GetStudyID(), theShape->GetEntry());
772 Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
773 (theCenter->GetStudyID(), theCenter->GetEntry());
775 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
777 //Get Shapes On Sphere
778 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
779 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
780 if (!GetOperations()->IsDone() || aHSeq.IsNull())
783 Standard_Integer aLength = aHSeq->Length();
784 aSeq->length(aLength);
785 for (Standard_Integer i = 1; i <= aLength; i++)
786 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
791 //=============================================================================
793 * GetShapesOnQuadrangle
795 //=============================================================================
796 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
797 (GEOM::GEOM_Object_ptr theShape,
798 CORBA::Long theShapeType,
799 GEOM::GEOM_Object_ptr theTopLeftPoint,
800 GEOM::GEOM_Object_ptr theTopRigthPoint,
801 GEOM::GEOM_Object_ptr theBottomLeftPoint,
802 GEOM::GEOM_Object_ptr theBottomRigthPoint,
803 GEOM::shape_state theState)
805 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
807 //Set a not done flag
808 GetOperations()->SetNotDone();
810 if (theShape == NULL ||
811 theTopLeftPoint == NULL ||
812 theTopRigthPoint == NULL ||
813 theBottomLeftPoint == NULL ||
814 theBottomRigthPoint == NULL )
817 //Get the reference objects
818 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
819 (theShape->GetStudyID(), theShape->GetEntry());
820 Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
821 (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
822 Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
823 (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
824 Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
825 (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
826 Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
827 (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
829 if (aShape.IsNull() ||
830 aTopLeftPoint.IsNull() ||
831 aTopRigthPoint.IsNull() ||
832 aBottomLeftPoint.IsNull() ||
833 aBottomRigthPoint.IsNull() )
836 //Get Shapes On Quadrangle
837 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
838 (aShape, theShapeType,
839 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
840 ShapeState(theState));
841 if (!GetOperations()->IsDone() || aHSeq.IsNull())
844 Standard_Integer aLength = aHSeq->Length();
845 aSeq->length(aLength);
846 for (Standard_Integer i = 1; i <= aLength; i++)
847 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
852 //=============================================================================
854 * GetShapesOnPlaneIDs
856 //=============================================================================
857 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
858 (GEOM::GEOM_Object_ptr theShape,
859 const CORBA::Long theShapeType,
860 GEOM::GEOM_Object_ptr theAx1,
861 const GEOM::shape_state theState)
863 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
865 //Set a not done flag
866 GetOperations()->SetNotDone();
868 if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
870 //Get the reference objects
871 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
872 (theShape->GetStudyID(), theShape->GetEntry());
873 Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
874 (theAx1->GetStudyID(), theAx1->GetEntry());
876 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
878 //Get Shapes On Plane
879 Handle(TColStd_HSequenceOfInteger) aHSeq =
880 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
881 if (!GetOperations()->IsDone() || aHSeq.IsNull())
884 Standard_Integer aLength = aHSeq->Length();
885 aSeq->length(aLength);
886 for (Standard_Integer i = 1; i <= aLength; i++)
887 aSeq[i-1] = aHSeq->Value(i);
892 //=============================================================================
894 * GetShapesOnCylinderIDs
896 //=============================================================================
897 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
898 (GEOM::GEOM_Object_ptr theShape,
899 const CORBA::Long theShapeType,
900 GEOM::GEOM_Object_ptr theAxis,
901 const CORBA::Double theRadius,
902 const GEOM::shape_state theState)
904 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
906 //Set a not done flag
907 GetOperations()->SetNotDone();
909 if (theShape == NULL || theAxis == NULL) return aSeq._retn();
911 //Get the reference objects
912 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
913 (theShape->GetStudyID(), theShape->GetEntry());
914 Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
915 (theAxis->GetStudyID(), theAxis->GetEntry());
917 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
919 //Get Shapes On Cylinder
920 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
921 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
922 if (!GetOperations()->IsDone() || aHSeq.IsNull())
925 Standard_Integer aLength = aHSeq->Length();
926 aSeq->length(aLength);
927 for (Standard_Integer i = 1; i <= aLength; i++)
928 aSeq[i-1] = aHSeq->Value(i);
933 //=============================================================================
935 * GetShapesOnSphereIDs
937 //=============================================================================
938 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
939 (GEOM::GEOM_Object_ptr theShape,
940 const CORBA::Long theShapeType,
941 GEOM::GEOM_Object_ptr theCenter,
942 const CORBA::Double theRadius,
943 const GEOM::shape_state theState)
945 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
947 //Set a not done flag
948 GetOperations()->SetNotDone();
950 if (theShape == NULL || theCenter == NULL) return aSeq._retn();
952 //Get the reference objects
953 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
954 (theShape->GetStudyID(), theShape->GetEntry());
955 Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
956 (theCenter->GetStudyID(), theCenter->GetEntry());
958 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
960 //Get Shapes On Sphere
961 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
962 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
963 if (!GetOperations()->IsDone() || aHSeq.IsNull())
966 Standard_Integer aLength = aHSeq->Length();
967 aSeq->length(aLength);
968 for (Standard_Integer i = 1; i <= aLength; i++)
969 aSeq[i-1] = aHSeq->Value(i);
974 //=============================================================================
976 * GetShapesOnQuadrangleIDs
978 //=============================================================================
979 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
980 (GEOM::GEOM_Object_ptr theShape,
981 CORBA::Long theShapeType,
982 GEOM::GEOM_Object_ptr theTopLeftPoint,
983 GEOM::GEOM_Object_ptr theTopRigthPoint,
984 GEOM::GEOM_Object_ptr theBottomLeftPoint,
985 GEOM::GEOM_Object_ptr theBottomRigthPoint,
986 GEOM::shape_state theState)
988 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
990 //Set a not done flag
991 GetOperations()->SetNotDone();
993 if (theShape == NULL ||
994 theTopLeftPoint == NULL ||
995 theTopRigthPoint == NULL ||
996 theBottomLeftPoint == NULL ||
997 theBottomRigthPoint == NULL )
1000 //Get the reference objects
1001 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1002 (theShape->GetStudyID(), theShape->GetEntry());
1003 Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
1004 (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
1005 Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
1006 (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
1007 Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
1008 (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
1009 Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
1010 (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
1012 if (aShape.IsNull() ||
1013 aTopLeftPoint.IsNull() ||
1014 aTopRigthPoint.IsNull() ||
1015 aBottomLeftPoint.IsNull() ||
1016 aBottomRigthPoint.IsNull() )
1017 return aSeq._retn();
1019 //Get Shapes On Quadrangle
1020 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1021 (aShape, theShapeType,
1022 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1023 ShapeState(theState));
1024 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1025 return aSeq._retn();
1027 Standard_Integer aLength = aHSeq->Length();
1028 aSeq->length(aLength);
1029 for (Standard_Integer i = 1; i <= aLength; i++)
1030 aSeq[i-1] = aHSeq->Value(i);
1032 return aSeq._retn();
1035 //=============================================================================
1039 //=============================================================================
1040 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1041 (GEOM::GEOM_Object_ptr theShapeWhere,
1042 GEOM::GEOM_Object_ptr theShapeWhat)
1044 GEOM::GEOM_Object_var aGEOMObject;
1046 //Set a not done flag
1047 GetOperations()->SetNotDone();
1049 if (theShapeWhere == NULL ||
1050 theShapeWhat == NULL) return aGEOMObject._retn();
1052 //Get the reference objects
1053 Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
1054 (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
1055 Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
1056 (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
1058 if (aShapeWhere.IsNull() ||
1059 aShapeWhat.IsNull()) return aGEOMObject._retn();
1061 //Get Shapes in place of aShapeWhat
1062 Handle(GEOM_Object) anObject =
1063 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1064 if (!GetOperations()->IsDone() || anObject.IsNull())
1065 return aGEOMObject._retn();
1067 return GetObject(anObject);