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

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

112 lines
4.1 KiB
C++
Raw Normal View History

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;
2022-06-14 15:02:54 +02:00
2023-03-21 20:15:01 +01:00
#include "../profile_helper.h"
2022-06-14 15:02:54 +02:00
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) {
2023-03-29 15:56:41 +02:00
const bool doFillet1 = !!inst->FilletRadius();
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
2023-03-29 15:56:41 +02:00
const bool doFlangeEdgeRadius = !!inst->FlangeEdgeRadius();
const bool hasSlope = !!inst->FlangeSlope();
#else
const bool doFlangeEdgeRadius = false;
#endif
2023-03-21 20:15:01 +01:00
const double x1 = inst->OverallWidth() / 2.0f * length_unit_;
const double y = inst->OverallDepth() / 2.0f * length_unit_;
const double d1 = inst->WebThickness() / 2.0f * length_unit_;
const double ft1 = inst->FlangeThickness() * length_unit_;
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
2023-03-29 15:56:41 +02:00
const double slope = inst->FlangeSlope().get_value_or(0.) * angle_unit_;
#endif
2022-06-14 15:02:54 +02:00
double dy = 0.;
2022-06-14 15:02:54 +02:00
double f1 = 0.;
double f2 = 0.;
double fe1 = 0.;
double fe2 = 0.;
double x2 = x1;
2023-01-08 22:28:58 +11:00
double ft2 = ft1;
2022-06-14 15:02:54 +02:00
if (doFillet1) {
2023-03-21 20:15:01 +01:00
f1 = *inst->FilletRadius() * length_unit_;
2022-06-14 15:02:54 +02:00
}
#ifdef SCHEMA_IfcIShapeProfileDef_HAS_FlangeEdgeRadius
if (doFlangeEdgeRadius) {
2023-03-29 15:56:41 +02:00
fe1 = *inst->FlangeEdgeRadius() * length_unit_;
}
if (hasSlope) {
2023-01-09 11:19:56 +11:00
dy = (x1 - d1) * tan(slope);
}
#endif
2022-06-14 15:02:54 +02:00
bool doFillet2 = doFillet1;
// @todo in IFC4 a IfcAsymmetricIShapeProfileDef is not a subtype anymore of IfcIShapeProfileDef!
2023-03-21 20:15:01 +01:00
if (inst->declaration().is(IfcSchema::IfcAsymmetricIShapeProfileDef::Class())) {
IfcSchema::IfcAsymmetricIShapeProfileDef* assym = (IfcSchema::IfcAsymmetricIShapeProfileDef*) inst;
x2 = assym->TopFlangeWidth() / 2. * length_unit_;
2022-06-14 15:02:54 +02:00
doFillet2 = !!assym->TopFlangeFilletRadius();
if (doFillet2) {
2023-03-21 20:15:01 +01:00
f2 = *assym->TopFlangeFilletRadius() * length_unit_;
2022-06-14 15:02:54 +02:00
}
if (assym->TopFlangeThickness()) {
ft2 = *assym->TopFlangeThickness() * length_unit_;
2022-06-14 15:02:54 +02:00
}
} else {
f2 = f1;
fe2 = fe1;
2023-03-21 20:15:01 +01:00
}
2023-11-15 10:32:20 +01:00
const double tol = settings_.get<settings::Precision>().get();
2022-06-14 15:02:54 +02:00
if (x1 < tol || x2 < tol || y < tol || d1 < tol || ft1 < tol || ft2 < tol) {
2026-06-10 09:14:22 +02:00
Logger::Message(Logger::LOG_NOTICE, "GEO", 264, "Skipping zero sized profile:", inst);
2023-03-21 20:15:01 +01:00
return nullptr;
2022-06-14 15:02:54 +02:00
}
taxonomy::matrix4::ptr m4;
2022-06-14 15:02:54 +02:00
bool has_position = true;
#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
if (has_position) {
m4 = taxonomy::cast<taxonomy::matrix4>(map(inst->Position()));
2022-06-14 15:02:54 +02:00
}
2023-03-21 20:15:01 +01:00
return profile_helper(m4, {
{{-x1,-y}},
{{x1,-y}},
{{x1,-y + ft1}, {fe1}},
{{d1,-y + ft1 + dy},{ f1} },
{{d1,y - ft2 - dy},{f2} },
{{x2,y - ft2}, {fe2}},
2023-03-21 20:15:01 +01:00
{{x2,y}},
{{-x2,y}},
{{-x2,y - ft2}, {fe2}},
{{-d1,y - ft2 - dy},{f2} },
{{-d1,-y + ft1 + dy},{f1} },
{{-x1,-y + ft1}, {fe1}}
2023-03-21 20:15:01 +01:00
});
2022-06-14 15:02:54 +02:00
}