Minor cleanups, 4x1 and 4x2 geom lib, granular schema macros

This commit is contained in:
Thomas Krijnen
2019-06-26 13:50:46 +02:00
parent 73f7c34c8d
commit 839b5a2699
36 changed files with 15869 additions and 2590 deletions
+2 -2
View File
@@ -199,14 +199,14 @@ else:
pickle.dump(mapping, f, protocol=0)
import header
import enum_header
import implementation
import schema_class
import definitions
header.Header(mapping).emit()
enum_header.EnumHeader(mapping).emit()
implementation.Implementation(mapping).emit()
schema_class.SchemaClass(mapping).emit()
definitions.Definitions(mapping).emit()
sys.stdout.write(schema.name)
"""%('\n '.join(statements)))
@@ -17,23 +17,46 @@
# #
###############################################################################
import templates
import operator
import nodes
import codegen
class EnumHeader(codegen.Base):
from collections import defaultdict
class Definitions(codegen.Base):
def __init__(self, mapping):
enumerable_types = sorted(set([name for name, type in mapping.schema.types.items()] + [name for name, type in mapping.schema.entities.items()]))
self.str = templates.enum_header % {
'schema_name_upper' : mapping.schema.name.upper(),
'schema_name' : mapping.schema.name.capitalize(),
'types' : ', '.join(enumerable_types)
}
schema_name = mapping.schema.name
self.schema_name = schema_name_title = schema_name.capitalize()
statements = ['']
self.schema_name = mapping.schema.name.capitalize()
self.file_name = '%senum.h'%self.schema_name
def write_entity(schema_name, name, type):
attribute_names = list(map(lambda t: (t.name, t.optional), type.attributes))
for attr, is_optional in attribute_names:
statements.append("#define SCHEMA_%(name)s_HAS_%(attr)s" % locals())
if is_optional:
statements.append("#define SCHEMA_%(name)s_%(attr)s_IS_OPTIONAL" % locals())
def write(name):
statements.append("#define SCHEMA_HAS_%(name)s" % locals())
fn = None
if mapping.schema.is_entity(name):
fn = write_entity
if fn is not None:
decl = mapping.schema[name]
if isinstance(decl, nodes.TypeDeclaration):
decl = decl.type.type
fn(schema_name, name, decl) is not False
for name in mapping.schema:
write(name)
self.str = "\n".join(statements) + "\n"
self.file_name = '%s-definitions.h' % self.schema_name
def __repr__(self):
return self.str
-2
View File
@@ -34,8 +34,6 @@ header = """
#include "../ifcparse/IfcException.h"
#include "../ifcparse/Argument.h"
#include "../ifcparse/%(schema_name)senum.h"
struct %(schema_name)s {
static const IfcParse::schema_definition& get_schema();
+4 -1
View File
@@ -80,6 +80,9 @@ if ( it != cache.T.end() ) { e = it->second; return true; }
#define INCLUDE_PARENT_DIR(x) STRINGIFY(../ifcparse/x.h)
#include INCLUDE_PARENT_DIR(IfcSchema)
#undef INCLUDE_PARENT_DIR
#define INCLUDE_PARENT_DIR(x) STRINGIFY(../ifcparse/x-definitions.h)
#include INCLUDE_PARENT_DIR(IfcSchema)
namespace IfcGeom {
class IFC_GEOM_API geometry_exception : public std::exception {
@@ -357,7 +360,7 @@ public:
const SurfaceStyle* get_style(const IfcSchema::IfcMaterial*);
template <typename T> std::pair<IfcSchema::IfcSurfaceStyle*, T*> _get_surface_style(const IfcSchema::IfcStyledItem* si) {
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
IfcEntityList::ptr style_assignments = si->Styles();
for (IfcEntityList::it kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
if (!(*kt)->declaration().is(IfcSchema::IfcPresentationStyleAssignment::Class())) {
+4 -4
View File
@@ -77,12 +77,12 @@
#include <TopLoc_Location.hxx>
#ifdef USE_IFC4
#include "../ifcgeom/IfcGeom.h"
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
#include <Geom_BSplineCurve.hxx>
#endif
#include "../ifcgeom/IfcGeom.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircle* l, Handle(Geom_Curve)& curve) {
@@ -143,7 +143,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLine* l, Handle(Geom_Curve)& c
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineCurveWithKnots* l, Handle(Geom_Curve)& curve) {
const bool is_rational = l->declaration().is(IfcSchema::IfcRationalBSplineCurveWithKnots::Class());
+17 -17
View File
@@ -97,15 +97,15 @@
#include <BRepLib_FindSurface.hxx>
#ifdef USE_IFC4
#include "../ifcgeom/IfcGeom.h"
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
#include <Geom_BSplineSurface.hxx>
#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
#endif
#include "../ifcgeom/IfcGeom.h"
#define Kernel MAKE_TYPE_NAME(Kernel)
namespace {
@@ -472,7 +472,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleProfileDef* l, TopoDS
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -495,7 +495,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRoundedRectangleProfileDef* l,
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -529,7 +529,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRectangleHollowProfileDef* l,
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -575,7 +575,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTrapeziumProfileDef* l, TopoDS
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -620,7 +620,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -659,7 +659,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcZShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -692,7 +692,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -767,7 +767,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcLShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -815,7 +815,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcUShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -904,7 +904,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTShapeProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -926,7 +926,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleProfileDef* l, TopoDS_Sh
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -958,7 +958,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCircleHollowProfileDef* l, Top
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -996,7 +996,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcEllipseProfileDef* l, TopoDS_S
gp_Trsf2d trsf2d;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -1124,7 +1124,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcPlane* l, TopoDS_Shape& face)
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) {
boost::shared_ptr< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
+2 -6
View File
@@ -1587,11 +1587,7 @@ IfcSchema::IfcRelVoidsElement::list::ptr IfcGeom::Kernel::find_openings(IfcSchem
// Is the IfcElement a decomposition of an IfcElement with any IfcOpeningElements?
IfcSchema::IfcObjectDefinition* obdef = product->as<IfcSchema::IfcObjectDefinition>();
for (;;) {
#ifdef USE_IFC4
IfcSchema::IfcRelAggregates::list::ptr decomposes = obdef->Decomposes();
#else
IfcSchema::IfcRelDecomposes::list::ptr decomposes = obdef->Decomposes();
#endif
auto decomposes = obdef->Decomposes();
if (decomposes->size() != 1) break;
IfcSchema::IfcObjectDefinition* rel_obdef = (*decomposes->begin())->RelatingObject();
if ( rel_obdef->declaration().is(IfcSchema::IfcElement::Class()) && !rel_obdef->declaration().is(IfcSchema::IfcOpeningElement::Class()) ) {
@@ -2175,7 +2171,7 @@ bool IfcGeom::Kernel::convert_layerset(const IfcSchema::IfcProduct* product, std
gp_Trsf extrusion_position;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = extrusion->hasPosition();
#endif
if (has_position) {
+35 -27
View File
@@ -119,7 +119,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -166,7 +166,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_S
return !shape.IsNull();
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolidTapered* l, TopoDS_Shape& shape) {
const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
if (height < getValue(GV_PRECISION)) {
@@ -180,7 +180,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolidTapered* l, T
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -280,7 +280,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, T
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -315,7 +315,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptSurface_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -344,7 +344,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_S
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -376,7 +376,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcManifoldSolidBrep* l, IfcRepre
if (l->declaration().is(IfcSchema::IfcFacetedBrepWithVoids::Class())) {
voids = l->as<IfcSchema::IfcFacetedBrepWithVoids>()->Voids();
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcAdvancedBrepWithVoids
if (l->declaration().is(IfcSchema::IfcAdvancedBrepWithVoids::Class())) {
voids = l->as<IfcSchema::IfcAdvancedBrepWithVoids>()->Voids();
}
@@ -545,27 +545,27 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
TopTools_ListOfShape second_operand_shapes;
for (auto& operand2 : second_operands) {
for (auto& op2 : second_operands) {
TopoDS_Shape s2;
bool shape2_processed = false;
bool is_halfspace = operand2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class());
bool is_unbounded_halfspace = is_halfspace && !operand2->declaration().is(IfcSchema::IfcPolygonalBoundedHalfSpace::Class());
bool is_halfspace = op2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class());
bool is_unbounded_halfspace = is_halfspace && !op2->declaration().is(IfcSchema::IfcPolygonalBoundedHalfSpace::Class());
has_halfspace_operand |= is_halfspace;
{
if (shape_type(operand2) == ST_SHAPELIST) {
if (shape_type(op2) == ST_SHAPELIST) {
IfcRepresentationShapeItems items2;
shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true);
} else if (shape_type(operand2) == ST_SHAPE) {
shape2_processed = convert_shape(operand2, s2);
shape2_processed = convert_shapes(op2, items2) && flatten_shape_list(items2, s2, true);
} else if (shape_type(op2) == ST_SHAPE) {
shape2_processed = convert_shape(op2, s2);
if (shape2_processed) {
TopoDS_Solid temp_solid;
s2 = ensure_fit_for_subtraction(s2, temp_solid);
}
} else {
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2);
Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", op2);
}
}
@@ -583,14 +583,14 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape
}
if (!shape2_processed) {
Logger::Message(Logger::LOG_ERROR, "Failed to convert SecondOperand:", operand2);
Logger::Message(Logger::LOG_ERROR, "Failed to convert SecondOperand:", op2);
continue;
}
if (operand2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class())) {
if (op2->declaration().is(IfcSchema::IfcHalfSpaceSolid::Class())) {
const double second_operand_volume = shape_volume(s2);
if (second_operand_volume <= ALMOST_ZERO) {
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", operand2);
Logger::Message(Logger::LOG_WARNING, "Empty solid for:", op2);
}
}
@@ -950,7 +950,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l,
gp_Trsf trsf;
bool has_position = true;
#ifdef USE_IFC4
#ifdef SCHEMA_IfcSweptAreaSolid_Position_IS_OPTIONAL
has_position = l->hasPosition();
#endif
if (has_position) {
@@ -1152,7 +1152,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSweptDiskSolid* l, TopoDS_Shap
return true;
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcCylindricalSurface
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_Shape& face) {
gp_Trsf trsf;
@@ -1167,10 +1167,18 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCylindricalSurface* l, TopoDS_
return true;
}
#endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep
bool IfcGeom::Kernel::convert(const IfcSchema::IfcAdvancedBrep* l, TopoDS_Shape& shape) {
return convert(l->Outer(), shape);
}
#endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS_Shape& shape) {
IfcSchema::IfcCartesianPointList3D* point_list = l->Coordinates();
const std::vector< std::vector<double> > coordinates = point_list->CoordList();
@@ -1231,18 +1239,18 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcTriangulatedFaceSet* l, TopoDS
bool valid_shell = false;
// @todo Do this more efficiently by creating proper half-edge pairs.
BRepOffsetAPI_Sewing builder;
builder.SetTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
builder.SetMaxTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
builder.SetMinTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
BRepOffsetAPI_Sewing sewing_builder;
sewing_builder.SetTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
sewing_builder.SetMaxTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
sewing_builder.SetMinTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
for (std::vector<TopoDS_Face>::const_iterator it = faces.begin(); it != faces.end(); ++it) {
builder.Add(*it);
sewing_builder.Add(*it);
}
try {
builder.Perform();
shape = builder.SewedShape();
sewing_builder.Perform();
shape = sewing_builder.SewedShape();
valid_shell = BRepCheck_Analyzer(shape).IsValid();
} catch(...) {}
+1 -1
View File
@@ -849,7 +849,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcSubedge* l, TopoDS_Wire& resul
}
}
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wire& result) {
+11 -3
View File
@@ -52,12 +52,20 @@ SHAPES(IfcMappedItem);
SHAPES(IfcManifoldSolidBrep);
SHAPES(IfcGeometricSet);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcCylindricalSurface
SHAPE(IfcCylindricalSurface);
#endif
#ifdef SCHEMA_HAS_IfcAdvancedBrep
SHAPE(IfcAdvancedBrep);
#endif
// FIXME: Surfaces should have a shape type of their own
#ifdef SCHEMA_HAS_IfcBSplineSurfaceWithKnots
SHAPE(IfcBSplineSurfaceWithKnots);
#endif
#ifdef SCHEMA_HAS_IfcTriangulatedFaceSet
SHAPE(IfcTriangulatedFaceSet);
#endif
#ifdef SCHEMA_HAS_IfcExtrudedAreaSolidTapered
SHAPE(IfcExtrudedAreaSolidTapered);
#endif
SHAPE(IfcPlane);
@@ -114,14 +122,14 @@ WIRE(IfcPolyLoop);
WIRE(IfcCompositeCurve);
WIRE(IfcTrimmedCurve);
WIRE(IfcArbitraryOpenProfileDef);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcIndexedPolyCurve
WIRE(IfcIndexedPolyCurve)
#endif
CURVE(IfcCircle);
CURVE(IfcEllipse);
CURVE(IfcLine);
#ifdef USE_IFC4
#ifdef SCHEMA_HAS_IfcBSplineCurveWithKnots
// IfcRationalBSplineCurveWithKnots included
CURVE(IfcBSplineCurveWithKnots);
#endif
-10
View File
@@ -28,16 +28,6 @@
#include "ifc_parse_api.h"
#ifdef USE_IFC4X2
#include "../ifcparse/Ifc4x2enum.h"
#elif USE_IFC4X1
#include "../ifcparse/Ifc4x1enum.h"
#elif USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
#include "../ifcparse/Ifc2x3enum.h"
#endif
#include "../ifcparse/IfcEntityList.h"
#include <boost/shared_ptr.hpp>
File diff suppressed because it is too large Load Diff
+298 -339
View File
File diff suppressed because it is too large Load Diff
-35
View File
@@ -1,35 +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/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC2X3_TC1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC2X3ENUM_H
#define IFC2X3ENUM_H
#include "../ifcparse/ifc_parse_api.h"
#include <string>
#include <boost/optional.hpp>
#endif
File diff suppressed because it is too large Load Diff
+409 -466
View File
File diff suppressed because it is too large Load Diff
-35
View File
@@ -1,35 +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/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC4.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC4ENUM_H
#define IFC4ENUM_H
#include "../ifcparse/ifc_parse_api.h"
#include <string>
#include <boost/optional.hpp>
#endif
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -19,7 +19,7 @@
/********************************************************************************
* *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
+1 -1
View File
@@ -19,7 +19,7 @@
/********************************************************************************
* *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
+1 -4
View File
@@ -19,12 +19,11 @@
/********************************************************************************
* *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC4X1_H
#define IFC4X1_H
@@ -41,8 +40,6 @@
#include "../ifcparse/IfcException.h"
#include "../ifcparse/Argument.h"
#include "../ifcparse/Ifc4x1enum.h"
struct Ifc4x1 {
static const IfcParse::schema_definition& get_schema();
-35
View File
@@ -1,35 +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/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC4x1.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC4X1ENUM_H
#define IFC4X1ENUM_H
#include "../ifcparse/ifc_parse_api.h"
#include <string>
#include <boost/optional.hpp>
#endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -19,7 +19,7 @@
/********************************************************************************
* *
* This file has been generated from IFC4x2.exp Draft. Do not make modifications *
* This file has been generated from IFC4x2.exp. Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
+410 -467
View File
File diff suppressed because it is too large Load Diff
-35
View File
@@ -1,35 +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/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file has been generated from IFC4x2.exp (Draft). Do not make modifications *
* but instead modify the python script that has been used to generate this. *
* *
********************************************************************************/
#ifndef IFC4X2ENUM_H
#define IFC4X2ENUM_H
#include "../ifcparse/ifc_parse_api.h"
#include <string>
#include <boost/optional.hpp>
#endif
-10
View File
@@ -22,16 +22,6 @@
#include "ifc_parse_api.h"
#ifdef USE_IFC4X2
#include "../ifcparse/Ifc4x2enum.h"
#elif USE_IFC4X1
#include "../ifcparse/Ifc4x1enum.h"
#elif USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
#include "../ifcparse/Ifc2x3enum.h"
#endif
#include "../ifcparse/IfcEntityInstanceData.h"
#include "../ifcparse/IfcSchema.h"
-137
View File
@@ -1,137 +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 IFCENTITYDESCRIPTOR_H
#define IFCENTITYDESCRIPTOR_H
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include "../ifcparse/IfcBaseClass.h"
#include "../ifcparse/IfcException.h"
#ifdef USE_IFC4X2
#include "../ifcparse/Ifc4x2enum.h"
#elif USE_IFC4X1
#include "../ifcparse/Ifc4x1enum.h"
#elif USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
#include "../ifcparse/Ifc2x3enum.h"
#endif
namespace IfcUtil {
class IFC_PARSE_API IfcEnumerationDescriptor {
private:
IfcSchema::Type::Enum type;
std::vector<std::string> values;
public:
IfcEnumerationDescriptor(IfcSchema::Type::Enum type, const std::vector<std::string>& values)
: type(type), values(values) {}
std::pair<const char*, int> getIndex(const std::string& value) const {
std::vector<std::string>::const_iterator it = std::find(values.begin(), values.end(), value);
if (it != values.end()) {
return std::make_pair(it->c_str(), (int)std::distance(it, values.begin()));
} else {
throw IfcParse::IfcException("Invalid enumeration value");
}
}
const std::vector<std::string>& getValues() {
return values;
}
IfcSchema::Type::Enum getType() {
return type;
}
};
class IFC_PARSE_API IfcEntityDescriptor {
public:
class IfcArgumentDescriptor
{
public:
std::string name;
bool optional;
ArgumentType argument_type;
IfcSchema::Type::Enum data_type;
IfcArgumentDescriptor(const std::string& name, bool optional, ArgumentType argument_type, IfcSchema::Type::Enum data_type)
: name(name), optional(optional), argument_type(argument_type), data_type(data_type) {}
};
private:
IfcSchema::Type::Enum type;
IfcEntityDescriptor* parent;
std::vector<IfcArgumentDescriptor> arguments;
unsigned argument_start() const {
return parent ? parent->getArgumentCount() : 0;
}
const IfcArgumentDescriptor& get_argument(unsigned i) const {
if (i < arguments.size()) return arguments[i];
else throw IfcParse::IfcAttributeOutOfRangeException("Argument index out of range");
}
public:
IfcEntityDescriptor(IfcSchema::Type::Enum type, IfcEntityDescriptor* parent)
: type(type), parent(parent) {}
void add(const std::string& name, bool optional, ArgumentType argument_type, IfcSchema::Type::Enum data_type = IfcSchema::Type::UNDEFINED) {
arguments.push_back(IfcArgumentDescriptor(name, optional, argument_type, data_type));
}
unsigned getArgumentCount() const {
return (parent ? parent->getArgumentCount() : 0) + (unsigned)arguments.size();
}
const std::string& getArgumentName(unsigned i) const {
const unsigned a = argument_start();
return i < a
? parent->getArgumentName(i)
: get_argument(i-a).name;
}
ArgumentType getArgumentType(unsigned i) const {
const unsigned a = argument_start();
return i < a
? parent->getArgumentType(i)
: get_argument(i-a).argument_type;
}
bool getArgumentOptional(unsigned i) const {
const unsigned a = argument_start();
return i < a
? parent->getArgumentOptional(i)
: get_argument(i-a).optional;
}
IfcSchema::Type::Enum getArgumentEntity(unsigned i) const {
const unsigned a = argument_start();
return i < a
? parent->getArgumentEntity(i)
: get_argument(i-a).data_type;
}
unsigned getArgumentIndex(const std::string& s) const {
unsigned a = argument_start();
for(std::vector<IfcArgumentDescriptor>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) {
if (i->name == s) return a;
a++;
}
if (parent) return parent->getArgumentIndex(s);
throw IfcParse::IfcException(std::string("Argument ") + s + " not found on " + IfcSchema::Type::ToString(type));
}
};
}
#endif
+1
View File
@@ -22,6 +22,7 @@
#include "../ifcparse/ArgumentType.h"
#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>
+4
View File
@@ -21,6 +21,8 @@
#include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/Ifc4.h"
#include "../ifcparse/Ifc4x1.h"
#include "../ifcparse/Ifc4x2.h"
double IfcParse::IfcSIPrefixToValue(const std::string& v) {
if ( v == "EXA" ) return 1.e18;
@@ -72,3 +74,5 @@ double IfcParse::get_SI_equivalent(typename Schema::IfcNamedUnit* named_unit) {
template double IfcParse::get_SI_equivalent<Ifc2x3>(typename Ifc2x3::IfcNamedUnit* named_unit);
template double IfcParse::get_SI_equivalent<Ifc4>(typename Ifc4::IfcNamedUnit* named_unit);
template double IfcParse::get_SI_equivalent<Ifc4x1>(typename Ifc4x1::IfcNamedUnit* named_unit);
template double IfcParse::get_SI_equivalent<Ifc4x2>(typename Ifc4x2::IfcNamedUnit* named_unit);
+4 -1
View File
@@ -64,16 +64,19 @@ IfcParse::schema_definition::~schema_definition() {
#include "../ifcparse/Ifc2x3.h"
#include "../ifcparse/Ifc4.h"
#include "../ifcparse/Ifc4x1.h"
#include "../ifcparse/Ifc4x2.h"
const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) {
// TODO: initialize automatically somehow
Ifc2x3::get_schema();
Ifc4::get_schema();
Ifc4x1::get_schema();
Ifc4x2::get_schema();
std::map<std::string, const IfcParse::schema_definition*>::const_iterator it = schemas.find(name);
if (it == schemas.end()) {
throw IfcParse::IfcException("No schema named " + name);
}
return it->second;
}
}
-12
View File
@@ -29,18 +29,6 @@
#include "../ifcparse/IfcException.h"
#ifdef USE_IFC4X2
#include "../ifcparse/Ifc4x2enum.h"
#elif USE_IFC4X1
#include "../ifcparse/Ifc4x1enum.h"
#elif USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
#include "../ifcparse/Ifc2x3enum.h"
#endif
// Forward declarations
class IfcEntityInstanceData;
+19 -4
View File
@@ -6,7 +6,7 @@
#include <libxml/parser.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/range/adaptor/transformed.hpp>
#include <boost/range/algorithm/copy.hpp>
@@ -328,9 +328,24 @@ static void start_element(void* user, const xmlChar* tag, const xmlChar** attrs)
attributes.push_back(std::make_pair(attrname, value));
if ((tagname == "ifc:ifcXML" || tagname == "ifcXML") && attrname == "xsi:schemaLocation" && boost::starts_with(value, "http://www.buildingsmart-tech.org/ifcXML/IFC4")) {
state->file = new IfcParse::IfcFile(IfcParse::schema_by_name("IFC4"));
state->file->parsing_complete() = false;
state->dialect = ifcxml_dialect_ifc4;
// We're expecting a schemaLocation like "http://www.buildingsmart-tech.org/ifcXML/IFC4/Add2 IFC4_ADD2_TC1.xsd"
// With token compression this is split into:
// [0] http:
// [1] www.buildingsmart-tech.org
// [2] ifcXML
// [3] IFC4
// [4] Add2
// [5] IFC4_ADD2_TC1.xsd
// The hosstname will likely change though.
auto it = boost::algorithm::make_split_iterator(value, boost::algorithm::token_finder(boost::algorithm::is_any_of("/ "), boost::algorithm::token_compress_on));
decltype(it) end;
for (int tok = 0; it != end && tok < 3; ++it, ++tok) {}
if (it != end) {
const std::string schema_name(&it->front(), it->size());
state->file = new IfcParse::IfcFile(IfcParse::schema_by_name(schema_name));
state->file->parsing_complete() = false;
state->dialect = ifcxml_dialect_ifc4;
}
goto end;
} else if (tagname == "ex:iso_10303_28" && attrname == "xsi:schemaLocation" && boost::starts_with(value, "http://www.iai-tech.org/ifcXML/IFC2x3")) {
state->file = new IfcParse::IfcFile(IfcParse::schema_by_name("IFC2X3"));
@@ -255,7 +255,7 @@ ptree& descend(IfcSchema::IfcObjectDefinition* product, ptree& tree) {
}
}
#ifndef USE_IFC4
#ifdef SCHEMA_IfcRelDecomposes_HAS_RelatedObjects
IfcSchema::IfcObjectDefinition::list::ptr structures = get_related
<IfcSchema::IfcObjectDefinition, IfcSchema::IfcRelDecomposes, IfcSchema::IfcObjectDefinition>
(product, &IfcSchema::IfcObjectDefinition::IsDecomposedBy, &IfcSchema::IfcRelDecomposes::RelatedObjects);