How thomthom/true-bend works
Main Components
• Extension Initialization & Bootstrap: The entry points are the main script (src/tt_truebend/main.rb) and bootstrap files (src/tt_truebend/bootstrap.rb). These modules initialize the extension when loaded within SketchUp.
• Command & VCB Input Handling: The modules that parse input and manage commands (e.g., src/tt_truebend/command.rb and src/tt_truebend/vcb_parser.rb) handle user commands including VCB input for angles, segment counts, and distance values.
• Geometry Manipulation: The “bender” (src/tt_truebend/bender.rb) and various geometry modules (e.g., src/tt_truebend/geom, which contains polar_projection, polygon, and segment) are core to the bending logic. They perform calculations to adjust the geometry without altering the original length.
• Graphics & Rendering: The modules under src/tt_truebend/gl (like bender_drawer.rb, grid.rb, slicer.rb, etc.) are responsible for drawing the updated geometry and displaying it to the user.
• Configuration & Settings: Files such as app_settings.rb and settings.rb provide the ability to read and manage the extension’s configuration, including user preferences and internal constants found in the constants directory.
• Helpers, Observers, and Tools: Supporting functionalities are provided by helper modules (e.g., src/tt_truebend/helpers/), observers for transaction handling (src/tt_truebend/observers/transaction.rb) and tools (src/tt_truebend/tools/truebend.rb). These help keep the code modular and maintain separation of concerns.
Relationships & Interactions
• The Extension Initialization component triggers the setup process (bootstrap), which then loads configuration settings and registers commands.
• When a SketchUp user interacts with the extension (for example with a VCB input), the command handler and VCB parser interpret the input. They pass the instructions to the bender module, which updates the underlying geometry.
• Observer modules monitor transactions and assist with undo/redo capabilities, ensuring consistent application state.
Architectural Patterns & Design Principles
• Modularity: The clear separation into directories (commands, constants, geom, gl, helpers, etc.) shows a modular design. Each module focuses on a specific concern such as input management, computation, or rendering.
• Command Pattern: The handling of VCB inputs and extension commands suggests a command pattern for decoupling the input handling from execution.
• MVC-like Separation: Though not a strict implementation, components like the model (geometry and bender), view (gl/drawing modules), and controller (command handling and bootstrap) illustrate separation of responsibilities.
• Extensibility: With a “vendor” folder and an extension.json file, the design is ready for further integration or customization if external libraries or additional settings are needed.