diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 8f77d82ce3..b10229a00c 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -462,9 +462,20 @@ int main(int argc, char** argv) { serializer->writeHeader(); int old_progress = -1; + + if (center_model) { + double* offset = serializer->settings().offset; + gp_XYZ center = (context_iterator.bounds_min() + context_iterator.bounds_max()) * 0.5; + offset[0] = -center.X(); + offset[1] = -center.Y(); + offset[2] = -center.Z(); + std::stringstream msg; + msg << "Using model offset (" << offset[0] << "," << offset[1] << "," << offset[2] << ")"; + Logger::Message(Logger::LOG_NOTICE, msg.str()); + } + Logger::Status("Creating geometry..."); - std::vector* > geometries; // The functions IfcGeom::Iterator::get() and IfcGeom::Iterator::next() // wrap an iterator of all geometrical products in the Ifc file. // IfcGeom::Iterator::get() returns an IfcGeom::TriangulationElement or @@ -475,43 +486,24 @@ int main(int argc, char** argv) { // calling next() the entity to be returned has already been processed, a // true return value guarantees that a successfully processed product is // available. + size_t num_created = 0; + do { - IfcGeom::Element *geom_object = context_iterator.get(true); // true == take ownership, we will clean up ourselves - geometries.push_back(geom_object); + IfcGeom::Element *geom_object = context_iterator.get(); + if (is_tesselated) { + serializer->write(static_cast*>(geom_object)); + } else { + serializer->write(static_cast*>(geom_object)); + } const int progress = context_iterator.progress() / 2; if (old_progress != progress) Logger::ProgressBar(progress); old_progress = progress; - } while (context_iterator.next()); + } while (++num_created, context_iterator.next()); - Logger::Status("\rDone creating geometry (" + boost::lexical_cast(geometries.size()) + + Logger::Status("\rDone creating geometry (" + boost::lexical_cast(num_created) + " objects) "); - if (center_model) { - double* offset = serializer->settings().offset; - gp_XYZ center = (context_iterator.bounds_min() + context_iterator.bounds_max()) * 0.5; - offset[0] = -center.X(); - offset[1] = -center.Y(); - offset[2] = -center.Z(); - //printf("Bounds min. (%g, %g, %g)\n", context_iterator.bounds_min().X(), context_iterator.bounds_min().Y(), context_iterator.bounds_min().Z()); - //printf("Bounds max. (%g, %g, %g)\n", context_iterator.bounds_min().X(), context_iterator.bounds_min().X(), context_iterator.bounds_min().Z()); - printf("Using model offset (%g, %g, %g)\n", offset[0], offset[1], offset[2]); //TODO Logger::Message(Logger::LOG_NOTICE, ...); - } - - Logger::Status("Serializing geometry..."); - - foreach(const IfcGeom::Element* geom, geometries) { - if (is_tesselated) { - serializer->write(static_cast*>(geom)); - } else { - serializer->write(static_cast*>(geom)); - } - delete geom; - } - - serializer->finalize(); - - Logger::Status("\rDone serializing geometry "); - + serializer->finalize(); delete serializer; rename_file(output_temp_filename, output_filename); @@ -525,11 +517,23 @@ int main(int argc, char** argv) { write_log(); time(&end); + int seconds = (int)difftime(end, start); - if (seconds < 60) - printf("\nConversion took %d seconds\n", seconds); // TODO Logger::Message(Logger::LOG_NOTICE, ...); - else - printf("\nConversion took %d minute(s) %d seconds\n", seconds/60, seconds%60); // TODO Logger::Message(Logger::LOG_NOTICE, ...); + std::stringstream msg; + int minutes = seconds / 60; + seconds = seconds % 60; + msg << "\nConversion took"; + if (minutes > 0) { + msg << " " << minutes << " minute"; + if (minutes > 1) { + msg << "s"; + } + } + msg << " " << seconds << " second"; + if (seconds > 1) { + msg << "s"; + } + Logger::Status(msg.str()); return 0; } diff --git a/src/ifcgeom/IfcGeomIterator.h b/src/ifcgeom/IfcGeomIterator.h index cf07d9e603..b3867b7539 100644 --- a/src/ifcgeom/IfcGeomIterator.h +++ b/src/ifcgeom/IfcGeomIterator.h @@ -543,15 +543,14 @@ namespace IfcGeom { return create(); } - /// Gets or takes the representation of the current geometrical entity. - /// @param take_ownership Pass in 'true' as if wishing to maintain the element lifetime yourself. - Element

* get(bool take_ownership = false) + /// Gets the representation of the current geometrical entity. + Element

* get() { // TODO: Test settings and throw Element

* ret = 0; - if (current_triangulation) { ret = current_triangulation; if (take_ownership) current_triangulation = 0; } - else if (current_serialization) { ret = current_serialization; if (take_ownership) current_serialization = 0; } - else if (current_shape_model) { ret = current_shape_model; if (take_ownership) current_shape_model = 0; } + if (current_triangulation) { ret = current_triangulation; } + else if (current_serialization) { ret = current_serialization; } + else if (current_shape_model) { ret = current_shape_model; } return ret; }