Replies: 1 comment
-
In the code below I repeated the experiment shown above, but now using a function that closely follows the standard function for offset. The result is identical to my previous experiment: the function return an offset version of the original object, not a shelled version. For reference the code below produces both an MakeThickSolid and an Offset from the original shape, both are identical. function Offset(shape, offsetDistance, tolerance, keepShape) {
if (!shape || shape.IsNull()) { console.error("Offset received Null Shape!"); }
if (!tolerance) { tolerance = 0.1; }
if (offsetDistance === 0.0) { return shape; }
let curOffset = CacheOp(arguments, () => {
let offset = null;
if (shape.ShapeType() === 5) {
offset = new oc.BRepOffsetAPI_MakeOffset();
offset.AddWire(shape);
offset.Perform(offsetDistance);
} else {
offset = new oc.BRepOffsetAPI_MakeOffsetShape();
offset.PerformByJoin(shape, offsetDistance, tolerance);
}
let offsetShape = new oc.TopoDS_Shape(offset.Shape());
// Convert Shell to Solid as is expected
if (offsetShape.ShapeType() == 3) {
let solidOffset = new oc.BRepBuilderAPI_MakeSolid();
solidOffset.Add(offsetShape);
offsetShape = new oc.TopoDS_Solid(solidOffset.Solid());
}
return offsetShape;
});
if (!keepShape) { sceneShapes = Remove(sceneShapes, shape); }
sceneShapes.push(curOffset);
return curOffset;
}
function MakeShell(shape, facesToRemove, offsetDistance, tolerance, keepShape) {
if (!shape || shape.IsNull()) { console.error("MakeShell received Null Shape!"); }
if (!tolerance) { tolerance = 0.1; }
if (offsetDistance === 0.0) { return shape; }
let curShell = CacheOp(arguments, () => {
let shell = null;
if (shape.ShapeType() === 5) {
shell = new oc.BRepOffsetAPI_MakeThickSolid();
shell.AddWire(shape);
shell.PerformByJoin(shape, facesToRemove, offsetDistance, tolerance);
} else {
shell = new oc.BRepOffsetAPI_MakeThickSolid();
shell.MakeThickSolidByJoin(shape, facesToRemove, offsetDistance, tolerance);
}
let shellShape = new oc.TopoDS_Shape(shell.Shape());
// Convert Shell to Solid as is expected
if (shellShape.ShapeType() == 3) {
let solidShell = new oc.BRepBuilderAPI_MakeSolid();
solidShell.Add(shellShape);
shellShape = new oc.TopoDS_Solid(solidOffset.Solid());
}
return shellShape;
});
if (!keepShape) { sceneShapes = Remove(sceneShapes, shape); }
sceneShapes.push(curShell);
return curShell;
}
let box_original = Box(20,20,30);
let thickness = 0.5;
let sidesToRemove = [];
sidesToRemove = [5];
let offset = Translate([0,40,0],Offset(box_original,-thickness,0.1,true));
let shell = Translate([40,0,0],MakeShell(box_original,sidesToRemove,-thickness,0.1,true)); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried to use the function makeThickSolidByJoin from OpenCascade.js in a script, but one way or another it does not work.
The resulting shape seems to be a shell. I tried converting this to a solid using the following lines
but this did not work. The other strange thing is that the resulting shape still contains the faces that were selected to be removed. The shape is only a shell that is offset from the original solid.
Can anyone help me find the error in my code?
Beta Was this translation helpful? Give feedback.
All reactions