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
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 »

paullee wrote: Sat Jan 05, 2019 9:32 am I am thinking instead of, or in addition to, generating 3d Dwire, a pair of Sketches are generated - horizontal and vertical
Your staircase idea is a good one. I'd pursue that. I might first post about that over in the Arch forum and link back here... Yorik mayu have considered that and run into issues, or there may be a history to help you get started.
paullee wrote: Sat Jan 05, 2019 9:32 am Pros is this approach for simple curvilinear ramp may not require 3d profile - the arc is 2d, the start and end profile are set at their respective elevation / height and it is done
2D is a subset of the 3D. So it would make sense to always adopt a 3D workflow, even if the result is more or less 2D. Otherwise, you're maintaining two separate workflows.
paullee wrote: Sat Jan 05, 2019 9:32 am Cons is when it is a multi-edge 2d curve / line, the Sweep tool has made some 'transition' at each junctions that may not be as expected
This is the same issue I had previously in this thread. Microelly posted about it and demonstrated a technique to overcome that undulation issue. Basically, the sweep tools in Part / PartDesign are not up to the task, so I have to build my own. Doesn't look too difficult.

In the end, at least in the case of the ramps, you'll need to generate a spline (not a dwire) from the curves. That's the most manageable way to handle it. It may be what you need to do for the stair rails as well, but I could be wrong...

The only issue is that splines are tessellated - subdivided into segments (like arcs), and thus have a limited accuracy. I can control that by adjusting the tessellation percentage setting in Edit->Preferences->PartDesign. For smaller projects it should be fine. For larger projects (kilometers / miles in length) it's still not accurate enough.

That said, splines are the way to go. That's what I'm sorting out right now. Once I get 3D curve generation from 2D horizontal / vertical alignments worked out, I'll start on the sweep issue...
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
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by paullee »

Joel_graff wrote: Sat Jan 05, 2019 11:57 am This is the same issue I had previously in this thread. Microelly posted about it and demonstrated a technique to overcome that undulation issue. Basically, the sweep tools in Part / PartDesign are not up to the task, so I have to build my own. Doesn't look too difficult.
Yes, I notice some of your discussion about that. Hope what your research could solve that :)

For 'Vertical + Horizontal Sketches' idea, whilst conceiving, it needs to be as simple as possible, otherwise user can't understand if it becomes complicated

... just discuss in ArchStairs thread: Simple Pre-built Stairs Tool but without flexibility in variation VS Complex Pre-Built Models with Complicated Parameters to tweak VS ...


Anyway, I'll see your and Microelly's works when it is available :)

Thanks!
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 »

Just got 3D splines working. I can now generate a 3D highway alignment from two existing 2D alginments (horizontal and vertical).

Works pretty slick! Many thanks to @microelly2 for coding the algorithm a few months ago!

phpBB [video]
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
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by Kunda1 »

Coolness!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
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 »

So on my mental roadmap in the not-so-distant future is the idea of implementing 'point controls' for models. The idea is a bit hard to describe, but I'll try to lay it out here as clearly as I can.

3D modeling in transportation engineering consists almost entirely of sweeping templates along alignments. In FreeCAD parlance, that's sweeping (or lofting) sketches along wires or splines. There's really little more to it than that.

However, in real life, road widths can vary for a number of reasons - going into a narrow area with steep cliffs, or widening out from a two-lane to a three or four-lane roadway. That means that the template / sketch needs to be able to handle transitions like those, moving from the default width to a target width.

This is where "point controls" come in handy. Basically, I specify a point in a template / sketch and tell FC that, as the sweep progresses, the point shifts position a few feet / meters one way or the other. Maybe it's a linear transition, maybe it's curvilinear. The control determines how the point moves as the template is swept.

An example can be seen in the following image:

point_control.png
point_control.png (35.33 KiB) Viewed 2047 times

The purple represents edges of the roadway, and the yellow represents edges of the shoulders. Note the solid lines might indicate the original limits of the sweep / loft that the sketch template created. The dashed lines represent the transition and desired limits that the point control could provide.

I can figure all of that out. It's not hard.

What I need to sort out though, is how to create a reference system for points that never changes. That is, if I have a template of a pavement cross-section that looks like this:

template_snip.jpg
template_snip.jpg (26.66 KiB) Viewed 2047 times

The upper-right point would be the outer edge of the pavement. I want to name it "Right Edge Of Pavement" or something like that. Then, after the user goes in and modifies the template (maybe even adds points), I want to ensure that it retains that name.

I know that the coin geometry has no way to uniquely identify a point like that - the vertices get re-indexed at will and that's necessary. I think it could be done easily enough using a list property in a SketchObjectPython instance, but that means using the point location as a way to correlate the point name with the point itself, assuming no two points ever occupy the same space (there's no reason they ever should). If the point changes it's location, then that, obviously needs to get updated in the list of names.

So... I think I know how to manage that. The SketchObjectPython class can trap those changes and make that a feasible solution. But, that leaves a few issues. First, I'm forced to test for changes in the points and update the list every time a change occurs, which may impact performance significantly when the user edits the sketch template. Second, I don't know if it's possible for more than one change to occur before the SketchObjectPython gets notified - which could possibly break things. For example, suppose a new point gets added an existing point gets moved. I could potentially have a case where I now have two points which are not found in the list (one because it's never been added and the other because it has moved), with no way to reconcile that.

So to be clear, what I'm trying to determine is the following:

1. Is there any other feasible way to create permanent references (by a unique ID or otherwise) to a point in a sketch that will always remain, even if the sketch gains / loses points or that point moves?

2. Can I be sure that when the SketchObjectPython sees a change, that change will be atomic? That is, it won't possibly include multiple changes at once (e.g., a new point, plus an existing point moving).

3. Would it be possible to create an "empty" constraint that applies to a specific point? It's a constraint that does nothing but exist on a point (or edge).That would provide an excellent way to reference sketcher geometry externally by a unique, unchanging reference and save a lot of the hassle I've described above.

Pinging the two guys who I know will have an opinion. :)
abdullah wrote:Ping!
microelly2 wrote:Ping!
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 »

This is a method to define a fix point in the sketch with constraints x y AAA,BBB
Whenever a user deletes it it will be reconstructed:
This method can run inside the execute or noChanged method of the sketch
and use object parameters instead of the hard coded values

Code: Select all


sk=App.ActiveDocument.Sketch

founda=False
foundb=False
namea="AAA"
nameb="BBB"

cs=sk.Constraints

for cai,ca in enumerate(cs):
	print ca.Name
	if ca.Name==namea:
		founda=True
		pta=ca.First
		# sk.setDatum(cai,App.Units.Quantity('200.000000 mm'))
		sk.setDatum(cai,50)
	if ca.Name==nameb:
		foundb=True
		ptb=ca.First
		sk.setDatum(cai,30)

print (founda,foundb)
if not founda and not foundb:

	p=sk.addGeometry(Part.Point(App.Vector(10,20,0)))
	App.ActiveDocument.recompute()

	c=sk.addConstraint(Sketcher.Constraint('DistanceX',p,1,50)) 
	App.ActiveDocument.Sketch.renameConstraint(c, u'AAA')

	c2=sk.addConstraint(Sketcher.Constraint('DistanceY',p,1,30))
	App.ActiveDocument.Sketch.renameConstraint(c2, u'BBB')

elif founda and not foundb:
	c2=sk.addConstraint(Sketcher.Constraint('DistanceY',pta,1,30))
	App.ActiveDocument.Sketch.renameConstraint(c2, nameb)

	App.ActiveDocument.recompute()

elif foundb and not founda:
	c2=sk.addConstraint(Sketcher.Constraint('DistanceX',ptb,1,60))
	App.ActiveDocument.Sketch.renameConstraint(c2, namea)

	App.ActiveDocument.recompute()

paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by paullee »

Joel_graff wrote: Mon Jan 07, 2019 11:45 pm Just got 3D splines working. I can now generate a 3D highway alignment from two existing 2D alginments (horizontal and vertical).

Works pretty slick! Many thanks to @microelly2 for coding the algorithm a few months ago!
Seems you have a complicated solution to solve :)

Can you share how you get 3d splines with 2 2D alignments in the meantime?

Thanks
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 Jan 16, 2019 2:54 pm This is a method to define a fix point in the sketch with constraints x y AAA,BBB
Whenever a user deletes it it will be reconstructed:
Hmm.. Maybe not quite what I'm after. ;)

I don't exactly want the point itself to be permanent... I just want to make sure I can always find that point using a consistent, unique identifier, no matter what the user does with the sketch. That is, the index may change if the user adds / deletes other points. The location changes if the user moves it. But in the end, the point itself still exists. I just need a way to identify that point consistently from outside the sketch.

Look, for example, at the sketch template I showed previously. It might represent a single roadway lane of a two-lane road (a typical roadway lane is 12 feet in the US). The sketch origin is at the road's center and the point at the far right would represent the right edge of pavement. I would want to name it 'EOP_RT' so I could permanently refer to it outside the sketch, and so it has a name that's meaningful to the user.

But how do I ensure that the point that I've named is always going to be the same point?

That's why I had the idea that maybe an 'empty constraint' attached to the point might be a solution. It doesn't constrain anything, it just provides a consistent way to reference the actual point from outside the sketch, unless, of course, the point itself (or the constraint) is deleted.
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 »

paullee wrote: Wed Jan 16, 2019 4:54 pm
Joel_graff wrote: Mon Jan 07, 2019 11:45 pm Just got 3D splines working. I can now generate a 3D highway alignment from two existing 2D alginments (horizontal and vertical).

Works pretty slick! Many thanks to @microelly2 for coding the algorithm a few months ago!
Seems you have a complicated solution to solve :)

Can you share how you get 3d splines with 2 2D alignments in the meantime?

Thanks
https://github.com/joelgraff/freecad-tr ... ignment.py

The 'build_alignment' function is where the magic happens. It's not well commented, but I can explain things if there's something specific you need to understand.
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
paullee
Veteran
Posts: 5098
Joined: Wed May 04, 2016 3:58 pm

Re: Civil engineering feature implementation (Transportation Engineering)

Post by paullee »

Thanks for the link, i'll have a look.

On your problem, I used 'non-driving' constraints (on both X and Y) and name them.

Then you can 'trace' the position of that point. The only risk is user delete it.
Post Reply