Files
IfcOpenShell/src/ifcgeom/mapping/IfcEllipse.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
2.5 KiB
C++
Raw Normal View History

2021-11-05 16:54:16 +01: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;
2015-06-02 15:56:09 +00:00
2023-03-21 20:15:01 +01:00
taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipse* inst) {
double x = inst->SemiAxis1() * length_unit_;
double y = inst->SemiAxis2() * length_unit_;
const double tol = conv_settings_.getValue(ConversionSettings::GV_PRECISION);
if (x < tol || y < tol) {
Logger::Message(Logger::LOG_ERROR, "Radius not greater than zero for:", inst);
return nullptr;
}
2023-03-21 20:15:01 +01:00
auto el = new taxonomy::ellipse;
el->matrix = as<taxonomy::matrix4>(map(inst->Position()));
// Open Cascade does not allow ellipses of which the minor radius
// is greater than the major radius. Hence, in this case, the
2023-03-21 20:15:01 +01:00
// ellipse is rotated. Note that special care is taken
// when creating a trimmed curve off of an ellipse like this.
2023-03-21 20:15:01 +01:00
if (y > x) {
el->matrix.components() <<
-el->matrix.ccomponents().col(1),
el->matrix.ccomponents().col(0),
el->matrix.ccomponents().col(2),
el->matrix.ccomponents().col(3);
std::swap(x, y);
}
2023-03-21 20:15:01 +01:00
el->radius = x;
el->radius2 = y;
return el;
}