### Get Positions Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Retrieves the positions of all vertices in the graph by reference. ```APIDOC ## GET /graph/positions ### Description Retrieves the positions of all vertices in the graph by reference. This allows direct modification of vertex positions. ### Method GET ### Endpoint /graph/positions ### Parameters No parameters required. ### Request Example ```json { } ``` ### Response #### Success Response (200) - **positions** (numpy.ndarray) - A NumPy array where each row represents the (x, y, z) coordinates of a vertex. #### Response Example ```json { "positions": [[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]] } ``` ``` -------------------------------- ### Minimum Spanning Tree API Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Computes the minimum spanning tree (MST) of a given graph starting from a specified root node using Prim's algorithm. ```APIDOC ## POST /graph/minimum_spanning_tree ### Description Computes the minimum spanning tree of a graph using Prim's algorithm. The spanning tree of the connected component containing the root node is returned. ### Method POST ### Endpoint `/graph/minimum_spanning_tree` ### Parameters #### Path Parameters None #### Query Parameters - **g** (Graph) - Required - The input graph object. - **root_node** (int) - Optional - The node to start Prim's algorithm from. Defaults to 0. ### Request Example ```json { "g": "", "root_node": 0 } ``` ### Response #### Success Response (200) - **mst** (Graph) - The computed minimum spanning tree as a new Graph object. #### Response Example ```json { "mst": "" } ``` ``` -------------------------------- ### Load PyGEL Library and Define API Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/.html Loads the appropriate PyGEL shared library based on the operating system (macOS, Windows, Linux) and defines the argument types and return types for various functions in the C API using the `ctypes` module. This setup is crucial for enabling Python to interact with the underlying C/C++ GEL library. ```python import os from sys import platform, prefix import ctypes as ct import numpy as np from numpy.ctypeslib import ndpointer def _get_script_path(): return os.path.dirname(__file__) def _get_lib_name(): if platform == "darwin": return "libPyGEL.dylib" if platform == "win32": return "PyGEL.dll" return "libPyGEL.so" # Load PyGEL the Python GEL bridge library lib_py_gel = ct.cdll.LoadLibrary(_get_script_path() + "/" + _get_lib_name()) # An InvalidIndex is just a special integer value. InvalidIndex = ct.c_size_t.in_dll(lib_py_gel, "InvalidIndex").value # The following many lines explitize the arguments and return types of the C API # IntVector lib_py_gel.IntVector_new.restype = ct.c_void_p lib_py_gel.IntVector_get.argtypes = (ct.c_void_p, ct.c_size_t) lib_py_gel.IntVector_size.argtypes = (ct.c_void_p,) lib_py_gel.IntVector_size.restype = ct.c_size_t lib_py_gel.IntVector_delete.argtypes = (ct.c_void_p,) # Vec3dVector lib_py_gel.Vec3dVector_new.restype = ct.c_void_p lib_py_gel.Vec3dVector_get.argtypes = (ct.c_void_p, ct.c_size_t) lib_py_gel.Vec3dVector_get.restype = ct.POINTER(ct.c_double) lib_py_gel.Vec3dVector_size.argtypes = (ct.c_void_p,) lib_py_gel.Vec3dVector_size.restype = ct.c_size_t ``` -------------------------------- ### Skeletonize Graph using Local Separators Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Generates a skeleton graph from an input graph using the local separators approach. An optional `sampling` parameter determines whether to use all vertices or a sample as starting points. Returns the new skeleton graph. ```Python skel = Graph() mapping = IntVector() lib_py_gel.graph_LS_skeleton(g.obj, skel.obj, mapping.obj, sampling) return skel ``` -------------------------------- ### Skeletonize Graph and Map Nodes using Local Separators Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Skeletonizes a graph using the local separators method and provides a mapping from original graph nodes to the skeletal nodes. The `sampling` parameter controls the starting points for separator finding. Returns both the skeleton graph and the node mapping. ```Python skel = Graph() mapping = IntVector() lib_py_gel.graph_LS_skeleton(g.obj, skel.obj, mapping.obj, sampling) return skel, mapping ``` -------------------------------- ### Skeletonize Graph using LS and Map (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Skeletonizes a graph using the local separators (LS) approach and provides a mapping from the original graph's nodes to the nodes in the resulting skeletal graph. It supports sampling for starting points. The function returns a tuple containing the new skeletal graph and the node mapping. ```Python def LS_skeleton_and_map(g: Graph, sampling=True): skel = Graph() mapping = IntVector() lib_py_gel.graph_LS_skeleton(g.obj, skel.obj, mapping.obj, sampling) return skel, mapping ``` -------------------------------- ### Skeletonize Graph using LS (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Creates a skeleton representation of a graph using the local separators (LS) approach. It can optionally use a sampling of vertices as starting points. The function returns a new graph object representing the skeleton. ```Python def LS_skeleton(g: Graph, sampling=True): skel = Graph() mapping = IntVector() lib_py_gel.graph_LS_skeleton(g.obj, skel.obj, mapping.obj, sampling) return skel ``` -------------------------------- ### Get Neighbors Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Retrieves the neighbors of a specified node. ```APIDOC ## GET /graph/neighbors ### Description Retrieves the neighbors of a specified node. The mode parameter determines whether to return neighboring nodes or incident edges. ### Method GET ### Endpoint /graph/neighbors ### Parameters #### Query Parameters - **n** (integer) - Required - The index of the node for which to find neighbors. - **mode** (string) - Optional - Specifies the type of neighbors to return. 'n' for nodes, 'e' for edges. Defaults to 'n'. ### Request Example ```json { "n": 1, "mode": "n" } ``` ### Response #### Success Response (200) - **neighbors** (IntVector) - An iterable range of neighbor indices or edge indices. #### Response Example ```json { "neighbors": [0, 2] } ``` ``` -------------------------------- ### Graph Initialization and Copying Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Initializes a new graph or creates a copy of an existing graph. ```APIDOC ## POST /graph ### Description Initializes a new graph or creates a copy of an existing graph. ### Method POST ### Endpoint /graph ### Parameters #### Request Body - **orig** (Graph) - Optional - The graph to copy. If None, a new empty graph is created. ### Request Example ```json { "orig": null } ``` ### Response #### Success Response (200) - **graph_obj** (Graph) - The newly created or copied graph object. #### Response Example ```json { "graph_obj": "" } ``` ``` -------------------------------- ### Manifold Creation and Basic Operations Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/.html Covers the creation of Manifold objects from various inputs and basic management operations. ```APIDOC ## Manifold Creation and Basic Operations ### Description Functions for creating, copying, merging, and deleting `Manifold` objects, as well as retrieving basic properties. ### Endpoints - **`Manifold_from_triangles`**: Creates a `Manifold` from a set of triangles. - **`Manifold_from_points`**: Creates a `Manifold` from a set of points. - **`Manifold_new`**: Creates a new empty `Manifold`. - **`Manifold_copy`**: Creates a copy of an existing `Manifold`. - **`Manifold_merge`**: Merges two `Manifold` objects. - **`Manifold_delete`**: Deletes a `Manifold` object. - **`Manifold_positions`**: Retrieves the positions of vertices in the `Manifold`. - **`Manifold_no_allocated_vertices`**: Gets the number of allocated vertices. - **`Manifold_no_allocated_faces`**: Gets the number of allocated faces. - **`Manifold_no_allocated_halfedges`**: Gets the number of allocated half-edges. ``` -------------------------------- ### Set up GLManifoldViewer Function Signatures Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/gl_display Defines the argument types and return types for the GLManifoldViewer functions from the lib_py_gel library using ctypes. This is crucial for correct interaction between Python and the underlying C/C++ library. ```python lib_py_gel.GLManifoldViewer_new.restype = ct.c_void_p lib_py_gel.GLManifoldViewer_delete.argtypes = (ct.c_void_p,) lib_py_gel.GLManifoldViewer_display.argtypes = (ct.c_void_p,ct.c_void_p,ct.c_void_p,ct.c_char,ct.c_bool, ct.POINTER(ct.c_float*3), ct.POINTER(ct.c_double),ct.c_bool,ct.c_bool) lib_py_gel.GLManifoldViewer_get_annotation_points.restype = ct.c_size_t lib_py_gel.GLManifoldViewer_get_annotation_points.argtypes = (ct.c_void_p, ct.POINTER(ct.POINTER(ct.c_double))) lib_py_gel.GLManifoldViewer_set_annotation_points.argtypes = (ct.c_void_p, ct.c_int, ct.POINTER(ct.c_double)) lib_py_gel.GLManifoldViewer_event_loop.argtypes = (ct.c_bool,) ``` -------------------------------- ### Get Nodes Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Retrieves all nodes in the graph as an iterable range. ```APIDOC ## GET /graph/nodes ### Description Retrieves all nodes in the graph as an iterable range. ### Method GET ### Endpoint /graph/nodes ### Parameters No parameters required. ### Request Example ```json { } ``` ### Response #### Success Response (200) - **nodes** (IntVector) - An iterable range of node indices. #### Response Example ```json { "nodes": [0, 1, 2, 3] } ``` ``` -------------------------------- ### Get Face Center Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the geometric center of a specified face. ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/centre ### Description Returns the centre of a face. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/centre ### Parameters #### Path Parameters - **fid** (int) - Required - The identifier of the face. ### Response #### Success Response (200) - **centre** (list[float]) - A list of three floats representing the [x, y, z] coordinates of the face's center. ``` -------------------------------- ### Initialize and Delete GLManifoldViewer Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/gl_display Demonstrates the initialization of a GLManifoldViewer instance and its subsequent deletion. This involves creating a new viewer object and ensuring its proper cleanup to prevent resource leaks. ```python class Viewer: def __init__(self): current_directory = getcwd() self.obj = lib_py_gel.GLManifoldViewer_new() chdir(current_directory) # Necessary because init_glfw changes cwd def __del__(self): lib_py_gel.GLManifoldViewer_delete(self.obj) ``` -------------------------------- ### Get Incident Vertex Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Retrieves the vertex incident to a given half-edge (hid). ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/vertex ### Description Returns the vertex incident to the given half-edge identifier. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/vertex ### Parameters #### Query Parameters - **hid** (integer) - Required - The identifier of the half-edge. ### Response #### Success Response (200) - **vertex_id** (integer) - The identifier of the incident vertex. #### Response Example ```json { "vertex_id": 456 } ``` ``` -------------------------------- ### Initialize PyGel3D Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Constructs a new PyGel3D graph. It can be initialized as a new empty graph or by copying an existing graph. ```python def __init__(self,orig=None): if orig == None: self.obj = lib_py_gel.Graph_new() else: self.obj = lib_py_gel.Graph_copy(orig.obj) ``` -------------------------------- ### Manifold Initialization and Copying Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh The Manifold class can be initialized as a new empty mesh or by copying an existing Manifold object. ```APIDOC ## Manifold ### Description The Manifold class represents a halfedge-based mesh. ### Methods #### `__init__(self, orig=None)` Initialize a new Manifold object. If `orig` is provided, a copy of the `orig` Manifold is created. Otherwise, a new empty Manifold is created. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **orig** (Manifold) - Optional. The Manifold object to copy. ### Request Example ```json { "orig": "" } ``` ### Response None #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Get Incident Face Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Retrieves the face incident to a given half-edge (hid). ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d ### Description Returns the face incident to the given half-edge identifier. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d ### Parameters #### Query Parameters - **hid** (integer) - Required - The identifier of the half-edge. ### Response #### Success Response (200) - **face_id** (integer) - The identifier of the incident face. #### Response Example ```json { "face_id": 123 } ``` ``` -------------------------------- ### Display Manifold and Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/gl_display Shows how to display a Manifold mesh and an optional Graph using the GLManifoldViewer. It supports various visualization modes, smoothing options, background colors, and per-vertex data. ```python def display(self, m: Manifold, g: Graph=None, mode='w', smooth=True, bg_col=[0.3,0.3,0.3], data=None, reset_view=False, once=False): data_ct = np.array(data,dtype=ct.c_double).ctypes data_a = data_ct.data_as(ct.POINTER(ct.c_double)) bg_col_ct = np.array(bg_col,dtype=ct.c_float).ctypes bg_col_a = bg_col_ct.data_as(ct.POINTER(ct.c_float*3)) if isinstance(m, Graph): g = m m = None if isinstance(m,Manifold) and isinstance(g, Graph): lib_py_gel.GLManifoldViewer_display(self.obj, m.obj, g.obj, ct.c_char(mode.encode('ascii')),smooth,bg_col_a,data_a,reset_view,once) elif isinstance(m,Manifold): lib_py_gel.GLManifoldViewer_display(self.obj, m.obj, 0, ct.c_char(mode.encode('ascii')),smooth,bg_col_a,data_a,reset_view,once) ``` -------------------------------- ### Get Vertex Valency Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the valency of a vertex, which is the number of edges incident to it. ```python return lib_py_gel.valency(self.obj,vid) ``` -------------------------------- ### Get Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates the length of an edge identified by a given halfedge. ```python return lib_py_gel.length(self.obj, hid) ``` -------------------------------- ### Initialize and Display Mesh/Graph with pygel3d Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/gl_display Initializes an OpenGL viewer and displays a Manifold mesh or a Graph. It handles different display modes, smoothing options, background color, per-vertex data, and view resetting. Supports displaying a mesh with or without an associated graph. ```python import ctypes as ct import numpy as np from pygel3d.hmesh import Manifold from pygel3d.graph import Graph from pygel3d import lib_py_gel class Viewer: def __init__(self): self.obj = lib_py_gel.GLManifoldViewer_new() def __del__(self): lib_py_gel.GLManifoldViewer_delete(self.obj) def display(self, m: Manifold, g: Graph=None, mode='w', smooth=True, bg_col=[0.3,0.3,0.3], data=None, reset_view=False, once=False): data_ct = np.array(data,dtype=ct.c_double).ctypes data_a = data_ct.data_as(ct.POINTER(ct.c_double)) bg_col_ct = np.array(bg_col,dtype=ct.c_float).ctypes bg_col_a = bg_col_ct.data_as(ct.POINTER(ct.c_float*3)) if isinstance(m, Graph): g = m m = None if isinstance(m,Manifold) and isinstance(g, Graph): lib_py_gel.GLManifoldViewer_display(self.obj, m.obj, g.obj, ct.c_char(mode.encode('ascii')),smooth,bg_col_a,data_a,reset_view,once) elif isinstance(m,Manifold): lib_py_gel.GLManifoldViewer_display(self.obj, m.obj, 0, ct.c_char(mode.encode('ascii')),smooth,bg_col_a,data_a,reset_view,once) elif isinstance(g,Graph): lib_py_gel.GLManifoldViewer_display(self.obj, 0, g.obj, ct.c_char(mode.encode('ascii')),smooth,bg_col_a,data_a,reset_view,once) ``` -------------------------------- ### Get Face Perimeter Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Retrieves the perimeter of a specified face within the manifold object. ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d ### Description Returns the perimeter of a face fid. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d ### Parameters #### Path Parameters - **fid** (int) - Required - The identifier of the face. ### Response #### Success Response (200) - **perimeter** (float) - The calculated perimeter of the face. ``` -------------------------------- ### Manifold Class Initialization and Copy Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Initializes a new Manifold object or creates a copy of an existing one using the lib_py_gel library. ```python class Manifold: def __init__(self,orig=None): if orig == None: self.obj = lib_py_gel.Manifold_new() else: self.obj = lib_py_gel.Manifold_copy(orig.obj) ``` -------------------------------- ### Get Median Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the median edge length of a mesh. ```APIDOC ## GET /mesh/median_edge_length ### Description Calculates and returns the median edge length of the given mesh. ### Method GET ### Endpoint /mesh/median_edge_length ### Parameters #### Query Parameters - **m** (Manifold) - Required - The mesh object to analyze. ### Request Example ``` GET /mesh/median_edge_length?m= ``` ### Response #### Success Response (200) - **median_edge_length** (float) - The median edge length of the mesh. #### Response Example ```json { "median_edge_length": 0.11111 } ``` ``` -------------------------------- ### Build PyGEL 3D KD-Tree Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/spatial Builds the PyGEL 3D KD-tree, making it searchable. This method must be called after all `insert` operations have been completed. ```python lib_py_gel.I3DTree_build(self.obj) ``` -------------------------------- ### Get Average Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the average edge length of a mesh. ```APIDOC ## GET /mesh/average_edge_length ### Description Calculates and returns the average edge length of the given mesh. ### Method GET ### Endpoint /mesh/average_edge_length ### Parameters #### Query Parameters - **m** (Manifold) - Required - The mesh object to analyze. ### Request Example ``` GET /mesh/average_edge_length?m= ``` ### Response #### Success Response (200) - **average_edge_length** (float) - The average edge length of the mesh. #### Response Example ```json { "average_edge_length": 0.12345 } ``` ``` -------------------------------- ### Graph Utility Functions Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Functions for creating, loading, and saving graph objects. ```APIDOC ## Graph Utility Functions ### Functions - **from_mesh(m)**: Creates a Graph object from a Manifold mesh 'm'. The graph will have the same vertices and edges as the mesh. - **load(fn)**: Loads a graph from a file specified by filename 'fn'. The file format is similar to Wavefront OBJ. Returns the loaded Graph object or None if loading fails. - **save(fn, g)**: Saves a Graph object 'g' to a file specified by filename 'fn'. Returns True if saving was successful, False otherwise. ``` -------------------------------- ### Get Average Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Calculates and returns the average edge length of the graph. ```APIDOC ## GET /graph/average_edge_length ### Description Calculates and returns the average length of all edges in the graph. ### Method GET ### Endpoint /graph/average_edge_length ### Parameters No parameters required. ### Request Example ```json { } ``` ### Response #### Success Response (200) - **average_edge_length** (float) - The computed average edge length. #### Response Example ```json { "average_edge_length": 1.5 } ``` ``` -------------------------------- ### Load Manifold from OBJ Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Loads a Manifold object from a Wavefront OBJ file. ```APIDOC ## GET /manifold/load/obj ### Description Load and return Manifold from Wavefront OBJ file. ### Method GET ### Endpoint `/manifold/load/obj` ### Parameters #### Query Parameters - **fn** (string) - Required - The filename of the OBJ file to load. ### Response #### Success Response (200) - **manifold** (Manifold) - The loaded Manifold object, or null if loading failed. #### Response Example ```json { "manifold": { ... Manifold object data ... } } ``` #### Error Response (400) - **error** (string) - Error message if loading failed. #### Error Response Example ```json { "error": "Failed to load manifold from file." } ``` ``` -------------------------------- ### Get Face Perimeter (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the perimeter of a specified face, identified by its index (fid). ```python def perimeter(self, fid): """ Returns the perimeter of a face fid. """ return lib_py_gel.perimeter(self.obj, fid) ``` -------------------------------- ### Graph Class Initialization and Copying in Python Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Initializes a new Graph object or creates a copy of an existing one. The constructor handles the creation of a new graph object or the copying of another graph's data, ensuring proper memory management through its destructor. ```python class Graph: def __init__(self,orig=None): if orig == None: self.obj = lib_py_gel.Graph_new() else: self.obj = lib_py_gel.Graph_copy(orig.obj) ``` -------------------------------- ### Get Vertex Valency in PyGel3D Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the valency of a vertex, which is the count of incident edges connected to it. ```python def valency(self,vid): """ Returns valency of vid, i.e. number of incident edges.""" return lib_py_gel.valency(self.obj,vid) ``` -------------------------------- ### Get Edge Length in PyGel3D Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the length of the edge defined by the given halfedge. ```python def edge_length(self, hid): """ Returns length of edge given by halfedge hid which is passed as argument. """ return lib_py_gel.length(self.obj, hid) ``` -------------------------------- ### Load Manifold (Auto-detect Format) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Loads a Manifold from a file, automatically detecting the format (X3D, OBJ, OFF, PLY). ```APIDOC ## GET /manifold/load ### Description Load a Manifold from an X3D/OBJ/OFF/PLY file. Return the loaded Manifold. ### Method GET ### Endpoint `/manifold/load` ### Parameters #### Query Parameters - **fn** (string) - Required - The filename of the mesh file to load. ### Response #### Success Response (200) - **manifold** (Manifold) - The loaded Manifold object, or null if loading failed or format is unsupported. #### Response Example ```json { "manifold": { ... Manifold object data ... } } ``` #### Error Response (400) - **error** (string) - Error message if loading failed. #### Error Response Example ```json { "error": "Failed to load manifold from file or unsupported format." } ``` ``` -------------------------------- ### Get Bounding Box Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the minimum and maximum corner points of the axis-aligned bounding box for the manifold. ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/bbox ### Description Returns the min and max corners of the bounding box of Manifold m. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/bbox ### Response #### Success Response (200) - **minCorner** (list[float]) - A list of three floats representing the [x, y, z] coordinates of the minimum corner. - **maxCorner** (list[float]) - A list of three floats representing the [x, y, z] coordinates of the maximum corner. ``` -------------------------------- ### Initialize Manifold (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Initializes a new Manifold object. It can be created empty or by copying an existing Manifold object. ```python def __init__(self,orig=None): """ Initializes a Manifold object.""" if orig == None: self.obj = lib_py_gel.Manifold_new() else: self.obj = lib_py_gel.Manifold_copy(orig.obj) ``` -------------------------------- ### Get Face Area (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the calculated area of a specified face, identified by its index (fid). ```python def area(self, fid): """ Returns the area of a face fid. """ return lib_py_gel.area(self.obj, fid) ``` -------------------------------- ### Skeletonize Graph using MSLS Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Generates a skeleton graph and a mapping from original nodes to skeleton nodes using the MSLS approach. Requires a graph object and a growth threshold. ```python def msls_skeleton_and_map(g, grow_thresh): """ Skeletonize a graph using the Multi Scale Local Separators (MSLS) approach. The first argument, g, is the graph. The second argument, grow_thresh, is the threshold for growing the skeleton. The function returns a tuple containing a new graph which is the skeleton of the input graph and a map from the graph nodes to the skeletal nodes. """ skel = Graph() mapping = IntVector() lib_py_gel.graph_MSLS_skeleton(g.obj, skel.obj, mapping.obj, grow_thresh) return skel, mapping ``` -------------------------------- ### Get Median Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the median edge length of a mesh. Operates on a Manifold object. ```python def median_edge_length(m: Manifold): """ Returns the median edge length of m""" return lib_py_gel.median_edge_length(m.obj) ``` -------------------------------- ### Get Face Center (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Computes and returns the center coordinates of a specified face. The center is returned as a NumPy array. ```python def centre(self, fid): """ Returns the centre of a face. """ c = ndarray(3, dtype=np.float64) lib_py_gel.centre(self.obj, fid, c) return c ``` -------------------------------- ### Get Face Edge Count (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Computes and returns the number of edges for a given face identified by its index (fid). ```python def no_edges(self, fid): """ Compute the number of edges of a face fid """ return lib_py_gel.no_edges(self.obj, fid) ``` -------------------------------- ### Skeletonize Graph using Multi-Scale Local Separators Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Creates a skeleton graph from an input graph using the multi-scale local separators approach. The `grow_thresh` parameter influences the skeletonization process. Returns the resulting skeleton graph. ```Python skel = Graph() mapping = IntVector() lib_py_gel.graph_MSLS_skeleton(g.obj, skel.obj, mapping.obj, grow_thresh) return skel ``` -------------------------------- ### Load Manifold from OBJ Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Loads and reconstructs a manifold mesh from a specified Wavefront OBJ file. ```APIDOC ## GET /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/obj_load ### Description Load and return Manifold from Wavefront obj file. Returns None if loading failed. ### Method GET ### Endpoint /websites/www2_compute_dtu_dk_projects_gel_pygel_pygel3d/obj_load ### Parameters #### Query Parameters - **fn** (string) - Required - The path to the OBJ file to load. ### Response #### Success Response (200) - **manifold** (object) - The loaded Manifold object, or null if loading failed. ``` -------------------------------- ### Get Average Edge Length Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Calculates and returns the average edge length of a given mesh. Operates on a Manifold object. ```python def average_edge_length(m: Manifold): """ Returns the average edge length of mesh m. """ return lib_py_gel.average_edge_length(m.obj) ``` -------------------------------- ### Get Incident Face (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the index of the face that contains the given halfedge identifier (hid). This function calls `lib_py_gel.Walker_incident_face`. ```python def incident_face(self,hid): """ Returns face corresponding to hid. """ return lib_py_gel.Walker_incident_face(self.obj, hid) ``` -------------------------------- ### Load Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Loads a graph from a file. The filename is expected to be in a format similar to Wavefront OBJ. Returns the loaded graph or None if loading fails. ```APIDOC ## POST /graph/load ### Description Loads a graph from a file specified by its filename. The file format is similar to Wavefront OBJ. ### Method POST ### Endpoint /graph/load ### Parameters #### Path Parameters - **fn** (string) - Required - The filename of the graph to load. ### Request Example { "fn": "path/to/your/graph.obj" } ### Response #### Success Response (200) - **Graph** (object) - The loaded graph object. #### Error Response (400) - **None** - If loading fails. ### Response Example { "Graph": { "vertices": [...], "edges": [...] } } ``` -------------------------------- ### Get Opposite Halfedge (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the index of the halfedge that is opposite to the given halfedge identifier (hid). This function calls `lib_py_gel.Walker_opposite_halfedge`. ```python def opposite_halfedge(self,hid): """ Returns opposite halfedge to hid. """ return lib_py_gel.Walker_opposite_halfedge(self.obj, hid) ``` -------------------------------- ### Manifold Creation from Triangles Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Creates a Manifold mesh from a list of vertices and triangle faces. ```APIDOC ## Manifold.from_triangles ### Description Given a list of vertices and triangles (faces), this class method produces a Manifold mesh. ### Method `classmethod from_triangles(cls, vertices, faces)` ### Endpoint None (Class Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **vertices** (list of float) - Required. A list of 3D vertex coordinates. - **faces** (list of int) - Required. A list of triangle faces, where each face is defined by three vertex indices. ### Request Example ```json { "vertices": [ [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0] ], "faces": [ [0, 1, 2] ] } ``` ### Response - **Manifold** (Manifold) - The created Manifold object. #### Success Response (200) - **Manifold** (Manifold) - The created Manifold object. #### Response Example ```json { "Manifold": "" } ``` ``` -------------------------------- ### Get Nodes in PyGel3D Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Retrieves all nodes in the graph as an iterable range. Requires an IntVector object to store the node indices. ```python def nodes(self): """ Get all nodes as an iterable range """ nodes = IntVector() lib_py_gel.Graph_nodes(self.obj, nodes.obj) return nodes ``` -------------------------------- ### Load Manifold from X3D Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Loads a Manifold object from an X3D file. ```APIDOC ## GET /manifold/load/x3d ### Description Load and return Manifold from X3D file. ### Method GET ### Endpoint `/manifold/load/x3d` ### Parameters #### Query Parameters - **fn** (string) - Required - The filename of the X3D file to load. ### Response #### Success Response (200) - **manifold** (Manifold) - The loaded Manifold object, or null if loading failed. #### Response Example ```json { "manifold": { ... Manifold object data ... } } ``` #### Error Response (400) - **error** (string) - Error message if loading failed. #### Error Response Example ```json { "error": "Failed to load manifold from file." } ``` ``` -------------------------------- ### Get Incident Vertex (PyGel3D) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the vertex corresponding to or pointed to by a given half-edge identifier. This is a core function for navigating the mesh structure. ```python def incident_vertex(self, hid): """ Returns vertex corresponding to (or pointed to by) hid. """ return lib_py_gel.Walker_incident_vertex(self.obj, hid) ``` -------------------------------- ### Get Previous Halfedge (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the index of the previous halfedge in sequence from the given halfedge identifier (hid). This function calls `lib_py_gel.Walker_prev_halfedge`. ```python def prev_halfedge(self,hid): """ Returns previous halfedge to hid. """ return lib_py_gel.Walker_prev_halfedge(self.obj, hid) ``` -------------------------------- ### Skeletonize Graph using Combined Approach Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Skeletonizes a graph using both front separators and multi-scale local separators, returning the skeleton graph and a node mapping. It takes a graph and node coloring data. ```python def combined_skeleton_and_map(g: Graph, colors, intervals=100): """ Skeletonize a graph using both the front separators approach and the multi scale local separators. The first argument, g, is the graph, and, colors is an nD array where each column contains a sequence of floating point values - one for each node. We can have as many columns as needed for the front separator computation. We can think of this as a coloring of the nodes, hence the name. In practice, a coloring might just be the x-coordinate of the nodes or some other function that indicates something about the structure of the graph. The function returns a tuple containing a new graph which is the skeleton of the input graph and a map from the graph nodes to the skeletal nodes. """ skel = Graph() mapping = IntVector() colors_flat = np.asarray(colors, dtype=ct.c_double, order='C') N_col = 1 if len(colors_flat.shape)==1 else colors_flat.shape[1] print("N_col:", N_col) lib_py_gel.graph_combined_skeleton(g.obj, skel.obj, mapping.obj, N_col, colors_flat.ctypes.data_as(ct.POINTER(ct.c_double)), intervals) return skel, mapping ``` -------------------------------- ### Load Manifold from PLY Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Loads a Manifold object from a Stanford PLY file. ```APIDOC ## GET /manifold/load/ply ### Description Load and return Manifold from Stanford PLY file. ### Method GET ### Endpoint `/manifold/load/ply` ### Parameters #### Query Parameters - **fn** (string) - Required - The filename of the PLY file to load. ### Response #### Success Response (200) - **manifold** (Manifold) - The loaded Manifold object, or null if loading failed. #### Response Example ```json { "manifold": { ... Manifold object data ... } } ``` #### Error Response (400) - **error** (string) - Error message if loading failed. #### Error Response Example ```json { "error": "Failed to load manifold from file." } ``` ``` -------------------------------- ### Get Next Halfedge (Python) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the index of the next halfedge in sequence from the given halfedge identifier (hid). This function calls `lib_py_gel.Walker_next_halfedge`. ```python def next_halfedge(self,hid): """ Returns next halfedge to hid. """ return lib_py_gel.Walker_next_halfedge(self.obj, hid) ``` -------------------------------- ### Get Vertex Positions in PyGel3D Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Retrieves vertex positions by reference, allowing for direct modification. Returns a NumPy array of positions. ```python def positions(self): """ Get the vertex positions by reference. You can assign to the positions. """ pos = ct.POINTER(ct.c_double)() n = lib_py_gel.Graph_positions(self.obj, ct.byref(pos)) return np.ctypeslib.as_array(pos,(n,3)) ``` -------------------------------- ### Manifold Creation from Points in PyGEL3D Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/.html Defines the argument and return types for `Manifold_from_points`, which constructs a Manifold from a set of points. It requires the number of points, point coordinates (float64, 2D C-contiguous array), and potentially normal vectors or other point-related data. ```Python lib_py_gel.Manifold_from_points.argtypes = (ct.c_size_t,ndpointer(np.float64, ndim=2, flags='C'), ndpointer(np.float64, shape=3),ndpointer(np.float64, shape=3)) lib_py_gel.Manifold_from_points.restype = ct.c_void_p ``` -------------------------------- ### Get Neighbors in PyGel3D Graph Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Fetches the neighbors of a specified node. Can return either neighboring nodes ('n') or incident edges ('e'). ```python def neighbors(self, n, mode='n'): """ Get the neighbors of node n. The final argument is either 'n' or 'e'. If it is 'n' the function returns all neighboring nodes, and if it is 'e' it returns incident edges.""" nbors = IntVector() lib_py_gel.Graph_neighbors(self.obj, n, nbors.obj, ct.c_char(mode.encode('ascii'))) return nbors ``` -------------------------------- ### Close Chordless Cycles API Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Closes chordless cycles within a graph. This operation can be performed starting from a specific node or for all nodes in the graph. ```APIDOC ## POST /graph/close_chordless_cycles ### Description Closes chordless cycles in a graph. A chordless cycle is a cycle where no two non-adjacent nodes in the cycle are connected by an edge. ### Method POST ### Endpoint `/graph/close_chordless_cycles` ### Parameters #### Path Parameters None #### Query Parameters - **g** (Graph) - Required - The input graph object. - **node** (int) - Optional - The starting node for searching cycles. If None, the operation is performed for all nodes. - **hops** (int) - Optional - Specifies the maximum distance from the starting node to search for cycles. Defaults to 5. - **rad** (float) - Optional - Specifies the maximum distance allowed for the farthest node in a cycle from the starting node. Defaults to the average edge length of the graph if not provided. ### Request Example ```json { "g": "", "node": 10, "hops": 7, "rad": 5.2 } ``` ### Response #### Success Response (200) This endpoint does not return a specific JSON body, but modifies the graph in place. #### Response Example ```json // No response body ``` ``` -------------------------------- ### Create Graph from Mesh Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/graph Creates a new graph from an existing mesh object. ```APIDOC ## POST /graph/from_mesh ### Description Creates a graph from a given mesh object 'm'. The resulting graph will have the same vertices and edges as the input mesh. ### Method POST ### Endpoint /graph/from_mesh ### Parameters #### Request Body - **m** (Manifold) - Required - The input mesh object. ### Request Example ```json { "m": "" } ``` ### Response #### Success Response (200) - **graph** (Graph) - The newly created graph object representing the mesh. #### Response Example ```json { "graph": "" } ``` ``` -------------------------------- ### Get Face Perimeter Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Returns the perimeter of a specified face within a manifold object. It takes a face ID as input and relies on the `lib_py_gel.perimeter` function. ```python def perimeter(self, fid): return lib_py_gel.perimeter(self.obj, fid) ``` -------------------------------- ### Manifold Creation from Points (Delaunay Triangulation) Source: https://www2.compute.dtu.dk/projects/GEL/PyGEL/pygel3d/hmesh Computes the Delaunay triangulation of a set of points and returns a Manifold mesh. ```APIDOC ## Manifold.from_points ### Description This class method computes the Delaunay triangulation of `pts`. You need to specify `xaxis` and `yaxis` if they are not canonical. The function returns a Manifold with the resulting triangles. This function may yield surprising results if the surface represented by the points is not well represented as a 2.5D surface (height field). ### Method `classmethod from_points(cls, pts, xaxis=[1, 0, 0], yaxis=[0, 1, 0])` ### Endpoint None (Class Method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pts** (list of float) - Required. A list of 3D points. - **xaxis** (list of float) - Optional. The x-axis vector. Defaults to `[1, 0, 0]`. - **yaxis** (list of float) - Optional. The y-axis vector. Defaults to `[0, 1, 0]`. ### Request Example ```json { "pts": [ [0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0] ], "xaxis": [1.0, 0.0, 0.0], "yaxis": [0.0, 1.0, 0.0] } ``` ### Response - **Manifold** (Manifold) - The Manifold object with the Delaunay triangulation. #### Success Response (200) - **Manifold** (Manifold) - The Manifold object with the Delaunay triangulation. #### Response Example ```json { "Manifold": "" } ``` ```