mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Made changes accordign to PR review
This commit is contained in:
@@ -409,11 +409,11 @@ if(HDF5_SUPPORT)
|
|||||||
"${HDF5_LIBRARY_DIR}/libaec.lib")
|
"${HDF5_LIBRARY_DIR}/libaec.lib")
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(HDF5_LIBRARIES
|
SET(HDF5_LIBRARIES
|
||||||
"${HDF5_LIBRARY_DIR}/hdf5_cpp.lib"
|
"${HDF5_LIBRARY_DIR}/hdf5_cpp.a"
|
||||||
"${HDF5_LIBRARY_DIR}/hdf5.lib"
|
"${HDF5_LIBRARY_DIR}/hdf5.a"
|
||||||
"${HDF5_LIBRARY_DIR}/libzlib.lib"
|
"${HDF5_LIBRARY_DIR}/libzlib.a"
|
||||||
"${HDF5_LIBRARY_DIR}/libsz.lib"
|
"${HDF5_LIBRARY_DIR}/libsz.a"
|
||||||
"${HDF5_LIBRARY_DIR}/libaec.lib"
|
"${HDF5_LIBRARY_DIR}/libaec.a"
|
||||||
zlib)
|
zlib)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -627,11 +627,11 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
path_t output_temp_filename = output_filename + IfcUtil::path::from_utf8(TEMP_FILE_EXTENSION);
|
path_t output_temp_filename = output_filename + IfcUtil::path::from_utf8(TEMP_FILE_EXTENSION);
|
||||||
|
|
||||||
std::vector<std::wstring> tokens;
|
std::vector<path_t> tokens;
|
||||||
split(tokens, output_filename, boost::is_any_of("."));
|
split(tokens, output_filename, boost::is_any_of("."));
|
||||||
std::vector<std::wstring>::iterator tok_iter;
|
std::vector<path_t>::iterator tok_iter;
|
||||||
std::wstring ext = *(tokens.end() - 1);
|
path_t ext = *(tokens.end() - 1);
|
||||||
std::wstring dot;
|
path_t dot;
|
||||||
dot = '.';
|
dot = '.';
|
||||||
path_t output_extension = dot + ext;
|
path_t output_extension = dot + ext;
|
||||||
|
|
||||||
@@ -806,7 +806,6 @@ int main(int argc, char** argv) {
|
|||||||
serializer = boost::make_shared<SvgSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
serializer = boost::make_shared<SvgSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
||||||
}
|
}
|
||||||
else if (output_extension == HDF) {
|
else if (output_extension == HDF) {
|
||||||
const path_t mtl_filename = change_extension(output_filename, MTL);
|
|
||||||
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
|
settings.set(IfcGeom::IteratorSettings::DISABLE_TRIANGULATION, true);
|
||||||
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,6 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
typedef struct s1_t {
|
|
||||||
int a, b, c;
|
|
||||||
} s1_t;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct s2_t {
|
|
||||||
double a, b, c;
|
|
||||||
} s2_t;
|
|
||||||
|
|
||||||
HdfSerializer::HdfSerializer(const std::string& hdf_filename, const SerializerSettings& settings)
|
HdfSerializer::HdfSerializer(const std::string& hdf_filename, const SerializerSettings& settings)
|
||||||
: GeometrySerializer(settings)
|
: GeometrySerializer(settings)
|
||||||
@@ -44,40 +36,9 @@ HdfSerializer::HdfSerializer(const std::string& hdf_filename, const SerializerSe
|
|||||||
, DATASET_NAME_NORMALS("Normals")
|
, DATASET_NAME_NORMALS("Normals")
|
||||||
, DATASET_NAME_INDICES("Indices")
|
, DATASET_NAME_INDICES("Indices")
|
||||||
, DATASET_NAME_OCCT("OCCT Text")
|
, DATASET_NAME_OCCT("OCCT Text")
|
||||||
, mtype1(sizeof(s1_t))
|
|
||||||
, mtype2(sizeof(s2_t))
|
|
||||||
, mtype3(sizeof(s1_t))
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
guids = {};
|
guids = {};
|
||||||
|
|
||||||
H5::IntType Intdatatype(H5::PredType::NATIVE_INT);
|
|
||||||
H5::FloatType datatype(H5::PredType::NATIVE_DOUBLE);
|
|
||||||
datatype.setOrder(H5T_ORDER_LE);
|
|
||||||
Intdatatype.setOrder(H5T_ORDER_LE);
|
|
||||||
|
|
||||||
const H5std_string MEMBER1("V1");
|
|
||||||
const H5std_string MEMBER2("V2");
|
|
||||||
const H5std_string MEMBER3("V3");
|
|
||||||
mtype1.insertMember(MEMBER1, HOFFSET(s1_t, a), H5::PredType::NATIVE_INT);
|
|
||||||
mtype1.insertMember(MEMBER2, HOFFSET(s1_t, c), H5::PredType::NATIVE_INT);
|
|
||||||
mtype1.insertMember(MEMBER3, HOFFSET(s1_t, b), H5::PredType::NATIVE_INT);
|
|
||||||
|
|
||||||
const H5std_string POS1("X");
|
|
||||||
const H5std_string POS2("Y");
|
|
||||||
const H5std_string POS3("Z");
|
|
||||||
mtype2.insertMember(POS1, HOFFSET(s2_t, a), datatype);
|
|
||||||
mtype2.insertMember(POS2, HOFFSET(s2_t, b), datatype);
|
|
||||||
mtype2.insertMember(POS3, HOFFSET(s2_t, c), datatype);
|
|
||||||
|
|
||||||
const H5std_string NOR1("X");
|
|
||||||
const H5std_string NOR2("Y");
|
|
||||||
const H5std_string NOR3("Z");
|
|
||||||
mtype3.insertMember(NOR1, HOFFSET(s1_t, a), Intdatatype);
|
|
||||||
mtype3.insertMember(NOR2, HOFFSET(s1_t, b), Intdatatype);
|
|
||||||
mtype3.insertMember(NOR3, HOFFSET(s1_t, c), Intdatatype);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,8 +84,8 @@ void HdfSerializer::write(const IfcGeom::BRepElement<real_t>* o) {
|
|||||||
|
|
||||||
guids.insert(guid);
|
guids.insert(guid);
|
||||||
elementGroup = file.createGroup(guid);
|
elementGroup = file.createGroup(guid);
|
||||||
meshGroup = elementGroup.createGroup("Triangle Mesh");
|
|
||||||
|
|
||||||
|
meshGroup = elementGroup.createGroup("Triangle Mesh");
|
||||||
OCCTGroup = elementGroup.createGroup("OCCT Data");
|
OCCTGroup = elementGroup.createGroup("OCCT Data");
|
||||||
|
|
||||||
H5::StrType str_type(0, H5T_VARIABLE);
|
H5::StrType str_type(0, H5T_VARIABLE);
|
||||||
@@ -135,12 +96,12 @@ void HdfSerializer::write(const IfcGeom::BRepElement<real_t>* o) {
|
|||||||
const int RANK = 2;
|
const int RANK = 2;
|
||||||
hsize_t dimsf[2];
|
hsize_t dimsf[2];
|
||||||
dimsf[0] = vcount;
|
dimsf[0] = vcount;
|
||||||
dimsf[1] = 1;
|
dimsf[1] = 3;
|
||||||
H5::DataSpace dataspace(RANK, dimsf);
|
H5::DataSpace dataspace(RANK, dimsf);
|
||||||
|
|
||||||
hsize_t dimsfaces[2];
|
hsize_t dimsfaces[2];
|
||||||
dimsfaces[0] = fcount;
|
dimsfaces[0] = fcount;
|
||||||
dimsfaces[1] = 1;
|
dimsfaces[1] = 3;
|
||||||
H5::DataSpace face_dataspace(RANK, dimsfaces);
|
H5::DataSpace face_dataspace(RANK, dimsfaces);
|
||||||
|
|
||||||
const int RANK_OCCT = 1;
|
const int RANK_OCCT = 1;
|
||||||
@@ -151,57 +112,14 @@ void HdfSerializer::write(const IfcGeom::BRepElement<real_t>* o) {
|
|||||||
OCCTDataset = OCCTGroup.createDataSet(DATASET_NAME_OCCT, str_type, occt_dataspace);
|
OCCTDataset = OCCTGroup.createDataSet(DATASET_NAME_OCCT, str_type, occt_dataspace);
|
||||||
OCCTDataset.write(brep_data, str_type);
|
OCCTDataset.write(brep_data, str_type);
|
||||||
|
|
||||||
indicesDataset = meshGroup.createDataSet(DATASET_NAME_INDICES, mtype1, face_dataspace);
|
indicesDataset = meshGroup.createDataSet(DATASET_NAME_INDICES, H5::PredType::NATIVE_INT, face_dataspace);
|
||||||
positionsDataset = meshGroup.createDataSet(DATASET_NAME_POSITIONS, mtype2, dataspace);
|
positionsDataset = meshGroup.createDataSet(DATASET_NAME_POSITIONS, H5::PredType::NATIVE_DOUBLE, dataspace);
|
||||||
normalsDataset = meshGroup.createDataSet(DATASET_NAME_NORMALS, mtype3, dataspace);
|
normalsDataset = meshGroup.createDataSet(DATASET_NAME_NORMALS, H5::PredType::NATIVE_DOUBLE, dataspace);
|
||||||
|
|
||||||
for (std::vector<real_t>::const_iterator it = mesh.verts().begin(); it != mesh.verts().end(); ) {
|
|
||||||
const real_t x = *(it++);
|
|
||||||
const real_t y = *(it++);
|
|
||||||
const real_t z = *(it++);
|
|
||||||
|
|
||||||
if (isyup) {
|
|
||||||
double_data_container.push_back(x);
|
|
||||||
double_data_container.push_back(z);
|
|
||||||
double_data_container.push_back(-y);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
double_data_container.push_back(x);
|
|
||||||
double_data_container.push_back(y);
|
|
||||||
double_data_container.push_back(z);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
positionsDataset.write(mesh.verts().data(), H5::PredType::NATIVE_DOUBLE);
|
||||||
|
normalsDataset.write(mesh.normals().data(), H5::PredType::NATIVE_DOUBLE);
|
||||||
|
indicesDataset.write(mesh.faces().data(), H5::PredType::NATIVE_INT);
|
||||||
|
|
||||||
}
|
|
||||||
positionsDataset.write(double_data_container.data(), mtype2);
|
|
||||||
double_data_container.clear();
|
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<real_t>::const_iterator it = mesh.normals().begin(); it != mesh.normals().end(); ) {
|
|
||||||
const real_t x = *(it++);
|
|
||||||
const real_t y = *(it++);
|
|
||||||
const real_t z = *(it++);
|
|
||||||
int_data_container.push_back((int)x);
|
|
||||||
int_data_container.push_back((int)y);
|
|
||||||
int_data_container.push_back((int)z);
|
|
||||||
|
|
||||||
}
|
|
||||||
normalsDataset.write(int_data_container.data(), mtype3);
|
|
||||||
int_data_container.clear();
|
|
||||||
|
|
||||||
|
|
||||||
for (std::vector<int>::const_iterator it = mesh.faces().begin(); it != mesh.faces().end(); ) {
|
|
||||||
const real_t x = *(it++);
|
|
||||||
const real_t y = *(it++);
|
|
||||||
const real_t z = *(it++);
|
|
||||||
int_data_container.push_back(x);
|
|
||||||
int_data_container.push_back(y);
|
|
||||||
int_data_container.push_back(z);
|
|
||||||
|
|
||||||
}
|
|
||||||
indicesDataset.write(int_data_container.data(), mtype1);
|
|
||||||
int_data_container.clear();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,22 +28,17 @@
|
|||||||
|
|
||||||
#include "../serializers/GeometrySerializer.h"
|
#include "../serializers/GeometrySerializer.h"
|
||||||
|
|
||||||
// http://people.sc.fsu.edu/~jburkardt/txt/obj_format.txt
|
|
||||||
class HdfSerializer : public GeometrySerializer {
|
class HdfSerializer : public GeometrySerializer {
|
||||||
private:
|
private:
|
||||||
const std::string hdf_filename;
|
const std::string hdf_filename;
|
||||||
unsigned int vcount_total;
|
unsigned int vcount_total;
|
||||||
H5::H5File file;
|
H5::H5File file;
|
||||||
std::set<std::string> guids;
|
std::set<std::string> guids;
|
||||||
std::vector<double> double_data_container;
|
|
||||||
std::vector<int> int_data_container;
|
|
||||||
const H5std_string DATASET_NAME_POSITIONS;
|
const H5std_string DATASET_NAME_POSITIONS;
|
||||||
const H5std_string DATASET_NAME_NORMALS;
|
const H5std_string DATASET_NAME_NORMALS;
|
||||||
const H5std_string DATASET_NAME_INDICES;
|
const H5std_string DATASET_NAME_INDICES;
|
||||||
const H5std_string DATASET_NAME_OCCT;
|
const H5std_string DATASET_NAME_OCCT;
|
||||||
H5::CompType mtype1;
|
|
||||||
H5::CompType mtype2;
|
|
||||||
H5::CompType mtype3;
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user