@@ -106,18 +106,29 @@ void HdfSerializer::write(const IfcGeom::TriangulationElement<real_t>* o){
106106
107107 H5::Group elementGroup;
108108 H5::Group meshGroup;
109- H5::DataSet dataset;
109+ H5::DataSet positionsDataset;
110+ H5::DataSet normalsDataset;
111+ H5::DataSet indicesDataset;
112+
110113
111114 const IfcGeom::Representation::Triangulation<real_t >& mesh = o->geometry ();
112- const int vcountt = (int )mesh.verts ().size () / 3 ;
115+ const int vcount = (int )mesh.verts ().size () / 3 ;
116+ const int fcount = (int )mesh.faces ().size () / 3 ;
117+
118+
119+ if (guid == " 2OBrcmyk58NupXoVOHUvr4" ) {
120+ Logger::Status (" Found" );
121+ }
113122
114123 if (std::find (guids.begin (), guids.end (), guid) != guids.end ())
115124 {
116125 elementGroup = file.openGroup (guid);
117126 meshGroup = elementGroup.openGroup (" Triangle Mesh" );
118- dataset = meshGroup.openDataSet (" Positions" );
127+ positionsDataset = meshGroup.openDataSet (" Positions" );
128+
119129
120130 } else {
131+
121132 guids.insert (guid);
122133 elementGroup = file.createGroup (guid);
123134 meshGroup = elementGroup.createGroup (" Triangle Mesh" );
@@ -128,29 +139,64 @@ void HdfSerializer::write(const IfcGeom::TriangulationElement<real_t>* o){
128139
129140 const int RANK = 2 ;
130141 hsize_t dimsf[2 ];
131- dimsf[0 ] = vcountt ;
142+ dimsf[0 ] = vcount ;
132143 dimsf[1 ] = 3 ;
133144 H5::DataSpace dataspace (RANK, dimsf);
134- // H5::IntType datatype(H5::PredType::NATIVE_INT);
145+
146+ hsize_t dimsfaces[2 ];
147+ dimsfaces[0 ] = fcount;
148+ dimsfaces[1 ] = 3 ;
149+ H5::DataSpace face_dataspace (RANK, dimsfaces);
150+
151+ H5::IntType Intdatatype (H5::PredType::NATIVE_INT);
135152 H5::FloatType datatype (H5::PredType::NATIVE_DOUBLE);
136153 datatype.setOrder (H5T_ORDER_LE);
137- dataset = meshGroup.createDataSet (DATASET_NAME_POSITIONS, datatype, dataspace);
154+
155+ positionsDataset = meshGroup.createDataSet (DATASET_NAME_POSITIONS, datatype, dataspace);
156+ normalsDataset = meshGroup.createDataSet (DATASET_NAME_NORMALS, Intdatatype, dataspace);
157+ indicesDataset = meshGroup.createDataSet (DATASET_NAME_INDICES, Intdatatype, face_dataspace);
158+
138159
139160 for (std::vector<real_t >::const_iterator it = mesh.verts ().begin (); it != mesh.verts ().end (); ) {
140161 const real_t x = *(it++);
141162 const real_t y = *(it++);
142163 const real_t z = *(it++);
143- data_container .push_back (x);
144- data_container .push_back (y);
145- data_container .push_back (z);
164+ double_data_container .push_back (x);
165+ double_data_container .push_back (y);
166+ double_data_container .push_back (z);
146167
147168 }
148169
149- // data_container.clear();
150- // data_container.push_back(3.4);
170+ positionsDataset.write (double_data_container.data (), H5::PredType::NATIVE_DOUBLE);
171+ double_data_container.clear ();
172+
173+
174+ for (std::vector<real_t >::const_iterator it = mesh.normals ().begin (); it != mesh.normals ().end (); ) {
175+ const real_t x = *(it++);
176+ const real_t y = *(it++);
177+ const real_t z = *(it++);
178+ int_data_container.push_back ((int )x);
179+ int_data_container.push_back ((int )y);
180+ int_data_container.push_back ((int )z);
181+
182+ }
183+ normalsDataset.write (int_data_container.data (), H5::PredType::NATIVE_INT);
184+ int_data_container.clear ();
185+
186+
187+
188+ for (std::vector<int >::const_iterator it = mesh.faces ().begin (); it != mesh.faces ().end (); ) {
189+ const real_t x = *(it++);
190+ const real_t y = *(it++);
191+ const real_t z = *(it++);
192+ int_data_container.push_back (x);
193+ int_data_container.push_back (y);
194+ int_data_container.push_back (z);
195+
196+ }
151197
152- dataset .write (data_container .data (), H5::PredType::NATIVE_DOUBLE );
153- data_container .clear ();
198+ indicesDataset .write (int_data_container .data (), H5::PredType::NATIVE_INT );
199+ int_data_container .clear ();
154200
155201 }
156202
0 commit comments