PAL7508. Update implementation of GetShapesOn<xxx>() functions.

This commit is contained in:
jfa 2005-01-21 09:16:41 +00:00
parent 1cfac3e905
commit 23c12be7ac
8 changed files with 632 additions and 265 deletions

View File

@ -18,6 +18,44 @@ module GEOM
enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL, enum shape_type { COMPOUND, COMPSOLID, SOLID, SHELL,
FACE, WIRE, EDGE, VERTEX, SHAPE }; FACE, WIRE, EDGE, VERTEX, SHAPE };
/*!
* State of shape relatively geometrical surface like plane, sphere or cylinder.
* Is used in functions GEOM_IShapesOperations.GetShapesOn<xxx>()
*/
enum shape_state
{
/*! Shape is on surface */
ST_ON,
/*!
* Shape is in the direction defined by the normal and not on surface.
* For plane it means above the plane,
* For sphere and cylinder it means outside of volume, bounded by the surface.
*/
ST_OUT,
/*!
* Shape is in the direction defined by the normal and on surface.
* ONOUT = ON || OUT
*/
ST_ONOUT,
/*!
* Complementary to ONOUT.
* For plane it means below the plane,
* For sphere and cylinder it means inside the volume, bounded by the surface
* (beyond axis and surface for cylinder and beyond cented and surface for sphere).
*/
ST_IN,
/*!
* Complementary to OUT.
* ONIN = ON || IN
*/
ST_ONIN
};
typedef sequence<string> string_array; typedef sequence<string> string_array;
typedef sequence<short> short_array; typedef sequence<short> short_array;
typedef sequence<long> ListOfLong; typedef sequence<long> ListOfLong;
@ -877,45 +915,52 @@ module GEOM
in long theShapeType); in long theShapeType);
/*! /*!
* Get sub-shapes of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified plane. * the specified plane by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param thePlane Face, specifying the plane to find shapes on. * \param theAx1 Vector (or line, or linear edge), specifying normal
* \return Group of all found sub-shapes. * direction and location of the plane to find shapes on.
* \param theState The state of the subshapes to find.
* \return List of all found sub-shapes.
*/ */
GEOM_Object GetShapesOnPlane (in GEOM_Object theShape, ListOfGO GetShapesOnPlane (in GEOM_Object theShape,
in long theShapeType, in long theShapeType,
in GEOM_Object thePlane); in GEOM_Object theAx1,
in shape_state theState);
/*! /*!
* Get sub-shape of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified cylinder. * the specified cylinder by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param theAxis Vector (or line, or linear edge), specifying * \param theAxis Vector (or line, or linear edge), specifying
* axis of the cylinder to find shapes on. * axis of the cylinder to find shapes on.
* \param theRadius Radius of the cylinder to find shapes on. * \param theRadius Radius of the cylinder to find shapes on.
* \return Group of all found sub-shapes. * \param theState The state of the subshapes to find.
* \return List of all found sub-shapes.
*/ */
GEOM_Object GetShapesOnCylinder (in GEOM_Object theShape, ListOfGO GetShapesOnCylinder (in GEOM_Object theShape,
in long theShapeType, in long theShapeType,
in GEOM_Object theAxis, in GEOM_Object theAxis,
in double theRadius); in double theRadius,
in shape_state theState);
/*! /*!
* Get sub-shape of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified sphere. * the specified sphere by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param theCenter Point, specifying center of the sphere to find shapes on. * \param theCenter Point, specifying center of the sphere to find shapes on.
* \param theRadius Radius of the sphere to find shapes on. * \param theRadius Radius of the sphere to find shapes on.
* \return Group of all found sub-shapes. * \param theState The state of the subshapes to find.
* \return List of all found sub-shapes.
*/ */
GEOM_Object GetShapesOnSphere (in GEOM_Object theShape, ListOfGO GetShapesOnSphere (in GEOM_Object theShape,
in long theShapeType, in long theShapeType,
in GEOM_Object theCenter, in GEOM_Object theCenter,
in double theRadius); in double theRadius,
in shape_state theState);
/*! /*!
* Get sub-shape(s) of theShapeWhere, which are * Get sub-shape(s) of theShapeWhere, which are

View File

@ -17,6 +17,8 @@ using namespace std;
#include "GEOM_Function.hxx" #include "GEOM_Function.hxx"
#include "GEOMAlgo_FinderShapeOn.hxx"
#include "utilities.h" #include "utilities.h"
#include "OpUtil.hxx" #include "OpUtil.hxx"
#include "Utils_ExceptHandlers.hxx" #include "Utils_ExceptHandlers.hxx"
@ -1014,19 +1016,20 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetSharedShapes
* GetShapesOnPlane * GetShapesOnPlane
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnPlane Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnPlane
(Handle(GEOM_Object) theShape, (const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) thePlane) const Handle(GEOM_Object)& theAx1,
const GEOMAlgo_State theState)
{ {
SetErrorCode(KO); SetErrorCode(KO);
if (theShape.IsNull() || thePlane.IsNull()) return NULL; if (theShape.IsNull() || theAx1.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue(); TopoDS_Shape aShape = theShape->GetValue();
TopoDS_Shape aPlane = thePlane->GetValue(); TopoDS_Shape anAx1 = theAx1->GetValue();
if (aShape.IsNull() || aPlane.IsNull()) return NULL; if (aShape.IsNull() || anAx1.IsNull()) return NULL;
TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType); TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType);
if (aShapeType != TopAbs_VERTEX && if (aShapeType != TopAbs_VERTEX &&
@ -1036,131 +1039,96 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnPlane
return NULL; return NULL;
} }
//Get plane parameters // Create plane
if (aPlane.IsNull() || aPlane.ShapeType() != TopAbs_FACE) return NULL; if (anAx1.ShapeType() != TopAbs_EDGE) return NULL;
TopoDS_Face aFace = TopoDS::Face(aPlane); TopoDS_Edge anEdge = TopoDS::Edge(anAx1);
Handle(Geom_Surface) surf = BRep_Tool::Surface(aFace); TopoDS_Vertex V1, V2;
Handle(Geom_Plane) pln = Handle(Geom_Plane)::DownCast(surf); TopExp::Vertices(anEdge, V1, V2, Standard_True);
if (pln.IsNull()) { if (V1.IsNull() || V2.IsNull()) {
SetErrorCode("Not planar face given"); SetErrorCode("Bad edge given for the plane normal vector");
return NULL; return NULL;
} }
const gp_Ax3 pos = pln->Position(); gp_Pnt aLoc = BRep_Tool::Pnt(V1);
const gp_Pnt loc = pos.Location(); gp_Vec aVec (aLoc, BRep_Tool::Pnt(V2));
const gp_Dir dir = pos.Direction(); if (aVec.Magnitude() < Precision::Confusion()) {
SetErrorCode("Vector with null magnitude given");
//Find sub-shapes on the plane return NULL;
TopTools_ListOfShape listSS;
TopTools_MapOfShape mapShapes;
TopExp_Explorer exp (aShape, aShapeType);
for (; exp.More(); exp.Next()) {
TopoDS_Shape aSS = exp.Current();
if (mapShapes.Add(aSS)) {
switch (aShapeType) {
case TopAbs_VERTEX:
{
TopoDS_Vertex aV = TopoDS::Vertex(aSS);
gp_Pnt aP = BRep_Tool::Pnt(aV);
gp_Vec vecToLoc (aP, loc);
if (vecToLoc.IsNormal(dir, Precision::Angular())) {
listSS.Append(aSS);
}
}
break;
case TopAbs_EDGE:
{
TopoDS_Edge anEdge = TopoDS::Edge(aSS);
Standard_Real f, l;
Handle(Geom2d_Curve) PC;
Handle(Geom_Surface) cur_surf;
TopLoc_Location L;
Standard_Integer i = 0;
// iterate on the surfaces of the edge
while (Standard_True) {
i++;
BRep_Tool::CurveOnSurface(anEdge, PC , cur_surf, L, f, l, i);
if (cur_surf.IsNull()) break;
Handle(Geom_Plane) cur_pln = Handle(Geom_Plane)::DownCast(cur_surf);
if (!cur_pln.IsNull()) {
const gp_Ax3 cur_pos = cur_pln->Position();
const gp_Pnt cur_loc = cur_pos.Location();
const gp_Dir cur_dir = cur_pos.Direction();
gp_Vec vecToLoc (cur_loc, loc);
if (vecToLoc.IsNormal(dir, Precision::Angular()) &&
cur_dir.IsParallel(dir, Precision::Angular())) {
listSS.Append(aSS);
}
}
}
}
break;
case TopAbs_FACE:
{
TopoDS_Face aF = TopoDS::Face(aSS);
Handle(Geom_Surface) cur_surf = BRep_Tool::Surface(aF);
Handle(Geom_Plane) cur_pln = Handle(Geom_Plane)::DownCast(cur_surf);
if (!cur_pln.IsNull()) {
const gp_Ax3 cur_pos = cur_pln->Position();
const gp_Pnt cur_loc = cur_pos.Location();
const gp_Dir cur_dir = cur_pos.Direction();
gp_Vec vecToLoc (cur_loc, loc);
if (vecToLoc.IsNormal(dir, Precision::Angular()) &&
cur_dir.IsParallel(dir, Precision::Angular())) {
listSS.Append(aSS);
}
}
}
break;
default:
break;
}
}
} }
Handle(Geom_Plane) aPlane = new Geom_Plane(aLoc, - aVec);
// The "-" is because interpretation of normale differs
// between interface and algorithm for the case of plane
// Call algo
GEOMAlgo_FinderShapeOn aFinder;
Standard_Real aTol = 0.0001; // default value
aFinder.SetShape(aShape);
aFinder.SetTolerance(aTol);
aFinder.SetSurface(aPlane);
aFinder.SetShapeType(aShapeType);
aFinder.SetState(theState);
aFinder.Perform();
// Interprete results
Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn.cxx
if (iErr) {
MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : ");
aMsg += TCollection_AsciiString(iErr);
SetErrorCode(aMsg);
return NULL;
}
Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn.cxx
if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn);
}
const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
if (listSS.Extent() < 1) { if (listSS.Extent() < 1) {
SetErrorCode("Not a single sub-shape of the requested type found on the given plane"); SetErrorCode("Not a single sub-shape of the requested type found on the given plane");
return NULL; return NULL;
} }
//Fill array of indices // Fill sequence of objects
TopTools_IndexedMapOfShape anIndices; TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices); TopExp::MapShapes(aShape, anIndices);
Handle(TColStd_HArray1OfInteger) anArray = Handle(GEOM_Object) anObj;
new TColStd_HArray1OfInteger (1, listSS.Extent()); Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TopTools_ListIteratorOfListOfShape itSub (listSS); TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) { for (int index = 1; itSub.More(); itSub.Next(), ++index) {
int id = anIndices.FindIndex(itSub.Value()); int id = anIndices.FindIndex(itSub.Value());
anArray->SetValue(index, id); anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj);
} }
//Add a new group object // The GetShapesOnPlane() doesn't change object so no new function is required.
Handle(GEOM_Object) aGroup = GetEngine()->AddSubShape(theShape, anArray); Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
//Set a GROUP type // Make a Python command
aGroup->SetType(GEOM_GROUP); TCollection_AsciiString anEntry, aDescr
("\nlistShapesOnPlane = IShapesOperations.GetShapesOnPlane(");
//Set a sub shape type
TDF_Label aFreeLabel = aGroup->GetFreeLabel();
TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)theShapeType);
//Make a Python command
TCollection_AsciiString anEntry, aDescr;
TDF_Tool::Entry(aGroup->GetEntry(), anEntry);
aDescr += anEntry;
aDescr += " = IShapesOperations.GetShapesOnPlane(";
TDF_Tool::Entry(theShape->GetEntry(), anEntry); TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + TCollection_AsciiString(theShapeType) + ","; aDescr += anEntry + TCollection_AsciiString(theShapeType) + ",";
TDF_Tool::Entry(thePlane->GetEntry(), anEntry); TDF_Tool::Entry(theAx1->GetEntry(), anEntry);
aDescr += anEntry + ")"; aDescr += anEntry + ",";
aDescr += TCollection_AsciiString(theState) + ")";
Handle(GEOM_Function) aFunction = aGroup->GetFunction(1); TCollection_AsciiString anOldDescr = aFunction->GetDescription();
aFunction->SetDescription(aDescr); anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr);
SetErrorCode(OK); SetErrorCode(OK);
return aGroup; return aSeq;
} }
//============================================================================= //=============================================================================
@ -1168,7 +1136,242 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnPlane
* GetShapesOnCylinder * GetShapesOnCylinder
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnCylinder Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnCylinder
(const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType,
const Handle(GEOM_Object)& theAxis,
const Standard_Real theRadius,
const GEOMAlgo_State theState)
{
SetErrorCode(KO);
if (theShape.IsNull() || theAxis.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue();
TopoDS_Shape anAxis = theAxis->GetValue();
if (aShape.IsNull() || anAxis.IsNull()) return NULL;
TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType);
if (aShapeType != TopAbs_VERTEX &&
aShapeType != TopAbs_EDGE &&
aShapeType != TopAbs_FACE) {
SetErrorCode("Not implemented for the given sub-shape type");
return NULL;
}
//Axis of the cylinder
if (anAxis.ShapeType() != TopAbs_EDGE) {
SetErrorCode("Not an edge given for the axis");
return NULL;
}
TopoDS_Edge anEdge = TopoDS::Edge(anAxis);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anEdge, V1, V2, Standard_True);
if (V1.IsNull() || V2.IsNull()) {
SetErrorCode("Bad edge given for the axis");
return NULL;
}
gp_Pnt aLoc = BRep_Tool::Pnt(V1);
gp_Vec aVec (aLoc, BRep_Tool::Pnt(V2));
if (aVec.Magnitude() < Precision::Confusion()) {
SetErrorCode("Vector with null magnitude given");
return NULL;
}
gp_Ax3 anAx3 (aLoc, aVec);
Handle(Geom_CylindricalSurface) aCylinder =
new Geom_CylindricalSurface(anAx3, theRadius);
// Call algo
GEOMAlgo_FinderShapeOn aFinder;
Standard_Real aTol = 0.0001; // default value
aFinder.SetShape(aShape);
aFinder.SetTolerance(aTol);
aFinder.SetSurface(aCylinder);
aFinder.SetShapeType(aShapeType);
aFinder.SetState(theState);
aFinder.Perform();
// Interprete results
Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn.cxx
if (iErr) {
MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : ");
aMsg += TCollection_AsciiString(iErr);
SetErrorCode(aMsg);
return NULL;
}
Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn.cxx
if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn);
}
const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
if (listSS.Extent() < 1) {
SetErrorCode("Not a single sub-shape of the requested type found on the given cylinder");
return NULL;
}
// Fill sequence of objects
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices);
Handle(GEOM_Object) anObj;
Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) {
int id = anIndices.FindIndex(itSub.Value());
anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj);
}
// The GetShapesOnCylinder() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
// Make a Python command
TCollection_AsciiString anEntry, aDescr
("\nlistShapesOnCylinder = IShapesOperations.GetShapesOnCylinder(");
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + TCollection_AsciiString(theShapeType) + ",";
TDF_Tool::Entry(theAxis->GetEntry(), anEntry);
aDescr += anEntry + ",";
aDescr += TCollection_AsciiString(theRadius) + ",";
aDescr += TCollection_AsciiString(theState) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr);
SetErrorCode(OK);
return aSeq;
}
//=============================================================================
/*!
* GetShapesOnSphere
*/
//=============================================================================
Handle(TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations::GetShapesOnSphere
(const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType,
const Handle(GEOM_Object)& theCenter,
const Standard_Real theRadius,
const GEOMAlgo_State theState)
{
SetErrorCode(KO);
if (theShape.IsNull() || theCenter.IsNull()) return NULL;
TopoDS_Shape aShape = theShape->GetValue();
TopoDS_Shape aCenter = theCenter->GetValue();
if (aShape.IsNull() || aCenter.IsNull()) return NULL;
TopAbs_ShapeEnum aShapeType = TopAbs_ShapeEnum(theShapeType);
if (aShapeType != TopAbs_VERTEX &&
aShapeType != TopAbs_EDGE &&
aShapeType != TopAbs_FACE) {
SetErrorCode("Not implemented for the given sub-shape type");
return NULL;
}
// Center of the sphere
if (aCenter.ShapeType() != TopAbs_VERTEX) return NULL;
gp_Pnt aLoc = BRep_Tool::Pnt(TopoDS::Vertex(aCenter));
gp_Ax3 anAx3 (aLoc, gp::DZ());
Handle(Geom_SphericalSurface) aSphere =
new Geom_SphericalSurface(anAx3, theRadius);
// Call algo
GEOMAlgo_FinderShapeOn aFinder;
Standard_Real aTol = 0.0001; // default value
aFinder.SetShape(aShape);
aFinder.SetTolerance(aTol);
aFinder.SetSurface(aSphere);
aFinder.SetShapeType(aShapeType);
aFinder.SetState(theState);
aFinder.Perform();
// Interprete results
Standard_Integer iErr = aFinder.ErrorStatus();
// the detailed description of error codes is in GEOMAlgo_FinderShapeOn.cxx
if (iErr) {
MESSAGE(" iErr : " << iErr);
TCollection_AsciiString aMsg (" iErr : ");
aMsg += TCollection_AsciiString(iErr);
SetErrorCode(aMsg);
return NULL;
}
Standard_Integer iWrn = aFinder.WarningStatus();
// the detailed description of warning codes is in GEOMAlgo_FinderShapeOn.cxx
if (iWrn) {
MESSAGE(" *** iWrn : " << iWrn);
}
const TopTools_ListOfShape& listSS = aFinder.Shapes(); // the result
if (listSS.Extent() < 1) {
SetErrorCode("Not a single sub-shape of the requested type found on the given sphere");
return NULL;
}
// Fill sequence of objects
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aShape, anIndices);
Handle(GEOM_Object) anObj;
Handle(TColStd_HArray1OfInteger) anArray;
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
TopTools_ListIteratorOfListOfShape itSub (listSS);
for (int index = 1; itSub.More(); itSub.Next(), ++index) {
int id = anIndices.FindIndex(itSub.Value());
anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, id);
anObj = GetEngine()->AddSubShape(theShape, anArray);
aSeq->Append(anObj);
}
// The GetShapesOnSphere() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
// Make a Python command
TCollection_AsciiString anEntry, aDescr
("\nlistShapesOnSphere = IShapesOperations.GetShapesOnSphere(");
TDF_Tool::Entry(theShape->GetEntry(), anEntry);
aDescr += anEntry + TCollection_AsciiString(theShapeType) + ",";
TDF_Tool::Entry(theCenter->GetEntry(), anEntry);
aDescr += anEntry + ",";
aDescr += TCollection_AsciiString(theRadius) + ",";
aDescr += TCollection_AsciiString(theState) + ")";
TCollection_AsciiString anOldDescr = aFunction->GetDescription();
anOldDescr += aDescr;
aFunction->SetDescription(anOldDescr);
SetErrorCode(OK);
return aSeq;
}
//=============================================================================
/*!
* GetShapesOnCylinderOld
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnCylinderOld
(Handle(GEOM_Object) theShape, (Handle(GEOM_Object) theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) theAxis, Handle(GEOM_Object) theAxis,
@ -1329,10 +1532,10 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnCylinder
//============================================================================= //=============================================================================
/*! /*!
* GetShapesOnSphere * GetShapesOnSphereOld
*/ */
//============================================================================= //=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnSphere Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetShapesOnSphereOld
(Handle(GEOM_Object) theShape, (Handle(GEOM_Object) theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) theCenter, Handle(GEOM_Object) theCenter,

View File

@ -4,6 +4,8 @@
#include "GEOM_IOperations.hxx" #include "GEOM_IOperations.hxx"
#include "GEOMAlgo_State.hxx"
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
#include <TColStd_HSequenceOfTransient.hxx> #include <TColStd_HSequenceOfTransient.hxx>
#include <TColStd_HSequenceOfInteger.hxx> #include <TColStd_HSequenceOfInteger.hxx>
@ -62,19 +64,32 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
Handle(GEOM_Object) theShape2, Handle(GEOM_Object) theShape2,
const Standard_Integer theShapeType); const Standard_Integer theShapeType);
Handle(GEOM_Object) GetShapesOnPlane (Handle(GEOM_Object) theShape, Handle(TColStd_HSequenceOfTransient) GetShapesOnPlane (const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) thePlane); const Handle(GEOM_Object)& theAx1,
const GEOMAlgo_State theState);
Handle(GEOM_Object) GetShapesOnCylinder (Handle(GEOM_Object) theShape, Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) theAxis, const Handle(GEOM_Object)& theAxis,
const Standard_Real theRadius); const Standard_Real theRadius,
const GEOMAlgo_State theState);
Handle(GEOM_Object) GetShapesOnSphere (Handle(GEOM_Object) theShape, Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
const Standard_Integer theShapeType, const Standard_Integer theShapeType,
Handle(GEOM_Object) theCenter, const Handle(GEOM_Object)& theCenter,
const Standard_Real theRadius); const Standard_Real theRadius,
const GEOMAlgo_State theState);
Handle(GEOM_Object) GetShapesOnCylinderOld (Handle(GEOM_Object) theShape,
const Standard_Integer theShapeType,
Handle(GEOM_Object) theAxis,
const Standard_Real theRadius);
Handle(GEOM_Object) GetShapesOnSphereOld (Handle(GEOM_Object) theShape,
const Standard_Integer theShapeType,
Handle(GEOM_Object) theCenter,
const Standard_Real theRadius);
Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere, Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
Handle(GEOM_Object) theShapeWhat); Handle(GEOM_Object) theShapeWhat);

View File

@ -491,6 +491,9 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::ChangeOrientation
//============================================================================= //=============================================================================
GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape) GEOM::ListOfLong* GEOM_IShapesOperations_i::GetFreeFacesIDs (GEOM::GEOM_Object_ptr theShape)
{ {
//Set a not done flag
GetOperations()->SetNotDone();
GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong; GEOM::ListOfLong_var aSeq = new GEOM::ListOfLong;
if (theShape == NULL) return aSeq._retn(); if (theShape == NULL) return aSeq._retn();
@ -519,6 +522,9 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
GEOM::GEOM_Object_ptr theShape2, GEOM::GEOM_Object_ptr theShape2,
const CORBA::Long theShapeType) const CORBA::Long theShapeType)
{ {
//Set a not done flag
GetOperations()->SetNotDone();
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO; GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
if (theShape1 == NULL || if (theShape1 == NULL ||
theShape2 == NULL) return aSeq._retn(); theShape2 == NULL) return aSeq._retn();
@ -544,40 +550,72 @@ GEOM::ListOfGO* GEOM_IShapesOperations_i::GetSharedShapes
return aSeq._retn(); return aSeq._retn();
} }
static GEOMAlgo_State ShapeState (const GEOM::shape_state theState)
{
GEOMAlgo_State aState = GEOMAlgo_ST_UNKNOWN;
switch (theState) {
case GEOM::ST_ON:
aState = GEOMAlgo_ST_ON;
break;
case GEOM::ST_OUT:
aState = GEOMAlgo_ST_OUT;
break;
case GEOM::ST_ONOUT:
aState = GEOMAlgo_ST_ONOUT;
break;
case GEOM::ST_IN:
aState = GEOMAlgo_ST_IN;
break;
case GEOM::ST_ONIN:
aState = GEOMAlgo_ST_ONIN;
break;
default:
break;
}
return aState;
}
//============================================================================= //=============================================================================
/*! /*!
* GetShapesOnPlane * GetShapesOnPlane
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnPlane GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnPlane
(GEOM::GEOM_Object_ptr theShape, (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr thePlane) GEOM::GEOM_Object_ptr theAx1,
const GEOM::shape_state theState)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::ListOfGO_var aSeq;
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
if (theShape == NULL || if (theShape == NULL || theAx1 == NULL) return aSeq._retn();
thePlane == NULL) return aGEOMObject._retn();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
(theShape->GetStudyID(), theShape->GetEntry()); (theShape->GetStudyID(), theShape->GetEntry());
Handle(GEOM_Object) aPlane = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) anAx1 = GetOperations()->GetEngine()->GetObject
(thePlane->GetStudyID(), thePlane->GetEntry()); (theAx1->GetStudyID(), theAx1->GetEntry());
if (aShape.IsNull() || if (aShape.IsNull() || anAx1.IsNull()) return aSeq._retn();
aPlane.IsNull()) return aGEOMObject._retn();
//Get Shapes On Plane //Get Shapes On Plane
Handle(GEOM_Object) anObject = Handle(TColStd_HSequenceOfTransient) aHSeq =
GetOperations()->GetShapesOnPlane(aShape, theShapeType, aPlane); GetOperations()->GetShapesOnPlane(aShape, theShapeType, anAx1, ShapeState(theState));
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || aHSeq.IsNull())
return aGEOMObject._retn(); return aSeq._retn();
return GetObject(anObject); Standard_Integer aLength = aHSeq->Length();
aSeq = new GEOM::ListOfGO;
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();
} }
//============================================================================= //=============================================================================
@ -585,19 +623,19 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnPlane
* GetShapesOnCylinder * GetShapesOnCylinder
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnCylinder GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnCylinder
(GEOM::GEOM_Object_ptr theShape, (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr theAxis, GEOM::GEOM_Object_ptr theAxis,
const CORBA::Double theRadius) const CORBA::Double theRadius,
const GEOM::shape_state theState)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::ListOfGO_var aSeq;
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
if (theShape == NULL || if (theShape == NULL || theAxis == NULL) return aSeq._retn();
theAxis == NULL) return aGEOMObject._retn();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
@ -605,16 +643,21 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnCylinder
Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) anAxis = GetOperations()->GetEngine()->GetObject
(theAxis->GetStudyID(), theAxis->GetEntry()); (theAxis->GetStudyID(), theAxis->GetEntry());
if (aShape.IsNull() || if (aShape.IsNull() || anAxis.IsNull()) return aSeq._retn();
anAxis.IsNull()) return aGEOMObject._retn();
//Get Shapes On Cylinder //Get Shapes On Cylinder
Handle(GEOM_Object) anObject = Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnCylinder
GetOperations()->GetShapesOnCylinder(aShape, theShapeType, anAxis, theRadius); (aShape, theShapeType, anAxis, theRadius, ShapeState(theState));
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || aHSeq.IsNull())
return aGEOMObject._retn(); return aSeq._retn();
return GetObject(anObject); Standard_Integer aLength = aHSeq->Length();
aSeq = new GEOM::ListOfGO;
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();
} }
//============================================================================= //=============================================================================
@ -622,19 +665,19 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnCylinder
* GetShapesOnSphere * GetShapesOnSphere
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnSphere GEOM::ListOfGO* GEOM_IShapesOperations_i::GetShapesOnSphere
(GEOM::GEOM_Object_ptr theShape, (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theCenter,
const CORBA::Double theRadius) const CORBA::Double theRadius,
const GEOM::shape_state theState)
{ {
GEOM::GEOM_Object_var aGEOMObject; GEOM::ListOfGO_var aSeq;
//Set a not done flag //Set a not done flag
GetOperations()->SetNotDone(); GetOperations()->SetNotDone();
if (theShape == NULL || if (theShape == NULL || theCenter == NULL) return aSeq._retn();
theCenter == NULL) return aGEOMObject._retn();
//Get the reference objects //Get the reference objects
Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject
@ -642,16 +685,21 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetShapesOnSphere
Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject Handle(GEOM_Object) aCenter = GetOperations()->GetEngine()->GetObject
(theCenter->GetStudyID(), theCenter->GetEntry()); (theCenter->GetStudyID(), theCenter->GetEntry());
if (aShape.IsNull() || if (aShape.IsNull() || aCenter.IsNull()) return aSeq._retn();
aCenter.IsNull()) return aGEOMObject._retn();
//Get Shapes On Sphere //Get Shapes On Sphere
Handle(GEOM_Object) anObject = Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->GetShapesOnSphere
GetOperations()->GetShapesOnSphere(aShape, theShapeType, aCenter, theRadius); (aShape, theShapeType, aCenter, theRadius, ShapeState(theState));
if (!GetOperations()->IsDone() || anObject.IsNull()) if (!GetOperations()->IsDone() || aHSeq.IsNull())
return aGEOMObject._retn(); return aSeq._retn();
return GetObject(anObject); Standard_Integer aLength = aHSeq->Length();
aSeq = new GEOM::ListOfGO;
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();
} }
//============================================================================= //=============================================================================

View File

@ -65,19 +65,22 @@ class GEOM_IShapesOperations_i :
GEOM::GEOM_Object_ptr theShape2, GEOM::GEOM_Object_ptr theShape2,
const CORBA::Long theShapeType); const CORBA::Long theShapeType);
GEOM::GEOM_Object_ptr GetShapesOnPlane (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO* GetShapesOnPlane (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr thePlane); GEOM::GEOM_Object_ptr theAx1,
const GEOM::shape_state theState);
GEOM::GEOM_Object_ptr GetShapesOnCylinder (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO* GetShapesOnCylinder (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr theAxis, GEOM::GEOM_Object_ptr theAxis,
const CORBA::Double theRadius); const CORBA::Double theRadius,
const GEOM::shape_state theState);
GEOM::GEOM_Object_ptr GetShapesOnSphere (GEOM::GEOM_Object_ptr theShape, GEOM::ListOfGO* GetShapesOnSphere (GEOM::GEOM_Object_ptr theShape,
const CORBA::Long theShapeType, const CORBA::Long theShapeType,
GEOM::GEOM_Object_ptr theCenter, GEOM::GEOM_Object_ptr theCenter,
const CORBA::Double theRadius); const CORBA::Double theRadius,
const GEOM::shape_state theState);
GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere, GEOM::GEOM_Object_ptr GetInPlace (GEOM::GEOM_Object_ptr theShapeWhere,
GEOM::GEOM_Object_ptr theShapeWhat); GEOM::GEOM_Object_ptr theShapeWhat);

View File

@ -233,17 +233,49 @@ def TestOtherOperations (geompy, math):
v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0) v_pp0 = geompy.MakeVectorDXDYDZ( 1, 1, 0)
v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0) v_np0 = geompy.MakeVectorDXDYDZ(-1, 1, 0)
pln_0pp = geompy.MakePlane(p0, v_0pp, 200) pln_0pp = geompy.MakePlane(p0, v_0pp, 300)
pln_0np = geompy.MakePlane(p0, v_0np, 200) pln_0np = geompy.MakePlane(p0, v_0np, 300)
pln_p0p = geompy.MakePlane(p0, v_p0p, 200) pln_p0p = geompy.MakePlane(p0, v_p0p, 300)
pln_n0p = geompy.MakePlane(p0, v_n0p, 200) pln_n0p = geompy.MakePlane(p0, v_n0p, 300)
pln_pp0 = geompy.MakePlane(p0, v_pp0, 200) pln_pp0 = geompy.MakePlane(p0, v_pp0, 300)
pln_np0 = geompy.MakePlane(p0, v_np0, 200) pln_np0 = geompy.MakePlane(p0, v_np0, 300)
part_tool = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0], part_tool_1 = geompy.MakePartition([b0, pln_0pp, pln_0np, pln_p0p, pln_n0p, pln_pp0, pln_np0],
[], [],
[], [],
[b0]) [b0])
pt_pnt_1 = geompy.MakeVertex( 55, 0, 55)
pt_pnt_2 = geompy.MakeVertex( 0, 55, 55)
pt_pnt_3 = geompy.MakeVertex(-55, 0, 55)
pt_pnt_4 = geompy.MakeVertex( 0, -55, 55)
pt_pnt_5 = geompy.MakeVertex( 55, 55, 0)
pt_pnt_6 = geompy.MakeVertex( 55, -55, 0)
pt_pnt_7 = geompy.MakeVertex(-55, 55, 0)
pt_pnt_8 = geompy.MakeVertex(-55, -55, 0)
pt_pnt_9 = geompy.MakeVertex( 55, 0, -55)
pt_pnt_10 = geompy.MakeVertex( 0, 55, -55)
pt_pnt_11 = geompy.MakeVertex(-55, 0, -55)
pt_pnt_12 = geompy.MakeVertex( 0, -55, -55)
pt_face_1 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_1)
pt_face_2 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_2)
pt_face_3 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_3)
pt_face_4 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_4)
pt_face_5 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_5)
pt_face_6 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_6)
pt_face_7 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_7)
pt_face_8 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_8)
pt_face_9 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_9)
pt_face_10 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_10)
pt_face_11 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_11)
pt_face_12 = geompy.GetFaceNearPoint(part_tool_1, pt_pnt_12)
pt_box = geompy.GetBlockNearPoint(part_tool_1, p0)
part_tool = geompy.MakeCompound([pt_face_1, pt_face_4, pt_face_7, pt_face_10,
pt_face_2, pt_face_5, pt_face_8, pt_face_11,
pt_face_3, pt_face_6, pt_face_9, pt_face_12, pt_box])
id_part_tool = geompy.addToStudy(part_tool, "part_tool") id_part_tool = geompy.addToStudy(part_tool, "part_tool")
part = geompy.MakePartition([s0], [part_tool]) part = geompy.MakePartition([s0], [part_tool])
@ -302,8 +334,22 @@ def TestOtherOperations (geompy, math):
geompy.addToStudyInFather(blocksComp, b0_image, "b0 image") geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
# GetShapesOnPlane(theShape, theShapeType, thePlane) # GetShapesOnPlane
# GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
# GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) v_0pp, geompy.GEOM.ST_ONIN)
for face_i in faces_on_pln:
geompy.addToStudy(face_i, "Face on Plane or in direction of normale (0, 1, 1)")
# GetShapesOnCylinder
edges_on_cyl = geompy.GetShapesOnCylinder(blocksComp, geompy.ShapeType["EDGE"],
vy, 55, geompy.GEOM.ST_OUT)
for edge_i in edges_on_cyl:
geompy.addToStudy(edge_i, "Edge out of Cylinder (axis = (0, 1, 0), r = 55)")
# GetShapesOnSphere
vertices_on_sph = geompy.GetShapesOnSphere(blocksComp, geompy.ShapeType["VERTEX"],
p0, 100, geompy.GEOM.ST_ON)
for vertex_i in vertices_on_sph:
geompy.addToStudy(vertex_i, "Vertex on Sphere (center = (0, 0, 0), r = 100)")
# GetInPlace(theShapeWhere, theShapeWhat) # GetInPlace(theShapeWhere, theShapeWhat)

View File

@ -405,24 +405,24 @@ def GetSharedShapes(theShape1, theShape2, theShapeType):
print "GetSharedShapes : ", ShapesOp.GetErrorCode() print "GetSharedShapes : ", ShapesOp.GetErrorCode()
return aList return aList
#def GetShapesOnPlane(theShape, theShapeType, thePlane): def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
# anObj = ShapesOp.GetShapesOnPlane(theShape, theShapeType, thePlane) aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
# if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
# print "GetShapesOnPlane : ", ShapesOp.GetErrorCode() print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
# return anObj return aList
#
#def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius): def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
# anObj = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
# if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
# print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode() print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
# return anObj return aList
#
#def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius): def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
# anObj = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
# if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
# print "GetShapesOnSphere : ", ShapesOp.GetErrorCode() print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
# return anObj return aList
#
#def GetInPlace(theShapeWhere, theShapeWhat): #def GetInPlace(theShapeWhere, theShapeWhat):
# anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) # anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
# if ShapesOp.IsDone() == 0: # if ShapesOp.IsDone() == 0:

View File

@ -862,70 +862,77 @@ def GetSharedShapes(theShape1, theShape2, theShapeType):
return aList return aList
""" """
* Get sub-shapes of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified plane. * the specified plane by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param thePlane Face, specifying the plane to find shapes on. * \param theAx1 Vector (or line, or linear edge), specifying normal
* \return Group of all found sub-shapes. * direction and location of the plane 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.
* Example: see GEOM_TestOthers.py * Example: see GEOM_TestOthers.py
""" """
def GetShapesOnPlane(theShape, theShapeType, thePlane): def GetShapesOnPlane(theShape, theShapeType, theAx1, theState):
anObj = ShapesOp.GetShapesOnPlane(theShape, theShapeType, thePlane) aList = ShapesOp.GetShapesOnPlane(theShape, theShapeType, theAx1, theState)
if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
print "GetShapesOnPlane : ", ShapesOp.GetErrorCode() print "GetShapesOnPlane : ", ShapesOp.GetErrorCode()
return anObj return aList
""" """
* Get sub-shape of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified cylinder. * the specified cylinder by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param theAxis Vector (or line, or linear edge), specifying * \param theAxis Vector (or line, or linear edge), specifying
* axis of the cylinder to find shapes on. * axis of the cylinder to find shapes on.
* \param theRadius Radius of the cylinder to find shapes on. * \param theRadius Radius of the cylinder to find shapes on.
* \return Group of all found sub-shapes. * \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.
* Example: see GEOM_TestOthers.py * Example: see GEOM_TestOthers.py
""" """
def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius): def GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState):
anObj = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius) aList = ShapesOp.GetShapesOnCylinder(theShape, theShapeType, theAxis, theRadius, theState)
if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode() print "GetShapesOnCylinder : ", ShapesOp.GetErrorCode()
return anObj return aList
""" """
* Get sub-shape of theShape of the given type, * Find in \a theShape all sub-shapes of type \a theShapeType, situated relatively
* laying on the specified sphere. * the specified sphere by the certain way, defined through \a theState parameter.
* \param theShape Shape to find sub-shapes of. * \param theShape Shape to find sub-shapes of.
* \param theShapeType Type of sub-shapes to be retrieved. * \param theShapeType Type of sub-shapes to be retrieved.
* \param theCenter Point, specifying center of the sphere to find shapes on. * \param theCenter Point, specifying center of the sphere to find shapes on.
* \param theRadius Radius of the sphere to find shapes on. * \param theRadius Radius of the sphere to find shapes on.
* \return Group of all found sub-shapes. * \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.
* Example: see GEOM_TestOthers.py * Example: see GEOM_TestOthers.py
""" """
def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius): def GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState):
anObj = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius) aList = ShapesOp.GetShapesOnSphere(theShape, theShapeType, theCenter, theRadius, theState)
if ShapesOp.IsDone() == 0: if ShapesOp.IsDone() == 0:
print "GetShapesOnSphere : ", ShapesOp.GetErrorCode() print "GetShapesOnSphere : ", ShapesOp.GetErrorCode()
return anObj return aList
""" #"""
* Get sub-shape(s) of theShapeWhere, which are # * Get sub-shape(s) of theShapeWhere, which are
* coincident with \a theShapeWhat or could be a part of it. # * coincident with \a theShapeWhat or could be a part of it.
* \param theShapeWhere Shape to find sub-shapes of. # * \param theShapeWhere Shape to find sub-shapes of.
* \param theShapeWhat Shape, specifying what to find. # * \param theShapeWhat Shape, specifying what to find.
* \return Group of all found sub-shapes or a single found sub-shape. # * \return Group of all found sub-shapes or a single found sub-shape.
#
* Example: see GEOM_TestOthers.py # * Example: see GEOM_TestOthers.py
""" #"""
def GetInPlace(theShapeWhere, theShapeWhat): #def GetInPlace(theShapeWhere, theShapeWhat):
anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat) # anObj = ShapesOp.GetInPlace(theShapeWhere, theShapeWhat)
if ShapesOp.IsDone() == 0: # if ShapesOp.IsDone() == 0:
print "GetInPlace : ", ShapesOp.GetErrorCode() # print "GetInPlace : ", ShapesOp.GetErrorCode()
return anObj # return anObj
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Access to sub-shapes by their unique IDs inside the main shape. # Access to sub-shapes by their unique IDs inside the main shape.