int NodeIndexer::getGlobalIndex(const Facet& facet, int localVertIndex, int axis) const { int index = 3 * facet.getVertIndex(localVertIndex)+ axis; if (constrainIndices.empty()) return index; else { int offset = std::lower_bound(constrainIndices.begin(), constrainIndices.end(), index) - constrainIndices.begin(); if (offset < constrainIndices.size() && index == constrainIndices[offset]) return -1; else if (offset == 0) return index; else return index - offset; } }
void Constrainer::setConstrains(const Vector& origin, const Vector& normal, ConstrainType constrainType){ const float epsilon = 1e-4; Facet *facet = mesh->getFacet(); for (int i = 0; i < mesh->getFacetCount(); i++){ facet->setVertIndexs(i); for (int j = 0; j < mesh->getVertPerFacetCount(); j++){ int index = facet->getVertIndex(j); Vector vert = mesh->getVertex(index); if (fabsf((vert - origin)*normal) < epsilon){ setConstrain(index, constrainType); } } } delete facet; }