001/** 002 * TriangleVertData -- An object that packages together information about triangle 003 * vertices. 004 * 005 * Copyright (C) 2015, by Joseph A. Huwaldt. All rights reserved. 006 * 007 * This library is free software; you can redistribute it and/or modify it under the terms 008 * of the GNU Lesser General Public License as published by the Free Software Foundation; 009 * either version 2.1 of the License, or (at your option) any later version. 010 * 011 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 013 * PARTICULAR PURPOSE. See the GNU Library General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public License along with 016 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - 017 * Suite 330, Boston, MA 02111-1307, USA. Or visit: http://www.gnu.org/licenses/lgpl.html 018 */ 019package geomss.geom; 020 021import jahuwaldt.js.param.Parameter; 022import java.util.List; 023import javax.measure.quantity.Area; 024import javax.measure.quantity.Dimensionless; 025import javolution.context.ObjectFactory; 026 027/** 028 * An simple container that packages together information about a list of 029 * triangles. In particular, it stores a list of non-repeating (unique) vertices 030 * and indexes into that list for each triangle, the area of each triangle, 031 * and the normal vector for each triangle. 032 * 033 * <p> Modified by: Joseph A. Huwaldt </p> 034 * 035 * @author Joseph A. Huwaldt, Date: August 28, 2015 036 * @version September 11, 2015 037 */ 038public class TriangleVertData { 039 040 /** 041 * The list of unique vertices in this triangle data. 042 */ 043 public PointString<? extends GeomPoint> vertices; 044 045 /** 046 * The number of triangles in the list. 047 */ 048 public int numTris; 049 050 /** 051 * The array of indexes into the "vertices" list for the vertices of each triangle. 052 * Each set of indices is represented by 3 consecutive integer indexes in a 053 * counter-clockwise winding. 054 */ 055 public int[] tris; 056 057 /** 058 * The surface area of one side of each triangle. 059 * The area is always positive, but can be zero. 060 */ 061 public List<Parameter<Area>> areas; 062 063 /** 064 * The surface normal vector for each triangle. 065 * If a triangle is degenerate (zero area), then the 066 * normal vector will have zero length. 067 */ 068 public List<GeomVector<Dimensionless>> normals; 069 070 /** 071 * Construct a new TriangleVertData structure. 072 * 073 * @return A new TriangleVertData structure. 074 */ 075 public static TriangleVertData newInstance() { 076 return FACTORY.object(); 077 } 078 079 /////////////////////// 080 // Factory creation. // 081 /////////////////////// 082 private TriangleVertData() { } 083 084 private static final ObjectFactory<TriangleVertData> FACTORY = new ObjectFactory<TriangleVertData>() { 085 @Override 086 protected TriangleVertData create() { 087 return new TriangleVertData(); 088 } 089 090 @Override 091 protected void cleanup(TriangleVertData obj) { 092 obj.vertices = null; 093 obj.tris = null; 094 obj.areas = null; 095 } 096 }; 097 098}