/********************************************************************************
* *
* 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 . *
* *
********************************************************************************/
#include "mapping.h"
#define mapping POSTFIX_SCHEMA(mapping)
using namespace ifcopenshell::geometry;
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRectangularPyramid* inst) {
const double dx = inst->XLength() * length_unit_;
const double dy = inst->YLength() * length_unit_;
const double dz = inst->Height() * length_unit_;
auto solid = taxonomy::make();
auto shell = taxonomy::make();
solid->children.push_back(shell);
// Base
{
auto face = taxonomy::make();
auto loop = taxonomy::make();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array points{
taxonomy::make(0, 0, 0),
taxonomy::make(dx, 0, 0),
taxonomy::make(dx, dy, 0),
taxonomy::make(0, dy, 0)
};
loop->children.push_back(taxonomy::make(points[0], points[1]));
loop->children.push_back(taxonomy::make(points[1], points[2]));
loop->children.push_back(taxonomy::make(points[2], points[3]));
loop->children.push_back(taxonomy::make(points[3], points[0]));
}
// Lateral faces
{
auto face = taxonomy::make();
auto loop = taxonomy::make();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array points{
taxonomy::make(0, 0, 0),
taxonomy::make(0, dy, 0),
taxonomy::make(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(taxonomy::make(points[0], points[1]));
loop->children.push_back(taxonomy::make(points[1], points[2]));
loop->children.push_back(taxonomy::make(points[2], points[0]));
}
{
auto face = taxonomy::make();
auto loop = taxonomy::make();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array points{
taxonomy::make(0, dy, 0),
taxonomy::make(dx, dy, 0),
taxonomy::make(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(taxonomy::make(points[0], points[1]));
loop->children.push_back(taxonomy::make(points[1], points[2]));
loop->children.push_back(taxonomy::make(points[2], points[0]));
}
{
auto face = taxonomy::make();
auto loop = taxonomy::make();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array points{
taxonomy::make(dx, dy, 0),
taxonomy::make(dx, 0, 0),
taxonomy::make(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(taxonomy::make(points[0], points[1]));
loop->children.push_back(taxonomy::make(points[1], points[2]));
loop->children.push_back(taxonomy::make(points[2], points[0]));
}
{
auto face = taxonomy::make();
auto loop = taxonomy::make();
face->children.push_back(loop);
loop->external = true;
shell->children.push_back(face);
std::array points{
taxonomy::make(dx, 0, 0),
taxonomy::make(0, 0, 0),
taxonomy::make(0.5*dx, 0.5*dy, dz)
};
loop->children.push_back(taxonomy::make(points[0], points[1]));
loop->children.push_back(taxonomy::make(points[1], points[2]));
loop->children.push_back(taxonomy::make(points[2], points[0]));
}
return solid;
}