资源简介
一个外国人写的,用C++语言实现了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
};
/ 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7699 2009-12-03 16:41 RTreeTemplate\MemoryTest.cpp
文件 1247 2010-01-05 16:04 RTreeTemplate\README.TXT
文件 45267 2010-01-05 15:55 RTreeTemplate\RTree.h
文件 2171 2009-12-03 16:41 RTreeTemplate\Test.cpp
- 上一篇:CDib类MFC图像编程必备
- 下一篇:简易学生管理系统(C++)
相关资源
- 北京化工大学计算方法(C/C++)讲义
- GBT 28169-2011 嵌入式软件 C语言编码规范
- XUnZip Zip解压缩.rar
- Windows_API_函数大全 C/C++
- C语言程序设计教材习题参考答案.do
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- 高效FFT的C/C++代码实现包括基2的DIF和
- c/c++开发网络验证和本地验证
- 操作系统存储管理实验报告c/c++
- C++编写的万年历源码
- C语言进阶源码---基于graphics实现图书
- 井字棋三连棋的AI实现,C/C++
- 《水果忍者》设计报告.doc
- MFC实现的红绿灯程序
- Win32简易画图程序
- C++网络爬虫项目
- 泡泡堂(炸弹人)小游戏C/C++完整源码
- 使用C/C++读取BITMAP的内容
- VC图像处理-用Canny算子提取边缘
- C/C++视频教程
- 个人总结的一些C/C++编码规范
- 高斯消去法求解线性方程组C/C++程序输
- celrityC/C++源码查看工具
- 网络编程MFC 实验四 FTP客户端功能实现
- C/C++语言大作业、小游戏
- 完整的C/C++时序的B+树数据库系统实现
- Eclipse C/C++ 自动补全的cdt补丁
- MongoDB C/C++开发使用案例Demo
- C/C++使用WinIO读取CMOS数据代码
- Diab C/C++ Compiler for PowerPC
川公网安备 51152502000135号
评论
共有 条评论