Wednesday, October 7, 2009

Remove internal wires

The functionality of the MakeFace tool is that it groups wires into faces (it is also used by the AutoGroup algorithm) and I also added the functionality that it groups several faces (selected with shift+click) into a bigger face to allow extruding them in one shot. In order to extrude the generated face a problem is to cleanup the internal wires and faces.
Tried to implement a remove internal wire/face algorithm.

The DrawTestHarness solution found until now that seems to work well:

circle c1 0 0 0 50
circle c2 0 0 0 25
circle c3 0 0 0 10
fit
mkedge ec1 c1 0 2*pi
mkedge ec2 c2 0 2*pi
mkedge ec3 c3 0 2*pi
wire wc1 ec1
wire wc2 ec2
wire wc3 ec3
mkplane p1 wc1
mkplane p2 wc2
mkplane p3 wc3
bcut result p1 p2
bfuse aux p1 p2
bfuse result aux p3
sprops result
RemoveIntWires t result 7853
donly t






The equivalent wrapper code:

// Calculate the result shape area
var prop = new OCGProp_GProps();
OCBRepGProp.SurfaceProperties(finalShape, prop);
var mass = prop.Mass();
// Remove internal area on the resulted shape
OCShapeUpgrade_RemoveInternalWires shapeUpgrade = new OCShapeUpgrade_RemoveInternalWires(finalShape);
shapeUpgrade.MinArea(mass);
shapeUpgrade.RemoveFaceMode(true);
shapeUpgrade.Perform();

if (shapeUpgrade.Status(OCShapeExtend_Status.ShapeExtend_DONE1) ||
shapeUpgrade.Status(OCShapeExtend_Status.ShapeExtend_DONE2))
{
// If operation succeeded replace the result shape with
// the one with no internal wires
finalShape = shapeUpgrade.GetResult();
}

The wrapper code doesn't work for the moment, it generates the same shape as the original one. Will move to solve higher priority bugs and come back at this algorithm soon.

No comments: