资源简介
一个可用的R树例子
代码片段和文件信息
#include
#include
#include
#include “RTree.h“
//
// MemoryTest.cpp
//
// This demonstrates a use of RTree
//
// Use CRT Debug facility to dump memory leaks on app exit
#ifdef WIN32
// These two are for MSVS 2005 security consciousness until safe std lib funcs are available
#pragma warning(disable : 4996) // Deprecated functions
#define _CRT_SECURE_NO_DEPRECATE // Allow old unsecure standard library functions Disable some ‘warning C4996 - function was deprecated‘
// The following macros set and clear respectively given bits
// of the C runtime library debug flag as specified by a bitmask.
#ifdef _DEBUG
#define SET_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#define CLEAR_CRT_DEBUG_FIELD(a) \
_CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG))
#else
#define SET_CRT_DEBUG_FIELD(a) ((void) 0)
#define CLEAR_CRT_DEBUG_FIELD(a) ((void) 0)
#endif
#endif //WIN32
//
// Get a random float b/n two values
// The returned value is >= min && < max (exclusive of max)
// Note this is a low precision random value since it is generated from an int.
//
static float RandFloat(float a_min float a_max)
{
const float ooMax = 1.0f / (float)(RAND_MAX+1);
float retValue = ( (float)rand() * ooMax * (a_max - a_min) + a_min);
ASSERT(retValue >= a_min && retValue < a_max); // Paranoid check
return retValue;
}
/// Simplify handling of 3 dimensional coordinate
struct Vec3
{
/// Default constructor
Vec3() {}
/// Construct from three elements
Vec3(float a_x float a_y float a_z)
{
v[0] = a_x;
v[1] = a_y;
v[2] = a_z;
}
/// Add two vectors and return result
Vec3 operator+ (const Vec3& a_other) const
{
return Vec3(v[0] + a_other.v[0]
v[1] + a_other.v[1]
v[2] + a_other.v[2]);
}
float v[3]; ///< 3 float components for axes or dimensions
};
static bool BoxesIntersect(const Vec3& a_boxMinA const Vec3& a_boxMaxA
const Vec3& a_boxMinB const Vec3& a_boxMaxB)
{
for(int axis=0; axis<3; ++axis)
{
if(a_boxMinA.v[axis] > a_boxMaxB.v[axis] ||
a_boxMaxA.v[axis] < a_boxMinB.v[axis])
{
return false;
}
}
return true;
}
/// A user type to test with instead of a simple type such as an ‘int‘
struct SomeThing
{
SomeThing()
{
++s_outstandingAllocs;
}
~SomeThing()
{
--s_outstandingAllocs;
}
int m_creationCounter; ///< Just a number for identifying within test program
Vec3 m_min m_max; ///< Minimal bounding rect values must be known and constant in order to remove from RTree
static int s_outstandingAllocs; ///< Count how many outstanding objects remain
};
/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 58880 2015-03-20 15:14 testRTree\Debug\testRTree.exe
文件 435628 2015-03-20 15:14 testRTree\Debug\testRTree.ilk
文件 510976 2015-03-20 15:14 testRTree\Debug\testRTree.pdb
文件 7342 2015-03-20 15:14 testRTree\testRTree\Debug\BuildLog.htm
文件 5569 2015-03-20 14:51 testRTree\testRTree\Debug\MemoryTest.obj
文件 65 2015-03-20 15:14 testRTree\testRTree\Debug\mt.dep
文件 81842 2015-03-20 15:14 testRTree\testRTree\Debug\Test.obj
文件 663 2015-03-20 14:51 testRTree\testRTree\Debug\testRTree.exe.em
文件 728 2015-03-20 14:51 testRTree\testRTree\Debug\testRTree.exe.em
文件 621 2015-03-20 15:14 testRTree\testRTree\Debug\testRTree.exe.intermediate.manifest
文件 76800 2015-03-20 15:14 testRTree\testRTree\Debug\vc90.idb
文件 86016 2015-03-20 15:14 testRTree\testRTree\Debug\vc90.pdb
文件 7969 2015-03-20 14:51 testRTree\testRTree\MemoryTest.cpp
文件 45267 2010-01-05 15:55 testRTree\testRTree\RTree.h
文件 2171 2015-03-20 15:14 testRTree\testRTree\Test.cpp
文件 4045 2015-03-20 14:51 testRTree\testRTree\testRTree.vcproj
文件 1415 2016-01-15 18:39 testRTree\testRTree\testRTree.vcproj.ZhouWH-PC.ZhouWH.user
文件 535552 2016-01-15 18:39 testRTree\testRTree.ncb
文件 893 2015-03-20 14:50 testRTree\testRTree.sln
..A..H. 13312 2016-01-15 18:39 testRTree\testRTree.suo
目录 0 2015-03-20 15:14 testRTree\testRTree\Debug
目录 0 2015-03-20 14:51 testRTree\Debug
目录 0 2015-03-20 15:14 testRTree\testRTree
目录 0 2016-01-15 18:37 testRTree
----------- --------- ---------- ----- ----
1875754 24
评论
共有 条评论