Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qgar::GenSegment< T > Class Template Reference
[Geometrical primitives]

#include <qgarlib/GenSegment.H>

Inheritance diagram for qgar::GenSegment< T >:

qgar::AbstractGenPrimitive< T > qgar::ISerializable List of all members.

Detailed Description

template<class T>
class qgar::GenSegment< T >

Geometrical segment, with coordinates of type T.

Author:
Gérald Masini
Date:
June 23, 2003 15:05
Since:
Qgar 1.0

Definition at line 131 of file _QGAR_GenSegment.H.

Public Types

Types
typedef T value_type
 Type of the source and target coordinates.
typedef value_typereference
 Reference to qgar::GenSegment::value_type.
typedef const value_typeconst_reference
 Constant reference to qgar::GenSegment::value_type.
typedef value_typepointer
 Pointer to qgar::GenSegment::value_type.
typedef const value_typeconst_pointer
 Constant pointer to qgar::GenSegment::value_type.

Public Member Functions

template<>
bool contains (const GenPoint< double > &c, double aDist)
Access to source and target
const GenPoint< value_type > & accessSource () const
 Get source point.
GenPoint< value_typesource () const
 Get a copy of the source point.
const GenPoint< value_type > & accessTarget () const
 Get target point.
GenPoint< value_typetarget () const
 Get a copy of the target point.
Access to separate coordinates
value_type xSource () const
 Get X coordinate of the source point.
value_type xTarget () const
 Get X coordinate of the target point.
value_type ySource () const
 Get Y coordinate of the source point.
value_type yTarget () const
 Get Y coordinate of the target point.
Access to geometrical characteristics
value_type dx () const
 Difference between target and source X coordinates.
value_type dy () const
 Difference between target and source Y coordinates.
Set source and/or target without update
void setSource (value_type aX, value_type aY)
 Set source point.
void setSource (const GenPoint< value_type > &aPt)
 Set source point.
void setTarget (value_type aX, value_type aY)
 Set target point.
void setTarget (const GenPoint< value_type > &aPt)
 Set target point.
void setSourceTarget (value_type aXSource, value_type aYSource, value_type aXTarget, value_type aYTarget)
 Set both source and target points.
void setSourceTarget (const GenPoint< value_type > &aSource, const GenPoint< value_type > &aTarget)
 Set both source and target points.
Set source and/or target with update
void fixSource (value_type aX, value_type aY)
 Set source point.
void fixSource (const GenPoint< value_type > &aPt)
 Set source point.
void fixTarget (value_type aX, value_type aY)
 Set target point.
void fixTarget (const GenPoint< value_type > &aPt)
 Set target point.
void fixSourceTarget (value_type aXSource, value_type aYSource, value_type aXTarget, value_type aYTarget)
 Set both source and target points.
void fixSourceTarget (const GenPoint< value_type > &aSource, const GenPoint< value_type > &aTarget)
 Set both source and target points.
Set separate (source and target) coordinates without update
void setXSource (value_type aX)
 Set X coordinate of the source point.
void setXTarget (value_type aX)
 Set X coordinate of the target point.
void setYSource (value_type aY)
 Set Y coordinate of the source point.
void setYTarget (value_type aY)
 Set Y coordinate of the target point.
Set separate (source and target) coordinates with update
void fixXSource (value_type aX)
 Set X coordinate of the source point.
void fixXTarget (value_type aX)
 Set X coordinate of the target point.
void fixYSource (value_type aY)
 Set Y coordinate of the source point.
void fixYTarget (value_type aY)
 Set Y coordinate of the target point.
Constructors
 GenSegment ()
 Default constructor.
 GenSegment (const GenSegment< value_type > &aSeg)
 Copy constructor.
 GenSegment (const GenQgarSegment< value_type > &aQSeg)
 Initialize from a Qgar segment.
 GenSegment (const GenPoint< value_type > &aSource, const GenPoint< value_type > &aTarget)
 Initialize from source and target points.
 GenSegment (const value_type aXSource, const value_type aYSource, const value_type aXTarget, const value_type aYTarget)
 Initialize from coordinates.
Destructor
virtual ~GenSegment ()
 Virtual destructor.
Copy
virtual GenSegment< value_type > * clone () const
 Return a deep copy of the surrent segment.
Access to geometrical features
double length () const
 Get length of the segment.
double sqr_length () const
 Get squared length of the segment.
double rho () const
 Distance between point (0,0) and its perpendicular projection onto the line supporting the segment.
double theta () const
 Angle between the X axis and the segment, in [0,2PI[ radians.
double angle () const
 Same as qgar::GenSegment::theta.
double slope () const
 Angle between the X axis and the segment, in [0,PI[ radians.
double thetaDegrees () const
 Same as qgar::GenSegment::theta, but the result is given in [0,360[ degrees.
double angleDegrees () const
 Same as qgar::GenSegment::theta, but the result is given in [0,360[ degrees.
double slopeDegrees () const
 Same as qgar::GenSegment::slope, but the result is given in [0,180[ degrees.
Geometrical predicates
bool contains (const GenPoint< T > &c, double aDist=Math::epsilonD())
 Return true if the given point approximately belongs to the current segment.
Operators
GenSegment< value_type > & operator= (const GenSegment< value_type > &aSeg)
 Assignment.
bool operator== (const GenSegment< value_type > &aSeg) const
 Same as function qgar::GenSegment::eq.
bool operator!= (const GenSegment< value_type > &aSeg) const
 Same as function qgar::GenSegment::notEq.
Functional operators
bool eq (const GenSegment< value_type > &aSeg) const
 Equality.
bool notEq (const GenSegment< value_type > &aSeg) const
 Inequality.
Geometry: Translation
virtual void translate (value_type aTransX, value_type aTransY)
 Translate current segment along X and Y axis.
Serialization/deserialization
virtual std::istream & read (std::istream &anInStream)
 Deserializes the current segment from an input stream.
virtual std::ostream & write (std::ostream &anOutStream) const
 Serializes the current segment to an input stream.
Access to source and target
const GenPoint< value_type > & accessSource () const
 Get source point.
GenPoint< value_typesource () const
 Get a copy of the source point.
const GenPoint< value_type > & accessTarget () const
 Get target point.
GenPoint< value_typetarget () const
 Get a copy of the target point.
Access to separate coordinates
value_type xSource () const
 Get X coordinate of the source point.
value_type xTarget () const
 Get X coordinate of the target point.
value_type ySource () const
 Get Y coordinate of the source point.
value_type yTarget () const
 Get Y coordinate of the target point.
Access to geometrical characteristics
value_type dx () const
 Difference between target and source X coordinates.
value_type dy () const
 Difference between target and source Y coordinates.
Set source and/or target without update
void setSource (value_type aX, value_type aY)
 Set source point.
void setSource (const GenPoint< value_type > &aPt)
 Set source point.
void setTarget (value_type aX, value_type aY)
 Set target point.
void setTarget (const GenPoint< value_type > &aPt)
 Set target point.
void setSourceTarget (value_type aXSource, value_type aYSource, value_type aXTarget, value_type aYTarget)
 Set both source and target points.
void setSourceTarget (const GenPoint< value_type > &aSource, const GenPoint< value_type > &aTarget)
 Set both source and target points.
Set source and/or target with update
void fixSource (value_type aX, value_type aY)
 Set source point.
void fixSource (const GenPoint< value_type > &aPt)
 Set source point.
void fixTarget (value_type aX, value_type aY)
 Set target point.
void fixTarget (const GenPoint< value_type > &aPt)
 Set target point.
void fixSourceTarget (value_type aXSource, value_type aYSource, value_type aXTarget, value_type aYTarget)
 Set both source and target points.
void fixSourceTarget (const GenPoint< value_type > &aSource, const GenPoint< value_type > &aTarget)
 Set both source and target points.
Set separate (source and target) coordinates without update
void setXSource (value_type aX)
 Set X coordinate of the source point.
void setXTarget (value_type aX)
 Set X coordinate of the target point.
void setYSource (value_type aY)
 Set Y coordinate of the source point.
void setYTarget (value_type aY)
 Set Y coordinate of the target point.
Set separate (source and target) coordinates with update
void fixXSource (value_type aX)
 Set X coordinate of the source point.
void fixXTarget (value_type aX)
 Set X coordinate of the target point.
void fixYSource (value_type aY)
 Set Y coordinate of the source point.
void fixYTarget (value_type aY)
 Set Y coordinate of the target point.

Protected Member Functions

Updates subsequent to source and target modifications
virtual void updateSource ()
 Update the geometrical structure when the source has been changed.
virtual void updateTarget ()
 Update the geometrical structure when the target has been changed.
virtual void updateSourceTarget ()
 Update the geometrical structure when both source and target have been changed.

Protected Attributes

Source and target
Apply a central symmetry to the current primitive, using the point of given coordinates as the symmetry center. Apply a central symmetry to the current primitive, using the given point as the symmetry center. Apply a mirror symmetry to the current primitive, using the line passing through the two given points for the symmetry. Apply a mirror symmetry to the current primitive, using the line supporting the given segment for the symmetry.

GenPoint< value_type_source
 Source point.
GenPoint< value_type_target
 Target point.
Source and target
Apply a central symmetry to the current primitive, using the point of given coordinates as the symmetry center. Apply a central symmetry to the current primitive, using the given point as the symmetry center. Apply a mirror symmetry to the current primitive, using the line passing through the two given points for the symmetry. Apply a mirror symmetry to the current primitive, using the line supporting the given segment for the symmetry.

GenPoint< value_type_source
 Source point.
GenPoint< value_type_target
 Target point.


Member Typedef Documentation

template<class T>
typedef const value_type* qgar::GenSegment< T >::const_pointer
 

Constant pointer to qgar::GenSegment::value_type.

Reimplemented from qgar::AbstractGenPrimitive< T >.

Definition at line 170 of file _QGAR_GenSegment.H.

template<class T>
typedef const value_type& qgar::GenSegment< T >::const_reference
 

Constant reference to qgar::GenSegment::value_type.

Reimplemented from qgar::AbstractGenPrimitive< T >.

Definition at line 160 of file _QGAR_GenSegment.H.

template<class T>
typedef value_type* qgar::GenSegment< T >::pointer
 

Pointer to qgar::GenSegment::value_type.

Reimplemented from qgar::AbstractGenPrimitive< T >.

Definition at line 165 of file _QGAR_GenSegment.H.

template<class T>
typedef value_type& qgar::GenSegment< T >::reference
 

Reference to qgar::GenSegment::value_type.

Reimplemented from qgar::AbstractGenPrimitive< T >.

Definition at line 155 of file _QGAR_GenSegment.H.

template<class T>
typedef T qgar::GenSegment< T >::value_type
 

Type of the source and target coordinates.

Reimplemented from qgar::AbstractGenPrimitive< T >.

Definition at line 150 of file _QGAR_GenSegment.H.


Constructor & Destructor Documentation

template<class T>
qgar::GenSegment< T >::GenSegment  ) 
 

Default constructor.

Zero-length segment located at the origin of the coordinate system.

Todo:
The created segment does not conform to the definition of a segment!

Definition at line 59 of file _QGAR_GenSegment.TCC.

template<class T>
qgar::GenSegment< T >::GenSegment const GenSegment< value_type > &  aSeg  ) 
 

Copy constructor.

template<class T>
qgar::GenSegment< T >::GenSegment const GenQgarSegment< value_type > &  aQSeg  )  [explicit]
 

Initialize from a Qgar segment.

Parameters:
aQSeg a Qgar segment
Warning:
This kind of conversion must be explicitely specified by the client.

Definition at line 80 of file _QGAR_GenSegment.TCC.

template<class T>
qgar::GenSegment< T >::GenSegment const GenPoint< value_type > &  aSource,
const GenPoint< value_type > &  aTarget
 

Initialize from source and target points.

Parameters:
aSource source point
aTarget target point

template<class T>
qgar::GenSegment< T >::GenSegment const value_type  aXSource,
const value_type  aYSource,
const value_type  aXTarget,
const value_type  aYTarget
 

Initialize from coordinates.

Parameters:
aXSource X coordinate of the source point
aYSource Y coordinate of the source point
aXTarget X coordinate of the target point
aYTarget X coordinate of the target point

Definition at line 106 of file _QGAR_GenSegment.TCC.

template<class T>
qgar::GenSegment< T >::~GenSegment  )  [virtual]
 

Virtual destructor.

Definition at line 123 of file _QGAR_GenSegment.TCC.


Member Function Documentation

template<class T>
const GenPoint< T > & qgar::AbstractGenPrimitive< T >::accessSource  )  const [inline, inherited]
 

Get source point.

Definition at line 143 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::_source.

Referenced by qgar::AbstractGenQgarPrimitive< T >::accessSource().

template<class T>
const GenPoint< T > & qgar::AbstractGenPrimitive< T >::accessTarget  )  const [inline, inherited]
 

Get target point.

Definition at line 163 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::_target.

Referenced by qgar::AbstractGenQgarPrimitive< T >::accessTarget(), and qgar::GenSegment< T >::slope().

template<class T>
double qgar::GenSegment< T >::angle  )  const [inline]
 

Same as qgar::GenSegment::theta.

Definition at line 291 of file _QGAR_GenSegment.TCC.

References qgar::GenSegment< T >::theta().

Referenced by qgar::GenQgarSegment< T >::angle().

template<class T>
double qgar::GenSegment< T >::angleDegrees  )  const [inline]
 

Same as qgar::GenSegment::theta, but the result is given in [0,360[ degrees.

Definition at line 310 of file _QGAR_GenSegment.TCC.

References qgar::qgRadiansToDegrees().

Referenced by qgar::GenQgarSegment< T >::angleDegrees().

template<class T>
GenSegment< T > * qgar::GenSegment< T >::clone  )  const [virtual]
 

Return a deep copy of the surrent segment.

Implements qgar::AbstractGenPrimitive< T >.

Definition at line 136 of file _QGAR_GenSegment.TCC.

template<>
bool qgar::GenSegment< double >::contains const GenPoint< double > &  c,
double  aDist
[inline]
 

Definition at line 400 of file _QGAR_GenSegment.TCC.

References qgar::AbstractGenPrimitive< T >::dx(), qgar::AbstractGenPrimitive< T >::dy(), qgar::GenSegment< T >::length(), qgar::qgDist(), qgar::GenPoint< T >::x(), qgar::AbstractGenPrimitive< T >::xSource(), qgar::GenPoint< T >::y(), and qgar::AbstractGenPrimitive< T >::ySource().

template<class T>
bool qgar::GenSegment< T >::contains const GenPoint< T > &  c,
double  aDist = Math::epsilonD()
[inline]
 

Return true if the given point approximately belongs to the current segment.

Here, ''to belong'' means to be at a distance smaller or equal to the given threshold from somed point between the source and the target of the segment.

Parameters:
c a point
aDist threshold used to decide whether the given point belongs to the segment (default qgar::Math::epsilonD)
Todo:
Use values computed for 'r' to get the distance between the point and the segment, instead of using function qgar::qgDist, which computes again these values.

Definition at line 345 of file _QGAR_GenSegment.TCC.

References qgar::GenSegment< T >::length(), qgar::qgDist(), qgar::GenPoint< T >::x(), qgar::AbstractGenPrimitive< T >::xSource(), qgar::AbstractGenPrimitive< T >::xTarget(), qgar::GenPoint< T >::y(), qgar::AbstractGenPrimitive< T >::ySource(), and qgar::AbstractGenPrimitive< T >::yTarget().

Referenced by qgar::GenQgarSegment< T >::contains().

template<class T>
T qgar::AbstractGenPrimitive< T >::dx  )  const [inline, inherited]
 

Difference between target and source X coordinates.

Definition at line 233 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::_source, qgar::AbstractGenPrimitive< T >::_target, and qgar::GenPoint< T >::x().

Referenced by qgar::GenSegment< T >::contains(), and qgar::AbstractGenQgarPrimitive< T >::dx().

template<class T>
T qgar::AbstractGenPrimitive< T >::dy  )  const [inline, inherited]
 

Difference between target and source Y coordinates.

Definition at line 243 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::_source, qgar::AbstractGenPrimitive< T >::_target, and qgar::GenPoint< T >::y().

Referenced by qgar::GenSegment< T >::contains(), qgar::AbstractGenQgarPrimitive< T >::dy(), and qgar::GenSegment< T >::length().

template<class T>
bool qgar::GenSegment< T >::eq const GenSegment< value_type > &  aSeg  )  const
 

Equality.

Parameters:
aSeg a segment
Returns:
true if the current segment and the given segment have the same coordinates.

Referenced by qgar::GenQgarSegment< T >::eq().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixSource const GenPoint< value_type > &  aPt  )  [inherited]
 

Set source point.

Parameters:
aPt a point
Warning:
Function qgar::AbstractGenPrimitive::updateSource is called after the modification of the source point.

template<class T>
void qgar::AbstractGenPrimitive< T >::fixSource value_type  aX,
value_type  aY
[inherited]
 

Set source point.

Parameters:
aX new X coordinate of the source point
aY new Y coordinate of the source point
Warning:
Function qgar::AbstractGenPrimitive::updateSource is called after the modification of the source point.

Definition at line 327 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setSource(), and qgar::AbstractGenPrimitive< T >::updateSource().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixSource().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixSourceTarget const GenPoint< value_type > &  aSource,
const GenPoint< value_type > &  aTarget
[inherited]
 

Set both source and target points.

Parameters:
aSource source point
aTarget target point
Warning:
Function qgar::AbstractGenPrimitive::updateSourceTarget is called after the modification of the source and target points.

template<class T>
void qgar::AbstractGenPrimitive< T >::fixSourceTarget value_type  aXSource,
value_type  aYSource,
value_type  aXTarget,
value_type  aYTarget
[inherited]
 

Set both source and target points.

Parameters:
aXSource new X coordinate of the source point
aYSource new Y coordinate of the source point
aXTarget new X coordinate of the target point
aYTarget new Y coordinate of the target point
Warning:
Function qgar::AbstractGenPrimitive::updateSourceTarget is called after the modification of the source and target points.

Definition at line 369 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setSourceTarget(), and qgar::AbstractGenPrimitive< T >::updateSourceTarget().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixSourceTarget().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixTarget const GenPoint< value_type > &  aPt  )  [inherited]
 

Set target point.

Parameters:
aPt a point
Warning:
Function qgar::AbstractGenPrimitive::updateTarget is called after the modification of the source target.

template<class T>
void qgar::AbstractGenPrimitive< T >::fixTarget value_type  aX,
value_type  aY
[inherited]
 

Set target point.

Parameters:
aX new X coordinate of the target point
aY new Y coordinate of the target point
Warning:
Function qgar::AbstractGenPrimitive::updateTarget is called after the modification of the target point.

Definition at line 348 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setTarget(), and qgar::AbstractGenPrimitive< T >::updateTarget().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixTarget().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixXSource value_type  aX  )  [inherited]
 

Set X coordinate of the source point.

Parameters:
aX new X coordinate of the source point
Warning:
Function qgar::AbstractGenPrimitive::updateSource is called after the modification of the source point.

Definition at line 443 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setXSource(), and qgar::AbstractGenPrimitive< T >::updateSource().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixXSource().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixXTarget value_type  aX  )  [inherited]
 

Set X coordinate of the target point.

Parameters:
aX new X coordinate of the target point
Warning:
Function qgar::AbstractGenPrimitive::updateTarget is called after the modification of the target point.

Definition at line 454 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setXTarget(), and qgar::AbstractGenPrimitive< T >::updateTarget().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixXTarget().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixYSource value_type  aY  )  [inherited]
 

Set Y coordinate of the source point.

Parameters:
aY new Y coordinate of the source point
Warning:
Function qgar::AbstractGenPrimitive::updateSource is called after the modification of the source point.

Definition at line 465 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setYSource(), and qgar::AbstractGenPrimitive< T >::updateSource().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixYSource().

template<class T>
void qgar::AbstractGenPrimitive< T >::fixYTarget value_type  aY  )  [inherited]
 

Set Y coordinate of the target point.

Parameters:
aY new Y coordinate of the target point
Warning:
Function qgar::AbstractGenPrimitive::updateTarget is called after the modification of the target point.

Definition at line 476 of file _QGAR_AbstractGenPrimitive.TCC.

References qgar::AbstractGenPrimitive< T >::setYTarget(), and qgar::AbstractGenPrimitive< T >::updateTarget().

Referenced by qgar::AbstractGenQgarPrimitive< T >::fixYTarget().

template<class T>
double qgar::GenSegment< T >::length  )  const [inline]
 

Get length of the segment.

Reimplemented in qgar::WDSegment.

Definition at line 151 of file _QGAR_GenSegment.TCC.

References qgar::AbstractGenPrimitive< T >::dy().

Referenced by qgar::GenSegment< T >::contains(), qgar::GenQgarSegment< T >::length(), qgar::GenSegment< T >::rho(), and qgar::GenSegment< T >::sqr_length().

template<class T>
bool qgar::GenSegment< T >::notEq const GenSegment< value_type > &  aSeg  )  const
 

Inequality.

Parameters:
aSeg a segment
Returns:
true if the coordinates of the current and given segments are different.

template<class T>
bool qgar::GenSegment< T >::operator!= const GenSegment< value_type > &  aSeg  )  const [inline]
 

Same as function qgar::GenSegment::notEq.

template<class T>
GenSegment<value_type>& qgar::GenSegment< T >::operator= const GenSegment< value_type > &  aSeg  )  [inline]
 

Assignment.

Parameters:
aSeg a segment

template<class T>
bool qgar::GenSegment< T >::operator== const GenSegment<