void IsotropicParticleMesher::_getSliceMask(int startidx, int endidx, Array3d<bool> &mask) { mask.fill(true); int width, height, depth; double dx; _getSubdividedGridDimensions(&width, &height, &depth, &dx); bool isStartSlice = startidx == 0; bool isEndSlice = endidx == width - 1; if (!isStartSlice) { int idx = 0; for (int k = 0; k < mask.depth; k++) { for (int j = 0; j < mask.height; j++) { mask.set(idx, j, k, false); } } } if (!isEndSlice) { int idx = mask.width - 1; for (int k = 0; k < mask.depth; k++) { for (int j = 0; j < mask.height; j++) { mask.set(idx, j, k, false); } } } }
void TurbulenceField::_getVelocityGrid(MACVelocityField *macfield, Array3d<glm::vec3> &vgrid) { glm::vec3 v; for (int k = 0; k < vgrid.depth; k++) { for (int j = 0; j < vgrid.height; j++) { for (int i = 0; i < vgrid.width; i++) { v = macfield->evaluateVelocityAtCellCenter(i, j, k); vgrid.set(i, j, k, v); } } } }
void ScalarField::getSetScalarFieldValues(Array3d<bool> &isVertexSet) { FLUIDSIM_ASSERT(isVertexSet.width == _isVertexSet.width && isVertexSet.height == _isVertexSet.height && isVertexSet.depth == _isVertexSet.depth); for (int k = 0; k < isVertexSet.depth; k++) { for (int j = 0; j < isVertexSet.height; j++) { for (int i = 0; i < isVertexSet.width; i++) { isVertexSet.set(i, j, k, _isVertexSet(i, j, k)); } } } }
void ScalarField::getWeightField(Array3d<float> &field) { if (!_isWeightFieldEnabled) { return; } FLUIDSIM_ASSERT(field.width == _field.width && field.height == _field.height && field.depth == _field.depth); for (int k = 0; k < field.depth; k++) { for (int j = 0; j < field.height; j++) { for (int i = 0; i < field.width; i++) { field.set(i, j, k, _weightField(i, j, k)); } } } }
void LevelSet::_getLayerCells(int idx, std::vector<GridIndex> &layer, std::vector<GridIndex> &nextLayer, Array3d<int> &layerGrid) { GridIndex ns[6]; GridIndex g, n; for (unsigned int i = 0; i < layer.size(); i++) { g = layer[i]; _getNeighbourGridIndices6(g, ns); for (int j = 0; j < 6; j++) { n = ns[j]; if (Grid3d::isGridIndexInRange(n, _isize, _jsize, _ksize) && layerGrid(n) == -1) { nextLayer.push_back(n); layerGrid.set(n, idx); } } } }
void ScalarField::getScalarField(Array3d<float> &field) { FLUIDSIM_ASSERT(field.width == _field.width && field.height == _field.height && field.depth == _field.depth); double val; for (int k = 0; k < field.depth; k++) { for (int j = 0; j < field.height; j++) { for (int i = 0; i < field.width; i++) { val = _field(i, j, k); if (_isVertexSolid(i, j, k) && val > _surfaceThreshold) { val = _surfaceThreshold; } field.set(i, j, k, (float)val); } } } }