-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # README.md
- Loading branch information
Showing
9 changed files
with
233 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
import pyck | ||
|
||
L = [10.0, 10.0, 0.0] | ||
r = 0.1 | ||
|
||
cubic = pyck.CubicPacker(L, r) | ||
pack = pyck.StructuredPack(cubic) | ||
|
||
cube = pyck.Cuboid(1, [2, 2, -1], [6, 6, 1]) | ||
sphere = pyck.Sphere(2, [2, 2, 2], 5) | ||
|
||
pack.AddShape(cube) | ||
pack.AddShape(sphere) | ||
pack.Process() | ||
|
||
model = pyck.Model(pack) | ||
|
||
|
||
# Create an IntField | ||
stateField = model.CreateIntField("State", 1) | ||
|
||
# The IntField may be set in the traditional way: | ||
model.SetIntField(stateField, 1, 10) | ||
|
||
# Or we can use a callback to determine the value of the | ||
# field as a function of position | ||
# Note that the callback must always take arguments for X Y and Z | ||
# regardless of the dimensionality of the pack | ||
|
||
|
||
def fieldCallback(x, y, z): | ||
return x | ||
|
||
model.SetIntFieldCallback(stateField, 2, fieldCallback) | ||
|
||
# The same can be done with DoubleFields | ||
posField = model.CreateDoubleField("pos", 3) | ||
|
||
|
||
def fieldCallback2(x, y, z): | ||
return [x, y, z] | ||
# Here our field is 3D, so we return a 3D value | ||
|
||
model.SetDoubleFieldCallback(posField, 2, fieldCallback2) | ||
|
||
writer = pyck.SparkWriter() | ||
model.Serialize("hello.vtp", writer) | ||
import pyck | ||
|
||
L = [10.0, 10.0, 0.0] | ||
r = 0.1 | ||
|
||
cubic = pyck.CubicPacker(L, r) | ||
pack = pyck.StructuredPack(cubic) | ||
|
||
cube = pyck.Cuboid(1, [2, 2, -1], [6, 6, 1]) | ||
sphere = pyck.Sphere(2, [2, 2, 2], 5) | ||
|
||
pack.AddShape(cube) | ||
pack.AddShape(sphere) | ||
pack.Process() | ||
|
||
model = pyck.Model(pack) | ||
|
||
|
||
# Create an IntField | ||
stateField = model.CreateIntField("State", 1) | ||
|
||
# The IntField may be set in the traditional way: | ||
model.SetIntField(stateField, 1, 10) | ||
|
||
# Or we can use a callback to determine the value of the | ||
# field as a function of position | ||
# Note that the callback must always take arguments for X Y and Z | ||
# regardless of the dimensionality of the pack | ||
|
||
|
||
def fieldCallback(x, y, z): | ||
return x | ||
|
||
model.SetIntFieldCallback(stateField, 2, fieldCallback) | ||
|
||
# The same can be done with DoubleFields | ||
posField = model.CreateDoubleField("pos", 3) | ||
|
||
|
||
def fieldCallback2(x, y, z): | ||
return [x, y, z] | ||
# Here our field is 3D, so we return a 3D value | ||
|
||
model.SetDoubleFieldCallback(posField, 2, fieldCallback2) | ||
|
||
writer = pyck.SparkWriter() | ||
model.Serialize("hello.vtp", writer) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.