Skip to content

Commit

Permalink
Error checking and release cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arnholm committed May 25, 2017
1 parent 9356644 commit f6b7def
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 139 deletions.
3 changes: 0 additions & 3 deletions XCSG.workspace
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
<Depends filename="dmesh/dmesh.cbp" />
<Depends filename="csplines/csplines.cbp" />
</Project>
<Project filename="xcsg_version/xcsg_version.cbp">
<Depends filename="xcsg/xcsg.cbp" />
</Project>
</Workspace>
</CodeBlocks_workspace_file>
7 changes: 3 additions & 4 deletions xcsg/boost_command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ namespace po = boost::program_options;
// http://www.boost.org/doc/libs/1_60_0/doc/html/program_options/tutorial.html

boost_command_line::boost_command_line(int argc , char **argv)
: generic("\nxcsg command line options & arguments")
: generic("\nxcsg command line options & arguments ("+std::string(XCSG_version)+")")
, hidden("Hidden options")
, m_parse_ok(false)
, m_help_shown(false)
, m_version_shown(false)
{
generic.add_options()
("help,h", "Show this help message.")
("version,v", "Show program version.")
("version,v", "Show program version (numeric part).")
("amf", "AMF output file format (Additive Manufacturing Format)")
("csg", "CSG output file format (OpenSCAD)")
("stl", "STL output file format (STereoLitography)")
Expand Down Expand Up @@ -150,15 +150,14 @@ boost_command_line::boost_command_line(int argc , char **argv)
void boost_command_line::show_version()
{
if(!m_version_shown) {
cout << "xcsg version " << XCSG_version << endl;
cout << string(XCSG_version).substr(1) << endl;
m_version_shown = true;
}
}

void boost_command_line::show_help()
{
if(!m_help_shown) {
show_version();
cout << generic << " <xcsg-file>\t\tpath to input .xcsg file (required)" << endl << endl;
m_help_shown = true;
}
Expand Down
4 changes: 2 additions & 2 deletions xcsg/xcsg_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "xintersection3d.h"
#include "xpolyhedron.h"
#include "xsphere.h"
#include "xtin_model.h"
// #include "xtin_model.h"
#include "xunion3d.h"
#include "xhull3d.h"
#include "xlinear_extrude.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ std::shared_ptr<xsolid> xcsg_factory::make_difference3d(const cf_xmlNode& node)
std::shared_ptr<xsolid> xcsg_factory::make_intersection3d(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xintersection3d(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_polyhedron(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xpolyhedron(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_sphere(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xsphere(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_tin_model(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xtin_model(node)); }
// std::shared_ptr<xsolid> xcsg_factory::make_tin_model(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xtin_model(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_union3d(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xunion3d(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_hull3d(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xhull3d(node)); }
std::shared_ptr<xsolid> xcsg_factory::make_linear_extrude(const cf_xmlNode& node) { return std::shared_ptr<xsolid>(new xlinear_extrude(node)); }
Expand Down
19 changes: 16 additions & 3 deletions xcsg/xspline_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "xspline_path.h"
#include "cf_xmlNode.h"
#include "mesh_utils.h"

xspline_path::xspline_path()
{}
Expand All @@ -24,7 +25,7 @@ xspline_path::xspline_path(const cf_xmlNode& const_node)
if(const_node.tag() != "spline_path")throw logic_error("Expected xml tag spline_path, but found " + const_node.tag());

m_cp.reserve(500);
int k = 0;

cf_xmlNode node = const_node;
for(auto i=node.begin(); i!=node.end(); i++) {

Expand All @@ -36,12 +37,24 @@ xspline_path::xspline_path(const cf_xmlNode& const_node)
double vx = sub.get_property("vx",0.0);
double vy = sub.get_property("vy",0.0);
double vz = sub.get_property("vz",0.0);
m_cp.push_back(csplines::cpoint(px,py,pz,vx,vy,vz));

csplines::cpoint cp(px,py,pz,vx,vy,vz);
if(cp.length() > 0.0) m_cp.push_back(cp);
else throw logic_error("spline_path: control point 'up' vector length must be > 0.0");

size_t ncp = m_cp.size();
if(ncp > 1) {
const csplines::cpoint& cp_prev = m_cp[ncp-2];
double dist = cp.dist(cp_prev);
if(dist < fabs(mesh_utils::secant_tolerance())) {
throw logic_error("spline_path: Neighbour control points too close to each other: " + std::to_string(dist));
}
}
}
}
m_cp.shrink_to_fit();

if(m_cp.size() < 2)throw logic_error("spline_path: at least 2 point must be specified.");
if(m_cp.size() < 2)throw logic_error("spline_path: at least 2 <cpoint> control points must be specified.");
}

xspline_path::~xspline_path()
Expand Down
10 changes: 6 additions & 4 deletions xcsg/xsweep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ xsweep::xsweep(const cf_xmlNode& const_node)
for(auto i=node.begin(); i!=node.end(); i++) {

cf_xmlNode sub(i);
if(!m_profile.get() && xcsg_factory::singleton().is_shape2d(sub)) {
m_profile = xcsg_factory::singleton().make_shape2d(sub);
if(xcsg_factory::singleton().is_shape2d(sub)) {
if(!m_profile.get()) m_profile = xcsg_factory::singleton().make_shape2d(sub);
else throw logic_error("xsweep: More than one sweep profile specified.");
}
else if(!m_path.get() && sub.tag()=="spline_path") {
m_path = std::shared_ptr<xspline_path>(new xspline_path(sub));
else if(sub.tag()=="spline_path") {
if(!m_path.get()) m_path = std::shared_ptr<xspline_path>(new xspline_path(sub));
else throw logic_error("xsweep: More than one spline_path specified.");
}
}

Expand Down
16 changes: 0 additions & 16 deletions xcsg_version/main.cpp

This file was deleted.

107 changes: 0 additions & 107 deletions xcsg_version/xcsg_version.cbp

This file was deleted.

0 comments on commit f6b7def

Please sign in to comment.