/** * Finds the node nearest to the point with specified coordinates. * @param x the x coordinate. * @param y the y coordinate. * @param z the z coordinate. * @return the nearest node. */ public synchronized Node findNodeNearest(float x, float y, float z) { return findNodeNearest((double)x,(double)y,(double)z); }
public void testAddFindRemove() { java.util.Random random = new java.util.Random(); TetMesh tm = new TetMesh(); //int nadd = 0; //int nremove = 0; for (int niter=0; niter<1000; ++niter) { float x = random.nextFloat(); float y = random.nextFloat(); float z = random.nextFloat(); if (tm.countNodes()<10 || random.nextFloat()>0.5f) { TetMesh.Node node = new TetMesh.Node(x,y,z); boolean ok = tm.addNode(node); assertTrue(ok); tm.validate(); //++nadd; } else if (tm.countNodes()>0) { TetMesh.Node node = tm.findNodeNearest(x,y,z); assertTrue(node!=null); TetMesh.Node nodeSlow = tm.findNodeNearestSlow(x,y,z); assertTrue(node==nodeSlow); tm.removeNode(node); tm.validate(); //++nremove; } } //System.out.println("Nodes added/removed = "+nadd+"/"+nremove); }
/** * Finds the node nearest to the point with specified coordinates. * @param x the x coordinate. * @param y the y coordinate. * @param z the z coordinate. * @return the nearest node. */ public synchronized Node findNodeNearest(float x, float y, float z) { TetMesh.Node meshNode = _mesh.findNodeNearest(x,y,z); return (Node)meshNode.data; }
sw.start(); for (int ifind=0; ifind<nfind; ++ifind) nfast[ifind] = tm.findNodeNearest(x[ifind],y[ifind],z[ifind]); sw.stop(); int sfast = (int)(nfind/sw.time());
for (int i1=0; i1<n1; ++i1) { float x1 = (float)s1.getValue(i1); TetMesh.Node node = _mesh.findNodeNearest(x1,x2,x3); if (g!=null) g[i3][i2][i1] = _f[node.index];
Node nodeNearest = findNodeNearest(x,y,z); if (node==nodeNearest || x!=nodeNearest.x() ||
assertEquals("foo",name); map = tm.getNodePropertyMap(name); n000 = tm.findNodeNearest(0.0f,0.0f,0.0f); n001 = tm.findNodeNearest(0.0f,0.0f,1.0f); n010 = tm.findNodeNearest(0.0f,1.0f,0.0f); n011 = tm.findNodeNearest(0.0f,1.0f,1.0f); n100 = tm.findNodeNearest(1.0f,0.0f,0.0f); n101 = tm.findNodeNearest(1.0f,0.0f,1.0f); n110 = tm.findNodeNearest(1.0f,1.0f,0.0f); n111 = tm.findNodeNearest(1.0f,1.0f,1.0f); assertEquals(0,((Integer)map.get(n000)).intValue()); assertEquals(1,((Integer)map.get(n001)).intValue());
public void testLine() { TetMesh tm = new TetMesh(); int n = 100; for (int i=0; i<n; ++i) { float x = (float)i; float y = 3.14f; float z = 4.13f; TetMesh.Node node = new TetMesh.Node(x,y,z); tm.addNode(node); } tm.validate(); for (int i=0; i<n; ++i) { float x = (float)i; float y = 3.14f; float z = 4.13f; TetMesh.Node node = tm.findNodeNearest(x,y,z); tm.removeNode(node); } tm.validate(); }
data.gz = (float)s.get(3,0); } else { // otherwise, just use value of nearest node TetMesh.Node m = _mesh.findNodeNearest(xg,yg,zg); data.f = f(m); data.gx = 0.0f;