def test_rectangleMesh(): plane = pgf.plane(pgf.var_vec3((0., 0., 0.)), pgf.var_vec3((1., 1., 0.))) box = pgf.box2(pgf.var_vec2((0., 0.)), pgf.var_vec2((15., 12.))) edgeLn = pgf.var_float(1.) rect = pgf.rectangleMesh(plane, box, edgeLn) area = pgf.area(rect) nfaces = pgf.numFaces(rect) nverts = pgf.numVertices(rect) assert 360 == pgf.read(nfaces) assert 208 == pgf.read(nverts) assert tu.equalf(180., pgf.read(area))
def test_meshPlaneClipping(): mesh = loadLargeBunny() half = pgf.var_float(0.5) plane = pgf.plane(pgf.vec3(half, half, half), pgf.vec3(half, half, half)) clipped = pgf.clipMesh(mesh, plane) area = pgf.read(pgf.area(clipped)) nfaces = pgf.read(pgf.numFaces(clipped)) nverts = pgf.read(pgf.numVertices(clipped)) assert tu.equalf(area, 19.79486274) assert nfaces == 59387 assert nverts == 30013
def test_cachedOffsetDataRegression(): # This tests for a regression (lack of) happened while working on PR # 53. pt = pgf.var_vec3((0., 0., 0.)) norm = pgf.var_vec3((0., 0., 1.)) plane = pgf.plane(pt, norm) minpt = pgf.var_vec3((-.5, -.5, 0.)) maxpt = pgf.var_vec3((.5, .5, 0.)) box2 = pgf.box2(pgf.var_vec2((-.5, -.5)), pgf.var_vec2((.5, .5))) box3 = pgf.box3(minpt, maxpt) npts = pgf.var_int(4) cloud = pgf.randomPointsInBox(box3, npts) edgeLen = pgf.var_float(1) rect = pgf.rectangleMesh(plane, box2, edgeLen) distances = pgf.distance(pgf.graft(pgf.vertices(rect)), cloud) pdists = pgf.read(pgf.flatten(distances)) assert len(pdists) == 16
import pygalfunc as pgf import pygalview as pgv pt = pgf.var_vec3((0., 0., 0.)) norm = pgf.var_vec3((0., 0., 1.)) plane = pgf.plane(pt, norm) minpt = pgf.var_vec3((-.5, -.5, 0.)) maxpt = pgf.var_vec3((.5, .5, 0.)) box2 = pgf.box2(pgf.var_vec2((-.5, -.5)), pgf.var_vec2((.5, .5))) box3 = pgf.box3(minpt, maxpt) npts = pgv.slideri32("Point count", 5, 50, 25) cloud = pgf.randomPointsInBox(box3, npts) edgeLen = pgf.var_float(.01) rect = pgf.rectangleMesh(plane, box2, edgeLen) distances = pgf.distance(pgf.graft(pgf.vertices(rect)), cloud) sortedDists = pgf.sort(distances, distances) maxDist = pgf.listItem(sortedDists, pgf.sub(pgf.listLength(sortedDists), pgf.var_int(1))) scheme = pgf.var_vec3([ (0., 0., 1.), (0., 1., 0.), (1., 1., 0.), (1., 0., 0.) ]) colors = pgf.mapValueToColor(maxDist, pgf.var_vec2((.5, 1.2)), scheme) colored = pgf.meshWithVertexColors(rect, colors) circ, *_ = pgf.boundingCircle(cloud)