本文整理汇总了C++中BinaryStream::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryStream::GetBuffer方法的具体用法?C++ BinaryStream::GetBuffer怎么用?C++ BinaryStream::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryStream
的用法示例。
在下文中一共展示了BinaryStream::GetBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadBinAC
O3DGCErrorCode LoadBinAC(Vector<long> & data,
const BinaryStream & bstream,
unsigned long & iterator)
{
size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 8;
size_t size = bstream.ReadUInt32Bin(iterator);
if (size == 0)
{
return O3DGC_OK;
}
unsigned char * buffer = 0;
bstream.GetBuffer(iterator, buffer);
iterator += sizeSize;
data.Allocate(size);
Arithmetic_Codec acd;
acd.set_buffer(sizeSize, buffer);
acd.start_decoder();
Adaptive_Bit_Model bModel;
#ifdef DEBUG_VERBOSE
printf("-----------\nsize %i\n", size);
fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
for(size_t i = 0; i < size; ++i)
{
data.PushBack(acd.decode(bModel));
#ifdef DEBUG_VERBOSE
printf("%i\t%i\n", i, data[i]);
fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
}
return O3DGC_OK;
}
示例2: mModelValues
O3DGCErrorCode LoadUIntAC(Vector<long> & data,
const unsigned long M,
const BinaryStream & bstream,
unsigned long & iterator)
{
unsigned long sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
unsigned long size = bstream.ReadUInt32Bin(iterator);
if (size == 0)
{
return O3DGC_OK;
}
long minValue = bstream.ReadUInt32Bin(iterator);
unsigned char * buffer = 0;
bstream.GetBuffer(iterator, buffer);
iterator += sizeSize;
data.Allocate(size);
Arithmetic_Codec acd;
acd.set_buffer(sizeSize, buffer);
acd.start_decoder();
Adaptive_Data_Model mModelValues(M+1);
#ifdef DEBUG_VERBOSE
printf("-----------\nsize %i\n", size);
fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
for(unsigned long i = 0; i < size; ++i)
{
data.PushBack(acd.decode(mModelValues)+minValue);
#ifdef DEBUG_VERBOSE
printf("%i\t%i\n", i, data[i]);
fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
}
return O3DGC_OK;
}
示例3: mModelValues
O3DGCErrorCode LoadIntACEGC(Vector<long> & data,
const unsigned long M,
const BinaryStream & bstream,
unsigned long & iterator)
{
size_t sizeSize = bstream.ReadUInt32Bin(iterator) - 12;
size_t size = bstream.ReadUInt32Bin(iterator);
if (size == 0)
{
return O3DGC_OK;
}
long minValue = bstream.ReadUInt32Bin(iterator) - O3DGC_MAX_LONG;
unsigned char * buffer = 0;
bstream.GetBuffer(iterator, buffer);
iterator += sizeSize;
data.Allocate(size);
Arithmetic_Codec acd;
acd.set_buffer(sizeSize, buffer);
acd.start_decoder();
Adaptive_Data_Model mModelValues(M+2);
Static_Bit_Model bModel0;
Adaptive_Bit_Model bModel1;
unsigned long value;
#ifdef DEBUG_VERBOSE
printf("-----------\nsize %i\n", size);
fprintf(g_fileDebugTF, "size %i\n", size);
#endif //DEBUG_VERBOSE
for(size_t i = 0; i < size; ++i)
{
value = acd.decode(mModelValues);
if ( value == M)
{
value += acd.ExpGolombDecode(0, bModel0, bModel1);
}
data.PushBack(value + minValue);
#ifdef DEBUG_VERBOSE
printf("%i\t%i\n", i, data[i]);
fprintf(g_fileDebugTF, "%i\t%i\n", i, data[i]);
#endif //DEBUG_VERBOSE
}
#ifdef DEBUG_VERBOSE
fflush(g_fileDebugTF);
#endif //DEBUG_VERBOSE
return O3DGC_OK;
}
示例4: testDecode
int testDecode(std::string & fileName)
{
std::string folder;
long found = (long)fileName.find_last_of(PATH_SEP);
if (found != -1)
{
folder = fileName.substr(0,found);
}
if (folder == "")
{
folder = ".";
}
std::string file(fileName.substr(found+1));
std::string outFileName = folder + PATH_SEP + file.substr(0, file.find_last_of(".")) + "_dec.obj";
std::vector< Vec3<Real> > points;
std::vector< Vec3<Real> > normals;
std::vector< Vec2<Real> > colors;
std::vector< Vec2<Real> > texCoords;
std::vector< Vec3<Index> > triangles;
std::vector< unsigned long > matIDs;
std::vector< Material > materials;
std::string materialLib;
std::string matFileName = folder + PATH_SEP + file.substr(0, file.find_last_of(".")) + ".mat";
bool ret = LoadMaterials(matFileName.c_str(), materials, materialLib);
if (ret)
{
const size_t numMaterials = materials.size();
unsigned long n, shift = 0;
for(size_t i = 0; i < numMaterials; ++i)
{
n = materials[i].m_numTriangles + shift;
matIDs.resize(n, materials[i].m_id);
shift = n;
}
}
BinaryStream bstream;
IndexedFaceSet<Index> ifs;
FILE * fin = fopen(fileName.c_str(), "rb");
if (!fin)
{
return -1;
}
fseek(fin, 0, SEEK_END);
unsigned long size = ftell(fin);
bstream.Allocate(size);
rewind(fin);
unsigned long nread = (unsigned long)fread((void *) bstream.GetBuffer(), 1, size, fin);
bstream.SetSize(size);
if (nread != size)
{
return -1;
}
fclose(fin);
std::cout << "Bitstream size (bytes) " << bstream.GetSize() << std::endl;
SC3DMCDecoder<Index> decoder;
// load header
Timer timer;
timer.Tic();
decoder.DecodeHeader(ifs, bstream);
timer.Toc();
std::cout << "DecodeHeader time (ms) " << timer.GetElapsedTime() << std::endl;
// allocate memory
triangles.resize(ifs.GetNCoordIndex());
ifs.SetCoordIndex((Index * const ) &(triangles[0]));
points.resize(ifs.GetNCoord());
ifs.SetCoord((Real * const ) &(points[0]));
if (ifs.GetNNormal() > 0)
{
normals.resize(ifs.GetNNormal());
ifs.SetNormal((Real * const ) &(normals[0]));
}
if (ifs.GetNColor() > 0)
{
colors.resize(ifs.GetNColor());
ifs.SetColor((Real * const ) &(colors[0]));
}
if (ifs.GetNTexCoord() > 0)
{
texCoords.resize(ifs.GetNTexCoord());
ifs.SetTexCoord((Real * const ) &(texCoords[0]));
}
std::cout << "Mesh info "<< std::endl;
std::cout << "\t# coords " << ifs.GetNCoord() << std::endl;
std::cout << "\t# normals " << ifs.GetNNormal() << std::endl;
std::cout << "\t# texcoords " << ifs.GetNTexCoord() << std::endl;
std::cout << "\t# triangles " << ifs.GetNCoordIndex() << std::endl;
// decode mesh
//.........这里部分代码省略.........