QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RSpline Class Reference

Low-level mathematical representation of a 2nd or 3rd degree spline. More...

#include <RSpline.h>

Inheritance diagram for RSpline:
RShape RExplodable RDirected RSplineData

List of all members.

Public Member Functions

void appendControlPoint (const RVector &point)
 Disabled for splines (bad performance).
void appendFitPoint (const RVector &point)
 Appends a fit point.
virtual RSplineclone () const
int countControlPoints () const
int countFitPoints () const
virtual bool flipHorizontal ()
virtual bool flipVertical ()
QList< RSplinegetBezierSegments () const
virtual RBox getBoundingBox () const
virtual QList< RVectorgetCenterPoints () const
QList< RVectorgetControlPoints () const
QList< RVectorgetControlPointsWrapped () const
int getDegree () const
virtual double getDirection1 () const
virtual double getDirection2 () const
virtual RVector getEndPoint () const
virtual QList< RVectorgetEndPoints () const
virtual QList< QSharedPointer
< RShape > > 
getExploded () const
QList< RVectorgetFitPoints () const
QList< double > getKnotVector () const
virtual double getLength () const
RVector getMiddlePoint () const
virtual QList< RVectorgetMiddlePoints () const
int getOrder () const
RVector getPointAt (double t) const
virtual QList< RVectorgetPointsWithDistanceToEnd (double distance, RS::From from=RS::FromAny) const
virtual RVector getStartPoint () const
RVector getTangentAtEnd () const
RVector getTangentAtStart () const
double getTDelta () const
double getTMax () const
double getTMin () const
virtual RS::Ending getTrimEnd (const RVector &coord, const RVector &trimPoint)
virtual RVector getVectorTo (const RVector &point, bool limited=true) const
QList< double > getWeights () const
bool hasFitPoints () const
bool isClosed () const
virtual bool isInterpolated () const
 Reimplement and return true if this shape relies on interpolation for geometrical operations such as finding intersection points.
bool isPeriodic () const
bool isValid () const
virtual bool mirror (const RLine &axis)
virtual bool move (const RVector &offset)
void removeLastControlPoint (bool upd=true)
 Removes the last control point.
void removeLastFitPoint (bool upd=true)
 Removes the last fit point.
virtual bool reverse ()
virtual bool rotate (double rotation, const RVector &center=RDEFAULT_RVECTOR)
 RSpline ()
 Creates a spline object without controlPoints.
 RSpline (const QList< RVector > &controlPoints, int degree)
 Creates a spline object with the given control points and degree.
virtual bool scale (const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
void setControlPoints (const QList< RVector > &points)
 Sets the control points of this spline.
void setDegree (int d)
 Sets the degree of this spline (2 or 3 for control point defined spline, 3 for fit point defined spline).
void setEndPoint (const RVector &v)
void setFitPoints (const QList< RVector > &points)
 Sets the fit points.
void setKnotVector (const QList< double > &knots)
 Sets the knot vector manually.
void setPeriodic (bool on)
void setStartPoint (const RVector &v)
void setTangentAtEnd (const RVector &t)
 Sets the end tangent.
void setTangentAtStart (const RVector &t)
 Sets the start tangent.
void setTangents (const RVector &start, const RVector &end)
 Sets the start and end tangents.
virtual void to2D ()
 Flattens this shape to the X/Y plane.
virtual void trimEndPoint (const RVector &p)
virtual void trimStartPoint (const RVector &p)
void unsetTangentAtEnd ()
 Clears the valud of the end tangent.
void unsetTangentAtStart ()
 Clears the valud of the start tangent.
void unsetTangents ()
 Clears the valud of the start and end tangents.
void updateTangentsPeriodic ()
 Updates the tangents at the start and end to make the spline periodic.
virtual ~RSpline ()
- Public Member Functions inherited from RShape
virtual RVector getClosestPointOnShape (const RVector &p, bool limited=true) const
virtual double getDistanceTo (const RVector &point, bool limited=true) const
QList< RVectorgetIntersectionPoints (const RShape &other, bool limited=true, bool same=false) const
virtual RVector getPointAtPercent (double p) const
virtual RVector getVectorFromEndpointTo (const RVector &point) const
virtual bool intersectsWith (const RShape &other, bool limited=true) const
virtual bool isOnShape (const RVector &point, bool limited=true, double tolerance=RDEFAULT_TOLERANCE_1E_MIN4) const
 RShape ()
virtual bool scale (double scaleFactor, const RVector &center=RVector())
virtual bool stretch (const RBox &area, const RVector &offset)
virtual bool stretch (const RPolyline &area, const RVector &offset)
virtual ~RShape ()
- Public Member Functions inherited from RExplodable
virtual ~RExplodable ()
- Public Member Functions inherited from RDirected
virtual ~RDirected ()

Public Attributes

QList< RVectorcontrolPoints
 Getter function for this property: getControlPoints.
int degree
 Getter function for this property: getDegree.
QList< RVectorfitPoints
 Getter function for this property: getFitPoints.
QList< double > knotVector
 Getter function for this property: getKnotVector.
bool periodic
 Closed periodic flag.
RVector tangentEnd
 Unit vector end tangent.
RVector tangentStart
 Unit vector start tangent.

Protected Member Functions

void invalidate ()
virtual void print (QDebug dbg) const
void updateBoundingBox ()
 Updates the internal bounding box.
void updateInternal ()

Private Member Functions

void updateFromControlPoints ()
void updateFromFitPoints (bool useTangents=false)
 Closes this spline and makes it periodic if it isn't already.

Private Attributes

RBox boundingBox
ON_NurbsCurve curve
QList< QSharedPointer< RShape > > exploded

Additional Inherited Members

- Static Public Member Functions inherited from RShape
static QList< RVectorgetIntersectionPoints (const RShape &shape1, const RShape &shape2, bool limited=true, bool same=false)
static QList< RVectorgetIntersectionPointsAA (const RArc &arc1, const RArc &arc2, bool limited=true)
static QList< RVectorgetIntersectionPointsAC (const RArc &arc1, const RCircle &circle2, bool limited=true)
static QList< RVectorgetIntersectionPointsAE (const RArc &arc1, const REllipse &ellipse2, bool limited=true)
static QList< RVectorgetIntersectionPointsAX (const RArc &arc1, const RExplodable &explodable2, bool limited=true)
static QList< RVectorgetIntersectionPointsCC (const RCircle &circle1, const RCircle &circle2)
static QList< RVectorgetIntersectionPointsCE (const RCircle &circle1, const REllipse &ellipse2)
static QList< RVectorgetIntersectionPointsCX (const RCircle &circle1, const RExplodable &explodable2, bool limited=true)
static QList< RVectorgetIntersectionPointsEE (const REllipse &ellipse1, const REllipse &ellipse2)
static QList< RVectorgetIntersectionPointsEX (const REllipse &ellipse1, const RExplodable &explodable2, bool limited=true)
static QList< RVectorgetIntersectionPointsLA (const RLine &line1, const RArc &arc2, bool limited=true)
static QList< RVectorgetIntersectionPointsLC (const RLine &line1, const RCircle &circle2, bool limited=true)
static QList< RVectorgetIntersectionPointsLE (const RLine &line1, const REllipse &ellipse2, bool limited=true)
static QList< RVectorgetIntersectionPointsLL (const RLine &line1, const RLine &line2, bool limited=true)
static QList< RVectorgetIntersectionPointsLX (const RLine &line1, const RExplodable &explodable2, bool limited=true)
static QList< RVectorgetIntersectionPointsXX (const RExplodable &explodable1, const RExplodable &explodable2, bool limited=true, bool same=false)
static bool order (QList< QList< QSharedPointer< RShape > > > &boundary)
 Orders the given list of loops into a list of closed loops in which all shapes are connected end to start point.

Detailed Description

Low-level mathematical representation of a 2nd or 3rd degree spline.

The spline may be defined by its control points or by its fit points but not both.

Scriptable:
This class is wrapped for script environments.
Shared Pointer Support:
Script wrappers of this class support wrapping in QSharedPointer.
Copyable:
Script wrappers of this class should pass objects by reference.

Constructor & Destructor Documentation

RSpline::RSpline ( )

Creates a spline object without controlPoints.

RSpline::RSpline ( const QList< RVector > &  controlPoints,
int  degree 
)

Creates a spline object with the given control points and degree.

RSpline::~RSpline ( )
virtual

Member Function Documentation

void RSpline::appendControlPoint ( const RVector point)

Disabled for splines (bad performance).

20120223: Re-enabled, seems to perform OK, needed by some users. Appends a control point.

void RSpline::appendFitPoint ( const RVector point)

Appends a fit point.

virtual RSpline* RSpline::clone ( ) const
inlinevirtual

Implements RShape.

int RSpline::countControlPoints ( ) const
Returns:
Number of control points.
int RSpline::countFitPoints ( ) const
Returns:
Number of fit points.
bool RSpline::flipHorizontal ( )
virtual

Reimplemented from RShape.

bool RSpline::flipVertical ( )
virtual

Reimplemented from RShape.

QList< RSpline > RSpline::getBezierSegments ( ) const
Returns:
Bezier spline segments which together represent this curve.
RBox RSpline::getBoundingBox ( ) const
virtual
Returns:
The bounding box of this shape.

Implements RShape.

QList< RVector > RSpline::getCenterPoints ( ) const
virtual
Returns:
The center point(s) of this shape.

Implements RShape.

QList< RVector > RSpline::getControlPoints ( ) const
Returns:
Control points.

Reimplemented in RSplineData.

QList< RVector > RSpline::getControlPointsWrapped ( ) const
Returns:
Control points of internal spline representation (may be closed).

Reimplemented in RSplineData.

int RSpline::getDegree ( ) const
Returns:
Degree of this spline.

Reimplemented in RSplineData.

double RSpline::getDirection1 ( ) const
virtual
Returns:
Tangent angle of spline at start point.

Implements RDirected.

Reimplemented in RSplineData.

double RSpline::getDirection2 ( ) const
virtual
Returns:
Tangent angle of spline at end point.

Implements RDirected.

Reimplemented in RSplineData.

RVector RSpline::getEndPoint ( ) const
virtual

Implements RDirected.

Reimplemented in RSplineData.

QList< RVector > RSpline::getEndPoints ( ) const
virtual
Returns:
The end point(s) of this shape.

Implements RShape.

QList< QSharedPointer< RShape > > RSpline::getExploded ( ) const
virtual
Returns:
List of RLines describing this spline.

Implements RExplodable.

QList< RVector > RSpline::getFitPoints ( ) const
Returns:
Fit points.

Reimplemented in RSplineData.

QList< double > RSpline::getKnotVector ( ) const
Returns:
Knot vector, internally calculated and updated.

Reimplemented in RSplineData.

double RSpline::getLength ( ) const
virtual
Returns:
The total length of this shape if applicable or NaN if not.

Implements RShape.

RVector RSpline::getMiddlePoint ( ) const
QList< RVector > RSpline::getMiddlePoints ( ) const
virtual
Returns:
The middle point(s) of this shape.

Implements RShape.

int RSpline::getOrder ( ) const
Returns:
Order of this spline (=degree+1).
RVector RSpline::getPointAt ( double  t) const
Returns:
Point on spline at given position t (0..1).
QList< RVector > RSpline::getPointsWithDistanceToEnd ( double  distance,
RS::From  from = RS::FromAny 
) const
virtual
Returns:
All points on this shape with the given distance to an endpoint.

Implements RShape.

RVector RSpline::getStartPoint ( ) const
virtual

Implements RDirected.

Reimplemented in RSplineData.

RVector RSpline::getTangentAtEnd ( ) const
Returns:
The end tangent.

Reimplemented in RSplineData.

RVector RSpline::getTangentAtStart ( ) const
Returns:
The start tangent.

Reimplemented in RSplineData.

double RSpline::getTDelta ( ) const
double RSpline::getTMax ( ) const
double RSpline::getTMin ( ) const
RS::Ending RSpline::getTrimEnd ( const RVector coord,
const RVector trimPoint 
)
virtual
Parameters:
coordClicked coordiante
trimPointTrim start point or end point to this coordiante.

Implements RDirected.

RVector RSpline::getVectorTo ( const RVector point,
bool  limited = true 
) const
virtual
Returns:
Shortest vector from this shape to the given point.
Parameters:
pointthe given point
limitedIf false, the shape is treaded as an unlimited shape that extends in a logical way. For example an unlimited line for a line, full circle for an arc or a plane for a triangle.

Implements RShape.

QList< double > RSpline::getWeights ( ) const
Returns:
Knot weights, internally calculated and updated.

Reimplemented in RSplineData.

bool RSpline::hasFitPoints ( ) const
Returns:
True if this spline has fit points and is therefore defined by its fit points, false otherwise.
void RSpline::invalidate ( )
protected
bool RSpline::isClosed ( ) const
Returns:
True if this spline is closed, i.e. start point and end point are very close to each other.

Reimplemented in RSplineData.

virtual bool RSpline::isInterpolated ( ) const
inlinevirtual

Reimplement and return true if this shape relies on interpolation for geometrical operations such as finding intersection points.

E.g. splines.

Reimplemented from RShape.

bool RSpline::isPeriodic ( ) const
Returns:
True if this spline is periodic, i.e. closed and 'smooth' where start and end connect. The tangents at the start point and end point are nearly identical.

Reimplemented in RSplineData.

bool RSpline::isValid ( ) const

Reimplemented in RSplineData.

bool RSpline::mirror ( const RLine axis)
virtual

Implements RShape.

bool RSpline::move ( const RVector offset)
virtual

Implements RShape.

void RSpline::print ( QDebug  dbg) const
protectedvirtual
Returns:
New spline that covers this spline from d1 to d2, where d1 and d2 are distances from the start point of this spline.

Reimplemented from RShape.

void RSpline::removeLastControlPoint ( bool  upd = true)

Removes the last control point.

Parameters:
updUpdate internal spline representation.
void RSpline::removeLastFitPoint ( bool  upd = true)

Removes the last fit point.

bool RSpline::reverse ( )
virtual

Implements RDirected.

Reimplemented in RSplineData.

bool RSpline::rotate ( double  rotation,
const RVector center = RDEFAULT_RVECTOR 
)
virtual

Implements RShape.

bool RSpline::scale ( const RVector scaleFactors,
const RVector center = RDEFAULT_RVECTOR 
)
virtual

Implements RShape.

void RSpline::setControlPoints ( const QList< RVector > &  points)

Sets the control points of this spline.

void RSpline::setDegree ( int  d)

Sets the degree of this spline (2 or 3 for control point defined spline, 3 for fit point defined spline).

void RSpline::setEndPoint ( const RVector v)
void RSpline::setFitPoints ( const QList< RVector > &  points)

Sets the fit points.

void RSpline::setKnotVector ( const QList< double > &  knots)

Sets the knot vector manually.

Mainly for importing ready data.

void RSpline::setPeriodic ( bool  on)
void RSpline::setStartPoint ( const RVector v)
void RSpline::setTangentAtEnd ( const RVector t)

Sets the end tangent.

void RSpline::setTangentAtStart ( const RVector t)

Sets the start tangent.

void RSpline::setTangents ( const RVector start,
const RVector end 
)

Sets the start and end tangents.

void RSpline::to2D ( )
virtual

Flattens this shape to the X/Y plane.

Implements RShape.

void RSpline::trimEndPoint ( const RVector p)
virtual

Implements RDirected.

void RSpline::trimStartPoint ( const RVector p)
virtual

Implements RDirected.

void RSpline::unsetTangentAtEnd ( )

Clears the valud of the end tangent.

The end tangent is calculated and updated internally if not set manually.

void RSpline::unsetTangentAtStart ( )

Clears the valud of the start tangent.

The start tangent is calculated and updated internally if not set manually.

void RSpline::unsetTangents ( )

Clears the valud of the start and end tangents.

The tangents are calculated and updated internally if not set manually.

void RSpline::updateBoundingBox ( )
protected

Updates the internal bounding box.

void RSpline::updateFromControlPoints ( )
private
void RSpline::updateFromFitPoints ( bool  useTangents = false)
private

Closes this spline and makes it periodic if it isn't already.

Updates the internal spline data from fitPoints. Degree is always corrected to 3rd degree.

void RSpline::updateInternal ( )
protected
void RSpline::updateTangentsPeriodic ( )

Updates the tangents at the start and end to make the spline periodic.


Member Data Documentation

RBox RSpline::boundingBox
mutableprivate
QList<RVector> RSpline::controlPoints

Getter function for this property: getControlPoints.

Setter function for this property: setControlPoints

ON_NurbsCurve RSpline::curve
mutableprivate
int RSpline::degree

Getter function for this property: getDegree.

Setter function for this property: setDegree

QList<QSharedPointer<RShape> > RSpline::exploded
mutableprivate
QList<RVector> RSpline::fitPoints

Getter function for this property: getFitPoints.

Setter function for this property: setFitPoints

QList<double> RSpline::knotVector

Getter function for this property: getKnotVector.

bool RSpline::periodic

Closed periodic flag.

RVector RSpline::tangentEnd

Unit vector end tangent.

RVector RSpline::tangentStart

Unit vector start tangent.


The documentation for this class was generated from the following files: