本文整理汇总了C++中SharedArray::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedArray::push_back方法的具体用法?C++ SharedArray::push_back怎么用?C++ SharedArray::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedArray
的用法示例。
在下文中一共展示了SharedArray::push_back方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSTLFromStream
bool Model::loadSTLFromStream(std::fstream &file, SharedArray vertexArray, SharedArray normalsArray)
{
int bufferSize = 80;
char buffer[bufferSize];
if (file.readsome(buffer, bufferSize * sizeof(char)) != bufferSize) {
return false;
}
unsigned int numberOfTriangles = 0;
if (file.readsome((char *)&numberOfTriangles, sizeof(unsigned int)) != sizeof(unsigned int)) {
return false;
}
vertexArray->resize(numberOfTriangles*9);
normalsArray->resize(numberOfTriangles*3);
STLTriangle triangle;
for(unsigned int i = 0; i < numberOfTriangles; i++){
if(file.readsome((char *)&triangle.normal, sizeof(float)*3) != sizeof(float)*3){
return false;
}
if(file.readsome((char *)&triangle.vertex, sizeof(float)*9) != sizeof(float)*9){
return false;
}
if(file.readsome((char *)&triangle.attribute, sizeof(unsigned short)) != sizeof(unsigned short)){
return false;
}
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
vertexArray->push_back(triangle.vertex[i][j]);
}
normalsArray->push_back(triangle.normal[i]);
}
}
}
示例2: CreateSharedBuffers
void CreateSharedBuffers( const int bytesPerBuffer ) {
// setup shared memory buffers
for ( int i = 0; i < constants::NUM_BUFFERS; ++i ) {
// create unique buffer file names
std::string bufferName = constants::BUFFER_BASE_NAME +
boost::lexical_cast<string> ( i ) + ".buf";
// create shared buffers
SharedBufferPtr bufPtr (
new SharedMemory (
bufferName,
bytesPerBuffer,
SHM::CreateShared,
0666 )
);
// store buffer in a vector
array_.push_back ( bufPtr );
}
}