Adding a shape to a shape problem

lbw

CAD practitioner
Sorry to bother you, but I'm having some occt problems.
I want to add a separate entity such as an edge to a shape such as a compound, the shapebrowser for this shape is shown in the picture
1711980340219.png
if I use the
BRep_Builder builder.
TopoDS_Compound comp;
Builder.MakeCompound(comp);
builder.Add(comp, shape);//target shape, is a compound
builder.Add(comp, edge);//added edge
shape=comp;
This changes the shapebrowser of the original shape, , as shown in Figure 2,which is not what I want to see,

1711980674931.png
I want to put the separate edge under the shape's compound without changing the original shape, as shown in Figure 3 after I paint it with the mosaic.
1711981093040.png
Thank you for your reply.
 

lbw

CAD practitioner
I also tried to add the edge directly to the shape using builder.Add(shape, edge); but it reports the error TopoDS__UnCompatibleShapes.
 

Quaoar

Administrator
Staff member
Hello @lbw

Do you want this result?

1711981933947.png

Initial shape is attached as `initialShape.brep`. The edge to add is attached as `edge.brep`. Then I used the following script:

Code:
> clear
> load-part C:/Users/serge/Desktop/initialShape.brep
> set-as-var shape
> load-part C:/Users/serge/Desktop/edge.brep
> set-as-var edge
> add-subshape shape edge
> set-as-part shape

In the end, it's just BRep_Builder().Add(), so you are using the right tools. Can you repeat the script and see if it works as expected?
 

Attachments

  • initialShape.brep
    2.2 KB · Views: 3
  • edge.brep
    471 bytes · Views: 1
Last edited:

lbw

CAD practitioner
Thank you for your help, I did some model testing, and by the way the models with the highest level being compound sometimes report the error TopoDS_FrozenShape, I did shape.Free(Standard_True) on the model before BRep_Builder and that solves the problem, I don't know what causes the The shape is frozen.1712037027872.png


Also for models where the topmost topology is a shell, performing BRep_Builder will result in the error TopoDS__UnCompatibleShapes, supposedly the shell is not allowed to be put into a separate edge, it seems that you can only perform BRep_Builder operations if you change the shell to a compound, is there any Is there any way to add edge without changing the topoDS_UnCompatibleShapes of the model to shell?

1712037626046.png
1712037828935.png
 
Last edited:

Quaoar

Administrator
Staff member
You may want to check the documentation of TopoDS_Builder, where in the header file it states that:

Code:
//! The Add method check for the following rules :
//!
//! - Any SHAPE can be added in a COMPOUND.
//!
//! - Only SOLID can be added in a COMPSOLID.
//!
//! - Only SHELL, EDGE and VERTEX can be added in a SOLID.
//! EDGE and VERTEX as to be INTERNAL or EXTERNAL.
//!
//! - Only FACE can be added in a SHELL.
//!
//! - Only WIRE and VERTEX can be added in a FACE.
//! VERTEX as to be INTERNAL or EXTERNAL.
//!
//! - Only EDGE can be added in a WIRE.
//!
//! - Only VERTEX can be added in an EDGE.
//!
//! - Nothing can be added in a VERTEX.

I.e. you can add an edge to a solid, but you cannot add an edge to a shell. I'm not sure what was the intention of it but it might be related to modeling boundary conditions. These are the fundamental rules of shape composing in OpenCascade. An old diagram:

1712040065865.png
 
Top