Skip to content

Commit

Permalink
fix: add a vtk grid from bb attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Mar 11, 2024
1 parent baa083a commit 4b50d91
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions LoopStructural/datatypes/_bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def __init__(
"maxz": (1, 2),
}

@property
def global_origin(self):
return self._origin

@property
def global_maximum(self):
return self._maximum

@property
def valid(self):
return self._origin is not None and self._maximum is not None
Expand Down Expand Up @@ -193,3 +201,19 @@ def regular_grid(self, nsteps=None, shuffle=False, order="C"):
# logger.info("Shuffling points")
rng.shuffle(locs)
return locs

@property
def vtk(self):

try:
import pyvista as pv
except ImportError:
raise ImportError("pyvista is required for vtk support")
x = np.linspace(self.origin[0], self.maximum[0], self.nsteps[0])
y = np.linspace(self.origin[1], self.maximum[1], self.nsteps[1])
z = np.linspace(self.origin[2], self.maximum[2], self.nsteps[2])
return pv.RectilinearGrid(
x,
y,
z,
)

0 comments on commit 4b50d91

Please sign in to comment.