Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/trapezium/attractor/FaceGenerator.java


1   /*
2    * @(#)FaceGenerator.java
3    *
4    * Copyright (c) 1998 by Trapezium Development LLC.  All Rights Reserved.
5    *
6    * The information in this file is the property of Trapezium Development LLC
7    * and may be used only in accordance with the terms of the license granted
8    * by Trapezium.
9    *
10   */
11  package com.trapezium.attractor;
12  
13  import com.trapezium.chisel.*;
14  import com.trapezium.space.*;
15  
16  /** The FaceGenerator generates a set of triangles based on a face from
17   *  the original attractor and its dual.  The triangles are two points from
18   *  the attractor face edge, and the one dual point in the middle of the
19   *  attractor face.
20   *
21   *  @author          Johannes N. Johannsen
22   *  @version         1.0, 8 Oct 1998
23   *
24   *  @since           1.0
25   */
26  
27  public class FaceGenerator {
28      SpaceEntitySet faces;
29      CoordAttractor nearCoords;
30  
31      /** Class constructor.
32       *
33       *  @param faces needed to access the vertex offsets of each face
34       *  @param nearCoords needed to convert an attractor offset into
35       *     its corresponding preserved floater offset
36       */
37      public FaceGenerator( SpaceEntitySet faces, CoordAttractor nearCoords ) {
38          this.faces = faces;
39          this.nearCoords = nearCoords;
40      }
41  
42      int numberFaces;
43      int dualMatch;
44      int[] face;
45  
46      /** Almost a class constructor, FaceGenEnumerator optimization is to
47       *  set values rather than re-create a FaceGenerator.  This method
48       *  accepts those values.
49       */
50      public void loadFaceSet( int[] faceInts, int dualMatch ) {
51          numberFaces = faceInts.length;
52          this.face = faceInts;
53          this.dualMatch = dualMatch;
54      }
55  
56      /** Get the number of faces this will generate */
57      public int getNumberFaces() {
58          return( numberFaces );
59      }
60  
61      /** Get the floater offset values of a particular generated face.
62       *
63       * @param faceOffset which face to generate
64       * @param faceIndex output parameter containing floater offset list of face
65       *
66       * @return true if faceIndex values are valid, false if any faceIndex
67       *    value is -1
68       */
69      public boolean getFace( int faceOffset, int[] faceIndex ) {
70          faceIndex[0] = nearCoords.getPreservedFloaterOffset( face[ faceOffset ] );
71          faceOffset++;
72          if ( faceOffset >= numberFaces ) {
73              faceOffset = 0;
74          }
75          faceIndex[1] = nearCoords.getPreservedFloaterOffset( face[ faceOffset ] );
76          faceIndex[2] = dualMatch;
77          return(( faceIndex[0] != -1 ) && ( faceIndex[1] != -1 ) &&
78                 ( faceIndex[2] != -1 ));
79      }
80  }