Skip to content

Commit

Permalink
rename CompleteGrainsAtShapeEdge to GrainCutShape
Browse files Browse the repository at this point in the history
  • Loading branch information
JLeliaert committed Oct 3, 2024
1 parent 677d8f9 commit aa02cd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions engine/ext_make3dgrains.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"math/rand"
)

var CompleteGrainsAtShapeEdge = false // complete the voronoi grains instead of cutting them off at the shape edge
var GrainCutShape = false // complete all voronoi grains whose centre lies within the shape. Warning, this also cuts away parts of the shape whose closest voronoi centre lies outside the shape

func init() {
DeclFunc("ext_make3dgrains", Voronoi3d, "3D Voronoi tesselation over shape (grain size, starting region number, num regions, shape, seed)")
DeclVar("CompleteGrainsAtShapeEdge", &CompleteGrainsAtShapeEdge, "Enables completion of grains beyond shape edge (default=false)")
DeclVar("GrainCutShape", &GrainCutShape, "Adds the complete voronoi grain, if its centre lies within the shape (default=false)")
}

func Voronoi3d(grainsize float64, startRegion int, numRegions int, inputShape Shape, seed int) {
Expand Down Expand Up @@ -110,7 +110,7 @@ func (t *tesselation3d) tabulateCells() []cellLocs {
y := cell.Y()
z := cell.Z()

if (t.shape(x, y, z)|| CompleteGrainsAtShapeEdge) {
if (t.shape(x, y, z)|| GrainCutShape) {
cells = append(cells, cellLocs{x, y, z})
}
}
Expand All @@ -125,8 +125,8 @@ func (t *tesselation3d) tabulateCells() []cellLocs {


func (t *tesselation3d) RegionOf(x, y, z float64) int {
// Check if the point is within the shape or edge grains should be completed
if !(t.shape(x, y, z) || CompleteGrainsAtShapeEdge) {
// Check if the point is within the shape or if we're cutting the shape along the grains
if !(t.shape(x, y, z) || GrainCutShape) {
return -1 // Regions < 0 won't be rastered
}

Expand All @@ -142,7 +142,7 @@ func (t *tesselation3d) RegionOf(x, y, z float64) int {
}

// Check if the nearest point's region should be returned
if t.shape(x, y, z) || (t.shape(nearest.x, nearest.y, nearest.z) && CompleteGrainsAtShapeEdge) {
if t.shape(x, y, z) || (t.shape(nearest.x, nearest.y, nearest.z) && GrainCutShape) {
return int(nearest.region)
}

Expand Down
2 changes: 1 addition & 1 deletion test/make3dgrains_shape_edge.mx3
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ defregion(1, sphere)

seed:=238948790
randSeed(seed)
CompleteGrainsAtShapeEdge=true
GrainCutShape=true
ext_make3Dgrains(8e-9, 2, 250, sphere, seed)

for i:=2; i<254; i+=1 {
Expand Down

0 comments on commit aa02cd0

Please sign in to comment.