moc_query.h

Go to the documentation of this file.
00001 /*
00002  *  This file is part of Healpix_cxx.
00003  *
00004  *  Healpix_cxx is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  Healpix_cxx is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with Healpix_cxx; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  *  For more information about HEALPix, see http://healpix.sourceforge.net
00019  */
00020 
00021 /*
00022  *  Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
00023  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00024  *  (DLR).
00025  */
00026 
00027 /*! \file moc_query.h
00028  *  Copyright (C) 2014-2015 Max-Planck-Society
00029  *  \author Martin Reinecke
00030  */
00031 
00032 #ifndef MOC_QUERY_H
00033 #define MOC_QUERY_H
00034 
00035 #include "vec3.h"
00036 #include "moc.h"
00037 
00038 enum MocQueryOp { AND,OR,XOR,NOT,NONE };
00039 
00040 class MocQueryComponent
00041   {
00042   public:
00043     MocQueryOp op;
00044     int nops;
00045     vec3 center;
00046     double radius;
00047     MocQueryComponent(MocQueryOp op_)
00048       : op(op_)
00049       {
00050       planck_assert(op_!=NONE,"bad operator");
00051       switch (op)
00052         {
00053         case AND:
00054         case OR:
00055         case XOR:
00056           nops=2;
00057           break;
00058         case NOT:
00059           nops=1;
00060           break;
00061         case NONE:
00062           nops=0;
00063           break;
00064         }
00065       }
00066     MocQueryComponent(MocQueryOp op_, int nops_)
00067       {
00068       op= op_;
00069       nops=nops_;
00070       switch (op)
00071         {
00072         case AND:
00073         case OR:
00074           planck_assert(nops>=2,"bad nops");
00075           break;
00076         case XOR:
00077           planck_assert(nops==2,"bad nops");
00078           break;
00079         case NOT:
00080           planck_assert(nops==1,"bad nops");
00081           break;
00082         case NONE:
00083           planck_fail("bad operator");
00084           break;
00085         }
00086       }
00087     MocQueryComponent(const vec3 &cnt, double rad)
00088       : op (NONE), nops(0), center(cnt.Norm()), radius(rad) {}
00089   };
00090 
00091 template<typename I> Moc<I> mocQuery (int order,
00092   const std::vector<MocQueryComponent> &comp);
00093 
00094 template<typename I> Moc<I> mocQueryInclusive (int order, int omax,
00095   const std::vector<MocQueryComponent> &comp);
00096 
00097 std::vector<MocQueryComponent> prepPolygon (const std::vector<vec3> &vertex);
00098 
00099 template<typename I> inline Moc<I> mocQuery (int order,
00100   const std::vector<vec3> &vertex)
00101   { return mocQuery<I>(order, prepPolygon(vertex)); }
00102 
00103 template<typename I> inline Moc<I> mocQueryInclusive (int order, int omax,
00104   const std::vector<vec3> &vertex)
00105   { return mocQueryInclusive<I>(order, omax, prepPolygon(vertex)); }
00106 
00107 #endif

Generated on Thu Oct 8 14:48:52 2015 for Healpix C++