From dc0102b3ab0ff8a529af04d910892bc7bea8d592 Mon Sep 17 00:00:00 2001 From: akl Date: Mon, 29 Sep 2008 07:20:49 +0000 Subject: [PATCH] To implement issue 0019962: MakePipeBiNormalAlongAxis implementation. --- idl/GEOM_Gen.idl | 16 +++++ idl/GEOM_Superv.idl | 4 ++ resources/Makefile.am | 1 + resources/pipebinormal.png | Bin 0 -> 1728 bytes src/GEOMGUI/GEOM_images.ts | 4 ++ src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx | 62 ++++++++++++++++ src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx | 4 ++ src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx | 47 +++++++++++++ src/GEOMImpl/GEOMImpl_PipeDriver.cxx | 74 ++++++++++++++++++++ src/GEOMImpl/GEOMImpl_Types.hxx | 1 + src/GEOMImpl/Makefile.am | 1 + 11 files changed, 214 insertions(+) create mode 100644 resources/pipebinormal.png create mode 100644 src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 6220952c2..0cf8d8573 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1107,6 +1107,22 @@ module GEOM */ GEOM_Object MakePipeShellsWithoutPath (in ListOfGO theSeqBases, in ListOfGO theLocations); + + /*! + * Create a shape by extrusion of the base shape along + * the path shape with constant bi-normal direction along the given vector. + * The path shape can be a wire or an edge. + * \param theBase Base shape to be extruded. + * \param thePath Path shape to extrude the base shape along it. + * \param theVec Vector defines a constant binormal direction to keep the + * same angle beetween the Direction and the sections + * along the sweep surface. + * \return New GEOM_Object, containing the created pipe. + */ + GEOM_Object MakePipeBiNormalAlongVector (in GEOM_Object theBase, + in GEOM_Object thePath, + in GEOM_Object theVec); + }; /*! diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 0c1b2252d..5ca45ef11 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -212,6 +212,10 @@ module GEOM GEOM_Object MakePipeShellsWithoutPath (in ListOfGO theSeqBases, in ListOfGO theLocations ); + GEOM_Object MakePipeBiNormalAlongVector (in GEOM_Object theBase, + in GEOM_Object thePath, + in GEOM_Object theVec); + //-----------------------------------------------------------// // BooleanOperations // //-----------------------------------------------------------// diff --git a/resources/Makefile.am b/resources/Makefile.am index 8a5787ddf..bce407e4a 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -110,6 +110,7 @@ partition.png \ partitionkeep.png \ partitionplane.png \ pipe.png \ +pipebinormal.png \ plane.png \ planeWorking.png \ plane3points.png \ diff --git a/resources/pipebinormal.png b/resources/pipebinormal.png new file mode 100644 index 0000000000000000000000000000000000000000..bc83f8d803b2041ae191bbe74071bb433fa24e0d GIT binary patch literal 1728 zcmb_cSx8k;6y5i|muYH)WWE9ktPjypkv>GCEPd$!b6L&guS`J!&v-Fg zTwE+xY(Gsg-K5=pH|WpL9~99{T3LG?%lK(BI<`$A?B23Xn3_&K)jOXv0Dq@QBtoyQ z)-j1e2KPfzjiMaov(^fm13#Z2h3-j(N$#rJj1Z5qmjjrSlOy(@?-AMA*&-_|OQff# z3y;Sm)->D)&c-g|zT}yn!xX`JVuM_G3L=cM#Qd7ebntB(HD{EOd+uV=qaom65@&U1 z=1^VtxTB)8a#KA60_^I@$VfrY#l55(g3je1pr$YPC^-6+3@u7U2im~{tYcGh$g`;G zkm8clNH|P&S!0%D$r6T6rlFCcM=gXErOe}WLI47a+l|(i9dPs5#itIrHcXRDlL{1Ko4uB0VZFo_|FKqz#F5V*cL zekvi$6{~OEu;r?Gd3kE#zDuO>Evb8bflg#@pu~BLWHH{~I>8)Lt{tJgrc=%#B(XVi zL!l6bqdMOXoiu(F^jL@#ms=JDKsK8Utu%+Q(_bk{pFdg7vxqR@^?HZ$YT799{UaU! z{D6*oOUMWZnb1Rhw@+eoH*oBZT<%Z2Hl`IFat90Gi5mU(ftrRpD9CGvzdfa(rcqm3 zp@p!b8{z?6%Ef|H6yM7ih|VbnFGTopUAL^EYe&D*VL=`V91AvF9Xzbb@iATyygFE%>|H#56kn6C b4ELpBUnu8F`|nc&wV3exs><%K+t>0BL>{xk literal 0 HcmV?d00001 diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 8f5801fd1..ddeb05af5 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -306,6 +306,10 @@ ICON_DLG_PIPE pipe.png + + ICON_DLG_PIPE_BINORMAL + pipebinormal.png + ICON_DLG_PLANE_3PNTS plane3points.png diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 983974343..77c960320 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -64,6 +64,7 @@ #include #include #include +#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC @@ -2122,3 +2123,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; +} + diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index 5099605fc..77bbe19a0 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -124,6 +124,10 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { const Handle(TColStd_HSequenceOfTransient)& theBases, const Handle(TColStd_HSequenceOfTransient)& theLocations); + Standard_EXPORT Handle(GEOM_Object) MakePipeBiNormalAlongVector (Handle(GEOM_Object) theBase, + Handle(GEOM_Object) thePath, + Handle(GEOM_Object) theVec); + }; #endif diff --git a/src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx b/src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx new file mode 100644 index 000000000..38d62fa2e --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx @@ -0,0 +1,47 @@ +// 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. +// +// 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 +// +//NOTE: This is an interface to a function for the Pipe creation. + +#ifndef _GEOMImpl_IPIPEBINORMAL_HXX_ +#define _GEOMImpl_IPIPEBINORMAL_HXX_ + +#include "GEOM_Function.hxx" + +#ifndef _GEOMImpl_IPIPE_HXX_ +#include "GEOMImpl_IPipe.hxx" +#endif + +#define PIPE_ARG_BASE 1 +#define PIPE_ARG_PATH 2 +#define PIPE_ARG_VEC 3 + +class GEOMImpl_IPipeBiNormal : public GEOMImpl_IPipe +{ + public: + + GEOMImpl_IPipeBiNormal(Handle(GEOM_Function)& theFunction):GEOMImpl_IPipe(theFunction) {} + + void SetVector(Handle(GEOM_Function) theVec) { _func->SetReference(PIPE_ARG_VEC, theVec); } + + Handle(GEOM_Function) GetVector() { return _func->GetReference(PIPE_ARG_VEC); } + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index 41aec4758..f93e069ad 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -1851,6 +1852,72 @@ static TopoDS_Shape CreatePipeShellsWithoutPath(GEOMImpl_IPipe* aCI) } +//======================================================================= +//function : CreatePipeBiNormalAlongVector +//purpose : auxilary for Execute() +//======================================================================= +static TopoDS_Shape CreatePipeBiNormalAlongVector(const TopoDS_Wire& aWirePath, + GEOMImpl_IPipe* aCI) +{ + GEOMImpl_IPipeBiNormal* aCIBN = (GEOMImpl_IPipeBiNormal*)aCI; + + Handle(GEOM_Function) aRefBase = aCIBN->GetBase(); + Handle(GEOM_Function) aRefVec = aCIBN->GetVector(); + TopoDS_Shape aShapeBase = aRefBase->GetValue(); + TopoDS_Shape aShapeVec = aRefVec->GetValue(); + + if (aShapeBase.IsNull()) { + if(aCIBN) delete aCIBN; + Standard_NullObject::Raise("MakePipe aborted : null base argument"); + } + + TopoDS_Shape aProf; + if( aShapeBase.ShapeType() == TopAbs_VERTEX ) { + aProf = aShapeBase; + } + else if( aShapeBase.ShapeType() == TopAbs_EDGE) { + aProf = BRepBuilderAPI_MakeWire(TopoDS::Edge(aShapeBase)).Shape(); + } + else if( aShapeBase.ShapeType() == TopAbs_WIRE) { + aProf = aShapeBase; + } + else if( aShapeBase.ShapeType() == TopAbs_FACE) { + TopExp_Explorer wexp(aShapeBase,TopAbs_WIRE); + aProf = wexp.Current(); + } + else { + Standard_TypeMismatch::Raise + ("MakePipe aborted : invalid type of base"); + } + BRepOffsetAPI_MakePipeShell PipeBuilder(aWirePath); + PipeBuilder.Add(aProf); + + if (aShapeVec.IsNull()) { + if(aCIBN) delete aCIBN; + Standard_NullObject::Raise + ("MakePipe aborted : null vector argument"); + } + if (aShapeVec.ShapeType() != TopAbs_EDGE) + Standard_TypeMismatch::Raise + ("MakePipe aborted: invalid type of vector"); + TopoDS_Edge anEdge = TopoDS::Edge(aShapeVec); + TopoDS_Vertex V1, V2; + TopExp::Vertices(anEdge, V1, V2, Standard_True); + if (V1.IsNull() || V2.IsNull()) + Standard_NullObject::Raise + ("MakePipe aborted: vector is not defined"); + gp_Vec aVec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2)); + gp_Dir BiNormal(aVec); + PipeBuilder.SetMode(BiNormal); + PipeBuilder.Build(); + if( aShapeBase.ShapeType() == TopAbs_FACE) { + PipeBuilder.MakeSolid(); + } + + return PipeBuilder.Shape(); +} + + //======================================================================= //function : Execute //purpose : @@ -1870,6 +1937,8 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const aCI = new GEOMImpl_IPipeShellSect(aFunction); else if(aType == PIPE_SHELLS_WITHOUT_PATH) aCI = new GEOMImpl_IPipeShellSect(aFunction); + else if(aType == PIPE_BI_NORMAL_ALONG_VECTOR) + aCI = new GEOMImpl_IPipeBiNormal(aFunction); else return 0; @@ -2293,6 +2362,11 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const aShape = CreatePipeShellsWithoutPath(aCI); } + //building a pipe with constant bi-normal along given vector + else if (aType == PIPE_BI_NORMAL_ALONG_VECTOR) { + aShape = CreatePipeBiNormalAlongVector(aWirePath, aCI); + } + if (aCI) { delete aCI; aCI = 0; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index 4220d7488..56bdc81e4 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -188,6 +188,7 @@ #define PIPE_DIFFERENT_SECTIONS 2 #define PIPE_SHELL_SECTIONS 3 #define PIPE_SHELLS_WITHOUT_PATH 4 +#define PIPE_BI_NORMAL_ALONG_VECTOR 5 #define THRUSECTIONS_RULED 1 #define THRUSECTIONS_SMOOTHED 2 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index 8bd5c417e..b0113b6ca 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -92,6 +92,7 @@ salomeinclude_HEADERS = \ GEOMImpl_IPartition.hxx \ GEOMImpl_IPipeDiffSect.hxx \ GEOMImpl_IPipeShellSect.hxx \ + GEOMImpl_IPipeBiNormal.hxx \ GEOMImpl_VectorDriver.hxx \ GEOMImpl_LineDriver.hxx \ GEOMImpl_DiskDriver.hxx \ -- 2.39.2