2022-06-14 15:02:54 +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/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
2023-03-21 20:15:01 +01:00
|
|
|
#include "mapping.h"
|
|
|
|
|
#define mapping POSTFIX_SCHEMA(mapping)
|
|
|
|
|
using namespace ifcopenshell::geometry;
|
|
|
|
|
|
|
|
|
|
#include <boost/math/constants/constants.hpp>
|
|
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCircleProfileDef* inst) {
|
2023-03-21 20:15:01 +01:00
|
|
|
std::vector<double> radii = { inst->Radius() * length_unit_ };
|
|
|
|
|
|
|
|
|
|
if (inst->as<IfcSchema::IfcCircleHollowProfileDef>()) {
|
|
|
|
|
double t = inst->as<IfcSchema::IfcCircleHollowProfileDef>()->WallThickness() * length_unit_;
|
|
|
|
|
radii.push_back(radii.front() - t);
|
2022-06-14 15:02:54 +02:00
|
|
|
}
|
2023-03-21 20:15:01 +01:00
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
auto f = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
|
|
|
|
|
for (auto it = radii.begin(); it != radii.end(); ++it) {
|
|
|
|
|
const double r = *it;
|
|
|
|
|
const bool exterior = it == radii.begin();
|
|
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
auto c = taxonomy::make<taxonomy::circle>();
|
2023-03-21 20:15:01 +01:00
|
|
|
c->radius = r;
|
|
|
|
|
|
|
|
|
|
bool has_position = true;
|
2022-06-14 15:02:54 +02:00
|
|
|
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
|
2023-03-21 20:15:01 +01:00
|
|
|
has_position = !!inst->Position();
|
2022-06-14 15:02:54 +02:00
|
|
|
#endif
|
2023-03-21 20:15:01 +01:00
|
|
|
if (has_position) {
|
2023-07-27 16:42:06 +08:00
|
|
|
c->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
2024-06-18 12:31:04 +02:00
|
|
|
} else {
|
|
|
|
|
// matrix needs to be set on elementary curves
|
|
|
|
|
c->matrix = taxonomy::make<taxonomy::matrix4>();
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
2022-06-14 15:02:54 +02:00
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
auto e = taxonomy::make<taxonomy::edge>();
|
2023-03-21 20:15:01 +01:00
|
|
|
e->basis = c;
|
|
|
|
|
e->start = 0.;
|
|
|
|
|
e->end = 2 * boost::math::constants::pi<double>();
|
2022-06-14 15:02:54 +02:00
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
auto l = taxonomy::make<taxonomy::loop>();
|
2023-03-21 20:15:01 +01:00
|
|
|
l->children = { e };
|
|
|
|
|
l->external = exterior;
|
|
|
|
|
|
|
|
|
|
f->children.push_back(l);
|
|
|
|
|
}
|
2022-06-14 15:02:54 +02:00
|
|
|
|
2023-03-21 20:15:01 +01:00
|
|
|
return f;
|
2022-06-14 15:02:54 +02:00
|
|
|
}
|