Skip to content

Commit

Permalink
Merge pull request #16 from GenerateNU/feature/step-conversion
Browse files Browse the repository at this point in the history
move step conversion to another file
  • Loading branch information
muneerlalji authored Feb 11, 2024
2 parents 0b1f859 + 82510f7 commit 33e23de
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 35 deletions.
2 changes: 2 additions & 0 deletions backend/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ 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)
add_executable(shape_to_bspline src/shape_to_bspline.cpp)
add_executable(tangent_vectors_geom_bspline src/tangent_vectors_geom_bspline.cpp)
target_link_libraries(cad_to_gcode ${OpenCASCADE_LIBRARIES})
target_link_libraries(iges_to_topo ${OpenCASCADE_LIBRARIES})
target_link_libraries(shape_to_bspline ${OpenCASCADE_LIBRARIES})
target_link_libraries(tangent_vectors_geom_bspline ${OpenCASCADE_LIBRARIES})
target_link_libraries(step_to_topo ${OpenCASCADE_LIBRARIES})
36 changes: 1 addition & 35 deletions backend/src/cad_to_gcode.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,8 @@
#include <iostream>
#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <BRepTools.hxx>
#include <iostream>
#include <string>
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 <TopoDS_Shape.hxx>

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);
}
38 changes: 38 additions & 0 deletions backend/src/step_to_topo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <BRepTools.hxx>
#include <iostream>
#include <string>
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);
}

0 comments on commit 33e23de

Please sign in to comment.