bool JelloMesh::isInterior(const JelloMesh::Spring& s) const { int i1,j1,k1,i2,j2,k2; GetCell(s.m_p1, i1, j1, k1); GetCell(s.m_p2, i2, j2, k2); return isInterior(i1,j1,k1) || isInterior(i2,j2,k2); }
// // s is a spoke pointing OUT from x // void Subdivision::optimize(Vec2& x, Edge *s) { Edge *start_spoke = s; Edge *spoke = s; do { Edge *e = spoke->Lnext(); Edge *t = e->Oprev(); if( isInterior(e) && shouldSwap(x, e) ) swap(e); else { spoke = spoke->Onext(); if( spoke == start_spoke ) break; } } while( true ); // // Now, update all the triangles spoke = start_spoke; do { Edge *e = spoke->Lnext(); Triangle *t = e->Lface(); if( t ) t->update(*this); spoke = spoke->Onext(); } while( spoke != start_spoke ); }
void shapedLattice::findSites(){ sites_.clear(); orientations_.clear(); std::vector<Vector3d> latticePos; std::vector<Vector3d> pointsOrt = simpleLattice_->getLatticePointsOrt(); int numMolPerCell = simpleLattice_->getNumSitesPerCell(); for(int i = beginNx_; i < endNx_; i++) { for(int j = beginNy_; j < endNy_; j++) { for(int k = beginNz_; k < endNz_; k++) { //get the position of the cell sites simpleLattice_->getLatticePointsPos(latticePos, i, j, k); for(int l = 0; l < numMolPerCell; l++) { if (isInterior(latticePos[l])){ Vector3d myPoint = latticePos[l]; Vector3d myOrt = pointsOrt[l]; sites_.push_back(myPoint); orientations_.push_back(myOrt); } } } } } sitesComputed_ = true; }
void JelloMesh::DrawCollisionNormals() { const ParticleGrid& g = m_vparticles; glBegin(GL_LINES); glColor3f(0.0, 1.0, 0.0); for(unsigned int i = 0; i < m_vcollisions.size(); i++) { Intersection intersection = m_vcollisions[i]; if (isInterior(intersection.m_p)) continue; const Particle& pt = GetParticle(g, intersection.m_p); vec3 normal = intersection.m_normal; vec3 end = pt.position + 0.2 * normal; glVertex3f(pt.position[0], pt.position[1], pt.position[2]); glVertex3f(end[0], end[1], end[2]); } glEnd(); }
void JelloMesh::DrawForces() { glBegin(GL_LINES); glColor3f(1.0, 0.0, 0.0); for (int i = 0; i < m_rows+1; i++) { for (int j = 0; j < m_cols+1; j++) { for (int k = 0; k < m_stacks+1; k++) { Particle p = m_vparticles[i][j][k]; if (isInterior(i,j,k)) continue; vec3 normal = p.force.Normalize(); vec3 end = p.position + 0.1 * normal; glVertex3f(p.position[0], p.position[1], p.position[2]); glVertex3f(end[0], end[1], end[2]); } } } glEnd(); }
void JelloMesh::DrawSprings(double a) { const ParticleGrid& g = m_vparticles; glBegin(GL_LINES); for (unsigned int i = 0; i < m_vsprings.size(); i++) { if (!(m_vsprings[i].m_type & m_drawflags)) continue; if (isInterior(m_vsprings[i])) continue; switch (m_vsprings[i].m_type) { case BEND: glColor4f(1.0, 1.0, 0.0, a); break; case STRUCTURAL: glColor4f(1.0, 1.0, 0.0, a); break; case SHEAR: glColor4f(0.0, 1.0, 1.0, a); break; }; vec3 p1 = GetParticle(g, m_vsprings[i].m_p1).position; vec3 p2 = GetParticle(g, m_vsprings[i].m_p2).position; glVertex3f(p1[0], p1[1], p1[2]); glVertex3f(p2[0], p2[1], p2[2]); } glEnd(); }
uint KdTree<Primitive>::Node::topChild() const { assert(isInterior()); return interior.above_child; }
uint KdTree<Primitive>::Node::splitAxis() const { assert(isInterior()); return interior.axis; }
bool JelloMesh::isInterior(int idx) const { int i,j,k; GetCell(idx, i, j, k); return isInterior(i,j,k); }