Coverage Report

Created: 2022-08-24 06:40

/src/geos/include/geos/geomgraph/index/SweepLineEvent.h
Line
Count
Source
1
/**********************************************************************
2
 *
3
 * GEOS - Geometry Engine Open Source
4
 * http://geos.osgeo.org
5
 *
6
 * Copyright (C) 2005-2006 Refractions Research Inc.
7
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
8
 *
9
 * This is free software; you can redistribute and/or modify it under
10
 * the terms of the GNU Lesser General Public Licence as published
11
 * by the Free Software Foundation.
12
 * See the COPYING file for more information.
13
 *
14
 **********************************************************************/
15
16
#pragma once
17
18
#include <geos/export.h>
19
#include <string>
20
21
// Forward declarations
22
namespace geos {
23
namespace geomgraph {
24
namespace index {
25
class SweepLineEventOBJ;
26
}
27
}
28
}
29
30
namespace geos {
31
namespace geomgraph { // geos::geomgraph
32
namespace index { // geos::geomgraph::index
33
34
//class SweepLineEventLessThen; // needed ??
35
36
class GEOS_DLL SweepLineEvent final {
37
    friend class SweepLineEventLessThen;
38
39
public:
40
41
    enum {
42
        INSERT_EVENT = 1,
43
        DELETE_EVENT
44
    };
45
46
    SweepLineEvent(void* newEdgeSet, double x,
47
                   SweepLineEvent* newInsertEvent,
48
                   SweepLineEventOBJ* newObj);
49
50
    ~SweepLineEvent() = default;
51
52
    bool
53
    isInsert()
54
13.9G
    {
55
13.9G
        return insertEvent == nullptr;
56
13.9G
    }
57
58
    bool
59
    isDelete()
60
33.6M
    {
61
33.6M
        return insertEvent != nullptr;
62
33.6M
    }
63
64
    int
65
    eventType()
66
193M
    {
67
193M
        return insertEvent == nullptr ? INSERT_EVENT : DELETE_EVENT;
68
193M
    }
69
70
    SweepLineEvent*
71
    getInsertEvent()
72
16.8M
    {
73
16.8M
        return insertEvent;
74
16.8M
    }
75
76
    size_t
77
    getDeleteEventIndex()
78
11.4M
    {
79
11.4M
        return deleteEventIndex;
80
11.4M
    }
81
82
    void
83
    setDeleteEventIndex(std::size_t newDeleteEventIndex)
84
16.8M
    {
85
16.8M
        deleteEventIndex = newDeleteEventIndex;
86
16.8M
    }
87
88
    SweepLineEventOBJ*
89
    getObject() const
90
6.98G
    {
91
6.98G
        return obj;
92
6.98G
    }
93
94
    int compareTo(SweepLineEvent* sle);
95
96
    std::string print();
97
98
    void* edgeSet;    // used for red-blue intersection detection
99
100
protected:
101
102
    SweepLineEventOBJ* obj;
103
104
private:
105
106
    double xValue;
107
108
    SweepLineEvent* insertEvent; // null if this is an INSERT_EVENT event
109
110
    std::size_t deleteEventIndex;
111
};
112
113
class GEOS_DLL SweepLineEventLessThen {
114
public:
115
    template<typename T>
116
    bool
117
    operator()(const T& f, const T& s) const
118
168M
    {
119
168M
        if(f->xValue < s->xValue) {
120
42.2M
            return true;
121
42.2M
        }
122
126M
        if(f->xValue > s->xValue) {
123
29.4M
            return false;
124
29.4M
        }
125
96.8M
        if(f->eventType() < s->eventType()) {
126
4.86M
            return true;
127
4.86M
        }
128
91.9M
        return false;
129
96.8M
    }
130
};
131
132
133
} // namespace geos.geomgraph.index
134
} // namespace geos.geomgraph
135
} // namespace geos
136