... | @@ -713,3 +713,72 @@ emit( translate(100,0,0) * linear_offset(mesh,v(0,1,0),10) ) |
... | @@ -713,3 +713,72 @@ emit( translate(100,0,0) * linear_offset(mesh,v(0,1,0),10) ) |
|
```linear_offsets(mesh,directions,offsets)```
|
|
```linear_offsets(mesh,directions,offsets)```
|
|
|
|
|
|
Same as ```linear_offset``` but multiple offsets can be applied at the same time. ```directions``` and ```offsets``` are arrays of vectors and numbers respectively and they have an ordered one-to-one correspondance.
|
|
Same as ```linear_offset``` but multiple offsets can be applied at the same time. ```directions``` and ```offsets``` are arrays of vectors and numbers respectively and they have an ordered one-to-one correspondance.
|
|
|
|
|
|
|
|
# Shape Representation
|
|
|
|
IceSL offers several functions for calculating representations of shapes (i.e., meshes, voxels, etc).
|
|
|
|
|
|
|
|
```to_voxel_solid(shape, voxSize)```
|
|
|
|
|
|
|
|
```to_voxel_solid(tex3d, voxSize)```
|
|
|
|
|
|
|
|
Creates a solid voxel volume from ```shape``` or ```tex3d``` where each voxel measures ```voxSize``` units.
|
|
|
|
* ```shape```: input shape
|
|
|
|
* ```tex3d```: 3D texture
|
|
|
|
* ```voxSize```: voxel size (in mm)
|
|
|
|
|
|
|
|
```to_voxel_solid(tex3d, boxMin, boxMax)```
|
|
|
|
|
|
|
|
Creates a solid voxel volume from ```tex3d```. ```boxMin``` and ```boxMax``` specify the volume in space to create the solid. Values in ```tex3d``` above ```0.5``` are considered solid, otherwise they are considered empty.
|
|
|
|
|
|
|
|
```to_voxel_distance_field(shape, voxSize)```
|
|
|
|
|
|
|
|
Creates a voxel distance field from ```shape``` using [this technique](http://www.comp.nus.edu.sg/~tants/jfa/i3d06.pdf). Each voxel measures ```voxSize``` units.
|
|
|
|
|
|
|
|
* ```shape```: input shape
|
|
|
|
* ```voxSize```: voxel size (in mm)
|
|
|
|
|
|
|
|
```set_distance_field_iso(voxels, threshold)```
|
|
|
|
|
|
|
|
In a distance field, sets the threshold to classify voxels as empty/solid whenever it is less/greater than ```threshold``` respectively.
|
|
|
|
|
|
|
|
* ```voxels```: voxel shape obtained by ```to_voxel_distance_field```
|
|
|
|
* ```threshold```: Number between ```0``` (empty) and ```1```(solid). Default is ```0.5```
|
|
|
|
|
|
|
|
```smooth_voxels(voxShape, windowSize)```
|
|
|
|
|
|
|
|
Smooths the voxel shape ```voxShape``` using a [trilinear interpolation](https://en.wikipedia.org/wiki/Trilinear_interpolation) with a windows size of ```windowSize```. This functions '''does not''' return a shape, instead it modifies the shape specified on the first parameter.
|
|
|
|
|
|
|
|
* ```voxShape```: input shape. Only supports voxels
|
|
|
|
* ```windowSize```: interpolation 3D window size
|
|
|
|
|
|
|
|
```smooth_voxels_preserve_volume(voxShape, windowSize)```
|
|
|
|
|
|
|
|
Same as above but tries to preserve the shape's volume.
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
|
|
|
|
```lua
|
|
|
|
s = sphere(5)
|
|
|
|
vs1 = to_voxel_solid(s, 0.1)
|
|
|
|
vs2 = to_voxel_solid(s, 0.1)
|
|
|
|
smooth_voxels(vs2,10)
|
|
|
|
emit(translate(0,0,0) * s)
|
|
|
|
emit(translate(15,0,0) * vs1)
|
|
|
|
emit(translate(30,0,0) * vs2)
|
|
|
|
```
|
|
|
|
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<img src="uploads/69b6b0930ded09a9c539f14033397535/Example_voxels.png" width="200">
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
```to_mesh(shape, voxSize)```
|
|
|
|
|
|
|
|
Creates a mesh from ```shape``` using the marching cubes algorithm. Before calculating the resulting mesh, the 3D space containing the shape is discretized using voxels of size ```voxSize``` units.
|
|
|
|
|
|
|
|
* ```shape```: input shape
|
|
|
|
* ```voxSize```: voxel size of space discretization (in mm) |