1 // Copyright (C) 2007-2015 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_IProjOnCyl.hxx>
39 #include <GEOMImpl_IOffset.hxx>
40 #include <GEOMImpl_IScale.hxx>
41 #include <GEOMImpl_IRotate.hxx>
42 #include <GEOMImpl_IPosition.hxx>
44 #include <GEOMImpl_Types.hxx>
46 #include <GEOM_Function.hxx>
47 #include <GEOM_PythonDump.hxx>
49 #include <Basics_OCCTVersion.hxx>
51 #include "utilities.h"
53 #include <Utils_ExceptHandlers.hxx>
55 #include <TFunction_DriverTable.hxx>
56 #include <TFunction_Driver.hxx>
57 #include <TFunction_Logbook.hxx>
58 #include <TDF_Tool.hxx>
60 #include <BRep_Tool.hxx>
61 #include <BRep_Builder.hxx>
64 #include <TopoDS_Edge.hxx>
65 #include <TopoDS_Vertex.hxx>
66 #include <TopoDS_Compound.hxx>
69 #include <gp_Trsf.hxx>
71 #include <StdFail_NotDone.hxx>
72 #include <Standard_Failure.hxx>
73 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
75 //=============================================================================
79 //=============================================================================
81 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
82 : GEOM_IOperations(theEngine, theDocID)
84 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
87 //=============================================================================
91 //=============================================================================
93 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
95 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
99 //=============================================================================
103 //=============================================================================
104 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
105 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
109 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
111 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
112 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
114 // Get last functions of the arguments
115 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
116 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
118 //Add a translate function
119 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
121 if (aFunction.IsNull()) return NULL;
123 //Check if the function is set correctly
124 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
126 GEOMImpl_ITranslate aTI (aFunction);
129 aTI.SetOriginal(aLastFunction);
131 //Compute the translation
134 if (!GetSolver()->ComputeFunction(aFunction)) {
135 SetErrorCode("Translation driver failed");
139 catch (Standard_Failure) {
140 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
141 SetErrorCode(aFail->GetMessageString());
145 //Make a Python command
146 GEOM::TPythonDump(aFunction) << "geompy.TranslateTwoPoints("
147 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
153 //=============================================================================
157 //=============================================================================
158 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
159 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
163 if (theObject.IsNull()) return NULL;
165 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
166 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
168 //Add a translate function
169 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
171 if (aFunction.IsNull()) return NULL;
173 //Check if the function is set correctly
174 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
176 GEOMImpl_ITranslate aTI(aFunction);
180 aTI.SetOriginal(aLastFunction);
182 //Compute the translation
185 if (!GetSolver()->ComputeFunction(aFunction)) {
186 SetErrorCode("Translation driver failed");
190 catch (Standard_Failure) {
191 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
192 SetErrorCode(aFail->GetMessageString());
196 //Make a Python command
197 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
198 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
205 //=============================================================================
207 * TranslateTwoPointsCopy
209 //=============================================================================
210 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
211 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
215 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
217 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
218 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
220 //Add a new Copy object
221 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
223 //Add a translate function
224 Handle(GEOM_Function) aFunction =
225 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
227 //Check if the function is set correctly
228 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
230 GEOMImpl_ITranslate aTI(aFunction);
231 aTI.SetPoint1(thePoint1->GetLastFunction());
232 aTI.SetPoint2(thePoint2->GetLastFunction());
233 //aTI.SetShape(theObject->GetValue());
234 aTI.SetOriginal(aLastFunction);
236 //Compute the translation
239 if (!GetSolver()->ComputeFunction(aFunction)) {
240 SetErrorCode("Translation driver failed");
244 catch (Standard_Failure) {
245 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
246 SetErrorCode(aFail->GetMessageString());
250 //Make a Python command
251 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
252 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
258 //=============================================================================
260 * TranslateDXDYDZCopy
262 //=============================================================================
263 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
264 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
268 if (theObject.IsNull()) return NULL;
270 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
271 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
273 //Add a new Copy object
274 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
276 //Add a translate function
277 Handle(GEOM_Function) aFunction =
278 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
280 //Check if the function is set correctly
281 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
283 GEOMImpl_ITranslate aTI(aFunction);
287 aTI.SetOriginal(aLastFunction);
289 //Compute the translation
292 if (!GetSolver()->ComputeFunction(aFunction)) {
293 SetErrorCode("Translation driver failed");
297 catch (Standard_Failure) {
298 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
299 SetErrorCode(aFail->GetMessageString());
303 //Make a Python command
304 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
305 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
312 //=============================================================================
316 //=============================================================================
317 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
318 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
322 if (theObject.IsNull() || theVector.IsNull()) return NULL;
324 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
325 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
327 // Get last functions of the arguments
328 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
330 //Add a translate function
331 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
333 if (aFunction.IsNull()) return NULL;
335 //Check if the function is set correctly
336 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
338 GEOMImpl_ITranslate aTI (aFunction);
340 aTI.SetOriginal(aLastFunction);
342 //Compute the translation
345 if (!GetSolver()->ComputeFunction(aFunction)) {
346 SetErrorCode("Translation driver failed");
350 catch (Standard_Failure) {
351 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
352 SetErrorCode(aFail->GetMessageString());
356 //Make a Python command
357 GEOM::TPythonDump(aFunction) << "geompy.TranslateVector("
358 << theObject << ", " << theVector << ")";
363 //=============================================================================
365 * TranslateVectorCopy
367 //=============================================================================
368 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
369 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
373 if (theObject.IsNull() || theVector.IsNull()) return NULL;
375 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
376 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
378 //Add a new Copy object
379 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
381 //Add a translate function
382 Handle(GEOM_Function) aFunction =
383 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
385 //Check if the function is set correctly
386 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
388 GEOMImpl_ITranslate aTI(aFunction);
389 aTI.SetVector(theVector->GetLastFunction());
390 // aTI.SetShape(theObject->GetValue());
391 aTI.SetOriginal(aLastFunction);
393 //Compute the translation
396 if (!GetSolver()->ComputeFunction(aFunction)) {
397 SetErrorCode("Translation driver failed");
401 catch (Standard_Failure) {
402 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
403 SetErrorCode(aFail->GetMessageString());
407 //Make a Python command
408 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
409 << theObject << ", " << theVector << ")";
415 //=============================================================================
417 * TranslateVectorDistance
419 //=============================================================================
420 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
421 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
425 if (theObject.IsNull() || theVector.IsNull()) return NULL;
427 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
428 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
430 Handle(GEOM_Object) aCopy; //Add a new Copy object
431 Handle(GEOM_Function) aFunction;
433 //Add a translate function
435 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
436 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
439 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
441 if (aFunction.IsNull()) return NULL;
443 //Check if the function is set correctly
444 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
446 GEOMImpl_ITranslate aTI(aFunction);
447 aTI.SetVector(theVector->GetLastFunction());
448 aTI.SetDistance(theDistance);
449 // aTI.SetShape(theObject->GetValue());
450 aTI.SetOriginal(aLastFunction);
452 //Compute the translation
455 if (!GetSolver()->ComputeFunction(aFunction)) {
456 SetErrorCode("Translation driver failed");
460 catch (Standard_Failure) {
461 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
462 SetErrorCode(aFail->GetMessageString());
466 //Make a Python command
468 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
469 << theObject << ", " << theVector << ", " << theDistance << ")";
474 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
475 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
480 //=============================================================================
484 //=============================================================================
485 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
486 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
487 double theStep, Standard_Integer theNbTimes)
491 if (theObject.IsNull()) return NULL;
493 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
494 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
496 //Add a new Copy object
497 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
499 //Add a translate function
500 Handle(GEOM_Function) aFunction =
501 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
503 //Check if the function is set correctly
504 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
506 GEOMImpl_ITranslate aTI (aFunction);
507 aTI.SetOriginal(aLastFunction);
508 if (!theVector.IsNull())
509 aTI.SetVector(theVector->GetLastFunction());
510 aTI.SetStep1(theStep);
511 aTI.SetNbIter1(theNbTimes);
513 //Compute the translation
516 if (!GetSolver()->ComputeFunction(aFunction)) {
517 SetErrorCode("Translation driver failed");
521 catch (Standard_Failure) {
522 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
523 SetErrorCode(aFail->GetMessageString());
527 //Make a Python command
528 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
529 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
535 //=============================================================================
539 //=============================================================================
540 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
541 Handle(GEOM_Object) theVector,
543 Standard_Integer theNbTimes1,
544 Handle(GEOM_Object) theVector2,
546 Standard_Integer theNbTimes2)
550 if (theObject.IsNull()) return NULL;
552 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
553 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
555 //Add a new Copy object
556 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
558 //Add a translate function
559 Handle(GEOM_Function) aFunction =
560 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
562 //Check if the function is set correctly
563 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
565 GEOMImpl_ITranslate aTI (aFunction);
566 aTI.SetOriginal(aLastFunction);
567 if (!theVector.IsNull())
568 aTI.SetVector(theVector->GetLastFunction());
569 aTI.SetStep1(theStep1);
570 aTI.SetNbIter1(theNbTimes1);
571 if (!theVector2.IsNull())
572 aTI.SetVector2(theVector2->GetLastFunction());
573 aTI.SetStep2(theStep2);
574 aTI.SetNbIter2(theNbTimes2);
576 //Compute the translation
579 if (!GetSolver()->ComputeFunction(aFunction)) {
580 SetErrorCode("Translation driver failed");
584 catch (Standard_Failure) {
585 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
586 SetErrorCode(aFail->GetMessageString());
590 //Make a Python command
591 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
592 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
593 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
599 //=============================================================================
603 //=============================================================================
605 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape& theShape,
606 GEOMImpl_ITranslate* theTI)
611 Handle(GEOM_Function) aVector = theTI->GetVector();
612 if (aVector.IsNull()) {
613 StdFail_NotDone::Raise("Invalid object is given for vector argument");
615 TopoDS_Shape aV = aVector->GetValue();
616 if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
617 StdFail_NotDone::Raise("Invalid object is given for vector argument");
619 TopoDS_Edge anEdge = TopoDS::Edge(aV);
621 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
622 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
623 if (aP1.Distance(aP2) < gp::Resolution()) {
624 StdFail_NotDone::Raise("Invalid object is given for vector argument");
628 Standard_Real step = theTI->GetStep1();
629 Standard_Integer nbtimes = theTI->GetNbIter1();
631 // Make multi-translation
634 TopoDS_Compound aCompound;
636 B.MakeCompound(aCompound);
638 gp_Vec Vec (aP1, aP2);
641 TopLoc_Location aLocOrig = theShape.Location();
642 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
644 for (int i = 0; i < nbtimes; i++) {
645 aVec = Vec * (i * step);
646 aTrsf.SetTranslation(aVec);
647 //NPAL18620: performance problem: multiple locations are accumulated
648 // in shape and need a great time to process
649 //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
650 //B.Add(aCompound, aTransformation.Shape());
651 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
652 B.Add(aCompound, theShape.Located(aLocRes));
660 //=============================================================================
664 //=============================================================================
666 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape& theShape,
667 GEOMImpl_ITranslate* theTI)
672 Handle(GEOM_Function) aVector1 = theTI->GetVector();
673 Handle(GEOM_Function) aVector2 = theTI->GetVector2();
675 if (aVector1.IsNull() || aVector2.IsNull()) {
676 StdFail_NotDone::Raise("Invalid object is given for vector argument");
679 TopoDS_Shape aV1 = aVector1->GetValue();
680 TopoDS_Shape aV2 = aVector2->GetValue();
682 if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
683 aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
684 StdFail_NotDone::Raise("Invalid object is given for vector argument");
687 TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
688 TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
690 gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
691 gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
692 gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
693 gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
695 if (aP11.Distance(aP12) < gp::Resolution() ||
696 aP21.Distance(aP22) < gp::Resolution()) {
697 StdFail_NotDone::Raise("Invalid object is given for vector argument");
700 gp_Vec Vec1 (aP11, aP12);
701 gp_Vec Vec2 (aP21, aP22);
707 Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
708 Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
710 // Make multi-translation
713 Standard_Real DX, DY, DZ;
714 TopoDS_Compound aCompound;
716 B.MakeCompound(aCompound);
718 TopLoc_Location aLocOrig = theShape.Location();
719 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
721 for (int i = 0; i < nbtimes1; i++) {
722 for (int j = 0; j < nbtimes2; j++) {
723 DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
724 DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
725 DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
726 aVec.SetCoord(DX, DY, DZ);
727 aTrsf.SetTranslation(aVec);
728 //NPAL18620: performance problem: multiple locations are accumulated
729 // in shape and need a great time to process
730 //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
731 //B.Add(aCompound, aBRepTransformation.Shape());
732 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
733 B.Add(aCompound, theShape.Located(aLocRes));
742 //=============================================================================
746 //=============================================================================
747 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
748 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
752 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
754 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
755 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
757 // Get last functions of the arguments
758 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
760 //Add a mirror function
761 Handle(GEOM_Function) aFunction =
762 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
763 if (aFunction.IsNull()) return NULL;
765 //Check if the function is set correctly
766 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
768 GEOMImpl_IMirror aTI (aFunction);
770 aTI.SetOriginal(aLastFunction);
775 if (!GetSolver()->ComputeFunction(aFunction)) {
776 SetErrorCode("Mirror driver failed");
780 catch (Standard_Failure) {
781 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
782 SetErrorCode(aFail->GetMessageString());
786 //Make a Python command
787 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPlane("
788 << theObject << ", " << thePlane << ")";
794 //=============================================================================
798 //=============================================================================
799 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
800 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
804 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
806 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
807 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
809 //Add a new Copy object
810 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
812 //Add a mirror function
813 Handle(GEOM_Function) aFunction =
814 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
816 //Check if the function is set correctly
817 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
819 GEOMImpl_IMirror aTI (aFunction);
820 aTI.SetPlane(thePlane->GetLastFunction());
821 aTI.SetOriginal(aLastFunction);
826 if (!GetSolver()->ComputeFunction(aFunction)) {
827 SetErrorCode("Mirror driver failed");
831 catch (Standard_Failure) {
832 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
833 SetErrorCode(aFail->GetMessageString());
837 //Make a Python command
838 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
839 << theObject << ", " << thePlane << ")";
845 //=============================================================================
849 //=============================================================================
850 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
851 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
855 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
857 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
858 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
860 // Get last functions of the arguments
861 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
863 //Add a mirror function
864 Handle(GEOM_Function) aFunction =
865 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
866 if (aFunction.IsNull()) return NULL;
868 //Check if the function is set correctly
869 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
871 GEOMImpl_IMirror aTI (aFunction);
873 aTI.SetOriginal(aLastFunction);
878 if (!GetSolver()->ComputeFunction(aFunction)) {
879 SetErrorCode("Mirror driver failed");
883 catch (Standard_Failure) {
884 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
885 SetErrorCode(aFail->GetMessageString());
889 //Make a Python command
890 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPoint("
891 << theObject << ", " << thePoint << ")";
897 //=============================================================================
901 //=============================================================================
902 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
903 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
907 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
909 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
910 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
912 //Add a new Copy object
913 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
915 //Add a mirror function
916 Handle(GEOM_Function) aFunction =
917 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
919 //Check if the function is set correctly
920 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
922 GEOMImpl_IMirror aTI (aFunction);
923 aTI.SetPoint(thePoint->GetLastFunction());
924 aTI.SetOriginal(aLastFunction);
929 if (!GetSolver()->ComputeFunction(aFunction)) {
930 SetErrorCode("Mirror driver failed");
934 catch (Standard_Failure) {
935 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
936 SetErrorCode(aFail->GetMessageString());
940 //Make a Python command
941 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
942 << theObject << ", " << thePoint << ")";
948 //=============================================================================
952 //=============================================================================
953 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
954 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
958 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
960 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
961 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
963 // Get last functions of the arguments
964 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
966 //Add a mirror function
967 Handle(GEOM_Function) aFunction =
968 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
969 if (aFunction.IsNull()) return NULL;
971 //Check if the function is set correctly
972 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
974 GEOMImpl_IMirror aTI (aFunction);
976 aTI.SetOriginal(aLastFunction);
981 if (!GetSolver()->ComputeFunction(aFunction)) {
982 SetErrorCode("Mirror driver failed");
986 catch (Standard_Failure) {
987 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
988 SetErrorCode(aFail->GetMessageString());
992 //Make a Python command
993 GEOM::TPythonDump(aFunction) << "geompy.MirrorByAxis("
994 << theObject << ", " << theAxis << ")";
1000 //=============================================================================
1004 //=============================================================================
1005 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
1006 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
1010 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1012 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1013 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
1015 //Add a new Copy object
1016 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1018 //Add a mirror function
1019 Handle(GEOM_Function) aFunction =
1020 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
1022 //Check if the function is set correctly
1023 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
1025 GEOMImpl_IMirror aTI (aFunction);
1026 aTI.SetAxis(theAxis->GetLastFunction());
1027 aTI.SetOriginal(aLastFunction);
1029 //Compute the mirror
1032 if (!GetSolver()->ComputeFunction(aFunction)) {
1033 SetErrorCode("Mirror driver failed");
1037 catch (Standard_Failure) {
1038 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1039 SetErrorCode(aFail->GetMessageString());
1043 //Make a Python command
1044 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
1045 << theObject << ", " << theAxis << ")";
1052 //=============================================================================
1056 //=============================================================================
1057 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
1058 (Handle(GEOM_Object) theObject, double theOffset)
1062 if (theObject.IsNull()) return NULL;
1064 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1065 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1067 //Add a new Offset function
1068 Handle(GEOM_Function) aFunction =
1069 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1070 if (aFunction.IsNull()) return NULL;
1072 //Check if the function is set correctly
1073 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1075 GEOMImpl_IOffset aTI (aFunction);
1076 aTI.SetShape(anOriginal);
1077 aTI.SetValue(theOffset);
1079 //Compute the offset
1082 if (!GetSolver()->ComputeFunction(aFunction)) {
1083 SetErrorCode("Offset driver failed");
1087 catch (Standard_Failure) {
1088 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1089 SetErrorCode(aFail->GetMessageString());
1093 //Make a Python command
1094 GEOM::TPythonDump(aFunction) << "geompy.Offset("
1095 << theObject << ", " << theOffset << ")";
1101 //=============================================================================
1105 //=============================================================================
1106 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1107 (Handle(GEOM_Object) theObject, double theOffset)
1111 if (theObject.IsNull()) return NULL;
1113 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1114 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1116 //Add a new Copy object
1117 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1119 //Add a new Offset function
1120 Handle(GEOM_Function) aFunction =
1121 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1122 if (aFunction.IsNull()) return NULL;
1124 //Check if the function is set correctly
1125 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1127 GEOMImpl_IOffset aTI (aFunction);
1128 aTI.SetShape(anOriginal);
1129 aTI.SetValue(theOffset);
1131 //Compute the offset
1134 if (!GetSolver()->ComputeFunction(aFunction)) {
1135 SetErrorCode("Offset driver failed");
1139 catch (Standard_Failure) {
1140 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1141 SetErrorCode(aFail->GetMessageString());
1145 //Make a Python command
1146 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1147 << theObject << ", " << theOffset << ")";
1154 //=============================================================================
1158 //=============================================================================
1160 GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource,
1161 Handle(GEOM_Object) theTarget)
1165 if (theSource.IsNull() || theTarget.IsNull()) return NULL;
1167 Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
1168 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
1170 Handle(GEOM_Object) aCopy;
1172 TopoDS_Shape aTarget = theTarget->GetValue();
1173 if ( aTarget.IsNull() ) return NULL;
1174 if ( aTarget.ShapeType() == TopAbs_EDGE ||
1175 aTarget.ShapeType() == TopAbs_WIRE )
1177 // a TPythonDump prevents dumping ProjectPointOnWire(),
1178 // dump of MakeProjection() is done at the end of this function
1179 GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true);
1180 Standard_Integer dummy;
1181 ProjectPointOnWire( theSource, theTarget, aCopy, dummy );
1182 if ( aCopy.IsNull() || !IsDone() )
1187 //Add a new Projection object
1188 aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1190 //Add a Projection function
1191 Handle(GEOM_Function) aFunction =
1192 aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
1194 //Check if the function is set correctly
1195 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
1197 GEOMImpl_IMirror aTI (aFunction);
1198 aTI.SetPlane(theTarget->GetLastFunction());
1199 aTI.SetOriginal(aLastFunction);
1201 //Compute the Projection
1204 if (!GetSolver()->ComputeFunction(aFunction)) {
1205 SetErrorCode("Projection driver failed");
1209 catch (Standard_Failure) {
1210 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1211 SetErrorCode(aFail->GetMessageString());
1216 //Make a Python command
1217 Handle(GEOM_Function) aFunction = aCopy->GetLastFunction();
1218 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
1219 << theSource << ", " << theTarget << ")";
1225 //=============================================================================
1227 * ProjectPointOnWire
1229 //=============================================================================
1230 Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire
1231 (Handle(GEOM_Object) thePoint,
1232 Handle(GEOM_Object) theWire,
1233 Handle(GEOM_Object) &thePointOnEdge,
1234 Standard_Integer &theEdgeInWireIndex)
1236 Standard_Real aResult = -1.;
1240 if (thePoint.IsNull() || theWire.IsNull()) {
1244 Handle(GEOM_Function) aLastFunction = thePoint->GetLastFunction();
1246 if (aLastFunction.IsNull()) {
1247 //There is no function which creates an object to be projected
1251 //Add a new Projection object
1252 thePointOnEdge = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1254 //Add a Projection function
1255 Handle(GEOM_Function) aFunction = thePointOnEdge->AddFunction
1256 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_WIRE);
1258 //Check if the function is set correctly
1259 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
1263 GEOMImpl_IProjection aProj (aFunction);
1264 aProj.SetPoint(aLastFunction);
1265 aProj.SetShape(theWire->GetLastFunction());
1267 //Compute the Projection
1270 if (!GetSolver()->ComputeFunction(aFunction)) {
1271 SetErrorCode("Projection driver failed");
1275 catch (Standard_Failure) {
1276 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1277 SetErrorCode(aFail->GetMessageString());
1281 aResult = aProj.GetU();
1282 theEdgeInWireIndex = aProj.GetIndex();
1285 //Make a Python command
1286 GEOM::TPythonDump(aFunction) << "(u, " << thePointOnEdge
1287 << ", EdgeInWireIndex) = geompy.MakeProjectionOnWire(" << thePoint
1288 << ", " << theWire << ")";
1295 //=============================================================================
1299 //=============================================================================
1300 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1301 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1305 if (theObject.IsNull()) return NULL;
1307 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1308 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1310 //Add a scale function
1311 Handle(GEOM_Function) aFunction =
1312 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1313 if (aFunction.IsNull()) return NULL;
1315 //Check if the function is set correctly
1316 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1319 GEOMImpl_IScale aTI (aFunction);
1320 aTI.SetShape(anOriginal);
1321 aTI.SetFactor(theFactor);
1323 // Set point argument
1324 if (!thePoint.IsNull()) {
1325 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1332 if (!GetSolver()->ComputeFunction(aFunction)) {
1333 SetErrorCode("Scale driver failed");
1337 catch (Standard_Failure) {
1338 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1339 SetErrorCode(aFail->GetMessageString());
1343 //Make a Python command
1344 GEOM::TPythonDump(aFunction) << "geompy.Scale("
1345 << theObject << ", " << thePoint << ", " << theFactor << ")";
1351 //=============================================================================
1355 //=============================================================================
1356 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1357 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1361 if (theObject.IsNull()) return NULL;
1363 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1364 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1366 //Add a new Copy object
1367 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1369 //Add a scale function
1370 Handle(GEOM_Function) aFunction =
1371 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1372 if (aFunction.IsNull()) return NULL;
1374 //Check if the function is set correctly
1375 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1378 GEOMImpl_IScale aTI (aFunction);
1379 aTI.SetShape(anOriginal);
1380 aTI.SetFactor(theFactor);
1382 // Set point argument
1383 if (!thePoint.IsNull()) {
1384 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1391 if (!GetSolver()->ComputeFunction(aFunction)) {
1392 SetErrorCode("Scale driver failed");
1396 catch (Standard_Failure) {
1397 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1398 SetErrorCode(aFail->GetMessageString());
1402 //Make a Python command
1403 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1404 << theObject << ", " << thePoint << ", " << theFactor << ")";
1410 //=============================================================================
1412 * ScaleShapeAlongAxes
1414 //=============================================================================
1415 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1416 Handle(GEOM_Object) thePoint,
1424 if (theObject.IsNull()) return NULL;
1426 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1427 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1429 //Add a scale function
1430 Handle(GEOM_Object) aCopy; //Add a new Copy object
1431 Handle(GEOM_Function) aFunction;
1433 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1434 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1437 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1439 if (aFunction.IsNull()) return NULL;
1441 //Check if the function is set correctly
1442 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1445 GEOMImpl_IScale aTI (aFunction);
1446 aTI.SetShape(anOriginal);
1447 aTI.SetFactorX(theFactorX);
1448 aTI.SetFactorY(theFactorY);
1449 aTI.SetFactorZ(theFactorZ);
1451 // Set point (optional argument)
1452 if (!thePoint.IsNull()) {
1453 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1460 if (!GetSolver()->ComputeFunction(aFunction)) {
1461 SetErrorCode("Scale driver failed");
1465 catch (Standard_Failure) {
1466 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1467 SetErrorCode(aFail->GetMessageString());
1473 //Make a Python command
1475 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1476 << theObject << ", " << thePoint << ", "
1477 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1481 GEOM::TPythonDump(aFunction) << "geompy.ScaleAlongAxes("
1482 << theObject << ", " << thePoint << ", "
1483 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1487 //=============================================================================
1491 //=============================================================================
1492 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1493 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1497 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1499 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1500 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1502 //Add a Position function
1503 Standard_Integer aType = POSITION_SHAPE;
1504 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1506 Handle(GEOM_Function) aFunction =
1507 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1508 if (aFunction.IsNull()) return NULL;
1510 //Check if the function is set correctly
1511 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1513 //Set operation arguments
1514 GEOMImpl_IPosition aTI (aFunction);
1515 aTI.SetShape(anOriginal);
1516 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1517 if (!theStartLCS.IsNull())
1518 aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1520 //Compute the Position
1523 if (!GetSolver()->ComputeFunction(aFunction)) {
1524 SetErrorCode("Position driver failed");
1528 catch (Standard_Failure) {
1529 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1530 SetErrorCode(aFail->GetMessageString());
1534 //Make a Python command
1535 GEOM::TPythonDump(aFunction) << "geompy.Position("
1536 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1542 //=============================================================================
1546 //=============================================================================
1547 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1548 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1552 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1554 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1555 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1557 //Add a new Copy object
1558 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1560 //Add a position function
1561 Standard_Integer aType = POSITION_SHAPE_COPY;
1562 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1564 Handle(GEOM_Function) aFunction =
1565 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1566 if (aFunction.IsNull()) return NULL;
1568 //Check if the function is set correctly
1569 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1571 GEOMImpl_IPosition aTI (aFunction);
1572 aTI.SetShape(anOriginal);
1573 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1574 if (!theStartLCS.IsNull())
1575 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1577 //Compute the position
1580 if (!GetSolver()->ComputeFunction(aFunction)) {
1581 SetErrorCode("Position driver failed");
1585 catch (Standard_Failure) {
1586 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1587 SetErrorCode(aFail->GetMessageString());
1591 //Make a Python command
1592 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1593 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1599 //=============================================================================
1603 //=============================================================================
1604 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1605 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1606 double theDistance, bool theCopy, bool theReverse)
1610 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1612 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1613 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1615 //Add a position function
1616 Handle(GEOM_Function) aFunction;
1617 Handle(GEOM_Object) aCopy;
1620 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1621 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1624 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1626 if (aFunction.IsNull()) return NULL;
1628 //Check if the function is set correctly
1629 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1631 GEOMImpl_IPosition aTI (aFunction);
1632 aTI.SetShape(anOriginal);
1633 aTI.SetPath(thePath->GetLastFunction());
1634 aTI.SetDistance(theDistance);
1635 aTI.SetReverse(theReverse);
1637 //Compute the position
1640 if (!GetSolver()->ComputeFunction(aFunction)) {
1641 SetErrorCode("Position driver failed");
1645 catch (Standard_Failure) {
1646 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1647 SetErrorCode(aFail->GetMessageString());
1651 //Make a Python command
1653 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePositionAlongPath("
1654 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1659 GEOM::TPythonDump(aFunction) << "geompy.PositionAlongPath("
1660 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1666 //=============================================================================
1670 //=============================================================================
1671 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1672 Handle(GEOM_Object) theAxis,
1677 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1679 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1680 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1682 // Get last functions of the arguments
1683 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1685 //Add a rotate function
1686 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1688 if (aFunction.IsNull()) return NULL;
1690 //Check if the function is set correctly
1691 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1693 GEOMImpl_IRotate aRI(aFunction);
1695 aRI.SetOriginal(aLastFunction);
1696 aRI.SetAngle(theAngle);
1698 //Compute the translation
1701 if (!GetSolver()->ComputeFunction(aFunction)) {
1702 SetErrorCode("Rotate driver failed");
1706 catch (Standard_Failure) {
1707 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1708 SetErrorCode(aFail->GetMessageString());
1712 //Make a Python command
1713 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1714 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1720 //=============================================================================
1724 //=============================================================================
1725 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject,
1726 Handle(GEOM_Object) theAxis,
1731 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1733 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1734 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1736 //Add a new Copy object
1737 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1739 //Add a rotate function
1740 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1741 if (aFunction.IsNull()) return NULL;
1743 //Check if the function is set correctly
1744 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1746 GEOMImpl_IRotate aRI(aFunction);
1747 aRI.SetAxis(theAxis->GetLastFunction());
1748 aRI.SetOriginal(aLastFunction);
1749 aRI.SetAngle(theAngle);
1751 //Compute the translation
1754 if (!GetSolver()->ComputeFunction(aFunction)) {
1755 SetErrorCode("Rotate driver failed");
1759 catch (Standard_Failure) {
1760 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1761 SetErrorCode(aFail->GetMessageString());
1765 //Make a Python command
1766 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1767 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1773 //=============================================================================
1775 * Rotate1D (for MultiRotate1DNbTimes)
1777 //=============================================================================
1778 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1779 Handle(GEOM_Object) theAxis,
1780 Standard_Integer theNbTimes)
1784 if (theObject.IsNull()) return NULL;
1786 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1787 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1789 //Add a new Copy object
1790 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1792 //Add a rotate function
1793 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1794 if (aFunction.IsNull()) return NULL;
1796 //Check if the function is set correctly
1797 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1799 GEOMImpl_IRotate aRI(aFunction);
1800 aRI.SetOriginal(aLastFunction);
1801 if (!theAxis.IsNull())
1802 aRI.SetAxis(theAxis->GetLastFunction());
1803 aRI.SetNbIter1(theNbTimes);
1805 //Compute the translation
1808 if (!GetSolver()->ComputeFunction(aFunction)) {
1809 SetErrorCode("Rotate driver failed");
1813 catch (Standard_Failure) {
1814 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1815 SetErrorCode(aFail->GetMessageString());
1819 //Make a Python command
1820 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1DNbTimes("
1821 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1827 //=============================================================================
1829 * Rotate1D (for MultiRotate1DByStep)
1831 //=============================================================================
1832 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1833 Handle(GEOM_Object) theAxis,
1834 double theAngleStep,
1835 Standard_Integer theNbSteps)
1839 if (theObject.IsNull()) return NULL;
1841 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1842 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1844 //Add a new Copy object
1845 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1847 //Add a rotate function
1848 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D_STEP);
1849 if (aFunction.IsNull()) return NULL;
1851 //Check if the function is set correctly
1852 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1854 //Convert angle into degrees
1855 double anAngleStep = theAngleStep * 180. / M_PI;
1857 GEOMImpl_IRotate aRI (aFunction);
1858 aRI.SetOriginal(aLastFunction);
1859 if (!theAxis.IsNull())
1860 aRI.SetAxis(theAxis->GetLastFunction());
1861 aRI.SetAngle(anAngleStep);
1862 aRI.SetNbIter1(theNbSteps);
1864 //Compute the translation
1867 if (!GetSolver()->ComputeFunction(aFunction)) {
1868 SetErrorCode("Rotate driver failed");
1872 catch (Standard_Failure) {
1873 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1874 SetErrorCode(aFail->GetMessageString());
1878 //Make a Python command
1879 GEOM::TPythonDump(aFunction)
1880 << aCopy << " = geompy.MultiRotate1DByStep(" << theObject << ", "
1881 << theAxis << ", " << anAngleStep << "*math.pi/180.0, " << theNbSteps << ")";
1887 //=============================================================================
1889 * Rotate2D (for MultiRotate2DNbTimes)
1891 //=============================================================================
1892 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1893 Handle(GEOM_Object) theAxis,
1894 Standard_Integer theNbObjects,
1895 double theRadialStep,
1896 Standard_Integer theNbSteps)
1900 if (theObject.IsNull()) return NULL;
1902 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1903 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1905 //Add a new Copy object
1906 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1908 //Add a rotate function
1909 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1910 if (aFunction.IsNull()) return NULL;
1912 //Check if the function is set correctly
1913 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1915 double anAngle = 360. / (double)theNbObjects;
1917 GEOMImpl_IRotate aRI (aFunction);
1918 aRI.SetOriginal(aLastFunction);
1919 if (!theAxis.IsNull())
1920 aRI.SetAxis(theAxis->GetLastFunction());
1921 aRI.SetAngle(anAngle);
1922 aRI.SetNbIter1(theNbObjects);
1923 aRI.SetStep(theRadialStep);
1924 aRI.SetNbIter2(theNbSteps);
1926 //Compute the translation
1929 if (!GetSolver()->ComputeFunction(aFunction)) {
1930 SetErrorCode("Rotate driver failed");
1934 catch (Standard_Failure) {
1935 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1936 SetErrorCode(aFail->GetMessageString());
1940 //Make a Python command
1941 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2DNbTimes("
1942 << theObject << ", " << theAxis << ", " << theNbObjects
1943 << ", " << theRadialStep << ", " << theNbSteps << ")";
1949 //=============================================================================
1951 * Rotate2D (for MultiRotate2DByStep)
1953 //=============================================================================
1954 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1955 Handle(GEOM_Object) theAxis,
1956 double theAngleStep,
1957 Standard_Integer theNbTimes1,
1959 Standard_Integer theNbTimes2)
1963 if (theObject.IsNull()) return NULL;
1965 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1966 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1968 //Add a new Copy object
1969 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1971 //Add a rotate function
1972 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1973 if (aFunction.IsNull()) return NULL;
1975 //Check if the function is set correctly
1976 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1978 //Convert angle into degrees
1979 double anAngleStep = theAngleStep * 180. / M_PI;
1981 GEOMImpl_IRotate aRI (aFunction);
1982 aRI.SetOriginal(aLastFunction);
1983 if (!theAxis.IsNull())
1984 aRI.SetAxis(theAxis->GetLastFunction());
1985 aRI.SetAngle(anAngleStep);
1986 aRI.SetNbIter1(theNbTimes1);
1987 aRI.SetStep(theStep);
1988 aRI.SetNbIter2(theNbTimes2);
1990 //Compute the translation
1993 if (!GetSolver()->ComputeFunction(aFunction)) {
1994 SetErrorCode("Rotate driver failed");
1998 catch (Standard_Failure) {
1999 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2000 SetErrorCode(aFail->GetMessageString());
2004 //Make a Python command
2005 GEOM::TPythonDump(aFunction)
2006 << aCopy << " = geompy.MultiRotate2DByStep(" << theObject << ", "
2007 << theAxis << ", " << anAngleStep << "*math.pi/180.0, "
2008 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
2014 //=============================================================================
2018 //=============================================================================
2019 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
2020 Handle(GEOM_Object) theCentPoint,
2021 Handle(GEOM_Object) thePoint1,
2022 Handle(GEOM_Object) thePoint2)
2026 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2028 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2029 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2031 // Get last functions of the arguments
2032 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
2033 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
2034 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
2037 //Add a rotate function
2038 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
2040 if (aFunction.IsNull()) return NULL;
2042 //Check if the function is set correctly
2043 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2045 GEOMImpl_IRotate aRI(aFunction);
2046 aRI.SetCentPoint(aCPF);
2047 aRI.SetPoint1(aP1F);
2048 aRI.SetPoint2(aP2F);
2049 aRI.SetOriginal(aLastFunction);
2051 //Compute the translation
2054 if (!GetSolver()->ComputeFunction(aFunction)) {
2055 SetErrorCode("Rotate driver failed");
2059 catch (Standard_Failure) {
2060 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2061 SetErrorCode(aFail->GetMessageString());
2065 //Make a Python command
2066 GEOM::TPythonDump(aFunction) << "geompy.RotateThreePoints(" << theObject
2067 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2073 //=============================================================================
2075 * RotateThreePointsCopy
2077 //=============================================================================
2078 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
2079 Handle(GEOM_Object) theCentPoint,
2080 Handle(GEOM_Object) thePoint1,
2081 Handle(GEOM_Object) thePoint2)
2085 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2087 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2088 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2090 //Add a new Copy object
2091 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2093 //Add a rotate function
2094 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
2095 if (aFunction.IsNull()) return NULL;
2097 //Check if the function is set correctly
2098 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2100 GEOMImpl_IRotate aRI(aFunction);
2101 aRI.SetCentPoint(theCentPoint->GetLastFunction());
2102 aRI.SetPoint1(thePoint1->GetLastFunction());
2103 aRI.SetPoint2(thePoint2->GetLastFunction());
2104 aRI.SetOriginal(aLastFunction);
2106 //Compute the translation
2109 if (!GetSolver()->ComputeFunction(aFunction)) {
2110 SetErrorCode("Rotate driver failed");
2114 catch (Standard_Failure) {
2115 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2116 SetErrorCode(aFail->GetMessageString());
2120 //Make a Python command
2121 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
2122 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2128 //=============================================================================
2130 * TransformLikeOtherCopy
2132 //=============================================================================
2133 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
2134 (Handle(GEOM_Object) theObject,
2135 Handle(GEOM_Object) theSample)
2139 if (theObject.IsNull() || theSample.IsNull()) return NULL;
2141 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2142 if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
2144 Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
2145 if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
2147 // Add a new Copy object
2148 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
2150 // Add a transform function (depends on theSample function)
2151 Handle(GEOM_Function) aFunction =
2152 aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
2153 if (aFunction.IsNull()) return NULL;
2155 // Check if the function is set correctly
2156 if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
2158 if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
2159 switch (aSampleFunc->GetType()) {
2162 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2163 GEOMImpl_ITranslate aRI_target (aFunction);
2165 aRI_target.SetVector(aRI_sample.GetVector());
2166 aRI_target.SetStep1(aRI_sample.GetStep1());
2167 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2169 aRI_target.SetOriginal(aLastFunction);
2174 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2175 GEOMImpl_ITranslate aRI_target (aFunction);
2177 aRI_target.SetVector(aRI_sample.GetVector());
2178 aRI_target.SetStep1(aRI_sample.GetStep1());
2179 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2181 aRI_target.SetVector2(aRI_sample.GetVector2());
2182 aRI_target.SetStep2(aRI_sample.GetStep2());
2183 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2185 aRI_target.SetOriginal(aLastFunction);
2190 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2195 else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
2196 switch (aSampleFunc->GetType()) {
2199 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2200 GEOMImpl_IRotate aRI_target (aFunction);
2202 aRI_target.SetAxis(aRI_sample.GetAxis());
2203 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2205 aRI_target.SetOriginal(aLastFunction);
2210 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2211 GEOMImpl_IRotate aRI_target (aFunction);
2213 aRI_target.SetAxis(aRI_sample.GetAxis());
2215 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2216 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2218 aRI_target.SetAngle(aRI_sample.GetAngle());
2219 aRI_target.SetStep(aRI_sample.GetStep());
2221 aRI_target.SetDir2(aRI_sample.GetDir2());
2223 aRI_target.SetOriginal(aLastFunction);
2226 case ROTATE_THREE_POINTS_COPY:
2228 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2229 GEOMImpl_IRotate aRI_target (aFunction);
2231 aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
2232 aRI_target.SetPoint1(aRI_sample.GetPoint1());
2233 aRI_target.SetPoint2(aRI_sample.GetPoint2());
2235 aRI_target.SetOriginal(aLastFunction);
2240 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2246 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2250 // Compute the transformation
2253 if (!GetSolver()->ComputeFunction(aFunction)) {
2254 SetErrorCode("Driver failed");
2258 catch (Standard_Failure) {
2259 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2260 SetErrorCode(aFail->GetMessageString());
2264 //Make a Python command
2265 //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
2266 // << theObject << ", " << theSample << ")";
2272 //=============================================================================
2274 * MakeProjectionOnCylinder
2276 //=============================================================================
2277 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MakeProjectionOnCylinder
2278 (const Handle(GEOM_Object) &theObject,
2279 const Standard_Real theRadius,
2280 const Standard_Real theStartAngle,
2281 const Standard_Real theAngleLength)
2285 if (theObject.IsNull()) {
2289 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2291 if (aLastFunction.IsNull()) {
2292 //There is no function which creates an object to be projected
2296 //Add a new Projection object
2297 Handle(GEOM_Object) aResult =
2298 GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
2300 //Add a Projection function
2301 Handle(GEOM_Function) aFunction = aResult->AddFunction
2302 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_CYLINDER);
2304 //Check if the function is set correctly
2305 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
2309 GEOMImpl_IProjOnCyl aProj (aFunction);
2311 aProj.SetShape(aLastFunction);
2312 aProj.SetRadius(theRadius);
2313 aProj.SetStartAngle(theStartAngle);
2314 aProj.SetAngleLength(theAngleLength);
2316 //Compute the Projection
2319 if (!GetSolver()->ComputeFunction(aFunction)) {
2320 SetErrorCode("Projection driver failed");
2324 catch (Standard_Failure) {
2325 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2326 SetErrorCode(aFail->GetMessageString());
2330 //Make a Python command
2331 GEOM::TPythonDump pd(aFunction);
2333 pd << aResult << " = geompy.MakeProjectionOnCylinder("
2334 << theObject << ", " << theRadius << ", " << theStartAngle;
2336 if (theAngleLength >= 0.) {
2337 pd << ", " << theAngleLength;