Revision 20e1dabed20b8419e759f1c442cce60a5843bed2 authored by Dmitri Naumov on 13 May 2021, 19:32:42 UTC, committed by Dmitri Naumov on 17 May 2021, 12:17:18 UTC
Using (const) access functions in two cases of direct member access.
1 parent a4cf5c6
LineSegment.h
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*/
#pragma once
#include "Point.h"
namespace GeoLib
{
class LineSegment final
{
public:
/// Constructs a line segment given by its begin and end points.
/// @remark The main purpose of class LineSegment is the use within a
/// polyline. For this reason the memory is not managed per default. But the
/// user has the freedom to hand over the responsibility for the mem
/// management of the points to the object.
LineSegment(GeoLib::Point* const a, GeoLib::Point* const b,
bool point_mem_management_by_line_segment = false);
LineSegment(LineSegment&& line_segment);
LineSegment(LineSegment const& line_segment);
~LineSegment();
LineSegment& operator=(LineSegment const& rhs);
LineSegment& operator=(LineSegment&& line_segment);
GeoLib::Point const& getBeginPoint() const;
GeoLib::Point & getBeginPoint();
GeoLib::Point const& getEndPoint() const;
GeoLib::Point & getEndPoint();
private:
GeoLib::Point* _a = nullptr;
GeoLib::Point* _b = nullptr;
bool _point_mem_management_by_line_segment = false;
};
std::ostream& operator<< (std::ostream& os, LineSegment const& s);
std::ostream& operator<<(std::ostream& os,
std::pair<GeoLib::LineSegment const&,
GeoLib::LineSegment const&> const& seg_pair);
/// Compares two objects of type LineSegment.
/// @note The comparison is not strict. Two line segments \f$s_0 = (b_0, e_0)\f$
/// and \f$s_1 = (b_1, e_1)\f$ are equal, if \f$\|b_0-b_1\|^2 < \epsilon\f$ and
/// \f$\|e_0-e_1\|^2 < \epsilon\f$ or \f$\|b_0-e_1\|^2 < \epsilon\f$ and
/// \f$\|e_0-b_1\|^2 < \epsilon\f$ where \f$\epsilon\f$ is the machine precision
/// of double.
bool operator==(LineSegment const& s0, LineSegment const& s1);
} // namespace GeoLib
Computing file changes ...