Skip to content
GitHub Action edited this page Aug 29, 2024 · 2 revisions

Class Node

The Node class represents a geometric or structural node within a system, defined by a point in space, along with optional attributes like a direction vector, identifying number, and other characteristics.

Constructor

__init__(self, point=None, vector=None, number=None, distance=0.0, diameter=None, comments=None)

"Initializes a new Node instance.

    - `id` (str): A unique identifier for the node.
    - `type` (str): The class name, "Node".
    - `point` (Point, optional): The location of the node in 3D space.
    - `vector` (Vector, optional): A vector indicating the orientation or direction associated with the node.
    - `number` (any, optional): An identifying number or label for the node.
    - `distance` (float): A scalar attribute, potentially representing distance from a reference point or another node.
    - `diameter` (any, optional): A diameter associated with the node, useful in structural applications.
    - `comments` (str, optional): Additional comments or notes about the node.

Methods

  • __str__(self) -> str: Generates a string representation of the Node.

  • deserialize(data: dict) -> Node: Recreates a Node object from a dictionary of serialized data.

  • merge(self): Merges this node with others in a project according to defined rules.

      The actual implementation of this method should consider merging nodes based on proximity or other criteria within the project context.
    
  • serialize(self) -> dict: Serializes the node's attributes into a dictionary.

      This method allows for the node's properties to be easily stored or transmitted in a dictionary format.
    
  • snap(self): Adjusts the node's position based on snapping criteria.

      This could involve aligning the node to a grid, other nodes, or specific geometric entities.
    

Documentation

__str__(self) -> str

Generates a string representation of the Node.

Returns:

str: A string that represents the Node, including its type and potentially other identifying information.


deserialize(data: dict) -> Node

Recreates a Node object from a dictionary of serialized data.

Parameters:

  • data (dict): The dictionary containing the node's serialized data.

Returns:

Node: A new Node object initialized with the data from the dictionary.


merge(self)

Merges this node with others in a project according to defined rules.

The actual implementation of this method should consider merging nodes based on proximity or other criteria within the project context.


serialize(self) -> dict

Serializes the node's attributes into a dictionary.

This method allows for the node's properties to be easily stored or transmitted in a dictionary format.

Returns:

dict: A dictionary containing the serialized attributes of the node.


snap(self)

Adjusts the node's position based on snapping criteria.

This could involve aligning the node to a grid, other nodes, or specific geometric entities.


Clone this wiki locally