pyjbt
Python extension module for the jbt library. The only extension
provided for in this module is for the jbt_build class. So with
this module you can generate a BlobTree data structure. These
data structures can be passed to pyrtl objects
or to pybv through their
infrastructure.
Module Functions
BlobTree()
Builds a pyjbt object. This object encapsulates the functionality
of the jbt_build class. Use the pyjbt members to build a
BlobTree data structure.
Geoff()
Constructs a Geoff field function. This is the standard field
function. The return of this function is suitable for passing to the
field method.
BiCubic([<bound=0.5:float>])
Constructs a bi-cubic field function with the given bound. The return
of this function is suitable for passing to the field method. bound
should be greater than 0 and less than 1.
ArcTan([<bound=50:float>])
Constructs an arctan field function with the given stiffness. The
return of this function is suitable for passing to the field method.
Blinn([<a=-2:float>])
Constructs an Blinn exponential field function with the given exponent
argument. The return of this
function is suitable for passing to the field method.
InversePower([<n=2:float>])
Constructs an inverse power field function with the given exponent
argument. The return of this function is suitable for passing to the
field method.
Blanc([<a=0:float>])
Constructs an Blanc field function with the given hardness
argument. The return of this
function is suitable for passing to the field method.
Euclidean([(<kx=1:float>,<ky=1:float>,<kz=1:float>)])
Constructs a Euclidean distance metric . This is the standard
distance metric. The return of this function is suitable for passing
to the distance method.
LMetric([<l=2:float>,(<kx=1:float>,<ky=1:float>,<kz=1:float>)])
Constructs an l-metric distance metric. An l-metric is a
generalization of the Euclidean metric, l==2 is the same as the
l-metric. The return of this function is suitable for passing to the
distance method.
SuperQuadric([<ew=1:float>,<ns=1:float>,(<kx=1:float>,<ky=1:float>,<kz=1:float>)])
Constructs a super-quadric distance metric. This metric is somewhat
due to Barr, it is a generalization of the l-metric. When ew=1 and
ns=1 we have squared Euclidean distance. The return of this function is
suitable for passing to the distance method.
AnisotropicLMetric((<x:float>,<y:float>,<z:float>),<p0:float>,<p1:float>,[<a:float=0>,<b:float=1>,(<kx:float>,<ky:float>,<kz:float>)])
Constructs an anisotropic L_p distance metric. Given a direction and
two p parameters it cubic interpolates between the two p parameters
based on the dot product of the displacement vector and the given
direction vector. The last parameter is the scaling parameter for
the metric.
AnisotropicSuperQuadric((<ew0:float>,<ns0:float>),(ew1:float>,<ns1:float>),[<a:float=0>,<b:float=1>,<axis:int=2>,(<x:float>,<y:float>,<z:float>)])
Constructs an anisotropic SuperQuadric distance metric. Given a
direction and two ew,ns parameter sets it cubic interpolates between
the two parameter sets based on the dot product of the displacement
vector and the given direction vector.
pyjbt Member Functions
push() Pushes the attributes of the jbt object onto a
stack. All attributes including attributes and
transformations are pushed.
pop()Pops the stack
translate(<x:float>,<y:float>,<z:float>) Multiplies the
current transformation matrix by the given translation.
scale(<x:float>,<y:float>,<z:float>) Multiplies the
current transformation matrix by the given scale.
rotate(<axis:int>,<angle:float>) Multiplies the current
transformation matrix by the given rotation. The axis is specified as
0|1|2 for x|y|z and the angle is given in degrees.
textranslate(<x:float>,<y:float>)Multiplies the current
texture space transfomation matrix by the given translation.
texscale(<x:float>,<y:float>)Multiplies the current
texture space transformation matrix by the given scale.
texrotate(<angle:float>)Multiplies the current texture
space transformation matrix by the given rotation.
colour((<red:float>,<green:float>,<blue::float>))Sets the
diffuse attribute for primitive objects in the BlobTree.
specular((<red:float>,<green:float>,<blue::float>))Sets the
specular attribute for primitive objects in the BlobTree.
specularexp(<e:float>)Sets the specular exponent for primitive
objects in the BlobTree.
specularcoeff(<e:float>)Sets the specular coefficient for primitive
objects in the BlobTree.
coefficient(<t:float>)Sets the coefficient of the field
value for the primitive objects in the BlobTree.
texturemap(<file:string>,[(<ssa:float=-1>,<ssb:float=-1>),<mode:int=0>])Sets
the texture map attribute for the primitive objects in the
BlobTree. The first parameter specifies the raw ppm (P6)
file to use for the texture map. The last two parameters specify how
the texture map should be incorporated with the colour attribute of
the primitives. The tuple gives the two parameters in 0..1 for the
smoothstep function (a cubic interpolation producing range 0..1 over
the domain ssa..ssb), the input to smoothstep is the y
channel of the texture map, the output is used to weight between the
texture map and the primitives colour. The mode parameter specifies
if this blending should be done 1, or should not be done 0. You
probably want to use values (0,0.1),1 if you want to use blending of
the texture map and the primitive colour.
checkermap([(<red:float=0>,<green:float=0>,<blue::float=0>),(<width:int=300>,<height:int=300>),(<ssa:float=-1>,<ssb:float=-1>),<mode:int=0>])Sets the texture map attribute for the primitive objects in the
BlobTree to a checker board texture. The checkers are
coloured with the given colour and its inverse. The pair of
integers sets the width and height for the image. For an
explanation of the rest of the parameters see the documentation to
texturemap.
blend([<se-n=1:float>]) Begins the definition of a
blending node of a BlobTree. The parameter specifies the
super-elliptic blending parameter. If you want the children to be
combined with the standard summation of their fields then just
neglect passing this parameter. The range of the se-n
parameter should be 1..inf. All types of interior nodes contribute
to the geometry of the blend. To end a composite node call one of
blend, union, intersection ... etc. See the following
documentation. Of course the se-n parameter is ignored if
the composite node is a csg operator. To add children to this
interior node, simply call some of the primitive functions, or
insert other composite interior nodes before the terminating call of
this node.
union()Begins the union of the children objects
specified for a composite interior node.
intersection()Begins the intersection of the children objects
specified for a composite interior node.
difference()Begins the difference of the first child and
the union of the remaining children specified for a composite
interior node.
twist([<angle:float=0>,<ymin:float=-bnd>,<ymax:float=bnd>])Begins twist of the blended children specified for a composite
interior node. Parameters are the angle in degrees to twist by .
taper([<x:float=1>,<z:int=1>,<ymin:float=-bnd>,<ymax:float=bnd>])Tapers the children specified for this composite interior
node. Parameters are the degree by which to taper along x and z
respectively, and the y values through which to perform the taper
(the default is through the bounds of the object)
bend([<angle:float=0>,<min:float=-1>,<max:float=1>,<mid:float=0>])A linear bend combination of the children specified for this
composite interior node. The parameters are the angle between the two
non-bent regions of space, the range of the curvature, and the center
of the curvature. The last three parameters specify together the
radius of the curvature of the bend. The bend is along the y-axis and
bending towards positive z.
extrude([(<axis=0:int>,<sign=1,int>)),<l=1:float>,(<kx=1:float>,<ky=1:float>,<kz=1:float>))Extrudes a field along a vector. Parameters are the axis and
direction
parameterize([<support:int=0>,<axis:int=1>])Combine
the children for this interior composite node and compute texturing
mapping for their blend. The first parameter is the geometry of the
support surface, 0 for cylindrical, 1 for spherical.
bumpmap(<map:string>[,<scale:float=1>])Combine the children for this interior composite node and compute
bump mapping for their blend. The first parameter is the filename of
the bump map. It should be in raw (P6) ppm . The scale
parameter is provided to exert control over the amount of
perturbation.
cblend(<blends:(int,int)*>)Controlled blending is not
yet implemented in jbt.
end()Terminates the current composite object.
object(<obj:pyjbt>)Insert the given child into the
current level of the BlobTree.
point([<radius:float=1>])Insert a point primitive with
the given radius into the current level of the BlobTree.
triangle((<x0:float>,<y0:float>,<z0:float>),(<x1:float>,<y1:float>,<z1:float>),(<x2:float>,<y2:float>,<z2:float>))Triangles
are not yet implemented in jbt. Insert a triangle primitive
into the current level of the BlobTree.
line([<length:float=1>,<radius:float=1>])Insert a line primitive into the current level of the BlobTree.
vrline([<length:float=1.0>,<top-radius:float=0.5>,<base-radius:float=0.5])Variable radius lines are not yet implemented in jbt.
plane([<R:float=1>])Inserts a plane primitive, this type is meant to be used as a cutting plane for CSG. R is the radius of the field.
circle([<radius-a=1:float>,<radius-b=0.5:float>])Insert a torus lieing in the xz plane.
The radius of the swept circle of the torus is radius-a
disk([<radius-a:float=1>,<radius-b:float=1>])
Insert a disk lieing in the xz plane.
The radius of the disk is radius-a, the
radius of the field is radius-b.
square([<x-radius:float=1>,<y-radius:float=1>,<radius-b:float=1>])
Insert a square lieing in the xz plane.
The square can be a rectangle by changing the x-radius, y-radius.
polyline([(<x:float>,<y:float>,<z:float>)*],<pr:radius>,[<r:float=1>])A poly-line primitive. This creates a set of connected line segments,
each pair of contiguous segments is connected by a continuous arc of
radius pr.
bound()Returns a 2-tuple of 3-tuples. The two 3-tuples
are the minimum and maximum corners of the bounds of the object.
field(<f:pyjbtfield>)Allows the setting of the function
to use for field evaluations. The argument must be the return of one
of the module functions which returns a field function.
distance(<f:pyjbtdistance>)Allows the setting of the function
to use for distance evaluations. The argument must be the return of one
of the module functions which returns a distance metric.