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;
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
#include "../profile_helper.h"
|
|
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
|
2023-03-21 20:15:01 +01:00
|
|
|
const double dx = inst->XLength() * length_unit_;
|
|
|
|
|
const double dy = inst->YLength() * length_unit_;
|
|
|
|
|
const double dz = inst->Height() * length_unit_;
|
|
|
|
|
|
2023-07-27 16:42:06 +08:00
|
|
|
auto solid = taxonomy::make<taxonomy::solid>();
|
|
|
|
|
auto shell = taxonomy::make<taxonomy::shell>();
|
2023-03-21 20:15:01 +01:00
|
|
|
solid->children.push_back(shell);
|
|
|
|
|
|
|
|
|
|
// Base
|
|
|
|
|
{
|
2023-07-27 16:42:06 +08:00
|
|
|
auto face = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
shell->children.push_back(face);
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
std::vector<taxonomy::point3::ptr> points{
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
2024-09-01 15:14:22 +02:00
|
|
|
taxonomy::make<taxonomy::point3>(0, dy, 0),
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
2024-09-01 15:14:22 +02:00
|
|
|
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
2023-03-21 20:15:01 +01:00
|
|
|
};
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
points.push_back(points.front());
|
|
|
|
|
face->children.push_back(polygon_from_points(points));
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Lateral faces
|
|
|
|
|
{
|
2023-07-27 16:42:06 +08:00
|
|
|
auto face = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
shell->children.push_back(face);
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
std::vector<taxonomy::point3::ptr> points{
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0, dy, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
2023-03-21 20:15:01 +01:00
|
|
|
};
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
points.push_back(points.front());
|
|
|
|
|
face->children.push_back(polygon_from_points(points));
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-27 16:42:06 +08:00
|
|
|
auto face = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
shell->children.push_back(face);
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
std::vector<taxonomy::point3::ptr> points{
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(0, dy, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
2023-03-21 20:15:01 +01:00
|
|
|
};
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
points.push_back(points.front());
|
|
|
|
|
face->children.push_back(polygon_from_points(points));
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-27 16:42:06 +08:00
|
|
|
auto face = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
shell->children.push_back(face);
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
std::vector<taxonomy::point3::ptr> points{
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(dx, dy, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
2023-03-21 20:15:01 +01:00
|
|
|
};
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
points.push_back(points.front());
|
|
|
|
|
face->children.push_back(polygon_from_points(points));
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
2023-07-27 16:42:06 +08:00
|
|
|
auto face = taxonomy::make<taxonomy::face>();
|
2023-03-21 20:15:01 +01:00
|
|
|
shell->children.push_back(face);
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
std::vector<taxonomy::point3::ptr> points{
|
2023-07-27 16:42:06 +08:00
|
|
|
taxonomy::make<taxonomy::point3>(dx, 0, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0, 0, 0),
|
|
|
|
|
taxonomy::make<taxonomy::point3>(0.5*dx, 0.5*dy, dz)
|
2023-03-21 20:15:01 +01:00
|
|
|
};
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
points.push_back(points.front());
|
|
|
|
|
face->children.push_back(polygon_from_points(points));
|
2023-03-21 20:15:01 +01:00
|
|
|
}
|
|
|
|
|
|
2024-09-01 15:14:22 +02:00
|
|
|
solid->matrix = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
|
|
|
|
|
|
2023-03-21 20:15:01 +01:00
|
|
|
return solid;
|
2022-06-14 15:02:54 +02:00
|
|
|
}
|