本文整理汇总了C++中IndexList类的典型用法代码示例。如果您正苦于以下问题:C++ IndexList类的具体用法?C++ IndexList怎么用?C++ IndexList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IndexList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createBlockIndices
void CpuClipmapRenderer::createBlockIndices( GeometryClipmapLevel& level, const Rectangle2i& blockRect, int levelSampleCount, IndexList& indices )
{
// todo: this needs rework..
if( blockRect.isEmpty() )
{
return;
}
assert( blockRect._x0 >= 0 );
assert( blockRect._y0 >= 0 );
assert( blockRect._x1 > blockRect._x0 );
assert( blockRect._y1 > blockRect._y0 );
assert( blockRect._x0 < levelSampleCount );
assert( blockRect._y0 < levelSampleCount );
assert( blockRect._x1 < levelSampleCount );
assert( blockRect._y1 < levelSampleCount );
for( int y = blockRect._y0; y < blockRect._y1; ++y )
{
assert( y + 1 < levelSampleCount );
const int row0 = ( level.blockOrigin[ 1 ] + y ) % levelSampleCount;
const int row1 = ( level.blockOrigin[ 1 ] + y + 1 ) % levelSampleCount;
for( int x = blockRect._x0; x < blockRect._x1; ++x )
{
assert( x + 1 < levelSampleCount );
const int col0 = ( level.blockOrigin[ 0 ] + x ) % levelSampleCount;
const int col1 = ( level.blockOrigin[ 0 ] + x + 1 ) % levelSampleCount;
const int idx0 = row0 * levelSampleCount + col0;
const int idx1 = row0 * levelSampleCount + col1;
const int idx2 = row1 * levelSampleCount + col0;
const int idx3 = row1 * levelSampleCount + col1;
assert( idx0 < 65536 );
assert( idx1 < 65536 );
assert( idx2 < 65536 );
assert( idx3 < 65536 );
indices.push_back( idx0 );
indices.push_back( idx2 );
indices.push_back( idx1 );
indices.push_back( idx1 );
indices.push_back( idx2 );
indices.push_back( idx3 );
}
}
}
示例2: equivalentTrianglesIndexOfstripsIndex
IndexList GLC_Mesh::equivalentTrianglesIndexOfstripsIndex(int lodIndex, GLC_uint materialId)
{
IndexList trianglesIndex;
if (containsStrips(lodIndex, materialId))
{
const QList<QVector<GLuint> > stripsIndex= getStripsIndex(lodIndex, materialId);
const int stripCount= stripsIndex.count();
for (int i= 0; i < stripCount; ++i)
{
const QVector<GLuint> currentStripIndex= stripsIndex.at(i);
trianglesIndex.append(currentStripIndex.at(0));
trianglesIndex.append(currentStripIndex.at(1));
trianglesIndex.append(currentStripIndex.at(2));
const int stripSize= currentStripIndex.size();
for (int j= 3; j < stripSize; ++j)
{
if ((j % 2) != 0)
{
trianglesIndex.append(currentStripIndex.at(j));
trianglesIndex.append(currentStripIndex.at(j - 1));
trianglesIndex.append(currentStripIndex.at(j - 2));
}
else
{
trianglesIndex.append(currentStripIndex.at(j));
trianglesIndex.append(currentStripIndex.at(j - 2));
trianglesIndex.append(currentStripIndex.at(j - 1));
}
}
}
}
return trianglesIndex;
}
示例3: operator
inline void operator() (Lattice& L, IndexList& idx)
{
typedef typename Lattice::element element;
for(int dim = 0; dim < idx.size(); ++dim)
{
sum += L(idx) * L.get_n_left(idx, dim);
sum += L(idx) * L.get_n_right(idx, dim);
}
}
示例4: GenerateTriangleIndices
void RenderingEngine::GenerateTriangleIndices(size_t lineCount,
IndexList& triangles) const
{
size_t destVertCount = lineCount * 8;
triangles.resize(lineCount * 18);
IndexList::iterator triangle = triangles.begin();
for (GLushort v = 0; v < destVertCount; v += 8) {
*triangle++ = 0 + v; *triangle++ = 1 + v; *triangle++ = 2 + v;
*triangle++ = 2 + v; *triangle++ = 1 + v; *triangle++ = 3 + v;
*triangle++ = 2 + v; *triangle++ = 3 + v; *triangle++ = 4 + v;
*triangle++ = 4 + v; *triangle++ = 3 + v; *triangle++ = 5 + v;
*triangle++ = 4 + v; *triangle++ = 5 + v; *triangle++ = 6 + v;
*triangle++ = 6 + v; *triangle++ = 5 + v; *triangle++ = 7 + v;
}
}
示例5: Subdivide
void Sky::Subdivide(std::vector<D3DXVECTOR3>& vertices, std::vector<DWORD>& indices)
{
VertexList vin = vertices;
IndexList iin = indices;
vertices.resize(0);
indices.resize(0);
UINT numTris = (UINT)iin.size()/3;
for(UINT i = 0; i < numTris; ++i)
{
D3DXVECTOR3 v0 = vin[ iin[i*3+0] ];
D3DXVECTOR3 v1 = vin[ iin[i*3+1] ];
D3DXVECTOR3 v2 = vin[ iin[i*3+2] ];
D3DXVECTOR3 m0 = 0.5f*(v0 + v1);
D3DXVECTOR3 m1 = 0.5f*(v1 + v2);
D3DXVECTOR3 m2 = 0.5f*(v0 + v2);
vertices.push_back(v0); // 0
vertices.push_back(v1); // 1
vertices.push_back(v2); // 2
vertices.push_back(m0); // 3
vertices.push_back(m1); // 4
vertices.push_back(m2); // 5
indices.push_back(i*6+0);
indices.push_back(i*6+3);
indices.push_back(i*6+5);
indices.push_back(i*6+3);
indices.push_back(i*6+4);
indices.push_back(i*6+5);
indices.push_back(i*6+5);
indices.push_back(i*6+4);
indices.push_back(i*6+2);
indices.push_back(i*6+3);
indices.push_back(i*6+1);
indices.push_back(i*6+4);
}
}
示例6: addTrianglesFan
// Add triangles Fan
GLC_uint GLC_Mesh::addTrianglesFan(GLC_Material* pMaterial, const IndexList& indexList, const int lod, double accuracy)
{
GLC_uint groupId= setCurrentMaterial(pMaterial, lod, accuracy);
Q_ASSERT(m_PrimitiveGroups.value(lod)->contains(groupId));
Q_ASSERT(!indexList.isEmpty());
GLC_uint id= 0;
if (0 == lod)
{
id= m_NextPrimitiveLocalId++;
}
m_MeshData.trianglesAdded(lod, indexList.size() - 2);
m_PrimitiveGroups.value(lod)->value(groupId)->addTrianglesFan(indexList, id);
// Invalid the geometry
m_GeometryIsValid = false;
return id;
}
示例7: equivalentTrianglesIndexOfFansIndex
IndexList GLC_Mesh::equivalentTrianglesIndexOfFansIndex(int lodIndex, GLC_uint materialId)
{
IndexList trianglesIndex;
if (containsFans(lodIndex, materialId))
{
const QList<QVector<GLuint> > fanIndex= getFansIndex(lodIndex, materialId);
const int fanCount= fanIndex.count();
for (int i= 0; i < fanCount; ++i)
{
const QVector<GLuint> currentFanIndex= fanIndex.at(i);
const int size= currentFanIndex.size();
for (int j= 1; j < size - 1; ++j)
{
trianglesIndex.append(currentFanIndex.first());
trianglesIndex.append(currentFanIndex.at(j));
trianglesIndex.append(currentFanIndex.at(j + 1));
}
}
}
return trianglesIndex;
}
示例8: getEquivalentTrianglesStripsFansIndex
IndexList GLC_Mesh::getEquivalentTrianglesStripsFansIndex(int lod, GLC_uint materialId)
{
IndexList subject;
if (containsTriangles(lod, materialId))
{
subject= getTrianglesIndex(lod, materialId).toList();
}
if (containsStrips(lod, materialId))
{
subject.append(equivalentTrianglesIndexOfstripsIndex(lod, materialId));
}
if (containsFans(lod, materialId))
{
subject.append(equivalentTrianglesIndexOfFansIndex(lod, materialId));
}
Q_ASSERT((subject.count() % 3) == 0);
return subject;
}
示例9: findKeyword
PWIZ_API_DECL IndexList ProteinList::findKeyword(const string& keyword, bool caseSensitive /*= true*/) const
{
IndexList indexList;
if (caseSensitive)
{
for (size_t index = 0, end = size(); index < end; ++index)
if (protein(index, false)->description.find(keyword) != string::npos)
indexList.push_back(index);
}
else
{
string lcKeyword = keyword;
for (size_t index = 0, end = size(); index < end; ++index)
{
string lcDescription = protein(index, false)->description;
bal::to_lower(lcDescription);
if (lcDescription.find(lcKeyword) != string::npos)
indexList.push_back(index);
}
}
return indexList;
}
示例10: polyIndices
void IndexArrayMapBuilder::addPolygon(const IndexList& indices) {
const size_t count = indices.size();
IndexList polyIndices(0);
polyIndices.reserve(3 * (count - 2));
for (size_t i = 0; i < count - 2; ++i) {
polyIndices.push_back(indices[0]);
polyIndices.push_back(indices[i + 1]);
polyIndices.push_back(indices[i + 2]);
}
add(GL_TRIANGLES, polyIndices);
}
示例11: GetGlobalEfficiency
double scn::GetVulnerability(UGraph::pGraph graph,size_t indexOfNode)
{
double original_efficiency = GetGlobalEfficiency(graph);
std::pair<IndexList, IndexList> result;
if(indexOfNode != Graph::NaF)
{//compute the vulnerability of one node
//remove the current node, note: only in_degree is used in
//UGraph
result = graph->RemoveNode(indexOfNode);
IndexList& edges = result.first;
//node edge
double new_efficiency = GetGlobalEfficiency(graph);
//restore the original graph
graph->AddEdge(graph->AddNode(indexOfNode), edges);
return (original_efficiency - new_efficiency) / original_efficiency;
}
else
{//compute the vunlerability of the whole network
IndexList setOfNode = graph->CopyIndexOfNodes();
//compute
double max_vul = -1e200, new_vul;
for(auto node = setOfNode.begin(); node != setOfNode.end(); node++)
{
//remove the current node, note: only in_degree is used in
//UGraph
result = graph->RemoveNode(*node);
IndexList& edges = result.first;
new_vul = (original_efficiency - GetGlobalEfficiency(graph)) / original_efficiency;
if(new_vul > max_vul)
max_vul = new_vul;
//restore the original graph
graph->AddEdge(graph->AddNode(*node), edges);
}
return max_vul;
}
}
示例12: process_for_equations
void process_for_equations(Modelica::MMO_Class &mmo_class) {
EquationList &equations = mmo_class.equations_ref().equations_ref();
EquationList new_equations;
foreach_ (Equation &e, equations) {
if (is<ForEq>(e)) {
ForEq feq = boost::get<ForEq>(e);
IndexList il = feq.range().indexes();
ERROR_UNLESS(il.size() == 1,
"process_for_equations:\n"
"forIndexList with more than 1 forIndex are not supported yet\n");
Index in = il.front();
Name variable = in.name();
OptExp ind = in.exp();
ERROR_UNLESS(ind, "for-equation's index with implicit range not supported yet\n");
Expression exp = ind.get();
ForIndexIterator *forIndexIter = NULL;
if (is<Range>(exp)) {
forIndexIter = new RangeIterator(get<Range>(exp),mmo_class.syms_ref());
} else if (is<Brace>(exp)) {
forIndexIter = new BraceIterator(get<Brace>(exp),mmo_class.syms_ref());
} else {
ERROR("For Iterator not supported");
}
while (forIndexIter->hasNext()) {
Real index_val = forIndexIter->next();
foreach_ (Equation eq, feq.elements())
new_equations.push_back(instantiate_equation(eq, variable, index_val, mmo_class.syms_ref()));
}
delete forIndexIter;
} else {
// Not a for eq
new_equations.push_back(e);
}
}
mmo_class.equations_ref().equations_ref()=new_equations;
}
示例13: BuildGeoSphere
//***************************************************************************************
// Name: BuildGeoSphere
// Desc: Function approximates a sphere by tesselating an icosahedron.
//***************************************************************************************
void BuildGeoSphere(UINT numSubdivisions, float radius, VertexList& vertices, IndexList& indices)
{
// Put a cap on the number of subdivisions.
numSubdivisions = Min(numSubdivisions, UINT(5));
// Approximate a sphere by tesselating an icosahedron.
const float X = 0.525731f;
const float Z = 0.850651f;
D3DXVECTOR3 pos[12] =
{
D3DXVECTOR3(-X, 0.0f, Z), D3DXVECTOR3(X, 0.0f, Z),
D3DXVECTOR3(-X, 0.0f, -Z), D3DXVECTOR3(X, 0.0f, -Z),
D3DXVECTOR3(0.0f, Z, X), D3DXVECTOR3(0.0f, Z, -X),
D3DXVECTOR3(0.0f, -Z, X), D3DXVECTOR3(0.0f, -Z, -X),
D3DXVECTOR3(Z, X, 0.0f), D3DXVECTOR3(-Z, X, 0.0f),
D3DXVECTOR3(Z, -X, 0.0f), D3DXVECTOR3(-Z, -X, 0.0f)
};
DWORD k[60] =
{
1,4,0, 4,9,0, 4,5,9, 8,5,4, 1,8,4,
1,10,8, 10,3,8, 8,3,5, 3,2,5, 3,7,2,
3,10,7, 10,6,7, 6,11,7, 6,0,11, 6,1,0,
10,1,6, 11,0,9, 2,11,9, 5,2,9, 11,2,7
};
vertices.resize(12);
indices.resize(60);
for(int i = 0; i < 12; ++i)
vertices[i] = pos[i];
for(int i = 0; i < 60; ++i)
indices[i] = k[i];
for(UINT i = 0; i < numSubdivisions; ++i)
Subdivide(vertices, indices);
// Project vertices onto sphere and scale.
for(size_t i = 0; i < vertices.size(); ++i)
{
D3DXVec3Normalize(&vertices[i], &vertices[i]);
vertices[i] *= radius;
}
}
示例14: addTrianglesStrip
// Add triangle strip to the group
void GLC_PrimitiveGroup::addTrianglesStrip(const IndexList& input, GLC_uint id)
{
m_StripsIndex+= input;
m_TrianglesStripSize= m_StripsIndex.size();
m_StripIndexSizes.append(static_cast<GLsizei>(input.size()));
if (m_StripIndexOffseti.isEmpty())
{
m_StripIndexOffseti.append(0);
}
int offset= m_StripIndexOffseti.last() + m_StripIndexSizes.last();
m_StripIndexOffseti.append(offset);
// The strip id
if (0 != id) m_StripsId.append(id);
else Q_ASSERT(m_StripsId.isEmpty());
}
示例15: CHECK_TEST_RESULT
void medTestDbApp::handleNonPersistentDataImported()
{
CHECK_TEST_RESULT(importedIndex.isValid());
CHECK_TEST_RESULT(importedIndex.isValidForSeries());
const int persistentSourceId = 1;
const int nonPersistentSourceId = 2;
// Check freshly imported data exists.
npDb = dataManager->controllerForDataSource(nonPersistentSourceId);
CHECK_TEST_RESULT( npDb );
CHECK_TEST_RESULT(npDb->dataSourceId() == nonPersistentSourceId);
CHECK_TEST_RESULT( !npDb->isPersistent() );
typedef QList<medDataIndex> IndexList;
IndexList patients = npDb->patients();
qDebug() << "patient size:"<< patients.size();
CHECK_TEST_RESULT(patients.size() == 1);
CHECK_TEST_RESULT(patients[0].patientId() == importedIndex.patientId());
IndexList studies = npDb->studies(patients[0]);
CHECK_TEST_RESULT(studies.size() == 1);
CHECK_TEST_RESULT(studies[0].studyId() == importedIndex.studyId());
IndexList series = npDb->series(studies[0]);
CHECK_TEST_RESULT(series.size() == 1);
CHECK_TEST_RESULT(series[0].seriesId() == importedIndex.seriesId());
// Ensure persistent DB is empty at first
db = dataManager->controllerForDataSource(persistentSourceId);
CHECK_TEST_RESULT( db );
CHECK_TEST_RESULT( db->patients().size() == 0 );
// Test import from non-Persistent to persistent
//disconnect(dataManager);
disconnect(dataManager, 0, this, 0);
connect(dataManager, SIGNAL(dataAdded(const medDataIndex&)), this, SLOT(onPersistentDataImported(const medDataIndex&)));
//TODO: reeanble this test when fixing supported extension bug,
//and priority list!
//dataManager->storeNonPersistentSingleDataToDatabase(importedIndex);
//when reenabling, remove these two lines
testResult = DTK_SUCCEED;
exit();
}