Back to index

salome-geom  6.5.0
GEOMImpl_I3DPrimOperations.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <Standard_Stream.hxx>
00024 
00025 #include <Basics_OCCTVersion.hxx>
00026 
00027 #include <GEOMImpl_I3DPrimOperations.hxx>
00028 
00029 #include "utilities.h"
00030 #include <OpUtil.hxx>
00031 #include <Utils_ExceptHandlers.hxx>
00032 
00033 #include <TFunction_DriverTable.hxx>
00034 #include <TFunction_Driver.hxx>
00035 #include <TFunction_Logbook.hxx>
00036 #include <TDF_Tool.hxx>
00037 
00038 #include <GEOM_Function.hxx>
00039 #include <GEOM_PythonDump.hxx>
00040 
00041 #include <GEOMImpl_Types.hxx>
00042 
00043 #include <GEOMImpl_BoxDriver.hxx>
00044 #include <GEOMImpl_FaceDriver.hxx>
00045 #include <GEOMImpl_DiskDriver.hxx>
00046 #include <GEOMImpl_CylinderDriver.hxx>
00047 #include <GEOMImpl_ConeDriver.hxx>
00048 #include <GEOMImpl_SphereDriver.hxx>
00049 #include <GEOMImpl_TorusDriver.hxx>
00050 #include <GEOMImpl_PrismDriver.hxx>
00051 #include <GEOMImpl_PipeDriver.hxx>
00052 #include <GEOMImpl_RevolutionDriver.hxx>
00053 #include <GEOMImpl_ShapeDriver.hxx>
00054 #include <GEOMImpl_FillingDriver.hxx>
00055 #include <GEOMImpl_ThruSectionsDriver.hxx>
00056 
00057 #include <GEOMImpl_IBox.hxx>
00058 #include <GEOMImpl_IFace.hxx>
00059 #include <GEOMImpl_IDisk.hxx>
00060 #include <GEOMImpl_ICylinder.hxx>
00061 #include <GEOMImpl_ICone.hxx>
00062 #include <GEOMImpl_ISphere.hxx>
00063 #include <GEOMImpl_ITorus.hxx>
00064 #include <GEOMImpl_IPrism.hxx>
00065 #include <GEOMImpl_IPipe.hxx>
00066 #include <GEOMImpl_IRevolution.hxx>
00067 #include <GEOMImpl_IFilling.hxx>
00068 #include <GEOMImpl_IThruSections.hxx>
00069 #include <GEOMImpl_IPipeDiffSect.hxx>
00070 #include <GEOMImpl_IPipeShellSect.hxx>
00071 #include <GEOMImpl_IPipeBiNormal.hxx>
00072 
00073 #include <Precision.hxx>
00074 
00075 #include <Standard_Failure.hxx>
00076 #include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
00077 
00078 //=============================================================================
00082 //=============================================================================
00083 GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations (GEOM_Engine* theEngine, int theDocID)
00084 : GEOM_IOperations(theEngine, theDocID)
00085 {
00086   MESSAGE("GEOMImpl_I3DPrimOperations::GEOMImpl_I3DPrimOperations");
00087 }
00088 
00089 //=============================================================================
00093 //=============================================================================
00094 GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations()
00095 {
00096   MESSAGE("GEOMImpl_I3DPrimOperations::~GEOMImpl_I3DPrimOperations");
00097 }
00098 
00099 
00100 //=============================================================================
00104 //=============================================================================
00105 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxDXDYDZ (double theDX, double theDY, double theDZ)
00106 {
00107   SetErrorCode(KO);
00108 
00109   //Add a new Box object
00110   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
00111 
00112   //Add a new Box function with DX_DY_DZ parameters
00113   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_DX_DY_DZ);
00114   if (aFunction.IsNull()) return NULL;
00115 
00116   //Check if the function is set correctly
00117   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return NULL;
00118 
00119   GEOMImpl_IBox aBI (aFunction);
00120 
00121   aBI.SetDX(theDX);
00122   aBI.SetDY(theDY);
00123   aBI.SetDZ(theDZ);
00124 
00125   //Compute the box value
00126   try {
00127 #if OCC_VERSION_LARGE > 0x06010000
00128     OCC_CATCH_SIGNALS;
00129 #endif
00130     if (!GetSolver()->ComputeFunction(aFunction)) {
00131       SetErrorCode("Box driver failed");
00132       return NULL;
00133     }
00134   }
00135   catch (Standard_Failure) {
00136     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00137     SetErrorCode(aFail->GetMessageString());
00138     return NULL;
00139   }
00140 
00141   //Make a Python command
00142   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxDXDYDZ("
00143     << theDX << ", " << theDY << ", " << theDZ << ")";
00144 
00145   SetErrorCode(OK);
00146   return aBox;
00147 }
00148 
00149 
00150 //=============================================================================
00154 //=============================================================================
00155 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Object) thePnt1,
00156                                                                Handle(GEOM_Object) thePnt2)
00157 {
00158   SetErrorCode(KO);
00159 
00160   if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;
00161 
00162   //Add a new Box object
00163   Handle(GEOM_Object) aBox = GetEngine()->AddObject(GetDocID(), GEOM_BOX);
00164 
00165   //Add a new Box function for creation a box relatively to two points
00166   Handle(GEOM_Function) aFunction = aBox->AddFunction(GEOMImpl_BoxDriver::GetID(), BOX_TWO_PNT);
00167   if (aFunction.IsNull()) return NULL;
00168 
00169   //Check if the function is set correctly
00170   if (aFunction->GetDriverGUID() != GEOMImpl_BoxDriver::GetID()) return aBox;
00171 
00172   GEOMImpl_IBox aBI (aFunction);
00173 
00174   Handle(GEOM_Function) aRefFunction1 = thePnt1->GetLastFunction();
00175   Handle(GEOM_Function) aRefFunction2 = thePnt2->GetLastFunction();
00176 
00177   if (aRefFunction1.IsNull() || aRefFunction2.IsNull()) return aBox;
00178 
00179   aBI.SetRef1(aRefFunction1);
00180   aBI.SetRef2(aRefFunction2);
00181 
00182   //Compute the Box value
00183   try {
00184 #if OCC_VERSION_LARGE > 0x06010000
00185     OCC_CATCH_SIGNALS;
00186 #endif
00187     if (!GetSolver()->ComputeFunction(aFunction)) {
00188       SetErrorCode("Box driver failed");
00189       return NULL;
00190     }
00191   }
00192   catch (Standard_Failure) {
00193     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00194     SetErrorCode(aFail->GetMessageString());
00195     return NULL;
00196   }
00197 
00198   //Make a Python command
00199   GEOM::TPythonDump(aFunction) << aBox << " = geompy.MakeBoxTwoPnt("
00200     << thePnt1 << ", " << thePnt2 << ")";
00201 
00202   SetErrorCode(OK);
00203   return aBox;
00204 }
00205 
00206 //=============================================================================
00210 //=============================================================================
00211 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation)
00212 {
00213   SetErrorCode(KO);
00214 
00215   if (theH == 0 || theW == 0) return NULL;
00216 
00217   //Add a new Face object
00218   Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
00219 
00220   //Add a new Box function for creation a box relatively to two points
00221   Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W);
00222   if (aFunction.IsNull()) return NULL;
00223 
00224   //Check if the function is set correctly
00225   if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
00226 
00227   GEOMImpl_IFace aFI (aFunction);
00228 
00229   aFI.SetH(theH);
00230   aFI.SetW(theW);
00231   aFI.SetOrientation(theOrientation);
00232 
00233   //Compute the Face
00234   try {
00235 #if OCC_VERSION_LARGE > 0x06010000
00236     OCC_CATCH_SIGNALS;
00237 #endif
00238     if (!GetSolver()->ComputeFunction(aFunction)) {
00239       SetErrorCode("Face driver failed");
00240       return NULL;
00241     }
00242   }
00243   catch (Standard_Failure) {
00244     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00245     SetErrorCode(aFail->GetMessageString());
00246     return NULL;
00247   }
00248 
00249   //Make a Python command
00250   GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW("
00251     << theH << ", " << theW << ", " << theOrientation << ")";
00252 
00253   SetErrorCode(OK);
00254   return aFace;
00255 }
00256 
00257 //=============================================================================
00261 //=============================================================================
00262 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj,
00263                                                                double theH, double theW)
00264 {
00265   SetErrorCode(KO);
00266 
00267   if (theObj.IsNull()) return NULL;
00268 
00269   //Add a new Face object
00270   Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
00271 
00272   //Add a new Box function for creation a box relatively to two points
00273   Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W);
00274   if (aFunction.IsNull()) return NULL;
00275 
00276   //Check if the function is set correctly
00277   if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace;
00278 
00279   GEOMImpl_IFace aFI (aFunction);
00280 
00281   Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction();
00282 
00283   if (aRefFunction1.IsNull())
00284     return aFace;
00285 
00286   aFI.SetRef1(aRefFunction1);
00287   aFI.SetH(theH);
00288   aFI.SetW(theW);
00289 
00290   //Compute the Face
00291   try {
00292 #if OCC_VERSION_LARGE > 0x06010000
00293     OCC_CATCH_SIGNALS;
00294 #endif
00295     if (!GetSolver()->ComputeFunction(aFunction)) {
00296       SetErrorCode("Face driver failed");
00297       return NULL;
00298     }
00299   }
00300   catch (Standard_Failure) {
00301     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00302     SetErrorCode(aFail->GetMessageString());
00303     return NULL;
00304   }
00305 
00306   //Make a Python command
00307   GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW("
00308     << theObj << ", " << theH << ", " << theW << ")";
00309 
00310   SetErrorCode(OK);
00311   return aFace;
00312 }
00313 
00314 //=============================================================================
00318 //=============================================================================
00319 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR
00320       (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR)
00321 {
00322   SetErrorCode(KO);
00323 
00324   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
00325 
00326   //Add a new Disk object
00327   Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
00328 
00329   //Add a new Disk function for creation a disk relatively to point and vector
00330   Handle(GEOM_Function) aFunction =
00331     aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R);
00332   if (aFunction.IsNull()) return NULL;
00333 
00334   //Check if the function is set correctly
00335   if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
00336 
00337   GEOMImpl_IDisk aCI (aFunction);
00338 
00339   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
00340   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
00341 
00342   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
00343 
00344   aCI.SetCenter(aRefPnt);
00345   aCI.SetVector(aRefVec);
00346   aCI.SetRadius(theR);
00347 
00348   //Compute the Disk value
00349   try {
00350 #if OCC_VERSION_LARGE > 0x06010000
00351     OCC_CATCH_SIGNALS;
00352 #endif
00353     if (!GetSolver()->ComputeFunction(aFunction)) {
00354       SetErrorCode("Disk driver failed");
00355       return NULL;
00356     }
00357   }
00358   catch (Standard_Failure) {
00359     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00360     SetErrorCode(aFail->GetMessageString());
00361     return NULL;
00362   }
00363 
00364   //Make a Python command
00365   GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR("
00366     << thePnt << ", " << theVec << ", " << theR << ")";
00367 
00368   SetErrorCode(OK);
00369   return aDisk;
00370 }
00371 
00372 //=============================================================================
00376 //=============================================================================
00377 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1,
00378                                                                   Handle(GEOM_Object) thePnt2,
00379                                                                   Handle(GEOM_Object) thePnt3)
00380 {
00381   SetErrorCode(KO);
00382 
00383   if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL;
00384 
00385   //Add a new Disk object
00386   Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
00387 
00388   //Add a new Disk function for creation a disk relatively to three points
00389   Handle(GEOM_Function) aFunction =
00390     aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT);
00391   if (aFunction.IsNull()) return NULL;
00392 
00393   //Check if the function is set correctly
00394   if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL;
00395 
00396   GEOMImpl_IDisk aCI (aFunction);
00397 
00398   Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction();
00399   Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction();
00400   Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction();
00401 
00402   if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL;
00403 
00404   aCI.SetPoint1(aRefPnt1);
00405   aCI.SetPoint2(aRefPnt2);
00406   aCI.SetPoint3(aRefPnt3);
00407 
00408   //Compute the Disk value
00409   try {
00410 #if OCC_VERSION_LARGE > 0x06010000
00411     OCC_CATCH_SIGNALS;
00412 #endif
00413     if (!GetSolver()->ComputeFunction(aFunction)) {
00414       SetErrorCode("Disk driver failed");
00415       return NULL;
00416     }
00417   }
00418   catch (Standard_Failure) {
00419     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00420     SetErrorCode(aFail->GetMessageString());
00421     return NULL;
00422   }
00423 
00424   //Make a Python command
00425   GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt("
00426     << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")";
00427 
00428   SetErrorCode(OK);
00429   return aDisk;
00430 }
00431 
00432 //=============================================================================
00436 //=============================================================================
00437 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation)
00438 {
00439   SetErrorCode(KO);
00440 
00441   if (theR == 0 ) return NULL;
00442 
00443   //Add a new Disk object
00444   Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE);
00445 
00446   //Add a new Box function for creation a box relatively to two points
00447   Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R);
00448   if (aFunction.IsNull()) return NULL;
00449 
00450   //Check if the function is set correctly
00451   if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk;
00452 
00453   GEOMImpl_IDisk aDI (aFunction);
00454 
00455   aDI.SetRadius(theR);
00456   aDI.SetOrientation(theOrientation);
00457 
00458   //Compute the Disk
00459   try {
00460 #if OCC_VERSION_LARGE > 0x06010000
00461     OCC_CATCH_SIGNALS;
00462 #endif
00463     if (!GetSolver()->ComputeFunction(aFunction)) {
00464       SetErrorCode("Disk driver failed");
00465       return NULL;
00466     }
00467   }
00468   catch (Standard_Failure) {
00469     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00470     SetErrorCode(aFail->GetMessageString());
00471     return NULL;
00472   }
00473 
00474   //Make a Python command
00475   GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR("
00476     << theR << ", " << theOrientation << ")";
00477 
00478   SetErrorCode(OK);
00479   return aDisk;
00480 }
00481 
00482 //=============================================================================
00486 //=============================================================================
00487 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderRH (double theR, double theH)
00488 {
00489   SetErrorCode(KO);
00490 
00491   //Add a new Cylinder object
00492   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
00493 
00494   //Add a new Cylinder function with R and H parameters
00495   Handle(GEOM_Function) aFunction = aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_R_H);
00496   if (aFunction.IsNull()) return NULL;
00497 
00498   //Check if the function is set correctly
00499   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
00500 
00501   GEOMImpl_ICylinder aCI (aFunction);
00502 
00503   aCI.SetR(theR);
00504   aCI.SetH(theH);
00505 
00506   //Compute the Cylinder value
00507   try {
00508 #if OCC_VERSION_LARGE > 0x06010000
00509     OCC_CATCH_SIGNALS;
00510 #endif
00511     if (!GetSolver()->ComputeFunction(aFunction)) {
00512       SetErrorCode("Cylinder driver failed");
00513       return NULL;
00514     }
00515   }
00516   catch (Standard_Failure) {
00517     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00518     SetErrorCode(aFail->GetMessageString());
00519     return NULL;
00520   }
00521 
00522   //Make a Python command
00523   GEOM::TPythonDump(aFunction) << aCylinder
00524     << " = geompy.MakeCylinderRH(" << theR << ", " << theH << ")";
00525 
00526   SetErrorCode(OK);
00527   return aCylinder;
00528 }
00529 
00530 
00531 //=============================================================================
00535 //=============================================================================
00536 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt,
00537                                                                       Handle(GEOM_Object) theVec,
00538                                                                       double theR, double theH)
00539 {
00540   SetErrorCode(KO);
00541 
00542   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
00543 
00544   //Add a new Cylinder object
00545   Handle(GEOM_Object) aCylinder = GetEngine()->AddObject(GetDocID(), GEOM_CYLINDER);
00546 
00547   //Add a new Cylinder function for creation a cylinder relatively to point and vector
00548   Handle(GEOM_Function) aFunction =
00549     aCylinder->AddFunction(GEOMImpl_CylinderDriver::GetID(), CYLINDER_PNT_VEC_R_H);
00550   if (aFunction.IsNull()) return NULL;
00551 
00552   //Check if the function is set correctly
00553   if (aFunction->GetDriverGUID() != GEOMImpl_CylinderDriver::GetID()) return NULL;
00554 
00555   GEOMImpl_ICylinder aCI (aFunction);
00556 
00557   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
00558   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
00559 
00560   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
00561 
00562   aCI.SetPoint(aRefPnt);
00563   aCI.SetVector(aRefVec);
00564   aCI.SetR(theR);
00565   aCI.SetH(theH);
00566 
00567   //Compute the Cylinder value
00568   try {
00569 #if OCC_VERSION_LARGE > 0x06010000
00570     OCC_CATCH_SIGNALS;
00571 #endif
00572     if (!GetSolver()->ComputeFunction(aFunction)) {
00573       SetErrorCode("Cylinder driver failed");
00574       return NULL;
00575     }
00576   }
00577   catch (Standard_Failure) {
00578     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00579     SetErrorCode(aFail->GetMessageString());
00580     return NULL;
00581   }
00582 
00583   //Make a Python command
00584   GEOM::TPythonDump(aFunction) << aCylinder << " = geompy.MakeCylinder("
00585     << thePnt << ", " << theVec << ", " << theR << ", " << theH << ")";
00586 
00587   SetErrorCode(OK);
00588   return aCylinder;
00589 }
00590 
00591 
00592 //=============================================================================
00596 //=============================================================================
00597 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConeR1R2H (double theR1, double theR2,
00598                                                                double theH)
00599 {
00600   SetErrorCode(KO);
00601 
00602   //Add a new Cone object
00603   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
00604 
00605   //Add a new Cone function with R and H parameters
00606   Handle(GEOM_Function) aFunction =
00607     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_R1_R2_H);
00608   if (aFunction.IsNull()) return NULL;
00609 
00610   //Check if the function is set correctly
00611   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
00612 
00613   GEOMImpl_ICone aCI (aFunction);
00614 
00615   aCI.SetR1(theR1);
00616   aCI.SetR2(theR2);
00617   aCI.SetH(theH);
00618 
00619   //Compute the Cone value
00620   try {
00621 #if OCC_VERSION_LARGE > 0x06010000
00622     OCC_CATCH_SIGNALS;
00623 #endif
00624     if (!GetSolver()->ComputeFunction(aFunction)) {
00625       SetErrorCode("Cone driver failed");
00626       return NULL;
00627     }
00628   }
00629   catch (Standard_Failure) {
00630     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00631     SetErrorCode(aFail->GetMessageString());
00632     return NULL;
00633   }
00634 
00635   //Make a Python command
00636   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeConeR1R2H("
00637     << theR1 << ", " << theR2 << ", " << theH << ")";
00638 
00639   SetErrorCode(OK);
00640   return aCone;
00641 }
00642 
00643 
00644 //=============================================================================
00648 //=============================================================================
00649 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt,
00650                                                                      Handle(GEOM_Object) theVec,
00651                                                                      double theR1, double theR2,
00652                                                                      double theH)
00653 {
00654   SetErrorCode(KO);
00655 
00656   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
00657 
00658   //Add a new Cone object
00659   Handle(GEOM_Object) aCone = GetEngine()->AddObject(GetDocID(), GEOM_CONE);
00660 
00661   //Add a new Cone function for creation a cone relatively to point and vector
00662   Handle(GEOM_Function) aFunction =
00663     aCone->AddFunction(GEOMImpl_ConeDriver::GetID(), CONE_PNT_VEC_R1_R2_H);
00664   if (aFunction.IsNull()) return NULL;
00665 
00666   //Check if the function is set correctly
00667   if (aFunction->GetDriverGUID() != GEOMImpl_ConeDriver::GetID()) return NULL;
00668 
00669   GEOMImpl_ICone aCI (aFunction);
00670 
00671   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
00672   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
00673 
00674   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
00675 
00676   aCI.SetPoint(aRefPnt);
00677   aCI.SetVector(aRefVec);
00678   aCI.SetR1(theR1);
00679   aCI.SetR2(theR2);
00680   aCI.SetH(theH);
00681 
00682   //Compute the Cone value
00683   try {
00684 #if OCC_VERSION_LARGE > 0x06010000
00685     OCC_CATCH_SIGNALS;
00686 #endif
00687     if (!GetSolver()->ComputeFunction(aFunction)) {
00688       SetErrorCode("Cone driver failed");
00689       return NULL;
00690     }
00691   }
00692   catch (Standard_Failure) {
00693     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00694     SetErrorCode(aFail->GetMessageString());
00695     return NULL;
00696   }
00697 
00698   //Make a Python command
00699   GEOM::TPythonDump(aFunction) << aCone << " = geompy.MakeCone(" << thePnt
00700     << ", " << theVec << ", " << theR1 << ", " << theR2 << ", " << theH << ")";
00701 
00702   SetErrorCode(OK);
00703   return aCone;
00704 }
00705 
00706 
00707 //=============================================================================
00711 //=============================================================================
00712 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSphereR (double theR)
00713 {
00714   SetErrorCode(KO);
00715 
00716   //Add a new Sphere object
00717   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
00718 
00719   //Add a new Sphere function with R parameter
00720   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_R);
00721   if (aFunction.IsNull()) return NULL;
00722 
00723   //Check if the function is set correctly
00724   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
00725 
00726   GEOMImpl_ISphere aCI (aFunction);
00727 
00728   aCI.SetR(theR);
00729 
00730   //Compute the Sphere value
00731   try {
00732 #if OCC_VERSION_LARGE > 0x06010000
00733     OCC_CATCH_SIGNALS;
00734 #endif
00735     if (!GetSolver()->ComputeFunction(aFunction)) {
00736       SetErrorCode("Sphere driver failed");
00737       return NULL;
00738     }
00739   }
00740   catch (Standard_Failure) {
00741     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00742     SetErrorCode(aFail->GetMessageString());
00743     return NULL;
00744   }
00745 
00746   //Make a Python command
00747   GEOM::TPythonDump(aFunction) << aSphere << " = geompy.MakeSphereR(" << theR << ")";
00748 
00749   SetErrorCode(OK);
00750   return aSphere;
00751 }
00752 
00753 
00754 //=============================================================================
00758 //=============================================================================
00759 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSpherePntR (Handle(GEOM_Object) thePnt,
00760                                                                 double theR)
00761 {
00762   SetErrorCode(KO);
00763 
00764   if (thePnt.IsNull()) return NULL;
00765 
00766   //Add a new Point object
00767   Handle(GEOM_Object) aSphere = GetEngine()->AddObject(GetDocID(), GEOM_SPHERE);
00768 
00769   //Add a new Sphere function for creation a sphere relatively to point
00770   Handle(GEOM_Function) aFunction = aSphere->AddFunction(GEOMImpl_SphereDriver::GetID(), SPHERE_PNT_R);
00771   if (aFunction.IsNull()) return NULL;
00772 
00773   //Check if the function is set correctly
00774   if (aFunction->GetDriverGUID() != GEOMImpl_SphereDriver::GetID()) return NULL;
00775 
00776   GEOMImpl_ISphere aCI (aFunction);
00777 
00778   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
00779 
00780   if (aRefPnt.IsNull()) return NULL;
00781 
00782   aCI.SetPoint(aRefPnt);
00783   aCI.SetR(theR);
00784 
00785   //Compute the Sphere value
00786   try {
00787 #if OCC_VERSION_LARGE > 0x06010000
00788     OCC_CATCH_SIGNALS;
00789 #endif
00790     if (!GetSolver()->ComputeFunction(aFunction)) {
00791       SetErrorCode("Sphere driver failed");
00792       return NULL;
00793     }
00794   }
00795   catch (Standard_Failure) {
00796     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00797     SetErrorCode(aFail->GetMessageString());
00798     return NULL;
00799   }
00800 
00801   //Make a Python command
00802   GEOM::TPythonDump(aFunction) << aSphere
00803     << " = geompy.MakeSpherePntR(" << thePnt << ", " << theR << ")";
00804 
00805   SetErrorCode(OK);
00806   return aSphere;
00807 }
00808 
00809 
00810 //=============================================================================
00814 //=============================================================================
00815 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusRR
00816                                            (double theRMajor, double theRMinor)
00817 {
00818   SetErrorCode(KO);
00819 
00820   //Add a new Torus object
00821   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
00822 
00823   //Add a new Torus function
00824   Handle(GEOM_Function) aFunction =
00825     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_RR);
00826   if (aFunction.IsNull()) return NULL;
00827 
00828   //Check if the function is set correctly
00829   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
00830 
00831   GEOMImpl_ITorus aCI (aFunction);
00832 
00833   aCI.SetRMajor(theRMajor);
00834   aCI.SetRMinor(theRMinor);
00835 
00836   //Compute the Torus value
00837   try {
00838 #if OCC_VERSION_LARGE > 0x06010000
00839     OCC_CATCH_SIGNALS;
00840 #endif
00841     if (!GetSolver()->ComputeFunction(aFunction)) {
00842       SetErrorCode("Torus driver failed");
00843       return NULL;
00844     }
00845   }
00846   catch (Standard_Failure) {
00847     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00848     SetErrorCode(aFail->GetMessageString());
00849     return NULL;
00850   }
00851 
00852   //Make a Python command
00853   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorusRR("
00854     << theRMajor << ", " << theRMinor << ")";
00855 
00856   SetErrorCode(OK);
00857   return anEll;
00858 }
00859 
00860 //=============================================================================
00864 //=============================================================================
00865 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeTorusPntVecRR
00866                        (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec,
00867                         double theRMajor, double theRMinor)
00868 {
00869   SetErrorCode(KO);
00870 
00871   if (thePnt.IsNull() || theVec.IsNull()) return NULL;
00872 
00873   //Add a new Torus object
00874   Handle(GEOM_Object) anEll = GetEngine()->AddObject(GetDocID(), GEOM_TORUS);
00875 
00876   //Add a new Torus function
00877   Handle(GEOM_Function) aFunction =
00878     anEll->AddFunction(GEOMImpl_TorusDriver::GetID(), TORUS_PNT_VEC_RR);
00879   if (aFunction.IsNull()) return NULL;
00880 
00881   //Check if the function is set correctly
00882   if (aFunction->GetDriverGUID() != GEOMImpl_TorusDriver::GetID()) return NULL;
00883 
00884   GEOMImpl_ITorus aCI (aFunction);
00885 
00886   Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction();
00887   Handle(GEOM_Function) aRefVec = theVec->GetLastFunction();
00888 
00889   if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL;
00890 
00891   aCI.SetCenter(aRefPnt);
00892   aCI.SetVector(aRefVec);
00893   aCI.SetRMajor(theRMajor);
00894   aCI.SetRMinor(theRMinor);
00895 
00896   //Compute the Torus value
00897   try {
00898 #if OCC_VERSION_LARGE > 0x06010000
00899     OCC_CATCH_SIGNALS;
00900 #endif
00901     if (!GetSolver()->ComputeFunction(aFunction)) {
00902       SetErrorCode("Torus driver failed");
00903       return NULL;
00904     }
00905   }
00906   catch (Standard_Failure) {
00907     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00908     SetErrorCode(aFail->GetMessageString());
00909     return NULL;
00910   }
00911 
00912   //Make a Python command
00913   GEOM::TPythonDump(aFunction) << anEll << " = geompy.MakeTorus(" << thePnt
00914     << ", " << theVec << ", " << theRMajor << ", " << theRMinor << ")";
00915 
00916   SetErrorCode(OK);
00917   return anEll;
00918 }
00919 
00920 
00921 //=============================================================================
00925 //=============================================================================
00926 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Object) theBase,
00927                                                                Handle(GEOM_Object) theVec,
00928                                                                double theH, double theScaleFactor)
00929 {
00930   SetErrorCode(KO);
00931 
00932   if (theBase.IsNull() || theVec.IsNull()) return NULL;
00933 
00934   //Add a new Prism object
00935   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
00936 
00937   //Add a new Prism function for creation a Prism relatively to vector
00938   Handle(GEOM_Function) aFunction =
00939     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H);
00940   if (aFunction.IsNull()) return NULL;
00941 
00942   //Check if the function is set correctly
00943   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
00944 
00945   GEOMImpl_IPrism aCI (aFunction);
00946 
00947   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
00948   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
00949 
00950   if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
00951 
00952   aCI.SetBase(aRefBase);
00953   aCI.SetVector(aRefVec);
00954   aCI.SetH(theH);
00955   aCI.SetScale(theScaleFactor);
00956 
00957   //Compute the Prism value
00958   try {
00959 #if OCC_VERSION_LARGE > 0x06010000
00960     OCC_CATCH_SIGNALS;
00961 #endif
00962     if (!GetSolver()->ComputeFunction(aFunction)) {
00963       //SetErrorCode("Prism driver failed");
00964       SetErrorCode("Extrusion can not be created, check input data");
00965       return NULL;
00966     }
00967   }
00968   catch (Standard_Failure) {
00969     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
00970     SetErrorCode(aFail->GetMessageString());
00971     return NULL;
00972   }
00973 
00974   //Make a Python command
00975   GEOM::TPythonDump pd (aFunction);
00976   pd << aPrism << " = geompy.MakePrismVecH(" << theBase << ", " << theVec << ", " << theH;
00977   if (theScaleFactor > Precision::Confusion())
00978     pd << ", " << theScaleFactor << ")";
00979   else
00980     pd << ")";
00981 
00982   SetErrorCode(OK);
00983   return aPrism;
00984 }
00985 
00986 //=============================================================================
00990 //=============================================================================
00991 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase,
00992                                                                     Handle(GEOM_Object) theVec,
00993                                                                     double theH)
00994 {
00995   SetErrorCode(KO);
00996 
00997   if (theBase.IsNull() || theVec.IsNull()) return NULL;
00998 
00999   //Add a new Prism object
01000   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
01001 
01002   //Add a new Prism function for creation a Prism relatively to vector
01003   Handle(GEOM_Function) aFunction =
01004     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_VEC_H_2WAYS);
01005   if (aFunction.IsNull()) return NULL;
01006 
01007   //Check if the function is set correctly
01008   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01009 
01010   GEOMImpl_IPrism aCI (aFunction);
01011 
01012   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01013   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
01014 
01015   if (aRefBase.IsNull() || aRefVec.IsNull()) return NULL;
01016 
01017   aCI.SetBase(aRefBase);
01018   aCI.SetVector(aRefVec);
01019   aCI.SetH(theH);
01020 
01021   //Compute the Prism value
01022   try {
01023 #if OCC_VERSION_LARGE > 0x06010000
01024     OCC_CATCH_SIGNALS;
01025 #endif
01026     if (!GetSolver()->ComputeFunction(aFunction)) {
01027       //SetErrorCode("Prism driver failed");
01028       SetErrorCode("Extrusion can not be created, check input data");
01029       return NULL;
01030     }
01031   }
01032   catch (Standard_Failure) {
01033     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01034     SetErrorCode(aFail->GetMessageString());
01035     return NULL;
01036   }
01037 
01038   //Make a Python command
01039   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismVecH2Ways("
01040     << theBase << ", " << theVec << ", " << theH << ")";
01041 
01042   SetErrorCode(OK);
01043   return aPrism;
01044 }
01045 
01046 //=============================================================================
01050 //=============================================================================
01051 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt
01052        (Handle(GEOM_Object) theBase,
01053         Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2,
01054         double theScaleFactor)
01055 {
01056   SetErrorCode(KO);
01057 
01058   if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
01059 
01060   //Add a new Prism object
01061   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
01062 
01063   //Add a new Prism function for creation a Prism relatively to two points
01064   Handle(GEOM_Function) aFunction =
01065     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT);
01066   if (aFunction.IsNull()) return NULL;
01067 
01068   //Check if the function is set correctly
01069   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01070 
01071   GEOMImpl_IPrism aCI (aFunction);
01072 
01073   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01074   Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
01075   Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
01076 
01077   if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
01078 
01079   aCI.SetBase(aRefBase);
01080   aCI.SetFirstPoint(aRefPnt1);
01081   aCI.SetLastPoint(aRefPnt2);
01082   aCI.SetScale(theScaleFactor);
01083 
01084   //Compute the Prism value
01085   try {
01086 #if OCC_VERSION_LARGE > 0x06010000
01087     OCC_CATCH_SIGNALS;
01088 #endif
01089     if (!GetSolver()->ComputeFunction(aFunction)) {
01090       //SetErrorCode("Prism driver failed");
01091       SetErrorCode("Extrusion can not be created, check input data");
01092       return NULL;
01093     }
01094   }
01095   catch (Standard_Failure) {
01096     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01097     SetErrorCode(aFail->GetMessageString());
01098     return NULL;
01099   }
01100 
01101   //Make a Python command
01102   GEOM::TPythonDump pd (aFunction);
01103   pd << aPrism << " = geompy.MakePrism(" << theBase << ", " << thePoint1 << ", " << thePoint2;
01104   if (theScaleFactor > Precision::Confusion())
01105     pd << ", " << theScaleFactor << ")";
01106   else
01107     pd << ")";
01108 
01109   SetErrorCode(OK);
01110   return aPrism;
01111 }
01112 
01113 //=============================================================================
01117 //=============================================================================
01118 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways
01119        (Handle(GEOM_Object) theBase,
01120         Handle(GEOM_Object) thePoint1, Handle(GEOM_Object) thePoint2)
01121 {
01122   SetErrorCode(KO);
01123 
01124   if (theBase.IsNull() || thePoint1.IsNull() || thePoint2.IsNull()) return NULL;
01125 
01126   //Add a new Prism object
01127   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
01128 
01129   //Add a new Prism function for creation a Prism relatively to two points
01130   Handle(GEOM_Function) aFunction =
01131     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_TWO_PNT_2WAYS);
01132   if (aFunction.IsNull()) return NULL;
01133 
01134   //Check if the function is set correctly
01135   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01136 
01137   GEOMImpl_IPrism aCI (aFunction);
01138 
01139   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01140   Handle(GEOM_Function) aRefPnt1 = thePoint1->GetLastFunction();
01141   Handle(GEOM_Function) aRefPnt2 = thePoint2->GetLastFunction();
01142 
01143   if (aRefBase.IsNull() || aRefPnt1.IsNull() || aRefPnt2.IsNull()) return NULL;
01144 
01145   aCI.SetBase(aRefBase);
01146   aCI.SetFirstPoint(aRefPnt1);
01147   aCI.SetLastPoint(aRefPnt2);
01148 
01149   //Compute the Prism value
01150   try {
01151 #if OCC_VERSION_LARGE > 0x06010000
01152     OCC_CATCH_SIGNALS;
01153 #endif
01154     if (!GetSolver()->ComputeFunction(aFunction)) {
01155       //SetErrorCode("Prism driver failed");
01156       SetErrorCode("Extrusion can not be created, check input data");
01157       return NULL;
01158     }
01159   }
01160   catch (Standard_Failure) {
01161     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01162     SetErrorCode(aFail->GetMessageString());
01163     return NULL;
01164   }
01165 
01166   //Make a Python command
01167   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrism2Ways("
01168     << theBase << ", " << thePoint1 << ", " << thePoint2 << ")";
01169 
01170   SetErrorCode(OK);
01171   return aPrism;
01172 }
01173 
01174 //=============================================================================
01178 //=============================================================================
01179 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ
01180        (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ,
01181         double theScaleFactor)
01182 {
01183   SetErrorCode(KO);
01184 
01185   if (theBase.IsNull()) return NULL;
01186 
01187   //Add a new Prism object
01188   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
01189 
01190   //Add a new Prism function for creation a Prism by DXDYDZ
01191   Handle(GEOM_Function) aFunction =
01192     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ);
01193   if (aFunction.IsNull()) return NULL;
01194 
01195   //Check if the function is set correctly
01196   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01197 
01198   GEOMImpl_IPrism aCI (aFunction);
01199 
01200   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01201 
01202   if (aRefBase.IsNull()) return NULL;
01203 
01204   aCI.SetBase(aRefBase);
01205   aCI.SetDX(theDX);
01206   aCI.SetDY(theDY);
01207   aCI.SetDZ(theDZ);
01208   aCI.SetScale(theScaleFactor);
01209 
01210   //Compute the Prism value
01211   try {
01212 #if OCC_VERSION_LARGE > 0x06010000
01213     OCC_CATCH_SIGNALS;
01214 #endif
01215     if (!GetSolver()->ComputeFunction(aFunction)) {
01216       SetErrorCode("Extrusion can not be created, check input data");
01217       return NULL;
01218     }
01219   }
01220   catch (Standard_Failure) {
01221     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01222     SetErrorCode(aFail->GetMessageString());
01223     return NULL;
01224   }
01225 
01226   //Make a Python command
01227   GEOM::TPythonDump pd (aFunction);
01228   pd << aPrism << " = geompy.MakePrismDXDYDZ("
01229      << theBase << ", " << theDX << ", " << theDY << ", " << theDZ;
01230   if (theScaleFactor > Precision::Confusion())
01231     pd << ", " << theScaleFactor << ")";
01232   else
01233     pd << ")";
01234 
01235   SetErrorCode(OK);
01236   return aPrism;
01237 }
01238 
01239 //=============================================================================
01243 //=============================================================================
01244 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways
01245        (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ)
01246 {
01247   SetErrorCode(KO);
01248 
01249   if (theBase.IsNull()) return NULL;
01250 
01251   //Add a new Prism object
01252   Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM);
01253 
01254   //Add a new Prism function for creation a Prism by DXDYDZ
01255   Handle(GEOM_Function) aFunction =
01256     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS);
01257   if (aFunction.IsNull()) return NULL;
01258 
01259   //Check if the function is set correctly
01260   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01261 
01262   GEOMImpl_IPrism aCI (aFunction);
01263 
01264   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01265 
01266   if (aRefBase.IsNull()) return NULL;
01267 
01268   aCI.SetBase(aRefBase);
01269   aCI.SetDX(theDX);
01270   aCI.SetDY(theDY);
01271   aCI.SetDZ(theDZ);
01272 
01273   //Compute the Prism value
01274   try {
01275 #if OCC_VERSION_LARGE > 0x06010000
01276     OCC_CATCH_SIGNALS;
01277 #endif
01278     if (!GetSolver()->ComputeFunction(aFunction)) {
01279       SetErrorCode("Extrusion can not be created, check input data");
01280       return NULL;
01281     }
01282   }
01283   catch (Standard_Failure) {
01284     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01285     SetErrorCode(aFail->GetMessageString());
01286     return NULL;
01287   }
01288 
01289   //Make a Python command
01290   GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways("
01291     << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")";
01292 
01293   SetErrorCode(OK);
01294   return aPrism;
01295 }
01296 
01297 //=============================================================================
01301 //=============================================================================
01302 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDraftPrism
01303        (Handle(GEOM_Object) theInitShape ,Handle(GEOM_Object) theBase, double theHeight, double theAngle, bool theFuse)
01304 {
01305   SetErrorCode(KO);
01306 
01307   if (theBase.IsNull() || theInitShape.IsNull()) return NULL;
01308 
01309   Handle(GEOM_Object) aPrism = NULL;
01310   
01311   if ( theFuse )
01312   {
01313     //Add a new Extruded Boss object  
01314     aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_BOSS);
01315   }
01316   else
01317   { 
01318     //Add a new Extruded Cut object  
01319     aPrism = GetEngine()->AddObject(GetDocID(), GEOM_EXTRUDED_CUT);
01320   }
01321   
01322   //Add a new Prism function for the creation of a Draft Prism feature
01323   Handle(GEOM_Function) aFunction = 
01324     aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), DRAFT_PRISM_FEATURE);
01325   if (aFunction.IsNull()) return NULL;
01326   
01327   //Check if the function is set correctly
01328   if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL;
01329   
01330   GEOMImpl_IPrism aCI (aFunction);
01331 
01332   Handle(GEOM_Function) aRefInit = theInitShape->GetLastFunction();
01333   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01334  
01335   if (aRefBase.IsNull() || aRefInit.IsNull()) return NULL;
01336   
01337   // Set parameters 
01338   aCI.SetBase(aRefBase);
01339   aCI.SetInitShape(aRefInit);
01340   aCI.SetH(theHeight);
01341   aCI.SetDraftAngle(theAngle);
01342   if ( theFuse )
01343     aCI.SetFuseFlag(1);
01344   else
01345     aCI.SetFuseFlag(0);
01346   
01347   //Compute the Draft Prism Feature value
01348   try {
01349 #if OCC_VERSION_LARGE > 0x06010000
01350     OCC_CATCH_SIGNALS;
01351 #endif
01352     if (!GetSolver()->ComputeFunction(aFunction)) {
01353       SetErrorCode("Extrusion can not be created, check input data");
01354       return NULL;
01355     }
01356   }
01357   catch (Standard_Failure) {
01358     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01359     SetErrorCode(aFail->GetMessageString());
01360     return NULL;
01361   }
01362   
01363   //Make a Python command
01364   if(theFuse)
01365   {
01366     GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedBoss("
01367       << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
01368   }
01369   else
01370   {   
01371     GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakeExtrudedCut("
01372       << theInitShape << ", " << theBase << ", " << theHeight << ", " << theAngle << ")";
01373   }
01374 
01375   SetErrorCode(OK);
01376   return aPrism;
01377 }
01378 
01379 //=============================================================================
01383 //=============================================================================
01384 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipe (Handle(GEOM_Object) theBase,
01385                                                           Handle(GEOM_Object) thePath)
01386 {
01387   SetErrorCode(KO);
01388 
01389   if (theBase.IsNull() || thePath.IsNull()) return NULL;
01390 
01391   //Add a new Pipe object
01392   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
01393 
01394   //Add a new Pipe function
01395   Handle(GEOM_Function) aFunction =
01396     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BASE_PATH);
01397   if (aFunction.IsNull()) return NULL;
01398 
01399   //Check if the function is set correctly
01400   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
01401 
01402   GEOMImpl_IPipe aCI (aFunction);
01403 
01404   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01405   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
01406 
01407   if (aRefBase.IsNull() || aRefPath.IsNull()) return NULL;
01408 
01409   aCI.SetBase(aRefBase);
01410   aCI.SetPath(aRefPath);
01411 
01412   //Compute the Pipe value
01413   try {
01414 #if OCC_VERSION_LARGE > 0x06010000
01415     OCC_CATCH_SIGNALS;
01416 #endif
01417     if (!GetSolver()->ComputeFunction(aFunction)) {
01418       SetErrorCode("Pipe driver failed");
01419       return NULL;
01420     }
01421   }
01422   catch (Standard_Failure) {
01423     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01424     SetErrorCode(aFail->GetMessageString());
01425     return NULL;
01426   }
01427 
01428   //Make a Python command
01429   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipe("
01430     << theBase << ", " << thePath << ")";
01431 
01432   SetErrorCode(OK);
01433   return aPipe;
01434 }
01435 
01436 
01437 //=============================================================================
01441 //=============================================================================
01442 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(GEOM_Object) theBase,
01443                                                                          Handle(GEOM_Object) theAxis,
01444                                                                          double theAngle)
01445 {
01446   SetErrorCode(KO);
01447 
01448   if (theBase.IsNull() || theAxis.IsNull()) return NULL;
01449 
01450   //Add a new Revolution object
01451   Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
01452 
01453   //Add a new Revolution function for creation a revolution relatively to axis
01454   Handle(GEOM_Function) aFunction =
01455     aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE);
01456   if (aFunction.IsNull()) return NULL;
01457 
01458   //Check if the function is set correctly
01459   if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
01460 
01461   GEOMImpl_IRevolution aCI (aFunction);
01462 
01463   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01464   Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
01465 
01466   if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
01467 
01468   aCI.SetBase(aRefBase);
01469   aCI.SetAxis(aRefAxis);
01470   aCI.SetAngle(theAngle);
01471 
01472   //Compute the Revolution value
01473   try {
01474 #if OCC_VERSION_LARGE > 0x06010000
01475     OCC_CATCH_SIGNALS;
01476 #endif
01477     if (!GetSolver()->ComputeFunction(aFunction)) {
01478       SetErrorCode("Revolution driver failed");
01479       return NULL;
01480     }
01481   }
01482   catch (Standard_Failure) {
01483     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01484     SetErrorCode(aFail->GetMessageString());
01485     return NULL;
01486   }
01487 
01488   //Make a Python command
01489   GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
01490     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
01491 
01492   SetErrorCode(OK);
01493   return aRevolution;
01494 }
01495 
01496 //=============================================================================
01500 //=============================================================================
01501 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways
01502                    (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theAxis, double theAngle)
01503 {
01504   SetErrorCode(KO);
01505 
01506   if (theBase.IsNull() || theAxis.IsNull()) return NULL;
01507 
01508   //Add a new Revolution object
01509   Handle(GEOM_Object) aRevolution = GetEngine()->AddObject(GetDocID(), GEOM_REVOLUTION);
01510 
01511   //Add a new Revolution function for creation a revolution relatively to axis
01512   Handle(GEOM_Function) aFunction =
01513     aRevolution->AddFunction(GEOMImpl_RevolutionDriver::GetID(), REVOLUTION_BASE_AXIS_ANGLE_2WAYS);
01514   if (aFunction.IsNull()) return NULL;
01515 
01516   //Check if the function is set correctly
01517   if (aFunction->GetDriverGUID() != GEOMImpl_RevolutionDriver::GetID()) return NULL;
01518 
01519   GEOMImpl_IRevolution aCI (aFunction);
01520 
01521   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
01522   Handle(GEOM_Function) aRefAxis = theAxis->GetLastFunction();
01523 
01524   if (aRefBase.IsNull() || aRefAxis.IsNull()) return NULL;
01525 
01526   aCI.SetBase(aRefBase);
01527   aCI.SetAxis(aRefAxis);
01528   aCI.SetAngle(theAngle);
01529 
01530   //Compute the Revolution value
01531   try {
01532 #if OCC_VERSION_LARGE > 0x06010000
01533     OCC_CATCH_SIGNALS;
01534 #endif
01535     if (!GetSolver()->ComputeFunction(aFunction)) {
01536       SetErrorCode("Revolution driver failed");
01537       return NULL;
01538     }
01539   }
01540   catch (Standard_Failure) {
01541     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01542     SetErrorCode(aFail->GetMessageString());
01543     return NULL;
01544   }
01545 
01546   //Make a Python command
01547   GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution2Ways("
01548     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / M_PI << "*math.pi/180.0)";
01549 
01550   SetErrorCode(OK);
01551   return aRevolution;
01552 }
01553 
01554 //=============================================================================
01558 //=============================================================================
01559 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling
01560        (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg,
01561         double theTol2D, double theTol3D, int theNbIter,
01562         int theMethod, bool isApprox)
01563 {
01564   SetErrorCode(KO);
01565 
01566   if (theShape.IsNull()) return NULL;
01567 
01568   //Add a new Filling object
01569   Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING);
01570 
01571   //Add a new Filling function for creation a filling  from a compound
01572   Handle(GEOM_Function) aFunction = aFilling->AddFunction(GEOMImpl_FillingDriver::GetID(), BASIC_FILLING);
01573   if (aFunction.IsNull()) return NULL;
01574 
01575   //Check if the function is set correctly
01576   if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL;
01577 
01578   GEOMImpl_IFilling aFI (aFunction);
01579 
01580   Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
01581 
01582   if (aRefShape.IsNull()) return NULL;
01583 
01584   aFI.SetShape(aRefShape);
01585   aFI.SetMinDeg(theMinDeg);
01586   aFI.SetMaxDeg(theMaxDeg);
01587   aFI.SetTol2D(theTol2D);
01588   aFI.SetTol3D(theTol3D);
01589   aFI.SetNbIter(theNbIter);
01590   aFI.SetApprox(isApprox);
01591   aFI.SetMethod(theMethod);
01592 
01593   //Compute the Solid value
01594   try {
01595 #if OCC_VERSION_LARGE > 0x06010000
01596     OCC_CATCH_SIGNALS;
01597 #endif
01598     if (!GetSolver()->ComputeFunction(aFunction)) {
01599       SetErrorCode("Filling driver failed");
01600       return NULL;
01601     }
01602   }
01603   catch (Standard_Failure) {
01604     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01605     if (strcmp(aFail->GetMessageString(), "Geom_BSplineSurface") == 0)
01606       SetErrorCode("B-Spline surface construction failed");
01607     else
01608       SetErrorCode(aFail->GetMessageString());
01609     return NULL;
01610   }
01611 
01612   //Make a Python command
01613   GEOM::TPythonDump pd (aFunction);
01614   pd << aFilling << " = geompy.MakeFilling("
01615      << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", "
01616      << theTol2D << ", " << theTol3D << ", " << theNbIter  << ", ";
01617   if( theMethod==1 ) pd << "GEOM.FOM_UseOri";
01618   else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect";
01619   else pd << "GEOM.FOM_Default";
01620   if(isApprox)
01621     pd << ", " << isApprox ;
01622   pd << ")";
01623 
01624   SetErrorCode(OK);
01625   return aFilling;
01626 }
01627 
01628 //=============================================================================
01632 //=============================================================================
01633 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections(
01634                                                 const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
01635                                                 bool theModeSolid,
01636                                                 double thePreci,
01637                                                 bool theRuled)
01638 {
01639   Handle(GEOM_Object) anObj;
01640   SetErrorCode(KO);
01641   if(theSeqSections.IsNull())
01642     return anObj;
01643 
01644   Standard_Integer nbObj = theSeqSections->Length();
01645   if (!nbObj)
01646     return anObj;
01647 
01648   //Add a new ThruSections object
01649   Handle(GEOM_Object) aThruSect = GetEngine()->AddObject(GetDocID(), GEOM_THRUSECTIONS);
01650 
01651 
01652   //Add a new ThruSections function
01653 
01654   int aTypeFunc = (theRuled ? THRUSECTIONS_RULED : THRUSECTIONS_SMOOTHED);
01655   Handle(GEOM_Function) aFunction =
01656     aThruSect->AddFunction(GEOMImpl_ThruSectionsDriver::GetID(), aTypeFunc);
01657   if (aFunction.IsNull()) return anObj;
01658 
01659   //Check if the function is set correctly
01660   if (aFunction->GetDriverGUID() != GEOMImpl_ThruSectionsDriver::GetID()) return NULL;
01661 
01662   GEOMImpl_IThruSections aCI (aFunction);
01663 
01664   Handle(TColStd_HSequenceOfTransient) aSeqSections = new TColStd_HSequenceOfTransient;
01665 
01666   Standard_Integer i =1;
01667   for( ; i <= nbObj; i++) {
01668 
01669     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
01670     if(anItem.IsNull())
01671       continue;
01672 
01673     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
01674     if(!aSectObj.IsNull())
01675     {
01676       Handle(GEOM_Function) aRefSect = aSectObj->GetLastFunction();
01677       if(!aRefSect.IsNull())
01678         aSeqSections->Append(aRefSect);
01679     }
01680   }
01681 
01682   if(!aSeqSections->Length())
01683     return anObj;
01684 
01685   aCI.SetSections(aSeqSections);
01686   aCI.SetSolidMode(theModeSolid);
01687   aCI.SetPrecision(thePreci);
01688 
01689   //Compute the ThruSections value
01690   try {
01691 #if OCC_VERSION_LARGE > 0x06010000
01692     OCC_CATCH_SIGNALS;
01693 #endif
01694     if (!GetSolver()->ComputeFunction(aFunction)) {
01695       SetErrorCode("ThruSections driver failed");
01696       return anObj;
01697     }
01698   }
01699   catch (Standard_Failure) {
01700     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01701     SetErrorCode(aFail->GetMessageString());
01702     return anObj;
01703   }
01704 
01705   //Make a Python command
01706   GEOM::TPythonDump pyDump(aFunction);
01707   pyDump << aThruSect << " = geompy.MakeThruSections([";
01708 
01709   for(i =1 ; i <= nbObj; i++) {
01710 
01711     Handle(Standard_Transient) anItem = theSeqSections->Value(i);
01712     if(anItem.IsNull())
01713       continue;
01714 
01715     Handle(GEOM_Object) aSectObj = Handle(GEOM_Object)::DownCast(anItem);
01716     if(!aSectObj.IsNull()) {
01717       pyDump<< aSectObj;
01718       if(i < nbObj)
01719         pyDump<<", ";
01720     }
01721   }
01722 
01723   pyDump<< "],"<<theModeSolid << "," << thePreci <<","<< theRuled <<")";
01724 
01725   SetErrorCode(OK);
01726   return aThruSect;
01727 }
01728 
01729 
01730 //=============================================================================
01734 //=============================================================================
01735 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections(
01736                 const Handle(TColStd_HSequenceOfTransient)& theBases,
01737                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
01738                 const Handle(GEOM_Object)& thePath,
01739                 bool theWithContact,
01740                 bool theWithCorrections)
01741 {
01742   Handle(GEOM_Object) anObj;
01743   SetErrorCode(KO);
01744   if(theBases.IsNull())
01745     return anObj;
01746 
01747   Standard_Integer nbBases = theBases->Length();
01748 
01749   if (!nbBases)
01750     return anObj;
01751 
01752   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
01753   //Add a new Pipe object
01754   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
01755 
01756   //Add a new Pipe function
01757 
01758   Handle(GEOM_Function) aFunction =
01759     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_DIFFERENT_SECTIONS);
01760   if (aFunction.IsNull()) return anObj;
01761 
01762   //Check if the function is set correctly
01763   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
01764 
01765   GEOMImpl_IPipeDiffSect aCI (aFunction);
01766 
01767   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
01768   if(aRefPath.IsNull())
01769     return anObj;
01770 
01771   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
01772   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
01773 
01774   Standard_Integer i =1;
01775   for( ; i <= nbBases; i++) {
01776 
01777     Handle(Standard_Transient) anItem = theBases->Value(i);
01778     if(anItem.IsNull())
01779       continue;
01780 
01781     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
01782     if(aBase.IsNull())
01783       continue;
01784     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
01785     if(aRefBase.IsNull())
01786       continue;
01787     if(nbLocs)
01788     {
01789       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
01790       if(anItemLoc.IsNull())
01791         continue;
01792 
01793       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
01794       if(aLoc.IsNull())
01795         continue;
01796       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
01797       if(aRefLoc.IsNull())
01798         continue;
01799       aSeqLocs->Append(aRefLoc);
01800     }
01801     aSeqBases->Append(aRefBase);
01802   }
01803 
01804   if(!aSeqBases->Length())
01805     return anObj;
01806 
01807   aCI.SetBases(aSeqBases);
01808   aCI.SetLocations(aSeqLocs);
01809   aCI.SetPath(aRefPath);
01810   aCI.SetWithContactMode(theWithContact);
01811   aCI.SetWithCorrectionMode(theWithCorrections);
01812 
01813   //Compute the Pipe value
01814   try {
01815 #if OCC_VERSION_LARGE > 0x06010000
01816     OCC_CATCH_SIGNALS;
01817 #endif
01818     if (!GetSolver()->ComputeFunction(aFunction)) {
01819       SetErrorCode("Pipe with defferent section driver failed");
01820       return anObj;
01821     }
01822   }
01823   catch (Standard_Failure) {
01824     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01825     SetErrorCode(aFail->GetMessageString());
01826     return anObj;
01827   }
01828 
01829   //Make a Python command
01830   GEOM::TPythonDump pyDump(aFunction);
01831   pyDump << aPipeDS << " = geompy.MakePipeWithDifferentSections([";
01832 
01833   for(i =1 ; i <= nbBases; i++) {
01834 
01835     Handle(Standard_Transient) anItem = theBases->Value(i);
01836     if(anItem.IsNull())
01837       continue;
01838 
01839     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
01840     if(!anObj.IsNull()) {
01841       pyDump<< anObj;
01842       if(i < nbBases)
01843         pyDump<<", ";
01844     }
01845   }
01846 
01847   pyDump<< "], [";
01848 
01849   for(i =1 ; i <= nbLocs; i++) {
01850 
01851     Handle(Standard_Transient) anItem = theLocations->Value(i);
01852     if(anItem.IsNull())
01853       continue;
01854 
01855     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
01856     if(!anObj.IsNull()) {
01857       pyDump<< anObj;
01858       if(i < nbLocs)
01859         pyDump<<", ";
01860     }
01861   }
01862 
01863   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
01864 
01865   SetErrorCode(OK);
01866   return aPipeDS;
01867 }
01868 
01869 
01870 //=============================================================================
01874 //=============================================================================
01875 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections(
01876                 const Handle(TColStd_HSequenceOfTransient)& theBases,
01877                 const Handle(TColStd_HSequenceOfTransient)& theSubBases,
01878                 const Handle(TColStd_HSequenceOfTransient)& theLocations,
01879                 const Handle(GEOM_Object)& thePath,
01880                 bool theWithContact,
01881                 bool theWithCorrections)
01882 {
01883   Handle(GEOM_Object) anObj;
01884   SetErrorCode(KO);
01885   if(theBases.IsNull())
01886     return anObj;
01887 
01888   Standard_Integer nbBases = theBases->Length();
01889 
01890   if (!nbBases)
01891     return anObj;
01892 
01893   Standard_Integer nbSubBases =  (theSubBases.IsNull() ? 0 :theSubBases->Length());
01894 
01895   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
01896 
01897   //Add a new Pipe object
01898   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
01899 
01900   //Add a new Pipe function
01901 
01902   Handle(GEOM_Function) aFunction =
01903     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELL_SECTIONS);
01904   if (aFunction.IsNull()) return anObj;
01905 
01906   //Check if the function is set correctly
01907   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
01908 
01909   //GEOMImpl_IPipeDiffSect aCI (aFunction);
01910   GEOMImpl_IPipeShellSect aCI (aFunction);
01911 
01912   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
01913   if(aRefPath.IsNull())
01914     return anObj;
01915 
01916   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
01917   Handle(TColStd_HSequenceOfTransient) aSeqSubBases = new TColStd_HSequenceOfTransient;
01918   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
01919 
01920   Standard_Integer i =1;
01921   for( ; i <= nbBases; i++) {
01922 
01923     Handle(Standard_Transient) anItem = theBases->Value(i);
01924     if(anItem.IsNull())
01925       continue;
01926     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
01927     if(aBase.IsNull())
01928       continue;
01929     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
01930     if(aRefBase.IsNull())
01931       continue;
01932 
01933     if( nbSubBases >= nbBases ) {
01934       Handle(Standard_Transient) aSubItem = theSubBases->Value(i);
01935       if(aSubItem.IsNull())
01936         continue;
01937       Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem);
01938       if(aSubBase.IsNull())
01939         continue;
01940       Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction();
01941       if(aRefSubBase.IsNull())
01942         continue;
01943       aSeqSubBases->Append(aRefSubBase);
01944     }
01945 
01946     if(nbLocs) {
01947       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
01948       if(anItemLoc.IsNull())
01949         continue;
01950       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
01951       if(aLoc.IsNull())
01952         continue;
01953       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
01954       if(aRefLoc.IsNull())
01955         continue;
01956       aSeqLocs->Append(aRefLoc);
01957     }
01958 
01959     aSeqBases->Append(aRefBase);
01960   }
01961 
01962   if(!aSeqBases->Length())
01963     return anObj;
01964 
01965   aCI.SetBases(aSeqBases);
01966   aCI.SetSubBases(aSeqSubBases);
01967   aCI.SetLocations(aSeqLocs);
01968   aCI.SetPath(aRefPath);
01969   aCI.SetWithContactMode(theWithContact);
01970   aCI.SetWithCorrectionMode(theWithCorrections);
01971 
01972   //Compute the Pipe value
01973   try {
01974 #if OCC_VERSION_LARGE > 0x06010000
01975     OCC_CATCH_SIGNALS;
01976 #endif
01977     if (!GetSolver()->ComputeFunction(aFunction)) {
01978       SetErrorCode("Pipe with shell sections driver failed");
01979       return anObj;
01980     }
01981   }
01982   catch (Standard_Failure) {
01983     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
01984     SetErrorCode(aFail->GetMessageString());
01985     return anObj;
01986   }
01987 
01988   //Make a Python command
01989   GEOM::TPythonDump pyDump(aFunction);
01990   pyDump << aPipeDS << " = geompy.MakePipeWithShellSections([";
01991 
01992   for(i =1 ; i <= nbBases; i++) {
01993 
01994     Handle(Standard_Transient) anItem = theBases->Value(i);
01995     if(anItem.IsNull())
01996       continue;
01997 
01998     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
01999     if(!anObj.IsNull()) {
02000       pyDump<< anObj;
02001       if(i < nbBases)
02002         pyDump<<", ";
02003     }
02004   }
02005 
02006   pyDump<< "], [";
02007 
02008   for(i =1 ; i <= nbSubBases; i++) {
02009 
02010     Handle(Standard_Transient) anItem = theSubBases->Value(i);
02011     if(anItem.IsNull())
02012       continue;
02013 
02014     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
02015     if(!anObj.IsNull()) {
02016       pyDump<< anObj;
02017       if(i < nbBases)
02018         pyDump<<", ";
02019     }
02020   }
02021 
02022   pyDump<< "], [";
02023 
02024   for(i =1 ; i <= nbLocs; i++) {
02025 
02026     Handle(Standard_Transient) anItem = theLocations->Value(i);
02027     if(anItem.IsNull())
02028       continue;
02029 
02030     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
02031     if(!anObj.IsNull()) {
02032       pyDump<< anObj;
02033       if(i < nbLocs)
02034         pyDump<<", ";
02035     }
02036   }
02037 
02038   pyDump<< "], "<<thePath<<","<<theWithContact << "," << theWithCorrections<<")";
02039 
02040   SetErrorCode(OK);
02041   return aPipeDS;
02042 
02043 }
02044 
02045 
02046 //=============================================================================
02050 //=============================================================================
02051 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath(
02052                 const Handle(TColStd_HSequenceOfTransient)& theBases,
02053                 const Handle(TColStd_HSequenceOfTransient)& theLocations)
02054 {
02055   Handle(GEOM_Object) anObj;
02056   SetErrorCode(KO);
02057   if(theBases.IsNull())
02058     return anObj;
02059 
02060   Standard_Integer nbBases = theBases->Length();
02061 
02062   if (!nbBases)
02063     return anObj;
02064 
02065   Standard_Integer nbLocs =  (theLocations.IsNull() ? 0 :theLocations->Length());
02066 
02067   //Add a new Pipe object
02068   Handle(GEOM_Object) aPipeDS = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
02069 
02070   //Add a new Pipe function
02071 
02072   Handle(GEOM_Function) aFunction =
02073     aPipeDS->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_SHELLS_WITHOUT_PATH);
02074   if (aFunction.IsNull()) return anObj;
02075 
02076   //Check if the function is set correctly
02077   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return anObj;
02078 
02079   GEOMImpl_IPipeShellSect aCI (aFunction);
02080 
02081   Handle(TColStd_HSequenceOfTransient) aSeqBases = new TColStd_HSequenceOfTransient;
02082   Handle(TColStd_HSequenceOfTransient) aSeqLocs = new TColStd_HSequenceOfTransient;
02083 
02084   Standard_Integer i =1;
02085   for( ; i <= nbBases; i++) {
02086 
02087     Handle(Standard_Transient) anItem = theBases->Value(i);
02088     if(anItem.IsNull())
02089       continue;
02090     Handle(GEOM_Object) aBase = Handle(GEOM_Object)::DownCast(anItem);
02091     if(aBase.IsNull())
02092       continue;
02093     Handle(GEOM_Function) aRefBase = aBase->GetLastFunction();
02094     if(aRefBase.IsNull())
02095       continue;
02096 
02097     if(nbLocs) {
02098       Handle(Standard_Transient) anItemLoc = theLocations->Value(i);
02099       if(anItemLoc.IsNull())
02100         continue;
02101       Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc);
02102       if(aLoc.IsNull())
02103         continue;
02104       Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction();
02105       if(aRefLoc.IsNull())
02106         continue;
02107       aSeqLocs->Append(aRefLoc);
02108     }
02109 
02110     aSeqBases->Append(aRefBase);
02111   }
02112 
02113   if(!aSeqBases->Length())
02114     return anObj;
02115 
02116   aCI.SetBases(aSeqBases);
02117   aCI.SetLocations(aSeqLocs);
02118 
02119   //Compute the Pipe value
02120   try {
02121 #if OCC_VERSION_LARGE > 0x06010000
02122     OCC_CATCH_SIGNALS;
02123 #endif
02124     if (!GetSolver()->ComputeFunction(aFunction)) {
02125       SetErrorCode("Pipe with shell sections without path driver failed");
02126       return anObj;
02127     }
02128   }
02129   catch (Standard_Failure) {
02130     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
02131     SetErrorCode(aFail->GetMessageString());
02132     return anObj;
02133   }
02134 
02135   //Make a Python command
02136   GEOM::TPythonDump pyDump(aFunction);
02137   pyDump << aPipeDS << " = geompy.MakePipeShellsWithoutPath([";
02138 
02139   for(i =1 ; i <= nbBases; i++) {
02140 
02141     Handle(Standard_Transient) anItem = theBases->Value(i);
02142     if(anItem.IsNull())
02143       continue;
02144 
02145     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
02146     if(!anObj.IsNull()) {
02147       pyDump<< anObj;
02148       if(i < nbBases)
02149         pyDump<<", ";
02150     }
02151   }
02152 
02153   pyDump<< "], [";
02154 
02155   for(i =1 ; i <= nbLocs; i++) {
02156 
02157     Handle(Standard_Transient) anItem = theLocations->Value(i);
02158     if(anItem.IsNull())
02159       continue;
02160 
02161     Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast(anItem);
02162     if(!anObj.IsNull()) {
02163       pyDump<< anObj;
02164       if(i < nbLocs)
02165         pyDump<<", ";
02166     }
02167   }
02168 
02169   pyDump<< "])";
02170 
02171   SetErrorCode(OK);
02172   return aPipeDS;
02173 
02174 }
02175 
02176 
02177 //=============================================================================
02181 //=============================================================================
02182 Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase,
02183                                                                              Handle(GEOM_Object) thePath,
02184                                                                              Handle(GEOM_Object) theVec)
02185 {
02186   SetErrorCode(KO);
02187 
02188   if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL;
02189 
02190   //Add a new Pipe object
02191   Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE);
02192 
02193   //Add a new Pipe function
02194   Handle(GEOM_Function) aFunction =
02195     aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR);
02196   if (aFunction.IsNull()) return NULL;
02197 
02198   //Check if the function is set correctly
02199   if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL;
02200 
02201   GEOMImpl_IPipeBiNormal aCI (aFunction);
02202 
02203   Handle(GEOM_Function) aRefBase = theBase->GetLastFunction();
02204   Handle(GEOM_Function) aRefPath = thePath->GetLastFunction();
02205   Handle(GEOM_Function) aRefVec  = theVec->GetLastFunction();
02206 
02207   if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL;
02208 
02209   aCI.SetBase(aRefBase);
02210   aCI.SetPath(aRefPath);
02211   aCI.SetVector(aRefVec);
02212 
02213   //Compute the Pipe value
02214   try {
02215 #if OCC_VERSION_LARGE > 0x06010000
02216     OCC_CATCH_SIGNALS;
02217 #endif
02218     if (!GetSolver()->ComputeFunction(aFunction)) {
02219       SetErrorCode("Pipe driver failed");
02220       return NULL;
02221     }
02222   }
02223   catch (Standard_Failure) {
02224     Handle(Standard_Failure) aFail = Standard_Failure::Caught();
02225     SetErrorCode(aFail->GetMessageString());
02226     return NULL;
02227   }
02228 
02229   //Make a Python command
02230   GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector("
02231     << theBase << ", " << thePath << ", " << theVec << ")";
02232 
02233   SetErrorCode(OK);
02234   return aPipe;
02235 }