mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 09:22:41 +00:00
Last minute refactoring
This commit is contained in:
@@ -27,22 +27,22 @@
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
WaveFrontOBJSerializer::WaveFrontOBJSerializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geometry::Settings& geometry_settings, const ifcopenshell::geometry::SerializerSettings& settings, ::logger* logger)
|
||||
: WriteOnlyGeometrySerializer(geometry_settings, settings, logger)
|
||||
wavefront_obj_serializer::wavefront_obj_serializer(const stream_or_filename& obj_filename, const stream_or_filename& mtl_filename, const ifcopenshell::geom::settings& settings, ::logger* logger)
|
||||
: write_only_geometry_serializer(settings, logger)
|
||||
, obj_stream(obj_filename)
|
||||
, mtl_stream(mtl_filename)
|
||||
, vcount_total(1)
|
||||
, ncount_total(1)
|
||||
{
|
||||
obj_stream.stream << std::setprecision(settings.get<ifcopenshell::geometry::settings::FloatingPointDigits>().get());
|
||||
mtl_stream.stream << std::setprecision(settings.get<ifcopenshell::geometry::settings::FloatingPointDigits>().get());
|
||||
obj_stream.stream << std::setprecision(settings.get<ifcopenshell::geom::settings::FloatingPointDigits>().get());
|
||||
mtl_stream.stream << std::setprecision(settings.get<ifcopenshell::geom::settings::FloatingPointDigits>().get());
|
||||
}
|
||||
|
||||
bool WaveFrontOBJSerializer::ready() {
|
||||
bool wavefront_obj_serializer::ready() {
|
||||
return obj_stream.is_ready() && mtl_stream.is_ready();
|
||||
}
|
||||
|
||||
void WaveFrontOBJSerializer::writeHeader() {
|
||||
void wavefront_obj_serializer::writeHeader() {
|
||||
obj_stream.stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n";
|
||||
#ifdef WIN32
|
||||
const char dir_separator = '\\';
|
||||
@@ -60,7 +60,7 @@ void WaveFrontOBJSerializer::writeHeader() {
|
||||
mtl_stream.stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n";
|
||||
}
|
||||
|
||||
void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonomy::style::ptr styleptr)
|
||||
void wavefront_obj_serializer::writeMaterial(const ifcopenshell::geom::taxonomy::style::ptr styleptr)
|
||||
{
|
||||
auto& style = *styleptr;
|
||||
std::string material_name = style.name;
|
||||
@@ -86,13 +86,13 @@ void WaveFrontOBJSerializer::writeMaterial(const ifcopenshell::geometry::taxonom
|
||||
}
|
||||
}
|
||||
|
||||
void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
|
||||
void wavefront_obj_serializer::write(const ifcopenshell::geom::triangulation_element* o)
|
||||
{
|
||||
obj_stream.stream << "g " << object_id(o) << "\n";
|
||||
obj_stream.stream << "s 1" << "\n";
|
||||
const bool isyup = settings().get<ifcopenshell::geometry::settings::UseYUp>().get();
|
||||
const bool isyup = settings().get<ifcopenshell::geom::settings::UseYUp>().get();
|
||||
|
||||
const IfcGeom::Representation::Triangulation& mesh = o->geometry();
|
||||
const ifcopenshell::geom::Representation::triangulation& mesh = o->geometry();
|
||||
|
||||
size_t vcount = mesh.verts().size() / 3;
|
||||
size_t ncount = mesh.normals().size() / 3;
|
||||
@@ -131,7 +131,7 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
|
||||
|
||||
const int material_id = *(material_it++);
|
||||
if (material_id != previous_material_id) {
|
||||
const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id];
|
||||
const ifcopenshell::geom::taxonomy::style::ptr material = mesh.materials()[material_id];
|
||||
std::string material_name = material->name;
|
||||
ifcopenshell::sanitate_material_name(material_name);
|
||||
obj_stream.stream << "usemtl " << material_name << "\n";
|
||||
@@ -177,7 +177,7 @@ void WaveFrontOBJSerializer::write(const IfcGeom::TriangulationElement* o)
|
||||
const int material_id = *(material_it++);
|
||||
|
||||
if (material_id != previous_material_id) {
|
||||
const ifcopenshell::geometry::taxonomy::style::ptr material = mesh.materials()[material_id];
|
||||
const ifcopenshell::geom::taxonomy::style::ptr material = mesh.materials()[material_id];
|
||||
std::string material_name = material->name;
|
||||
ifcopenshell::sanitate_material_name(material_name);
|
||||
obj_stream.stream << "usemtl " << material_name << "\n";
|
||||
|
||||
Reference in New Issue
Block a user