mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Fix SVG exporer in 0.6 branch
This commit is contained in:
@@ -620,7 +620,7 @@ int main(int argc, char** argv) {
|
|||||||
SerializerSettings settings;
|
SerializerSettings settings;
|
||||||
/// @todo Make APPLY_DEFAULT_MATERIALS configurable? Quickly tested setting this to false and using obj exporter caused the program to crash and burn.
|
/// @todo Make APPLY_DEFAULT_MATERIALS configurable? Quickly tested setting this to false and using obj exporter caused the program to crash and burn.
|
||||||
settings.set(IfcGeom::IteratorSettings::APPLY_DEFAULT_MATERIALS, true);
|
settings.set(IfcGeom::IteratorSettings::APPLY_DEFAULT_MATERIALS, true);
|
||||||
settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, use_world_coords);
|
settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, use_world_coords || output_extension == SVG || output_extension == OBJ);
|
||||||
settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, weld_vertices);
|
settings.set(IfcGeom::IteratorSettings::WELD_VERTICES, weld_vertices);
|
||||||
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, convert_back_units);
|
settings.set(IfcGeom::IteratorSettings::CONVERT_BACK_UNITS, convert_back_units);
|
||||||
#if OCC_VERSION_HEX < 0x60900
|
#if OCC_VERSION_HEX < 0x60900
|
||||||
@@ -632,7 +632,7 @@ int main(int argc, char** argv) {
|
|||||||
settings.set(IfcGeom::IteratorSettings::APPLY_LAYERSETS, enable_layerset_slicing);
|
settings.set(IfcGeom::IteratorSettings::APPLY_LAYERSETS, enable_layerset_slicing);
|
||||||
settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals);
|
settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals);
|
||||||
settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs);
|
settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs);
|
||||||
settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy);
|
settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy || output_extension == SVG);
|
||||||
settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement);
|
settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement);
|
||||||
settings.set(IfcGeom::IteratorSettings::BUILDING_LOCAL_PLACEMENT, building_local_placement);
|
settings.set(IfcGeom::IteratorSettings::BUILDING_LOCAL_PLACEMENT, building_local_placement);
|
||||||
settings.set(IfcGeom::IteratorSettings::VALIDATE_QUANTITIES, validate);
|
settings.set(IfcGeom::IteratorSettings::VALIDATE_QUANTITIES, validate);
|
||||||
@@ -649,10 +649,6 @@ int main(int argc, char** argv) {
|
|||||||
if (output_extension == OBJ) {
|
if (output_extension == OBJ) {
|
||||||
// Do not use temp file for MTL as it's such a small file.
|
// Do not use temp file for MTL as it's such a small file.
|
||||||
const path_t mtl_filename = change_extension(output_filename, MTL);
|
const path_t mtl_filename = change_extension(output_filename, MTL);
|
||||||
if (!use_world_coords) {
|
|
||||||
Logger::Notice("Using world coords when writing WaveFront OBJ files");
|
|
||||||
settings.set(IfcGeom::IteratorSettings::USE_WORLD_COORDS, true);
|
|
||||||
}
|
|
||||||
serializer = boost::make_shared<WaveFrontOBJSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(mtl_filename), settings);
|
serializer = boost::make_shared<WaveFrontOBJSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(mtl_filename), settings);
|
||||||
#ifdef WITH_OPENCOLLADA
|
#ifdef WITH_OPENCOLLADA
|
||||||
} else if (output_extension == DAE) {
|
} else if (output_extension == DAE) {
|
||||||
|
|||||||
@@ -288,57 +288,25 @@ void SvgSerializer::write(const IfcGeom::BRepElement<real_t>* o)
|
|||||||
IfcUtil::IfcBaseEntity* storey = storey_;
|
IfcUtil::IfcBaseEntity* storey = storey_;
|
||||||
boost::optional<double> storey_elevation = boost::none;
|
boost::optional<double> storey_elevation = boost::none;
|
||||||
|
|
||||||
/*
|
for (const auto& p : o->parents()) {
|
||||||
|
if (p->type() == "IfcBuildingStorey") {
|
||||||
TODO: based on BRepElement::parent()
|
try {
|
||||||
|
|
||||||
IfcSchema::IfcObjectDefinition* obdef = static_cast<IfcSchema::IfcObjectDefinition*>(file->entityById(o->id()));
|
|
||||||
|
|
||||||
#ifndef USE_IFC4
|
|
||||||
typedef IfcSchema::IfcRelDecomposes decomposition_element;
|
|
||||||
#else
|
|
||||||
typedef IfcSchema::IfcRelAggregates decomposition_element;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (; storey == 0;) {
|
|
||||||
// Iterate over the decomposing element to find the parent IfcBuildingStorey
|
|
||||||
decomposition_element::list::ptr decomposes = obdef->Decomposes();
|
|
||||||
if (!decomposes->size()) {
|
|
||||||
if (obdef->declaration().is(IfcSchema::Type::IfcElement)) {
|
|
||||||
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr containment = ((IfcSchema::IfcElement*)obdef)->ContainedInStructure();
|
|
||||||
if (!containment->size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it it = containment->begin(); it != containment->end(); ++it) {
|
|
||||||
IfcSchema::IfcRelContainedInSpatialStructure* container = *it;
|
|
||||||
if (container->RelatingStructure() != obdef) {
|
|
||||||
obdef = container->RelatingStructure();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (decomposition_element::list::it it = decomposes->begin(); it != decomposes->end(); ++it) {
|
|
||||||
decomposition_element* decompose = *it;
|
|
||||||
if (decompose->RelatingObject() != obdef) {
|
|
||||||
obdef = decompose->RelatingObject();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (obdef->declaration().is(IfcSchema::Type::IfcBuildingStorey)) {
|
|
||||||
storey = static_cast<IfcSchema::IfcBuildingStorey*>(obdef);
|
|
||||||
if (storey->hasElevation()) {
|
|
||||||
const IfcGeom::ElementSettings& settings = o->geometry().settings();
|
const IfcGeom::ElementSettings& settings = o->geometry().settings();
|
||||||
storey_elevation = storey->Elevation() * settings.unit_magnitude();
|
double e = *p->product()->get("Elevation");
|
||||||
|
storey_elevation = e * settings.unit_magnitude();
|
||||||
|
} catch (...) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
storey = p->product();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// With a global section height, building storeys are not a requirement.
|
// With a global section height, building storeys are not a requirement.
|
||||||
if (!storey && !section_height) return;
|
if (!storey && !section_height) {
|
||||||
|
Logger::Warning("No global section height and unable to determine building storey for:", o->product());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
path_object& p = start_path(storey, nameElement(o));
|
path_object& p = start_path(storey, nameElement(o));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user