mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 06:39:13 +00:00
Change file extension and start cleaning
This commit is contained in:
@@ -626,7 +626,14 @@ 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);
|
||||||
|
|
||||||
path_t output_extension = output_filename.substr(output_filename.size()-4);
|
std::vector<std::wstring> tokens;
|
||||||
|
split(tokens, output_filename, boost::is_any_of("."));
|
||||||
|
std::vector<std::wstring>::iterator tok_iter;
|
||||||
|
std::wstring ext = *(tokens.end() - 1);
|
||||||
|
std::wstring dot;
|
||||||
|
dot = '.';
|
||||||
|
path_t output_extension = dot + ext;
|
||||||
|
|
||||||
boost::to_lower(output_extension);
|
boost::to_lower(output_extension);
|
||||||
|
|
||||||
IfcParse::IfcFile* ifc_file = 0;
|
IfcParse::IfcFile* ifc_file = 0;
|
||||||
@@ -638,7 +645,7 @@ int main(int argc, char** argv) {
|
|||||||
STP = IfcUtil::path::from_utf8(".stp"),
|
STP = IfcUtil::path::from_utf8(".stp"),
|
||||||
IGS = IfcUtil::path::from_utf8(".igs"),
|
IGS = IfcUtil::path::from_utf8(".igs"),
|
||||||
SVG = IfcUtil::path::from_utf8(".svg"),
|
SVG = IfcUtil::path::from_utf8(".svg"),
|
||||||
HDF = IfcUtil::path::from_utf8(".hdf"),
|
HDF = IfcUtil::path::from_utf8(".h5"),
|
||||||
XML = IfcUtil::path::from_utf8(".xml"),
|
XML = IfcUtil::path::from_utf8(".xml"),
|
||||||
IFC = IfcUtil::path::from_utf8(".ifc");
|
IFC = IfcUtil::path::from_utf8(".ifc");
|
||||||
|
|
||||||
@@ -799,7 +806,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
else if (output_extension == HDF) {
|
else if (output_extension == HDF) {
|
||||||
const path_t mtl_filename = change_extension(output_filename, MTL);
|
const path_t mtl_filename = change_extension(output_filename, MTL);
|
||||||
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(mtl_filename), settings);
|
serializer = boost::make_shared<HdfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(output_filename), settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -30,71 +30,58 @@
|
|||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
|
|
||||||
const H5std_string FILE_NAME("output_file.h5");
|
//const H5std_string FILE_NAME("output_file.h5");
|
||||||
|
|
||||||
|
|
||||||
HdfSerializer::HdfSerializer(const std::string& obj_filename, const std::string& mtl_filename, const SerializerSettings& settings)
|
HdfSerializer::HdfSerializer(const std::string& obj_filename, const std::string& mtl_filename, const SerializerSettings& settings)
|
||||||
: GeometrySerializer(settings)
|
: GeometrySerializer(settings)
|
||||||
, mtl_filename(mtl_filename)
|
, mtl_filename(obj_filename)
|
||||||
, obj_stream(IfcUtil::path::from_utf8(obj_filename).c_str())
|
|
||||||
, mtl_stream(IfcUtil::path::from_utf8(mtl_filename).c_str())
|
|
||||||
, vcount_total(1)
|
|
||||||
, file(FILE_NAME, H5F_ACC_TRUNC)
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
obj_stream << std::setprecision(settings.precision);
|
|
||||||
mtl_stream << std::setprecision(settings.precision);
|
|
||||||
guids = {};
|
guids = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool HdfSerializer::ready() {
|
bool HdfSerializer::ready() {
|
||||||
return obj_stream.is_open() && mtl_stream.is_open();
|
|
||||||
|
//return obj_stream.is_open() && mtl_stream.is_open();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HdfSerializer::writeHeader() {
|
void HdfSerializer::writeHeader() {
|
||||||
obj_stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n";
|
const H5std_string FILE_NAME(mtl_filename);
|
||||||
#ifdef WIN32
|
file = H5::H5File(FILE_NAME, H5F_ACC_TRUNC);
|
||||||
const char dir_separator = '\\';
|
|
||||||
#else
|
|
||||||
const char dir_separator = '/';
|
|
||||||
#endif
|
|
||||||
std::string mtl_basename = mtl_filename;
|
|
||||||
std::string::size_type slash = mtl_basename.find_last_of(dir_separator);
|
|
||||||
if (slash != std::string::npos) {
|
|
||||||
mtl_basename = mtl_basename.substr(slash + 1);
|
|
||||||
}
|
|
||||||
obj_stream << "mtllib " << mtl_basename << "\n";
|
|
||||||
mtl_stream << "# File generated by IfcOpenShell " << IFCOPENSHELL_VERSION << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void HdfSerializer::writeMaterial(const IfcGeom::Material& style)
|
|
||||||
{
|
|
||||||
std::string material_name = (settings().get(SerializerSettings::USE_MATERIAL_NAMES)
|
|
||||||
? style.original_name() : style.name());
|
|
||||||
IfcUtil::sanitate_material_name(material_name);
|
|
||||||
mtl_stream << "newmtl " << material_name << "\n";
|
|
||||||
|
|
||||||
if (style.hasDiffuse()) {
|
|
||||||
const double* diffuse = style.diffuse();
|
|
||||||
mtl_stream << "Kd " << diffuse[0] << " " << diffuse[1] << " " << diffuse[2] << "\n";
|
|
||||||
}
|
|
||||||
if (style.hasSpecular()) {
|
|
||||||
const double* specular = style.specular();
|
|
||||||
mtl_stream << "Ks " << specular[0] << " " << specular[1] << " " << specular[2] << "\n";
|
|
||||||
}
|
|
||||||
if (style.hasSpecularity()) {
|
|
||||||
mtl_stream << "Ns " << style.specularity() << "\n";
|
|
||||||
}
|
|
||||||
if (style.hasTransparency()) {
|
|
||||||
const double transparency = 1.0 - style.transparency();
|
|
||||||
if (transparency < 1) {
|
|
||||||
mtl_stream << "d " << transparency << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void HdfSerializer::writeMaterial(const IfcGeom::Material& style)
|
||||||
|
//{
|
||||||
|
// std::string material_name = (settings().get(SerializerSettings::USE_MATERIAL_NAMES)
|
||||||
|
// ? style.original_name() : style.name());
|
||||||
|
// IfcUtil::sanitate_material_name(material_name);
|
||||||
|
// mtl_stream << "newmtl " << material_name << "\n";
|
||||||
|
//
|
||||||
|
// if (style.hasDiffuse()) {
|
||||||
|
// const double* diffuse = style.diffuse();
|
||||||
|
// mtl_stream << "Kd " << diffuse[0] << " " << diffuse[1] << " " << diffuse[2] << "\n";
|
||||||
|
// }
|
||||||
|
// if (style.hasSpecular()) {
|
||||||
|
// const double* specular = style.specular();
|
||||||
|
// mtl_stream << "Ks " << specular[0] << " " << specular[1] << " " << specular[2] << "\n";
|
||||||
|
// }
|
||||||
|
// if (style.hasSpecularity()) {
|
||||||
|
// mtl_stream << "Ns " << style.specularity() << "\n";
|
||||||
|
// }
|
||||||
|
// if (style.hasTransparency()) {
|
||||||
|
// const double transparency = 1.0 - style.transparency();
|
||||||
|
// if (transparency < 1) {
|
||||||
|
// mtl_stream << "d " << transparency << "\n";
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
void HdfSerializer::write(const IfcGeom::TriangulationElement<real_t>* o){
|
void HdfSerializer::write(const IfcGeom::TriangulationElement<real_t>* o){
|
||||||
|
|||||||
Reference in New Issue
Block a user