Esempio n. 1
0
/*!
	Extracts the neighbours of the specified cell for the given vertex.

	Cells that has only a vertex in common are considered neighbours only
	if there are other cells "connecting" them.

	                  .-----.                   .-----.
	                  |     |                   |     |
	                V | A1  |                 V | A2  |
	            .-----+-----.             .-----+-----.
	            |     |                   |     |     |
	            | B1  |                   | B2  | C2  |
	            .-----.                   .-----.-----.

	For example, A1 and B1 are not neighbours (although they share the
	vertex V), whereas A2 and B2 are neighbours.

	\param id is the id of the cell
	\param vertex is a vertex of the cell
	\param blackList is a list of cells that are excluded from the search
	\result The neighbours of the specified cell for the given vertex.
*/
std::vector<long> Patch::extract_cell_vertex_neighs(const long &id, const int &vertex, const std::vector<long> &blackList) const
{
	std::vector<int> vertexList(1);
	vertexList[0] = vertex;

	return extract_cell_vertex_neighs(id, vertexList, blackList);
}
Esempio n. 2
0
	void Cube::init() {

		std::vector<Vertex> vertexList(8);
		vertexList[0] = Vertex(-1.0, 1.0, 1.0, 1.0);
		vertexList[1] = Vertex(-1.0, -1.0, 1.0, 1.0);
		vertexList[2] = Vertex(1.0, -1.0, 1.0, 1.0);
		vertexList[3] = Vertex(1.0, 1.0, 1.0, 1.0);
		vertexList[4] = Vertex(-1.0, 1.0, -1.0, 1.0);
		vertexList[5] = Vertex(-1.0, -1.0, -1.0, 1.0);
		vertexList[6] = Vertex(1.0, -1.0, -1.0, 1.0);
		vertexList[7] = Vertex(1.0, 1.0, -1.0, 1.0);
		
		setVertexList(vertexList);

		std::vector<GLuint> indexList(24);
		indexList[0] = 0;   indexList[1] = 1;   indexList[2] = 2; 	indexList[3] = 3;
		indexList[4] = 3;   indexList[5] = 2;   indexList[6] = 6; 	indexList[7] = 7;   
		indexList[8] = 7;  indexList[9] = 6;  indexList[10] = 5; 	indexList[11] = 4;  
		indexList[12] = 4;  indexList[13] = 5;  indexList[14] = 1; 	indexList[15] = 0;  
		indexList[16] = 0;  indexList[17] = 3;  indexList[18] = 7; 	indexList[19] = 4; 
		indexList[20] = 1;  indexList[21] = 2;  indexList[22] = 6; 	indexList[23] = 5;  

		setIndexList(indexList);
	}
Esempio n. 3
0
/* Function: phyzxInit
 * Description: Creates and initializes the phyzx object
 * Input: inputModel - Object model information
 *		  phyzxObj - current object structure 
 * Output: None
 */
void phyzxInit(phyzx *phyzxObj)
{
	int numVertices = 0;
	int size = 0;
	point v1, v2, v3;

	numVertices = phyzxObj->model->numvertices + 1;		// Count of the number of vertices in the Model

	phyzxObj->h = gTStep;
	phyzxObj->n = gNStep;
	phyzxObj->alpha = gAlpha;
	phyzxObj->beta = gBeta;
	phyzxObj->delta = gDelta;
	phyzxObj->kWall = gKCol;
	phyzxObj->dWall = gDCol;
	phyzxObj->kSphere = 50.0;
	phyzxObj->dSphere = 0.2;
	phyzxObj->totalMass = 0.0;
	phyzxObj->avgVel = vMake(0.0);

	phyzxObj->velocity = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->extForce = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->stable = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->goal = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->relStableLoc = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->relDeformedLoc = (point *)calloc(numVertices, sizeof(point));
	phyzxObj->mass = (double *)calloc(numVertices, sizeof(double));
	phyzxObj->triAreas = (double *)calloc(phyzxObj->model->numtriangles, sizeof(double));
	phyzxObj->q = (matrix *)calloc(numVertices, sizeof(matrix));
	phyzxObj->qT = (matrix *)calloc(numVertices, sizeof(matrix));

	// Initialise attributes with stable values
	for(int index = STARTFROM; index <= numVertices; index++)
	{
		phyzxObj->stable[index].x = phyzxObj->model->vertices[3*index];
		phyzxObj->stable[index].y = phyzxObj->model->vertices[3*index+1];
		phyzxObj->stable[index].z = phyzxObj->model->vertices[3*index+2];
		phyzxObj->mass[index] = 0.0;//param.MASS;
		phyzxObj->extForce[index] = vMake(0.0, gGravity, 0.0);
		phyzxObj->velocity[index] = vMake(0.01, 0.0, 0.0);
	}
	
	for(unsigned int index = 0; index < phyzxObj->model->numtriangles; index++)
	{
		v1 = vMake(phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[0]], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[0]+1], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[0]+2]);
		v2 = vMake(phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[1]], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[1]+1], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[1]+2]);
		v3 = vMake(phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[2]], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[2]+1], phyzxObj->model->vertices[3*phyzxObj->model->triangles[index].vindices[2]+2]);
		phyzxObj->triAreas[index] = AreaOfTri(v1, v2, v3); 

		(*phyzxObj).surArea += phyzxObj->triAreas[index];
	}
	
	phyzxObj->NBTStruct = glmBuildNeighborStructure(phyzxObj->model);
	phyzxObj->NBVStruct = vertexList(phyzxObj->model, phyzxObj->NBTStruct, 0.05);
	filterNBV(phyzxObj->model, phyzxObj->NBVStruct);
	compMass(phyzxObj->NBTStruct, phyzxObj);

	CalcCM(0, phyzxObj);
	CalcRelLoc(0, phyzxObj);
	CalcAqq(phyzxObj);
	calcTAqq(phyzxObj);
}