Civil engineering feature implementation (Transportation Engineering)

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by microelly2 »

Joel_graff wrote: Wed Nov 27, 2019 6:34 pm
That's next. Then I need to work on developing the outer envelope (merging the outermost tracks where one exceeds another)
Alpha shapes! https://youtu.be/Hvc_ofV2iZc
There are good algorithms implemented in numpy/scipy
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

microelly2 wrote: Wed Nov 27, 2019 9:06 pm Alpha shapes! https://youtu.be/Hvc_ofV2iZc
There are good algorithms implemented in numpy/scipy
I knew of that but hadn't researched it. I was planning on tracking the progression at each step and saving the vertices which were outermost. It's some vector math and probably a week of testing...

The only issue I see with the alpha shapes approach is not being able to get an ordered list of the boundary vertices, which I'm certain I'll need in order to render it as an SoLineSet in Coin3D.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by microelly2 »

Joel_graff wrote: Thu Nov 28, 2019 1:26 pm The only issue I see with the alpha shapes approach is not being able to get an ordered list of the boundary vertices, which I'm certain I'll need in order to render it as an SoLineSet in Coin3D.
The algorithms for alpha shapes do not need ordered sets, so you can discretize your track curves and analyze the resulting point cloud.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

microelly2 wrote: Thu Nov 28, 2019 1:37 pm The algorithms for alpha shapes do not need ordered sets, so you can discretize your track curves and analyze the resulting point cloud.
Precisely the problem. I need ordered vertices, so it seems to me I’d break even to post process the alpha shape to get them rather than write my own which will generate them as it goes..

Unless there’s a ready way to get that from the alpha shape with minimal post processing?
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by microelly2 »

Joel_graff wrote: Thu Nov 28, 2019 5:53 pm Unless there’s a ready way to get that from the alpha shape with minimal post processing?
I don't know at the moment. My idea was a running frame (bounding box of the car) where the alpha shape of the border points is calculated.
I will play a bit with such structures to get a feeling.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

microelly2 wrote: Thu Nov 28, 2019 8:58 pm I don't know at the moment. My idea was a running frame (bounding box of the car) where the alpha shape of the border points is calculated.
I will play a bit with such structures to get a feeling.
Yeah, adding trailers is where it gets complex. I suppose a triangulated mesh would be ok, but all I want to visualize is the outline for the turning envelope...
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by microelly2 »

for 2D simulation this is a simple to use tool:
https://alphashape.readthedocs.io/en/latest/readme.html
we can create a frame of the tracked curve discretized and the path curve and than apply the alpha shape method to get a bounding polgon.
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

microelly2 wrote: Fri Nov 29, 2019 9:56 am https://alphashape.readthedocs.io/en/latest/readme.html
we can create a frame of the tracked curve discretized and the path curve and than apply the alpha shape method to get a bounding polgon.
Some of that is easy to do - the wheel tracks don't ever define the outer envelope, for example, so those can be excluded from the alpha shape. But even using only the outer points on the vehicle body, you still have to find a way to pick the inside ones and remove them to be left with just the outermost boundary.

Consider a tractor / trailer combination with four points on each body. That's eight outer tracks (four on each side) which will defined the total envelope. As the tractor / trailer turn and move, each of those tracks will inevitably be the outermost track and define the limit of the envelope.

The issue I can't get past is that an alpha shape will leave me with the same problem I begin with - determining which points are outermost so I can have just a boundary, even if it does create a nice mesh. Solving that would require the same approach I would use if I never used alpha shapes to begin with...

That said, if there's some other way to hide the mesh interior (or generate a poly line that represents it's boundary) using the alpha shape library, I'm all for it. :)

In the end, it's really only an aesthetic issue - I don't want to see a triangulated mesh for the swept path boundary. I might even consider using the boundary vertices as points for a spline to provide smoother edges, but that's another matter entirely.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Joel_graff »

I will say this:

pivy_trackers has been quite helpful in visualizing the algorithm I'm developing for building the swept path outer envelope...

Really, really helpful.

The only piece of actual FC geometry I'm using is the spline path the vehicle is following...

turns_vehicle.gif
turns_vehicle.gif (190.27 KiB) Viewed 1123 times

@microelly2 - in case you're wondering, I did play with the alphashapes library you pointed out. The chief issue I had with it was it's own dependencies and the considerable time it took to import. That said, it did appears an alphashape object retains a list of the boundary points, so I think it would have worked. :)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Civil engineering feature implementation (Transportation Engineering)

Post by microelly2 »

Joel_graff wrote: Thu Dec 05, 2019 12:53 pm @microelly2 - in case you're wondering, I did play with the alphashapes library you pointed out. The chief issue I had with it was it's own dependencies and the considerable time it took to import. That said, it did appears an alphashape object retains a list of the boundary points, so I think it would have worked. :)
Finding the best way is always time consuming, so I can learn what others do.
Post Reply