Sun, 12/01/2019 - 09:28
Forums:
Hello everyone,
I want to select an edge or a face of a solid.
My code is below:
void setFilter()
{
Handle(StdSelect_ShapeTypeFilter) solidFilter = new StdSelect_ShapeTypeFilter(TopAbs_SOLID);
Handle(StdSelect_FaceFilter) faceFilter = new StdSelect_FaceFilter(StdSelect_AnyFace);
Handle(StdSelect_EdgeFilter) edgeFilter = new StdSelect_EdgeFilter(StdSelect_AnyEdge);
m_context->AddFilter(solidFilter);
m_context->AddFilter(faceFilter);
m_context->AddFilter(edgeFilter);
}
void DrawWidget::createCylinder()
{
gp_Ax2 axes(gp_Pnt(0,0,0),gp_Dir(0,1,0));
double r = 50;
double h = 60;
double angle = M_PI*1.5;
TopoDS_Shape topo_cylinder = BRepPrimAPI_MakeCylinder(axes, r, h, angle);
Handle(AIS_Shape) ais_cylinder = new AIS_Shape(topo_cylinder);
m_context->Display(ais_cylinder, Standard_True);
const int aFaceMode = AIS_Shape::SelectionMode(TopAbs_FACE);
const int aEdgeMode = AIS_Shape::SelectionMode(TopAbs_EDGE);
m_context->Activate(ais_cylinder, aFaceMode);
m_context->Activate(ais_cylinder, aEdgeMode);
}
I select edges or faces by upper code, when I move the mouse to the edge or face which will highlight,but the selected result is the whole cylider shape.
How can I do?Anyone can help me?
Tue, 12/03/2019 - 12:20
What do you mean by "selected result is the whole cylinder shape"?
How do you check result?
Note that activating selection of both SOLID and FACE doesn't make sense, as FACE will be always preferred over SOLID
(although you can iterate over picking results <> which will include SOLID).
Draw Harness script doing the similar thing that your C++ code works as expected:
Tue, 12/03/2019 - 16:22
Glad to see your reply.
I've tested your code. It works very well.
Thank you.I made it.
Mon, 06/29/2020 - 10:18
can you share your code?