Fade2D Documentation pages v2.16.7
Delaunay Features
GEOM_FADE2D::Segment2 Class Reference

Represents a line segment between two points. More...

#include <Segment2.h>

Public Member Functions

CLASS_DECLSPEC Segment2 ()
 Default constructor for a Segment2 object. More...
 
CLASS_DECLSPEC Segment2 (const Point2 &src_, const Point2 &trg_)
 Create a Segment2 object with specified source and target points. More...
 
CLASS_DECLSPEC double getSqLen2D () const
 Calculate the squared 2D length of the segment. More...
 
CLASS_DECLSPEC Point2 getSrc () const
 Get the source point of the segment. More...
 
CLASS_DECLSPEC Point2 getTrg () const
 Get the target point of the segment. More...
 
bool operator< (const Segment2 &other) const
 Less-than operator for comparing two segments lexicographically. More...
 
CLASS_DECLSPEC bool operator== (const Segment2 &other) const
 Equality operator for the Segment2 class. More...
 
CLASS_DECLSPEC void swapSrcTrg ()
 Swap the source and target points of the segment. More...
 

Protected Attributes

Point2 src
 The source point of the segment.
 
Point2 trg
 The target point of the segment.
 

Friends

CLASS_DECLSPEC friend std::ostream & operator<< (std::ostream &stream, Segment2 seg)
 Stream output operator for the Segment2 class. More...
 

Detailed Description

The Segment2 class defines a line segment between two points (Point2 objects).

Constructor & Destructor Documentation

◆ Segment2() [1/2]

CLASS_DECLSPEC GEOM_FADE2D::Segment2::Segment2 ( const Point2 src_,
const Point2 trg_ 
)

This constructor initializes the segment using two given Point2 objects as the source and target.

Parameters
src_The first endpoint (source) of the segment.
trg_The second endpoint (target) of the segment.

◆ Segment2() [2/2]

CLASS_DECLSPEC GEOM_FADE2D::Segment2::Segment2 ( )

This constructor creates a default Segment2 object with the coordinates of both the source and target points initialized to -DBL_MAX.

Member Function Documentation

◆ getSqLen2D()

CLASS_DECLSPEC double GEOM_FADE2D::Segment2::getSqLen2D ( ) const

This function calculates the squared 2D length of the segment.

Returns
The squared 2D length of the segment.

◆ getSrc()

CLASS_DECLSPEC Point2 GEOM_FADE2D::Segment2::getSrc ( ) const

This function returns the source point of the segment.

Returns
The source point as a Point2 object.

◆ getTrg()

CLASS_DECLSPEC Point2 GEOM_FADE2D::Segment2::getTrg ( ) const

This function returns the target point of the segment.

Returns
The target point as a Point2 object.

◆ operator<()

bool GEOM_FADE2D::Segment2::operator< ( const Segment2 other) const
inline

This operator does not compare the lenghts but the source and target points for ordering purposes.

Parameters
otherThe other Segment2 object to compare.
Returns
true if the current segment is considered less than the other segment, false otherwise.

◆ operator==()

CLASS_DECLSPEC bool GEOM_FADE2D::Segment2::operator== ( const Segment2 other) const

This operator checks whether two segments are equal. This check is undirected, it compares the points regardless of their order.

Parameters
otherThe other Segment2 object to compare.
Returns
true if the two segments are equal, false otherwise.

◆ swapSrcTrg()

CLASS_DECLSPEC void GEOM_FADE2D::Segment2::swapSrcTrg ( )

This function swaps the source and target points of the segment. After the operation, the previous target point becomes the source, and the previous source becomes the target.

Friends And Related Function Documentation

◆ operator<<

CLASS_DECLSPEC friend std::ostream& operator<< ( std::ostream &  stream,
Segment2  seg 
)
friend

This operator prints a segment to an output stream.

Parameters
streamThe output stream to which the segment is written.
segThe Segment2 object to output.
Returns
The output stream with the segment data written to it.

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