Personally, I think changing children to myShape would have the greater

flexibility.

However, if you wanted to stay with children(), and since we can't pass

parameters to the children, the first solution that popped into mind is to

use more children and build a ADC (Analog Digital Converter) to switch

between them (e.g. like a CASE or SWITCH statement). See the sample code

below. In this case, the number of children corresponds to the granularity

of the ADC. In the example below, we assume all points intensities in range [0-255].

--------------------------

points = [15, 30, 100, 200, 60, 255, 178];

radius = 5;

module test_ADC()

{

ADC = 256/$children;

echo ($children, "-bit ADC, granularity =", ADC);

for (i = [0: len(points)-1])

{

x = floor(points[i]/ADC);

echo ("value=", points[i], " location= ", i*10, "Shape =", x );

translate ([i*10, 0, 0]) children(x);

}

}

module show_all_shapes()

{

for (i = [0: len(points)-1])

{

translate ([i*10, 0, 0]) children(i);

}

}

//show_all_shapes()

test_ADC()

{

circle (r=radius, $fn=3);

circle (r=radius, $fn=4);

circle (r=radius, $fn=5);

circle (r=radius, $fn=6);

circle (r=radius, $fn=8);

circle (r=radius, $fn=10);

square (radius*2, true);

}

--

Sent from:

http://forum.openscad.org/_______________________________________________

OpenSCAD mailing list

Discuss@lists.openscad.org

http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org