Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ALICE-open-data
ALICE Blender animation
Commits
1277e3b1
Commit
1277e3b1
authored
Oct 31, 2019
by
Rafael Pezzi
Browse files
Add member to dataDriver: datafile
parent
efe37505
Changes
2
Hide whitespace changes
Inline
Side-by-side
drivers.py
View file @
1277e3b1
...
...
@@ -66,13 +66,14 @@ class genDriver(animationDriver): # A driver for particle generators
return
particles
;
class
dataDriver
(
animationDriver
):
# A driver for data from files.
def
__init__
(
self
,
name
,
filename
):
self
.
name
=
name
+
"_"
+
filename
+
"_"
def
__init__
(
self
,
name
,
datafile
):
self
.
name
=
name
+
"_"
+
datafile
+
"_"
self
.
datafile
=
datafile
def
getParticles
(
self
):
# Create particles acording to parameters from file
# Count number of lines in file = number of particles
detail_file
=
open
(
filenam
e
,
'r'
)
detail_file
=
open
(
self
.
datafil
e
,
'r'
)
linecount
=
0
for
line
in
open
(
filenam
e
).
readlines
(
):
linecount
+=
1
# File must be in the same directory
for
line
in
open
(
self
.
datafil
e
).
readlines
(
):
linecount
+=
1
# File must be in the same directory
# Set number of particles
N_particles
=
linecount
particles
=
[]
...
...
@@ -87,9 +88,9 @@ class dataDriver(animationDriver): # A driver for data from files.
Px
=
lines
[
i
].
split
(
' '
)[
5
]
Py
=
lines
[
i
].
split
(
' '
)[
6
]
Pz
=
lines
[
i
].
split
(
' '
)[
7
]
part
=
ParticlePropagator
(
i
,
x
,
y
,
z
,
charge
,
mass
)
part
.
SetMagneticField
()
part
.
SetProperties
(
Px
,
Py
,
Pz
)
part
=
ParticlePropagator
(
i
,
float
(
x
),
float
(
y
),
float
(
z
),
float
(
charge
),
float
(
mass
)
)
part
.
SetMagneticField
(
0.5
)
part
.
SetProperties
(
float
(
Px
),
float
(
Py
),
float
(
Pz
)
)
particles
.
append
(
part
)
detail_file
.
close
()
return
particles
;
scene_functions.py
View file @
1277e3b1
...
...
@@ -72,6 +72,7 @@ def createSceneParticles(particles):
# Create blender spheres (particles)
blender_particles
=
[]
n_particles
=
len
(
particles
)
for
particle
in
particles
:
this_type
=
random
.
choice
(
particle_types
)
#TO DO: make this not random, but according to file data
print
(
"Adding Sphere - Particle "
+
str
(
len
(
blender_particles
))
+
" of "
+
str
(
n_particles
-
1
)
+
" - "
+
this_type
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment