Ray Tracing in OpenFOAM
Hi OpenFOAMers!!
I'm looking for an algorithm to search the intersection between a line and cell faces of a mesh. I know Ray Tracing, which is quite similar to my problem, is an important field of study for graphic programmers, but I didn't find nothing practically interesting about CFD mesh applications. I've already searched in the forum but I didn't find nothing. Could anybody help me? Thank you a lot! Regards from Italy! |
There are a lot of functions in OF to find intersections of faces and lines/rays. Usually they are methods of indexedOctree classes. It only depends on, what you would like to intersect.
Boundary faces, triSurface faces, mesh faces? With lines (find intersection between start point and end point) or with rays (start point and vector)? Do you just need to find these intersections or are you really looking for a ray tracing algorithm, like monte carlo ray tracing? |
I'd like to know the intersection points of a line from a start point to an end point with every mesh faces at runtime.
The indexedOctree functions may be useful, but I'm having troubles with their use. Have you some advices about their application? Which headers have I to include? Is there a specific function that you suggest? |
Here are some code snippets I used to find all intersections of a line with all mesh faces. This is no complete working code.
Code:
Code:
treeBoundBox allBb(mesh.points()); Code:
const point pStart = ...; // start point of line |
Thank you mirx.
Nice code, it works very well, I just add a list to save the hit points. Code:
DynamicList<pointIndexHit> pHitList; Code:
pHitList.append(pHit); |
There was a reason that I didn't use it. I wanted to run some extra code for every intersection I had found.
But you are right. findLineAny actually executes a similar while loop as the one I have posted. I think my loop was inspired by the one in findLineAny. So if you just need the intersections, I think you can use something like: Code:
const point pStart = ...; |
I tried that but the list output seems to be not accepted:
Code:
error: no matching function for call to ‘Foam::List<Foam::PointIndexHit<Foam::Vector<double> > >::List(Foam::pointIndexHit)’ |
Oh sorry, my mistake. I confused Any with All. triSurfaceSearch has a method called fineLineAll.
Code:
void findLineAll findLineAny returns any of the intersections, not all. |
OK! Thank you a lot for your useful replies!
Bye! P.S.: I said "Any", so it was my mistake! :-) |
including header files
Hey guys,
Is any body still interested in this ray tracing application in OpenFOAM? I am having trouble with including the header file "meshtools.H"--fatal error, no such file or directory. Do you have any comments? |
Hi,
it's meshTools.H not meshtools.h. Also you need Code:
-I$(LIB_SRC)/meshTools/lnInclude |
Thanks Alexeym!
I got it going! one more question: do you know how can i use findLineAll member function of triSurfaceSearch? |
Hi,
Looked through the documentation on the method, now I have doubts I've got your question right. You've got triSurface, you construct triSurfaceSearch, you call findLineAll. So what's your question? |
For a ray tracing application I think you will be interested in the first intersection of a ray with a surface. In this case you may use method findLine of indexedOctree<treeDataTriSurface>.
This is a short example how to use this method: Code:
const triSurface surf(runTime.constantPath()/"triSurface"/surfFileName); |
Greetings! Hope someone will be able to give some hints on my issue. Thanks in advance.
I'm doing ray tracing, using octree: Code:
indexedOctree<treeDataFace> faceTree Code:
faceTree.findLine(p0, p1); Code:
treeDataFace(false, mesh), Code:
treeDataFace(false, "small part of the mesh"), |
Quote:
Code:
undefined reference to `Foam::PrimitivePatch<Foam::labelledTri, Foam::List, Foam::Field<Foam::Vector<double> >, Foam::Vector<double> >::faceNormals() const' Cheers, David |
Sinsi,
Did you ever find a method of restricting the search to a smaller part of the mesh? All the best, Tom treeDataFace(false, "small part of the mesh"), |
is it possible to search the intersection for the user specified cells?
|
All times are GMT -4. The time now is 03:56. |