API Documentation

To Document

class AlignedEllipse : public ocl::Ellipse

an aligned ellipse, used by the edgePush function of BullCutter

Public Functions

AlignedEllipse(Point &centerin, double major_length, double minor_length, double offset, Point &majorDir, Point &minorDir)

create an aligned ellipse

virtual Point normal(const EllipsePosition &position) const

normal vector at given EllipsePosition

virtual Point ePoint(const EllipsePosition &position) const

ellipse-point at given EllipsePosition

virtual Point oePoint(const EllipsePosition &pos) const

offset-ellipse point at given EllipsePosition

virtual double error(double dia) const

error-function for the solver

bool aligned_solver(const Fiber &f)

aligned offset-ellipse solver. callsn Numeric::brent_solver()

class Arc

a finite arc segment in 3D space specified by its end points (p1, p2)

Public Functions

Arc(const Point &p1, const Point &p2, const Point &c, bool dir)

create an arc from point p1 to point p2 with center c and direction dir. direction is true for anti-clockwise arcs.

Arc(const Arc &a)

copy constructor

inline double length2d() const

return the length of the arc

Point getPoint(double t) const

return a point along the arc at parameter value t [0,1]

double xyIncludedAngle(const Point &v1, const Point &v2, bool dir = true)

returns the absolute included angle (in radians) between two vectors v1 and v2 in the direction of dir ( true=acw false=cw)

Public Members

Point p1

start point

Point p2

end point

Point c

centre point

bool dir

direction true for anti-clockwise

Friends

friend std::ostream &operator<<(std::ostream &stream, const Arc &a)

text output

class ArcSpan : public ocl::Span

circular Arc Span

Public Functions

inline ArcSpan(const Arc &a)

create span

inline virtual SpanType type() const

return type

inline virtual double length2d() const

return length in xy-plane

inline virtual Point getPoint(double t) const

return a point on the span

Public Members

Arc arc

arc

class Bbox

axis-aligned bounding-box

Public Functions

Bbox()

default constructor

Bbox(double b1, double b2, double b3, double b4, double b5, double b6)

explicit constructor

double operator[](const unsigned int idx) const

index into maxpt and minpt returning a vector [minx maxx miny maxy minz maxz]

bool isInside(Point &p) const

return true if Point p is inside this Bbox

bool overlaps(const Bbox &other) const

return true if *this overlaps Bbox b

does this Bbox overlap with b?

void clear()

reset the Bbox (sets initialized=false)

void addPoint(const Point &p)

Add a Point to the Bbox. This enlarges the Bbox so that p is contained within it.

void addTriangle(const Triangle &t)

add each vertex of the Triangle

Add each vertex of a Triangle to the Bbox. This enlarges the Bbox so that the Triangle is contained within it. Calls addPoint() for each vertex of the Triangle.

Public Members

Point maxpt

the maximum point

Point minpt

the minimum point

class CCPoint : public ocl::Point

Cutter-Contact (CC) point. A Point with a CCType.

Cutter-Contact (CC) Point. A Point which also contains the type of cutter-contact.

Public Functions

CCPoint()

create a CCPoint at (0,0,0)

CCPoint(double x, double y, double z)

create CCPoint at (x,y,z)

CCPoint(double x, double y, double z, CCType t)

create CCPoint at (x,y,z) with type t

CCPoint(const Point &p, CCType t)

create CCPoint at p with type t

CCPoint(const Point &p)

create a CCPoint at Point p

CCPoint &operator=(const Point &p)

assign coordinates of Point to this CCPoint. sets type=NONE

std::string str() const

string repr

Public Members

CCType type

specifies the type of the Cutter Contact point.

Friends

friend std::ostream &operator<<(std::ostream &stream, const CCPoint &p)

string repr

class CLFilter

CL point filter virtual base class.

Subclassed by ocl::LineCLFilter

Public Functions

inline CLFilter()

constructor

virtual void addCLPoint(const CLPoint &p) = 0

add CLPoint

virtual void setTolerance(const double tol) = 0

set the tolerance value

virtual void run() = 0

run filter

Public Members

std::list<CLPoint> clpoints

the list of CL-points to be processed

double tol

tolerance

class CLPoint : public ocl::Point

Cutter-Location (CL) point.

Public Functions

CLPoint()

CLPoint at (0,0,0)

CLPoint(double x, double y, double z)

CLPoint at (x,y,z)

CLPoint(double x, double y, double z, CCPoint &ccp)

CLPoint at (x,y,z) with CCPoint ccp.

CLPoint(const CLPoint &cl)

copy constructor

CLPoint(const Point &p)

cl-point at Point p

std::string str() const

string repr

bool liftZ_if_InsidePoints(double z, CCPoint &cc_tmp, const Point &p1, const Point &p2)

if cc is in the edge p1-p2, test if clpoint needs to be lifted to z if so, set cc = cc_tmp and return true

bool liftZ_if_inFacet(double z, CCPoint &cc_tmp, const Triangle &t)

if cc in in Triangle facet, test if clpoint needs to be lifted if so, set cc=cc_tmp and return true

bool liftZ(double zin, CCPoint &ccp)

if zin > z, lift CLPoint and update cc-point, and return true

bool liftZ(const double zin)

if zin > z, lift CLPoint and return true.

bool below(const Triangle &t) const

return true if cl-point above triangle

CCPoint getCC()

return the CCPoint (for python)

CLPoint &operator=(const CLPoint &p)

assignment

const CLPoint operator+(const CLPoint &p) const

addition

Public Members

std::atomic<CCPoint*> cc

Atomic pointer to the corresponding CCPoint, protected against concurrent replacement in liftZ.

class Ellipse

An Ellipse.

Subclassed by ocl::AlignedEllipse

Public Functions

inline Ellipse()

dummy constructor

Ellipse(Point &centerin, double a, double b, double offset)

create an Ellipse with centerpoint center, X-axis a, Y-axis b, and offset distance offset.

virtual Point ePoint(const EllipsePosition &position) const

return a point on the ellipse at given EllipsePosition

virtual Point oePoint(const EllipsePosition &position) const

return a point on the offset-ellipse at given EllipsePosition

virtual Point normal(const EllipsePosition &position) const

return a normalized normal vector of the ellipse at the given EllipsePosition

int solver_brent()

offset-ellipse Brent solver

offfset-ellipse solver using Brent’s method find the EllipsePosition that makes the offset-ellipse point be at p this is a zero of Ellipse::error() returns number of iterations

called (only?) by BullCutter::singleEdgeDropCanonical()

void print_solutions()

print out the found solutions

bool find_EllipsePosition2()

given one EllipsePosition solution, find the other.

double error(EllipsePosition &position) const

error function for the solver

virtual double error(double dia) const

error function for solver

Point calcEcenter(const Point &up1, const Point &up2, int sln)

calculate ellipse center

given the two solutions EllipsePosition1 and EllipsePosition2 and the edge up1-up2 locate the ellipse center correctly

void setEllipsePositionHi(const Point &u1, const Point &u2)

set EllipsePosition_hi to either EllipsePosition1 or EllipsePosition2, depending on which has the center (given by calcEcenter() ) with higher z-coordinate

Point ePointHi() const

once EllipsePosition_hi is set, return an ellipse-point at this position

Point ePoint1() const

ellipse-point at EllipsePosition1

Point ePoint2() const

ellipse-point at EllipsePosition2

Point oePoint1() const

offset-ellipse-point at EllipsePosition1

Point oePoint2() const

offset-ellipse-point at EllipsePosition2

inline void setA(double ain)

set length of ellipse major axis

inline void setB(double bin)

set length of ellipse minor axis

inline void setCenter(Point &pin)

set the ellipse center

inline void setOffset(double ofs)

set offset-ellipse offset distance

inline void setEccen()

set/calculate the eccentricity

inline double getCenterZ()

returns the z-coordinate of this->center

Public Members

double eccen

eccentricity = a/b

Friends

friend std::ostream &operator<<(std::ostream &stream, const Ellipse &e)

string repr

class EllipsePosition

EllipsePosition defines a position in (s,t) coordinates on a unit-circle. The (s,t) pair is used to locate points on an ellipse.

s^2 + t^2 = 1 should be true at all times.

Public Functions

EllipsePosition()

create an EllipsePosition

inline EllipsePosition(double sin, double tin)

create EllipsePosition at (s,t)

void setDiangle(double dia)

set (s,t) pair to the position corresponding to diangle

EllipsePosition &operator=(const EllipsePosition &pos)

set rhs EllipsePosition (s,t) values equal to lhs EllipsePosition

bool isValid() const

return true if (s,t) is valid, i.e. lies on the unit circle checks s^2 + t^2 == 1 (to within tolerance)

std::string str() const

string repr

Public Members

double s

s-parameter in [-1, 1]

double t

t-parameter in [-1, 1]

double diangle

diamond angle parameter in [0,4] (modulo 4) this models an angle [0,2pi] and maps from the angle to an (s,t) pair using setD()

Friends

friend std::ostream &operator<<(std::ostream &stream, EllipsePosition pos)

string repr

class Fiber

a fiber is an infinite line in space along which the cutter can be pushed into contact with a triangle. A Weave is built from many X-fibers and Y-fibers. might be called a Dexel also in some papers/textbooks.

Public Functions

Fiber(const Point &p1, const Point &p2)

create a Fiber between points p1 and p2

void addInterval(Interval &i)

add an interval to this Fiber

bool contains(Interval &i) const

return true if Fiber already has interval i in it

bool missing(Interval &i) const

return true if Interval i is completely missing (no overlaps) from Fiber

double tval(Point &p) const

t-value corresponding to Point p

Point point(double t) const

Point corresponding to t-value.

void printInts() const

print the intervals

inline bool empty() const

return true if the Fiber contains no intervals

inline unsigned int size() const

return number of intervals

inline Point upperCLPoint(unsigned int n) const

return the upper cl-point of interval n

inline Point lowerCLPoint(unsigned int n) const

return the lower cl-point of interval n

Public Members

Point p1

start point

Point p2

end point

Point dir

direction vector (normalized)

std::vector<Interval> ints

the intervals in this Fiber

Friends

friend std::ostream &operator<<(std::ostream &stream, const Fiber &f)

string repr

class Interval

interval for use by fiber and weave a parameter interval [upper, lower]

Public Types

typedef boost::adjacency_list_traits<boost::listS, boost::listS, boost::bidirectionalS, boost::listS>::vertex_descriptor WeaveVertex

intersections with other intervals are stored in this set of VertexPairs of type std::pair<VertexDescriptor, double>

typedef std::set<VertexPair, VertexPairCompare> VertexIntersectionSet

intersections stored in this set (for rapid finding of neighbors etc)

Public Functions

Interval(const double l, const double u)

create and interval [l,u] (is this ever called??)

void updateUpper(const double t, CCPoint &p)

update upper with t, and corresponding cc-point p

void updateLower(const double t, CCPoint &p)

update lower with t, and corresponding cc-point p

void update(const double t, CCPoint &p)

call both updateUpper() and updateLower() with the given (t,p) pair

bool update_ifCCinEdgeAndTrue(double t_cl, CCPoint &cc_tmp, const Point &p1, const Point &p2, bool condition)

update interval with t_cl and cc_tmp if cc_tmp is in the p1-p2 edge and condition==true

bool outside(const Interval &i) const

return true if Interval i is outside *this

bool inside(const Interval &i) const

return true if Interval i is inside *this

bool empty() const

return true if the interval is empty

std::string str() const

string repr

Public Members

CCPoint upper_cc

cutter contact points at upper and lower are stored in upper_cc and lower_cc

CCPoint lower_cc

cutter contact point corresponding to lower

double upper

the upper t-value

double lower

the lower t-value

bool in_weave

flag for use by Weave::build()

std::set<std::vector<Fiber>::iterator> intersections_fibers

fibers

struct VertexPairCompare

compare based on pair.second, the coordinate of the intersection

Public Functions

inline bool operator()(const VertexPair &lhs, const VertexPair &rhs) const

comparison operator

Warning

doxygenclass: Cannot find class “ocl::VertexPairCompare” in doxygen xml output for project “opencamlib” from directory: ../src/doc/xml

template<class BBObj>
class KDNode

K-D tree node. http://en.wikipedia.org/wiki/Kd-tree.

A k-d tree is used for searching for triangles overlapping with the cutter.

Public Functions

inline KDNode(int d, double cv, KDNode<BBObj> *parentNode, KDNode<BBObj> *hi_child, KDNode<BBObj> *lo_child, const std::list<BBObj> *tlist, int nodeDepth)

Create a node which partitions(cuts) along dimension d, at cut value cv, with child-nodes hi_c and lo_c. If this is a bucket-node containing triangles, they are in the list tris depth indicates the depth of the node in the tree

inline std::string str() const

string repr

Public Members

int depth

level of node in tree

int dim

dimension of cut

double cutval

Cut value. Child node hi contains only triangles with a higher value than this. Child node lo contains triangles with lower values.

KDNode *parent

parent-node

KDNode *hi

Child-node hi.

KDNode *lo

Child-node lo.

std::list<BBObj> *tris

A list of triangles, if this is a bucket-node (NULL for internal nodes)

bool isLeaf

flag to indicate leaf in the tree. Leafs or bucket-nodes contain triangles in the list tris.

template<class BBObj>
class KDTree

a kd-tree for storing triangles and fast searching for triangles that overlap the cutter

Public Functions

inline void setBucketSize(int b)

set the bucket-size

inline void setXYDimensions()

set the search dimension to the XY-plane

inline void setYZDimensions()

set search-plane to YZ

inline void setXZDimensions()

set search plane to XZ

inline void build(const std::list<BBObj> &list)

build the kd-tree based on a list of input objects

inline std::list<BBObj> *search(const Bbox &bb)

search for overlap with input Bbox bb, return found objects

inline std::list<BBObj> *search_cutter_overlap(const MillingCutter *c, CLPoint *cl)

search for overlap with a MillingCutter c positioned at cl, return found objects

std::string str() const

string repr

class Line

A finite line segment in 3D space specified by its end points (p1, p2)

Public Functions

Line(const Point &p1, const Point &p2)

create a line from p1 to p2

Line(const Line &l)

create a copy of line l.

double length2d() const

return the length of the line-segment in the xy-plane

Point getPoint(double t) const

return a Point on the Line at parameter value t [0,1]

Point Near(const Point &p) const

return the point on the Line which is closest to Point p.

Public Members

Point p1

start point

Point p2

end point

Friends

friend std::ostream &operator<<(std::ostream &stream, const Line &l)

text output

class LineCLFilter : public ocl::CLFilter

LineCLFilter takes a sequence of cutter-location (CL) points as input and produces another sequence as output.

The number of CL-points is reduced by finding co-linear points, to within a set tolerance, and deleting redundant ones.

Public Functions

virtual void addCLPoint(const CLPoint &p)

add CLPoint

virtual void setTolerance(const double tol)

set the tolerance value

virtual void run()

run filter

class LineSpan : public ocl::Span

Line Span.

Public Functions

inline LineSpan(const Line &l)

create a line span from Line l

inline virtual SpanType type() const

return span type

inline virtual double length2d() const

return span length

inline virtual Point getPoint(double t) const

return point on span

Public Members

Line line

the line

class Path

A collection of Span objects.

Public Functions

Path()

create empty path

Path(const Path &p)

copy constructor

virtual ~Path()

destructor

void append(const Line &l)

append a Line to this path

void append(const Arc &a)

append an Arc to this path

Public Members

std::list<Span*> span_list

list of spans in this path

class Point

a point or vector in 3D space specified by its coordinates (x, y, z)

Subclassed by ocl::CCPoint, ocl::CLPoint

Public Functions

Point()

create a point at (0,0,0)

Point(double x, double y, double z)

create a point at (x,y,z)

Point(double x, double y)

create a point at (x,y,0)

Point(const Point &p)

create a point at p

inline virtual ~Point()

destructor. empty.

double dot(const Point &p) const

dot product

Point cross(const Point &p) const

cross product

double norm() const

norm of vector, or distance from (0,0,0) to *this

void normalize()

scales vector so that norm()==1.0

double xyDistance(const Point &p) const

distance from Point to another Point p in the XY plane

double xyNorm() const

length of vector in the XY plane

void xyNormalize()

normalize so that length xyNorm == 1.0

Point xyPerp() const

return perpendicular in the xy plane, rotated 90 degree to the left

void z_projectOntoEdge(const Point &p1, const Point &p2)

move *this along z-axis so it lies on p1-p2 line-segment

void xyRotate(double cosa, double sina)

rotate point in the xy-plane by angle theta inputs are cos(theta) and sin(theta)

void xyRotate(double angle)

rotate point in xy-plane bu angle theta (radians or degrees??)

void xRotate(double theta)

rotate around x-axis

void yRotate(double theta)

rotate around y-axis

void zRotate(double theta)

rotate around z-axis

double xyDistanceToLine(const Point &p1, const Point &p2) const

distance from Point to infinite line through p1 and p2. In the XY plane.

Point closestPoint(const Point &p1, const Point &p2) const

return closest Point to line through p1 and p2. in 3D.

return Point on p1-p2 line which is closest in 3D to this.

Point xyClosestPoint(const Point &p1, const Point &p2) const

return closest Point to line through p1 and p2. Works in the XY plane.

return Point on p1-p2 line which is closest in XY-plane to this

bool isRight(const Point &p1, const Point &p2) const

returns true if point is right of line through p1 and p2 (works in the XY-plane)

bool isInside(const Triangle &t) const

returns true if Point *this is inside Triangle t

bool isInside(const Point &p1, const Point &p2) const

return true if Point within line segment p1-p2

bool xParallel() const

return true if the x and y components are both zero.

bool yParallel() const

return true if vector parallel to y-axis

bool zParallel() const

return true if vector parallel to z-axis

Point &operator=(const Point &p)

assignment

Point &operator+=(const Point &p)

addition

Point &operator-=(const Point &p)

subtraction

const Point operator+(const Point &p) const

addition

const Point operator-(const Point &p) const

subtraction

Point &operator*=(const double &a)

scalar multiplication

const Point operator*(const double &a) const

Point * scalar.

bool operator==(const Point &p) const

equality

bool operator!=(const Point &p) const

inequality

std::string str() const

string repr

Public Members

double x

X coordinate.

double y

Y coordinate.

double z

Z coordinate.

Friends

friend std::ostream &operator<<(std::ostream &stream, const Point &p)

string repr

class Span

A finite curve which returns Point objects along its length.

location along span is based on a parameter t for which 0 <= t <= 1.0

Subclassed by ocl::ArcSpan, ocl::LineSpan

Public Functions

virtual SpanType type() const = 0

return type of span

virtual double length2d() const = 0

return the length of the span in the xy-plane

virtual Point getPoint(double t) const = 0

return a point at parameter value 0 <= t <= 1.0

inline virtual ~Span()

avoid gcc 4.7.1 delete-non-virtual-dtor error

class Spread

KDTree spread, a measure of how spread-out a list of triangles are.

simple struct-like class for storing the “spread” or maximum extent of a list of triangles. Used by the kd-tree algorithm.

Public Functions

inline Spread(int dim, double v, double s)

constructor

Public Members

int d

dimension

double val

spread-value

double start

minimum or start value

Public Static Functions

static inline bool spread_compare(Spread *x, Spread *y)

comparison of Spread objects. Used for finding the largest spread along which the next partition/cut is made.

class STLReader

STL file reader, reads an STL file and calls addTriangle on the STLSurf.

Public Functions

STLReader(const std::wstring &filepath, STLSurf &surface)

construct with file name and surface to fill

virtual ~STLReader()

destructor

class STLSurf

STL surface, essentially an unordered list of Triangle objects.

STL surfaces consist of triangles. There is by definition no structure or order among the triangles, i.e. they can be positioned or connected in arbitrary ways.

Public Functions

inline STLSurf()

Create an empty STL-surface.

inline virtual ~STLSurf()

destructor

void addTriangle(const Triangle &t)

add Triangle t to this surface

unsigned int size() const

return number of triangles in surface

void rotate(double xr, double yr, double zr)

call Triangle::rotate on all triangles

Public Members

std::list<Triangle> tris

list of Triangles in this surface

Bbox bb

bounding-box

Friends

friend std::ostream &operator<<(std::ostream &stream, const STLSurf s)

STLSurf string repr.

class Triangle

a Triangle defined by its three vertices

Public Functions

Triangle()

default constructor

Triangle(const Triangle &t)

copy constructor

inline virtual ~Triangle()

destructor

Triangle(Point p1, Point p2, Point p3)

Create a triangle with the vertices p1, p2, and p3.

bool zslice_verts(Point &p1, Point &p2, double zcut) const

return true if Triangle is sliced by a z-plane at z=zcut modify p1 and p2 so that they are intesections of the triangle edges and the plane. These vertices are used by CylCutter::edgePush()

void rotate(double xrot, double yrot, double zrot)

rotate triangle xrot radians around X-axis, yrot radians around Y-axis and zrot radians around Z-axis

Point upNormal() const

return normal vector with positive z-coordinate

Public Members

Point p[3]

the three vertex Points of the Triangle

Point n

normal vector

Bbox bb

bounding-box

Friends

friend std::ostream &operator<<(std::ostream &stream, const Triangle t)

Triangle string repr