Remove TopoDS_Shape from TopoDS_Shape

Hello,

I'd like to know, why this command [b]brepBuilder.Remove(_ptpdsShape,TempShape);[/b] doesn't work? =/

Do I need to do something like a Perform, or SAVE afterwards this command?

Thanks in advance.

Evgeny Lodyzhehsky's picture

Dear Thiago Macedo.

There are two possibilities to fail here:
1. The shape _ptpdsShape is frozen, i.e. _ptpdsShape is const reference. Try to avoid const references here.
2. The shape _ptpdsShape is not straight ancestor for the shape TempShape. For e.g. you can not remove a vertex from a solid, but you can remove the vertex from an edge(if of course the vertex belongs to the edge).

tmacedo29's picture

Hi Lodyzhensky,
Thank you for your answer! =)

About your tips:
1- I'm not using any const reference for the first parameter.
2- I'm trying to remove a EDGE from a SHAPE, or a FACE from a SHAPE. Is it possible? Is there a place to find this hierarchy?

Thanks in advance

Evgeny Lodyzhehsky's picture

Dear Thiago Macedo.

- The class TopoDS_Shape is root class for all types (vertex, edge, etc).
So, try to get the type of your shape aS.ShapeType() before removing smth from it.
- The types of shapes are declared in TopAbs.cdl as the follwing:

enumeration ShapeEnum is
---Purpose: Identifies various topological shapes. This
-- enumeration allows you to use dynamic typing of shapes.
-- The values are listed in order of complexity, from the
-- most complex to the most simple i.e.
-- COMPOUND > COMPSOLID > SOLID > .... > VERTEX > SHAPE.
-- Any shape can contain simpler shapes in its definition.
-- Abstract topological data structure describes a basic
-- entity, the shape (present in this enumeration as the
-- SHAPE value), which can be divided into the following
-- component topologies:
-- - COMPOUND: A group of any of the shapes below.
-- - COMPSOLID: A set of solids connected by their
-- faces. This expands the notions of WIRE and SHELL to solids.
-- - SOLID: A part of 3D space bounded by shells.
-- - SHELL: A set of faces connected by some of the
-- edges of their wire boundaries. A shell can be open or closed.
-- - FACE: Part of a plane (in 2D geometry) or a surface
-- (in 3D geometry) bounded by a closed wire. Its
-- geometry is constrained (trimmed) by contours.
-- - WIRE: A sequence of edges connected by their
-- vertices. It can be open or closed depending on
-- whether the edges are linked or not.
-- - EDGE: A single dimensional shape corresponding
-- to a curve, and bound by a vertex at each extremity.
-- - VERTEX: A zero-dimensional shape corresponding to a point in geometry.

COMPOUND,
COMPSOLID,
SOLID,
SHELL,
FACE,
WIRE,
EDGE,
VERTEX,
SHAPE
end ShapeEnum;

Stephen Leary's picture

I also find that this function doesnt work.

I was trying to remove a duplicate VERTEX from a SHAPE. I dont want to have to check the shapetype because the fact that the function takes SHAPE as a parameter implies that it will work on anything :-

COMPOUND,
COMPSOLID,
SOLID,
SHELL,
FACE,
WIRE,
EDGE,
VERTEX,
SHAPE

I've had to write my own remove functions now.

Would be better to remove this function than leave it in as it is.

Evgeny Lodyzhehsky's picture

Hi Stephen Leary.
How are you getting on?

Roman Lygin's picture

BRep_Builder is a direct/primitive construction tool to operate on direct subshapes of the shape. For instance, with its help you can remove an internal wire from a face. However, if your face is inside the shell and you need to remove a wire from that face, it won't help you.
Use ShapeBuild_ReShape (or its parent BRepTools_ReShape) ::Remove() and then ::Apply().
*_ReShape acts as a map where you record a mapping between original and new shape and then call Apply() to 'apply' these requested modification to your shape.
In example above, you say ::Remove (aWire) and then ::Apply(aShell).

Svetlozar Kostadinov's picture

Let me offer you one general advice which helped me to solve most of the failures happened deeply in the OCC code. You should compile a debug version of the OCC libraries (if you use WinXXX platform) Then you can trace into OCC code to search by yourself. This is an excellent way to study how is OCC functioning.