[Bf-blender-cvs] [ad168871b13] functions: dot export for new data flow graph

Jacques Lucke noreply at git.blender.org
Sat Apr 27 10:01:51 CEST 2019


Commit: ad168871b139068e8d9b40f26b716439380cbbc2
Author: Jacques Lucke
Date:   Sat Apr 27 10:01:36 2019 +0200
Branches: functions
https://developer.blender.org/rBad168871b139068e8d9b40f26b716439380cbbc2

dot export for new data flow graph

===================================================================

M	source/blender/functions/core/data_flow_graph.cpp
M	source/blender/functions/core/data_flow_graph.hpp
M	source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp

===================================================================

diff --git a/source/blender/functions/core/data_flow_graph.cpp b/source/blender/functions/core/data_flow_graph.cpp
index d27d1576c40..9290c3defcc 100644
--- a/source/blender/functions/core/data_flow_graph.cpp
+++ b/source/blender/functions/core/data_flow_graph.cpp
@@ -68,4 +68,44 @@ DataFlowGraph::~DataFlowGraph()
   }
 }
 
+std::string DataFlowGraph::to_dot()
+{
+  DataFlowGraphBuilder builder;
+  this->insert_in_builder(builder);
+  return builder.to_dot();
+}
+
+void DataFlowGraph::to_dot__clipboard()
+{
+  DataFlowGraphBuilder builder;
+  this->insert_in_builder(builder);
+  builder.to_dot__clipboard();
+}
+
+void DataFlowGraph::insert_in_builder(DataFlowGraphBuilder &builder)
+{
+  SmallVector<DFGB_Node *> dfgb_nodes;
+
+  for (auto &node : m_nodes) {
+    DFGB_Node *dfgb_node = builder.insert_function(node.function);
+    dfgb_nodes.append(dfgb_node);
+  }
+
+  for (uint input_id = 0; input_id < m_inputs.size(); input_id++) {
+    uint from_id = m_inputs[input_id].origin;
+    uint from_node_id = m_outputs[from_id].node;
+    uint from_index = this->index_of_output(from_id);
+    DFGB_Node *from_dfgb_node = dfgb_nodes[from_node_id];
+    DFGB_Socket from_dfgb_socket = from_dfgb_node->output(from_index);
+
+    uint to_id = input_id;
+    uint to_node_id = m_inputs[to_id].node;
+    uint to_index = this->index_of_input(to_id);
+    DFGB_Node *to_dfgb_node = dfgb_nodes[to_node_id];
+    DFGB_Socket to_dfgb_socket = to_dfgb_node->input(to_index);
+
+    builder.insert_link(from_dfgb_socket, to_dfgb_socket);
+  }
+}
+
 }  // namespace FN
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index 54d07f8fdd4..5f8f144dddc 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -339,6 +339,12 @@ class DataFlowGraph : public RefCountedBase {
     uint index = this->index_of_output(output_socket);
     return this->function_of_node(node)->signature().outputs()[index];
   }
+
+  std::string to_dot();
+  void to_dot__clipboard();
+
+ private:
+  void insert_in_builder(DataFlowGraphBuilder &builder);
 };
 
 }  // namespace FN
diff --git a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
index a3329031cb1..e1255b67831 100644
--- a/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/function_generation.cpp
@@ -17,6 +17,7 @@ Optional<SharedFunction> generate_function(bNodeTree *btree)
   }
 
   FunctionGraph fgraph = fgraph_.value();
+  // fgraph.graph()->to_dot__clipboard();
 
   auto fn = SharedFunction::New(btree->id.name, fgraph.signature());
   fgraph_add_DependenciesBody(fn, fgraph);
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
index b18e11da6fa..1932e97bbee 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
@@ -276,8 +276,6 @@ Optional<FunctionGraph> generate_function_graph(bNodeTree *btree)
 
   insert_unlinked_inputs(builder, inserters);
 
-  // graph_builder.to_dot__clipboard();
-
   return finalize_function_graph(graph_builder, input_sockets, output_sockets);
 }



More information about the Bf-blender-cvs mailing list