mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
Merge branch 'master' into performance_improvements
# Conflicts: # src/ifcconvert/ColladaSerializer.cpp # src/ifcconvert/ColladaSerializer.h # src/ifcgeom/IfcGeomIterator.h # src/ifcgeom/IfcGeomRenderStyles.h
This commit is contained in:
@@ -86,6 +86,9 @@ namespace IfcGeom {
|
||||
template <typename P>
|
||||
class Iterator {
|
||||
private:
|
||||
Iterator(const Iterator&); // N/I
|
||||
Iterator& operator=(const Iterator&); // N/I
|
||||
|
||||
Kernel kernel;
|
||||
IteratorSettings settings;
|
||||
|
||||
@@ -110,6 +113,8 @@ namespace IfcGeom {
|
||||
std::string unit_name;
|
||||
// double?
|
||||
P unit_magnitude;
|
||||
gp_XYZ bounds_min_;
|
||||
gp_XYZ bounds_max_;
|
||||
|
||||
void initUnits() {
|
||||
IfcSchema::IfcProject::list::ptr projects = ifc_file->entitiesByType<IfcSchema::IfcProject>();
|
||||
@@ -121,6 +126,7 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
std::set<boost::regex> names_to_include_or_exclude; // regex containing a name or a wildcard expression
|
||||
std::set<IfcSchema::Type::Enum> entities_to_include_or_exclude;
|
||||
bool include_entities_in_processing;
|
||||
|
||||
@@ -148,7 +154,7 @@ namespace IfcGeom {
|
||||
} catch (...) {}
|
||||
|
||||
std::set<std::string> context_types;
|
||||
if (!settings.exclude_solids_and_surfaces()) {
|
||||
if (!settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES)) {
|
||||
// Really this should only be 'Model', as per
|
||||
// the standard 'Design' is deprecated. So,
|
||||
// just for backwards compatibility:
|
||||
@@ -157,7 +163,7 @@ namespace IfcGeom {
|
||||
// DDS likes to output 'model view'
|
||||
context_types.insert("model view");
|
||||
}
|
||||
if (settings.include_curves()) {
|
||||
if (settings.get(IteratorSettings::INCLUDE_CURVES)) {
|
||||
context_types.insert("plan");
|
||||
}
|
||||
|
||||
@@ -247,39 +253,74 @@ namespace IfcGeom {
|
||||
done = 0;
|
||||
total = representations->size();
|
||||
|
||||
for (int i = 1; i < 4; ++i) {
|
||||
bounds_min_.SetCoord(i, std::numeric_limits<double>::infinity());
|
||||
bounds_max_.SetCoord(i, -std::numeric_limits<double>::infinity());
|
||||
}
|
||||
|
||||
IfcSchema::IfcProduct::list::ptr products = ifc_file->entitiesByType<IfcSchema::IfcProduct>();
|
||||
for (IfcSchema::IfcProduct::list::it iter = products->begin(); iter != products->end(); ++iter) {
|
||||
IfcSchema::IfcProduct* product = *iter;
|
||||
if (product->hasObjectPlacement()) {
|
||||
gp_Trsf trsf; // Use a fresh trsf every time in order to prevent the result to be concatenated
|
||||
if (kernel.convert(product->ObjectPlacement(), trsf)) {
|
||||
const gp_XYZ& pos = trsf.TranslationPart();
|
||||
bounds_min_.SetX(std::min(bounds_min_.X(), pos.X()));
|
||||
bounds_min_.SetY(std::min(bounds_min_.Y(), pos.Y()));
|
||||
bounds_min_.SetZ(std::min(bounds_min_.Z(), pos.Z()));
|
||||
bounds_max_.SetX(std::max(bounds_max_.X(), pos.X()));
|
||||
bounds_max_.SetY(std::max(bounds_max_.Y(), pos.Y()));
|
||||
bounds_max_.SetZ(std::max(bounds_max_.Z(), pos.Z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int progress() {
|
||||
return 100 * done / total;
|
||||
}
|
||||
int progress() const { return 100 * done / total; }
|
||||
|
||||
const std::string& getUnitName() {
|
||||
return unit_name;
|
||||
}
|
||||
const std::string& getUnitName() const { return unit_name; }
|
||||
|
||||
const P getUnitMagnitude() {
|
||||
return unit_magnitude;
|
||||
}
|
||||
P getUnitMagnitude() const { return unit_magnitude; }
|
||||
|
||||
const std::string getLog() {
|
||||
return Logger::GetLog();
|
||||
}
|
||||
std::string getLog() const { return Logger::GetLog(); }
|
||||
|
||||
IfcParse::IfcFile* getFile() {
|
||||
return ifc_file;
|
||||
}
|
||||
IfcParse::IfcFile* getFile() const { return ifc_file; }
|
||||
|
||||
/// @note Entity names are handled case-insensitively.
|
||||
void includeEntities(const std::set<std::string>& entities) {
|
||||
populate_set(entities);
|
||||
include_entities_in_processing = true;
|
||||
}
|
||||
|
||||
/// @note Entity names are handled case-insensitively.
|
||||
void excludeEntities(const std::set<std::string>& entities) {
|
||||
populate_set(entities);
|
||||
include_entities_in_processing = false;
|
||||
}
|
||||
|
||||
/// @note Arbitrary names or wildcard expressions are handled case-sensitively.
|
||||
void include_entity_names(const std::vector<std::string>& names)
|
||||
{
|
||||
names_to_include_or_exclude.clear();
|
||||
foreach(const std::string &name, names)
|
||||
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
|
||||
include_entities_in_processing = true;
|
||||
}
|
||||
|
||||
/// @note Arbitrary names or wildcard expressions are handled case-sensitively.
|
||||
void exclude_entity_names(const std::vector<std::string>& names)
|
||||
{
|
||||
names_to_include_or_exclude.clear();
|
||||
foreach(const std::string &name, names)
|
||||
names_to_include_or_exclude.insert(IfcUtil::wildcard_string_to_regex(name));
|
||||
include_entities_in_processing = false;
|
||||
}
|
||||
|
||||
const gp_XYZ& bounds_min() const { return bounds_min_; }
|
||||
const gp_XYZ& bounds_max() const { return bounds_max_; }
|
||||
|
||||
private:
|
||||
// Move to the next IfcRepresentation
|
||||
void _nextShape() {
|
||||
@@ -340,7 +381,7 @@ namespace IfcGeom {
|
||||
}
|
||||
}
|
||||
|
||||
const bool process_maps_for_current_representation = (!has_openings || settings.disable_opening_subtractions());
|
||||
const bool process_maps_for_current_representation = (!has_openings || settings.get(IteratorSettings::DISABLE_OPENING_SUBTRACTIONS));
|
||||
bool representation_processed_as_mapped_item = false;
|
||||
|
||||
IfcSchema::IfcRepresentation* representation_mapped_to = 0;
|
||||
@@ -365,7 +406,7 @@ namespace IfcGeom {
|
||||
IfcSchema::IfcProduct::list::ptr products_of_prodrep = (*it)->entity->getInverse(IfcSchema::Type::IfcProduct, -1)->as<IfcSchema::IfcProduct>();
|
||||
products->push(products_of_prodrep);
|
||||
for (IfcSchema::IfcProduct::list::it jt = products_of_prodrep->begin(); jt != products_of_prodrep->end(); ++jt) {
|
||||
if (kernel.find_openings(*jt)->size() > 0 && !settings.disable_opening_subtractions()) {
|
||||
if (kernel.find_openings(*jt)->size() > 0 && !settings.get(IteratorSettings::DISABLE_OPENING_SUBTRACTIONS)) {
|
||||
all_product_without_openings = false;
|
||||
break;
|
||||
}
|
||||
@@ -418,7 +459,7 @@ namespace IfcGeom {
|
||||
for (IfcSchema::IfcProductRepresentation::list::it kt = prodreps->begin(); kt != prodreps->end(); ++kt) {
|
||||
IfcSchema::IfcProduct::list::ptr prods = (*kt)->entity->getInverse(IfcSchema::Type::IfcProduct, -1)->as<IfcSchema::IfcProduct>();
|
||||
for (IfcSchema::IfcProduct::list::it lt = prods->begin(); lt != prods->end(); ++lt) {
|
||||
if (kernel.find_openings(*lt)->size() == 0 || settings.disable_opening_subtractions()) {
|
||||
if (kernel.find_openings(*lt)->size() == 0 || settings.get(IteratorSettings::DISABLE_OPENING_SUBTRACTIONS)) {
|
||||
if (!unfiltered_products->contains(*lt)) {
|
||||
unfiltered_products->push(*lt);
|
||||
}
|
||||
@@ -440,6 +481,14 @@ namespace IfcGeom {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach(const boost::regex& r, names_to_include_or_exclude) {
|
||||
if (boost::regex_match((*jt)->Name(), r)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (found == include_entities_in_processing) {
|
||||
ifcproducts->push(*jt);
|
||||
}
|
||||
@@ -494,13 +543,17 @@ namespace IfcGeom {
|
||||
return create();
|
||||
}
|
||||
|
||||
Element<P>* get() {
|
||||
// TODO: Test settings and throw
|
||||
if (current_triangulation) return current_triangulation;
|
||||
else if (current_serialization) return current_serialization;
|
||||
else if (current_shape_model) return current_shape_model;
|
||||
else return 0;
|
||||
}
|
||||
/// Gets or takes the representation of the current geometrical entity.
|
||||
/// @param take_ownership Pass in 'true' as if wishing to maintain the element lifetime yourself.
|
||||
Element<P>* get(bool take_ownership = false)
|
||||
{
|
||||
// TODO: Test settings and throw
|
||||
Element<P>* ret = 0;
|
||||
if (current_triangulation) { ret = current_triangulation; if (take_ownership) current_triangulation = 0; }
|
||||
else if (current_serialization) { ret = current_serialization; if (take_ownership) current_serialization = 0; }
|
||||
else if (current_shape_model) { ret = current_shape_model; if (take_ownership) current_shape_model = 0; }
|
||||
return ret;
|
||||
}
|
||||
|
||||
const Element<P>* getObject(int id) {
|
||||
|
||||
@@ -549,15 +602,15 @@ namespace IfcGeom {
|
||||
} catch (...) {}
|
||||
|
||||
if (next_shape_model) {
|
||||
if (settings.use_brep_data()) {
|
||||
if (settings.get(IteratorSettings::USE_BREP_DATA)) {
|
||||
try {
|
||||
next_serialization = new SerializedElement<P>(*next_shape_model);
|
||||
} catch (...) {
|
||||
success = false;
|
||||
}
|
||||
} else if (!settings.disable_triangulation()) {
|
||||
} else if (!settings.get(IteratorSettings::DISABLE_TRIANGULATION)) {
|
||||
try {
|
||||
if (ifcproduct_iterator == ifcproducts->begin() || settings.use_world_coords()) {
|
||||
if (ifcproduct_iterator == ifcproducts->begin() || settings.get(IteratorSettings::USE_WORLD_COORDS)) {
|
||||
next_triangulation = new TriangulationElement<P>(*next_shape_model);
|
||||
} else {
|
||||
next_triangulation = new TriangulationElement<P>(*next_shape_model, current_triangulation->geometry_pointer());
|
||||
@@ -591,8 +644,9 @@ namespace IfcGeom {
|
||||
unit_name = "METER";
|
||||
unit_magnitude = 1.f;
|
||||
|
||||
kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.sew_shells() ? 1000 : -1);
|
||||
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.include_curves() ? (settings.exclude_solids_and_surfaces() ? -1. : 0.) : +1.));
|
||||
kernel.setValue(IfcGeom::Kernel::GV_MAX_FACES_TO_SEW, settings.get(IteratorSettings::SEW_SHELLS) ? 1000 : -1);
|
||||
kernel.setValue(IfcGeom::Kernel::GV_DIMENSIONALITY, (settings.get(IteratorSettings::INCLUDE_CURVES)
|
||||
? (settings.get(IteratorSettings::EXCLUDE_SOLIDS_AND_SURFACES) ? -1. : 0.) : +1.));
|
||||
}
|
||||
|
||||
bool owns_ifc_file;
|
||||
|
||||
Reference in New Issue
Block a user