From 479fcd9013393e9693acae0aa29238a03a7d5a30 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Tue, 6 Dec 2011 10:38:14 +0000 Subject: [PATCH] Further address UCS2 - UCS4 incompatibility, move compatibility layer to ifcwrap/Interface.h --- src/ifcblender/io_import_scene_ifc/__init__.py | 15 +++++++++++---- src/ifcgeom/IfcGeomObjects.cpp | 8 -------- src/ifcgeom/IfcGeomObjects.h | 1 - src/ifcwrap/Interface.h | 4 +++- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ifcblender/io_import_scene_ifc/__init__.py b/src/ifcblender/io_import_scene_ifc/__init__.py index bfc02e27e1..7c57f5af79 100644 --- a/src/ifcblender/io_import_scene_ifc/__init__.py +++ b/src/ifcblender/io_import_scene_ifc/__init__.py @@ -44,7 +44,8 @@ max_unicode = 0x110000-1 if sys.platform[0:5] == 'linux' else 0x10000-1 wrong_unicode = max_unicode != sys.maxunicode if wrong_unicode: print("\nWarning: wrong unicode representation detected, switching to "\ - "compatibility layer for text transferral\n") + "compatibility layer for text transferral, may result in undefined "\ + "behaviour, please use offical release from http://blender.org\n") if "bpy" in locals(): import imp @@ -71,9 +72,9 @@ def import_ifc(filename, use_names, process_relations): from . import IfcImport print("Reading %s..."%bpy.path.basename(filename)) if wrong_unicode: - vec = IfcImport.IntVector(len(filename)) - for i in range(len(filename)): vec[i] = ord(filename[i]) - valid_file = IfcImport.Init(vec) + valid_file = IfcImport.InitUCS2( + ''.join(['\0']+['\0%s'%s for s in filename]+['\0\0']) + ) else: valid_file = IfcImport.Init(filename) if not valid_file: @@ -233,6 +234,12 @@ class ImportIFC(bpy.types.Operator, ImportHelper): default=False) def execute(self, context): + global wrong_unicode + if wrong_unicode and sys.platform[0:5] != 'linux': + self.report({'ERROR'}, + 'Your version of Blender is incompatible with IfcBlender\n' \ + 'Please use the offical release from http://blender.org instead' + ) if not import_ifc(self.filepath, self.use_names, self.process_relations): self.report({'ERROR'}, 'Unable to parse .ifc file or no geometrical entities found' diff --git a/src/ifcgeom/IfcGeomObjects.cpp b/src/ifcgeom/IfcGeomObjects.cpp index d5db0ace67..1b227a0b58 100644 --- a/src/ifcgeom/IfcGeomObjects.cpp +++ b/src/ifcgeom/IfcGeomObjects.cpp @@ -435,14 +435,6 @@ const IfcGeomObjects::IfcGeomObject* IfcGeomObjects::Get() { bool IfcGeomObjects::Init(const std::string fn) { return IfcGeomObjects::Init(fn, 0, 0); } -bool IfcGeomObjects::Init(const std::vector& fn) { - std::string f; - for ( std::vector::const_iterator it = fn.begin(); it != fn.end(); ++ it ) { - const char c = (char) *it; - f.push_back(c); - } - return IfcGeomObjects::Init(f, 0, 0); -} bool _Init() { shapereps = Ifc::EntitiesByType(); if ( ! shapereps ) return false; diff --git a/src/ifcgeom/IfcGeomObjects.h b/src/ifcgeom/IfcGeomObjects.h index de239ec59b..f24af91d49 100644 --- a/src/ifcgeom/IfcGeomObjects.h +++ b/src/ifcgeom/IfcGeomObjects.h @@ -116,7 +116,6 @@ namespace IfcGeomObjects { }; bool Init(const std::string fn); - bool Init(const std::vector& fn); bool Init(void* data, int len); bool Init(const std::string fn, std::ostream* log1= 0, std::ostream* log2= 0); bool Init(std::istream& f, int len, std::ostream* log1= 0, std::ostream* log2= 0); diff --git a/src/ifcwrap/Interface.h b/src/ifcwrap/Interface.h index ebbd2b14b2..1297a0bdce 100644 --- a/src/ifcwrap/Interface.h +++ b/src/ifcwrap/Interface.h @@ -64,7 +64,9 @@ namespace IfcGeomObjects { bool Next(); const IfcGeomObject* Get(); bool Init(const std::string fn); - bool Init(const std::vector& fn); + bool InitUCS2(const char* fn) { + return Init(std::string(fn+1)); + } void Settings(int setting, bool value); int Progress(); const IfcObject* GetObject(int id);