CaptainSpaceCat

eBeam - Mesh

Jul 13th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. /*
  2.  * This support class contains imformation
  3.  * on the mesh that is used to output
  4.  * an STL file.
  5.  * */
  6.  
  7. public class Mesh {
  8.  
  9.   float[][] vertices;
  10.   int[] triangles;
  11.  
  12.   public Mesh() {
  13.   }
  14.  
  15.   public Mesh(float[][] v, int[] t) {
  16.     vertices = v;
  17.     triangles = t;
  18.   }
  19.  
  20.   public void setVertice(int index, int dimension, float value) {
  21.     vertices[index][dimension] = value;
  22.   }
  23.  
  24.   public float getVertice(int index, int dimension) {
  25.     return vertices[index][dimension];
  26.   }
  27.  
  28.   public int getNumVertices() {
  29.     return vertices.length;
  30.   }
  31.  
  32.   public int getNumTriangles() {
  33.     return triangles.length;
  34.   }
  35.  
  36.   public float[][] getFacetFromIndex(int index) {
  37.     float[][] facet = new float[3][3];
  38.     for (int i = 0; i < 3; i++) {
  39.       for (int n = 0; n < 3; n++) {
  40.         facet[i][n] = vertices[triangles[i+index]][n];
  41.       }
  42.     }
  43.     return facet;
  44.   }
  45.  
  46. }
Add Comment
Please, Sign In to add comment