Compare commits

...

2 Commits

Author SHA1 Message Date
Thomas Krijnen 5cd799d4d1 delete obsolete files 2025-02-02 09:00:49 +01:00
Thomas Krijnen 7e4a7e093d Virtual inheritance configurable at codegen time 2025-01-30 13:11:15 +01:00
11 changed files with 910 additions and 1127 deletions
-1
View File
@@ -28,7 +28,6 @@
#include "../ifcparse/IfcLogger.h"
#include "../ifcgeom/IfcGeomRepresentation.h"
#include "../ifcgeom/IteratorSettings.h"
#include "../ifcgeom/ifc_geom_api.h"
namespace IfcGeom {
-15
View File
@@ -1,15 +0,0 @@
#include "IteratorSettings.h"
#include "../ifcparse/IfcLogger.h"
/*
void IfcGeom::IteratorSettings::set_deflection_tolerance(double value)
{
deflection_tolerance_ = value;
if (deflection_tolerance_ <= 1e-6) {
Logger::Message(Logger::LOG_WARNING, "Deflection tolerance cannot be set to <= 1e-6; using the default value 1e-3");
deflection_tolerance_ = 1e-3;
}
}
*/
-1
View File
@@ -61,7 +61,6 @@
#include "../ifcparse/IfcFile.h"
#include "../ifcgeom/IfcGeomElement.h"
#include "../ifcgeom/IteratorSettings.h"
#include "../ifcgeom/ConversionResult.h"
#include "../ifcgeom/IfcGeomFilter.h"
#include "../ifcgeom/taxonomy.h"
-212
View File
@@ -1,212 +0,0 @@
/********************************************************************************
* *
* 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/>. *
* *
********************************************************************************/
#ifndef IFCGEOMITERATORSETTINGS_H
#define IFCGEOMITERATORSETTINGS_H
/*
#include "ifc_geom_api.h"
#include "../ifcparse/IfcException.h"
#include "../ifcparse/IfcBaseClass.h"
#include <set>
#include <array>
namespace IfcGeom
{
class IFC_GEOM_API IteratorSettings
{
public:
/// Enumeration of setting identifiers. These settings define the
/// behaviour of various aspects of IfcOpenShell.
enum Setting : uint64_t
{
/// Specifies whether vertices are welded, meaning that the coordinates
/// vector will only contain unique xyz-triplets. This results in a
/// manifold mesh which is useful for modelling applications, but might
/// result in unwanted shading artifacts in rendering applications.
WELD_VERTICES = 1,
/// Specifies whether to apply the local placements of building elements
/// directly to the coordinates of the representation mesh rather than
/// to represent the local placement in the 4x3 matrix, which will in that
/// case be the identity matrix.
USE_WORLD_COORDS = 1 << 1,
/// Internally IfcOpenShell measures everything in meters. This settings
/// specifies whether to convert IfcGeomObjects back to the units in which
/// the geometry in the IFC file is specified.
CONVERT_BACK_UNITS = 1 << 2,
/// Specifies whether to use the Open Cascade BREP format for representation
/// items rather than to create triangle meshes. This is useful is IfcOpenShell
/// is used as a library in an application that is also built on Open Cascade.
USE_BREP_DATA = 1 << 3,
/// Specifies whether to sew IfcConnectedFaceSets (open and closed shells) to
/// TopoDS_Shells or whether to keep them as a loose collection of faces.
SEW_SHELLS = 1 << 4,
/// Disables the subtraction of IfcOpeningElement representations from
/// the related building element representations.
DISABLE_OPENING_SUBTRACTIONS = 1 << 5,
/// Disables the triangulation of the topological representations. Useful if
/// the client application understands Open Cascade's native format.
DISABLE_TRIANGULATION = 1 << 6,
/// Applies default materials to entity instances without a surface style or
/// product-level material association.
APPLY_DEFAULT_MATERIALS = 1 << 7,
/// Specifies whether to include subtypes of IfcCurve.
INCLUDE_CURVES = 1 << 8,
/// Specifies whether to exclude subtypes of IfcSolidModel and IfcSurface.
EXCLUDE_SOLIDS_AND_SURFACES = 1 << 9,
/// Disables computation of normals. Saves time and file size and is useful
/// in instances where you're going to recompute normals for the exported
/// model in other modelling application in any case.
NO_NORMALS = 1 << 10,
/// Generates UVs by using simple box projection. Requires normals.
/// Applicable for OBJ and DAE output.
GENERATE_UVS = 1 << 11,
/// Specifies whether to slice representations according to associated
/// IfcMaterialLayerSets.
APPLY_LAYERSETS = 1 << 12,
/// Emit the relative placements from IFC instead of a flat listing of
/// absolute placements.
ELEMENT_HIERARCHY = 1 << 13,
/// Emit placements relative to the IfcSite. Useful if the IfcSite itself
/// introduces a placement with a large geospatial offset that inhibits
/// rendering.
SITE_LOCAL_PLACEMENT = 1 << 14,
/// Emit placements relative to the IfcBuilding. Useful if the IfcBuilding
/// itself introduces a placement with a large geospatial offset that
/// inhibits rendering.
BUILDING_LOCAL_PLACEMENT = 1 << 15,
/// After geometry interpretation, lookup an IfcOpenShell-specific quantity set
/// and compare values for validation.
VALIDATE_QUANTITIES = 1 << 16,
/// Assigns the first layer material to the entire product
LAYERSET_FIRST = 1 << 17,
/// Adds arrow heads to edge segments to signify edge direction. Useful as a
/// debugging mechanism for face orientation or advanced brep IfcOrientedEdge.
EDGE_ARROWS = 1 << 18,
/// Disables the evaluation of IfcBooleanResult and simply returns FirstOperand
DISABLE_BOOLEAN_RESULT = 1 << 19,
/// Disables wire intersection checks. These checks are done on faces to prevent
/// self-intersections of face bounds. Self-intersections reduce the reliability
/// of boolean operations and may lead to crashes.
NO_WIRE_INTERSECTION_CHECK = 1 << 20,
/// Set wire intersection tolerance to 0. By default the above check is done
/// using a tolerance criterium. So that when a vertex is a certain epsilon
/// distance away from an edge this is flagged as an intersection.
NO_WIRE_INTERSECTION_TOLERANCE = 1 << 21,
/// Strictly use the tolerance from the IFC model. Typically this value is
/// increased 10-fold to have more reliable boolean subtraction results.
STRICT_TOLERANCE = 1 << 22,
/// Write boolean operands to file in current directory for debugging purposes
DEBUG_BOOLEAN = 1 << 23,
/// Try to perform boolean subtractions in 2d. Defaults to true.
BOOLEAN_ATTEMPT_2D = 1 << 24,
/// Number of different setting flags.
NUM_SETTINGS = 25,
};
IteratorSettings()
: settings_(WELD_VERTICES | BOOLEAN_ATTEMPT_2D) // OR options that default to true here
, deflection_tolerance_(1.e-3)
, angular_tolerance_(0.5)
, force_space_transparency_(-1.0)
{
}
/// Note that this is independent of the IFC length unit, one millimeter by default.
double deflection_tolerance() const { return deflection_tolerance_; }
double angular_tolerance() const { return angular_tolerance_; }
double force_space_transparency() const { return force_space_transparency_; }
const std::set<int>& context_ids() const { return context_ids_; }
/// @todo Using deflection tolerance of 1e-6 or smaller hangs the conversion, research more in-depth.
/// This bug can be reproduced e.g. with the Duplex model that can be found from http://www.nibs.org/?page=bsa_commonbimfiles#project1
void set_deflection_tolerance(double value);
void set_angular_tolerance(double value) {
angular_tolerance_ = value;
}
void force_space_transparency(double 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.
bool get(uint64_t setting) const
{
/// @todo If unknown setting value/combination: throw IfcParse::IfcException("Invalid IteratorSetting")?
return (settings_ & setting) != 0;
}
/// Set boolean value for a single settings or for a combination of settings.
void set(uint64_t setting, bool value)
{
/// @todo If unknown setting value/combination: throw IfcParse::IfcException("Invalid IteratorSetting")?
if (value) {
settings_ |= setting;
} else {
settings_ &= ~setting;
}
}
/// Optional offset that is applied to serialized objects, (0,0,0) by default.
std::array<double,3> offset = std::array<double,3>{0.0, 0.0, 0.0};
/// Optional rotation that is applied to serialized objects, (0,0,0,1) by default.
std::array<double,4> rotation = std::array<double,4>{0.0, 0.0, 0.0, 1.0};
uint64_t get_raw() const {
return settings_;
}
protected:
uint64_t settings_;
double deflection_tolerance_, angular_tolerance_, force_space_transparency_;
std::set<int> context_ids_;
};
class IFC_GEOM_API ElementSettings : public IteratorSettings
{
public:
ElementSettings(const IteratorSettings& settings,
double unit_magnitude,
const std::string& element_type)
: IteratorSettings(settings)
, unit_magnitude_(unit_magnitude)
, element_type_(element_type)
{
}
double unit_magnitude() const { return unit_magnitude_; }
const std::string& element_type() const { return element_type_; }
private:
double unit_magnitude_;
std::string element_type_;
};
}
*/
#endif
-1
View File
@@ -4,7 +4,6 @@
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/aggregate_of_instance.h"
#include "../ifcgeom/taxonomy.h"
#include "../ifcgeom/IteratorSettings.h"
#include "../ifcgeom/ConversionSettings.h"
#include <boost/function.hpp>
@@ -26,6 +26,7 @@ import documentation
from collections import defaultdict
USE_VIRTUAL_INHERITANCE = True
class Header(codegen.Base):
def __init__(self, mapping):
@@ -50,7 +51,7 @@ class Header(codegen.Base):
for name, type in mapping.schema.selects.items():
for nm in type.values:
select_super_types[str(nm).lower()].append(name)
write(templates.select, name=name)
write(templates.select_virtual if USE_VIRTUAL_INHERITANCE else templates.select_plain, name=name)
def get_select_super_types(nm, bases=[]):
x = list(select_super_types[nm.lower()])
@@ -82,7 +83,9 @@ class Header(codegen.Base):
superclass = mapping.simple_type_parent(superclass)
else:
superclasses.append("IfcUtil::IfcBaseType")
superclasses.extend(get_select_super_types(name, bases=all_superclasses))
if USE_VIRTUAL_INHERITANCE:
superclasses.extend(get_select_super_types(name, bases=all_superclasses))
is_emitted = (
lambda nm: nm == "IfcUtil::IfcBaseType"
@@ -155,8 +158,8 @@ class Header(codegen.Base):
tt = mapping.schema.entities[tt.supertypes[0]]
supertypes = list(type.supertypes) if len(type.supertypes) else ["IfcUtil::IfcBaseEntity"]
direct_superclass = supertypes[0]
supertypes.extend(get_select_super_types(name, bases=all_supertypes))
if USE_VIRTUAL_INHERITANCE:
supertypes.extend(get_select_super_types(name, bases=all_supertypes))
supertypes = list(map(case_normalize, supertypes))
superclass = create_supertype_statement(supertypes)
@@ -22,6 +22,8 @@ import templates
from schema import OrderedCaseInsensitiveDict
from header import USE_VIRTUAL_INHERITANCE
class Implementation(codegen.Base):
def __init__(self, mapping):
@@ -68,14 +70,15 @@ class Implementation(codegen.Base):
),
)
for name, enum in mapping.schema.selects.items():
write(
templates.select_function,
name=name,
schema_name=schema_name,
schema_name_upper=schema_name_upper,
index_in_schema=self.names.index(str(name)),
)
if USE_VIRTUAL_INHERITANCE:
for name, enum in mapping.schema.selects.items():
write(
templates.select_function,
name=name,
schema_name=schema_name,
schema_name_upper=schema_name_upper,
index_in_schema=self.names.index(str(name)),
)
write = lambda str, **kwargs: entity_implementations.append(str % kwargs)
@@ -98,6 +101,7 @@ class Implementation(codegen.Base):
def find_template(arg):
simple = mapping.schema.is_simpletype(arg["list_instance_type"])
select = arg["list_instance_type"] == "IfcUtil::IfcBaseClass"
express = (
mapping.flatten_type_string(arg["list_instance_type"]) in mapping.express_to_cpp_typemapping
)
@@ -105,7 +109,7 @@ class Implementation(codegen.Base):
return templates.get_attr_stmt_enum
elif arg["is_nested"] and arg["is_templated_list"]:
return templates.get_attr_stmt_nested_array
elif arg["is_templated_list"] and not (simple or express):
elif arg["is_templated_list"] and not (select or simple or express):
return templates.get_attr_stmt_array
elif arg["non_optional_type"].endswith("*"):
return templates.get_attr_stmt_entity
@@ -23,6 +23,7 @@ import nodes
import templates
import schema
from header import USE_VIRTUAL_INHERITANCE
class Mapping:
@@ -180,12 +181,11 @@ class Mapping:
ty = ty.replace("*", "")
# https://github.com/IfcOpenShell/IfcOpenShell/issues/2805
# This is no longer applicable, we do support statically typed select types as aggregates
#
# if self.schema.is_select(attr_type.type):
# type_str = templates.untyped_list
# We do support statically typed select types as aggregates when USE_VIRTUAL_INHERITANCE=True
if self.schema.is_simpletype(ty) or str(ty) in self.express_to_cpp_typemapping.values():
if not USE_VIRTUAL_INHERITANCE and self.schema.is_select(attr_type.type):
type_str = templates.untyped_list
elif self.schema.is_simpletype(ty) or str(ty) in self.express_to_cpp_typemapping.values():
tmpl = templates.nested_array_type if is_nested_list else templates.array_type
bounds = (attr_type.bounds.lower, attr_type.bounds.upper) if attr_type.bounds else (-1, -1)
type_str = tmpl % {"instance_type": ty, "lower": bounds[0], "upper": bounds[1]}
@@ -224,8 +224,8 @@ class Mapping:
isinstance(v, nodes.SimpleType) and isinstance(v.type, nodes.StringType)
):
return "string"
# if self.schema.is_select(v):
# return "IfcUtil::IfcBaseClass"
if not USE_VIRTUAL_INHERITANCE and self.schema.is_select(v):
return "IfcUtil::IfcBaseClass"
if str(v) in self.schema.types or str(v) in self.schema.entities:
return "::%s::%s" % (self.schema.name.capitalize(), v)
else:
@@ -136,7 +136,7 @@ simpletype_impl_cast_templated = (
)
simpletype_impl_declaration = "return *((IfcParse::type_declaration*)%(schema_name_upper)s_types[%(index_in_schema)d]);"
select = """%(documentation)s
select_virtual = """%(documentation)s
class IFC_PARSE_API %(name)s : public virtual IfcUtil::IfcBaseInterface {
public:
static const IfcParse::select_type& Class();
@@ -144,6 +144,10 @@ public:
};
"""
select_plain = """%(documentation)s
typedef IfcUtil::IfcBaseClass %(name)s;
"""
enumeration = """class IFC_PARSE_API %(name)s : public IfcUtil::IfcBaseType {
%(documentation)s
public:
File diff suppressed because it is too large Load Diff
+2
View File
@@ -122,6 +122,8 @@ public:
uint32_t id() const { return id_; }
void toString(std::ostream&, bool upper = false) const;
typedef aggregate_of_instance list;
};
class IFC_PARSE_API IfcBaseEntity : public IfcBaseClass {