static void print_component (std::ostream &out, const ClosureComponent *comp, ShadingSystemImpl *ss, const Color3 &weight) { out << "(" << weight[0]*comp->w[0] << ", " << weight[1]*comp->w[1] << ", " << weight[2]*comp->w[2] << ") * "; const ClosureRegistry::ClosureEntry *clentry = ss->find_closure(comp->id); ASSERT(clentry); out << clentry->name.c_str() << " ("; int i; for (i = 0; i < clentry->nformal; ++i) { if (i) out << ", "; if (clentry->params[i].type.numelements() > 1) out << "["; for (size_t j = 0; j < clentry->params[i].type.numelements(); ++j) { if (j) out << ", "; print_component_value(out, ss, clentry->params[i].type.elementtype(), (const char *)comp->data() + clentry->params[i].offset + clentry->params[i].type.elementsize() * j); } if (clentry->params[i].type.numelements() > 1) out << "]"; } if (comp->nattrs) { const ClosureComponent::Attr * attrs = comp->attrs(); for (int j = 0; j < comp->nattrs; ++j) { if (i || j) out << ", "; // find the type TypeDesc td; for (int p = 0; p < clentry->nkeyword; ++p) if (!strcmp(clentry->params[clentry->nformal + p].key, attrs[j].key.c_str())) td = clentry->params[clentry->nformal + p].type; if (td != TypeDesc()) { out << "\"" << attrs[j].key.c_str() << "\", "; print_component_value(out, ss, td, &attrs[j].value); } } } out << ")"; }
static void print_component (std::ostream &out, const ClosureComponent *comp, ShadingSystemImpl *ss, const Color3 &weight) { out << "(" << weight[0]*comp->w[0] << ", " << weight[1]*comp->w[1] << ", " << weight[2]*comp->w[2] << ") * "; const ClosureRegistry::ClosureEntry *clentry = ss->find_closure(comp->id); ASSERT(clentry); out << clentry->name.c_str() << " ("; for (int i = 0, nparams = clentry->params.size() - 1; i < nparams; ++i) { if (i) out << ", "; const ClosureParam& param = clentry->params[i]; if (param.key != 0) out << "\"" << param.key << "\", "; if (param.type.numelements() > 1) out << "["; for (size_t j = 0; j < param.type.numelements(); ++j) { if (j) out << ", "; print_component_value(out, ss, param.type.elementtype(), (const char *)comp->data() + param.offset + param.type.elementsize() * j); } if (clentry->params[i].type.numelements() > 1) out << "]"; } out << ")"; }