1 // Copyright (C) 2007-2016 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 "utilities.h"
51 #include <Utils_ExceptHandlers.hxx>
53 #include <TFunction_DriverTable.hxx>
54 #include <TFunction_Driver.hxx>
55 #include <TDF_Tool.hxx>
57 #include <BRep_Tool.hxx>
58 #include <BRep_Builder.hxx>
61 #include <TopoDS_Edge.hxx>
62 #include <TopoDS_Vertex.hxx>
63 #include <TopoDS_Compound.hxx>
66 #include <gp_Trsf.hxx>
68 #include <StdFail_NotDone.hxx>
69 #include <Standard_Failure.hxx>
70 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
72 //=============================================================================
76 //=============================================================================
78 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
79 : GEOM_IOperations(theEngine, theDocID)
81 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
84 //=============================================================================
88 //=============================================================================
90 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
92 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
96 //=============================================================================
100 //=============================================================================
101 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
102 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
106 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
108 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
109 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
111 // Get last functions of the arguments
112 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
113 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
115 //Add a translate function
116 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
118 if (aFunction.IsNull()) return NULL;
120 //Check if the function is set correctly
121 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
123 GEOMImpl_ITranslate aTI (aFunction);
126 aTI.SetOriginal(aLastFunction);
128 //Compute the translation
131 if (!GetSolver()->ComputeFunction(aFunction)) {
132 SetErrorCode("Translation driver failed");
136 catch (Standard_Failure) {
137 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
138 SetErrorCode(aFail->GetMessageString());
142 //Make a Python command
143 GEOM::TPythonDump(aFunction) << "geompy.TranslateTwoPoints("
144 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
150 //=============================================================================
154 //=============================================================================
155 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
156 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
160 if (theObject.IsNull()) return NULL;
162 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
163 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
165 //Add a translate function
166 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
168 if (aFunction.IsNull()) return NULL;
170 //Check if the function is set correctly
171 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
173 GEOMImpl_ITranslate aTI(aFunction);
177 aTI.SetOriginal(aLastFunction);
179 //Compute the translation
182 if (!GetSolver()->ComputeFunction(aFunction)) {
183 SetErrorCode("Translation driver failed");
187 catch (Standard_Failure) {
188 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
189 SetErrorCode(aFail->GetMessageString());
193 //Make a Python command
194 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
195 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
202 //=============================================================================
204 * TranslateTwoPointsCopy
206 //=============================================================================
207 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
208 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
212 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
214 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
215 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
217 //Add a new Copy object
218 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
220 //Add a translate function
221 Handle(GEOM_Function) aFunction =
222 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
224 //Check if the function is set correctly
225 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
227 GEOMImpl_ITranslate aTI(aFunction);
228 aTI.SetPoint1(thePoint1->GetLastFunction());
229 aTI.SetPoint2(thePoint2->GetLastFunction());
230 //aTI.SetShape(theObject->GetValue());
231 aTI.SetOriginal(aLastFunction);
233 //Compute the translation
236 if (!GetSolver()->ComputeFunction(aFunction)) {
237 SetErrorCode("Translation driver failed");
241 catch (Standard_Failure) {
242 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
243 SetErrorCode(aFail->GetMessageString());
247 //Make a Python command
248 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
249 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
255 //=============================================================================
257 * TranslateDXDYDZCopy
259 //=============================================================================
260 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
261 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
265 if (theObject.IsNull()) return NULL;
267 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
268 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
270 //Add a new Copy object
271 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
273 //Add a translate function
274 Handle(GEOM_Function) aFunction =
275 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
277 //Check if the function is set correctly
278 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
280 GEOMImpl_ITranslate aTI(aFunction);
284 aTI.SetOriginal(aLastFunction);
286 //Compute the translation
289 if (!GetSolver()->ComputeFunction(aFunction)) {
290 SetErrorCode("Translation driver failed");
294 catch (Standard_Failure) {
295 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
296 SetErrorCode(aFail->GetMessageString());
300 //Make a Python command
301 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
302 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
309 //=============================================================================
313 //=============================================================================
314 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
315 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
319 if (theObject.IsNull() || theVector.IsNull()) return NULL;
321 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
322 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
324 // Get last functions of the arguments
325 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
327 //Add a translate function
328 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
330 if (aFunction.IsNull()) return NULL;
332 //Check if the function is set correctly
333 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
335 GEOMImpl_ITranslate aTI (aFunction);
337 aTI.SetOriginal(aLastFunction);
339 //Compute the translation
342 if (!GetSolver()->ComputeFunction(aFunction)) {
343 SetErrorCode("Translation driver failed");
347 catch (Standard_Failure) {
348 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
349 SetErrorCode(aFail->GetMessageString());
353 //Make a Python command
354 GEOM::TPythonDump(aFunction) << "geompy.TranslateVector("
355 << theObject << ", " << theVector << ")";
360 //=============================================================================
362 * TranslateVectorCopy
364 //=============================================================================
365 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
366 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
370 if (theObject.IsNull() || theVector.IsNull()) return NULL;
372 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
373 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
375 //Add a new Copy object
376 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
378 //Add a translate function
379 Handle(GEOM_Function) aFunction =
380 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
382 //Check if the function is set correctly
383 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
385 GEOMImpl_ITranslate aTI(aFunction);
386 aTI.SetVector(theVector->GetLastFunction());
387 // aTI.SetShape(theObject->GetValue());
388 aTI.SetOriginal(aLastFunction);
390 //Compute the translation
393 if (!GetSolver()->ComputeFunction(aFunction)) {
394 SetErrorCode("Translation driver failed");
398 catch (Standard_Failure) {
399 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
400 SetErrorCode(aFail->GetMessageString());
404 //Make a Python command
405 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
406 << theObject << ", " << theVector << ")";
412 //=============================================================================
414 * TranslateVectorDistance
416 //=============================================================================
417 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
418 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
422 if (theObject.IsNull() || theVector.IsNull()) return NULL;
424 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
425 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
427 Handle(GEOM_Object) aCopy; //Add a new Copy object
428 Handle(GEOM_Function) aFunction;
430 //Add a translate function
432 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
433 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
436 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
438 if (aFunction.IsNull()) return NULL;
440 //Check if the function is set correctly
441 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
443 GEOMImpl_ITranslate aTI(aFunction);
444 aTI.SetVector(theVector->GetLastFunction());
445 aTI.SetDistance(theDistance);
446 // aTI.SetShape(theObject->GetValue());
447 aTI.SetOriginal(aLastFunction);
449 //Compute the translation
452 if (!GetSolver()->ComputeFunction(aFunction)) {
453 SetErrorCode("Translation driver failed");
457 catch (Standard_Failure) {
458 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
459 SetErrorCode(aFail->GetMessageString());
463 //Make a Python command
465 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
466 << theObject << ", " << theVector << ", " << theDistance << ")";
471 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
472 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
477 //=============================================================================
481 //=============================================================================
482 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
483 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
484 double theStep, Standard_Integer theNbTimes)
488 if (theObject.IsNull()) return NULL;
490 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
491 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
493 //Add a new Copy object
494 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
496 //Add a translate function
497 Handle(GEOM_Function) aFunction =
498 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
500 //Check if the function is set correctly
501 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
503 GEOMImpl_ITranslate aTI (aFunction);
504 aTI.SetOriginal(aLastFunction);
505 if (!theVector.IsNull())
506 aTI.SetVector(theVector->GetLastFunction());
507 aTI.SetStep1(theStep);
508 aTI.SetNbIter1(theNbTimes);
510 //Compute the translation
513 if (!GetSolver()->ComputeFunction(aFunction)) {
514 SetErrorCode("Translation driver failed");
518 catch (Standard_Failure) {
519 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
520 SetErrorCode(aFail->GetMessageString());
524 //Make a Python command
525 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
526 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
532 //=============================================================================
536 //=============================================================================
537 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
538 Handle(GEOM_Object) theVector,
540 Standard_Integer theNbTimes1,
541 Handle(GEOM_Object) theVector2,
543 Standard_Integer theNbTimes2)
547 if (theObject.IsNull()) return NULL;
549 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
550 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
552 //Add a new Copy object
553 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
555 //Add a translate function
556 Handle(GEOM_Function) aFunction =
557 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
559 //Check if the function is set correctly
560 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
562 GEOMImpl_ITranslate aTI (aFunction);
563 aTI.SetOriginal(aLastFunction);
564 if (!theVector.IsNull())
565 aTI.SetVector(theVector->GetLastFunction());
566 aTI.SetStep1(theStep1);
567 aTI.SetNbIter1(theNbTimes1);
568 if (!theVector2.IsNull())
569 aTI.SetVector2(theVector2->GetLastFunction());
570 aTI.SetStep2(theStep2);
571 aTI.SetNbIter2(theNbTimes2);
573 //Compute the translation
576 if (!GetSolver()->ComputeFunction(aFunction)) {
577 SetErrorCode("Translation driver failed");
581 catch (Standard_Failure) {
582 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
583 SetErrorCode(aFail->GetMessageString());
587 //Make a Python command
588 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
589 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
590 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
596 //=============================================================================
600 //=============================================================================
602 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape& theShape,
603 GEOMImpl_ITranslate* theTI)
608 Handle(GEOM_Function) aVector = theTI->GetVector();
609 if (aVector.IsNull()) {
610 StdFail_NotDone::Raise("Invalid object is given for vector argument");
612 TopoDS_Shape aV = aVector->GetValue();
613 if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
614 StdFail_NotDone::Raise("Invalid object is given for vector argument");
616 TopoDS_Edge anEdge = TopoDS::Edge(aV);
618 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
619 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
620 if (aP1.Distance(aP2) < gp::Resolution()) {
621 StdFail_NotDone::Raise("Invalid object is given for vector argument");
625 Standard_Real step = theTI->GetStep1();
626 Standard_Integer nbtimes = theTI->GetNbIter1();
628 // Make multi-translation
631 TopoDS_Compound aCompound;
633 B.MakeCompound(aCompound);
635 gp_Vec Vec (aP1, aP2);
638 TopLoc_Location aLocOrig = theShape.Location();
639 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
641 for (int i = 0; i < nbtimes; i++) {
642 aVec = Vec * (i * step);
643 aTrsf.SetTranslation(aVec);
644 //NPAL18620: performance problem: multiple locations are accumulated
645 // in shape and need a great time to process
646 //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
647 //B.Add(aCompound, aTransformation.Shape());
648 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
649 B.Add(aCompound, theShape.Located(aLocRes));
657 //=============================================================================
661 //=============================================================================
663 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape& theShape,
664 GEOMImpl_ITranslate* theTI)
669 Handle(GEOM_Function) aVector1 = theTI->GetVector();
670 Handle(GEOM_Function) aVector2 = theTI->GetVector2();
672 if (aVector1.IsNull() || aVector2.IsNull()) {
673 StdFail_NotDone::Raise("Invalid object is given for vector argument");
676 TopoDS_Shape aV1 = aVector1->GetValue();
677 TopoDS_Shape aV2 = aVector2->GetValue();
679 if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
680 aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
681 StdFail_NotDone::Raise("Invalid object is given for vector argument");
684 TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
685 TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
687 gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
688 gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
689 gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
690 gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
692 if (aP11.Distance(aP12) < gp::Resolution() ||
693 aP21.Distance(aP22) < gp::Resolution()) {
694 StdFail_NotDone::Raise("Invalid object is given for vector argument");
697 gp_Vec Vec1 (aP11, aP12);
698 gp_Vec Vec2 (aP21, aP22);
704 Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
705 Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
707 // Make multi-translation
710 Standard_Real DX, DY, DZ;
711 TopoDS_Compound aCompound;
713 B.MakeCompound(aCompound);
715 TopLoc_Location aLocOrig = theShape.Location();
716 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
718 for (int i = 0; i < nbtimes1; i++) {
719 for (int j = 0; j < nbtimes2; j++) {
720 DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
721 DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
722 DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
723 aVec.SetCoord(DX, DY, DZ);
724 aTrsf.SetTranslation(aVec);
725 //NPAL18620: performance problem: multiple locations are accumulated
726 // in shape and need a great time to process
727 //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
728 //B.Add(aCompound, aBRepTransformation.Shape());
729 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
730 B.Add(aCompound, theShape.Located(aLocRes));
739 //=============================================================================
743 //=============================================================================
744 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
745 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
749 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
751 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
752 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
754 // Get last functions of the arguments
755 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
757 //Add a mirror function
758 Handle(GEOM_Function) aFunction =
759 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
760 if (aFunction.IsNull()) return NULL;
762 //Check if the function is set correctly
763 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
765 GEOMImpl_IMirror aTI (aFunction);
767 aTI.SetOriginal(aLastFunction);
772 if (!GetSolver()->ComputeFunction(aFunction)) {
773 SetErrorCode("Mirror driver failed");
777 catch (Standard_Failure) {
778 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
779 SetErrorCode(aFail->GetMessageString());
783 //Make a Python command
784 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPlane("
785 << theObject << ", " << thePlane << ")";
791 //=============================================================================
795 //=============================================================================
796 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
797 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
801 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
803 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
804 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
806 //Add a new Copy object
807 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
809 //Add a mirror function
810 Handle(GEOM_Function) aFunction =
811 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
813 //Check if the function is set correctly
814 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
816 GEOMImpl_IMirror aTI (aFunction);
817 aTI.SetPlane(thePlane->GetLastFunction());
818 aTI.SetOriginal(aLastFunction);
823 if (!GetSolver()->ComputeFunction(aFunction)) {
824 SetErrorCode("Mirror driver failed");
828 catch (Standard_Failure) {
829 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
830 SetErrorCode(aFail->GetMessageString());
834 //Make a Python command
835 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
836 << theObject << ", " << thePlane << ")";
842 //=============================================================================
846 //=============================================================================
847 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
848 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
852 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
854 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
855 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
857 // Get last functions of the arguments
858 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
860 //Add a mirror function
861 Handle(GEOM_Function) aFunction =
862 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
863 if (aFunction.IsNull()) return NULL;
865 //Check if the function is set correctly
866 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
868 GEOMImpl_IMirror aTI (aFunction);
870 aTI.SetOriginal(aLastFunction);
875 if (!GetSolver()->ComputeFunction(aFunction)) {
876 SetErrorCode("Mirror driver failed");
880 catch (Standard_Failure) {
881 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
882 SetErrorCode(aFail->GetMessageString());
886 //Make a Python command
887 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPoint("
888 << theObject << ", " << thePoint << ")";
894 //=============================================================================
898 //=============================================================================
899 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
900 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
904 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
906 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
907 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
909 //Add a new Copy object
910 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
912 //Add a mirror function
913 Handle(GEOM_Function) aFunction =
914 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
916 //Check if the function is set correctly
917 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
919 GEOMImpl_IMirror aTI (aFunction);
920 aTI.SetPoint(thePoint->GetLastFunction());
921 aTI.SetOriginal(aLastFunction);
926 if (!GetSolver()->ComputeFunction(aFunction)) {
927 SetErrorCode("Mirror driver failed");
931 catch (Standard_Failure) {
932 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
933 SetErrorCode(aFail->GetMessageString());
937 //Make a Python command
938 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
939 << theObject << ", " << thePoint << ")";
945 //=============================================================================
949 //=============================================================================
950 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
951 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
955 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
957 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
958 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
960 // Get last functions of the arguments
961 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
963 //Add a mirror function
964 Handle(GEOM_Function) aFunction =
965 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
966 if (aFunction.IsNull()) return NULL;
968 //Check if the function is set correctly
969 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
971 GEOMImpl_IMirror aTI (aFunction);
973 aTI.SetOriginal(aLastFunction);
978 if (!GetSolver()->ComputeFunction(aFunction)) {
979 SetErrorCode("Mirror driver failed");
983 catch (Standard_Failure) {
984 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
985 SetErrorCode(aFail->GetMessageString());
989 //Make a Python command
990 GEOM::TPythonDump(aFunction) << "geompy.MirrorByAxis("
991 << theObject << ", " << theAxis << ")";
997 //=============================================================================
1001 //=============================================================================
1002 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
1003 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
1007 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1009 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1010 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
1012 //Add a new Copy object
1013 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1015 //Add a mirror function
1016 Handle(GEOM_Function) aFunction =
1017 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
1019 //Check if the function is set correctly
1020 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
1022 GEOMImpl_IMirror aTI (aFunction);
1023 aTI.SetAxis(theAxis->GetLastFunction());
1024 aTI.SetOriginal(aLastFunction);
1026 //Compute the mirror
1029 if (!GetSolver()->ComputeFunction(aFunction)) {
1030 SetErrorCode("Mirror driver failed");
1034 catch (Standard_Failure) {
1035 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1036 SetErrorCode(aFail->GetMessageString());
1040 //Make a Python command
1041 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
1042 << theObject << ", " << theAxis << ")";
1049 //=============================================================================
1053 //=============================================================================
1054 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
1055 (Handle(GEOM_Object) theObject, double theOffset)
1059 if (theObject.IsNull()) return NULL;
1061 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1062 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1064 //Add a new Offset function
1065 Handle(GEOM_Function) aFunction =
1066 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1067 if (aFunction.IsNull()) return NULL;
1069 //Check if the function is set correctly
1070 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1072 GEOMImpl_IOffset aTI (aFunction);
1073 aTI.SetShape(anOriginal);
1074 aTI.SetValue(theOffset);
1076 //Compute the offset
1079 if (!GetSolver()->ComputeFunction(aFunction)) {
1080 SetErrorCode("Offset driver failed");
1084 catch (Standard_Failure) {
1085 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1086 SetErrorCode(aFail->GetMessageString());
1090 //Make a Python command
1091 GEOM::TPythonDump(aFunction) << "geompy.Offset("
1092 << theObject << ", " << theOffset << ")";
1098 //=============================================================================
1102 //=============================================================================
1103 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1104 (Handle(GEOM_Object) theObject, double theOffset)
1108 if (theObject.IsNull()) return NULL;
1110 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1111 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1113 //Add a new Copy object
1114 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1116 //Add a new Offset function
1117 Handle(GEOM_Function) aFunction =
1118 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1119 if (aFunction.IsNull()) return NULL;
1121 //Check if the function is set correctly
1122 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1124 GEOMImpl_IOffset aTI (aFunction);
1125 aTI.SetShape(anOriginal);
1126 aTI.SetValue(theOffset);
1128 //Compute the offset
1131 if (!GetSolver()->ComputeFunction(aFunction)) {
1132 SetErrorCode("Offset driver failed");
1136 catch (Standard_Failure) {
1137 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1138 SetErrorCode(aFail->GetMessageString());
1142 //Make a Python command
1143 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1144 << theObject << ", " << theOffset << ")";
1151 //=============================================================================
1155 //=============================================================================
1157 GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource,
1158 Handle(GEOM_Object) theTarget)
1162 if (theSource.IsNull() || theTarget.IsNull()) return NULL;
1164 Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
1165 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
1167 Handle(GEOM_Object) aCopy;
1169 TopoDS_Shape aTarget = theTarget->GetValue();
1170 if ( aTarget.IsNull() ) return NULL;
1171 if ( aTarget.ShapeType() == TopAbs_EDGE ||
1172 aTarget.ShapeType() == TopAbs_WIRE )
1174 // a TPythonDump prevents dumping ProjectPointOnWire(),
1175 // dump of MakeProjection() is done at the end of this function
1176 GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true);
1177 Standard_Integer dummy;
1178 ProjectPointOnWire( theSource, theTarget, aCopy, dummy );
1179 if ( aCopy.IsNull() || !IsDone() )
1184 //Add a new Projection object
1185 aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1187 //Add a Projection function
1188 Handle(GEOM_Function) aFunction =
1189 aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
1191 //Check if the function is set correctly
1192 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
1194 GEOMImpl_IMirror aTI (aFunction);
1195 aTI.SetPlane(theTarget->GetLastFunction());
1196 aTI.SetOriginal(aLastFunction);
1198 //Compute the Projection
1201 if (!GetSolver()->ComputeFunction(aFunction)) {
1202 SetErrorCode("Projection driver failed");
1206 catch (Standard_Failure) {
1207 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1208 SetErrorCode(aFail->GetMessageString());
1213 //Make a Python command
1214 Handle(GEOM_Function) aFunction = aCopy->GetLastFunction();
1215 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
1216 << theSource << ", " << theTarget << ")";
1222 //=============================================================================
1224 * ProjectPointOnWire
1226 //=============================================================================
1227 Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire
1228 (Handle(GEOM_Object) thePoint,
1229 Handle(GEOM_Object) theWire,
1230 Handle(GEOM_Object) &thePointOnEdge,
1231 Standard_Integer &theEdgeInWireIndex)
1233 Standard_Real aResult = -1.;
1237 if (thePoint.IsNull() || theWire.IsNull()) {
1241 Handle(GEOM_Function) aLastFunction = thePoint->GetLastFunction();
1243 if (aLastFunction.IsNull()) {
1244 //There is no function which creates an object to be projected
1248 //Add a new Projection object
1249 thePointOnEdge = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1251 //Add a Projection function
1252 Handle(GEOM_Function) aFunction = thePointOnEdge->AddFunction
1253 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_WIRE);
1255 //Check if the function is set correctly
1256 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
1260 GEOMImpl_IProjection aProj (aFunction);
1261 aProj.SetPoint(aLastFunction);
1262 aProj.SetShape(theWire->GetLastFunction());
1264 //Compute the Projection
1267 if (!GetSolver()->ComputeFunction(aFunction)) {
1268 SetErrorCode("Projection driver failed");
1272 catch (Standard_Failure) {
1273 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1274 SetErrorCode(aFail->GetMessageString());
1278 aResult = aProj.GetU();
1279 theEdgeInWireIndex = aProj.GetIndex();
1282 //Make a Python command
1283 GEOM::TPythonDump(aFunction) << "(u, " << thePointOnEdge
1284 << ", EdgeInWireIndex) = geompy.MakeProjectionOnWire(" << thePoint
1285 << ", " << theWire << ")";
1292 //=============================================================================
1296 //=============================================================================
1297 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1298 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1302 if (theObject.IsNull()) return NULL;
1304 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1305 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1307 //Add a scale function
1308 Handle(GEOM_Function) aFunction =
1309 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1310 if (aFunction.IsNull()) return NULL;
1312 //Check if the function is set correctly
1313 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1316 GEOMImpl_IScale aTI (aFunction);
1317 aTI.SetShape(anOriginal);
1318 aTI.SetFactor(theFactor);
1320 // Set point argument
1321 if (!thePoint.IsNull()) {
1322 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1329 if (!GetSolver()->ComputeFunction(aFunction)) {
1330 SetErrorCode("Scale driver failed");
1334 catch (Standard_Failure) {
1335 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1336 SetErrorCode(aFail->GetMessageString());
1340 //Make a Python command
1341 GEOM::TPythonDump(aFunction) << "geompy.Scale("
1342 << theObject << ", " << thePoint << ", " << theFactor << ")";
1348 //=============================================================================
1352 //=============================================================================
1353 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1354 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1358 if (theObject.IsNull()) return NULL;
1360 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1361 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1363 //Add a new Copy object
1364 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1366 //Add a scale function
1367 Handle(GEOM_Function) aFunction =
1368 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1369 if (aFunction.IsNull()) return NULL;
1371 //Check if the function is set correctly
1372 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1375 GEOMImpl_IScale aTI (aFunction);
1376 aTI.SetShape(anOriginal);
1377 aTI.SetFactor(theFactor);
1379 // Set point argument
1380 if (!thePoint.IsNull()) {
1381 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1388 if (!GetSolver()->ComputeFunction(aFunction)) {
1389 SetErrorCode("Scale driver failed");
1393 catch (Standard_Failure) {
1394 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1395 SetErrorCode(aFail->GetMessageString());
1399 //Make a Python command
1400 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1401 << theObject << ", " << thePoint << ", " << theFactor << ")";
1407 //=============================================================================
1409 * ScaleShapeAlongAxes
1411 //=============================================================================
1412 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1413 Handle(GEOM_Object) thePoint,
1421 if (theObject.IsNull()) return NULL;
1423 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1424 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1426 //Add a scale function
1427 Handle(GEOM_Object) aCopy; //Add a new Copy object
1428 Handle(GEOM_Function) aFunction;
1430 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1431 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1434 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1436 if (aFunction.IsNull()) return NULL;
1438 //Check if the function is set correctly
1439 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1442 GEOMImpl_IScale aTI (aFunction);
1443 aTI.SetShape(anOriginal);
1444 aTI.SetFactorX(theFactorX);
1445 aTI.SetFactorY(theFactorY);
1446 aTI.SetFactorZ(theFactorZ);
1448 // Set point (optional argument)
1449 if (!thePoint.IsNull()) {
1450 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1457 if (!GetSolver()->ComputeFunction(aFunction)) {
1458 SetErrorCode("Scale driver failed");
1462 catch (Standard_Failure) {
1463 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1464 SetErrorCode(aFail->GetMessageString());
1470 //Make a Python command
1472 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1473 << theObject << ", " << thePoint << ", "
1474 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1478 GEOM::TPythonDump(aFunction) << "geompy.ScaleAlongAxes("
1479 << theObject << ", " << thePoint << ", "
1480 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1484 //=============================================================================
1488 //=============================================================================
1489 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1490 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1494 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1496 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1497 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1499 //Add a Position function
1500 Standard_Integer aType = POSITION_SHAPE;
1501 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1503 Handle(GEOM_Function) aFunction =
1504 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1505 if (aFunction.IsNull()) return NULL;
1507 //Check if the function is set correctly
1508 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1510 //Set operation arguments
1511 GEOMImpl_IPosition aTI (aFunction);
1512 aTI.SetShape(anOriginal);
1513 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1514 if (!theStartLCS.IsNull())
1515 aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1517 //Compute the Position
1520 if (!GetSolver()->ComputeFunction(aFunction)) {
1521 SetErrorCode("Position driver failed");
1525 catch (Standard_Failure) {
1526 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1527 SetErrorCode(aFail->GetMessageString());
1531 //Make a Python command
1532 GEOM::TPythonDump(aFunction) << "geompy.Position("
1533 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1539 //=============================================================================
1543 //=============================================================================
1544 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1545 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1549 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1551 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1552 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1554 //Add a new Copy object
1555 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1557 //Add a position function
1558 Standard_Integer aType = POSITION_SHAPE_COPY;
1559 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1561 Handle(GEOM_Function) aFunction =
1562 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1563 if (aFunction.IsNull()) return NULL;
1565 //Check if the function is set correctly
1566 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1568 GEOMImpl_IPosition aTI (aFunction);
1569 aTI.SetShape(anOriginal);
1570 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1571 if (!theStartLCS.IsNull())
1572 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1574 //Compute the position
1577 if (!GetSolver()->ComputeFunction(aFunction)) {
1578 SetErrorCode("Position driver failed");
1582 catch (Standard_Failure) {
1583 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1584 SetErrorCode(aFail->GetMessageString());
1588 //Make a Python command
1589 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1590 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1596 //=============================================================================
1600 //=============================================================================
1601 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1602 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1603 double theDistance, bool theCopy, bool theReverse)
1607 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1609 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1610 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1612 //Add a position function
1613 Handle(GEOM_Function) aFunction;
1614 Handle(GEOM_Object) aCopy;
1617 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1618 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1621 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1623 if (aFunction.IsNull()) return NULL;
1625 //Check if the function is set correctly
1626 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1628 GEOMImpl_IPosition aTI (aFunction);
1629 aTI.SetShape(anOriginal);
1630 aTI.SetPath(thePath->GetLastFunction());
1631 aTI.SetDistance(theDistance);
1632 aTI.SetReverse(theReverse);
1634 //Compute the position
1637 if (!GetSolver()->ComputeFunction(aFunction)) {
1638 SetErrorCode("Position driver failed");
1642 catch (Standard_Failure) {
1643 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1644 SetErrorCode(aFail->GetMessageString());
1648 //Make a Python command
1650 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePositionAlongPath("
1651 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1656 GEOM::TPythonDump(aFunction) << "geompy.PositionAlongPath("
1657 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1663 //=============================================================================
1667 //=============================================================================
1668 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1669 Handle(GEOM_Object) theAxis,
1674 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1676 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1677 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1679 // Get last functions of the arguments
1680 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1682 //Add a rotate function
1683 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1685 if (aFunction.IsNull()) return NULL;
1687 //Check if the function is set correctly
1688 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1690 GEOMImpl_IRotate aRI(aFunction);
1692 aRI.SetOriginal(aLastFunction);
1693 aRI.SetAngle(theAngle);
1695 //Compute the translation
1698 if (!GetSolver()->ComputeFunction(aFunction)) {
1699 SetErrorCode("Rotate driver failed");
1703 catch (Standard_Failure) {
1704 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1705 SetErrorCode(aFail->GetMessageString());
1709 //Make a Python command
1710 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1711 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1717 //=============================================================================
1721 //=============================================================================
1722 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject,
1723 Handle(GEOM_Object) theAxis,
1728 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1730 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1731 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1733 //Add a new Copy object
1734 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1736 //Add a rotate function
1737 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1738 if (aFunction.IsNull()) return NULL;
1740 //Check if the function is set correctly
1741 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1743 GEOMImpl_IRotate aRI(aFunction);
1744 aRI.SetAxis(theAxis->GetLastFunction());
1745 aRI.SetOriginal(aLastFunction);
1746 aRI.SetAngle(theAngle);
1748 //Compute the translation
1751 if (!GetSolver()->ComputeFunction(aFunction)) {
1752 SetErrorCode("Rotate driver failed");
1756 catch (Standard_Failure) {
1757 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1758 SetErrorCode(aFail->GetMessageString());
1762 //Make a Python command
1763 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1764 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1770 //=============================================================================
1772 * Rotate1D (for MultiRotate1DNbTimes)
1774 //=============================================================================
1775 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1776 Handle(GEOM_Object) theAxis,
1777 Standard_Integer theNbTimes)
1781 if (theObject.IsNull()) return NULL;
1783 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1784 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1786 //Add a new Copy object
1787 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1789 //Add a rotate function
1790 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1791 if (aFunction.IsNull()) return NULL;
1793 //Check if the function is set correctly
1794 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1796 GEOMImpl_IRotate aRI(aFunction);
1797 aRI.SetOriginal(aLastFunction);
1798 if (!theAxis.IsNull())
1799 aRI.SetAxis(theAxis->GetLastFunction());
1800 aRI.SetNbIter1(theNbTimes);
1802 //Compute the translation
1805 if (!GetSolver()->ComputeFunction(aFunction)) {
1806 SetErrorCode("Rotate driver failed");
1810 catch (Standard_Failure) {
1811 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1812 SetErrorCode(aFail->GetMessageString());
1816 //Make a Python command
1817 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1DNbTimes("
1818 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1824 //=============================================================================
1826 * Rotate1D (for MultiRotate1DByStep)
1828 //=============================================================================
1829 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1830 Handle(GEOM_Object) theAxis,
1831 double theAngleStep,
1832 Standard_Integer theNbSteps)
1836 if (theObject.IsNull()) return NULL;
1838 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1839 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1841 //Add a new Copy object
1842 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1844 //Add a rotate function
1845 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D_STEP);
1846 if (aFunction.IsNull()) return NULL;
1848 //Check if the function is set correctly
1849 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1851 //Convert angle into degrees
1852 double anAngleStep = theAngleStep * 180. / M_PI;
1854 GEOMImpl_IRotate aRI (aFunction);
1855 aRI.SetOriginal(aLastFunction);
1856 if (!theAxis.IsNull())
1857 aRI.SetAxis(theAxis->GetLastFunction());
1858 aRI.SetAngle(anAngleStep);
1859 aRI.SetNbIter1(theNbSteps);
1861 //Compute the translation
1864 if (!GetSolver()->ComputeFunction(aFunction)) {
1865 SetErrorCode("Rotate driver failed");
1869 catch (Standard_Failure) {
1870 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1871 SetErrorCode(aFail->GetMessageString());
1875 //Make a Python command
1876 GEOM::TPythonDump(aFunction)
1877 << aCopy << " = geompy.MultiRotate1DByStep(" << theObject << ", "
1878 << theAxis << ", " << anAngleStep << "*math.pi/180.0, " << theNbSteps << ")";
1884 //=============================================================================
1886 * Rotate2D (for MultiRotate2DNbTimes)
1888 //=============================================================================
1889 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1890 Handle(GEOM_Object) theAxis,
1891 Standard_Integer theNbObjects,
1892 double theRadialStep,
1893 Standard_Integer theNbSteps)
1897 if (theObject.IsNull()) return NULL;
1899 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1900 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1902 //Add a new Copy object
1903 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1905 //Add a rotate function
1906 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1907 if (aFunction.IsNull()) return NULL;
1909 //Check if the function is set correctly
1910 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1912 double anAngle = 360. / (double)theNbObjects;
1914 GEOMImpl_IRotate aRI (aFunction);
1915 aRI.SetOriginal(aLastFunction);
1916 if (!theAxis.IsNull())
1917 aRI.SetAxis(theAxis->GetLastFunction());
1918 aRI.SetAngle(anAngle);
1919 aRI.SetNbIter1(theNbObjects);
1920 aRI.SetStep(theRadialStep);
1921 aRI.SetNbIter2(theNbSteps);
1923 //Compute the translation
1926 if (!GetSolver()->ComputeFunction(aFunction)) {
1927 SetErrorCode("Rotate driver failed");
1931 catch (Standard_Failure) {
1932 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1933 SetErrorCode(aFail->GetMessageString());
1937 //Make a Python command
1938 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2DNbTimes("
1939 << theObject << ", " << theAxis << ", " << theNbObjects
1940 << ", " << theRadialStep << ", " << theNbSteps << ")";
1946 //=============================================================================
1948 * Rotate2D (for MultiRotate2DByStep)
1950 //=============================================================================
1951 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1952 Handle(GEOM_Object) theAxis,
1953 double theAngleStep,
1954 Standard_Integer theNbTimes1,
1956 Standard_Integer theNbTimes2)
1960 if (theObject.IsNull()) return NULL;
1962 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1963 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1965 //Add a new Copy object
1966 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1968 //Add a rotate function
1969 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1970 if (aFunction.IsNull()) return NULL;
1972 //Check if the function is set correctly
1973 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1975 //Convert angle into degrees
1976 double anAngleStep = theAngleStep * 180. / M_PI;
1978 GEOMImpl_IRotate aRI (aFunction);
1979 aRI.SetOriginal(aLastFunction);
1980 if (!theAxis.IsNull())
1981 aRI.SetAxis(theAxis->GetLastFunction());
1982 aRI.SetAngle(anAngleStep);
1983 aRI.SetNbIter1(theNbTimes1);
1984 aRI.SetStep(theStep);
1985 aRI.SetNbIter2(theNbTimes2);
1987 //Compute the translation
1990 if (!GetSolver()->ComputeFunction(aFunction)) {
1991 SetErrorCode("Rotate driver failed");
1995 catch (Standard_Failure) {
1996 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1997 SetErrorCode(aFail->GetMessageString());
2001 //Make a Python command
2002 GEOM::TPythonDump(aFunction)
2003 << aCopy << " = geompy.MultiRotate2DByStep(" << theObject << ", "
2004 << theAxis << ", " << anAngleStep << "*math.pi/180.0, "
2005 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
2011 //=============================================================================
2015 //=============================================================================
2016 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
2017 Handle(GEOM_Object) theCentPoint,
2018 Handle(GEOM_Object) thePoint1,
2019 Handle(GEOM_Object) thePoint2)
2023 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2025 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2026 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2028 // Get last functions of the arguments
2029 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
2030 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
2031 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
2034 //Add a rotate function
2035 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
2037 if (aFunction.IsNull()) return NULL;
2039 //Check if the function is set correctly
2040 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2042 GEOMImpl_IRotate aRI(aFunction);
2043 aRI.SetCentPoint(aCPF);
2044 aRI.SetPoint1(aP1F);
2045 aRI.SetPoint2(aP2F);
2046 aRI.SetOriginal(aLastFunction);
2048 //Compute the translation
2051 if (!GetSolver()->ComputeFunction(aFunction)) {
2052 SetErrorCode("Rotate driver failed");
2056 catch (Standard_Failure) {
2057 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2058 SetErrorCode(aFail->GetMessageString());
2062 //Make a Python command
2063 GEOM::TPythonDump(aFunction) << "geompy.RotateThreePoints(" << theObject
2064 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2070 //=============================================================================
2072 * RotateThreePointsCopy
2074 //=============================================================================
2075 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
2076 Handle(GEOM_Object) theCentPoint,
2077 Handle(GEOM_Object) thePoint1,
2078 Handle(GEOM_Object) thePoint2)
2082 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2084 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2085 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2087 //Add a new Copy object
2088 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
2090 //Add a rotate function
2091 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
2092 if (aFunction.IsNull()) return NULL;
2094 //Check if the function is set correctly
2095 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2097 GEOMImpl_IRotate aRI(aFunction);
2098 aRI.SetCentPoint(theCentPoint->GetLastFunction());
2099 aRI.SetPoint1(thePoint1->GetLastFunction());
2100 aRI.SetPoint2(thePoint2->GetLastFunction());
2101 aRI.SetOriginal(aLastFunction);
2103 //Compute the translation
2106 if (!GetSolver()->ComputeFunction(aFunction)) {
2107 SetErrorCode("Rotate driver failed");
2111 catch (Standard_Failure) {
2112 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2113 SetErrorCode(aFail->GetMessageString());
2117 //Make a Python command
2118 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
2119 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2125 //=============================================================================
2127 * TransformLikeOtherCopy
2129 //=============================================================================
2130 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
2131 (Handle(GEOM_Object) theObject,
2132 Handle(GEOM_Object) theSample)
2136 if (theObject.IsNull() || theSample.IsNull()) return NULL;
2138 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2139 if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
2141 Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
2142 if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
2144 // Add a new Copy object
2145 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
2147 // Add a transform function (depends on theSample function)
2148 Handle(GEOM_Function) aFunction =
2149 aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
2150 if (aFunction.IsNull()) return NULL;
2152 // Check if the function is set correctly
2153 if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
2155 if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
2156 switch (aSampleFunc->GetType()) {
2159 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2160 GEOMImpl_ITranslate aRI_target (aFunction);
2162 aRI_target.SetVector(aRI_sample.GetVector());
2163 aRI_target.SetStep1(aRI_sample.GetStep1());
2164 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2166 aRI_target.SetOriginal(aLastFunction);
2171 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2172 GEOMImpl_ITranslate aRI_target (aFunction);
2174 aRI_target.SetVector(aRI_sample.GetVector());
2175 aRI_target.SetStep1(aRI_sample.GetStep1());
2176 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2178 aRI_target.SetVector2(aRI_sample.GetVector2());
2179 aRI_target.SetStep2(aRI_sample.GetStep2());
2180 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2182 aRI_target.SetOriginal(aLastFunction);
2187 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2192 else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
2193 switch (aSampleFunc->GetType()) {
2196 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2197 GEOMImpl_IRotate aRI_target (aFunction);
2199 aRI_target.SetAxis(aRI_sample.GetAxis());
2200 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2202 aRI_target.SetOriginal(aLastFunction);
2207 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2208 GEOMImpl_IRotate aRI_target (aFunction);
2210 aRI_target.SetAxis(aRI_sample.GetAxis());
2212 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2213 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2215 aRI_target.SetAngle(aRI_sample.GetAngle());
2216 aRI_target.SetStep(aRI_sample.GetStep());
2218 aRI_target.SetDir2(aRI_sample.GetDir2());
2220 aRI_target.SetOriginal(aLastFunction);
2223 case ROTATE_THREE_POINTS_COPY:
2225 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2226 GEOMImpl_IRotate aRI_target (aFunction);
2228 aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
2229 aRI_target.SetPoint1(aRI_sample.GetPoint1());
2230 aRI_target.SetPoint2(aRI_sample.GetPoint2());
2232 aRI_target.SetOriginal(aLastFunction);
2237 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2243 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2247 // Compute the transformation
2250 if (!GetSolver()->ComputeFunction(aFunction)) {
2251 SetErrorCode("Driver failed");
2255 catch (Standard_Failure) {
2256 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2257 SetErrorCode(aFail->GetMessageString());
2261 //Make a Python command
2262 //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
2263 // << theObject << ", " << theSample << ")";
2269 //=============================================================================
2271 * MakeProjectionOnCylinder
2273 //=============================================================================
2274 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MakeProjectionOnCylinder
2275 (const Handle(GEOM_Object) &theObject,
2276 const Standard_Real theRadius,
2277 const Standard_Real theStartAngle,
2278 const Standard_Real theAngleLength,
2279 const Standard_Real theAngleRotation)
2283 if (theObject.IsNull()) {
2287 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2289 if (aLastFunction.IsNull()) {
2290 //There is no function which creates an object to be projected
2294 //Add a new Projection object
2295 Handle(GEOM_Object) aResult =
2296 GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
2298 //Add a Projection function
2299 Handle(GEOM_Function) aFunction = aResult->AddFunction
2300 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_CYLINDER);
2302 //Check if the function is set correctly
2303 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
2307 GEOMImpl_IProjOnCyl aProj (aFunction);
2309 aProj.SetShape(aLastFunction);
2310 aProj.SetRadius(theRadius);
2311 aProj.SetStartAngle(theStartAngle);
2312 aProj.SetAngleLength(theAngleLength);
2313 aProj.SetAngleRotation(theAngleRotation);
2315 //Compute the Projection
2318 if (!GetSolver()->ComputeFunction(aFunction)) {
2319 SetErrorCode("Projection driver failed");
2323 catch (Standard_Failure) {
2324 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2325 SetErrorCode(aFail->GetMessageString());
2329 //Make a Python command
2330 GEOM::TPythonDump(aFunction)
2331 << aResult << " = geompy.MakeProjectionOnCylinder("
2332 << theObject << ", " << theRadius << ", " << theStartAngle
2333 << ", " << theAngleLength << ", " << theAngleRotation << ")";