• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PolyVoxCore/include/PolyVoxCore/Density.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 Copyright (c) 2005-2009 David Williams
00003 
00004 This software is provided 'as-is', without any express or implied
00005 warranty. In no event will the authors be held liable for any damages
00006 arising from the use of this software.
00007 
00008 Permission is granted to anyone to use this software for any purpose,
00009 including commercial applications, and to alter it and redistribute it
00010 freely, subject to the following restrictions:
00011 
00012     1. The origin of this software must not be misrepresented; you must not
00013     claim that you wrote the original software. If you use this software
00014     in a product, an acknowledgment in the product documentation would be
00015     appreciated but is not required.
00016 
00017     2. Altered source versions must be plainly marked as such, and must not be
00018     misrepresented as being the original software.
00019 
00020     3. This notice may not be removed or altered from any source
00021     distribution.   
00022 *******************************************************************************/
00023 
00024 #ifndef __PolyVox_Density_H__
00025 #define __PolyVox_Density_H__
00026 
00027 #include "PolyVoxImpl/TypeDef.h"
00028 
00029 #include <cassert>
00030 #include <limits>
00031 
00032 namespace PolyVox
00033 {
00046     template <typename DensityType>
00047     class Density
00048     {
00049     public:
00050         Density() : m_uDensity(0) {}
00051         Density(DensityType uDensity) : m_uDensity(uDensity) {}
00052 
00053         bool operator==(const Density& rhs) const throw()
00054         {
00055             return (m_uDensity == rhs.m_uDensity);
00056         };
00057 
00058         bool operator!=(const Density& rhs) const throw()
00059         {
00060             return !(*this == rhs);
00061         }
00062 
00063         DensityType getDensity() const throw() { return m_uDensity; }
00064         uint32_t getMaterial() const throw() { return 1; }
00065 
00066         void setDensity(DensityType uDensity) { m_uDensity = uDensity; }
00067         void setMaterial(uint32_t uMaterial) { assert(false); } //Cannot set material on voxel of type Density
00068 
00069         static DensityType getMaxDensity() throw() { return (std::numeric_limits<DensityType>::max)(); } 
00070         static DensityType getMinDensity() throw() { return (std::numeric_limits<DensityType>::min)(); }
00071         static DensityType getThreshold() throw() { return (std::numeric_limits<DensityType>::max)() / 2; }
00072 
00073     private:
00074         DensityType m_uDensity;
00075     };
00076 
00077     typedef Density<uint8_t> Density8;
00078 }
00079 
00080 #endif //__PolyVox_Density_H__

Generated on Sat Nov 19 2011 00:27:30 for PolyVox by  doxygen 1.7.1