mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Merge remote-tracking branch 'origin/v0.6.0' into v0.7.0
# Conflicts: # .github/workflows/ci.yml # src/ifcparse/IfcParse.cpp
This commit is contained in:
@@ -552,13 +552,13 @@ void SvgSerializer::write(const IfcGeom::BRepElement* 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.)
|
||||
auto compound_unmirrored = make_transform_global.Shape();
|
||||
|
||||
if (is_section || is_elevation) {
|
||||
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.)
|
||||
auto compound_unmirrored = make_transform_global.Shape();
|
||||
|
||||
boost::optional<double> scale;
|
||||
boost::optional<std::pair<double, double>> size;
|
||||
|
||||
@@ -675,6 +675,10 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
|
||||
element_buffer_.push_back(data);
|
||||
}
|
||||
|
||||
// Augment bnd_ regardless of whether emitting storeys as we depend
|
||||
// on the global bounds also for the storey height annotations.
|
||||
BRepBndLib::Add(compound_unmirrored, bnd_);
|
||||
|
||||
if (emit_building_storeys_) {
|
||||
write(data);
|
||||
}
|
||||
@@ -705,6 +709,19 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
int infront_or_behind(const gp_Pln& pln, const gp_Pnt& p) {
|
||||
auto d = (p.XYZ() - pln.Location().XYZ()).Dot(pln.Axis().Direction().XYZ());
|
||||
int state;
|
||||
if (std::abs(d) < 1.e-5) {
|
||||
state = 0;
|
||||
} else {
|
||||
state = d < 0. ? -1 : 1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
void SvgSerializer::write(const geometry_data& data) {
|
||||
std::vector<section_data> section_heights_storage;
|
||||
const std::vector<section_data>* section_heights_used = §ion_heights_storage;
|
||||
@@ -736,10 +753,6 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (is_floor_plan_) {
|
||||
BRepBndLib::Add(compound_unmirrored, bnd_);
|
||||
}
|
||||
|
||||
// SVG has a coordinate system with the origin in the *upper*-left corner
|
||||
// therefore we mirror the shape along the XZ-plane.
|
||||
gp_Trsf trsf_mirror;
|
||||
@@ -902,13 +915,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
// See if any of the vertices is in the negative Z-axis of the projection plane
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
gp_Pnt p(xs[(i & 1) == 1], ys[(i & 2) == 2], zs[(i & 4) == 4]);
|
||||
auto d = (p.XYZ() - projection_plane.Location().XYZ()).Dot(projection_plane.Axis().Direction().XYZ());
|
||||
int state;
|
||||
if (std::abs(d) < 1.e-5) {
|
||||
state = 0;
|
||||
} else {
|
||||
state = d < 0. ? -1 : 1;
|
||||
}
|
||||
int state = infront_or_behind(projection_plane, p);
|
||||
if (state == -1) {
|
||||
any_in_front = true;
|
||||
} else if (state == +1) {
|
||||
@@ -947,13 +954,7 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
TopExp_Explorer exp2(face, TopAbs_VERTEX);
|
||||
for (; exp2.More(); exp2.Next()) {
|
||||
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(exp2.Current()));
|
||||
auto d = (p.XYZ() - projection_plane.Location().XYZ()).Dot(projection_plane.Axis().Direction().XYZ());
|
||||
int state;
|
||||
if (std::abs(d) < 1.e-5) {
|
||||
state = 0;
|
||||
} else {
|
||||
state = d < 0. ? -1 : 1;
|
||||
}
|
||||
int state = infront_or_behind(projection_plane, p);
|
||||
if (state == -1) {
|
||||
any_in_front_face = true;
|
||||
} else if (state == +1) {
|
||||
@@ -1064,15 +1065,17 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
object_type.erase(std::remove_if(object_type.begin(), object_type.end(), [](char c) { return !std::isalnum(c); }), object_type.end());
|
||||
}
|
||||
|
||||
auto z_local = gp::DZ().Transformed(data.trsf.Inverted());
|
||||
auto z_global = gp::DZ().Transformed(data.trsf);
|
||||
auto xyz_global = gp_Pnt().Transformed(data.trsf);
|
||||
int state = infront_or_behind(projection_plane, xyz_global);
|
||||
|
||||
if (data.product->declaration().is("IfcAnnotation") && // is an Annotation
|
||||
(proj.Magnitude() > 1.e-5) && // when projected onto the view has a length
|
||||
is_floor_plan_
|
||||
(is_floor_plan_
|
||||
? (zmin >= range.first && zmin < (range.second - 1.e-5)) // the Z-coords are within the range of the building storey,
|
||||
// this excludes the upper bound with a small tolerance
|
||||
: (projection_direction.Dot(z_local) < -0.99) // For elevations only include annotations that are "facing" the view direction
|
||||
)
|
||||
: (projection_direction.Dot(z_global) > 0.99 && state == -1) // For elevations only include annotations that are "facing" the view direction
|
||||
))
|
||||
{
|
||||
auto svg_name = data.svg_name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user