aardgoose / CaveView.js

Web native 3d cave survey viewer
https://aardgoose.github.io/CaveView.js/
MIT License
44 stars 11 forks source link

Walls based on splays #11

Open vldgeorgiev opened 6 years ago

vldgeorgiev commented 6 years ago

Hi

I noticed that there is an option to display walls, from both 3D and LOX, but only for LRUD data. Is there a feature to display splay walls, or do you plan to add one?

I don't mean the wall generation that Loch does based on the scraps, but a wall model based on any number of splays from the stations. I think it is getting much more relevant with the advance of the Disto-style surveying, compared to the traditional LRUD :)

Thanks.

aardgoose commented 6 years ago

Hi,

I have thought about modelling passages based on splays, but haven't seen many surveys with a high density of splays, but it is certainly worth investigating with more 'point cloud' type surveys being made.

One problem is there is not a definitive mechanism for determining the correct shape only best guesses can be made, so it will take a bit of experimentation to get something workable, and some decent samples - the best example I have to hand is for the Titan shaft. Any pointers to useful literature welcome.

vldgeorgiev commented 6 years ago

Well, I haven't researched any literature on the subject, and I am not that good with JS to determine how useful they would be. But I suppose that the authors of Survex, Therion or TopoDroid would have good ideas. These are just some apps that do 3D modelling based on splays.

In my opinion, the survey doesn't need to be very detailed or with a very dense point cloud. A few splays per station would be enough to generate a model, which will be no worse than the LRUD one. The LRUD by definition is only four measurements per station. And it would be up to the surveyor to make it more or less detailed. I can send you samples of caves of different sizes surveyed like that, with about 4-10 splays per station.

But since you are doing the work, it's up to you to decide :) It might not be an easy feature to add, unless there is a 3rd party lib doing something similar. I can try to help with the research, samples, etc.

aardgoose commented 6 years ago

Hi,

I have made some progress, found a javascript package implementing 'alpha-shapes' which appear to be the best approach. Calculating these for even small surveys is slow, so I have implemented a mechanism to carrying out all the maths in a background thread which works well. The results will improve when I can break the point cloud into passage sections, but requires a bit more topology to be worked out. When I have done this I can also use multiple background threads and tune model creation to the characteristics of each section of passage (average leg length, how winding a passage is etc)

Test using Titan in Derbyshire (a survey with a lot of spays from a relatively small number of stations):

alpha

vldgeorgiev commented 6 years ago

Good progress :) The model looks realistic enough.

ojwb commented 6 years ago

I did some work many years ago which stitched a passage envelope from a series of splays taken along the passage - this screenshot is from that code (on some fake data during development):

The algorithm essentially just matches up the splay inclinations between consecutive "passes" to create a mesh of elongated triangles (with the long direction being along the passage as the image above shows), which can be done without a lot of computation.

With OpenGL smoothing added it worked well in real use for a single passage, but the approach doesn't really seem to generalise to provide a good way to handle junctions and chambers, and those are really the more interesting cases to be able to visualise, so I didn't end up merging it. This was also before the disto-x and there wasn't much general use for generating passage shapes from splays.

The alpha shapes approach seems a very plausible one, with the big advantage that it should do something at least vaguely sensible with complex cases, though if different sections are being processed separately then a hybrid approach where simple passages are handled by a faster algorithm might be worth considering.

I've attached a couple of small surveys which are fairly splay rich in case some more test data is useful:

101-and-171.zip

aardgoose commented 6 years ago

Hi, thanks. I initially considered something simple for plain passages and as you say a hybrid approach may be the best. Certainly in JavaScript alpha shapes take a bit of time computing (which is why I push that work into background workers (and get to use multiple cores)). I'll have to give some thought to tuning the 'concavity' parameter as well. It is certainly an interesting area with low density point clouds becoming more common.

Thanks for the examples, which exposed a bug where splays ending in unnamed stations were ignored. 171.3d show below.

171-alpha2

ojwb commented 6 years ago

That looks plausibly like my memory of the cave at least.

It occurred to me that one thing the alpha shape doesn't really capture exactly is that a splay with the "WALL" flag is a fairly definite indication that there's a wall at the end of that splay (give or take survey uncertainty), whereas the alpha shape will happily ignore points which it thinks are inside the passage. Sometimes that's actually right because there might be a blunder - e.g. if the laser beam actually hit something nearer than the wall it was aimed such as one of the cavers or a boulder, or a splay is attached to the wrong station or flagged as "WALL" when it was actually to a feature inside the passage. Perhaps in practice this isn't a big issue though.

Do you do anything special with the centre-line? That shouldn't cross outside the walls, but at least the alpha shape code I've looked at seem to work from points. I guess sampling the centreline into points spaced slightly less than the alpha radius would work, but seems clumsy.

What sort of speed are you seeing for generating the alpha shape?

aardgoose commented 6 years ago

Hi,

I see your point about not putting wall points on the envelope. The issue with vertices out of the shape is probably my rather broken mechanism that was treating the points batches. I think for better fit the 'alpha' parameter needs to vary across the set of points, although I haven't looked deeply into the algorithm to see if this is feasible. I'll have to return to this when I have more time.

Speed wise it takes about 2 seconds for this example.

apgeo commented 4 years ago

At EuroSpeleo 2016 there was a presentation of an algorithm that generates walls based on splays only.

https://poormanslaserscanner.github.io/pmls4matlab/paper.pdf http://cave3d.org/cmssimple/

https://github.com/poormanslaserscanner/pmls4matlab

It looked as it had good results as it was taking into account the splay lines as well, not only the splay end points, thus generating a more realistic model. They promised to publish the source code but I think they are yet to do that. But maybe it's available on request.

ojwb commented 4 years ago

There seems to be source code at the last link above, though it looks like it is for a matlab plugin so may not be very reusable as-is.