本文整理汇总了C++中KDTree::add方法的典型用法代码示例。如果您正苦于以下问题:C++ KDTree::add方法的具体用法?C++ KDTree::add怎么用?C++ KDTree::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KDTree
的用法示例。
在下文中一共展示了KDTree::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
//===========================================================================================================================
// Load points
//===========================================================================================================================
TheaArray<Vector3> sample_positions;
TheaArray<Vector3> sample_normals;
if (loadSamples(samples_path, sample_positions, sample_normals))
return -1;
bool has_normals = (!sample_positions.empty() && sample_normals.size() == sample_positions.size());
THEA_CONSOLE << "Loaded " << sample_positions.size() << " sample(s) from " << samples_path;
//===========================================================================================================================
// Load mesh or dense samples
//===========================================================================================================================
TheaArray<Vector3> dense_positions;
TheaArray<Vector3> dense_normals;
bool dense_has_normals = false;
KDTree kdtree;
if (mesh_path != "-")
{
// First try to load the file as a set of points
int dense_load_status = loadSamples(mesh_path, dense_positions, dense_normals);
dense_has_normals = (!dense_positions.empty() && dense_normals.size() == dense_positions.size());
if (dense_load_status != 0 && dense_load_status != UNSUPPORTED_FORMAT)
{
return -1;
}
else if (dense_load_status == 0)
{
THEA_CONSOLE << dense_positions.size() << " extra samples added from: " << mesh_path;
}
else // Now try to load the file as a mesh, if the above failed
{
MG mg;
try
{
mg.load(mesh_path);
}
THEA_STANDARD_CATCH_BLOCKS(return -1;, ERROR, "Could not load mesh %s", mesh_path.c_str())
THEA_CONSOLE << "Loaded mesh from " << mesh_path;
// Make sure the mesh is properly scaled
AxisAlignedBox3 mesh_bounds = mg.getBounds();
AxisAlignedBox3 samples_bounds;
for (array_size_t i = 0; i < sample_positions.size(); ++i)
samples_bounds.merge(sample_positions[i]);
Real scale_error = (mesh_bounds.getLow() - samples_bounds.getLow()).length()
+ (mesh_bounds.getHigh() - samples_bounds.getHigh()).length();
if (scale_error > 0.01 * mesh_bounds.getExtent().length())
{
// Rescale the mesh
Real scale = (samples_bounds.getExtent() / mesh_bounds.getExtent()).max(); // samples give a smaller bound than the
// true bound, so take the axis in which
// the approximation is best
AffineTransform3 tr = AffineTransform3::translation(samples_bounds.getCenter())
* AffineTransform3::scaling(scale)
* AffineTransform3::translation(-mesh_bounds.getCenter());
MeshTransformer func(tr);
mg.forEachMeshUntil(&func);