hull -- Build convex hulls from lines or surfaces¶
This module provides functions to compute convex hulls
(See https://en.wikipedia.org/wiki/Convex_hull)
and other hull-related operations for Mesh and Web
Those can be very helpful to complete sketches or parts by adding the missing surface portions. Also very helpful to sort a set of directions.
convexhull(source)
¶
compute the convex hull of the input container

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
typedlist / Web / Mesh
|
the input container, if it is a Web or Mesh, their groups are kept in the output data |
required |
Examples:
>>> m = convexhull(mesh([
... uvsphere(O, 1, alignment=X),
... uvsphere(4*X, 2, alignment=X),
... ]))
Source code in madcad/hull.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
convexoutline(source, normal=None, flatten=False)
¶
based on convexhull() but will extract the loop formed by the edges in the biggest planar projection of the convex hull

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
typedlist / Web / Mesh
|
the input container, if it is a Web or Mesh, their groups are kept in the output data |
required |
normal
|
vec3
|
the projection normal to retreive the outline using |
None
|
flatten
|
bool
|
whether to project the outline points in its mean plane |
False
|
Examples:
>>> convexoutline(web([
... Circle(Axis(O,Z), 1),
... Circle(Axis(4*X,Z), 2),
... ]))
Source code in madcad/hull.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
simple_convexhull(points)
¶
Just like convexhull() but minimalist.
It does not take care of groups crossing. It doesn't return a new Mesh but a buffer of triangles indices
Source code in madcad/hull.py
24 25 26 27 28 29 | |
horizon(mesh, direction)
¶
Return a Web of the ORIENTED edges of the given mesh that lay between triangles that are oriented either sides of `direction`

Source code in madcad/hull.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
widest_surface_direction(mesh)
¶
Source code in madcad/hull.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
restore_groups(source, indices)
¶
Create a mesh contaning the given simplices, associated with groups created from group crossing from the source mesh.
The simplices must refer to points in source.
The created groups are tuples of indices of the groups touched by each simplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Mesh / Web
|
the mesh containing reference triangles and groups |
required |
indices
|
a buffer of simplices indices (depending on the dimensionnality of |
required |
Source code in madcad/hull.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |