11 m_vertexColors[m_vertices.size()] =
color;
12 m_vertices.push_back(vtx.template cast<ValueType>());
19 m_lineColors[m_lines.size()] =
color;
24 m_lines.push_back({m_vertices.size() - 2, m_vertices.size() - 1});
31 m_faceColors[m_faces.size()] =
color;
34 idxs.reserve(vtxs.size());
35 for (
const auto& vtx : vtxs) {
37 idxs.push_back(m_vertices.size() - 1);
44 const std::vector<FaceType>& faces,
51 m_faceColors[m_faces.size()] =
color;
53 auto vtxoffs = m_vertices.size();
55 m_vertexColors[m_vertices.size()] =
color;
57 m_vertices.insert(m_vertices.end(), vtxs.begin(), vtxs.end());
58 for (
const auto& face : faces) {
59 if (face.size() == 2) {
60 m_lines.push_back({face[0] + vtxoffs, face[2] + vtxoffs});
64 [&](
size_t& iv) {
return (iv + vtxoffs); });
65 m_faces.push_back(rawFace);
75 if (not IVisualization3D::hasExtension(objectpath)) {
80 IVisualization3D::replaceExtension(mtlpath,
".mtl");
81 os <<
"mtllib " << mtlpath <<
"\n";
91 std::stringstream sterile;
97 std::map<std::string, bool> materials;
101 materialName =
"material_";
106 if (materials.find(materialName) == materials.end()) {
107 mos <<
"newmtl " << materialName <<
"\n";
108 std::vector<std::string> shadings = {
"Ka",
"Kd",
"Ks"};
109 for (
const auto& shd : shadings) {
121 ColorRGB lastVertexColor = {0, 0, 0};
123 if (m_vertexColors.find(iv) != m_vertexColors.end()) {
124 auto color = m_vertexColors.find(iv)->second;
125 if (
color != lastVertexColor) {
126 os << mixColor(
color) <<
"\n";
127 lastVertexColor =
color;
131 os <<
"v " << std::setprecision(m_outputPrecision)
132 << m_outputScalor * vtx.x() <<
" " << m_outputScalor * vtx.y() <<
" "
133 << m_outputScalor * vtx.z() <<
"\n";
138 for (
const LineType& ln : m_lines) {
139 if (m_lineColors.find(il) != m_lineColors.end()) {
140 auto color = m_lineColors.find(il)->second;
141 if (
color != lastLineColor) {
142 os << mixColor(
color) <<
"\n";
143 lastLineColor =
color;
146 os <<
"l " << ln.first + 1 <<
" " << ln.second + 1 <<
"\n";
151 for (
const FaceType&
fc : m_faces) {
152 if (m_faceColors.find(is) != m_faceColors.end()) {
153 auto color = m_faceColors.find(is)->second;
154 if (
color != lastFaceColor) {
155 os << mixColor(
color) <<
"\n";
156 lastFaceColor =
color;
160 for (
size_t i = 0;
i <
fc.size();
i++) {
161 os <<
" " <<
fc[
i] + 1;
168 template <
typename T>
173 m_lineColors.clear();
174 m_vertexColors.clear();
175 m_faceColors.clear();