Skip to content

Commit

Permalink
Update Ex_SimpleLatticeAndSliceExtract.cs
Browse files Browse the repository at this point in the history
SimpleLatticeAndSliceExtract example now also outputs interpolated slices
  • Loading branch information
LinKayser committed Jul 29, 2024
1 parent 3dee682 commit 08bba06
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Examples/Ex_SimpleLatticeAndSliceExtract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,25 @@ public static void Task()

// Read the voxel slice from the middle of the voxel field
// into our grayscale image
vox.GetVoxelSlice(nZSize / 2, ref img);

int nMiddle = nZSize / 2;

vox.GetVoxelSlice(nMiddle, ref img);

// Save it as an TGA file to the log folder
TgaIo.SaveTga(Path.Combine(Library.strLogFolder, "Slice.tga"), img);
TgaIo.SaveTga(Path.Combine(Library.strLogFolder, $"Slice_{nMiddle}.tga"), img);

// Try out interpolated slices

for (float f=0;f<1;f+=0.1f)
{
float fZ = nMiddle + f;
vox.GetInterpolatedVoxelSlice(fZ, ref img);
TgaIo.SaveTga(Path.Combine(Library.strLogFolder, $"Slice_In_{fZ}.tga"), img);

PolySlice oSlice = PolySlice.oFromSdf(img, fZ, Vector2.Zero, Library.fVoxelSizeMM);
oSlice.SaveToSvgFile(Path.Combine(Library.strLogFolder, $"Slice_In_{fZ}.svg"), true);
}
}

catch (Exception e)
Expand Down

0 comments on commit 08bba06

Please sign in to comment.