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

Reduce redundancy in object graph through inference and caching #1586

Closed
hannobraun opened this issue Feb 14, 2023 · 0 comments · Fixed by #1647
Closed

Reduce redundancy in object graph through inference and caching #1586

hannobraun opened this issue Feb 14, 2023 · 0 comments · Fixed by #1647
Assignees
Labels
topic: core Issues relating to core geometry, operations, algorithms type: development Work to ease development or maintenance, without direct effect on features or bugs

Comments

@hannobraun
Copy link
Owner

hannobraun commented Feb 14, 2023

(This issue is part of a larger cleanup effort. See #1589.)

Problem

Shapes in Fornjot are made of objects: Vertices, edges, faces, etc. Those objects reference each other and form a graph.

Right now, this object graph is highly redundant. For example, the vertices that bound an edge are defined in 1-dimensional curve coordinates, 2-dimensional surface coordinates, and 3-dimensional global coordinates. This is done to ensure that each of those values is only calculated once and then re-used whenever it is needed anywhere. Otherwise, we'd risk having slightly different numbers that should be the same, which would lead to various problems.

This redundant data in the object graph makes working with it very challenging. When building shapes, you have different information available at various points in time. There are mechanisms to infer missing information later, but they are ad-hoc. Overall, it's very easy to build shapes with missing or conflicting information. There are various protections in place to prevent this from resulting in an invalid shape, but that doesn't help with the difficulty of building a valid shape.

I used to think that this redundancy in the object graph was necessary, and just an expression of the inherent complexity of the problem. I no longer believe this. I'm convinced that the complexity in the object graph can be limited by reducing or completely removing this redundancy.

Proposed Solution

Here's what I have in mind:

  • Remove all redundant information from the object graph.
  • Leave only the forms with the least redundancy, for example the 1-dimensional curve coordinates of a vertex. (Leaving a 3-dimensional coordinate instead would be more redundant, as a 3-dimensional position encodes more information that could be inferred from and, most critically, could disagree with the definition of the curve.)
  • Have a supplementary structure that infers other information (for example 2D and 3D vertex positions) from the object graph.
  • Use caching (based on object identities) to make sure that queries for information about identical objects always results in the same values.

Context and Outlook

This is one of multiple measures targeted at simplifying the kernel's core data structures, and as a result make it easier and less error-prone to work with. I have already opened some issues in that vein, and am working on creating more. I also plan to open a meta-issue, that will point to all issues that are related to this work.

Experience has shown that the complexity of the core data structures, the very thing these efforts are meant to address, often makes the implementation of these efforts quite hard, usually in unexpected ways. For that reason, there's no obvious order in which to do things. It might make sense to start working on one issue, then pause it when things get dicey, and attack the problem from another direction before resuming.

For that reason, I'm assigning myself to this issue and will work on it where it makes sense. But it's unlikely that I can work on this in a single block of time.

@hannobraun hannobraun added type: development Work to ease development or maintenance, without direct effect on features or bugs topic: core Issues relating to core geometry, operations, algorithms labels Feb 14, 2023
@hannobraun hannobraun self-assigned this Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: core Issues relating to core geometry, operations, algorithms type: development Work to ease development or maintenance, without direct effect on features or bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant