Skip to content

Che: The orchestrator class

moutella edited this page Sep 9, 2021 · 1 revision

This class is the main class of che.js. It is responsible for holding references for each of the levels, loading the meshes, and the orchestration of the methods in each level.

Attribbutes

This class has 4 main attributes, that serve the purpose of holding references for each level:

  • _level0:
    • If loaded, will reference a CheL0 instance.
  • _level1
    • If loaded, will reference a CheL1 instance.
  • _level2
    • If loaded, will reference a CheL2 instance.
  • _level3
    • If loaded, will reference a CheL3 instance.

Methods

Mesh Loading

  • loadPly(plyBody)
    • This method calls the loadCheL0 method, creating its arguments based on the body of a .ply file. The ply file should be in ascii format, and should only contain the coordinates on the vertices part.

Level loading and unloading

  • loadCheL0(tableG, tableV)

    • This method loads the base level of the Compact Half-Edge and sets the _level0 pointer to the instance created in it.
    • The tableG parammeter should be an array containing Vertex instances, each representing a vertex of the mesh.
    • The tableV parameter should be an array ccontaining, for every three elements of it, the index of the vertices that represent eacch triangle.
  • loadCheL1()

    • If all the previous levels are already loaded, this method loads the level 1 of the Compact Half-Edge and sets the _level1 pointer to the instance created in it.
  • cleanL1(force)

    • This methods removes the reference of the CheL1 instance.
    • It will only remove the reference if no upper levels are loaded.
    • If the force parameter is set to true, it will unload upper levels.
  • loadCheL2()

    • If all the previous levels are already loaded, this method loads the level 2 of the Compact Half-Edge and sets the _level2 pointer to the instance created in it.
  • cleanL2(force)

    • This methods removes the reference of the CheL2 instance.
    • It will only remove the reference if no upper levels are loaded.
    • If the force parameter is set to true, it will unload upper levels.
  • loadCheL3()

    • If all the previous levels are already loaded, this method loads the level 3 of the Compact Half-Edge and sets the _level3 pointer to the instance created in it.
  • cleanL3(force)

    • This methods removes the reference of the CheL3 instance.
    • It will only remove the reference if no upper levels are loaded.
    • If the force parameter is set to true, it will unload upper levels.

The class has getters for all of the level references, so you can read them without worrying about overwriting.

  • level0: returns the reference store on _level0
  • level1: returns the reference store on _level1
  • level2: returns the reference store on _level2
  • level3: returns the reference store on _level3

Relation methods

Some of the methods below have different methods in each level. The Che class will always use the fastest method available.

  • relation00(vertexId)

    • Returns the index of the vertices in the star of the vertex identified by vertexId.
  • relation02(vertexId)

    • Returns the index of the triangles in the star of the vertex identified by vertexId.
  • relation10(halfEdgeId)

    • Returns the index of the vertices in the star of the edge identified by halfEdgeId.
  • relation12(halfEdgeId)

    • Returns the index of the triangles in the star of the edge identified by halfEdgeId.
  • relation22(halfEdgeId)

    • Returns the index of the triangles in the star of the triangle that contains the half-edge identified by halfEdgeId.

Level 0 methods

All of these methods from the CheL0 class can be used directly from the orchestrator.

Getters

  • vertexCount: returns the amount of vertices in the mesh.

  • triangleCount: returns the amount of triangles in the mesh.

  • halfEdgeCount: returns the amount of half-edges in the mmesh.

  • getVertex(vertexId)

    • returns the vertex at the vertexId index.
  • getHalfEdgeVertex(heId)

    • returns the vertex associated with the half-edge at the heId index.
  • triangle(heId)

    • returns the triangle that the half-edge at heId is a part of.
  • getTriangleCenter(triId)

    • returns the average x,y,z from the three vertices in the triId triangle.

Validators

  • isValidVertex(vertexId)
    • checks if vertexId is a valid vertex element.
  • isValidHalfEdge(heId)
    • checks if heId is a valid half-edge element.

Geommetry modification

  • setVertex(vertexId, geometry)
    • changes the geometry of the vertex at the vertexId index.
  • setHalfEdgeVertex(heId, vertexId)
    • changes the vertex assocciated with a half-edge.

Half-Edge operators

  • nextHalfEdge(heId)

    • returns the index of the "next" half-edge in the triangle that heId is a part of.
  • previousHalfEdge(heId)

    • returns the index of the "previous" half-edge in the triangle that heId is a part of.

Level 1 methods

All of these methods from the CheL1 class can be used directly from the orchestrator.

Half-Edge operators

  • getOppositeHalfEdge(heId)
    • returns the index of the "opposite" half-edge of heId.

Level 2 methods

All of these methods from the CheL2 class can be used directly from the orchestrator.

Half-Edge operators

  • getEdgeHalfEdge(heId)

    • returns the edge associated with the heId half-edge.
  • getVertexHalfEdge(vertexId)

    • returns the half-edge associated with the vertex at vertexId.

Level 3 methods

All of these methods from the CheL2 class can be used directly from the orchestrator.

Curve operators

  • getCurveHalfEdge(curveId)
    • returns the half-edge that represents the boundary curve curveId.