nushoin / rtree Goto Github PK
View Code? Open in Web Editor NEWN-dimensional RTree implementation in C++
License: Other
N-dimensional RTree implementation in C++
License: Other
Hi,
Sorry to disturb you. My data set are some time series. I need to regard each time series as one point to insert RTree. For example:
point 1:{(x1,y1),(x2,y2),(x3,y3),(x4,y4) ,..., (xn,yn)}.
point 2:{(),()....},
point 3.....
I met a situation that some times when min value is equal to max value (y1==y2), the volume calculation is zero.
How to deal with this situation?
Thank you very much.
Hi,
In this example, what Foo stands for?
RTree<Foo*, double, 3> tree;
double min[3] = {0., 0., 0.};
double max[3] = {1., 1., 1.};
Foo* bar = new Foo();
tree.Insert(min, max, bar);
Also is there a way to get all collision pairs without duplicates?
Meaning that the pair 0-1 and 1-0 is the same therefore the second one must be ignored.
There is a warning in Pickbranch:
Variable 'bestArea' may be uninitialized when used here
at line:
else if ((increase == bestIncr) && (area < bestArea))
Best regards
Ben
Hello,
The source code is this repository is unlicensed. What terms may I use this source code under?
fopen
gives some warning when compiling in MSVC compiler.
C4996 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details
easy workaround:
#pragma warning( push )
#pragma warning(disable:4996)
#pragma warning(disable:4244)
#include "RTree.h"
#pragma warning( pop )
also this line:
ELEMTYPEREAL halfExtent = ((ELEMTYPEREAL)a_rect->m_max[index] - (ELEMTYPEREAL)a_rect->m_min[index]) * 0.5f;
gives this warning
C4244 'initializing': conversion from 'float' to 'ELEMTYPEREAL', possible loss of data
it's probably the * 0.5f
But I must say, otherwise, this worked out of the box, in no time! and improved my code from O(n^2) to O(nlogn) and it's a blast.
Hi,
How can I print a list of all boxes in an rtree to vizualize the tree hierarchy like the image below (blue boxes)?
My current code for neighbour search is this:
//////////////////////////////////////////////////////////////////////////////
// Create RTree
//////////////////////////////////////////////////////////////////////////////
RTree<int, double, 3> tree;
//////////////////////////////////////////////////////////////////////////////
// Insert AABB
//////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < elements.size(); i++) {
double min[3] = { elements[i].aabb.xmin(), elements[i].aabb.ymin(), elements[i].aabb.zmin() };
double max[3] = { elements[i].aabb.xmax(), elements[i].aabb.ymax(), elements[i].aabb.zmax() };
tree.Insert(min, max, i);
}
//////////////////////////////////////////////////////////////////////////////
// Search Closest Boxes | Skip duplicates pairs | Perform callback with OBB
//////////////////////////////////////////////////////////////////////////////
std::vector<int> result;
for (int i = 0; i < elements.size(); i++) {//AABB.size()
//std::vector<int> result;
auto callback = [&result, i, &elements](int foundValue) -> bool
{
if (i < foundValue && cgal_box_util::GetCollision(elements[i].oob, elements[foundValue].oob)) {
result.push_back(i);
result.push_back(foundValue);
}
return true;
};
double min[3] = { elements[i].aabb.xmin(), elements[i].aabb.ymin(), elements[i].aabb.zmin() };
double max[3] = { elements[i].aabb.xmax(), elements[i].aabb.ymax(), elements[i].aabb.zmax() };
int nhits = tree.Search(min, max, callback);//callback in this method call callback above
}
hello,nushoin
i have read your code adn i have a question, you code insert a box when init the Rtree. could i add point as (x,y) in init Rtree and Rtree gennerted automatic ?
Thanks!
Hello, I was trying to make a 3d tree from a file and stepped into this:
Line 61 in b45759b
should it be rectVector.push_back( Rect( xmin, ymin, xmax, ymax ) );
?
Dear @AlexVonB
Thank you for a previous help.
I have one more question.
How can I modify existing code or include into lambda, the check that the id of a box is bigger than searched one?
I want to avoid the second loop below when I collect resultWanted.
std::vector<int> result;
auto callback = [&result](int foundValue) -> bool { result.push_back(foundValue); return true; };
int nhits = tree.Search(min, max, callback);
std::vector<int> resultWanted;
for (int j = 0; j < result.size(); j++) {
if(result[j]>j){
resultWanted.push_back(result[j]);
}
}
Hi,
I am a student who is studying R-Tree now.
I wonder if the tree.search() function also supports Box-Segment intersection? So far the input is always a search_rectangle, could I directly input a segment represented by two 3D points, and get all the rectangles intersected with the input segment?
Hi, can you stick an appropriate license on this code?
As-is, technically it's illegal to actually use this code - a simple BSD license is probably most appropriate.
Hi,
I am using RTree on YearPredictionMSD with dimension=91.
I got an assertion error after 9 vectors inserted:
Assertion `PartitionVars::NOT_TAKEN == a_parVars->m_partition[a_index]' failed.
const size_t dimension = 91;
typedef RTree<float, float , dimension, float> MyTree;
MyTree tree;
for(int i=0; i < nb; i++)
{
tree.Insert(&xb[i * dimension], &xb[i * dimension], i);
}
Any idea?
Thanks a lot,
Xinyan
Is there any way to get the coordinate when we have the match, instead of loop through the whole tree using the iterator?
Also, where can I set the a_searchResult array?
/// Find all within search rectangle
/// \param a_min Min of search bounding rect
/// \param a_max Max of search bounding rect
/// \param a_searchResult Search result array. Caller should set grow size. Function will reset, not append to array.
/// \param a_resultCallback Callback function to return result. Callback should return 'true' to continue searching
/// \param a_context User context to pass as parameter to a_resultCallback
/// \return Returns the number of entries found
int Search(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], t_resultCallback a_resultCallback, void* a_context);
Unused variable 'branch'
RTree.h string #898 "Branch branch;"
Probably its just unnecessary string.
i have inserted some data into the rtree, but when i insert new data, it invoke the bug. how can i send the test code and the data to you? my email is [email protected]. thank you very mush.
Hello,
I'm wondering why there is no RemoveId (or whatever the name) function with simple signature
void RemoveId(const DATATYPE& a_dataId);
in addition to the existing
void Remove(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE& a_dataId);
It would just remove all entries with that id which is a feature that seems to be very useful because it is needed for every update.
Instead, one has to know the a_min and a_max of the entry which is a little counter-intuitive because:
Similarly, a function to update the a_min[NUMDIMS] and a_max[NUMDIMS] of an entry without having to delete it might also be great. Is there any way to do that already?
(By the way, is "entry" synonymous with "leaf"?)
Thanks for answer,
Mathias
Hi I found that in PickSeeds function.
It has the situation that there is no seed picked by the function.
Then it causes segmentation fault.
In this situation, should we not to execute Classify on the seeds?
Hi,
I want to use long long as the data type of my work.
May I ask how to use long long with this library?
Thanks a lot
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.