Mesh: [skip ci] support of loading colored mesh segments
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user