/usr/include/OpenMS/DATASTRUCTURES/ConvexHull2D.h is in libopenms-dev 1.11.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | // --------------------------------------------------------------------------
// OpenMS -- Open-Source Mass Spectrometry
// --------------------------------------------------------------------------
// Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
// ETH Zurich, and Freie Universitaet Berlin 2002-2013.
//
// This software is released under a three-clause BSD license:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of any author or any participating institution
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// For a full list of authors, refer to the file AUTHORS.
// --------------------------------------------------------------------------
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
// INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// --------------------------------------------------------------------------
// $Maintainer: Stephan Aiche$
// $Authors: Marc Sturm, Chris Bielow $
// --------------------------------------------------------------------------
#ifndef OPENMS_DATASTRUCTURES_CONVEXHULL2D_H
#define OPENMS_DATASTRUCTURES_CONVEXHULL2D_H
#include <OpenMS/config.h>
#include <OpenMS/CONCEPT/Types.h>
#include <OpenMS/DATASTRUCTURES/DBoundingBox.h>
#include <OpenMS/DATASTRUCTURES/DRange.h>
#include <OpenMS/DATASTRUCTURES/Map.h>
#include <vector>
namespace OpenMS
{
/**
@brief A 2-dimensional hull representation in [counter]clockwise direction - depending on axis labelling.
The current implementation does not guarantee to produce convex hulls.
It can still store 'old' convex hulls from featureXML without problems, but does not support the enclose() query in this case,
and you will get an exception. As an alternative, you can use my_hull.getBoundingBox().encloses(), which yields similar results,
and will always work.
If you are creating new hull from peaks (eg during FeatureFinding), the generated hulls of a feature are defined as
a range in m/z dimension for each RT scan (thus might be non-convex). This has the advantage that one can clearly see
where points range within each scan (although missing points within this range are still not shown).
When hulls are created like this, the encloses() function is supported, and works as expected, i.e.
for the shape defined by this hull (view it in TOPPView) it answers whether the point is inside the shape.
However, once you store the hull in featureXML and load it again, the encloses() function is not supported any longer, because
the old convex hulls did not save min&max for each scan.
(to support encloses() at least for the new hulls, one would need to check if there exists a min&max value for each scan
--> then the query would be valid and the inner representation can be filled. Old featureXML's are not supported in any case.)
The outer hullpoints can be queried by getHullPoints().
@improvement For chromatograms we could postprocess the input and remove points in intermediate RT scans,
which are currently reported but make the number of points rather large.
@ingroup Datastructures
*/
class OPENMS_DLLAPI ConvexHull2D
{
public:
typedef DPosition<2> PointType;
typedef std::vector<PointType> PointArrayType;
typedef PointArrayType::size_type SizeType;
typedef PointArrayType::const_iterator PointArrayTypeConstIterator;
typedef Map<PointType::CoordinateType, DBoundingBox<1> > HullPointType;
/// default constructor
ConvexHull2D();
/// assignment operator
ConvexHull2D & operator=(const ConvexHull2D & rhs);
/// equality operator
bool operator==(const ConvexHull2D & rhs) const;
/// removes all points
void clear();
/// accessor for the outer points
const PointArrayType & getHullPoints() const;
/// accessor for the outer(!) points (no checking is performed if this is actually a convex hull)
void setHullPoints(const PointArrayType & points);
/// returns the bounding box of the feature hull points
DBoundingBox<2> getBoundingBox() const;
/// adds a point to the hull if it is not already contained. Returns if the point was added.
/// this will trigger recomputation of the outer hull points (thus points set with setHullPoints() will be lost)
bool addPoint(const PointType & point);
/// adds points to the hull if it is not already contained.
/// this will trigger recomputation of the outer hull points (thus points set with setHullPoints() will be lost)
void addPoints(const PointArrayType & points);
/**
@brief Allows to reduce the disk/memory footprint of a hull
Removes points from the hull which lie on a straight line and do not contribute to
the hulls shape. Should be called before saving to disk.
Example: Consider a series of 3 scans with the same dimension in m/z. After calling
compress, the points from the second scan will be removed, since they do not contribute
to the convex hull.
@returns Number of removed scans
**/
Size compress();
/**
@brief Expand a convex hull to its bounding box.
This reduces the size of a convex hull to four points, its
bounding box, thus reducing size when storing the information.
Note that this leads to an enclosed area that can be significantly
larger than the original convex hull.
**/
void expandToBoundingBox();
/**
@brief returns if the @p point lies in the feature hull
This function is only supported if the hull is created using addPoint() or addPoints(),
but not then suing setHullPoints().
If you require the latter functionality, then augment this function.
@throws Exception::NotImplemented if only hull points (outer_points_), but no internal structure (map_points_) is given
**/
bool encloses(const PointType & point) const;
protected:
/// internal structure maintaining the hull and enabling queries to encloses()
HullPointType map_points_;
/// just the list of points of the outer hull (derived from map_points_ or given by user)
mutable PointArrayType outer_points_;
};
} // namespace OPENMS
#endif // OPENMS_DATASTRUCTURES_DCONVEXHULL_H
|