1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-21 14:04:53 +02:00
This commit is contained in:
Justin Lin
2021-09-23 07:46:45 +08:00
parent 57da4b39ad
commit 1634403e28
3 changed files with 6 additions and 43 deletions

View File

@@ -37,17 +37,14 @@ function _geom_pts_faces(points, radius) =
[m_pts[1], faces]; [m_pts[1], faces];
function _geom_info(tris, radius, detail) = function _geom_info(tris, radius, detail) =
let( _geom_pts_faces([
points = detail == 0 ? [for(tri = tris) each tri] : [
for(tri = tris) for(tri = tris)
each [for(t = tri_subdivide(tri, detail)) each t] each [for(t = tri_subdivide(tri, detail)) each t]
] ], radius);
)
_geom_pts_faces(points, radius);
function _geom_info_quick(tris, radius, detail) = function _geom_info_quick(tris, radius, detail) =
let( let(
points = detail == 0 ? [for(tri = tris) each _geom_prj2sphere(tri, radius)] : [ points = [
for(tri = tris) for(tri = tris)
each [for(t = tri_subdivide(tri, detail)) each _geom_prj2sphere(t, radius)] each [for(t = tri_subdivide(tri, detail)) each _geom_prj2sphere(t, radius)]
], ],
@@ -56,6 +53,7 @@ function _geom_info_quick(tris, radius, detail) =
[points, faces]; [points, faces];
function _geom_platonic_polyhedra(points, faces, radius, detail, quick_mode) = function _geom_platonic_polyhedra(points, faces, radius, detail, quick_mode) =
detail == 0 ? [_geom_prj2sphere(points, radius), faces] :
let( let(
tris = [ tris = [
for(face = faces) for(face = faces)

View File

@@ -1 +0,0 @@
function _geom_prj2sphere(t, r) = [for(p = t) p / norm(p) * r];

View File

@@ -1,34 +0,0 @@
use <__comm__/_pt3_hash.scad>;
use <util/map/hashmap.scad>;
use <util/map/hashmap_put.scad>;
use <util/map/hashmap_get.scad>;
function _pimap_pts(radius, points, leng, hash, m, deduped_pts = [], n = -1, i = 0) =
i == leng ? [m, deduped_pts] :
let(v = hashmap_get(m, points[i], hash = hash))
is_undef(v) ?
_pimap_pts(radius, points, leng, hash, hashmap_put(m, points[i], n + 1, hash = hash), concat(deduped_pts, [points[i] / norm(points[i]) * radius]), n + 1, i + 1) :
_pimap_pts(radius, points, leng, hash, m, deduped_pts, n, i + 1);
function _geom_pts_faces(points, radius) =
let(
number_of_buckets = ceil(sqrt(len(points)) * 1.5),
hash = function(p) _pt3_hash(p),
leng = len(points),
m_pts = _pimap_pts(
radius,
points,
leng,
hash,
hashmap(number_of_buckets = number_of_buckets)
),
faces = [
for(i = [0:3:leng - 3])
[
hashmap_get(m_pts[0], points[i], hash = hash),
hashmap_get(m_pts[0], points[i + 1], hash = hash),
hashmap_get(m_pts[0], points[i + 2], hash = hash)
]
]
)
[m_pts[1], faces];