Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_translation3d():
"""Translation of a volume object."""
geom = pygmsh.opencascade.Geometry(0.2, 0.2)
ball = geom.add_ball([0, 0, 0], 1)
ball2 = geom.add_ball([1.5, 0, 0], 1)
geom.translate(ball, [1.5, 0, 0])
geom.boolean_union([ball2, ball])
mesh = pygmsh.generate_mesh(geom)
surf = 4 / 3 * np.pi
assert isinstance(ball, pygmsh.opencascade.volume_base.VolumeBase)
assert isinstance(ball, pygmsh.built_in.volume_base.VolumeBase)
assert np.abs(compute_volume(mesh) - surf) < 2e-2 * surf
return
from .volume_base import VolumeBase
class Cone(VolumeBase):
"""
Creates a cone.
center : array-like[3]
The 3 coordinates of the center of the first circular face.
axis : array-like[3]
The 3 components of the vector defining its axis.
radius0 : float
Radius of the first circle.
radius1 : float
Radius of the second circle.
alpha : float
Angular opening of the the Cone.
"""
def __init__(self, center, axis, radius0, radius1, alpha=None, char_length=None):
# 'Delete;' if delete_first else '',
# legal_dim_types[dim],
# ';'.join(e.id for e in tool_entities),
# 'Delete;' if delete_other else ''
# ))
"%(name)s[] = %(op)s{ %(ientities)s %(idelete)s } { %(tentities)s %(tdelete)s};"
% {
"name": name,
"op": operation,
"ientities": formatted_input_entities,
"idelete": input_delete,
"tentities": formatted_tool_entities,
"tdelete": tool_delete,
}
)
mapping = {"Line": None, "Surface": SurfaceBase, "Volume": VolumeBase}
return mapping[legal_dim_types[dim]](id0=name, is_list=True)
from .volume_base import VolumeBase
class Box(VolumeBase):
"""
Creates a box.
Parameters
----------
x0 : array-like[3]
List containing the x, y, z values of the start point.
extends : array-like[3]
List of the 3 extents of the box edges.
char_length : float
Characteristic length of the mesh elements of this polygon.
"""
def __init__(self, x0, extents, char_length=None):
super().__init__()
from .volume_base import VolumeBase
class Wedge(VolumeBase):
"""
Creates a right angular wedge.
x0 : array-like[3]
The 3 coordinates of the right-angle point.
extends : array-like[3]
List of the 3 extends of the box edges.
top_extend : float
Defines the top X extent.
char_length : float
Characteristic length of the mesh elements of this polygon.
"""
def __init__(self, x0, extents, top_extent=None, char_length=None):
super().__init__()
from .volume_base import VolumeBase
class Torus(VolumeBase):
"""
Creates a torus.
center : array-like[3]
The 3 coordinates of its center.
radius0 : float
Inner radius.
radius1 : float
Outer radius.
alpha : float
Defines the angular opening.
char_length : float
Characteristic length of the mesh elements of this polygon.
"""
def __init__(self, center, radius0, radius1, alpha=None, char_length=None):
from .volume_base import VolumeBase
class Ball(VolumeBase):
"""
Creates a sphere.
Parameters
----------
center: array-like[3]
Center of the ball.
radius: float
Radius of the ball.
x0: float
If specified and `x0 > -1`, the ball is cut off at `x0*radius`
parallel to the y-z plane.
x1: float
If specified and `x1 < +1`, the ball is cut off at `x1*radius`
parallel to the y-z plane.
alpha: float
from .volume_base import VolumeBase
class Cylinder(VolumeBase):
"""
Creates a cylinder.
Parameters
----------
x0 : array-like[3]
The 3 coordinates of the center of the first circular face.
axis : array-like[3]
The 3 components of the vector defining its axis.
radius : float
Radius value of the cylinder.
angle : float
Angular opening of the cylinder.
char_length : float
Characteristic length of the mesh elements of this polygon.
"""