diff --git a/include/vde/brep/iges_export.h b/include/vde/brep/iges_export.h index bd1f4b6..ca38283 100644 --- a/include/vde/brep/iges_export.h +++ b/include/vde/brep/iges_export.h @@ -82,6 +82,6 @@ namespace vde::brep { * * @see export_iges 获取字符串输出 */ -void export_iges_file(const std::string& filepath, const std::vector& bodies); +bool export_iges_file(const std::string& filepath, const std::vector& bodies); } // namespace vde::brep diff --git a/include/vde/brep/pmi_mbd.h b/include/vde/brep/pmi_mbd.h index b7b00d6..8fc0486 100644 --- a/include/vde/brep/pmi_mbd.h +++ b/include/vde/brep/pmi_mbd.h @@ -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); /** diff --git a/include/vde/brep/step_export.h b/include/vde/brep/step_export.h index 418865b..f5dc216 100644 --- a/include/vde/brep/step_export.h +++ b/include/vde/brep/step_export.h @@ -72,6 +72,6 @@ namespace vde::brep { * * @see export_step 获取字符串输出 */ -void export_step_file(const std::string& filepath, const std::vector& bodies); +bool export_step_file(const std::string& filepath, const std::vector& bodies); } // namespace vde::brep diff --git a/include/vde/foundation/industrial_formats.h b/include/vde/foundation/industrial_formats.h index 8dc4170..66a17a6 100644 --- a/include/vde/foundation/industrial_formats.h +++ b/include/vde/foundation/industrial_formats.h @@ -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 diff --git a/include/vde/foundation/io_obj.h b/include/vde/foundation/io_obj.h index cbc883d..b979bfa 100644 --- a/include/vde/foundation/io_obj.h +++ b/include/vde/foundation/io_obj.h @@ -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 diff --git a/src/brep/iges_export.cpp b/src/brep/iges_export.cpp index b069b96..7709f83 100644 --- a/src/brep/iges_export.cpp +++ b/src/brep/iges_export.cpp @@ -643,10 +643,11 @@ std::string export_iges(const std::vector& bodies) { return writer.write(bodies); } -void export_iges_file(const std::string& filepath, const std::vector& bodies) { +bool export_iges_file(const std::string& filepath, const std::vector& bodies) { std::ofstream out(filepath); - if (!out) return; + if (!out) return false; out << export_iges(bodies); + return true; } } // namespace vde::brep diff --git a/src/brep/pmi_mbd.cpp b/src/brep/pmi_mbd.cpp index 9285dde..40d30f4 100644 --- a/src/brep/pmi_mbd.cpp +++ b/src/brep/pmi_mbd.cpp @@ -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, diff --git a/src/brep/step_export.cpp b/src/brep/step_export.cpp index 2215c65..ffdbea3 100644 --- a/src/brep/step_export.cpp +++ b/src/brep/step_export.cpp @@ -430,10 +430,11 @@ std::string export_step(const std::vector& bodies) { return writer.ss.str(); } -void export_step_file(const std::string& filepath, const std::vector& bodies) { +bool export_step_file(const std::string& filepath, const std::vector& bodies) { std::ofstream out(filepath); - if (!out) return; + if (!out) return false; out << export_step(bodies); + return true; } } // namespace vde::brep diff --git a/src/curves/advanced_intersection.cpp b/src/curves/advanced_intersection.cpp index 493b301..5725d99 100644 --- a/src/curves/advanced_intersection.cpp +++ b/src/curves/advanced_intersection.cpp @@ -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; diff --git a/src/foundation/industrial_formats.cpp b/src/foundation/industrial_formats.cpp index a9da695..83f0558 100644 --- a/src/foundation/industrial_formats.cpp +++ b/src/foundation/industrial_formats.cpp @@ -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(data.size())); + return true; } // ═══════════════════════════════════════════════════════════════ diff --git a/src/foundation/io_obj.cpp b/src/foundation/io_obj.cpp index a41a6d9..16f620d 100644 --- a/src/foundation/io_obj.cpp +++ b/src/foundation/io_obj.cpp @@ -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