From 50a8740cf7cadcbb4a1f1f7fa3c7205f98c01e5c Mon Sep 17 00:00:00 2001 From: aaronkimbrooktec <218adk@gmail.com> Date: Sun, 11 Feb 2024 15:14:18 -0500 Subject: [PATCH] move step conversion to another file --- backend/CMakeLists.txt | 2 ++ backend/src/cad_to_gcode.cpp | 36 +--------------------------------- backend/src/step_to_topo.cpp | 38 ++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 35 deletions(-) create mode 100644 backend/src/step_to_topo.cpp diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index eec7115..929715d 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -8,6 +8,8 @@ include_directories(${OCE_INCLUDE_DIRS}) add_executable(cad_to_gcode src/cad_to_gcode.cpp) add_executable(iges_to_topo src/iges_to_topo.cpp) +add_executable(step_to_topo src/step_to_topo.cpp) target_link_libraries(cad_to_gcode ${OpenCASCADE_LIBRARIES}) target_link_libraries(iges_to_topo ${OpenCASCADE_LIBRARIES}) +target_link_libraries(step_to_topo ${OpenCASCADE_LIBRARIES}) diff --git a/backend/src/cad_to_gcode.cpp b/backend/src/cad_to_gcode.cpp index 00e9f13..1a4e8c5 100644 --- a/backend/src/cad_to_gcode.cpp +++ b/backend/src/cad_to_gcode.cpp @@ -1,42 +1,8 @@ #include -#include -#include -#include -#include -#include -using namespace std; - -TopoDS_Shape read_step(const string& filename) { - STEPControl_Reader reader; - IFSelect_ReturnStatus status = reader.ReadFile(filename.c_str()); - - if (status != IFSelect_RetDone) { - cout << "Error reading STEP file." << endl; - return TopoDS_Shape(); - } - - cout << "Number of roots in STEP file: " << reader.NbRootsForTransfer() << endl; - cout << "STEP roots transferred: " << reader.TransferRoots() << endl; - cout << "Number of resulting shapes is: " << reader.NbShapes() << endl; - - TopoDS_Shape result = reader.OneShape(); - - if (result.IsNull()) { - cout << "Error: The resulting shape is invalid." << endl; - return TopoDS_Shape(); - } - - return result; -} +#include int main(int argc, char* argv[]) { TopoDS_Shape shape = TopoDS_Shape(); bool eq = shape.IsEqual(TopoDS_Shape()); std::cout << eq << std::endl; - - string full_frame_filename = "Full_Frame.STEP"; - TopoDS_Shape full_frame_shape = read_step(full_frame_filename); - - string rrh_filename = "RRH.STEP"; - TopoDS_Shape rrh_shape = read_step(rrh_filename); } \ No newline at end of file diff --git a/backend/src/step_to_topo.cpp b/backend/src/step_to_topo.cpp new file mode 100644 index 0000000..45cc075 --- /dev/null +++ b/backend/src/step_to_topo.cpp @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include +#include +using namespace std; + +TopoDS_Shape read_step(const string& filename) { + STEPControl_Reader reader; + IFSelect_ReturnStatus status = reader.ReadFile(filename.c_str()); + + if (status != IFSelect_RetDone) { + cout << "Error reading STEP file." << endl; + return TopoDS_Shape(); + } + + cout << "Number of roots in STEP file: " << reader.NbRootsForTransfer() << endl; + cout << "STEP roots transferred: " << reader.TransferRoots() << endl; + cout << "Number of resulting shapes is: " << reader.NbShapes() << endl; + + TopoDS_Shape result = reader.OneShape(); + + if (result.IsNull()) { + cout << "Error: The resulting shape is invalid." << endl; + return TopoDS_Shape(); + } + + return result; +} + +int main(int argc, char* argv[]) { + string full_frame_filename = "Full_Frame.STEP"; + TopoDS_Shape full_frame_shape = read_step(full_frame_filename); + + string rrh_filename = "RRH.STEP"; + TopoDS_Shape rrh_shape = read_step(rrh_filename); +} \ No newline at end of file