heap alloc for eigen types for alignment issues

This commit is contained in:
Thomas Krijnen
2020-06-11 20:48:35 +02:00
parent 185b4ef9fa
commit 109131961f
15 changed files with 203 additions and 94 deletions
+12 -10
View File
@@ -197,14 +197,14 @@ void ColladaSerializer::ColladaExporter::ColladaScene::add(
// If this is not the first parent, get the relative placement
if (parentNodes.size() > 0)
{
auto m4 = ifcopenshell::geometry::taxonomy::matrix4(matrixStack.top().data().components * transformation.data().components);
auto m4 = ifcopenshell::geometry::taxonomy::matrix4(*matrixStack.top().data().components * *transformation.data().components);
relative_trsf = new ifcopenshell::geometry::Transformation(transformation.settings(), m4);
transformation_towrite = relative_trsf;
}
// @todo verify
const double* m = transformation_towrite->data().components.data();
const double* m = transformation_towrite->data().components->data();
double matrix_array[4][4] = {
{ m[0], m[4], m[8], m[12] },
@@ -251,14 +251,14 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const ifcopensh
// If this is not the first parent, get the relative placement
if (parentNodes.size() > 0)
{
auto m4 = ifcopenshell::geometry::taxonomy::matrix4(matrixStack.top().data().components * parent_trsf.data().components);
auto m4 = ifcopenshell::geometry::taxonomy::matrix4(*matrixStack.top().data().components * *parent_trsf.data().components);
relative_trsf = new ifcopenshell::geometry::Transformation(parent_trsf.settings(), m4);
transformation_towrite = relative_trsf;
}
// @todo verify
const double* parentMatrix = transformation_towrite->data().components.data();
const double* parentMatrix = transformation_towrite->data().components->data();
double matrix_array[4][4] = {
{ (double)parentMatrix[0], (double)parentMatrix[3], (double)parentMatrix[6], (double)parentMatrix[9] },
@@ -280,7 +280,7 @@ void ColladaSerializer::ColladaExporter::ColladaScene::addParent(const ifcopensh
current_node->addMatrix(matrix_array);
// Add the node to the parent stack
matrixStack.push(ifcopenshell::geometry::Transformation(parent_trsf.settings(), ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data().components.inverse())));
matrixStack.push(ifcopenshell::geometry::Transformation(parent_trsf.settings(), ifcopenshell::geometry::taxonomy::matrix4(parent_trsf.data().components->inverse())));
parentNodes.push(current_node);
serializer->parentStackId.push(parent.id());
}
@@ -320,11 +320,11 @@ void ColladaSerializer::ColladaExporter::ColladaMaterials::ColladaEffects::write
COLLADASW::EffectProfile effect(mSW);
effect.setShaderType(COLLADASW::EffectProfile::LAMBERT);
if (material.diffuse) {
auto diffuse = material.diffuse.get().components;
const auto& diffuse = *material.diffuse.get().components;
effect.setDiffuse(COLLADASW::ColorOrTexture(COLLADASW::Color(diffuse[0],diffuse[1],diffuse[2])));
}
if (material.specular) {
auto specular = material.specular.get().components;
const auto& specular = *material.specular.get().components;
effect.setSpecular(COLLADASW::ColorOrTexture(COLLADASW::Color(specular[0],specular[1],specular[2])));
}
if (material.specularity) {
@@ -348,9 +348,11 @@ void ColladaSerializer::ColladaExporter::ColladaMaterials::ColladaEffects::close
void ColladaSerializer::ColladaExporter::ColladaMaterials::add(const ifcopenshell::geometry::taxonomy::style& material) {
if (!contains(material)) {
// @todo original_name
std::string material_name = *(serializer->settings().get(SerializerSettings::USE_MATERIAL_NAMES)
? material.name : material.name);
// @todo original_name?
// @todo apparently material.name is unitialized in some cases now.
std::string material_name = material.name.get_value_or("missing-material");
if (material_name.empty()) {
material_name = "missing-material-" + *material.name;
+2 -2
View File
@@ -94,7 +94,7 @@ int GltfSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style&
base.fill(1.0);
if (style.diffuse) {
for (int i = 0; i < 3; ++i) {
base[i] = style.diffuse->components[i];
base[i] = (*style.diffuse->components)[i];
}
}
if (style.transparency) {
@@ -167,7 +167,7 @@ void GltfSerializer::write(const ifcopenshell::geometry::TriangulationElement* o
node_array_.push_back(json_["nodes"].size());
const double* m = o->transformation().data().components.data();
const double* m = o->transformation().data().components->data();
// nb: note that this applies the Y-UP transform.
const std::array<double, 16> matrix_flat = {
+1 -1
View File
@@ -490,7 +490,7 @@ void SvgSerializer::setFile(IfcParse::IfcFile* f) {
auto item = mapping_->map(*product->get("ObjectPlacement"));
if (item) {
auto matrix = (ifcopenshell::geometry::taxonomy::matrix4*) item;
const double& Z = matrix->components(3, 2);
const double& Z = (*matrix->components)(3, 2);
setSectionHeight(Z + 1.);
Logger::Warning("No building storeys encountered, used for reference:", product);
return;
@@ -131,7 +131,7 @@ boost::optional<std::string> format_attribute(ifcopenshell::geometry::abstract_m
std::stringstream stream;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
const double trsf_value = matrix->components(j, i);
const double trsf_value = (*matrix->components)(j, i);
stream << trsf_value;
if (i < 3 && j < 3) {
stream << " ";