Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Gordon Surfaces #831

Open
gumyr opened this issue Dec 20, 2024 Discussed in #830 · 1 comment
Open

Creating Gordon Surfaces #831

gumyr opened this issue Dec 20, 2024 Discussed in #830 · 1 comment
Labels
enhancement New feature or request

Comments

@gumyr
Copy link
Owner

gumyr commented Dec 20, 2024

Discussed in #830

Originally posted by jsbroks December 19, 2024
I'm wondering what is the best way to create a Gordon Surface?

Here is what I have so far but as you would expect I getting Error building a non-planer face with the provided exterior.

import csv
import numpy as np
from build123d import *


def read_heightmap(filename: str):
    with open(filename, 'r') as f:
        reader = csv.reader(f)
        heightmap = []
        for row in reader:
            heightmap.append([float(val) for val in row])
    return np.array(heightmap)


heightmap = read_heightmap('heightmap.csv')

points = []
for x in range(heightmap.shape[0]):
    for y in range(heightmap.shape[1]):
        points.append(Vector(x, y, heightmap[x,y]))


x_splines = []
y_splines = []


for x in range(heightmap.shape[0]):
    points = [(x, y, heightmap[x,y]) for y in range(heightmap.shape[1])]
    x_splines.append(Spline(points))


for y in range(heightmap.shape[1]):
    points = [(x, y, heightmap[x,y]) for x in range(heightmap.shape[0])]
    y_splines.append(Spline(points))

boundary_wire = Wire.make_wire([x_splines[0], y_splines[0], x_splines[-1], y_splines[-1]])

show_object(Face.make_surface(boundary_wire))
```</div>
@gumyr gumyr added the enhancement New feature or request label Dec 20, 2024
@gumyr gumyr added this to the Not Gating Release 1.0.0 milestone Dec 20, 2024
@gumyr
Copy link
Owner Author

gumyr commented Dec 20, 2024

From @mnesarco

TiGL[1] has an OpenCascade based Gordon surface builder that is very good (c++). Christophe Grellier (@tomate44) ported it to FreeCAD's Curves WB[2] long time ago in Python. It can be used as a reference to port it to build123d. I am in the process of reorganizing the implementation as a standalone python module, but it is WIP and i can't make compromises on that [3]

[1] https://dlr-sc.github.io/tigl/
[2] https://github.com/tomate44/CurvesWB/blob/master/freecad/Curves/gordon.py
[3] https://github.com/mnesarco/MarzWorkbench/blob/master/freecad/marz/curves/gordon.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant