PageRenderTime 142ms CodeModel.GetById 20ms app.highlight 114ms RepoModel.GetById 1ms app.codeStats 0ms

/src/contrib/geom-5.1.2.7/src/GEOMImpl/GEOMImpl_ITransformOperations.cpp

http://pythonocc.googlecode.com/
C++ | 1782 lines | 1119 code | 328 blank | 335 comment | 215 complexity | 260d8e4f051e2e58186a812bf24f3979 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
   2// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
   3//
   4// This library is free software; you can redistribute it and/or
   5// modify it under the terms of the GNU Lesser General Public
   6// License as published by the Free Software Foundation; either
   7// version 2.1 of the License.
   8//
   9// This library is distributed in the hope that it will be useful
  10// but WITHOUT ANY WARRANTY; without even the implied warranty of
  11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12// Lesser General Public License for more details.
  13//
  14// You should have received a copy of the GNU Lesser General Public
  15// License along with this library; if not, write to the Free Software
  16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  17//
  18// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
  19//
  20#include "utilities.h"
  21
  22#include <Standard_Stream.hxx>
  23
  24#include <GEOMImpl_ITransformOperations.hxx>
  25
  26#define SETPARAM(aFUNC,aVAL)  \
  27  if (aVAL.IsString())         \
  28	aFUNC( aVAL.GetString() ); \
  29  else                         \
  30	aFUNC( aVAL.GetDouble() );
  31
  32#include <TFunction_DriverTable.hxx>
  33#include <TFunction_Driver.hxx>
  34#include <TFunction_Logbook.hxx>
  35#include <TDF_Tool.hxx>
  36
  37#include <GEOM_Function.hxx>
  38#include <GEOM_PythonDump.hxx>
  39
  40#include <GEOMImpl_TranslateDriver.hxx>
  41#include <GEOMImpl_MirrorDriver.hxx>
  42#include <GEOMImpl_OffsetDriver.hxx>
  43#include <GEOMImpl_ScaleDriver.hxx>
  44#include <GEOMImpl_RotateDriver.hxx>
  45#include <GEOMImpl_PositionDriver.hxx>
  46
  47#include <GEOMImpl_ITranslate.hxx>
  48#include <GEOMImpl_IMirror.hxx>
  49#include <GEOMImpl_IOffset.hxx>
  50#include <GEOMImpl_IScale.hxx>
  51#include <GEOMImpl_IRotate.hxx>
  52#include <GEOMImpl_IPosition.hxx>
  53
  54#include <GEOMImpl_Types.hxx>
  55
  56#include <Standard_Failure.hxx>
  57#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
  58
  59//=============================================================================
  60/*!
  61 *   constructor:
  62 */
  63//=============================================================================
  64
  65GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations (GEOM_Engine* theEngine, int theDocID)
  66: GEOM_IOperations(theEngine, theDocID)
  67{
  68  //MESSAGE("GEOMImpl_ITransformOperations::GEOMImpl_ITransformOperations");
  69}
  70
  71//=============================================================================
  72/*!
  73 *  destructor
  74 */
  75//=============================================================================
  76
  77GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations()
  78{
  79  //MESSAGE("GEOMImpl_ITransformOperations::~GEOMImpl_ITransformOperations");
  80}
  81
  82
  83//=============================================================================
  84/*!
  85 *  TranslateTwoPoints
  86 */
  87//=============================================================================
  88Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPoints
  89       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
  90{
  91  SetErrorCode(GEOM_KO);
  92
  93  if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
  94
  95  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
  96  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
  97
  98  // Get last functions of the arguments
  99  Handle(GEOM_Function) aP1F = thePoint1->GetLastFunction();
 100  Handle(GEOM_Function) aP2F = thePoint2->GetLastFunction();
 101
 102  //Add a translate function
 103  aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS);
 104
 105  if (aFunction.IsNull()) return NULL;
 106
 107  //Check if the function is set correctly
 108  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 109
 110  GEOMImpl_ITranslate aTI (aFunction);
 111  aTI.SetPoint1(aP1F);
 112  aTI.SetPoint2(aP2F);
 113  aTI.SetOriginal(aLastFunction);
 114
 115  //Compute the translation
 116  try {
 117#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 118    OCC_CATCH_SIGNALS;
 119#endif
 120    if (!GetSolver()->ComputeFunction(aFunction)) {
 121      SetErrorCode("Translation driver failed");
 122      return NULL;
 123    }
 124  }
 125  catch (Standard_Failure) {
 126    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 127    SetErrorCode(aFail->GetMessageString());
 128    return NULL;
 129  }
 130
 131  //Make a Python command
 132  GEOM::TPythonDump(aFunction) << "TranslateTwoPoints("
 133    << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
 134
 135  SetErrorCode(GEOM_OK);
 136  return theObject;
 137}
 138
 139//=============================================================================
 140/*!
 141 *  TranslateDXDYDZ
 142 */
 143//=============================================================================
 144Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZ
 145	   (Handle(GEOM_Object) theObject, const GEOM_Parameter&  theX, const GEOM_Parameter&  theY,  const GEOM_Parameter&  theZ)
 146{
 147  SetErrorCode(GEOM_KO);
 148
 149  if (theObject.IsNull()) return NULL;
 150
 151  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
 152  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 153
 154  //Add a translate function
 155  aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ);
 156
 157  if (aFunction.IsNull()) return NULL;
 158
 159  //Check if the function is set correctly
 160  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 161
 162  GEOMImpl_ITranslate aTI(aFunction);
 163  SETPARAM(aTI.SetDX,theX);
 164  SETPARAM(aTI.SetDY,theY);
 165  SETPARAM(aTI.SetDZ,theZ);
 166  aTI.SetOriginal(aLastFunction);
 167
 168  //Compute the translation
 169  try {
 170#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 171    OCC_CATCH_SIGNALS;
 172#endif
 173    if (!GetSolver()->ComputeFunction(aFunction)) {
 174      SetErrorCode("Translation driver failed");
 175      return NULL;
 176    }
 177  }
 178  catch (Standard_Failure) {
 179    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 180    SetErrorCode(aFail->GetMessageString());
 181    return NULL;
 182  }
 183
 184  //Make a Python command
 185  GEOM::TPythonDump(aFunction) << "TranslateDXDYDZ("
 186    << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
 187
 188  SetErrorCode(GEOM_OK);
 189  return theObject;
 190}
 191
 192
 193//=============================================================================
 194/*!
 195 *  TranslateTwoPointsCopy
 196 */
 197//=============================================================================
 198Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateTwoPointsCopy
 199       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
 200{
 201  SetErrorCode(GEOM_KO);
 202
 203  if (theObject.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
 204
 205  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 206  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 207
 208  //Add a new Copy object
 209  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 210
 211  //Add a translate function
 212  Handle(GEOM_Function) aFunction =
 213    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_TWO_POINTS_COPY);
 214
 215  //Check if the function is set correctly
 216  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 217
 218  GEOMImpl_ITranslate aTI(aFunction);
 219  aTI.SetPoint1(thePoint1->GetLastFunction());
 220  aTI.SetPoint2(thePoint2->GetLastFunction());
 221  //aTI.SetShape(theObject->GetValue());
 222  aTI.SetOriginal(aLastFunction);
 223
 224  //Compute the translation
 225  try {
 226#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 227    OCC_CATCH_SIGNALS;
 228#endif
 229    if (!GetSolver()->ComputeFunction(aFunction)) {
 230      SetErrorCode("Translation driver failed");
 231      return NULL;
 232    }
 233  }
 234  catch (Standard_Failure) {
 235    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 236    SetErrorCode(aFail->GetMessageString());
 237    return NULL;
 238  }
 239
 240  //Make a Python command
 241  GEOM::TPythonDump(aFunction) << aCopy << " = TranslateTwoPointsCopy("
 242    << theObject << ", " << thePoint1 << ", " << thePoint2 << ")";
 243
 244  SetErrorCode(GEOM_OK);
 245  return aCopy;
 246}
 247
 248//=============================================================================
 249/*!
 250 *  TranslateDXDYDZCopy
 251 */
 252//=============================================================================
 253Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateDXDYDZCopy
 254	   (Handle(GEOM_Object) theObject, const GEOM_Parameter& theX, const GEOM_Parameter& theY,  const GEOM_Parameter& theZ)
 255{
 256  SetErrorCode(GEOM_KO);
 257
 258  if (theObject.IsNull()) return NULL;
 259
 260  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 261  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 262
 263  //Add a new Copy object
 264  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 265
 266  //Add a translate function
 267  Handle(GEOM_Function) aFunction =
 268    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_XYZ_COPY);
 269
 270  //Check if the function is set correctly
 271  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 272
 273  GEOMImpl_ITranslate aTI(aFunction);
 274  SETPARAM(aTI.SetDX,theX);
 275  SETPARAM(aTI.SetDY,theY);
 276  SETPARAM(aTI.SetDZ,theZ);
 277  aTI.SetOriginal(aLastFunction);
 278
 279  //Compute the translation
 280  try {
 281#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 282    OCC_CATCH_SIGNALS;
 283#endif
 284    if (!GetSolver()->ComputeFunction(aFunction)) {
 285      SetErrorCode("Translation driver failed");
 286      return NULL;
 287    }
 288  }
 289  catch (Standard_Failure) {
 290    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 291    SetErrorCode(aFail->GetMessageString());
 292    return NULL;
 293  }
 294
 295  //Make a Python command
 296  GEOM::TPythonDump(aFunction) << aCopy << " = TranslateDXDYDZCopy("
 297    << theObject << ", " << theX << ", " << theY << ", " << theZ << ")";
 298
 299  SetErrorCode(GEOM_OK);
 300  return aCopy;
 301}
 302
 303
 304//=============================================================================
 305/*!
 306 *  TranslateVector
 307 */
 308//=============================================================================
 309Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVector
 310       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
 311{
 312  SetErrorCode(GEOM_KO);
 313
 314  if (theObject.IsNull() || theVector.IsNull()) return NULL;
 315
 316  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
 317  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 318
 319  // Get last functions of the arguments
 320  Handle(GEOM_Function) aVF = theVector->GetLastFunction();
 321
 322  //Add a translate function
 323  aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR);
 324
 325  if (aFunction.IsNull()) return NULL;
 326
 327  //Check if the function is set correctly
 328  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 329
 330  GEOMImpl_ITranslate aTI (aFunction);
 331  aTI.SetVector(aVF);
 332  aTI.SetOriginal(aLastFunction);
 333
 334  //Compute the translation
 335  try {
 336#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 337    OCC_CATCH_SIGNALS;
 338#endif
 339    if (!GetSolver()->ComputeFunction(aFunction)) {
 340      SetErrorCode("Translation driver failed");
 341      return NULL;
 342    }
 343  }
 344  catch (Standard_Failure) {
 345    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 346    SetErrorCode(aFail->GetMessageString());
 347    return NULL;
 348  }
 349
 350  //Make a Python command
 351  GEOM::TPythonDump(aFunction) << "TranslateVector("
 352                               << theObject << ", " << theVector << ")";
 353
 354  SetErrorCode(GEOM_OK);
 355  return theObject;
 356}
 357
 358//=============================================================================
 359/*!
 360 *  TranslateVectorCopy
 361 */
 362//=============================================================================
 363Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorCopy
 364       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector)
 365{
 366  SetErrorCode(GEOM_KO);
 367
 368  if (theObject.IsNull() || theVector.IsNull()) return NULL;
 369
 370  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 371  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 372
 373  //Add a new Copy object
 374  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 375
 376  //Add a translate function
 377  Handle(GEOM_Function) aFunction =
 378    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_COPY);
 379
 380  //Check if the function is set correctly
 381  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 382
 383  GEOMImpl_ITranslate aTI(aFunction);
 384  aTI.SetVector(theVector->GetLastFunction());
 385//  aTI.SetShape(theObject->GetValue());
 386  aTI.SetOriginal(aLastFunction);
 387
 388  //Compute the translation
 389  try {
 390#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 391    OCC_CATCH_SIGNALS;
 392#endif
 393    if (!GetSolver()->ComputeFunction(aFunction)) {
 394      SetErrorCode("Translation driver failed");
 395      return NULL;
 396    }
 397  }
 398  catch (Standard_Failure) {
 399    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 400    SetErrorCode(aFail->GetMessageString());
 401    return NULL;
 402  }
 403
 404  //Make a Python command
 405  GEOM::TPythonDump(aFunction) << aCopy << " = TranslateVectorCopy("
 406                               << theObject << ", " << theVector << ")";
 407
 408  SetErrorCode(GEOM_OK);
 409  return aCopy;
 410}
 411
 412//=============================================================================
 413/*!
 414 *  TranslateVectorDistance
 415 */
 416//=============================================================================
 417Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateVectorDistance
 418	   (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, const GEOM_Parameter& theDistance, bool theCopy)
 419{
 420  SetErrorCode(GEOM_KO);
 421
 422  if (theObject.IsNull() || theVector.IsNull()) return NULL;
 423
 424  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 425  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 426
 427  Handle(GEOM_Object) aCopy;   //Add a new Copy object
 428  Handle(GEOM_Function) aFunction;
 429
 430  //Add a translate function
 431  if (theCopy) {
 432    aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 433    aFunction = aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
 434  }
 435  else {
 436    aFunction = theObject->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_VECTOR_DISTANCE);
 437  }
 438  if (aFunction.IsNull()) return NULL;
 439
 440  //Check if the function is set correctly
 441  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 442
 443  GEOMImpl_ITranslate aTI(aFunction);
 444  aTI.SetVector(theVector->GetLastFunction());
 445  SETPARAM(aTI.SetDistance,theDistance);
 446//  aTI.SetShape(theObject->GetValue());
 447  aTI.SetOriginal(aLastFunction);
 448
 449  //Compute the translation
 450  try {
 451#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 452    OCC_CATCH_SIGNALS;
 453#endif
 454    if (!GetSolver()->ComputeFunction(aFunction)) {
 455      SetErrorCode("Translation driver failed");
 456      return NULL;
 457    }
 458  }
 459  catch (Standard_Failure) {
 460    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 461    SetErrorCode(aFail->GetMessageString());
 462    return NULL;
 463  }
 464
 465  //Make a Python command
 466  if (theCopy) {
 467	GEOM::TPythonDump(aFunction) << aCopy << " = MakeTranslationVectorDistance("
 468				 << theObject << ", " << theVector << ", " << theDistance << ")";
 469	SetErrorCode(GEOM_OK);
 470    return aCopy;
 471  }
 472
 473  GEOM::TPythonDump(aFunction) << "TranslateVectorDistance("
 474			       << theObject << ", " << theVector << ", " << theDistance << ", " << (int)theCopy << ")";
 475  SetErrorCode(GEOM_OK);
 476  return theObject;
 477}
 478
 479//=============================================================================
 480/*!
 481 *  Translate1D
 482 */
 483//=============================================================================
 484Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate1D
 485       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector,
 486		const GEOM_Parameter& theStep, const GEOM_Parameter& theNbTimes)
 487{
 488  SetErrorCode(GEOM_KO);
 489
 490  if (theObject.IsNull() || theVector.IsNull()) return NULL;
 491
 492  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 493  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 494
 495  //Add a new Copy object
 496  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 497
 498  //Add a translate function
 499  Handle(GEOM_Function) aFunction =
 500    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_1D);
 501
 502  //Check if the function is set correctly
 503  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 504
 505  GEOMImpl_ITranslate aTI(aFunction);
 506  aTI.SetVector(theVector->GetLastFunction());
 507  aTI.SetOriginal(aLastFunction);
 508  SETPARAM(aTI.SetStep1,theStep);
 509  SETPARAM(aTI.SetNbIter1,theNbTimes);
 510
 511  //Compute the translation
 512  try {
 513#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 514    OCC_CATCH_SIGNALS;
 515#endif
 516    if (!GetSolver()->ComputeFunction(aFunction)) {
 517      SetErrorCode("Translation driver failed");
 518      return NULL;
 519    }
 520  }
 521  catch (Standard_Failure) {
 522    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 523    SetErrorCode(aFail->GetMessageString());
 524    return NULL;
 525  }
 526
 527  //Make a Python command
 528  GEOM::TPythonDump(aFunction) << aCopy << " = Translate1D("
 529    << theObject << ", " << theVector << ", " << theStep << ", " << theNbTimes << ")";
 530
 531  SetErrorCode(GEOM_OK);
 532  return aCopy;
 533}
 534
 535//=============================================================================
 536/*!
 537 *  Translate2D
 538 */
 539//=============================================================================
 540Handle(GEOM_Object) GEOMImpl_ITransformOperations::Translate2D (Handle(GEOM_Object) theObject,
 541								Handle(GEOM_Object) theVector,
 542								const GEOM_Parameter& theStep1,
 543								const GEOM_Parameter& theNbTimes1,
 544								Handle(GEOM_Object) theVector2,
 545								const GEOM_Parameter& theStep2,
 546								const GEOM_Parameter& theNbTimes2)
 547{
 548  SetErrorCode(GEOM_KO);
 549
 550  if (theObject.IsNull() || theVector.IsNull() || theVector2.IsNull()) return NULL;
 551
 552  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 553  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 554
 555  //Add a new Copy object
 556  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 557
 558  //Add a translate function
 559  Handle(GEOM_Function) aFunction =
 560    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_2D);
 561
 562  //Check if the function is set correctly
 563  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 564
 565  GEOMImpl_ITranslate aTI(aFunction);
 566  aTI.SetVector(theVector->GetLastFunction());
 567  aTI.SetVector2(theVector2->GetLastFunction());
 568  aTI.SetOriginal(aLastFunction);
 569  SETPARAM(aTI.SetStep1,theStep1);
 570  SETPARAM(aTI.SetNbIter1,theNbTimes1);
 571  SETPARAM(aTI.SetStep2,theStep2);
 572  SETPARAM(aTI.SetNbIter2,theNbTimes2);
 573
 574  //Compute the translation
 575  try {
 576#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 577    OCC_CATCH_SIGNALS;
 578#endif
 579    if (!GetSolver()->ComputeFunction(aFunction)) {
 580      SetErrorCode("Translation driver failed");
 581      return NULL;
 582    }
 583  }
 584  catch (Standard_Failure) {
 585    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 586    SetErrorCode(aFail->GetMessageString());
 587    return NULL;
 588  }
 589
 590  //Make a Python command
 591  GEOM::TPythonDump(aFunction) << aCopy << " = Translate2D("
 592    << theObject << ", " << theVector  << ", " << theStep1 << ", " << theNbTimes1
 593      << ", " << theVector2 << ", " << theStep2 << ", " << theNbTimes2 << ")";
 594
 595  SetErrorCode(GEOM_OK);
 596  return aCopy;
 597}
 598
 599//=============================================================================
 600/*!
 601 *  TranslateAlongRail
 602 */
 603//=============================================================================
 604Handle(GEOM_Object) GEOMImpl_ITransformOperations::TranslateAlongRail( Handle(GEOM_Object) theObject,
 605                    Handle(GEOM_Object) theRail, const GEOM_Parameter& theStep,
 606                    const GEOM_Parameter& theNbTimes, const GEOM_Parameter& theType)
 607{
 608  SetErrorCode(GEOM_KO);
 609
 610  if (theObject.IsNull() || theRail.IsNull()) return NULL;
 611
 612  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 613  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be moved
 614
 615  //Add a new Copy object
 616  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 617
 618  //Add a translate function
 619  Handle(GEOM_Function) aFunction =
 620    aCopy->AddFunction(GEOMImpl_TranslateDriver::GetID(), TRANSLATE_ALONG_RAIL);
 621
 622  //Check if the function is set correctly
 623  if (aFunction->GetDriverGUID() != GEOMImpl_TranslateDriver::GetID()) return NULL;
 624
 625  GEOMImpl_ITranslate aTI(aFunction);
 626  aTI.SetRailShape(theRail->GetLastFunction());
 627  aTI.SetOriginal(aLastFunction);
 628
 629  SETPARAM(aTI.SetStep1,theStep);
 630  SETPARAM(aTI.SetNbIter1,theNbTimes);
 631  SETPARAM(aTI.SetNbIter2,theType);     //0=No rotation, 1=Plane based rotation, 2=Freeform rotation
 632
 633  //Compute the translation
 634  try {
 635#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 636    OCC_CATCH_SIGNALS;
 637#endif
 638    if (!GetSolver()->ComputeFunction(aFunction)) {
 639      SetErrorCode("Translation driver failed");
 640      return NULL;
 641    }
 642  }
 643  catch (Standard_Failure) {
 644    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 645    SetErrorCode(aFail->GetMessageString());
 646    return NULL;
 647  }
 648
 649  //Make a Python command
 650  GEOM::TPythonDump(aFunction) << aCopy << " = TranslateAlongRail("
 651    << theObject << ", " << theRail  << ", " << theStep
 652    << ", " << theNbTimes << ", " << theType << ")";
 653
 654  SetErrorCode(GEOM_OK);
 655  return aCopy;
 656}
 657
 658//=============================================================================
 659/*!
 660 *  MirrorPlane
 661 */
 662//=============================================================================
 663Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlane
 664       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
 665{
 666  SetErrorCode(GEOM_KO);
 667
 668  if (theObject.IsNull() || thePlane.IsNull()) return NULL;
 669
 670  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 671  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
 672
 673  // Get last functions of the arguments
 674  Handle(GEOM_Function) aPF = thePlane->GetLastFunction();
 675
 676  //Add a mirror function
 677  Handle(GEOM_Function) aFunction =
 678    theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE);
 679  if (aFunction.IsNull()) return NULL;
 680
 681  //Check if the function is set correctly
 682  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 683
 684  GEOMImpl_IMirror aTI (aFunction);
 685  aTI.SetPlane(aPF);
 686  aTI.SetOriginal(aLastFunction);
 687
 688  //Compute the mirror
 689  try {
 690#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 691    OCC_CATCH_SIGNALS;
 692#endif
 693    if (!GetSolver()->ComputeFunction(aFunction)) {
 694      SetErrorCode("Mirror driver failed");
 695      return NULL;
 696    }
 697  }
 698  catch (Standard_Failure) {
 699    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 700    SetErrorCode(aFail->GetMessageString());
 701    return NULL;
 702  }
 703
 704  //Make a Python command
 705  GEOM::TPythonDump(aFunction) << "MirrorPlane("
 706                               << theObject << ", " << thePlane << ")";
 707
 708  SetErrorCode(GEOM_OK);
 709  return theObject;
 710}
 711
 712//=============================================================================
 713/*!
 714 *  MirrorPlaneCopy
 715 */
 716//=============================================================================
 717Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPlaneCopy
 718       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePlane)
 719{
 720  SetErrorCode(GEOM_KO);
 721
 722  if (theObject.IsNull() || thePlane.IsNull()) return NULL;
 723
 724  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 725  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
 726
 727  //Add a new Copy object
 728  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 729
 730  //Add a mirror function
 731  Handle(GEOM_Function) aFunction =
 732    aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_PLANE_COPY);
 733
 734  //Check if the function is set correctly
 735  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 736
 737  GEOMImpl_IMirror aTI (aFunction);
 738  aTI.SetPlane(thePlane->GetLastFunction());
 739  aTI.SetOriginal(aLastFunction);
 740
 741  //Compute the mirror
 742  try {
 743#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 744    OCC_CATCH_SIGNALS;
 745#endif
 746    if (!GetSolver()->ComputeFunction(aFunction)) {
 747      SetErrorCode("Mirror driver failed");
 748      return NULL;
 749    }
 750  }
 751  catch (Standard_Failure) {
 752    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 753    SetErrorCode(aFail->GetMessageString());
 754    return NULL;
 755  }
 756
 757  //Make a Python command
 758  GEOM::TPythonDump(aFunction) << aCopy << " = MirrorPlaneCopy("
 759                               << theObject << ", " << thePlane << ")";
 760
 761  SetErrorCode(GEOM_OK);
 762  return aCopy;
 763}
 764
 765//=============================================================================
 766/*!
 767 *  MirrorPoint
 768 */
 769//=============================================================================
 770Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPoint
 771       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
 772{
 773  SetErrorCode(GEOM_KO);
 774
 775  if (theObject.IsNull() || thePoint.IsNull()) return NULL;
 776
 777  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 778  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
 779
 780  // Get last functions of the arguments
 781  Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
 782
 783  //Add a mirror function
 784  Handle(GEOM_Function) aFunction =
 785    theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT);
 786  if (aFunction.IsNull()) return NULL;
 787
 788  //Check if the function is set correctly
 789  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 790
 791  GEOMImpl_IMirror aTI (aFunction);
 792  aTI.SetPoint(aPF);
 793  aTI.SetOriginal(aLastFunction);
 794
 795  //Compute the mirror
 796  try {
 797#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 798    OCC_CATCH_SIGNALS;
 799#endif
 800    if (!GetSolver()->ComputeFunction(aFunction)) {
 801      SetErrorCode("Mirror driver failed");
 802      return NULL;
 803    }
 804  }
 805  catch (Standard_Failure) {
 806    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 807    SetErrorCode(aFail->GetMessageString());
 808    return NULL;
 809  }
 810
 811  //Make a Python command
 812  GEOM::TPythonDump(aFunction) << "MirrorPoint("
 813                               << theObject << ", " << thePoint << ")";
 814
 815  SetErrorCode(GEOM_OK);
 816  return NULL;
 817}
 818
 819//=============================================================================
 820/*!
 821 *  MirrorPointCopy
 822 */
 823//=============================================================================
 824Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorPointCopy
 825       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint)
 826{
 827  SetErrorCode(GEOM_KO);
 828
 829  if (theObject.IsNull() || thePoint.IsNull()) return NULL;
 830
 831  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 832  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
 833
 834  //Add a new Copy object
 835  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 836
 837  //Add a mirror function
 838  Handle(GEOM_Function) aFunction =
 839    aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_POINT_COPY);
 840
 841  //Check if the function is set correctly
 842  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 843
 844  GEOMImpl_IMirror aTI (aFunction);
 845  aTI.SetPoint(thePoint->GetLastFunction());
 846  aTI.SetOriginal(aLastFunction);
 847
 848  //Compute the mirror
 849  try {
 850#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 851    OCC_CATCH_SIGNALS;
 852#endif
 853    if (!GetSolver()->ComputeFunction(aFunction)) {
 854      SetErrorCode("Mirror driver failed");
 855      return NULL;
 856    }
 857  }
 858  catch (Standard_Failure) {
 859    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 860    SetErrorCode(aFail->GetMessageString());
 861    return NULL;
 862  }
 863
 864  //Make a Python command
 865  GEOM::TPythonDump(aFunction) << aCopy << " = MirrorPointCopy("
 866                               << theObject << ", " << thePoint << ")";
 867
 868  SetErrorCode(GEOM_OK);
 869  return aCopy;
 870}
 871
 872//=============================================================================
 873/*!
 874 *  MirrorAxis
 875 */
 876//=============================================================================
 877Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxis
 878       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
 879{
 880  SetErrorCode(GEOM_KO);
 881
 882  if (theObject.IsNull() || theAxis.IsNull()) return NULL;
 883
 884  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 885  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be mirrored
 886
 887  // Get last functions of the arguments
 888  Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
 889
 890  //Add a mirror function
 891  Handle(GEOM_Function) aFunction =
 892    theObject->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS);
 893  if (aFunction.IsNull()) return NULL;
 894
 895  //Check if the function is set correctly
 896  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 897
 898  GEOMImpl_IMirror aTI (aFunction);
 899  aTI.SetAxis(anAF);
 900  aTI.SetOriginal(aLastFunction);
 901
 902  //Compute the mirror
 903  try {
 904#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 905    OCC_CATCH_SIGNALS;
 906#endif
 907    if (!GetSolver()->ComputeFunction(aFunction)) {
 908      SetErrorCode("Mirror driver failed");
 909      return NULL;
 910    }
 911  }
 912  catch (Standard_Failure) {
 913    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 914    SetErrorCode(aFail->GetMessageString());
 915    return NULL;
 916  }
 917
 918  //Make a Python command
 919  GEOM::TPythonDump(aFunction) << "MirrorAxis("
 920                               << theObject << ", " << theAxis << ")";
 921
 922  SetErrorCode(GEOM_OK);
 923  return NULL;
 924}
 925
 926//=============================================================================
 927/*!
 928 *  MirrorAxisCopy
 929 */
 930//=============================================================================
 931Handle(GEOM_Object) GEOMImpl_ITransformOperations::MirrorAxisCopy
 932       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis)
 933{
 934  SetErrorCode(GEOM_KO);
 935
 936  if (theObject.IsNull() || theAxis.IsNull()) return NULL;
 937
 938  Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
 939  if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be mirrored
 940
 941  //Add a new Copy object
 942  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
 943
 944  //Add a mirror function
 945  Handle(GEOM_Function) aFunction =
 946    aCopy->AddFunction(GEOMImpl_MirrorDriver::GetID(), MIRROR_AXIS_COPY);
 947
 948  //Check if the function is set correctly
 949  if (aFunction->GetDriverGUID() != GEOMImpl_MirrorDriver::GetID()) return NULL;
 950
 951  GEOMImpl_IMirror aTI (aFunction);
 952  aTI.SetAxis(theAxis->GetLastFunction());
 953  aTI.SetOriginal(aLastFunction);
 954
 955  //Compute the mirror
 956  try {
 957#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 958    OCC_CATCH_SIGNALS;
 959#endif
 960    if (!GetSolver()->ComputeFunction(aFunction)) {
 961      SetErrorCode("Mirror driver failed");
 962      return NULL;
 963    }
 964  }
 965  catch (Standard_Failure) {
 966    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 967    SetErrorCode(aFail->GetMessageString());
 968    return NULL;
 969  }
 970
 971  //Make a Python command
 972  GEOM::TPythonDump(aFunction) << aCopy << " = MirrorAxisCopy("
 973                               << theObject << ", " << theAxis << ")";
 974
 975  SetErrorCode(GEOM_OK);
 976  return aCopy;
 977}
 978
 979
 980//=============================================================================
 981/*!
 982 *  OffsetShape
 983 */
 984//=============================================================================
 985Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShape
 986							  (Handle(GEOM_Object) theObject, const GEOM_Parameter& theOffset, const GEOM_Parameter& theHeightOffset, bool isPlanar)
 987{
 988  SetErrorCode(GEOM_KO);
 989
 990  if (theObject.IsNull()) return NULL;
 991
 992  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
 993  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
 994
 995  //Add a new Offset function
 996  Handle(GEOM_Function) aFunction;
 997  if (isPlanar)
 998	aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_PLANAR);
 999  else
1000	aFunction = theObject->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1001
1002  if (aFunction.IsNull()) return NULL;
1003
1004  //Check if the function is set correctly
1005  if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1006
1007  GEOMImpl_IOffset aTI (aFunction);
1008  aTI.SetShape(anOriginal);
1009  SETPARAM(aTI.SetValue,theOffset);
1010  SETPARAM(aTI.SetAltValue,theHeightOffset);
1011
1012  //Compute the offset
1013  try {
1014#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1015    OCC_CATCH_SIGNALS;
1016#endif
1017    if (!GetSolver()->ComputeFunction(aFunction)) {
1018      SetErrorCode("Offset driver failed");
1019      return NULL;
1020    }
1021  }
1022  catch (Standard_Failure) {
1023    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1024    SetErrorCode(aFail->GetMessageString());
1025    return NULL;
1026  }
1027
1028  //Make a Python command
1029  GEOM::TPythonDump(aFunction) << "OffsetShape("
1030							   << theObject << ", " << theOffset << ", " << theHeightOffset << ", Planar: " << (int)isPlanar << ")";
1031
1032  SetErrorCode(GEOM_OK);
1033  return theObject;
1034}
1035
1036//=============================================================================
1037/*!
1038 *  OffsetShapeCopy
1039 */
1040//=============================================================================
1041Handle(GEOM_Object) GEOMImpl_ITransformOperations::OffsetShapeCopy
1042							  (Handle(GEOM_Object) theObject, const GEOM_Parameter& theOffset, const GEOM_Parameter& theHeightOffset, bool isPlanar)
1043{
1044  SetErrorCode(GEOM_KO);
1045
1046  if (theObject.IsNull()) return NULL;
1047
1048  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1049  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be offset
1050
1051  //Add a new Copy object
1052  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1053
1054  //Add a new Offset function
1055  Handle(GEOM_Function) aFunction;
1056  if (isPlanar)
1057	aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_PLANAR);
1058  else
1059	aFunction = aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE);
1060
1061  //Add a new Offset function
1062  //Handle(GEOM_Function) aFunction =
1063  //  aCopy->AddFunction(GEOMImpl_OffsetDriver::GetID(), OFFSET_SHAPE_COPY);
1064  
1065  if (aFunction.IsNull()) return NULL;
1066
1067  //Check if the function is set correctly
1068  if (aFunction->GetDriverGUID() != GEOMImpl_OffsetDriver::GetID()) return NULL;
1069
1070  GEOMImpl_IOffset aTI (aFunction);
1071  aTI.SetShape(anOriginal);
1072  SETPARAM(aTI.SetValue,theOffset);
1073  SETPARAM(aTI.SetAltValue,theHeightOffset);
1074
1075  //Compute the offset
1076  try {
1077#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1078    OCC_CATCH_SIGNALS;
1079#endif
1080    if (!GetSolver()->ComputeFunction(aFunction)) {
1081      SetErrorCode("Offset driver failed");
1082      return NULL;
1083	}
1084  }
1085  catch (Standard_Failure) {
1086    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1087    SetErrorCode(aFail->GetMessageString());
1088    return NULL;
1089  }
1090
1091  //Make a Python command
1092  GEOM::TPythonDump(aFunction) << aCopy << " = OffsetShapeCopy("
1093							   << theObject << ", " << theOffset << ", " << theHeightOffset << ", Planar: " << (int)isPlanar << ")";
1094
1095  SetErrorCode(GEOM_OK);
1096  return aCopy;
1097}
1098
1099
1100//=============================================================================
1101/*!
1102 *  ScaleShape
1103 */
1104//=============================================================================
1105Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShape
1106	   (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, const GEOM_Parameter& theFactor)
1107{
1108	SetErrorCode(GEOM_KO);
1109
1110  if (theObject.IsNull()) return NULL;
1111
1112  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1113  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1114
1115  //Add a scale function
1116  Handle(GEOM_Function) aFunction =
1117    theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE);
1118  if (aFunction.IsNull()) return NULL;
1119
1120  //Check if the function is set correctly
1121  if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1122
1123  // Set arguments
1124  GEOMImpl_IScale aTI (aFunction);
1125  aTI.SetShape(anOriginal);
1126  SETPARAM(aTI.SetFactor,theFactor);
1127
1128  // Set point argument
1129  if (!thePoint.IsNull()) {
1130    Handle(GEOM_Function) aPF = thePoint->GetLastFunction();
1131    aTI.SetPoint(aPF);
1132  }
1133
1134  //Compute the scale
1135  try {
1136#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1137    OCC_CATCH_SIGNALS;
1138#endif
1139    if (!GetSolver()->ComputeFunction(aFunction)) {
1140      SetErrorCode("Scale driver failed");
1141      return NULL;
1142    }
1143  }
1144  catch (Standard_Failure) {
1145    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1146    SetErrorCode(aFail->GetMessageString());
1147    return NULL;
1148  }
1149
1150  //Make a Python command
1151  GEOM::TPythonDump(aFunction) << "ScaleShape("
1152	<< theObject << ", " << thePoint << ", " << theFactor << ")";
1153
1154  SetErrorCode(GEOM_OK);
1155  return theObject;
1156}
1157
1158//=============================================================================
1159/*!
1160 *  ScaleShapeCopy
1161 */
1162//=============================================================================
1163Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeCopy
1164	   (Handle(GEOM_Object) theObject, Handle(GEOM_Object) thePoint, const GEOM_Parameter& theFactor)
1165{
1166  SetErrorCode(GEOM_KO);
1167
1168  if (theObject.IsNull() || thePoint.IsNull()) return NULL;
1169
1170  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1171  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1172
1173  //Add a new Copy object
1174  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1175
1176  //Add a scale function
1177  Handle(GEOM_Function) aFunction =
1178    aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_COPY);
1179  if (aFunction.IsNull()) return NULL;
1180
1181  //Check if the function is set correctly
1182  if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1183
1184  GEOMImpl_IScale aTI (aFunction);
1185  aTI.SetShape(anOriginal);
1186  aTI.SetPoint(thePoint->GetLastFunction());
1187  SETPARAM(aTI.SetFactor,theFactor);
1188
1189  //Compute the scale
1190  try {
1191#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1192    OCC_CATCH_SIGNALS;
1193#endif
1194    if (!GetSolver()->ComputeFunction(aFunction)) {
1195      SetErrorCode("Scale driver failed");
1196      return NULL;
1197    }
1198  }
1199  catch (Standard_Failure) {
1200    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1201    SetErrorCode(aFail->GetMessageString());
1202    return NULL;
1203  }
1204
1205  //Make a Python command
1206  GEOM::TPythonDump(aFunction) << aCopy << " = ScaleShapeCopy("
1207    << theObject << ", " << thePoint << ", " << theFactor << ")";
1208
1209  SetErrorCode(GEOM_OK);
1210  return aCopy;
1211}
1212
1213//=============================================================================
1214/*!
1215 *  ScaleShapeAffine
1216 */
1217//=============================================================================
1218Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAffine
1219	   (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, const GEOM_Parameter& theFactor)
1220{
1221  SetErrorCode(GEOM_KO);
1222
1223  if (theObject.IsNull() || theVector.IsNull()) return NULL;
1224
1225  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1226  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1227
1228  // Get last functions of the arguments
1229  Handle(GEOM_Function) aVF = theVector->GetLastFunction();
1230
1231  //Add a scale function
1232  Handle(GEOM_Function) aFunction =
1233	theObject->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AFFINE);
1234  if (aFunction.IsNull()) return NULL;
1235
1236  //Check if the function is set correctly
1237  if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1238
1239  GEOMImpl_IScale aTI (aFunction);
1240  aTI.SetShape(anOriginal);
1241  aTI.SetVector(aVF);
1242  SETPARAM(aTI.SetFactor,theFactor);
1243
1244  //Compute the scale
1245  try {
1246#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1247    OCC_CATCH_SIGNALS;
1248#endif
1249    if (!GetSolver()->ComputeFunction(aFunction)) {
1250      SetErrorCode("Scale driver failed");
1251      return NULL;
1252    }
1253  }
1254  catch (Standard_Failure) {
1255    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1256    SetErrorCode(aFail->GetMessageString());
1257    return NULL;
1258  }
1259
1260  //Make a Python command
1261  GEOM::TPythonDump(aFunction) << "ScaleShapeAffine("
1262	<< theObject << ", " << theVector << ", " << theFactor << ")";
1263
1264  SetErrorCode(GEOM_OK);
1265  return theObject;
1266}
1267
1268//=============================================================================
1269/*!
1270 *  ScaleShapeAffineCopy
1271 */
1272//=============================================================================
1273Handle(GEOM_Object) GEOMImpl_ITransformOperations::ScaleShapeAffineCopy
1274	   (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theVector, const GEOM_Parameter& theFactor)
1275{
1276  SetErrorCode(GEOM_KO);
1277
1278  if (theObject.IsNull() || theVector.IsNull()) return NULL;
1279
1280  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1281  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be scaled
1282
1283  //Add a new Copy object
1284  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1285
1286  //Add a scale function
1287  Handle(GEOM_Function) aFunction =
1288	aCopy->AddFunction(GEOMImpl_ScaleDriver::GetID(), SCALE_SHAPE_AFFINE_COPY);
1289  if (aFunction.IsNull()) return NULL;
1290
1291  //Check if the function is set correctly
1292  if (aFunction->GetDriverGUID() != GEOMImpl_ScaleDriver::GetID()) return NULL;
1293
1294  GEOMImpl_IScale aTI (aFunction);
1295  aTI.SetShape(anOriginal);
1296  aTI.SetVector(theVector->GetLastFunction());
1297  SETPARAM(aTI.SetFactor,theFactor);
1298
1299  //Compute the scale
1300  try {
1301#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1302    OCC_CATCH_SIGNALS;
1303#endif
1304    if (!GetSolver()->ComputeFunction(aFunction)) {
1305      SetErrorCode("Scale driver failed");
1306      return NULL;
1307    }
1308  }
1309  catch (Standard_Failure) {
1310    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1311    SetErrorCode(aFail->GetMessageString());
1312    return NULL;
1313  }
1314
1315  //Make a Python command
1316  GEOM::TPythonDump(aFunction) << aCopy << " = ScaleShapeAffineCopy("
1317	<< theObject << ", " << theVector << ", " << theFactor << ")";
1318
1319  SetErrorCode(GEOM_OK);
1320  return aCopy;
1321}
1322
1323//=============================================================================
1324/*!
1325 *  PositionShape
1326 */
1327//=============================================================================
1328Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShape
1329        (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1330{
1331  SetErrorCode(GEOM_KO);
1332
1333  if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1334
1335  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1336  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1337
1338  //Add a Position function
1339  Standard_Integer aType = POSITION_SHAPE;
1340  if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL;
1341
1342  Handle(GEOM_Function) aFunction =
1343    theObject->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1344  if (aFunction.IsNull()) return NULL;
1345
1346  //Check if the function is set correctly
1347  if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1348
1349  //Set operation arguments
1350  GEOMImpl_IPosition aTI (aFunction);
1351  aTI.SetShape(anOriginal);
1352  aTI.SetEndLCS(theEndLCS->GetLastFunction());
1353  if (!theStartLCS.IsNull())
1354    aTI.SetStartLCS(theStartLCS->GetLastFunction());
1355
1356  //Compute the Position
1357  try {
1358#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1359    OCC_CATCH_SIGNALS;
1360#endif
1361    if (!GetSolver()->ComputeFunction(aFunction)) {
1362      SetErrorCode("Position driver failed");
1363      return NULL;
1364    }
1365  }
1366  catch (Standard_Failure) {
1367    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1368    SetErrorCode(aFail->GetMessageString());
1369    return NULL;
1370  }
1371
1372  //Make a Python command
1373  GEOM::TPythonDump(aFunction) << "PositionShape("
1374    << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1375
1376  SetErrorCode(GEOM_OK);
1377  return theObject;
1378}
1379
1380//=============================================================================
1381/*!
1382 *  PositionShapeCopy
1383 */
1384//=============================================================================
1385Handle(GEOM_Object) GEOMImpl_ITransformOperations::PositionShapeCopy
1386       (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theStartLCS, Handle(GEOM_Object) theEndLCS)
1387{
1388  SetErrorCode(GEOM_KO);
1389
1390  if (theObject.IsNull() || theEndLCS.IsNull()) return NULL;
1391
1392  Handle(GEOM_Function) anOriginal = theObject->GetLastFunction();
1393  if (anOriginal.IsNull()) return NULL; //There is no function which creates an object to be set in position
1394
1395  //Add a new Copy object
1396  Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), theObject->GetType());
1397
1398  //Add a position function
1399  Standard_Integer aType = POSITION_SHAPE_COPY;
1400  if (theStartLCS.IsNull()) aType = POSITION_SHAPE_FROM_GLOBAL_COPY;
1401
1402  Handle(GEOM_Function) aFunction =
1403    aCopy->AddFunction(GEOMImpl_PositionDriver::GetID(), aType);
1404  if (aFunction.IsNull()) return NULL;
1405
1406  //Check if the function is set correctly
1407  if (aFunction->GetDriverGUID() != GEOMImpl_PositionDriver::GetID()) return NULL;
1408
1409  GEOMImpl_IPosition aTI (aFunction);
1410  aTI.SetShape(anOriginal);
1411  aTI.SetEndLCS(theEndLCS->GetLastFunction());
1412  if (!theStartLCS.IsNull())
1413    aTI.SetStartLCS(theStartLCS->GetLastFunction());
1414
1415  //Compute the position
1416  try {
1417#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1418    OCC_CATCH_SIGNALS;
1419#endif
1420    if (!GetSolver()->ComputeFunction(aFunction)) {
1421      SetErrorCode("Position driver failed");
1422      return NULL;
1423    }
1424  }
1425  catch (Standard_Failure) {
1426    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1427    SetErrorCode(aFail->GetMessageString());
1428    return NULL;
1429  }
1430
1431  //Make a Python command
1432  GEOM::TPythonDump(aFunction) << aCopy << " = PositionShapeCopy("
1433    << theObject << ", " << theStartLCS << ", " << theEndLCS << ")";
1434
1435  SetErrorCode(GEOM_OK);
1436  return aCopy;
1437}
1438
1439//=============================================================================
1440/*!
1441 *  Rotate
1442 */
1443//=============================================================================
1444Handle(GEOM_Object) GEOMImpl_ITransformOperations::Rotate (Handle(GEOM_Object) theObject,
1445                                                           Handle(GEOM_Object) theAxis,
1446														   const GEOM_Parameter& theAngle)
1447{
1448  SetErrorCode(GEOM_KO);
1449
1450  if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1451
1452  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1453  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1454
1455  // Get last functions of the arguments
1456  Handle(GEOM_Function) anAF = theAxis->GetLastFunction();
1457
1458  //Add a rotate function
1459  aFunction = theObject->AddFunction(GEOMImpl_RotateDriver::GetID(), ROTATE);
1460
1461  if (aFunction.IsNull()) return NULL;
1462
1463  //Check if the function is set correctly
1464  if (aFunction->GetDriverGUID() != GEOMImpl_RotateDriver::GetID()) return NULL;
1465
1466  GEOMImpl_IRotate aRI(aFunction);
1467  aRI.SetAxis(anAF);
1468  aRI.SetOriginal(aLastFunction);
1469  SETPARAM(aRI.SetAngle,theAngle);
1470
1471  //Compute the translation
1472  try {
1473#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1474    OCC_CATCH_SIGNALS;
1475#endif
1476    if (!GetSolver()->ComputeFunction(aFunction)) {
1477      SetErrorCode("Rotate driver failed");
1478      return NULL;
1479    }
1480  }
1481  catch (Standard_Failure) {
1482    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1483    SetErrorCode(aFail->GetMessageString());
1484    return NULL;
1485  }
1486
1487  //Make a Python command
1488  GEOM::TPythonDump(aFunction) << "Rotate(" << theObject
1489    << ", " << theAxis << ", " << theAngle << ")";
1490
1491  SetErrorCode(GEOM_OK);
1492  return theObject;
1493}
1494
1495//=============================================================================
1496/*!
1497 *  Rotate
1498 */
1499//=============================================================================
1500Handle(GEOM_Object) GEOMImpl_ITransformOperations::RotateCopy (Handle(GEOM_Object) theObject, Handle(GEOM_Object) theAxis, const GEOM_Parameter& theAngle)
1501{
1502  SetErrorCode(GEOM_KO);
1503
1504  if (theObject.IsNull() || theAxis.IsNull()) return NULL;
1505
1506  Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
1507  if (aLastFunction.IsNull()) return NULL;  //There is no function which creates an object to be rotated
1508
1509  //Add a new Copy object
1510  Handle(GEOM_Object) aCopy = 

Large files files are truncated, but you can click here to view the full file