source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vrippack-0.31/src/plytools/plysets2conf @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2#
3# plysets2conf:  This program takes a bunch of ply sets, and then
4# generates a conf file, which grabs the first listed ply file
5# for each set, and the matrix transform.
6
7
8if (($#ARGV == -1) || ($ARGV[0] eq "-h")) {
9    print STDERR "\n";
10    print STDERR "Usage: plysets2conf [-l n] <1.set> <2.set> ... > all.conf\n";
11    print STDERR "\n";
12    print STDERR "The program will add the first-listed ply file for\n";
13    print STDERR "Each set to the conf file, as well as the xf.\n";
14    print STDERR "\n";
15    print STDERR "  -l    Use the nth level mesh.  E.g. if n is 1,\n";
16    print STDERR "        use the first mesh listed in each set file.\n";
17    print STDERR "\n";
18    print STDERR "Ex:  plysets2conf -l 4 a.set b.set\n";
19    print STDERR "     Will generate a .conf file with level 4 of each set.\n";
20    print STDERR "\n";
21    exit(-1);
22}
23
24# Set a resolution level.  1 is highest, 4 is lowest
25$reslev = 1;
26if ($ARGV[0] eq "-l") {
27    $reslev = int($ARGV[1]);
28    ($reslev > 0) || die "Error: res level must be greater than 0.\n";
29    # Cut first 2 arguments off the list so we ignore the number... :-)
30    splice(@ARGV, 0,2);
31}
32
33
34for ($argc=0; $argc <= $#ARGV; $argc++) {
35    $set = $ARGV[$argc];
36    open(SET, $set);
37    print STDERR "Using mesh $reslev of set $set...\n";
38    # skip first two lines, then skip to the right reslev...
39    for ($i=1; $i < 2+$reslev; $i++) {
40        <SET>;
41    }
42    $line = <SET>;
43    @words = split(' ', $line);
44    # Assertion check
45    if ($#words != 2) {
46        print STDERR "Error: $set does not contain a mesh number $reslev.\n";
47        exit(-1);
48    }
49    # Get directory, too
50    $plydir = $set;
51    while (length($plydir) > 0 && substr($plydir, -1, 1) ne "/") {
52        chop $plydir;
53    }
54
55    $plyname = $words[2];
56    $xf = $set;
57    $xf =~ s/.set/.xf/g;
58    $quat = `matrix2quat < $xf`;
59    $outline = "bmesh $plydir$plyname $quat";
60    print $outline;
61    close(SET);
62}
63
Note: See TracBrowser for help on using the repository browser.