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 <Basics_OCCTVersion.hxx>
51 #include "utilities.h"
53 #include <Utils_ExceptHandlers.hxx>
55 #include <TFunction_DriverTable.hxx>
56 #include <TFunction_Driver.hxx>
57 #include <TDF_Tool.hxx>
59 #include <BRep_Tool.hxx>
60 #include <BRep_Builder.hxx>
63 #include <TopoDS_Edge.hxx>
64 #include <TopoDS_Vertex.hxx>
65 #include <TopoDS_Compound.hxx>
68 #include <gp_Trsf.hxx>
70 #include <StdFail_NotDone.hxx>
71 #include <Standard_Failure.hxx>
72 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
74 //=============================================================================
78 //=============================================================================
80 GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
81 : GEOM_IOperations(theEngine, theDocID)
83 MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
86 //=============================================================================
90 //=============================================================================
92 GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
94 MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
98 //=============================================================================
102 //=============================================================================
103 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
104 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
108 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
110 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
111 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
113 // Get last functions of the arguments
114 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
115 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
117 //Add a translate function
118 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
120 if (aFunction.IsNull()) return NULL;
122 //Check if the function is set correctly
123 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
125 GEOMImpl_ITranslate aTI (aFunction);
128 aTI.SetOriginal(aLastFunction);
130 //Compute the translation
133 if (!GetSolver()->ComputeFunction(aFunction)) {
134 SetErrorCode("Translation driver failed");
138 catch (Standard_Failure) {
139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
140 SetErrorCode(aFail->GetMessageString());
144 //Make a Python command
145 GEOM::TPythonDump(aFunction) << "geompy.TranslateTwoPoints("
146 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
152 //=============================================================================
156 //=============================================================================
157 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
158 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
162 if (theObject.IsNull()) return NULL;
164 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
165 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
167 //Add a translate function
168 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
170 if (aFunction.IsNull()) return NULL;
172 //Check if the function is set correctly
173 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
175 GEOMImpl_ITranslate aTI(aFunction);
179 aTI.SetOriginal(aLastFunction);
181 //Compute the translation
184 if (!GetSolver()->ComputeFunction(aFunction)) {
185 SetErrorCode("Translation driver failed");
189 catch (Standard_Failure) {
190 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
191 SetErrorCode(aFail->GetMessageString());
195 //Make a Python command
196 GEOM::TPythonDump(aFunction) << "geompy.TranslateDXDYDZ("
197 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
204 //=============================================================================
206 * TranslateTwoPointsCopy
208 //=============================================================================
209 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
210 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
214 if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
216 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
217 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
219 //Add a new Copy object
220 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
222 //Add a translate function
223 Handle(GEOM_Function) aFunction =
224 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
226 //Check if the function is set correctly
227 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
229 GEOMImpl_ITranslate aTI(aFunction);
230 aTI.SetPoint1(thePoint1->GetLastFunction());
231 aTI.SetPoint2(thePoint2->GetLastFunction());
232 //aTI.SetShape(theObject->GetValue());
233 aTI.SetOriginal(aLastFunction);
235 //Compute the translation
238 if (!GetSolver()->ComputeFunction(aFunction)) {
239 SetErrorCode("Translation driver failed");
243 catch (Standard_Failure) {
244 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
245 SetErrorCode(aFail->GetMessageString());
249 //Make a Python command
250 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationTwoPoints("
251 << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
257 //=============================================================================
259 * TranslateDXDYDZCopy
261 //=============================================================================
262 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
263 (Handle(GEOM_Object) theObject, double theX, double theY, double theZ)
267 if (theObject.IsNull()) return NULL;
269 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
270 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
272 //Add a new Copy object
273 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
275 //Add a translate function
276 Handle(GEOM_Function) aFunction =
277 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
279 //Check if the function is set correctly
280 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
282 GEOMImpl_ITranslate aTI(aFunction);
286 aTI.SetOriginal(aLastFunction);
288 //Compute the translation
291 if (!GetSolver()->ComputeFunction(aFunction)) {
292 SetErrorCode("Translation driver failed");
296 catch (Standard_Failure) {
297 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
298 SetErrorCode(aFail->GetMessageString());
302 //Make a Python command
303 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslation("
304 << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
311 //=============================================================================
315 //=============================================================================
316 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
317 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
321 if (theObject.IsNull() || theVector.IsNull()) return NULL;
323 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
324 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
326 // Get last functions of the arguments
327 Handle(GEOM_Function) aVF = theVector->GetLastFunction();
329 //Add a translate function
330 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
332 if (aFunction.IsNull()) return NULL;
334 //Check if the function is set correctly
335 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
337 GEOMImpl_ITranslate aTI (aFunction);
339 aTI.SetOriginal(aLastFunction);
341 //Compute the translation
344 if (!GetSolver()->ComputeFunction(aFunction)) {
345 SetErrorCode("Translation driver failed");
349 catch (Standard_Failure) {
350 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
351 SetErrorCode(aFail->GetMessageString());
355 //Make a Python command
356 GEOM::TPythonDump(aFunction) << "geompy.TranslateVector("
357 << theObject << ", " << theVector << ")";
362 //=============================================================================
364 * TranslateVectorCopy
366 //=============================================================================
367 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
368 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
372 if (theObject.IsNull() || theVector.IsNull()) return NULL;
374 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
375 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
377 //Add a new Copy object
378 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
380 //Add a translate function
381 Handle(GEOM_Function) aFunction =
382 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
384 //Check if the function is set correctly
385 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
387 GEOMImpl_ITranslate aTI(aFunction);
388 aTI.SetVector(theVector->GetLastFunction());
389 // aTI.SetShape(theObject->GetValue());
390 aTI.SetOriginal(aLastFunction);
392 //Compute the translation
395 if (!GetSolver()->ComputeFunction(aFunction)) {
396 SetErrorCode("Translation driver failed");
400 catch (Standard_Failure) {
401 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
402 SetErrorCode(aFail->GetMessageString());
406 //Make a Python command
407 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVector("
408 << theObject << ", " << theVector << ")";
414 //=============================================================================
416 * TranslateVectorDistance
418 //=============================================================================
419 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
420 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, double theDistance, bool theCopy)
424 if (theObject.IsNull() || theVector.IsNull()) return NULL;
426 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
427 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
429 Handle(GEOM_Object) aCopy; //Add a new Copy object
430 Handle(GEOM_Function) aFunction;
432 //Add a translate function
434 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
435 aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
438 aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
440 if (aFunction.IsNull()) return NULL;
442 //Check if the function is set correctly
443 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
445 GEOMImpl_ITranslate aTI(aFunction);
446 aTI.SetVector(theVector->GetLastFunction());
447 aTI.SetDistance(theDistance);
448 // aTI.SetShape(theObject->GetValue());
449 aTI.SetOriginal(aLastFunction);
451 //Compute the translation
454 if (!GetSolver()->ComputeFunction(aFunction)) {
455 SetErrorCode("Translation driver failed");
459 catch (Standard_Failure) {
460 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
461 SetErrorCode(aFail->GetMessageString());
465 //Make a Python command
467 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeTranslationVectorDistance("
468 << theObject << ", " << theVector << ", " << theDistance << ")";
473 GEOM::TPythonDump(aFunction) << "geompy.TranslateVectorDistance("
474 << theObject << ", " << theVector << ", " << theDistance << ", " << theCopy << ")";
479 //=============================================================================
483 //=============================================================================
484 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
485 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
486 double theStep, Standard_Integer theNbTimes)
490 if (theObject.IsNull()) return NULL;
492 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
493 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
495 //Add a new Copy object
496 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
498 //Add a translate function
499 Handle(GEOM_Function) aFunction =
500 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
502 //Check if the function is set correctly
503 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
505 GEOMImpl_ITranslate aTI (aFunction);
506 aTI.SetOriginal(aLastFunction);
507 if (!theVector.IsNull())
508 aTI.SetVector(theVector->GetLastFunction());
509 aTI.SetStep1(theStep);
510 aTI.SetNbIter1(theNbTimes);
512 //Compute the translation
515 if (!GetSolver()->ComputeFunction(aFunction)) {
516 SetErrorCode("Translation driver failed");
520 catch (Standard_Failure) {
521 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
522 SetErrorCode(aFail->GetMessageString());
526 //Make a Python command
527 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation1D("
528 << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
534 //=============================================================================
538 //=============================================================================
539 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
540 Handle(GEOM_Object) theVector,
542 Standard_Integer theNbTimes1,
543 Handle(GEOM_Object) theVector2,
545 Standard_Integer theNbTimes2)
549 if (theObject.IsNull()) return NULL;
551 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
552 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
554 //Add a new Copy object
555 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
557 //Add a translate function
558 Handle(GEOM_Function) aFunction =
559 aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
561 //Check if the function is set correctly
562 if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
564 GEOMImpl_ITranslate aTI (aFunction);
565 aTI.SetOriginal(aLastFunction);
566 if (!theVector.IsNull())
567 aTI.SetVector(theVector->GetLastFunction());
568 aTI.SetStep1(theStep1);
569 aTI.SetNbIter1(theNbTimes1);
570 if (!theVector2.IsNull())
571 aTI.SetVector2(theVector2->GetLastFunction());
572 aTI.SetStep2(theStep2);
573 aTI.SetNbIter2(theNbTimes2);
575 //Compute the translation
578 if (!GetSolver()->ComputeFunction(aFunction)) {
579 SetErrorCode("Translation driver failed");
583 catch (Standard_Failure) {
584 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
585 SetErrorCode(aFail->GetMessageString());
589 //Make a Python command
590 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMultiTranslation2D("
591 << theObject << ", " << theVector << ", " << theStep1 << ", " << theNbTimes1
592 << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
598 //=============================================================================
602 //=============================================================================
604 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape1D (const TopoDS_Shape& theShape,
605 GEOMImpl_ITranslate* theTI)
610 Handle(GEOM_Function) aVector = theTI->GetVector();
611 if (aVector.IsNull()) {
612 StdFail_NotDone::Raise("Invalid object is given for vector argument");
614 TopoDS_Shape aV = aVector->GetValue();
615 if (aV.IsNull() || aV.ShapeType() != TopAbs_EDGE) {
616 StdFail_NotDone::Raise("Invalid object is given for vector argument");
618 TopoDS_Edge anEdge = TopoDS::Edge(aV);
620 gp_Pnt aP1 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge));
621 gp_Pnt aP2 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge));
622 if (aP1.Distance(aP2) < gp::Resolution()) {
623 StdFail_NotDone::Raise("Invalid object is given for vector argument");
627 Standard_Real step = theTI->GetStep1();
628 Standard_Integer nbtimes = theTI->GetNbIter1();
630 // Make multi-translation
633 TopoDS_Compound aCompound;
635 B.MakeCompound(aCompound);
637 gp_Vec Vec (aP1, aP2);
640 TopLoc_Location aLocOrig = theShape.Location();
641 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
643 for (int i = 0; i < nbtimes; i++) {
644 aVec = Vec * (i * step);
645 aTrsf.SetTranslation(aVec);
646 //NPAL18620: performance problem: multiple locations are accumulated
647 // in shape and need a great time to process
648 //BRepBuilderAPI_Transform aTransformation(theShape, aTrsf, Standard_False);
649 //B.Add(aCompound, aTransformation.Shape());
650 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
651 B.Add(aCompound, theShape.Located(aLocRes));
659 //=============================================================================
663 //=============================================================================
665 TopoDS_Shape GEOMImpl_ITransformOperations::TranslateShape2D (const TopoDS_Shape& theShape,
666 GEOMImpl_ITranslate* theTI)
671 Handle(GEOM_Function) aVector1 = theTI->GetVector();
672 Handle(GEOM_Function) aVector2 = theTI->GetVector2();
674 if (aVector1.IsNull() || aVector2.IsNull()) {
675 StdFail_NotDone::Raise("Invalid object is given for vector argument");
678 TopoDS_Shape aV1 = aVector1->GetValue();
679 TopoDS_Shape aV2 = aVector2->GetValue();
681 if (aV1.IsNull() || aV1.ShapeType() != TopAbs_EDGE ||
682 aV2.IsNull() || aV2.ShapeType() != TopAbs_EDGE) {
683 StdFail_NotDone::Raise("Invalid object is given for vector argument");
686 TopoDS_Edge anEdge1 = TopoDS::Edge(aV1);
687 TopoDS_Edge anEdge2 = TopoDS::Edge(aV2);
689 gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
690 gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge1));
691 gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
692 gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex(anEdge2));
694 if (aP11.Distance(aP12) < gp::Resolution() ||
695 aP21.Distance(aP22) < gp::Resolution()) {
696 StdFail_NotDone::Raise("Invalid object is given for vector argument");
699 gp_Vec Vec1 (aP11, aP12);
700 gp_Vec Vec2 (aP21, aP22);
706 Standard_Real step1 = theTI->GetStep1(), step2 = theTI->GetStep2();
707 Standard_Integer nbtimes1 = theTI->GetNbIter1(), nbtimes2 = theTI->GetNbIter2();
709 // Make multi-translation
712 Standard_Real DX, DY, DZ;
713 TopoDS_Compound aCompound;
715 B.MakeCompound(aCompound);
717 TopLoc_Location aLocOrig = theShape.Location();
718 gp_Trsf aTrsfOrig = aLocOrig.Transformation();
720 for (int i = 0; i < nbtimes1; i++) {
721 for (int j = 0; j < nbtimes2; j++) {
722 DX = i * step1 * Vec1.X() + j * step2 * Vec2.X();
723 DY = i * step1 * Vec1.Y() + j * step2 * Vec2.Y();
724 DZ = i * step1 * Vec1.Z() + j * step2 * Vec2.Z();
725 aVec.SetCoord(DX, DY, DZ);
726 aTrsf.SetTranslation(aVec);
727 //NPAL18620: performance problem: multiple locations are accumulated
728 // in shape and need a great time to process
729 //BRepBuilderAPI_Transform aBRepTransformation(theShape, aTrsf, Standard_False);
730 //B.Add(aCompound, aBRepTransformation.Shape());
731 TopLoc_Location aLocRes (aTrsf * aTrsfOrig);
732 B.Add(aCompound, theShape.Located(aLocRes));
741 //=============================================================================
745 //=============================================================================
746 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
747 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
751 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
753 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
754 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
756 // Get last functions of the arguments
757 Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
759 //Add a mirror function
760 Handle(GEOM_Function) aFunction =
761 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
762 if (aFunction.IsNull()) return NULL;
764 //Check if the function is set correctly
765 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
767 GEOMImpl_IMirror aTI (aFunction);
769 aTI.SetOriginal(aLastFunction);
774 if (!GetSolver()->ComputeFunction(aFunction)) {
775 SetErrorCode("Mirror driver failed");
779 catch (Standard_Failure) {
780 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
781 SetErrorCode(aFail->GetMessageString());
785 //Make a Python command
786 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPlane("
787 << theObject << ", " << thePlane << ")";
793 //=============================================================================
797 //=============================================================================
798 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
799 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
803 if (theObject.IsNull() || thePlane.IsNull()) return NULL;
805 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
806 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
808 //Add a new Copy object
809 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
811 //Add a mirror function
812 Handle(GEOM_Function) aFunction =
813 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
815 //Check if the function is set correctly
816 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
818 GEOMImpl_IMirror aTI (aFunction);
819 aTI.SetPlane(thePlane->GetLastFunction());
820 aTI.SetOriginal(aLastFunction);
825 if (!GetSolver()->ComputeFunction(aFunction)) {
826 SetErrorCode("Mirror driver failed");
830 catch (Standard_Failure) {
831 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
832 SetErrorCode(aFail->GetMessageString());
836 //Make a Python command
837 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPlane("
838 << theObject << ", " << thePlane << ")";
844 //=============================================================================
848 //=============================================================================
849 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
850 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
854 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
856 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
857 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
859 // Get last functions of the arguments
860 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
862 //Add a mirror function
863 Handle(GEOM_Function) aFunction =
864 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
865 if (aFunction.IsNull()) return NULL;
867 //Check if the function is set correctly
868 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
870 GEOMImpl_IMirror aTI (aFunction);
872 aTI.SetOriginal(aLastFunction);
877 if (!GetSolver()->ComputeFunction(aFunction)) {
878 SetErrorCode("Mirror driver failed");
882 catch (Standard_Failure) {
883 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
884 SetErrorCode(aFail->GetMessageString());
888 //Make a Python command
889 GEOM::TPythonDump(aFunction) << "geompy.MirrorByPoint("
890 << theObject << ", " << thePoint << ")";
896 //=============================================================================
900 //=============================================================================
901 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
902 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
906 if (theObject.IsNull() || thePoint.IsNull()) return NULL;
908 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
909 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
911 //Add a new Copy object
912 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
914 //Add a mirror function
915 Handle(GEOM_Function) aFunction =
916 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
918 //Check if the function is set correctly
919 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
921 GEOMImpl_IMirror aTI (aFunction);
922 aTI.SetPoint(thePoint->GetLastFunction());
923 aTI.SetOriginal(aLastFunction);
928 if (!GetSolver()->ComputeFunction(aFunction)) {
929 SetErrorCode("Mirror driver failed");
933 catch (Standard_Failure) {
934 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
935 SetErrorCode(aFail->GetMessageString());
939 //Make a Python command
940 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByPoint("
941 << theObject << ", " << thePoint << ")";
947 //=============================================================================
951 //=============================================================================
952 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
953 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
957 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
959 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
960 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
962 // Get last functions of the arguments
963 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
965 //Add a mirror function
966 Handle(GEOM_Function) aFunction =
967 theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
968 if (aFunction.IsNull()) return NULL;
970 //Check if the function is set correctly
971 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
973 GEOMImpl_IMirror aTI (aFunction);
975 aTI.SetOriginal(aLastFunction);
980 if (!GetSolver()->ComputeFunction(aFunction)) {
981 SetErrorCode("Mirror driver failed");
985 catch (Standard_Failure) {
986 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
987 SetErrorCode(aFail->GetMessageString());
991 //Make a Python command
992 GEOM::TPythonDump(aFunction) << "geompy.MirrorByAxis("
993 << theObject << ", " << theAxis << ")";
999 //=============================================================================
1003 //=============================================================================
1004 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
1005 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
1009 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1011 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
1012 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
1014 //Add a new Copy object
1015 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1017 //Add a mirror function
1018 Handle(GEOM_Function) aFunction =
1019 aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
1021 //Check if the function is set correctly
1022 if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
1024 GEOMImpl_IMirror aTI (aFunction);
1025 aTI.SetAxis(theAxis->GetLastFunction());
1026 aTI.SetOriginal(aLastFunction);
1028 //Compute the mirror
1031 if (!GetSolver()->ComputeFunction(aFunction)) {
1032 SetErrorCode("Mirror driver failed");
1036 catch (Standard_Failure) {
1037 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1038 SetErrorCode(aFail->GetMessageString());
1042 //Make a Python command
1043 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeMirrorByAxis("
1044 << theObject << ", " << theAxis << ")";
1051 //=============================================================================
1055 //=============================================================================
1056 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
1057 (Handle(GEOM_Object) theObject, double theOffset)
1061 if (theObject.IsNull()) return NULL;
1063 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1064 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1066 //Add a new Offset function
1067 Handle(GEOM_Function) aFunction =
1068 theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1069 if (aFunction.IsNull()) return NULL;
1071 //Check if the function is set correctly
1072 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1074 GEOMImpl_IOffset aTI (aFunction);
1075 aTI.SetShape(anOriginal);
1076 aTI.SetValue(theOffset);
1078 //Compute the offset
1081 if (!GetSolver()->ComputeFunction(aFunction)) {
1082 SetErrorCode("Offset driver failed");
1086 catch (Standard_Failure) {
1087 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1088 SetErrorCode(aFail->GetMessageString());
1092 //Make a Python command
1093 GEOM::TPythonDump(aFunction) << "geompy.Offset("
1094 << theObject << ", " << theOffset << ")";
1100 //=============================================================================
1104 //=============================================================================
1105 Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1106 (Handle(GEOM_Object) theObject, double theOffset)
1110 if (theObject.IsNull()) return NULL;
1112 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1113 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1115 //Add a new Copy object
1116 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1118 //Add a new Offset function
1119 Handle(GEOM_Function) aFunction =
1120 aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1121 if (aFunction.IsNull()) return NULL;
1123 //Check if the function is set correctly
1124 if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1126 GEOMImpl_IOffset aTI (aFunction);
1127 aTI.SetShape(anOriginal);
1128 aTI.SetValue(theOffset);
1130 //Compute the offset
1133 if (!GetSolver()->ComputeFunction(aFunction)) {
1134 SetErrorCode("Offset driver failed");
1138 catch (Standard_Failure) {
1139 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1140 SetErrorCode(aFail->GetMessageString());
1144 //Make a Python command
1145 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeOffset("
1146 << theObject << ", " << theOffset << ")";
1153 //=============================================================================
1157 //=============================================================================
1159 GEOMImpl_ITransformOperations::ProjectShapeCopy (Handle(GEOM_Object) theSource,
1160 Handle(GEOM_Object) theTarget)
1164 if (theSource.IsNull() || theTarget.IsNull()) return NULL;
1166 Handle(GEOM_Function) aLastFunction = theSource->GetLastFunction();
1167 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be projected
1169 Handle(GEOM_Object) aCopy;
1171 TopoDS_Shape aTarget = theTarget->GetValue();
1172 if ( aTarget.IsNull() ) return NULL;
1173 if ( aTarget.ShapeType() == TopAbs_EDGE ||
1174 aTarget.ShapeType() == TopAbs_WIRE )
1176 // a TPythonDump prevents dumping ProjectPointOnWire(),
1177 // dump of MakeProjection() is done at the end of this function
1178 GEOM::TPythonDump preventDump(aLastFunction, /*append=*/true);
1179 Standard_Integer dummy;
1180 ProjectPointOnWire( theSource, theTarget, aCopy, dummy );
1181 if ( aCopy.IsNull() || !IsDone() )
1186 //Add a new Projection object
1187 aCopy = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1189 //Add a Projection function
1190 Handle(GEOM_Function) aFunction =
1191 aCopy->AddFunction(GEOMImpl_ProjectionDriver::GetID(), PROJECTION_COPY);
1193 //Check if the function is set correctly
1194 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) return NULL;
1196 GEOMImpl_IMirror aTI (aFunction);
1197 aTI.SetPlane(theTarget->GetLastFunction());
1198 aTI.SetOriginal(aLastFunction);
1200 //Compute the Projection
1203 if (!GetSolver()->ComputeFunction(aFunction)) {
1204 SetErrorCode("Projection driver failed");
1208 catch (Standard_Failure) {
1209 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1210 SetErrorCode(aFail->GetMessageString());
1215 //Make a Python command
1216 Handle(GEOM_Function) aFunction = aCopy->GetLastFunction();
1217 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeProjection("
1218 << theSource << ", " << theTarget << ")";
1224 //=============================================================================
1226 * ProjectPointOnWire
1228 //=============================================================================
1229 Standard_Real GEOMImpl_ITransformOperations::ProjectPointOnWire
1230 (Handle(GEOM_Object) thePoint,
1231 Handle(GEOM_Object) theWire,
1232 Handle(GEOM_Object) &thePointOnEdge,
1233 Standard_Integer &theEdgeInWireIndex)
1235 Standard_Real aResult = -1.;
1239 if (thePoint.IsNull() || theWire.IsNull()) {
1243 Handle(GEOM_Function) aLastFunction = thePoint->GetLastFunction();
1245 if (aLastFunction.IsNull()) {
1246 //There is no function which creates an object to be projected
1250 //Add a new Projection object
1251 thePointOnEdge = GetEngine()->AddObject(GetDocID(), GEOM_PROJECTION);
1253 //Add a Projection function
1254 Handle(GEOM_Function) aFunction = thePointOnEdge->AddFunction
1255 (GEOMImpl_ProjectionDriver::GetID(), PROJECTION_ON_WIRE);
1257 //Check if the function is set correctly
1258 if (aFunction->GetDriverGUID() != GEOMImpl_ProjectionDriver::GetID()) {
1262 GEOMImpl_IProjection aProj (aFunction);
1263 aProj.SetPoint(aLastFunction);
1264 aProj.SetShape(theWire->GetLastFunction());
1266 //Compute the Projection
1269 if (!GetSolver()->ComputeFunction(aFunction)) {
1270 SetErrorCode("Projection driver failed");
1274 catch (Standard_Failure) {
1275 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1276 SetErrorCode(aFail->GetMessageString());
1280 aResult = aProj.GetU();
1281 theEdgeInWireIndex = aProj.GetIndex();
1284 //Make a Python command
1285 GEOM::TPythonDump(aFunction) << "(u, " << thePointOnEdge
1286 << ", EdgeInWireIndex) = geompy.MakeProjectionOnWire(" << thePoint
1287 << ", " << theWire << ")";
1294 //=============================================================================
1298 //=============================================================================
1299 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1300 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1304 if (theObject.IsNull()) return NULL;
1306 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1307 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1309 //Add a scale function
1310 Handle(GEOM_Function) aFunction =
1311 theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1312 if (aFunction.IsNull()) return NULL;
1314 //Check if the function is set correctly
1315 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1318 GEOMImpl_IScale aTI (aFunction);
1319 aTI.SetShape(anOriginal);
1320 aTI.SetFactor(theFactor);
1322 // Set point argument
1323 if (!thePoint.IsNull()) {
1324 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1331 if (!GetSolver()->ComputeFunction(aFunction)) {
1332 SetErrorCode("Scale driver failed");
1336 catch (Standard_Failure) {
1337 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1338 SetErrorCode(aFail->GetMessageString());
1342 //Make a Python command
1343 GEOM::TPythonDump(aFunction) << "geompy.Scale("
1344 << theObject << ", " << thePoint << ", " << theFactor << ")";
1350 //=============================================================================
1354 //=============================================================================
1355 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1356 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, double theFactor)
1360 if (theObject.IsNull()) return NULL;
1362 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1363 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1365 //Add a new Copy object
1366 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1368 //Add a scale function
1369 Handle(GEOM_Function) aFunction =
1370 aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1371 if (aFunction.IsNull()) return NULL;
1373 //Check if the function is set correctly
1374 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1377 GEOMImpl_IScale aTI (aFunction);
1378 aTI.SetShape(anOriginal);
1379 aTI.SetFactor(theFactor);
1381 // Set point argument
1382 if (!thePoint.IsNull()) {
1383 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1390 if (!GetSolver()->ComputeFunction(aFunction)) {
1391 SetErrorCode("Scale driver failed");
1395 catch (Standard_Failure) {
1396 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1397 SetErrorCode(aFail->GetMessageString());
1401 //Make a Python command
1402 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleTransform("
1403 << theObject << ", " << thePoint << ", " << theFactor << ")";
1409 //=============================================================================
1411 * ScaleShapeAlongAxes
1413 //=============================================================================
1414 Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAlongAxes (Handle(GEOM_Object) theObject,
1415 Handle(GEOM_Object) thePoint,
1423 if (theObject.IsNull()) return NULL;
1425 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1426 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1428 //Add a scale function
1429 Handle(GEOM_Object) aCopy; //Add a new Copy object
1430 Handle(GEOM_Function) aFunction;
1432 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1433 aFunction = aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES_COPY);
1436 aFunction = theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AXES);
1438 if (aFunction.IsNull()) return NULL;
1440 //Check if the function is set correctly
1441 if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1444 GEOMImpl_IScale aTI (aFunction);
1445 aTI.SetShape(anOriginal);
1446 aTI.SetFactorX(theFactorX);
1447 aTI.SetFactorY(theFactorY);
1448 aTI.SetFactorZ(theFactorZ);
1450 // Set point (optional argument)
1451 if (!thePoint.IsNull()) {
1452 Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1459 if (!GetSolver()->ComputeFunction(aFunction)) {
1460 SetErrorCode("Scale driver failed");
1464 catch (Standard_Failure) {
1465 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1466 SetErrorCode(aFail->GetMessageString());
1472 //Make a Python command
1474 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeScaleAlongAxes("
1475 << theObject << ", " << thePoint << ", "
1476 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1480 GEOM::TPythonDump(aFunction) << "geompy.ScaleAlongAxes("
1481 << theObject << ", " << thePoint << ", "
1482 << theFactorX << ", " << theFactorY << ", " << theFactorZ << ")";
1486 //=============================================================================
1490 //=============================================================================
1491 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1492 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1496 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1498 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1499 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1501 //Add a Position function
1502 Standard_Integer aType = POSITION_SHAPE;
1503 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1505 Handle(GEOM_Function) aFunction =
1506 theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1507 if (aFunction.IsNull()) return NULL;
1509 //Check if the function is set correctly
1510 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1512 //Set operation arguments
1513 GEOMImpl_IPosition aTI (aFunction);
1514 aTI.SetShape(anOriginal);
1515 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1516 if (!theStartLCS.IsNull())
1517 aTI.SetStartLCS(theObject == theStartLCS ? anOriginal : theStartLCS->GetLastFunction());
1519 //Compute the Position
1522 if (!GetSolver()->ComputeFunction(aFunction)) {
1523 SetErrorCode("Position driver failed");
1527 catch (Standard_Failure) {
1528 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1529 SetErrorCode(aFail->GetMessageString());
1533 //Make a Python command
1534 GEOM::TPythonDump(aFunction) << "geompy.Position("
1535 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1541 //=============================================================================
1545 //=============================================================================
1546 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1547 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1551 if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1553 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1554 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1556 //Add a new Copy object
1557 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1559 //Add a position function
1560 Standard_Integer aType = POSITION_SHAPE_COPY;
1561 if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1563 Handle(GEOM_Function) aFunction =
1564 aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1565 if (aFunction.IsNull()) return NULL;
1567 //Check if the function is set correctly
1568 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1570 GEOMImpl_IPosition aTI (aFunction);
1571 aTI.SetShape(anOriginal);
1572 aTI.SetEndLCS(theEndLCS->GetLastFunction());
1573 if (!theStartLCS.IsNull())
1574 aTI.SetStartLCS(theStartLCS->GetLastFunction());
1576 //Compute the position
1579 if (!GetSolver()->ComputeFunction(aFunction)) {
1580 SetErrorCode("Position driver failed");
1584 catch (Standard_Failure) {
1585 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1586 SetErrorCode(aFail->GetMessageString());
1590 //Make a Python command
1591 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePosition("
1592 << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1598 //=============================================================================
1602 //=============================================================================
1603 Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionAlongPath
1604 (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePath,
1605 double theDistance, bool theCopy, bool theReverse)
1609 if (theObject.IsNull() || thePath.IsNull()) return NULL;
1611 Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1612 if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1614 //Add a position function
1615 Handle(GEOM_Function) aFunction;
1616 Handle(GEOM_Object) aCopy;
1619 aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1620 aFunction = aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1623 aFunction = theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), POSITION_ALONG_PATH);
1625 if (aFunction.IsNull()) return NULL;
1627 //Check if the function is set correctly
1628 if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1630 GEOMImpl_IPosition aTI (aFunction);
1631 aTI.SetShape(anOriginal);
1632 aTI.SetPath(thePath->GetLastFunction());
1633 aTI.SetDistance(theDistance);
1634 aTI.SetReverse(theReverse);
1636 //Compute the position
1639 if (!GetSolver()->ComputeFunction(aFunction)) {
1640 SetErrorCode("Position driver failed");
1644 catch (Standard_Failure) {
1645 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1646 SetErrorCode(aFail->GetMessageString());
1650 //Make a Python command
1652 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakePositionAlongPath("
1653 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1658 GEOM::TPythonDump(aFunction) << "geompy.PositionAlongPath("
1659 << theObject << ", " << thePath << ", " << theDistance << ", " << theCopy << ", " << theReverse << ")";
1665 //=============================================================================
1669 //=============================================================================
1670 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1671 Handle(GEOM_Object) theAxis,
1676 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1678 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1679 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1681 // Get last functions of the arguments
1682 Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1684 //Add a rotate function
1685 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1687 if (aFunction.IsNull()) return NULL;
1689 //Check if the function is set correctly
1690 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1692 GEOMImpl_IRotate aRI(aFunction);
1694 aRI.SetOriginal(aLastFunction);
1695 aRI.SetAngle(theAngle);
1697 //Compute the translation
1700 if (!GetSolver()->ComputeFunction(aFunction)) {
1701 SetErrorCode("Rotate driver failed");
1705 catch (Standard_Failure) {
1706 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1707 SetErrorCode(aFail->GetMessageString());
1711 //Make a Python command
1712 GEOM::TPythonDump(aFunction) << "geompy.Rotate(" << theObject
1713 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1719 //=============================================================================
1723 //=============================================================================
1724 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject,
1725 Handle(GEOM_Object) theAxis,
1730 if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1732 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1733 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1735 //Add a new Copy object
1736 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
1738 //Add a rotate function
1739 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_COPY);
1740 if (aFunction.IsNull()) return NULL;
1742 //Check if the function is set correctly
1743 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1745 GEOMImpl_IRotate aRI(aFunction);
1746 aRI.SetAxis(theAxis->GetLastFunction());
1747 aRI.SetOriginal(aLastFunction);
1748 aRI.SetAngle(theAngle);
1750 //Compute the translation
1753 if (!GetSolver()->ComputeFunction(aFunction)) {
1754 SetErrorCode("Rotate driver failed");
1758 catch (Standard_Failure) {
1759 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1760 SetErrorCode(aFail->GetMessageString());
1764 //Make a Python command
1765 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotation(" << theObject
1766 << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
1772 //=============================================================================
1774 * Rotate1D (for MultiRotate1DNbTimes)
1776 //=============================================================================
1777 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1778 Handle(GEOM_Object) theAxis,
1779 Standard_Integer theNbTimes)
1783 if (theObject.IsNull()) return NULL;
1785 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1786 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1788 //Add a new Copy object
1789 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1791 //Add a rotate function
1792 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D);
1793 if (aFunction.IsNull()) return NULL;
1795 //Check if the function is set correctly
1796 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1798 GEOMImpl_IRotate aRI(aFunction);
1799 aRI.SetOriginal(aLastFunction);
1800 if (!theAxis.IsNull())
1801 aRI.SetAxis(theAxis->GetLastFunction());
1802 aRI.SetNbIter1(theNbTimes);
1804 //Compute the translation
1807 if (!GetSolver()->ComputeFunction(aFunction)) {
1808 SetErrorCode("Rotate driver failed");
1812 catch (Standard_Failure) {
1813 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1814 SetErrorCode(aFail->GetMessageString());
1818 //Make a Python command
1819 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate1DNbTimes("
1820 << theObject << ", " << theAxis << ", " << theNbTimes << ")";
1826 //=============================================================================
1828 * Rotate1D (for MultiRotate1DByStep)
1830 //=============================================================================
1831 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate1D (Handle(GEOM_Object) theObject,
1832 Handle(GEOM_Object) theAxis,
1833 double theAngleStep,
1834 Standard_Integer theNbSteps)
1838 if (theObject.IsNull()) return NULL;
1840 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1841 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1843 //Add a new Copy object
1844 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1846 //Add a rotate function
1847 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_1D_STEP);
1848 if (aFunction.IsNull()) return NULL;
1850 //Check if the function is set correctly
1851 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1853 //Convert angle into degrees
1854 double anAngleStep = theAngleStep * 180. / M_PI;
1856 GEOMImpl_IRotate aRI (aFunction);
1857 aRI.SetOriginal(aLastFunction);
1858 if (!theAxis.IsNull())
1859 aRI.SetAxis(theAxis->GetLastFunction());
1860 aRI.SetAngle(anAngleStep);
1861 aRI.SetNbIter1(theNbSteps);
1863 //Compute the translation
1866 if (!GetSolver()->ComputeFunction(aFunction)) {
1867 SetErrorCode("Rotate driver failed");
1871 catch (Standard_Failure) {
1872 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1873 SetErrorCode(aFail->GetMessageString());
1877 //Make a Python command
1878 GEOM::TPythonDump(aFunction)
1879 << aCopy << " = geompy.MultiRotate1DByStep(" << theObject << ", "
1880 << theAxis << ", " << anAngleStep << "*math.pi/180.0, " << theNbSteps << ")";
1886 //=============================================================================
1888 * Rotate2D (for MultiRotate2DNbTimes)
1890 //=============================================================================
1891 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1892 Handle(GEOM_Object) theAxis,
1893 Standard_Integer theNbObjects,
1894 double theRadialStep,
1895 Standard_Integer theNbSteps)
1899 if (theObject.IsNull()) return NULL;
1901 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1902 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1904 //Add a new Copy object
1905 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1907 //Add a rotate function
1908 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1909 if (aFunction.IsNull()) return NULL;
1911 //Check if the function is set correctly
1912 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1914 double anAngle = 360. / (double)theNbObjects;
1916 GEOMImpl_IRotate aRI (aFunction);
1917 aRI.SetOriginal(aLastFunction);
1918 if (!theAxis.IsNull())
1919 aRI.SetAxis(theAxis->GetLastFunction());
1920 aRI.SetAngle(anAngle);
1921 aRI.SetNbIter1(theNbObjects);
1922 aRI.SetStep(theRadialStep);
1923 aRI.SetNbIter2(theNbSteps);
1925 //Compute the translation
1928 if (!GetSolver()->ComputeFunction(aFunction)) {
1929 SetErrorCode("Rotate driver failed");
1933 catch (Standard_Failure) {
1934 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1935 SetErrorCode(aFail->GetMessageString());
1939 //Make a Python command
1940 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MultiRotate2DNbTimes("
1941 << theObject << ", " << theAxis << ", " << theNbObjects
1942 << ", " << theRadialStep << ", " << theNbSteps << ")";
1948 //=============================================================================
1950 * Rotate2D (for MultiRotate2DByStep)
1952 //=============================================================================
1953 Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate2D (Handle(GEOM_Object) theObject,
1954 Handle(GEOM_Object) theAxis,
1955 double theAngleStep,
1956 Standard_Integer theNbTimes1,
1958 Standard_Integer theNbTimes2)
1962 if (theObject.IsNull()) return NULL;
1964 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1965 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
1967 //Add a new Copy object
1968 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1970 //Add a rotate function
1971 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_2D);
1972 if (aFunction.IsNull()) return NULL;
1974 //Check if the function is set correctly
1975 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1977 //Convert angle into degrees
1978 double anAngleStep = theAngleStep * 180. / M_PI;
1980 GEOMImpl_IRotate aRI (aFunction);
1981 aRI.SetOriginal(aLastFunction);
1982 if (!theAxis.IsNull())
1983 aRI.SetAxis(theAxis->GetLastFunction());
1984 aRI.SetAngle(anAngleStep);
1985 aRI.SetNbIter1(theNbTimes1);
1986 aRI.SetStep(theStep);
1987 aRI.SetNbIter2(theNbTimes2);
1989 //Compute the translation
1992 if (!GetSolver()->ComputeFunction(aFunction)) {
1993 SetErrorCode("Rotate driver failed");
1997 catch (Standard_Failure) {
1998 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1999 SetErrorCode(aFail->GetMessageString());
2003 //Make a Python command
2004 GEOM::TPythonDump(aFunction)
2005 << aCopy << " = geompy.MultiRotate2DByStep(" << theObject << ", "
2006 << theAxis << ", " << anAngleStep << "*math.pi/180.0, "
2007 << theNbTimes1 << ", " << theStep << ", " << theNbTimes2 << ")";
2013 //=============================================================================
2017 //=============================================================================
2018 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePoints (Handle(GEOM_Object) theObject,
2019 Handle(GEOM_Object) theCentPoint,
2020 Handle(GEOM_Object) thePoint1,
2021 Handle(GEOM_Object) thePoint2)
2025 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2027 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2028 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2030 // Get last functions of the arguments
2031 Handle(GEOM_Function) aCPF = theCentPoint->GetLastFunction();
2032 Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
2033 Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
2036 //Add a rotate function
2037 aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS);
2039 if (aFunction.IsNull()) return NULL;
2041 //Check if the function is set correctly
2042 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2044 GEOMImpl_IRotate aRI(aFunction);
2045 aRI.SetCentPoint(aCPF);
2046 aRI.SetPoint1(aP1F);
2047 aRI.SetPoint2(aP2F);
2048 aRI.SetOriginal(aLastFunction);
2050 //Compute the translation
2053 if (!GetSolver()->ComputeFunction(aFunction)) {
2054 SetErrorCode("Rotate driver failed");
2058 catch (Standard_Failure) {
2059 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2060 SetErrorCode(aFail->GetMessageString());
2064 //Make a Python command
2065 GEOM::TPythonDump(aFunction) << "geompy.RotateThreePoints(" << theObject
2066 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2072 //=============================================================================
2074 * RotateThreePointsCopy
2076 //=============================================================================
2077 Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateThreePointsCopy (Handle(GEOM_Object) theObject,
2078 Handle(GEOM_Object) theCentPoint,
2079 Handle(GEOM_Object) thePoint1,
2080 Handle(GEOM_Object) thePoint2)
2084 if (theObject.IsNull() || theCentPoint.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
2086 Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
2087 if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be rotated
2089 //Add a new Copy object
2090 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
2092 //Add a rotate function
2093 aFunction = aCopy->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE_THREE_POINTS_COPY);
2094 if (aFunction.IsNull()) return NULL;
2096 //Check if the function is set correctly
2097 if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
2099 GEOMImpl_IRotate aRI(aFunction);
2100 aRI.SetCentPoint(theCentPoint->GetLastFunction());
2101 aRI.SetPoint1(thePoint1->GetLastFunction());
2102 aRI.SetPoint2(thePoint2->GetLastFunction());
2103 aRI.SetOriginal(aLastFunction);
2105 //Compute the translation
2108 if (!GetSolver()->ComputeFunction(aFunction)) {
2109 SetErrorCode("Rotate driver failed");
2113 catch (Standard_Failure) {
2114 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2115 SetErrorCode(aFail->GetMessageString());
2119 //Make a Python command
2120 GEOM::TPythonDump(aFunction) << aCopy << " = geompy.MakeRotationThreePoints(" << theObject
2121 << ", " << theCentPoint << ", "<<thePoint1 << ", " << thePoint2 << ")";
2127 //=============================================================================
2129 * TransformLikeOtherCopy
2131 //=============================================================================
2132 Handle(GEOM_Object) GEOMImpl_ITransformOperations::TransformLikeOtherCopy
2133 (Handle(GEOM_Object) theObject,
2134 Handle(GEOM_Object) theSample)
2138 if (theObject.IsNull() || theSample.IsNull()) return NULL;
2140 Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
2141 if (aLastFunction.IsNull()) return NULL; // There is no function which creates an object to be transformed
2143 Handle(GEOM_Function) aSampleFunc = theSample->GetLastFunction();
2144 if (aSampleFunc.IsNull()) return NULL; // There is no function which creates a sample object
2146 // Add a new Copy object
2147 Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
2149 // Add a transform function (depends on theSample function)
2150 Handle(GEOM_Function) aFunction =
2151 aCopy->AddFunction(aSampleFunc->GetDriverGUID(), aSampleFunc->GetType());
2152 if (aFunction.IsNull()) return NULL;
2154 // Check if the function is set correctly
2155 if (aFunction->GetDriverGUID() != aSampleFunc->GetDriverGUID()) return NULL;
2157 if (aSampleFunc->GetDriverGUID() == GEOMImpl_TranslateDriver::GetID()) {
2158 switch (aSampleFunc->GetType()) {
2161 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2162 GEOMImpl_ITranslate aRI_target (aFunction);
2164 aRI_target.SetVector(aRI_sample.GetVector());
2165 aRI_target.SetStep1(aRI_sample.GetStep1());
2166 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2168 aRI_target.SetOriginal(aLastFunction);
2173 GEOMImpl_ITranslate aRI_sample (aSampleFunc);
2174 GEOMImpl_ITranslate aRI_target (aFunction);
2176 aRI_target.SetVector(aRI_sample.GetVector());
2177 aRI_target.SetStep1(aRI_sample.GetStep1());
2178 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2180 aRI_target.SetVector2(aRI_sample.GetVector2());
2181 aRI_target.SetStep2(aRI_sample.GetStep2());
2182 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2184 aRI_target.SetOriginal(aLastFunction);
2189 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2194 else if (aSampleFunc->GetDriverGUID() == GEOMImpl_RotateDriver::GetID()) {
2195 switch (aSampleFunc->GetType()) {
2198 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2199 GEOMImpl_IRotate aRI_target (aFunction);
2201 aRI_target.SetAxis(aRI_sample.GetAxis());
2202 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2204 aRI_target.SetOriginal(aLastFunction);
2209 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2210 GEOMImpl_IRotate aRI_target (aFunction);
2212 aRI_target.SetAxis(aRI_sample.GetAxis());
2214 aRI_target.SetNbIter1(aRI_sample.GetNbIter1());
2215 aRI_target.SetNbIter2(aRI_sample.GetNbIter2());
2217 aRI_target.SetAngle(aRI_sample.GetAngle());
2218 aRI_target.SetStep(aRI_sample.GetStep());
2220 aRI_target.SetDir2(aRI_sample.GetDir2());
2222 aRI_target.SetOriginal(aLastFunction);
2225 case ROTATE_THREE_POINTS_COPY:
2227 GEOMImpl_IRotate aRI_sample (aSampleFunc);
2228 GEOMImpl_IRotate aRI_target (aFunction);
2230 aRI_target.SetCentPoint(aRI_sample.GetCentPoint());
2231 aRI_target.SetPoint1(aRI_sample.GetPoint1());
2232 aRI_target.SetPoint2(aRI_sample.GetPoint2());
2234 aRI_target.SetOriginal(aLastFunction);
2239 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2245 SetErrorCode("Not implemented case of TransformLikeOtherCopy");
2249 // Compute the transformation
2252 if (!GetSolver()->ComputeFunction(aFunction)) {
2253 SetErrorCode("Driver failed");
2257 catch (Standard_Failure) {
2258 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2259 SetErrorCode(aFail->GetMessageString());
2263 //Make a Python command
2264 //GEOM::TPythonDump(aFunction) << aCopy << " = geompy.TransformLikeOtherCopy("
2265 // << theObject << ", " << theSample << ")";
2271 //=============================================================================
2273 * MakeProjectionOnCylinder
2275 //=============================================================================
2276 Handle(GEOM_Object) GEOMImpl_ITransformOperations::MakeProjectionOnCylinder
2277 (const Handle(GEOM_Object) &theObject,
2278 const Standard_Real theRadius,
2279 const Standard_Real theStartAngle,
2280 const Standard_Real theAngleLength,
2281 const Standard_Real theAngleRotation)
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);
2315 aProj.SetAngleRotation(theAngleRotation);
2317 //Compute the Projection
2320 if (!GetSolver()->ComputeFunction(aFunction)) {
2321 SetErrorCode("Projection driver failed");
2325 catch (Standard_Failure) {
2326 Handle(Standard_Failure) aFail = Standard_Failure::Caught();
2327 SetErrorCode(aFail->GetMessageString());
2331 //Make a Python command
2332 GEOM::TPythonDump(aFunction)
2333 << aResult << " = geompy.MakeProjectionOnCylinder("
2334 << theObject << ", " << theRadius << ", " << theStartAngle
2335 << ", " << theAngleLength << ", " << theAngleRotation << ")";