QCAD
Open Source 2D CAD
RShape Class Referenceabstract

Interface for geometrical shape classes. More...

#include <RShape.h>

Inheritance diagram for RShape:
RArc RCircle REllipse RLine RPoint RPolyline RSpline RTriangle RXLine

Public Types

enum  Type {
  Unknown = -1, Point = 0, Line = 1, Arc = 2,
  Circle = 3, Ellipse = 4, Polyline = 5, Spline = 6,
  Triangle = 7, XLine = 8, Ray = 9
}
 

Public Member Functions

virtual RShapeclone () const =0
 
void dump ()
 
virtual QList< RVectorfilterOnShape (const QList< RVector > &pointList, bool limited=true, double tolerance=RDEFAULT_TOLERANCE_1E_MIN4) const
 
virtual bool flipHorizontal ()
 
virtual bool flipVertical ()
 
virtual double getAngleAt (double distance, RS::From from=RS::FromStart) const
 
virtual RBox getBoundingBox () const =0
 
virtual QList< RVectorgetCenterPoints () const =0
 
virtual RVector getClosestPointOnShape (const RVector &p, bool limited=true, double strictRange=RMAXDOUBLE) const
 
virtual double getDistanceTo (const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const
 
virtual QList< RVectorgetEndPoints () const =0
 
QList< RVectorgetIntersectionPoints (const RShape &other, bool limited=true, bool same=false, bool force=false) const
 
virtual double getLength () const =0
 
virtual QList< RVectorgetMiddlePoints () const =0
 
virtual QList< QSharedPointer< RShape > > getOffsetShapes (double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
 
virtual RVector getPointAtPercent (double p) const
 
virtual QList< RVectorgetPointsWithDistanceToEnd (double distance, int from=RS::FromAny) const =0
 
virtual RVector getPointWithDistanceToEnd (double distance)
 
virtual RVector getPointWithDistanceToStart (double distance)
 
virtual QSharedPointer< RShapegetTransformed (const QTransform &transform) const =0
 
virtual RShape::Type getType () const
 
virtual RVector getVectorFromEndpointTo (const RVector &point) const
 
virtual RVector getVectorTo (const RVector &point, bool limited=true, double strictRange=RMAXDOUBLE) const =0
 
virtual bool intersectsWith (const RShape &other, bool limited=true) const
 
virtual bool isInterpolated () const
 Reimplement and return true if this shape relies on interpolation for geometrical operations such as finding intersection points. More...
 
virtual bool isOnShape (const RVector &point, bool limited=true, double tolerance=RDEFAULT_TOLERANCE_1E_MIN4) const
 
virtual bool mirror (const RLine &axis)=0
 
virtual bool move (const RVector &offset)=0
 
virtual bool rotate (double rotation, const RVector &center=RDEFAULT_RVECTOR)=0
 
 RShape ()
 
virtual bool scale (double scaleFactor, const RVector &center=RVector())
 
virtual bool scale (const RVector &scaleFactors, const RVector &center=RVector())=0
 
virtual QList< QSharedPointer< RShape > > splitAt (const QList< RVector > &points) const
 
virtual bool stretch (const RBox &area, const RVector &offset)
 
virtual bool stretch (const RPolyline &area, const RVector &offset)
 
virtual void to2D ()=0
 Flattens this shape to the X/Y plane. More...
 
virtual ~RShape ()
 

Static Public Member Functions

static const RExplodablecastToExplodable (const RShape *shape)
 
static int getErrorCode ()
 
static QList< RVectorgetIntersectionPoints (const RShape &shape1, const RShape &shape2, bool limited=true, bool same=false, bool force=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< RVectorgetIntersectionPointsAS (const RArc &arc1, const RSpline &spline2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsAT (const RArc &arc1, const RTriangle &triangle2, 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< RVectorgetIntersectionPointsCS (const RCircle &circle1, const RSpline &spline2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsCX (const RCircle &circle1, const RExplodable &explodable2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsEE (const REllipse &ellipse1, const REllipse &ellipse2)
 Based on "Hughes and Chraibi (2011-2012), Calculating Ellipse Overlap Areas". More...
 
static QList< RVectorgetIntersectionPointsEE (const REllipse &ellipse1, const REllipse &ellipse2, bool limited)
 
static QList< RVectorgetIntersectionPointsES (const REllipse &ellipse1, const RSpline &spline2, bool limited=true)
 
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< RVectorgetIntersectionPointsLA (const RLine &line1, const RArc &arc2, bool limited1, bool limited2)
 
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< RVectorgetIntersectionPointsLE (const RLine &line1, const REllipse &ellipse2, bool limited1, bool limited2)
 
static QList< RVectorgetIntersectionPointsLL (const RLine &line1, const RLine &line2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsLL (const RLine &line1, const RLine &line2, bool limited1, bool limited2)
 
static QList< RVectorgetIntersectionPointsLS (const RLine &line1, const RSpline &spline2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsLT (const RLine &line1, const RTriangle &triangle2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsLT (const RLine &line1, const RTriangle &triangle2, bool limited1, bool limited2)
 
static QList< RVectorgetIntersectionPointsLX (const RLine &line1, const RExplodable &explodable2, bool limited=true)
 
static QList< RVectorgetIntersectionPointsSS (const RSpline &spline1, const RSpline &spline2, bool limited=true, bool same=false)
 
static QList< RVectorgetIntersectionPointsSX (const RSpline &spline1, const RExplodable &explodable2, bool limited)
 
static QList< RVectorgetIntersectionPointsXX (const RExplodable &explodable1, const RExplodable &explodable2, bool limited=true, bool same=false)
 
static QList< QSharedPointer< RShape > > getOffsetArcs (const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
 
static QList< QSharedPointer< RShape > > getOffsetLines (const RShape &shape, double distance, int number, RS::Side side, const RVector &position=RVector::invalid)
 
static QList< QSharedPointer< RShape > > getReversedShapeList (const QList< QSharedPointer< RShape > > &shapes)
 
static bool isArcShape (const RShape &s)
 
static bool isCircleShape (const RShape &s)
 
static bool isEllipseShape (const RShape &s)
 
static bool isFullEllipseShape (const RShape &s)
 
static bool isLineShape (const RShape &s)
 
static bool isPointShape (const RShape &s)
 
static bool isPolylineShape (const RShape &s)
 
static bool isRayShape (const RShape &s)
 
static bool isSplineShape (const RShape &s)
 
static bool isTriangleShape (const RShape &s)
 
static bool isXLineShape (const RShape &s)
 
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. More...
 
static QList< QSharedPointer< RShape > > trim (const RShape &trimShape, const RVector &trimClickPos, const RShape &limitingShape, const RVector &limitingClickPos, bool trimBoth, bool samePolyline)
 Trims a shape to another or two shapes to each other. More...
 

Protected Member Functions

virtual void print (QDebug dbg) const
 

Static Protected Attributes

static int errorCode = 0
 

Static Private Member Functions

static double ellipse2tr (double x, double y, double AA, double BB, double CC, double DD, double EE, double FF)
 

Static Private Attributes

static double epsTolerance = 1.0e-04
 
static double twopi = M_PI*2
 Copyright (c) 2011-2016 by Andrew Mustun. More...
 

Friends

QDebug operator<< (QDebug dbg, const RShape &s)
 

Detailed Description

Interface for geometrical shape classes.

Scriptable:
This class is available in script environments.
Shared Pointer Support:
Objects can be used in QSharedPointer.

Constructor & Destructor Documentation

RShape::RShape ( )
inline
virtual RShape::~RShape ( )
inlinevirtual

Member Function Documentation

const RExplodable * RShape::castToExplodable ( const RShape shape)
static
virtual RShape* RShape::clone ( ) const
pure virtual
void RShape::dump ( )
double RShape::ellipse2tr ( double  x,
double  y,
double  AA,
double  BB,
double  CC,
double  DD,
double  EE,
double  FF 
)
staticprivate
QList< RVector > RShape::filterOnShape ( const QList< RVector > &  pointList,
bool  limited = true,
double  tolerance = RDEFAULT_TOLERANCE_1E_MIN4 
) const
virtual
Returns
List of those points in pointList which are on this shape.
bool RShape::flipHorizontal ( )
virtual

Reimplemented in RSpline, RTriangle, RLine, RCircle, and RPoint.

bool RShape::flipVertical ( )
virtual

Reimplemented in RSpline, RTriangle, RLine, RCircle, and RPoint.

virtual double RShape::getAngleAt ( double  distance,
RS::From  from = RS::FromStart 
) const
inlinevirtual
Returns
Angle on the entity at the given distance from the start point.

Reimplemented in RSplineData, RPolyline, RSpline, REllipse, RArc, RCircle, RPoint, RXLine, and RLine.

virtual RBox RShape::getBoundingBox ( ) const
pure virtual
Returns
The bounding box of this shape.

Implemented in RSpline, RPolyline, RArc, REllipse, RTriangle, RCircle, RPoint, RLine, RXLine, and RViewportData.

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

Implemented in RSpline, RPolyline, RArc, RTriangle, REllipse, RCircle, RPoint, RXLine, and RLine.

RVector RShape::getClosestPointOnShape ( const RVector p,
bool  limited = true,
double  strictRange = RMAXDOUBLE 
) const
virtual
Returns
Point on this shape that is closest to p. Based on getVectorTo.
double RShape::getDistanceTo ( const RVector point,
bool  limited = true,
double  strictRange = RMAXDOUBLE 
) const
virtual
Returns
Shortest distance from this shape to the given point. Based on getVectorTo.

Reimplemented in RPolyline, and RTriangle.

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

Implemented in RSpline, RPolyline, RArc, RTriangle, REllipse, RCircle, RPoint, RXLine, and RLine.

static int RShape::getErrorCode ( )
inlinestatic
QList< RVector > RShape::getIntersectionPoints ( const RShape other,
bool  limited = true,
bool  same = false,
bool  force = false 
) const
Returns
The intersection point(s) between this shape and the given other shape.
QList< RVector > RShape::getIntersectionPoints ( const RShape shape1,
const RShape shape2,
bool  limited = true,
bool  same = false,
bool  force = false 
)
static
Returns
The intersection point(s) between this shape and the given other shape.
QList< RVector > RShape::getIntersectionPointsAA ( const RArc arc1,
const RArc arc2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsAC ( const RArc arc1,
const RCircle circle2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsAE ( const RArc arc1,
const REllipse ellipse2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsAS ( const RArc arc1,
const RSpline spline2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsAT ( const RArc arc1,
const RTriangle triangle2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsAX ( const RArc arc1,
const RExplodable explodable2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsCC ( const RCircle circle1,
const RCircle circle2 
)
static
QList< RVector > RShape::getIntersectionPointsCE ( const RCircle circle1,
const REllipse ellipse2 
)
static
QList< RVector > RShape::getIntersectionPointsCS ( const RCircle circle1,
const RSpline spline2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsCX ( const RCircle circle1,
const RExplodable explodable2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsEE ( const REllipse ellipse1,
const REllipse ellipse2 
)
static

Based on "Hughes and Chraibi (2011-2012), Calculating Ellipse Overlap Areas".

QList< RVector > RShape::getIntersectionPointsEE ( const REllipse ellipse1,
const REllipse ellipse2,
bool  limited 
)
static
QList< RVector > RShape::getIntersectionPointsES ( const REllipse ellipse1,
const RSpline spline2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsEX ( const REllipse ellipse1,
const RExplodable explodable2,
bool  limited = true 
)
static
static QList<RVector> RShape::getIntersectionPointsLA ( const RLine line1,
const RArc arc2,
bool  limited = true 
)
inlinestatic
QList< RVector > RShape::getIntersectionPointsLA ( const RLine line1,
const RArc arc2,
bool  limited1,
bool  limited2 
)
static
QList< RVector > RShape::getIntersectionPointsLC ( const RLine line1,
const RCircle circle2,
bool  limited = true 
)
static
static QList<RVector> RShape::getIntersectionPointsLE ( const RLine line1,
const REllipse ellipse2,
bool  limited = true 
)
inlinestatic
QList< RVector > RShape::getIntersectionPointsLE ( const RLine line1,
const REllipse ellipse2,
bool  limited1,
bool  limited2 
)
static
static QList<RVector> RShape::getIntersectionPointsLL ( const RLine line1,
const RLine line2,
bool  limited = true 
)
inlinestatic
QList< RVector > RShape::getIntersectionPointsLL ( const RLine line1,
const RLine line2,
bool  limited1,
bool  limited2 
)
static
QList< RVector > RShape::getIntersectionPointsLS ( const RLine line1,
const RSpline spline2,
bool  limited = true 
)
static
static QList<RVector> RShape::getIntersectionPointsLT ( const RLine line1,
const RTriangle triangle2,
bool  limited = true 
)
inlinestatic
QList< RVector > RShape::getIntersectionPointsLT ( const RLine line1,
const RTriangle triangle2,
bool  limited1,
bool  limited2 
)
static
QList< RVector > RShape::getIntersectionPointsLX ( const RLine line1,
const RExplodable explodable2,
bool  limited = true 
)
static
QList< RVector > RShape::getIntersectionPointsSS ( const RSpline spline1,
const RSpline spline2,
bool  limited = true,
bool  same = false 
)
static
QList< RVector > RShape::getIntersectionPointsSX ( const RSpline spline1,
const RExplodable explodable2,
bool  limited 
)
static
QList< RVector > RShape::getIntersectionPointsXX ( const RExplodable explodable1,
const RExplodable explodable2,
bool  limited = true,
bool  same = false 
)
static
Parameters
sameTrue if the two shapes are identical, from the same interpolated shape (e.g. spline).
virtual double RShape::getLength ( ) const
pure virtual
Returns
The total length of this shape if applicable or NaN if not.

Implemented in RSplineData, RSpline, RPolyline, REllipse, RArc, REllipseData, RArcData, RXLine, RLine, RTriangle, RCircle, and RPoint.

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

Implemented in RSpline, RPolyline, RArc, RTriangle, REllipse, RCircle, RPoint, RXLine, and RLine.

QList< QSharedPointer< RShape > > RShape::getOffsetArcs ( const RShape shape,
double  distance,
int  number,
RS::Side  side,
const RVector position = RVector::invalid 
)
static
QList< QSharedPointer< RShape > > RShape::getOffsetLines ( const RShape shape,
double  distance,
int  number,
RS::Side  side,
const RVector position = RVector::invalid 
)
static
QList< QSharedPointer< RShape > > RShape::getOffsetShapes ( double  distance,
int  number,
RS::Side  side,
const RVector position = RVector::invalid 
)
virtual
Returns
Parallels to this shape.
Parameters
distanceDistance of first parallel or concentric arc or circle.
numberNumber of offset shapes to generate.
sideSide, should be RS.LeftHand or RS.RightHand or RS.BothSides.
sidePositionPosition indicating what side of the shape the parallels should be.

Reimplemented in REllipse, RArc, RLine, RXLine, and RCircle.

RVector RShape::getPointAtPercent ( double  p) const
virtual
Returns
Point at given percentile.
virtual QList<RVector> RShape::getPointsWithDistanceToEnd ( double  distance,
int  from = RS::FromAny 
) const
pure virtual
Returns
All points on this shape with the given distance to an endpoint.

Implemented in RSpline, RPolyline, RArc, RTriangle, REllipse, RCircle, RPoint, RXLine, RLine, and RRay.

virtual RVector RShape::getPointWithDistanceToEnd ( double  distance)
inlinevirtual
virtual RVector RShape::getPointWithDistanceToStart ( double  distance)
inlinevirtual
QList< QSharedPointer< RShape > > RShape::getReversedShapeList ( const QList< QSharedPointer< RShape > > &  shapes)
static
virtual QSharedPointer<RShape> RShape::getTransformed ( const QTransform &  transform) const
pure virtual
virtual RShape::Type RShape::getType ( ) const
inlinevirtual
RVector RShape::getVectorFromEndpointTo ( const RVector point) const
virtual
Returns
Shortest vector from any end point of this shape to the given point.
virtual RVector RShape::getVectorTo ( const RVector point,
bool  limited = true,
double  strictRange = RMAXDOUBLE 
) const
pure virtual
Returns
Shortest vector from this shape to the given point.
Parameters
pointthe given point
limitedIf false, the shape is treated 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.

Implemented in RSpline, RPolyline, RArc, RTriangle, RCircle, RPoint, REllipse, RXLine, RLine, and RRay.

bool RShape::intersectsWith ( const RShape other,
bool  limited = true 
) const
virtual
Returns
True if this shape intersects with the given shape.
static bool RShape::isArcShape ( const RShape s)
inlinestatic
static bool RShape::isCircleShape ( const RShape s)
inlinestatic
static bool RShape::isEllipseShape ( const RShape s)
inlinestatic
bool RShape::isFullEllipseShape ( const RShape s)
static
virtual bool RShape::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 in RPolyline, and RSpline.

static bool RShape::isLineShape ( const RShape s)
inlinestatic
bool RShape::isOnShape ( const RVector point,
bool  limited = true,
double  tolerance = RDEFAULT_TOLERANCE_1E_MIN4 
) const
virtual
Returns
true if the given point is on this shape.

Reimplemented in RSpline.

static bool RShape::isPointShape ( const RShape s)
inlinestatic
static bool RShape::isPolylineShape ( const RShape s)
inlinestatic
static bool RShape::isRayShape ( const RShape s)
inlinestatic
static bool RShape::isSplineShape ( const RShape s)
inlinestatic
static bool RShape::isTriangleShape ( const RShape s)
inlinestatic
static bool RShape::isXLineShape ( const RShape s)
inlinestatic
virtual bool RShape::mirror ( const RLine axis)
pure virtual
virtual bool RShape::move ( const RVector offset)
pure virtual
bool RShape::order ( QList< QList< QSharedPointer< RShape > > > &  boundary)
static

Orders the given list of loops into a list of closed loops in which all shapes are connected end to start point.

Empty loops are dropped.

Returns
True if all loops are closed, false otherwise.
void RShape::print ( QDebug  dbg) const
protectedvirtual
virtual bool RShape::rotate ( double  rotation,
const RVector center = RDEFAULT_RVECTOR 
)
pure virtual
bool RShape::scale ( double  scaleFactor,
const RVector center = RVector() 
)
virtual

Reimplemented in RPolyline.

virtual bool RShape::scale ( const RVector scaleFactors,
const RVector center = RVector() 
)
pure virtual
QList< QSharedPointer< RShape > > RShape::splitAt ( const QList< RVector > &  points) const
virtual
Returns
Array of shapes which represent the given shape split up at the given points.
Parameters
pointsArray of RVector, assumed to be on shape.

Reimplemented in RSpline, REllipse, RArc, RLine, RXLine, RCircle, and RRay.

bool RShape::stretch ( const RBox area,
const RVector offset 
)
virtual
bool RShape::stretch ( const RPolyline area,
const RVector offset 
)
virtual

Reimplemented in RPolyline, RArc, RXLine, RLine, RLeaderData, and RRay.

virtual void RShape::to2D ( )
pure virtual

Flattens this shape to the X/Y plane.

Implemented in RSpline, RPolyline, REllipse, RXLine, RCircle, RTriangle, RArc, RLine, and RPoint.

QList< QSharedPointer< RShape > > RShape::trim ( const RShape trimShape,
const RVector trimClickPos,
const RShape limitingShape,
const RVector limitingClickPos,
bool  trimBoth,
bool  samePolyline 
)
static

Trims a shape to another or two shapes to each other.

Parameters
trimShapeShape which will always be trimmed.
trimClickPosCoordinate which defines which endpoint of the trim entity to trim.
limitingShapeEntity to which the trim entity will be trimmed.
limitingClickPosCoordinate which defines the intersection to which the trim entity will be trimmed.
trimBothtrue: Trim both entities. false: trim trimEntity only.

Friends And Related Function Documentation

QDebug operator<< ( QDebug  dbg,
const RShape s 
)
friend
Non-Scriptable:
This function is not available in script environments.

Member Data Documentation

double RShape::epsTolerance = 1.0e-04
staticprivate
int RShape::errorCode = 0
staticprotected
double RShape::twopi = M_PI*2
staticprivate

Copyright (c) 2011-2016 by Andrew Mustun.

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.


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