Ruled surface between two spline curves with different control point spacing

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
snow54
Posts: 17
Joined: Sat Apr 24, 2021 8:42 am
Location: Japan

Ruled surface between two spline curves with different control point spacing

Post by snow54 »

How can I create a smooth ruled surface between two spline curves with different control point spacing? When spline curves have varying control point densities along each curve and are used to create a ruled surface, FreeCAD tends to connect parts of the curves that have denser control points. It sometimes creates a skewed surface. I want FreeCAD to connect parts of the curves at the same x coordinate or with minimal distance.

The following is a minimal reproducible example. FCStd file is also attached.
  1. Create a spline curve by sketcher with denser control points on one side.
    Screenshot from 2022-08-16 11-35-41.png
    Screenshot from 2022-08-16 11-35-41.png (53.5 KiB) Viewed 1558 times
  2. Create a spline curve by sketcher with denser control points on the other side. Place this sketch at z=30.
    Screenshot from 2022-08-16 11-36-44.png
    Screenshot from 2022-08-16 11-36-44.png (60.7 KiB) Viewed 1558 times
  3. Create a ruled surface between the two curves. When viewed from the front, it shows strange wrinkles.
    Screenshot from 2022-08-16 11-37-59.png
    Screenshot from 2022-08-16 11-37-59.png (44.88 KiB) Viewed 1558 times
  4. The cause of the wrinkles is visible on hidden line mode. It shows that the parts of the curve with denser control points are connected.
    Screenshot from 2022-08-16 11-38-16.png
    Screenshot from 2022-08-16 11-38-16.png (35.59 KiB) Viewed 1558 times
A workaround that I found is to cut the curves into segments before creating the ruled surface. I have been looking for a better way for the past couple of weeks with no luck. I tried Gordon surface as well but it resulted in a similar result. I appreciate your help.

Code: Select all

OS: Ubuntu 18.04.6 LTS (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.29177 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 0.20)
Hash: 68e337670e227889217652ddac593c93b5e8dc94
Python 3.9.13, Qt 5.12.9, Coin 4.0.0, Vtk 9.1.0, OCC 7.5.3
Locale: English/United States (en_US)
Installed mods: 
  * Curves 0.5.5
Attachments
rulesurf_spline.FCStd
(7.9 KiB) Downloaded 33 times
edwilliams16
Veteran
Posts: 3111
Joined: Thu Sep 24, 2020 10:31 pm
Location: Hawaii
Contact:

Re: Ruled surface between two spline curves with different control point spacing

Post by edwilliams16 »

You can re-parameterize the edges using the curves workbench and see if another algorithm is more to your liking.
Screen Shot 2022-08-15 at 5.49.52 PM.png
Screen Shot 2022-08-15 at 5.49.52 PM.png (26.88 KiB) Viewed 1544 times
Screen Shot 2022-08-15 at 5.52.52 PM.png
Screen Shot 2022-08-15 at 5.52.52 PM.png (34.17 KiB) Viewed 1544 times
Attachments
rulesurf_splineEW.FCStd
(41.68 KiB) Downloaded 26 times
snow54
Posts: 17
Joined: Sat Apr 24, 2021 8:42 am
Location: Japan

Re: Ruled surface between two spline curves with different control point spacing

Post by snow54 »

Thank you for your quick reply. The method you suggested worked nicely to create a surface but alters the original curves. I need to use the original curves because those are the edges of another surface that I use to create a solid. Altering the original curves voids watertightness of the geometry that causes issues in creating a solid. I tried to connect the surfaces using facebinder to solve it but it didn't work.

Is there a way to do something similar without altering the original curves?
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Ruled surface between two spline curves with different control point spacing

Post by Chris_G »

snow54 wrote: Tue Aug 16, 2022 7:01 am Is there a way to do something similar without altering the original curves?
I am afraid it is not possible.
You cannot change the internal parametrization of a curve, without changing its shape
Therefore, here are some possible solutions :
- approximate the existing curves, as proposed by edwilliams above, but the tolerance required to get water-tightness is very low (around 1e-7), so this may be very hard to achieve.
- approximate the existing curves first, and use them to build the other surfaces.
- add more control points inside the sketcher, to have same number of poles for each curve, and make the control points roughly equally spaced.

We would need more information about what you want to achieve, and what is the input data, to give better advice.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Ruled surface between two spline curves with different control point spacing

Post by onekk »

snow54 wrote: Tue Aug 16, 2022 7:01 am ...
Altering the original curves voids watertightness of the geometry that causes issues in creating a solid.
...
Is there a way to do something similar without altering the original curves?
As @Chris_G has told you, it is difficult to maintain the original curves, as BSpline is a mathematically defined, and obvious changing the definition will change the polynomials.

See maybe:

https://en.wikipedia.org/wiki/B-spline

https://www.cs.utexas.edu/~bajaj/cvc/so ... HM/RBO.pdf

It could be done, but the point is the "approximation" that has to be under the FC tolerance stated by @Chris_G, probably the technique described in the second link could be used, but it is beyond my math skills.

I think that if approximation could be acceptable, yuu could redefine all BSpline deriving say for each BSpline a decent number of control points (20 ... 100) and then operate on the derived BSplines, to build ALL your solid.

Hope it helps.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
snow54
Posts: 17
Joined: Sat Apr 24, 2021 8:42 am
Location: Japan

Re: Ruled surface between two spline curves with different control point spacing

Post by snow54 »

Thank you, Chris_G and Carlo for the additional advice. I understand it is not possible to change the internal parameterization of the curve itself without changing its shape. However, I don't understand why a ruled surface has to follow that. There could be many algorithms to connect two curves. For example, you could pick points on curves with the same x coordinate or you could look for points on curves that have minimum distance.

The workaround of cutting the curves into segments that I mentioned in the original post seems to be the best solution to me although it adds some seemingly unnecessary artifacts. I found "Splitcurve" in Curves wb which makes such operation fairly easy. Thank you for creating the great addon.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Ruled surface between two spline curves with different control point spacing

Post by onekk »

snow54 wrote: Tue Aug 16, 2022 12:27 pm However, I don't understand why a ruled surface has to follow that.
Ruled surfaces tend to join points with lines, it has to take some assumptions when choding point to join so there is some math behind, and probably some tangent considerations.

Probably what is seems normal at a first glance when transposed to "numbers" has some not so plain interpretation, if you see the "comb diagram" of bsplines you will see that there are changes that are not very smooth as you have an abrupt change where there is the flex point with a very big "comb" and probably is where the ruled surface has the "groove".

Behind every shapes there are precise mathematical or geometric concepts as CAD is not about artistic representation but about geometric representation.

Underlying "modelling engine" could be different but the whole CAD concept is different from "artistic 3d graphics" based on different concepts like meshes and similar things, a mesh is composed by linear segments joining vertexes and line equations are less complicated than curves equations.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Chris_G
Veteran
Posts: 2579
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Ruled surface between two spline curves with different control point spacing

Post by Chris_G »

snow54 wrote: Tue Aug 16, 2022 12:27 pm However, I don't understand why a ruled surface has to follow that.
A BSpline curve has 2 components :
- an algebraic part, defined by the degree and the knot sequence, that define the "attracting power" of each control point.
- a geometric part : the control points.

To build a ruled surface from 2 BSpline curves, you have to find a common algebraic part from them.
The only way to do this (from what I know) is by degree elevation and knot insertion.
This will compute new sets of control points without changing the shape of the curves.
This will guarantee that the ruled surface matches exactly the input curves.
But this will not change the parametrization of the input curves.
snow54 wrote: Tue Aug 16, 2022 12:27 pm There could be many algorithms to connect two curves. For example, you could pick points on curves with the same x coordinate or you could look for points on curves that have minimum distance.
Yes, but we're back to the approximation of at least one of the curves.
User avatar
Vincent B
Veteran
Posts: 4713
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Ruled surface between two spline curves with different control point spacing

Post by Vincent B »

Rebuilding the surface with GordonSurface give something lightly smoothy or different.
Attachments
rulesurf_spline_VB.FCStd
(27.22 KiB) Downloaded 19 times
Capture.JPG
Capture.JPG (89.04 KiB) Viewed 1237 times
snow54
Posts: 17
Joined: Sat Apr 24, 2021 8:42 am
Location: Japan

Re: Ruled surface between two spline curves with different control point spacing

Post by snow54 »

Thank you all for your additional replies.
Chris_G wrote: Tue Aug 16, 2022 3:42 pm The only way to do this (from what I know) is by degree elevation and knot insertion.
This will compute new sets of control points without changing the shape of the curves.
This will guarantee that the ruled surface matches exactly the input curves.
But this will not change the parametrization of the input curves.
I see. If you pick "t" in the link below for each curve, you can uniquely identify a point on a curve. If you pick "t" for each curve, you can define a line that connects two curves. If you do that throughout both curves, you can construct a surface. How to pick "t" for each curve can be arbitrary and different between curves, and you have many different options for the surface. That's what I thought but it seems to be somehow wrong.
https://en.wikipedia.org/wiki/B-spline# ... r_graphics

With the difficulty mentioned here, I'm satisfied with the workaround. An example is shown below and attached. If you split each curve into 3 segments, for example, you can have surfaces that connect points on two curves that are not too far. You can adjust how to split into segments depending on how you want FreeCAD to connect two curves and on how much complexity you are willing to deal with.
Screenshot from 2022-08-17 22-31-00.png
Screenshot from 2022-08-17 22-31-00.png (32.04 KiB) Viewed 1160 times
Screenshot from 2022-08-17 22-31-15.png
Screenshot from 2022-08-17 22-31-15.png (52.18 KiB) Viewed 1160 times
Attachments
rulesurf_spline_split.FCStd
(14.09 KiB) Downloaded 22 times
Post Reply