Skip to content

Commit d5fc130

Browse files
replaced line and polyline conversion methods to verb layer not to cause deprecations in old scripts where verb was used
1 parent 3227a41 commit d5fc130

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

packages/dev/core/lib/api/bitbybit/verb/curve.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,46 @@ export class VerbCurve {
4242
return this.context.verb.geom.NurbsCurve.byPoints(inputs.points, inputs.degree);
4343
}
4444

45+
/**
46+
* Converts lines to NURBS curves
47+
* Returns array of the verbnurbs Line objects
48+
* @param inputs Lines to be transformed to curves
49+
* @returns Verb nurbs curves
50+
*/
51+
convertLinesToNurbsCurves(inputs: Inputs.Verb.LinesDto): any[] {
52+
return inputs.lines.map(line => new this.context.verb.geom.Line(line.start, line.end));
53+
}
54+
55+
/**
56+
* Converts line to NURBS curve
57+
* Returns the verbnurbs Line object
58+
* @param inputs Line to be transformed to curve
59+
* @returns Verb nurbs curves
60+
*/
61+
convertLineToNurbsCurve(inputs: Inputs.Verb.LineDto): any {
62+
return new this.context.verb.geom.Line(inputs.line.start, inputs.line.end);
63+
}
64+
65+
/**
66+
* Converts a polyline to a NURBS curve
67+
* Returns the verbnurbs NurbsCurve object
68+
* @param inputs Polyline to be transformed to curve
69+
* @returns Verb nurbs curve
70+
*/
71+
convertPolylineToNurbsCurve(inputs: Inputs.Verb.PolylineDto): any {
72+
return this.context.verb.geom.NurbsCurve.byPoints(inputs.polyline.points, 1);
73+
}
74+
75+
/**
76+
* Converts a polylines to a NURBS curves
77+
* Returns the verbnurbs NurbsCurve objects
78+
* @param inputs Polylines to be transformed to curves
79+
* @returns Verb nurbs curves
80+
*/
81+
convertPolylinesToNurbsCurves(inputs: Inputs.Verb.PolylinesDto): any[] {
82+
return inputs.polylines.map(polyline => this.convertPolylineToNurbsCurve({ polyline }));
83+
}
84+
4585
/**
4686
* Creates a Bezier Nurbs curve by providing control points and weights
4787
* @param inputs Control points

packages/dev/core/lib/api/inputs/verb-inputs.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,42 @@ export namespace Verb {
1414
*/
1515
curve: any;
1616
}
17+
export class LineDto {
18+
constructor(line?: Base.Line3) {
19+
if (line !== undefined) { this.line = line; }
20+
}
21+
/**
22+
* Basic line
23+
*/
24+
line: Base.Line3;
25+
}
26+
export class LinesDto {
27+
constructor(lines?: Base.Line3[]) {
28+
if (lines !== undefined) { this.lines = lines; }
29+
}
30+
/**
31+
* Basic lines
32+
*/
33+
lines: Base.Line3[];
34+
}
35+
export class PolylineDto {
36+
constructor(polyline?: Base.Polyline3) {
37+
if (polyline !== undefined) { this.polyline = polyline; }
38+
}
39+
/**
40+
* Basic polyline
41+
*/
42+
polyline: Base.Polyline3;
43+
}
44+
export class PolylinesDto {
45+
constructor(polylines?: Base.Polyline3[]) {
46+
if (polylines !== undefined) { this.polylines = polylines; }
47+
}
48+
/**
49+
* Basic polyline
50+
*/
51+
polylines: Base.Polyline3[];
52+
}
1753
export class CurvesDto {
1854
constructor(curves?: any[]) {
1955
if (curves !== undefined) { this.curves = curves; }

0 commit comments

Comments
 (0)