-
Notifications
You must be signed in to change notification settings - Fork 0
/
ply-vis-chopper.go
61 lines (49 loc) · 1.27 KB
/
ply-vis-chopper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"EXoloN/plyreader"
"EXoloN/visio"
"fmt"
"os"
)
func open_files(args []string) (*os.File, *os.File, *os.File, *os.File) {
var err error
var out [4]*os.File
for c := 0; c < 3; c++ {
if out[c], err = os.Open(args[c]); err != nil {
panic(fmt.Sprint("Can't open input file: ", err))
}
}
if out[3], err = os.OpenFile(args[3], os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0664); err != nil {
panic(fmt.Sprint("Can't open ouput file: ", err))
}
return out[0], out[1], out[2], out[3]
}
func main() {
// var original, cropped cloudcompare.PointCloud
var err error
if len(os.Args) != 5 {
panic("Must have four Args!")
}
original_ply, cropped_ply, ply_vis, chopped_vis := open_files(os.Args[1:])
original, err := plyreader.ReadPLY(original_ply)
if err != nil {
panic(err)
}
cropped, err := plyreader.ReadPLY(cropped_ply)
if err != nil {
panic(err)
}
vis, err := visio.ReadVis(ply_vis)
if err != nil {
panic(err)
}
positions := make([]int, cropped.Elements())
for pos := range positions {
if newpos, exists := original.GetPosition(cropped.GetPointAt(pos)); exists {
positions[pos] = newpos
} else {
panic(fmt.Sprint("Point at position ", pos, " can not be found in original PLY file."))
}
}
vis.WriteListTo(positions, chopped_vis)
}