any_object module

class gensei.any_object.AnyObject(**kwargs)

Base class of all geometrical objects to be sliced.

Methods

accepted
copy
fd_close
fd_open
from_conf
get_aligned_bounding_box
get_dict
get_intersector
get_origin_bounding_box
has_intersection
init_intersection_counters
init_trait
intersects
objects_from_dict
report
set_conf
set_default_traits
setup_orientation
store_intersection
update_stats
accepted()

Called when an object’s placement is accepted.

Just adds one to the actual object class count.

static from_conf(conf, box)

Return an object class instance, based on conf.kind. The conf.kind should correspond to a module in the ‘gensei’ package directory. That module should contain a class named as the capitalized conf.kind, for example:

conf.kind = 'ellipsoid'

means the module gensei.ellipsoid with the Ellipsoid class.

get_aligned_bounding_box()

Get the objects’s axes-aligned bounding box.

Return:
bbox : 3 x 2 array
The bounding box.
get_intersector()
get_origin_bounding_box()

Get the objects’s axes-aligned bounding box as if centered at the origin.

Return:
bbox : 3 x 2 array
The bounding box.
has_intersection(axis)
init_intersection_counters(axis)
Initialize for using store_intersection().
intersects(other)

Test whether two objects intersect. Some objects may provide only an approximate answer using a kind of bounding box (an intersector). In that case -1 is returned in place of 1 or 2, and the objects may not actually intersect (but should be mutually very close).

Returns:

flag : int

  • 0 -> the objects are disjoint
  • 1 -> touch in a single surface point
  • 2 -> have common inner points
  • -1 -> may have common surface or inner points (inexact computation)

Some objects may return 2 instead of 1.

report(filename)
set_conf(conf, requested_conf)
setup_orientation()

If direction (orientation of the long axis of an object in space) is set in self.conf, compute the corresponding rot_axis (the direction vector of rotation axis) and rot_angle (the rotation angle around the rotation axis), that map the unrotated object (with direction0 orientation) to the rotated one.

From rot_axis and rot_angle form the rotation matrix rot_mtx, so that:

  • direction = dot(rot_mtx.T, direction0)
  • direction0 = dot(rot_mtx, direction)

If direction is not set in self.conf, use rot_axis and rot_angle from self.conf, and compute the direction using the above relation.

store_intersection(mask, axis, coor)

Store intersection if it occurred.

Parameters:

mask : bool array

Slice mask, True where the object inside is.

axis : ‘x’, ‘y’ or ‘z’

Axis perpendicular to the slices.

coor: float :

Coordinate along the axis, where intersection might occur.

update_stats(stats)
Add the object volume, surface and length to global statistics.

Previous topic

Developer Guide

This Page