imagico.de
imagico.de

imagico.de

MechSim

previous: Sim-POV Documentation - part 2 current: Sim-POV Documentation - part 3 next: Sim-POV Documentation - part 4 Navigation

3 The 'mechsim.inc' include file

This part of the Sim-POV documentation describes the 'mechsim.inc' include file that comes with Sim-POV and contains various macros simplifying the use of Sim-POV features.

The 'mechsim.inc' include file contains several macros so simplify the generation of simulation topologies as well as macros building POV-Ray objects representing the simulation data.

3.1 general aspects

At the beginning of the file there are various declarations of textures and other things that are used by the macros. In most cases you can override the default values by declaring the identifiers differently before including the file.

MSIM_INCLUDE_VERSION

The version number of the 'mechsim.inc' include file.

No_Trans

A dummy transform that can be used in the topology generation macros if no transform is supposed to be used.

MSim_File_Decimals

The number of decimal places to be written to files for coordinates. Default value is 12.

MSim_Test_Render

If true reflection is turned off for the textures in this include file. Default value is false.

MSim_Tex_N

Texture to be used for texturing the nodes (masses) of the simulation topology. A grey metallic texture by default.

MSim_Tex_C

Texture to be used for texturing the connections of the simulation topology. A gold metallic texture by default.

MSim_Tex_Mesh

Texture to be used for texturing the faces of the simulation topology. A bluish metallic texture by default.

fn_Stress_CM

Color map function to use for visualizing the stress in simulation topologies. A color (pigment) function is used here. It is evaluated in x-direction between 0 and 1.

3.2 The Object generation macros

These macros generate POV-Ray objects from the simulation data. Currently there are macros for general topology visualization and specific macros for generating meshes from patch topologies created with the patch generation macros.

MechSim_Show_Objects() sample

3.2.1 MechSim_Show_Objects()

This macro generates POV-Ray shapes for all masses and connections or faces from a certain range of the simulation data.

Depending on the value of the Show_Faces parameter the macro will either generate a union of cylinders and spheres representing the masses and connections or a mesh with triangles representing the faces.

parameters:

example:

// show all masses and connections
MechSim_Show_Objects(000-1-1-1-1false-1"")
// declare an object of all faces
#declare Obj=MechSim_Show_Objects(000-1-1-1-1true-1"")
// show a subset of connections and faces, texture connections
// to visualize stress, write objects to file
MechSim_Show_Objects(0001003000-1false120"sim01.inc")

MechSim_Show_All_Objects() sample

3.2.2 MechSim_Show_All_Objects()

Variation of the MechSim_Show_Objects() macro displaying all elements of the current simulation data.

parameters:

example:

// show all masses and connections
MechSim_Show_All_Objects(-1false-1"")
// declare an object of all faces
#declare Obj=MechSim_Show_All_Objects(-1true-1"")

MechSim_Show_Patch() sample

3.2.3 MechSim_Show_Patch()

This macro generates a mesh from the patch topology created with the MechSim_Generate_Patch() macro. The mesh is generated in form of the new mesh2 type and optionally includes uv- and normal data depending on the parameters.

parameters:

example:

// show a 50x50 patch with smoothing
MechSim_Show_Patch(05050truefalse-1, )
// declare an object for the patch, generate uv coordinates
// and normal vectors, write the results to a file
#declare Obj=MechSim_Show_Patch(05050truetrue-1, sim01.inc)

Here a comparison between the different methods and variations:

cylinders and spheres face triangles patch macro (stress visualization)
cylinders and spheres face triangles patch macro (stress visualization)
no smooth, no uv smooth uv mapped
no smooth, no uv smooth uv mapped

3.3 The topology generation macros

These macros are supposed to be placed in the topology{} block of the mechsim{} section. They generate the masses, connections and faces for certain geometries.

3.3.1 explanation of the 'Connect_Arr' parameter

Most of the macros have a parameter named Connect_Arr. This is an array containing weighting factors for the different connections in.

The objects generated by the macros have different types of connections: axis-parallel connections, 2D and 3D diagonal connections and possibly bending connections. How these connections are weighted influences the properties of the object and can be controlled by the values in this array. Which value refers to which type of connection depends on the macro and is mentioned in the macro description.

MechSim_Generate_Grid_Fn() sample

3.3.3 MechSim_Generate_Grid_Fn()

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. The density of the masses as well as the stiffness and damping of the connections can be varied with functions.

The generated box starts at the origin and extends in positive x, y and z-direction.

parameters:

meaning of the 'Connect_Arr' entries:

See a description of this array in general. If the first entry is 0 no connections are generated. The individual entries are used for the following connections. Only connections up to the size of the array are generated.

The following pictures illustrate the different sizes of the array:

0 (first element zero) array size 1 array size 2
0 (first element zero) array size 1 array size 2
array size 3 array size 4  
array size 3 array size 4  

example code:

// generate a 4x4x4 masses grid with double diagonal connections
// and increasing stiffness and damping in x-direction

#declare Con_Array=array[3]
#declare Con_Array[0]=1;
#declare Con_Array[1]=1;
#declare Con_Array[2]=1;

#declare fn_Density=function(xyz{ 32000 }
#declare fn_Stiffness=function(xyz{ 1000 + x*1500 }
#declare fn_Damping=function(xyz{ 2000 + x*1500 }

MechSim_Generate_Grid_Fn(<000>0.08, fn_Density, fn_Stiffness, fn_Damping,
                         true<0.40.40.4><444>, No_Trans, Con_Array)

MechSim_Generate_Grid() sample

3.3.4 MechSim_Generate_Grid()

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. In contrast to the MechSim_Generate_Grid_Fn() macro the density stiffness and damping values are fixed.

parameters:

example code:

// generate a 4x4x4 masses grid with double diagonal connections

#declare Con_Array=array[3]
#declare Con_Array[0]=1;
#declare Con_Array[1]=1;
#declare Con_Array[2]=1;

MechSim_Generate_Grid(<000>0.083200010002000,
                      true<0.40.40.4><444>, No_Trans, Con_Array)

MechSim_Generate_Grid_Std() sample

3.3.5 MechSim_Generate_Grid_Std()

This macro generates 3D rectangular grid of masses with connections and optionally faces on the outside. In contrast to the MechSim_Generate_Grid() macro all connections all have the same stiffness and damping.

parameters:

example code:

// generate a 4x4x4 masses grid with double diagonal connections
MechSim_Generate_Grid_Std(<000>0.083200010002000,
                          true<0.40.40.4><444>, No_Trans, 3)

MechSim_Generate_Box() sample

3.3.6 MechSim_Generate_Box()

Variation of the MechSim_Generate_Grid_Std() macro where instead of the density of the individual masses the mass of the whole grid is given.

parameters:

example code:

// generate a 4x4x4 masses grid with double diagonal connections
// and a total mass of 20 kg
MechSim_Generate_Box(<000>0.082010002000,
                     true<0.40.40.4><444>, No_Trans, 3)

MechSim_Generate_Patch() sample

3.3.7 MechSim_Generate_Patch()

This macro generates a rectangular patch of masses with connections and optionally faces forming the surface. The masses can be fixed with help of a function

parameters:

meaning of the 'Connect_Arr' entries:

See a description of this array in general. The following picture shows which entries in the array weight which connections. Only connections up to the size of the array are generated.

patch connection numbers

example code:

// generate a 50x50 patch with bending and shearing stiffness
// no masses are fixed

#declare fn_Fixed=function { -1 }
#declare Con_Array=array[3]
#declare Con_Array[0]=1;
#declare Con_Array[1]=1;
#declare Con_Array[2]=1;

MechSim_Generate_Patch(<000>0.0658000100000,
                       true<0.0550.055><5050>, No_Trans, fn_Fixed, Con_Array)

MechSim_Generate_Patch_Std() sample

3.3.8 MechSim_Generate_Patch_Std()

This macro generates a rectangular patch of masses with connections and optionally faces forming the surface. In contrast to the MechSim_Generate_Patch() macro all connections all have the same stiffness and damping. Also none of the masses is fixed.

parameters:

example code:

// generate a 50x50 with bending and shearing stiffness
MechSim_Generate_Patch_Std(<000>0.0658000100000,
                           true<0.0550.055><5050>, No_Trans, 3)

MechSim_Generate_Line() sample

3.3.9 MechSim_Generate_Line()

This macro generates a line of connected masses and can be used for simulating things like ropes, chains, etc. The masses of the line can be fixed with help of a function

parameters:

meaning of the 'Connect_Arr' entries:

See a description of this array in general. The first element of the array weights the direct connections between two neighboring masses. Further values in the array weight the more distant connections that introduce bending stiffness to the line. Only connections up to the size of the array are generated.

example code:

// generate a 10 masses line with bending stiffness
// no masses are fixed

#declare fn_Fixed=function { -1 }
#declare Con_Array=array[2]
#declare Con_Array[0]=1;
#declare Con_Array[1]=1;

MechSim_Generate_Line(<000>0.098000100000,
                      0.4510<111>, No_Trans, fn_Fixed, Con_Array)

MechSim_Generate_Line_Std() sample

3.3.10 MechSim_Generate_Line_Std()

This macro generates a line of connected masses and can be used for simulating things like ropes, chains, etc.. In contrast to the MechSim_Generate_Line() macro only shortest distance connections are generated. Also none of the masses is fixed.

parameters:

example code:

// generate a 10 masses line
MechSim_Generate_Line(<000>0.098000100000,
                      0.4510<111>, No_Trans)