mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Refactor
This commit is contained in:
+1614
-392
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,17 @@
|
||||
namespace IfcParse {
|
||||
|
||||
class IfcHdf5File {
|
||||
public:
|
||||
enum Profile {
|
||||
standard,
|
||||
padded,
|
||||
standard_referenced,
|
||||
padded_referenced
|
||||
};
|
||||
|
||||
private:
|
||||
Profile profile_;
|
||||
|
||||
class allocator_t {
|
||||
private:
|
||||
// TODO: Change this?
|
||||
@@ -57,6 +67,7 @@ namespace IfcParse {
|
||||
|
||||
std::string name_;
|
||||
schema_definition schema_;
|
||||
IfcFile& ifcfile_;
|
||||
|
||||
H5::H5File* file;
|
||||
H5::Group schema_group;
|
||||
@@ -68,10 +79,12 @@ namespace IfcParse {
|
||||
|
||||
std::map<IfcSchema::Type::Enum, H5::DataType*> declared_types;
|
||||
// TODO: why? get_datatype()
|
||||
/*
|
||||
std::map<IfcParse::simple_type::data_type, const H5::DataType*> default_types;
|
||||
std::map<std::string, const H5::DataType*> overridden_types;
|
||||
std::map<IfcParse::simple_type::data_type, std::string> default_type_names;
|
||||
std::map<IfcUtil::ArgumentType, std::string> default_cpp_type_names;
|
||||
*/
|
||||
|
||||
#ifdef SORT_ON_NAME
|
||||
std::map<IfcSchema::Type::Enum, std::vector<uint32_t> > sorted_entities;
|
||||
@@ -89,9 +102,9 @@ namespace IfcParse {
|
||||
void visit_select(const IfcParse::select_type* pt, std::set<const IfcParse::declaration*>& leafs);
|
||||
std::string flatten_aggregate_name(const IfcParse::parameter_type* at) const;
|
||||
std::pair<size_t, size_t> make_instance_reference(const IfcUtil::IfcBaseClass* instance) const;
|
||||
void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
|
||||
// void write_select(void*& ptr, IfcUtil::IfcBaseClass* instance, const H5::CompType* datatype) const;
|
||||
|
||||
void write_schema(const schema_definition& schema);
|
||||
void write_schema(const schema_definition& schema, IfcFile& f);
|
||||
void write_population(IfcFile& f);
|
||||
|
||||
template <typename T>
|
||||
@@ -99,6 +112,7 @@ namespace IfcParse {
|
||||
return default_types.find(IfcUtil::cpp_to_schema_type<T>::schema_type)->second;
|
||||
}
|
||||
|
||||
/*
|
||||
void advance(void*& ptr, size_t n) const;
|
||||
|
||||
template <typename T>
|
||||
@@ -112,28 +126,49 @@ namespace IfcParse {
|
||||
template <typename T>
|
||||
void write_number_of_size(void*& ptr, size_t n, T i) const;
|
||||
|
||||
void write_string_of_size(void*& ptr, const std::string& s, size_t n) const;
|
||||
|
||||
template <typename T>
|
||||
void write_aggregate(void*& ptr, const T& ts) const;
|
||||
|
||||
template <typename T>
|
||||
void write_consecutive(void*& ptr, const std::vector<T>& ts, hsize_t* num = 0, size_t* elem_size=0) const;
|
||||
|
||||
template <typename T>
|
||||
void write_aggregate2(void*& ptr, const std::vector< std::vector<T> >& ts) const;
|
||||
|
||||
template <typename T>
|
||||
void write_consecutive2(void*& ptr, const std::vector< std::vector<T> >& ts, hsize_t* num = 0, size_t* elem_size = 0) const;
|
||||
|
||||
template <typename T>
|
||||
void write_reference_attribute(void*& ptr, const std::string& dsn, const std::vector<T>& vs);
|
||||
|
||||
template <typename T>
|
||||
void write_reference_attribute2(void*& ptr, const std::string& dsn, const std::vector< std::vector<T> >& vs);
|
||||
|
||||
const H5::DataType* specify_length(const H5::DataType* dt, const size_t* n);
|
||||
*/
|
||||
|
||||
H5::DataSet create_dataset(const std::string& path, H5::DataType datatype, int rank, hsize_t* dimensions);
|
||||
|
||||
template <typename T>
|
||||
void write_instance(void*& ptr, T& visitor, H5::DataType& datatype, IfcUtil::IfcBaseEntity* v);
|
||||
|
||||
// TODO: Obviously change this;
|
||||
void* mapper_;
|
||||
public:
|
||||
typedef std::pair<std::string, const H5::DataType*> compound_member;
|
||||
|
||||
IfcHdf5File(IfcFile* f, const std::string& name, const Hdf5Settings& settings)
|
||||
: name_(name)
|
||||
|
||||
|
||||
IfcHdf5File(IfcFile* f, const std::string& name, const Hdf5Settings& settings, Profile profile)
|
||||
: profile_(profile)
|
||||
, name_(name)
|
||||
, schema_(*f->schema())
|
||||
, ifcfile_(*f)
|
||||
, settings_(settings)
|
||||
{
|
||||
write_schema(*f->schema());
|
||||
write_population(*f);
|
||||
write_schema(schema_, ifcfile_);
|
||||
write_population(ifcfile_);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1552,5 +1552,5 @@ std::pair<IfcSchema::IfcNamedUnit*, double> IfcFile::getUnit(IfcSchema::IfcUnitE
|
||||
}
|
||||
|
||||
void IfcFile::write_hdf5(const std::string& name, const Hdf5Settings& settings) {
|
||||
IfcHdf5File(this, name, settings);
|
||||
IfcHdf5File(this, name, settings, IfcHdf5File::standard);
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace IfcParse {
|
||||
|
||||
class simple_type : public parameter_type {
|
||||
public:
|
||||
typedef enum { binary_type, boolean_type, integer_type, logical_type, number_type, real_type, string_type } data_type;
|
||||
typedef enum { binary_type, boolean_type, integer_type, logical_type, number_type, real_type, string_type, datatype_COUNT } data_type;
|
||||
protected:
|
||||
data_type declared_type_;
|
||||
public:
|
||||
|
||||
+24
-1
@@ -232,7 +232,7 @@ public:
|
||||
}
|
||||
outer_it begin() const { return ls.begin(); }
|
||||
outer_it end() const { return ls.end(); }
|
||||
int size() const { return (int)ls.size(); }
|
||||
unsigned int size() const { return (unsigned int)ls.size(); }
|
||||
int totalSize() const {
|
||||
int accum = 0;
|
||||
for (outer_it it = begin(); it != end(); ++it) {
|
||||
@@ -379,4 +379,27 @@ public:
|
||||
static std::string GetLog();
|
||||
};
|
||||
|
||||
namespace IfcUtil {
|
||||
template <ArgumentType>
|
||||
struct attr_type_to_cpp_type;
|
||||
template <> struct attr_type_to_cpp_type <Argument_INT> { typedef int cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_BOOL> { typedef bool cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_DOUBLE> { typedef double cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_STRING> { typedef std::string cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_BINARY> { typedef boost::dynamic_bitset<> cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_ENTITY_INSTANCE> { typedef IfcUtil::IfcBaseClass* cpp_type; };
|
||||
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_INT> { typedef std::vector<int> cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BOOL> { typedef std::vector<bool> cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_DOUBLE> { typedef std::vector<double> cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_STRING> { typedef std::vector<std::string> cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_BINARY> { typedef std::vector< boost::dynamic_bitset<> > cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_ENTITY_INSTANCE> { typedef IfcEntityList::ptr cpp_type; };
|
||||
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_INT> { typedef std::vector< std::vector<int> > cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_BOOL> { typedef std::vector< std::vector<bool> > cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_DOUBLE> { typedef std::vector< std::vector<double> > cpp_type; };
|
||||
template <> struct attr_type_to_cpp_type <Argument_AGGREGATE_OF_AGGREGATE_OF_ENTITY_INSTANCE> { typedef IfcEntityListList::ptr cpp_type; };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
:: Usage: call cecho.cmd background foreground "message here"
|
||||
:: NOTES/TODOS 1) This is super slow 2) leading spaces are omitted 3) printing string with quotes doesn't work (quotes must be escaped awkwardly)
|
||||
@powershell -command write-host -background %~1 -foreground "%~2" "%3"
|
||||
:: @powershell -command write-host -background %~1 -foreground "%~2" "%3"
|
||||
echo %3
|
||||
@exit /b
|
||||
|
||||
Reference in New Issue
Block a user