home | project pages | download | documentation | doxygen | contact |
00001 /* Voxel.h - A voxel. 00002 * Copyright (C) 2008 Take Vos 00003 * 00004 * This program 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 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef VOXEL_H 00018 #define VOXEL_H 00019 00020 #include <stdint.h> 00021 00022 namespace camvox { 00023 00024 class Voxel { 00025 public: 00026 uint32_t value; 00027 00028 Voxel() { 00029 value = 0; 00030 } 00031 00032 Voxel(uint32_t _value) { 00033 value = _value; 00034 } 00035 00036 Voxel(const Voxel &other) { 00037 value = other.value; 00038 } 00039 00040 Voxel &operator=(const Voxel &other) { 00041 value = other.value; 00042 return *this; 00043 } 00044 00045 bool operator!=(const Voxel &other) const { 00046 return value != other.value; 00047 } 00048 00049 void orLayers(const Voxel &other) { 00050 value|= other.value; 00051 } 00052 00053 void andLayers(const Voxel &other) { 00054 value&= other.value; 00055 } 00056 00057 void xorLayers(const Voxel &other) { 00058 value^= other.value; 00059 } 00060 00061 void setNodeNr(uint32_t node_nr) { 00062 value = node_nr | 0x80000000; 00063 } 00064 00065 void setLayers(uint32_t layers) { 00066 value = (layers & 0x3fffffff) | 0x40000000; 00067 } 00068 00069 void setDontPrune(void) { 00070 value = 0; 00071 } 00072 00073 bool isNodeNr(void) { 00074 return (value & 0x80000000) == 0x80000000; 00075 } 00076 00077 bool isLayers(void) { 00078 return (value & 0xc0000000) == 0x40000000; 00079 } 00080 00081 bool isDontPrune(void) const { 00082 return value == 0; 00083 } 00084 00085 uint32_t getValue(void) const { 00086 return value; 00087 } 00088 00089 uint32_t getNodeNr(void) const { 00090 return value & 0x7fffffff; 00091 } 00092 00093 uint32_t getLayers(void) const { 00094 return value & 0x3fffffff; 00095 } 00096 }; 00097 00098 } 00099 00100 #endif