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 * GetShapesOnPlaneWithLocation
713 //=============================================================================
714 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
715 (GEOM::GEOM_Object_ptr theShape,
716 const CORBA::Long theShapeType,
717 GEOM::GEOM_Object_ptr theAx1,
718 GEOM::GEOM_Object_ptr thePnt,
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 || theAx1 == NULL || thePnt == 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) anAx1 = GetOperations()->GetEngine()->GetObject
732 (theAx1->GetStudyID(), theAx1->GetEntry());
733 Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
734 (thePnt->GetStudyID(), thePnt->GetEntry());
736 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
738 //Get Shapes On Plane
739 Handle(TColStd_HSequenceOfTransient) aHSeq =
740 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
741 if (!GetOperations()->IsDone() || aHSeq.IsNull())
744 Standard_Integer aLength = aHSeq->Length();
745 aSeq->length(aLength);
746 for (Standard_Integer i = 1; i <= aLength; i++)
747 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
752 //=============================================================================
754 * GetShapesOnCylinder
756 //=============================================================================
757 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
758 (GEOM::GEOM_Object_ptr theShape,
759 const CORBA::Long theShapeType,
760 GEOM::GEOM_Object_ptr theAxis,
761 const CORBA::Double theRadius,
762 const GEOM::shape_state theState)
764 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
766 //Set a not done flag
767 GetOperations()->SetNotDone();
769 if (theShape == NULL || theAxis == NULL) return aSeq._retn();
771 //Get the reference objects
772 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
773 (theShape->GetStudyID(), theShape->GetEntry());
774 Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
775 (theAxis->GetStudyID(), theAxis->GetEntry());
777 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
779 //Get Shapes On Cylinder
780 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
781 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
782 if (!GetOperations()->IsDone() || aHSeq.IsNull())
785 Standard_Integer aLength = aHSeq->Length();
786 aSeq->length(aLength);
787 for (Standard_Integer i = 1; i <= aLength; i++)
788 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
793 //=============================================================================
797 //=============================================================================
798 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
799 (GEOM::GEOM_Object_ptr theShape,
800 const CORBA::Long theShapeType,
801 GEOM::GEOM_Object_ptr theCenter,
802 const CORBA::Double theRadius,
803 const 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 || theCenter == NULL) return aSeq._retn();
812 //Get the reference objects
813 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
814 (theShape->GetStudyID(), theShape->GetEntry());
815 Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
816 (theCenter->GetStudyID(), theCenter->GetEntry());
818 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
820 //Get Shapes On Sphere
821 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
822 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
823 if (!GetOperations()->IsDone() || aHSeq.IsNull())
826 Standard_Integer aLength = aHSeq->Length();
827 aSeq->length(aLength);
828 for (Standard_Integer i = 1; i <= aLength; i++)
829 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
834 //=============================================================================
836 * GetShapesOnQuadrangle
838 //=============================================================================
839 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
840 (GEOM::GEOM_Object_ptr theShape,
841 CORBA::Long theShapeType,
842 GEOM::GEOM_Object_ptr theTopLeftPoint,
843 GEOM::GEOM_Object_ptr theTopRigthPoint,
844 GEOM::GEOM_Object_ptr theBottomLeftPoint,
845 GEOM::GEOM_Object_ptr theBottomRigthPoint,
846 GEOM::shape_state theState)
848 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
850 //Set a not done flag
851 GetOperations()->SetNotDone();
853 if (theShape == NULL ||
854 theTopLeftPoint == NULL ||
855 theTopRigthPoint == NULL ||
856 theBottomLeftPoint == NULL ||
857 theBottomRigthPoint == NULL )
860 //Get the reference objects
861 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
862 (theShape->GetStudyID(), theShape->GetEntry());
863 Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
864 (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
865 Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
866 (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
867 Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
868 (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
869 Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
870 (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
872 if (aShape.IsNull() ||
873 aTopLeftPoint.IsNull() ||
874 aTopRigthPoint.IsNull() ||
875 aBottomLeftPoint.IsNull() ||
876 aBottomRigthPoint.IsNull() )
879 //Get Shapes On Quadrangle
880 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
881 (aShape, theShapeType,
882 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
883 ShapeState(theState));
884 if (!GetOperations()->IsDone() || aHSeq.IsNull())
887 Standard_Integer aLength = aHSeq->Length();
888 aSeq->length(aLength);
889 for (Standard_Integer i = 1; i <= aLength; i++)
890 aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
895 //=============================================================================
897 * GetShapesOnPlaneIDs
899 //=============================================================================
900 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
901 (GEOM::GEOM_Object_ptr theShape,
902 const CORBA::Long theShapeType,
903 GEOM::GEOM_Object_ptr theAx1,
904 const GEOM::shape_state theState)
906 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
908 //Set a not done flag
909 GetOperations()->SetNotDone();
911 if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
913 //Get the reference objects
914 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
915 (theShape->GetStudyID(), theShape->GetEntry());
916 Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
917 (theAx1->GetStudyID(), theAx1->GetEntry());
919 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
921 //Get Shapes On Plane
922 Handle(TColStd_HSequenceOfInteger) aHSeq =
923 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
924 if (!GetOperations()->IsDone() || aHSeq.IsNull())
927 Standard_Integer aLength = aHSeq->Length();
928 aSeq->length(aLength);
929 for (Standard_Integer i = 1; i <= aLength; i++)
930 aSeq[i-1] = aHSeq->Value(i);
935 //=============================================================================
937 * GetShapesOnPlaneWithLocationIDs
939 //=============================================================================
940 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
941 (GEOM::GEOM_Object_ptr theShape,
942 const CORBA::Long theShapeType,
943 GEOM::GEOM_Object_ptr theAx1,
944 GEOM::GEOM_Object_ptr thePnt,
945 const GEOM::shape_state theState)
947 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
949 //Set a not done flag
950 GetOperations()->SetNotDone();
952 if (theShape == NULL || theAx1 == NULL || thePnt == NULL) return aSeq._retn();
954 //Get the reference objects
955 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
956 (theShape->GetStudyID(), theShape->GetEntry());
957 Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
958 (theAx1->GetStudyID(), theAx1->GetEntry());
959 Handle(GEOM_Object) anPnt = GetOperations()->GetEngine()->GetObject
960 (thePnt->GetStudyID(), thePnt->GetEntry());
962 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
964 //Get Shapes On Plane
965 Handle(TColStd_HSequenceOfInteger) aHSeq =
966 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
967 if (!GetOperations()->IsDone() || aHSeq.IsNull())
970 Standard_Integer aLength = aHSeq->Length();
971 aSeq->length(aLength);
972 for (Standard_Integer i = 1; i <= aLength; i++)
973 aSeq[i-1] = aHSeq->Value(i);
978 //=============================================================================
980 * GetShapesOnCylinderIDs
982 //=============================================================================
983 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
984 (GEOM::GEOM_Object_ptr theShape,
985 const CORBA::Long theShapeType,
986 GEOM::GEOM_Object_ptr theAxis,
987 const CORBA::Double theRadius,
988 const GEOM::shape_state theState)
990 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
992 //Set a not done flag
993 GetOperations()->SetNotDone();
995 if (theShape == NULL || theAxis == NULL) return aSeq._retn();
997 //Get the reference objects
998 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
999 (theShape->GetStudyID(), theShape->GetEntry());
1000 Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
1001 (theAxis->GetStudyID(), theAxis->GetEntry());
1003 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1005 //Get Shapes On Cylinder
1006 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1007 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1008 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1009 return aSeq._retn();
1011 Standard_Integer aLength = aHSeq->Length();
1012 aSeq->length(aLength);
1013 for (Standard_Integer i = 1; i <= aLength; i++)
1014 aSeq[i-1] = aHSeq->Value(i);
1016 return aSeq._retn();
1019 //=============================================================================
1021 * GetShapesOnSphereIDs
1023 //=============================================================================
1024 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1025 (GEOM::GEOM_Object_ptr theShape,
1026 const CORBA::Long theShapeType,
1027 GEOM::GEOM_Object_ptr theCenter,
1028 const CORBA::Double theRadius,
1029 const GEOM::shape_state theState)
1031 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1033 //Set a not done flag
1034 GetOperations()->SetNotDone();
1036 if (theShape == NULL || theCenter == NULL) return aSeq._retn();
1038 //Get the reference objects
1039 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1040 (theShape->GetStudyID(), theShape->GetEntry());
1041 Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
1042 (theCenter->GetStudyID(), theCenter->GetEntry());
1044 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1046 //Get Shapes On Sphere
1047 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1048 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1049 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1050 return aSeq._retn();
1052 Standard_Integer aLength = aHSeq->Length();
1053 aSeq->length(aLength);
1054 for (Standard_Integer i = 1; i <= aLength; i++)
1055 aSeq[i-1] = aHSeq->Value(i);
1057 return aSeq._retn();
1060 //=============================================================================
1062 * GetShapesOnQuadrangleIDs
1064 //=============================================================================
1065 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1066 (GEOM::GEOM_Object_ptr theShape,
1067 CORBA::Long theShapeType,
1068 GEOM::GEOM_Object_ptr theTopLeftPoint,
1069 GEOM::GEOM_Object_ptr theTopRigthPoint,
1070 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1071 GEOM::GEOM_Object_ptr theBottomRigthPoint,
1072 GEOM::shape_state theState)
1074 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1076 //Set a not done flag
1077 GetOperations()->SetNotDone();
1079 if (theShape == NULL ||
1080 theTopLeftPoint == NULL ||
1081 theTopRigthPoint == NULL ||
1082 theBottomLeftPoint == NULL ||
1083 theBottomRigthPoint == NULL )
1084 return aSeq._retn();
1086 //Get the reference objects
1087 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1088 (theShape->GetStudyID(), theShape->GetEntry());
1089 Handle(GEOM_Object) aTopLeftPoint = GetOperations()->GetEngine()->GetObject
1090 (theShape->GetStudyID(), theTopLeftPoint->GetEntry());
1091 Handle(GEOM_Object) aTopRigthPoint = GetOperations()->GetEngine()->GetObject
1092 (theShape->GetStudyID(), theTopRigthPoint->GetEntry());
1093 Handle(GEOM_Object) aBottomLeftPoint = GetOperations()->GetEngine()->GetObject
1094 (theShape->GetStudyID(), theBottomLeftPoint->GetEntry());
1095 Handle(GEOM_Object) aBottomRigthPoint = GetOperations()->GetEngine()->GetObject
1096 (theShape->GetStudyID(), theBottomRigthPoint->GetEntry());
1098 if (aShape.IsNull() ||
1099 aTopLeftPoint.IsNull() ||
1100 aTopRigthPoint.IsNull() ||
1101 aBottomLeftPoint.IsNull() ||
1102 aBottomRigthPoint.IsNull() )
1103 return aSeq._retn();
1105 //Get Shapes On Quadrangle
1106 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1107 (aShape, theShapeType,
1108 aTopLeftPoint, aTopRigthPoint, aBottomLeftPoint, aBottomRigthPoint,
1109 ShapeState(theState));
1110 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1111 return aSeq._retn();
1113 Standard_Integer aLength = aHSeq->Length();
1114 aSeq->length(aLength);
1115 for (Standard_Integer i = 1; i <= aLength; i++)
1116 aSeq[i-1] = aHSeq->Value(i);
1118 return aSeq._retn();
1121 //=============================================================================
1125 //=============================================================================
1126 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1127 (GEOM::GEOM_Object_ptr theBox,
1128 GEOM::GEOM_Object_ptr theShape,
1129 CORBA::Long theShapeType,
1130 GEOM::shape_state theState)
1132 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1134 //Set a not done flag
1135 GetOperations()->SetNotDone();
1137 if ( theShape == NULL || theBox == NULL )
1138 return aSeq._retn();
1140 //Get the reference objects
1141 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1142 (theShape->GetStudyID(), theShape->GetEntry());
1143 Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
1144 (theShape->GetStudyID(), theBox->GetEntry());
1146 if (aShape.IsNull() || aBox.IsNull() )
1147 return aSeq._retn();
1150 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
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] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
1160 return aSeq._retn();
1163 //=============================================================================
1165 * GetShapesOnQuadrangleIDs
1167 //=============================================================================
1168 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1169 (GEOM::GEOM_Object_ptr theBox,
1170 GEOM::GEOM_Object_ptr theShape,
1171 CORBA::Long theShapeType,
1172 GEOM::shape_state theState)
1174 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1176 //Set a not done flag
1177 GetOperations()->SetNotDone();
1179 if ( theShape == NULL || theBox == NULL )
1180 return aSeq._retn();
1182 //Get the reference objects
1183 Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
1184 (theShape->GetStudyID(), theShape->GetEntry());
1185 Handle(GEOM_Object) aBox = GetOperations()->GetEngine()->GetObject
1186 (theShape->GetStudyID(), theBox->GetEntry());
1188 if (aShape.IsNull() || aBox.IsNull() )
1189 return aSeq._retn();
1192 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1193 (aBox,aShape, theShapeType,ShapeState(theState));
1194 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1195 return aSeq._retn();
1197 Standard_Integer aLength = aHSeq->Length();
1198 aSeq->length(aLength);
1199 for (Standard_Integer i = 1; i <= aLength; i++)
1200 aSeq[i-1] = aHSeq->Value(i);
1202 return aSeq._retn();
1205 //=============================================================================
1209 //=============================================================================
1210 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1211 (GEOM::GEOM_Object_ptr theShapeWhere,
1212 GEOM::GEOM_Object_ptr theShapeWhat)
1214 GEOM::GEOM_Object_var aGEOMObject;
1216 //Set a not done flag
1217 GetOperations()->SetNotDone();
1219 if (theShapeWhere == NULL ||
1220 theShapeWhat == NULL) return aGEOMObject._retn();
1222 //Get the reference objects
1223 Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
1224 (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
1225 Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
1226 (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
1228 if (aShapeWhere.IsNull() ||
1229 aShapeWhat.IsNull()) return aGEOMObject._retn();
1231 //Get Shapes in place of aShapeWhat
1232 Handle(GEOM_Object) anObject =
1233 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1234 if (!GetOperations()->IsDone() || anObject.IsNull())
1235 return aGEOMObject._retn();
1237 return GetObject(anObject);
1240 //=============================================================================
1244 //=============================================================================
1245 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
1246 (GEOM::GEOM_Object_ptr theShapeWhere,
1247 GEOM::GEOM_Object_ptr theShapeWhat)
1249 GEOM::GEOM_Object_var aGEOMObject;
1251 //Set a not done flag
1252 GetOperations()->SetNotDone();
1254 if (theShapeWhere == NULL ||
1255 theShapeWhat == NULL) return aGEOMObject._retn();
1257 //Get the reference objects
1258 Handle(GEOM_Object) aShapeWhere = GetOperations()->GetEngine()->GetObject
1259 (theShapeWhere->GetStudyID(), theShapeWhere->GetEntry());
1260 Handle(GEOM_Object) aShapeWhat = GetOperations()->GetEngine()->GetObject
1261 (theShapeWhat->GetStudyID(), theShapeWhat->GetEntry());
1263 if (aShapeWhere.IsNull() ||
1264 aShapeWhat.IsNull()) return aGEOMObject._retn();
1266 //Get Shapes in place of aShapeWhat
1267 Handle(GEOM_Object) anObject =
1268 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
1269 if (!GetOperations()->IsDone() || anObject.IsNull())
1270 return aGEOMObject._retn();
1272 return GetObject(anObject);