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

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

89 lines
3.7 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
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* inst) {
2024-04-18 21:15:40 +02:00
const bool items_to_include = !this->settings_.get<settings::OutputDimensionality>().get();
2022-06-14 15:02:54 +02:00
2023-03-21 20:15:01 +01:00
auto items = map_to_collection(this, inst->Items());
if (!items) {
2023-03-21 20:15:01 +01:00
return nullptr;
}
/*
// Don't blindly flatten, as we're culling away IfcMappedItem transformations
auto flat = flatten(items);
if (flat == nullptr) {
return nullptr;
}
*/
// @todo
// if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) {
2024-04-18 21:15:40 +02:00
auto filtered = filter_in_place(items, [&items_to_include](taxonomy::ptr i) {
auto is_curve = (i->kind() == taxonomy::EDGE || i->kind() == taxonomy::LOOP || i->kind() == taxonomy::PIECEWISE_FUNCTION);
if (is_curve && items_to_include == settings::SURFACES_AND_SOLIDS) {
return false;
} else if (!is_curve && items_to_include == settings::CURVES) {
return false;
} else {
return true;
}
2023-03-21 20:15:01 +01:00
});
if (filtered->children.empty()) {
return nullptr;
}
return filtered;
2023-03-21 20:15:01 +01:00
}
/*
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcRepresentation* l, ConversionResults& shapes) {
2023-03-21 20:15:01 +01:00
IfcSchema::IfcRepresentationItem::list::ptr items = inst->Items();
2022-06-14 15:02:54 +02:00
bool part_succes = false;
if ( items->size() ) {
for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) {
IfcSchema::IfcRepresentationptr representation_item = *it;
2022-06-14 15:02:54 +02:00
if ( shape_type(representation_item) == ST_SHAPELIST ) {
part_succes |= convert_shapes(*it, shapes);
} else {
TopoDS_Shape s;
if (convert_shape(representation_item, s)) {
if (s.ShapeType() == TopAbs_COMPOUND && TopoDS_Iterator(s).More() && TopoDS_Iterator(s).Value().ShapeType() == TopAbs_SOLID) {
2022-11-13 11:04:16 +01:00
TopoDS_Iterator topo_it(s);
for (; topo_it.More(); topo_it.Next()) {
2023-03-21 20:15:01 +01:00
shapes.push_back(ConversionResult(representation_item->data().id(), topo_it.Value(), get_style(representation_item)));
2022-06-14 15:02:54 +02:00
}
} else {
2023-03-21 20:15:01 +01:00
shapes.push_back(ConversionResult(representation_item->data().id(), s, get_style(representation_item)));
2022-06-14 15:02:54 +02:00
}
part_succes |= true;
}
}
}
}
return part_succes;
}
2023-03-21 20:15:01 +01:00
*/