An example of Gordon Surface based upon OCC

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: An example of Gordon Surface based upon OCC

Post by microelly2 »

Chris_G wrote: Mon Jul 09, 2018 8:25 pm
hammax wrote: Mon Jul 09, 2018 4:55 pm you are actually working on the GordonSurface-feature (I'm following your CurvesWB-experiments in GitHub)
and I'm curious seeing first results.
Used your example for a loft-experiment => Gordon will surely be better.
Hi,
I got it working on basic test-files tonight.
But there are a couple of things to fix still (like closed profiles, like in your picture).
And most important, I would like to check if output surfaces are "watertight-matching" the boundary edges.
gordon-1.jpg
nice to see the progress,
would be nice to see your workflow and testfiles to apply on other situations.
User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: An example of Gordon Surface based upon OCC

Post by hammax »

… hey it works for some of the tigl-Testfiles.
It seems that only the open shells get a Gordon-Surface.???
How to produce own models?
FC.18.14061   Win10_32
FC.18.14061 Win10_32
Gordon_3.PNG (53.91 KiB) Viewed 1889 times
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: An example of Gordon Surface based upon OCC

Post by Chris_G »

hammax wrote: Wed Jul 11, 2018 9:30 am … hey it works for some of the tigl-Testfiles.
It seems that only the open shells get a Gordon-Surface.???
You're right, there are still several bugs, including one with closed curves.
The bad news is that tracking the state of data through the ~1000 lines of code is a real pain.
hammax wrote: Wed Jul 11, 2018 9:30 am How to produce own models?
You need to create a network of intersecting edges ( wires not supported ).
If all the edges are into a single shape, the Gordon_Surface tool will "try" to sort profiles and guides.
Or you can use the tool with 2 objects selected ( one containing guides and the other containing profiles ).
But be aware that the tool will fail most of the time !
freecad-heini-1
Veteran
Posts: 7788
Joined: Tue Jan 07, 2014 11:10 am
Contact:

Re: An example of Gordon Surface based upon OCC

Post by freecad-heini-1 »

hammax wrote: Mon Jul 09, 2018 4:55 pm Hi Chris,
you are actually working on the GordonSurface-feature (I'm following your CurvesWB-experiments in GitHub)
and I'm curious seeing first results.
Used your example for a loft-experiment => Gordon will surely be better.
Please could you post the linkadress to Chris github. Thank you so much.
User avatar
easyw-fc
Veteran
Posts: 3629
Joined: Thu Jul 09, 2015 9:34 am

Re: An example of Gordon Surface based upon OCC

Post by easyw-fc »

User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: An example of Gordon Surface based upon OCC

Post by hammax »

… trying to perform a similar approach:
You need to create a network of intersecting edges ( wires not supported ).
Using at first sketcher and/or Draft-BSplines , how do I convert them in a "gordon-compatible" edge format???

Gordon_4.PNG
Gordon_4.PNG (40.44 KiB) Viewed 1816 times

I e.g would have "no problems" selecting guides and profiles by hand. You say Gordon selects them automatically.
Would be there a potential to reduce the 1000 codeline-monster and make it lean.
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: An example of Gordon Surface based upon OCC

Post by Chris_G »

hammax wrote: Thu Jul 12, 2018 7:20 am Using at first sketcher and/or Draft-BSplines , how do I convert them in a "gordon-compatible" edge format???
No conversion needed.
- Make a Part.Compound out of the selected profile edges.
- Make a Part.Compound out of the selected guide edges.
- Call the Gordon surface tool on these 2 compounds (and cross fingers :lol: )
hammax wrote: Thu Jul 12, 2018 7:20 am I e.g would have "no problems" selecting guides and profiles by hand. You say Gordon selects them automatically.
The best is to make 2 separate objects (guides and profiles) like said above.
If the tool is activated with a single object selected, it will try to sort and find guides and profiles by itself.
I added this to make quick tests on Iso-Curve objects (at the right of the green cube in the CurvesWB toolbar).
hammax wrote: Thu Jul 12, 2018 7:20 am Would be there a potential to reduce the 1000 codeline-monster and make it lean.
Up to now, I just did a stupid low-level c++ to python conversion.
I am now trying to get a better overall understanding of the whole process.

The idea of the algorithm is pretty simple.
It works on 3 intermediate surfaces :
- a surface S1 that interpolates the guides
- a surface S2 that interpolates the profiles
- a surface S3 that interpolates the intersection points of the network
The Gordon surface is : S1 + S2 - S3 ( it means that this operation is done on each corresponding control point of these surface ).
This is the easy part.
The real pain is that these surfaces must be made "compatible" before : they must have the same BSpline properties (knots, degrees, multiplicities).
This is this preliminary work that is pretty complicated to follow.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: An example of Gordon Surface based upon OCC

Post by microelly2 »

Chris_G wrote: Thu Jul 12, 2018 10:17 am The idea of the algorithm is pretty simple.
It works on 3 intermediate surfaces :
- a surface S1 that interpolates the guides
- a surface S2 that interpolates the profiles
- a surface S3 that interpolates the intersection points of the network
The Gordon surface is : S1 + S2 - S3 ( it means that this operation is done on each corresponding control point of these surface ).
This is the easy part.
The real pain is that these surfaces must be made "compatible" before : they must have the same BSpline properties (knots, degrees, multiplicities).
This is this preliminary work that is pretty complicated to follow.
Here is my version for a 3 guides + 3 profiles test (use the 3 curves of BeGrid)
I still have not implemented the antisymmetry part S3,
but the metfods compute good models near the origin BePlan Nurbs.
I only use degree 3 Bsplines
I use Lagrange polynomes as blender

https://www.dropbox.com/s/j1f7ojx0q6q2k ... fcstd?dl=0

EDIT: I have added the S3 component. So I get a really good approximation .

Code: Select all


def createGordon():

	es=App.ActiveDocument.BeGrid.Shape.Edges

	poles=[]
	for e in es:
		poles += [e.Curve.getPoles()]

	polsu=np.array(poles[0:3])
	polsv=np.array(poles[3:6])

	# lagrange polynoms as blender
	blender=[
		lambda t: (t-1)*(t-2),
		lambda t: (t-0)*(t-2),
		lambda t: (t-0)*(t-1),
	]

	s3tt=np.zeros(7*7*3).reshape(7,7,3)

	dd=0.4
	for ui,u in enumerate([0,dd,1-dd,1,1+dd,2-dd,2]):
		for vi,v in enumerate([0,dd,1-dd,1,1+dd,2-dd,2]):
#			print (ui,vi,".................")
			for i in range(3):
				for j in range(3):
					# print polsu[i][3*j],polsv[j][3*i]
					s3tt[ui,vi] += polsu[i][3*j]*blender[i](u)/blender[i](i)*blender[j](v)/blender[j](j)

	ag=Part.BSplineSurface()
	ag.buildFromPolesMultsKnots(s3tt, 
			[4,3,4],[4,3,4],
			[0,1,2],[0,1,2],
			False,False,3,3)

	name="gordonS3"
	tt=App.ActiveDocument.getObject(name)
	if tt==None:
		tt=App.ActiveDocument.addObject('Part::Spline',name)
	tt.Shape=ag.toShape()


	ptsarr=[]

	for u in [0,dd,1-dd,1,1+dd,2-dd,2]:
		pts=np.zeros(7*3).reshape(1,7,3)
		for i in range(3):
			pts += [polsu[i]*blender[i](u)/blender[i](i)]
		ptsa=[FreeCAD.Vector(p) for p in pts[0]]
		ptsarr += [ptsa]

	ag=Part.BSplineSurface()
	ag.buildFromPolesMultsKnots(ptsarr, 
			[4,3,4],[4,3,4],
			[0,1,2],[0,1,2],
			False,False,3,3)

	name="gordonU"
	tt=App.ActiveDocument.getObject(name)
	if tt==None:
		tt=App.ActiveDocument.addObject('Part::Spline',name)
	tt.Shape=ag.toShape()

	ptsarr2=[]

	for u in [0,dd,1-dd,1,1+dd,2-dd,2]:
		pts=np.zeros(7*3).reshape(1,7,3)
		for i in range(3):
			pts += [polsv[i]*blender[i](u)/blender[i](i)]
		ptsa=[FreeCAD.Vector(p) for p in pts[0]]
		ptsarr2 += [ptsa]

	ag=Part.BSplineSurface()
	ag.buildFromPolesMultsKnots(ptsarr2, 
			[4,3,4],[4,3,4],
			[0,1,2],[0,1,2],
			False,False,3,3)

	name="gordonV"
	tt=App.ActiveDocument.getObject(name)
	if tt==None:
		tt=App.ActiveDocument.addObject('Part::Spline',name)
	tt.Shape=ag.toShape()


	ptsarr3=(np.array(ptsarr) +np.array(ptsarr2).swapaxes(0,1)-s3tt)

	ag=Part.BSplineSurface()
	ag.buildFromPolesMultsKnots(ptsarr3, 
			[4,3,4],[4,3,4],
			[0,1,2],[0,1,2],
			False,False,3,3)

	name="gordon"
	tt=App.ActiveDocument.getObject(name)
	if tt==None:
		tt=App.ActiveDocument.addObject('Part::Spline',name)
	tt.Shape=ag.toShape()


User avatar
hammax
Veteran
Posts: 1985
Joined: Thu Jan 19, 2017 5:03 pm
Location: Ammersee DE

Re: An example of Gordon Surface based upon OCC

Post by hammax »

… seeking for informative links about Coons-Gordon-surface:
https://www.math.hmc.edu/~gu/math142/me ... Schem.html
There is more, but Elsevier has mostly its hands on.

For my own hobby I excavated an old boat-hull-file, which has only 3 guides and 3 profiles.
There could be made a profiles loft (blue) and a guides loft (yellow), which stand for S1 and S2.
But gordon does not take the hurdle. (even when fingers crossed).

Gordon_5.PNG
Gordon_5.PNG (49.03 KiB) Viewed 1755 times
Attachments
GordonHullTest.FCStd
FC.18.14061
(23.13 KiB) Downloaded 71 times
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: An example of Gordon Surface based upon OCC

Post by Chris_G »

Hey, I was looking for a boat, and I got a fish ! :lol:
fish.jpg
fish.jpg (20.79 KiB) Viewed 1746 times
Post Reply