Map StepShape_ManifoldSolidBrep to TDF_Label/TopoDS_Shape while importing step file

I am trying to import STEP file and trying to classify 'CUT' and 'NOCUT' bodies. I have attached the step model. The issue I am facing is with reliably being able to identify those bodies. In different STEP files, different STEP entities are named as 'CUT' and 'NOCUT'. E.g. 'PRODUCT', 'NEXT_ASSEMBLY_USAGE_OCCURRENCE', and others. but I have seen that 'MANIFOLD_SOLID_BREP' name seems to be reliable. However, I am not able to map 'MANIFOLD_SOLID_BREP' to the TDF_Label or TopoDS_Shape in the TDocStd_Document. It seems they are different data structures of the STEP files. I want to know if there is a way to do the mapping?
How can I reliably establish a relationship between a given 'MANIFOLD_SOLID_BREP' which will be StepShape_ManifoldSolidBrep and its corresponding TDF_Label or TopoDS_Shape?

Or is there a way to retrieve the name of 'MANIFOLD_SOLID_BREP' entity when iterating over the TDF_Labels and form a mapping between the name and TopoDS_Shape?

Attachments: 
Dmitrii Pasukhin's picture

Hello. Detection of CUT/NOCUT\Cutting LINE and especially MCS/CSW/PCS and other CS are not possible by pure XCAF.

You need to extract that attributes manually from the StepData_StepModel. Iterating over graph and map translated shapes and Step entities by your logic. OCCT functionality is enough for assembly building of cutting tool and turret or machines.

Some sample: how to get the id of entity in STEP file? - Forum Open Cascade Technology

Best regards, Dmitrii.

 

Rajendra Pardeshi's picture

Thank you Dmitrii for your suggestion, I tried one appraoch to map Step entities and OCCT shape.

But I stuck at comparing TopoDS_Shape.

Following is what I am trying -

1. Collect all shapes (SOLID and COMPOUND) by iterating starting from TopoDS_Shape shape = stepCtrlReader->Reader().Shape(i);
2. Iterate over all the entities in the model
3. Filter StepBasic_ProductDefinition.
4. Find shape from StepBasic_ProductDefinition using Transfer_Binder.
5. Find StepShape_ManifoldSolidBrep from StepBasic_ProductDefinition.
6. Create map of name to shape.

But when comparing TopoDS_Shape retrieved from step 1 to the shape from StepBasic_ProductDefinition using Transfer_Binder, it is giving me not same result even for shapes that have the same TopoDS_TShape because of location.

Problematic code is this -

auto iter = std::find_if(compounds.begin(), compounds.end(), [&S](const TopoDS_Shape& shape)
{
return shape.IsSame(S);
});

This does not return any shape.

How should I compare shapes? Is this a valid approach?

Attaching full code in txt file.

Attachments: 
Rajendra Pardeshi's picture

I am using IsPartner for this. It is working fine for now.

Rajendra Pardeshi's picture

Hi @Dimitrii, what if the same StepBasic_ProductDefinition has multiple StepShape_ManifoldSolidBrep but they have 'CUT' or 'NOCUT' classification on the entity MANIFOLD_SOLID_BREP. Will I able to classify them differently using the data structures provided by OCCT? I have a model for which I am running in to this issue.