]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
0020081: EDF 886 GEOM : GetShapesOnCylinderWithLocation function in TUI BR_FSH_DEV V6_0_0
authoreap <eap@opencascade.com>
Mon, 28 Dec 2009 07:41:33 +0000 (07:41 +0000)
committereap <eap@opencascade.com>
Mon, 28 Dec 2009 07:41:33 +0000 (07:41 +0000)
+    ListOfGO GetShapesOnCylinderWithLocation (in GEOM_Object theShape,

idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/GEOMImpl/GEOMImpl_IShapesOperations.hxx
src/GEOM_I/GEOM_IShapesOperations_i.cc
src/GEOM_I/GEOM_IShapesOperations_i.hh
src/GEOM_SWIG/GEOM_TestOthers.py
src/GEOM_SWIG/geompyDC.py

index 978cde0d2256233d1177829ae3ad715bc9dbcbab..0763fb49355c05b86db6aa5bd0b4b6ceba217bfe 100644 (file)
@@ -1516,6 +1516,25 @@ module GEOM
                                  in double      theRadius,
                                  in shape_state theState);
 
+    /*!
+     *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
+     *  the specified cylinder by the certain way, defined through \a theState parameter.
+     *  \param theShape Shape to find sub-shapes of.
+     *  \param theShapeType Type of sub-shapes to be retrieved.
+     *  \param theAxis Vector (or line, or linear edge), specifying
+     *                 axis of the cylinder to find shapes on.
+     *  \param thePnt Point specifying location of the bottom of the cylinder.
+     *  \param theRadius Radius of the cylinder to find shapes on.
+     *  \param theState The state of the subshapes to find.
+     *  \return List of all found sub-shapes.
+     */
+    ListOfGO GetShapesOnCylinderWithLocation (in GEOM_Object theShape,
+                                              in long        theShapeType,
+                                              in GEOM_Object theAxis,
+                                              in GEOM_Object thePnt,
+                                              in double      theRadius,
+                                              in shape_state theState);
+
     /*!
      *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
      *  the specified sphere by the certain way, defined through \a theState parameter.
@@ -1601,6 +1620,25 @@ module GEOM
                                       in double      theRadius,
                                       in shape_state theState);
 
+    /*!
+     *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
+     *  the specified cylinder by the certain way, defined through \a theState parameter.
+     *  \param theShape Shape to find sub-shapes of.
+     *  \param theShapeType Type of sub-shapes to be retrieved.
+     *  \param theAxis Vector (or line, or linear edge), specifying
+     *                 axis of the cylinder to find shapes on.
+     *  \param thePnt Point specifying location of the bottom of the cylinder.
+     *  \param theRadius Radius of the cylinder to find shapes on.
+     *  \param theState The state of the subshapes to find.
+     *  \return List of IDs all found sub-shapes.
+     */
+    ListOfLong GetShapesOnCylinderWithLocationIDs (in GEOM_Object theShape,
+                                                   in long        theShapeType,
+                                                   in GEOM_Object theAxis,
+                                                   in GEOM_Object thePnt,
+                                                   in double      theRadius,
+                                                   in shape_state theState);
+
     /*!
      *  Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
      *  the specified sphere by the certain way, defined through \a theState parameter.
index ecfdffee79e944a0ec23e52d293564161bbe4312..7e247e126a2440eafc5eb64ddb6e554d37bf9fd8 100644 (file)
 
 #include <Bnd_Box.hxx>
 #include <GProp_GProps.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Lin.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <TColStd_Array1OfReal.hxx>
 #include <TColStd_HArray1OfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <gp_Cylinder.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pnt.hxx>
 
 #include <vector>
 
@@ -2153,7 +2154,7 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlan
   gp_Vec aVec(BRep_Tool::Pnt(V1),BRep_Tool::Pnt(V2));
 
   if (aVec.Magnitude() < Precision::Confusion()) {
-     SetErrorCode("Vector with null magnitude given");
+    SetErrorCode("Vector with null magnitude given");
     return NULL;
   }
   Handle(Geom_Surface) aPlane = new Geom_Plane(aLoc, aVec);
@@ -2231,6 +2232,77 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCyli
   return aSeq;
 }
 
+//=============================================================================
+/*!
+ *  GetShapesOnCylinderWithLocation
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCylinderWithLocation
+                                          (const Handle(GEOM_Object)& theShape,
+                                           const Standard_Integer     theShapeType,
+                                           const Handle(GEOM_Object)& theAxis,
+                                           const Handle(GEOM_Object)& thePnt,
+                                           const Standard_Real        theRadius,
+                                           const GEOMAlgo_State       theState)
+{
+  SetErrorCode(KO);
+
+  if (theShape.IsNull() || theAxis.IsNull() || thePnt.IsNull()) return NULL;
+
+  TopoDS_Shape aShape = theShape->GetValue();
+  TopoDS_Shape anAxis = theAxis->GetValue();
+  TopoDS_Shape aPnt   = thePnt->GetValue();
+
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return NULL;
+
+  if (aPnt.ShapeType() != TopAbs_VERTEX )
+  {
+    SetErrorCode("Bottom location point must be vertex");
+    return NULL;
+  }
+
+  TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType);
+  if ( !checkTypeShapesOn( aShapeType ))
+    return NULL;
+
+  // Create a cylinder surface
+  Handle(Geom_Surface) aCylinder = makeCylinder( anAxis, theRadius );
+  if ( aCylinder.IsNull() )
+    return NULL;
+
+  // translate the surface
+  Handle(Geom_CylindricalSurface) aCylSurface =
+    Handle(Geom_CylindricalSurface)::DownCast( aCylinder );
+  if ( aCylSurface.IsNull() )
+  {
+    SetErrorCode("Unexpected surface type instead of Geom_CylindricalSurface");
+    return NULL;
+  }
+  gp_Pnt fromLoc = aCylSurface->Cylinder().Location();
+  gp_Pnt toLoc   = BRep_Tool::Pnt( TopoDS::Vertex( aPnt ));
+  aCylinder->Translate( fromLoc, toLoc );
+
+  // Find objects
+  TCollection_AsciiString anAsciiList;
+  Handle(TColStd_HSequenceOfTransient) aSeq;
+  aSeq = getShapesOnSurface( aCylinder, theShape, aShapeType, theState, anAsciiList );
+  if ( aSeq.IsNull() || aSeq->Length() == 0 )
+    return NULL;
+
+  // Make a Python command
+
+  Handle(GEOM_Object) anObj = Handle(GEOM_Object)::DownCast( aSeq->Value( 1 ));
+  Handle(GEOM_Function) aFunction = anObj->GetLastFunction();
+
+  GEOM::TPythonDump(aFunction)
+    << "[" << anAsciiList.ToCString()
+    << "] = geompy.GetShapesOnCylinderWithLocation(" << theShape << ", " << aShapeType << ", "
+    << theAxis << ", " << thePnt << ", " << theRadius << ", " << theState << ")";
+
+  SetErrorCode(OK);
+  return aSeq;
+}
+
 //=============================================================================
 /*!
  *  GetShapesOnSphere
@@ -2443,6 +2515,74 @@ Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnCylind
   return aSeq;
 }
 
+//=============================================================================
+/*!
+ *  GetShapesOnCylinderWithLocationIDs
+ */
+//=============================================================================
+Handle(TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations::GetShapesOnCylinderWithLocationIDs
+                                          (const Handle(GEOM_Object)& theShape,
+                                           const Standard_Integer     theShapeType,
+                                           const Handle(GEOM_Object)& theAxis,
+                                           const Handle(GEOM_Object)& thePnt,
+                                           const Standard_Real        theRadius,
+                                           const GEOMAlgo_State       theState)
+{
+  SetErrorCode(KO);
+
+  if (theShape.IsNull() || theAxis.IsNull() || thePnt.IsNull()) return NULL;
+
+  TopoDS_Shape aShape = theShape->GetValue();
+  TopoDS_Shape anAxis = theAxis->GetValue();
+  TopoDS_Shape aPnt   = thePnt->GetValue();
+
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return NULL;
+
+  if (aPnt.ShapeType() != TopAbs_VERTEX )
+  {
+    SetErrorCode("Bottom location point must be vertex");
+    return NULL;
+  }
+
+  TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType);
+  if ( !checkTypeShapesOn( aShapeType ))
+    return NULL;
+
+  // Create a cylinder surface
+  Handle(Geom_Surface) aCylinder = makeCylinder( anAxis, theRadius );
+  if ( aCylinder.IsNull() )
+    return NULL;
+
+  // translate the surface
+  Handle(Geom_CylindricalSurface) aCylSurface =
+    Handle(Geom_CylindricalSurface)::DownCast( aCylinder );
+  if ( aCylSurface.IsNull() )
+  {
+    SetErrorCode("Unexpected surface type instead of Geom_CylindricalSurface");
+    return NULL;
+  }
+  gp_Pnt fromLoc = aCylSurface->Cylinder().Location();
+  gp_Pnt toLoc   = BRep_Tool::Pnt( TopoDS::Vertex( aPnt ));
+  aCylinder->Translate( fromLoc, toLoc );
+
+  // Find object IDs
+  Handle(TColStd_HSequenceOfInteger) aSeq;
+  aSeq = getShapesOnSurfaceIDs( aCylinder, aShape, aShapeType, theState );
+
+  // The GetShapesOnCylinder() doesn't change object so no new function is required.
+  Handle(GEOM_Function) aFunction = 
+    GEOM::GetCreatedLast(theShape, GEOM::GetCreatedLast(thePnt,theAxis))->GetLastFunction();
+
+  // Make a Python command
+  GEOM::TPythonDump(aFunction, /*append=*/true)
+    << "listShapesOnCylinder = geompy.GetShapesOnCylinderWithLocationIDs"
+    << "(" << theShape << ", " << aShapeType << ", " << theAxis << ", "
+    << thePnt << ", " << theRadius << ", " << theState << ")";
+
+  SetErrorCode(OK);
+  return aSeq;
+}
+
 //=============================================================================
 /*!
  *  GetShapesOnSphereIDs
index 859fb6ead0f3f53795556e833ebc8ea71dfed2a7..27da52b1fb90ef712e76b65899b36874c3e7534d 100644 (file)
@@ -134,6 +134,14 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
                          const Standard_Real        theRadius,
                          const GEOMAlgo_State       theState);
 
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
+    GetShapesOnCylinderWithLocation (const Handle(GEOM_Object)& theShape,
+                                     const Standard_Integer     theShapeType,
+                                     const Handle(GEOM_Object)& theAxis,
+                                     const Handle(GEOM_Object)& thePnt,
+                                     const Standard_Real        theRadius,
+                                     const GEOMAlgo_State       theState);
+
   Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
     GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
                        const Standard_Integer     theShapeType,
@@ -161,6 +169,14 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations
                             const Standard_Real        theRadius,
                             const GEOMAlgo_State       theState);
 
+  Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
+    GetShapesOnCylinderWithLocationIDs (const Handle(GEOM_Object)& theShape,
+                                        const Standard_Integer     theShapeType,
+                                        const Handle(GEOM_Object)& theAxis,
+                                        const Handle(GEOM_Object)& thePnt,
+                                        const Standard_Real        theRadius,
+                                        const GEOMAlgo_State       theState);
+
   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
     GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
                           const Standard_Integer     theShapeType,
index 7013c56fd24c7ffb1e85530b4fc82b70c8101e6f..3681742cae5e11d3154fdbb067c6ffb16492e882 100644 (file)
@@ -809,6 +809,45 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
   return aSeq._retn();
 }
 
+//=============================================================================
+/*!
+ *  GetShapesOnCylinderWithLocation
+ */
+//=============================================================================
+GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocation
+                                                (GEOM::GEOM_Object_ptr   theShape,
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
+{
+  GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
+  Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
+
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
+
+  //Get Shapes On Cylinder
+  Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinderWithLocation
+    (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
+
+  return aSeq._retn();
+}
+
 //=============================================================================
 /*!
  *  GetShapesOnSphere
@@ -1007,6 +1046,45 @@ GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderIDs
   return aSeq._retn();
 }
 
+//=============================================================================
+/*!
+ *  GetShapesOnCylinderWithLocationIDs
+ */
+//=============================================================================
+GEOM::ListOfLong* GEOM_IShapesOperations_i::GetShapesOnCylinderWithLocationIDs
+                                                (GEOM::GEOM_Object_ptr   theShape,
+                                                 const CORBA::Long       theShapeType,
+                                                 GEOM::GEOM_Object_ptr   theAxis,
+                                                 GEOM::GEOM_Object_ptr   thePnt,
+                                                 const CORBA::Double     theRadius,
+                                                 const GEOM::shape_state theState)
+{
+  GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
+
+  //Set a not done flag
+  GetOperations()->SetNotDone();
+
+  //Get the reference objects
+  Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
+  Handle(GEOM_Object) anAxis = GetObjectImpl(theAxis);
+  Handle(GEOM_Object) aPnt   = GetObjectImpl(thePnt);
+
+  if (aShape.IsNull() || anAxis.IsNull() || aPnt.IsNull()) return aSeq._retn();
+
+  //Get Shapes On Cylinder
+  Handle(TColStd_HSequenceOfInteger) aHSeq = GetOperations()->GetShapesOnCylinderWithLocationIDs
+    (aShape, theShapeType, anAxis, aPnt, theRadius, ShapeState(theState));
+  if (!GetOperations()->IsDone() || aHSeq.IsNull())
+    return aSeq._retn();
+
+  Standard_Integer aLength = aHSeq->Length();
+  aSeq->length(aLength);
+  for (Standard_Integer i = 1; i <= aLength; i++)
+    aSeq[i-1] = aHSeq->Value(i);
+
+  return aSeq._retn();
+}
+
 //=============================================================================
 /*!
  *  GetShapesOnSphereIDs
index 61747cc3662faac98d93c5041f6d3cbcf6d8c2ad..acc80263fdb74ed16102d651db3fbdbdba67afc9 100644 (file)
@@ -124,6 +124,13 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i :
                                       CORBA::Double         theRadius,
                                       GEOM::shape_state     theState);
 
+  GEOM::ListOfGO* GetShapesOnCylinderWithLocation (GEOM::GEOM_Object_ptr theShape,
+                                                   CORBA::Long           theShapeType,
+                                                   GEOM::GEOM_Object_ptr theAxis,
+                                                   GEOM::GEOM_Object_ptr thePnt,
+                                                   CORBA::Double         theRadius,
+                                                   GEOM::shape_state     theState);
+
   GEOM::ListOfGO* GetShapesOnSphere (GEOM::GEOM_Object_ptr theShape,
                                     CORBA::Long           theShapeType,
                                     GEOM::GEOM_Object_ptr theCenter,
@@ -155,6 +162,13 @@ class GEOM_I_EXPORT GEOM_IShapesOperations_i :
                                            CORBA::Double         theRadius,
                                            GEOM::shape_state     theState);
 
+  GEOM::ListOfLong* GetShapesOnCylinderWithLocationIDs (GEOM::GEOM_Object_ptr theShape,
+                                                        CORBA::Long           theShapeType,
+                                                        GEOM::GEOM_Object_ptr theAxis,
+                                                        GEOM::GEOM_Object_ptr thePnt,
+                                                        CORBA::Double         theRadius,
+                                                        GEOM::shape_state     theState);
+
   GEOM::ListOfLong* GetShapesOnSphereIDs (GEOM::GEOM_Object_ptr theShape,
                                          CORBA::Long           theShapeType,
                                          GEOM::GEOM_Object_ptr theCenter,
index fb8c18bf8af5c028e2b6a20cd80a5570a7cf9bc8..dc3ac505dd8316f0ba67b675a2755e1411b4d6ba 100644 (file)
@@ -551,6 +551,19 @@ def TestOtherOperations (geompy, math):
   geompy.UnionIDs(edges_in, edges_in_cyl_ids)
   geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)")
 
+  # GetShapesOnCylinderWithLocation
+  edges_out_cyl = geompy.GetShapesOnCylinderWithLocation(blocksComp, geompy.ShapeType["EDGE"],
+                                                         vy, 55, geompy.GEOM.ST_OUT)
+  for edge_i in edges_out_cyl:
+    geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), r = 55)")
+
+  # GetShapesOnCylinderIDs
+  edges_in_cyl_ids = geompy.GetShapesOnCylinderIDs(blocksComp, geompy.ShapeType["EDGE"],
+                                                   vy, 80, geompy.GEOM.ST_IN)
+  edges_in = geompy.CreateGroup(blocksComp, geompy.ShapeType["EDGE"])
+  geompy.UnionIDs(edges_in, edges_in_cyl_ids)
+  geompy.addToStudy(edges_in, "Group of edges inside Cylinder (axis = (0, 1, 0), r = 55)")
+
   # GetShapesOnSphere
   vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"],
                                              p0, 100, geompy.GEOM.ST_ON)
index c8ef92793f9a967e0a405260321f5ad3903b1394..4e05cc58dd0296ccf1e32a41e23809601212e436 100644 (file)
@@ -1774,6 +1774,34 @@ class geompyDC(GEOM._objref_GEOM_Gen):
             RaiseIfFailed("GetShapesOnCylinderIDs", self.ShapesOp)
             return aList
 
+        ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
+        #  the specified cylinder by the certain way, defined through \a theState parameter.
+        #  @param theShape Shape to find sub-shapes of.
+        #  @param theShapeType Type of sub-shapes to be retrieved.
+        #  @param theAxis Vector (or line, or linear edge), specifying
+        #                 axis of the cylinder to find shapes on.
+        #  @param thePnt Point specifying location of the bottom of the cylinder.
+        #  @param theRadius Radius of the cylinder to find shapes on.
+        #  @param theState The state of the subshapes to find. It can be one of
+        #   ST_ON, ST_OUT, ST_ONOUT, ST_IN, ST_ONIN.
+        #  @return List of all found sub-shapes.
+        #
+        #  @ref swig_GetShapesOnCylinderWithLocation "Example"
+        def GetShapesOnCylinderWithLocation(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState):
+            # Example: see GEOM_TestOthers.py
+            aList = self.ShapesOp.GetShapesOnCylinderWithLocation(theShape, theShapeType, theAxis, thePnt, theRadius, theState)
+            RaiseIfFailed("GetShapesOnCylinderWithLocation", self.ShapesOp)
+            return aList
+
+        ## Works like the above method, but returns list of sub-shapes indices
+        #
+        #  @ref swig_GetShapesOnCylinderWithLocationIDs "Example"
+        def GetShapesOnCylinderWithLocationIDs(self, theShape, theShapeType, theAxis, thePnt, theRadius, theState):
+            # Example: see GEOM_TestOthers.py
+            aList = self.ShapesOp.GetShapesOnCylinderWithLocationIDs(theShape, theShapeType, theAxis, thePnt, theRadius, theState)
+            RaiseIfFailed("GetShapesOnCylinderWithLocationIDs", self.ShapesOp)
+            return aList
+
         ## Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
         #  the specified sphere by the certain way, defined through \a theState parameter.
         #  @param theShape Shape to find sub-shapes of.