mirror of https://github.com/vitalif/openscad
Merge branch 'poly2_bug' of git://github.com/OskarLinde/openscad into OskarLinde-poly2_bug
commit
b33ab943ff
|
@ -42,20 +42,26 @@ namespace ClipperUtils {
|
|||
path before adding it to the Polygon2d.
|
||||
*/
|
||||
Polygon2d *toPolygon2d(const ClipperLib::PolyTree &poly) {
|
||||
const double CLEANING_DISTANCE = 0.001 * CLIPPER_SCALE;
|
||||
|
||||
Polygon2d *result = new Polygon2d;
|
||||
const ClipperLib::PolyNode *node = poly.GetFirst();
|
||||
while (node) {
|
||||
Outline2d outline;
|
||||
outline.positive = !node->IsHole();
|
||||
const Vector2d *lastv = NULL;
|
||||
BOOST_FOREACH(const ClipperLib::IntPoint &ip, node->Contour) {
|
||||
Vector2d v(1.0*ip.X/CLIPPER_SCALE, 1.0*ip.Y/CLIPPER_SCALE);
|
||||
// Ignore too close vertices. This is to be nice to subsequent processes.
|
||||
if (lastv && (v-*lastv).squaredNorm() < 0.001) continue;
|
||||
outline.vertices.push_back(v);
|
||||
lastv = &outline.vertices.back();
|
||||
|
||||
ClipperLib::Path cleaned_path;
|
||||
ClipperLib::CleanPolygon(node->Contour, cleaned_path, CLEANING_DISTANCE);
|
||||
|
||||
// CleanPolygon can in some cases reduce the polygon down to no vertices
|
||||
if (cleaned_path.size() >= 3) {
|
||||
BOOST_FOREACH(const ClipperLib::IntPoint &ip, cleaned_path) {
|
||||
Vector2d v(1.0*ip.X/CLIPPER_SCALE, 1.0*ip.Y/CLIPPER_SCALE);
|
||||
outline.vertices.push_back(v);
|
||||
}
|
||||
result->addOutline(outline);
|
||||
}
|
||||
result->addOutline(outline);
|
||||
|
||||
node = node->GetNext();
|
||||
}
|
||||
result->setSanitized(true);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
|
||||
$fn = 64;
|
||||
|
||||
module inverse() difference() { square(1e6,center=true); child(); }
|
||||
module offset(d=1) minkowski() { circle(d); child(); }
|
||||
|
||||
module s() {
|
||||
inverse() offset(2) inverse() offset(2) union() {
|
||||
hull() { circle(r=4); translate([0,3]) circle(r=4); }
|
||||
translate([0,-3]) hull() { circle(r=1); translate([10,0]) circle(r=1); }
|
||||
}
|
||||
}
|
||||
difference() {
|
||||
linear_extrude(height=3,center=true,convexity=3) s();
|
||||
linear_extrude(height=9,center=true) circle(r=2);
|
||||
}
|
|
@ -863,6 +863,7 @@ list(APPEND CGALPNGTEST_FILES ${FEATURES_FILES} ${SCAD_DXF_FILES} ${EXAMPLE_FILE
|
|||
list(APPEND CGALPNGTEST_FILES ${CMAKE_SOURCE_DIR}/../testdata/scad/misc/include-tests.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/use-tests.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/transform-nan-inf-tests.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/bugs/incorrect_polygon.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles-test.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/localfiles_dir/localfiles-compatibility-test.scad
|
||||
${CMAKE_SOURCE_DIR}/../testdata/scad/misc/rotate-empty-bbox.scad
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
Loading…
Reference in New Issue