Back

ExportDotVisitor

abstract
The `ExportDotVisitor` writes the hierarchical structure of a SOFA scene into DOT format, enabling visualization using Graphviz.
sheet
# ExportDotVisitor ## Overview The `ExportDotVisitor` is a visitor component in the SOFA framework designed to write out the graph structure of a simulation scene into DOT format. This allows for visualizing the hierarchical relationships between nodes and objects within the scene, which can be useful for debugging and understanding complex simulations. ## Dependencies and Connections The `ExportDotVisitor` operates on the scene graph hierarchy, specifically visiting each node and object to generate unique identifiers and determine their relationships. It does not have any specific dependencies but relies on the SOFA framework's scene graph structure.
componentDescription
{
  "attributes": {
    "labelNodeClass": "A boolean indicating whether to label nodes with their class names.",
    "labelNodeName": "A boolean indicating whether to label nodes with their names.",
    "labelObjectClass": "A boolean indicating whether to label objects with their class names.",
    "labelObjectName": "A boolean indicating whether to label objects with their names.",
    "showBehaviorModel": "A boolean indicating whether to include behavior models in the generated graph.",
    "showCollisionModel": "A boolean indicating whether to include collision models in the generated graph.",
    "showCollisionPipeline": "A boolean indicating whether to include collision pipelines in the generated graph.",
    "showConstraint": "A boolean indicating whether to include constraints in the generated graph.",
    "showContext": "A boolean indicating whether to include context information (e.g., scene settings) in the generated graph.",
    "showForceField": "A boolean indicating whether to include force fields in the generated graph.",
    "showInteractionForceField": "A boolean indicating whether to include interaction force fields in the generated graph.",
    "showMapping": "A boolean indicating whether to include mappings between objects in the generated graph.",
    "showMass": "A boolean indicating whether to include mass properties in the generated graph.",
    "showMechanicalMapping": "A boolean indicating whether to include mechanical mappings in the generated graph.",
    "showMechanicalState": "A boolean indicating whether to include mechanical states in the generated graph.",
    "showNode": "A boolean indicating whether to include nodes in the generated graph.",
    "showObject": "A boolean indicating whether to include base objects in the generated graph.",
    "showSolver": "A boolean indicating whether to include solvers in the generated graph.",
    "showTopology": "A boolean indicating whether to include topology information in the generated graph.",
    "showVisualModel": "A boolean indicating whether to include visual models in the generated graph."
  },
  "dependencies": [
    "sofa::simulation::Visitor",
    "std::ostream"
  ],
  "description": "The `ExportDotVisitor` class is designed to visualize the scene graph structure in SOFA (Simulation Open-Framework Architecture). It generates a representation of the scene\u0027s node and object hierarchy using the DOT language, which can then be rendered into a visual graph by tools like Graphviz. This component helps in understanding the relationships between nodes and objects within a SOFA simulation.",
  "methods": {
    "ExportDotVisitor(const sofa::core::ExecParams* params, std::ostream* out)": "The constructor initializes the `ExportDotVisitor` object with an execution parameter and output stream for DOT language.",
    "Result processNodeTopDown(Node* node)": "Method that processes each node top-down during scene traversal. It decides if and how nodes should be included in the generated graph based on their type, name, etc.",
    "bool display(Node* node, const char** color=nullptr)": "Checks if a node should be displayed and returns appropriate fill color (if any).",
    "bool display(core::objectmodel::BaseObject* obj, const char** color=nullptr)": "Checks if an object should be displayed and returns appropriate fill color (if any).",
    "processObject(Node* node, core::objectmodel::BaseObject* obj)": "Processes a given SOFA object to generate its representation in the DOT graph.",
    "std::string getName(core::objectmodel::Base* o, std::string prefix)": "Generates a unique name for a given SOFA base node or object with an optional prefix.",
    "std::string getName(core::objectmodel::BaseNode *node)": "Generates a unique name specifically for a given SOFA node.",
    "std::string getName(core::objectmodel::BaseObject* obj)": "Generates a unique name specifically for a given SOFA object.",
    "std::string getParentName(core::objectmodel::BaseObject* obj)": "Finds the parent name of a given SOFA object.",
    "void processNodeBottomUp(Node* node)": "Processes a given SOFA node bottom-up during scene traversal to ensure correct hierarchical representation.",
    "~ExportDotVisitor()": "Destructor."
  },
  "name": "ExportDotVisitor",
  "namespace": "sofa::simulation::graph",
  "usage": "This component is used when the user wants to visualize or debug the hierarchical structure of nodes and objects in a SOFA scene. It outputs the DOT representation, which can be rendered by Graphviz tools to generate an image showing the relationships between different components."
}
maths
The provided code represents the implementation of an `ExportDotVisitor` class in the SOFA simulation framework, which is used to visualize the graph structure of a scene. This visitor writes out the hierarchical and object relationships of nodes and objects within the scene into a DOT file format, compatible with Graphviz for visualization. ### Mathematical Description: - **Graph Representation:** The system models the scene as a directed graph where each node in the graph represents either a `Node` (a container that holds objects) or an `Object` (an entity in the simulation). Each node and object is given a unique identifier, facilitating their representation in the DOT format. - **Unique Identifier Generation:** For each object (`BaseObject`) or node (`BaseNode`), a unique name is generated using `getName()`. This function ensures that names are unique by appending an index if needed. The generation of these identifiers can be modeled as a mapping from objects/nodes to strings, where the uniqueness constraint is maintained. - **Edge Representation:** Edges in the graph represent relationships between nodes and objects (e.g., object belonging to a node, mapping relations). This relationship is established by the `processObject()` method, which iterates through each object in a node and checks if it should be displayed based on various criteria (`display()` function). ### Physical Description: - **Node Representation:** In physical terms, nodes can represent different parts of a simulation scene. For example, one node might contain objects representing the skin of an animated character, while another node contains objects representing its internal organs. - **Object Relationships:** Objects within the same node or across different nodes are interconnected through relationships such as interaction force fields and mappings (e.g., mechanical mappings). These relationships define how forces are propagated between different parts of the scene. - **Visualization Output:** The DOT file generated by this visitor provides a visual representation of the simulation's structure, which can be crucial for debugging complex simulations or understanding the architecture of a model. Each node and object is represented as a graph vertex with edges connecting them based on their relationships.
{
  "name": "ExportDotVisitor",
  "main": {
    "name": "ExportDotVisitor",
    "namespace": "sofa::simulation::graph",
    "module": "Sofa.framework.Simulation.Core",
    "include": "sofa/simulation/ExportDotVisitor.h",
    "doc": "Write the graph, starting from a root Node, into a std::ostream.\nThe format is the DOT language from Graphviz (https://graphviz.org/)",
    "inherits": [
      "Visitor"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "processObject",
        "return_type": "void",
        "params": [
          {
            "name": "node",
            "type": "Node *"
          },
          {
            "name": "obj",
            "type": "core::objectmodel::BaseObject *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "processNodeTopDown",
        "return_type": "Result",
        "params": [
          {
            "name": "node",
            "type": "Node *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "processNodeBottomUp",
        "return_type": "void",
        "params": [
          {
            "name": "node",
            "type": "Node *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "display",
        "return_type": "bool",
        "params": [
          {
            "name": "node",
            "type": "Node *"
          },
          {
            "name": "color",
            "type": "const char **"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "display",
        "return_type": "bool",
        "params": [
          {
            "name": "obj",
            "type": "core::objectmodel::BaseObject *"
          },
          {
            "name": "color",
            "type": "const char **"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getParentName",
        "return_type": "int",
        "params": [
          {
            "name": "obj",
            "type": "core::objectmodel::BaseObject *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getName",
        "return_type": "int",
        "params": [
          {
            "name": "o",
            "type": "core::objectmodel::Base *"
          },
          {
            "name": "prefix",
            "type": "int"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getName",
        "return_type": "int",
        "params": [
          {
            "name": "node",
            "type": "core::objectmodel::BaseNode *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      },
      {
        "name": "getName",
        "return_type": "int",
        "params": [
          {
            "name": "obj",
            "type": "core::objectmodel::BaseObject *"
          }
        ],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "protected"
      }
    ]
  },
  "desc": {
    "componentDescription": {
      "name": "ExportDotVisitor",
      "namespace": "sofa::simulation::graph",
      "description": "The `ExportDotVisitor` class is designed to visualize the scene graph structure in SOFA (Simulation Open-Framework Architecture). It generates a representation of the scene's node and object hierarchy using the DOT language, which can then be rendered into a visual graph by tools like Graphviz. This component helps in understanding the relationships between nodes and objects within a SOFA simulation.",
      "attributes": {
        "showNode": "A boolean indicating whether to include nodes in the generated graph.",
        "showObject": "A boolean indicating whether to include base objects in the generated graph.",
        "showBehaviorModel": "A boolean indicating whether to include behavior models in the generated graph.",
        "showCollisionModel": "A boolean indicating whether to include collision models in the generated graph.",
        "showVisualModel": "A boolean indicating whether to include visual models in the generated graph.",
        "showMapping": "A boolean indicating whether to include mappings between objects in the generated graph.",
        "showContext": "A boolean indicating whether to include context information (e.g., scene settings) in the generated graph.",
        "showCollisionPipeline": "A boolean indicating whether to include collision pipelines in the generated graph.",
        "showSolver": "A boolean indicating whether to include solvers in the generated graph.",
        "showMechanicalState": "A boolean indicating whether to include mechanical states in the generated graph.",
        "showForceField": "A boolean indicating whether to include force fields in the generated graph.",
        "showInteractionForceField": "A boolean indicating whether to include interaction force fields in the generated graph.",
        "showConstraint": "A boolean indicating whether to include constraints in the generated graph.",
        "showMass": "A boolean indicating whether to include mass properties in the generated graph.",
        "showTopology": "A boolean indicating whether to include topology information in the generated graph.",
        "showMechanicalMapping": "A boolean indicating whether to include mechanical mappings in the generated graph.",
        "labelNodeName": "A boolean indicating whether to label nodes with their names.",
        "labelNodeClass": "A boolean indicating whether to label nodes with their class names.",
        "labelObjectName": "A boolean indicating whether to label objects with their names.",
        "labelObjectClass": "A boolean indicating whether to label objects with their class names."
      },
      "methods": {
        "ExportDotVisitor(const sofa::core::ExecParams* params, std::ostream* out)": "The constructor initializes the `ExportDotVisitor` object with an execution parameter and output stream for DOT language.",
        "~ExportDotVisitor()": "Destructor.",
        "processObject(Node* node, core::objectmodel::BaseObject* obj)": "Processes a given SOFA object to generate its representation in the DOT graph.",
        "Result processNodeTopDown(Node* node)": "Method that processes each node top-down during scene traversal. It decides if and how nodes should be included in the generated graph based on their type, name, etc.",
        "void processNodeBottomUp(Node* node)": "Processes a given SOFA node bottom-up during scene traversal to ensure correct hierarchical representation.",
        "bool display(Node* node, const char** color=nullptr)": "Checks if a node should be displayed and returns appropriate fill color (if any).",
        "bool display(core::objectmodel::BaseObject* obj, const char** color=nullptr)": "Checks if an object should be displayed and returns appropriate fill color (if any).",
        "std::string getParentName(core::objectmodel::BaseObject* obj)": "Finds the parent name of a given SOFA object.",
        "std::string getName(core::objectmodel::Base* o, std::string prefix)": "Generates a unique name for a given SOFA base node or object with an optional prefix.",
        "std::string getName(core::objectmodel::BaseNode *node)": "Generates a unique name specifically for a given SOFA node.",
        "std::string getName(core::objectmodel::BaseObject* obj)": "Generates a unique name specifically for a given SOFA object."
      },
      "usage": "This component is used when the user wants to visualize or debug the hierarchical structure of nodes and objects in a SOFA scene. It outputs the DOT representation, which can be rendered by Graphviz tools to generate an image showing the relationships between different components.",
      "dependencies": [
        "sofa::simulation::Visitor",
        "std::ostream"
      ]
    }
  },
  "maths": {
    "maths": "The provided code represents the implementation of an `ExportDotVisitor` class in the SOFA simulation framework, which is used to visualize the graph structure of a scene. This visitor writes out the hierarchical and object relationships of nodes and objects within the scene into a DOT file format, compatible with Graphviz for visualization.\n\n### Mathematical Description:\n- **Graph Representation:** The system models the scene as a directed graph where each node in the graph represents either a `Node` (a container that holds objects) or an `Object` (an entity in the simulation). Each node and object is given a unique identifier, facilitating their representation in the DOT format.\n\n- **Unique Identifier Generation:** For each object (`BaseObject`) or node (`BaseNode`), a unique name is generated using `getName()`. This function ensures that names are unique by appending an index if needed. The generation of these identifiers can be modeled as a mapping from objects/nodes to strings, where the uniqueness constraint is maintained.\n\n- **Edge Representation:** Edges in the graph represent relationships between nodes and objects (e.g., object belonging to a node, mapping relations). This relationship is established by the `processObject()` method, which iterates through each object in a node and checks if it should be displayed based on various criteria (`display()` function).\n\n### Physical Description:\n- **Node Representation:** In physical terms, nodes can represent different parts of a simulation scene. For example, one node might contain objects representing the skin of an animated character, while another node contains objects representing its internal organs.\n\n- **Object Relationships:** Objects within the same node or across different nodes are interconnected through relationships such as interaction force fields and mappings (e.g., mechanical mappings). These relationships define how forces are propagated between different parts of the scene.\n\n- **Visualization Output:** The DOT file generated by this visitor provides a visual representation of the simulation's structure, which can be crucial for debugging complex simulations or understanding the architecture of a model. Each node and object is represented as a graph vertex with edges connecting them based on their relationships."
  },
  "summary": {
    "abstract": "The `ExportDotVisitor` writes the hierarchical structure of a SOFA scene into DOT format, enabling visualization using Graphviz.",
    "sheet": "# ExportDotVisitor\n\n## Overview\n\nThe `ExportDotVisitor` is a visitor component in the SOFA framework designed to write out the graph structure of a simulation scene into DOT format. This allows for visualizing the hierarchical relationships between nodes and objects within the scene, which can be useful for debugging and understanding complex simulations.\n\n## Dependencies and Connections\n\nThe `ExportDotVisitor` operates on the scene graph hierarchy, specifically visiting each node and object to generate unique identifiers and determine their relationships. It does not have any specific dependencies but relies on the SOFA framework's scene graph structure."
  }
}