Commit 59e9086f authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

adde convenience method disjoint_parts

parent 5327d169
......@@ -47,7 +47,12 @@ def provide(cls, path, function, *args, **kwargs):
provide the object of type tfields_clas saved unter path
and generated by function with *args and **kwargs
Args:
cls (type):
cls (type): type of the object returned by the function
path (str): path where to save the object returned by function
function (callable): function expected to return an object of type cls
*args: passed to function
**kwargs : passed to function
"""
path = resolve(path)
if os.path.exists(path):
......
......@@ -951,7 +951,8 @@ class Mesh3D(tfields.TensorMaps):
"""
with self.tmp_transform(coord_sys or self.coord_sys):
if isinstance(expression, Mesh3D):
obj = self._cut_template(expression)
template = expression
obj = self._cut_template(template)
else:
at_intersection = at_intersection or "remove"
obj, template = self._cut_sympy(expression, at_intersection=at_intersection)
......@@ -959,6 +960,19 @@ class Mesh3D(tfields.TensorMaps):
return obj, template
return obj
def disjoint_parts(self, return_template=False):
mp_description = self.disjoint_map(0)
parts = self.parts(mp_description)
if not return_template:
return parts
else:
templates = []
for i, part in enumerate(parts):
template = part.copy()
template.maps[0].fields[0] = tfields.Tensors(mp_description[1][i])
templates.append(template)
return parts, templates
def plot(self, **kwargs): # pragma: no cover
"""
Forwarding to plotTools.plot_mesh
......
......@@ -141,7 +141,7 @@ class Points3D(tfields.Tensors):
def balls(self, radius, spacing=(5, 3)):
"""
Buils a sphere around each point with resolution
Builds a sphere around each point with resolution
Args:
radius (float): radius of spheres
spacing (tuple of int): n_phi, n_theta
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment