]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
To implement issue 0019962: MakePipeBiNormalAlongAxis implementation.
authorakl <akl@opencascade.com>
Mon, 29 Sep 2008 07:20:49 +0000 (07:20 +0000)
committerakl <akl@opencascade.com>
Mon, 29 Sep 2008 07:20:49 +0000 (07:20 +0000)
idl/GEOM_Gen.idl
idl/GEOM_Superv.idl
resources/Makefile.am
resources/pipebinormal.png [new file with mode: 0644]
src/GEOMGUI/GEOM_images.ts
src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx
src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx
src/GEOMImpl/GEOMImpl_IPipeBiNormal.hxx [new file with mode: 0644]
src/GEOMImpl/GEOMImpl_PipeDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOMImpl/Makefile.am

index 6220952c25cf94ff5c11354f0ba12962294b69d0..0cf8d8573a0862716e03f6b9ecebe6105a2657bd 100644 (file)
@@ -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);
+
   };
 
   /*!
index 0c1b2252d80fe372ef0494c3a76a24d74d5e1e5e..5ca45ef111460d0d535f18fd4787f70b197d7e2c 100644 (file)
@@ -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                                         //
     //-----------------------------------------------------------//
index 8a5787ddf5295481c774ba4ad9ca6d61eb1dd83a..bce407e4afa074d91f0ac587e51388fd456fde42 100644 (file)
@@ -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 (file)
index 0000000..bc83f8d
Binary files /dev/null and b/resources/pipebinormal.png differ
index 8f5801fd1996a227234d396b26ffde5e7aaa184f..ddeb05af5dcc134628994bd87f88762e77b4454c 100644 (file)
             <source>ICON_DLG_PIPE</source>
             <translation>pipe.png</translation>
         </message>
+        <message>
+            <source>ICON_DLG_PIPE_BINORMAL</source>
+            <translation>pipebinormal.png</translation>
+        </message>
         <message>
             <source>ICON_DLG_PLANE_3PNTS</source>
             <translation>plane3points.png</translation>
index 98397434385d953aa5d58b4f94273b74b5d66e09..77c96032078a8c6e66ffbbd416a8a843af3fb0ce 100644 (file)
@@ -64,6 +64,7 @@
 #include <GEOMImpl_IThruSections.hxx>
 #include <GEOMImpl_IPipeDiffSect.hxx>
 #include <GEOMImpl_IPipeShellSect.hxx>
+#include <GEOMImpl_IPipeBiNormal.hxx>
 
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx> // 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;
+}
+
index 5099605fc35a7e2589c9e1fd596847eb0e153a4d..77bbe19a0c299684ae0017f38f48a9c376ddfa2f 100644 (file)
@@ -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 (file)
index 0000000..38d62fa
--- /dev/null
@@ -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
index 41aec47585d22ed6c750270cb1b0b5250b616a44..f93e069addf18cb3aec69f515eee656fc0ec1abd 100644 (file)
@@ -25,6 +25,7 @@
 #include <GEOMImpl_IShapesOperations.hxx>
 #include <GEOMImpl_IPipeDiffSect.hxx>
 #include <GEOMImpl_IPipeShellSect.hxx>
+#include <GEOMImpl_IPipeBiNormal.hxx>
 #include <GEOMImpl_IPipe.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
@@ -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;
index 4220d74884734d28bb7437f477367377d98c9eba..56bdc81e4901d226d2613179560566efd0b1e6d5 100755 (executable)
 #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
index 8bd5c417e711c3830d6168e24d2b773d8c099c53..b0113b6ca1c415dea687f7ab867595cc18be71b5 100644 (file)
@@ -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                 \