skin automatically flips faces when paths are reversed; bugfix in rounded_prism

This commit is contained in:
Adrian Mariano 2024-11-03 07:26:41 -05:00
parent 3aff85aedc
commit 400f3efa97
2 changed files with 9 additions and 4 deletions

View file

@ -2214,7 +2214,7 @@ module rounded_prism(bottom, top, joint_bot=0, joint_top=0, joint_sides=0, k_bot
result = rounded_prism(bottom=bottom, top=top, joint_bot=joint_bot, joint_top=joint_top, joint_sides=joint_sides, result = rounded_prism(bottom=bottom, top=top, joint_bot=joint_bot, joint_top=joint_top, joint_sides=joint_sides,
k_bot=k_bot, k_top=k_top, k_sides=k_sides, k=k, splinesteps=splinesteps, h=h, length=length, height=height, l=l, k_bot=k_bot, k_top=k_top, k_sides=k_sides, k=k, splinesteps=splinesteps, h=h, length=length, height=height, l=l,
debug=debug, _full_info=true); debug=debug, _full_info=true);
height = one_defined([l,h,height,length], "l,h,height,length", dflt=u_add(bottom_height,top_height)); height = one_defined([l,h,height,length], "l,h,height,length", dflt=undef);
top = is_undef(top) ? path3d(bottom,height/2) : top = is_undef(top) ? path3d(bottom,height/2) :
len(top[0])==2 ? path3d(top,height/2) : len(top[0])==2 ? path3d(top,height/2) :
top; top;

View file

@ -38,7 +38,11 @@
// 2d curves with heights given in the `z` parameter. It is your responsibility to ensure // 2d curves with heights given in the `z` parameter. It is your responsibility to ensure
// that the resulting polyhedron is free from self-intersections, which would make it invalid // that the resulting polyhedron is free from self-intersections, which would make it invalid
// and can result in cryptic CGAL errors upon rendering with a second object present, even though the polyhedron appears // and can result in cryptic CGAL errors upon rendering with a second object present, even though the polyhedron appears
// OK during preview or when rendered by itself. // OK during preview or when rendered by itself. The order of points in your profiles must be
// consistent from slice to slice so that points match up without creating twists. You can specify
// profiles in any consistent order: if necessary, skin() will reverse the faces to ensure that the final
// result has clockwise faces as required by CGAL. Note that the face reversal test may give random results
// if you use skin to construct self-intersecting (invalid) polyhedra.
// . // .
// For this operation to be well-defined, the profiles must all have the same vertex count and // For this operation to be well-defined, the profiles must all have the same vertex count and
// we must assume that profiles are aligned so that vertex `i` links to vertex `i` on all polygons. // we must assume that profiles are aligned so that vertex `i` links to vertex `i` on all polygons.
@ -502,10 +506,11 @@ function skin(profiles, slices, refine=1, method="direct", sampling, caps, close
refine[i] * len(pair[0]) refine[i] * len(pair[0])
) )
subdivide_and_slice(pair,slices[i], nsamples, method=sampling)], subdivide_and_slice(pair,slices[i], nsamples, method=sampling)],
vnf=vnf_join( pvnf=vnf_join(
[for(i=idx(full_list)) [for(i=idx(full_list))
vnf_vertex_array(full_list[i], cap1=i==0 && fullcaps[0], cap2=i==len(full_list)-1 && fullcaps[1], vnf_vertex_array(full_list[i], cap1=i==0 && fullcaps[0], cap2=i==len(full_list)-1 && fullcaps[1],
col_wrap=true, style=style)]) col_wrap=true, style=style)]),
vnf = vnf_volume(pvnf)<0 ? vnf_reverse_faces(pvnf) : pvnf
) )
reorient(anchor,spin,orient,vnf=vnf,p=vnf,extent=atype=="hull",cp=cp); reorient(anchor,spin,orient,vnf=vnf,p=vnf,extent=atype=="hull",cp=cp);