Class PolygonContext

This object represents a collection of triangles to be rendered using the integrated CPU based polygon rendering engine. An arbitrary number of polygon objects can be assigned to a render engine. PolygonContext objects are allocated with a number of utiity functions from the Fovia.ServerContext class.

Hierarchy

  • PolygonContext

Index

Constructors

constructor

Properties

Private polygonContextID

polygonContextID: number

Methods

cleanMesh

  • cleanMesh(doClean: boolean, callbackFunc?: any): any
  • Converts a mesh to a manifold representation for compatibility with a 3D printer. A manifold mesh has no holes, border edges, inverted triangles, or intersecting and interior polygons. Not all meshes can be cleaned in a single operation. Prior application of parameters in the Optimize function may be necessary to successfully clean a mesh.

    Parameters

    • doClean: boolean

      If true the mesh will be cleaned, if false, the mesh will only be analyzed, with results returned in the promise.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(data) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , data)

    Where data is:

    data.err - An error ReturnCode .
    data.numBorders - The number of border edges.
    data.numFlippedTriangles - The number of inverted triangles.
    data.numHoles - The number of holes in the mesh.
    data.numNonManifold - The number of non-manifold edges.

    All data fields must be 0 for the mesh to be fully cleaned. Multiple cleaning passes may be performed.

clearTextureMap

  • clearTextureMap(callbackFunc?: any): any
  • Clears the current texture map.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

colorizePolygonFromVolumeData

  • colorizePolygonFromVolumeData(renderEngineContext: RenderEngineContext3D, vrColor?: boolean, callbackFunc?: any): any
  • Generate vertex colors for the polygon context, resulting in a colorized object.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      rendering engine that will perform the rendering operation.

    • Default value vrColor: boolean = true

      true if using Volume Rendering (VR) colorization or false for Transfer Function (TF) colorization.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

convertToIndexBuffer

  • convertToIndexBuffer(callbackFunc?: any): any
  • Converts a mesh from a vertex buffer represtentation to an index buffer representation. This operation can result in a large reduction in the number of vertices needed to define the mesh. This will also reduce the amount of memory required to store the mesh data. This funciton is called internally on meshes processed with the cleanMesh() and optimizeMesh() functions.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

enableCutPlanes

  • enableCutPlanes(cutPlanesEnabled: boolean, callbackFunc?: any): any
  • Setting to determine if the polygon rendering should be affected by the cut planes.

    Parameters

    • cutPlanesEnabled: boolean

      true if polygons should be clipped by cut planes, false otherwise.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

enableTextureLighting

  • enableTextureLighting(textureLightingEnabled: boolean, callbackFunc?: any): any
  • Turns lighting on/off for texture mapped objects. Default is off. Generally, lighting should be on for mesh objects like implants and surgical guides. Lighting should be off for render-to-texture objects like VOI slices.

    Parameters

    • textureLightingEnabled: boolean

      true if texture lighting is to be enabled, false otherwise.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

enableUniformShading

  • enableUniformShading(uniformShading: boolean, callbackFunc?: any): any
  • This method determines if shading is enabled for the whole polygon object.

    Parameters

    • uniformShading: boolean

      true if the entire polygon context should have shading enabled, false otherwise.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

getMeshDetails

  • getMeshDetails(callbackFunc?: any): any
  • Get the current polygon mesh details and return this from the promise.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(data).catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , data)

    Where data is:

    data.err - An error ReturnCode .
    data.numVerticies - The number of vertices in the mesh object.
    data.numPolygons - The number of polygons in the mesh object.
    data.numIndicies - The number of indices in the mesh object.

getPolygonContextID

  • getPolygonContextID(): number
  • Return the polygon context ID associated with this object

    Returns number

getTransform

  • getTransform(callbackFunc?: any): any
  • Gets the current 4x4 transformation matrix that is multiplied to each polygon object vertex before being displayed.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then(matrix: Matrix ) .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode , matrix: Matrix )

invertMeshGradients

  • invertMeshGradients(invertGradients: boolean, callbackFunc?: any): any
  • Inverts mesh lighting calculations so that the inside of the mesh is illuminated.

    Parameters

    • invertGradients: boolean

      true if gradient lighting should be inverted, false for normal lighting.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

optimize

  • optimize(cleanIslands: boolean, islandPercentage: number, decimate: boolean, decimatePercentage: number, smoothBefore: boolean, smoothAfter: boolean, smoothAmount: number, flip: boolean, callbackFunc?: any): any
  • Executes a set of mesh optimization algorithms such as polygon decimation, connected set limitation, and vertex smoothing. This method can perfom all of these operations, or a subset of them.

    Parameters

    • cleanIslands: boolean

      Determins if the connected set reduction operation is run.

    • islandPercentage: number

      Value between 0 and 100 that sets the connected set size percentage threshold. For example, if a mesh has 100 polygons and islandPercentage is set to 10, then all sets containing 10 or fewer polygons are deleted.

    • decimate: boolean

      Determins if the decimate operation is run.

    • decimatePercentage: number

      Value between 0 and 100 that determines the percentage of polygons that will be removed. For example, if set to 75, then 75 percent of the polygons will be removed.

    • smoothBefore: boolean

      Determines if the smoothing operation is run before the decimate operation.

    • smoothAfter: boolean

      Determines if the smoothing operation is run after the decimate operation.

    • smoothAmount: number

      Value between 0 and 1 that determines how aggressively the mesh is smoothed. Higher values equate to more smoothing.

    • flip: boolean

      Determines if the polygon flip operation is applied.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

Private release

  • release(): number
  • Returns number

releaseSessionResources

  • releaseSessionResources(callbackFunc?: any): any
  • Releases server side memory associated with this PolygonContext object.

    Parameters

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

renderPolygonOutline

  • renderPolygonOutline(lineWidth: number, callbackFunc?: any): any
  • When rendeirng polygons on MPR views, you typically render as an outline that intersects with the curent view. The width of the line (in pixels) is specified by this method. This is NOT used when setType is set to lines.

    Parameters

    • lineWidth: number

      Width of the line (in pixels) when rendering an outline.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

save

  • save(filename: string, polygonFileType: PolygonFileType, callbackFunc?: any): any
  • Saves the polygon context to the specifieid file on the server, in either OBJ, STL, or PLY format.

    Parameters

    • filename: string

      The file name to save the polygon object to.

    • polygonFileType: PolygonFileType

      A member of the PolygonFileType enumeration specifying the ouput file format.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setCullMode

  • setCullMode(cullMode: CullMode, callbackFunc?: any): any
  • Sets the backface culling mode.

    Parameters

    • cullMode: CullMode

      A member of the CullMode enumeration specifying the cull mode.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setTextureMapFromFile

  • setTextureMapFromFile(filename: string, callbackFunc?: any): any
  • Sets the texture mapping source to the specified image file on disk.

    Parameters

    • filename: string

      The name of the image file to load.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setTextureMapFromRenderEngine

  • Sets the texture mapping source to the specified rendering engine.

    Parameters

    • renderEngineContext: RenderEngineContext3D

      The RenderEngineContext3D object to use as the texture mapping source.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setTransform

  • setTransform(matrix: Matrix, callbackFunc?: any): any
  • Sets a 4x4 matrix for each of the vertices to be multiplied by before being displayed

    Parameters

    • matrix: Matrix

      The transformation matrix to be applied to this polygon object.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setType

  • setType(polygonType: PolygonType, callbackFunc?: any): any
  • Sets if polygon rendering mode should be lines (as an outline) or triangles.

    Parameters

    • polygonType: PolygonType

      A member of the PolygonType enumeration specifying the polygon type.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )

setUniformColor

  • setUniformColor(uniformColor: Color, callbackFunc?: any): any
  • This method sets the color for the entire polygon context.

    Parameters

    • uniformColor: Color

      Color to be applied to the entire polygon context.

    • Optional callbackFunc: any

    Returns any

    This is an asynchronous method that returns a Promise as follows:

    Promise .then() .catch (err: ReturnCode )

    callbackFunc(err: ReturnCode )