Skip to content

Commit

Permalink
Add support for surfaces generated via extrusion - fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Rauf Bingol committed Apr 26, 2020
1 parent 94f5cb5 commit 2d6d065
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/on2json/on2json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ bool on2json(std::string &fileName, Config &cfg, std::string &jsonString)
case ON::brep_object:
extractBrepData(geometry, cfg, data);
break;
case ON::extrusion_object:
extractExtrusionData(geometry, cfg, data);
break;
}
}
// Only add to the array if JSON output is not empty
Expand Down
18 changes: 18 additions & 0 deletions src/rw3dm/rw3dm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,24 @@ void extractSurfaceData(const ON_Geometry* geometry, Config &cfg, Json::Value &d
}
}

void extractExtrusionData(const ON_Geometry* geometry, Config& cfg, Json::Value& data)
{
// We expect an extrusion object
if (ON::object_type::extrusion_object != geometry->ObjectType())
return;

// We know that "geometry" is an extrusion object
ON_Extrusion* extr = (ON_Extrusion*)geometry;

// Try to get the NURBS surface form of the extrusion object
ON_NurbsSurface nurbsSurface;
if (extr->NurbsSurface(&nurbsSurface))
{
// Extract NURBS surface data
extractNurbsSurfaceData(&nurbsSurface, cfg, data);
}
}

void extractBrepData(const ON_Geometry* geometry, Config &cfg, Json::Value &data)
{
// We expect a BRep object
Expand Down
1 change: 1 addition & 0 deletions src/rw3dm/rw3dm.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void extractCurveData(const ON_Geometry *, Config &, Json::Value &, double * = n
void extractNurbsSurfaceData(const ON_NurbsSurface *, Config &, Json::Value &);
void extractSurfaceData(const ON_Geometry *, Config &, Json::Value &);
void extractBrepData(const ON_Geometry *, Config &, Json::Value &);
void extractExtrusionData(const ON_Geometry*, Config&, Json::Value&);

// Geometry conversion (geomdl -> 3DM)
void constructCurveData(Json::Value &, Config &, ON_NurbsCurve *&);
Expand Down

0 comments on commit 2d6d065

Please sign in to comment.