Merge pull request #2 from aothms/master

Assorted fixes
This commit is contained in:
Thomas Krijnen
2015-09-13 15:05:46 +02:00
19 changed files with 150 additions and 113 deletions
+3 -2
View File
@@ -56,6 +56,7 @@ FIND_LIBRARY(icu "icuuc" /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 ${I
IF(icu)
MESSAGE(STATUS "ICU libraries found")
ADD_DEFINITIONS(-DHAVE_ICU)
SET(ICU_LIBRARIES icuuc icudata)
ELSE()
MESSAGE(STATUS "Unable to find ICU library files, continuing")
ENDIF()
@@ -170,13 +171,13 @@ ADD_EXECUTABLE(IfcConvert
../src/ifcconvert/util.cpp
)
TARGET_LINK_LIBRARIES (IfcConvert IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES})
TARGET_LINK_LIBRARIES (IfcConvert IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${Boost_LIBRARIES} ${OPENCOLLADA_LIBRARIES} ${ICU_LIBRARIES})
ADD_EXECUTABLE(IfcGeomServer
../src/ifcgeomserver/IfcGeomServer.cpp
)
TARGET_LINK_LIBRARIES (IfcGeomServer IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset)
TARGET_LINK_LIBRARIES (IfcGeomServer IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKSTEP TKSTEPBase TKSTEPAttr TKXSBase TKSTEP209 TKIGES TKOffset ${ICU_LIBRARIES})
# Build python wrapper using separate CMakeLists.txt
ADD_SUBDIRECTORY(../src/ifcwrap ifcwrap)
+4
View File
@@ -381,6 +381,10 @@ int main(int argc, char** argv) {
file.setSurfaceColour(door->Representation(), 0.9, 0.9, 0.9);
file.addEntity(new IfcSchema::IfcRelFillsElement(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), null, null, door_opening, door));
IfcSchema::IfcDoorStyle* door_style = new IfcSchema::IfcDoorStyle(guid(), file.getSingle<IfcSchema::IfcOwnerHistory>(), S("Door type"), null, null, null, null, null,
IfcSchema::IfcDoorStyleOperationEnum::IfcDoorStyleOperation_SINGLE_SWING_LEFT, IfcSchema::IfcDoorStyleConstructionEnum::IfcDoorStyleConstruction_WOOD, false, false);
file.addRelatedObject<IfcSchema::IfcRelDefinesByType>(door_style, door);
// Surface styles are assigned to representation items, hence there is no real limitation to
// assign different colours within the same representation. However, some viewers have
// difficulties rendering products with representation items with different surface styles.
+19 -11
View File
@@ -90,16 +90,10 @@ void SvgSerializer::write(path_object& p, const TopoDS_Wire& wire) {
path.add(",");
addYCoordinate(path.add(p1.Y()));
if (p1.X() < xmin) xmin = p1.X();
if (p1.X() > xmax) xmax = p1.X();
if (p1.Y() < ymin) ymin = p1.Y();
if (p1.Y() > ymax) ymax = p1.Y();
growBoundingBox(p1.X(), p1.Y());
}
if (p2.X() < xmin) xmin = p2.X();
if (p2.X() > xmax) xmax = p2.X();
if (p2.Y() < ymin) ymin = p2.Y();
if (p2.Y() > ymax) ymax = p2.Y();
growBoundingBox(p2.X(), p2.Y());
Handle(Standard_Type) ty = curve->DynamicType();
@@ -218,7 +212,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement<double>* o) {
if (!storey) return;
path_object& p = start_path(storey, o->unique_id());
path_object& p = start_path(storey, nameElement(o));
for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->geometry().begin(); it != o->geometry().end(); ++ it) {
gp_GTrsf gtrsf = it->Placement();
@@ -334,9 +328,9 @@ void SvgSerializer::finalize() {
svg_file << " </g>\n";
}
std::ostringstream oss;
svg_file << " <g id=\"storey-" << IfcParse::IfcGlobalId(it->first->GlobalId()).formatted() << "\">\n";
svg_file << " <g " << nameElement(it->first) << ">\n";
}
svg_file << " <g id=\"" << it->second.first << "\">\n";
svg_file << " <g " << it->second.first << ">\n";
std::vector<util::string_buffer>::const_iterator jt;
for (jt = it->second.second.begin(); jt != it->second.second.end(); ++jt) {
svg_file << jt->str();
@@ -353,3 +347,17 @@ void SvgSerializer::finalize() {
void SvgSerializer::writeHeader() {
svg_file << "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
}
std::string SvgSerializer::nameElement(const IfcGeom::Element<double>* elem) {
std::ostringstream oss;
const std::string type = "product";
oss << "id=\"" << type << "-" << elem->unique_id() << "\"";
return oss.str();
}
std::string SvgSerializer::nameElement(const IfcSchema::IfcProduct* elem) {
std::ostringstream oss;
const std::string type = elem->is(IfcSchema::Type::IfcBuildingStorey) ? "storey" : "product";
oss << "id=\"product-" << IfcParse::IfcGlobalId(elem->GlobalId()).formatted() << "\"";
return oss.str();
}
+3
View File
@@ -59,6 +59,7 @@ public:
virtual void addXCoordinate(const SHARED_PTR<util::string_buffer::float_item>& fi) { xcoords.push_back(fi); }
virtual void addYCoordinate(const SHARED_PTR<util::string_buffer::float_item>& fi) { ycoords.push_back(fi); }
virtual void addSizeComponent(const SHARED_PTR<util::string_buffer::float_item>& fi) { radii.push_back(fi); }
virtual void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; }
virtual ~SvgSerializer() {}
virtual void writeHeader();
virtual void writeMaterial(const IfcGeom::SurfaceStyle& style) {}
@@ -73,6 +74,8 @@ public:
virtual void setFile(IfcParse::IfcFile* f) { file = f; }
virtual void setBoundingRectangle(double width, double height);
virtual void setSectionHeight(double h) { section_height = h; }
virtual std::string nameElement(const IfcGeom::Element<double>* elem);
virtual std::string nameElement(const IfcSchema::IfcProduct* elem);
};
#endif
+11 -11
View File
@@ -52,11 +52,11 @@ class Mapping:
def simple_type_parent(self, type):
parent = self.schema.types[type].type.type
if isinstance(parent, nodes.AggregationType): parent = None
return None if parent in self.express_to_cpp_typemapping else parent
return None if str(parent) in self.express_to_cpp_typemapping else parent
def make_type_string(self, type):
if isinstance(type, str):
return self.express_to_cpp_typemapping.get(type, type)
if isinstance(type, (str, nodes.BinaryType)):
return self.express_to_cpp_typemapping.get(str(type), type)
else:
is_list = self.schema.is_entity(type.type)
is_nested_list = isinstance(type.type, nodes.AggregationType)
@@ -83,12 +83,8 @@ class Mapping:
def make_argument_type(self, attr):
def _make_argument_type(type):
if type in self.express_to_cpp_typemapping:
return self.express_to_cpp_typemapping.get(type, type).split('::')[-1].upper()
elif self.schema.is_entity(type) or isinstance(type, nodes.SelectType):
if self.schema.is_entity(type) or isinstance(type, nodes.SelectType):
return "ENTITY_INSTANCE"
elif self.schema.is_type(type):
return _make_argument_type(self.schema.types[type].type.type)
elif isinstance(type, nodes.BinaryType):
return "BINARY"
elif isinstance(type, nodes.EnumerationType):
@@ -97,17 +93,21 @@ class Mapping:
ty = _make_argument_type(type.type)
if ty == "UNKNOWN": return "UNKNOWN"
return "AGGREGATE_OF_" + ty
elif str(type) in self.express_to_cpp_typemapping:
return self.express_to_cpp_typemapping.get(str(type), type).split('::')[-1].upper()
elif self.schema.is_type(type):
return _make_argument_type(self.schema.types[type].type.type)
else:
raise ValueError("Unable to map type %r for attribute %r" % (type, attr))
ty = _make_argument_type(attr.type if hasattr(attr, 'type') else attr)
if ty not in self.supported_argument_types:
print("Attribute %r mapped as 'unknown'" % (type, attr), file=sys.stderr)
print("Attribute %r mapped as 'unknown'" % (attr), file=sys.stderr)
ty = 'UNKNOWN'
return "IfcUtil::Argument_%s" % ty
def get_type_dep(self, type):
if isinstance(type, str):
return self.express_to_cpp_typemapping.get(type, type)
return self.express_to_cpp_typemapping.get(str(type), type)
else:
return self.get_type_dep(type.type)
@@ -124,7 +124,7 @@ class Mapping:
ty = self.get_parameter_type(attr_type.type if is_nested_list else attr_type, False, allow_entities, False)
if self.schema.is_select(attr_type.type):
type_str = templates.untyped_list
elif self.schema.is_simpletype(ty) or ty in self.express_to_cpp_typemapping.values():
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
type_str = tmpl % {
'instance_type' : ty,
+6 -6
View File
@@ -22,15 +22,15 @@ import collections
class Schema:
def is_enumeration(self, v):
return v in self.enumerations
return str(v) in self.enumerations
def is_select(self, v):
return v in self.selects
return str(v) in self.selects
def is_simpletype(self, v):
return v in self.simpletypes
return str(v) in self.simpletypes
def is_type(self, v):
return v in self.types
return str(v) in self.types
def is_entity(self, v):
return v in self.entities
return str(v) in self.entities
def __init__(self, parsetree):
self.name = parsetree[1]
@@ -43,4 +43,4 @@ class Schema:
self.enumerations = of_type(nodes.EnumerationType)
self.selects = of_type(nodes.SelectType)
self.simpletypes = of_type(str, nodes.AggregationType)
self.simpletypes = of_type(str, nodes.AggregationType, nodes.BinaryType)
+9 -2
View File
@@ -164,7 +164,11 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
if (is_interior == !process_interior) continue;
TopoDS_Wire wire;
if (!convert_wire(loop, wire)) break;
if (!convert_wire(loop, wire)) {
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary loop", loop->entity);
delete mf;
return false;
}
/*
The approach below does not result in a significant speed-up
@@ -252,13 +256,16 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcFace* l, TopoDS_Shape& face) {
// Reinitialize the builder to the outer face
// bound in order to add holes more robustly.
delete mf;
// TODO: What about the face_surface?
mf = new BRepBuilderAPI_MakeFace(outer_face_bound);
} else {
face = outer_face_bound;
success = true;
}
} else {
break;
Logger::Message(Logger::LOG_ERROR, "Failed to process face boundary", bound->entity);
delete mf;
return false;
}
} else {
+3 -4
View File
@@ -64,6 +64,8 @@
#include <limits>
#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <gp_Mat.hxx>
#include <gp_Mat2d.hxx>
#include <gp_GTrsf.hxx>
@@ -125,10 +127,7 @@ namespace IfcGeom {
void populate_set(const std::set<std::string>& include_or_ignore) {
entities_to_include_or_exclude.clear();
for (std::set<std::string>::const_iterator it = include_or_ignore.begin(); it != include_or_ignore.end(); ++it) {
std::string uppercase_type = *it;
for (std::string::iterator c = uppercase_type.begin(); c != uppercase_type.end(); ++c) {
*c = toupper(*c);
}
const std::string uppercase_type = boost::to_upper_copy(*it);
IfcSchema::Type::Enum ty;
try {
ty = IfcSchema::Type::FromString(uppercase_type);
@@ -82,6 +82,9 @@ class entity_instance(object):
attr_type = self.attribute_type(idx).title().replace(' ', '')
attr_type = attr_type.replace('Binary', 'String')
attr_type = attr_type.replace('Enumeration', 'String')
try:
if isinstance(value, unicode): value = value.encode("utf-8")
except: pass
getattr(self.wrapped_data, "setArgumentAs%s" % attr_type)(idx, entity_instance.unwrap_value(value))
return value
def __len__(self): return len(self.wrapped_data)
@@ -141,3 +144,6 @@ def create_entity(type,*args,**kwargs):
for idx, arg in attrs: e[idx] = arg
return e
version = ifcopenshell_wrapper.version()
schema_identifier = ifcopenshell_wrapper.schema_identifier()
+10 -3
View File
@@ -288,7 +288,7 @@ UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
#endif
#ifdef HAVE_ICU
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::UTF8;
// Many BIM software (eg. Revit, ArchiCAD, ...) has wrong behavior
bool IfcCharacterDecoder::compatibility_mode = false;
@@ -352,8 +352,15 @@ IfcCharacterEncoder::operator std::string() {
#else
for (std::string::const_iterator i = str.begin(); i != str.end(); ++i) {
char ch = *i;
if ( ch == '\\' || ch == '\'' ) oss.put(ch);
oss.put(ch);
const bool within_spf_range = ch >= 0x20 && ch <= 0x7e;
if (within_spf_range) {
if ( ch == '\\' || ch == '\'' ) {
oss.put(ch);
}
oss.put(ch);
} else {
oss.put('_');
}
}
#endif
oss.put('\'');
+43 -11
View File
@@ -78,8 +78,8 @@ public:
double xx=1.0, double xy=0.0, double xz=0.0);
template <class T>
void addRelatedObject(IfcSchema::IfcObjectDefinition* related_object,
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
void addRelatedObject(IfcSchema::IfcObjectDefinition* relating_object,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist = 0)
{
typename T::list::ptr li = entitiesByType<T>();
bool found = false;
@@ -100,9 +100,9 @@ public:
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcObjectDefinition::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
relating_objects->push(relating_object);
T* t = new T(IfcParse::IfcGlobalId(), owner_hist, boost::none, boost::none, related_object, relating_objects);
IfcSchema::IfcObjectDefinition::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcObjectDefinition>());
related_objects->push(related_object);
T* t = new T(IfcParse::IfcGlobalId(), owner_hist, boost::none, boost::none, relating_object, related_objects);
addEntity(t);
}
}
@@ -174,14 +174,14 @@ private:
};
template <>
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* related_object,
IfcSchema::IfcObjectDefinition* relating_object, IfcSchema::IfcOwnerHistory* owner_hist)
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSpatialStructure> (IfcSchema::IfcObjectDefinition* relating_structure,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist)
{
IfcSchema::IfcRelContainedInSpatialStructure::list::ptr li = entitiesByType<IfcSchema::IfcRelContainedInSpatialStructure>();
bool found = false;
for (IfcSchema::IfcRelContainedInSpatialStructure::list::it i = li->begin(); i != li->end(); ++i) {
IfcSchema::IfcRelContainedInSpatialStructure* rel = *i;
if (rel->RelatingStructure() == relating_object) {
if (rel->RelatingStructure() == relating_structure) {
IfcSchema::IfcProduct::list::ptr products = rel->RelatedElements();
products->push((IfcSchema::IfcProduct*)related_object);
rel->setRelatedElements(products);
@@ -196,10 +196,42 @@ inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelContainedInSp
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcProduct::list::ptr relating_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
relating_objects->push((IfcSchema::IfcProduct*)relating_object);
IfcSchema::IfcProduct::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcProduct>());
related_objects->push((IfcSchema::IfcProduct*)related_object);
IfcSchema::IfcRelContainedInSpatialStructure* t = new IfcSchema::IfcRelContainedInSpatialStructure(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, relating_objects, (IfcSchema::IfcSpatialStructureElement*)related_object);
boost::none, boost::none, related_objects, (IfcSchema::IfcSpatialStructureElement*)relating_structure);
addEntity(t);
}
}
template <>
inline void IfcHierarchyHelper::addRelatedObject <IfcSchema::IfcRelDefinesByType> (IfcSchema::IfcObjectDefinition* relating_type,
IfcSchema::IfcObjectDefinition* related_object, IfcSchema::IfcOwnerHistory* owner_hist)
{
IfcSchema::IfcRelDefinesByType::list::ptr li = entitiesByType<IfcSchema::IfcRelDefinesByType>();
bool found = false;
for (IfcSchema::IfcRelDefinesByType::list::it i = li->begin(); i != li->end(); ++i) {
IfcSchema::IfcRelDefinesByType* rel = *i;
if (rel->RelatingType() == relating_type) {
IfcSchema::IfcObject::list::ptr objects = rel->RelatedObjects();
objects->push((IfcSchema::IfcObject*)related_object);
rel->setRelatedObjects(objects);
found = true;
break;
}
}
if (! found) {
if (! owner_hist) {
owner_hist = getSingle<IfcSchema::IfcOwnerHistory>();
}
if (! owner_hist) {
owner_hist = addOwnerHistory();
}
IfcSchema::IfcObject::list::ptr related_objects (new IfcTemplatedEntityList<IfcSchema::IfcObject>());
related_objects->push((IfcSchema::IfcObject*)related_object);
IfcSchema::IfcRelDefinesByType* t = new IfcSchema::IfcRelDefinesByType(IfcParse::IfcGlobalId(), owner_hist,
boost::none, boost::none, related_objects, (IfcSchema::IfcTypeObject*)relating_type);
addEntity(t);
}
+4 -6
View File
@@ -19,6 +19,8 @@
#include <sstream>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcWritableEntity.h"
#include "../ifcparse/IfcUtil.h"
@@ -44,9 +46,7 @@ IfcWrite::IfcWritableEntity* IfcParse::IfcLateBoundEntity::writable_entity() {
return e;
}
IfcParse::IfcLateBoundEntity::IfcLateBoundEntity(const std::string& s) {
std::string S = s;
for (std::string::iterator i = S.begin(); i != S.end(); ++i ) *i = toupper(*i);
_type = IfcSchema::Type::FromString(S);
_type = IfcSchema::Type::FromString(boost::to_upper_copy(s));
entity = new IfcWrite::IfcWritableEntity(_type);
for (unsigned i = 0; i < getArgumentCount(); ++i) {
// Side effect of this is that a NULL attribute is created.
@@ -78,9 +78,7 @@ std::string IfcParse::IfcLateBoundEntity::is_a() const {
return IfcSchema::Type::ToString(_type);
}
bool IfcParse::IfcLateBoundEntity::is_a(const std::string& s) const {
std::string S = s;
for (std::string::iterator i = S.begin(); i != S.end(); ++i ) *i = toupper(*i);
return is(IfcSchema::Type::FromString(S));
return is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));
}
IfcSchema::Type::Enum IfcParse::IfcLateBoundEntity::type() const {
return _type;
+4 -4
View File
@@ -28,6 +28,8 @@
#include <Windows.h>
#endif
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcException.h"
@@ -855,7 +857,7 @@ std::string Entity::toString(bool upper) const {
std::string dt = datatype();
if (upper) {
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
boost::to_upper(dt);
}
if (!IfcSchema::Type::IsSimple(type()) || _id != 0) {
@@ -1355,9 +1357,7 @@ IfcEntityList::ptr IfcFile::entitiesByType(IfcSchema::Type::Enum t) {
}
IfcEntityList::ptr IfcFile::entitiesByType(const std::string& t) {
std::string ty = t;
for (std::string::iterator p = ty.begin(); p != ty.end(); ++p ) *p = toupper(*p);
return entitiesByType(IfcSchema::Type::FromString(ty));
return entitiesByType(IfcSchema::Type::FromString(boost::to_upper_copy(t)));
}
IfcEntityList::ptr IfcFile::entitiesByReference(int t) {
+3 -1
View File
@@ -20,6 +20,8 @@
#include <iomanip>
#include <locale>
#include <boost/algorithm/string.hpp>
#include "../ifcparse/IfcParse.h"
#include "../ifcparse/IfcWrite.h"
#include "../ifcparse/IfcWritableEntity.h"
@@ -91,7 +93,7 @@ std::string IfcWritableEntity::toString(bool upper) const {
std::string dt = datatype();
if (upper) {
for (std::string::iterator p = dt.begin(); p != dt.end(); ++p ) *p = toupper(*p);
boost::to_upper(dt);
}
if (_id && !IfcSchema::Type::IsSimple(type())) {
+1 -1
View File
@@ -16,7 +16,7 @@ SET(CMAKE_SWIG_FLAGS "")
SET_SOURCE_FILES_PROPERTIES(IfcPython.i PROPERTIES CPLUSPLUS ON)
SWIG_ADD_MODULE(ifcopenshell_wrapper python IfcPython.i)
SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${PYTHON_LIBRARIES} IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKOffset)
SWIG_LINK_LIBRARIES(ifcopenshell_wrapper ${PYTHON_LIBRARIES} IfcParse IfcGeom TKernel TKMath TKBRep TKGeomBase TKGeomAlgo TKG3d TKG2d TKShHealing TKTopAlgo TKMesh TKPrim TKBool TKBO TKFillet TKOffset ${ICU_LIBRARIES})
# To install IfcPython let's get the site-packages dir from python
EXECUTE_PROCESS(COMMAND python -c "import sys; from distutils.sysconfig import get_python_lib; sys.stdout.write(get_python_lib())"
+8 -49
View File
@@ -93,47 +93,6 @@
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, void*, int);
%ignore IfcGeom::Iterator<double>::Iterator(const IfcGeom::IteratorSettings&, std::istream&, int);
// Ignore the std::vector accessors and replace them to pairs that will
// be expanded to Python tuples by means of typemaps. This in order to
// minimize passing STL objects across dynamic library boundaries.
%ignore IfcGeom::Representation::Triangulation::verts;
%ignore IfcGeom::Representation::Triangulation::faces;
%ignore IfcGeom::Representation::Triangulation::edges;
%ignore IfcGeom::Representation::Triangulation::normals;
%ignore IfcGeom::Representation::Triangulation::material_ids;
%ignore IfcGeom::Representation::Triangulation::materials;
%extend IfcGeom::Representation::Triangulation {
std::pair<const int*, unsigned> get_faces() {
return std::make_pair(&$self->faces()[0], $self->faces().size());
}
std::pair<const int*, unsigned> get_edges() {
return std::make_pair(&$self->edges()[0], $self->edges().size());
}
std::pair<const int*, unsigned> get_material_ids() {
return std::make_pair(&$self->material_ids()[0], $self->material_ids().size());
}
std::pair<const IfcGeom::Material*, unsigned> get_materials() {
return std::make_pair(&$self->materials()[0], $self->materials().size());
}
}
%extend IfcGeom::Representation::Triangulation<float> {
std::pair<const float*, unsigned> get_verts() {
return std::make_pair(&$self->verts()[0], $self->verts().size());
}
std::pair<const float*, unsigned> get_normals() {
return std::make_pair(&$self->normals()[0], $self->normals().size());
}
}
%extend IfcGeom::Representation::Triangulation<double> {
std::pair<const double*, unsigned> get_verts() {
return std::make_pair(&$self->verts()[0], $self->verts().size());
}
std::pair<const double*, unsigned> get_normals() {
return std::make_pair(&$self->normals()[0], $self->normals().size());
}
}
%extend IfcGeom::IteratorSettings {
%pythoncode %{
attrs = ("convert_back_units", "deflection_tolerance", "disable_opening_subtractions", "disable_triangulation", "faster_booleans", "sew_shells", "use_brep_data", "use_world_coords", "weld_vertices")
@@ -159,10 +118,10 @@
if _newclass:
# Hide the getters with read-only property implementations
id = property(id)
faces = property(get_faces)
edges = property(get_edges)
material_ids = property(get_material_ids)
materials = property(get_materials)
faces = property(faces)
edges = property(edges)
material_ids = property(material_ids)
materials = property(materials)
%}
};
@@ -172,16 +131,16 @@
%pythoncode %{
if _newclass:
# Hide the getters with read-only property implementations
verts = property(get_verts)
normals = property(get_normals)
verts = property(verts)
normals = property(normals)
%}
};
%extend IfcGeom::Representation::Triangulation<double> {
%pythoncode %{
if _newclass:
# Hide the getters with read-only property implementations
verts = property(get_verts)
normals = property(get_normals)
verts = property(verts)
normals = property(normals)
%}
};
+8
View File
@@ -200,4 +200,12 @@ namespace IfcUtil {
f->Init(s);
return f;
}
const char* const schema_identifier() {
return IfcSchema::Identifier;
}
const char* const version() {
return IFCOPENSHELL_VERSION;
}
%}
+4 -2
View File
@@ -110,9 +110,11 @@
PyObject* pythonize(const unsigned int& t) { return PyInt_FromLong(t); }
PyObject* pythonize(const bool& t) { return PyBool_FromLong(t); }
PyObject* pythonize(const double& t) { return PyFloat_FromDouble(t); }
PyObject* pythonize(const std::string& t) { return PyString_FromString(t.c_str()); }
PyObject* pythonize(const std::string& t) { return PyUnicode_FromString(t.c_str()); }
PyObject* pythonize(const IfcUtil::IfcBaseClass* t) { return SWIG_NewPointerObj(SWIG_as_voidptr(t), SWIGTYPE_p_IfcParse__IfcLateBoundEntity, 0); }
// NB: This cannot be temporary as a Python object is constructed from a pointer to the address of this object
PyObject* pythonize(const IfcGeom::Material& t) { return SWIG_NewPointerObj(SWIG_as_voidptr(&t), SWIGTYPE_p_IfcGeom__Material, 0); }
PyObject* pythonize(const boost::dynamic_bitset<>& t) {
std::string bitstring;
boost::to_string(t, bitstring);
+1
View File
@@ -105,3 +105,4 @@ CREATE_VECTOR_TYPEMAP_OUT(int)
CREATE_VECTOR_TYPEMAP_OUT(unsigned int)
CREATE_VECTOR_TYPEMAP_OUT(double)
CREATE_VECTOR_TYPEMAP_OUT(std::string)
CREATE_VECTOR_TYPEMAP_OUT(IfcGeom::Material)