1 package org.catacomb.numeric.mesh;
2
3 import org.catacomb.interlish.structure.Mesh;
4 import org.catacomb.numeric.difnet.NetFactory;
5 import org.catacomb.numeric.difnet.NetStructure;
6
7
8
9 public class DifMesh implements Mesh {
10
11 MeshPoint[] points;
12
13 int[] indexTable;
14
15
16 public void setPoints(MeshPoint[] dmpa) {
17 points = dmpa;
18 }
19
20
21 public MeshPoint[] getPoints() {
22 return points;
23 }
24
25 public MeshPoint getPoint(int ipt) {
26 return points[ipt];
27 }
28
29
30 public int[] getRemeshMap() {
31 if (indexTable == null) {
32 makeIndexTable();
33 }
34 return indexTable;
35 }
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 private void makeIndexTable() {
54 int maxp = -1;
55 int np = points.length;
56 int[] bufpa = new int[np];
57 for (int i = 0; i < np; i++) {
58 int isrc = points[i].getIDIndex();
59 if (isrc >= 0 && isrc < np) {
60 bufpa[isrc] = i;
61 if (isrc > maxp) {
62 maxp = isrc;
63 }
64 }
65 }
66 if (maxp < 0) {
67 indexTable = new int[0];
68 } else {
69 indexTable = new int[maxp+1];
70 for (int i = 0; i < maxp; i++) {
71 indexTable[i] = bufpa[i];
72 }
73 }
74 }
75
76
77
78
79
80 public void rediscretize(double disqrtr, int nmax) {
81
82 MeshPoint[] mpa = Discretizer.discretize(points, disqrtr, nmax);
83
84 points = mpa;
85 indexTable = null;
86 }
87
88
89 public int getSize() {
90 return points.length;
91 }
92
93
94
95 public NetStructure makeNetStructure(NetFactory nf) {
96
97 NetStructure netStructure = MeshNetConverter.meshToNet(points, nf);
98 return netStructure;
99 }
100
101 }