Further address UCS2 - UCS4 incompatibility, move compatibility layer to ifcwrap/Interface.h

This commit is contained in:
Thomas Krijnen
2011-12-06 10:38:14 +00:00
parent 203dd2107e
commit 479fcd9013
4 changed files with 14 additions and 14 deletions
+11 -4
View File
@@ -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'
-8
View File
@@ -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<int>& fn) {
std::string f;
for ( std::vector<int>::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<Ifc2x3::IfcShapeRepresentation>();
if ( ! shapereps ) return false;
-1
View File
@@ -116,7 +116,6 @@ namespace IfcGeomObjects {
};
bool Init(const std::string fn);
bool Init(const std::vector<int>& 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);
+3 -1
View File
@@ -64,7 +64,9 @@ namespace IfcGeomObjects {
bool Next();
const IfcGeomObject* Get();
bool Init(const std::string fn);
bool Init(const std::vector<int>& 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);