void APolygonalMesh::create(unsigned np, unsigned ni, unsigned nf) { createBuffer(np, ni); setNumPoints(np); setNumIndices(ni); m_numPolygons = nf; m_faceCounts->create(nf * 4); m_faceDrifts->create(nf * 4); }
int TriangleMeshFecData::setDataProperty(int property, void const* value, int numElements) { if (property == NUM_INDICES) { return setNumIndices(*((unsigned int const*) value)); } else if (property == FEC_TRIANGLES) { setFecTriangles((double const*) value, numElements); } else { return TriangleMeshData::setDataProperty(property, value, numElements); } return 1; }
RandomMesh::RandomMesh(unsigned numFaces, const Vector3F & center, const float & size, int type) { createBuffer(numFaces * 4, numFaces * 4); Vector3F * p = points(); unsigned * idx = indices(); float rx, ry, rz, r, phi, theta; for(unsigned i = 0; i < numFaces; i++) { idx[i * 3] = i * 3; idx[i * 3 + 1] = i * 3 + 1; idx[i * 3 + 2] = i * 3 + 2; if(type == 0) { rx = (float(rand()%694) / 694.f - 0.5f) * 1.4f; ry = (float(rand()%594) / 594.f - 0.5f) * 1.4f; rz = (float(rand()%794) / 794.f - 0.5f) * 1.4f; } else { phi = ((float)(rand() % 25391)) / 25391.f * 2.f * 3.14f; theta = ((float)(rand() % 24331)) / 24331.f * 3.14f; r = ((float)(rand() % 24091)) / 24091.f * .1f + 0.9f; rx = sin(theta) * cos(phi); ry = sin(theta) * sin(phi); rz = cos(theta); } p[i * 3] = center + Vector3F(rx * size, ry * size, rz * size); rx = float(rand()%294) / 294.f - 0.5f; ry = float(rand()%594) / 594.f - 0.5f; rz = float(rand()%794) / 794.f - 0.5f; p[i * 3 + 1] = p[i * 3] + Vector3F(rx, ry, rz); rx = float(rand()%394) / 394.f - 0.5f; ry = float(rand()%594) / 594.f - 0.5f; rz = float(rand()%794) / 794.f - 0.5f; p[i * 3 + 2] = p[i * 3] + Vector3F(rx, ry, rz); } setNumPoints(numFaces * 3); setNumIndices(numFaces * 3); }
int TriangleMeshData::setDataProperty(int property, void const* value, int numElements) { if (property == NUM_VERTICES) { return setNumVertices(*((unsigned int const*) value)); } else if (property == NUM_INDICES) { return setNumIndices(*((unsigned int const*) value)); } else if (property == X_COORDINATES) { setDataX((double const*) value, numElements); } else if (property == Y_COORDINATES) { setDataY((double const*) value, numElements); } else if (property == Z_COORDINATES) { setDataZ((double const*) value, numElements); } else if (property == COORDINATES) { setVertices((double const*) value, numElements); } else if (property == INDICES) { setIndices((unsigned int const*) value, numElements); } else if (property == VALUES) { setValues((double const*) value, numElements); } else { return Data3D::setDataProperty(property, value, numElements); } return 1; }
void ATriangleMesh::create(unsigned np, unsigned nt) { createBuffer(np, nt * 3); setNumPoints(np); setNumIndices(nt * 3); }
void ATetrahedronMesh::create(unsigned np, unsigned nt) { createBuffer(np, nt * 4); setNumPoints(np); setNumIndices(nt * 4); }