discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

function svgPoints() in the pathbuilder library

JW
Joe Weinpert
Sat, Jan 15, 2022 6:48 PM

Is there a procedure or function to remove consecutive duplicate points
from the data array returned by *svgPoints() *in the *pathbuilder *library?

The path string of an object from Inkscape (see attached SVG file) is used
in this example:

include <pathbuilder.scad>
objPath = "m 342.90003,358.02333 c -17.99286,0.81185 -30.32223,-20.88856
-6.71865,-24.03758 16.88561,-10.79732 -20.03126,-10.28204
-27.35932,-11.70948 -37.07082,-2.12289 -74.82867,-13.28583
-104.47467,-36.14505 -24.74472,-16.82199 6.06985,-34.22515
22.82105,-38.64347 12.57605,-8.11766 45.64911,-10.10405 41.27481,-28.09373
-21.88703,-10.96832 -49.44,-1.40288 -66.64094,14.41026 -14.24983,14.20294
-34.9447,18.91307 -54.29572,14.43611 -17.82597,-2.78354 -45.06864,-12.16807
-38.97227,-35.28131 4.71503,-20.28987 5.14435,-45.72284
-17.009616,-55.91851 C 63.952387,138.00383 31.319233,127.18815
4.6650364,106.89205 -9.9373433,82.327563 35.688067,84.640361
50.178576,87.454382 72.612859,88.247563 93.886477,102.66
116.37228,97.980052 123.11748,79.968912 89.608116,69.637168
77.911759,57.610527 62.707809,44.554392 38.377235,33.304517
36.5066,11.307517 49.450489,-7.0560881 76.599268,1.9067695
95.844793,0.96007991 138.61692,3.4682666 177.89163,21.499635
217.53749,35.883572 c 25.22282,12.027609 49.3191,-12.77849
74.91019,-5.331008 34.0276,6.744788 65.48384,22.58502 95.4376,39.519935
20.09121,14.267118 -1.35799,36.674211 -19.63921,36.773151 -16.79328,4.97808
-50.99454,-5.42638 -57.63504,0.77705 32.70828,22.42571 73.9426,11.14363
110.54962,16.64152 22.41783,18.54233 -15.77882,37.31572 -32.12701,42.41169
-18.60861,8.21893 -39.6846,2.67809 -58.49455,8.93302 10.55941,14.7401
35.50254,14.75874 53.03443,19.14379 25.74282,5.336 52.90342,4.73575
77.77611,13.46553 17.74919,7.97803 24.40774,31.64564 12.3753,47.32415
-15.21061,25.57157 -48.52265,28.59664 -67.45281,49.62076 -12.10676,20.26289
35.03067,25.59881 18.1882,44.16738 -19.35702,15.60126 -45.20843,8.17325
-67.92448,9.26802 -4.54616,-0.15022 -9.09845,-0.23765 -13.63581,-0.57523 z";
objPoints = svgPoints( objPath );
echo( objPoints[0] );

The resulting array is 331 points out of which 31 of them are consecutively
duplicated throughout.

Because of the consecutive duplicates, this points array is rejected by the
offset_sweep() function in the *BOSL2 *library.

Joe Weinpert

Is there a procedure or function to remove consecutive duplicate points from the data array returned by *svgPoints() *in the *pathbuilder *library? The path string of an object from Inkscape (see attached SVG file) is used in this example: include <pathbuilder.scad> objPath = "m 342.90003,358.02333 c -17.99286,0.81185 -30.32223,-20.88856 -6.71865,-24.03758 16.88561,-10.79732 -20.03126,-10.28204 -27.35932,-11.70948 -37.07082,-2.12289 -74.82867,-13.28583 -104.47467,-36.14505 -24.74472,-16.82199 6.06985,-34.22515 22.82105,-38.64347 12.57605,-8.11766 45.64911,-10.10405 41.27481,-28.09373 -21.88703,-10.96832 -49.44,-1.40288 -66.64094,14.41026 -14.24983,14.20294 -34.9447,18.91307 -54.29572,14.43611 -17.82597,-2.78354 -45.06864,-12.16807 -38.97227,-35.28131 4.71503,-20.28987 5.14435,-45.72284 -17.009616,-55.91851 C 63.952387,138.00383 31.319233,127.18815 4.6650364,106.89205 -9.9373433,82.327563 35.688067,84.640361 50.178576,87.454382 72.612859,88.247563 93.886477,102.66 116.37228,97.980052 123.11748,79.968912 89.608116,69.637168 77.911759,57.610527 62.707809,44.554392 38.377235,33.304517 36.5066,11.307517 49.450489,-7.0560881 76.599268,1.9067695 95.844793,0.96007991 138.61692,3.4682666 177.89163,21.499635 217.53749,35.883572 c 25.22282,12.027609 49.3191,-12.77849 74.91019,-5.331008 34.0276,6.744788 65.48384,22.58502 95.4376,39.519935 20.09121,14.267118 -1.35799,36.674211 -19.63921,36.773151 -16.79328,4.97808 -50.99454,-5.42638 -57.63504,0.77705 32.70828,22.42571 73.9426,11.14363 110.54962,16.64152 22.41783,18.54233 -15.77882,37.31572 -32.12701,42.41169 -18.60861,8.21893 -39.6846,2.67809 -58.49455,8.93302 10.55941,14.7401 35.50254,14.75874 53.03443,19.14379 25.74282,5.336 52.90342,4.73575 77.77611,13.46553 17.74919,7.97803 24.40774,31.64564 12.3753,47.32415 -15.21061,25.57157 -48.52265,28.59664 -67.45281,49.62076 -12.10676,20.26289 35.03067,25.59881 18.1882,44.16738 -19.35702,15.60126 -45.20843,8.17325 -67.92448,9.26802 -4.54616,-0.15022 -9.09845,-0.23765 -13.63581,-0.57523 z"; objPoints = svgPoints( objPath ); echo( objPoints[0] ); The resulting array is 331 points out of which 31 of them are consecutively duplicated throughout. Because of the consecutive duplicates, this points array is rejected by the *offset_sweep()* function in the *BOSL2 *library. Joe Weinpert
AM
Adrian Mariano
Sat, Jan 15, 2022 7:06 PM

You should be able to use the BOSL2 deduplicate() function to remove
sequential duplicate points.

On Sat, Jan 15, 2022 at 1:49 PM Joe Weinpert joe.weinpert@gmail.com wrote:

Is there a procedure or function to remove consecutive duplicate points from the data array returned by svgPoints() in the pathbuilder library?

The path string of an object from Inkscape (see attached SVG file) is used in this example:

include <pathbuilder.scad>
objPath = "m 342.90003,358.02333 c -17.99286,0.81185 -30.32223,-20.88856 -6.71865,-24.03758 16.88561,-10.79732 -20.03126,-10.28204 -27.35932,-11.70948 -37.07082,-2.12289 -74.82867,-13.28583 -104.47467,-36.14505 -24.74472,-16.82199 6.06985,-34.22515 22.82105,-38.64347 12.57605,-8.11766 45.64911,-10.10405 41.27481,-28.09373 -21.88703,-10.96832 -49.44,-1.40288 -66.64094,14.41026 -14.24983,14.20294 -34.9447,18.91307 -54.29572,14.43611 -17.82597,-2.78354 -45.06864,-12.16807 -38.97227,-35.28131 4.71503,-20.28987 5.14435,-45.72284 -17.009616,-55.91851 C 63.952387,138.00383 31.319233,127.18815 4.6650364,106.89205 -9.9373433,82.327563 35.688067,84.640361 50.178576,87.454382 72.612859,88.247563 93.886477,102.66 116.37228,97.980052 123.11748,79.968912 89.608116,69.637168 77.911759,57.610527 62.707809,44.554392 38.377235,33.304517 36.5066,11.307517 49.450489,-7.0560881 76.599268,1.9067695 95.844793,0.96007991 138.61692,3.4682666 177.89163,21.499635 217.53749,35.883572 c 25.22282,12.027609 49.3191,-12.77849 74.91019,-5.331008 34.0276,6.744788 65.48384,22.58502 95.4376,39.519935 20.09121,14.267118 -1.35799,36.674211 -19.63921,36.773151 -16.79328,4.97808 -50.99454,-5.42638 -57.63504,0.77705 32.70828,22.42571 73.9426,11.14363 110.54962,16.64152 22.41783,18.54233 -15.77882,37.31572 -32.12701,42.41169 -18.60861,8.21893 -39.6846,2.67809 -58.49455,8.93302 10.55941,14.7401 35.50254,14.75874 53.03443,19.14379 25.74282,5.336 52.90342,4.73575 77.77611,13.46553 17.74919,7.97803 24.40774,31.64564 12.3753,47.32415 -15.21061,25.57157 -48.52265,28.59664 -67.45281,49.62076 -12.10676,20.26289 35.03067,25.59881 18.1882,44.16738 -19.35702,15.60126 -45.20843,8.17325 -67.92448,9.26802 -4.54616,-0.15022 -9.09845,-0.23765 -13.63581,-0.57523 z";
objPoints = svgPoints( objPath );
echo( objPoints[0] );

The resulting array is 331 points out of which 31 of them are consecutively duplicated throughout.

Because of the consecutive duplicates, this points array is rejected by the offset_sweep() function in the BOSL2 library.

Joe Weinpert


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

You should be able to use the BOSL2 deduplicate() function to remove sequential duplicate points. On Sat, Jan 15, 2022 at 1:49 PM Joe Weinpert <joe.weinpert@gmail.com> wrote: > > > Is there a procedure or function to remove consecutive duplicate points from the data array returned by svgPoints() in the pathbuilder library? > > The path string of an object from Inkscape (see attached SVG file) is used in this example: > > include <pathbuilder.scad> > objPath = "m 342.90003,358.02333 c -17.99286,0.81185 -30.32223,-20.88856 -6.71865,-24.03758 16.88561,-10.79732 -20.03126,-10.28204 -27.35932,-11.70948 -37.07082,-2.12289 -74.82867,-13.28583 -104.47467,-36.14505 -24.74472,-16.82199 6.06985,-34.22515 22.82105,-38.64347 12.57605,-8.11766 45.64911,-10.10405 41.27481,-28.09373 -21.88703,-10.96832 -49.44,-1.40288 -66.64094,14.41026 -14.24983,14.20294 -34.9447,18.91307 -54.29572,14.43611 -17.82597,-2.78354 -45.06864,-12.16807 -38.97227,-35.28131 4.71503,-20.28987 5.14435,-45.72284 -17.009616,-55.91851 C 63.952387,138.00383 31.319233,127.18815 4.6650364,106.89205 -9.9373433,82.327563 35.688067,84.640361 50.178576,87.454382 72.612859,88.247563 93.886477,102.66 116.37228,97.980052 123.11748,79.968912 89.608116,69.637168 77.911759,57.610527 62.707809,44.554392 38.377235,33.304517 36.5066,11.307517 49.450489,-7.0560881 76.599268,1.9067695 95.844793,0.96007991 138.61692,3.4682666 177.89163,21.499635 217.53749,35.883572 c 25.22282,12.027609 49.3191,-12.77849 74.91019,-5.331008 34.0276,6.744788 65.48384,22.58502 95.4376,39.519935 20.09121,14.267118 -1.35799,36.674211 -19.63921,36.773151 -16.79328,4.97808 -50.99454,-5.42638 -57.63504,0.77705 32.70828,22.42571 73.9426,11.14363 110.54962,16.64152 22.41783,18.54233 -15.77882,37.31572 -32.12701,42.41169 -18.60861,8.21893 -39.6846,2.67809 -58.49455,8.93302 10.55941,14.7401 35.50254,14.75874 53.03443,19.14379 25.74282,5.336 52.90342,4.73575 77.77611,13.46553 17.74919,7.97803 24.40774,31.64564 12.3753,47.32415 -15.21061,25.57157 -48.52265,28.59664 -67.45281,49.62076 -12.10676,20.26289 35.03067,25.59881 18.1882,44.16738 -19.35702,15.60126 -45.20843,8.17325 -67.92448,9.26802 -4.54616,-0.15022 -9.09845,-0.23765 -13.63581,-0.57523 z"; > objPoints = svgPoints( objPath ); > echo( objPoints[0] ); > > The resulting array is 331 points out of which 31 of them are consecutively duplicated throughout. > > Because of the consecutive duplicates, this points array is rejected by the offset_sweep() function in the BOSL2 library. > > > > Joe Weinpert > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org