mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
fix filename bug
This commit is contained in:
@@ -691,7 +691,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
std::vector<path_t> tokens;
|
std::vector<path_t> tokens;
|
||||||
split(tokens, output_filename, boost::is_any_of("."));
|
split(tokens, output_filename, boost::is_any_of("."));
|
||||||
std::vector<path_t>::iterator tok_iter;
|
std::vector<path_t>::iterator tok_itxer;
|
||||||
path_t ext = *(tokens.end() - 1);
|
path_t ext = *(tokens.end() - 1);
|
||||||
path_t dot;
|
path_t dot;
|
||||||
dot = '.';
|
dot = '.';
|
||||||
@@ -713,7 +713,8 @@ int main(int argc, char** argv) {
|
|||||||
XML = IfcUtil::path::from_utf8(".xml"),
|
XML = IfcUtil::path::from_utf8(".xml"),
|
||||||
IFC = IfcUtil::path::from_utf8(".ifc"),
|
IFC = IfcUtil::path::from_utf8(".ifc"),
|
||||||
USD = IfcUtil::path::from_utf8(".usd"),
|
USD = IfcUtil::path::from_utf8(".usd"),
|
||||||
USDA = IfcUtil::path::from_utf8(".usda");
|
USDA = IfcUtil::path::from_utf8(".usda"),
|
||||||
|
USDC = IfcUtil::path::from_utf8(".usdc");
|
||||||
|
|
||||||
// @todo clean up serializer selection
|
// @todo clean up serializer selection
|
||||||
// @todo detect program options that conflict with the chosen serializer
|
// @todo detect program options that conflict with the chosen serializer
|
||||||
@@ -858,7 +859,7 @@ int main(int argc, char** argv) {
|
|||||||
serializer = boost::make_shared<GltfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
serializer = boost::make_shared<GltfSerializer>(IfcUtil::path::to_utf8(output_temp_filename), settings);
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_USD
|
#ifdef WITH_USD
|
||||||
} else if (output_extension == USD || output_extension == USDA) {
|
} else if (output_extension == USD || output_extension == USDA || output_extension == USDC) {
|
||||||
serializer = boost::make_shared<USDSerializer>(IfcUtil::path::to_utf8(output_filename), settings);
|
serializer = boost::make_shared<USDSerializer>(IfcUtil::path::to_utf8(output_filename), settings);
|
||||||
#endif
|
#endif
|
||||||
} else if (output_extension == STP) {
|
} else if (output_extension == STP) {
|
||||||
@@ -1183,11 +1184,17 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
Logger::Message(Logger::LOG_PERF, "done file geometry conversion");
|
Logger::Message(Logger::LOG_PERF, "done file geometry conversion");
|
||||||
|
|
||||||
|
bool successful;
|
||||||
|
if(output_extension == USD || output_extension == USDC || output_extension == USDA) {
|
||||||
|
// No need to rename the file
|
||||||
|
successful = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Renaming might fail (e.g. maybe the existing file was open in a viewer application)
|
||||||
|
// Do not remove the temp file as user can salvage the conversion result from it.
|
||||||
|
successful = IfcUtil::path::rename_file(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(output_filename));
|
||||||
|
}
|
||||||
|
|
||||||
// Renaming might fail (e.g. maybe the existing file was open in a viewer application)
|
|
||||||
// Do not remove the temp file as user can salvage the conversion result from it.
|
|
||||||
bool successful = IfcUtil::path::rename_file(IfcUtil::path::to_utf8(output_temp_filename), IfcUtil::path::to_utf8(output_filename))
|
|
||||||
|| output_extension == USD || output_extension == USDA;
|
|
||||||
if (!successful) {
|
if (!successful) {
|
||||||
cerr_ << "Unable to write output file '" << output_filename << "', see '" <<
|
cerr_ << "Unable to write output file '" << output_filename << "', see '" <<
|
||||||
output_temp_filename << "' for the conversion result.";
|
output_temp_filename << "' for the conversion result.";
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ USDSerializer::USDSerializer(const std::string& out_filename, const SerializerSe
|
|||||||
WriteOnlyGeometrySerializer(settings),
|
WriteOnlyGeometrySerializer(settings),
|
||||||
filename_(out_filename)
|
filename_(out_filename)
|
||||||
{
|
{
|
||||||
// why does this not work with just the filename ???
|
stage_ = pxr::UsdStage::CreateNew(filename_);
|
||||||
stage_ = pxr::UsdStage::CreateNew(filename_ + ".usda");
|
|
||||||
|
|
||||||
if(!stage_)
|
if(!stage_)
|
||||||
throw std::runtime_error("Could not create USD stage");
|
throw std::runtime_error("Could not create USD stage");
|
||||||
@@ -51,10 +50,7 @@ USDSerializer::~USDSerializer() {
|
|||||||
|
|
||||||
void USDSerializer::createLighting() {
|
void USDSerializer::createLighting() {
|
||||||
const std::string& light_path = "/World/defaultLight";
|
const std::string& light_path = "/World/defaultLight";
|
||||||
pxr::UsdLuxDistantLight::Define(stage_, pxr::SdfPath(light_path));
|
auto light = pxr::UsdLuxDistantLight::Define(stage_, pxr::SdfPath(light_path));
|
||||||
pxr::UsdGeomXform xform(stage_->GetPrimAtPath(pxr::SdfPath(light_path)));
|
|
||||||
pxr::GfVec3f light_direction(0.0f, 0.0f, -1.0f);
|
|
||||||
pxr::UsdLuxDistantLight light(stage_->GetPrimAtPath(pxr::SdfPath(light_path)));
|
|
||||||
light.CreateIntensityAttr().Set(1000.0f);
|
light.CreateIntensityAttr().Set(1000.0f);
|
||||||
light.CreateColorAttr().Set(pxr::GfVec3f(1.0f, 1.0f, 1.0f));
|
light.CreateColorAttr().Set(pxr::GfVec3f(1.0f, 1.0f, 1.0f));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule src/svgfill updated: 4d2aa7acf7...22216ac584
Reference in New Issue
Block a user