Class OBJMesh

java.lang.Object
sc.fiji.snt.viewer.OBJMesh

public class OBJMesh extends Object
An OBJMesh stores information about a Wavefront .obj mesh loaded into Viewer3D, with access points to its OBJFile and DrawableVBO
Author:
Tiago Ferreira
  • Field Details

    • SHADING_DEFAULT

      public static final int SHADING_DEFAULT
      Shading mode: jzy3d fixed-function rendering (default).
      See Also:
    • SHADING_SMOOTH

      public static final int SHADING_SMOOTH
      Shading mode: per-fragment Phong lighting with hemispherical ambient (GLSL 1.20).
      See Also:
    • loader

      protected sc.fiji.snt.viewer.OBJMesh.OBJFileLoaderPlus loader
    • drawable

      protected sc.fiji.snt.viewer.OBJMesh.RemountableDrawableVBO drawable
    • unit

      protected String unit
  • Constructor Details

    • OBJMesh

      public OBJMesh(String filePath)
      Instantiates a new wavefront OBJ mesh from a file path/URL.
      Parameters:
      filePath - the absolute path to the .OBJ file to be imported. URL representations accepted
      Throws:
      IllegalArgumentException - if filePath is invalid or file does not contain a compilable mesh
    • OBJMesh

      public OBJMesh(URL url, String meshUnit)
  • Method Details

    • setSymmetryAxis

      public void setSymmetryAxis(int axis)
      Sets the axis defining the symmetry plane of this mesh (e.g., the sagittal plane for most bilateria models), where X=0; Y=1; Z=2;
    • getSymmetryAxis

      public int getSymmetryAxis()
    • getSourceAnnotation

      public BrainAnnotation getSourceAnnotation()
      Returns the BrainAnnotation (atlas compartment) from which this mesh was retrieved, or null if this mesh was loaded from a standalone file.
      Returns:
      the source annotation, or null
    • setSourceAnnotation

      public void setSourceAnnotation(BrainAnnotation annotation)
      Associates this mesh with the BrainAnnotation (atlas compartment) it was retrieved from.
      Parameters:
      annotation - the source annotation
    • setDisplayedHemisphere

      public void setDisplayedHemisphere(String hemiHalf)
      Sets which hemisphere of this mesh is displayed.
      Parameters:
      hemiHalf - "left" (or "l", "1"), "right" (or "r", "2"), or anything else for both hemispheres
    • getDisplayedHemisphere

      public String getDisplayedHemisphere()
      Returns the currently displayed hemisphere: "left", "right", or "both".
      Returns:
      the displayed hemisphere
    • duplicate

      public OBJMesh duplicate()
    • translate

      public void translate(SNTPoint offset)
      Translates the vertices of this mesh by the specified offset. If mesh is displayed, changes may only occur once scene is rebuilt.
      Parameters:
      offset - the translation offset
    • setColor

      public void setColor(String color, double transparencyPercent)
      Script friendly method to assign a color to the mesh.
      Parameters:
      color - the color to render the imported file, either a 1) HTML color codes starting with hash (#), a color preset ("red", "blue", etc.), or integer triples of the form r,g,b and range [0, 255]
      transparencyPercent - the color transparency (in percentage)
    • setColor

      public void setColor(org.scijava.util.ColorRGB color, double transparencyPercent)
      Assigns a color to the mesh.
      Parameters:
      color - the color to render the imported file
      transparencyPercent - the color transparency (in percentage)
    • setTransparency

      public void setTransparency(double transparencyPercent)
      Changes the transparency of this mesh.
      Parameters:
      transparencyPercent - the mesh transparency (in percentage).
    • setBoundingBoxColor

      public void setBoundingBoxColor(org.scijava.util.ColorRGB boundingBoxColor)
      Determines whether the mesh bounding box should be displayed.
      Parameters:
      boundingBoxColor - the color of the mesh bounding box. If null, no bounding box is displayed
    • setBoundingBoxColor

      public void setBoundingBoxColor(String boundingBoxColor)
      Determines whether the mesh bounding box should be displayed.
      Parameters:
      boundingBoxColor - the color of the mesh bounding box, either a 1) HTML color codes starting with hash (#), a color preset ("red", "blue", etc.), or integer triples of the form r,g,b and range [0, 255]. If null, or if string does not encode a valid color, no bounding box is displayed
    • getBoundingBox

      public BoundingBox getBoundingBox(String hemiHalf)
      Gets the minimum bounding box of this mesh.
      Parameters:
      hemiHalf - either "left", "l", "right", "r" otherwise bounding box is retrieved for both hemi-halves, i.e., the full mesh. It is ignored if a hemisphere was already specified in the constructor.
      Returns:
      the minimum bounding box
    • getLabel

      @Deprecated public String getLabel()
      Deprecated.
      use label instead
    • label

      public String label()
      Gets this mesh label.
    • setLabel

      public void setLabel(String label)
      Sets the label for this mesh.
      Parameters:
      label - the label to set
    • setVolume

      public void setVolume(double volume)
      Sets the volume of this mesh.
      Parameters:
      volume - the volume to set
    • getVolume

      public double getVolume()
      Gets the volume of this mesh.
      Returns:
      the mesh volume
    • getVertices

      public Collection<? extends SNTPoint> getVertices()
      Returns the mesh vertices.
      Returns:
      the mesh vertices as SNTPoints
    • getVertices

      public Collection<? extends SNTPoint> getVertices(String hemihalf)
      Returns the mesh vertices.
      Parameters:
      hemihalf - either "left", "l", "right", "r" otherwise centroid is retrieved for both hemi-halves, i.e., the full mesh
      Returns:
      the mesh vertices as SNTPoints
    • getCentroid

      public SNTPoint getCentroid(String hemihalf)
      Returns the spatial centroid of the specified (hemi)mesh.
      Parameters:
      hemihalf - either "left", "l", "right", "r", otherwise centroid is retrieved for both hemi-halves, i.e., the full mesh
      Returns:
      the SNT point defining the (X,Y,Z) center of the (hemi)mesh.
    • getPrincipalAxes

      public PCAnalyzer.PrincipalAxis[] getPrincipalAxes(String hemiHalf)
      Computes the principal axes of the mesh using Principal Component Analysis (PCA). The principal axes represent the directions of maximum, medium, and minimum variance in the mesh geometry, providing insight into the overall shape orientation of this mesh.
      Parameters:
      hemiHalf - either "left", "l", "right", "r", otherwise principal axes are computed for both hemi-halves, i.e., the full mesh
      Returns:
      array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
    • computePrincipalAxes

      public PCAnalyzer.PrincipalAxis[] computePrincipalAxes(String hemiHalf)
      Computes the principal axes of this mesh using the new PCAnalyzer. This method replaces the deprecated getPrincipalAxes(String) method.
      Parameters:
      hemiHalf - either "left", "l", "right", "r", otherwise principal axes are computed for both hemi-halves, i.e., the full mesh
      Returns:
      array of three PrincipalAxis objects ordered by decreasing variance (primary, secondary, tertiary), or null if computation fails
    • getLocalDirection

      public double[] getLocalDirection(SNTPoint point, String hemiHalf, int neighborCount)
      Computes the local direction of the mesh at a specific point using nearest neighbor analysis. This method finds the dominant direction of mesh curvature in the local neighborhood of the specified point, which is useful for analyzing how structures align with curved anatomical surfaces.
      Parameters:
      point - the point at which to compute the local mesh direction
      hemiHalf - either "left", "l", "right", "r", otherwise analysis is performed on both hemi-halves, i.e., the full mesh
      neighborCount - the number of nearest mesh vertices to use for local analysis (default: 20)
      Returns:
      the local mesh direction as a normalized vector, or null if computation fails
    • getAngleWithLocalDirection

      public double getAngleWithLocalDirection(SNTPoint point, double[] direction, String hemiHalf, int neighborCount)
      Computes the angle between a direction vector and the local mesh direction at a point. This is useful for e.g., analyzing how neuronal processes align with the local curvature of surfaces (neuropil meshes).
      Parameters:
      point - the point at which to compute the local mesh direction
      direction - the normalized vector for which the angle will be computed
      hemiHalf - either "left", "l", "right", "r", otherwise analysis is performed on both hemi-halves, i.e., the full mesh
      neighborCount - the number of nearest mesh vertices to use for local analysis
      Returns:
      the acute angle in degrees (0-90°) between the direction vector and local mesh direction, or NaN if computation fails
    • getObj

      public org.jzy3d.io.obj.OBJFile getObj()
      Returns the OBJFile associated with this mesh
      Returns:
      the OBJFile
    • getDrawable

      public org.jzy3d.plot3d.primitives.vbo.drawable.DrawableVBO getDrawable()
      Returns the DrawableVBO associated with this mesh
      Returns:
      the DrawableVBO