Author Topic: CHALLENGE: Block Elevations to Contours  (Read 7426 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #30 on: October 28, 2021, 06:16:24 AM »
BTW Let me know if something doesn’t work. I’m out of quarantine this weekend, I’ll be at the beach redoing my tan  :laugh:

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #31 on: October 28, 2021, 07:03:52 PM »
I think the convex hull idea will work fine, I tried to convert gile’s 2d version to just carry along the Z value, but I messed up somewhere. But it’s a proof of concept
https://www.theswamp.org/index.php?topic=31865.msg429538#msg429538

here's a before and after. I added a new command "makehull" to have a visual test


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #32 on: October 28, 2021, 07:09:30 PM »
hull works here, so something may just need minor corrections  :laugh:

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #33 on: October 28, 2021, 08:43:20 PM »
Found a fast hull routine here https://stackoverflow.com/a/46371357
BlockRefs modified = 2816, BlockRefs not modified = 0 :
Total Time in Milliseconds = 1866

But I don’t think the accuracy will be as good as if the hull contains each segment.
So.. more proof of concept  :laugh:


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #34 on: October 29, 2021, 06:09:10 AM »
convex hull is not the correct tool, we're looking for a alpha shape or concave hull

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #35 on: November 15, 2021, 05:03:08 AM »
modified the concave hull routine here,  https://www.theswamp.org/index.php?topic=57135.0
I'm not brave enough to port it to .NET though, maybe someone here can. there's also a java script version it might be easier to port from.
link is in the code;

I think this would be a better tool to get the blocks that are outside the TIN, and also it may be useful to cleanup the TIN, I.e. if an edge is outside the hull, don't create the triangle.

tough task  :mrgreen:

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: CHALLENGE: Block Elevations to Contours
« Reply #36 on: November 15, 2021, 11:44:26 AM »
tough task  :mrgreen:

Yeah, it's interesting to me when I look at these these types of problems, how something that looks simple can be so complex.

My take on it was pull each block out of the collection when it was found inside of a triangle. Once all the blocks inside triangles had been processed take the remainder of the collection, and interpolate them between the nearest two points of the TIN.

I haven't had time to program recently  :cry: so I'll have to wait to give this a shot.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #37 on: November 16, 2021, 04:02:00 AM »
Possible inspiration, with a constrained TIN (c++ source
https://www.theswamp.org/index.php?topic=57122.msg607079#msg607079 )

It may be possible to run the tin inside the boundary, and again on the outside, but include the position of the blocks in the outside tin. It may make finding the triangles attached to the block easier, combined with mojo to guesstimate the Z from the other two points


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8658
  • AKA Daniel
Re: CHALLENGE: Block Elevations to Contours
« Reply #38 on: November 24, 2021, 05:39:49 AM »
https://www.theswamp.org/index.php?topic=57122.0
I posted an algorithm, that if it works for the project should be able to be fairly easy to port to .NET
In function Createctin2.
1, generate the tin, save the triangles
2, filter triangles by angle to remove the outside edges, save these triangles.
3, iterate all the filtered triangle edges. Edges the don’t have a match are outside edges. I used a dictionary for this.
4, iterate all the outside triangles and order them clockwise.
5, iterate the outside edges, add the points to the polyline.
6, using the original tin, if the center of the triangle is inside the polyline, keep it.

I actually spent time trying to port Createctin to .NET, I tried to hand roll a R-tree and priority_queue classes but failed.

Atook

  • Swamp Rat
  • Posts: 1027
  • AKA Tim
Re: CHALLENGE: Block Elevations to Contours
« Reply #39 on: November 24, 2021, 12:20:24 PM »
Thanks Daniel!