mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix compilation and execution of IfcConvert
This commit is contained in:
@@ -55,7 +55,7 @@ namespace po = boost::program_options;
|
||||
|
||||
void print_version()
|
||||
{
|
||||
std::cout << "IfcOpenShell " << " IfcConvert " << IFCOPENSHELL_VERSION << " (OCC " << OCC_VERSION_STRING_EXT << ")\n";
|
||||
std::cout << "IfcOpenShell IfcConvert " << IFCOPENSHELL_VERSION << " (OCC " << OCC_VERSION_STRING_EXT << ")\n";
|
||||
}
|
||||
|
||||
void print_usage(bool suggest_help = true)
|
||||
@@ -148,7 +148,7 @@ void parse_filter(geom_filter &, const std::vector<std::string>&);
|
||||
std::vector<IfcGeom::filter_t> setup_filters(const std::vector<geom_filter>&, const std::string&);
|
||||
*/
|
||||
|
||||
bool init_input_file(const std::string& filename, IfcParse::IfcFile* ifc_file, bool no_progress, bool mmap);
|
||||
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap);
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@@ -707,7 +707,7 @@ void write_log() {
|
||||
}
|
||||
}
|
||||
|
||||
bool init_input_file(const std::string& filename, IfcParse::IfcFile* ifc_file, bool no_progress, bool mmap) {
|
||||
bool init_input_file(const std::string& filename, IfcParse::IfcFile*& ifc_file, bool no_progress, bool mmap) {
|
||||
|
||||
// Prevent IfcFile::Init() prints by setting output to null temporarily
|
||||
if (no_progress) { Logger::SetOutput(NULL, &log_stream); }
|
||||
|
||||
@@ -60,10 +60,6 @@ class Implementation(codegen.Base):
|
||||
else templates.parent_type_test%(type.supertypes[0])
|
||||
|
||||
constructor_arguments = mapping.get_assignable_arguments(type, include_derived = True)
|
||||
# if name == "IfcCartesianPoint":
|
||||
# import pprint
|
||||
# pprint.pprint(constructor_arguments)
|
||||
# exit()
|
||||
constructor_arguments_str = catc("%(full_type)s v%(index)d_%(name)s"%a for a in constructor_arguments if not a['is_derived'])
|
||||
attributes = []
|
||||
constructor_implementations = []
|
||||
@@ -203,11 +199,6 @@ class Implementation(codegen.Base):
|
||||
|
||||
simple_type_impl = []
|
||||
for class_name, type in mapping.schema.simpletypes.items():
|
||||
if class_name == "IfcPropertySetDefinitionSet":
|
||||
print(repr(type), type)
|
||||
print(mapping.flatten_type_string(type))
|
||||
print(mapping.make_type_string(mapping.flatten_type_string(type)))
|
||||
|
||||
type_str = mapping.make_type_string(mapping.flatten_type_string(type))
|
||||
attr_type = mapping.make_argument_type(type)
|
||||
superclass = mapping.simple_type_parent(class_name)
|
||||
|
||||
@@ -209,7 +209,7 @@ class SchemaClass(codegen.Base):
|
||||
' return *s;',
|
||||
'}','',''))
|
||||
|
||||
declarations_by_index.sort()
|
||||
declarations_by_index.sort(key=str.lower)
|
||||
declarations_by_index_map = dict(("index_in_schema_%s" % j,i) for i,j in enumerate(declarations_by_index))
|
||||
|
||||
def bind(s):
|
||||
|
||||
@@ -13,21 +13,18 @@ namespace IfcGeom {
|
||||
#define STRINGIFY(x) #x
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
|
||||
void MAKE_INIT_FN(IteratorImplementation_)() {
|
||||
template <typename P>
|
||||
void MAKE_INIT_FN(IteratorImplementation_)(IteratorFactoryImplementation<P>* mapping) {
|
||||
static const std::string schema_name = TOSTRING(IfcSchema);
|
||||
|
||||
struct {
|
||||
IfcGeom::IteratorImplementation<float>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) const {
|
||||
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<float>(settings, file);
|
||||
IfcGeom::IteratorImplementation<P>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) const {
|
||||
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<P>(settings, file);
|
||||
}
|
||||
} factory_float;
|
||||
} factory;
|
||||
|
||||
struct {
|
||||
IfcGeom::IteratorImplementation<double>* operator()(const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) const {
|
||||
return new IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<double>(settings, file);
|
||||
}
|
||||
} factory_double;
|
||||
mapping->bind(schema_name, factory);
|
||||
}
|
||||
|
||||
static Registrar< IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<float> > float_registration(schema_name, factory_float);
|
||||
static Registrar< IfcGeom::MAKE_TYPE_NAME(IteratorImplementation_)<double> > double_registration(schema_name, factory_double);
|
||||
}
|
||||
template void MAKE_INIT_FN(IteratorImplementation_)<float>(IteratorFactoryImplementation<float>*);
|
||||
template void MAKE_INIT_FN(IteratorImplementation_)<double>(IteratorFactoryImplementation<double>*);
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "IteratorImplementation.h"
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
|
||||
template <typename P>
|
||||
IteratorFactoryImplementation<P>& iterator_implementations() {
|
||||
static IteratorFactoryImplementation<P> impl;
|
||||
@@ -9,23 +11,29 @@ IteratorFactoryImplementation<P>& iterator_implementations() {
|
||||
template IteratorFactoryImplementation<float>& iterator_implementations<float>();
|
||||
template IteratorFactoryImplementation<double>& iterator_implementations<double>();
|
||||
|
||||
#define INIT(a) extern void init_##a(); init_##a();
|
||||
template <typename P>
|
||||
extern void init_IteratorImplementation_Ifc2x3(IteratorFactoryImplementation<P>*);
|
||||
|
||||
template <typename P>
|
||||
extern void init_IteratorImplementation_Ifc4(IteratorFactoryImplementation<P>*);
|
||||
|
||||
template <typename P>
|
||||
IteratorFactoryImplementation<P>::IteratorFactoryImplementation() {
|
||||
INIT(IteratorImplementation_Ifc2x3);
|
||||
INIT(IteratorImplementation_Ifc4);
|
||||
init_IteratorImplementation_Ifc2x3(this);
|
||||
init_IteratorImplementation_Ifc4(this);
|
||||
}
|
||||
|
||||
template <class P>
|
||||
void IteratorFactoryImplementation<P>::bind(const std::string& schema_name, typename get_factory_type<P>::type fn) {
|
||||
this->insert(std::make_pair(schema_name, fn));
|
||||
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
||||
this->insert(std::make_pair(schema_name_lower, fn));
|
||||
}
|
||||
|
||||
template <class P>
|
||||
IfcGeom::IteratorImplementation<P>* IteratorFactoryImplementation<P>::construct(const std::string& schema_name, const IfcGeom::IteratorSettings& settings, IfcParse::IfcFile* file) {
|
||||
const std::string schema_name_lower = boost::to_lower_copy(schema_name);
|
||||
std::map<std::string, typename get_factory_type<P>::type>::const_iterator it;
|
||||
it = this->find(schema_name);
|
||||
it = this->find(schema_name_lower);
|
||||
if (it == end()) {
|
||||
throw IfcParse::IfcException("No geometry iterator registered for " + schema_name);
|
||||
}
|
||||
|
||||
+672
-672
File diff suppressed because it is too large
Load Diff
+750
-750
File diff suppressed because it is too large
Load Diff
@@ -1938,7 +1938,9 @@ void IfcFile::setDefaultHeaderValues() {
|
||||
std::vector<std::string> file_description, schema_identifiers, empty_vector;
|
||||
|
||||
file_description.push_back("ViewDefinition [CoordinationView]");
|
||||
schema_identifiers.push_back(schema()->name());
|
||||
if (schema()) {
|
||||
schema_identifiers.push_back(schema()->name());
|
||||
}
|
||||
|
||||
header().file_description().description(file_description);
|
||||
header().file_description().implementation_level("2;1");
|
||||
|
||||
@@ -60,7 +60,14 @@ IfcParse::schema_definition::~schema_definition() {
|
||||
}
|
||||
}
|
||||
|
||||
#include "../ifcparse/Ifc2x3.h"
|
||||
#include "../ifcparse/Ifc4.h"
|
||||
|
||||
const IfcParse::schema_definition* IfcParse::schema_by_name(const std::string& name) {
|
||||
// TODO: initialize automatically somehow
|
||||
Ifc2x3::get_schema();
|
||||
Ifc4::get_schema();
|
||||
|
||||
std::map<std::string, const IfcParse::schema_definition*>::const_iterator it = schemas.find(name);
|
||||
if (it == schemas.end()) {
|
||||
throw IfcParse::IfcException("No schema named " + name);
|
||||
|
||||
@@ -119,16 +119,18 @@ namespace IfcParse {
|
||||
|
||||
class declaration {
|
||||
protected:
|
||||
std::string name_;
|
||||
std::string name_, name_lower_;
|
||||
int index_in_schema_;
|
||||
|
||||
public:
|
||||
declaration(const std::string& name, int index_in_schema)
|
||||
: name_(name)
|
||||
, name_lower_(boost::to_lower_copy(name))
|
||||
, index_in_schema_(index_in_schema)
|
||||
{}
|
||||
|
||||
std::string name() const { return name_; }
|
||||
std::string name_lc() const { return name_lower_; }
|
||||
|
||||
virtual const type_declaration* as_type_declaration() const { return static_cast<type_declaration*>(0); }
|
||||
virtual const select_type* as_select_type() const { return static_cast<select_type*>(0); }
|
||||
@@ -392,8 +394,7 @@ namespace IfcParse {
|
||||
class declaration_by_name_cmp : public std::binary_function<const declaration*, const std::string&, bool> {
|
||||
public:
|
||||
bool operator()(const declaration* decl, const std::string& name) {
|
||||
// TODO: Efficiency?
|
||||
return boost::to_lower_copy(decl->name()) < boost::to_lower_copy(name);
|
||||
return decl->name_lc() < name;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -413,8 +414,9 @@ namespace IfcParse {
|
||||
~schema_definition();
|
||||
|
||||
const declaration* declaration_by_name(const std::string& name) const {
|
||||
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), name, declaration_by_name_cmp());
|
||||
if (it == declarations_.end() || boost::to_lower_copy((**it).name()) != boost::to_lower_copy(name)) {
|
||||
const std::string name_lower = boost::to_lower_copy(name);
|
||||
std::vector<const declaration*>::const_iterator it = std::lower_bound(declarations_.begin(), declarations_.end(), name_lower, declaration_by_name_cmp());
|
||||
if (it == declarations_.end() || (**it).name_lc() != name_lower) {
|
||||
throw IfcParse::IfcException("Entity with '" + name + "' not found");
|
||||
} else {
|
||||
return *it;
|
||||
|
||||
Reference in New Issue
Block a user