cm
to fit the initial linear mesh to the data using tri-cubic Hermite basis functions. The command file and necessary files for this process are given in the example below.
#!/usr/local/perl5.6/bin/perl # ........................................................................ # Name: asci2ex.pl # Description: Reads the asci file format exported by the faro-mounted laser # scanner (Model Maker) which contains coordinates of data points acquired by the # scanner and converts it to an .exdata file. # Updates: # Usage: asci2ex.pl input_file[.asc] # ........................................................................ # get input arguments $input_argument = $ARGV[0]; $input_file = $input_argument . ".asc"; $output_file = $input_argument . ".exdata"; $node_value = "1"; # Open .asc file. open (input,$input_file) or die "Error opening "; # Open new exdata output file. open (output, ">$output_file") or die "Error opening "; # Print .exdata header to output print output " Group name: laser_scanned_data\n"; print output " #Fields=1\n"; print output " 1) coordinates, coordinate, rectangular cartesian, #Components=3\n"; print output " x. Value index=1, #Derivatives=0, #Versions=1\n"; print output " y. Value index=2, #Derivatives=0, #Versions=1\n"; print output " z. Value index=3, #Derivatives=0, #Versions=1\n"; # Read Input and assign first value on each line as x coordinate, # second as y coordinate and third as z coordinate. Print these and Node value. while () { chomp; ($x_coord, $y_coord, $z_coord) = split; print output " Node: $node_value\n"; print output " $x_coord\n"; print output " $y_coord\n"; print output " $z_coord\n"; $node_value++; } # Close the files. close input; close output;
#! /bin/perl # # ........................................................................ # Name: trilinearex2ipelem.pl # Description: Reads a frontend .exelem file containing 8-noded elements and converts that file to the backend. Very simple e.g. does not handle versions. # Updates: # Usage: trilinearex2ipelem.pl exelemfile ipelemfile # ........................................................................ use strict; if (scalar @ARGV < 2) { print "Usage $0 exelemfile ipelemfile\n"; die; } my $filenameIn = $ARGV[0]; my $filenameOut = $ARGV[1]; my $data; my $number_location; my $element_number; my $number_of_nodes; my $number_of_elements; my $collapsed_basis; my $one; my $two; my $three; my $four; my $five; my $six; my $seven; my $eight; open (INPUT_FILE,"<$filenameIn") || (die "Could not open file $filenameIn"); open (OUTPUT_FILE, ">$filenameOut") || (die "Could not open output file $filenameOut"); $number_of_elements=0; print OUTPUT_FILE <<END_HEADER; CMISS Version 1.21 ipelem File Version 2 Heading: END_HEADER print OUTPUT_FILE " The number of elements is [1]: "; $number_location = tell OUTPUT_FILE; print OUTPUT_FILE "XXXXX\n\n"; while (defined($data = <INPUT_FILE>)) { if ($data =~ m/#Nodes=\s*(\d+)/) { $number_of_nodes = $1; } if (($data =~ m/Element:\s*([0-9]+).*/) && ($1 > 0)) { #Only want top level elements. $element_number = $1; #print "found element $1\n"; if ($number_of_nodes == 8) { $number_of_elements++; print OUTPUT_FILE " Element number [1]: $element_number\n"; #Read until we get the nodes while ((defined ($data = <INPUT_FILE>)) && !($data =~ m/Nodes:/)) { } #Read the node numbers if ((defined ($data = <INPUT_FILE>)) && ($data =~ m/\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)\s*([0-9]*)/)) { $collapsed_basis = 0; $one = $1; $two = $2; $three = $3; $four = $4; $five = $5; $six = $6; $seven = $7; $eight = $8; print OUTPUT_FILE <<END_ELEMENT; The number of geometric Xj-coordinates is [3]: 3 The basis function type for geometric variable 1 is [1]: 1 The basis function type for geometric variable 2 is [1]: 1 The basis function type for geometric variable 3 is [1]: 1 Enter the 8 global numbers for basis 1: $one $two $three $four $five $six $seven $eight END_ELEMENT } else { die "Node numbers not found for element $element_number"; } } else { die "Fatal error: $number_of_nodes nodes for the top level element is not supported.\n"; } } } close INPUT_FILE; seek (OUTPUT_FILE, $number_location, 0); printf (OUTPUT_FILE "%5d", $number_of_elements); close OUTPUT_FILE;