CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (http://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   octreeLine.getIntersections() causes compile error in OF 1.7.x (http://www.cfd-online.com/Forums/openfoam-bugs/89213-octreeline-getintersections-causes-compile-error-1-7-x.html)

RDanks June 7, 2011 17:03

octreeLine.getIntersections() causes compile error in OF 1.7.x
 
1 Attachment(s)
Hi Foamers,

I'm trying to do some simple shadowing in openFOAM using ray-casting. Obviously, I'd rather use the built in octree classes to speed this process up rather than doing a brute force check of every patch face against the points I want to get shading data for. To this end I tried to impliment the octreeLine class with it's getIntersections() method, (http://foam.sourceforge.net/doc/Doxy...ctreeLine.html) to get a list of the cells intersected by a given line.

I followed the exact same setup as shown on octreeLine's Doxygen page but whenever I compile I get all kinds of errors that look like they reside in the base OF code. (See attachment for the output)

Has anyone successfully used this method or is this a bug in the code? Thanks!

RDanks June 8, 2011 09:55

Fixed it
 
Hey everyone,

After a night's rest I found the problem.

The pointHitSort class didn't have a " < " operator defined in pointHitSort.H, the std::sort algorithm needs this to sort the intersections the lineSearch finds.

If you add the following to pointHitSort.H everything compiles fine...

Code:

bool operator<(const pointHitSort& rhs) const
{
    return inter_.distance() < rhs.inter().distance();
}


aot July 19, 2011 05:41

Hi,
i also want to include some ray-casting in OF. Up to now I used some brute force searching with findcell. Have you been successful with using getintersections and is it possible to get some more information on your implementation (or at best some code snippets)?

RDanks July 19, 2011 08:25

Hi Andreas,

Basically my implementation is the same as one outlined on the Doxygen page for the octreeLine class...
Code:

   
octree<octreeDataFace> oc( .. );
octreeLine<octreeDataFace> lineSearch(oc, pStart, pEnd);
while (lineSearch.getIntersection())
{
    const point& pt = lineSearch.hitInfo().hitPoint();
        ..
}

You generate an octree of faces that could block your rays, and another one for the cells. Then you use octreeLine to see if there is an intersection between each cell centre and your ray source.
There's not much more to it than that. The built in octree classes are quite fast and I've had some good results working with it.

Quote:

Originally Posted by aot (Post 316581)
Hi,
i also want to include some ray-casting in OF. Up to now I used some brute force searching with findcell. Have you been successful with using getintersections and is it possible to get some more information on your implementation (or at best some code snippets)?


aot July 19, 2011 09:28

Hi Ryan,
thanks for the quick answer. How do you generate those octrees? Up to now I don't have any experience in working with octree-classes and there is merely any discussion on this topic in the forum.

Thanks
Andreas


All times are GMT -4. The time now is 14:33.