本文整理汇总了C++中UIntArray类的典型用法代码示例。如果您正苦于以下问题:C++ UIntArray类的具体用法?C++ UIntArray怎么用?C++ UIntArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UIntArray类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: addFaceList
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void OutlineEdgeExtractor::addFaceList(const UIntArray& faceList)
{
size_t numFaceListEntries = faceList.size();
size_t i = 0;
while (i < numFaceListEntries)
{
uint numVerticesInFace = faceList[i++];
CVF_ASSERT(numVerticesInFace > 0);
CVF_ASSERT(i + numVerticesInFace <= numFaceListEntries);
const uint* indexPtr = &faceList[i];
addPrimitives(numVerticesInFace, indexPtr, numVerticesInFace);
i += numVerticesInFace;
}
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:20,代码来源:cvfOutlineEdgeExtractor.cpp
示例2: TEST
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(PrimitiveSetIndexedUInt, GetOpenGLPrimitive_FromLineLoop)
{
ref<UIntArray> indices = new UIntArray;
indices->reserve(4);
indices->add(0);
indices->add(1);
indices->add(2);
indices->add(3);
ref<PrimitiveSetIndexedUInt> myPrim = new PrimitiveSetIndexedUInt(PT_LINE_LOOP);
myPrim->setIndices(indices.p());
ASSERT_EQ(4u, myPrim->faceCount());
UIntArray conn;
myPrim->getFaceIndices(0, &conn);
ASSERT_EQ(2u, conn.size());
EXPECT_EQ(0u, conn.get(0));
EXPECT_EQ(1u, conn.get(1));
myPrim->getFaceIndices(1, &conn);
ASSERT_EQ(2u, conn.size());
EXPECT_EQ(1u, conn.get(0));
EXPECT_EQ(2u, conn.get(1));
myPrim->getFaceIndices(2, &conn);
ASSERT_EQ(2u, conn.size());
EXPECT_EQ(2u, conn.get(0));
EXPECT_EQ(3u, conn.get(1));
myPrim->getFaceIndices(3, &conn);
ASSERT_EQ(2u, conn.size());
EXPECT_EQ(3u, conn.get(0));
EXPECT_EQ(0u, conn.get(1));
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:39,代码来源:cvfPrimitiveSetIndexedUInt-Test.cpp
示例3: addTriangleStrip
//--------------------------------------------------------------------------------------------------
/// Add a triangle strip
///
/// Vertex ordering for triangle strips:
/// <PRE>
/// v0 v2 v4 Resulting triangles:
/// *-------*-------* t1: v0, v1, v2
/// \ / \ / \ t2: v2, v1, v3
/// \ / \ / \ t3: v2, v3, v4
/// \ / \ / \ t4: v4, v3, v5
/// *-------*-------*
/// v1 v3 v5 </PRE>
///
/// \remarks The number of entries in the \a indices array must be at least 3.
//--------------------------------------------------------------------------------------------------
void GeometryBuilder::addTriangleStrip(const UIntArray& indices)
{
size_t numIndices = indices.size();
CVF_ASSERT(numIndices >= 3);
size_t numTriangles = numIndices - 2;
CVF_ASSERT(numTriangles >= 1);
size_t i;
for (i = 0; i < numTriangles; i++)
{
if (i % 2 == 0)
{
addTriangle(indices[i], indices[i + 1], indices[i + 2]);
}
else
{
addTriangle(indices[i + 1], indices[i], indices[i + 2]);
}
}
}
开发者ID:akva2,项目名称:ResInsight,代码行数:36,代码来源:cvfGeometryBuilder.cpp
示例4: addFace
//--------------------------------------------------------------------------------------------------
/// Add one face
///
/// The type of primitive added will be determined from the number of indices passed in \a indices
///
/// \remarks Currently, points and lines are not supported. Faces with more than 4 indices will
/// be triangulated using fanning
//--------------------------------------------------------------------------------------------------
void GeometryBuilder::addFace(const UIntArray& indices)
{
size_t numIndices = indices.size();
CVF_ASSERT(numIndices >= 3);
if (numIndices == 3)
{
addTriangle(indices[0], indices[1], indices[2]);
}
else if (numIndices == 4)
{
addQuad(indices[0], indices[1], indices[2], indices[3]);
}
else
{
size_t numTriangles = numIndices - 2;
size_t i;
for (i = 0; i < numTriangles; i++)
{
addTriangle(indices[0], indices[i + 1], indices[i + 2]);
}
}
}
开发者ID:akva2,项目名称:ResInsight,代码行数:31,代码来源:cvfGeometryBuilder.cpp
示例5: TEST
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(MeshEdgeExtractorTest, ThreeQuadsFromUIntArray)
{
// 3------4------5 9------8
// | | | | |
// | | | | |
// 0------1------2 6------7
MeshEdgeExtractor ee;
// Two connected quads
{
UIntArray q;
q.reserve(2*4);
// Observe different winding
q.add(0); q.add(1); q.add(4); q.add(3);
q.add(1); q.add(4); q.add(5); q.add(2);
ee.addPrimitives(4, q);
}
// Single loose quad
{
UIntArray q;
q.reserve(4);
q.add(6); q.add(7); q.add(8); q.add(9);
ee.addPrimitives(4, q);
}
ref<UIntArray> li = ee.lineIndices();
ASSERT_EQ(2*11, li->size());
EXPECT_EQ(0, li->get(0)); EXPECT_EQ(1, li->get(1));
EXPECT_EQ(0, li->get(2)); EXPECT_EQ(3, li->get(3));
EXPECT_EQ(1, li->get(4)); EXPECT_EQ(2, li->get(5));
EXPECT_EQ(1, li->get(6)); EXPECT_EQ(4, li->get(7));
EXPECT_EQ(2, li->get(8)); EXPECT_EQ(5, li->get(9));
EXPECT_EQ(3, li->get(10)); EXPECT_EQ(4, li->get(11));
EXPECT_EQ(4, li->get(12)); EXPECT_EQ(5, li->get(13));
EXPECT_EQ(6, li->get(14)); EXPECT_EQ(7, li->get(15));
EXPECT_EQ(6, li->get(16)); EXPECT_EQ(9, li->get(17));
EXPECT_EQ(7, li->get(18)); EXPECT_EQ(8, li->get(19));
EXPECT_EQ(8, li->get(20)); EXPECT_EQ(9, li->get(21));
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:49,代码来源:cvfMeshEdgeExtractor-Test.cpp
示例6: Array_readLocalData
//.........这里部分代码省略.........
{
UByteArray* array = new UByteArray;
array->reserve(capacity);
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
unsigned int uint_value;
if (fr[0].getUInt(uint_value))
{
++fr;
array->push_back(uint_value);
}
else ++fr;
}
++fr;
return_array = array;
}
else if (strcmp(arrayName,"UShortArray")==0)
{
UShortArray* array = new UShortArray;
array->reserve(capacity);
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
unsigned int uint_value;
if (fr[0].getUInt(uint_value))
{
++fr;
array->push_back(uint_value);
}
else ++fr;
}
++fr;
return_array = array;
}
else if (strcmp(arrayName,"UIntArray")==0)
{
UIntArray* array = new UIntArray;
array->reserve(capacity);
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
unsigned int uint_value;
if (fr[0].getUInt(uint_value))
{
++fr;
array->push_back(uint_value);
}
else ++fr;
}
++fr;
return_array = array;
}
else if (strcmp(arrayName,"UVec4bArray")==0 || strcmp(arrayName,"Vec4ubArray")==0)
{
Vec4ubArray* array = new Vec4ubArray;
array->reserve(capacity);
while (!fr.eof() && fr[0].getNoNestedBrackets()>entry)
{
unsigned int r,g,b,a;
if (fr[0].getUInt(r) &&
fr[1].getUInt(g) &&
fr[2].getUInt(b) &&
fr[3].getUInt(a))
{
fr+=4;
array->push_back(osg::Vec4ub(r,g,b,a));
}
else ++fr;
开发者ID:,项目名称:,代码行数:67,代码来源:
示例7: setFromFaceList
//--------------------------------------------------------------------------------------------------
/// Sets the DrawableGeo object's geometry representation from a face list
///
/// \param faceList Face list
///
/// faceList contains number of items before each face connectivities. E.g. 3 0 1 2 3 2 3 1 3 2 1 3
///
/// \note This method will use more temporary memory than strictly needed in order to optimize
/// performance.
//--------------------------------------------------------------------------------------------------
void DrawableGeo::setFromFaceList(const UIntArray& faceList)
{
m_primitiveSets.clear();
size_t numFaceListEntries = faceList.size();
ref<UIntArray> triangleConnects = new UIntArray;
triangleConnects->reserve(numFaceListEntries*3); // Usually too much, but temporary and will be squeezed if kept.
size_t i = 0;
while (i < numFaceListEntries)
{
uint numConnects = faceList[i++];
CVF_ASSERT(numConnects >= 3);
if (numConnects == 3)
{
triangleConnects->add(faceList[i++]);
triangleConnects->add(faceList[i++]);
triangleConnects->add(faceList[i++]);
}
else
{
size_t j;
for (j = 0; j < numConnects - 2; j++)
{
triangleConnects->add(faceList[i]);
triangleConnects->add(faceList[i + 1 + j]);
triangleConnects->add(faceList[i + 2 + j]);
}
i += numConnects;
}
}
// Check if the largest index used in the triangle connects exceeds short representation
if (triangleConnects->max() < std::numeric_limits<ushort>::max())
{
// Create an USHORT primitive set
size_t arraySize = triangleConnects->size();
ref<UShortArray> shortIndices = new UShortArray;
shortIndices->resize(arraySize);
size_t j;
for (j = 0; j < arraySize; j++)
{
shortIndices->set(j, static_cast<ushort>(triangleConnects->get(j)));
}
ref<PrimitiveSetIndexedUShort> prim = new PrimitiveSetIndexedUShort(PT_TRIANGLES);
prim->setIndices(shortIndices.p());
m_primitiveSets.push_back(prim.p());
}
else
{
// Create a UINT primitive set
ref<PrimitiveSetIndexedUInt> prim = new PrimitiveSetIndexedUInt(PT_TRIANGLES);
triangleConnects->squeeze();
prim->setIndices(triangleConnects.p());
m_primitiveSets.push_back(prim.p());
}
}
开发者ID:akva2,项目名称:ResInsight,代码行数:75,代码来源:cvfDrawableGeo.cpp
示例8: CVF_ASSERT
//--------------------------------------------------------------------------------------------------
/// Intersect the drawable geo with the ray and return the closest intersection point and the face hit
///
/// Returns true if anything was hit.
//--------------------------------------------------------------------------------------------------
bool DrawableGeo::rayIntersect(const Ray& ray, Vec3d* intersectionPoint, uint* faceHit) const
{
CVF_ASSERT(intersectionPoint);
bool anyHits = false;
double minDistSquared = 1.0e300;
cref<Vec3fArray> vertexArr = m_vertexBundle->vertexArray();
size_t numPrimitiveSets = m_primitiveSets.size();
size_t iPrimSet;
int accumulatedFaceCount = 0;
for (iPrimSet = 0; iPrimSet < numPrimitiveSets; iPrimSet++)
{
const PrimitiveSet* primSet = m_primitiveSets.at(iPrimSet);
CVF_TIGHT_ASSERT(primSet);
UIntArray conn;
int numPrimFaces = static_cast<int>(primSet->faceCount());
#pragma omp parallel for private (conn)
for (int i = 0; i < numPrimFaces; i++)
{
bool hitThisFace = false;
Vec3d localIntersect;
primSet->getFaceIndices(static_cast<size_t>(i), &conn);
int numconn = static_cast<int>(conn.size());
CVF_TIGHT_ASSERT(numconn <= 3);
if (numconn == 3)
{
hitThisFace = ray.triangleIntersect(Vec3d(vertexArr->get(conn[0])),
Vec3d(vertexArr->get(conn[1])),
Vec3d(vertexArr->get(conn[2])),
&localIntersect);
}
if (hitThisFace)
{
double distSquared = (ray.origin() - localIntersect).lengthSquared();
#pragma omp critical
{
if (distSquared < minDistSquared)
{
*intersectionPoint = localIntersect;
minDistSquared = distSquared;
if (faceHit)
{
*faceHit = i + accumulatedFaceCount;
}
}
anyHits = true;
}
}
} // End omp parallel for
accumulatedFaceCount += numPrimFaces;
}
return anyHits;
}
开发者ID:akva2,项目名称:ResInsight,代码行数:67,代码来源:cvfDrawableGeo.cpp
示例9: TEST
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(OutlineEdgeExtractorTest, SinglePrimitives)
{
ref<Vec3fArray> va = new Vec3fArray;
va->reserve(4);
va->add(Vec3f(0, 0, 0));
va->add(Vec3f(1, 0, 0));
va->add(Vec3f(1, 1, 0));
va->add(Vec3f(0, 1, 0));
// Point
{
const cvf::uint conn[1] = { 0 };
OutlineEdgeExtractor ee(0, *va);
ee.addPrimitives(1, conn, 1);
UIntArray li = *ee.lineIndices();
ASSERT_EQ(0, li.size());
}
// Line
{
const cvf::uint conn[2] = { 0, 1 };
OutlineEdgeExtractor ee(0, *va);
ee.addPrimitives(2, conn, 2);
UIntArray li = *ee.lineIndices();
ASSERT_EQ(2, li.size());
ASSERT_EQ(0, li[0]);
ASSERT_EQ(1, li[1]);
}
// Tri
{
const cvf::uint conn[3] = { 0, 1, 2 };
OutlineEdgeExtractor ee(0, *va);
ee.addPrimitives(3, conn, 3);
UIntArray li = *ee.lineIndices();
ASSERT_EQ(6, li.size());
ASSERT_EQ(0, li[0]);
ASSERT_EQ(1, li[1]);
ASSERT_EQ(0, li[2]);
ASSERT_EQ(2, li[3]);
ASSERT_EQ(1, li[4]);
ASSERT_EQ(2, li[5]);
}
// Quad
{
const cvf::uint conn[4] = { 0, 1, 2, 3};
OutlineEdgeExtractor ee(0, *va);
ee.addPrimitives(4, conn, 4);
UIntArray li = *ee.lineIndices();
ASSERT_EQ(8, li.size());
ASSERT_EQ(0, li[0]);
ASSERT_EQ(1, li[1]);
ASSERT_EQ(0, li[2]);
ASSERT_EQ(3, li[3]);
ASSERT_EQ(1, li[4]);
ASSERT_EQ(2, li[5]);
ASSERT_EQ(2, li[6]);
ASSERT_EQ(3, li[7]);
}
}
开发者ID:JacobStoren,项目名称:ResInsight,代码行数:68,代码来源:cvfOutlineEdgeExtractor-Test.cpp
注:本文中的UIntArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论