mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 21:12:07 +00:00
Filter by context id, not using curves or solids. See #1674.
This commit is contained in:
committed by
Thomas Krijnen
parent
37bddc25ca
commit
514c5eb790
@@ -342,6 +342,11 @@ namespace IfcGeom {
|
|||||||
// WR31: The parent context shall not be another geometric representation sub context.
|
// WR31: The parent context shall not be another geometric representation sub context.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto context_id : settings.context_ids()) {
|
||||||
|
IfcSchema::IfcGeometricRepresentationContext* context = ifc_file->instance_by_id(context_id)->as<IfcSchema::IfcGeometricRepresentationContext>();
|
||||||
|
representations->push(context->RepresentationsInContext());
|
||||||
|
}
|
||||||
|
|
||||||
if (any_precision_encountered) {
|
if (any_precision_encountered) {
|
||||||
// Some arbitrary factor that has proven to work better for the models in the set of test files.
|
// Some arbitrary factor that has proven to work better for the models in the set of test files.
|
||||||
lowest_precision_encountered *= kernel.getValue(IfcGeom::Kernel::GV_PRECISION_FACTOR);
|
lowest_precision_encountered *= kernel.getValue(IfcGeom::Kernel::GV_PRECISION_FACTOR);
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ namespace IfcGeom
|
|||||||
double deflection_tolerance() const { return deflection_tolerance_; }
|
double deflection_tolerance() const { return deflection_tolerance_; }
|
||||||
double angular_tolerance() const { return angular_tolerance_; }
|
double angular_tolerance() const { return angular_tolerance_; }
|
||||||
double force_space_transparency() const { return force_space_transparency_; }
|
double force_space_transparency() const { return force_space_transparency_; }
|
||||||
|
std::set<int> context_ids() const { return context_ids_; }
|
||||||
|
|
||||||
void set_deflection_tolerance(double value)
|
void set_deflection_tolerance(double value)
|
||||||
{
|
{
|
||||||
@@ -130,7 +131,11 @@ namespace IfcGeom
|
|||||||
|
|
||||||
void force_space_transparency(double value) {
|
void force_space_transparency(double value) {
|
||||||
force_space_transparency_ = value;
|
force_space_transparency_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_context_ids(std::vector<int> value) {
|
||||||
|
context_ids_ = std::set<int>(value.begin(), value.end());
|
||||||
|
}
|
||||||
|
|
||||||
/// Get boolean value for a single settings or for a combination of settings.
|
/// Get boolean value for a single settings or for a combination of settings.
|
||||||
bool get(unsigned setting) const
|
bool get(unsigned setting) const
|
||||||
@@ -158,6 +163,7 @@ namespace IfcGeom
|
|||||||
protected:
|
protected:
|
||||||
unsigned settings_;
|
unsigned settings_;
|
||||||
double deflection_tolerance_, angular_tolerance_, force_space_transparency_;
|
double deflection_tolerance_, angular_tolerance_, force_space_transparency_;
|
||||||
|
std::set<int> context_ids_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IFC_GEOM_API ElementSettings : public IteratorSettings
|
class IFC_GEOM_API ElementSettings : public IteratorSettings
|
||||||
|
|||||||
@@ -887,8 +887,6 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
|
|||||||
// @nb the selection is partly duplicated from convert_curves() but it's needed as a
|
// @nb the selection is partly duplicated from convert_curves() but it's needed as a
|
||||||
// geometric set by it's static class definition does not inform us of the type of elements.
|
// geometric set by it's static class definition does not inform us of the type of elements.
|
||||||
// @todo handle this better so that this doesn't log an error.
|
// @todo handle this better so that this doesn't log an error.
|
||||||
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
|
|
||||||
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
|
|
||||||
|
|
||||||
aggregate_of_instance::ptr elements = l->Elements();
|
aggregate_of_instance::ptr elements = l->Elements();
|
||||||
if ( !elements->size() ) return false;
|
if ( !elements->size() ) return false;
|
||||||
@@ -902,11 +900,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcGeometricSet* l, IfcRepresenta
|
|||||||
if (!(convert_shapes(element, items) && flatten_shape_list(items, s, false))) {
|
if (!(convert_shapes(element, items) && flatten_shape_list(items, s, false))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (shape_type(element) == ST_SHAPE && include_solids_and_surfaces) {
|
} else if (shape_type(element) == ST_SHAPE) {
|
||||||
if (!convert_shape(element, s)) {
|
if (!convert_shape(element, s)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (shape_type(element) == ST_WIRE && include_curves) {
|
} else if (shape_type(element) == ST_WIRE) {
|
||||||
TopoDS_Wire w;
|
TopoDS_Wire w;
|
||||||
if (!convert_wire(element, w)) {
|
if (!convert_wire(element, w)) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -54,34 +54,30 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r)
|
|||||||
const unsigned int id = l->data().id();
|
const unsigned int id = l->data().id();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
bool ignored = false;
|
|
||||||
|
|
||||||
#ifndef NO_CACHE
|
#ifndef NO_CACHE
|
||||||
std::map<int,TopoDS_Shape>::const_iterator it = cache.Shape.find(id);
|
std::map<int,TopoDS_Shape>::const_iterator it = cache.Shape.find(id);
|
||||||
if ( it != cache.Shape.end() ) { r = it->second; return true; }
|
if ( it != cache.Shape.end() ) { r = it->second; return true; }
|
||||||
#endif
|
#endif
|
||||||
const bool include_curves = getValue(GV_DIMENSIONALITY) != +1;
|
|
||||||
const bool include_solids_and_surfaces = getValue(GV_DIMENSIONALITY) != -1;
|
|
||||||
|
|
||||||
IfcGeom::ShapeType st = shape_type(l);
|
IfcGeom::ShapeType st = shape_type(l);
|
||||||
ignored = (!include_solids_and_surfaces && (st == ST_SHAPE || st == ST_FACE)) || (!include_curves && (st == ST_WIRE || st == ST_CURVE));
|
|
||||||
if (st == ST_SHAPELIST) {
|
if (st == ST_SHAPELIST) {
|
||||||
processed = true;
|
processed = true;
|
||||||
IfcRepresentationShapeItems items;
|
IfcRepresentationShapeItems items;
|
||||||
success = convert_shapes(l, items) && flatten_shape_list(items, r, false);
|
success = convert_shapes(l, items) && flatten_shape_list(items, r, false);
|
||||||
} else if (st == ST_SHAPE && include_solids_and_surfaces) {
|
} else if (st == ST_SHAPE) {
|
||||||
#include "IfcRegisterConvertShape.h"
|
#include "IfcRegisterConvertShape.h"
|
||||||
} else if (st == ST_FACE && include_solids_and_surfaces) {
|
} else if (st == ST_FACE) {
|
||||||
processed = true;
|
processed = true;
|
||||||
success = convert_face(l, r);
|
success = convert_face(l, r);
|
||||||
} else if (st == ST_WIRE && include_curves) {
|
} else if (st == ST_WIRE) {
|
||||||
processed = true;
|
processed = true;
|
||||||
TopoDS_Wire w;
|
TopoDS_Wire w;
|
||||||
success = convert_wire(l, w);
|
success = convert_wire(l, w);
|
||||||
if (success) {
|
if (success) {
|
||||||
r = w;
|
r = w;
|
||||||
}
|
}
|
||||||
} else if (st == ST_CURVE && include_curves) {
|
} else if (st == ST_CURVE) {
|
||||||
processed = true;
|
processed = true;
|
||||||
Handle(Geom_Curve) crv;
|
Handle(Geom_Curve) crv;
|
||||||
TopoDS_Wire w;
|
TopoDS_Wire w;
|
||||||
@@ -102,7 +98,7 @@ bool IfcGeom::Kernel::convert_shape(const IfcBaseInterface* l, TopoDS_Shape& r)
|
|||||||
BRepCheck_Analyzer ana(r);
|
BRepCheck_Analyzer ana(r);
|
||||||
Logger::Notice("Valid: " + std::to_string(ana.IsValid()), l);
|
Logger::Notice("Valid: " + std::to_string(ana.IsValid()), l);
|
||||||
}
|
}
|
||||||
} else if (!ignored) {
|
} else {
|
||||||
const char* const msg = processed
|
const char* const msg = processed
|
||||||
? "Failed to convert:"
|
? "Failed to convert:"
|
||||||
: "No operation defined for:";
|
: "No operation defined for:";
|
||||||
@@ -131,4 +127,4 @@ bool IfcGeom::Kernel::convert_curve(const IfcBaseInterface* l, Handle(Geom_Curve
|
|||||||
#include "IfcRegisterConvertCurve.h"
|
#include "IfcRegisterConvertCurve.h"
|
||||||
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
Logger::Message(Logger::LOG_ERROR,"No operation defined for:",l);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user