void Lattice::assignModelPointsToLatticeCells(Vector2d &modelPoints) { mp = &modelPoints; modelPointIndex.resize(modelPoints.size()); for (size_t model = 0; model < modelPoints.size(); ++model) { modelPointIndex[model].resize(modelPoints[model].size()); for (size_t point = 0; point < modelPoints[model].size(); ++point) { gmtl::Vec3f distToMin; for (int i = 0; i < 3; ++i) { // if a point lies outside of the lattice minimum correct the // point to be a bit larger than the lattice minimum. if ((modelPoints[model][point][i]) <= lastCellPoints[0][0][0][i]) modelPoints[model][point][i] = lastCellPoints[0][0][0][i] + epsilon; // if a point lies outside of the lattice maximum correct // the point to be a bit smaller than the lattice maximum. else if ((modelPoints[model][point][i]) >= lastCellPoints[cellDivisions[0]] [cellDivisions[1]] [cellDivisions[2]][i]) modelPoints[model][point][i] = lastCellPoints[cellDivisions[0]] [cellDivisions[1]] [cellDivisions[2]][i] - epsilon; } // get distance to lattice origin distToMin = getDistancePerAxis(modelPoints[model][point], lastCellPoints[0][0][0]); for (int i = 0; i < 3; ++i) { assert(distToMin[i] >= 0.0f); // calculate the index for each model point in each dimension // get index regarding the lattice subdivisions modelPointIndex[model][point][i] = floor(distToMin[i] / latticeDividedLength[i]); if (modelPointIndex[model][point][i] >= latticeDivisions[i]) { cout << "index " << modelPointIndex[model][point][i]; cout << " >= division " << latticeDivisions[i] << endl; } assert(modelPointIndex[model][point][i] < latticeDivisions[i]); } } } }
/// Gets a list of space-delimited and/or comma-delimited vectors from the underlying string value void XMLAttrib::get_vector_value(Vector2d& v) { // indicate this attribute has been processed processed = true; VectorNd w = VectorNd::parse(value); if (w.size() != v.size()) throw MissizeException(); v = Vector2d(w[0], w[1]); }
void Lattice::executeFFD(Vector2d &modelPointsSavepoint, Vector2d &modelPoints) { gmtl::Vec3f stu; for (size_t model = 0; model < modelPoints.size(); ++model) { for (size_t point = 0; point < modelPoints[model].size(); ++point) { stu = modelPointsSavepoint[model][point]; transformStuRelative(stu, modelPointIndex[model][point]); getLatticeRelativeControlPoints( modelPointIndex[model][point], controlPoints); stu = Bezier::calculateBernstein3d(stu, controlPoints, dim); transformStuAbsolute(stu, modelPointIndex[model][point]); modelPoints[model][point] = stu; } } }