std :: bad_alloc в исключении расположения памяти при загрузке трехмерного объекта с использованием Assimp

Я пытаюсь загрузить 3D-объекты, используя Assimp, созданный с VS2008. Пример кода Assimp загружает объект правильно, пока я не определю (но не создаю экземпляр) класс сетки для обработки данных объекта в моей сборке. В частности, ошибка возникает, когда я включаю код для проверки размера вектора. Эта проблема возникает независимо от того, использую ли я версию nompoost Assimp. Я пробовал несколько разных файлов .obj с одинаковым результатом.

Используя отладчик, я обнаружил, что загрузчик Assimp не работает при чтении граней файла .obj. Это происходит в строке 317 файла Assimp ObjFileParser.cpp:

pIndices->push_back( iVal-1 );

Mesh.cpp (этот класс не создан или не используется в качестве предварительного объявления в main.cpp)

#pragma once

#include <vector>

class Mesh
{
void Init(const std::vector<unsigned int>& Indices){  Indices.size(); }
^^^^^^^^^^^^^^^
};

main.cpp

#include <assimp/Importer.hpp> // C++ importer interface
#include <assimp/scene.h> // Output data structure
#include <assimp/postprocess.h> // Post processing flags
bool DoTheImportThing( const std::string& pFile)
{
// Create an instance of the Importer class
Assimp::Importer importer;
// And have it read the given file with some example postprocessing
// Usually - if speed is not the most important aspect for you - you'll
// propably to request more postprocessing than we do in this example.
const aiScene* scene = importer.ReadFile( pFile,
aiProcess_CalcTangentSpace |
aiProcess_Triangulate |
aiProcess_JoinIdenticalVertices |
aiProcess_SortByPType);
// If the import failed, report it
if( !scene)
{
//DoTheErrorLogging( importer.GetErrorString());
const char* err =  importer.GetErrorString();
return false;
}
// Now we can access the file's contents.
//DoTheSceneProcessing( scene);
// We're done. Everything will be cleaned up by the importer destructor
return true;
}int main()

{
DoTheImportThing("floor.obj");

}

Std :: bad_alloc в исключении расположения памяти выдается в mlock.c

void __cdecl _unlock (
int locknum
)
{
/*
* leave the critical section.
*/
LeaveCriticalSection( _locktable[locknum].lock );
}

Мой стек вызовов

    KernelBase.dll!7512c41f()
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]
KernelBase.dll!7512c41f()
ntdll.dll!7746107b()
>   msvcr90d.dll!_unlock(int locknum=8)  Line 376   C
msvcr90d.dll!_unlockexit()  Line 808 + 0x7 bytes    C
msvcr90d.dll!_CxxThrowException(void * pExceptionObject=0x0110d644, const _s__ThrowInfo * pThrowInfo=0x54655f68)  Line 161  C++
msvcr90d.dll!operator new(unsigned int size=842150452)  Line 64 C++
AssimpLoadFileTest.exe!std::_Allocate<unsigned int>(unsigned int _Count=210537613, unsigned int * __formal=0x00000000)  Line 43 + 0xc bytes C++
AssimpLoadFileTest.exe!std::allocator<unsigned int>::allocate(unsigned int _Count=210537613)  Line 145 + 0xb bytes  C++
AssimpLoadFileTest.exe!std::vector<unsigned int,std::allocator<unsigned int> >::_Insert_n(std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> > _Where=..., unsigned int _Count=1, const unsigned int & _Val=0)  Line 1173 + 0xf bytes    C++
AssimpLoadFileTest.exe!std::vector<unsigned int,std::allocator<unsigned int> >::insert(std::_Vector_const_iterator<unsigned int,std::allocator<unsigned int> > _Where=..., const unsigned int & _Val=0)  Line 878   C++
AssimpLoadFileTest.exe!std::vector<unsigned int,std::allocator<unsigned int> >::push_back(const unsigned int & _Val=0)  Line 824    C++
AssimpLoadFileTest.exe!Assimp::ObjFileParser::getFace(aiPrimitiveType type=aiPrimitiveType_POLYGON)  Line 319 + 0x1e bytes  C++
AssimpLoadFileTest.exe!Assimp::ObjFileParser::parseFile()  Line 142 C++
AssimpLoadFileTest.exe!Assimp::ObjFileParser::ObjFileParser(std::vector<char,std::allocator<char> > & Data=[216](103 'g',32 ' ',102 'f',108 'l',111 'o',111 'o',114 'r',13 '
',10 '
',118 'v',32 ' ',45 '-',53 '5',48 '0',48 '0',46 '.',48 '0',32 ' ',48 '0',46 '.',48 '0',32 ' ',45 '-',53 '5',48 '0',48 '0',46 '.',48 '0',13 '
',10 '
',118 'v',32 ' ',45 '-',53 '5',48 '0',48 '0',46 '.',48 '0',32 ' ',48 '0',46 '.',48 '0',32 ' ',53 '5',48 '0',48 '0',46 '.',48 '0',13 '
',10 '
',118 'v',32 ' ',53 '5',48 '0',48 '0',...,...), const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & strModelName="floor.obj", Assimp::IOSystem * io=0x0110f464)  Line 81   C++
AssimpLoadFileTest.exe!Assimp::ObjFileImporter::InternReadFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & pFile="floor.obj", aiScene * pScene=0x00e7a738, Assimp::IOSystem * pIOHandler=0x0110f464)  Line 145 + 0x1d bytes    C++
AssimpLoadFileTest.exe!Assimp::BaseImporter::ReadFile(const Assimp::Importer * pImp=0x0110faac, const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & pFile="floor.obj", Assimp::IOSystem * pIOHandler=0x00e72e88)  Line 88 + 0x2c bytes C++
AssimpLoadFileTest.exe!Assimp::Importer::ReadFile(const char * _pFile=0x0110fae8, unsigned int pFlags=32779)  Line 650 + 0x18 bytes C++
AssimpLoadFileTest.exe!Assimp::Importer::ReadFile(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & pFile="floor.obj", unsigned int pFlags=32779)  Line 629  C++
AssimpLoadFileTest.exe!DoTheImportThing(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & pFile="floor.obj")  Line 15 + 0x11 bytes   C++
AssimpLoadFileTest.exe!main()  Line 34 + 0x2d bytes C++
AssimpLoadFileTest.exe!__tmainCRTStartup()  Line 586 + 0x19 bytes   C
AssimpLoadFileTest.exe!mainCRTStartup()  Line 403   C
kernel32.dll!75a1336a()
ntdll.dll!77459f72()
ntdll.dll!77459f45()

Выход:

'AssimpLoadFileTest.exe': Loaded 'C:\Visual Studio 2008\Projects\AssimpLoadFileTest\Debug\AssimpLoadFileTest.exe', Symbols loaded.
'AssimpLoadFileTest.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll'
'AssimpLoadFileTest.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'AssimpLoadFileTest.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'AssimpLoadFileTest.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcp90d.dll', Symbols loaded.
'AssimpLoadFileTest.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcr90d.dll', Symbols loaded.
First-chance exception at 0x7512c41f in AssimpLoadFileTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0110d644..
The program '[3340] AssimpLoadFileTest.exe: Native' has exited with code 0 (0x0).

floor.obj:

g floor
v -500.0 0.0 -500.0
v -500.0 0.0 500.0
v 500.0 0.0 -500.0
v 500.0 0.0 500.0
#
vn 0 1 0
#
vt 0.0 0.0
vt 0.0 500.0
vt 500.0 0.0
vt 500.0 500.0
#
f 1/1/1 2/2/1 3/3/1
f 3/3/1 2/2/1 4/4/1

3

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector