本文整理汇总了C++中Vertices::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertices::push_back方法的具体用法?C++ Vertices::push_back怎么用?C++ Vertices::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices::push_back方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: e
void MDAL::DriverFlo2D::createMesh( const std::vector<CellCenter> &cells, double half_cell_size )
{
// Create all Faces from cell centers.
// Vertexs must be also created, they are not stored in FLO-2D files
// try to reuse Vertexs already created for other Faces by usage of unique_Vertexs set.
Faces faces;
Vertices vertices;
std::map<Vertex, size_t, VertexCompare> unique_vertices; //vertex -> id
size_t vertex_idx = 0;
for ( size_t i = 0; i < cells.size(); ++i )
{
Face e( 4 );
for ( size_t position = 0; position < 4; ++position )
{
Vertex n = createVertex( position, half_cell_size, cells[i] );
const auto iter = unique_vertices.find( n );
if ( iter == unique_vertices.end() )
{
unique_vertices[n] = vertex_idx;
vertices.push_back( n );
e[position] = vertex_idx;
++vertex_idx;
}
else
{
e[position] = iter->second;
}
}
faces.push_back( e );
}
mMesh.reset(
new MemoryMesh(
name(),
vertices.size(),
faces.size(),
4, //maximum quads
computeExtent( vertices ),
mDatFileName
)
);
mMesh->faces = faces;
mMesh->vertices = vertices;
}
示例2: setup
void setup(size_t& vertex_count, Ogre::Vector3* vertices, size_t& index_count, unsigned long* indices, double scale)
{
// If we add more Objects we need an Offset for the Indices
std::size_t indices_offset = m_Vertices.size();
Vector3 temp;
for (int i = 0; i < vertex_count; i++)
{
temp << vertices[i].x / (Ogre::Real)scale, vertices[i].y / (Ogre::Real)scale,
vertices[i].z / (Ogre::Real)scale;
m_Vertices.push_back(temp);
}
for (int i = 0; i < index_count; i += 3)
{
Eigen::Matrix<unsigned long, 3, 1> temp;
temp << (unsigned long)(indices[i] + indices_offset), (unsigned long)(indices[i + 1] + indices_offset),
(unsigned long)(indices[i + 2] + indices_offset);
m_Faces.push_back(temp);
// Calculate the normal to each triangle:
// m_Normals.push_back(Ogre::Math::calculateBasicFaceNormal(m_Vertices[indices[i]],m_Vertices[indices[i+1]],m_Vertices[indices[i+2]]));
}
};
示例3: listUpdateVertices
/**
* List up all the vertices that have to be tested for the conflict graph.
*/
void listUpdateVertices(Arrangement &arr, Vertex *v, Edges &horizon, Vertices &vertices)
{
map<Vertex*, bool> hashtable;
for (int i = 0; i < horizon.size(); ++i) {
Face* f1 = horizon[i]->face;
Face* f2 = horizon[i]->twin->face;
for (int j = 0; j < f1->visibleVertices.size(); ++j) {
if (f1->visibleVertices[j] != v) {
hashtable[f1->visibleVertices[j]] = true;
}
}
for (int j = 0; j < f2->visibleVertices.size(); ++j) {
if (f2->visibleVertices[j] != v) {
hashtable[f2->visibleVertices[j]] = true;
}
}
}
for (map<Vertex*, bool>::iterator it = hashtable.begin(); it != hashtable.end(); ++it) {
vertices.push_back((*it).first);
}
}
示例4: main
//.........这里部分代码省略.........
boost::add_edge(0, 1, g);
boost::add_edge(1, 2, g);
// Fix number of vertices, and add one edge array.
{
int num_vertices = 3;
typedef std::pair<int, int> Edge;
std::vector<Edge> edges{
{0, 1},
{1, 2},
};
Graph g(edges.data(), edges.data() + edges.size(), num_vertices);
}
// It is also possible to add vertices with #add_vertex.
//#vertices
{
// Number of vertices.
boost::graph_traits<Graph>::vertices_size_type num_vertices = boost::num_vertices(g);
assert(num_vertices == 3u);
//#vertices() Returns a begin() end() vertex iterator pair so we know where to stop.
{
typedef std::vector<boost::graph_traits<Graph>::vertex_descriptor> Vertices;
Vertices vertices;
vertices.reserve(num_vertices);
//IndexMap
auto index = boost::get(boost::vertex_index, g);
//std::pair<vertex_iter, vertex_iter> vp
for (auto vp = boost::vertices(g); vp.first != vp.second; ++vp.first) {
// Vertex
auto v = *vp.first;
vertices.push_back(index[v]);
}
assert((vertices == Vertices{0, 1, 2}));
}
// The iterator is a ranom access iterator.
{
auto index = boost::get(boost::vertex_index, g);
auto it = boost::vertices(g).first;
assert(index[it[2]] == 2);
assert(index[it[1]] == 1);
}
}
//#edges
{
// It seems that only AdjencyMatrix has a method to get an edge given two vertices:
//edge(u, v, g)
}
}
//#source is also a global function: <http://stackoverflow.com/questions/16114616/why-is-boost-graph-librarys-source-a-global-function>
//#dijikstra
std::cout << "#dijkstra" << std::endl;
{
typedef boost::adjacency_list<
boost::listS,
boost::vecS,
boost::directedS,
boost::no_property,
boost::property<boost::edge_weight_t, int>
> Graph;
示例5: assert
void MDAL::Driver3Di::populateFacesAndVertices( Vertices &vertices, Faces &faces )
{
assert( vertices.empty() );
size_t faceCount = mDimensions.size( CFDimensions::Face2D );
faces.resize( faceCount );
size_t verticesInFace = mDimensions.size( CFDimensions::MaxVerticesInFace );
size_t arrsize = faceCount * verticesInFace;
std::map<std::string, size_t> xyToVertex2DId;
// X coordinate
int ncidX = mNcFile.getVarId( "Mesh2DContour_x" );
double fillX = mNcFile.getFillValue( ncidX );
std::vector<double> faceVerticesX( arrsize );
if ( nc_get_var_double( mNcFile.handle(), ncidX, faceVerticesX.data() ) ) throw MDAL_Status::Err_UnknownFormat;
// Y coordinate
int ncidY = mNcFile.getVarId( "Mesh2DContour_y" );
double fillY = mNcFile.getFillValue( ncidY );
std::vector<double> faceVerticesY( arrsize );
if ( nc_get_var_double( mNcFile.handle(), ncidY, faceVerticesY.data() ) ) throw MDAL_Status::Err_UnknownFormat;
// now populate create faces and backtrack which vertices
// are used in multiple faces
for ( size_t faceId = 0; faceId < faceCount; ++faceId )
{
Face face;
for ( size_t faceVertexId = 0; faceVertexId < verticesInFace; ++faceVertexId )
{
size_t arrId = faceId * verticesInFace + faceVertexId;
Vertex vertex;
vertex.x = faceVerticesX[arrId];
vertex.y = faceVerticesY[arrId];
vertex.z = 0;
if ( MDAL::equals( vertex.x, fillX ) || MDAL::equals( vertex.y, fillY ) )
break;
size_t vertexId;
std::string key = std::to_string( vertex.x ) + "," + std::to_string( vertex.y );
const auto it = xyToVertex2DId.find( key );
if ( it == xyToVertex2DId.end() )
{
// new vertex
vertexId = vertices.size();
xyToVertex2DId[key] = vertexId;
vertices.push_back( vertex );
}
else
{
// existing vertex
vertexId = it->second;
}
face.push_back( vertexId );
}
faces[faceId] = face;
}
// Only now we have number of vertices, since we identified vertices that
// are used in multiple faces
mDimensions.setDimension( CFDimensions::Vertex2D, vertices.size() );
}
示例6: tmp
pcl::simulation::TriangleMeshModel::TriangleMeshModel (pcl::PolygonMesh::Ptr plg)
{
Vertices vertices;
Indices indices;
bool found_rgb = false;
for (size_t i=0; i < plg->cloud.fields.size () ; ++i)
if (plg->cloud.fields[i].name.compare ("rgb") == 0)
found_rgb = true;
if (found_rgb)
{
pcl::PointCloud<pcl::PointXYZRGB> newcloud;
pcl::fromROSMsg (plg->cloud, newcloud);
PCL_DEBUG("RGB Triangle mesh: ");
PCL_DEBUG("Mesh polygons: %ld", plg->polygons.size ());
PCL_DEBUG("Mesh points: %ld", newcloud.points.size ());
Eigen::Vector4f tmp;
for(size_t i=0; i< plg->polygons.size (); ++i)
{ // each triangle/polygon
pcl::Vertices apoly_in = plg->polygons[i];
for(size_t j = 0; j < apoly_in.vertices.size (); ++j)
{ // each point
uint32_t pt = apoly_in.vertices[j];
tmp = newcloud.points[pt].getVector4fMap();
vertices.push_back (Vertex (Eigen::Vector3f (tmp (0), tmp (1), tmp (2)),
Eigen::Vector3f (newcloud.points[pt].r/255.0f,
newcloud.points[pt].g/255.0f,
newcloud.points[pt].b/255.0f)));
indices.push_back (indices.size ());
}
}
}
else
{
pcl::PointCloud<pcl::PointXYZ> newcloud;
pcl::fromROSMsg (plg->cloud, newcloud);
Eigen::Vector4f tmp;
for(size_t i=0; i< plg->polygons.size (); i++)
{ // each triangle/polygon
pcl::Vertices apoly_in = plg->polygons[i];
for(size_t j=0; j< apoly_in.vertices.size (); j++)
{ // each point
uint32_t pt = apoly_in.vertices[j];
tmp = newcloud.points[pt].getVector4fMap();
vertices.push_back (Vertex (Eigen::Vector3f (tmp (0), tmp (1), tmp (2)),
Eigen::Vector3f (1.0, 1.0, 1.0)));
indices.push_back (indices.size ());
}
}
}
PCL_DEBUG("Vertices: %ld", vertices.size ());
PCL_DEBUG("Indices: %ld", indices.size ());
glGenBuffers (1, &vbo_);
glBindBuffer (GL_ARRAY_BUFFER, vbo_);
glBufferData (GL_ARRAY_BUFFER, vertices.size () * sizeof (vertices[0]), &(vertices[0]), GL_STATIC_DRAW);
glBindBuffer (GL_ARRAY_BUFFER, 0);
glGenBuffers (1, &ibo_);
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, ibo_);
glBufferData (GL_ELEMENT_ARRAY_BUFFER, indices.size () * sizeof (indices[0]), &(indices[0]), GL_STATIC_DRAW);
glBindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
if (indices.size () > std::numeric_limits<GLuint>::max ())
PCL_THROW_EXCEPTION(PCLException, "Too many vertices");
size_ = static_cast<GLuint>(indices.size ());
}
示例7: pk
Maxclique(const BB* conn, const int sz, const float tt = 0.025) \
: pk(0), level(1), Tlimit(tt){
for(int i = 0; i < sz; i++) V.push_back(Vertex(i));
e = conn, C.resize(sz + 1), S.resize(sz + 1);
}
示例8:
void cut2(const Vertices &A, Vertices &B){
for(int i = 0; i < (int)A.size() - 1; i++)
if(e[A.back().i][A[i].i])
B.push_back(A[i].i);
}
示例9: if
//.........这里部分代码省略.........
double betaY;
double betaZ;
double posX;
double posY;
double posZ;
// Loop over particles
for( int counter = 0; counter < m_part_num ; ++counter ){
// need to check for NAN as not all ifstream implementations can handle this directly
std::string lineStr ;
std::getline( m_input, lineStr ) ;
if( m_input.eof() ) {
if( counter==0 ) {
return EVENT_READER_IO_ERROR ; // reading first particle of event failed
} else{
++m_currEvent;
return EVENT_READER_OK ; // simply EOF
}
}
std::transform(lineStr.begin(), lineStr.end(), lineStr.begin(), ::tolower);
if( lineStr.find("nan") != std::string::npos){
printout(WARNING,"EventReader","### Read line with 'nan' entries - particle will be ignored ! " ) ;
continue ;
}
std::stringstream m_input_str( lineStr ) ;
m_input_str >> Energy
>> betaX >> betaY >> betaZ
>> posX >> posY >> posZ ;
// printf(" ------- %e %e %e %e %e %e %e \n", Energy,betaX, betaY,betaZ,posX,posY,posZ ) ;
//
// Create a MCParticle and fill it from stdhep info
Particle* p = new Particle(counter);
PropertyMask status(p->status);
// PDGID: If Energy positive (negative) particle is electron (positron)
p->pdgID = 11;
p->charge = -1;
if(Energy < 0.0) {
p->pdgID = -11;
p->charge = +1;
}
// Momentum vector
p->pex = p->psx = betaX*TMath::Abs(Energy)*GeV;
p->pey = p->psy = betaY*TMath::Abs(Energy)*GeV;
p->pez = p->psz = betaZ*TMath::Abs(Energy)*GeV;
// Mass
p->mass = 0.0005109989461*GeV;
//
// Creation time (note the units [1/c_light])
// ( not information in GuineaPig files )
p->time = 0.0;
p->properTime = 0.0;
// Vertex
p->vsx = posX*nm;
p->vsy = posY*nm;
p->vsz = posZ*nm;
Vertex* vtx = new Vertex ;
vtx->x = p->vsx ;
vtx->y = p->vsy ;
vtx->z = p->vsz ;
vtx->time = p->time ;
vtx->out.insert( p->id );
//
// Generator status
// Simulator status 0 until simulator acts on it
p->status = 0;
status.set(G4PARTICLE_GEN_STABLE);
// Add the particle to the collection vector
particles.push_back(p);
// create a new vertex for this particle
vertices.push_back( vtx) ;
} // End loop over particles
++m_currEvent;
return EVENT_READER_OK;
}
示例10: main
int main(int argc, char** argv)
{
if(argc != 3)
return usage(argv[0]);
mark_tag vertex_index(1), vertex_x(2), vertex_y(3), vertex_z(4);
sregex tface_re = bos >> *space >> "TFACE" >> *space >> eos;
sregex vertex_re = bos >> *space >> "VRTX"
>> +space >> (vertex_index=+_d)
>> +space >> (vertex_x=+(digit|'-'|'+'|'.'))
>> +space >> (vertex_y=+(digit|'-'|'+'|'.'))
>> +space >> (vertex_z=+(digit|'-'|'+'|'.'))
>> eos;
sregex triangle_re = bos >> *space >> "TRGL"
>> +space >> (s1=+digit)
>> +space >> (s2=+digit)
>> +space >> (s3=+digit)
>> eos;
sregex end_re = bos >> *space >> "END" >> *space >> eos;
std::ifstream input(argv[1]);
std::ofstream output(argv[2]);
if(!input) {
std::cerr << "Cannot read \"" << argv[1] << "\"!\n";
return EXIT_FAILURE;
}
if(!output) {
std::cerr << "Cannot write to \"" << argv[2] << "\"!\n";
return EXIT_FAILURE;
}
std::string line;
std::getline(input, line);
smatch results;
while(input && ! regex_match(line, tface_re)) // search line "TFACE"
{
std::getline(input, line);
}
std::getline(input, line);
while(input && regex_match(line, results, vertex_re)) {
vertices.push_back(boost::make_tuple(results[vertex_x],
results[vertex_y],
results[vertex_z]));
std::getline(input, line);
}
while(input && regex_match(line, results, triangle_re)) {
std::stringstream s;
int i, j, k;
s << results[1] << " " << results[2] << " " << results[3];
s >> i >> j >> k;
faces.push_back(boost::make_tuple(i, j, k));
std::getline(input, line);
}
if(!input || !regex_match(line, end_re))
return incorrect_input("premature end of file!");
output << "OFF " << vertices.size() << " " << faces.size() << " " << "0\n";
for(Vertices::const_iterator vit = vertices.begin(), vend = vertices.end();
vit != vend; ++vit)
output << boost::get<0>(*vit) << " "
<< boost::get<1>(*vit) << " "
<< boost::get<2>(*vit) << "\n";
for(Faces::const_iterator fit = faces.begin(), fend = faces.end();
fit != fend; ++fit)
output << "3 " << boost::get<0>(*fit)
<< " " << boost::get<1>(*fit)
<< " " << boost::get<2>(*fit) << "\n";
if(output)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
};
示例11: InitVertices
void InitVertices( unsigned recursionDepth, float edgeSize,
Vertices &pyramidVertices,
Indices &pyramidIndices)
{
assert( 0 == pyramidIndices.size() );
assert( 0 == pyramidVertices.size() );
std::vector<Node> nodes;
const float alpha = atanf( sqrtf(2.0f) );
const float cosAlpha = cosf(alpha);
const float sinAlpha = sinf(alpha);
//top right triangle
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, -edgeSize/ 2,
sinAlpha, cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, edgeSize/ 2,
sinAlpha, cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( 0.0f, edgeSize*sqrtf(2.0f)/2, 0.0f,
sinAlpha, cosAlpha, 0.0f ) );
//top back triangle
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, edgeSize/ 2,
0.0f, cosAlpha, sinAlpha ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, edgeSize/ 2,
0.0f, cosAlpha, sinAlpha ) );
pyramidVertices.push_back( Vertex( 0.0f, edgeSize*sqrtf(2.0f)/2, 0.0f,
0.0f, cosAlpha, sinAlpha ) );
//top left triangle
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, edgeSize/ 2,
-sinAlpha, cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, -edgeSize/ 2,
-sinAlpha, cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( 0.0f, edgeSize*sqrtf(2.0f)/2, 0.0f,
-sinAlpha, cosAlpha, 0.0f ) );
//top fron triangle
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, -edgeSize/ 2,
0.0f, cosAlpha, -sinAlpha ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, -edgeSize/ 2,
0.0f, cosAlpha, -sinAlpha ) );
pyramidVertices.push_back( Vertex( 0.0f, edgeSize*sqrtf(2.0f)/2, 0.0f,
0.0f, cosAlpha, -sinAlpha ) );
//bottom right triangle
pyramidVertices.push_back( Vertex( 0.0f, -edgeSize*sqrtf(2.0f)/2, 0.0f,
sinAlpha, -cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, -edgeSize/ 2,
sinAlpha, -cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, edgeSize/ 2,
sinAlpha, -cosAlpha, 0.0f ) );
//bottom back triangle
pyramidVertices.push_back( Vertex( 0.0f, -edgeSize*sqrtf(2.0f)/2, 0.0f,
0.0f, -cosAlpha, sinAlpha ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, edgeSize/ 2,
0.0f, -cosAlpha, sinAlpha ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, edgeSize/ 2,
0.0f, -cosAlpha, sinAlpha ) );
//bottom left triangle
pyramidVertices.push_back( Vertex( 0.0f, -edgeSize*sqrtf(2.0f)/2, 0.0f,
-sinAlpha, -cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, edgeSize/ 2,
-sinAlpha, -cosAlpha, 0.0f ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, -edgeSize/ 2,
-sinAlpha, -cosAlpha, 0.0f ) );
//bottom fron triangle
pyramidVertices.push_back( Vertex( 0.0f, -edgeSize*sqrtf(2.0f)/2, 0.0f,
0.0f, -cosAlpha, -sinAlpha ) );
pyramidVertices.push_back( Vertex( -edgeSize/2, 0.0f, -edgeSize/ 2,
0.0f, -cosAlpha, -sinAlpha ) );
pyramidVertices.push_back( Vertex( edgeSize/2, 0.0f, -edgeSize/ 2,
0.0f, -cosAlpha, -sinAlpha ) );
for( Index index=0; index<pyramidVertices.size(); ++index )
{
nodes.push_back( Node(NULL, NULL, index) );
}
for( unsigned i=0; i<nodes.size(); i+=3 )
{
Tessellation( nodes[i], nodes[i+1], nodes[i+2], pyramidVertices, pyramidIndices, 0, recursionDepth );
}
}
示例12: ComputeAtoms
void Atoms::ComputeAtoms() {
// Get minimal triangulation
EliminationOrder* eo = new EliminationOrder(G_);
FillEdges* F = new FillEdges(G_);
VertexList* minsep_generators = new VertexList();
MCSmPlus::Run(*G_, eo, F, minsep_generators);
std::list< VertexSet* > vertices_of_atoms;
SeparatorComponents cc(G_);
Vertices deleted_vertices; // in paper, this is V(G_) - V(G_')
std::vector< bool > is_deleted(G_->order(), false);
// Examine minsep_generators, eo-earliest first
for (int i : *minsep_generators) {
// Check to see if minimal separator is a clique
Vertex v = eo->VertexAt(i);
Vertices S;
for (Vertex u : G_->N(v)) {
if (eo->Before(v, u) && !is_deleted[u]) {
S.push_back(u);
}
}
for (Vertex u : (*F)[v]) {
if (eo->Before(v, u) && !is_deleted[u]) {
S.push_back(u);
}
}
if (G_->IsClique(S)) {
clique_minimal_separators_.Insert(S);
for (Vertex u : deleted_vertices) {
S.push_back(u);
}
cc.Separate(S);
Vertices C = cc.ConnectedComponent(v);
VertexSet* atom = new VertexSet();
for (Vertex u : C) {
if (!is_deleted[u]) {
deleted_vertices.push_back(u);
is_deleted[u] = true;
atom->insert(u);
}
}
for (Vertex u : S) {
if (!is_deleted[u]) {
atom->insert(u);
}
}
vertices_of_atoms.push_back(atom);
}
}
// Remaining vertices form an atom
Vertices C;
for (Vertex v : *G_) {
if (!is_deleted[v]) {
C.push_back(v);
}
}
if (!C.empty()) {
VertexSet* atom = new VertexSet();
for (Vertex v : C) {
atom->insert(v);
}
vertices_of_atoms.push_back(atom);
}
for (VertexSet* U : vertices_of_atoms) {
atom_subgraphs_.push_back(new InducedSubgraph(G_, *U));
delete U;
}
delete eo;
delete F;
delete minsep_generators;
return;
}