Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bitbybit-occt

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitbybit-occt - npm Package Compare versions

Comparing version 0.9.29 to 0.9.30

lib/services/booleans.test.d.ts

2

lib/occ-helper.d.ts

@@ -115,3 +115,3 @@ import { Adaptor3d_Curve, BRepAdaptor_CompCurve_2, Geom2d_Curve, TopoDS_Shell, TopoDS_Solid, Geom_Circle, Geom_Curve, Geom_Ellipse, Geom_Surface, gp_Ax1, gp_Ax2, gp_Ax22d_2, gp_Ax2d_2, gp_Ax3, gp_Dir2d_4, gp_Dir_4, gp_Pln_3, gp_Pnt2d_3, gp_Pnt_3, gp_Vec2d_4, gp_Vec_4, gp_XYZ_2, Handle_Geom_Curve, OpenCascadeInstance, TopoDS_Compound, TopoDS_Edge, TopoDS_Face, TopoDS_Shape, TopoDS_Vertex, TopoDS_Wire } from '../bitbybit-dev-occt/bitbybit-dev-occt';

interpolatePoints(inputs: Inputs.OCCT.InterpolationDto): TopoDS_Wire;
getNumSolidsInCompound(shape: TopoDS_Shape): number | TopoDS_Shape;
getNumSolidsInCompound(shape: TopoDS_Shape): number;
getSolidFromCompound(shape: TopoDS_Shape, index: number): any;

@@ -118,0 +118,0 @@ forEachSolid(shape: any, callback: any): void;

@@ -67,3 +67,7 @@ export var typeSpecificityEnum;

inputs.shapes.forEach(shape => {
builder.Add(resCompound, shape);
const cp = new this.occ.BRepBuilderAPI_Copy_2(shape, true, false);
const s = cp.Shape();
builder.Add(resCompound, s);
cp.delete();
s.delete();
});

@@ -801,6 +805,5 @@ builder.delete();

if (!shape ||
shape.ShapeType() > this.occ.TopAbs_ShapeEnum.TopAbs_COMPSOLID ||
this.getShapeTypeEnum(shape) !== shapeTypeEnum.compound ||
shape.IsNull()) {
console.error('Not a compound shape!');
return shape;
throw new Error('Shape is not a compound or is null.');
}

@@ -951,3 +954,3 @@ let solidsFound = 0;

if (makeWire.IsDone()) {
this.occ.BRepLib.BuildCurves3d_2(makeWire.Wire());
this.occ.BRepLib.BuildCurves3d_1(makeWire.Wire(), 1.0e-7, this.occ.GeomAbs_Shape.GeomAbs_C1, 14, 0);
const wire = makeWire.Wire();

@@ -1023,6 +1026,6 @@ makeWire.delete();

transformation.SetTranslation_1(gpVec);
const translation = new this.occ.TopLoc_Location_2(transformation);
const moved = inputs.shape.Moved(translation, false);
const shp = this.getActualTypeOfShape(moved);
moved.delete();
const transf = new this.occ.BRepBuilderAPI_Transform_2(inputs.shape, transformation, true);
const s = transf.Shape();
const shp = this.getActualTypeOfShape(s);
s.delete();
transformation.delete();

@@ -1029,0 +1032,0 @@ gpVec.delete();

@@ -1,2 +0,2 @@

import { Geom2d_Curve, OpenCascadeInstance } from '../../../bitbybit-dev-occt/bitbybit-dev-occt';
import { Geom2d_Curve, Geom_Circle, Geom_Ellipse, OpenCascadeInstance } from '../../../bitbybit-dev-occt/bitbybit-dev-occt';
import { OccHelper } from '../../occ-helper';

@@ -13,4 +13,4 @@ import * as Inputs from '../../api/inputs/inputs';

get2dPointFrom2dCurveOnParam(inputs: Inputs.OCCT.DataOnGeometryAtParamDto<Geom2d_Curve>): number[];
geomCircleCurve(inputs: Inputs.OCCT.CircleDto): any;
geomEllipseCurve(inputs: Inputs.OCCT.EllipseDto): import("../../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../../bitbybit-dev-occt/bitbybit-dev-occt").Geom_Ellipse | import("../../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Wire | import("../../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face;
geomCircleCurve(inputs: Inputs.OCCT.CircleDto): Geom_Circle;
geomEllipseCurve(inputs: Inputs.OCCT.EllipseDto): Geom_Ellipse;
}

@@ -17,2 +17,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

import { OCCTGeom } from "../geom/geom";
import { OCCT } from "../../api/inputs";
describe('OCCT face unit tests', () => {

@@ -172,2 +173,76 @@ let occt;

});
it('should subdivide face into points controlled', () => {
const sph = occHelper.bRepPrimAPIMakeSphere([0, 0, 0], [0, 1, 0], 2);
const f = face.getFace({ shape: sph, index: 0 });
const subdOpt = new OCCT.FaceSubdivisionControlledDto(f);
subdOpt.nrDivisionsU = 5;
subdOpt.nrDivisionsV = 6;
subdOpt.shiftHalfStepNthU = 2;
const pts = face.subdivideToPointsControlled(subdOpt);
expect(pts.length).toBe(30);
expect(pts).toEqual([
[8.659560562354932e-17, -2, 8.659560562354934e-17],
[0, -1.618033988749895, 1.1755705045849463],
[1.3449970239279145, -0.6180339887498948, 1.3449970239279148],
[0, 0.6180339887498948, 1.902113032590307],
[0.8312538755549068, 1.618033988749895, 0.8312538755549069],
[0, 2, 1.2246467991473532e-16],
[8.659560562354934e-17, -2, -8.659560562354932e-17],
[1.1755705045849463, -1.618033988749895, 7.198293278059966e-17],
[1.3449970239279148, -0.6180339887498948, -1.3449970239279145],
[1.902113032590307, 0.6180339887498948, 1.1647083184890923e-16],
[0.8312538755549069, 1.618033988749895, -0.8312538755549068],
[1.2246467991473532e-16, 2, 7.498798913309288e-33],
[-8.659560562354932e-17, -2, -8.659560562354935e-17],
[1.4396586556119933e-16, -1.618033988749895, -1.1755705045849463],
[-1.3449970239279145, -0.6180339887498948, -1.344997023927915],
[2.3294166369781847e-16, 0.6180339887498948, -1.902113032590307],
[-0.8312538755549068, 1.618033988749895, -0.831253875554907],
[1.4997597826618576e-32, 2, -1.2246467991473532e-16],
[-8.659560562354935e-17, -2, 8.65956056235493e-17],
[-1.1755705045849463, -1.618033988749895, -2.15948798341799e-16],
[-1.344997023927915, -0.6180339887498948, 1.3449970239279143],
[-1.902113032590307, 0.6180339887498948, -3.494124955467277e-16],
[-0.831253875554907, 1.618033988749895, 0.8312538755549067],
[-1.2246467991473532e-16, 2, -2.2496396739927864e-32],
[8.65956056235493e-17, -2, 8.659560562354935e-17],
[-2.8793173112239865e-16, -1.618033988749895, 1.1755705045849463],
[1.3449970239279143, -0.6180339887498948, 1.344997023927915],
[-4.658833273956369e-16, 0.6180339887498948, 1.902113032590307],
[0.8312538755549067, 1.618033988749895, 0.831253875554907],
[-2.999519565323715e-32, 2, 1.2246467991473532e-16]
]);
sph.delete();
f.delete();
});
it('should subdivide face into points controlled with removals', () => {
const sph = occHelper.bRepPrimAPIMakeSphere([0, 0, 0], [0, 1, 0], 2);
const f = face.getFace({ shape: sph, index: 0 });
const subdOpt = new OCCT.FaceSubdivisionControlledDto(f);
subdOpt.nrDivisionsU = 4;
subdOpt.nrDivisionsV = 7;
subdOpt.shiftHalfStepNthV = 3;
subdOpt.removeEndEdgeNthV = 2;
subdOpt.removeEndEdgeNthU = 1;
subdOpt.removeStartEdgeNthV = 2;
subdOpt.removeStartEdgeNthU = 1;
const pts = face.subdivideToPointsControlled(subdOpt);
expect(pts.length).toBe(12);
expect(pts).toEqual([
[1.0605752387249069e-16, -2, -6.123233995736764e-17],
[0.8660254037844385, -1.7320508075688774, -0.49999999999999967],
[1.5, -1, -0.8660254037844383],
[1.7320508075688774, 0, -0.9999999999999996],
[1.5000000000000002, 0.9999999999999997, -0.8660254037844384],
[0.8660254037844393, 1.732050807568877, -0.5000000000000001],
[1.0605752387249069e-16, 2, -6.123233995736764e-17],
[-0.8660254037844383, -1.7320508075688774, -0.5000000000000003],
[-1.4999999999999996, -1, -0.8660254037844394],
[-1.732050807568877, 0, -1.0000000000000009],
[-1.4999999999999998, 0.9999999999999997, -0.8660254037844395],
[-0.866025403784439, 1.732050807568877, -0.5000000000000008]
]);
sph.delete();
f.delete();
});
it('should subdivide face into points', () => {

@@ -174,0 +249,0 @@ const sph = occHelper.bRepPrimAPIMakeSphere([0, 0, 0], [0, 1, 0], 2);

@@ -10,6 +10,6 @@ import { OccHelper } from '../../occ-helper';

fromClosedShell(inputs: Inputs.OCCT.ShapeDto<TopoDS_Shell>): TopoDS_Solid;
createBox(inputs: Inputs.OCCT.BoxDto): any;
createBoxFromCorner(inputs: Inputs.OCCT.BoxFromCornerDto): any;
createCylinder(inputs: Inputs.OCCT.CylinderDto): any;
createCylindersOnLines(inputs: Inputs.OCCT.CylindersOnLinesDto): any;
createBox(inputs: Inputs.OCCT.BoxDto): TopoDS_Solid;
createBoxFromCorner(inputs: Inputs.OCCT.BoxFromCornerDto): TopoDS_Solid;
createCylinder(inputs: Inputs.OCCT.CylinderDto): TopoDS_Solid;
createCylindersOnLines(inputs: Inputs.OCCT.CylindersOnLinesDto): TopoDS_Solid[];
createSphere(inputs: Inputs.OCCT.SphereDto): any;

@@ -16,0 +16,0 @@ createCone(inputs: Inputs.OCCT.ConeDto): any;

@@ -44,2 +44,77 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}));
it('should create a box solid', () => __awaiter(void 0, void 0, void 0, function* () {
const box = solid.createBox({ width: 2, height: 2, length: 2, center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: box })).toBeCloseTo(8);
box.delete();
}));
it('should create a box solid from corner', () => __awaiter(void 0, void 0, void 0, function* () {
const box = solid.createBoxFromCorner({ corner: [-1, -1, -1], width: 3, height: 2, length: 2 });
const center = solid.getSolidCenterOfMass({ shape: box });
expect(solid.getSolidVolume({ shape: box })).toBeCloseTo(12);
expect(center).toEqual([0.5, 0, 0]);
box.delete();
}));
it('should create a cylinder solid', () => __awaiter(void 0, void 0, void 0, function* () {
const cylinder = solid.createCylinder({ radius: 2, height: 2, center: [0, 0, 0], direction: [0, 0, 1] });
expect(solid.getSolidVolume({ shape: cylinder })).toBeCloseTo(25.13274122871834);
cylinder.delete();
}));
it('should create a cylinder solid wit default direction', () => __awaiter(void 0, void 0, void 0, function* () {
const cylinder = solid.createCylinder({ radius: 2, height: 2, center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: cylinder })).toBeCloseTo(25.13274122871834);
cylinder.delete();
}));
it('should create a sphere solid', () => __awaiter(void 0, void 0, void 0, function* () {
const sphere = solid.createSphere({ radius: 2, center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: sphere })).toBeCloseTo(33.51032163829113);
sphere.delete();
}));
it('should create a cone solid', () => __awaiter(void 0, void 0, void 0, function* () {
const cone = solid.createCone({ height: 3, radius1: 3, radius2: 1, angle: Math.PI, direction: [0, 1, 0], center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: cone })).toBeCloseTo(20.42035224833366);
expect(solid.getSolidSurfaceArea({ shape: cone })).toBeCloseTo(50.36231006622692);
cone.delete();
}));
it('should create a cone of half angle solid', () => __awaiter(void 0, void 0, void 0, function* () {
const cone = solid.createCone({ height: 3, radius1: 3, radius2: 1, angle: Math.PI / 2, direction: [0, 1, 0], center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: cone })).toBeCloseTo(20.42035224833366 / 2);
cone.delete();
}));
it('should create a cone of half angle solid', () => __awaiter(void 0, void 0, void 0, function* () {
const cone = solid.createCone({ height: 3, radius1: 3, radius2: 1, angle: Math.PI / 2, direction: [0, 1, 0], center: [0, 0, 0] });
expect(solid.getSolidVolume({ shape: cone })).toBeCloseTo(20.42035224833366 / 2);
cone.delete();
}));
it('should create cylinders on lines and get volumes', () => __awaiter(void 0, void 0, void 0, function* () {
const cylinders = solid.createCylindersOnLines({
radius: 2,
lines: [
{ start: [0, 0, 0], end: [0, 1, 0] },
{ start: [0, -1, 0], end: [0, 1, 1] },
{ start: [-1, -1, 0], end: [1, 1, 0] }
]
});
expect(cylinders.length).toBe(3);
const volumes = solid.getSolidsVolumes({ shapes: cylinders });
const centersOfMass = solid.getSolidsCentersOfMass({ shapes: cylinders });
expect(volumes[0]).toBeCloseTo(12.56637061435917);
expect(volumes[1]).toBeCloseTo(28.099258924162907);
expect(volumes[2]).toBeCloseTo(35.54306350526693);
expect(centersOfMass[0]).toEqual([
-7.016405868980245e-17,
0.49999999999999994,
-7.06789929214115e-17
]);
expect(centersOfMass[1]).toEqual([
-5.167467325983023e-17,
9.482581965210151e-17,
0.5000000000000001
]);
expect(centersOfMass[2]).toEqual([
8.746079156879059e-17,
-7.496639277324908e-17,
-9.515812715170455e-18
]);
cylinders.forEach(c => c.delete());
}));
});

@@ -387,2 +387,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}));
it('should create a ngon wire', () => {
const w = wire.createNGonWire({ nrCorners: 6, radius: 1, center: [0, 0, 0], direction: [0, 0, 1] });
const length = wire.getWireLength({ shape: w });
const cornerPoints = edge.getCornerPointsOfEdgesForShape({ shape: w });
expect(cornerPoints.length).toBe(6);
expect(length).toBeCloseTo(6);
expect(cornerPoints).toEqual([
[0, 1, 0],
[0.8660254037844386, 0.5000000000000001, 0],
[0.8660254037844387, -0.4999999999999998, 0],
[1.1102230246251565e-16, -1, 0],
[-0.8660254037844385, -0.5000000000000004, 0],
[-0.866025403784439, 0.49999999999999933, 0]
]);
w.delete();
});
});

@@ -25,11 +25,11 @@ export class OCCTTransforms {

const transformation = new this.occ.gp_Trsf_1();
const gpPnt = this.och.gpPnt([0, 0, 0]);
const gpPnt = this.och.gpPnt([0.0, 0.0, 0.0]);
transformation.SetScale(gpPnt, inputs.factor);
const scaling = new this.occ.TopLoc_Location_2(transformation);
const moved = inputs.shape.Moved(scaling, false);
const result = this.och.getActualTypeOfShape(moved);
const transf = new this.occ.BRepBuilderAPI_Transform_2(inputs.shape, transformation, true);
const s = transf.Shape();
const result = this.och.getActualTypeOfShape(s);
gpPnt.delete();
transformation.delete();
scaling.delete();
moved.delete();
transf.delete();
s.delete();
return result;

@@ -41,3 +41,3 @@ }

const scale = inputs.scale;
const mat = new this.occ.gp_Mat_2(scale[0], 0, 0, 0, scale[1], 0, 0, 0, scale[2]);
const mat = new this.occ.gp_Mat_2(scale[0], 0.0, 0.0, 0.0, scale[1], 0.0, 0.0, 0.0, scale[2]);
transformation.SetVectorialPart(mat);

@@ -44,0 +44,0 @@ let result;

{
"name": "bitbybit-occt",
"version": "0.9.29",
"version": "0.9.30",
"description": "Bit By Bit Developers CAD algorithms using OpenCascade Technology kernel. Run in Node and in Browser.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc