Skip to content
Snippets Groups Projects
Commit 30002496 authored by Udo Eisenbarth's avatar Udo Eisenbarth :speech_balloon:
Browse files

Implement own simple dot export for OpticScenery

parent 57078eb4
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,8 @@ use std::io::Write;
fn main() {
println!("opticscenery example");
let scenery = OpticScenery::default();
let mut scenery = OpticScenery::default();
scenery.set_description("OpticScenery demo".into());
println!("default opticscenery: {:?}", scenery);
println!("export to `dot` format: {}", scenery.to_dot());
let path = "graph.dot";
......
use crate::optic_node::OpticNode;
use petgraph::dot::Dot;
use petgraph::prelude::{DiGraph, NodeIndex};
/// Opticscenery represents the overall optical model and additional metatdata. All optical elements (OpticNodes) have to be added to this
......@@ -24,7 +23,10 @@ impl OpticScenery {
}
/// Export the optic graph into the `dot` format to be used in combination with the [`graphviz`](https://graphviz.org/) software.
pub fn to_dot(&self) -> String {
format!("{:?}", Dot::new(&self.g))
let mut dot_string="digraph {\n".to_owned();
dot_string.push_str(&format!(" label=\"{}\"\n", self.description));
dot_string+="}";
dot_string
}
/// Analyze this [`OpticScenery`] using a given OpticAnalyzer.
pub fn analyze(&self) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment