How to differentiate the selected edge is a standalone curve or a surface edge

After I set the edge selection mode by the following function, the user can select the edge only from the CONTEXT.
myAISContext->ActivateStandardMode(TopAbs_EDGE);

In this selection mode, the user can select both standalone edges and the surface edges. If the user wants to delete the selected shapes, I just want the standalone curves/edges to be deleted. The surface edges should not be removed.

So, I need a solution to identify the curves.

Any suggestion is appreciated.

Thank you!

-Fan

Pawel's picture

Hi Fan,

implement a filter (derived from SelectMgr_Filter). In the filter check if the selected edge is a free edge. You can use TopExp_Explorer to do that:

TopExp_Explorer ex;
ex.Init(shape, TopAbs_EDGE, TopAbs_FACE); //free edges only

Pawel

SF. Fan's picture

Hi, Pawel

Thank you for you quick reply.
I'll give it a try.

-FAN

SF. Fan's picture

Hi, Pawel

I realize the solution you mentioned is implied during the selection processing. The face edge will be rejected from selection. Actually the face edges are allowed for selection with standalone edges.
What I need is to filter out such face edges for some particular fuctions(ex: delete).
Finally, I got a solution for that.

for(myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
{
Handle_AIS_Shape hShape = Handle_AIS_Shape::DownCast(myAISContext->SelectedOwner()->Selectable());
//if the edge belongs to a face, it gives "TopAbs_FACE"
if (hShape->Shape().ShapeType() != TopAbs_EDGE)
continue;

// It is allowed to be processed
{
......
}
}

Thank you for your suggestion!

-FAN

Sharjith Naramparambath's picture

Did you have a look at:

static Standard_Boolean BRep_Tool::IsGeometric (const TopoDS_Edge &E);
Returns True if is a 3d curve or a curve on
surface.

Looks like this should tell you if the edge is a part of the Topo Shape or not. I haven't tried it though.

SF. Fan's picture

Hi, Sharjith
Thank you for your suggestion. Unfortunately, it doesn't work per test I did.

for(myAISContext->InitSelected(); myAISContext->MoreSelected(); myAISContext->NextSelected())
{
TopoDS_Shape selShape = myAISContext->SelectedShape();
if (selShape.ShapeType() == TopAbs_EDGE)
{
Standard_Boolean bCheck = BRep_Tool::IsGeometric (TopoDS::Edge(selShape)); //Always return 1;
if (bCheck)
AfxMessageBox(_T("It is a standalone edge"));
else
AfxMessageBox(_T("It is a face edge"));
}
}
}

Sharjith Naramparambath's picture

Then the best option would be to use the check that Pawel suggested. But not inside a filter as you need to have both selections active. Rather the check could be done on the selected edge by adding it to the explorer for finding faces. A free edge wouldn't have a face associated with it in the explorer.

SF. Fan's picture

Assuming a local context is opened and the current mode is EDGE selection.
myAISContext->ActivateStandardMode(TopAbs_EDGE);

In this situation, you can select both standalone edges and the face boundaries. All the selected the components are TopAbs_EDGE type. The selected face edge can't be filter out with the explorer, because they are EDGEs.

TopExp_Explorer ex;
ex.Init(ashape, TopAbs_EDGE, TopAbs_FACE);

Maybe I misunderstand your solution. Thank you for your input.

Regards,

-Fan

Sharjith Naramparambath's picture

I'm sorry, I was telling you the incomplete way of doing it using the iterator. However, what I am trying to say is that the selected edge should be tested for it being a part of the surface by getting the selected entity owner which gives you the original shape which the selected decomposed edge is a part of. According to the 3d Viewer MFC Sample which shows a fillet creation from a selected (decomposed) edge on a box the code gets the original shape of the selected edge and adds it to the Fillet algorithm and then adds the selected edge along which the fillet is to be created. The method AIS_InteractiveContext::SelectedInteractive() returns the original shape from which the edges have been decomposed and the method AIS_InteractiveContext::SelectedShape() returns the selected decomposed shape (edge in this case). Once you get the original shape you may use it to check using the iterator or any other method you deem fit.
Have a look at the method void CViewer3dDoc::OnFillet3d() in the MFC 04_Viewer3d sample which will give you a clear idea.

SF. Fan's picture

Hi, Sharjith

Thank you for your suggestion. It is very informational.

Regards,

-Fan