X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_I3DPrimOperations.cxx;h=cc2b9791bcf774c6f814e03998eecbfdc8a5302a;hb=90dda39995ebbd4c4de8184fd89f528fafc45474;hp=a1c554544528d6aa825ae2b810144f72ca162eb0;hpb=239f8109c64fa0c5a2e1d87a420bad5529b57f48;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index a1c554544..cc2b9791b 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1,22 +1,25 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + #include #include @@ -36,6 +39,8 @@ #include #include +#include +#include #include #include #include @@ -48,6 +53,8 @@ #include #include +#include +#include #include #include #include @@ -55,11 +62,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -192,6 +199,281 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeBoxTwoPnt (Handle(GEOM_Objec return aBox; } +//============================================================================= +/*! + * MakeFaceHW + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceHW (double theH, double theW, int theOrientation) +{ + SetErrorCode(KO); + + if (theH == 0 || theW == 0) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Box function for creation a box relatively to two points + Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_H_W); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace; + + GEOMImpl_IFace aFI (aFunction); + + aFI.SetH(theH); + aFI.SetW(theW); + aFI.SetOrientation(theOrientation); + + //Compute the Face + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Face driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceHW(" + << theH << ", " << theW << ", " << theOrientation << ")"; + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeFaceObjHW + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFaceObjHW (Handle(GEOM_Object) theObj, + double theH, double theW) +{ + SetErrorCode(KO); + + if (theObj.IsNull()) return NULL; + + //Add a new Face object + Handle(GEOM_Object) aFace = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Box function for creation a box relatively to two points + Handle(GEOM_Function) aFunction = aFace->AddFunction(GEOMImpl_FaceDriver::GetID(), FACE_OBJ_H_W); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_FaceDriver::GetID()) return aFace; + + GEOMImpl_IFace aFI (aFunction); + + Handle(GEOM_Function) aRefFunction1 = theObj->GetLastFunction(); + + if (aRefFunction1.IsNull()) + return aFace; + + aFI.SetRef1(aRefFunction1); + aFI.SetH(theH); + aFI.SetW(theW); + + //Compute the Face + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Face driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aFace << " = geompy.MakeFaceObjHW(" + << theObj << ", " << theH << ", " << theW << ")"; + + SetErrorCode(OK); + return aFace; +} + +//============================================================================= +/*! + * MakeDiskPntVecR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskPntVecR + (Handle(GEOM_Object) thePnt, Handle(GEOM_Object) theVec, double theR) +{ + SetErrorCode(KO); + + if (thePnt.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Disk object + Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Disk function for creation a disk relatively to point and vector + Handle(GEOM_Function) aFunction = + aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_PNT_VEC_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL; + + GEOMImpl_IDisk aCI (aFunction); + + Handle(GEOM_Function) aRefPnt = thePnt->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefPnt.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetCenter(aRefPnt); + aCI.SetVector(aRefVec); + aCI.SetRadius(theR); + + //Compute the Disk value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Disk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskPntVecR(" + << thePnt << ", " << theVec << ", " << theR << ")"; + + SetErrorCode(OK); + return aDisk; +} + +//============================================================================= +/*! + * MakeDiskThreePnt + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskThreePnt (Handle(GEOM_Object) thePnt1, + Handle(GEOM_Object) thePnt2, + Handle(GEOM_Object) thePnt3) +{ + SetErrorCode(KO); + + if (thePnt1.IsNull() || thePnt2.IsNull() || thePnt3.IsNull()) return NULL; + + //Add a new Disk object + Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Disk function for creation a disk relatively to three points + Handle(GEOM_Function) aFunction = + aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_THREE_PNT); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return NULL; + + GEOMImpl_IDisk aCI (aFunction); + + Handle(GEOM_Function) aRefPnt1 = thePnt1->GetLastFunction(); + Handle(GEOM_Function) aRefPnt2 = thePnt2->GetLastFunction(); + Handle(GEOM_Function) aRefPnt3 = thePnt3->GetLastFunction(); + + if (aRefPnt1.IsNull() || aRefPnt2.IsNull() || aRefPnt3.IsNull()) return NULL; + + aCI.SetPoint1(aRefPnt1); + aCI.SetPoint2(aRefPnt2); + aCI.SetPoint3(aRefPnt3); + + //Compute the Disk value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Disk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskThreePnt(" + << thePnt1 << ", " << thePnt2 << ", " << thePnt3 << ")"; + + SetErrorCode(OK); + return aDisk; +} + +//============================================================================= +/*! + * MakeDiskR + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeDiskR (double theR, int theOrientation) +{ + SetErrorCode(KO); + + if (theR == 0 ) return NULL; + + //Add a new Disk object + Handle(GEOM_Object) aDisk = GetEngine()->AddObject(GetDocID(), GEOM_FACE); + + //Add a new Box function for creation a box relatively to two points + Handle(GEOM_Function) aFunction = aDisk->AddFunction(GEOMImpl_DiskDriver::GetID(), DISK_R); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_DiskDriver::GetID()) return aDisk; + + GEOMImpl_IDisk aDI (aFunction); + + aDI.SetRadius(theR); + aDI.SetOrientation(theOrientation); + + //Compute the Disk + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Disk driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aDisk << " = geompy.MakeDiskR(" + << theR << ", " << theOrientation << ")"; + + SetErrorCode(OK); + return aDisk; +} //============================================================================= /*! @@ -698,8 +980,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH (Handle(GEOM_Objec */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismVecH2Ways (Handle(GEOM_Object) theBase, - Handle(GEOM_Object) theVec, - double theH) + Handle(GEOM_Object) theVec, + double theH) { SetErrorCode(KO); @@ -874,6 +1156,121 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismTwoPnt2Ways return aPrism; } +//============================================================================= +/*! + * MakePrismDXDYDZ + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ + (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + if (theBase.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism by DXDYDZ + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetDX(theDX); + aCI.SetDY(theDY); + aCI.SetDZ(theDZ); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ(" + << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")"; + + SetErrorCode(OK); + return aPrism; +} + +//============================================================================= +/*! + * MakePrismDXDYDZ_2WAYS + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePrismDXDYDZ2Ways + (Handle(GEOM_Object) theBase, double theDX, double theDY, double theDZ) +{ + SetErrorCode(KO); + + if (theBase.IsNull()) return NULL; + + //Add a new Prism object + Handle(GEOM_Object) aPrism = GetEngine()->AddObject(GetDocID(), GEOM_PRISM); + + //Add a new Prism function for creation a Prism by DXDYDZ + Handle(GEOM_Function) aFunction = + aPrism->AddFunction(GEOMImpl_PrismDriver::GetID(), PRISM_BASE_DXDYDZ_2WAYS); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PrismDriver::GetID()) return NULL; + + GEOMImpl_IPrism aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + + if (aRefBase.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetDX(theDX); + aCI.SetDY(theDY); + aCI.SetDZ(theDZ); + + //Compute the Prism value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Extrusion can not be created, check input data"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPrism << " = geompy.MakePrismDXDYDZ2Ways(" + << theBase << ", " << theDX << ", " << theDY << ", " << theDZ << ")"; + + SetErrorCode(OK); + return aPrism; +} //============================================================================= /*! @@ -1050,59 +1447,6 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways return aRevolution; } -//============================================================================= -/*! - * MakeSolidShell - */ -//============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell) -{ - SetErrorCode(KO); - - if (theShell.IsNull()) return NULL; - - //Add a new Solid object - Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID); - - //Add a new Solid function for creation a solid from a shell - Handle(GEOM_Function) aFunction = - aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL); - if (aFunction.IsNull()) return NULL; - - //Check if the function is set correctly - if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL; - - GEOMImpl_IShapes aCI (aFunction); - - Handle(GEOM_Function) aRefShell = theShell->GetLastFunction(); - - if (aRefShell.IsNull()) return NULL; - - aCI.SetBase(aRefShell); - - //Compute the Solid value - try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 - OCC_CATCH_SIGNALS; -#endif - if (!GetSolver()->ComputeFunction(aFunction)) { - SetErrorCode("Solid driver failed"); - return NULL; - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - SetErrorCode(aFail->GetMessageString()); - return NULL; - } - - //Make a Python command - GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")"; - - SetErrorCode(OK); - return aSolid; -} - //============================================================================= /*! * MakeFilling @@ -1110,7 +1454,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Obje //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, - double theTol2D, double theTol3D, int theNbIter, bool isApprox) + double theTol2D, double theTol3D, int theNbIter, + int theMethod, bool isApprox) { SetErrorCode(KO); @@ -1139,6 +1484,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling aFI.SetTol3D(theTol3D); aFI.SetNbIter(theNbIter); aFI.SetApprox(isApprox); + aFI.SetMethod(theMethod); //Compute the Solid value try { @@ -1162,10 +1508,13 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling //Make a Python command GEOM::TPythonDump pd (aFunction); pd << aFilling << " = geompy.MakeFilling(" - << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", " - << theTol2D << ", " << theTol3D << ", " << theNbIter; + << theShape << ", " << theMinDeg << ", " << theMaxDeg << ", " + << theTol2D << ", " << theTol3D << ", " << theNbIter << ", "; + if( theMethod==1 ) pd << "GEOM.FOM_UseOri"; + else if( theMethod==2 ) pd << "GEOM.FOM_AutoCorrect"; + else pd << "GEOM.FOM_Default"; if(isApprox) - pd << ", " << isApprox; + pd << ", " << isApprox ; pd << ")"; SetErrorCode(OK); @@ -1178,10 +1527,10 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections( - const Handle(TColStd_HSequenceOfTransient)& theSeqSections, - bool theModeSolid, - double thePreci, - bool theRuled) + const Handle(TColStd_HSequenceOfTransient)& theSeqSections, + bool theModeSolid, + double thePreci, + bool theRuled) { Handle(GEOM_Object) anObj; SetErrorCode(KO); @@ -1263,7 +1612,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections( if(!aSectObj.IsNull()) { pyDump<< aSectObj; if(i < nbObj) - pyDump<<", "; + pyDump<<", "; } } @@ -1282,11 +1631,11 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeThruSections( */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( - const Handle(TColStd_HSequenceOfTransient)& theBases, - const Handle(TColStd_HSequenceOfTransient)& theLocations, - const Handle(GEOM_Object)& thePath, - bool theWithContact, - bool theWithCorrections) + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations, + const Handle(GEOM_Object)& thePath, + bool theWithContact, + bool theWithCorrections) { Handle(GEOM_Object) anObj; SetErrorCode(KO); @@ -1337,14 +1686,14 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( { Handle(Standard_Transient) anItemLoc = theLocations->Value(i); if(anItemLoc.IsNull()) - continue; + continue; Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc); if(aLoc.IsNull()) - continue; + continue; Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction(); if(aRefLoc.IsNull()) - continue; + continue; aSeqLocs->Append(aRefLoc); } aSeqBases->Append(aRefBase); @@ -1389,7 +1738,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbBases) - pyDump<<", "; + pyDump<<", "; } } @@ -1406,7 +1755,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbLocs) - pyDump<<", "; + pyDump<<", "; } } @@ -1425,12 +1774,12 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithDifferentSections( */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( - const Handle(TColStd_HSequenceOfTransient)& theBases, - const Handle(TColStd_HSequenceOfTransient)& theSubBases, - const Handle(TColStd_HSequenceOfTransient)& theLocations, - const Handle(GEOM_Object)& thePath, - bool theWithContact, - bool theWithCorrections) + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theSubBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations, + const Handle(GEOM_Object)& thePath, + bool theWithContact, + bool theWithCorrections) { Handle(GEOM_Object) anObj; SetErrorCode(KO); @@ -1485,26 +1834,26 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( if( nbSubBases >= nbBases ) { Handle(Standard_Transient) aSubItem = theSubBases->Value(i); if(aSubItem.IsNull()) - continue; + continue; Handle(GEOM_Object) aSubBase = Handle(GEOM_Object)::DownCast(aSubItem); if(aSubBase.IsNull()) - continue; + continue; Handle(GEOM_Function) aRefSubBase = aSubBase->GetLastFunction(); if(aRefSubBase.IsNull()) - continue; + continue; aSeqSubBases->Append(aRefSubBase); } if(nbLocs) { Handle(Standard_Transient) anItemLoc = theLocations->Value(i); if(anItemLoc.IsNull()) - continue; + continue; Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc); if(aLoc.IsNull()) - continue; + continue; Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction(); if(aRefLoc.IsNull()) - continue; + continue; aSeqLocs->Append(aRefLoc); } @@ -1551,7 +1900,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbBases) - pyDump<<", "; + pyDump<<", "; } } @@ -1568,7 +1917,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbBases) - pyDump<<", "; + pyDump<<", "; } } @@ -1585,7 +1934,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbLocs) - pyDump<<", "; + pyDump<<", "; } } @@ -1603,8 +1952,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeWithShellSections( */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( - const Handle(TColStd_HSequenceOfTransient)& theBases, - const Handle(TColStd_HSequenceOfTransient)& theLocations) + const Handle(TColStd_HSequenceOfTransient)& theBases, + const Handle(TColStd_HSequenceOfTransient)& theLocations) { Handle(GEOM_Object) anObj; SetErrorCode(KO); @@ -1651,13 +2000,13 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( if(nbLocs) { Handle(Standard_Transient) anItemLoc = theLocations->Value(i); if(anItemLoc.IsNull()) - continue; + continue; Handle(GEOM_Object) aLoc = Handle(GEOM_Object)::DownCast(anItemLoc); if(aLoc.IsNull()) - continue; + continue; Handle(GEOM_Function) aRefLoc = aLoc->GetLastFunction(); if(aRefLoc.IsNull()) - continue; + continue; aSeqLocs->Append(aRefLoc); } @@ -1700,7 +2049,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbBases) - pyDump<<", "; + pyDump<<", "; } } @@ -1717,7 +2066,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( if(!anObj.IsNull()) { pyDump<< anObj; if(i < nbLocs) - pyDump<<", "; + pyDump<<", "; } } @@ -1728,3 +2077,64 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeShellsWithoutPath( } + +//============================================================================= +/*! + * MakePipeBiNormalAlongVector + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePath, + Handle(GEOM_Object) theVec) +{ + SetErrorCode(KO); + + if (theBase.IsNull() || thePath.IsNull() || theVec.IsNull()) return NULL; + + //Add a new Pipe object + Handle(GEOM_Object) aPipe = GetEngine()->AddObject(GetDocID(), GEOM_PIPE); + + //Add a new Pipe function + Handle(GEOM_Function) aFunction = + aPipe->AddFunction(GEOMImpl_PipeDriver::GetID(), PIPE_BI_NORMAL_ALONG_VECTOR); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_PipeDriver::GetID()) return NULL; + + GEOMImpl_IPipeBiNormal aCI (aFunction); + + Handle(GEOM_Function) aRefBase = theBase->GetLastFunction(); + Handle(GEOM_Function) aRefPath = thePath->GetLastFunction(); + Handle(GEOM_Function) aRefVec = theVec->GetLastFunction(); + + if (aRefBase.IsNull() || aRefPath.IsNull() || aRefVec.IsNull()) return NULL; + + aCI.SetBase(aRefBase); + aCI.SetPath(aRefPath); + aCI.SetVector(aRefVec); + + //Compute the Pipe value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("Pipe driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump(aFunction) << aPipe << " = geompy.MakePipeBiNormalAlongVector(" + << theBase << ", " << thePath << ", " << theVec << ")"; + + SetErrorCode(OK); + return aPipe; +} +