Giter VIP home page Giter VIP logo

Comments (5)

jbehley avatar jbehley commented on July 17, 2024

Thanks for the comment, but currently I'm busy with quite different stuff.

At least, the other neighbor queries are partially already done: nearest neighbor. k nearest neighbors is also sometimes needed, but currently not supported.

Adding and removing points needs some thought on how to get a sensible solution and also a nice interface for such things. For instance: currently, I decided to have a pointer on the original data to save space and also time for copying the data, but how would it work to add points without having direct access to the original data structure. Should we then copy the data, which would increase the runtime for the first point added. Similar issues arise with removing points: Should we keep the original data and how would we let the user decide to remove points: remove(const Point& p); might be one option, but then its hard to decide if its really the point one wants to remove. Allowing for an index-based removal seems like a good idea, but then how does the user know about the indexes, etc.

Maybe I promised there more than I could deliver right now...

from octree.

nzqo avatar nzqo commented on July 17, 2024

Well, I guess that will depend on the exact situation someone wants to use it in. Personally, I don't need the original data points, it's okay for them to get emptied, but that might be different for a different problem setting. But I can see, that this is a little difficult to implement, far too complicated for me personally :)
I'll stay tuned in case you ever implement this though!

from octree.

yetigit avatar yetigit commented on July 17, 2024

hey , hey , a good idea would be an universal solution , no more of copy/or not copy option , what we need is a vector of a simple wrapper containing a pointer to PointT ( pointer to existing object), and &x,&y, &z fields as references to the point's component, also it should contain a int "index" field , and voila , that way the current code doesn't change , no real copy is performed , and the user is responsible for copying data and co, if it want to. To remove the point we can use what is in findNeighbor(), get in the octant of interest , search for the octant item whose .index is the index to remove and it's done

from octree.

jbehley avatar jbehley commented on July 17, 2024

Lately, I had a lot of other stuff to do, so I had not time to look into this issue.

However, if I get your idea right, it would somehow only partially solve the issue. Adding points still needs access to the container or an intelligent way to tell what points were added.

I still believe that a clean solution should not depend on the "awareness" of the user (I often manage to fool myself ...) Currently, this is also not perfectly solved. The library needs awareness of the fact that the octree cannot live without the points. The intentional use case is something like that:

std::vector<Point3f> pts;

Octree oct;
oct.initialize(pts);

oct.radiusNeighbors<L2>(points[0], 0.5f, results);

However, one could do also something like that:

Octree oct;

{
  std::vector<Point3f> pts;
  oct.initialize(pts);
}

oct.radiusNeighbors<L2>(points[0], 0.5f, results);

Therefore, a copy of the points would be safer and also "user-friendlier", at the cost of a single copy. Alternatively, one could pass a shared_ptr to avoid a copy.

Same problem would occur with your reference to the pointer idea.

In the end, I think there is no "universal solution" to all use cases, since different people will have different requirements. With this in mind, I would now suggest that one just forks the repo and add his or her own way that fits their needs.

from octree.

yetigit avatar yetigit commented on July 17, 2024

Thank you for you quick response , I understand. Ok then , a copy is more friendly , however for some cases it might be really expensive so how about having an optional bool parameter =false ( so well hidden ) and let the power user turn it on so It can virtually have its points passed as reference ( via the wrapper idea)

here' s how it goes :

	/*
	* \class containing a pointer to point and its index
		this class allows to get a point in a structure 
		without copying 
	*/
	template<typename PointT>
	class PointIndexPair
	{
	private:
		PointT* point;
	public:
		decltype(point->x) &x =  point->x;
		decltype(point->y) &y =  point->y;
		decltype(point->z) &z =  point->z;
	    int index;


		PointIndexPair(PointT* pointPtr, int pointInd )
			:
			point(pointPtr),
			index(pointInd)
		{ 
		}
	
 
		PointIndexPair(PointIndexPair const& other)
			:
			point(other.point),
			index(other.index)
		{
		}

		PointIndexPair &operator=( PointIndexPair const& )=delete;
	 
		
	};

of course it must be used with caution. I already did a std::vector<PointIndexPair> and used it on your last implementation , it worked without a problem , and thanks to the index member of the class I could push sparse indices into my point array, I think sparse indices is required for any idea of removal in the octree.. then you can use findNeighbor , radiusNeighbor , get the result indice(s) use the index to get entry in point array, and

 auto pointIndice = pointArray[resultInd].index;

from octree.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.