Tue, 03/22/2022 - 00:50
Hello Open CASCADE Community,
I require to import a STEP file with separated "faces" of all sub shapes. Code snippets are below:
TopoDS_Shape sub_shape;
XCAFDoc_ShapeTool::GetShape(referred_label, sub_shape);
if (sub_shape.ShapeType() == TopAbs_COMPOUND || sub_shape.ShapeType() == TopAbs_COMPSOLID
|| sub_shape.ShapeType() == TopAbs_SOLID || sub_shape.ShapeType() == TopAbs_SHELL
|| sub_shape.ShapeType() == TopAbs_FACE || sub_shape.ShapeType() == TopAbs_WIRE
|| sub_shape.ShapeType() == TopAbs_EDGE || sub_shape.ShapeType() == TopAbs_VERTEX) {
BRepBuilderAPI_Transform transform(sub_shape, local_location, Standard_True);
Handle_XCAFPrs_AISObject object = new XCAFPrs_AISObject(referred_label);
if(sub_shape.ShapeType() == TopAbs_COMPOUND){
std::cout<<"sub shape is COMPOUND!"<<std::endl;
meshes.emplace_back(TopoDS::Compound(transform.Shape()), full_name, mesh_id_, object, local_location);
} else if(sub_shape.ShapeType() == TopAbs_COMPSOLID){
std::cout<<"sub shape is COMPSOLID!"<<std::endl;
meshes.emplace_back(TopoDS::CompSolid(transform.Shape()), full_name, mesh_id_, object, local_location);
} else if (sub_shape.ShapeType() == TopAbs_SOLID){
std::cout<<"sub shape is SOLID!"<<std::endl;
meshes.emplace_back(TopoDS::Solid(transform.Shape()), full_name, mesh_id_, object, local_location);
} else if (sub_shape.ShapeType() == TopAbs_SHELL){
std::cout<<"sub shape is SHELL!"<<std::endl;
meshes.emplace_back(TopoDS::Shell(transform.Shape()), full_name, mesh_id_, object, local_location);
} else if (sub_shape.ShapeType() == TopAbs_FACE){
std::cout<<"sub shape is FACE!"<<std::endl;
meshes.emplace_back(TopoDS::Face(transform.Shape()), full_name, mesh_id_, object, local_location);
} else if (sub_shape.ShapeType() == TopAbs_WIRE){
std::cout<<"sub shape is WIRE!"<<std::endl;
meshes.emplace_back(TopoDS::Wire(transform.Shape()), full_name, mesh_id_, object, local_location);
}else if (sub_shape.ShapeType() == TopAbs_EDGE){
std::cout<<"sub shape is EDGE!"<<std::endl;
meshes.emplace_back(TopoDS::Edge(transform.Shape()), full_name, mesh_id_, object, local_location);
}else if (sub_shape.ShapeType() == TopAbs_VERTEX){
std::cout<<"sub shape is VERTEX!"<<std::endl;
meshes.emplace_back(TopoDS::Vertex(transform.Shape()), full_name, mesh_id_, object, local_location);
}
}
However, all of subshapes are SOLID (i.e. TopAbs_SOLID). Some sample step files are attached this post. Can you see where I went wrong and why it only imports solid shape from the code? If I can parse it as a face, then I will show the vertex points with the mouse selection and I will choose what I want them. So I need to acquire the faces separately.
Thank you in advance!
Attachments: