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);
287 //=============================================================================
289 * TranslateVectorDistance
291 //=============================================================================
292 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::TranslateVectorDistance
293 (GEOM::GEOM_Object_ptr theObject,
294 GEOM::GEOM_Object_ptr theVector,
295 CORBA::Double theDistance,
296 CORBA::Boolean theCopy)
298 GEOM::GEOM_Object_var aGEOMObject;
299 GetOperations()->SetNotDone(); //Set a not done flag
301 if (theObject == NULL || theVector == NULL || theDistance == 0) return aGEOMObject._retn();
303 //check if the object is a subshape
304 if(!theObject->IsMainShape()) {
305 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
306 return aGEOMObject._retn();
310 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
312 //Get the object itself
313 Handle(GEOM_Object) aBasicObject =
314 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
315 if (aBasicObject.IsNull()) return aGEOMObject._retn();
317 //Get the vector of translation
318 Handle(GEOM_Object) aVector =
319 GetOperations()->GetEngine()->GetObject(theVector->GetStudyID(), theVector->GetEntry());
320 if (aVector.IsNull()) return aGEOMObject._retn();
322 //Perform the translation
324 Handle(GEOM_Object) anObject = GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
325 if (!GetOperations()->IsDone() || anObject.IsNull())
326 return aGEOMObject._retn();
328 return GetObject(anObject);
331 GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
332 return aGEOMObject._retn();
335 //=============================================================================
339 //=============================================================================
340 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::Rotate (GEOM::GEOM_Object_ptr theObject,
341 GEOM::GEOM_Object_ptr theAxis,
342 CORBA::Double theAngle)
344 //Set a not done flag
345 GetOperations()->SetNotDone();
346 GEOM::GEOM_Object_var aGEOMObject;
348 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
350 //check if the object is a subshape
351 if(!theObject->IsMainShape()) {
352 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
353 return aGEOMObject._retn();
356 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
358 //Get the object itself
359 Handle(GEOM_Object) anObject = GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
360 if (anObject.IsNull()) return aGEOMObject._retn();
362 //Get the axis of revolution
363 Handle(GEOM_Object) anAxis =
364 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
365 if (anAxis.IsNull()) return aGEOMObject._retn();
367 //Perform the rotation
368 GetOperations()->Rotate(anObject, anAxis, theAngle);
370 return aGEOMObject._retn();
373 //=============================================================================
377 //=============================================================================
378 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateCopy (GEOM::GEOM_Object_ptr theObject,
379 GEOM::GEOM_Object_ptr theAxis,
380 CORBA::Double theAngle)
382 GEOM::GEOM_Object_var aGEOMObject;
384 //Set a not done flag
385 GetOperations()->SetNotDone();
387 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
389 //Get the object itself
390 Handle(GEOM_Object) aBasicObject =
391 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
392 if (aBasicObject.IsNull()) return aGEOMObject._retn();
394 //Get the axis of rotation
395 Handle(GEOM_Object) anAxis =
396 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
397 if (anAxis.IsNull()) return aGEOMObject._retn();
399 //Perform the rotation
400 Handle(GEOM_Object) anObject = GetOperations()->RotateCopy(aBasicObject, anAxis, theAngle);
401 if (!GetOperations()->IsDone() || anObject.IsNull())
402 return aGEOMObject._retn();
404 return GetObject(anObject);
408 //=============================================================================
412 //=============================================================================
413 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlane
414 (GEOM::GEOM_Object_ptr theObject,
415 GEOM::GEOM_Object_ptr thePlane)
417 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
419 //Set a not done flag
420 GetOperations()->SetNotDone();
422 if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
424 //check if the object is a subshape
425 if(!theObject->IsMainShape()) {
426 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
427 return aGEOMObject._retn();
430 //Get the object itself
431 Handle(GEOM_Object) anObject =
432 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
433 if (anObject.IsNull()) return aGEOMObject._retn();
436 Handle(GEOM_Object) aPlane =
437 GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
438 if (aPlane.IsNull()) return aGEOMObject._retn();
441 GetOperations()->MirrorPlane(anObject, aPlane);
443 return aGEOMObject._retn();
446 //=============================================================================
450 //=============================================================================
451 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPlaneCopy
452 (GEOM::GEOM_Object_ptr theObject,
453 GEOM::GEOM_Object_ptr thePlane)
455 GEOM::GEOM_Object_var aGEOMObject;
457 //Set a not done flag
458 GetOperations()->SetNotDone();
460 if (theObject == NULL || thePlane == NULL) return aGEOMObject._retn();
462 //Get the object itself
463 Handle(GEOM_Object) aBasicObject =
464 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
465 if (aBasicObject.IsNull()) return aGEOMObject._retn();
467 //Get the vector of translation
468 Handle(GEOM_Object) aPlane =
469 GetOperations()->GetEngine()->GetObject(thePlane->GetStudyID(), thePlane->GetEntry());
470 if (aPlane.IsNull()) return aGEOMObject._retn();
473 Handle(GEOM_Object) anObject = GetOperations()->MirrorPlaneCopy(aBasicObject, aPlane);
474 if (!GetOperations()->IsDone() || anObject.IsNull())
475 return aGEOMObject._retn();
477 return GetObject(anObject);
480 //=============================================================================
484 //=============================================================================
485 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxis
486 (GEOM::GEOM_Object_ptr theObject,
487 GEOM::GEOM_Object_ptr theAxis)
489 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
491 //Set a not done flag
492 GetOperations()->SetNotDone();
494 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
496 //check if the object is a subshape
497 if(!theObject->IsMainShape()) {
498 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
499 return aGEOMObject._retn();
502 //Get the object itself
503 Handle(GEOM_Object) anObject =
504 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
505 if (anObject.IsNull()) return aGEOMObject._retn();
508 Handle(GEOM_Object) aAxis =
509 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
510 if (aAxis.IsNull()) return aGEOMObject._retn();
513 GetOperations()->MirrorAxis(anObject, aAxis);
515 return aGEOMObject._retn();
518 //=============================================================================
522 //=============================================================================
523 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorAxisCopy
524 (GEOM::GEOM_Object_ptr theObject,
525 GEOM::GEOM_Object_ptr theAxis)
527 GEOM::GEOM_Object_var aGEOMObject;
529 //Set a not done flag
530 GetOperations()->SetNotDone();
532 if (theObject == NULL || theAxis == NULL) return aGEOMObject._retn();
534 //Get the object itself
535 Handle(GEOM_Object) aBasicObject =
536 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
537 if (aBasicObject.IsNull()) return aGEOMObject._retn();
539 //Get the vector of translation
540 Handle(GEOM_Object) aAxis =
541 GetOperations()->GetEngine()->GetObject(theAxis->GetStudyID(), theAxis->GetEntry());
542 if (aAxis.IsNull()) return aGEOMObject._retn();
545 Handle(GEOM_Object) anObject = GetOperations()->MirrorAxisCopy(aBasicObject, aAxis);
546 if (!GetOperations()->IsDone() || anObject.IsNull())
547 return aGEOMObject._retn();
549 return GetObject(anObject);
552 //=============================================================================
556 //=============================================================================
557 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPoint
558 (GEOM::GEOM_Object_ptr theObject,
559 GEOM::GEOM_Object_ptr thePoint)
561 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
563 //Set a not done flag
564 GetOperations()->SetNotDone();
566 if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
568 //check if the object is a subshape
569 if(!theObject->IsMainShape()) {
570 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
571 return aGEOMObject._retn();
574 //Get the object itself
575 Handle(GEOM_Object) anObject =
576 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
577 if (anObject.IsNull()) return aGEOMObject._retn();
580 Handle(GEOM_Object) aPoint =
581 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
582 if (aPoint.IsNull()) return aGEOMObject._retn();
585 GetOperations()->MirrorPoint(anObject, aPoint);
587 return aGEOMObject._retn();
590 //=============================================================================
594 //=============================================================================
595 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MirrorPointCopy
596 (GEOM::GEOM_Object_ptr theObject,
597 GEOM::GEOM_Object_ptr thePoint)
599 GEOM::GEOM_Object_var aGEOMObject;
601 //Set a not done flag
602 GetOperations()->SetNotDone();
604 if (theObject == NULL || thePoint == NULL) return aGEOMObject._retn();
606 //Get the object itself
607 Handle(GEOM_Object) aBasicObject =
608 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
609 if (aBasicObject.IsNull()) return aGEOMObject._retn();
611 //Get the vector of translation
612 Handle(GEOM_Object) aPoint =
613 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
614 if (aPoint.IsNull()) return aGEOMObject._retn();
617 Handle(GEOM_Object) anObject = GetOperations()->MirrorPointCopy(aBasicObject, aPoint);
618 if (!GetOperations()->IsDone() || anObject.IsNull())
619 return aGEOMObject._retn();
621 return GetObject(anObject);
625 //=============================================================================
629 //=============================================================================
630 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShape
631 (GEOM::GEOM_Object_ptr theObject,
632 CORBA::Double theOffset)
634 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
636 //Set a not done flag
637 GetOperations()->SetNotDone();
639 if (theObject == NULL) return aGEOMObject._retn();
641 //check if the object is a subshape
642 if(!theObject->IsMainShape()) {
643 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
644 return aGEOMObject._retn();
648 //Get the basic object
649 Handle(GEOM_Object) aBasicObject =
650 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
651 if (aBasicObject.IsNull()) return aGEOMObject._retn();
653 //Create the offset shape
654 GetOperations()->OffsetShape(aBasicObject, theOffset);
656 return aGEOMObject._retn();
659 //=============================================================================
663 //=============================================================================
664 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::OffsetShapeCopy
665 (GEOM::GEOM_Object_ptr theObject,
666 CORBA::Double theOffset)
668 GEOM::GEOM_Object_var aGEOMObject;
670 //Set a not done flag
671 GetOperations()->SetNotDone();
673 if (theObject == NULL) return aGEOMObject._retn();
675 //Get the basic object
676 Handle(GEOM_Object) aBasicObject =
677 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
678 if (aBasicObject.IsNull()) return aGEOMObject._retn();
680 //Create the offset shape
681 Handle(GEOM_Object) anObject = GetOperations()->OffsetShapeCopy(aBasicObject, theOffset);
682 if (!GetOperations()->IsDone() || anObject.IsNull())
683 return aGEOMObject._retn();
685 return GetObject(anObject);
689 //=============================================================================
693 //=============================================================================
694 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShape
695 (GEOM::GEOM_Object_ptr theObject,
696 GEOM::GEOM_Object_ptr thePoint,
697 CORBA::Double theFactor)
699 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
701 //Set a not done flag
702 GetOperations()->SetNotDone();
704 if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
706 //check if the object is a subshape
707 if(!theObject->IsMainShape()) {
708 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
709 return aGEOMObject._retn();
712 //Get the object itself
713 Handle(GEOM_Object) anObject =
714 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
715 if (anObject.IsNull()) return aGEOMObject._retn();
718 Handle(GEOM_Object) aPoint =
719 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
720 if (aPoint.IsNull()) return aGEOMObject._retn();
723 GetOperations()->ScaleShape(anObject, aPoint, theFactor);
725 return aGEOMObject._retn();
728 //=============================================================================
732 //=============================================================================
733 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::ScaleShapeCopy
734 (GEOM::GEOM_Object_ptr theObject,
735 GEOM::GEOM_Object_ptr thePoint,
736 CORBA::Double theFactor)
738 GEOM::GEOM_Object_var aGEOMObject;
740 //Set a not done flag
741 GetOperations()->SetNotDone();
743 if (thePoint == NULL || theObject == NULL) return aGEOMObject._retn();
745 //Get the basic object
746 Handle(GEOM_Object) aBasicObject =
747 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
748 if (aBasicObject.IsNull()) return aGEOMObject._retn();
751 Handle(GEOM_Object) aPoint =
752 GetOperations()->GetEngine()->GetObject(thePoint->GetStudyID(), thePoint->GetEntry());
753 if (aPoint.IsNull()) return aGEOMObject._retn();
756 Handle(GEOM_Object) anObject =
757 GetOperations()->ScaleShapeCopy(aBasicObject, aPoint, theFactor);
758 if (!GetOperations()->IsDone() || anObject.IsNull())
759 return aGEOMObject._retn();
761 return GetObject(anObject);
764 //=============================================================================
768 //=============================================================================
769 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShape
770 (GEOM::GEOM_Object_ptr theObject,
771 GEOM::GEOM_Object_ptr theStartLCS,
772 GEOM::GEOM_Object_ptr theEndLCS)
774 GEOM::GEOM_Object_var aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
776 //Set a not done flag
777 GetOperations()->SetNotDone();
779 if (theObject == NULL || theEndLCS == NULL)
780 return aGEOMObject._retn();
782 //check if the object is a subshape
783 if(!theObject->IsMainShape()) {
784 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
785 return aGEOMObject._retn();
788 //Get the basic object
789 Handle(GEOM_Object) anObject =
790 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
791 if (anObject.IsNull()) return aGEOMObject._retn();
793 //Get the Start LCS (may be NULL for positioning from global LCS)
794 Handle(GEOM_Object) aStartLCS = NULL;
795 if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
796 aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
797 if (aStartLCS.IsNull()) return aGEOMObject._retn();
801 Handle(GEOM_Object) aEndLCS =
802 GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
803 if (aEndLCS.IsNull()) return aGEOMObject._retn();
805 //Perform the Position
806 GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
808 return aGEOMObject._retn();
811 //=============================================================================
815 //=============================================================================
816 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::PositionShapeCopy
817 (GEOM::GEOM_Object_ptr theObject,
818 GEOM::GEOM_Object_ptr theStartLCS,
819 GEOM::GEOM_Object_ptr theEndLCS)
821 GEOM::GEOM_Object_var aGEOMObject;
823 //Set a not done flag
824 GetOperations()->SetNotDone();
826 if (theObject == NULL || theEndLCS == NULL)
827 return aGEOMObject._retn();
829 //Get the basic object
830 Handle(GEOM_Object) aBasicObject =
831 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
832 if (aBasicObject.IsNull()) return aGEOMObject._retn();
834 //Get the Start LCS (may be NULL for positioning from global LCS)
835 Handle(GEOM_Object) aStartLCS = NULL;
836 if (theStartLCS != NULL && !CORBA::is_nil(theStartLCS)) {
837 aStartLCS = GetOperations()->GetEngine()->GetObject(theStartLCS->GetStudyID(), theStartLCS->GetEntry());
838 if (aStartLCS.IsNull()) return aGEOMObject._retn();
842 Handle(GEOM_Object) aEndLCS =
843 GetOperations()->GetEngine()->GetObject(theEndLCS->GetStudyID(), theEndLCS->GetEntry());
844 if (aEndLCS.IsNull()) return aGEOMObject._retn();
846 //Perform the position
847 Handle(GEOM_Object) anObject =
848 GetOperations()->PositionShapeCopy(aBasicObject, aStartLCS, aEndLCS);
849 if (!GetOperations()->IsDone() || anObject.IsNull())
850 return aGEOMObject._retn();
852 return GetObject(anObject);
855 //=============================================================================
859 //=============================================================================
860 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate1D
861 (GEOM::GEOM_Object_ptr theObject,
862 GEOM::GEOM_Object_ptr theVector,
863 CORBA::Double theStep, CORBA::Long theNbTimes)
865 //Set a not done flag
866 GetOperations()->SetNotDone();
868 GEOM::GEOM_Object_var aGEOMObject;
870 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
872 //Get the object itself
873 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
874 (theObject->GetStudyID(), theObject->GetEntry());
875 if (aBasicObject.IsNull()) return aGEOMObject._retn();
877 //Get the vector of translation
878 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
879 (theVector->GetStudyID(), theVector->GetEntry());
880 if (aVector.IsNull()) return aGEOMObject._retn();
882 //Perform the translation
883 Handle(GEOM_Object) anObject =
884 GetOperations()->Translate1D(aBasicObject, aVector, theStep, theNbTimes);
885 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
887 return GetObject(anObject);
890 //=============================================================================
894 //=============================================================================
895 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiTranslate2D (GEOM::GEOM_Object_ptr theObject,
896 GEOM::GEOM_Object_ptr theVector1,
897 CORBA::Double theStep1,
898 CORBA::Long theNbTimes1,
899 GEOM::GEOM_Object_ptr theVector2,
900 CORBA::Double theStep2,
901 CORBA::Long theNbTimes2)
903 //Set a not done flag
904 GetOperations()->SetNotDone();
906 GEOM::GEOM_Object_var aGEOMObject;
908 if (theObject == NULL || theVector1 == NULL || theVector2 == NULL) return aGEOMObject._retn();
910 //Get the object itself
911 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
912 (theObject->GetStudyID(), theObject->GetEntry());
913 if (aBasicObject.IsNull()) return aGEOMObject._retn();
915 //Get the vector1 of translation
916 Handle(GEOM_Object) aVector1 = GetOperations()->GetEngine()->GetObject
917 (theVector1->GetStudyID(), theVector1->GetEntry());
918 if (aVector1.IsNull()) return aGEOMObject._retn();
920 //Get the vector2 of translation
921 Handle(GEOM_Object) aVector2 = GetOperations()->GetEngine()->GetObject
922 (theVector2->GetStudyID(), theVector2->GetEntry());
923 if (aVector2.IsNull()) return aGEOMObject._retn();
925 //Perform the translation
926 Handle(GEOM_Object) anObject = GetOperations()->Translate2D
927 (aBasicObject, aVector1, theStep1, theNbTimes1, aVector2, theStep2, theNbTimes2);
928 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
930 return GetObject(anObject);
933 //=============================================================================
937 //=============================================================================
938 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate1D (GEOM::GEOM_Object_ptr theObject,
939 GEOM::GEOM_Object_ptr theVector,
940 CORBA::Long theNbTimes)
942 //Set a not done flag
943 GetOperations()->SetNotDone();
945 GEOM::GEOM_Object_var aGEOMObject;
947 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
949 //Get the object itself
950 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
951 (theObject->GetStudyID(), theObject->GetEntry());
952 if (aBasicObject.IsNull()) return aGEOMObject._retn();
954 //Get the a directon of rotation
955 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
956 (theVector->GetStudyID(), theVector->GetEntry());
957 if (aVector.IsNull()) return aGEOMObject._retn();
959 //Perform the rotation
960 Handle(GEOM_Object) anObject = GetOperations()->Rotate1D(aBasicObject, aVector, theNbTimes);
961 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
963 return GetObject(anObject);
966 //=============================================================================
970 //=============================================================================
971 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::MultiRotate2D (GEOM::GEOM_Object_ptr theObject,
972 GEOM::GEOM_Object_ptr theVector,
973 CORBA::Double theAngle,
974 CORBA::Long theNbTimes1,
975 CORBA::Double theStep,
976 CORBA::Long theNbTimes2)
978 //Set a not done flag
979 GetOperations()->SetNotDone();
981 GEOM::GEOM_Object_var aGEOMObject;
983 if (theObject == NULL || theVector == NULL) return aGEOMObject._retn();
985 //Get the object itself
986 Handle(GEOM_Object) aBasicObject = GetOperations()->GetEngine()->GetObject
987 (theObject->GetStudyID(), theObject->GetEntry());
988 if (aBasicObject.IsNull()) return aGEOMObject._retn();
990 //Get the a directon of rotation
991 Handle(GEOM_Object) aVector = GetOperations()->GetEngine()->GetObject
992 (theVector->GetStudyID(), theVector->GetEntry());
993 if (aVector.IsNull()) return aGEOMObject._retn();
995 //Perform the rotation
996 Handle(GEOM_Object) anObject = GetOperations()->Rotate2D
997 (aBasicObject, aVector, theAngle, theNbTimes1, theStep, theNbTimes2);
998 if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn();
1000 return GetObject(anObject);
1003 //=============================================================================
1007 //=============================================================================
1008 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePoints
1009 (GEOM::GEOM_Object_ptr theObject,
1010 GEOM::GEOM_Object_ptr theCentPoint,
1011 GEOM::GEOM_Object_ptr thePoint1,
1012 GEOM::GEOM_Object_ptr thePoint2)
1014 //Set a not done flag
1015 GetOperations()->SetNotDone();
1016 GEOM::GEOM_Object_var aGEOMObject;
1018 if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
1020 //check if the object is a subshape
1021 if(!theObject->IsMainShape()) {
1022 GetOperations()->SetErrorCode(SUBSHAPE_ERROR);
1023 return aGEOMObject._retn();
1026 aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject);
1028 //Get the object itself
1029 Handle(GEOM_Object) anObject =
1030 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1031 if (anObject.IsNull()) return aGEOMObject._retn();
1033 //Get the central point of rotation
1034 Handle(GEOM_Object) aCentPoint =
1035 GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
1036 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1038 //Get the first point
1039 Handle(GEOM_Object) aPoint1 =
1040 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
1041 if (aPoint1.IsNull()) return aGEOMObject._retn();
1043 //Get the second point
1044 Handle(GEOM_Object) aPoint2 =
1045 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
1046 if (aPoint2.IsNull()) return aGEOMObject._retn();
1048 //Perform the translation
1049 GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
1051 return aGEOMObject._retn();
1054 //=============================================================================
1056 * RotateThreePointsCopy
1058 //=============================================================================
1059 GEOM::GEOM_Object_ptr GEOM_ITransformOperations_i::RotateThreePointsCopy
1060 (GEOM::GEOM_Object_ptr theObject,
1061 GEOM::GEOM_Object_ptr theCentPoint,
1062 GEOM::GEOM_Object_ptr thePoint1,
1063 GEOM::GEOM_Object_ptr thePoint2)
1065 GEOM::GEOM_Object_var aGEOMObject;
1067 //Set a not done flag
1068 GetOperations()->SetNotDone();
1070 if (theCentPoint == NULL || thePoint1 == NULL || thePoint2 == NULL || theObject == NULL) return aGEOMObject._retn();
1072 //Get the object itself
1073 Handle(GEOM_Object) aBasicObject =
1074 GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry());
1075 if (aBasicObject.IsNull()) return aGEOMObject._retn();
1077 //Get the central point of rotation
1078 Handle(GEOM_Object) aCentPoint =
1079 GetOperations()->GetEngine()->GetObject(theCentPoint->GetStudyID(), theCentPoint->GetEntry());
1080 if (aCentPoint.IsNull()) return aGEOMObject._retn();
1082 //Get the first point
1083 Handle(GEOM_Object) aPoint1 =
1084 GetOperations()->GetEngine()->GetObject(thePoint1->GetStudyID(), thePoint1->GetEntry());
1085 if (aPoint1.IsNull()) return aGEOMObject._retn();
1087 //Get the second point
1088 Handle(GEOM_Object) aPoint2 =
1089 GetOperations()->GetEngine()->GetObject(thePoint2->GetStudyID(), thePoint2->GetEntry());
1090 if (aPoint2.IsNull()) return aGEOMObject._retn();
1092 //Perform the rotation
1093 Handle(GEOM_Object) anObject =
1094 GetOperations()->RotateThreePointsCopy(aBasicObject, aCentPoint, aPoint1, aPoint2);
1095 if (!GetOperations()->IsDone() || anObject.IsNull())
1096 return aGEOMObject._retn();
1098 return GetObject(anObject);