Healpix C++  3.83
moc_query.h
Go to the documentation of this file.
1 /*
2  * This file is part of Healpix_cxx.
3  *
4  * Healpix_cxx is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Healpix_cxx is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Healpix_cxx; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * For more information about HEALPix, see http://healpix.sourceforge.net
19  */
20 
21 /*
22  * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
23  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
24  * (DLR).
25  */
26 
27 /*! \file moc_query.h
28  * Copyright (C) 2014-2015 Max-Planck-Society
29  * \author Martin Reinecke
30  */
31 
32 #ifndef MOC_QUERY_H
33 #define MOC_QUERY_H
34 
35 #include "vec3.h"
36 #include "moc.h"
37 
38 enum MocQueryOp { AND,OR,XOR,NOT,NONE };
39 
40 class MocQueryComponent
41  {
42  public:
43  MocQueryOp op;
44  int nops;
45  vec3 center;
46  double radius;
47  MocQueryComponent(MocQueryOp op_)
48  : op(op_)
49  {
50  planck_assert(op_!=NONE,"bad operator");
51  switch (op)
52  {
53  case AND:
54  case OR:
55  case XOR:
56  nops=2;
57  break;
58  case NOT:
59  nops=1;
60  break;
61  case NONE:
62  nops=0;
63  break;
64  }
65  }
66  MocQueryComponent(MocQueryOp op_, int nops_)
67  {
68  op= op_;
69  nops=nops_;
70  switch (op)
71  {
72  case AND:
73  case OR:
74  planck_assert(nops>=2,"bad nops");
75  break;
76  case XOR:
77  planck_assert(nops==2,"bad nops");
78  break;
79  case NOT:
80  planck_assert(nops==1,"bad nops");
81  break;
82  case NONE:
83  planck_fail("bad operator");
84  break;
85  }
86  }
87  MocQueryComponent(const vec3 &cnt, double rad)
88  : op (NONE), nops(0), center(cnt.Norm()), radius(rad) {}
89  };
90 
91 template<typename I> Moc<I> mocQuery (int order,
92  const std::vector<MocQueryComponent> &comp);
93 
94 template<typename I> Moc<I> mocQueryInclusive (int order, int omax,
95  const std::vector<MocQueryComponent> &comp);
96 
97 std::vector<MocQueryComponent> prepPolygon (const std::vector<vec3> &vertex);
98 
99 template<typename I> inline Moc<I> mocQuery (int order,
100  const std::vector<vec3> &vertex)
101  { return mocQuery<I>(order, prepPolygon(vertex)); }
102 
103 template<typename I> inline Moc<I> mocQueryInclusive (int order, int omax,
104  const std::vector<vec3> &vertex)
105  { return mocQueryInclusive<I>(order, omax, prepPolygon(vertex)); }
106 
107 #endif

Generated on Wed Nov 13 2024 12:18:30 for Healpix C++