_nmin = null; _dmin = 0.0; _deadTris = new TriList(); _nnodeListeners = 0; _ntriListeners = 0;
if (tri!=null) { mark(tri); nabors.add(tri); Node n0 = tri._n0; Node n1 = tri._n1;
public double accumulateAreas( double xp, double yp, TriMesh mesh, TriMesh.NodeList nodeList, TriMesh.TriList triList) { clear(); int ntri = triList.ntri(); TriMesh.Tri[] tris = triList.tris(); for (int itri=0; itri<ntri; ++itri) { TriMesh.Tri tri = tris[itri]; TriMesh.Node na = tri.nodeA(); TriMesh.Node nb = tri.nodeB(); TriMesh.Node nc = tri.nodeC(); double xa = na.xp(), ya = na.yp(); double xb = nb.xp(), yb = nb.yp(); double xc = nc.xp(), yc = nc.yp(); Geometry.centerCircle(xp,yp,xb,yb,xc,yc,_ca); Geometry.centerCircle(xp,yp,xc,yc,xa,ya,_cb); Geometry.centerCircle(xp,yp,xa,ya,xb,yb,_cc); Geometry.centerCircle(xa,ya,xb,yb,xc,yc,_ct); double aa = area(_cb,_cc,_ct); double ab = area(_cc,_ca,_ct); double ac = area(_ca,_cb,_ct); accumulate(na,aa); accumulate(nb,ab); accumulate(nc,ac); } return sum(); } private double[] _ca = new double[2]; // circumcenter of fake tri pbc
private void processTris( double xp, double yp, TriMesh mesh, TriMesh.TriList triList) { _edgeList.clear(); int ntri = triList.ntri(); TriMesh.Tri[] tris = triList.tris(); for (int itri=0; itri<ntri; ++itri) { TriMesh.Tri tri = tris[itri]; TriMesh.Tri ta = tri.triA(); TriMesh.Tri tb = tri.triB(); TriMesh.Tri tc = tri.triC(); TriMesh.Node na = tri.nodeA(); TriMesh.Node nb = tri.nodeB(); TriMesh.Node nc = tri.nodeC(); tri.centerCircle(_xy); double xt = _xy[0]-xp, yt = _xy[1]-yp; processTriNabor(xp,yp,xt,yt,mesh,ta,nb,nc); processTriNabor(xp,yp,xt,yt,mesh,tb,nc,na); processTriNabor(xp,yp,xt,yt,mesh,tc,na,nb); } } private void processTriNabor(
/** * Constructs an interpolator with specified method and samples. * Coordinates for each sample must be unique. * <p> * This constructor is provided primarily for testing. * The default Hale-Liang method is accurate and fast. * @param method the implementation method. * @param f array of sample values f(x1,x2). * @param x1 array of sample x1 coordinates. * @param x2 array of sample x2 coordinates. */ public SibsonInterpolator2( Method method, float[] f, float[] x1, float[] x2) { makeMesh(f,x1,x2); _nodeList = new TriMesh.NodeList(); _triList = new TriMesh.TriList(); if (method==Method.WATSON_SAMBRIDGE) { _va = new WatsonSambridge(); } else if (method==Method.BRAUN_SAMBRIDGE) { _va = new BraunSambridge(); } else if (method==Method.HALE_LIANG) { _va = new HaleLiang(); } }
/** * Appends the tri nabors of the specified edge to the specified list. * @param edge the edge for which to get nabors. * @param nabors the list to which nabors are appended. */ public synchronized void getTriNabors(Edge edge, TriList nabors) { Tri triLeft = edge.triLeft(); Tri triRight = edge.triRight(); if (triLeft==null && triRight==null) { Node na = edge.nodeA(); Node nb = edge.nodeB(); edge = findEdge(na,nb); triLeft = edge.triLeft(); triRight = edge.triRight(); } if (triLeft!=null) nabors.add(triLeft); if (triRight!=null) nabors.add(triRight); }
/** * Returns a new tri, possibly one resurrected from the dead. * Resurrection reduces the need for garbage collection of dead tris. */ private Tri makeTri(Node n0, Node n1, Node n2) { ++_ntri; int ndead = _deadTris.ntri(); if (ndead==0) { _troot = new Tri(n0,n1,n2); } else { _troot = _deadTris.remove(ndead-1); _troot.init(n0,n1,n2); } if (_ntriListeners>0) fireTriAdded(_troot); return _troot; }
private void addTri(double xp, double yp, TriMesh.Tri tri) { _mesh.mark(tri); _triList.add(tri); addNode(tri.nodeA()); addNode(tri.nodeB()); addNode(tri.nodeC()); TriMesh.Tri ta = tri.triA(); TriMesh.Tri tb = tri.triB(); TriMesh.Tri tc = tri.triC(); if (needTri(xp,yp,ta)) addTri(xp,yp,ta); if (needTri(xp,yp,tb)) addTri(xp,yp,tb); if (needTri(xp,yp,tc)) addTri(xp,yp,tc); } private void addNode(TriMesh.Node node) {
private boolean getNaturalNabors(float x, float y) { _mesh.clearNodeMarks(); _mesh.clearTriMarks(); _nodeList.clear(); _triList.clear(); TriMesh.PointLocation pl = _mesh.locatePoint(x,y); if (pl.isOutside()) return false; addTri(x,y,pl.tri()); return true; } private void addTri(double xp, double yp, TriMesh.Tri tri) {
/** * Kills a tri and, if there is room, buries it in the graveyard, * from where it may be resurrected later. */ private void killTri(Tri tri) { --_ntri; fireTriRemoved(tri); int ndead = _deadTris.ntri(); if (ndead<256) { _deadTris.add(tri); } // We assume that killTri is called only within contexts in // which _troot is updated to point to a live tri in the mesh. // Therefore, we do not update _troot here, when _troot==tri. }