Class PbMesh

Direct Known Subclasses:
PbMesh1D, PbMesh2D, PbMesh3D

public class PbMesh extends PbBase
Defines an abstract mesh. A mesh is a set of nodes linked by edges. A mesh can be a surface mesh (see PbMesh2D) or a volume mesh (see PbMesh3D). A surface mesh can be either 2D (its nodes have 2 coordinates) or 3D (its nodes have 3 coordinates). Each node is referred to by an index named node_index.

A mesh is composed of a list of cells. A cell is a "simple" basic volume or surface element that connects adjacent nodes of the mesh. Surface meshes can be defined by triangles, quadrangles and polygonal cells. Volume meshes can be defined by tetrahedrons, hexahedrons, prisms, or pyramid cells. A cell is defined by the list of nodes (node indices) that it connects. The order of the nodes that define a cell is the same for each cell in the mesh. Each cell is referred to by an index named cell_index.

A list of value-set can be defined. A value is a scalar (float), string, or a vector. Each value is located on mesh node, so the number of values in a set must be equal to the number of mesh's nodes. Each set of values can be named by a string.

A scalar value set is used to color the representations of the mesh. A string value set is used by some charting representations. A vector value set is used to make "hedgehog" vector field representations, or streamline representations. Each data-set is referred by an index named set_index. This index is used by classes of mesh representation to indicate which value set must be used for coloring. (see PoMesh.valuesIndex and PoMesh.vecsIndex). Mapping a scalar value onto a color is done by PbDataMapping or PoDataMapping classes (and derived).

Data duplication:

If the last argument is_data_duplicate of a constructor of a derived class is false, the geometry and values sets are not copied by the object.

In this case, the methods setGeometry, addValuesSet, addStringsSet and addVecsSet save only the adress of the user data set and it is the application's responsibility to manage the validity of data during the existence of the mesh object.

  • Method Details

    • addValuesSet

      public void addValuesSet(int set_index, float[] val)
      Calls addValuesSet(set_index, val, "").
    • addValuesSet

      public void addValuesSet(int set_index, float[] val, PbMesh.DataBindings binding)
      Calls addValuesSet(set_index, val, binding, "").
    • addStringsSet

      public void addStringsSet(int set_index, String[] val)
      Calls addStringsSet(set_index, val, "").
    • addVecsSet

      public void addVecsSet(int set_index, SbVec3f[] val)
      Calls addVecsSet(set_index, val, "").
    • getStringsSetName

      public String getStringsSetName(int set_index)
      Gets the name associated to a string values set. NULL is returned if the set does not exist.
    • getVecsSetName

      public String getVecsSetName(int set_index)
      Gets the name associated to a vec values set. NULL is returned if the set does not exist.
    • addVecsSet

      public void addVecsSet(int set_index, SbVec3f[] val, String set_name)
      Adds a set of vector values . The number of values in a set must be equal to the number of nodes in the mesh. The set can be optionally named (set_name parameter).
    • getValuesSetName

      public String getValuesSetName(int set_index)
      Gets the name associated to a scalar values set. NULL is returned if the set does not exist.
    • getDirectValuesSet

      public FloatBuffer getDirectValuesSet(int set_index)
      Gets a set of scalar values.
    • getVecsSet

      public SbVec3f[] getVecsSet(int set_index)
      Gets a set of vector values.
    • removeValuesSet

      public boolean removeValuesSet(int set_index)
      Remove a set of scalar values.

      Returns:
      false if the scalar set does not exist,

    • getDirectVecsSet

      public FloatBuffer getDirectVecsSet(int set_index)
      Gets a set of vector values.
    • getValuesSet

      public float[] getValuesSet(int set_index)
      Gets a set of scalar values.
    • getNodeCoord

      public SbVec3f getNodeCoord(int nod_index)
      Gets the coordinates of a node.
    • getBoundingBox

      public SbBox3f getBoundingBox()
      Gets the bounding box of the mesh.
    • getNumCells

      public int getNumCells()
      Gets the number of cells in the mesh.
    • getMinValuesSet

      public float getMinValuesSet(int set_index)
      Gets the min of a set of scalars.

      Returns:
      false if the scalar set does not exist,

    • getNumNodes

      public int getNumNodes()
      Gets the number of nodes in the mesh.
    • getValuesBinding

      public PbMesh.DataBindings getValuesBinding(int set_index)
      Gets the binding of the scalar value set.

      Parameters:
      set_index - the index of the set of scalar values.

      Returns:
      PER_CELL or PER_NODE, or undefined binding if specified data set does not exist.

    • addStringsSet

      public void addStringsSet(int set_index, String[] val, String set_name)
      Adds a set of string values . The number of string in a set must be equal to the number of nodes in the mesh. The set can be optionally named (set_name parameter).
    • addValuesSet

      public void addValuesSet(int set_index, float[] val, PbMesh.DataBindings binding, String set_name)
      Adds a set of scalar values that can be located either at nodes or at cells. Warning: At this time, the PER_CELL data binding is taken into account only by the following classes:

      The other classes use inherited coloring mode when the PER_CELL binding is used.

      Parameters:
      set_index - the index of the new set added.

      val - the array of values. Its size must be either the number of nodes or the number of cells depending on the binding argument.

      binding - specifies the location of the values.

      set_name - string associated with this set of values. NOTE: This method must be called after a setGeometry method because the size of the argument val is determined by the number of nodes in the mesh. The setGeometry methods are defined in subclasses of PbMesh.
    • isDataDuplicated

      public boolean isDataDuplicated()
      Returns true if mesh's data are duplicated, false otherwise. If the data are not duplicated, the method addValuesSet, addStringsSet, addVecsSet save only the adress of the user data set. In this case, it user's responsibility to check the validity of data during the existence of the PbMesh object.
    • addValuesSet

      public void addValuesSet(int set_index, float[] val, String set_name)
      Adds a set of scalar values. The values are located at nodes so the number of values in a set must be equal to the number of nodes in the mesh.

      Parameters:
      set_index - the index of the new set added.

      val - the array of values. Its size must be the number of nodes.

      set_name - string associated with this set of values. NOTE: This method must be called after a setGeometry method because the size of the argument val is determined by the number of nodes in the mesh. The setGeometry methods are defined in subclasses of PbMesh.
    • removeStringsSet

      public boolean removeStringsSet(int set_index)
      Remove a set of string values.

      Returns:
      false if the scalar set does not exist,

    • getMaxValuesSet

      public float getMaxValuesSet(int set_index)
      Gets the max of a set of scalars.

      Returns:
      false if the scalar set does not exist,

    • getBiggestCellBox

      public PbMesh.CellBox getBiggestCellBox()
      Gets the biggest cell's bounding box, returns also the index of this cell .
    • getVolume

      public float getVolume()
      Gets the volume of the mesh. Returns always 0 for a surface mesh
    • getArea

      public float getArea()
      Gets the area of the mesh. Returns always 0 for a volume mesh
    • getMinVecsSet

      public float getMinVecsSet(int set_index)
      Gets the min module of a set of vectors.

      Returns:
      false if the vector set does not exist,

    • getMaxVecsSet

      public float getMaxVecsSet(int set_index)
      Gets the max module of a set of vectors.

      Returns:
      false if the vector set does not exist,

    • getCell

      public PbCell getCell(int cell_index)
      Gets the cell with index cell_index. Returns NULL if the cell does not exist. Attention! this method returns always the same adress of an internal private cell. This private cell is updated each time getCell is called.
    • getSmallestCellBox

      public PbMesh.CellBox getSmallestCellBox()
      Gets the smallest cell's bounding box, returns also the index of this cell .
    • removeAllVecsSet

      public void removeAllVecsSet()
      Remove all sets of vector values.
    • getCoordinates

      public PbMesh.CoordinatesInfo getCoordinates()
      Get the current coordinates of the nodes of this mesh.

      Parameters:
      xnod - array of x coord

      ynod - array of y coord

      znod - array of z coord

      size_xnod - size of the array xnod

      size_ynod - size of the array ynod

      size_znod - size of the array znod
    • removeAllStringsSet

      public void removeAllStringsSet()
      Remove all sets of strings values.
    • removeVecsSet

      public boolean removeVecsSet(int set_index)
      Remove a set of vector values.

      Returns:
      false if the vector set does not exist,

    • removeAllValuesSet

      public void removeAllValuesSet()
      Remove all sets of scalar values.
    • getNumValuesSet

      public int getNumValuesSet()
      Gets the number of set of scalar values.
    • getNumVecsSet

      public int getNumVecsSet()
      Gets the number of set of vector values.
    • findContainingCell

      public PbMesh.ContainingCell findContainingCell(SbVec3f point, float tolerance, PbCell adjacent_cell)
    • findContainingCell

      public PbMesh.ContainingCell findContainingCell(SbVec3f point, float tolerance)
      Find the cell that contains the point. If the (optional) adjacent cell is given, searching the containing cell starts by the cells around this adjacent one. Returns also the parametric coordinates of the point in the found cell. Parametric coordinates are the coordinates of the point relative to a topological equivalent unit cell. A point is inside a cell if its parametric coordinates range from 0 to 1. However we use a test with a tolerance value : a point is inside the cell if its parametric coordinates p verify -tolerance <= p <= 1+tolerance. Parametric coordinates are useful to interpolate the value in the cell (see PbCell.getValue). Attention! This method returns always the same address of an internal private cell. This private cell is updated each time findContainingCell is called.
    • setCoordinates

      public void setCoordinates(float[] x_nod, float[] y_nod, float[] z_nod)
      Set new node coordinates without modifying the mesh topology. For performance reasons, this method should be called instead of setGeometry when doing a mesh deformation animation.
    • getNumStringsSet

      public int getNumStringsSet()
      Gets the number of set of string values.