Scene Module
Cuboid
Bases: Solid
Also known as the Right Rectangular Prism, the Cuboid is defined by its width (a, b, c) in each axis (x, y, z) respectively.
The position refers to the vector from global origin to its centroid. The generated mesh will be divided into the following subgroups: Left (-x), Right (+x), Bottom (-y), Top (+y), Front (-z), Back (+z).
Source code in pytissueoptics/scene/solids/cuboid.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
stack(other, onSurface='top', stackLabel='CuboidStack')
Basic implementation for stacking cuboids along an axis.
For example, stacking on 'top' will move the other cuboid on top of this cuboid. They will now share the same mesh at the interface and inside/outside materials at the interface will be properly defined. This will return a new cuboid that represents the stack, with a new 'interface' surface group.
Limitations
- Requires cuboids with the same shape except along the stack axis.
- Cannot stack another stack unless it is along its stacked axis (ill-defined interface material).
- Expected behavior not guaranteed for pre-rotated cuboids.
- Stacked cuboids will lose reference to their initial stack surface (not a closed solid anymore). Use the returned cuboid stack.
Source code in pytissueoptics/scene/solids/cuboid.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Cylinder
Bases: Solid
Source code in pytissueoptics/scene/solids/cylinder.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | |
__init__(radius=1, length=1, u=32, v=3, s=2, position=Vector(0, 0, 0), material=None, primitive=primitives.DEFAULT, label='cylinder', smooth=True)
Default cylinder orientation will be along the z axis. The front face towards the negative z axis and the back face towards the positive z axis. Position refers to its centroid. Available surfaces are "front", "lateral" and "back".
Source code in pytissueoptics/scene/solids/cylinder.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
Ellipsoid
Bases: Solid
We take the unit sphere, then calculate the theta, phi position of each vertex (with ISO mathematical convention). Then we apply the ellipsoid formula in the spherical coordinate to isolate the component R. We then calculate the difference the ellipsoid would with the unit sphere for this theta,phi and then .add() or .subtract() the corresponding vector.
Source code in pytissueoptics/scene/solids/ellipsoid.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
contains(*vertices)
Only returns true if all vertices are inside the minimum radius of the ellipsoid towards each vertex direction (more restrictive with low order ellipsoids).
Source code in pytissueoptics/scene/solids/ellipsoid.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
Loader
Base class to manage the conversion between files and Scene() or Solid() from various types of files.
Source code in pytissueoptics/scene/loader/loader.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
Logger
Source code in pytissueoptics/scene/logger/logger.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
getRawDataPoints(key=None)
All raw 3D data points recorded for this InteractionKey (not binned). Array of shape (n, 4) or (n, 5) where the second axis is (value, x, y, z) or (value, x, y, z, photonID) if photon IDs were logged.
Source code in pytissueoptics/scene/logger/logger.py
133 134 135 136 | |
getSeenSolidLabels()
Returns a list of all solid labels that have been logged in the past even if the data was discarded.
Source code in pytissueoptics/scene/logger/logger.py
56 57 58 59 | |
getSeenSurfaceLabels(solidLabel)
Returns a list of all surface labels that have been logged in the past for the given solid even if the data was discarded.
Source code in pytissueoptics/scene/logger/logger.py
61 62 63 64 | |
getStoredSolidLabels()
Returns a list of all solid labels that are currently stored in the logger.
Source code in pytissueoptics/scene/logger/logger.py
66 67 68 | |
getStoredSurfaceLabels(solidLabel)
Returns a list of all surface labels that are currently stored in the logger.
Source code in pytissueoptics/scene/logger/logger.py
70 71 72 73 74 75 76 | |
logDataPointArray(array, key)
'array' must be of shape (n, 4) or (n, 5) where the second axis is (value, x, y, z) or (value, x, y, z, photonID). The photonID column is optional.
Source code in pytissueoptics/scene/logger/logger.py
95 96 97 98 99 | |
logPointArray(array, key=None)
'array' must be of shape (n, 3) where the second axis is (x, y, z)
Source code in pytissueoptics/scene/logger/logger.py
90 91 92 93 | |
logSegmentArray(array, key=None)
'array' must be of shape (n, 6) where the second axis is (x1, y1, z1, x2, y2, z2)
Source code in pytissueoptics/scene/logger/logger.py
101 102 103 104 | |
Scene
Bases: Displayable
Source code in pytissueoptics/scene/scene/scene.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
Sphere
Bases: Ellipsoid
The Sphere is the 3D analog to the circle. Meshing a sphere requires an infinite number of vertices. The position refers to the vector from global origin to its centroid. The radius of the sphere will determine the outermost distance from its centroid.
This class offers two possible methods to generate the sphere mesh. - With Quads: Specify the number of separation lines on the vertical axis and the horizontal axis of the sphere. - With Triangle: Specify the order of splitting. This will generate what is known as an IcoSphere.
Source code in pytissueoptics/scene/solids/sphere.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
contains(*vertices)
Only returns true if all vertices are inside the minimum radius of the sphere (more restrictive with low order spheres).
Source code in pytissueoptics/scene/solids/sphere.py
47 48 49 50 51 52 53 54 55 | |
SymmetricLens
Bases: ThickLens
A symmetrical thick lens of focal length f in air.
Source code in pytissueoptics/scene/solids/lens.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |
ThickLens
Bases: Cylinder
The Lens is defined by a front radius, a back radius, a diameter and a thickness (along its center). A positive frontRadius means that the front surface is convex. This is reversed for the back surface. A flat surface is obtained by setting the corresponding radius to 0 or math.inf. The position refers to the vector from global origin to its centroid. The generated mesh will be divided into the following subgroups: Front, Side and Back. By default, front will point towards the negative z-axis.
Source code in pytissueoptics/scene/solids/lens.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
focalLength
property
Returns the focal length of the lens in air. Requires a refractive material to be defined.
Vector
Basic implementation of a mutable 3D Vector. It implements most of the basic vector operation. Mutability is necessary when working with shared object references for expected behavior.
Source code in pytissueoptics/scene/geometry/vector.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
rotateAround(unitAxis, theta)
Rotate the vector around unitAxis by theta radians. Assumes the axis to be a unit vector.
Uses Rodrigues' rotation formula.
Source code in pytissueoptics/scene/geometry/vector.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |