UnityMol  0.9.6-875
UnityMol viewer / In developement
AdjacencySets.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using System.Collections;
3 using System.Collections.Generic;
4 
5 public class AdjacencySets {
6  private HashSet<int>[] vertexArray;
7  private static int NBVERT = 65000;
8 
9  /*
10  public AdjacencySets() {
11  vertexArray = new HashSet<int>[NBVERT];
12  for(int i=0; i<NBVERT; i++) {
13  vertexArray[i] = new HashSet<int>();
14  }
15  }
16  */
17 
18  public AdjacencySets(int nb) {
19  NBVERT = nb;
20  vertexArray = new HashSet<int>[NBVERT];
21  for(int i=0; i<NBVERT; i++) {
22  vertexArray[i] = new HashSet<int>();
23  }
24  }
25 
26  public HashSet<int> GetAdjacencySet(int vIndex) {
27  return vertexArray[vIndex];
28  }
29 
30 
31  public void AddAllTriangles(int[] triangles) {
32  for(int i=0; i<triangles.Length; i+=3) {
33  // Neighbors of vertex i
34  vertexArray[triangles[i]].Add(triangles[i+1]);
35  vertexArray[triangles[i]].Add(triangles[i+2]);
36 
37  // Neighbors of vertex i+1
38  vertexArray[triangles[i+1]].Add(triangles[i]);
39  vertexArray[triangles[i+1]].Add(triangles[i+2]);
40 
41  // Neighbors of vertex i+2
42  vertexArray[triangles[i+2]].Add(triangles[i]);
43  vertexArray[triangles[i+2]].Add(triangles[i+1]);
44  }
45  }
46 
47 
48 
49  /*
50  public void AddLastNTriangles(int nbTriangles, List<int> triangles) {
51  int firstIndex = triangles.Count - 3*nbTriangles;
52  for(int i=firstIndex; i<triangles.Count; i+=3) {
53  // Neighbors of vertex i
54  vertexArray[i].Add(triangles[i+1]);
55  vertexArray[i].Add(triangles[i+2]);
56 
57  // Neighbors of vertex i+1
58  vertexArray[i+1].Add(triangles[i]);
59  vertexArray[i+1].Add(triangles[i+2]);
60 
61  // Neighbors of vertex i+1
62  vertexArray[i+2].Add(triangles[i]);
63  vertexArray[i+2].Add(triangles[i+1]);
64  }
65  }
66  */
67 }
AdjacencySets(int nb)
void AddAllTriangles(int[] triangles)
static int NBVERT
Definition: AdjacencySets.cs:7
HashSet< int >[] vertexArray
Definition: AdjacencySets.cs:6
HashSet< int > GetAdjacencySet(int vIndex)