MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / encloses

Method encloses

src/openms/source/DATASTRUCTURES/ConvexHull2D.cpp:232–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230 }
231
232 bool ConvexHull2D::encloses(const PointType& point) const
233 {
234 if ((map_points_.empty()) && !outer_points_.empty()) // we cannot answer the query as we lack the internal data structure
235 { // (if you need this you need to augment encloses() to work on outer_points_ only)
236 throw Exception::NotImplemented(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION);
237 }
238
239 if (map_points_.find(point[0]) != map_points_.end())
240 {
241 if (map_points_.at(point[0]).encloses(point[1]))
242 {
243 return true;
244 }
245 }
246
247 // find the two RT scans surrounding the point:
248 HullPointType::const_iterator it_upper = map_points_.end(), it_lower = map_points_.end();
249 // iterate over keys (which are sorted by ascending RT)
250 for (HullPointType::const_iterator it = map_points_.begin(); it != map_points_.end(); ++it)
251 {
252 // lower bound
253 if (((it->first) < (point[0])))
254 {
255 it_lower = it;
256 }
257 // upper bound
258 if ((it_upper == map_points_.end()) && ((it->first) > (point[0])))
259 {
260 it_upper = it;
261 }
262 }
263
264 // point is not between two scans
265 if ((it_lower == map_points_.end()) || (it_upper == map_points_.end()))
266 {
267 return false;
268 }
269 // check if point is within bounds
270 double mz_low = it_lower->second.minPosition()[0] // m/z offset
271 + ((point[0] - (it_lower->first)) / ((it_upper->first) - (it_lower->first))) // factor (0-1)
272 * (it_upper->second.minPosition()[0] - it_lower->second.minPosition()[0]); // m/z range
273
274 double mz_high = it_lower->second.maxPosition()[0] // m/z offset
275 + ((point[0] - (it_lower->first)) / ((it_upper->first) - (it_lower->first))) // factor (0-1)
276 * (it_upper->second.maxPosition()[0] - it_lower->second.maxPosition()[0]); // m/z range
277
278
279 DBoundingBox<1> range(mz_low, mz_high);
280 return range.encloses(point[1]);
281 }
282
283} // namespace OpenMS

Callers 2

test_convex_hull_1Function · 0.95
addPointMethod · 0.45

Calls 5

atMethod · 0.80
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by 1

test_convex_hull_1Function · 0.76