New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.10.5 to 0.10.6

4

generate-prod-build-yaml.js

@@ -352,2 +352,6 @@ // this file is used to generate a custom build yml file by reading source code "this.occ." references of the classes in use. This makes sure that

'gp_Vec2d',
'TopOpeBRepTool',
'TopOpeBRepTool_PurgeInternalEdges',
'TopTools_DataMapOfShapeListOfShape',
'TopTools_IndexedDataMapOfShapeListOfShape'
];

@@ -354,0 +358,0 @@ files.forEach(file => {

@@ -53,2 +53,7 @@ import { Base } from "./inputs";

}
enum BRepOffsetModeEnum {
skin = "skin",
pipe = "pipe",
rectoVerso = "rectoVerso"
}
enum ApproxParametrizationTypeEnum {

@@ -123,2 +128,38 @@ approxChordLength = "approxChordLength",

}
class ClosestPointsOnShapeFromPointsDto<T> {
/**
* The OCCT shape
* @default undefined
*/
shape: T;
/**
* The list of points
* @default undefined
*/
points: Base.Point3[];
}
class ClosestPointsOnShapesFromPointsDto<T> {
/**
* The OCCT shapes
* @default undefined
*/
shapes: T[];
/**
* The list of points
* @default undefined
*/
points: Base.Point3[];
}
class ClosestPointsBetweenTwoShapesDto<T> extends ShapesDto<T> {
/**
* The OCCT shapes
* @default undefined
*/
shape1?: T;
/**
* The OCCT shapes
* @default undefined
*/
shape2?: T;
}
class FaceFromSurfaceAndWireDto<T, U> extends ShapesDto<T> {

@@ -830,2 +871,36 @@ /**

}
class Fillet3DWireDto<T> {
constructor(shape?: T);
/**
* Shape to apply the fillets
* @default undefined
*/
shape: T;
/**
* Radius of the fillets
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 0.1
* @optional true
*/
radius?: number;
/**
* Radius list
* @default undefined
* @optional true
*/
radiusList?: number[];
/**
* List of edge indexes to which apply the fillet, if left empty all edges will be rounded
* @default undefined
* @optional true
*/
indexes?: number[];
/**
* Orientation direction for the fillet
* @default [0, 1, 0]
*/
direction: Base.Vector3;
}
class ChamferDto<T> {

@@ -1123,2 +1198,37 @@ constructor(shape?: T, distance?: number, indexes?: number[], all?: boolean);

}
class OffsetAdvancedDto<T> {
constructor(shape?: T, distance?: number, tolerance?: number);
/**
* Shape to offset
* @default undefined
*/
shape: T;
/**
* Distance of offset
* @default 0.2
* @minimum -Infinity
* @maximum Infinity
* @step 0.1
*/
distance: number;
/**
* Offset tolerance
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 0.01
*/
tolerance: number;
/**
* Join defines how to fill the holes that may appear between parallels to the two adjacent faces. It may take values GeomAbs_Arc or GeomAbs_Intersection:
* if Join is equal to GeomAbs_Arc, then pipes are generated between two free edges of two adjacent parallels, and spheres are generated on "images" of vertices; it is the default value
* @default arc
*/
joinType: JoinTypeEnum;
/**
* Removes internal edges
* @default false
*/
removeIntEdges: boolean;
}
class RevolveDto<T> {

@@ -1163,2 +1273,58 @@ constructor(shape?: T, degrees?: number, direction?: Base.Vector3, copy?: boolean);

}
class PipeWiresCylindricalDto<T> {
constructor(shapes?: T[]);
/**
* Wire paths to pipe
* @default undefined
*/
shapes: T[];
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
radius: number;
}
class PipeWireCylindricalDto<T> {
constructor(shapes?: T);
/**
* Wire path to pipe
* @default undefined
*/
shape: T;
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
radius: number;
}
class PipePolygonWireNGonDto<T> {
constructor(shapes?: T);
/**
* Wire path to pipe
* @default undefined
*/
shape: T;
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
radius: number;
/**
* Nr of ngon corners to be used
* @default 6
* @minimum 3
* @maximum Infinity
* @step 1
*/
nrCorners: number;
}
class ExtrudeDto<T> {

@@ -1165,0 +1331,0 @@ constructor(shape?: T, direction?: Base.Vector3);

@@ -10,2 +10,8 @@ // tslint:disable-next-line: no-namespace

})(JoinTypeEnum = OCCT.JoinTypeEnum || (OCCT.JoinTypeEnum = {}));
let BRepOffsetModeEnum;
(function (BRepOffsetModeEnum) {
BRepOffsetModeEnum["skin"] = "skin";
BRepOffsetModeEnum["pipe"] = "pipe";
BRepOffsetModeEnum["rectoVerso"] = "rectoVerso";
})(BRepOffsetModeEnum = OCCT.BRepOffsetModeEnum || (OCCT.BRepOffsetModeEnum = {}));
let ApproxParametrizationTypeEnum;

@@ -56,2 +62,11 @@ (function (ApproxParametrizationTypeEnum) {

OCCT.FilletTwoEdgesInPlaneDto = FilletTwoEdgesInPlaneDto;
class ClosestPointsOnShapeFromPointsDto {
}
OCCT.ClosestPointsOnShapeFromPointsDto = ClosestPointsOnShapeFromPointsDto;
class ClosestPointsOnShapesFromPointsDto {
}
OCCT.ClosestPointsOnShapesFromPointsDto = ClosestPointsOnShapesFromPointsDto;
class ClosestPointsBetweenTwoShapesDto extends ShapesDto {
}
OCCT.ClosestPointsBetweenTwoShapesDto = ClosestPointsBetweenTwoShapesDto;
class FaceFromSurfaceAndWireDto extends ShapesDto {

@@ -738,2 +753,22 @@ constructor() {

OCCT.FilletDto = FilletDto;
class Fillet3DWireDto {
constructor(shape) {
/**
* Radius of the fillets
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 0.1
* @optional true
*/
this.radius = 0.1;
/**
* Orientation direction for the fillet
* @default [0, 1, 0]
*/
this.direction = [0, 1, 0];
this.shape = shape;
}
}
OCCT.Fillet3DWireDto = Fillet3DWireDto;
class ChamferDto {

@@ -1004,2 +1039,39 @@ constructor(shape, distance, indexes, all) {

OCCT.OffsetDto = OffsetDto;
class OffsetAdvancedDto {
constructor(shape, distance, tolerance) {
/**
* Distance of offset
* @default 0.2
* @minimum -Infinity
* @maximum Infinity
* @step 0.1
*/
this.distance = 0.2;
/**
* Offset tolerance
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 0.01
*/
this.tolerance = 0.1;
/**
* Join defines how to fill the holes that may appear between parallels to the two adjacent faces. It may take values GeomAbs_Arc or GeomAbs_Intersection:
* if Join is equal to GeomAbs_Arc, then pipes are generated between two free edges of two adjacent parallels, and spheres are generated on "images" of vertices; it is the default value
* @default arc
*/
this.joinType = JoinTypeEnum.arc;
/**
* Removes internal edges
* @default false
*/
this.removeIntEdges = false;
this.shape = shape;
this.distance = distance;
if (tolerance) {
this.tolerance = tolerance;
}
}
}
OCCT.OffsetAdvancedDto = OffsetAdvancedDto;
class RevolveDto {

@@ -1041,2 +1113,52 @@ constructor(shape, degrees, direction, copy) {

OCCT.ShapeShapesDto = ShapeShapesDto;
class PipeWiresCylindricalDto {
constructor(shapes) {
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
this.radius = 0.1;
this.shapes = shapes;
}
}
OCCT.PipeWiresCylindricalDto = PipeWiresCylindricalDto;
class PipeWireCylindricalDto {
constructor(shapes) {
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
this.radius = 0.1;
this.shape = shapes;
}
}
OCCT.PipeWireCylindricalDto = PipeWireCylindricalDto;
class PipePolygonWireNGonDto {
constructor(shapes) {
/**
* Radius of the cylindrical pipe
* @default 0.1
* @minimum 0
* @maximum Infinity
* @step 1
*/
this.radius = 0.1;
/**
* Nr of ngon corners to be used
* @default 6
* @minimum 3
* @maximum Infinity
* @step 1
*/
this.nrCorners = 6;
this.shape = shapes;
}
}
OCCT.PipePolygonWireNGonDto = PipePolygonWireNGonDto;
class ExtrudeDto {

@@ -1043,0 +1165,0 @@ constructor(shape, direction) {

@@ -31,2 +31,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';

splitShapeWithShapes(inputs: Inputs.OCCT.SplitDto<TopoDS_Shape>): TopoDS_Shape;
extrude(inputs: Inputs.OCCT.ExtrudeDto<TopoDS_Shape>): TopoDS_Shape;
makeCompound(inputs: Inputs.OCCT.CompoundShapesDto<TopoDS_Shape>): TopoDS_Compound;

@@ -33,0 +34,0 @@ gpAx3(point: Base.Point3, direction: Base.Vector3): gp_Ax3;

@@ -62,2 +62,10 @@ export var typeSpecificityEnum;

}
extrude(inputs) {
const gpVec = new this.occ.gp_Vec_4(inputs.direction[0], inputs.direction[1], inputs.direction[2]);
const prismMaker = new this.occ.BRepPrimAPI_MakePrism_1(inputs.shape, gpVec, false, true);
const prismShape = prismMaker.Shape();
prismMaker.delete();
gpVec.delete();
return prismShape;
}
makeCompound(inputs) {

@@ -64,0 +72,0 @@ const resCompound = new this.occ.TopoDS_Compound();

@@ -11,4 +11,5 @@ import { OccHelper } from '../occ-helper';

filletTwoEdgesInPlaneIntoAWire(inputs: Inputs.OCCT.FilletTwoEdgesInPlaneDto<TopoDS_Edge>): TopoDS_Wire;
fillet3DWire(inputs: Inputs.OCCT.Fillet3DWireDto<TopoDS_Wire>): TopoDS_Wire;
fillet2d(inputs: Inputs.OCCT.FilletDto<TopoDS_Wire | TopoDS_Face>): TopoDS_Face | TopoDS_Wire;
private applyRadiusToVertex;
}

@@ -120,2 +120,16 @@ export class OCCTFillets {

}
fillet3DWire(inputs) {
const extrusion = this.och.extrude({ shape: inputs.shape, direction: inputs.direction });
const filletShape = this.filletEdges({ shape: extrusion, radius: inputs.radius, indexes: inputs.indexes, radiusList: inputs.radiusList });
const faceEdges = [];
this.och.getFaces({ shape: filletShape }).forEach(f => {
const firstEdge = this.och.getEdges({ shape: f })[0];
faceEdges.push(firstEdge);
});
const result = this.och.combineEdgesAndWiresIntoAWire({ shapes: faceEdges });
extrusion.delete();
filletShape.delete();
faceEdges.forEach(e => e.delete());
return result;
}
fillet2d(inputs) {

@@ -122,0 +136,0 @@ if (inputs.indexes && inputs.radiusList && inputs.radiusList.length !== inputs.indexes.length) {

@@ -8,6 +8,9 @@ import { OpenCascadeInstance, TopoDS_Shape, TopoDS_Wire } from '../../bitbybit-dev-occt/bitbybit-dev-occt';

constructor(occ: OpenCascadeInstance, och: OccHelper);
closestPointsBetweenTwoShapes(inputs: Inputs.OCCT.ShapesDto<TopoDS_Shape>): [Inputs.Base.Point3, Inputs.Base.Point3];
closestPointsBetweenTwoShapes(inputs: Inputs.OCCT.ClosestPointsBetweenTwoShapesDto<TopoDS_Shape>): [Inputs.Base.Point3, Inputs.Base.Point3];
closestPointsOnShapeFromPoints(inputs: Inputs.OCCT.ClosestPointsOnShapeFromPointsDto<TopoDS_Shape>): Inputs.Base.Point3[];
closestPointsOnShapesFromPoints(inputs: Inputs.OCCT.ClosestPointsOnShapesFromPointsDto<TopoDS_Shape>): Inputs.Base.Point3[];
loft(inputs: Inputs.OCCT.LoftDto<TopoDS_Wire>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
loftAdvanced(inputs: Inputs.OCCT.LoftAdvancedDto<TopoDS_Wire>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
offset(inputs: Inputs.OCCT.OffsetDto<TopoDS_Shape>): TopoDS_Shape;
offsetAdv(inputs: Inputs.OCCT.OffsetAdvancedDto<TopoDS_Shape>): TopoDS_Shape;
extrudeShapes(inputs: Inputs.OCCT.ExtrudeShapesDto<TopoDS_Shape>): TopoDS_Shape[];

@@ -19,4 +22,9 @@ extrude(inputs: Inputs.OCCT.ExtrudeDto<TopoDS_Shape>): TopoDS_Shape;

pipe(inputs: Inputs.OCCT.ShapeShapesDto<TopoDS_Wire, TopoDS_Shape>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
pipePolylineWireNGon(inputs: Inputs.OCCT.PipePolygonWireNGonDto<TopoDS_Wire>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
pipeWireCylindrical(inputs: Inputs.OCCT.PipeWireCylindricalDto<TopoDS_Wire>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
pipeWiresCylindrical(inputs: Inputs.OCCT.PipeWiresCylindricalDto<TopoDS_Wire>): (import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid)[];
makeThickSolidSimple(inputs: Inputs.OCCT.ThisckSolidSimpleDto<TopoDS_Shape>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
makeThickSolidByJoin(inputs: Inputs.OCCT.ThickSolidByJoinDto<TopoDS_Shape>): import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Edge | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Compound | TopoDS_Wire | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Vertex | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Face | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Shell | import("../../bitbybit-dev-occt/bitbybit-dev-occt").TopoDS_Solid;
private getJoinType;
private getBRepOffsetMode;
}

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

import { shapeTypeEnum, typeSpecificityEnum } from '../occ-helper';
import * as Inputs from '../api/inputs/inputs';

@@ -10,2 +11,16 @@ export class OCCTOperations {

}
closestPointsOnShapeFromPoints(inputs) {
const vertexes = inputs.points.map(p => this.och.makeVertex(p));
const pointsOnShape = vertexes.map(v => this.och.closestPointsBetweenTwoShapes(v, inputs.shape));
return pointsOnShape.map(p => p[1]);
}
closestPointsOnShapesFromPoints(inputs) {
const vertexes = inputs.points.map(p => this.och.makeVertex(p));
let result = [];
inputs.shapes.forEach((s) => {
const pointsOnShape = vertexes.map(v => this.och.closestPointsBetweenTwoShapes(v, s));
result.push(...pointsOnShape.map(p => p[1]));
});
return result;
}
loft(inputs) {

@@ -92,2 +107,5 @@ const pipe = new this.occ.BRepOffsetAPI_ThruSections(inputs.makeSolid, false, 1.0e-06);

offset(inputs) {
return this.offsetAdv({ shape: inputs.shape, distance: inputs.distance, tolerance: inputs.tolerance, joinType: Inputs.OCCT.JoinTypeEnum.arc, removeIntEdges: false });
}
offsetAdv(inputs) {
if (!inputs.tolerance) {

@@ -100,7 +118,10 @@ inputs.tolerance = 0.1;

let offset = null;
let joinType = this.getJoinType(inputs.joinType);
// only this mode is implemented currently, so we cannot expose others...
let brepOffsetMode = this.occ.BRepOffset_Mode.BRepOffset_Skin;
const wires = [];
if (inputs.shape.ShapeType() === this.occ.TopAbs_ShapeEnum.TopAbs_WIRE ||
inputs.shape.ShapeType() === this.occ.TopAbs_ShapeEnum.TopAbs_EDGE) {
if ((this.och.getShapeTypeEnum(inputs.shape) === shapeTypeEnum.wire ||
this.och.getShapeTypeEnum(inputs.shape) === shapeTypeEnum.edge)) {
let wire;
if (inputs.shape.ShapeType() === this.occ.TopAbs_ShapeEnum.TopAbs_EDGE) {
if (this.och.getShapeTypeEnum(inputs.shape) === shapeTypeEnum.edge) {
wire = this.och.bRepBuilderAPIMakeWire(inputs.shape);

@@ -112,14 +133,18 @@ wires.push(wire);

}
offset = new this.occ.BRepOffsetAPI_MakeOffset_1();
offset.Init_2(this.occ.GeomAbs_JoinType.GeomAbs_Arc, false);
offset.AddWire(wire);
offset.Perform(inputs.distance, 0.0);
try {
offset = new this.occ.BRepOffsetAPI_MakeOffset_1();
offset.Init_2(joinType, false);
offset.AddWire(wire);
offset.Perform(inputs.distance, 0.0);
}
catch (ex) {
// if first method fails we can still try the second one on wire
offset = new this.occ.BRepOffsetAPI_MakeOffsetShape();
offset.PerformByJoin(wire, inputs.distance, inputs.tolerance, brepOffsetMode, false, false, joinType, inputs.removeIntEdges, new this.occ.Message_ProgressRange_1());
}
}
else {
let shell = inputs.shape;
if (inputs.shape.ShapeType() === this.occ.TopAbs_ShapeEnum.TopAbs_FACE) {
shell = this.och.bRepBuilderAPIMakeShell(inputs.shape);
}
let shapeToOffset = inputs.shape;
offset = new this.occ.BRepOffsetAPI_MakeOffsetShape();
offset.PerformByJoin(shell, inputs.distance, inputs.tolerance, this.occ.BRepOffset_Mode.BRepOffset_Skin, false, false, this.occ.GeomAbs_JoinType.GeomAbs_Arc, false, new this.occ.Message_ProgressRange_1());
offset.PerformByJoin(shapeToOffset, inputs.distance, inputs.tolerance, brepOffsetMode, false, false, joinType, inputs.removeIntEdges, new this.occ.Message_ProgressRange_1());
}

@@ -144,8 +169,3 @@ const offsetShape = offset.Shape();

extrude(inputs) {
const gpVec = new this.occ.gp_Vec_4(inputs.direction[0], inputs.direction[1], inputs.direction[2]);
const prismMaker = new this.occ.BRepPrimAPI_MakePrism_1(inputs.shape, gpVec, false, true);
const prismShape = prismMaker.Shape();
prismMaker.delete();
gpVec.delete();
return prismShape;
return this.och.extrude(inputs);
}

@@ -249,2 +269,77 @@ splitShapeWithShapes(inputs) {

}
pipePolylineWireNGon(inputs) {
const wire = inputs.shape;
const shapesToPassThrough = [];
const edges = this.och.getEdges({ shape: wire });
edges.forEach((e, index) => {
const edgeStartPt = this.och.startPointOnEdge({ shape: e });
const tangent = this.och.tangentOnEdgeAtParam({ shape: e, param: 0 });
let tangentPreviousEdgeEnd;
let averageTangentVec = tangent;
if (index > 0 && index < edges.length - 1) {
const previousEdge = edges[index - 1];
tangentPreviousEdgeEnd = this.och.tangentOnEdgeAtParam({ shape: previousEdge, param: 1 });
averageTangentVec = [tangent[0] + tangentPreviousEdgeEnd[0] / 2, tangent[1] + tangentPreviousEdgeEnd[1] / 2, tangent[2] + tangentPreviousEdgeEnd[2] / 2];
}
const ngon = this.och.createNGonWire({ radius: inputs.radius, center: edgeStartPt, direction: averageTangentVec, nrCorners: inputs.nrCorners });
shapesToPassThrough.push(ngon);
if (index === edges.length - 1) {
const edgeEndPt = this.och.endPointOnEdge({ shape: e });
const tangentEndPt = this.och.tangentOnEdgeAtParam({ shape: e, param: 1 });
const ngon = this.och.createNGonWire({ radius: inputs.radius, center: edgeEndPt, direction: tangentEndPt, nrCorners: inputs.nrCorners });
shapesToPassThrough.push(ngon);
}
});
const pipe = new this.occ.BRepOffsetAPI_MakePipeShell(wire);
shapesToPassThrough.forEach(s => {
pipe.Add_1(s, false, false);
});
pipe.Build(new this.occ.Message_ProgressRange_1());
pipe.MakeSolid();
const pipeShape = pipe.Shape();
const result = this.och.getActualTypeOfShape(pipeShape);
pipeShape.delete();
pipe.delete();
return result;
}
pipeWireCylindrical(inputs) {
const wire = inputs.shape;
const shapesToPassThrough = [];
const edges = this.och.getEdges({ shape: wire });
edges.forEach((e, index) => {
const edgeStartPt = this.och.startPointOnEdge({ shape: e });
const tangent = this.och.tangentOnEdgeAtParam({ shape: e, param: 0 });
let tangentPreviousEdgeEnd;
let averageTangentVec = tangent;
if (index > 0 && index < edges.length - 1) {
const previousEdge = edges[index - 1];
tangentPreviousEdgeEnd = this.och.tangentOnEdgeAtParam({ shape: previousEdge, param: 1 });
averageTangentVec = [tangent[0] + tangentPreviousEdgeEnd[0] / 2, tangent[1] + tangentPreviousEdgeEnd[1] / 2, tangent[2] + tangentPreviousEdgeEnd[2] / 2];
}
const circle = this.och.createCircle(inputs.radius, edgeStartPt, averageTangentVec, typeSpecificityEnum.wire);
shapesToPassThrough.push(circle);
if (index === edges.length - 1) {
const edgeEndPt = this.och.endPointOnEdge({ shape: e });
const tangentEndPt = this.och.tangentOnEdgeAtParam({ shape: e, param: 1 });
const line = this.och.createCircle(inputs.radius, edgeEndPt, tangentEndPt, typeSpecificityEnum.wire);
shapesToPassThrough.push(line);
}
});
const pipe = new this.occ.BRepOffsetAPI_MakePipeShell(wire);
shapesToPassThrough.forEach(s => {
pipe.Add_1(s, false, false);
});
pipe.Build(new this.occ.Message_ProgressRange_1());
pipe.MakeSolid();
const pipeShape = pipe.Shape();
const result = this.och.getActualTypeOfShape(pipeShape);
pipeShape.delete();
pipe.delete();
return result;
}
pipeWiresCylindrical(inputs) {
return inputs.shapes.map(wire => {
return this.pipeWireCylindrical({ shape: wire, radius: inputs.radius });
});
}
makeThickSolidSimple(inputs) {

@@ -266,12 +361,3 @@ const maker = new this.occ.BRepOffsetAPI_MakeThickSolid();

const myBody = new this.occ.BRepOffsetAPI_MakeThickSolid();
let jointType;
if (inputs.joinType === Inputs.OCCT.JoinTypeEnum.arc) {
jointType = this.occ.GeomAbs_JoinType.GeomAbs_Arc;
}
else if (inputs.joinType === Inputs.OCCT.JoinTypeEnum.intersection) {
jointType = this.occ.GeomAbs_JoinType.GeomAbs_Intersection;
}
else if (inputs.joinType === Inputs.OCCT.JoinTypeEnum.tangent) {
jointType = this.occ.GeomAbs_JoinType.GeomAbs_Tangent;
}
let jointType = this.getJoinType(inputs.joinType);
myBody.MakeThickSolidByJoin(inputs.shape, facesToRemove, inputs.offset, inputs.tolerance, this.occ.BRepOffset_Mode.BRepOffset_Skin, // currently a single option

@@ -286,2 +372,28 @@ inputs.intersection, inputs.selfIntersection, jointType, inputs.removeIntEdges, new this.occ.Message_ProgressRange_1());

}
getJoinType(jointType) {
let res;
if (jointType === Inputs.OCCT.JoinTypeEnum.arc) {
res = this.occ.GeomAbs_JoinType.GeomAbs_Arc;
}
else if (jointType === Inputs.OCCT.JoinTypeEnum.intersection) {
res = this.occ.GeomAbs_JoinType.GeomAbs_Intersection;
}
else if (jointType === Inputs.OCCT.JoinTypeEnum.tangent) {
res = this.occ.GeomAbs_JoinType.GeomAbs_Tangent;
}
return res;
}
getBRepOffsetMode(offsetMode) {
let res;
if (offsetMode === Inputs.OCCT.BRepOffsetModeEnum.skin) {
res = this.occ.BRepOffset_Mode.BRepOffset_Skin;
}
else if (offsetMode === Inputs.OCCT.BRepOffsetModeEnum.pipe) {
res = this.occ.BRepOffset_Mode.BRepOffset_Pipe;
}
else if (offsetMode === Inputs.OCCT.BRepOffsetModeEnum.rectoVerso) {
res = this.occ.BRepOffset_Mode.BRepOffset_RectoVerso;
}
return res;
}
}

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

}));
it('should get five closest points between a shape and a collection of points', () => __awaiter(void 0, void 0, void 0, function* () {
const points = [
[0, 2, 0],
[1, 1, 1],
[2, -2, 2],
[-3, 3, 3],
[4, 4, -4],
];
const sph = occHelper.bRepPrimAPIMakeSphere([0, 0, 0], [0, 1, 0], 1);
const res = operations.closestPointsOnShapeFromPoints({ shape: sph, points });
expect(res.length).toBe(5);
expect(res).toEqual([
[-1.4997597826618576e-32, 1, 6.123233995736766e-17],
[0.5773502691896258, 0.5773502691896257, 0.5773502691896257],
[0.5773502691896258, -0.5773502691896257, 0.5773502691896257],
[-0.5773502691896258, 0.5773502691896257, 0.5773502691896256],
[0.5773502691896258, 0.5773502691896257, -0.5773502691896257]
]);
}));
it('should get ten closest points between two shape and a collection of points', () => __awaiter(void 0, void 0, void 0, function* () {
const points = [
[0, 2, 0],
[1, 1, 1],
[2, -2, 2],
[-3, 3, 3],
[4, 4, -4],
];
const sph1 = occHelper.bRepPrimAPIMakeSphere([0, 10, 0], [0, 1, 0], 1);
const sph2 = occHelper.bRepPrimAPIMakeSphere([0, 0, 10], [0, 1, 0], 2);
const res = operations.closestPointsOnShapesFromPoints({ shapes: [sph1, sph2], points });
expect(res.length).toBe(10);
expect(res).toEqual([
[-1.4997597826618576e-32, 9, 6.123233995736766e-17],
[0.1097642599896904, 9.012121660092786, 0.10976425998969039],
[0.1622214211307626, 9.026671473215425, 0.16222142113076257],
[-0.3665083330689157, 9.144813889505864, 0.36650833306891556],
[0.48507125007266594, 9.272393124891002, -0.4850712500726658],
[2.4017299715812683e-16, 0.3922322702763681, 8.03883864861816],
[0.21952851997938053, 0.21952851997938067, 8.024243320185574],
[0.471404520791032, -0.47140452079103173, 8.114381916835873],
[-0.733016666137831, 0.7330166661378313, 8.289627779011727],
[0.5298129428260179, 0.5298129428260177, 8.145654700108938]
]);
}));
});

2

package.json
{
"name": "bitbybit-occt",
"version": "0.10.5",
"version": "0.10.6",
"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