Skip to content

Commit

Permalink
refactor(iges): add vectors dep, update addXXX signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 4, 2019
1 parent ee8200c commit 2fe6f8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
3 changes: 2 additions & 1 deletion packages/iges/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"@thi.ng/checks": "^2.4.0",
"@thi.ng/defmulti": "^1.1.4",
"@thi.ng/strings": "^1.3.0",
"@thi.ng/transducers": "^5.4.5"
"@thi.ng/transducers": "^5.4.5",
"@thi.ng/vectors": "^3.3.1"
},
"keywords": [
"CAD",
Expand Down
35 changes: 17 additions & 18 deletions packages/iges/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import {
push,
transduce,
wordWrap,
wrap
wrapSides
} from "@thi.ng/transducers";
import { ReadonlyVec } from "@thi.ng/vectors";
import {
BooleanNode,
BooleanTree,
Expand Down Expand Up @@ -254,7 +255,7 @@ const addEntity = (

export const addPolyline = (
doc: IGESDocument,
pts: ArrayLike<number>[],
pts: ReadonlyVec[],
form = PolylineMode.OPEN,
opts?: Partial<EntityOpts>
) => {
Expand All @@ -272,11 +273,9 @@ export const addPolyline = (
},
[
...params,
...mapcat<number[], Param>(
...mapcat<ReadonlyVec, Param>(
(p) => map((x) => <Param>[x, Type.FLOAT], p),
form === PolylineMode.CLOSED
? <any>wrap(pts, 1, false, true)
: pts
form === PolylineMode.CLOSED ? wrapSides(pts, 0, 1) : pts
)
],
opts
Expand All @@ -285,13 +284,13 @@ export const addPolyline = (

export const addPolygon = (
doc: IGESDocument,
pts: ArrayLike<number>[],
pts: ReadonlyVec[],
opts?: Partial<EntityOpts>
) => addPolyline(doc, pts, PolylineMode.FILLED, opts);

export const addPoint = (
doc: IGESDocument,
p: ArrayLike<number>,
p: ReadonlyVec,
opts?: Partial<EntityOpts>
) =>
addEntity(
Expand All @@ -309,8 +308,8 @@ export const addPoint = (

export const addLine = (
doc: IGESDocument,
a: ArrayLike<number>,
b: ArrayLike<number>,
a: ReadonlyVec,
b: ReadonlyVec,
opts?: Partial<EntityOpts>
) =>
addEntity(
Expand Down Expand Up @@ -356,10 +355,10 @@ const postOrder = (acc: Param[], tree: BooleanNode) => {

export const addCSGBox = (
doc: IGESDocument,
pos: ArrayLike<number>,
size: ArrayLike<number>,
xaxis: ArrayLike<number> = [1, 0, 0],
zaxis: ArrayLike<number> = [0, 0, 1],
pos: ReadonlyVec,
size: ReadonlyVec,
xaxis: ReadonlyVec = [1, 0, 0],
zaxis: ReadonlyVec = [0, 0, 1],
opts?: Partial<EntityOpts>
) =>
addEntity(
Expand All @@ -385,10 +384,10 @@ export const addCSGBox = (

export const addCSGCylinder = (
doc: IGESDocument,
pos: ArrayLike<number>,
normal: ArrayLike<number>,
radius: ArrayLike<number>,
height: ArrayLike<number>,
pos: ReadonlyVec,
normal: ReadonlyVec,
radius: ReadonlyVec,
height: ReadonlyVec,
opts?: Partial<EntityOpts>
) =>
addEntity(
Expand Down

0 comments on commit 2fe6f8c

Please sign in to comment.