Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void Step2GlbOccConverter::Debug(){
Handle(XCAFDoc_ShapeTool) ShapeTool = XCAFDoc_DocumentTool::ShapeTool (XdeDoc->Main());
TDF_LabelSequence RootLabels;
ShapeTool->GetFreeShapes (RootLabels);
TopoDS_Compound Compound;
BRep_Builder BuildTool;
BuildTool.MakeCompound (Compound);
std::cout << "Debugging parts :"<<std::endl;
BRepMesh_IncrementalMesh WatsonAlgorithm;
Handle(Prs3d_Drawer) Drawer = new Prs3d_Drawer(); // holds visualization defaults
const TopoDS_Compound FixedCompound = Compound;
const Handle(Prs3d_Drawer) FixedDrawer = Drawer; // holds visualization defaults
WatsonAlgorithm.ChangeParameters().Deflection = StdPrs_ToolTriangulatedShape::GetDeflection (FixedCompound, FixedDrawer);
WatsonAlgorithm.ChangeParameters().Angle = 20.0 * M_PI / 180.0; // 20 degrees
WatsonAlgorithm.ChangeParameters().InParallel = true;
for (TDF_LabelSequence::Iterator RootIter (RootLabels); RootIter.More(); RootIter.Next())
{
const TDF_Label& RootLabel = RootIter.Value();
TopoDS_Shape RootShape;
GetName(RootLabel) ;
if (XCAFDoc_ShapeTool::GetShape (RootLabel, RootShape))
{
const Message_ProgressRange & message_ProgressRange = Message_ProgressRange();
if (ShapeTool->IsAssembly(RootLabel)) // Assembly or sub-assembly component
{
GetName(RootLabel); // Set the component's name
TDF_LabelSequence label_comps;
ShapeTool->GetComponents(RootLabel, label_comps);
int compSize = label_comps.Length();
for (int i = 1; i <= compSize; ++i)
{
const TDF_Label& label_comp = label_comps.Value(i);
//std::cout << label_comp <<'\n';
std::cout <<"COMPONENT NAME :";
GetName(label_comp);
const TopoDS_Shape& shape = ShapeTool->GetShape(label_comp);
WatsonAlgorithm.SetShape(shape);
WatsonAlgorithm.Perform();
//AddSubComponents(comp, label_comp); // Recursive call
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.