Skip to content

Commit

Permalink
Merge pull request #12 from GenerateNU/feature/step-conversion
Browse files Browse the repository at this point in the history
Feature/step conversion
  • Loading branch information
hmcclew authored Feb 7, 2024
2 parents 724a322 + e70ab53 commit d8cddb2
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions backend/src/cad_to_gcode.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
#include <iostream>
#include <TopoDS_Shape.hxx>
#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[]) {
std::cout << "hello world" << std::endl;
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);
}

0 comments on commit d8cddb2

Please sign in to comment.