1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include "GEOM_IShapesOperations_i.hh"
27 #include "utilities.h"
29 #include "Utils_ExceptHandlers.hxx"
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
35 #include <TColStd_HSequenceOfTransient.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
41 * This function converts GEOM::comparison_condition type into
42 * GEOMUtils::ComparisonCondition type.
44 * \param theCondition the condition of GEOM::comparison_condition type
45 * \return the condition of GEOMUtils::ComparisonCondition type.
47 static GEOMUtils::ComparisonCondition ComparisonCondition
48 (const GEOM::comparison_condition theCondition)
50 GEOMUtils::ComparisonCondition aResult = GEOMUtils::CC_GT;
52 switch (theCondition) {
54 aResult = GEOMUtils::CC_GE;
57 aResult = GEOMUtils::CC_LT;
60 aResult = GEOMUtils::CC_LE;
69 //=============================================================================
73 //=============================================================================
74 GEOM_IShapesOperations_i::GEOM_IShapesOperations_i (PortableServer::POA_ptr thePOA,
75 GEOM::GEOM_Gen_ptr theEngine,
76 ::GEOMImpl_IShapesOperations* theImpl)
77 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
79 MESSAGE("GEOM_IShapesOperations_i::GEOM_IShapesOperations_i");
82 //=============================================================================
86 //=============================================================================
87 GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i()
89 MESSAGE("GEOM_IShapesOperations_i::~GEOM_IShapesOperations_i");
93 //=============================================================================
97 //=============================================================================
98 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdge
99 (GEOM::GEOM_Object_ptr thePnt1, GEOM::GEOM_Object_ptr thePnt2)
101 GEOM::GEOM_Object_var aGEOMObject;
103 //Set a not done flag
104 GetOperations()->SetNotDone();
106 //Get the reference points
107 Handle(::GEOM_Object) aPnt1 = GetObjectImpl(thePnt1);
108 Handle(::GEOM_Object) aPnt2 = GetObjectImpl(thePnt2);
110 if (aPnt1.IsNull() || aPnt2.IsNull()) return aGEOMObject._retn();
113 Handle(::GEOM_Object) anObject = GetOperations()->MakeEdge(aPnt1, aPnt2);
114 if (!GetOperations()->IsDone() || anObject.IsNull())
115 return aGEOMObject._retn();
117 return GetObject(anObject);
120 //=============================================================================
122 * MakeEdgeOnCurveByLength
124 //=============================================================================
125 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeOnCurveByLength
126 (GEOM::GEOM_Object_ptr theCurve,
127 CORBA::Double theLength,
128 GEOM::GEOM_Object_ptr theStartPoint)
130 GEOM::GEOM_Object_var aGEOMObject;
132 //Set a not done flag
133 GetOperations()->SetNotDone();
135 //Get the reference curve
136 Handle(::GEOM_Object) aRefCurve = GetObjectImpl(theCurve);
137 if (aRefCurve.IsNull()) return aGEOMObject._retn();
139 //Get the reference point (can be NULL)
140 Handle(::GEOM_Object) aRefPoint;
141 if (!CORBA::is_nil(theStartPoint)) {
142 aRefPoint = GetObjectImpl(theStartPoint);
146 Handle(::GEOM_Object) anObject =
147 GetOperations()->MakeEdgeOnCurveByLength(aRefCurve, theLength, aRefPoint);
148 if (!GetOperations()->IsDone() || anObject.IsNull())
149 return aGEOMObject._retn();
151 return GetObject(anObject);
154 //=============================================================================
158 //=============================================================================
159 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeEdgeWire
160 (GEOM::GEOM_Object_ptr theWire,
161 const CORBA::Double theLinearTolerance,
162 const CORBA::Double theAngularTolerance)
164 GEOM::GEOM_Object_var aGEOMObject;
166 //Set a not done flag
167 GetOperations()->SetNotDone();
169 //Get the source wire
170 Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
172 if (aWire.IsNull()) return aGEOMObject._retn();
175 Handle(::GEOM_Object) anObject = GetOperations()->MakeEdgeWire(aWire, theLinearTolerance, theAngularTolerance);
176 if (!GetOperations()->IsDone() || anObject.IsNull())
177 return aGEOMObject._retn();
179 return GetObject(anObject);
182 //=============================================================================
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
188 (const GEOM::ListOfGO& theEdgesAndWires,
189 const CORBA::Double theTolerance)
191 GEOM::GEOM_Object_var aGEOMObject;
193 //Set a not done flag
194 GetOperations()->SetNotDone();
197 std::list<Handle(::GEOM_Object)> aShapes;
200 aLen = theEdgesAndWires.length();
201 for (ind = 0; ind < aLen; ind++) {
202 Handle(::GEOM_Object) aSh = GetObjectImpl(theEdgesAndWires[ind]);
203 if (aSh.IsNull()) return aGEOMObject._retn();
204 aShapes.push_back(aSh);
208 Handle(::GEOM_Object) anObject =
209 GetOperations()->MakeWire(aShapes, theTolerance);
210 if (!GetOperations()->IsDone() || anObject.IsNull())
211 return aGEOMObject._retn();
213 return GetObject(anObject);
216 //=============================================================================
220 //=============================================================================
221 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFace
222 (GEOM::GEOM_Object_ptr theWire,
223 const CORBA::Boolean isPlanarWanted)
225 GEOM::GEOM_Object_var aGEOMObject;
227 //Set a not done flag
228 GetOperations()->SetNotDone();
230 //Get the reference wire
231 Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
232 if (aWire.IsNull()) return aGEOMObject._retn();
235 Handle(::GEOM_Object) anObject = GetOperations()->MakeFace(aWire, isPlanarWanted);
236 //if (!GetOperations()->IsDone() || anObject.IsNull())
237 // enable warning status
238 if (anObject.IsNull())
239 return aGEOMObject._retn();
241 return GetObject(anObject);
244 //=============================================================================
248 //=============================================================================
249 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWires
250 (const GEOM::ListOfGO& theWires,
251 const CORBA::Boolean isPlanarWanted)
253 GEOM::GEOM_Object_var aGEOMObject;
255 //Set a not done flag
256 GetOperations()->SetNotDone();
259 std::list<Handle(::GEOM_Object)> aShapes;
262 aLen = theWires.length();
263 for (ind = 0; ind < aLen; ind++) {
264 Handle(::GEOM_Object) aSh = GetObjectImpl(theWires[ind]);
265 if (aSh.IsNull()) return aGEOMObject._retn();
266 aShapes.push_back(aSh);
270 Handle(::GEOM_Object) anObject =
271 GetOperations()->MakeFaceWires(aShapes, isPlanarWanted);
272 //if (!GetOperations()->IsDone() || anObject.IsNull())
273 // enable warning status
274 if (anObject.IsNull())
275 return aGEOMObject._retn();
277 return GetObject(anObject);
280 //=============================================================================
282 * MakeFaceFromSurface
284 //=============================================================================
285 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceFromSurface
286 (GEOM::GEOM_Object_ptr theFace,
287 GEOM::GEOM_Object_ptr theWire)
289 GEOM::GEOM_Object_var aGEOMObject;
291 //Set a not done flag
292 GetOperations()->SetNotDone();
294 //Get the reference face and wire
295 Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
296 Handle(::GEOM_Object) aWire = GetObjectImpl(theWire);
298 if (aFace.IsNull() || aWire.IsNull()) {
299 return aGEOMObject._retn();
303 Handle(::GEOM_Object) anObject =
304 GetOperations()->MakeFaceFromSurface(aFace, aWire);
306 if (anObject.IsNull()) {
307 return aGEOMObject._retn();
310 return GetObject(anObject);
313 //=============================================================================
315 * MakeFaceWithConstraints
317 //=============================================================================
318 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeFaceWithConstraints
319 (const GEOM::ListOfGO& theConstraints)
321 GEOM::GEOM_Object_var aGEOMObject;
323 //Set a not done flag
324 GetOperations()->SetNotDone();
327 std::list<Handle(::GEOM_Object)> aConstraints;
328 for( CORBA::ULong ind = 0; ind < theConstraints.length(); ind++ ) {
329 Handle(::GEOM_Object) anObject = GetObjectImpl( theConstraints[ind] );
330 aConstraints.push_back(anObject);
334 Handle(::GEOM_Object) anObject =
335 GetOperations()->MakeFaceWithConstraints( aConstraints );
337 // enable warning status
338 if (anObject.IsNull())
339 return aGEOMObject._retn();
341 return GetObject(anObject);
344 //=============================================================================
348 //=============================================================================
349 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeShell
350 (const GEOM::ListOfGO& theFacesAndShells)
352 GEOM::GEOM_Object_var aGEOMObject;
354 //Set a not done flag
355 GetOperations()->SetNotDone();
358 std::list<Handle(::GEOM_Object)> aShapes;
361 aLen = theFacesAndShells.length();
362 for (ind = 0; ind < aLen; ind++) {
363 Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesAndShells[ind]);
364 if (aSh.IsNull()) return aGEOMObject._retn();
365 aShapes.push_back(aSh);
369 Handle(::GEOM_Object) anObject =
370 GetOperations()->MakeShell(aShapes);
371 if (!GetOperations()->IsDone() || anObject.IsNull())
372 return aGEOMObject._retn();
374 return GetObject(anObject);
377 //=============================================================================
381 //=============================================================================
382 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShell
383 (GEOM::GEOM_Object_ptr theShell)
385 GEOM::GEOM_Object_var aGEOMObject;
387 //Set a not done flag
388 GetOperations()->SetNotDone();
390 //Get the reference objects
391 Handle(::GEOM_Object) aShell = GetObjectImpl(theShell);
392 if (aShell.IsNull()) return aGEOMObject._retn();
394 std::list<Handle(::GEOM_Object)> aShapes;
395 aShapes.push_back(aShell);
398 Handle(::GEOM_Object) anObject = GetOperations()->MakeSolidShells(aShapes);
399 if (!GetOperations()->IsDone() || anObject.IsNull())
400 return aGEOMObject._retn();
402 return GetObject(anObject);
405 //=============================================================================
409 //=============================================================================
410 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidShells
411 (const GEOM::ListOfGO& theShells)
413 GEOM::GEOM_Object_var aGEOMObject;
415 //Set a not done flag
416 GetOperations()->SetNotDone();
419 std::list<Handle(::GEOM_Object)> aShapes;
422 aLen = theShells.length();
423 for (ind = 0; ind < aLen; ind++) {
424 Handle(::GEOM_Object) aSh = GetObjectImpl(theShells[ind]);
425 if (aSh.IsNull()) return aGEOMObject._retn();
426 aShapes.push_back(aSh);
430 Handle(::GEOM_Object) anObject =
431 GetOperations()->MakeSolidShells(aShapes);
432 if (!GetOperations()->IsDone() || anObject.IsNull())
433 return aGEOMObject._retn();
435 return GetObject(anObject);
438 //=============================================================================
442 //=============================================================================
443 GEOM::GEOM_Object_ptr
444 GEOM_IShapesOperations_i::MakeCompound (const GEOM::ListOfGO& theShapes)
446 GEOM::GEOM_Object_var aGEOMObject;
448 //Set a not done flag
449 GetOperations()->SetNotDone();
452 std::list<Handle(::GEOM_Object)> aShapes;
455 aLen = theShapes.length();
456 for (ind = 0; ind < aLen; ind++) {
457 Handle(::GEOM_Object) aSh = GetObjectImpl(theShapes[ind]);
458 if (aSh.IsNull()) return aGEOMObject._retn();
459 aShapes.push_back(aSh);
463 Handle(::GEOM_Object) anObject =
464 GetOperations()->MakeCompound(aShapes);
465 if (!GetOperations()->IsDone() || anObject.IsNull())
466 return aGEOMObject._retn();
468 return GetObject(anObject);
471 //=============================================================================
473 * MakeSolidFromConnectedFaces
475 //=============================================================================
476 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSolidFromConnectedFaces
477 (const GEOM::ListOfGO& theFacesOrShells,
478 const CORBA::Boolean isIntersect)
480 GEOM::GEOM_Object_var aGEOMObject;
482 //Set a not done flag
483 GetOperations()->SetNotDone();
486 std::list<Handle(::GEOM_Object)> aShapes;
489 aLen = theFacesOrShells.length();
490 for (ind = 0; ind < aLen; ind++) {
491 ::Handle(::GEOM_Object) aSh = GetObjectImpl(theFacesOrShells[ind]);
492 if (aSh.IsNull()) return aGEOMObject._retn();
493 aShapes.push_back(aSh);
497 Handle(::GEOM_Object) anObject =
498 GetOperations()->MakeSolidFromConnectedFaces(aShapes, isIntersect);
499 if (!GetOperations()->IsDone() || anObject.IsNull())
500 return aGEOMObject._retn();
502 return GetObject(anObject);
505 //=============================================================================
509 //=============================================================================
510 GEOM::GEOM_Object_ptr
511 GEOM_IShapesOperations_i::MakeGlueFaces (const GEOM::ListOfGO& theShapes,
512 CORBA::Double theTolerance,
513 CORBA::Boolean doKeepNonSolids)
515 GEOM::GEOM_Object_var aGEOMObject;
517 //Set a not done flag
518 GetOperations()->SetNotDone();
520 //Get the reference objects
521 std::list< Handle(::GEOM_Object) > aShapes;
522 if (! GetListOfObjectsImpl( theShapes, aShapes ))
523 return aGEOMObject._retn();
526 Handle(::GEOM_Object) anObject =
527 GetOperations()->MakeGlueFaces(aShapes, theTolerance, doKeepNonSolids);
528 //if (!GetOperations()->IsDone() || anObject.IsNull())
530 if (anObject.IsNull())
531 return aGEOMObject._retn();
533 return GetObject(anObject);
536 //=============================================================================
540 //=============================================================================
542 GEOM_IShapesOperations_i::GetGlueFaces (const GEOM::ListOfGO& theShapes,
543 const CORBA::Double theTolerance)
545 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
547 //Set a not done flag
548 GetOperations()->SetNotDone();
550 //Get the reference objects
551 std::list< Handle(::GEOM_Object) > aShapes;
552 if (! GetListOfObjectsImpl( theShapes, aShapes ))
555 Handle(TColStd_HSequenceOfTransient) aHSeq =
556 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_FACE);
558 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
563 Standard_Integer aLength = aHSeq->Length();
564 aSeq->length(aLength);
565 for (Standard_Integer i = 1; i <= aLength; i++)
566 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
571 //=============================================================================
573 * MakeGlueFacesByList
575 //=============================================================================
576 GEOM::GEOM_Object_ptr
577 GEOM_IShapesOperations_i::MakeGlueFacesByList (const GEOM::ListOfGO& theShapes,
578 CORBA::Double theTolerance,
579 const GEOM::ListOfGO& theFaces,
580 CORBA::Boolean doKeepNonSolids,
581 CORBA::Boolean doGlueAllEdges)
583 GEOM::GEOM_Object_var aGEOMObject;
585 //Set a not done flag
586 GetOperations()->SetNotDone();
588 //Get the reference objects
589 std::list< Handle(::GEOM_Object) > aShapes;
590 if (! GetListOfObjectsImpl( theShapes, aShapes ))
591 return aGEOMObject._retn();
594 std::list<Handle(::GEOM_Object)> aFaces;
595 if (! GetListOfObjectsImpl( theFaces, aFaces ))
596 return aGEOMObject._retn();
599 Handle(::GEOM_Object) anObject =
600 GetOperations()->MakeGlueFacesByList(aShapes, theTolerance, aFaces,
601 doKeepNonSolids, doGlueAllEdges);
602 //if (!GetOperations()->IsDone() || anObject.IsNull())
604 if (anObject.IsNull())
605 return aGEOMObject._retn();
607 return GetObject(anObject);
610 //=============================================================================
614 //=============================================================================
615 GEOM::GEOM_Object_ptr
616 GEOM_IShapesOperations_i::MakeGlueEdges (const GEOM::ListOfGO& theShapes,
617 CORBA::Double theTolerance)
619 GEOM::GEOM_Object_var aGEOMObject;
621 //Set a not done flag
622 GetOperations()->SetNotDone();
624 //Get the reference objects
625 std::list< Handle(::GEOM_Object) > aShapes;
626 if (! GetListOfObjectsImpl( theShapes, aShapes ))
627 return aGEOMObject._retn();
630 Handle(::GEOM_Object) anObject =
631 GetOperations()->MakeGlueEdges(aShapes, theTolerance);
632 //if (!GetOperations()->IsDone() || anObject.IsNull())
634 if (anObject.IsNull())
635 return aGEOMObject._retn();
637 return GetObject(anObject);
640 //=============================================================================
644 //=============================================================================
646 GEOM_IShapesOperations_i::GetGlueEdges (const GEOM::ListOfGO& theShapes,
647 const CORBA::Double theTolerance)
649 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
651 //Set a not done flag
652 GetOperations()->SetNotDone();
654 //Get the reference objects
655 std::list< Handle(::GEOM_Object) > aShapes;
656 if (! GetListOfObjectsImpl( theShapes, aShapes ))
659 Handle(TColStd_HSequenceOfTransient) aHSeq =
660 GetOperations()->GetGlueShapes(aShapes, theTolerance, TopAbs_EDGE);
662 //if (!GetOperations()->IsDone() || aHSeq.IsNull())
667 Standard_Integer aLength = aHSeq->Length();
668 aSeq->length(aLength);
669 for (Standard_Integer i = 1; i <= aLength; i++)
670 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
675 //=============================================================================
677 * MakeGlueEdgesByList
679 //=============================================================================
680 GEOM::GEOM_Object_ptr
681 GEOM_IShapesOperations_i::MakeGlueEdgesByList (const GEOM::ListOfGO& theShapes,
682 CORBA::Double theTolerance,
683 const GEOM::ListOfGO& theEdges)
685 GEOM::GEOM_Object_var aGEOMObject;
687 //Set a not done flag
688 GetOperations()->SetNotDone();
690 //Get the reference objects
691 std::list< Handle(::GEOM_Object) > aShapes;
692 if (! GetListOfObjectsImpl( theShapes, aShapes ))
693 return aGEOMObject._retn();
696 std::list<Handle(::GEOM_Object)> anEdges;
697 if (! GetListOfObjectsImpl( theEdges, anEdges ))
698 return aGEOMObject._retn();
701 Handle(::GEOM_Object) anObject =
702 GetOperations()->MakeGlueEdgesByList(aShapes, theTolerance, anEdges);
703 //if (!GetOperations()->IsDone() || anObject.IsNull())
705 if (anObject.IsNull())
706 return aGEOMObject._retn();
708 return GetObject(anObject);
711 //=============================================================================
713 * GetExistingSubObjects
715 //=============================================================================
717 GEOM_IShapesOperations_i::GetExistingSubObjects (GEOM::GEOM_Object_ptr theShape,
718 CORBA::Boolean theGroupsOnly)
720 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
722 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
723 if (aShape.IsNull()) return aSeq._retn();
725 Handle(TColStd_HSequenceOfTransient) aHSeq =
726 GetOperations()->GetExistingSubObjects(aShape, (Standard_Boolean)theGroupsOnly);
727 if (!GetOperations()->IsDone() || aHSeq.IsNull())
730 Standard_Integer aLength = aHSeq->Length();
731 aSeq->length(aLength);
732 for (Standard_Integer i = 1; i <= aLength; i++)
733 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
738 //=============================================================================
740 * MakeExplode (including theShape itself, bad sorting)
742 //=============================================================================
743 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeExplode (GEOM::GEOM_Object_ptr theShape,
744 const CORBA::Long theShapeType,
745 const CORBA::Boolean isSorted)
747 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
749 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
750 if (aShape.IsNull()) return aSeq._retn();
752 Handle(TColStd_HSequenceOfTransient) aHSeq =
753 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
754 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
755 if (!GetOperations()->IsDone() || aHSeq.IsNull())
758 Standard_Integer aLength = aHSeq->Length();
759 aSeq->length(aLength);
760 for (Standard_Integer i = 1; i <= aLength; i++)
761 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
766 //=============================================================================
768 * MakeAllSubShapes (including theShape itself, good sorting)
770 //=============================================================================
771 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeAllSubShapes (GEOM::GEOM_Object_ptr theShape,
772 const CORBA::Long theShapeType,
773 const CORBA::Boolean isSorted)
775 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
777 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
778 if (aShape.IsNull()) return aSeq._retn();
780 Handle(TColStd_HSequenceOfTransient) aHSeq =
781 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
782 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
783 if (!GetOperations()->IsDone() || aHSeq.IsNull())
786 Standard_Integer aLength = aHSeq->Length();
787 aSeq->length(aLength);
788 for (Standard_Integer i = 1; i <= aLength; i++)
789 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
794 //=============================================================================
796 * ExtractSubShapes (excluding theShape itself, good sorting)
798 //=============================================================================
799 GEOM::ListOfGO* GEOM_IShapesOperations_i::ExtractSubShapes (GEOM::GEOM_Object_ptr theShape,
800 const CORBA::Long theShapeType,
801 const CORBA::Boolean isSorted)
803 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
805 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
806 if (aShape.IsNull()) return aSeq._retn();
808 Handle(TColStd_HSequenceOfTransient) aHSeq =
809 // TODO: enum instead of bool for the last argument
810 GetOperations()->MakeExplode(aShape, theShapeType, isSorted,
811 GEOMImpl_IShapesOperations::EXPLODE_NEW_EXCLUDE_MAIN);
812 if (!GetOperations()->IsDone() || aHSeq.IsNull())
815 Standard_Integer aLength = aHSeq->Length();
816 aSeq->length(aLength);
817 for (Standard_Integer i = 1; i <= aLength; i++)
818 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
823 //=============================================================================
827 //=============================================================================
828 GEOM::ListOfLong* GEOM_IShapesOperations_i::SubShapeAllIDs (GEOM::GEOM_Object_ptr theShape,
829 const CORBA::Long theShapeType,
830 const CORBA::Boolean isSorted)
832 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
834 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
835 if (aShape.IsNull()) return aSeq._retn();
837 Handle(TColStd_HSequenceOfInteger) aHSeq =
838 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
839 GEOMImpl_IShapesOperations::EXPLODE_OLD_INCLUDE_MAIN);
840 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
842 Standard_Integer aLength = aHSeq->Length();
843 aSeq->length(aLength);
844 for (Standard_Integer i = 1; i <= aLength; i++)
845 aSeq[i-1] = aHSeq->Value(i);
850 //=============================================================================
854 //=============================================================================
855 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetAllSubShapesIDs (GEOM::GEOM_Object_ptr theShape,
856 const CORBA::Long theShapeType,
857 const CORBA::Boolean isSorted)
859 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
861 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
862 if (aShape.IsNull()) return aSeq._retn();
864 Handle(TColStd_HSequenceOfInteger) aHSeq =
865 GetOperations()->SubShapeAllIDs(aShape, theShapeType, isSorted,
866 GEOMImpl_IShapesOperations::EXPLODE_NEW_INCLUDE_MAIN);
867 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
869 Standard_Integer aLength = aHSeq->Length();
870 aSeq->length(aLength);
871 for (Standard_Integer i = 1; i <= aLength; i++)
872 aSeq[i-1] = aHSeq->Value(i);
877 //=============================================================================
881 //=============================================================================
882 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
883 (GEOM::GEOM_Object_ptr theMainShape,
884 const CORBA::Long theID)
886 GEOM::GEOM_Object_var aGEOMObject;
888 //Set a not done flag
889 GetOperations()->SetNotDone();
891 //Get the reference objects
892 Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
893 if (aShape.IsNull()) return aGEOMObject._retn();
895 Handle(::GEOM_Object) anObject = GetOperations()->GetSubShape(aShape, theID);
896 if (!GetOperations()->IsDone() || anObject.IsNull())
897 return aGEOMObject._retn();
899 return GetObject(anObject);
902 //=============================================================================
906 //=============================================================================
907 GEOM::ListOfGO* GEOM_IShapesOperations_i::MakeSubShapes (GEOM::GEOM_Object_ptr theMainShape,
908 const GEOM::ListOfLong& theIndices)
910 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
912 //Set a not done flag
913 GetOperations()->SetNotDone();
915 if (theIndices.length() < 1)
918 Handle(::GEOM_Object) aShape = GetObjectImpl(theMainShape);
919 if (aShape.IsNull()) return aSeq._retn();
921 Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, theIndices.length());
922 for (CORBA::ULong i = 0; i < theIndices.length(); i++)
923 anArray->SetValue(i+1, theIndices[i]);
925 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->MakeSubShapes(aShape, anArray);
926 if (!GetOperations()->IsDone() || aHSeq.IsNull())
929 Standard_Integer aLength = aHSeq->Length();
930 aSeq->length(aLength);
931 for (int i = 0; i < aLength; i++)
932 aSeq[i] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i+1)));
937 //=============================================================================
941 //=============================================================================
942 CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex
943 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
945 //Get the reference shapes
946 Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
947 Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
949 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
951 //Get the unique ID of <theSubShape> inside <theMainShape>
952 CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef);
953 if (!GetOperations()->IsDone())
959 //=============================================================================
961 * GetSubShapesIndices
963 //=============================================================================
964 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSubShapesIndices
965 (GEOM::GEOM_Object_ptr theMainShape, const GEOM::ListOfGO& theSubShapes)
967 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
969 //Get the reference main shape
970 Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
971 if (aMainShapeRef.IsNull()) return aSeq._retn();
974 std::list<Handle(::GEOM_Object)> aShapes;
975 int aLen = theSubShapes.length();
976 for (int ind = 0; ind < aLen; ind++) {
977 Handle(::GEOM_Object) aSh = GetObjectImpl(theSubShapes[ind]);
980 MESSAGE("NULL shape");
983 aShapes.push_back(aSh);
986 //Get the IDs of <theSubShapes> inside <theMainShape>
987 Handle(TColStd_HSequenceOfInteger) aHSeq =
988 GetOperations()->GetSubShapesIndices(aMainShapeRef, aShapes);
990 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
992 Standard_Integer aLength = aHSeq->Length();
993 aSeq->length(aLength);
995 for (Standard_Integer i = 1; i <= aLength; i++)
996 aSeq[i-1] = aHSeq->Value(i);
1002 //=============================================================================
1006 //=============================================================================
1007 CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex
1008 (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape)
1010 //Get the reference shapes
1011 Handle(::GEOM_Object) aMainShapeRef = GetObjectImpl(theMainShape);
1012 Handle(::GEOM_Object) aSubShapeRef = GetObjectImpl(theSubShape);
1014 if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1;
1016 //Get an ID of <theSubShape>, unique among all sub-shapes of <theMainShape> of the same type
1017 CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef);
1018 if (!GetOperations()->IsDone())
1024 //=============================================================================
1026 * GetShapeTypeString
1028 //=============================================================================
1029 char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape)
1031 //Get the reference shape
1032 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1033 if (aShape.IsNull()) return NULL;
1035 // Get shape parameters
1036 TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape);
1037 return CORBA::string_dup(aDescription.ToCString());
1040 //=============================================================================
1042 * IsSubShapeBelongsTo
1044 //=============================================================================
1045 CORBA::Boolean GEOM_IShapesOperations_i::IsSubShapeBelongsTo( GEOM::GEOM_Object_ptr theSubObject,
1046 const CORBA::Long theSubObjectIndex,
1047 GEOM::GEOM_Object_ptr theObject,
1048 const CORBA::Long theObjectIndex)
1050 Handle(::GEOM_Object) aSubObject = GetObjectImpl( theSubObject );
1051 Handle(::GEOM_Object) anObject = GetObjectImpl( theObject );
1052 if( anObject.IsNull() || aSubObject.IsNull() )
1056 return GetOperations()->IsSubShapeBelongsTo( aSubObject, theSubObjectIndex, anObject, theObjectIndex );
1059 //=============================================================================
1063 //=============================================================================
1064 CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
1066 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
1069 //=============================================================================
1073 //=============================================================================
1074 CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
1076 return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
1079 //=============================================================================
1083 //=============================================================================
1084 CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
1085 const CORBA::Long theShapeType)
1087 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1088 if (aShape.IsNull()) return -1;
1090 CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
1091 if (!GetOperations()->IsDone()) return -1;
1096 //=============================================================================
1100 //=============================================================================
1101 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
1102 (GEOM::GEOM_Object_ptr theShape)
1104 GEOM::GEOM_Object_var aGEOMObject;
1106 //Set a not done flag
1107 GetOperations()->SetNotDone();
1109 //Get the reference objects
1110 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1111 if (aShape.IsNull()) return aGEOMObject._retn();
1114 Handle(::GEOM_Object) anObject = GetOperations()->ReverseShape(aShape);
1115 if (!GetOperations()->IsDone() || anObject.IsNull())
1116 return aGEOMObject._retn();
1118 return GetObject(anObject);
1121 //=============================================================================
1125 //=============================================================================
1126 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
1128 //Set a not done flag
1129 GetOperations()->SetNotDone();
1131 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1133 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1134 if (aShape.IsNull()) return aSeq._retn();
1136 Handle(TColStd_HSequenceOfInteger) aHSeq =
1137 GetOperations()->GetFreeFacesIDs(aShape);
1138 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
1140 Standard_Integer aLength = aHSeq->Length();
1141 aSeq->length(aLength);
1142 for (Standard_Integer i = 1; i <= aLength; i++)
1143 aSeq[i-1] = aHSeq->Value(i);
1145 return aSeq._retn();
1148 //=============================================================================
1152 //=============================================================================
1153 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
1154 (GEOM::GEOM_Object_ptr theShape1,
1155 GEOM::GEOM_Object_ptr theShape2,
1156 const CORBA::Long theShapeType)
1158 //Set a not done flag
1159 GetOperations()->SetNotDone();
1161 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1163 Handle(::GEOM_Object) aShape1 = GetObjectImpl(theShape1);
1164 Handle(::GEOM_Object) aShape2 = GetObjectImpl(theShape2);
1166 if (aShape1.IsNull() || aShape2.IsNull()) return aSeq._retn();
1168 Handle(TColStd_HSequenceOfTransient) aHSeq =
1169 GetOperations()->GetSharedShapes(aShape1, aShape2, theShapeType);
1170 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1171 return aSeq._retn();
1173 Standard_Integer aLength = aHSeq->Length();
1174 aSeq->length(aLength);
1175 for (Standard_Integer i = 1; i <= aLength; i++)
1176 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1178 return aSeq._retn();
1181 //=============================================================================
1183 * GetSharedShapesMulti
1185 //=============================================================================
1186 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapesMulti
1187 (const GEOM::ListOfGO& theShapes,
1188 const CORBA::Long theShapeType,
1189 CORBA::Boolean theMultiShare)
1191 //Set a not done flag
1192 GetOperations()->SetNotDone();
1194 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1197 std::list<Handle(::GEOM_Object)> aShapes;
1198 if (! GetListOfObjectsImpl( theShapes, aShapes ))
1199 return aSeq._retn();
1201 Handle(TColStd_HSequenceOfTransient) aHSeq =
1202 GetOperations()->GetSharedShapes(aShapes, theShapeType, theMultiShare);
1203 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1204 return aSeq._retn();
1206 Standard_Integer aLength = aHSeq->Length();
1207 aSeq->length(aLength);
1208 for (Standard_Integer i = 1; i <= aLength; i++)
1209 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1211 return aSeq._retn();
1214 static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
1216 GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
1220 aState = GEOMAlgo_ST_ON;
1223 aState = GEOMAlgo_ST_OUT;
1225 case GEOM::ST_ONOUT:
1226 aState = GEOMAlgo_ST_ONOUT;
1229 aState = GEOMAlgo_ST_IN;
1232 aState = GEOMAlgo_ST_ONIN;
1241 //=============================================================================
1245 //=============================================================================
1246 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
1247 (GEOM::GEOM_Object_ptr theShape,
1248 const CORBA::Long theShapeType,
1249 GEOM::GEOM_Object_ptr theAx1,
1250 const GEOM::shape_state theState)
1252 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1254 //Set a not done flag
1255 GetOperations()->SetNotDone();
1257 //Get the reference objects
1258 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1259 Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1261 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1263 //Get Shapes On Plane
1264 Handle(TColStd_HSequenceOfTransient) aHSeq =
1265 GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
1266 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1267 return aSeq._retn();
1269 Standard_Integer aLength = aHSeq->Length();
1270 aSeq->length(aLength);
1271 for (Standard_Integer i = 1; i <= aLength; i++)
1272 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1274 return aSeq._retn();
1277 //=============================================================================
1279 * GetShapesOnPlaneWithLocation
1281 //=============================================================================
1282 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocation
1283 (GEOM::GEOM_Object_ptr theShape,
1284 const CORBA::Long theShapeType,
1285 GEOM::GEOM_Object_ptr theAx1,
1286 GEOM::GEOM_Object_ptr thePnt,
1287 const GEOM::shape_state theState)
1289 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1291 //Set a not done flag
1292 GetOperations()->SetNotDone();
1294 //Get the reference objects
1295 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1296 Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1297 Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
1299 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1301 //Get Shapes On Plane
1302 Handle(TColStd_HSequenceOfTransient) aHSeq =
1303 GetOperations()->GetShapesOnPlaneWithLocation(aShape, theShapeType, anAx1, anPnt, ShapeState(theState));
1304 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1305 return aSeq._retn();
1307 Standard_Integer aLength = aHSeq->Length();
1308 aSeq->length(aLength);
1309 for (Standard_Integer i = 1; i <= aLength; i++)
1310 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1312 return aSeq._retn();
1315 //=============================================================================
1317 * GetShapesOnCylinder
1319 //=============================================================================
1320 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
1321 (GEOM::GEOM_Object_ptr theShape,
1322 const CORBA::Long theShapeType,
1323 GEOM::GEOM_Object_ptr theAxis,
1324 const CORBA::Double theRadius,
1325 const GEOM::shape_state theState)
1327 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1329 //Set a not done flag
1330 GetOperations()->SetNotDone();
1332 //Get the reference objects
1333 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1334 Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1336 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1338 //Get Shapes On Cylinder
1339 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
1340 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1341 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1342 return aSeq._retn();
1344 Standard_Integer aLength = aHSeq->Length();
1345 aSeq->length(aLength);
1346 for (Standard_Integer i = 1; i <= aLength; i++)
1347 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1349 return aSeq._retn();
1352 //=============================================================================
1354 * GetShapesOnCylinderWithLocation
1356 //=============================================================================
1357 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
1358 (GEOM::GEOM_Object_ptr theShape,
1359 const CORBA::Long theShapeType,
1360 GEOM::GEOM_Object_ptr theAxis,
1361 GEOM::GEOM_Object_ptr thePnt,
1362 const CORBA::Double theRadius,
1363 const GEOM::shape_state theState)
1365 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1367 //Set a not done flag
1368 GetOperations()->SetNotDone();
1370 //Get the reference objects
1371 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1372 Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1373 Handle(::GEOM_Object) aPnt = GetObjectImpl(thePnt);
1375 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1377 //Get Shapes On Cylinder
1378 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
1379 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1380 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1381 return aSeq._retn();
1383 Standard_Integer aLength = aHSeq->Length();
1384 aSeq->length(aLength);
1385 for (Standard_Integer i = 1; i <= aLength; i++)
1386 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1388 return aSeq._retn();
1391 //=============================================================================
1395 //=============================================================================
1396 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
1397 (GEOM::GEOM_Object_ptr theShape,
1398 const CORBA::Long theShapeType,
1399 GEOM::GEOM_Object_ptr theCenter,
1400 const CORBA::Double theRadius,
1401 const GEOM::shape_state theState)
1403 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1405 //Set a not done flag
1406 GetOperations()->SetNotDone();
1408 //Get the reference objects
1409 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1410 Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
1412 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1414 //Get Shapes On Sphere
1415 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
1416 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1417 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1418 return aSeq._retn();
1420 Standard_Integer aLength = aHSeq->Length();
1421 aSeq->length(aLength);
1422 for (Standard_Integer i = 1; i <= aLength; i++)
1423 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1425 return aSeq._retn();
1428 //=============================================================================
1430 * GetShapesOnQuadrangle
1432 //=============================================================================
1433 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnQuadrangle
1434 (GEOM::GEOM_Object_ptr theShape,
1435 CORBA::Long theShapeType,
1436 GEOM::GEOM_Object_ptr theTopLeftPoint,
1437 GEOM::GEOM_Object_ptr theTopRightPoint,
1438 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1439 GEOM::GEOM_Object_ptr theBottomRightPoint,
1440 GEOM::shape_state theState)
1442 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1444 //Set a not done flag
1445 GetOperations()->SetNotDone();
1447 //Get the reference objects
1448 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1449 Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1450 Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
1451 Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1452 Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
1454 if (aShape.IsNull() ||
1455 aTopLeftPoint.IsNull() ||
1456 aTopRightPoint.IsNull() ||
1457 aBottomLeftPoint.IsNull() ||
1458 aBottomRightPoint.IsNull())
1459 return aSeq._retn();
1461 //Get Shapes On Quadrangle
1462 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnQuadrangle
1463 (aShape, theShapeType,
1464 aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
1465 ShapeState(theState));
1466 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1467 return aSeq._retn();
1469 Standard_Integer aLength = aHSeq->Length();
1470 aSeq->length(aLength);
1471 for (Standard_Integer i = 1; i <= aLength; i++)
1472 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1474 return aSeq._retn();
1477 //=============================================================================
1479 * GetShapesOnPlaneIDs
1481 //=============================================================================
1482 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneIDs
1483 (GEOM::GEOM_Object_ptr theShape,
1484 const CORBA::Long theShapeType,
1485 GEOM::GEOM_Object_ptr theAx1,
1486 const GEOM::shape_state theState)
1488 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1490 //Set a not done flag
1491 GetOperations()->SetNotDone();
1493 //Get the reference objects
1494 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1495 Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1497 if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
1499 //Get Shapes On Plane
1500 Handle(TColStd_HSequenceOfInteger) aHSeq =
1501 GetOperations()->GetShapesOnPlaneIDs(aShape, theShapeType, anAx1, ShapeState(theState));
1502 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1503 return aSeq._retn();
1505 Standard_Integer aLength = aHSeq->Length();
1506 aSeq->length(aLength);
1507 for (Standard_Integer i = 1; i <= aLength; i++)
1508 aSeq[i-1] = aHSeq->Value(i);
1510 return aSeq._retn();
1513 //=============================================================================
1515 * GetShapesOnPlaneWithLocationIDs
1517 //=============================================================================
1518 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnPlaneWithLocationIDs
1519 (GEOM::GEOM_Object_ptr theShape,
1520 const CORBA::Long theShapeType,
1521 GEOM::GEOM_Object_ptr theAx1,
1522 GEOM::GEOM_Object_ptr thePnt,
1523 const GEOM::shape_state theState)
1525 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1527 //Set a not done flag
1528 GetOperations()->SetNotDone();
1530 //Get the reference objects
1531 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1532 Handle(::GEOM_Object) anAx1 = GetObjectImpl(theAx1);
1533 Handle(::GEOM_Object) anPnt = GetObjectImpl(thePnt);
1535 if (aShape.IsNull() || anAx1.IsNull() || anPnt.IsNull()) return aSeq._retn();
1537 //Get Shapes On Plane
1538 Handle(TColStd_HSequenceOfInteger) aHSeq =
1539 GetOperations()->GetShapesOnPlaneWithLocationIDs(aShape, theShapeType,
1540 anAx1, anPnt, ShapeState(theState));
1541 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1542 return aSeq._retn();
1544 Standard_Integer aLength = aHSeq->Length();
1545 aSeq->length(aLength);
1546 for (Standard_Integer i = 1; i <= aLength; i++)
1547 aSeq[i-1] = aHSeq->Value(i);
1549 return aSeq._retn();
1552 //=============================================================================
1554 * GetShapesOnCylinderIDs
1556 //=============================================================================
1557 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
1558 (GEOM::GEOM_Object_ptr theShape,
1559 const CORBA::Long theShapeType,
1560 GEOM::GEOM_Object_ptr theAxis,
1561 const CORBA::Double theRadius,
1562 const GEOM::shape_state theState)
1564 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1566 //Set a not done flag
1567 GetOperations()->SetNotDone();
1569 //Get the reference objects
1570 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1571 Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1573 if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
1575 //Get Shapes On Cylinder
1576 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderIDs
1577 (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
1578 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1579 return aSeq._retn();
1581 Standard_Integer aLength = aHSeq->Length();
1582 aSeq->length(aLength);
1583 for (Standard_Integer i = 1; i <= aLength; i++)
1584 aSeq[i-1] = aHSeq->Value(i);
1586 return aSeq._retn();
1589 //=============================================================================
1591 * GetShapesOnCylinderWithLocationIDs
1593 //=============================================================================
1594 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
1595 (GEOM::GEOM_Object_ptr theShape,
1596 const CORBA::Long theShapeType,
1597 GEOM::GEOM_Object_ptr theAxis,
1598 GEOM::GEOM_Object_ptr thePnt,
1599 const CORBA::Double theRadius,
1600 const GEOM::shape_state theState)
1602 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1604 //Set a not done flag
1605 GetOperations()->SetNotDone();
1607 //Get the reference objects
1608 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1609 Handle(::GEOM_Object) anAxis = GetObjectImpl(theAxis);
1610 Handle(::GEOM_Object) aPnt = GetObjectImpl(thePnt);
1612 if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
1614 //Get Shapes On Cylinder
1615 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
1616 (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
1617 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1618 return aSeq._retn();
1620 Standard_Integer aLength = aHSeq->Length();
1621 aSeq->length(aLength);
1622 for (Standard_Integer i = 1; i <= aLength; i++)
1623 aSeq[i-1] = aHSeq->Value(i);
1625 return aSeq._retn();
1628 //=============================================================================
1630 * GetShapesOnSphereIDs
1632 //=============================================================================
1633 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnSphereIDs
1634 (GEOM::GEOM_Object_ptr theShape,
1635 const CORBA::Long theShapeType,
1636 GEOM::GEOM_Object_ptr theCenter,
1637 const CORBA::Double theRadius,
1638 const GEOM::shape_state theState)
1640 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1642 //Set a not done flag
1643 GetOperations()->SetNotDone();
1645 //Get the reference objects
1646 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1647 Handle(::GEOM_Object) aCenter = GetObjectImpl(theCenter);
1649 if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
1651 //Get Shapes On Sphere
1652 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnSphereIDs
1653 (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
1654 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1655 return aSeq._retn();
1657 Standard_Integer aLength = aHSeq->Length();
1658 aSeq->length(aLength);
1659 for (Standard_Integer i = 1; i <= aLength; i++)
1660 aSeq[i-1] = aHSeq->Value(i);
1662 return aSeq._retn();
1665 //=============================================================================
1667 * GetShapesOnQuadrangleIDs
1669 //=============================================================================
1670 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnQuadrangleIDs
1671 (GEOM::GEOM_Object_ptr theShape,
1672 CORBA::Long theShapeType,
1673 GEOM::GEOM_Object_ptr theTopLeftPoint,
1674 GEOM::GEOM_Object_ptr theTopRightPoint,
1675 GEOM::GEOM_Object_ptr theBottomLeftPoint,
1676 GEOM::GEOM_Object_ptr theBottomRightPoint,
1677 GEOM::shape_state theState)
1679 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1681 //Set a not done flag
1682 GetOperations()->SetNotDone();
1684 //Get the reference objects
1685 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1686 Handle(::GEOM_Object) aTopLeftPoint = GetObjectImpl(theTopLeftPoint);
1687 Handle(::GEOM_Object) aTopRightPoint = GetObjectImpl(theTopRightPoint);
1688 Handle(::GEOM_Object) aBottomLeftPoint = GetObjectImpl(theBottomLeftPoint);
1689 Handle(::GEOM_Object) aBottomRightPoint = GetObjectImpl(theBottomRightPoint);
1691 if (aShape.IsNull() ||
1692 aTopLeftPoint.IsNull() ||
1693 aTopRightPoint.IsNull() ||
1694 aBottomLeftPoint.IsNull() ||
1695 aBottomRightPoint.IsNull() )
1696 return aSeq._retn();
1698 //Get Shapes On Quadrangle
1699 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnQuadrangleIDs
1700 (aShape, theShapeType,
1701 aTopLeftPoint, aTopRightPoint, aBottomLeftPoint, aBottomRightPoint,
1702 ShapeState(theState));
1703 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1704 return aSeq._retn();
1706 Standard_Integer aLength = aHSeq->Length();
1707 aSeq->length(aLength);
1708 for (Standard_Integer i = 1; i <= aLength; i++)
1709 aSeq[i-1] = aHSeq->Value(i);
1711 return aSeq._retn();
1714 //=============================================================================
1718 //=============================================================================
1719 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnBox
1720 (GEOM::GEOM_Object_ptr theBox,
1721 GEOM::GEOM_Object_ptr theShape,
1722 CORBA::Long theShapeType,
1723 GEOM::shape_state theState)
1725 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1727 //Set a not done flag
1728 GetOperations()->SetNotDone();
1730 //Get the reference objects
1731 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1732 Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
1734 if (aShape.IsNull() || aBox.IsNull() )
1735 return aSeq._retn();
1738 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnBox
1739 (aBox,aShape, theShapeType,ShapeState(theState));
1740 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1741 return aSeq._retn();
1743 Standard_Integer aLength = aHSeq->Length();
1744 aSeq->length(aLength);
1745 for (Standard_Integer i = 1; i <= aLength; i++)
1746 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1748 return aSeq._retn();
1751 //=============================================================================
1753 * GetShapesOnQuadrangleIDs
1755 //=============================================================================
1756 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnBoxIDs
1757 (GEOM::GEOM_Object_ptr theBox,
1758 GEOM::GEOM_Object_ptr theShape,
1759 CORBA::Long theShapeType,
1760 GEOM::shape_state theState)
1762 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1764 //Set a not done flag
1765 GetOperations()->SetNotDone();
1767 //Get the reference objects
1768 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1769 Handle(::GEOM_Object) aBox = GetObjectImpl(theBox);
1771 if (aShape.IsNull() || aBox.IsNull() )
1772 return aSeq._retn();
1775 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnBoxIDs
1776 (aBox,aShape, theShapeType,ShapeState(theState));
1777 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1778 return aSeq._retn();
1780 Standard_Integer aLength = aHSeq->Length();
1781 aSeq->length(aLength);
1782 for (Standard_Integer i = 1; i <= aLength; i++)
1783 aSeq[i-1] = aHSeq->Value(i);
1785 return aSeq._retn();
1789 //=============================================================================
1793 //=============================================================================
1794 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnShape
1795 (GEOM::GEOM_Object_ptr theCheckShape,
1796 GEOM::GEOM_Object_ptr theShape,
1797 CORBA::Short theShapeType,
1798 GEOM::shape_state theState)
1800 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
1802 //Set a not done flag
1803 GetOperations()->SetNotDone();
1805 //Get the reference objects
1806 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1807 Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1809 if (aShape.IsNull() || aCheckShape.IsNull() )
1810 return aSeq._retn();
1812 //Get Shapes On Shape
1813 Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnShape
1814 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1816 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1817 return aSeq._retn();
1819 Standard_Integer aLength = aHSeq->Length();
1820 aSeq->length(aLength);
1821 for (Standard_Integer i = 1; i <= aLength; i++)
1822 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
1824 return aSeq._retn();
1828 //=============================================================================
1830 * GetShapesOnShapeAsCompound
1832 //=============================================================================
1833 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnShapeAsCompound
1834 (GEOM::GEOM_Object_ptr theCheckShape,
1835 GEOM::GEOM_Object_ptr theShape,
1836 CORBA::Short theShapeType,
1837 GEOM::shape_state theState)
1839 GEOM::GEOM_Object_var aGEOMObject;
1841 //Set a not done flag
1842 GetOperations()->SetNotDone();
1844 //Get the reference objects
1845 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1846 Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1848 if (aShape.IsNull() || aCheckShape.IsNull() )
1849 return aGEOMObject._retn();
1851 //Get Shapes On Shape
1852 Handle(::GEOM_Object) anObject = GetOperations()->GetShapesOnShapeAsCompound
1853 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1855 if (anObject.IsNull())
1856 return aGEOMObject._retn();
1858 return GetObject(anObject);
1862 //=============================================================================
1864 * GetShapesOnShapeIDs
1866 //=============================================================================
1867 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnShapeIDs
1868 (GEOM::GEOM_Object_ptr theCheckShape,
1869 GEOM::GEOM_Object_ptr theShape,
1870 CORBA::Short theShapeType,
1871 GEOM::shape_state theState)
1873 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
1875 //Set a not done flag
1876 GetOperations()->SetNotDone();
1878 //Get the reference objects
1879 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
1880 Handle(::GEOM_Object) aCheckShape = GetObjectImpl(theCheckShape);
1882 if (aShape.IsNull() || aCheckShape.IsNull() )
1883 return aSeq._retn();
1885 //Get Shapes On Shape
1886 Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnShapeIDs
1887 (aCheckShape,aShape, theShapeType,ShapeState(theState));
1888 if (!GetOperations()->IsDone() || aHSeq.IsNull())
1889 return aSeq._retn();
1891 Standard_Integer aLength = aHSeq->Length();
1892 aSeq->length(aLength);
1893 for (Standard_Integer i = 1; i <= aLength; i++)
1894 aSeq[i-1] = aHSeq->Value(i);
1896 return aSeq._retn();
1900 //=============================================================================
1904 //=============================================================================
1905 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlace
1906 (GEOM::GEOM_Object_ptr theShapeWhere,
1907 GEOM::GEOM_Object_ptr theShapeWhat)
1909 GEOM::GEOM_Object_var aGEOMObject;
1911 //Set a not done flag
1912 GetOperations()->SetNotDone();
1914 //Get the reference objects
1915 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1916 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1918 if (aShapeWhere.IsNull() ||
1919 aShapeWhat.IsNull()) return aGEOMObject._retn();
1921 //Get Shapes in place of aShapeWhat
1922 Handle(::GEOM_Object) anObject =
1923 GetOperations()->GetInPlace(aShapeWhere, aShapeWhat);
1924 if (!GetOperations()->IsDone() || anObject.IsNull())
1925 return aGEOMObject._retn();
1927 return GetObject(anObject);
1930 //=============================================================================
1934 //=============================================================================
1935 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceOld
1936 (GEOM::GEOM_Object_ptr theShapeWhere,
1937 GEOM::GEOM_Object_ptr theShapeWhat)
1939 GEOM::GEOM_Object_var aGEOMObject;
1941 //Set a not done flag
1942 GetOperations()->SetNotDone();
1944 //Get the reference objects
1945 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1946 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1948 if (aShapeWhere.IsNull() ||
1949 aShapeWhat.IsNull()) return aGEOMObject._retn();
1951 //Get Shapes in place of aShapeWhat
1952 Handle(::GEOM_Object) anObject =
1953 GetOperations()->GetInPlaceOld(aShapeWhere, aShapeWhat);
1954 if (!GetOperations()->IsDone() || anObject.IsNull())
1955 return aGEOMObject._retn();
1957 return GetObject(anObject);
1960 //=============================================================================
1962 * GetInPlaceByHistory
1964 //=============================================================================
1965 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetInPlaceByHistory
1966 (GEOM::GEOM_Object_ptr theShapeWhere,
1967 GEOM::GEOM_Object_ptr theShapeWhat)
1969 GEOM::GEOM_Object_var aGEOMObject;
1971 //Set a not done flag
1972 GetOperations()->SetNotDone();
1974 //Get the reference objects
1975 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
1976 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
1978 if (aShapeWhere.IsNull() ||
1979 aShapeWhat.IsNull()) return aGEOMObject._retn();
1981 //Get Shapes in place of aShapeWhat
1982 Handle(::GEOM_Object) anObject =
1983 GetOperations()->GetInPlaceByHistory(aShapeWhere, aShapeWhat);
1984 if (!GetOperations()->IsDone() || anObject.IsNull())
1985 return aGEOMObject._retn();
1987 return GetObject(anObject);
1990 //=============================================================================
1994 //=============================================================================
1995 GEOM::ListOfListOfLong*
1996 GEOM_IShapesOperations_i::GetInPlaceMap (GEOM::GEOM_Object_ptr theShapeWhere,
1997 GEOM::GEOM_Object_ptr theShapeWhat)
1999 GEOM::ListOfListOfLong_var aResult = new GEOM::ListOfListOfLong();
2001 //Get the reference objects
2002 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2003 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2005 if (!aShapeWhere.IsNull() &&
2006 !aShapeWhat.IsNull())
2008 std::vector< std::vector< int > > resVec;
2009 GetOperations()->GetInPlaceMap(aShapeWhere, aShapeWhat, resVec);
2011 aResult->length( resVec.size() );
2012 for ( size_t i = 0; i < resVec.size(); ++i )
2014 //if ( !resVec[i].empty() )
2015 aResult[i].length( resVec[i].size() );
2016 for ( size_t j = 0; j < resVec[i].size(); ++j )
2017 aResult[i][j] = resVec[i][j];
2020 return aResult._retn();
2023 //=============================================================================
2027 //=============================================================================
2028 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSame
2029 (GEOM::GEOM_Object_ptr theShapeWhere,
2030 GEOM::GEOM_Object_ptr theShapeWhat)
2032 GEOM::GEOM_Object_var aGEOMObject;
2034 //Set a not done flag
2035 GetOperations()->SetNotDone();
2037 //Get the reference objects
2038 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2039 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2041 if (aShapeWhere.IsNull() ||
2042 aShapeWhat.IsNull()) return aGEOMObject._retn();
2044 //Get Shapes in place of aShapeWhat
2045 Handle(::GEOM_Object) anObject =
2046 GetOperations()->GetSame(aShapeWhere, aShapeWhat);
2047 if (!GetOperations()->IsDone() || anObject.IsNull())
2048 return aGEOMObject._retn();
2050 return GetObject(anObject);
2053 //=============================================================================
2057 //=============================================================================
2058 GEOM::ListOfLong* GEOM_IShapesOperations_i::GetSameIDs
2059 (GEOM::GEOM_Object_ptr theShapeWhere,
2060 GEOM::GEOM_Object_ptr theShapeWhat) {
2061 GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
2063 //Get the reference objects
2064 Handle(::GEOM_Object) aShapeWhere = GetObjectImpl(theShapeWhere);
2065 Handle(::GEOM_Object) aShapeWhat = GetObjectImpl(theShapeWhat);
2067 if (aShapeWhere.IsNull() ||
2068 aShapeWhat.IsNull()) return aSeq._retn();
2071 Handle(TColStd_HSequenceOfInteger) aHSeq =
2072 GetOperations()->GetSameIDs(aShapeWhere, aShapeWhat);
2074 if (!GetOperations()->IsDone() || aHSeq.IsNull()) return aSeq._retn();
2076 Standard_Integer aLength = aHSeq->Length();
2077 aSeq->length(aLength);
2078 for (Standard_Integer i = 1; i <= aLength; i++)
2079 aSeq[i-1] = aHSeq->Value(i);
2081 return aSeq._retn();
2084 //=============================================================================
2088 //=============================================================================
2089 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendEdge
2090 (GEOM::GEOM_Object_ptr theEdge,
2091 CORBA::Double theMin,
2092 CORBA::Double theMax)
2094 GEOM::GEOM_Object_var aGEOMObject;
2096 //Set a not done flag
2097 GetOperations()->SetNotDone();
2099 //Get the reference objects
2100 Handle(::GEOM_Object) anEdge = GetObjectImpl(theEdge);
2102 if (anEdge.IsNull()) {
2103 return aGEOMObject._retn();
2106 //Get Shapes in place of aShapeWhat
2107 Handle(::GEOM_Object) aNewEdge =
2108 GetOperations()->ExtendEdge(anEdge, theMin, theMax);
2110 if (!GetOperations()->IsDone() || aNewEdge.IsNull()) {
2111 return aGEOMObject._retn();
2114 return GetObject(aNewEdge);
2117 //=============================================================================
2121 //=============================================================================
2122 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ExtendFace
2123 (GEOM::GEOM_Object_ptr theFace,
2124 CORBA::Double theUMin,
2125 CORBA::Double theUMax,
2126 CORBA::Double theVMin,
2127 CORBA::Double theVMax)
2129 GEOM::GEOM_Object_var aGEOMObject;
2131 //Set a not done flag
2132 GetOperations()->SetNotDone();
2134 //Get the reference objects
2135 Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
2137 if (aFace.IsNull()) {
2138 return aGEOMObject._retn();
2141 //Get Shapes in place of aShapeWhat
2142 Handle(::GEOM_Object) aNewFace =
2143 GetOperations()->ExtendFace(aFace, theUMin, theUMax, theVMin, theVMax);
2145 if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2146 return aGEOMObject._retn();
2149 return GetObject(aNewFace);
2152 //=============================================================================
2154 * MakeSurfaceFromFace
2156 //=============================================================================
2157 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeSurfaceFromFace
2158 (GEOM::GEOM_Object_ptr theFace)
2160 GEOM::GEOM_Object_var aGEOMObject;
2162 //Set a not done flag
2163 GetOperations()->SetNotDone();
2165 //Get the reference object
2166 Handle(::GEOM_Object) aFace = GetObjectImpl(theFace);
2168 if (aFace.IsNull()) {
2169 return aGEOMObject._retn();
2172 //Get Shapes in place of aShapeWhat
2173 Handle(::GEOM_Object) aNewFace = GetOperations()->MakeSurfaceFromFace(aFace);
2175 if (!GetOperations()->IsDone() || aNewFace.IsNull()) {
2176 return aGEOMObject._retn();
2179 return GetObject(aNewFace);
2182 //=============================================================================
2184 * GetSubShapeEdgeSorted
2186 //=============================================================================
2187 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapeEdgeSorted
2188 (GEOM::GEOM_Object_ptr theShape,
2189 GEOM::GEOM_Object_ptr theStartPoint)
2191 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
2193 //Set a not done flag
2194 GetOperations()->SetNotDone();
2196 //Get the reference objects
2197 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
2198 Handle(::GEOM_Object) aStartPoint = GetObjectImpl(theStartPoint);
2200 if (aShape.IsNull() || aStartPoint.IsNull()) {
2201 return aSeq._retn();
2204 //Get Shapes On Shape
2205 Handle(TColStd_HSequenceOfTransient) aHSeq =
2206 GetOperations()->GetSubShapeEdgeSorted(aShape, aStartPoint);
2208 if (!GetOperations()->IsDone() || aHSeq.IsNull())
2209 return aSeq._retn();
2211 const Standard_Integer aLength = aHSeq->Length();
2214 aSeq->length(aLength);
2216 for (i = 1; i <= aLength; i++) {
2217 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
2220 return aSeq._retn();
2223 //=============================================================================
2225 * GetSubShapesWithTolerance
2227 //=============================================================================
2228 GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSubShapesWithTolerance
2229 (GEOM::GEOM_Object_ptr theShape,
2230 CORBA::Short theShapeType,
2231 GEOM::comparison_condition theCondition,
2232 CORBA::Double theTolerance)
2234 GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
2236 //Set a not done flag
2237 GetOperations()->SetNotDone();
2239 //Get the reference objects
2240 Handle(::GEOM_Object) aShape = GetObjectImpl(theShape);
2242 if (aShape.IsNull()) {
2243 return aSeq._retn();
2246 //Get Shapes On Shape
2247 const GEOMUtils::ComparisonCondition aCondition =
2248 ComparisonCondition(theCondition);
2249 Handle(TColStd_HSequenceOfTransient) aHSeq =
2250 GetOperations()->GetSubShapesWithTolerance
2251 (aShape, theShapeType, aCondition, theTolerance);
2253 if (!GetOperations()->IsDone() || aHSeq.IsNull())
2254 return aSeq._retn();
2256 const Standard_Integer aLength = aHSeq->Length();
2259 aSeq->length(aLength);
2261 for (i = 1; i <= aLength; i++) {
2262 aSeq[i-1] = GetObject(Handle(::GEOM_Object)::DownCast(aHSeq->Value(i)));
2265 return aSeq._retn();
2268 //=============================================================================
2272 //=============================================================================
2273 GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeExtraction
2274 (GEOM::GEOM_Object_ptr theShape,
2275 const GEOM::ListOfLong &theSubShapeIDs,
2276 GEOM::GEOM_IShapesOperations::ExtractionStats_out theStats)
2278 GEOM::GEOM_Object_var aGEOMObject;
2280 //Set a not done flag
2281 theStats = new GEOM::GEOM_IShapesOperations::ExtractionStats;
2282 GetOperations()->SetNotDone();
2284 //Get the reference object
2285 Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
2287 if (aShape.IsNull()) {
2288 return aGEOMObject._retn();
2291 const int aNbIDs = theSubShapeIDs.length();
2294 return aGEOMObject._retn();
2298 Handle(TColStd_HArray1OfInteger) anArray =
2299 new TColStd_HArray1OfInteger (1, aNbIDs);
2301 for (i = 0; i < aNbIDs; i++) {
2302 anArray->SetValue(i + 1, theSubShapeIDs[i]);
2305 //Get Shapes in place of aShapeWhat
2306 std::list<GEOMImpl_IShapesOperations::ExtractionStat> aStats;
2307 Handle(GEOM_Object) aResult =
2308 GetOperations()->MakeExtraction(aShape, anArray, aStats);
2310 if (!GetOperations()->IsDone() || aResult.IsNull()) {
2311 return aGEOMObject._retn();
2314 // Convert statistics.
2315 const int aNbStats = aStats.size();
2317 theStats->length(aNbStats);
2319 // fill the local CORBA array with values from lists
2320 std::list<GEOMImpl_IShapesOperations::ExtractionStat>::const_iterator
2321 anIt = aStats.begin();
2323 for (i = 0; anIt != aStats.end(); i++, anIt++) {
2324 GEOM::GEOM_IShapesOperations::ExtractionStat_var aResStat =
2325 new GEOM::GEOM_IShapesOperations::ExtractionStat;
2328 switch (anIt->type) {
2329 case GEOMImpl_IShapesOperations::EST_Removed:
2330 aResStat->type = GEOM::GEOM_IShapesOperations::EST_Removed;
2332 case GEOMImpl_IShapesOperations::EST_Modified:
2333 aResStat->type = GEOM::GEOM_IShapesOperations::EST_Modified;
2335 case GEOMImpl_IShapesOperations::EST_Added:
2336 aResStat->type = GEOM::GEOM_IShapesOperations::EST_Added;
2342 // Copy the list of IDs
2343 std::list<Standard_Integer> aIDList = anIt->indices;
2344 GEOM::ListOfLong_var aResIDList = new GEOM::ListOfLong;
2346 aResIDList->length(aIDList.size());
2348 std::list<Standard_Integer>::iterator anIDIt = aIDList.begin();
2351 for (; anIDIt != aIDList.end(); j++, anIDIt++) {
2352 aResIDList[j] = *anIDIt;
2355 aResStat->indices = aResIDList;
2357 theStats[(_CORBA_ULong)i] = aResStat;
2360 return GetObject(aResult);