コード例 #1
0
TriangleMesh IsotropicParticleMesher::_polygonizeAll(FragmentedVector<MarkerParticle> &particles, 
	                                                 FluidMaterialGrid &materialGrid) {
	int subd = _subdivisionLevel;
	int width = _isize*subd;
	int height = _jsize*subd;
	int depth = _ksize*subd;
	double dx = _dx / (double)subd;

	ImplicitSurfaceScalarField field(width + 1, height + 1, depth + 1, dx);

	int origsubd = materialGrid.getSubdivisionLevel();
	materialGrid.setSubdivisionLevel(subd);
	field.setMaterialGrid(materialGrid);
	materialGrid.setSubdivisionLevel(origsubd);

	field.setPointRadius(_particleRadius);

    for (unsigned int i = 0; i < particles.size(); i++) {
        field.addPoint(particles[i].position);
    }

    Polygonizer3d polygonizer(&field);
    polygonizer.polygonizeSurface();

    return polygonizer.getTriangleMesh();
}
コード例 #2
0
void IsotropicParticleMesher::_getSliceMaterialGrid(int startidx, int endidx,
		                       FluidMaterialGrid &materialGrid,
		                       FluidMaterialGrid &sliceMaterialGrid) {

	int origsubd = materialGrid.getSubdivisionLevel();
	materialGrid.setSubdivisionLevel(_subdivisionLevel);
	
	Material m;
	for (int k = 0; k < sliceMaterialGrid.depth; k++) {
		for (int j = 0; j < sliceMaterialGrid.height; j++) {
			for (int i = 0; i < sliceMaterialGrid.width; i++) {
				m = materialGrid(startidx + i, j, k);
				sliceMaterialGrid.set(i, j, k, m);
			}
		}
	}

	materialGrid.setSubdivisionLevel(origsubd);
}