source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/image3dstiching/VRml2Depth/Wrl2Depth.pl @ 37

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

Added original make3d

File size: 1.6 KB
Line 
1#!/usr/bin/perl
2
3# Read the whole file
4$file = $ARGV[0] or  $file = 'building0010';
5
6open(INFO, $file.'.wrl');
7@WholeWrl  = <INFO>;
8close(INFO);
9$IndexedFaceSetStart = 0;
10$IndexedFaceSetEnd = 0;
11$TextureCoordinateStart = 0;
12$TextureCoordinateEnd = 0;
13
14if (1)
15{
16for ( $i = 0; $i < @WholeWrl; ++$i)
17{
18        if ( $WholeWrl[$i] =~ /geometry IndexedFaceSet {/)
19        {
20                print "Find IndexedFaceSetStart"."\n"   ;
21                $IndexedFaceSetStart = $i+3;
22                print @WholeWrl[$IndexedFaceSetStart];
23        }
24        elsif ( $WholeWrl[$i] =~ /texCoord TextureCoordinate {/)
25        {
26                print "Find TextureCoordinateStart"."\n"        ;
27                $TextureCoordinateStart = $i+2; 
28                print @WholeWrl[$TextureCoordinateStart];
29        }
30        elsif ($WholeWrl[$i] =~ /]/)
31        {
32                if ($IndexedFaceSetEnd == 0 && $IndexedFaceSetStart != 0)
33                {
34                        print "Find End of IndexedFaceSet"."\n";
35                        $IndexedFaceSetEnd = $i-1;
36                        print @WholeWrl[$IndexedFaceSetEnd];
37                }       
38                if ($TextureCoordinateEnd == 0 && $TextureCoordinateStart != 0)
39                {
40                        print "Find End of TextureCoordinate"."\n";
41                        $TextureCoordinateEnd = $i-1;
42                        print @WholeWrl[$TextureCoordinateEnd];
43                }       
44        }
45}
46@IndexedFaceSet = @WholeWrl[$IndexedFaceSetStart..$IndexedFaceSetEnd];
47# clear up the data
48for ($i = 0; $i < @IndexedFaceSet; ++$i)
49{
50        $IndexedFaceSet[$i] =~ s/,//;
51}
52$OutIndexedFaceSetFile = 'IndexedFaceSet_'.$file;
53open(INFO, ">$OutIndexedFaceSetFile");
54print INFO @IndexedFaceSet;
55close(INFO);
56
57@TextureCoordinate = @WholeWrl[$TextureCoordinateStart..$TextureCoordinateEnd];
58for ($i = 0; $i < @TextureCoordinate; ++$i)
59{
60        $TextureCoordinate[$i] =~ s/,//;
61}
62$OutTextureCoordinateFile = 'TextureCoordinate_'.$file;
63open(INFO, ">$OutTextureCoordinateFile");
64print INFO @TextureCoordinate;
65close(INFO);
66
67}
Note: See TracBrowser for help on using the repository browser.