mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 08:52:27 +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
|
wrong_unicode = max_unicode != sys.maxunicode
|
||||||
if wrong_unicode:
|
if wrong_unicode:
|
||||||
print("\nWarning: wrong unicode representation detected, switching to "\
|
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():
|
if "bpy" in locals():
|
||||||
import imp
|
import imp
|
||||||
@@ -71,9 +72,9 @@ def import_ifc(filename, use_names, process_relations):
|
|||||||
from . import IfcImport
|
from . import IfcImport
|
||||||
print("Reading %s..."%bpy.path.basename(filename))
|
print("Reading %s..."%bpy.path.basename(filename))
|
||||||
if wrong_unicode:
|
if wrong_unicode:
|
||||||
vec = IfcImport.IntVector(len(filename))
|
valid_file = IfcImport.InitUCS2(
|
||||||
for i in range(len(filename)): vec[i] = ord(filename[i])
|
''.join(['\0']+['\0%s'%s for s in filename]+['\0\0'])
|
||||||
valid_file = IfcImport.Init(vec)
|
)
|
||||||
else:
|
else:
|
||||||
valid_file = IfcImport.Init(filename)
|
valid_file = IfcImport.Init(filename)
|
||||||
if not valid_file:
|
if not valid_file:
|
||||||
@@ -233,6 +234,12 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
|||||||
default=False)
|
default=False)
|
||||||
|
|
||||||
def execute(self, context):
|
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):
|
if not import_ifc(self.filepath, self.use_names, self.process_relations):
|
||||||
self.report({'ERROR'},
|
self.report({'ERROR'},
|
||||||
'Unable to parse .ifc file or no geometrical entities found'
|
'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) {
|
bool IfcGeomObjects::Init(const std::string fn) {
|
||||||
return IfcGeomObjects::Init(fn, 0, 0);
|
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() {
|
bool _Init() {
|
||||||
shapereps = Ifc::EntitiesByType<Ifc2x3::IfcShapeRepresentation>();
|
shapereps = Ifc::EntitiesByType<Ifc2x3::IfcShapeRepresentation>();
|
||||||
if ( ! shapereps ) return false;
|
if ( ! shapereps ) return false;
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ namespace IfcGeomObjects {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool Init(const std::string fn);
|
bool Init(const std::string fn);
|
||||||
bool Init(const std::vector<int>& fn);
|
|
||||||
bool Init(void* data, int len);
|
bool Init(void* data, int len);
|
||||||
bool Init(const std::string fn, std::ostream* log1= 0, std::ostream* log2= 0);
|
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);
|
bool Init(std::istream& f, int len, std::ostream* log1= 0, std::ostream* log2= 0);
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ namespace IfcGeomObjects {
|
|||||||
bool Next();
|
bool Next();
|
||||||
const IfcGeomObject* Get();
|
const IfcGeomObject* Get();
|
||||||
bool Init(const std::string fn);
|
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);
|
void Settings(int setting, bool value);
|
||||||
int Progress();
|
int Progress();
|
||||||
const IfcObject* GetObject(int id);
|
const IfcObject* GetObject(int id);
|
||||||
|
|||||||
Reference in New Issue
Block a user