Creating a 3D mesh projecting a surface #15
-
Hi, I was reading parts of the pymadcad code to learn more about 3D surface offsetting and I am currently facing a problem which you might have an answer to. Is there an elegant way to achieve this or do I have to iterate through the mesh and fix each intersection individually? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hello @ETK3 and welcome here ! The good new is that there is few ways to acheive it. None are as simple as en extrusion ... curve = wire(Softened([
vec3(-0.2296, 0, 0.1898),
vec3(-0.08743, 0, 0.1648),
vec3(-0.1569, 0, 0.06546),
vec3(0.2357, 0, 0.08456),
vec3(0.1315, 0, 0.1761),
vec3(0.1717, 0, 0.2101),
vec3(0.3164, 0, 0.1736)]))
surf = extrusion(0.1*Y, curve)
mesh_extruded = extrusion(mat3(1,1,-1), surf) # the mat3 here makes a symetry in direction Z This is giving what you already have
mesh_generated = ( surf # original top surface
+ surf.transform(mat3(1,1,-1)).flip() # generate a symetric lower surface with the symetry transformation
+ flatsurface(curve.flip() + curve.transform(mat3(1,1,-1))) # generate a triangulated surface from generated symetric curves
)
from madcad.selection import select, edgenear, stopangle
lower = surf.transform(mat3(1,1,-1)) # generate the lower surface with a symetry transformation
some = ( wire(select(surf, edgenear(surf.outlines(), Y), stopangle(0.5))) # select the surface edges that are the closest to point Y and then select until there is an angle above 0.5 rad
+ wire(select(lower, edgenear(lower.outlines(), Y), stopangle(0.5))).flip() ) # same selection for the lower surface
mesh_triangulated = flatsurface(some) (same result as before)
# option 1: flat side surface
side = flatsurface(wire([ # this is a simple rectangular plane
vec3(curve.points[0].x, 0, 0.3), # always use x min and max coordinates from the surface, so we are sure the boolean operation will work
vec3(curve.points[-1].x, 0, 0.3),
vec3(curve.points[-1].x, 0, -0.3),
vec3(curve.points[0].x, 0, -0.3),
]).transform(0.01*Y)),
# option 2: weird surface, for the example
side = saddle(
Softened([
vec3(curve.points[0].x, -0.02, 0.5), # take the precise x min location of the surface
vec3(0.07548, -0.02745, 0.5092),
vec3(0.1703, 0.02395, 0.5),
vec3(curve.points[-1].x, -0.03, 0.5), # take the precise x max location of the surface
]),
Softened([ # second path stays on the plane as its x=0
vec3(0, -0.08676, 0.483),
vec3(0, -0.04412, 0.2477),
vec3(0, 0.007296, -0.04252),
vec3(0, -0.1125, -0.4239),]),
)
# quite readable operation once we have a good surface:
# execute a boolean operation to cut and titch meshes
mesh_cutted = difference(
surf + surf.transform(mat3(1,1,-1)).flip(),
side,
) Unfortunately I do not know other good ways to acheive such. I hope these options can be useful to you, else let me now ! |
Beta Was this translation helpful? Give feedback.
Hello @ETK3 and welcome here !
If I correctly understood, you are looking to a way to achieve this:
The good new is that there is few ways to acheive it. None are as simple as en extrusion ...
This is giving what you already have