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_ITransformOperations_i.hh"
24 #include "utilities.h"
26 #include "Utils_ExceptHandlers.hxx"
28 #include <TDF_Label.hxx>
29 #include <TDF_Tool.hxx>
30 #include <TCollection_AsciiString.hxx>
31 #include "GEOM_Engine.hxx"
32 #include "GEOM_Object.hxx"
34 #define SUBSHAPE_ERROR "Sub shape cannot be transformed"
36 //=============================================================================
40 //=============================================================================
42 GEOM_ITransformOperations_i::GEOM_ITransformOperations_i (PortableServer::POA_ptr thePOA,
43 GEOM::GEOM_Gen_ptr theEngine,
44 ::GEOMImpl_ITransformOperations* theImpl)
45 :GEOM_IOperations_i(thePOA, theEngine, theImpl)
47 MESSAGE("GEOM_ITransformOperations_i::GEOM_ITransformOperations_i");
50 //=============================================================================
54 //=============================================================================
56 GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i()
58 MESSAGE("GEOM_ITransformOperations_i::~GEOM_ITransformOperations_i");
62 //=============================================================================
66 //=============================================================================
67 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPoints
68 (GEOM::GEOM_Object_ptr theObject,
69 GEOM::GEOM_Object_ptr thePoint1,
70 GEOM::GEOM_Object_ptr thePoint2)
73 GetOperations()->SetNotDone();
74 GEOM::GEOM_Object_var aGEOMObject;
76 if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
78 //check if the object is a subshape
79 if(!theObject->IsMainShape()) {
80 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
81 return aGEOMObject._retn();
84 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
86 //Get the object itself
87 Handle(GEOM_Object) anObject =
88 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
89 if (anObject.IsNull()) return aGEOMObject._retn();
91 //Get the first point of translation
92 Handle(GEOM_Object) aPoint1 =
93 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
94 if (aPoint1.IsNull()) return aGEOMObject._retn();
96 //Get the second point of translation
97 Handle(GEOM_Object) aPoint2 =
98 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
99 if (aPoint2.IsNull()) return aGEOMObject._retn();
101 //Perform the translation
102 GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
104 return aGEOMObject._retn();
107 //=============================================================================
109 * TranslateTwoPointsCopy
111 //=============================================================================
112 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateTwoPointsCopy
113 (GEOM::GEOM_Object_ptr theObject,
114 GEOM::GEOM_Object_ptr thePoint1,
115 GEOM::GEOM_Object_ptr thePoint2)
117 GEOM::GEOM_Object_var aGEOMObject;
119 //Set a not done flag
120 GetOperations()->SetNotDone();
122 if (thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
124 //Get the object itself
125 Handle(GEOM_Object) aBasicObject =
126 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
127 if (aBasicObject.IsNull()) return aGEOMObject._retn();
129 //Get the first point of translation
130 Handle(GEOM_Object) aPoint1 =
131 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
132 if (aPoint1.IsNull()) return aGEOMObject._retn();
134 //Get the second point of translation
135 Handle(GEOM_Object) aPoint2 =
136 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
137 if (aPoint2.IsNull()) return aGEOMObject._retn();
139 //Create the translated shape
140 Handle(GEOM_Object) anObject =
141 GetOperations()->TranslateTwoPointsCopy(aBasicObject, aPoint1, aPoint2);
142 if (!GetOperations()->IsDone() || anObject.IsNull())
143 return aGEOMObject._retn();
145 return GetObject(anObject);
148 //=============================================================================
152 //=============================================================================
153 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZ (GEOM::GEOM_Object_ptr theObject,
154 CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
156 //Set a not done flag
157 GetOperations()->SetNotDone();
158 GEOM::GEOM_Object_var aGEOMObject ;
160 if (theObject == NULL) return aGEOMObject._retn();
162 //check if the object is a subshape
163 if(!theObject->IsMainShape()) {
164 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
165 return aGEOMObject._retn();
168 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
170 //Get the object itself
171 Handle(GEOM_Object) anObject =
172 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
173 if (anObject.IsNull()) return aGEOMObject._retn();
175 //Perform the translation
176 GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
178 return aGEOMObject._retn();
182 //=============================================================================
184 * TranslateDXDYDZCopy
186 //=============================================================================
187 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateDXDYDZCopy
188 (GEOM::GEOM_Object_ptr theObject, CORBA::Double theDX, CORBA::Double theDY, CORBA::Double theDZ)
190 GEOM::GEOM_Object_var aGEOMObject;
192 //Set a not done flag
193 GetOperations()->SetNotDone();
195 if (theObject == NULL) return aGEOMObject._retn();
197 //Get the object itself
198 Handle(GEOM_Object) aBasicObject =
199 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
200 if (aBasicObject.IsNull()) return aGEOMObject._retn();
204 //Create the translated shape
205 Handle(GEOM_Object) anObject =
206 GetOperations()->TranslateDXDYDZCopy(aBasicObject, theDX, theDY, theDZ);
207 if (!GetOperations()->IsDone() || anObject.IsNull())
208 return aGEOMObject._retn();
210 return GetObject(anObject);
214 //=============================================================================
218 //=============================================================================
219 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVector
220 (GEOM::GEOM_Object_ptr theObject,
221 GEOM::GEOM_Object_ptr theVector)
223 //Set a not done flag
224 GetOperations()->SetNotDone();
225 GEOM::GEOM_Object_var aGEOMObject;
227 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
229 //check if the object is a subshape
230 if(!theObject->IsMainShape()) {
231 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
232 return aGEOMObject._retn();
235 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
237 //Get the object itself
238 Handle(GEOM_Object) anObject =
239 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
240 if (anObject.IsNull()) return aGEOMObject._retn();
242 //Get the vector of translation
243 Handle(GEOM_Object) aVector =
244 GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry());
245 if (aVector.IsNull()) return aGEOMObject._retn();
247 //Perform the translation
248 GetOperations()->TranslateVector(anObject, aVector);
250 return aGEOMObject._retn();
253 //=============================================================================
255 * TranslateVectorCopy
257 //=============================================================================
258 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorCopy
259 (GEOM::GEOM_Object_ptr theObject,
260 GEOM::GEOM_Object_ptr theVector)
262 GEOM::GEOM_Object_var aGEOMObject;
264 //Set a not done flag
265 GetOperations()->SetNotDone();
267 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
269 //Get the object itself
270 Handle(GEOM_Object) aBasicObject =
271 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
272 if (aBasicObject.IsNull()) return aGEOMObject._retn();
274 //Get the vector of translation
275 Handle(GEOM_Object) aVector =
276 GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry());
277 if (aVector.IsNull()) return aGEOMObject._retn();
279 //Perform the translation
280 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorCopy(aBasicObject, aVector);
281 if (!GetOperations()->IsDone() || anObject.IsNull())
282 return aGEOMObject._retn();
284 return GetObject(anObject);
288 //=============================================================================
292 //=============================================================================
293 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
294 GEOM::GEOM_Object_ptr theAxis,
295 CORBA::Double theAngle)
297 //Set a not done flag
298 GetOperations()->SetNotDone();
299 GEOM::GEOM_Object_var aGEOMObject;
301 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
303 //check if the object is a subshape
304 if(!theObject->IsMainShape()) {
305 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
306 return aGEOMObject._retn();
309 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
311 //Get the object itself
312 Handle(GEOM_Object) anObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
313 if (anObject.IsNull()) return aGEOMObject._retn();
315 //Get the axis of revolution
316 Handle(GEOM_Object) anAxis =
317 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
318 if (anAxis.IsNull()) return aGEOMObject._retn();
320 //Perform the rotation
321 GetOperations()->Rotate(anObject, anAxis, theAngle);
323 return aGEOMObject._retn();
326 //=============================================================================
330 //=============================================================================
331 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
332 GEOM::GEOM_Object_ptr theAxis,
333 CORBA::Double theAngle)
335 GEOM::GEOM_Object_var aGEOMObject;
337 //Set a not done flag
338 GetOperations()->SetNotDone();
340 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
342 //Get the object itself
343 Handle(GEOM_Object) aBasicObject =
344 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
345 if (aBasicObject.IsNull()) return aGEOMObject._retn();
347 //Get the axis of rotation
348 Handle(GEOM_Object) anAxis =
349 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
350 if (anAxis.IsNull()) return aGEOMObject._retn();
352 //Perform the rotation
353 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
354 if (!GetOperations()->IsDone() || anObject.IsNull())
355 return aGEOMObject._retn();
357 return GetObject(anObject);
361 //=============================================================================
365 //=============================================================================
366 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
367 (GEOM::GEOM_Object_ptr theObject,
368 GEOM::GEOM_Object_ptr thePlane)
370 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
372 //Set a not done flag
373 GetOperations()->SetNotDone();
375 if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
377 //check if the object is a subshape
378 if(!theObject->IsMainShape()) {
379 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
380 return aGEOMObject._retn();
383 //Get the object itself
384 Handle(GEOM_Object) anObject =
385 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
386 if (anObject.IsNull()) return aGEOMObject._retn();
389 Handle(GEOM_Object) aPlane =
390 GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
391 if (aPlane.IsNull()) return aGEOMObject._retn();
394 GetOperations()->MirrorPlane(anObject, aPlane);
396 return aGEOMObject._retn();
399 //=============================================================================
403 //=============================================================================
404 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
405 (GEOM::GEOM_Object_ptr theObject,
406 GEOM::GEOM_Object_ptr thePlane)
408 GEOM::GEOM_Object_var aGEOMObject;
410 //Set a not done flag
411 GetOperations()->SetNotDone();
413 if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
415 //Get the object itself
416 Handle(GEOM_Object) aBasicObject =
417 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
418 if (aBasicObject.IsNull()) return aGEOMObject._retn();
420 //Get the vector of translation
421 Handle(GEOM_Object) aPlane =
422 GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
423 if (aPlane.IsNull()) return aGEOMObject._retn();
426 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
427 if (!GetOperations()->IsDone() || anObject.IsNull())
428 return aGEOMObject._retn();
430 return GetObject(anObject);
433 //=============================================================================
437 //=============================================================================
438 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
439 (GEOM::GEOM_Object_ptr theObject,
440 GEOM::GEOM_Object_ptr theAxis)
442 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
444 //Set a not done flag
445 GetOperations()->SetNotDone();
447 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
449 //check if the object is a subshape
450 if(!theObject->IsMainShape()) {
451 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
452 return aGEOMObject._retn();
455 //Get the object itself
456 Handle(GEOM_Object) anObject =
457 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
458 if (anObject.IsNull()) return aGEOMObject._retn();
461 Handle(GEOM_Object) aAxis =
462 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
463 if (aAxis.IsNull()) return aGEOMObject._retn();
466 GetOperations()->MirrorAxis(anObject, aAxis);
468 return aGEOMObject._retn();
471 //=============================================================================
475 //=============================================================================
476 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
477 (GEOM::GEOM_Object_ptr theObject,
478 GEOM::GEOM_Object_ptr theAxis)
480 GEOM::GEOM_Object_var aGEOMObject;
482 //Set a not done flag
483 GetOperations()->SetNotDone();
485 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
487 //Get the object itself
488 Handle(GEOM_Object) aBasicObject =
489 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
490 if (aBasicObject.IsNull()) return aGEOMObject._retn();
492 //Get the vector of translation
493 Handle(GEOM_Object) aAxis =
494 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
495 if (aAxis.IsNull()) return aGEOMObject._retn();
498 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
499 if (!GetOperations()->IsDone() || anObject.IsNull())
500 return aGEOMObject._retn();
502 return GetObject(anObject);
505 //=============================================================================
509 //=============================================================================
510 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
511 (GEOM::GEOM_Object_ptr theObject,
512 GEOM::GEOM_Object_ptr thePoint)
514 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
516 //Set a not done flag
517 GetOperations()->SetNotDone();
519 if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
521 //check if the object is a subshape
522 if(!theObject->IsMainShape()) {
523 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
524 return aGEOMObject._retn();
527 //Get the object itself
528 Handle(GEOM_Object) anObject =
529 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
530 if (anObject.IsNull()) return aGEOMObject._retn();
533 Handle(GEOM_Object) aPoint =
534 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
535 if (aPoint.IsNull()) return aGEOMObject._retn();
538 GetOperations()->MirrorPoint(anObject, aPoint);
540 return aGEOMObject._retn();
543 //=============================================================================
547 //=============================================================================
548 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
549 (GEOM::GEOM_Object_ptr theObject,
550 GEOM::GEOM_Object_ptr thePoint)
552 GEOM::GEOM_Object_var aGEOMObject;
554 //Set a not done flag
555 GetOperations()->SetNotDone();
557 if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
559 //Get the object itself
560 Handle(GEOM_Object) aBasicObject =
561 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
562 if (aBasicObject.IsNull()) return aGEOMObject._retn();
564 //Get the vector of translation
565 Handle(GEOM_Object) aPoint =
566 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
567 if (aPoint.IsNull()) return aGEOMObject._retn();
570 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
571 if (!GetOperations()->IsDone() || anObject.IsNull())
572 return aGEOMObject._retn();
574 return GetObject(anObject);
578 //=============================================================================
582 //=============================================================================
583 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
584 (GEOM::GEOM_Object_ptr theObject,
585 CORBA::Double theOffset)
587 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
589 //Set a not done flag
590 GetOperations()->SetNotDone();
592 if (theObject == NULL) return aGEOMObject._retn();
594 //check if the object is a subshape
595 if(!theObject->IsMainShape()) {
596 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
597 return aGEOMObject._retn();
601 //Get the basic object
602 Handle(GEOM_Object) aBasicObject =
603 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
604 if (aBasicObject.IsNull()) return aGEOMObject._retn();
606 //Create the offset shape
607 GetOperations()->OffsetShape(aBasicObject, theOffset);
609 return aGEOMObject._retn();
612 //=============================================================================
616 //=============================================================================
617 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
618 (GEOM::GEOM_Object_ptr theObject,
619 CORBA::Double theOffset)
621 GEOM::GEOM_Object_var aGEOMObject;
623 //Set a not done flag
624 GetOperations()->SetNotDone();
626 if (theObject == NULL) return aGEOMObject._retn();
628 //Get the basic object
629 Handle(GEOM_Object) aBasicObject =
630 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
631 if (aBasicObject.IsNull()) return aGEOMObject._retn();
633 //Create the offset shape
634 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
635 if (!GetOperations()->IsDone() || anObject.IsNull())
636 return aGEOMObject._retn();
638 return GetObject(anObject);
642 //=============================================================================
646 //=============================================================================
647 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
648 (GEOM::GEOM_Object_ptr theObject,
649 GEOM::GEOM_Object_ptr thePoint,
650 CORBA::Double theFactor)
652 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
654 //Set a not done flag
655 GetOperations()->SetNotDone();
657 if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
659 //check if the object is a subshape
660 if(!theObject->IsMainShape()) {
661 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
662 return aGEOMObject._retn();
665 //Get the object itself
666 Handle(GEOM_Object) anObject =
667 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
668 if (anObject.IsNull()) return aGEOMObject._retn();
671 Handle(GEOM_Object) aPoint =
672 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
673 if (aPoint.IsNull()) return aGEOMObject._retn();
676 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
678 return aGEOMObject._retn();
681 //=============================================================================
685 //=============================================================================
686 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
687 (GEOM::GEOM_Object_ptr theObject,
688 GEOM::GEOM_Object_ptr thePoint,
689 CORBA::Double theFactor)
691 GEOM::GEOM_Object_var aGEOMObject;
693 //Set a not done flag
694 GetOperations()->SetNotDone();
696 if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
698 //Get the basic object
699 Handle(GEOM_Object) aBasicObject =
700 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
701 if (aBasicObject.IsNull()) return aGEOMObject._retn();
704 Handle(GEOM_Object) aPoint =
705 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
706 if (aPoint.IsNull()) return aGEOMObject._retn();
709 Handle(GEOM_Object) anObject =
710 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
711 if (!GetOperations()->IsDone() || anObject.IsNull())
712 return aGEOMObject._retn();
714 return GetObject(anObject);
717 //=============================================================================
721 //=============================================================================
722 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
723 (GEOM::GEOM_Object_ptr theObject,
724 GEOM::GEOM_Object_ptr theStartLCS,
725 GEOM::GEOM_Object_ptr theEndLCS)
727 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
729 //Set a not done flag
730 GetOperations()->SetNotDone();
732 if (theObject == NULL || theEndLCS == NULL)
733 return aGEOMObject._retn();
735 //check if the object is a subshape
736 if(!theObject->IsMainShape()) {
737 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
738 return aGEOMObject._retn();
741 //Get the basic object
742 Handle(GEOM_Object) anObject =
743 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
744 if (anObject.IsNull()) return aGEOMObject._retn();
746 //Get the Start LCS (may be NULL for positioning from global LCS)
747 Handle(GEOM_Object) aStartLCS = NULL;
748 if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
749 aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
750 if (aStartLCS.IsNull()) return aGEOMObject._retn();
754 Handle(GEOM_Object) aEndLCS =
755 GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
756 if (aEndLCS.IsNull()) return aGEOMObject._retn();
758 //Perform the Position
759 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
761 return aGEOMObject._retn();
764 //=============================================================================
768 //=============================================================================
769 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
770 (GEOM::GEOM_Object_ptr theObject,
771 GEOM::GEOM_Object_ptr theStartLCS,
772 GEOM::GEOM_Object_ptr theEndLCS)
774 GEOM::GEOM_Object_var aGEOMObject;
776 //Set a not done flag
777 GetOperations()->SetNotDone();
779 if (theObject == NULL || theEndLCS == NULL)
780 return aGEOMObject._retn();
782 //Get the basic object
783 Handle(GEOM_Object) aBasicObject =
784 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
785 if (aBasicObject.IsNull()) return aGEOMObject._retn();
787 //Get the Start LCS (may be NULL for positioning from global LCS)
788 Handle(GEOM_Object) aStartLCS = NULL;
789 if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
790 aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
791 if (aStartLCS.IsNull()) return aGEOMObject._retn();
795 Handle(GEOM_Object) aEndLCS =
796 GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
797 if (aEndLCS.IsNull()) return aGEOMObject._retn();
799 //Perform the position
800 Handle(GEOM_Object) anObject =
801 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
802 if (!GetOperations()->IsDone() || anObject.IsNull())
803 return aGEOMObject._retn();
805 return GetObject(anObject);
808 //=============================================================================
812 //=============================================================================
813 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
814 (GEOM::GEOM_Object_ptr theObject,
815 GEOM::GEOM_Object_ptr theVector,
816 CORBA::Double theStep, CORBA::Long theNbTimes)
818 //Set a not done flag
819 GetOperations()->SetNotDone();
821 GEOM::GEOM_Object_var aGEOMObject;
823 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
825 //Get the object itself
826 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
827 (theObject->GetStudyID(), theObject->GetEntry());
828 if (aBasicObject.IsNull()) return aGEOMObject._retn();
830 //Get the vector of translation
831 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
832 (theVector->GetStudyID(), theVector->GetEntry());
833 if (aVector.IsNull()) return aGEOMObject._retn();
835 //Perform the translation
836 Handle(GEOM_Object) anObject =
837 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
838 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
840 return GetObject(anObject);
843 //=============================================================================
847 //=============================================================================
848 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
849 GEOM::GEOM_Object_ptr theVector1,
850 CORBA::Double theStep1,
851 CORBA::Long theNbTimes1,
852 GEOM::GEOM_Object_ptr theVector2,
853 CORBA::Double theStep2,
854 CORBA::Long theNbTimes2)
856 //Set a not done flag
857 GetOperations()->SetNotDone();
859 GEOM::GEOM_Object_var aGEOMObject;
861 if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn();
863 //Get the object itself
864 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
865 (theObject->GetStudyID(), theObject->GetEntry());
866 if (aBasicObject.IsNull()) return aGEOMObject._retn();
868 //Get the vector1 of translation
869 Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject
870 (theVector1->GetStudyID(), theVector1->GetEntry());
871 if (aVector1.IsNull()) return aGEOMObject._retn();
873 //Get the vector2 of translation
874 Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject
875 (theVector2->GetStudyID(), theVector2->GetEntry());
876 if (aVector2.IsNull()) return aGEOMObject._retn();
878 //Perform the translation
879 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
880 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
881 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
883 return GetObject(anObject);
886 //=============================================================================
890 //=============================================================================
891 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
892 GEOM::GEOM_Object_ptr theVector,
893 CORBA::Long theNbTimes)
895 //Set a not done flag
896 GetOperations()->SetNotDone();
898 GEOM::GEOM_Object_var aGEOMObject;
900 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
902 //Get the object itself
903 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
904 (theObject->GetStudyID(), theObject->GetEntry());
905 if (aBasicObject.IsNull()) return aGEOMObject._retn();
907 //Get the a directon of rotation
908 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
909 (theVector->GetStudyID(), theVector->GetEntry());
910 if (aVector.IsNull()) return aGEOMObject._retn();
912 //Perform the rotation
913 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
914 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
916 return GetObject(anObject);
919 //=============================================================================
923 //=============================================================================
924 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
925 GEOM::GEOM_Object_ptr theVector,
926 CORBA::Double theAngle,
927 CORBA::Long theNbTimes1,
928 CORBA::Double theStep,
929 CORBA::Long theNbTimes2)
931 //Set a not done flag
932 GetOperations()->SetNotDone();
934 GEOM::GEOM_Object_var aGEOMObject;
936 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
938 //Get the object itself
939 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
940 (theObject->GetStudyID(), theObject->GetEntry());
941 if (aBasicObject.IsNull()) return aGEOMObject._retn();
943 //Get the a directon of rotation
944 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
945 (theVector->GetStudyID(), theVector->GetEntry());
946 if (aVector.IsNull()) return aGEOMObject._retn();
948 //Perform the rotation
949 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
950 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
951 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
953 return GetObject(anObject);
956 //=============================================================================
960 //=============================================================================
961 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
962 (GEOM::GEOM_Object_ptr theObject,
963 GEOM::GEOM_Object_ptr theCentPoint,
964 GEOM::GEOM_Object_ptr thePoint1,
965 GEOM::GEOM_Object_ptr thePoint2)
967 //Set a not done flag
968 GetOperations()->SetNotDone();
969 GEOM::GEOM_Object_var aGEOMObject;
971 if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
973 //check if the object is a subshape
974 if(!theObject->IsMainShape()) {
975 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
976 return aGEOMObject._retn();
979 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
981 //Get the object itself
982 Handle(GEOM_Object) anObject =
983 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
984 if (anObject.IsNull()) return aGEOMObject._retn();
986 //Get the central point of rotation
987 Handle(GEOM_Object) aCentPoint =
988 GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
989 if (aCentPoint.IsNull()) return aGEOMObject._retn();
991 //Get the first point
992 Handle(GEOM_Object) aPoint1 =
993 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
994 if (aPoint1.IsNull()) return aGEOMObject._retn();
996 //Get the second point
997 Handle(GEOM_Object) aPoint2 =
998 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
999 if (aPoint2.IsNull()) return aGEOMObject._retn();
1001 //Perform the translation
1002 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1004 return aGEOMObject._retn();
1007 //=============================================================================
1009 * RotateThreePointsCopy
1011 //=============================================================================
1012 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1013 (GEOM::GEOM_Object_ptr theObject,
1014 GEOM::GEOM_Object_ptr theCentPoint,
1015 GEOM::GEOM_Object_ptr thePoint1,
1016 GEOM::GEOM_Object_ptr thePoint2)
1018 GEOM::GEOM_Object_var aGEOMObject;
1020 //Set a not done flag
1021 GetOperations()->SetNotDone();
1023 if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
1025 //Get the object itself
1026 Handle(GEOM_Object) aBasicObject =
1027 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1028 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1030 //Get the central point of rotation
1031 Handle(GEOM_Object) aCentPoint =
1032 GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
1033 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1035 //Get the first point
1036 Handle(GEOM_Object) aPoint1 =
1037 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
1038 if (aPoint1.IsNull()) return aGEOMObject._retn();
1040 //Get the second point
1041 Handle(GEOM_Object) aPoint2 =
1042 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
1043 if (aPoint2.IsNull()) return aGEOMObject._retn();
1045 //Perform the rotation
1046 Handle(GEOM_Object) anObject =
1047 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1048 if (!GetOperations()->IsDone() || anObject.IsNull())
1049 return aGEOMObject._retn();
1051 return GetObject(anObject);