@@ -87,36 +87,41 @@ auto CFrontendIR::reciprocate(const TypedHandle<const IExprNode> other) -> Typed
8787void CFrontendIR::printDotGraph (std::ostringstream& str) const
8888{
8989 str << " digraph {\n " ;
90- auto getNodeID = [](TypedHandle<const INode> handle)->core ::string
91- {
92- return core::string (" _" )+std::to_string (handle);
93- };
9490
91+ // TODO: track layering depth and indent accordingly?
9592 core::vector<TypedHandle<const CLayer>> layerStack = m_rootNodes;
9693 core::stack<TypedHandle<const IExprNode>> exprStack;
97- // TODO : print identifiers for root nodes/materials
9894 while (!layerStack.empty ())
9995 {
100- const auto * layerNode = deref ( layerStack.back () );
96+ const auto layerHandle = layerStack.back ();
10197 layerStack.pop_back ();
98+ const auto * layerNode = deref (layerHandle);
99+ //
100+ const auto layerID = getNodeID (layerHandle);
101+ str << " \n\t " << getLabelledNodeID (layerHandle);
102+ //
102103 if (layerNode->coated )
103104 {
104- // TODO: print coating
105+ str << " \n\t " << layerID << " -> " << getNodeID (layerNode-> coated ) << " [label= \" coats \" ] \n " ;
105106 layerStack.push_back (layerNode->coated );
106107 }
107- // TODO: print labelled edges
108- exprStack.push (layerNode->brdfTop );
109- exprStack.push (layerNode->btdf );
110- exprStack.push (layerNode->brdfBottom );
108+ auto pushExprRoot = [&](const TypedHandle<const IExprNode> root, const std::string_view edgeLabel)->void
109+ {
110+ if (!root)
111+ return ;
112+ str << " \n\t " << layerID << " -> " << getNodeID (root) << " [label=\" " << edgeLabel << " \" ]" ;
113+ exprStack.push (root);
114+ };
115+ pushExprRoot (layerNode->brdfTop ," Top BRDF" );
116+ pushExprRoot (layerNode->btdf ," BTDF" );
117+ pushExprRoot (layerNode->brdfBottom ," Bottom BRDF" );
111118 while (!exprStack.empty ())
112119 {
113120 const auto entry = exprStack.top ();
114121 exprStack.pop ();
122+ str << " \n\t " << getLabelledNodeID (entry);
123+ str << " \n\t " << getNodeID (entry) << " -> {" ;
115124 const auto * node = deref (entry);
116- str << " \t " << getNodeID (entry) << " [label=" << node->getTypeName () << " \\ n" ;
117- if (const auto * debug = deref (node->debugInfo ); debug && !debug->data ().empty ())
118- str << std::string_view (reinterpret_cast <const char *>(debug->data ().data ()),debug->data ().size ());
119- str << " ]\n\t " << getNodeID (entry) << " -> {" ;
120125 const auto childCount = node->getChildCount ();
121126 for (auto childIx=0 ; childIx<childCount; childIx++)
122127 {
@@ -131,7 +136,7 @@ void CFrontendIR::printDotGraph(std::ostringstream& str) const
131136 }
132137 }
133138
134- str << " }\n " ;
139+ str << " \n }\n " ;
135140}
136141
137142}
0 commit comments