brepjs 3.0.2 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/brepjs.cjs CHANGED
@@ -1977,8 +1977,9 @@ function deserializeShape(data) {
1977
1977
  return cast(oc.BRepToolsWrapper.Read(data));
1978
1978
  }
1979
1979
  function isShape3DInternal(shape) {
1980
- const name = shape.constructor.name;
1981
- return name === "Shell" || name === "Solid" || name === "CompSolid" || name === "Compound";
1980
+ const shapeTypeRaw = shape.wrapped?.ShapeType?.();
1981
+ const shapeType2 = typeof shapeTypeRaw === "object" && shapeTypeRaw !== null ? shapeTypeRaw.value : shapeTypeRaw;
1982
+ return typeof shapeType2 === "number" && shapeType2 <= 3;
1982
1983
  }
1983
1984
  function buildCompoundOc(shapes) {
1984
1985
  const oc = getKernel().oc;
@@ -2012,9 +2013,29 @@ function fuseAll$2(shapes, { optimisation = "none", simplify: simplify2 = false,
2012
2013
  shapes.map((s) => s.wrapped),
2013
2014
  { optimisation, simplify: simplify2, strategy }
2014
2015
  );
2016
+ const shapeTypeEnumRaw = result.ShapeType?.();
2017
+ const shapeTypeEnum = typeof shapeTypeEnumRaw === "object" && shapeTypeEnumRaw !== null ? shapeTypeEnumRaw.value : shapeTypeEnumRaw;
2018
+ const typeNames = [
2019
+ "COMPOUND",
2020
+ "COMPSOLID",
2021
+ "SOLID",
2022
+ "SHELL",
2023
+ "FACE",
2024
+ "WIRE",
2025
+ "EDGE",
2026
+ "VERTEX",
2027
+ "SHAPE"
2028
+ ];
2029
+ const rawTypeName = typeof shapeTypeEnum === "number" ? typeNames[shapeTypeEnum] ?? `UNKNOWN(${shapeTypeEnum})` : "UNKNOWN";
2015
2030
  return andThen(cast(result), (newShape) => {
2016
- if (!isShape3DInternal(newShape))
2017
- return err(typeCastError("FUSE_ALL_NOT_3D", "fuseAll did not produce a 3D shape"));
2031
+ if (!isShape3DInternal(newShape)) {
2032
+ return err(
2033
+ typeCastError(
2034
+ "FUSE_ALL_NOT_3D",
2035
+ `fuseAll did not produce a 3D shape. Got ${rawTypeName} (${newShape.constructor.name}) instead.`
2036
+ )
2037
+ );
2038
+ }
2018
2039
  return ok(newShape);
2019
2040
  });
2020
2041
  }
@@ -3869,8 +3890,21 @@ function buildCompoundOcInternal(shapes) {
3869
3890
  function castToShape3D(shape, errorCode, errorMsg) {
3870
3891
  const wrapped = castShape(shape);
3871
3892
  if (!isShape3D(wrapped)) {
3893
+ const shapeType2 = shape.ShapeType();
3894
+ const typeNames = [
3895
+ "COMPOUND",
3896
+ "COMPSOLID",
3897
+ "SOLID",
3898
+ "SHELL",
3899
+ "FACE",
3900
+ "WIRE",
3901
+ "EDGE",
3902
+ "VERTEX",
3903
+ "SHAPE"
3904
+ ];
3905
+ const typeName = typeNames[shapeType2] ?? `UNKNOWN(${shapeType2})`;
3872
3906
  wrapped[Symbol.dispose]();
3873
- return err(typeCastError(errorCode, errorMsg));
3907
+ return err(typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`));
3874
3908
  }
3875
3909
  return ok(wrapped);
3876
3910
  }
package/dist/brepjs.js CHANGED
@@ -1975,8 +1975,9 @@ function deserializeShape(data) {
1975
1975
  return cast(oc.BRepToolsWrapper.Read(data));
1976
1976
  }
1977
1977
  function isShape3DInternal(shape) {
1978
- const name = shape.constructor.name;
1979
- return name === "Shell" || name === "Solid" || name === "CompSolid" || name === "Compound";
1978
+ const shapeTypeRaw = shape.wrapped?.ShapeType?.();
1979
+ const shapeType2 = typeof shapeTypeRaw === "object" && shapeTypeRaw !== null ? shapeTypeRaw.value : shapeTypeRaw;
1980
+ return typeof shapeType2 === "number" && shapeType2 <= 3;
1980
1981
  }
1981
1982
  function buildCompoundOc(shapes) {
1982
1983
  const oc = getKernel().oc;
@@ -2010,9 +2011,29 @@ function fuseAll$2(shapes, { optimisation = "none", simplify: simplify2 = false,
2010
2011
  shapes.map((s) => s.wrapped),
2011
2012
  { optimisation, simplify: simplify2, strategy }
2012
2013
  );
2014
+ const shapeTypeEnumRaw = result.ShapeType?.();
2015
+ const shapeTypeEnum = typeof shapeTypeEnumRaw === "object" && shapeTypeEnumRaw !== null ? shapeTypeEnumRaw.value : shapeTypeEnumRaw;
2016
+ const typeNames = [
2017
+ "COMPOUND",
2018
+ "COMPSOLID",
2019
+ "SOLID",
2020
+ "SHELL",
2021
+ "FACE",
2022
+ "WIRE",
2023
+ "EDGE",
2024
+ "VERTEX",
2025
+ "SHAPE"
2026
+ ];
2027
+ const rawTypeName = typeof shapeTypeEnum === "number" ? typeNames[shapeTypeEnum] ?? `UNKNOWN(${shapeTypeEnum})` : "UNKNOWN";
2013
2028
  return andThen(cast(result), (newShape) => {
2014
- if (!isShape3DInternal(newShape))
2015
- return err(typeCastError("FUSE_ALL_NOT_3D", "fuseAll did not produce a 3D shape"));
2029
+ if (!isShape3DInternal(newShape)) {
2030
+ return err(
2031
+ typeCastError(
2032
+ "FUSE_ALL_NOT_3D",
2033
+ `fuseAll did not produce a 3D shape. Got ${rawTypeName} (${newShape.constructor.name}) instead.`
2034
+ )
2035
+ );
2036
+ }
2016
2037
  return ok(newShape);
2017
2038
  });
2018
2039
  }
@@ -3867,8 +3888,21 @@ function buildCompoundOcInternal(shapes) {
3867
3888
  function castToShape3D(shape, errorCode, errorMsg) {
3868
3889
  const wrapped = castShape(shape);
3869
3890
  if (!isShape3D(wrapped)) {
3891
+ const shapeType2 = shape.ShapeType();
3892
+ const typeNames = [
3893
+ "COMPOUND",
3894
+ "COMPSOLID",
3895
+ "SOLID",
3896
+ "SHELL",
3897
+ "FACE",
3898
+ "WIRE",
3899
+ "EDGE",
3900
+ "VERTEX",
3901
+ "SHAPE"
3902
+ ];
3903
+ const typeName = typeNames[shapeType2] ?? `UNKNOWN(${shapeType2})`;
3870
3904
  wrapped[Symbol.dispose]();
3871
- return err(typeCastError(errorCode, errorMsg));
3905
+ return err(typeCastError(errorCode, `${errorMsg}. Got ${typeName} instead.`));
3872
3906
  }
3873
3907
  return ok(wrapped);
3874
3908
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brepjs",
3
- "version": "3.0.2",
3
+ "version": "4.0.2",
4
4
  "description": "Web CAD library built on OpenCascade",
5
5
  "keywords": [
6
6
  "cad",