1 // Copyright (C) 2007-2014 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 <GEOMImpl_ITransformOperations.hxx>
27 #include <GEOMImpl_TranslateDriver.hxx>
28 #include <GEOMImpl_MirrorDriver.hxx>
29 #include <GEOMImpl_ProjectionDriver.hxx>
30 #include <GEOMImpl_OffsetDriver.hxx>
31 #include <GEOMImpl_ScaleDriver.hxx>
32 #include <GEOMImpl_RotateDriver.hxx>
33 #include <GEOMImpl_PositionDriver.hxx>
35 #include <GEOMImpl_ITranslate.hxx>
36 #include <GEOMImpl_IMirror.hxx>
37 #include <GEOMImpl_IProjection.hxx>
38 #include <GEOMImpl_IOffset.hxx>
39 #include <GEOMImpl_IScale.hxx>
40 #include <GEOMImpl_IRotate.hxx>
41 #include <GEOMImpl_IPosition.hxx>
43 #include <GEOMImpl_Types.hxx>
45 #include <GEOM_Function.hxx>
46 #include <GEOM_PythonDump.hxx>
48 #include <Basics_OCCTVersion.hxx>
50 #include "utilities.h"
52 #include <Utils_ExceptHandlers.hxx>
54 #include <TFunction_DriverTable.hxx>
55 #include <TFunction_Driver.hxx>
56 #include <TFunction_Logbook.hxx>
57 #include <TDF_Tool.hxx>
59 #include <BRep_Tool.hxx>
60 #include <BRep_Builder.hxx>
63 #include <TopoDS_Edge.hxx>
64 #include <TopoDS_Vertex.hxx>
65 #include <TopoDS_Compound.hxx>
68 #include <gp_Trsf.hxx>
70 #include <StdFail_NotDone.hxx>
71 #include <Standard_Failure.hxx>
72 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
74 //=============================================================================
78 //=============================================================================
80 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
81 : GEOM_IOperations(theEngine, theDocID)
83 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
86 //=============================================================================
90 //=============================================================================
92 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
94 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
98 //=============================================================================
102 //=============================================================================
103 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
104 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
108 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
110 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
111 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
113 // Get last functions of the arguments
114 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
115 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
117 //Add a translate function
118 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
120 if (aFunction.IsNull()) return NULL;
122 //Check if the function is set correctly
123 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
125 GEOMImpl_ITranslate aTI (aFunction);
128 aTI.SetOriginal(aLastFunction);
130 //Compute the translation
132 #if OCC_VERSION_LARGE > 0x06010000
135 if (!GetSolver()->ComputeFunction(aFunction)) {
136 SetErrorCode("Translation driver failed");
140 catch (Standard_Failure) {
141 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
142 SetErrorCode(aFail->GetMessageString());
146 //Make a Python command
147 GEOM::TPythonDump(aFunction) << "geompy.TranslateTwoPoints("
148 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
154 //=============================================================================
158 //=============================================================================
159 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
160 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
164 if (theObject.IsNull()) return NULL;
166 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
167 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
169 //Add a translate function
170 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
172 if (aFunction.IsNull()) return NULL;
174 //Check if the function is set correctly
175 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
177 GEOMImpl_ITranslate aTI(aFunction);
181 aTI.SetOriginal(aLastFunction);
183 //Compute the translation
185 #if OCC_VERSION_LARGE > 0x06010000
188 if (!GetSolver()->ComputeFunction(aFunction)) {
189 SetErrorCode("Translation driver failed");
193 catch (Standard_Failure) {
194 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
195 SetErrorCode(aFail->GetMessageString());
199 //Make a Python command
200 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
201 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
208 //=============================================================================
210 * TranslateTwoPointsCopy
212 //=============================================================================
213 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
214 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
218 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
220 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
221 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
223 //Add a new Copy object
224 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
226 //Add a translate function
227 Handle(GEOM_Function) aFunction =
228 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
230 //Check if the function is set correctly
231 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
233 GEOMImpl_ITranslate aTI(aFunction);
234 aTI.SetPoint1(thePoint1->GetLastFunction());
235 aTI.SetPoint2(thePoint2->GetLastFunction());
236 //aTI.SetShape(theObject->GetValue());
237 aTI.SetOriginal(aLastFunction);
239 //Compute the translation
241 #if OCC_VERSION_LARGE > 0x06010000
244 if (!GetSolver()->ComputeFunction(aFunction)) {
245 SetErrorCode("Translation driver failed");
249 catch (Standard_Failure) {
250 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
251 SetErrorCode(aFail->GetMessageString());
255 //Make a Python command
256 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
257 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
263 //=============================================================================
265 * TranslateDXDYDZCopy
267 //=============================================================================
268 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
269 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
273 if (theObject.IsNull()) return NULL;
275 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
276 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
278 //Add a new Copy object
279 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
281 //Add a translate function
282 Handle(GEOM_Function) aFunction =
283 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
285 //Check if the function is set correctly
286 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
288 GEOMImpl_ITranslate aTI(aFunction);
292 aTI.SetOriginal(aLastFunction);
294 //Compute the translation
296 #if OCC_VERSION_LARGE > 0x06010000
299 if (!GetSolver()->ComputeFunction(aFunction)) {
300 SetErrorCode("Translation driver failed");
304 catch (Standard_Failure) {
305 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
306 SetErrorCode(aFail->GetMessageString());
310 //Make a Python command
311 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
312 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
319 //=============================================================================
323 //=============================================================================
324 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
325 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
329 if (theObject.IsNull() || theVector.IsNull()) return NULL;
331 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
332 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
334 // Get last functions of the arguments
335 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
337 //Add a translate function
338 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
340 if (aFunction.IsNull()) return NULL;
342 //Check if the function is set correctly
343 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
345 GEOMImpl_ITranslate aTI (aFunction);
347 aTI.SetOriginal(aLastFunction);
349 //Compute the translation
351 #if OCC_VERSION_LARGE > 0x06010000
354 if (!GetSolver()->ComputeFunction(aFunction)) {
355 SetErrorCode("Translation driver failed");
359 catch (Standard_Failure) {
360 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
361 SetErrorCode(aFail->GetMessageString());
365 //Make a Python command
366 GEOM::TPythonDump(aFunction) << "geompy.TranslateVector("
367 << theObject << ", " << theVector << ")";
372 //=============================================================================
374 * TranslateVectorCopy
376 //=============================================================================
377 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
378 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
382 if (theObject.IsNull() || theVector.IsNull()) return NULL;
384 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
385 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
387 //Add a new Copy object
388 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
390 //Add a translate function
391 Handle(GEOM_Function) aFunction =
392 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
394 //Check if the function is set correctly
395 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
397 GEOMImpl_ITranslate aTI(aFunction);
398 aTI.SetVector(theVector->GetLastFunction());
399 // aTI.SetShape(theObject->GetValue());
400 aTI.SetOriginal(aLastFunction);
402 //Compute the translation
404 #if OCC_VERSION_LARGE > 0x06010000
407 if (!GetSolver()->ComputeFunction(aFunction)) {
408 SetErrorCode("Translation driver failed");
412 catch (Standard_Failure) {
413 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
414 SetErrorCode(aFail->GetMessageString());
418 //Make a Python command
419 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
420 << theObject << ", " << theVector << ")";
426 //=============================================================================
428 * TranslateVectorDistance
430 //=============================================================================
431 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
432 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
436 if (theObject.IsNull() || theVector.IsNull()) return NULL;
438 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
439 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
441 Handle(GEOM_Object) aCopy; //Add a new Copy object
442 Handle(GEOM_Function) aFunction;
444 //Add a translate function
446 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
447 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
450 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
452 if (aFunction.IsNull()) return NULL;
454 //Check if the function is set correctly
455 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
457 GEOMImpl_ITranslate aTI(aFunction);
458 aTI.SetVector(theVector->GetLastFunction());
459 aTI.SetDistance(theDistance);
460 // aTI.SetShape(theObject->GetValue());
461 aTI.SetOriginal(aLastFunction);
463 //Compute the translation
465 #if OCC_VERSION_LARGE > 0x06010000
468 if (!GetSolver()->ComputeFunction(aFunction)) {
469 SetErrorCode("Translation driver failed");
473 catch (Standard_Failure) {
474 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
475 SetErrorCode(aFail->GetMessageString());
479 //Make a Python command
481 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
482 << theObject << ", " << theVector << ", " << theDistance << ")";
487 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
488 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
493 //=============================================================================
497 //=============================================================================
498 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
499 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
500 double theStep, Standard_Integer theNbTimes)
504 if (theObject.IsNull()) return NULL;
506 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
507 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
509 //Add a new Copy object
510 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
512 //Add a translate function
513 Handle(GEOM_Function) aFunction =
514 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
516 //Check if the function is set correctly
517 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
519 GEOMImpl_ITranslate aTI (aFunction);
520 aTI.SetOriginal(aLastFunction);
521 if (!theVector.IsNull())
522 aTI.SetVector(theVector->GetLastFunction());
523 aTI.SetStep1(theStep);
524 aTI.SetNbIter1(theNbTimes);
526 //Compute the translation
528 #if OCC_VERSION_LARGE > 0x06010000
531 if (!GetSolver()->ComputeFunction(aFunction)) {
532 SetErrorCode("Translation driver failed");
536 catch (Standard_Failure) {
537 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
538 SetErrorCode(aFail->GetMessageString());
542 //Make a Python command
543 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
544 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
550 //=============================================================================
554 //=============================================================================
555 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
556 Handle(GEOM_Object) theVector,
558 Standard_Integer theNbTimes1,
559 Handle(GEOM_Object) theVector2,
561 Standard_Integer theNbTimes2)
565 if (theObject.IsNull()) return NULL;
567 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
568 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
570 //Add a new Copy object
571 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
573 //Add a translate function
574 Handle(GEOM_Function) aFunction =
575 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
577 //Check if the function is set correctly
578 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
580 GEOMImpl_ITranslate aTI (aFunction);
581 aTI.SetOriginal(aLastFunction);
582 if (!theVector.IsNull())
583 aTI.SetVector(theVector->GetLastFunction());
584 aTI.SetStep1(theStep1);
585 aTI.SetNbIter1(theNbTimes1);
586 if (!theVector2.IsNull())
587 aTI.SetVector2(theVector2->GetLastFunction());
588 aTI.SetStep2(theStep2);
589 aTI.SetNbIter2(theNbTimes2);
591 //Compute the translation
593 #if OCC_VERSION_LARGE > 0x06010000
596 if (!GetSolver()->ComputeFunction(aFunction)) {
597 SetErrorCode("Translation driver failed");
601 catch (Standard_Failure) {
602 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
603 SetErrorCode(aFail->GetMessageString());
607 //Make a Python command
608 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
609 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
610 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
616 //=============================================================================
620 //=============================================================================
622 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape& theShape,
623 GEOMImpl_ITranslate* theTI)
628 Handle(GEOM_Function) aVector = theTI->GetVector();
629 if (aVector.IsNull()) {
630 StdFail_NotDone::Raise("Invalid object is given for vector argument");
632 TopoDS_Shape aV = aVector->GetValue();
633 if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
634 StdFail_NotDone::Raise("Invalid object is given for vector argument");
636 TopoDS_Edge anEdge = TopoDS::Edge(aV);
638 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
639 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
640 if (aP1.Distance(aP2) < gp::Resolution()) {
641 StdFail_NotDone::Raise("Invalid object is given for vector argument");
645 Standard_Real step = theTI->GetStep1();
646 Standard_Integer nbtimes = theTI->GetNbIter1();
648 // Make multi-translation
651 TopoDS_Compound aCompound;
653 B.MakeCompound(aCompound);
655 gp_Vec Vec (aP1, aP2);
658 TopLoc_Location aLocOrig = theShape.Location();
659 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
661 for (int i = 0; i < nbtimes; i++) {
662 aVec = Vec * (i * step);
663 aTrsf.SetTranslation(aVec);
664 //NPAL18620: performance problem: multiple locations are accumulated
665 // in shape and need a great time to process
666 //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
667 //B.Add(aCompound, aTransformation.Shape());
668 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
669 B.Add(aCompound, theShape.Located(aLocRes));
677 //=============================================================================
681 //=============================================================================
683 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape& theShape,
684 GEOMImpl_ITranslate* theTI)
689 Handle(GEOM_Function) aVector1 = theTI->GetVector();
690 Handle(GEOM_Function) aVector2 = theTI->GetVector2();
692 if (aVector1.IsNull() || aVector2.IsNull()) {
693 StdFail_NotDone::Raise("Invalid object is given for vector argument");
696 TopoDS_Shape aV1 = aVector1->GetValue();
697 TopoDS_Shape aV2 = aVector2->GetValue();
699 if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
700 aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
701 StdFail_NotDone::Raise("Invalid object is given for vector argument");
704 TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
705 TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
707 gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
708 gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
709 gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
710 gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
712 if (aP11.Distance(aP12) < gp::Resolution() ||
713 aP21.Distance(aP22) < gp::Resolution()) {
714 StdFail_NotDone::Raise("Invalid object is given for vector argument");
717 gp_Vec Vec1 (aP11, aP12);
718 gp_Vec Vec2 (aP21, aP22);
724 Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
725 Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
727 // Make multi-translation
730 Standard_Real DX, DY, DZ;
731 TopoDS_Compound aCompound;
733 B.MakeCompound(aCompound);
735 TopLoc_Location aLocOrig = theShape.Location();
736 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
738 for (int i = 0; i < nbtimes1; i++) {
739 for (int j = 0; j < nbtimes2; j++) {
740 DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
741 DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
742 DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
743 aVec.SetCoord(DX, DY, DZ);
744 aTrsf.SetTranslation(aVec);
745 //NPAL18620: performance problem: multiple locations are accumulated
746 // in shape and need a great time to process
747 //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
748 //B.Add(aCompound, aBRepTransformation.Shape());
749 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
750 B.Add(aCompound, theShape.Located(aLocRes));
759 //=============================================================================
763 //=============================================================================
764 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
765 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
769 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
771 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
772 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
774 // Get last functions of the arguments
775 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
777 //Add a mirror function
778 Handle(GEOM_Function) aFunction =
779 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
780 if (aFunction.IsNull()) return NULL;
782 //Check if the function is set correctly
783 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
785 GEOMImpl_IMirror aTI (aFunction);
787 aTI.SetOriginal(aLastFunction);
791 #if OCC_VERSION_LARGE > 0x06010000
794 if (!GetSolver()->ComputeFunction(aFunction)) {
795 SetErrorCode("Mirror driver failed");
799 catch (Standard_Failure) {
800 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
801 SetErrorCode(aFail->GetMessageString());
805 //Make a Python command
806 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPlane("
807 << theObject << ", " << thePlane << ")";
813 //=============================================================================
817 //=============================================================================
818 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
819 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
823 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
825 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
826 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
828 //Add a new Copy object
829 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
831 //Add a mirror function
832 Handle(GEOM_Function) aFunction =
833 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
835 //Check if the function is set correctly
836 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
838 GEOMImpl_IMirror aTI (aFunction);
839 aTI.SetPlane(thePlane->GetLastFunction());
840 aTI.SetOriginal(aLastFunction);
844 #if OCC_VERSION_LARGE > 0x06010000
847 if (!GetSolver()->ComputeFunction(aFunction)) {
848 SetErrorCode("Mirror driver failed");
852 catch (Standard_Failure) {
853 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
854 SetErrorCode(aFail->GetMessageString());
858 //Make a Python command
859 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
860 << theObject << ", " << thePlane << ")";
866 //=============================================================================
870 //=============================================================================
871 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
872 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
876 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
878 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
879 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
881 // Get last functions of the arguments
882 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
884 //Add a mirror function
885 Handle(GEOM_Function) aFunction =
886 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
887 if (aFunction.IsNull()) return NULL;
889 //Check if the function is set correctly
890 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
892 GEOMImpl_IMirror aTI (aFunction);
894 aTI.SetOriginal(aLastFunction);
898 #if OCC_VERSION_LARGE > 0x06010000
901 if (!GetSolver()->ComputeFunction(aFunction)) {
902 SetErrorCode("Mirror driver failed");
906 catch (Standard_Failure) {
907 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
908 SetErrorCode(aFail->GetMessageString());
912 //Make a Python command
913 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPoint("
914 << theObject << ", " << thePoint << ")";
920 //=============================================================================
924 //=============================================================================
925 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
926 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
930 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
932 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
933 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
935 //Add a new Copy object
936 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
938 //Add a mirror function
939 Handle(GEOM_Function) aFunction =
940 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
942 //Check if the function is set correctly
943 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
945 GEOMImpl_IMirror aTI (aFunction);
946 aTI.SetPoint(thePoint->GetLastFunction());
947 aTI.SetOriginal(aLastFunction);
951 #if OCC_VERSION_LARGE > 0x06010000
954 if (!GetSolver()->ComputeFunction(aFunction)) {
955 SetErrorCode("Mirror driver failed");
959 catch (Standard_Failure) {
960 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
961 SetErrorCode(aFail->GetMessageString());
965 //Make a Python command
966 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
967 << theObject << ", " << thePoint << ")";
973 //=============================================================================
977 //=============================================================================
978 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
979 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
983 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
985 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
986 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
988 // Get last functions of the arguments
989 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
991 //Add a mirror function
992 Handle(GEOM_Function) aFunction =
993 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
994 if (aFunction.IsNull()) return NULL;
996 //Check if the function is set correctly
997 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
999 GEOMImpl_IMirror aTI (aFunction);
1001 aTI.SetOriginal(aLastFunction);
1003 //Compute the mirror
1005 #if OCC_VERSION_LARGE > 0x06010000
1008 if (!GetSolver()->ComputeFunction(aFunction)) {
1009 SetErrorCode("Mirror driver failed");
1013 catch (Standard_Failure) {
1014 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1015 SetErrorCode(aFail->GetMessageString());
1019 //Make a Python command
1020 GEOM::TPythonDump(aFunction) << "geompy.MirrorByAxis("
1021 << theObject << ", " << theAxis << ")";
1027 //=============================================================================
1031 //=============================================================================
1032 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
1033 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
1037 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1039 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1040 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
1042 //Add a new Copy object
1043 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1045 //Add a mirror function
1046 Handle(GEOM_Function) aFunction =
1047 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
1049 //Check if the function is set correctly
1050 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
1052 GEOMImpl_IMirror aTI (aFunction);
1053 aTI.SetAxis(theAxis->GetLastFunction());
1054 aTI.SetOriginal(aLastFunction);
1056 //Compute the mirror
1058 #if OCC_VERSION_LARGE > 0x06010000
1061 if (!GetSolver()->ComputeFunction(aFunction)) {
1062 SetErrorCode("Mirror driver failed");
1066 catch (Standard_Failure) {
1067 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1068 SetErrorCode(aFail->GetMessageString());
1072 //Make a Python command
1073 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
1074 << theObject << ", " << theAxis << ")";
1081 //=============================================================================
1085 //=============================================================================
1086 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
1087 (Handle(GEOM_Object) theObject, double theOffset)
1091 if (theObject.IsNull()) return NULL;
1093 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1094 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1096 //Add a new Offset function
1097 Handle(GEOM_Function) aFunction =
1098 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1099 if (aFunction.IsNull()) return NULL;
1101 //Check if the function is set correctly
1102 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1104 GEOMImpl_IOffset aTI (aFunction);
1105 aTI.SetShape(anOriginal);
1106 aTI.SetValue(theOffset);
1108 //Compute the offset
1110 #if OCC_VERSION_LARGE > 0x06010000
1113 if (!GetSolver()->ComputeFunction(aFunction)) {
1114 SetErrorCode("Offset driver failed");
1118 catch (Standard_Failure) {
1119 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1120 SetErrorCode(aFail->GetMessageString());
1124 //Make a Python command
1125 GEOM::TPythonDump(aFunction) << "geompy.Offset("
1126 << theObject << ", " << theOffset << ")";
1132 //=============================================================================
1136 //=============================================================================
1137 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1138 (Handle(GEOM_Object) theObject, double theOffset)
1142 if (theObject.IsNull()) return NULL;
1144 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1145 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1147 //Add a new Copy object
1148 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1150 //Add a new Offset function
1151 Handle(GEOM_Function) aFunction =
1152 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1153 if (aFunction.IsNull()) return NULL;
1155 //Check if the function is set correctly
1156 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1158 GEOMImpl_IOffset aTI (aFunction);
1159 aTI.SetShape(anOriginal);
1160 aTI.SetValue(theOffset);
1162 //Compute the offset
1164 #if OCC_VERSION_LARGE > 0x06010000
1167 if (!GetSolver()->ComputeFunction(aFunction)) {
1168 SetErrorCode("Offset driver failed");
1172 catch (Standard_Failure) {
1173 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1174 SetErrorCode(aFail->GetMessageString());
1178 //Make a Python command
1179 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1180 << theObject << ", " << theOffset << ")";
1187 //=============================================================================
1191 //=============================================================================
1192 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ProjectShapeCopy
1193 (Handle(GEOM_Object) theSource, Handle(GEOM_Object) theTarget)
1197 if (theSource.IsNull() || theTarget.IsNull()) return NULL;
1199 Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
1200 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
1202 //Add a new Projection object
1203 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1205 //Add a Projection function
1206 Handle(GEOM_Function) aFunction =
1207 aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
1209 //Check if the function is set correctly
1210 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
1212 GEOMImpl_IMirror aTI (aFunction);
1213 aTI.SetPlane(theTarget->GetLastFunction());
1214 aTI.SetOriginal(aLastFunction);
1216 //Compute the Projection
1218 #if OCC_VERSION_LARGE > 0x06010000
1221 if (!GetSolver()->ComputeFunction(aFunction)) {
1222 SetErrorCode("Projection driver failed");
1226 catch (Standard_Failure) {
1227 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1228 SetErrorCode(aFail->GetMessageString());
1232 //Make a Python command
1233 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
1234 << theSource << ", " << theTarget << ")";
1240 //=============================================================================
1242 * ProjectPointOnWire
1244 //=============================================================================
1245 Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire
1246 (Handle(GEOM_Object) thePoint,
1247 Handle(GEOM_Object) theWire,
1248 Handle(GEOM_Object) &thePointOnEdge,
1249 Standard_Integer &theEdgeInWireIndex)
1251 Standard_Real aResult = -1.;
1255 if (thePoint.IsNull() || theWire.IsNull()) {
1259 Handle(GEOM_Function) aLastFunction = thePoint->GetLastFunction();
1261 if (aLastFunction.IsNull()) {
1262 //There is no function which creates an object to be projected
1266 //Add a new Projection object
1267 thePointOnEdge = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1269 //Add a Projection function
1270 Handle(GEOM_Function) aFunction = thePointOnEdge->AddFunction
1271 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_WIRE);
1273 //Check if the function is set correctly
1274 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
1278 GEOMImpl_IProjection aProj (aFunction);
1279 aProj.SetPoint(aLastFunction);
1280 aProj.SetShape(theWire->GetLastFunction());
1282 //Compute the Projection
1284 #if OCC_VERSION_LARGE > 0x06010000
1287 if (!GetSolver()->ComputeFunction(aFunction)) {
1288 SetErrorCode("Projection driver failed");
1292 catch (Standard_Failure) {
1293 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1294 SetErrorCode(aFail->GetMessageString());
1298 aResult = aProj.GetU();
1299 theEdgeInWireIndex = aProj.GetIndex();
1302 //Make a Python command
1303 GEOM::TPythonDump(aFunction) << "(u, " << thePointOnEdge
1304 << ", EdgeInWireIndex) = geompy.MakeProjectionOnWire(" << thePoint
1305 << ", " << theWire << ")";
1312 //=============================================================================
1316 //=============================================================================
1317 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1318 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1322 if (theObject.IsNull()) return NULL;
1324 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1325 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1327 //Add a scale function
1328 Handle(GEOM_Function) aFunction =
1329 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1330 if (aFunction.IsNull()) return NULL;
1332 //Check if the function is set correctly
1333 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1336 GEOMImpl_IScale aTI (aFunction);
1337 aTI.SetShape(anOriginal);
1338 aTI.SetFactor(theFactor);
1340 // Set point argument
1341 if (!thePoint.IsNull()) {
1342 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1348 #if OCC_VERSION_LARGE > 0x06010000
1351 if (!GetSolver()->ComputeFunction(aFunction)) {
1352 SetErrorCode("Scale driver failed");
1356 catch (Standard_Failure) {
1357 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1358 SetErrorCode(aFail->GetMessageString());
1362 //Make a Python command
1363 GEOM::TPythonDump(aFunction) << "geompy.Scale("
1364 << theObject << ", " << thePoint << ", " << theFactor << ")";
1370 //=============================================================================
1374 //=============================================================================
1375 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1376 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1380 if (theObject.IsNull()) return NULL;
1382 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1383 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1385 //Add a new Copy object
1386 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1388 //Add a scale function
1389 Handle(GEOM_Function) aFunction =
1390 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1391 if (aFunction.IsNull()) return NULL;
1393 //Check if the function is set correctly
1394 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1397 GEOMImpl_IScale aTI (aFunction);
1398 aTI.SetShape(anOriginal);
1399 aTI.SetFactor(theFactor);
1401 // Set point argument
1402 if (!thePoint.IsNull()) {
1403 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1409 #if OCC_VERSION_LARGE > 0x06010000
1412 if (!GetSolver()->ComputeFunction(aFunction)) {
1413 SetErrorCode("Scale driver failed");
1417 catch (Standard_Failure) {
1418 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1419 SetErrorCode(aFail->GetMessageString());
1423 //Make a Python command
1424 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1425 << theObject << ", " << thePoint << ", " << theFactor << ")";
1431 //=============================================================================
1433 * ScaleShapeAlongAxes
1435 //=============================================================================
1436 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1437 Handle(GEOM_Object) thePoint,
1445 if (theObject.IsNull()) return NULL;
1447 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1448 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1450 //Add a scale function
1451 Handle(GEOM_Object) aCopy; //Add a new Copy object
1452 Handle(GEOM_Function) aFunction;
1454 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1455 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1458 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1460 if (aFunction.IsNull()) return NULL;
1462 //Check if the function is set correctly
1463 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1466 GEOMImpl_IScale aTI (aFunction);
1467 aTI.SetShape(anOriginal);
1468 aTI.SetFactorX(theFactorX);
1469 aTI.SetFactorY(theFactorY);
1470 aTI.SetFactorZ(theFactorZ);
1472 // Set point (optional argument)
1473 if (!thePoint.IsNull()) {
1474 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1480 #if OCC_VERSION_LARGE > 0x06010000
1483 if (!GetSolver()->ComputeFunction(aFunction)) {
1484 SetErrorCode("Scale driver failed");
1488 catch (Standard_Failure) {
1489 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1490 SetErrorCode(aFail->GetMessageString());
1496 //Make a Python command
1498 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1499 << theObject << ", " << thePoint << ", "
1500 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1504 GEOM::TPythonDump(aFunction) << "geompy.ScaleAlongAxes("
1505 << theObject << ", " << thePoint << ", "
1506 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1510 //=============================================================================
1514 //=============================================================================
1515 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1516 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1520 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1522 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1523 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1525 //Add a Position function
1526 Standard_Integer aType = POSITION_SHAPE;
1527 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1529 Handle(GEOM_Function) aFunction =
1530 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1531 if (aFunction.IsNull()) return NULL;
1533 //Check if the function is set correctly
1534 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1536 //Set operation arguments
1537 GEOMImpl_IPosition aTI (aFunction);
1538 aTI.SetShape(anOriginal);
1539 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1540 if (!theStartLCS.IsNull())
1541 aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1543 //Compute the Position
1545 #if OCC_VERSION_LARGE > 0x06010000
1548 if (!GetSolver()->ComputeFunction(aFunction)) {
1549 SetErrorCode("Position driver failed");
1553 catch (Standard_Failure) {
1554 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1555 SetErrorCode(aFail->GetMessageString());
1559 //Make a Python command
1560 GEOM::TPythonDump(aFunction) << "geompy.Position("
1561 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1567 //=============================================================================
1571 //=============================================================================
1572 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1573 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1577 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1579 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1580 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1582 //Add a new Copy object
1583 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1585 //Add a position function
1586 Standard_Integer aType = POSITION_SHAPE_COPY;
1587 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1589 Handle(GEOM_Function) aFunction =
1590 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1591 if (aFunction.IsNull()) return NULL;
1593 //Check if the function is set correctly
1594 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1596 GEOMImpl_IPosition aTI (aFunction);
1597 aTI.SetShape(anOriginal);
1598 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1599 if (!theStartLCS.IsNull())
1600 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1602 //Compute the position
1604 #if OCC_VERSION_LARGE > 0x06010000
1607 if (!GetSolver()->ComputeFunction(aFunction)) {
1608 SetErrorCode("Position driver failed");
1612 catch (Standard_Failure) {
1613 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1614 SetErrorCode(aFail->GetMessageString());
1618 //Make a Python command
1619 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1620 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1626 //=============================================================================
1630 //=============================================================================
1631 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1632 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1633 double theDistance, bool theCopy, bool theReverse)
1637 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1639 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1640 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1642 //Add a position function
1643 Handle(GEOM_Function) aFunction;
1644 Handle(GEOM_Object) aCopy;
1647 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1648 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1651 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1653 if (aFunction.IsNull()) return NULL;
1655 //Check if the function is set correctly
1656 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1658 GEOMImpl_IPosition aTI (aFunction);
1659 aTI.SetShape(anOriginal);
1660 aTI.SetPath(thePath->GetLastFunction());
1661 aTI.SetDistance(theDistance);
1662 aTI.SetReverse(theReverse);
1664 //Compute the position
1666 #if OCC_VERSION_LARGE > 0x06010000
1669 if (!GetSolver()->ComputeFunction(aFunction)) {
1670 SetErrorCode("Position driver failed");
1674 catch (Standard_Failure) {
1675 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1676 SetErrorCode(aFail->GetMessageString());
1680 //Make a Python command
1682 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePositionAlongPath("
1683 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1688 GEOM::TPythonDump(aFunction) << "geompy.PositionAlongPath("
1689 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1695 //=============================================================================
1699 //=============================================================================
1700 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1701 Handle(GEOM_Object) theAxis,
1706 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1708 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1709 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1711 // Get last functions of the arguments
1712 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1714 //Add a rotate function
1715 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1717 if (aFunction.IsNull()) return NULL;
1719 //Check if the function is set correctly
1720 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1722 GEOMImpl_IRotate aRI(aFunction);
1724 aRI.SetOriginal(aLastFunction);
1725 aRI.SetAngle(theAngle);
1727 //Compute the translation
1729 #if OCC_VERSION_LARGE > 0x06010000
1732 if (!GetSolver()->ComputeFunction(aFunction)) {
1733 SetErrorCode("Rotate driver failed");
1737 catch (Standard_Failure) {
1738 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1739 SetErrorCode(aFail->GetMessageString());
1743 //Make a Python command
1744 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1745 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1751 //=============================================================================
1755 //=============================================================================
1756 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject,
1757 Handle(GEOM_Object) theAxis,
1762 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1764 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1765 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1767 //Add a new Copy object
1768 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1770 //Add a rotate function
1771 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1772 if (aFunction.IsNull()) return NULL;
1774 //Check if the function is set correctly
1775 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1777 GEOMImpl_IRotate aRI(aFunction);
1778 aRI.SetAxis(theAxis->GetLastFunction());
1779 aRI.SetOriginal(aLastFunction);
1780 aRI.SetAngle(theAngle);
1782 //Compute the translation
1784 #if OCC_VERSION_LARGE > 0x06010000
1787 if (!GetSolver()->ComputeFunction(aFunction)) {
1788 SetErrorCode("Rotate driver failed");
1792 catch (Standard_Failure) {
1793 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1794 SetErrorCode(aFail->GetMessageString());
1798 //Make a Python command
1799 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1800 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1806 //=============================================================================
1808 * Rotate1D (for MultiRotate1DNbTimes)
1810 //=============================================================================
1811 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1812 Handle(GEOM_Object) theAxis,
1813 Standard_Integer theNbTimes)
1817 if (theObject.IsNull()) return NULL;
1819 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1820 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1822 //Add a new Copy object
1823 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1825 //Add a rotate function
1826 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1827 if (aFunction.IsNull()) return NULL;
1829 //Check if the function is set correctly
1830 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1832 GEOMImpl_IRotate aRI(aFunction);
1833 aRI.SetOriginal(aLastFunction);
1834 if (!theAxis.IsNull())
1835 aRI.SetAxis(theAxis->GetLastFunction());
1836 aRI.SetNbIter1(theNbTimes);
1838 //Compute the translation
1840 #if OCC_VERSION_LARGE > 0x06010000
1843 if (!GetSolver()->ComputeFunction(aFunction)) {
1844 SetErrorCode("Rotate driver failed");
1848 catch (Standard_Failure) {
1849 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1850 SetErrorCode(aFail->GetMessageString());
1854 //Make a Python command
1855 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1DNbTimes("
1856 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1862 //=============================================================================
1864 * Rotate1D (for MultiRotate1DByStep)
1866 //=============================================================================
1867 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1868 Handle(GEOM_Object) theAxis,
1869 double theAngleStep,
1870 Standard_Integer theNbSteps)
1874 if (theObject.IsNull()) return NULL;
1876 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1877 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1879 //Add a new Copy object
1880 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1882 //Add a rotate function
1883 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D_STEP);
1884 if (aFunction.IsNull()) return NULL;
1886 //Check if the function is set correctly
1887 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1889 //Convert angle into degrees
1890 double anAngleStep = theAngleStep * 180. / M_PI;
1892 GEOMImpl_IRotate aRI (aFunction);
1893 aRI.SetOriginal(aLastFunction);
1894 if (!theAxis.IsNull())
1895 aRI.SetAxis(theAxis->GetLastFunction());
1896 aRI.SetAngle(anAngleStep);
1897 aRI.SetNbIter1(theNbSteps);
1899 //Compute the translation
1901 #if OCC_VERSION_LARGE > 0x06010000
1904 if (!GetSolver()->ComputeFunction(aFunction)) {
1905 SetErrorCode("Rotate driver failed");
1909 catch (Standard_Failure) {
1910 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1911 SetErrorCode(aFail->GetMessageString());
1915 //Make a Python command
1916 GEOM::TPythonDump(aFunction)
1917 << aCopy << " = geompy.MultiRotate1DByStep(" << theObject << ", "
1918 << theAxis << ", " << anAngleStep << "*math.pi/180.0, " << theNbSteps << ")";
1924 //=============================================================================
1926 * Rotate2D (for MultiRotate2DNbTimes)
1928 //=============================================================================
1929 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1930 Handle(GEOM_Object) theAxis,
1931 Standard_Integer theNbObjects,
1932 double theRadialStep,
1933 Standard_Integer theNbSteps)
1937 if (theObject.IsNull()) return NULL;
1939 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1940 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1942 //Add a new Copy object
1943 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1945 //Add a rotate function
1946 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1947 if (aFunction.IsNull()) return NULL;
1949 //Check if the function is set correctly
1950 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1952 double anAngle = 360. / (double)theNbObjects;
1954 GEOMImpl_IRotate aRI (aFunction);
1955 aRI.SetOriginal(aLastFunction);
1956 if (!theAxis.IsNull())
1957 aRI.SetAxis(theAxis->GetLastFunction());
1958 aRI.SetAngle(anAngle);
1959 aRI.SetNbIter1(theNbObjects);
1960 aRI.SetStep(theRadialStep);
1961 aRI.SetNbIter2(theNbSteps);
1963 //Compute the translation
1965 #if OCC_VERSION_LARGE > 0x06010000
1968 if (!GetSolver()->ComputeFunction(aFunction)) {
1969 SetErrorCode("Rotate driver failed");
1973 catch (Standard_Failure) {
1974 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1975 SetErrorCode(aFail->GetMessageString());
1979 //Make a Python command
1980 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2DNbTimes("
1981 << theObject << ", " << theAxis << ", " << theNbObjects
1982 << ", " << theRadialStep << ", " << theNbSteps << ")";
1988 //=============================================================================
1990 * Rotate2D (for MultiRotate2DByStep)
1992 //=============================================================================
1993 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1994 Handle(GEOM_Object) theAxis,
1995 double theAngleStep,
1996 Standard_Integer theNbTimes1,
1998 Standard_Integer theNbTimes2)
2002 if (theObject.IsNull()) return NULL;
2004 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2005 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2007 //Add a new Copy object
2008 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2010 //Add a rotate function
2011 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
2012 if (aFunction.IsNull()) return NULL;
2014 //Check if the function is set correctly
2015 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2017 //Convert angle into degrees
2018 double anAngleStep = theAngleStep * 180. / M_PI;
2020 GEOMImpl_IRotate aRI (aFunction);
2021 aRI.SetOriginal(aLastFunction);
2022 if (!theAxis.IsNull())
2023 aRI.SetAxis(theAxis->GetLastFunction());
2024 aRI.SetAngle(anAngleStep);
2025 aRI.SetNbIter1(theNbTimes1);
2026 aRI.SetStep(theStep);
2027 aRI.SetNbIter2(theNbTimes2);
2029 //Compute the translation
2031 #if OCC_VERSION_LARGE > 0x06010000
2034 if (!GetSolver()->ComputeFunction(aFunction)) {
2035 SetErrorCode("Rotate driver failed");
2039 catch (Standard_Failure) {
2040 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2041 SetErrorCode(aFail->GetMessageString());
2045 //Make a Python command
2046 GEOM::TPythonDump(aFunction)
2047 << aCopy << " = geompy.MultiRotate2DByStep(" << theObject << ", "
2048 << theAxis << ", " << anAngleStep << "*math.pi/180.0, "
2049 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
2055 //=============================================================================
2059 //=============================================================================
2060 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
2061 Handle(GEOM_Object) theCentPoint,
2062 Handle(GEOM_Object) thePoint1,
2063 Handle(GEOM_Object) thePoint2)
2067 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2069 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2070 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2072 // Get last functions of the arguments
2073 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
2074 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
2075 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
2078 //Add a rotate function
2079 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
2081 if (aFunction.IsNull()) return NULL;
2083 //Check if the function is set correctly
2084 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2086 GEOMImpl_IRotate aRI(aFunction);
2087 aRI.SetCentPoint(aCPF);
2088 aRI.SetPoint1(aP1F);
2089 aRI.SetPoint2(aP2F);
2090 aRI.SetOriginal(aLastFunction);
2092 //Compute the translation
2094 #if OCC_VERSION_LARGE > 0x06010000
2097 if (!GetSolver()->ComputeFunction(aFunction)) {
2098 SetErrorCode("Rotate driver failed");
2102 catch (Standard_Failure) {
2103 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2104 SetErrorCode(aFail->GetMessageString());
2108 //Make a Python command
2109 GEOM::TPythonDump(aFunction) << "geompy.RotateThreePoints(" << theObject
2110 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2116 //=============================================================================
2118 * RotateThreePointsCopy
2120 //=============================================================================
2121 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
2122 Handle(GEOM_Object) theCentPoint,
2123 Handle(GEOM_Object) thePoint1,
2124 Handle(GEOM_Object) thePoint2)
2128 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2130 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2131 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2133 //Add a new Copy object
2134 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2136 //Add a rotate function
2137 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
2138 if (aFunction.IsNull()) return NULL;
2140 //Check if the function is set correctly
2141 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2143 GEOMImpl_IRotate aRI(aFunction);
2144 aRI.SetCentPoint(theCentPoint->GetLastFunction());
2145 aRI.SetPoint1(thePoint1->GetLastFunction());
2146 aRI.SetPoint2(thePoint2->GetLastFunction());
2147 aRI.SetOriginal(aLastFunction);
2149 //Compute the translation
2151 #if OCC_VERSION_LARGE > 0x06010000
2154 if (!GetSolver()->ComputeFunction(aFunction)) {
2155 SetErrorCode("Rotate driver failed");
2159 catch (Standard_Failure) {
2160 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2161 SetErrorCode(aFail->GetMessageString());
2165 //Make a Python command
2166 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
2167 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2173 //=============================================================================
2175 * TransformLikeOtherCopy
2177 //=============================================================================
2178 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
2179 (Handle(GEOM_Object) theObject,
2180 Handle(GEOM_Object) theSample)
2184 if (theObject.IsNull() || theSample.IsNull()) return NULL;
2186 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2187 if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
2189 Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
2190 if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
2192 // Add a new Copy object
2193 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2195 // Add a transform function (depends on theSample function)
2196 Handle(GEOM_Function) aFunction =
2197 aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
2198 if (aFunction.IsNull()) return NULL;
2200 // Check if the function is set correctly
2201 if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
2203 if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
2204 switch (aSampleFunc->GetType()) {
2207 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2208 GEOMImpl_ITranslate aRI_target (aFunction);
2210 aRI_target.SetVector(aRI_sample.GetVector());
2211 aRI_target.SetStep1(aRI_sample.GetStep1());
2212 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2214 aRI_target.SetOriginal(aLastFunction);
2219 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2220 GEOMImpl_ITranslate aRI_target (aFunction);
2222 aRI_target.SetVector(aRI_sample.GetVector());
2223 aRI_target.SetStep1(aRI_sample.GetStep1());
2224 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2226 aRI_target.SetVector2(aRI_sample.GetVector2());
2227 aRI_target.SetStep2(aRI_sample.GetStep2());
2228 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2230 aRI_target.SetOriginal(aLastFunction);
2235 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2240 else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
2241 switch (aSampleFunc->GetType()) {
2244 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2245 GEOMImpl_IRotate aRI_target (aFunction);
2247 aRI_target.SetAxis(aRI_sample.GetAxis());
2248 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2250 aRI_target.SetOriginal(aLastFunction);
2255 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2256 GEOMImpl_IRotate aRI_target (aFunction);
2258 aRI_target.SetAxis(aRI_sample.GetAxis());
2260 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2261 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2263 aRI_target.SetAngle(aRI_sample.GetAngle());
2264 aRI_target.SetStep(aRI_sample.GetStep());
2266 aRI_target.SetDir2(aRI_sample.GetDir2());
2268 aRI_target.SetOriginal(aLastFunction);
2271 case ROTATE_THREE_POINTS_COPY:
2273 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2274 GEOMImpl_IRotate aRI_target (aFunction);
2276 aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
2277 aRI_target.SetPoint1(aRI_sample.GetPoint1());
2278 aRI_target.SetPoint2(aRI_sample.GetPoint2());
2280 aRI_target.SetOriginal(aLastFunction);
2285 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2291 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2295 // Compute the transformation
2297 #if OCC_VERSION_LARGE > 0x06010000
2300 if (!GetSolver()->ComputeFunction(aFunction)) {
2301 SetErrorCode("Driver failed");
2305 catch (Standard_Failure) {
2306 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2307 SetErrorCode(aFail->GetMessageString());
2311 //Make a Python command
2312 //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
2313 // << theObject << ", " << theSample << ")";