mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 02:31:09 +00:00
Merge branch 'v0.6.0' of github.com:IfcOpenShell/IfcOpenShell into v0.6.0
This commit is contained in:
+43
-24
@@ -30,6 +30,7 @@
|
|||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
#include <BRepAlgoAPI_Common.hxx>
|
#include <BRepAlgoAPI_Common.hxx>
|
||||||
#include <BRepAlgoAPI_Cut.hxx>
|
#include <BRepAlgoAPI_Cut.hxx>
|
||||||
|
#include <BRepExtrema_DistShapeShape.hxx>
|
||||||
#include <BRepClass3d_SolidClassifier.hxx>
|
#include <BRepClass3d_SolidClassifier.hxx>
|
||||||
|
|
||||||
namespace IfcGeom {
|
namespace IfcGeom {
|
||||||
@@ -38,6 +39,30 @@ namespace IfcGeom {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class tree {
|
class tree {
|
||||||
|
|
||||||
|
bool test(const TopoDS_Shape& A, const TopoDS_Shape& B, bool completely_within, double extend) const {
|
||||||
|
if (extend > 0.) {
|
||||||
|
BRepExtrema_DistShapeShape dss(A, B);
|
||||||
|
if (dss.Perform() && dss.NbSolution() >= 1) {
|
||||||
|
return dss.Value() <= extend;
|
||||||
|
}
|
||||||
|
} else if (completely_within) {
|
||||||
|
BRepAlgoAPI_Cut cut(B, A);
|
||||||
|
if (cut.IsDone()) {
|
||||||
|
if (IfcGeom::Kernel::count(cut.Shape(), TopAbs_SHELL) == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BRepAlgoAPI_Common common(A, B);
|
||||||
|
if (common.IsDone()) {
|
||||||
|
if (IfcGeom::Kernel::count(common.Shape(), TopAbs_SHELL) > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void add(const T& t, const Bnd_Box& b) {
|
void add(const T& t, const Bnd_Box& b) {
|
||||||
@@ -104,8 +129,8 @@ namespace IfcGeom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<T> select(const T& t, bool completely_within = false) const {
|
std::vector<T> select(const T& t, bool completely_within = false, double extend = 0.0) const {
|
||||||
std::vector<T> ts = select_box(t);
|
std::vector<T> ts = select_box(t, completely_within, extend);
|
||||||
if (ts.empty()) {
|
if (ts.empty()) {
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
@@ -126,29 +151,18 @@ namespace IfcGeom {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (completely_within) {
|
if (test(A, B, completely_within, extend)) {
|
||||||
BRepAlgoAPI_Cut cut(B, A);
|
ts_filtered.push_back(*it);
|
||||||
if (cut.IsDone()) {
|
|
||||||
if (IfcGeom::Kernel::count(cut.Shape(), TopAbs_SHELL) == 0) {
|
|
||||||
ts_filtered.push_back(*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
BRepAlgoAPI_Common common(A, B);
|
|
||||||
if (common.IsDone()) {
|
|
||||||
if (IfcGeom::Kernel::count(common.Shape(), TopAbs_SHELL) > 0) {
|
|
||||||
ts_filtered.push_back(*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ts_filtered;
|
return ts_filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<T> select(const TopoDS_Shape& s) const {
|
std::vector<T> select(const TopoDS_Shape& s, bool completely_within = false, double extend = -1.e-5) const {
|
||||||
Bnd_Box bb;
|
Bnd_Box bb;
|
||||||
BRepBndLib::AddClose(s, bb);
|
BRepBndLib::AddClose(s, bb);
|
||||||
|
bb.SetGap(bb.GetGap() + extend);
|
||||||
|
|
||||||
std::vector<T> ts;
|
std::vector<T> ts;
|
||||||
|
|
||||||
@@ -156,7 +170,7 @@ namespace IfcGeom {
|
|||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
||||||
ts = select_box(bb);
|
ts = select_box(bb, completely_within);
|
||||||
|
|
||||||
if (ts.empty()) {
|
if (ts.empty()) {
|
||||||
return ts;
|
return ts;
|
||||||
@@ -173,11 +187,8 @@ namespace IfcGeom {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
BRepAlgoAPI_Common common(s, B);
|
if (test(s, B, completely_within, extend)) {
|
||||||
if (common.IsDone()) {
|
ts_filtered.push_back(*it);
|
||||||
if (IfcGeom::Kernel::count(common.Shape(), TopAbs_SHELL) > 0) {
|
|
||||||
ts_filtered.push_back(*it);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,6 +269,10 @@ namespace IfcGeom {
|
|||||||
add_file(f, settings);
|
add_file(f, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tree(IfcGeom::Iterator<double>& it) {
|
||||||
|
add_file(it);
|
||||||
|
}
|
||||||
|
|
||||||
void add_file(IfcParse::IfcFile& f, const IfcGeom::IteratorSettings& settings) {
|
void add_file(IfcParse::IfcFile& f, const IfcGeom::IteratorSettings& settings) {
|
||||||
IfcGeom::IteratorSettings settings_ = settings;
|
IfcGeom::IteratorSettings settings_ = settings;
|
||||||
settings_.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
|
settings_.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
|
||||||
@@ -266,10 +281,14 @@ namespace IfcGeom {
|
|||||||
|
|
||||||
IfcGeom::Iterator<double> it(settings_, &f);
|
IfcGeom::Iterator<double> it(settings_, &f);
|
||||||
|
|
||||||
|
add_file(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
void add_file(IfcGeom::Iterator<double>& it) {
|
||||||
if (it.initialize()) {
|
if (it.initialize()) {
|
||||||
do {
|
do {
|
||||||
IfcGeom::BRepElement<double>* elem = (IfcGeom::BRepElement<double>*)it.get();
|
IfcGeom::BRepElement<double>* elem = (IfcGeom::BRepElement<double>*)it.get();
|
||||||
add((IfcUtil::IfcBaseEntity*)f.instance_by_id(elem->id()), elem->geometry().as_compound());
|
add((IfcUtil::IfcBaseEntity*)it.file()->instance_by_id(elem->id()), elem->geometry().as_compound());
|
||||||
} while (it.next());
|
} while (it.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -574,6 +574,11 @@ void SvgSerializer::write(const IfcGeom::BRepElement<real_t>* brep_obj) {
|
|||||||
b->second[0] - b->first[0],
|
b->second[0] - b->first[0],
|
||||||
b->second[1] - b->first[1]
|
b->second[1] - b->first[1]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if OCC_VERSION_HEX >= 0x70300
|
||||||
|
view_box_3d_.emplace();
|
||||||
|
BRepBndLib::AddOBB(compound_unmirrored, *view_box_3d_, false, false, false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<string_property> props;
|
std::vector<string_property> props;
|
||||||
@@ -712,6 +717,17 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
// (When determinant < 0, copy is implied and the input is not mutated.)
|
// (When determinant < 0, copy is implied and the input is not mutated.)
|
||||||
auto compound_unmirrored = make_transform_global.Shape();
|
auto compound_unmirrored = make_transform_global.Shape();
|
||||||
|
|
||||||
|
#if OCC_VERSION_HEX >= 0x70300
|
||||||
|
if (view_box_3d_) {
|
||||||
|
Bnd_OBB obb;
|
||||||
|
BRepBndLib::AddOBB(compound_unmirrored, obb, false, false, false);
|
||||||
|
if (view_box_3d_->IsOut(obb)) {
|
||||||
|
Logger::Notice("Not including element due to viewBox", data.product);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (is_floor_plan_) {
|
if (is_floor_plan_) {
|
||||||
BRepBndLib::Add(compound_unmirrored, bnd_);
|
BRepBndLib::Add(compound_unmirrored, bnd_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,11 @@
|
|||||||
#include <HLRAlgo_Projector.hxx>
|
#include <HLRAlgo_Projector.hxx>
|
||||||
#include <gp_Pln.hxx>
|
#include <gp_Pln.hxx>
|
||||||
#include <Bnd_Box.hxx>
|
#include <Bnd_Box.hxx>
|
||||||
|
#include <Standard_Version.hxx>
|
||||||
|
|
||||||
|
#if OCC_VERSION_HEX >= 0x70300
|
||||||
|
#include <Bnd_OBB.hxx>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -141,6 +146,11 @@ protected:
|
|||||||
boost::optional<std::pair<double, double>> size_, offset_2d_;
|
boost::optional<std::pair<double, double>> size_, offset_2d_;
|
||||||
boost::optional<std::string> space_name_transform_;
|
boost::optional<std::string> space_name_transform_;
|
||||||
|
|
||||||
|
#if OCC_VERSION_HEX >= 0x70300
|
||||||
|
boost::optional<Bnd_OBB> view_box_3d_;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
bool with_section_heights_from_storey_, print_space_names_, print_space_areas_;
|
bool with_section_heights_from_storey_, print_space_names_, print_space_areas_;
|
||||||
storey_height_display_types storey_height_display_;
|
storey_height_display_types storey_height_display_;
|
||||||
bool draw_door_arcs_, is_floor_plan_;
|
bool draw_door_arcs_, is_floor_plan_;
|
||||||
|
|||||||
Reference in New Issue
Block a user