Beispiel #1
0
void BccLattice::addTetrahedronsAllNodeVisited(unsigned * vOctahedron)
{
    unsigned code;
    bool allVisited;
    int i, j;
    for(i=0; i<4; i++) {
        allVisited = 1;
        for(j=0; j<4; j++) {
            code = vOctahedron[OctahedronToTetrahedronVetex[i][j]];
            sdb::CellValue * found = findGrid(code);
            if(!found) {
                // std::cout<<" cannot find grid "<<nodeCenter(code)<<" ";
                allVisited = 0;
                continue;
            }
            if(!found->visited) allVisited = 0;
        }
        
        if(allVisited) {
            Tetrahedron * t = &m_tetrahedrons[m_numTetrahedrons];
            for(j=0; j<4; j++) {
                code = vOctahedron[OctahedronToTetrahedronVetex[i][j]];
                t->v[j] = code;
            }
            m_numTetrahedrons++;
        }
    }
}
Beispiel #2
0
void BccLattice::drawTetrahedrons(unsigned * anchored)
{
    glBegin(GL_TRIANGLES);
    unsigned i, j;
    Vector3F q;
	unsigned a[4];
    for(i=0; i< m_numTetrahedrons; i++) {
        Tetrahedron * tet = &m_tetrahedrons[i];
		for(j=0; j<4; j++) {
			sdb::CellValue * found = findGrid(tet->v[j]);
			a[j] = anchored[found->index];
		}
		
        for(j=0; j< 12; j++) {
            q = nodeCenter(tet->v[TetrahedronToTriangleVertex[j]]);
			
			if(a[TetrahedronToTriangleVertex[j]])
				glColor3f(.993f, .14f, .04f);
			else
				glColor3f(.03f, .14f, .44f);
            glVertex3fv((GLfloat *)&q);
        }
    }
    glEnd();
}
Beispiel #3
0
static void
doNeighbor (Grid* grid, int i, int j, node_list* nodes)
{
  cell*         cellp = findGrid (grid, i, j);
  node_list*    qs;
  Agnode_t*     p;
  Agnode_t*     q;
  double        xdelta, ydelta;
  double        dist2;

  if (cellp) {
    if (Verbose >= 3)
      fprintf (stderr, "  doNeighbor (%d,%d) : %d\n", i, j, gLength (cellp));
    for (; nodes != 0; nodes = nodes->next) {
      p = nodes->node;
      for (qs = cellp->nodes; qs != 0; qs = qs->next) {
        q = qs->node;
        xdelta = q->u.pos[0] - p->u.pos[0];
        ydelta = q->u.pos[1] - p->u.pos[1];
        dist2 = xdelta*xdelta + ydelta*ydelta;
        if (dist2 < Cell2)
          doRep (p, q, xdelta, ydelta, dist2);
      }
    }
  }
}
Beispiel #4
0
void BccLattice::extractIndices(unsigned * dst)
{
    unsigned i, j, k = 0;
	for(i=0; i< numTetrahedrons(); i++) {
        Tetrahedron * tet = &m_tetrahedrons[i];
        for(j=0; j< 4; j++) {
            sdb::CellValue * found = findGrid(tet->v[j]);
            dst[k] = found->index;
            k++;
        }
    }
}
Beispiel #5
0
void BccLattice::addAnchors(unsigned * anchored, KdIntersection * tree)
{
	Vector3F q[4];
	unsigned j, i=0;
	for(; i< numTetrahedrons(); i++) {
        Tetrahedron * tet = &m_tetrahedrons[i];
        for(j=0; j< 4; j++)
            q[j] = nodeCenter(tet->v[j]); 
        
		if(!tree->intersectTetrahedron(q)) continue;
		
		for(j=0; j< 4; j++) {
			sdb::CellValue * found = findGrid(tet->v[j]);
			anchored[found->index] = 1;
		}
    }
}
Beispiel #6
0
void BccLattice::logTetrahedronMesh()
{
    Vector3F p;
    BaseLog log("./tetmesh.txt");
    
    log.write(boost::str(boost::format("static const unsigned TetraNumVertices = %1%;\n") % numVertices()));
	log.write(boost::str(boost::format("static const float TetraP[%1%][3] = {\n") % numVertices()));
	sdb::CellHash * latticeNode = cells();
    
	latticeNode->begin();
	while(!latticeNode->end()) {
	    if(latticeNode->value()->visited) {
	        p = nodeCenter(latticeNode->key());
	        log.write(boost::str(boost::format("{%1%f,%2%f,%3%f}") % p.x % p.y % p.z));
	        if(latticeNode->value()->index < numVertices()-1) log.write(",\n");
	        else log.write("\n");
	    }
	    latticeNode->next();
	}
	log.write("};\n");
	log.write(boost::str(boost::format("static const unsigned TetraNumTetrahedrons = %1%;\n") % numTetrahedrons()));
	log.write(boost::str(boost::format("static const unsigned TetraIndices[%1%][4] = {\n") % numTetrahedrons()));
	
	unsigned i, j;
	unsigned v[4];
	for(i=0; i< numTetrahedrons(); i++) {
        Tetrahedron * tet = &m_tetrahedrons[i];
        for(j=0; j< 4; j++) {
            sdb::CellValue * found = findGrid(tet->v[j]);
            v[j] = found->index;
        }
        log.write(boost::str(boost::format("{%1%,%2%,%3%,%4%}") % v[0] % v[1] % v[2] % v[3]));
	    if(i < numTetrahedrons()-1) log.write(",\n");
	    else log.write("\n");
    }
    
	log.write("};\n");
}
Beispiel #7
0
void BccLattice::touch4Tetrahedrons(unsigned * vOctahedron, KdIntersection * tree)
{
    unsigned code[4];
    Vector3F tet[4];
    int i, j;
    for(i=0; i<4; i++) {
        for(j=0; j<4; j++) {
            code[j] = vOctahedron[OctahedronToTetrahedronVetex[i][j]];
            tet[j] = nodeCenter(code[j]);
        }
        if(tree->intersectTetrahedron(tet)) {
            for(j=0; j<4; j++) {
                code[j] = vOctahedron[OctahedronToTetrahedronVetex[i][j]];
                sdb::CellValue * found = findGrid(code[j]);
                if(!found) {
                    std::cout<<" cannot find grid "<<nodeCenter(code[j])<<" ";
                    break;
                }
                found->visited = 1;
            }
        }
    }
}