implemented png export so that we get a overlay of the splitt lines and also directly export a node tree visualization of the node tree with graphviz.
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// EmitDOT serialisiert den BSP-Baum mit Wurzel root und schreibt ihn als DOT-Datei nach path.
|
||||
@@ -39,3 +40,12 @@ func EmitDOT(root *bsp.Node, path string) error {
|
||||
buf.WriteString("}\n")
|
||||
return os.WriteFile(path, buf.Bytes(), 0644)
|
||||
}
|
||||
|
||||
func RunGraphviz(dotFile, pngFile string) error {
|
||||
cmd := exec.Command("dot", "-Tpng", dotFile, "-o", pngFile)
|
||||
out, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
return fmt.Errorf("graphviz failed: %v\n%s", err, string(out))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user