pycsoft

Python extension module for the csoft library. The only extension provided for in this module is for the csoft_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 its infrastructure.

Module Functions

CSoft([<k:int=0>])
Builds a pycsoft object. This object encapsulates the functionality of the csoft_build class. Use the pycsoft members to build a BlobTree data structure. The k argument is for indicating if the attributes should be killed.
KillAttribs()
Destroys the attribute table. If your usage of this module iterates over the creation of a set of csoft objects then at each iteration you should call this function. The effect is that the global attributes table for csoft objects gets destroyed so that it does not grow too large. A typical case where you need to do this is between frames of an animation.

pycsoft Member Functions

push()
Pushes the attributes of the csoft object onto a stack. All attributes including material properties and transformations are pushed.
pop()
Pops the attribute 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 colour attribute for primitive objects in the BlobTree.
transparency(<t:float>)
Sets the transparency attribute for the primitive objects in the BlobTree.
field(<t:float>)
Sets the field value attribute 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.
begin([<se-n=1:float>])
Begins the definition of an interior 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.
blend()
Blends the children objects specified for this composite interior node.
union()
Produces the union of the children objects specified for this composite interior node.
intersection()
Produces the intersection of the children objects specified for this composite interior node.
difference()
Produces the difference of the first child and the union of the remaining children specified for this composite interior node.
twist([<axis:int=1>,<angle:float=0>])
Twists the children specified for this composite interior node. Parameters are the axis to twist around and the angle in degrees to twist by.
taper([<axis:int=1>,<axis:int=>,<angle:float=0>])
Tapers the children specified for this composite interior node. Parameters are the axis to taper along, the axis to taper against and the angle in degrees to taper by.
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.
texturing([<support:int=0>,<field:float=0.5>,(<utiles:int=1>,<vtiles:int=1>),<axis:int=1>,<tx-blends:int=0>])
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. The rest of the parameters are self explanatory. The tx-blends parameter is boolean, if true the algorithm from the SIBGRAPI 98 paper is implemented for blending the mapping according to the transformations of the children.
cblend(<blends:(int,int)*>)
Combine the children of the current composite interior node with a controlled blend. The parameter is a list of 2-tuples holding the blend relationships. The numbers are the indices of the children, zero based.
object(<obj:pycsoft>)
Insert the given child into the current level of the BlobTree.
sphere([<radius:float=0.5>])
Insert a sphere 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>))
Insert a triangle primitive into the current level of the BlobTree.
cylinder([<length:float=1.0>,<radius:float=0.5>])
Insert a cylinder primitive into the current level of the BlobTree.
cone([<length:float=1.0>,<top-radius:float=0.5>,<base-radius:float=0.5])
Insert a cone primitive into the current level of the BlobTree.
plane([<axis:int=1>,<negate:int=0>])
Insert an axis orthogonal aligned plane primitive in the current level of the _italiz(BlobTree).
gplane([(<x:float=0>,<y:float=0>,<z:float=0>),(<nx:float=0>,<ny:float=1>,<nz:float=0>)])
Insert a general plane containing the given point and having normal parallel to the given direction.
torus([<radius-a:float>,<radius-b:float>,<axis:int>])
Insert a torus lieing in the plane with normal as the given axis. The radius of the swept circle of the torus is radius-a
bound()
Returns a 2-tuple of 3-tuples. The two 3-tuples are the minimum and maximum corners of the bounds of the object.
function(<f:string|function>,[<p:float>])
Allows the setting of the function to use for field evaluations. The argument can be either a string from the set: "geoff", "bicubic", "arctan" or it can be a python function. The function needs to take two floats and return a float. The first argument is a number between 0 and the second argument. The return value should be the scalar field value. The second parameter to this function is the parameter to bi-cubic blends or to arctan blends (default for bicubic is 0.5, and for arctan is 50.