void ScalarField::setMaterialGrid(FluidMaterialGrid &matGrid) { FLUIDSIM_ASSERT(matGrid.width == _isize-1 && matGrid.height == _jsize-1 && matGrid.depth == _ksize-1); GridIndex vertices[8]; for (int k = 0; k < _ksize-1; k++) { for (int j = 0; j < _jsize-1; j++) { for (int i = 0; i < _isize-1; i++) { if (matGrid.isCellSolid(i, j, k)) { Grid3d::getGridIndexVertices(i, j, k, vertices); for (int idx = 0; idx < 8; idx++) { _isVertexSolid.set(vertices[idx], true); } } } } } }
GridIndexVector FluidSource::getFluidOrAirCells(FluidMaterialGrid &materialGrid, double dx) { int w = materialGrid.width; int h = materialGrid.height; int d = materialGrid.depth; GridIndexVector cells(w, h, d); if (!isActive()) { return cells; } GridIndexVector overlappingIndices(w, h, d); _getOverlappingCells(overlappingIndices, dx); GridIndex g; for (unsigned int i = 0; i < overlappingIndices.size(); i++) { g = overlappingIndices[i]; if (!materialGrid.isCellSolid(g)) { cells.push_back(g); } } return cells; }