Here is some snippet:
BRepAlgoAPI_Cut aBuilder;
...
aBuilder->Build();
ShapeUpgrade_UnifySameDomain shapeUpgrade_aWorkPiece(aWorkPieceCopy); // important after Boolean operation
shapeUpgrade_aWorkPiece.Build(); //so far normal Cut Operation
BRepAlgoAPI_Section asect(aWorkPiece, aTool, Standard_False); // getting the intersection
asect.Approximation(Standard_True);
asect.Build();
TopoDS_Shape aInterface = asect.Shape();
//doing HLR to get the projection of the aInterface on a plane
myAlgo->Add(aInterface);
myAlgo->Update();
HLRBRep_HLRToShape aHLRToShape(myAlgo);
TopoDS_Shape aProjectedContactFace; //projected shape of contact
aProjectedContactFace = aHLRToShape.VCompound(); //visible projected shapes are used
ShapeFixIt(aProjectedContactFace); //some healing
Handle(TopTools_HSequenceOfShape) EdgesQ = new TopTools_HSequenceOfShape(); // exploring all Edges
Handle(TopTools_HSequenceOfShape) Wires = new TopTools_HSequenceOfShape(); // to create Wires
TopExp_Explorer anEdgeExplorer(aProjectedContactFace, TopAbs_EDGE);
while (anEdgeExplorer.More())
{
TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current());
ShapeFixIt(anEdge); //some healing
EdgesQ->Append(anEdge);
anEdgeExplorer.Next();
}
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(EdgesQ, 5.0, false, Wires); // 5.0 worked frequently
Handle(TopTools_HSequenceOfShape) ClosedWires = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) OpenWires = new TopTools_HSequenceOfShape();
ShapeAnalysis_FreeBounds::SplitWires(Wires, 1.0, false, ClosedWires, OpenWires);
//from here onwards we only use the ClosedWires for further area calculation (making faces and then asking MassPropoerties).
Problem still is: the projected Contact Face (aProjectedContactFace) looks like a scattered out contour but the ConnectEdgesToWires is able to get a closed wire from it.
BRepAlgoAPI_Cut aBuilder;
...
aBuilder->Build();
ShapeUpgrade_UnifySameDomain shapeUpgrade_aWorkPiece(aWorkPieceCopy); // important after Boolean operation
shapeUpgrade_aWorkPiece.Build(); //so far normal Cut Operation
BRepAlgoAPI_Section asect(aWorkPiece, aTool, Standard_False); // getting the intersection
asect.Approximation(Standard_True);
asect.Build();
TopoDS_Shape aInterface = asect.Shape();
//doing HLR to get the projection of the aInterface on a plane
myAlgo->Add(aInterface);
myAlgo->Update();
HLRBRep_HLRToShape aHLRToShape(myAlgo);
TopoDS_Shape aProjectedContactFace; //projected shape of contact
aProjectedContactFace = aHLRToShape.VCompound(); //visible projected shapes are used
ShapeFixIt(aProjectedContactFace); //some healing
Handle(TopTools_HSequenceOfShape) EdgesQ = new TopTools_HSequenceOfShape(); // exploring all Edges
Handle(TopTools_HSequenceOfShape) Wires = new TopTools_HSequenceOfShape(); // to create Wires
TopExp_Explorer anEdgeExplorer(aProjectedContactFace, TopAbs_EDGE);
while (anEdgeExplorer.More())
{
TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current());
ShapeFixIt(anEdge); //some healing
EdgesQ->Append(anEdge);
anEdgeExplorer.Next();
}
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(EdgesQ, 5.0, false, Wires); // 5.0 worked frequently
Handle(TopTools_HSequenceOfShape) ClosedWires = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) OpenWires = new TopTools_HSequenceOfShape();
ShapeAnalysis_FreeBounds::SplitWires(Wires, 1.0, false, ClosedWires, OpenWires);
//from here onwards we only use the ClosedWires for further area calculation (making faces and then asking MassPropoerties).
Problem still is: the projected Contact Face (aProjectedContactFace) looks like a scattered out contour but the ConnectEdgesToWires is able to get a closed wire from it.