mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 02:47:48 +00:00
Further address UCS2 - UCS4 incompatibility, move compatibility layer to ifcwrap/Interface.h
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user