fix: unify IO return types — all write/export/save return bool
CI / Build & Test (push) Failing after 1m36s
CI / Release Build (push) Failing after 36s
Build & Test / build-and-test (push) Has been cancelled
Build & Test / python-bindings (push) Has been cancelled

export_jt, write_obj, export_step_file, export_iges_file,
export_pmi_step_ap242_file: void → bool
Return false on file open failure, true on success

Also fix duplicate using namespace in advanced_intersection.cpp
This commit is contained in:
茂之钳
2026-07-30 11:20:24 +08:00
parent 5cf7d86a41
commit 2cb76b76d0
11 changed files with 26 additions and 20 deletions
+1 -1
View File
@@ -82,6 +82,6 @@ namespace vde::brep {
*
* @see export_iges 获取字符串输出
*/
void export_iges_file(const std::string& filepath, const std::vector<BrepModel>& bodies);
bool export_iges_file(const std::string& filepath, const std::vector<BrepModel>& bodies);
} // namespace vde::brep
+1 -1
View File
@@ -263,7 +263,7 @@ int attach_pmi(BrepModel& body, const PMIAnnotation& annotation,
* @param body B-Rep model
* @param pmi_model PMI annotations and views
*/
void export_pmi_step_ap242_file(const std::string& filepath,
bool export_pmi_step_ap242_file(const std::string& filepath,
const BrepModel& body, const PMIModel& pmi_model);
/**
+1 -1
View File
@@ -72,6 +72,6 @@ namespace vde::brep {
*
* @see export_step 获取字符串输出
*/
void export_step_file(const std::string& filepath, const std::vector<BrepModel>& bodies);
bool export_step_file(const std::string& filepath, const std::vector<BrepModel>& bodies);
} // namespace vde::brep
+1 -1
View File
@@ -105,7 +105,7 @@ struct JtSegmentHeader {
*
* @throws std::runtime_error 写入失败
*/
void export_jt(const brep::BrepModel& body, const std::string& path);
bool export_jt(const brep::BrepModel& body, const std::string& path);
// ═══════════════════════════════════════════════════════════════
// Parasolid XT
+1 -1
View File
@@ -105,6 +105,6 @@ ObjMeshData read_obj(const std::string& filepath);
* @see read_obj
* @ingroup foundation
*/
void write_obj(const std::string& filepath, const ObjMeshData& data);
bool write_obj(const std::string& filepath, const ObjMeshData& data);
} // namespace vde::foundation
+3 -2
View File
@@ -643,10 +643,11 @@ std::string export_iges(const std::vector<BrepModel>& bodies) {
return writer.write(bodies);
}
void export_iges_file(const std::string& filepath, const std::vector<BrepModel>& bodies) {
bool export_iges_file(const std::string& filepath, const std::vector<BrepModel>& bodies) {
std::ofstream out(filepath);
if (!out) return;
if (!out) return false;
out << export_iges(bodies);
return true;
}
} // namespace vde::brep
+5 -5
View File
@@ -302,15 +302,15 @@ std::string export_pmi_step_ap242(
return base_step;
}
void export_pmi_step_ap242_file(const std::string& filepath,
bool export_pmi_step_ap242_file(const std::string& filepath,
const BrepModel& body, const PMIModel& pmi_model) {
std::string step_content = export_pmi_step_ap242(body, pmi_model);
std::ofstream out(filepath);
if (out.is_open()) {
out << step_content;
out.close();
}
if (!out) return false;
out << step_content;
out.close();
return true;
}
int auto_generate_pmi(const BrepModel& body, PMIModel& pmi_model,
+3 -2
View File
@@ -430,10 +430,11 @@ std::string export_step(const std::vector<BrepModel>& bodies) {
return writer.ss.str();
}
void export_step_file(const std::string& filepath, const std::vector<BrepModel>& bodies) {
bool export_step_file(const std::string& filepath, const std::vector<BrepModel>& bodies) {
std::ofstream out(filepath);
if (!out) return;
if (!out) return false;
out << export_step(bodies);
return true;
}
} // namespace vde::brep
+2 -2
View File
@@ -14,6 +14,8 @@
namespace vde::curves {
using namespace std::chrono;
namespace {
// ── 内部辅助函数 ──────────────────────────────────────────
@@ -84,7 +86,6 @@ SSIResult robust_ssi(
const NurbsSurface& surf_b,
const SSIOptions& options)
{
using namespace std::chrono;
auto t_start = high_resolution_clock::now();
SSIResult result;
@@ -424,7 +425,6 @@ SelfIntersectionResult self_intersection_detection(
const NurbsSurface& surface,
double tolerance)
{
using namespace std::chrono;
auto t_start = high_resolution_clock::now();
SelfIntersectionResult result;
+5 -2
View File
@@ -438,9 +438,12 @@ BrepModel import_jt_binary(const uint8_t* data, size_t size, const JTOptions& op
return parser.parse(opts);
}
void export_jt(const BrepModel& body, const std::string& path) {
bool export_jt(const BrepModel& body, const std::string& path) {
std::string data = jt::build_jt_file(body);
write_file_bytes(path, data);
std::ofstream f(path, std::ios::binary);
if (!f) return false;
f.write(data.data(), static_cast<std::streamsize>(data.size()));
return true;
}
// ═══════════════════════════════════════════════════════════════
+3 -2
View File
@@ -85,9 +85,9 @@ ObjMeshData read_obj(const std::string& filepath) {
return data;
}
void write_obj(const std::string& filepath, const ObjMeshData& data) {
bool write_obj(const std::string& filepath, const ObjMeshData& data) {
std::ofstream file(filepath);
if (!file) return;
if (!file) return false;
file.precision(12);
@@ -140,6 +140,7 @@ void write_obj(const std::string& filepath, const ObjMeshData& data) {
}
file << "\n";
}
return true;
}
} // namespace vde::foundation