本文整理汇总了C++中trianglegeom::Pointer::resizeTriList方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::resizeTriList方法的具体用法?C++ Pointer::resizeTriList怎么用?C++ Pointer::resizeTriList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trianglegeom::Pointer
的用法示例。
在下文中一共展示了Pointer::resizeTriList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readFile
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void ReadStlFile::readFile()
{
DataContainer::Pointer sm = getDataContainerArray()->getDataContainer(m_SurfaceMeshDataContainerName);
// Open File
FILE* f = fopen(m_StlFilePath.toLatin1().data(), "rb");
if (NULL == f)
{
setErrorCondition(-1003);
notifyErrorMessage(getHumanLabel(), "Error opening STL file", -1003);
return;
}
// Read Header
char h[80];
int32_t triCount = 0;
fread(h, sizeof(int32_t), 20, f);
fread(&triCount, sizeof(int32_t), 1, f);
TriangleGeom::Pointer triangleGeom = sm->getGeometryAs<TriangleGeom>();
triangleGeom->resizeTriList(triCount);
triangleGeom->resizeVertexList(triCount * 3);
float* nodes = triangleGeom->getVertexPointer(0);
int64_t* triangles = triangleGeom->getTriPointer(0);
// Resize the triangle attribute matrix to hold the normals and update the normals pointer
QVector<size_t> tDims(1, triCount);
sm->getAttributeMatrix(getFaceAttributeMatrixName())->resizeAttributeArrays(tDims);
updateFaceInstancePointers();
// Read the triangles
static const size_t k_StlElementCount = 12;
float v[k_StlElementCount];
unsigned short attr;
for (int32_t t = 0; t < triCount; ++t)
{
fread(reinterpret_cast<void*>(v), sizeof(float), k_StlElementCount, f);
fread(reinterpret_cast<void*>(&attr), sizeof(unsigned short), 1, f);
if (attr > 0)
{
std::vector<unsigned char> buffer(attr); // Allocate a buffer for the STL attribute data to be placed into
fread( reinterpret_cast<void*>(&(buffer.front())), attr, 1, f); // Read the bytes into the buffer so that we can skip it.
}
if(v[3] < m_minXcoord) { m_minXcoord = v[3]; }
if(v[3] > m_maxXcoord) { m_maxXcoord = v[3]; }
if(v[4] < m_minYcoord) { m_minYcoord = v[4]; }
if(v[4] > m_maxYcoord) { m_maxYcoord = v[4]; }
if(v[5] < m_minZcoord) { m_minZcoord = v[5]; }
if(v[5] > m_maxZcoord) { m_maxZcoord = v[5]; }
if(v[6] < m_minXcoord) { m_minXcoord = v[6]; }
if(v[6] > m_maxXcoord) { m_maxXcoord = v[6]; }
if(v[7] < m_minYcoord) { m_minYcoord = v[7]; }
if(v[7] > m_maxYcoord) { m_maxYcoord = v[7]; }
if(v[8] < m_minZcoord) { m_minZcoord = v[8]; }
if(v[8] > m_maxZcoord) { m_maxZcoord = v[8]; }
if(v[9] < m_minXcoord) { m_minXcoord = v[9]; }
if(v[9] > m_maxXcoord) { m_maxXcoord = v[9]; }
if(v[10] < m_minYcoord) { m_minYcoord = v[10]; }
if(v[10] > m_maxYcoord) { m_maxYcoord = v[10]; }
if(v[11] < m_minZcoord) { m_minZcoord = v[11]; }
if(v[11] > m_maxZcoord) { m_maxZcoord = v[11]; }
m_FaceNormals[3 * t + 0] = v[0];
m_FaceNormals[3 * t + 1] = v[1];
m_FaceNormals[3 * t + 2] = v[2];
nodes[3 * (3 * t + 0) + 0] = v[3];
nodes[3 * (3 * t + 0) + 1] = v[4];
nodes[3 * (3 * t + 0) + 2] = v[5];
nodes[3 * (3 * t + 1) + 0] = v[6];
nodes[3 * (3 * t + 1) + 1] = v[7];
nodes[3 * (3 * t + 1) + 2] = v[8];
nodes[3 * (3 * t + 2) + 0] = v[9];
nodes[3 * (3 * t + 2) + 1] = v[10];
nodes[3 * (3 * t + 2) + 2] = v[11];
triangles[t * 3] = 3 * t + 0;
triangles[t * 3 + 1] = 3 * t + 1;
triangles[t * 3 + 2] = 3 * t + 2;
}
return;
}