Skip to content

Conversation

@webdevred
Copy link
Owner

This update improves the way jbeam_edit processes meta nodes (such as {"group":"..."}) that interrupt vertex groupings within .jbeam files. Previously, encountering these meta nodes resulted in an explicit error message indicating unsupported input, preventing further processing.

Key changes:

  • Extract all vertices from sections interrupted by meta nodes.
  • Sort vertices within their respective groups while preserving the original order relative to meta nodes.
  • Move and reinsert vertices back into their original nodes, maintaining file structure integrity.
  • Enhance logic to gracefully handle meta nodes interrupting vertex lists.

Example of the previous grouping logic being broken by meta nodes:

{"group": "group1"}
["fr0", -0.426, -2.084, 0.235]
["fr1", 0.487, -2.072, 0.235]
{"group": "group2"}
["fr2", -0.418, -2.034, 0.300]

With this update, jbeam_edit properly handles such cases by treating meta nodes as separators, allowing vertices to be grouped and sorted correctly within their respective groups.

@webdevred webdevred force-pushed the new_transformation branch from 5d40fac to 65c2838 Compare June 1, 2025 20:57
@webdevred webdevred force-pushed the new_transformation branch 4 times, most recently from 1c7da63 to 8c66882 Compare June 5, 2025 05:43
@webdevred webdevred marked this pull request as ready for review June 5, 2025 19:39
@webdevred webdevred force-pushed the new_transformation branch from 76c858c to 92f767b Compare June 6, 2025 10:33
@webdevred webdevred force-pushed the new_transformation branch 14 times, most recently from 25fbfea to f8fe8dd Compare June 23, 2025 21:43
@webdevred webdevred force-pushed the new_transformation branch from 57416e3 to fd3e7aa Compare July 7, 2025 09:26
@webdevred
Copy link
Owner Author

webdevred commented Jul 7, 2025

New transformation pipeline

VertexTree Transformation Roadmap

This roadmap outlines the transition from the existing VertexTree transformation logic to a more robust and flexible system. The goal is to support meta node handling, group-aware vertex positioning, and future extensibility.


Before

This update improves the way jbeam_edit processes meta nodes (such as {"group":"..."}) that interrupt vertex groupings within .jbeam files.
Previously, encountering these meta nodes resulted in an explicit error message indicating unsupported input, preventing further processing.
There was no support for grouping metadata and vertices together, no logic for relocating misplaced vertices, and renaming strategies were minimal and fragile.

After: New Transformation Logic

The transformation proceeds through several clearly defined stages:

1. Input & Parsing

  • Input: A VertexTree structure, derived from .nodes data.
  • Parsing steps:
    • getVertexTree: Flattens the top-level node structure into a list of VertexTreeEntry.
    • nodesListToTree: Rebuilds the hierarchical VertexTree from this flat list.
    • updateVertices: Entry point for renaming and movement.

2. Name & Group Preparation

  • vertexNames: Collects all unique vertex names.
  • Comment groups:
    • Vertices are grouped with surrounding comment/meta nodes into CommentGroups:
      data CommentGroup = CommentGroup
        { cComments :: [VertexTreeEntry]
        , cVertex :: Vertex
        }
    • Each group may have 0 or more comment/meta entries and exactly one vertex.
    • Comments and metadata are preserved and follow the vertex throughout the transformation.

3. Filtering & Movement

  • filterVerticesToMove: Identifies vertices needing relocation, based on their type or context.
  • Decision point:
    • If all vertices are in the correct location: skip movement, proceed to renaming.
    • If not, perform:
      • Type comparison between vertex and parent tree.
      • Relocation using type rules and spatial (X-axis) hints.
      • Tree restructuring where needed (new subtrees created).
      • Zipper-based tree traversal (to be implemented later).
      • All associated meta/comment nodes move along with the vertex.

4. Renaming & Updating

  • Vertices within groups are sorted consistently.
  • New names are assigned based on group and position.
  • A vertexNameMap is created: mapping old → new names.
  • Tree and .nodes entries are updated using this map:
    • Replaces names in VertexTree.
    • Updates references in metadata.
  • ungroupCommentGroups: Reassembles the final structure with comments preserved.

5. Final Output

  • A valid VertexTree with:
    • All misplaced vertices corrected.
    • Updated names.
    • Group/meta structure intact.
  • Order is preserved unless a new tree is explicitly created.
  • Users can expect:
    • Clean grouping.
    • Predictable naming.
    • Structural consistency.

After Merging

To be implemented in future PRs:

  • Indent JBFL property to specify number of spaces for indentation.
  • Detect support vertices (nodes with many beam connections) and group them automatically.
  • Allow prefix replacement via CLI (e.g., replace bf in node/beam names).

@webdevred webdevred force-pushed the master branch 2 times, most recently from 0e7fea4 to a65275a Compare July 8, 2025 14:33
@webdevred webdevred force-pushed the new_transformation branch 2 times, most recently from 5d4121d to 39303ef Compare July 17, 2025 10:49
@webdevred webdevred force-pushed the new_transformation branch from 39303ef to 0beadd1 Compare July 30, 2025 13:38
- Strongly type VertexTreeEntry:
  - CommentEntry now holds InternalComment instead of Node
  - MetaEntry now holds Object instead of Node
  - Added OtherNodeEntry for miscellaneous nodes
- Replace VertexTree chaining (tRest) with VertexForest map keyed by VertexTreeType
- Introduce MetaMap and carry meta information alongside vertices
- Remove VertexZipper and related navigation helpers
- Simplify vertex grouping logic and add support for SupportTree merging
- Improve vertex name handling and support vertex detection
- Rework update/sort pipeline to operate on VertexForest
- Update transform to work with new forest-based representation
- Added `createVertexForFirstNode` to safely extract and convert the first node into a vertex.
- Introduced `toVertexTreeEntry` to convert nodes (vertices, metadata, comments) into `VertexTreeEntry`.
- Updated `newVertexTree` to use these helpers, improving safety and readability.
@webdevred webdevred force-pushed the new_transformation branch 2 times, most recently from 2774d62 to 27b95d1 Compare August 27, 2025 21:27
@webdevred webdevred merged commit 55c6db1 into master Aug 28, 2025
11 checks passed
@webdevred webdevred deleted the new_transformation branch August 28, 2025 17:31
This was referenced Oct 2, 2025
webdevred added a commit that referenced this pull request Oct 5, 2025
Updated examle files to showcase how the recent changes to Transformation code affect jbeam. The major changes to transformation code are in #69

The changes to transformation which are related to this new example files are the following:

- Transformation reimplemenation: before errors were handled less safely and meta groups interrupting vertex groups was not supported #2
- Transformation refactoring: split Transformation into different files and added improved how comments and metadata is handled when moving vertices #41
- Support vertex detection: implemented detection of support vertices and automatically moving them to their own tree  #52
- Associate comments without newline before with prior node #56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants