how can I use BRepTools_ReShape

I want to use BRepTools_ReShape to remove an edge from an object but I don't know how can I use.
Thank you very much for your help

Bearloga's picture

It is not allowed to remove a subshape from a shape. Usually a copy of the shape is created with missed subshape. So, you can use reshape in order to make a copy of your shape without an edge. For that, just initialize reshape tool with your shape, and then tell it that you want to remove the edge, and then you can get the result.

ATTIA's picture

Thank you very much Bearloga for your help but I don't understand how can get a copy of a shape without this shape.
Please, can you give me the lines of code to do thid.
Regards

Bearloga's picture

You wrote:
> I want to use BRepTools_ReShape to remove an edge from an object
And now you say you do not have a shape. Where is the truth?

ATTIA's picture

I have a shape that contains wires (which is a set of edges) and I want to delete an edge of the shape selected.the shape selected is imported from file iges.
In fact I open a local context to select an edge to be deleted.
I have not found a method so I wanted to make a copy of my shape without the edge selected then I clean my Interactive context then I display the new shape without the edge selected

Bearloga's picture

I think you approach is right. But you need not to clean the context (especially in the case you have many objects in the context). Just remove the old shape and display the new one.

ATTIA's picture

But you do not give me how I can copy this shape without this edge even though I described all the steps I am trying to do.
I wanted to know the code lines for use in doing that using BRepTools_ReShape or if there is another method.
I await your reply.
Thanks

Bearloga's picture

OK. Here is the code. I did not compile it though.

TopoDS_Shape RemoveEdge(TopoDS_Edge edge, TopoDS_Shape shape)
{
BRepTools_ReShape reshape;
reshape.Remove(edge);
return reshape.Apply(shape);
}

ATTIA's picture

-Hi ,
if (myAISContext->NbSelected()!=0)
{
BRepTools_ReShape aReshape;
for (myAISContext->InitSelected(); myAISContext->MoreSelected();AISContext->NextSelected())
{
aReshape.Remove(myAISContext->SelectedShape());
Handle_AIS_InteractiveObject picked;
picked= myAISContext->SelectedInteractive();
Handle(AIS_Shape) aShape=Handle(AIS_Shape)::DownCast(picked);
TopoDS_Shape TopoDsShape=aShape->Shape();
aReshape.Apply(aShape->Shape());
myAISContext->Redisplay(aShape);
}
}

But it doesn't work.
The edge isn't delete.
Have you eny idea what is the problem?

Bearloga's picture

You did not modify topods shape inside the context in your code. The following should be right:
aReshape.Remove(myAISContext->SelectedShape());
Handle_AIS_InteractiveObject picked;
picked= myAISContext->SelectedInteractive();
Handle(AIS_Shape) aShape=Handle(AIS_Shape)::DownCast(picked);
TopoDS_Shape aNewShape=aReshape.Apply(aShape->Shape());
aShape->Set(aNewShape);
myAISContext->Redisplay(aShape);

ATTIA's picture

Thank you very very much Bearloga.
Now, It works very well.

James Blackmon's picture

Hello, ATTIA:

I tried this method. It works if I tried to delete a face, but it didn't work if I tried to delete an edge.

Here is what I did. I created a box, then I selected a face, I can delete it. But if I selected an edge, when I tried to delete it, it actually deleted both faces that share that edge.

Any idea?

Thanks a lot,
James

Pawel's picture

Hi,

you have to reshape the whole TopoDS_Shape. Deleting a face does not affect the consistency of the data. If you remove an edge you will also have to update both faces sharing it (in a box) - this is probably why the faces gets 'deleted' (or rather invalid and thus not being visualized any more).

Pawel

Anup's picture

Hi Baerloga,

I want to use BRepTools_ReShape to change the orientation of triangles of an TopoDs_Shape i mean when i import an IGES File the traingles are in clockwise-order i want to change it to counter-clockwise-order. Please tell me i can do this.

Thanks & Regards
Anup S