From ce38854cff72a960efbb27fd0b3b3f9f9a1e7e94 Mon Sep 17 00:00:00 2001 From: Stinkfist0 Date: Thu, 10 Mar 2016 13:29:22 +0200 Subject: [PATCH] Add --no-normals --- src/ifcconvert/IfcConvert.cpp | 8 ++++---- src/ifcconvert/WavefrontObjSerializer.cpp | 5 ++++- src/ifcgeom/IfcGeomIteratorSettings.h | 2 +- src/ifcgeom/IfcGeomRepresentation.h | 7 ++++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 02328e02e8..9a19b4b0a9 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -176,12 +176,12 @@ int main(int argc, char** argv) { /*("names", boost::program_options::value< std::vector >(&names)->multitoken(), "A list of names or wildcard patterns that should be included in or excluded from the " "geometrical output, depending on whether --exclude or --include is specified. " - "The names are handled case-sensitively. Cannot be placed right before input file argument.") + "The names are handled case-sensitively. Cannot be placed right before input file argument.")*/ ("no-normals", "Disables computation of normals. Saves time and file size and is useful " "in instances where you're going to recompute normals for the exported " "model in other modelling application in any case.") - ("deflection-tolerance", boost::program_options::value(&deflection_tolerance), + /*("deflection-tolerance", boost::program_options::value(&deflection_tolerance), "Sets the deflection tolerance of the mesher, 1e-3 by default if not specified.")*/; std::string bounds; @@ -261,7 +261,7 @@ int main(int argc, char** argv) { const bool use_element_names = vmap.count("use-element-names") != 0; const bool use_element_guids = vmap.count("use-element-guids") != 0 ; const bool use_material_names = vmap.count("use-material-names") != 0; - //const bool no_normals = vmap.count("no-normals") != 0 ; + const bool no_normals = vmap.count("no-normals") != 0 ; //const bool center_model = vmap.count("center-model") != 0 ; //const bool generate_uvs = vmap.count("generate-uvs") != 0 ; //const bool deflection_tolerance_specified = vmap.count("deflection-tolerance") != 0 ; @@ -344,7 +344,7 @@ int main(int argc, char** argv) { settings.set(IfcGeom::IteratorSettings::USE_ELEMENT_NAMES, use_element_names); settings.set(IfcGeom::IteratorSettings::USE_ELEMENT_GUIDS, use_element_guids); settings.set(IfcGeom::IteratorSettings::USE_MATERIAL_NAMES, use_material_names); - //settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals); + settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals); //settings.set(IfcGeom::IteratorSettings::CENTER_MODEL, center_model); //settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs); //if (deflection_tolerance_specified) diff --git a/src/ifcconvert/WavefrontObjSerializer.cpp b/src/ifcconvert/WavefrontObjSerializer.cpp index 3874a85163..a51f36f98f 100644 --- a/src/ifcconvert/WavefrontObjSerializer.cpp +++ b/src/ifcconvert/WavefrontObjSerializer.cpp @@ -73,7 +73,10 @@ void WaveFrontOBJSerializer::writeMaterial(const IfcGeom::Material& style) void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o) { - obj_stream << "g " << (settings().get(IfcGeom::IteratorSettings::USE_ELEMENT_GUIDS) ? o->guid() : (settings().get(IfcGeom::IteratorSettings::USE_ELEMENT_NAMES) ? o->name() : o->unique_id())) << "\n"; + const std::string name = (settings().get(IfcGeom::IteratorSettings::USE_ELEMENT_GUIDS) + ? o->guid() : (settings().get(IfcGeom::IteratorSettings::USE_ELEMENT_NAMES) + ? o->name() : o->unique_id())); + obj_stream << "g " << name << "\n"; obj_stream << "s 1" << "\n"; const IfcGeom::Representation::Triangulation& mesh = o->geometry(); diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index 3f5afc2577..441741d9d8 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -70,7 +70,7 @@ namespace IfcGeom /// Disables computation of normals. Saves time and file size and is useful /// in instances where you're going to recompute normals for the exported /// model in other modelling application in any case. - //NO_NORMALS = 1 << 11, + NO_NORMALS = 1 << 11, /// Use entity names instead of unique IDs for naming elements. /// Applicable for OBJ, DAE, and SVG output. USE_ELEMENT_NAMES = 1 << 12, diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index 802444edf8..de46e1c93c 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -181,8 +181,9 @@ namespace IfcGeom { BRepGProp_Face prop(face); std::map dict; - // Vertex normals are only calculated if vertices are not welded - const bool calculate_normals = !settings().get(IteratorSettings::WELD_VERTICES); + // Vertex normals are only calculated if vertices are not welded and calculation is not disable explicitly. + const bool calculate_normals = !settings().get(IteratorSettings::WELD_VERTICES) && + !settings().get(IteratorSettings::NO_NORMALS); for( int i = 1; i <= nodes.Length(); ++ i ) { coords.push_back(nodes(i).Transformed(loc).XYZ()); @@ -309,4 +310,4 @@ namespace IfcGeom { } } -#endif \ No newline at end of file +#endif