2025-09-26 14:24:49 +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/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
#ifndef ABSTRACT_MAPPING_H
|
|
|
|
|
#define ABSTRACT_MAPPING_H
|
|
|
|
|
|
2026-01-04 10:40:02 +01:00
|
|
|
#include "../ifcparse/express.h"
|
2019-08-04 09:36:31 +02:00
|
|
|
#include "../ifcgeom/taxonomy.h"
|
2023-03-21 20:15:01 +01:00
|
|
|
#include "../ifcgeom/ConversionSettings.h"
|
2026-04-14 13:50:23 +02:00
|
|
|
#include "../plugin/plugin.h"
|
2019-08-16 17:40:13 +02:00
|
|
|
|
|
|
|
|
#include <boost/function.hpp>
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2023-03-21 20:15:01 +01:00
|
|
|
#include <tuple>
|
2019-08-04 09:36:31 +02:00
|
|
|
|
|
|
|
|
namespace ifcopenshell {
|
|
|
|
|
|
|
|
|
|
namespace geometry {
|
2019-08-16 17:40:13 +02:00
|
|
|
|
2025-09-26 14:24:49 +02:00
|
|
|
struct IFC_GEOM_API geometry_conversion_task {
|
2019-08-16 17:40:13 +02:00
|
|
|
int index;
|
2026-01-04 10:40:02 +01:00
|
|
|
express::Base representation;
|
|
|
|
|
std::vector<express::Base> products;
|
2019-08-16 17:40:13 +02:00
|
|
|
};
|
|
|
|
|
|
2026-01-04 10:40:02 +01:00
|
|
|
/// The filter function (free or member function) or function object (use boost::ref() to reference to it)
|
|
|
|
|
/// should return true if the geometry for the product is wanted to be included in the output.
|
|
|
|
|
/// http://www.boost.org/doc/libs/1_62_0/doc/html/function/tutorial.html
|
|
|
|
|
typedef boost::function<bool(const express::Base&)> filter_t;
|
2019-08-04 09:36:31 +02:00
|
|
|
|
2026-06-10 18:30:54 +02:00
|
|
|
class IFC_GEOM_API abstract_mapping {
|
2019-10-06 19:03:31 +02:00
|
|
|
protected:
|
2023-11-15 10:32:20 +01:00
|
|
|
Settings settings_;
|
2026-07-09 13:30:48 +02:00
|
|
|
::logger& logger_;
|
2024-06-11 11:20:40 +02:00
|
|
|
|
|
|
|
|
bool use_caching_ = true;
|
2024-08-23 20:29:07 +02:00
|
|
|
|
2019-08-04 09:36:31 +02:00
|
|
|
public:
|
2026-07-09 13:30:48 +02:00
|
|
|
abstract_mapping(Settings& s, ::logger& logger = ::logger::root()) : settings_(s), logger_(logger) {}
|
2024-08-23 20:29:07 +02:00
|
|
|
virtual ~abstract_mapping() {}
|
2019-10-06 19:03:31 +02:00
|
|
|
|
2026-01-04 10:40:02 +01:00
|
|
|
virtual ifcopenshell::geometry::taxonomy::ptr map(const express::Base&) = 0;
|
|
|
|
|
virtual void get_representations(std::vector<geometry_conversion_task>& tasks, std::vector<filter_t>& filters) = 0;
|
|
|
|
|
virtual express::Base get_decomposing_entity(const express::Base& product, bool include_openings = true) = 0;
|
|
|
|
|
virtual std::map<std::string, express::Base> get_layers(const express::Base&) = 0;
|
|
|
|
|
virtual std::vector<express::Base> find_openings(const express::Base&) = 0;
|
2023-03-21 20:15:01 +01:00
|
|
|
virtual void initialize_settings() = 0;
|
2026-01-04 10:40:02 +01:00
|
|
|
virtual bool get_layerset_information(const express::Base&, layerset_information&, int&) = 0;
|
|
|
|
|
virtual bool get_wall_neighbours(const express::Base&, std::vector<endpoint_connection>&) = 0;
|
|
|
|
|
virtual const express::Base get_product_type(const express::Base&) = 0;
|
|
|
|
|
virtual const express::Base get_single_material_association(const express::Base&) = 0;
|
2023-03-21 20:15:01 +01:00
|
|
|
virtual double get_length_unit() const = 0;
|
2025-03-20 13:57:30 +01:00
|
|
|
virtual const std::string& get_length_unit_name() const = 0;
|
2026-01-04 10:40:02 +01:00
|
|
|
virtual express::Base representation_of(const express::Base& product) = 0;
|
2023-03-21 20:15:01 +01:00
|
|
|
|
2023-11-15 10:32:20 +01:00
|
|
|
const Settings& settings() const { return settings_; }
|
2024-04-29 21:03:33 +02:00
|
|
|
Settings& settings() { return settings_; }
|
2026-07-09 13:30:48 +02:00
|
|
|
::logger& logger() const { return logger_; }
|
2024-06-11 11:20:40 +02:00
|
|
|
|
|
|
|
|
bool use_caching() const { return use_caching_; }
|
|
|
|
|
bool& use_caching() { return use_caching_; }
|
2019-08-04 09:36:31 +02:00
|
|
|
};
|
2019-08-16 17:40:13 +02:00
|
|
|
|
|
|
|
|
namespace impl {
|
2026-07-09 13:30:48 +02:00
|
|
|
typedef boost::function3<abstract_mapping*, ifcopenshell::file*, Settings&, ::logger&> mapping_fn;
|
2019-08-16 17:40:13 +02:00
|
|
|
|
2026-04-14 13:50:23 +02:00
|
|
|
class IFC_GEOM_API mapping_registry {
|
|
|
|
|
public:
|
2026-04-17 11:24:09 +02:00
|
|
|
void bind(const std::string& schema_name, mapping_fn fn, const ifcopenshell::plugin::module& module = ifcopenshell::plugin::module());
|
2026-07-09 13:30:48 +02:00
|
|
|
abstract_mapping* construct(ifcopenshell::file* file, Settings& settings, ::logger& logger = ::logger::root());
|
2026-04-14 13:50:23 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct entry {
|
|
|
|
|
mapping_fn fn_;
|
2026-04-17 11:24:09 +02:00
|
|
|
ifcopenshell::plugin::module module_;
|
2026-04-14 13:50:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::map<std::string, entry> entries_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
IFC_GEOM_API mapping_registry& mapping_registry_instance();
|
|
|
|
|
|
|
|
|
|
class IFC_GEOM_API MappingFactoryImplementation {
|
2019-08-16 17:40:13 +02:00
|
|
|
public:
|
|
|
|
|
MappingFactoryImplementation();
|
|
|
|
|
void bind(const std::string& schema_name, mapping_fn);
|
2026-07-09 13:30:48 +02:00
|
|
|
abstract_mapping* construct(ifcopenshell::file*, Settings&, ::logger& logger = ::logger::root());
|
2019-08-16 17:40:13 +02:00
|
|
|
};
|
|
|
|
|
|
2025-09-26 14:24:49 +02:00
|
|
|
IFC_GEOM_API MappingFactoryImplementation& mapping_implementations();
|
2019-08-16 17:40:13 +02:00
|
|
|
}
|
2019-08-04 09:36:31 +02:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-16 17:40:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|