2026-04-17 11:24:09 +02:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is distributed in the hope that it will be useful, *
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef IFCOPENSHELL_TREE_H
|
|
|
|
|
#define IFCOPENSHELL_TREE_H
|
|
|
|
|
|
2026-08-08 14:19:57 +02:00
|
|
|
#include "element.h"
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace ifcopenshell {
|
|
|
|
|
class file;
|
|
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
namespace geom {
|
|
|
|
|
class settings;
|
2026-04-17 11:24:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
namespace ifcopenshell::geom {
|
|
|
|
|
class iterator;
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
using tree_point = std::array<double, 3>;
|
|
|
|
|
using tree_box = std::array<tree_point, 2>;
|
|
|
|
|
|
|
|
|
|
struct IFC_GEOM_API ray_intersection_result {
|
|
|
|
|
double distance;
|
|
|
|
|
int style_index;
|
2026-08-08 07:42:45 +02:00
|
|
|
express::entity instance;
|
2026-04-17 11:24:09 +02:00
|
|
|
tree_point position;
|
|
|
|
|
tree_point normal;
|
|
|
|
|
double ray_distance;
|
|
|
|
|
double dot_product;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct IFC_GEOM_API clash {
|
|
|
|
|
int clash_type;
|
2026-08-08 07:42:45 +02:00
|
|
|
express::base a;
|
|
|
|
|
express::base b;
|
2026-04-17 11:24:09 +02:00
|
|
|
double distance;
|
|
|
|
|
tree_point p1;
|
|
|
|
|
tree_point p2;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class IFC_GEOM_API tree {
|
|
|
|
|
public:
|
|
|
|
|
tree();
|
|
|
|
|
explicit tree(const std::string& backend_id);
|
|
|
|
|
explicit tree(ifcopenshell::file& file);
|
2026-08-08 07:42:45 +02:00
|
|
|
tree(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings);
|
|
|
|
|
explicit tree(ifcopenshell::geom::iterator& iterator);
|
2026-04-17 11:24:09 +02:00
|
|
|
~tree();
|
|
|
|
|
|
|
|
|
|
tree(tree&& other) noexcept;
|
|
|
|
|
tree& operator=(tree&& other) noexcept;
|
|
|
|
|
|
|
|
|
|
tree(const tree& other) = delete;
|
|
|
|
|
tree& operator=(const tree& other) = delete;
|
|
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
void add_file(ifcopenshell::file& file, const ifcopenshell::geom::settings& settings);
|
|
|
|
|
void add_file(ifcopenshell::geom::iterator& iterator);
|
|
|
|
|
void add_element(ifcopenshell::geom::element* element);
|
2026-04-17 11:24:09 +02:00
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
std::vector<express::entity> select_box(const express::entity& entity, bool completely_within = false, double extend = -1.e-5) const;
|
|
|
|
|
std::vector<express::entity> select_box(const tree_point& point) const;
|
|
|
|
|
std::vector<express::entity> select_box(const tree_box& bounds, bool completely_within = false) const;
|
2026-04-17 11:24:09 +02:00
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
std::vector<express::entity> select(const express::entity& entity, bool completely_within = false, double extend = 0.0) const;
|
|
|
|
|
std::vector<express::entity> select(const ifcopenshell::geom::element* element, bool completely_within = false, double extend = -1.e-5) const;
|
|
|
|
|
std::vector<express::entity> select(const tree_point& point, double extend = 0.0) const;
|
2026-04-17 11:24:09 +02:00
|
|
|
std::vector<ray_intersection_result> select_ray(const tree_point& origin, const tree_point& direction, double length = 1000.) const;
|
|
|
|
|
|
2026-08-08 07:42:45 +02:00
|
|
|
std::vector<clash> clash_intersection_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, double tolerance = 0.002, bool check_all = true) const;
|
|
|
|
|
std::vector<clash> clash_collision_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, bool allow_touching = false) const;
|
|
|
|
|
std::vector<clash> clash_clearance_many(const std::vector<express::base>& set_a, const std::vector<express::base>& set_b, double clearance = 0.05, bool check_all = false) const;
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
const std::vector<double>& distances() const;
|
|
|
|
|
const std::vector<double>& protrusion_distances() const;
|
|
|
|
|
|
|
|
|
|
bool enable_face_styles() const;
|
|
|
|
|
void enable_face_styles(bool enable);
|
2026-08-08 07:42:45 +02:00
|
|
|
const std::vector<ifcopenshell::geom::taxonomy::style::ptr>& styles() const;
|
2026-04-17 11:24:09 +02:00
|
|
|
|
|
|
|
|
std::string uint8_to_b64(const std::vector<uint8_t>& uuids_array) const;
|
|
|
|
|
static bool is_manifold(const std::vector<int>& faces);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
class impl;
|
|
|
|
|
std::unique_ptr<impl> impl_;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|