PageRenderTime 118ms CodeModel.GetById 14ms app.highlight 95ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://pythonocc.googlecode.com/
C++ | 1628 lines | 1085 code | 280 blank | 263 comment | 193 complexity | 7610f87fbaa6bfe843883d82b7126859 MD5 | raw 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_ILocalOperations.hxx>
  25
  26#include <GEOM_Function.hxx>
  27#include <GEOM_PythonDump.hxx>
  28
  29#include <GEOMImpl_Types.hxx>
  30
  31#include <GEOMImpl_FilletDriver.hxx>
  32#include <GEOMImpl_ChamferDriver.hxx>
  33#include <GEOMImpl_ThickSolidDriver.hxx>
  34#include <GEOMImpl_VariableFilletDriver.hxx>
  35#include <GEOMImpl_DraftDriver.hxx>
  36
  37#include <GEOMImpl_IFillet.hxx>
  38#include <GEOMImpl_IVariableFillet.hxx>
  39#include <GEOMImpl_IChamfer.hxx>
  40#include <GEOMImpl_IThickSolid.hxx>
  41#include <GEOMImpl_IDraft.hxx>
  42
  43#include <GEOMImpl_IArchimede.hxx>
  44#include <GEOMImpl_ArchimedeDriver.hxx>
  45
  46#include <GEOMImpl_Gen.hxx>
  47#include <GEOMImpl_IShapesOperations.hxx>
  48
  49#define SETPARAM(aFUNC,aVAL)  \
  50  if (aVAL.IsString())         \
  51	aFUNC( aVAL.GetString() ); \
  52  else                         \
  53	aFUNC( aVAL.GetDouble() );
  54
  55#include <TFunction_DriverTable.hxx>
  56#include <TFunction_Driver.hxx>
  57#include <TFunction_Logbook.hxx>
  58#include <TDF_Tool.hxx>
  59
  60#include <TopExp.hxx>
  61#include <TopoDS_TShape.hxx>
  62#include <TopTools_IndexedMapOfShape.hxx>
  63#include <TColStd_HArray1OfReal.hxx>
  64
  65#include <Standard_Failure.hxx>
  66#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
  67
  68#define LOCAL_OPS_CREATE_NEW_OBJECT
  69
  70
  71//=============================================================================
  72/*!
  73 *   constructor:
  74 */
  75//=============================================================================
  76GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations (GEOM_Engine* theEngine, int theDocID)
  77: GEOM_IOperations(theEngine, theDocID)
  78{
  79  //MESSAGE("GEOMImpl_ILocalOperations::GEOMImpl_ILocalOperations");
  80}
  81
  82//=============================================================================
  83/*!
  84 *  destructor
  85 */
  86//=============================================================================
  87GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations()
  88{
  89  //MESSAGE("GEOMImpl_ILocalOperations::~GEOMImpl_ILocalOperations");
  90}
  91
  92
  93//=============================================================================
  94/*!
  95 *  MakeFilletAll
  96 */
  97//=============================================================================
  98Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletAll
  99									(Handle(GEOM_Object) theShape, const GEOM_Parameter& theR)
 100{
 101  SetErrorCode(GEOM_KO);
 102
 103 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 104  //Add a new Fillet object
 105  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 106 #else
 107  Handle(GEOM_Object) aFillet = theShape;
 108 #endif
 109
 110  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 111  if (aRefShape.IsNull()) return NULL;
 112
 113  //Add a new Fillet function
 114  Handle(GEOM_Function) aFunction =
 115    aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_ALL);
 116  if (aFunction.IsNull()) return NULL;
 117
 118  //Check if the function is set correctly
 119  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 120
 121  GEOMImpl_IFillet aCI (aFunction);
 122
 123  aCI.SetShape(aRefShape);
 124  SETPARAM(aCI.SetR,theR);
 125
 126  //Compute the Fillet value
 127  try {
 128#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 129    OCC_CATCH_SIGNALS;
 130#endif
 131    if (!GetSolver()->ComputeFunction(aFunction)) {
 132      SetErrorCode("Fillet driver failed");
 133      return NULL;
 134    }
 135  }
 136  catch (Standard_Failure) {
 137    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 138    SetErrorCode(aFail->GetMessageString());
 139    return NULL;
 140  }
 141
 142  //Make a Python command
 143  GEOM::TPythonDump(aFunction) << aFillet << " = MakeFilletAll("
 144                               << theShape << ", " << theR << ")";
 145
 146  SetErrorCode(GEOM_OK);
 147  return aFillet;
 148}
 149
 150//=============================================================================
 151/*!
 152 *  MakeFilletEdges
 153 */
 154//=============================================================================
 155Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdges
 156	   (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR, std::list<int> theEdges)
 157{
 158  SetErrorCode(GEOM_KO);
 159
 160 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 161  //Add a new Fillet object
 162  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 163 #else
 164  Handle(GEOM_Object) aFillet = theShape;
 165 #endif
 166
 167  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 168  if (aRefShape.IsNull()) return NULL;
 169
 170  //Add a new Fillet function
 171  Handle(GEOM_Function) aFunction =
 172    aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES);
 173  if (aFunction.IsNull()) return NULL;
 174
 175  //Check if the function is set correctly
 176  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 177
 178  GEOMImpl_IFillet aCI (aFunction);
 179
 180  aCI.SetShape(aRefShape);
 181  SETPARAM(aCI.SetR,theR);
 182  int aLen = theEdges.size();
 183  aCI.SetLength(aLen);
 184
 185  int ind = 1;
 186  std::list<int>::iterator it = theEdges.begin();
 187  for (; it != theEdges.end(); it++, ind++) {
 188    aCI.SetEdge(ind, (*it));
 189  }
 190
 191  //Compute the Fillet value
 192  try {
 193#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 194    OCC_CATCH_SIGNALS;
 195#endif
 196    if (!GetSolver()->ComputeFunction(aFunction)) {
 197      SetErrorCode("Fillet driver failed");
 198      return NULL;
 199    }
 200  }
 201  catch (Standard_Failure) {
 202    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 203    SetErrorCode(aFail->GetMessageString());
 204    return NULL;
 205  }
 206
 207  //Make a Python command
 208  GEOM::TPythonDump pd (aFunction);
 209  pd << aFillet << " = MakeFilletEdges(" << theShape
 210    << ", " << theR << ", [";
 211
 212  it = theEdges.begin();
 213  pd << (*it++);
 214  while (it != theEdges.end()) {
 215    pd << ", " << (*it++);
 216  }
 217  pd << "])";
 218
 219  SetErrorCode(GEOM_OK);
 220  return aFillet;
 221}
 222
 223//=============================================================================
 224/*!
 225 *  MakeFilletEdges R1 R2
 226 */
 227//=============================================================================
 228Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletEdgesR1R2
 229	   (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR1, const GEOM_Parameter& theR2, std::list<int> theEdges)
 230{
 231  SetErrorCode(GEOM_KO);
 232
 233 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 234  //Add a new Fillet object
 235  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 236 #else
 237  Handle(GEOM_Object) aFillet = theShape;
 238 #endif
 239
 240  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 241  if (aRefShape.IsNull()) return NULL;
 242
 243  //Add a new Fillet function
 244  Handle(GEOM_Function) aFunction =
 245	aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_EDGES_2R);
 246  if (aFunction.IsNull()) return NULL;
 247
 248  //Check if the function is set correctly
 249  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 250
 251  GEOMImpl_IFillet aCI (aFunction);
 252
 253  aCI.SetShape(aRefShape);
 254  SETPARAM(aCI.SetR1,theR1);
 255  SETPARAM(aCI.SetR2,theR2);
 256  int aLen = theEdges.size();
 257  aCI.SetLength(aLen);
 258
 259  int ind = 1;
 260  std::list<int>::iterator it = theEdges.begin();
 261  for (; it != theEdges.end(); it++, ind++) {
 262    aCI.SetEdge(ind, (*it));
 263  }
 264
 265  //Compute the Fillet value
 266  try {
 267#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 268    OCC_CATCH_SIGNALS;
 269#endif
 270    if (!GetSolver()->ComputeFunction(aFunction)) {
 271      SetErrorCode("Fillet driver failed");
 272      return NULL;
 273    }
 274  }
 275  catch (Standard_Failure) {
 276    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 277    SetErrorCode(aFail->GetMessageString());
 278    return NULL;
 279  }
 280
 281  //Make a Python command
 282  GEOM::TPythonDump pd (aFunction);
 283  pd << aFillet << " = MakeFilletR1R2(" << theShape
 284	<< ", " << theR1 << ", " <<theR2 << ", ShapeType[\"EDGE\"], [";
 285
 286  it = theEdges.begin();
 287  pd << (*it++);
 288  while (it != theEdges.end()) {
 289    pd << ", " << (*it++);
 290  }
 291  pd << "])";
 292
 293  SetErrorCode(GEOM_OK);
 294  return aFillet;
 295}
 296
 297//=============================================================================
 298/*!
 299 *  MakeFilletFaces
 300 */
 301//=============================================================================
 302Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFaces
 303	   (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR, std::list<int> theFaces)
 304{
 305  SetErrorCode(GEOM_KO);
 306
 307 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 308  //Add a new Fillet object
 309  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 310 #else
 311  Handle(GEOM_Object) aFillet = theShape;
 312 #endif
 313
 314  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 315  if (aRefShape.IsNull()) return NULL;
 316
 317  //Add a new Fillet function
 318  Handle(GEOM_Function) aFunction =
 319	aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES);
 320  if (aFunction.IsNull()) return NULL;
 321
 322  //Check if the function is set correctly
 323  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 324
 325  GEOMImpl_IFillet aCI (aFunction);
 326
 327  aCI.SetShape(aRefShape);
 328  SETPARAM(aCI.SetR,theR);
 329  int aLen = theFaces.size();
 330  aCI.SetLength(aLen);
 331
 332  int ind = 1;
 333  std::list<int>::iterator it = theFaces.begin();
 334  for (; it != theFaces.end(); it++, ind++) {
 335    aCI.SetFace(ind, (*it));
 336  }
 337
 338  //Compute the Fillet value
 339  try {
 340#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 341    OCC_CATCH_SIGNALS;
 342#endif
 343    if (!GetSolver()->ComputeFunction(aFunction)) {
 344      SetErrorCode("Fillet driver failed");
 345      return NULL;
 346    }
 347  }
 348  catch (Standard_Failure) {
 349    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 350    SetErrorCode(aFail->GetMessageString());
 351    return NULL;
 352  }
 353
 354  //Make a Python command
 355  GEOM::TPythonDump pd (aFunction);
 356  pd << aFillet << " = MakeFilletFaces(" << theShape
 357	<< ", " << theR << ", [";
 358
 359  it = theFaces.begin();
 360  pd << (*it++);
 361  while (it != theFaces.end()) {
 362    pd << ", " << (*it++);
 363  }
 364  pd << "])";
 365
 366  SetErrorCode(GEOM_OK);
 367  return aFillet;
 368}
 369
 370//=============================================================================
 371/*!
 372 *  MakeVariableFillet
 373 */
 374//=============================================================================
 375Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeVariableFillet
 376	   (Handle(GEOM_Object) theShape, std::list<GEOM_Parameter> theEdgesParams, std::list<GEOM_Parameter> theRadiusAtParam, std::list<int> theEdges)
 377{
 378  SetErrorCode(GEOM_KO);
 379
 380 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 381  //Add a new Fillet object
 382  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_VARFILLET);
 383 #else
 384  Handle(GEOM_Object) aFillet = theShape;
 385 #endif
 386
 387  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 388  if (aRefShape.IsNull()) return NULL;
 389
 390  //Add a new Fillet function
 391  Handle(GEOM_Function) aFunction =
 392	aFillet->AddFunction(GEOMImpl_VariableFilletDriver::GetID(), VARFILLET);
 393  if (aFunction.IsNull()) return NULL;
 394
 395  //Check if the function is set correctly
 396  if (aFunction->GetDriverGUID() != GEOMImpl_VariableFilletDriver::GetID()) return NULL;
 397
 398  GEOMImpl_IVariableFillet aCI (aFunction);
 399  //check if the input data is ok
 400  if (theEdges.size() == 0)
 401	return NULL;
 402  else if (theRadiusAtParam.size() == 0)
 403	return NULL;
 404  else if ((theEdgesParams.size() != 0) && (theEdgesParams.size() != theRadiusAtParam.size()))
 405	return NULL;
 406
 407  //set the base shape
 408  aCI.SetShape(aRefShape);
 409
 410  //------------------------
 411  //BEGIN EDGES LIST SECTION
 412
 413  //create an edge array to be filled
 414  Handle(TColStd_HArray1OfInteger) 	anEdgeArray  = new TColStd_HArray1OfInteger(1, theEdges.size() );
 415
 416  //fill the edge array
 417  int ind = 1;
 418  std::list<int>::iterator it = theEdges.begin();
 419  for (; it != theEdges.end(); it++, ind++) {
 420	anEdgeArray->SetValue(ind, *it);
 421  }
 422
 423  //add the data to the function
 424  aCI.SetEdgesArray( anEdgeArray );
 425
 426  //END EDGES LIST SECTION
 427  //------------------------
 428
 429
 430  //set the GEOM_Parameter iterator
 431  std::list<GEOM_Parameter>::iterator it2;
 432
 433
 434  //------------------------
 435  //BEGIN PARAMETER VALUES SECTION
 436
 437  //set flags for later use
 438  bool ParamsAreExpressionsFlag = false;
 439  bool hasEdgeParameters 		= true;
 440
 441  if (theEdgesParams.size() == 0)
 442	hasEdgeParameters = false;
 443
 444  if (hasEdgeParameters)
 445  {
 446	  //now check if the u param of edge is a double or an expression
 447	  it2 = theEdgesParams.begin();
 448	  for (; it2 != theEdgesParams.end(); it2++, ind++)
 449	  {
 450		GEOM_Parameter aParam = *it2;
 451		if (aParam.IsString())
 452		{
 453		  ParamsAreExpressionsFlag = true;
 454		  break;
 455		}
 456	  }
 457  }
 458
 459  Handle(TColStd_HArray1OfReal) 		aParamArrayAsReal;
 460  Handle(TColStd_HArray1OfAsciiString) 	aParamArrayAsString;
 461
 462  //if params are expressions fill an asciistring array and pass it to the driver
 463  //otherwise fill a double array ans pass it.
 464  if (ParamsAreExpressionsFlag && hasEdgeParameters)
 465  {
 466	  //here we have expressions
 467	  aParamArrayAsString  = new TColStd_HArray1OfAsciiString(1, theEdgesParams.size() );
 468
 469	  ind = 1;
 470	  it2 = theEdgesParams.begin();
 471	  for (; it2 != theEdgesParams.end(); it2++, ind++) {
 472		GEOM_Parameter aParam = *it2;
 473		aParamArrayAsString->SetValue(ind, aParam.GetString() );
 474	  }
 475	  aCI.SetParamsArray(aParamArrayAsString);
 476  }
 477  else if (!ParamsAreExpressionsFlag && hasEdgeParameters)
 478  {
 479	  //here we have doubles
 480	  aParamArrayAsReal  = new TColStd_HArray1OfReal(1, theEdgesParams.size() );
 481
 482	  ind = 1;
 483	  it2 = theEdgesParams.begin();
 484	  for (; it2 != theEdgesParams.end(); it2++, ind++) {
 485		GEOM_Parameter aParam = *it2;
 486		aParamArrayAsReal->SetValue(ind, aParam.GetDouble() );
 487	  }
 488	  if (theEdgesParams.size() != 0)
 489		aCI.SetParamsArray(aParamArrayAsReal);
 490  }
 491  //END PARAMETER VALUES SECTION
 492  //------------------------
 493
 494
 495  //------------------------
 496  //BEGIN RADIUS VALUES SECTION
 497  bool RadiusAreExpressionsFlag = false;
 498
 499  //also check if the radiuses used are expressions or doubles
 500  it2 = theRadiusAtParam.begin();
 501  for (; it2 != theRadiusAtParam.end(); it2++, ind++)
 502  {
 503	GEOM_Parameter aParam = *it2;
 504	if (aParam.IsString())
 505	{
 506	  RadiusAreExpressionsFlag = true;
 507	  break;
 508	}
 509  }
 510
 511  //Do the same as above for the radius values
 512  if (RadiusAreExpressionsFlag)
 513  {
 514	  //here we have expressions
 515	  Handle(TColStd_HArray1OfAsciiString) 	aRadiusArray  = new TColStd_HArray1OfAsciiString(1, theRadiusAtParam.size() );
 516
 517	  ind = 1;
 518	  it2 = theRadiusAtParam.begin();
 519	  for (; it2 != theRadiusAtParam.end(); it2++, ind++) {
 520		GEOM_Parameter aParam = *it2;
 521		aRadiusArray->SetValue(ind, aParam.GetString() );
 522	  }
 523
 524	  aCI.SetRadiusArray(aRadiusArray);
 525  }
 526  else
 527  {
 528	  //here we have doubles
 529	  Handle(TColStd_HArray1OfReal) aRadiusArray  = new TColStd_HArray1OfReal(1, theRadiusAtParam.size() );
 530
 531	  ind = 1;
 532	  it2 = theRadiusAtParam.begin();
 533	  for (; it2 != theRadiusAtParam.end(); it2++, ind++) {
 534		GEOM_Parameter aParam = *it2;
 535		aRadiusArray->SetValue(ind, aParam.GetDouble() );
 536	  }
 537
 538	  aCI.SetRadiusArray(aRadiusArray);
 539  }
 540  //------------------------
 541  //END RADIUS VALUES SECTION
 542
 543
 544  //Compute the var Fillet value
 545  try {
 546#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 547	OCC_CATCH_SIGNALS;
 548#endif
 549	if (!GetSolver()->ComputeFunction(aFunction)) {
 550	  SetErrorCode("Variable Fillet driver failed");
 551	  return NULL;
 552	}
 553  }
 554  catch (Standard_Failure) {
 555	Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 556	SetErrorCode(aFail->GetMessageString());
 557	return NULL;
 558  }
 559
 560  //Make a Python command
 561  GEOM::TPythonDump pd (aFunction);
 562  pd << aFillet << " = MakeVariableFillet(" << theShape
 563
 564  //EDGE DUMP
 565  <<", [";
 566  it = theEdges.begin();
 567  pd << (*it++);
 568  while (it != theEdges.end()) {
 569	pd << ", " << (*it++);
 570  }
 571  pd << "]";
 572
 573  //PARAM DUMP
 574  pd << ", [";
 575  it2 = theEdgesParams.begin();
 576  pd << (*it2++);
 577  while (it2 != theEdgesParams.end()) {
 578    pd << ", " << (*it2++);
 579  }
 580  pd << "]";
 581
 582  //RADIUS AT PARAM DUMP
 583  pd << ", [";
 584  it2 = theRadiusAtParam.begin();
 585  pd << (*it2++);
 586  while (it2 != theRadiusAtParam.end()) {
 587	pd << ", " << (*it2++);
 588  }
 589  pd << "]";
 590
 591  SetErrorCode(GEOM_OK);
 592  return aFillet;
 593}
 594
 595//=============================================================================
 596/*!
 597 *  MakeFillet2DVertices
 598 */
 599//=============================================================================
 600Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2DVertices
 601	   (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR, std::list<int> theVertices)
 602{
 603  SetErrorCode(GEOM_KO);
 604
 605 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 606  //Add a new Fillet object
 607  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 608 #else
 609  Handle(GEOM_Object) aFillet = theShape;
 610 #endif
 611
 612  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 613  if (aRefShape.IsNull()) return NULL;
 614
 615  //Add a new Fillet function
 616  Handle(GEOM_Function) aFunction =
 617	aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_VERTEX_2D);
 618  if (aFunction.IsNull()) return NULL;
 619
 620  //Check if the function is set correctly
 621  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 622
 623  GEOMImpl_IFillet aCI (aFunction);
 624
 625  aCI.SetShape(aRefShape);
 626  SETPARAM(aCI.SetR,theR);
 627  int aLen = theVertices.size();
 628  aCI.SetLength(aLen);
 629
 630  int ind = 1;
 631  std::list<int>::iterator it = theVertices.begin();
 632  for (; it != theVertices.end(); it++, ind++) {
 633	aCI.SetVertex(ind, (*it));
 634  }
 635
 636  //Compute the Fillet value
 637  try {
 638#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 639    OCC_CATCH_SIGNALS;
 640#endif
 641    if (!GetSolver()->ComputeFunction(aFunction)) {
 642      SetErrorCode("Fillet driver failed");
 643      return NULL;
 644    }
 645  }
 646  catch (Standard_Failure) {
 647    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 648    SetErrorCode(aFail->GetMessageString());
 649    return NULL;
 650  }
 651
 652  //Make a Python command
 653  GEOM::TPythonDump pd (aFunction);
 654  pd << aFillet << " = MakeFillet2DVertices(" << theShape
 655	<< ", " << theR << ", [";
 656
 657  it = theVertices.begin();
 658  pd << (*it++);
 659  while (it != theVertices.end()) {
 660    pd << ", " << (*it++);
 661  }
 662  pd << "])";
 663
 664  SetErrorCode(GEOM_OK);
 665  return aFillet;
 666}
 667
 668//=============================================================================
 669/*!
 670 *  MakeFilletFaces R1 R2
 671 */
 672//=============================================================================
 673Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2
 674       (Handle(GEOM_Object) theShape, const GEOM_Parameter& theR1, const GEOM_Parameter& theR2, std::list<int> theFaces)
 675{
 676  SetErrorCode(GEOM_KO);
 677
 678 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 679  //Add a new Fillet object
 680  Handle(GEOM_Object) aFillet = GetEngine()->AddObject(GetDocID(), GEOM_FILLET);
 681 #else
 682  Handle(GEOM_Object) aFillet = theShape;
 683 #endif
 684
 685  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 686  if (aRefShape.IsNull()) return NULL;
 687
 688  //Add a new Fillet function
 689  Handle(GEOM_Function) aFunction =
 690	aFillet->AddFunction(GEOMImpl_FilletDriver::GetID(), FILLET_SHAPE_FACES_2R);
 691  if (aFunction.IsNull()) return NULL;
 692
 693  //Check if the function is set correctly
 694  if (aFunction->GetDriverGUID() != GEOMImpl_FilletDriver::GetID()) return NULL;
 695
 696  GEOMImpl_IFillet aCI (aFunction);
 697
 698  aCI.SetShape(aRefShape);
 699  SETPARAM(aCI.SetR1,theR1);
 700  SETPARAM(aCI.SetR2,theR2);
 701  int aLen = theFaces.size();
 702  aCI.SetLength(aLen);
 703
 704  int ind = 1;
 705  std::list<int>::iterator it = theFaces.begin();
 706  for (; it != theFaces.end(); it++, ind++) {
 707    aCI.SetFace(ind, (*it));
 708  }
 709
 710  //Compute the Fillet value
 711  try {
 712#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 713    OCC_CATCH_SIGNALS;
 714#endif
 715    if (!GetSolver()->ComputeFunction(aFunction)) {
 716      SetErrorCode("Fillet driver failed");
 717      return NULL;
 718    }
 719  }
 720  catch (Standard_Failure) {
 721    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 722    SetErrorCode(aFail->GetMessageString());
 723    return NULL;
 724  }
 725
 726  //Make a Python command
 727  GEOM::TPythonDump pd (aFunction);
 728  pd << aFillet << " = MakeFilletR1R2(" << theShape
 729	<< ", " << theR1 << ", " << theR2 << ", ShapeType[\"FACE\"], [";
 730
 731  it = theFaces.begin();
 732  pd << (*it++);
 733  while (it != theFaces.end()) {
 734    pd << ", " << (*it++);
 735  }
 736  pd << "])";
 737
 738  SetErrorCode(GEOM_OK);
 739  return aFillet;
 740}
 741
 742//=============================================================================
 743/*!
 744 *  MakeChamferAll
 745 */
 746//=============================================================================
 747Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferAll (Handle(GEOM_Object) theShape, const GEOM_Parameter& theD)
 748{
 749  SetErrorCode(GEOM_KO);
 750
 751 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 752  //Add a new Chamfer object
 753  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
 754 #else
 755  Handle(GEOM_Object) aChamfer = theShape;
 756 #endif
 757
 758  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 759  if (aRefShape.IsNull()) return NULL;
 760
 761  //Add a new Chamfer function
 762  Handle(GEOM_Function) aFunction =
 763	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_ALL);
 764  if (aFunction.IsNull()) return NULL;
 765
 766  //Check if the function is set correctly
 767  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
 768
 769  GEOMImpl_IChamfer aCI (aFunction);
 770
 771  aCI.SetShape(aRefShape);
 772  SETPARAM(aCI.SetD, theD);
 773
 774  //Compute the Chamfer value
 775  try {
 776#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 777    OCC_CATCH_SIGNALS;
 778#endif
 779    if (!GetSolver()->ComputeFunction(aFunction)) {
 780      SetErrorCode("Chamfer driver failed");
 781      return NULL;
 782    }
 783  }
 784  catch (Standard_Failure) {
 785    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 786    SetErrorCode(aFail->GetMessageString());
 787    return NULL;
 788  }
 789
 790  //Make a Python command
 791  GEOM::TPythonDump(aFunction) << aChamfer << " = MakeChamferAll("
 792							   << theShape << ", " << theD << ")";
 793
 794  SetErrorCode(GEOM_OK);
 795  return aChamfer;
 796}
 797
 798//=============================================================================
 799/*!
 800 *  MakeChamferEdge
 801 */
 802//=============================================================================
 803Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdge
 804							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD1, const GEOM_Parameter& theD2,
 805							 int theFace1, int theFace2)
 806{
 807  SetErrorCode(GEOM_KO);
 808
 809 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 810  //Add a new Chamfer object
 811  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
 812 #else
 813  Handle(GEOM_Object) aChamfer = theShape;
 814 #endif
 815
 816  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 817  if (aRefShape.IsNull()) return NULL;
 818
 819  //Add a new Chamfer function
 820  Handle(GEOM_Function) aFunction =
 821	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE);
 822  if (aFunction.IsNull()) return NULL;
 823
 824  //Check if the function is set correctly
 825  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
 826
 827  GEOMImpl_IChamfer aCI (aFunction);
 828
 829  aCI.SetShape(aRefShape);
 830  SETPARAM(aCI.SetD1,theD1);
 831  SETPARAM(aCI.SetD2,theD2);
 832  aCI.SetFace1(theFace1);
 833  aCI.SetFace2(theFace2);
 834
 835  //Compute the Chamfer value
 836  try {
 837#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 838    OCC_CATCH_SIGNALS;
 839#endif
 840    if (!GetSolver()->ComputeFunction(aFunction)) {
 841      SetErrorCode("Chamfer driver failed");
 842      return NULL;
 843    }
 844  }
 845  catch (Standard_Failure) {
 846    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 847    SetErrorCode(aFail->GetMessageString());
 848    return NULL;
 849  }
 850
 851  //Make a Python command
 852  GEOM::TPythonDump(aFunction) << aChamfer
 853	<< " = MakeChamferEdge(" << theShape << ", " << theD1
 854	  << ", " << theD2 << ", " << theFace1 << ", " << theFace2 << ")";
 855
 856  SetErrorCode(GEOM_OK);
 857  return aChamfer;
 858}
 859
 860//=============================================================================
 861/*!
 862 *  MakeChamferEdgeAD
 863 */
 864//=============================================================================
 865Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgeAD
 866							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD, const GEOM_Parameter& theAngle,
 867                             int theFace1, int theFace2)
 868{
 869  SetErrorCode(GEOM_KO);
 870
 871 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 872  //Add a new Chamfer object
 873  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
 874 #else
 875  Handle(GEOM_Object) aChamfer = theShape;
 876 #endif
 877
 878  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 879  if (aRefShape.IsNull()) return NULL;
 880
 881  //Add a new Chamfer function
 882  Handle(GEOM_Function) aFunction =
 883	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGE_AD);
 884  if (aFunction.IsNull()) return NULL;
 885
 886  //Check if the function is set correctly
 887  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
 888
 889  GEOMImpl_IChamfer aCI (aFunction);
 890
 891  aCI.SetShape(aRefShape);
 892
 893  SETPARAM(aCI.SetD, theD);
 894  SETPARAM(aCI.SetAngle, theAngle);
 895
 896  aCI.SetFace1(theFace1);
 897  aCI.SetFace2(theFace2);
 898
 899  //Compute the Chamfer value
 900  try {
 901#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 902    OCC_CATCH_SIGNALS;
 903#endif
 904    if (!GetSolver()->ComputeFunction(aFunction)) {
 905      SetErrorCode("Chamfer driver failed");
 906      return NULL;
 907    }
 908  }
 909  catch (Standard_Failure) {
 910    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 911    SetErrorCode(aFail->GetMessageString());
 912    return NULL;
 913  }
 914
 915  //Make a Python command
 916  GEOM::TPythonDump(aFunction) << aChamfer
 917	<< " = MakeChamferEdgeAD(" << theShape << ", " << theD
 918      << ", " << theAngle << ", " << theFace1 << ", " << theFace2 << ")";
 919  SetErrorCode(GEOM_OK);
 920  return aChamfer;
 921}
 922
 923//=============================================================================
 924/*!
 925 *  MakeChamferFaces
 926 */
 927//=============================================================================
 928Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFaces
 929							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD1, const GEOM_Parameter& theD2,
 930                             std::list<int> theFaces)
 931{
 932  SetErrorCode(GEOM_KO);
 933
 934 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
 935  //Add a new Chamfer object
 936  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
 937 #else
 938  Handle(GEOM_Object) aChamfer = theShape;
 939 #endif
 940
 941  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
 942  if (aRefShape.IsNull()) return NULL;
 943
 944  //Add a new Chamfer function
 945  Handle(GEOM_Function) aFunction =
 946	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES);
 947  if (aFunction.IsNull()) return NULL;
 948
 949  //Check if the function is set correctly
 950  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
 951
 952  GEOMImpl_IChamfer aCI (aFunction);
 953
 954  aCI.SetShape(aRefShape);
 955  SETPARAM(aCI.SetD1,theD1);
 956  SETPARAM(aCI.SetD2,theD2);
 957  int aLen = theFaces.size();
 958  aCI.SetLength(aLen);
 959
 960  int ind = 1;
 961  std::list<int>::iterator it = theFaces.begin();
 962  for (; it != theFaces.end(); it++, ind++) {
 963    aCI.SetFace(ind, (*it));
 964  }
 965
 966  //Compute the Chamfer value
 967  try {
 968#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
 969    OCC_CATCH_SIGNALS;
 970#endif
 971    if (!GetSolver()->ComputeFunction(aFunction)) {
 972      SetErrorCode("Chamfer driver failed");
 973      return NULL;
 974    }
 975  }
 976  catch (Standard_Failure) {
 977    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
 978    SetErrorCode(aFail->GetMessageString());
 979    return NULL;
 980  }
 981
 982  //Make a Python command
 983  GEOM::TPythonDump pd (aFunction);
 984  pd << aChamfer << " = MakeChamferFaces(" << theShape
 985	<< ", " << theD1 << ", " << theD2 << ", [";
 986
 987  it = theFaces.begin();
 988  pd << (*it++);
 989  while (it != theFaces.end()) {
 990    pd << ", " << (*it++);
 991  }
 992  pd << "])";
 993
 994  SetErrorCode(GEOM_OK);
 995  return aChamfer;
 996}
 997
 998//=============================================================================
 999/*!
1000 *  MakeChamfer2DEdges
1001 */
1002//=============================================================================
1003Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamfer2DEdges
1004							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD1, const GEOM_Parameter& theD2,
1005							 int theEdge1, int theEdge2)
1006{
1007  SetErrorCode(GEOM_KO);
1008
1009 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1010  //Add a new Chamfer object
1011  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
1012 #else
1013  Handle(GEOM_Object) aChamfer = theShape;
1014 #endif
1015
1016  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1017  if (aRefShape.IsNull()) return NULL;
1018
1019  //Add a new Chamfer function
1020  Handle(GEOM_Function) aFunction =
1021	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_2D);
1022  if (aFunction.IsNull()) return NULL;
1023
1024  //Check if the function is set correctly
1025  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
1026
1027  GEOMImpl_IChamfer aCI (aFunction);
1028
1029  aCI.SetShape(aRefShape);
1030  SETPARAM(aCI.SetD1,theD1);
1031  SETPARAM(aCI.SetD2,theD2);
1032  aCI.Set2DEdge1(theEdge1);
1033  aCI.Set2DEdge2(theEdge2);
1034
1035  //Compute the Chamfer value
1036  try {
1037#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1038    OCC_CATCH_SIGNALS;
1039#endif
1040    if (!GetSolver()->ComputeFunction(aFunction)) {
1041      SetErrorCode("Chamfer driver failed");
1042      return NULL;
1043    }
1044  }
1045  catch (Standard_Failure) {
1046    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1047    SetErrorCode(aFail->GetMessageString());
1048    return NULL;
1049  }
1050
1051  //Make a Python command
1052  GEOM::TPythonDump(aFunction) << aChamfer
1053	<< " = MakeChamfer2DEdge(" << theShape << ", " << theD1
1054	  << ", " << theD2 << ", " << theEdge1 << ", " << theEdge2 << ")";
1055
1056  SetErrorCode(GEOM_OK);
1057  return aChamfer;
1058}
1059
1060//=============================================================================
1061/*!
1062 *  MakeThickSolid
1063 */
1064//=============================================================================
1065Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeThickSolid
1066	   (Handle(GEOM_Object) theShape, const GEOM_Parameter& theOffset, std::list<int> theFaces)
1067{
1068  SetErrorCode(GEOM_KO);
1069
1070 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1071  //Add a new ThickSolid object
1072  Handle(GEOM_Object) aThickSolid = GetEngine()->AddObject(GetDocID(), GEOM_THICKSOLID);
1073 #else
1074  Handle(GEOM_Object) aThickSolid = theShape;
1075 #endif
1076
1077  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1078  if (aRefShape.IsNull()) return NULL;
1079
1080  //Add a new ThickSolid function
1081  Handle(GEOM_Function) aFunction =
1082	aThickSolid->AddFunction(GEOMImpl_ThickSolidDriver::GetID(), THICKSOLID);
1083  if (aFunction.IsNull()) return NULL;
1084
1085  //Check if the function is set correctly
1086  if (aFunction->GetDriverGUID() != GEOMImpl_ThickSolidDriver::GetID()) return NULL;
1087
1088  GEOMImpl_IThickSolid aCI (aFunction);
1089
1090  aCI.SetShape(aRefShape);
1091  SETPARAM(aCI.SetOffset,theOffset);
1092  int aLen = theFaces.size();
1093  aCI.SetLength(aLen);
1094
1095  int ind = 1;
1096  std::list<int>::iterator it = theFaces.begin();
1097  for (; it != theFaces.end(); it++, ind++) {
1098    aCI.SetFace(ind, (*it));
1099  }
1100
1101  //Compute the ThickSolid value
1102  try {
1103#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1104    OCC_CATCH_SIGNALS;
1105#endif
1106    if (!GetSolver()->ComputeFunction(aFunction)) {
1107	  SetErrorCode("ThickSolid driver failed");
1108      return NULL;
1109    }
1110  }
1111  catch (Standard_Failure) {
1112    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1113    SetErrorCode(aFail->GetMessageString());
1114    return NULL;
1115  }
1116
1117  //Make a Python command
1118  GEOM::TPythonDump pd (aFunction);
1119  pd << aThickSolid << " = MakeThickSolid(" << theShape
1120	<< ", " << theOffset << ", ";
1121
1122  it = theFaces.begin();
1123  pd << (*it++);
1124  while (it != theFaces.end()) {
1125    pd << ", " << (*it++);
1126  }
1127  pd << ")";
1128
1129  SetErrorCode(GEOM_OK);
1130  return aThickSolid;
1131}
1132
1133//=============================================================================
1134/*!
1135 *  MakeDraftFacesAngle
1136 */
1137//=============================================================================
1138Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeDraftFacesAngle
1139	   (Handle(GEOM_Object) theShape, Handle(GEOM_Object) theNeutralPlane,
1140		const GEOM_Parameter& theAngle, std::list<int> theFaces)
1141{
1142  SetErrorCode(GEOM_KO);
1143
1144 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1145  //Add a new Draft Solid object
1146  Handle(GEOM_Object) aDraftSolid = GetEngine()->AddObject(GetDocID(), GEOM_DRAFT);
1147 #else
1148  Handle(GEOM_Object) aDraftSolid = theShape;
1149 #endif
1150
1151  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1152  if (aRefShape.IsNull())
1153	return NULL;
1154
1155  Handle(GEOM_Function) aRefPlane = theNeutralPlane->GetLastFunction();
1156  if (aRefPlane.IsNull())
1157	return NULL;
1158
1159  //Add a new Draft Solid function
1160  Handle(GEOM_Function) aFunction = aDraftSolid->AddFunction(GEOMImpl_DraftDriver::GetID(), DRAFT_BY_FACE_PLN_ANG);
1161
1162  if (aFunction.IsNull())
1163	return NULL;
1164
1165  //Check if the function is set correctly
1166  if (aFunction->GetDriverGUID() != GEOMImpl_DraftDriver::GetID())
1167	return NULL;
1168
1169  GEOMImpl_IDraft aCI (aFunction);
1170
1171  aCI.SetShape(aRefShape);
1172  aCI.SetPlane(aRefPlane);
1173
1174  SETPARAM(aCI.SetAngle,theAngle);
1175
1176  int aLen = theFaces.size();
1177  aCI.SetLength(aLen);
1178
1179  int ind = 1;
1180  std::list<int>::iterator it = theFaces.begin();
1181  for (; it != theFaces.end(); it++, ind++) {
1182	aCI.SetFace(ind, (*it));
1183  }
1184
1185  //Compute the Draft value
1186  try {
1187#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1188	OCC_CATCH_SIGNALS;
1189#endif
1190	if (!GetSolver()->ComputeFunction(aFunction)) {
1191	  SetErrorCode("Draft driver failed");
1192	  return NULL;
1193	}
1194  }
1195  catch (Standard_Failure) {
1196	Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1197    SetErrorCode(aFail->GetMessageString());
1198	return NULL;
1199  }
1200
1201  //Make a Python command
1202  GEOM::TPythonDump pd (aFunction);
1203  pd << aDraftSolid << " = MakeDraftFacesAngle(" << theShape
1204  << ", " << theNeutralPlane << ", " << theAngle << ", [";
1205
1206  it = theFaces.begin();
1207  pd << (*it++);
1208  while (it != theFaces.end()) {
1209	pd << ", " << (*it++);
1210  }
1211  pd << "])";
1212
1213  SetErrorCode(GEOM_OK);
1214  return aDraftSolid;
1215}
1216
1217//=============================================================================
1218/*!
1219 *  MakeDraftFacesAngleWithStationaryFace
1220 */
1221//=============================================================================
1222Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeDraftFacesAngleWithStationaryFace
1223	   (Handle(GEOM_Object) theShape, int theNeutralPlane, const GEOM_Parameter& theAngle, std::list<int> theFaces)
1224{
1225  SetErrorCode(GEOM_KO);
1226
1227 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1228  //Add a new Draft Solid object
1229  Handle(GEOM_Object) aDraftSolid = GetEngine()->AddObject(GetDocID(), GEOM_DRAFT);
1230 #else
1231  Handle(GEOM_Object) aDraftSolid = theShape;
1232 #endif
1233
1234  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1235  if (aRefShape.IsNull())
1236	return NULL;
1237
1238  //Add a new Draft Solid function
1239  Handle(GEOM_Function) aFunction = aDraftSolid->AddFunction(GEOMImpl_DraftDriver::GetID(), DRAFT_BY_FACE_STA_ANG);
1240
1241  if (aFunction.IsNull())
1242	return NULL;
1243
1244  //Check if the function is set correctly
1245  if (aFunction->GetDriverGUID() != GEOMImpl_DraftDriver::GetID())
1246	return NULL;
1247
1248  GEOMImpl_IDraft aCI (aFunction);
1249
1250  aCI.SetStationary(theNeutralPlane);
1251  aCI.SetShape(aRefShape);
1252
1253  SETPARAM(aCI.SetAngle,theAngle);
1254
1255  int aLen = theFaces.size();
1256  aCI.SetLength(aLen);
1257
1258  int ind = 1;
1259  std::list<int>::iterator it = theFaces.begin();
1260  for (; it != theFaces.end(); it++, ind++) {
1261	aCI.SetFace(ind, (*it));
1262  }
1263
1264  //Compute the Draft value
1265  try {
1266#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1267	OCC_CATCH_SIGNALS;
1268#endif
1269	if (!GetSolver()->ComputeFunction(aFunction)) {
1270	  SetErrorCode("Draft driver failed");
1271	  return NULL;
1272	}
1273  }
1274  catch (Standard_Failure) {
1275	Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1276    SetErrorCode(aFail->GetMessageString());
1277	return NULL;
1278  }
1279
1280  //Make a Python command
1281  GEOM::TPythonDump pd (aFunction);
1282  pd << aDraftSolid << " = MakeDraftFacesAngleWithStationaryFace(" << theShape
1283  << ", " << theNeutralPlane << ", " << theAngle << ", [";
1284
1285  it = theFaces.begin();
1286  pd << (*it++);
1287  while (it != theFaces.end()) {
1288	pd << ", " << (*it++);
1289  }
1290  pd << "])";
1291
1292  SetErrorCode(GEOM_OK);
1293  return aDraftSolid;
1294}
1295
1296//=============================================================================
1297/*!
1298 *  MakeChamferFacesAD
1299 */
1300//=============================================================================
1301Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferFacesAD
1302							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD, const GEOM_Parameter& theAngle,
1303                             std::list<int> theFaces)
1304{
1305  SetErrorCode(GEOM_KO);
1306
1307 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1308  //Add a new Chamfer object
1309  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
1310 #else
1311  Handle(GEOM_Object) aChamfer = theShape;
1312 #endif
1313
1314  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1315  if (aRefShape.IsNull()) return NULL;
1316
1317  //Add a new Chamfer function
1318  Handle(GEOM_Function) aFunction =
1319	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_FACES_AD);
1320  if (aFunction.IsNull()) return NULL;
1321
1322  //Check if the function is set correctly
1323  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID()) return NULL;
1324
1325  GEOMImpl_IChamfer aCI (aFunction);
1326
1327  aCI.SetShape(aRefShape);
1328
1329  SETPARAM(aCI.SetD, theD);
1330  SETPARAM(aCI.SetAngle, theAngle);
1331
1332  int aLen = theFaces.size();
1333  aCI.SetLength(aLen);
1334
1335  int ind = 1;
1336  std::list<int>::iterator it = theFaces.begin();
1337  for (; it != theFaces.end(); it++, ind++) {
1338    aCI.SetFace(ind, (*it));
1339  }
1340
1341  //Compute the Chamfer value
1342  try {
1343#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1344    OCC_CATCH_SIGNALS;
1345#endif
1346    if (!GetSolver()->ComputeFunction(aFunction)) {
1347      SetErrorCode("Chamfer driver failed");
1348      return NULL;
1349    }
1350  }
1351  catch (Standard_Failure) {
1352    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1353    SetErrorCode(aFail->GetMessageString());
1354    return NULL;
1355  }
1356
1357  //Make a Python command
1358  GEOM::TPythonDump pd (aFunction);
1359  pd << aChamfer << " = MakeChamferFacesAD(" << theShape
1360    << ", " << theD << ", " << theAngle << ", [";
1361
1362  it = theFaces.begin();
1363  pd << (*it++);
1364  while (it != theFaces.end()) {
1365    pd << ", " << (*it++);
1366  }
1367  pd << "])";
1368
1369  SetErrorCode(GEOM_OK);
1370  return aChamfer;
1371}
1372
1373//=============================================================================
1374/*!
1375 *  MakeChamferEdges
1376 */
1377//=============================================================================
1378Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdges
1379							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD1, const GEOM_Parameter& theD2,
1380                             std::list<int> theEdges)
1381{
1382  SetErrorCode(GEOM_KO);
1383
1384 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1385  //Add a new Chamfer object
1386  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
1387 #else
1388  Handle(GEOM_Object) aChamfer = theShape;
1389 #endif
1390
1391  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1392  if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
1393
1394  //Add a new Chamfer function
1395  Handle(GEOM_Function) aFunction =
1396	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES);
1397  if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL;}
1398
1399  //Check if the function is set correctly
1400  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
1401	{ MESSAGE ( "Chamfer Driver is NULL!!!" ); return NULL; }
1402
1403  GEOMImpl_IChamfer aCI (aFunction);
1404
1405  aCI.SetShape(aRefShape);
1406
1407  SETPARAM(aCI.SetD1, theD1);
1408  SETPARAM(aCI.SetD2, theD2);
1409
1410  int aLen = theEdges.size();
1411  aCI.SetLength(aLen);
1412
1413  int ind = 1;
1414  std::list<int>::iterator it = theEdges.begin();
1415  for (; it != theEdges.end(); it++, ind++) {
1416    aCI.SetEdge(ind, (*it));
1417  }
1418
1419  //Compute the Chamfer value
1420  try {
1421#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1422    OCC_CATCH_SIGNALS;
1423#endif
1424    if (!GetSolver()->ComputeFunction(aFunction)) {
1425      SetErrorCode("Chamfer driver failed");
1426      return NULL;
1427    }
1428  }
1429  catch (Standard_Failure) {
1430    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1431    SetErrorCode(aFail->GetMessageString());
1432    return NULL;
1433  }
1434
1435  //Make a Python command
1436  GEOM::TPythonDump pd (aFunction);
1437  pd << aChamfer << " = MakeChamferEdges(" << theShape
1438    << ", " << theD1 << ", " << theD2 << ", [";
1439
1440  it = theEdges.begin();
1441  pd << (*it++);
1442  while (it != theEdges.end()) {
1443    pd << ", " << (*it++);
1444  }
1445  pd << "])";
1446
1447  SetErrorCode(GEOM_OK);
1448  return aChamfer;
1449}
1450
1451//=============================================================================
1452/*!
1453 *  MakeChamferEdgesAD
1454 */
1455//=============================================================================
1456Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeChamferEdgesAD
1457							(Handle(GEOM_Object) theShape, const GEOM_Parameter& theD, const GEOM_Parameter& theAngle,
1458                             std::list<int> theEdges)
1459{
1460  SetErrorCode(GEOM_KO);
1461
1462 #ifdef LOCAL_OPS_CREATE_NEW_OBJECT
1463  //Add a new Chamfer object
1464  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_CHAMFER);
1465 #else
1466  Handle(GEOM_Object) aChamfer = theShape;
1467 #endif
1468
1469  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1470  if (aRefShape.IsNull()) { MESSAGE ("Shape is NULL!!!"); return NULL;}
1471
1472  //Add a new Chamfer function
1473  Handle(GEOM_Function) aFunction =
1474	aChamfer->AddFunction(GEOMImpl_ChamferDriver::GetID(), CHAMFER_SHAPE_EDGES_AD);
1475  if (aFunction.IsNull()) { MESSAGE ( "Edges Function is NULL!!!" ); return NULL; }
1476
1477  //Check if the function is set correctly
1478  if (aFunction->GetDriverGUID() != GEOMImpl_ChamferDriver::GetID())
1479	{ MESSAGE("Chamfer Driver is NULL!!!"); return NULL;}
1480
1481  GEOMImpl_IChamfer aCI (aFunction);
1482
1483  aCI.SetShape(aRefShape);
1484
1485  SETPARAM(aCI.SetD, theD);
1486  SETPARAM(aCI.SetAngle, theAngle);
1487
1488  int aLen = theEdges.size();
1489  aCI.SetLength(aLen);
1490
1491  int ind = 1;
1492  std::list<int>::iterator it = theEdges.begin();
1493  for (; it != theEdges.end(); it++, ind++) {
1494    aCI.SetEdge(ind, (*it));
1495  }
1496
1497  //Compute the Chamfer value
1498  try {
1499#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1500    OCC_CATCH_SIGNALS;
1501#endif
1502    if (!GetSolver()->ComputeFunction(aFunction)) {
1503      SetErrorCode("Chamfer driver failed");
1504      return NULL;
1505    }
1506  }
1507  catch (Standard_Failure) {
1508    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1509    SetErrorCode(aFail->GetMessageString());
1510    return NULL;
1511  }
1512
1513  //Make a Python command
1514  GEOM::TPythonDump pd (aFunction);
1515  pd << aChamfer << " = MakeChamferEdgesAD(" << theShape
1516    << ", " << theD << ", " << theAngle << ", [";
1517
1518  it = theEdges.begin();
1519  pd << (*it++);
1520  while (it != theEdges.end()) {
1521    pd << ", " << (*it++);
1522  }
1523  pd << "])";
1524
1525  SetErrorCode(GEOM_OK);
1526  return aChamfer;
1527}
1528
1529//=============================================================================
1530/*!
1531 *  Archimede
1532 */
1533//=============================================================================
1534Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeArchimede (Handle(GEOM_Object) theShape,
1535															  const GEOM_Parameter& theWeight,
1536															  const GEOM_Parameter& theWaterDensity,
1537															  const GEOM_Parameter& theMeshingDeflection)
1538{
1539  SetErrorCode(GEOM_KO);
1540
1541  //Add a new Archimede object
1542  Handle(GEOM_Object) aChamfer = GetEngine()->AddObject(GetDocID(), GEOM_ARCHIMEDE);
1543
1544  //Add a new Archimede function
1545  Handle(GEOM_Function) aFunction = aChamfer->AddFunction(GEOMImpl_ArchimedeDriver::GetID(), ARCHIMEDE_TYPE);
1546  if (aFunction.IsNull()) return NULL;
1547
1548  //Check if the function is set correctly
1549  if (aFunction->GetDriverGUID() != GEOMImpl_ArchimedeDriver::GetID()) return NULL;
1550
1551  GEOMImpl_IArchimede aAI (aFunction);
1552
1553  Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
1554  if (aRefShape.IsNull()) return NULL;
1555
1556  aAI.SetBasicShape(aRefShape);
1557  SETPARAM(aAI.SetWeight,theWeight);
1558  SETPARAM(aAI.SetDensity,theWaterDensity);
1559  SETPARAM(aAI.SetDeflection,theMeshingDeflection);
1560
1561  //Compute the Archimede value
1562  try {
1563#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
1564    OCC_CATCH_SIGNALS;
1565#endif
1566    if (!GetSolver()->ComputeFunction(aFunction)) {
1567      SetErrorCode("Archimede driver failed");
1568      return NULL;
1569    }
1570  }
1571  catch (Standard_Failure) {
1572    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
1573    SetErrorCode(aFail->GetMessageString());
1574    return NULL;
1575  }
1576
1577  //Make a Python command
1578  GEOM::TPythonDump(aFunction) << aChamfer
1579	<< " = Archimede(" << theShape << ", " << theWeight << ", "
1580	  << theWaterDensity << ", " << theMeshingDeflection << ")";
1581
1582  SetErrorCode(GEOM_OK);
1583  return aChamfer;
1584}
1585
1586//=============================================================================
1587/*!
1588 *  GetSubShape
1589 */
1590//=============================================================================
1591bool GEOMImpl_ILocalOperations::GetSubShape (const TopoDS_Shape& theShape, const int theIndex,
1592                                             TopoDS_Shape& theSubShape)
1593{
1594  if (theShape.IsNull() || theIndex < 1)
1595    return false;
1596
1597  TopTools_IndexedMapOfShape anIndices;
1598  TopExp::MapShapes(theShape, anIndices);
1599  if (theIndex > anIndices.Extent()) return false;
1600  theSubShape = anIndices.FindKey(theIndex);
1601
1602  return true;
1603}
1604
1605//=============================================================================
1606/*!
1607 *  GetSubShapeIndex
1608 */
1609//=============================================================================
1610Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object) theShape,
1611                                                              Handle(GEOM_Object) theSubShape)
1612{
1613  SetErrorCode(GEOM_KO);
1614
1615  Standard_Integer anInd = -1;
1616  GEOM_Engine* anEngine = GetEngine();
1617  //GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
1618  GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
1619
1620  if (aGen) {
1621    GEOMImpl_IShapesOperations* anIShapesOperations =
1622      aGen->GetIShapesOperations(GetDocID());
1623    anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
1624    SetErrorCode(anIShapesOperations->GetErrorCode());
1625  }
1626
1627  return anInd;
1628}