Finite Element Tools

Documentation

Back to FE Tools Home

C++ Programs:


amiraToD

fujiToImage

printNodes

amiraToK

kToNike

sphereToCircle

amiraToOff

makeShells

surfToBYU

changeProperties

mergeFiles

surfToOff

changeShellNormals

modulus

thickElements

changeShells

nodeReader

Thickness

extractSurface

offToBYU

 

findSurfNodes

parseNormals

 


VTK Programs:

normals

 

Bonemat Programs:

Bonemat Documentation

 

amiraToD                         

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts an Amira TetMesh or Surface output (hypermesh ascii format) to dyna3d .d format.

 

Programming Notes:

 

 

 

amiraToK                         

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts an Amira TetMesh or Surface output (hypermesh ascii format) to .k format.

 

Programming Notes:

Converts  *nodes to *NODEs and *tetras to *ELEMENT_SOLIDs.

 

 

amiraToOff

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts an Amira TetMesh or Surface output (hypermesh ascii format) to .off format.

 

Programming Notes:

Lists  *nodes first followed by *tetras (with -1 offset for connectivity set. Ex: tetra(10,6,3,4,5) is printed as 6 2 3 4. 

 

 

changeProperties

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Changes property values (numbering and material values) of a .k file and outputs in tabbed format.

 

Programming Notes:

Since each of these changes are optional, a series of if statements control the output while reading and printing each line.  Also, since .k files may have multiple occurrences and various orders of NODEs, ELEMENT_SOLIDs, and ELEMENT_SHELLs, boolean variables are set to distinguish the current line. 

 

 

changeShellNormals

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Changes normals for all Elelment Shells and their Thicknesses given in a .k file.

 

Programming Notes:

A shell with connectivity 1 2 3 3 will be printed with connectivity 3 2 1 1.

 

 

changeShells

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

nodeReader

Description:

Changes shell property values of a .k file for an input list of shell indexes (output of truegrid).

 

Programming Notes:

Since the input shell indexes can be in two overlapping groups of numerical order, the file is repeatedly scanned until all indexes are found.

 

 

extractSurface

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

nodeReader

Description:

Extracts the elements of given nodes (output of truegrid) from a .k file

 

Programming Notes:

Since the elements can include nodes that aren’t on the surface, an additional origin node is printed and used in the connectivity.

 

 

findSurfNodes

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

findMaxNode.cpp

Description:

Finds the number of surface nodes (largest node number) used in the given shells of a .k file.

 

Programming Notes:

 

 

 

fujiToImage

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

circleMapper.h, circleMapper.cpp

Description:

Converts a 2D 8-bit image into a 2D mapped .k image.

 

Programming Notes:

 

 

 

kToNike 

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts .k file to .nike format.

 

Programming Notes:

Converts *NODEs from index, xcord, ycord, zcord, part#, part# to index, part#, xcord, ycord, zcord, part#.  Since original NODES may be separated by either commas or spaces, boolean variables are used to distinguish the inputs.

 

 

makeShells

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

nodeReader

Description:

Makes new shells for an input list of shell indexes (output of truegrid) by copying connectivity of existing shells of a .k file.  New shells will have new numbering, material values (part #s), and thickness values as specified.

 

Programming Notes:

Assumes input shell indexes are in numerical order.

 

 

mergeFiles

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Prints the contents of two files into one.

 

Programming Notes:

 

 

 

modulus

OS:  

Windows ,Unix, Linux

CC tags:

-LANG:std –lm

(the –lm tag needs to be at the end of the compile command, after all other tags and arguments)

Requirements:

Mesh.h, Mesh.cpp, ImageSet.h, ImageSet.cpp

Description:

The Bonemat program serves the same function as the modulus program and works much better.  This code calculates intensity by averaging the 9 nearest voxels to each node whereas the Bonemat code uses a more effective element volume integration algorithm.  This program is no longer maintained or recommended for use.

The raw data input should be in little endian format (use ImageJ to change).

Computes the elastic modulus of shells in a .k file using the raw data.  Prints findModulus.log containing the calculated EMs and statistics.  Also prints a .k file with new elements using the connectivity from the given shells.  Specifications about the data and .k file are needed.

     

Programming Notes:

Wow, this is crazy!

  Ok, first modulus.cpp gets info from the user and manages calls to the ImageSet and Mesh class member functions.

  The ImageSet class keeps track of the raw data.  Nothing too tricky here, just scan in the data and save variables for x, y, z dimensions and slice thickness.  It should be noted that the imageSet will be read in with little endian format, not Big endian.  It makes a difference!!!

  The Mesh class does all the work.  ReadMesh saves the node coordinates from the .k file.  FindModulus calculates the EM for every node (saved in ReadMesh).  It finds the intensity of a node and its 8 nearest neighbors (from the ImageSet), takes the average, then calculates the Hosenfield Units, Apparent Density, and Elastic Modulus.  Checks are made to ensure that there are 8 neighbors.  A default EM is assigned if the node is on the mesh surface, the Average intensity is too small (<802), or the AD is negative.  A log file (findModulus.log) is written with statistics on all EMs other than the assigned cases.  LabelElements calculates the EM for each ELEMENT_SOLID in the .k file.  It uses the average EM (calculated in FindModulus) of the 4 element vertices.  The shell material value (part #) is assigned by dividing the total EM range by 10.  Each sub-range is assigned a different material value.  PrintElements prints a .k file with new ELEMENT_SOLIDs having index  specified by the user, material value (from LabelElements) and connectivity  nodes (taken from original .k shells).

 

 

nodeReader

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

The nodeReader class reads a node index file (output of truegrid) and returns each integer when getNext is called.  It expands integers when necessary (Ex: 4:6 expands to 4 5 6).  0 is returned at the end of the list.  Since there can be multiple groups of node lists in a file, it ignores anything other than integers.  This is used by many other programs.

 

Programming Notes:

The function setFile opens the node file for reading and scans through ‘till the nodes are found.  The function getNext expands semicolons by keeping track of the stopnode.

  If using in code, it should look something like this:

#include "path/nodeReader/nodeReader.cpp"

//some code

FILE *fileName=fopen("file.nodes","rt");

nodeReader name;

name.setFile(fileName);

int nextNode; 

//some more code

nextNode=name.getNext();

nextNode=name.getNext(); 

 

 

offToBYU

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts a file in .off format to .byu format.

 

Programming Notes:

When printing triangles, values are offset by +1 and the sign of the third node is reversed.  Ex. 3 0 1 2163 (.off) is converted to 1 2 -2164 (.byu)

 

 

parseNormals

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts normals.vtk files (output from normals.tcl) into a format listing only the normals values.  The values are output to a new file.

 

Programming Notes:

 

 

printNodes

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

nodeReader

Description:

Expands and prints a node index file (output of truegrid) to a new file with 8 nodes per line.  (Ex: 4:6 expands to 4, 5, 6).

 

Programming Notes:

Uses a nodeReader to get each node.

 

 

sphereToCircle

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std –lm

(the –lm tag needs to be at the end of the compile command, after all other tags and arguments)

Requirements:

nodeReader, sphereFit.cpp, sphereMapper.h, sphereMapper.cpp

Description:

Converts a .k file of a hemisphere into a 2D mapped .k image.

 

Programming Notes:

The Least Squares sphere fitting algorithm was taken mostly from LeastSquaresFitting.pdf

 

 

surfToBYU

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts an Amira surface output (HxSurface ascii format) to .byu format.

 

Programming Notes:

When printing triangles, the sign of the third node is reversed.  Ex. 4 3 2 (.surf) is converted to 4 3 -2 (.byu).  Since the number of triangles must be printed in the .byu header, the vertex values are stored to a temporary file (buffer.txt) until the .byu header is complete.  The number of edges in the .byu file is calculated by multiplying the number of triangles by 3.

 

 

surfToOff

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

 

Description:

Converts an Amira surface output (HxSurface ascii format) to .off format.

 

Programming Notes:

When printing triangles, values are preceded by the part number and offset by -1.  Ex. 4 3 2 (.surf) is converted to 3 3 2 1 (.off).  Since the number of triangles must be printed in the .off header, the vertex values are stored to a temporary file (buffer.txt) until the .off header is complete.  The number of edges in the .off file is calculated by multiplying the number of triangles by 3.

 

 

thickElements

OS:  

Windows, Unix, Linux

CC tags:

-LANG:std

Requirements:

nodeReader

Description:

Creates new element layers around existing shells of a .k file for given shell indexes (file output of truegrid) using given normal values (.vtk file output of normals.tcl)\n");  Requires input of the number of existing nodes to use (most often, only the surface nodes are needed).  Allows up to 3 new element layers to be created with a specified total thickness (in mm) for all new layers. 

 

Programming Notes:

  The main function gets info from the user and manages calls to the other functions.

  The oldNodes structure is used to store the coordinates (from .k file) and normal values (from .vtk file) of existing nodes.  A boolean variable is used to track which nodes are used in actually making the new element layers.

  The newCords structure is used to store node coordinate values for the new elements.  One array of newCords is used for each new element layer. 

  The storeNodes function reads the .k file and stores the node coordinates in an oldNodes array.  The array index corresponds to one less than the original node number.  Ex. Original node #1 has array index 0.

  The storeNormals function reads the normals.vtk file and stores the node normals in an oldNodes array.  Three consecutive values in the normals.vtk file correspond to the x, y, and z components of a node.

  The computeElements function computes the node values and connectivity of the new element layers.  The original element shells are obtained by reading the .k file and finding the given shell indexes in the truegrid file.  The node numbers in the original element connectivity are looked up in the oldNodes array.  If the node has not been encountered yet, new node coordinates for the new element shells are computed (using the oldNodes’ normal values and the given layer thickness) and stored in the newCords arrays.  A new element is then printed for each layer according to the following:

    number – the first element number is specified by the user.  Element number is then incremented by 1 with the order in which it is printed.

    part # - specified by user and constant for all layers.

    node connectivity – The eight values are printed in the reverse order of the original elements.  The first four represent the lower boundary of the layer, while the last four represent the upper boundary.  Ex. If the old shell was 1 2 1 2 3 3, then a new element in the first layer would use the original element for the lower boundary and the new first layer element for the upper giving something like 1 2 3 2 1 1 13 12 10 10 . 

The printNodes function computes the index for the new nodes and prints them.  A list of the original nodes that were used is also printed to a log file followed by a count of the number changed.  For each layer generated the new node is computed according to the following:

    index – found by adding the total number of original nodes multiplied by the layer number to the original index number.  This ensures that no node index is repeated even though some node indexes may be skipped (due to their never being used in the new element connectivities).

    coordinates   calculated during the computeElements function by adding the layer thickness multiplied by the x y or z components of the node normals to the x y or z coordinates respectively.

 

 

Thickness

OS:  

Windows

Requirements:

ANN software

Description:

Calculates the thickness between Amira cortical and trabecular surfaces (HxSurface ascii format) for all nodes of an Amira TetMesh (hypermesh ascii format) along the given cortical normals (.vtk file output of normals.tcl).  A log of the thickness and angle values found is written to an ans (.log) file.  A log of the calculations is written to a table (.log) file. 

 

Programming Notes:

  All of the program functions are contained in newthickness.cpp. The other files contain code for the ANN software.

  The main function gets info from the user and manages calls to the other functions.

  The parse_mesh_file and parse_surf_file functions get and store the vertex coordinates of the mesh, cortical, and trabecular files in an AnnTableWrap structure.

  The parse_norm_file function gets and stores the normal values from the cortical normals file into an ANNpoint array.

  The calculate_and_print function does the computations and prints the results.  It takes the mesh vertices and finds the nearest neighbor cortical vertices using the program ANN (University of Maryland).  The cortical vertices are used because the geometry is much more representative of the CT data than the mesh vertices.  Next, the 400 (defined as NNB at beginning) nearest neighbor trabecular vertices (to the cortical vertices) are found.  A normalized vector is calculated by taking the differences between these cortical vertices and trabecular vertices.  The angle theta between the cortical normals and the normalized vector is calculated and sorted.  The length of the vector from the cortical to the trabecular points is also calculated.  The angle theta and the length are then each given a weight factor.  In the lengths sorting, the length based upon the angle is normally taken.  However, if the length based on the angle is 1.5 greater than the length (tested in lenPtToSurf function) based solely on the length then the program replaces the length based on the angle by the shortest length found.  We found that this method solved most of the problems that the program was encountering with sharp edges.  Finally, the distance between the cortical bone and the trabecular bone is reported as the thickness of the bone.  This distance is written out to a new .k file. Thus a nodal dependent cortical bone thickness is defined for each shell element node. 

 

 

normals                          

OS:  

Windows, Unix, Linux

Requirements:

VTK, Tcl, colors.tcl, vtkInt.tcl, vtkImageInclude.tcl

Description:

Gets the data normals from an Amira Surface output (hypermesh ascii format).  It also visualizes the surface in a VTK window.

 

Programming Notes:

The first lines (all beginning with set) need to be set for the specific paths when installed.

 

 

Created by Janna Balling j.balling@utah.edu

     For Andrew Anderson at Musculoskeletal Research Laboratories

University Of tah