Loading [MathJax]/extensions/tex2jax.js
LSST Applications g04a91732dc+7fec47d7bc,g07dc498a13+5ab4d22ec3,g0fba68d861+565de8e5d5,g1409bbee79+5ab4d22ec3,g1a7e361dbc+5ab4d22ec3,g1fd858c14a+11200c7927,g20f46db602+25d63fd678,g35bb328faa+fcb1d3bbc8,g4d2262a081+61302e889d,g4d39ba7253+d05e267ece,g4e0f332c67+5d362be553,g53246c7159+fcb1d3bbc8,g60b5630c4e+d05e267ece,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g8048e755c2+a1301e4c20,g8852436030+163ceb82d8,g89139ef638+5ab4d22ec3,g89e1512fd8+fbb808ebce,g8d6b6b353c+d05e267ece,g9125e01d80+fcb1d3bbc8,g989de1cb63+5ab4d22ec3,g9f33ca652e+8abe617c77,ga9baa6287d+d05e267ece,gaaedd4e678+5ab4d22ec3,gabe3b4be73+1e0a283bba,gb1101e3267+fefe9ce5b1,gb58c049af0+f03b321e39,gb90eeb9370+824c420ec4,gc741bbaa4f+77ddc33078,gcf25f946ba+163ceb82d8,gd315a588df+0f88d5218e,gd6cbbdb0b4+c8606af20c,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+e6bd566e97,ge278dab8ac+932305ba37,ge82c20c137+76d20ab76d,w.2025.10
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
indexing.h
Go to the documentation of this file.
1// This file is part of afw.
2//
3// Developed for the LSST Data Management System.
4// This product includes software developed by the LSST Project
5// (http://www.lsst.org).
6// See the COPYRIGHT file at the top-level directory of this distribution
7// for details of code ownership.
8//
9// This program is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// This program is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17// GNU General Public License for more details.
18//
19// You should have received a copy of the GNU General Public License
20// along with this program. If not, see <http://www.gnu.org/licenses/>.
21
22#ifndef LSST_AFW_IMAGE_PYTHON_INDEXING_H
23#define LSST_AFW_IMAGE_PYTHON_INDEXING_H
24
25#include "pybind11/pybind11.h"
26#include "lsst/geom/Box.h"
27
28namespace lsst { namespace afw { namespace image { namespace python {
29
30inline void checkBounds(geom::Point2I const & index, geom::Box2I const & bbox) {
31 if (!bbox.contains(index)) {
32 std::string msg = (boost::format("Index (%d, %d) outside image bounds (%d, %d) to (%d, %d).")
33 % index.getX() % index.getY() % bbox.getMinX() % bbox.getMinY()
34 % bbox.getMaxX() % bbox.getMaxY()).str();
35 if (index.getX() < 0 || index.getY() < 0) {
36 msg += " Note that negative indices are only interpreted as relative to the upper bound "
37 "when LOCAL coordinates are used.";
38 }
39 PyErr_SetString(PyExc_IndexError, msg.c_str());
40 throw pybind11::error_already_set();
41 }
42}
43
44}}}} // namespace lsst::afw::image::python
45
46#endif
47
T c_str(T... args)
An integer coordinate rectangle.
Definition Box.h:55
void checkBounds(geom::Point2I const &index, geom::Box2I const &bbox)
Definition indexing.h:30
Point< int, 2 > Point2I
Definition Point.h:321