Mesh: [skip ci] support of loading colored mesh segments

This commit is contained in:
wmayer
2020-07-06 12:17:15 +02:00
parent d04d675267
commit 8082def6b5

View File

@@ -192,6 +192,21 @@ private:
(pcDoc->addObject("Mesh::Feature", groupName.c_str()));
pcFeature->Label.setValue(groupName.c_str());
pcFeature->Mesh.swapMesh(*segm);
// if colors are set per face
if (mat.binding == MeshCore::MeshIO::PER_FACE &&
mat.diffuseColor.size() == mesh.countFacets()) {
App::PropertyColorList* prop = static_cast<App::PropertyColorList*>
(pcFeature->addDynamicProperty("App::PropertyColorList", "VertexColors"));
if (prop) {
std::vector<App::Color> diffuseColor;
diffuseColor.reserve(group.getIndices().size());
for (const auto& it : group.getIndices()) {
diffuseColor.push_back(mat.diffuseColor[it]);
}
prop->setValues(diffuseColor);
}
}
pcFeature->purgeTouched();
}
}
@@ -271,6 +286,21 @@ private:
(pcDoc->addObject("Mesh::Feature", groupName.c_str()));
pcFeature->Label.setValue(groupName.c_str());
pcFeature->Mesh.swapMesh(*segm);
// if colors are set per face
if (mat.binding == MeshCore::MeshIO::PER_FACE &&
mat.diffuseColor.size() == mesh.countFacets()) {
App::PropertyColorList* prop = static_cast<App::PropertyColorList*>
(pcFeature->addDynamicProperty("App::PropertyColorList", "VertexColors"));
if (prop) {
std::vector<App::Color> diffuseColor;
diffuseColor.reserve(group.getIndices().size());
for (const auto& it : group.getIndices()) {
diffuseColor.push_back(mat.diffuseColor[it]);
}
prop->setValues(diffuseColor);
}
}
pcFeature->purgeTouched();
}
}