0020081: EDF 886 GEOM : GetShapesOnCylinderWithLocation function in TUI

+    ListOfGO GetShapesOnCylinderWithLocation (in GEOM_Object theShape,
This commit is contained in:
eap 2009-12-28 07:41:33 +00:00
parent 0b6826bc5f
commit ec1c5fd3a4
7 changed files with 332 additions and 5 deletions

View 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.

View File

@ -109,12 +109,13 @@
#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

View 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,

View 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

View 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,

View 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)

View 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.