Import Geant4 4.1.0 source tree
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
sub usage {
|
||||
print STDERR "This script takes a STEP file (from STDIN)\n";
|
||||
print STDERR "and writes it to STDOUT with the data section\n";
|
||||
print STDERR "sorted by ID.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub error {
|
||||
print STDERR $_[0]."\n";
|
||||
exit 2;
|
||||
}
|
||||
|
||||
if ($#ARGV >= 0) {
|
||||
&usage();
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
|
||||
$entry= "";
|
||||
while (<STDIN>) {
|
||||
while ($_ ne "") {
|
||||
|
||||
if (/[;']/) { #']){
|
||||
|
||||
$entry.= $`.$&;
|
||||
$_= $';
|
||||
if ($& eq ";") {
|
||||
|
||||
# end of entry
|
||||
$lof= $_;
|
||||
&processEntry($entry);
|
||||
$entry= "";
|
||||
$_= $lof;
|
||||
|
||||
} else {
|
||||
|
||||
# start of string
|
||||
/[']/ || &error("String does not end within the line!"); #'];
|
||||
$entry.= $`.$&;
|
||||
$_= $';
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
$entry.= $_;
|
||||
$_= "";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/^[ \t\n]*$/m || &error("File does not end with ';' !");
|
||||
print "$_\n";
|
||||
exit 0;
|
||||
|
||||
##########################################################################
|
||||
|
||||
sub processEntry {
|
||||
local($e)= @_;
|
||||
|
||||
if (!$inData) {
|
||||
|
||||
print $e;
|
||||
if ($e =~ /^(\s|\n)*DATA(\s|\n)*;$/m) {
|
||||
$inData= 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ($e =~ /^(\s|\n)*\#([0-9]+)\=/m) {
|
||||
|
||||
$id= $2;
|
||||
$entries[$id]= $e;
|
||||
|
||||
} else {
|
||||
|
||||
$e =~ /^(\s|\n)*ENDSEC(\s|\n)*;$/m ||
|
||||
&error("Data section does not end with ENDSEC;");
|
||||
$inData= 0;
|
||||
for ($id=0; $id<=$#entries; $id++) {
|
||||
$en= $entries[$id];
|
||||
if ($en ne "") {
|
||||
print $en;
|
||||
}
|
||||
}
|
||||
print $e;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
##########################################################################
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
$filename = $ARGV[0];
|
||||
open(INFILE, $filename) || die "\nSTEP file ".$filename." not found.";
|
||||
print "Opening file ".$filename;
|
||||
@filebuf = <INFILE>;
|
||||
close(INFILE);
|
||||
|
||||
$g4 = "G4";
|
||||
$outputfile = $g4 . $filename;
|
||||
open(OUTFILE, ">$outputfile");
|
||||
print "\nModifying STEP file for NIST toolkit...";
|
||||
|
||||
foreach (@filebuf)
|
||||
{
|
||||
if(/.*VERTEX\_POINT.*/)
|
||||
{
|
||||
s/VERTEX\_POINT\s*\(\s*\'\s*\'\s*\,/VERTEX\_POINT\(\'\'\,\'\'\,/g ;
|
||||
s/VERTEX\_POINT\s*\(\s*\'NONE\'\s*\,/VERTEX\_POINT\(\'NONE\'\,\'\'\,/g ;
|
||||
}
|
||||
elsif(/.*EDGE\_LOOP.*/)
|
||||
{
|
||||
s/EDGE\_LOOP\s*\(\s*\'\s*\'\s*\,/EDGE\_LOOP\(\'\'\,\'\'\,/g;
|
||||
s/EDGE\_LOOP\s*\(\s*\'NONE\'\s*\,/EDGE\_LOOP\(\'NONE\'\,\'\'\,/g;
|
||||
}
|
||||
elsif(/.*POLY\_LOOP.*/)
|
||||
{
|
||||
s/POLY\_LOOP\s*\(\s*\'\s*\'\s*\,/POLY\_LOOP\(\'\'\,\'\'\,/g;
|
||||
s/POLY\_LOOP\s*\(\s*\'NONE\'\s*\,/POLY\_LOOP\(\'NONE\'\,\'\'\,/g;
|
||||
}
|
||||
elsif(/.*ADVANCED\_FACE.*/)
|
||||
{
|
||||
($a,$b,$c) = split('\)',$&);
|
||||
s//$a\)\,\'\'$b\)$c\n/;
|
||||
}
|
||||
elsif(/.*FACE\_SURFACE.*/)
|
||||
{
|
||||
($a,$b,$c) = split('\)',$&);
|
||||
s//$a\)\,\'\'$b\)$c\n/;
|
||||
}
|
||||
elsif(/.*EDGE\_CURVE.*/)
|
||||
{
|
||||
($a,$b,$c,$d,$e) = split(",",$&);
|
||||
s//$a\,$b\,$c\,\'\'\,$d\,$e\n/;
|
||||
}
|
||||
|
||||
print OUTFILE;
|
||||
}
|
||||
|
||||
close(OUTFILE);
|
||||
print "\nOutput written to ".$outputfile."\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user