Normalize whitespaces in the codebase

This commit is contained in:
Andrej730
2026-08-19 18:16:59 +05:00
parent 030e6e5bb4
commit 104591a80b
117 changed files with 636 additions and 638 deletions
+11 -11
View File
@@ -70,12 +70,12 @@ void collada_serializer::collada_exporter::collada_geometries::write(
const std::vector<double>& uvs, const std::vector<std::string>& material_references)
{
openMesh(mesh_id);
// The normals vector can be empty for example when the WELD_VERTICES setting is used.
// IfcOpenShell does not provide them with multiple face normals collapsed into a single vertex.
const bool has_normals = !normals.empty();
const bool has_uvs = !uvs.empty();
addFloatSource(mesh_id, COLLADASW::LibraryGeometries::POSITIONS_SOURCE_ID_SUFFIX, positions);
if (has_normals) {
addFloatSource(mesh_id, COLLADASW::LibraryGeometries::NORMALS_SOURCE_ID_SUFFIX, normals);
@@ -88,7 +88,7 @@ void collada_serializer::collada_exporter::collada_geometries::write(
vertices.setId(mesh_id + COLLADASW::LibraryGeometries::VERTICES_ID_SUFFIX );
vertices.getInputList().push_back(COLLADASW::Input(COLLADASW::InputSemantic::POSITION, "#" + mesh_id + COLLADASW::LibraryGeometries::POSITIONS_SOURCE_ID_SUFFIX));
vertices.add();
std::vector<int>::const_iterator index_range_start = faces.begin();
std::vector<int>::const_iterator material_it = material_ids.begin();
int previous_material_id = -1;
@@ -185,7 +185,7 @@ void collada_serializer::collada_exporter::collada_scene::add(
openVisualScene(scene_id);
scene_opened = true;
}
COLLADASW::Node node(mSW);
node.setNodeId(node_id);
node.setNodeName(node_name);
@@ -195,7 +195,7 @@ void collada_serializer::collada_exporter::collada_scene::add(
// Note that this placement is absolute, ie it is multiplied with all parent placements.
auto transformation_towrite = transformation.data()->ccomponents();
// If this is not the first parent, get the relative placement
if (parentNodes.size() > 0)
{
@@ -294,9 +294,9 @@ void collada_serializer::collada_exporter::collada_scene::write() {
if (scene_opened) {
closeVisualScene();
closeLibrary();
COLLADASW::Scene scene (mSW, COLLADASW::URI ("#" + scene_id));
scene.add();
scene.add();
}
}
@@ -442,11 +442,11 @@ void collada_serializer::collada_exporter::endDocument() {
// only at this point all objects are written to the stream.
materials.write();
bool use_hierarchy = serializer->settings().get<ifcopenshell::geom::settings::UseElementHierarchy>().get();
std::set<std::string> geometries_written;
//if the setting USE_ELEMENT_HIERARCHY is in use, we sort the deferreds objects by their parents.
if (use_hierarchy) {
std::sort(deferreds.begin(), deferreds.end(), [](const auto& first, const auto& second) {
const auto& first_parents = first->parents();
@@ -461,7 +461,7 @@ void collada_serializer::collada_exporter::endDocument() {
: *first_parents[index] < *second_parents[index];
});
}
for (const auto& object_pointer : deferreds) {
const auto& object = *object_pointer;
std::string representation_id = "representation-" + object.geometry().id();
@@ -527,7 +527,7 @@ void collada_serializer::collada_exporter::endDocument() {
}
}
}
/// @todo redundant information using ID as both ID and Name, maybe omit Name or allow specifying what would be used as the name
scene.add(object_name, object_name, representation_id, material_references, object.transformation());
}
+16 -16
View File
@@ -93,7 +93,7 @@ int gltf_serializer::writeMaterial(const ifcopenshell::geom::taxonomy::style::pt
if (it != materials_.end()) {
return it->second;
}
int idx = json_["materials"].size();
materials_[style->name] = idx;
@@ -116,7 +116,7 @@ int gltf_serializer::writeMaterial(const ifcopenshell::geom::taxonomy::style::pt
json_["materials"].push_back({ {"name", style->name}, {"doubleSided", true}, {"pbrMetallicRoughness", {{"baseColorFactor", base}, {"metallicFactor", 0}, {"roughnessFactor", roughness}}}});
} else
json_["materials"].push_back({ {"name", style->name}, {"doubleSided", true}, {"pbrMetallicRoughness", {{"baseColorFactor", base}, {"metallicFactor", 0}}}});
if (style->transparency == style->transparency && style->transparency > 1.e-9) {
json_["materials"].back()["alphaMode"] = "BLEND";
}
@@ -212,7 +212,7 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
break;
}
auto mm = (*it)->transformation().data()->ccomponents();
if (!is_root) {
mm = (*jt)->transformation().data()->ccomponents().inverse() * mm;
@@ -238,9 +238,9 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
mm(0,3), mm(2,3), -mm(1,3), mm(3,3)
};
}
static const std::array<double, 16> identity_matrix = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
if (matrix_flat != identity_matrix) {
// glTF validator complains about identity matrices
parent_node["matrix"] = matrix_flat;
@@ -260,7 +260,7 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
}
}
}
json node;
{
std::array<double, 16> matrix_flat;
@@ -281,16 +281,16 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
m(0,3), m(2,3), -m(1,3), m(3,3)
};
}
static const std::array<double, 16> identity_matrix = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1};
if (matrix_flat != identity_matrix) {
// glTF validator complains about identity matrices
node["matrix"] = matrix_flat;
}
}
node["name"] = object_id(o);
int current_mesh_index;
// See if this mesh has already been processed
@@ -316,7 +316,7 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
json mesh;
mesh["name"] = o->geometry().id();
while (true) {
// In glTF we need to decompose a mesh into several primitives
// with a constant material. In the triangulations coming from
@@ -342,7 +342,7 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
});
json primitive = json::object();
primitive["indices"] = write_accessor<1U>(json_, tmp_fstream1_, idx_transformed.begin(), idx_transformed.end(), bufferViewId++);
auto vbegin = o->geometry().verts().begin();
@@ -354,12 +354,12 @@ void gltf_serializer::write(const ifcopenshell::geom::triangulation_element* o)
std::vector<float> nf(nbegin + idx_begin * 3, nbegin + idx_end * 3);
primitive["attributes"]["NORMAL"] = write_accessor<3U>(json_, tmp_fstream2_, nf.begin(), nf.end(), bufferViewId++);
}
if (*mid0 >= 0) {
primitive["material"] = writeMaterial(o->geometry().materials()[*mid0]);
}
primitive["mode"] = primitive_type;
mesh["primitives"].push_back(primitive);
if (mid1 == o->geometry().material_ids().end()) {
@@ -471,7 +471,7 @@ void gltf_serializer::finalize() {
json_["scenes"].push_back(scene_0);
//The generated glb file will contain the indices buffer followed by the vertices buffer.
//Therefore once we know the size of the indices buffer, we update our vertices buffer
//Therefore once we know the size of the indices buffer, we update our vertices buffer
//to have an offset equal to the size of the indices buffer.
for (auto &n : json_["bufferViews"]) {
if (n.contains("byteStride")) {
@@ -488,7 +488,7 @@ void gltf_serializer::finalize() {
const int GLB_JSON_HEADER = 8;
const int GLB_BINARY_CHUNK_HEADER = 8;
uint32_t header[] = { GLTF, 2U, GLB_FILE_HEADER + GLB_JSON_HEADER + json_length + padding_for(json_length) +
uint32_t header[] = { GLTF, 2U, GLB_FILE_HEADER + GLB_JSON_HEADER + json_length + padding_for(json_length) +
GLB_BINARY_CHUNK_HEADER + binary_length + padding_for(binary_length) };
fstream_.write((const char*)header, sizeof(header));
@@ -551,7 +551,7 @@ void gltf_serializer::setFile(ifcopenshell::file& f) {
express::base target_crs = coordop.as<express::entity>().get("TargetCRS");
auto name_attr = target_crs.as<express::entity>().get("Name");
if (coordop.declaration().is("IfcMapConversion")) {
if (!name_attr.isNull()) {
std::string epsg_code = name_attr;
crs_epsg = epsg_code;
@@ -66,4 +66,3 @@ const char* open_cascade_based_serializer::getSymbolForUnitMagnitude(float mag)
}
#endif
@@ -345,7 +345,7 @@ void POSTFIX_SCHEMA(json_serializer)::finalize() {
jprop["unit"] = std::distance(units.begin(), std::find(units.begin(), units.end(), unit));
}
}
return jprop;
};
@@ -358,7 +358,7 @@ void POSTFIX_SCHEMA(json_serializer)::finalize() {
"value": 12.5,
"valueType": "ElementQuantity",
"unit": 3
}
}
*/
if (auto qto = qto_.as<IfcSchema::IfcPhysicalQuantity>()) {
jprop["name"] = qto.Name();
@@ -37,11 +37,11 @@ namespace {
// TODO: Make this a member of xml_serializer?
std::map<std::string, std::string> POSTFIX_SCHEMA(argument_name_map);
// Format an IFC attribute and maybe returns as string. Only literal scalar
// Format an IFC attribute and maybe returns as string. Only literal scalar
// values are converted. Things like entity instances and lists are omitted.
std::optional<std::string> format_attribute(ifcopenshell::geom::abstract_mapping* mapping, ifcopenshell::attribute_value argument, ifcopenshell::argument_type argument_type, const std::string& argument_name) {
std::optional<std::string> value;
// Hard-code lat-lon as it represents an array
// of integers best emitted as a single decimal
if (argument_name == "IfcSite.RefLatitude" ||
@@ -109,7 +109,7 @@ std::optional<std::string> format_attribute(ifcopenshell::geom::abstract_mapping
} else if (auto placement = e.as<IfcSchema::IfcLocalPlacement>()) {
auto item = mapping->map(e);
auto matrix = ifcopenshell::geom::taxonomy::cast< ifcopenshell::geom::taxonomy::matrix4>(item);
std::stringstream stream;
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 4; ++j) {
@@ -139,7 +139,7 @@ ptree* format_entity_instance(ifcopenshell::logger& log, ifcopenshell::geom::abs
} catch (const std::exception&) {
log.error("SER", 9, "Expected " + boost::lexical_cast<std::string>(n) + " attributes for:", instance);
break;
}
}
auto argument = instance.get_attribute_value(i);
if (argument.isNull()) continue;
@@ -185,7 +185,7 @@ std::string qualify_unrooted_instance(const express::base& inst) {
return inst.declaration().name() + "_" + std::to_string(inst.id());
}
// A function to be called recursively. Template specialization is used
// A function to be called recursively. Template specialization is used
// to descend into decomposition, containment and property relationships.
template <typename A>
ptree* descend(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping* mapping, A instance, ptree& tree, express::base parent = express::base()) {
@@ -212,14 +212,14 @@ auto get_related(ifcopenshell::logger& log, T t, F f, G g) {
} else if constexpr (std::is_base_of_v<express::select, decltype(vs)>) {
if (auto vv = vs.concrete().template as<V>()) {
acc.push_back(vv);
}
}
} else {
for (auto& v : vs) {
if (auto vv = v.template as<V>()) {
acc.push_back(vv);
}
}
}
}
} catch (ifcopenshell::exception& e) {
log.error(e);
}
@@ -249,12 +249,12 @@ ptree* descend(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping*
descend(log, mapping, f, child, product);
}
}
if (auto structure = product.as<IfcSchema::IfcSpatialStructureElement>()) {
auto elements = get_related
<IfcSchema::IfcSpatialStructureElement, IfcSchema::IfcRelContainedInSpatialStructure, IfcSchema::IfcObjectDefinition>
(log, structure, &IfcSchema::IfcSpatialStructureElement::ContainsElements, &IfcSchema::IfcRelContainedInSpatialStructure::RelatedElements);
for (auto& el : elements) {
descend(log, mapping, el, child, product);
}
@@ -342,7 +342,7 @@ ptree* descend(ifcopenshell::logger& log, ifcopenshell::geom::abstract_mapping*
node.put("<xmlattr>.xlink:href", "#" + p.first);
format_entity_instance(log, mapping, p.second, node, child, true);
}
auto associations = product.HasAssociations();
for (auto& rel : associations) {
if (auto relmat = rel.as<IfcSchema::IfcRelAssociatesMaterial>()) {
@@ -652,7 +652,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
auto pschedules = file->instances_by_type<IfcSchema::IfcWorkSchedule>();
for (auto& schedule : pschedules) {
ptree* nschedule = format_entity_instance(log, mapping_, schedule, pwork_schedules);
if(nschedule) {
auto controls = schedule.Controls();
for(auto& control : controls) {
@@ -691,13 +691,13 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
}
}
work.add_child("plans", pwork_plans);
// Write all work calendars and values as XML nodes.
#ifdef SCHEMA_HAS_IfcWorkCalendar
auto pcalendars = file->instances_by_type<IfcSchema::IfcWorkCalendar>();
for (auto& calendar : pcalendars) {
ptree* ncalendar = format_entity_instance(log, mapping_, calendar, calendars);
if (ncalendar) {
auto working_times = calendar.WorkingTimes().value_or(std::vector<IfcSchema::IfcWorkTime>{});
for (auto& working_time : working_times)
@@ -707,7 +707,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
}
}
#endif
auto pconnections = file->instances_by_type<IfcSchema::IfcRelConnectsElements>();
for (auto& connection : pconnections) {
ptree* nconnection = format_entity_instance(log, mapping_, connection, connections);
@@ -717,7 +717,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
format_entity_instance(log, mapping_, connection.RelatedElement(), nrelatedElement, true);
format_entity_instance(log, mapping_, connection.RelatingElement(), nrelatingElement, true);
nconnection->add_child("RelatedElement", nrelatedElement);
nconnection->add_child("RelatingElement", nrelatingElement);
}
@@ -726,7 +726,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
auto type_objects = file->instances_by_type<IfcSchema::IfcTypeObject>();
for (auto& type_object : type_objects) {
ptree* node = descend(log, mapping_, type_object, types);
if (node && type_object.HasPropertySets()) {
auto property_sets = *type_object.HasPropertySets();
for (auto& pset : property_sets) {
@@ -774,11 +774,11 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
ptree node;
node.put("<xmlattr>.id", qualify_unrooted_instance(mat));
// @todo this does not handle IfcMaterialProfileSetUsage and IfcMaterialConstituentSet
if (mat.concrete().as<IfcSchema::IfcMaterialLayerSetUsage>() || mat.concrete().as<IfcSchema::IfcMaterialLayerSet>()) {
if (mat.concrete().as<IfcSchema::IfcMaterialLayerSetUsage>() || mat.concrete().as<IfcSchema::IfcMaterialLayerSet>()) {
IfcSchema::IfcMaterialLayerSet layerset = mat.concrete().as<IfcSchema::IfcMaterialLayerSet>();
if (!layerset) {
layerset = mat.concrete().as<IfcSchema::IfcMaterialLayerSetUsage>().ForLayerSet();
}
}
if (layerset.LayerSetName()) {
node.put("<xmlattr>.LayerSetName", *layerset.LayerSetName());
}
@@ -821,7 +821,7 @@ void POSTFIX_SCHEMA(xml_serializer)::finalize() {
#else
boost::property_tree::xml_writer_settings<char> settings('\t', 1);
#endif
std::ofstream f(ifcopenshell::path::from_utf8(xml_filename).c_str());
boost::property_tree::write_xml(f, root, settings);
}
+1 -1
View File
@@ -32,7 +32,7 @@
class step_serializer : public open_cascade_based_serializer
{
private:
STEPControl_Writer writer;
STEPControl_Writer writer;
public:
explicit step_serializer(const std::string& out_filename, const ifcopenshell::geom::settings& settings, ifcopenshell::logger* logger = nullptr)
: open_cascade_based_serializer(out_filename, settings, logger)
+37 -37
View File
@@ -392,7 +392,7 @@ void svg_serializer::write(path_object& p, const TopoDS_Shape& comp_or_wire, std
std::swap(p1, p2);
}
if (first) {
if (first_wire) {
@@ -599,7 +599,7 @@ namespace {
/*
// in v0.8 apparently we don't get a solid/shell anymore because
// we no longer use PrimAPI, but rather resolve the box to an
// explicit shell with 6 faces in the mapping, which - depending
// explicit shell with 6 faces in the mapping, which - depending
// on settings - may remain solely a compound of 6.
TopExp_Explorer exp(compound, TopAbs_SHELL);
@@ -736,9 +736,9 @@ void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) {
if (file) {
auto item = this->file->instance_by_id(x.ItemId());
curve_style_name = get_curve_style_name(item);
}
if (curve_style_name &&
}
if (curve_style_name &&
(boost::starts_with(*curve_style_name, "LINE_") ||
boost::starts_with(*curve_style_name, "DASH_")))
{
@@ -775,7 +775,7 @@ void svg_serializer::write(const ifcopenshell::geom::native_element* brep_obj) {
} else if (elevation_ref_guid_) {
is_elevation = *elevation_ref_guid_ == brep_obj->guid();
}
BRepBuilderAPI_Transform make_transform_global(compound_local, trsf, true);
make_transform_global.Build();
// (When determinant < 0, copy is implied and the input is not mutated.)
@@ -1153,7 +1153,7 @@ void svg_serializer::write(const geometry_data& data) {
#endif
// SVG has a coordinate system with the origin in the *upper*-left corner
// therefore we mirror the shape along the XZ-plane.
// therefore we mirror the shape along the XZ-plane.
gp_Trsf trsf_mirror;
if (!mirror_y_) {
trsf_mirror.SetMirror(gp_Ax2(gp::Origin(), gp::DY()));
@@ -1253,17 +1253,17 @@ void svg_serializer::write(const geometry_data& data) {
B.Add(annotation, BRepBuilderAPI_MakeEdge(p2, center).Edge());
}
}
}
}
}
bool emitted = false;
for (auto sit = section_heights_used->begin(); sit != section_heights_used->end(); ++sit) {
const auto& variant = *sit;
// Elev + offset
double cut_z = std::numeric_limits<double>::infinity();
// Elev .. Elev(next)
std::pair<double, double> range;
@@ -1331,7 +1331,7 @@ void svg_serializer::write(const geometry_data& data) {
// Exclude annotations, spaces and grids from HLR
if (any_in_front && !data.product.declaration().is("IfcAnnotation") && !data.product.declaration().is("IfcSpace") && !data.product.declaration().is("IfcGrid")) {
TopoDS_Shape* compound_to_hlr = &compound_to_use;
TopoDS_Shape subtracted_shape;
@@ -1350,7 +1350,7 @@ void svg_serializer::write(const geometry_data& data) {
bool should_cut = false;
TopExp_Explorer exp(compound_to_use, TopAbs_FACE);
for (; exp.More(); exp.Next()) {
const TopoDS_Face& face = TopoDS::Face(exp.Current());
BRepGProp_Face prop(face);
gp_Pnt _;
@@ -1424,7 +1424,7 @@ void svg_serializer::write(const geometry_data& data) {
}
try {
BRepBuilderAPI_MakeFace mf(new Geom_Plane(projection_plane), min_u - 1., max_u + 1., min_v - 1., max_v + 1., Precision::Confusion());
auto f = mf.Face();
gp_Pnt ref = projection_plane.Position().Location().XYZ() + projection_plane.Position().Direction().XYZ();
@@ -1466,12 +1466,12 @@ void svg_serializer::write(const geometry_data& data) {
TopExp::Vertices(edge, v0, v1);
auto pnt0 = BRep_Tool::Pnt(v0);
auto pnt1 = BRep_Tool::Pnt(v1);
// Exclude edges that have both vertices behind plane;
if (infront_or_behind(projection_plane, pnt0) != -1 && infront_or_behind(projection_plane, pnt1) != -1) {
continue;
}
double u0, u1;
auto crv = BRep_Tool::Curve(edge, u0, u1);
gp_Pnt _;
@@ -1487,7 +1487,7 @@ void svg_serializer::write(const geometry_data& data) {
}
auto faces = map.FindFromIndex(i);
// Add non-manifold edges
bool add = faces.Extent() != 2;
@@ -1524,12 +1524,12 @@ void svg_serializer::write(const geometry_data& data) {
// Profile edges are adges where the sign of the
// dot product Vdir . Fnormal flips sign.
add = std::signbit(dot0) != std::signbit(dot1);
}
}
}
if (add) {
BB.Add(profile_edges, edge);
}
}
}
}
}
@@ -1657,7 +1657,7 @@ void svg_serializer::write(const geometry_data& data) {
}
auto svg_name = data.svg_name;
path_object* po_ = nullptr;
auto po = [this, &po_, &pln, &storey, &drawing_name, &svg_name]() {
if (po_ == nullptr) {
@@ -1812,7 +1812,7 @@ void svg_serializer::write(const geometry_data& data) {
path.add("</text>");
po()->second.push_back(path);
}
} else if (object_type == "Symbol") {
TopExp_Explorer exp(subshape_to_use, TopAbs_WIRE, TopAbs_FACE);
@@ -1820,7 +1820,7 @@ void svg_serializer::write(const geometry_data& data) {
const auto& W = TopoDS::Wire(exp.Current());
write(*po(), W, *dash_it);
}
}
// We're finished processing IfcAnnotation instances
@@ -1882,7 +1882,7 @@ void svg_serializer::write(const geometry_data& data) {
BB.MakeCompound(wires_compound);
for (int i = 1; i <= wires->Length(); ++i) {
// @nb not const, because in case of storey annotations we might
// generate a new wire with fixed length
@@ -1905,19 +1905,19 @@ void svg_serializer::write(const geometry_data& data) {
}
}
if (file && data.product.declaration().is("IfcBuildingStorey") && storey_height_display_ != SH_NONE && wires->Length() == 1 && ifcopenshell::geom::util::count(wire, TopAbs_EDGE) == 1) {
std::string elev_str;
const double lu = file->get_unit("LENGTHUNIT").second;
auto a = data.product.as<express::entity>().get("Elevation");
if (!a.isNull()) {
double elev = a;
// @nb we don't actually factor in the length unit.
// elev *= lu;
if (almost(1.) == lu) {
// m
elev_str = boost::str(boost::format("%.3f") % elev);
@@ -2027,7 +2027,7 @@ void svg_serializer::write(const geometry_data& data) {
);
if (d > furthest_points_distance) {
// Sample some points on the line and assure it's inside.
bool all_inside = true;
for (int n = 5; n < 95; ++n) {
@@ -2132,7 +2132,7 @@ std::array<std::array<double, 3>, 3> svg_serializer::resize() {
double sc, cx, cy;
if (offset_2d_ && scale_) {
// offset_2d is the offset in plane u,v coordinates as we want to keep the
// offset_2d is the offset in plane u,v coordinates as we want to keep the
// plane coordinates used for HLR close to the model origin.
sc = (*scale_) * 1000;
cx = offset_2d_->first;
@@ -2351,7 +2351,7 @@ void svg_serializer::addTextAnnotations(const drawing_key& k) {
po = &start_path(meta.pln_3d, k.first, svg_name);
} else {
po = &start_path(meta.pln_3d, k.second, svg_name);
}
}
std::optional<double> font_size;
std::vector<std::string> tokens;
@@ -2366,7 +2366,7 @@ void svg_serializer::addTextAnnotations(const drawing_key& k) {
// @todo column or row?
double z_rotation = gp::DX().Transformed(trsf).AngleWithRef(
meta.pln_3d.Position().XDirection(),
meta.pln_3d.Position().Direction()
meta.pln_3d.Position().Direction()
);
z_rotation *= 180. / M_PI;
@@ -2496,7 +2496,7 @@ void svg_serializer::finalize() {
}
resetScale();
if (deferred_section_data_ && deferred_section_data_->size() && element_buffer_.size()) {
// Draw door arcs only on floor plans.
@@ -2526,7 +2526,7 @@ void svg_serializer::finalize() {
if (use_hlr) {
const auto& section = boost::get<vertical_section>(sd);
const auto& ax = section.plane.Position();
draw_hlr(ax, { express::base{}, drawing_name });
}
@@ -2622,7 +2622,7 @@ void svg_serializer::finalize() {
}
svg_file.stream << " </g>\n";
}
if (previous) {
svg_file.stream << " </g>\n";
}
@@ -2640,12 +2640,12 @@ void svg_serializer::doWriteHeader() {
svg_file.stream << " xmlns:ifc=\"http://www.ifcopenshell.org/ns\"";
}
if (scale_ && size_) {
svg_file.stream <<
svg_file.stream <<
" width=\"" << size_->first << "mm\""
" height=\"" << size_->second << "mm\"" <<
" viewBox=\"0 0 " << size_->first << " " << size_->second << "\"";
}
svg_file.stream << ">\n"
" <defs>\n"
" <marker id=\"arrowend\" markerWidth=\"10\" markerHeight=\"7\" refX=\"10\" refY=\"3.5\" orient=\"auto\">\n"
@@ -2883,7 +2883,7 @@ namespace {
template <typename T>
std::string array_to_string(const T& v) {
return "[" + std::accumulate(
v.begin() + 1, v.end(),
v.begin() + 1, v.end(),
array_to_string(v.front()),
[](const std::string& accum, decltype(*v.cbegin())& item) {
return accum + "," + array_to_string(item);
+10 -10
View File
@@ -328,7 +328,7 @@ namespace {
if (!fclass) {
fclass = new BRepTopAdaptor_FClass2d(face, 1.e-5);
}
// @todo unify with the 2d boolean algo
// @todo unify with the 2d boolean algo
gp_Pnt2d bottomright(topright.X(), bottomleft.Y());
gp_Pnt2d topleft(bottomleft.X(), topright.Y());
std::array<gp_Pnt2d const*, 4> loop{ {
@@ -450,7 +450,7 @@ namespace {
return false;
}
void add(const TopoDS_Shape& s, express::base product) {
if (!use_prefiltering_) {
items_.insert(items_.end(), {product, s});
@@ -499,7 +499,7 @@ namespace {
for (; exp.More(); exp.Next()) {
const auto& face = TopoDS::Face(exp.Current());
if (BRep_Tool::Surface(face)->DynamicType() == STANDARD_TYPE(Geom_Plane)) {
// find large faces orthogonal to view dir
BRepGProp_Face prop(face);
prop.Normal(0., 0., P, V);
@@ -541,7 +541,7 @@ namespace {
if (use_prefiltering_) {
logger_.notice("SER", 35, "Included " + std::to_string(n_included) + " elements out of " + std::to_string(items_.size()) + " after prefiltering");
}
hlr_calc vis(projector_);
if (segment_projection_) {
vis.set_product_shape(&items_);
@@ -571,10 +571,10 @@ protected:
std::optional<std::pair<double, double>> size_, offset_2d_;
std::optional<std::string> space_name_transform_;
#if OCC_VERSION_HEX >= 0x70300
#if OCC_VERSION_HEX >= 0x70300
std::optional<Bnd_OBB> view_box_3d_;
#endif
bool with_section_heights_from_storey_, print_space_names_, print_space_areas_;
storey_height_display_types storey_height_display_;
@@ -608,7 +608,7 @@ protected:
size_t xcoords_begin, ycoords_begin, radii_begin;
std::optional<std::string> section_ref_, elevation_ref_, elevation_ref_guid_;
std::list<geometry_data> element_buffer_;
hlr_engine* hlr;
@@ -699,12 +699,12 @@ public:
std::array<std::array<double, 3>, 3> resize();
void resetScale();
void setSectionRef(const std::optional<std::string>& s) {
section_ref_ = s;
void setSectionRef(const std::optional<std::string>& s) {
section_ref_ = s;
}
void setElevationRef(const std::optional<std::string>& s) {
elevation_ref_ = s;
elevation_ref_ = s;
elevation_ref_guid_ = std::nullopt;
}
+1 -1
View File
@@ -96,7 +96,7 @@ namespace {
}
void emit_line_component(
std::ostream& os,
std::ostream& os,
const std::vector<double>& vertices,
const std::vector<int>& component,
bool force_2d = false,
+7 -7
View File
@@ -114,7 +114,7 @@ std::vector<pxr::UsdShadeMaterial> usd_serializer::createMaterials(const std::ve
}
void usd_serializer::writeHeader() {
stage_->GetRootLayer()->SetComment("File generated by IfcOpenShell " + std::string(IFCOPENSHELL_VERSION));
stage_->GetRootLayer()->SetComment("File generated by IfcOpenShell " + std::string(IFCOPENSHELL_VERSION));
}
std::string usd_serializer::object_id_unique(const ifcopenshell::geom::element* o) {
@@ -147,10 +147,10 @@ T usd_serializer::writeNode(const ifcopenshell::geom::element* o, const ifcopens
written_.insert(o->id());
auto m = o->transformation().data()->ccomponents();
// store absolute matrix for calculating relative child matrices later on.
placements_[o->id()] = o->transformation().data();
bool is_root = false;
std::string prefix = "/";
if (settings_.get<ifcopenshell::geom::settings::UseElementHierarchy>().get() && p == nullptr && o->parents().empty()) {
@@ -168,7 +168,7 @@ T usd_serializer::writeNode(const ifcopenshell::geom::element* o, const ifcopens
std::ostringstream oss;
std::copy(names.begin(), names.end(), std::ostream_iterator<std::string>(oss, "/"));
prefix += oss.str();
// std::ostringstream pss;
// pss << "MATT" << std::endl << std::endl;
// pss << m << std::endl << std::endl << o->parents().back()->transformation().data()->ccomponents() << std::endl << std::endl;
@@ -180,12 +180,12 @@ T usd_serializer::writeNode(const ifcopenshell::geom::element* o, const ifcopens
}
auto el_path = prefix + object_id_unique(o);
paths_[o->id()] = el_path;
T t = T::Define(stage_, pxr::SdfPath(el_path));
if (is_root) {
stage_->SetDefaultPrim(t.GetPrim());
}
t.AddTransformOp().Set(pxr::GfMatrix4d(
m.data()[0], m.data()[1], m.data()[2], m.data()[3],
m.data()[4], m.data()[5], m.data()[6], m.data()[7],
@@ -207,7 +207,7 @@ void usd_serializer::write(const ifcopenshell::geom::triangulation_element* o) {
const auto verts = mesh.verts();
const auto faces = mesh.faces();
const auto material_ids = mesh.material_ids();
pxr::VtVec3fArray points;
for(std::size_t i = 0; i < verts.size(); i+=3) {
+1 -1
View File
@@ -63,7 +63,7 @@ namespace usd_utils {
for (std::size_t i = 0; i < vec.size(); ++i)
array[i] = vec[i];
return array;
}
}
}
class SERIALIZERS_API usd_serializer : public ifcopenshell::geom::write_only_geometry_serializer {
+2 -2
View File
@@ -101,7 +101,7 @@ void wavefront_obj_serializer::write(const ifcopenshell::geom::triangulation_ele
const double x = *(it++);
const double y = *(it++);
const double z = *(it++);
if (isyup) {
obj_stream.stream << "v " << x << " " << z << " " << -y << "\n";
} else {
@@ -128,7 +128,7 @@ void wavefront_obj_serializer::write(const ifcopenshell::geom::triangulation_ele
const bool has_uvs = !mesh.uvs().empty();
const bool has_normals = !mesh.normals().empty();
for ( std::vector<int>::const_iterator it = mesh.faces().begin(); it != mesh.faces().end(); ) {
const int material_id = *(material_it++);
if (material_id != previous_material_id) {
const ifcopenshell::geom::taxonomy::style::ptr material = mesh.materials()[material_id];