mpacts.commands.geometry. triangle

In order to be able to use this module import it like this:

import mpacts.commands.geometry.triangle
#or assign it to a shorter name
import mpacts.commands.geometry.triangle as tri

ComputeCurvatureCommand

class mpacts.commands.geometry.triangle.ComputeCurvatureCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

This command calculates the local curvatures on the nodes for a triangulated body. This is translated to an inverse curvature or ‘radius of curvature’ for each triangle. The Voronoi area of each node is stored in the node array ‘area’, and the node normal is calculated and stored in the node array ‘normal’. The command creates two new arrays if they do not already exist: ‘area_flat’ (double) and ‘counter’ (unsigned), which are normally only used in-scope. Pre-requisites: normals ‘normal’ calculated for each triangle, list of neighbouring triangles ‘triangleIndices’ for each node as well as ‘area’ calculated for each triangle. Details on this algorithm can be found in ‘Meyer et al. Discrete differential-geometry operators for triangulated 2-manifolds. Visualization and mathematics III. Springer, Berlin, Heidelberg, 2003. 35-57‘.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • maximal_radius (m) — Maximal radius of curvature for a triangle in a deformable body. To avoid infinitely high radii, any calculated inverse curvature higher than this parameter will be set to maximal_radius.
    • pc — Particle container on which the command is applied
    • triangles — Array Manager containing the triangles of the deformable body.
  • Optional keywords:
    • enforce_positive (default value = 0) — If 'True', the radius of curvature is forced to be positive. Negative values get set to maximal_radius
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • minimal_radius (m) (default value = 0) — Minimal radius of curvature for a triangle in a deformable body. Any inverse curvature lower than this parameter will be set to minimal_radius, even if calculated otherwise.
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
    • save_for_nodes (default value = 0) — If 'True', the radius of curvature is also stored for each node in the array 'inverse_curvature' of the nodes.
    • x (default value = None) — Array with positions of the nodes
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, triangles, maximal_radius, [gate, predicate, minimal_radius, enforce_positive, save_for_nodes, x]
ComputeCurvatureCommand(name, parent, **kwargs)

ComputeEdgeCommand

class mpacts.commands.geometry.triangle.ComputeEdgeCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command to find edges of contact area between two surfaces.
Default location: ‘loop_cmds/post_contact_cmds’
  • Required keywords:
    • dist_threshold — Scalar determining below which distance is there considered to be contact.
    • distance_to_surface — Array holding the distance of nodes to pc1.
    • edges — Array manager where list of edges is stored.
    • pc — Particle container on which the command is applied
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, distance_to_surface, dist_threshold, edges, [gate, predicate]
ComputeEdgeCommand(name, parent, **kwargs)

ComputeEncompassingSphereCommand

class mpacts.commands.geometry.triangle.ComputeEncompassingSphereCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command for computing the encompassing sphere with a given radius ‘inverse_curvature through triangles. The computed sphere center position is stored in an Array ‘center_sphere’. This command also computes the normal unit vector on the triangles ‘normal’, which it derives from the counter-clockwise ordering of the triangle indices. An array ‘x’ must be provided which is used as the triangle corners. This could be controlPoints(‘x’) in the case of a RigidBody geometry or an ‘x’ array in a node manager in the case of a deformable body geometry. Warning: the given radius of the sphere may be changed if the radius is too small for a sphere to fit. In that case, it will be changed to the minimal radius that can be fitted through the triangle.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • x — Array of positions of the triangle corners (Could be in controlPoints or other ArrayManager)
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, x, [gate, predicate]
ComputeEncompassingSphereCommand(name, parent, **kwargs)

ComputeGaussianCurvatureCommand

class mpacts.commands.geometry.triangle.ComputeGaussianCurvatureCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

This command calculates the local Gaussian curvatures on the nodes for a triangulated body. The Voronoi area of each node is stored in the node array ‘area’, and the node normal is calculated and stored in the node array ‘normal’. Pre-requisites: normals ‘normal’ calculated for each triangle, list of neighbouring triangles ‘triangleIndices’ for each node as well as ‘area’ calculated for each triangle. Note that for most applications, the regular mean curvature obtained from ComputeCurvatureCommand is sufficient.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • triangles — Array Manager containing the triangles of the deformable body.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
    • x (default value = None) — Array with positions the nodes
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, triangles, [gate, predicate, x]
ComputeGaussianCurvatureCommand(name, parent, **kwargs)

ComputeLocalDiameterCommand

class mpacts.commands.geometry.triangle.ComputeLocalDiameterCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Computes the local ‘diameter’ for each triangle in the particle container. For this, we compute the first intersection point in our body, perpendicular to the triangle’s normal. The distance between that intersection point and the center of our triangle gives the local diameter.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • diameter — Array in which to store the local diameter per primitive.
    • pc — Particle container on which the command is applied
    • x — Array with positions of the primitives’ corners
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • max_diameter (default value = 1.7976931348623157e+308) — Maximal diameter for a given primitive.
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, x, diameter, [gate, predicate, max_diameter]
ComputeLocalDiameterCommand(name, parent, **kwargs)

ComputeNodeStrainCommand

class mpacts.commands.geometry.triangle.ComputeNodeStrainCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Compute Eulerian-Almansi finite strain tensor along with deformation gradient and its inverse for each node from the node (and its neighbor) positions and initial positions. e_i = \frac{1}{2} \left( {\mathbb I} - F^{-T}_i F^{-1}_i \right), where \mathbb I is the identity matrix and F is deformation gradient obtained as solution of F_i \left[ \sum_{ j \in N(i) } \left( \vec{x}^0_j - \vec{x}^0_i \right) \left( \vec{x}^0_j - \vec{x}^0_i \right) \right] = \sum_{ j \in N(i) }\left( \vec{x}_j - \vec{x}_i \right) \left( \vec{x}^0_j - \vec{x}^0_i \right), where \vec{x}_j (\vec{x}^0_j) is the (initial) position of the node j from neighbors of node i, j \in N(i). This command does not guarantee F F^{-1} = {\mathbb I}.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • nodeIndexList — Array of std::vector<R3::Index_t> containing list of primitives connected to each node
    • pc — Particle container on which the command is applied
    • triangles — Array Manager containing the triangles of the deformable body.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, nodeIndexList, triangles, [gate, predicate]
ComputeNodeStrainCommand(name, parent, **kwargs)

ComputePrincipalCurvaturesCommand

class mpacts.commands.geometry.triangle.ComputePrincipalCurvaturesCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

To be done
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • maximal_radius — Maximal radius of curvature for a triangle in a deformable body. To avoid infinitely high radii, any calculated inverse curvature higher than this parameter will be set to maximal_radius.
    • pc — Particle container on which the command is applied
    • triangles — Array Manager containing the triangles of the deformable body.
  • Optional keywords:
    • enforce_positive (default value = 0) — If ‘True’, the radius of curvature is forced to be positive. Negative values get set to ‘maximal_radius’
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, triangles, maximal_radius, [gate, predicate, enforce_positive]
ComputePrincipalCurvaturesCommand(name, parent, **kwargs)

ComputeTriangleCentersCommand

class mpacts.commands.geometry.triangle.ComputeTriangleCentersCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command for computing the center point as the Euclidean mean of the three corner points of the triangle. The center point will be kept in an array ‘x’ which can be used e.g. by single-grid contact detection algorithms. Center position \vec{x}_c = \frac{1}{3} ( \vec{x}_i + \vec{x}_j + \vec{x}_k).
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • x — Array with positions of the Ngon corners
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, x, [gate, predicate]
ComputeTriangleCentersCommand(name, parent, **kwargs)

ComputeTriangleIndexListCommand

class mpacts.commands.geometry.triangle.ComputeTriangleIndexListCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command for calculating a list of triangles per node for a body. The array ‘nodeIndexList’ (type std::vector<R3::Index_t> ) which is passed as argument stores the list of triangles found for a given node. Note that a ComputeTriangleIndexListCommand should usually be followed by a SortTriangleIndexListCommand, to ensure that the triangles are sorted in a counter-clock-wise manner. The latter is a strict requirement for most methods that use the ‘triangleIndices’, e.g. mpacts.commands.geometry.triangle.ComputeCurvatureCommand.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • nodeIndexList — Array of std::vector<R3::Index_t> containing list of primitives connected to each node
    • pc — Particle container on which the command is applied
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, nodeIndexList, [gate, predicate]
ComputeTriangleIndexListCommand(name, parent, **kwargs)

ComputeTriangleNormalsCommand

class mpacts.commands.geometry.triangle.ComputeTriangleNormalsCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command for computing the normals of the triangles which are stored in the normal array. If the triangle ArrayManager keeps the array ‘area’, also the the area of the triangle is computed (and thus set) by this command. Area A = \frac{1}{2} || ( \vec{x}_j - \vec{x}_i)\times ( \vec{x}_k - \vec{x}_i ) || and normal \vec{\hat{n}} = \frac{1}{2 A} [( \vec{x}_j - \vec{x}_i)\times ( \vec{x}_k - \vec{x}_i )] for counter-clock-wise sorted triangle indices i, j, and k.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • x — Array with positions of the primitives’ corners
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, x, [gate, predicate]
ComputeTriangleNormalsCommand(name, parent, **kwargs)

ComputeVolumeCommand

class mpacts.commands.geometry.triangle.ComputeVolumeCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Computes the volume of a closed triangulated body based on Gauss’ theorem. It requires the triangle ArrayManager ‘normal’ array to be computed at this point. Because the command only adds to the volume array, it is the responsibility of the user to make sure that the ‘volume’ array of the deformable body (parent particle container) has been set to 0. Formula: V = \sum_t^N(\frac{A_t}{3} \vec{x}_{t,i}\cdot\vec{\hat{n}}) where we loop over N triangles t and where i refers to the first of three counter-clockwise sorted triangle corners i, j and k.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • nodes — Array Manager containing the nodes of the deformable body.
    • pc — Particle container on which the command is applied
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, nodes, [gate, predicate]
ComputeVolumeCommand(name, parent, **kwargs)

GenerateSeedPointsAlongThicknessCommand

class mpacts.commands.geometry.triangle.GenerateSeedPointsAlongThicknessCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Generates a set of seed points for each triangle in the normal direction.
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • x — Array with positions of the primitives’ corners
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • max_diameter (default value = 1.7976931348623157e+308) — Maximal diameter for a given primitive.
    • number_of_points (default value = 5) — Number of points to be generated along the thickness.
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, x, [gate, predicate, number_of_points, max_diameter]
GenerateSeedPointsAlongThicknessCommand(name, parent, **kwargs)

ProjectNewMeshCommand

class mpacts.commands.geometry.triangle.ProjectNewMeshCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Projects a collection of newly added nodes onto a “closed”, “convex” triangulated shape (e.g. a cell finishing mitosis).
Default location: ‘loop_cmds/post_contact_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • triangle_pc — Particle container of triangles
  • Optional keywords:
    • doNotThrow (default value = 0) — If true, we will not throw even for non-convex meshes (but the shape will be wrong!).
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • new_indices (default value = new_indices) — Indices of added nodes (as python list)
    • plane_center (default value = 1.79769e+308 1.79769e+308 1.79769e+308) — If both this and ‘plane_normal’ are given, we will project either on triangles or, if it is closer, the given plane.
    • plane_normal (default value = 1.79769e+308 1.79769e+308 1.79769e+308) — If both this and ‘plane_center’ are given, we will project either on triangles or, if it is closer, the given plane.
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, triangle_pc, [gate, predicate, new_indices, doNotThrow, plane_center, plane_normal]
ProjectNewMeshCommand(name, parent, **kwargs)

SortTriangleIndexListCommand

class mpacts.commands.geometry.triangle.SortTriangleIndexListCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command for sorting the order of the nodes saved in the array ‘triangleIndices’ which keeps the triangles connected to each node. The triangles are sorted in such a way that neighbouring triangles in the list always share one common edge (hence two common nodes). Important: in order for ComputeCurvature to work, the indices in the array ‘triangleIndices’ MUST be sorted in the same way as in this command!
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
    • triangles — Array Manager containing the triangles of the deformable body.
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, triangles, [gate, predicate]
SortTriangleIndexListCommand(name, parent, **kwargs)

StoreNeighbourTrianglesCommand

class mpacts.commands.geometry.triangle.StoreNeighbourTrianglesCommand

Bases: mpacts.core.command.Command, mpacts.core.baseobject.BaseObject

Command which stores the index of the neighbouring triangle at each edge. Index 0 represents the triangle which shares controlPoints 0 and 1; Index 1/2 share contolPoints (1 and 2) / (0 and 2).
Default location: ‘loop_cmds/pre_body_force_cmds’
  • Required keywords:
    • pc — Particle container on which the command is applied
  • Optional keywords:
    • gate (default value = ET::ChildProperty const*) — Can decide to (temporarily) not execute the command in a CommandList. (Default is ExecuteAlways)
    • predicate (default value = None) — Predicate that will decide whether this command is executed for a specific particle, when absent the command is executed for every particle.
object __init__(tuple args, dict kwds) :
args: name, parent kwds: pc, [gate, predicate]
StoreNeighbourTrianglesCommand(name, parent, **kwargs)