本文整理汇总了C++中Octree::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Octree::load方法的具体用法?C++ Octree::load怎么用?C++ Octree::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Octree
的用法示例。
在下文中一共展示了Octree::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: voxelize
Dynamics Voxels::voxelize(Model m, double density, double mass, double resolution)
{
#ifdef METHOD_RANDOM
srand (time(NULL));
#endif
// Zero point
auto zero = m.min();
auto max = m.max();
Point3 com(0, 0, 0);
zero.x -= resolution;
zero.y -= resolution;
zero.z -= resolution;
max.x += resolution;
max.y += resolution;
max.z += resolution;
// Dimensions
int width = (max.x-zero.x)/resolution;
int height = (max.y-zero.y)/resolution;
int depth = (max.z-zero.z)/resolution;
Dynamics dynamics;
int cubes = 0;
Octree octree;
octree.load(m);
// Volume and mass of each cube
double volume_per_cube = resolution*resolution*resolution;
double mass_per_cube;
#ifdef METHOD_RANDOM
for (int i=0; i<width*height*depth; i++)
#else
for (int z=0; z<depth; z++)
for (int y=0; y<height; y++)
for (int x=0; x<width; x++)
#endif
{
int left = 0;
int right = 0;
float X, Y, Z;
#ifdef METHOD_RANDOM
X = random_number(zero.x, max.x+1);
Y = random_number(zero.y, max.y+1);
Z = random_number(zero.z, max.z+1);
#else
X = zero.x+x*resolution+resolution/2;
Y = zero.y+y*resolution+resolution/2;
Z = zero.z+z*resolution+resolution/2;
#endif
//std::cout << X << " " << Y << " " << Z << std::endl;
Line l(Point3(X,Y,Z), Point3(DX, DY, DZ));
auto faces = octree.facesFor(l);
for (auto face : faces) {
float alpha;
if (face->intersects(l, &alpha)) {
if (alpha > 0) {
right++;
} else {
left++;
}
}
}
/*
int oleft=0, oright=0;
for (auto &volume : m.volumes)
for (auto &face : volume.faces) {
float alpha;
if (face.intersects(l, &alpha)) {
if (alpha > 0) {
oright++;
} else {
oleft++;
}
}
}
if (left!=oleft || right!=oright) {
std::cout << "=========== ERROR =============" << std::endl;
l.dump();
std::cout << oleft << "/" << oright << std::endl;
std::cout << left << "/" << right << std::endl;
for (auto &face : faces) {
//for (auto &volume : m.volumes)
//for (auto &face : volume.faces) {
float alpha;
if (face->intersects(l, &alpha)) {
// auto p = l.get(alpha);
// std::cout << p.x << " " << p.y << " " << p.z << std::endl;
//face.dump();
face->dump();
// face->gnuplot();
std::cout << std::endl << std::endl;
}
}
exit(0);
}
//.........这里部分代码省略.........