I am looking for code or pseudo-code for the generation of genus $k$ tori triangle meshes. I want to get something like in the image here. Book/paper references, code, github links, etc. are all welcome.


1 Answer 1


I can't leave a comment, because I don't have enough reputation points.

Do you know how to represent your objects using an implicit function like f(x, y, z)? If so, then you can use Marching Cubes or Dual Contouring, or some similar algorithm to convert that field into a triangle mesh.

As you can see in the source, the tori are multiplied together, and a non-zero isovalue is used.

The final code is at: https://github.com/sjhalayka/k-genus_torus

genus 5 tori

  • 1
    $\begingroup$ I assume you meant implicit function, e.g. $f(x,y,z) = 0$, and not parametric function, e.g. $(x(u,v), y(u,v), z(u,v))$. But yes, I could theoretically use an implicit function where I smooth merge two tori sdfs. $\endgroup$
    – lightxbulb
    Nov 4, 2023 at 17:42
  • $\begingroup$ My bad, I appreciate the correction. I changed the answer. $\endgroup$ Nov 4, 2023 at 19:11
  • 1
    $\begingroup$ @lightxbulb I altered the answer. $\endgroup$ Nov 12, 2023 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.