sgenoud / replicad

The library to build browser based 3D models with code.
https://replicad.xyz
MIT License
323 stars 38 forks source link

Add shell method without removing faces to 3DShape class #120

Closed Niels-IO closed 6 months ago

Niels-IO commented 7 months ago

Hi @sgenoud,

I would like to enable a way to have a shell without removing faces. Opencascade has the method MakeThickSolidBySimple for this. Somehow, it returns an undefined shape. Do you have an idea on how to make it work?

An example for a script would be this:

const { drawCircle, drawPolysides, polysideInnerRadius } = replicad;

const defaultParams = {
  height: 150,
  radius: 40,
  sidesCount: 12,
  sideRadius: -2,
  sideTwist: 6,
  endFactor: 1.5,
  topFillet: 0,
  bottomFillet: 5,

  holeMode: 1,
  wallThickness: 3,
};

const main = (
  r,
  {
    height,
    radius,
    sidesCount,
    sideRadius,
    sideTwist,
    endFactor,
    topFillet,
    bottomFillet,
    holeMode,
    wallThickness,
  }
) => {
  const extrusionProfile = endFactor
    ? { profile: "s-curve", endFactor }
    : undefined;
  const twistAngle = (360 / sidesCount) * sideTwist;

  const drawing = drawPolysides(radius, 6)
  let shape = drawing.sketchOnPlane("XY").extrude(20).shell(2)

  return [{shape:shape}];
};
sgenoud commented 7 months ago

Mmmm I wonder if this is the right method. In the doc it says:

Non-closed shell or face is expected as input.

The shapes that it can run on (as defined now) are only closed ones. Would you try to add the method on a simple face and see if it works (my guess is that it is some kind of weird extrude.

Niels-IO commented 6 months ago

I will close this now, as Opencascade probably doesn't have a direct method for it