2
0

ObjFileParser.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. #include "AssimpPCH.h"
  35. #ifndef ASSIMP_BUILD_NO_OBJ_IMPORTER
  36. #include "ObjFileParser.h"
  37. #include "ObjFileMtlImporter.h"
  38. #include "ObjTools.h"
  39. #include "ObjFileData.h"
  40. #include "fast_atof.h"
  41. #include "DefaultIOSystem.h"
  42. namespace Assimp {
  43. // -------------------------------------------------------------------
  44. const std::string ObjFileParser::DEFAULT_MATERIAL = AI_DEFAULT_MATERIAL_NAME;
  45. // fix: changed that to our standard default name
  46. // -------------------------------------------------------------------
  47. // Constructor with loaded data and directories.
  48. ObjFileParser::ObjFileParser(std::vector<char> &Data,
  49. const std::string &strAbsPath,
  50. const std::string &strModelName) :
  51. m_strAbsPath(strAbsPath),
  52. m_DataIt(Data.begin()),
  53. m_DataItEnd(Data.end()),
  54. m_pModel(NULL),
  55. m_uiLine(0)
  56. {
  57. // Create the model instance to store all the data
  58. m_pModel = new ObjFile::Model();
  59. m_pModel->m_ModelName = strModelName;
  60. m_pModel->m_pDefaultMaterial = new ObjFile::Material();
  61. m_pModel->m_pDefaultMaterial->MaterialName.Set( DEFAULT_MATERIAL );
  62. m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL );
  63. m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial;
  64. // Start parsing the file
  65. parseFile();
  66. }
  67. // -------------------------------------------------------------------
  68. ObjFileParser::~ObjFileParser()
  69. {
  70. delete m_pModel->m_pDefaultMaterial;
  71. m_pModel->m_pDefaultMaterial = NULL;
  72. delete m_pModel;
  73. m_pModel = NULL;
  74. }
  75. // -------------------------------------------------------------------
  76. ObjFile::Model *ObjFileParser::GetModel() const
  77. {
  78. return m_pModel;
  79. }
  80. // -------------------------------------------------------------------
  81. void ObjFileParser::parseFile()
  82. {
  83. if (m_DataIt == m_DataItEnd)
  84. return;
  85. while (m_DataIt != m_DataItEnd)
  86. {
  87. switch (*m_DataIt)
  88. {
  89. case 'v': // Parse a vertex texture coordinate
  90. {
  91. ++m_DataIt;
  92. if (*m_DataIt == ' ')
  93. {
  94. // Read in vertex definition
  95. getVector3(m_pModel->m_Vertices);
  96. }
  97. else if (*m_DataIt == 't')
  98. {
  99. // Read in texture coordinate (2D)
  100. ++m_DataIt;
  101. getVector2(m_pModel->m_TextureCoord);
  102. }
  103. else if (*m_DataIt == 'n')
  104. {
  105. // Read in normal vector definition
  106. ++m_DataIt;
  107. getVector3(m_pModel->m_Normals);
  108. }
  109. }
  110. break;
  111. case 'f': // Parse a face
  112. {
  113. getFace();
  114. }
  115. break;
  116. case '#': // Parse a comment
  117. {
  118. getComment();
  119. }
  120. break;
  121. case 'u': // Parse a material desc. setter
  122. {
  123. getMaterialDesc();
  124. }
  125. break;
  126. case 'm': // Parse a material library
  127. {
  128. getMaterialLib();
  129. }
  130. break;
  131. case 'g': // Parse group name
  132. {
  133. getGroupName();
  134. }
  135. break;
  136. case 's': // Parse group number
  137. {
  138. getGroupNumber();
  139. }
  140. break;
  141. case 'o': // Parse object name
  142. {
  143. getObjectName();
  144. }
  145. break;
  146. default:
  147. {
  148. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  149. }
  150. break;
  151. }
  152. }
  153. }
  154. // -------------------------------------------------------------------
  155. // Copy the next word in a temporary buffer
  156. void ObjFileParser::copyNextWord(char *pBuffer, size_t length)
  157. {
  158. size_t index = 0;
  159. m_DataIt = getNextWord<DataArrayIt>(m_DataIt, m_DataItEnd);
  160. while (!isSpace(*m_DataIt) && m_DataIt != m_DataItEnd)
  161. {
  162. pBuffer[index] = *m_DataIt;
  163. index++;
  164. if (index == length-1)
  165. break;
  166. ++m_DataIt;
  167. }
  168. pBuffer[index] = '\0';
  169. }
  170. // -------------------------------------------------------------------
  171. // Copy the next line into a temporary buffer
  172. void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
  173. {
  174. size_t index = 0;
  175. while (m_DataIt != m_DataItEnd)
  176. {
  177. if (*m_DataIt == '\n' || *m_DataIt == '\r')
  178. break;
  179. assert (index+1 <= length);
  180. pBuffer[ index ] = *m_DataIt;
  181. ++index;
  182. ++m_DataIt;
  183. }
  184. pBuffer[ index ] = '\0';
  185. }
  186. // -------------------------------------------------------------------
  187. // Get values for a new 3D vector instance
  188. void ObjFileParser::getVector3(std::vector<aiVector3D*> &point3d_array)
  189. {
  190. float x, y, z;
  191. copyNextWord(m_buffer, BUFFERSIZE);
  192. x = (float) fast_atof(m_buffer);
  193. copyNextWord(m_buffer, BUFFERSIZE);
  194. y = (float) fast_atof(m_buffer);
  195. copyNextWord(m_buffer, BUFFERSIZE);
  196. z = (float) fast_atof(m_buffer);
  197. point3d_array.push_back(new aiVector3D(x,y,z));
  198. //skipLine();
  199. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  200. }
  201. // -------------------------------------------------------------------
  202. // Get values for a new 2D vector instance
  203. void ObjFileParser::getVector2( std::vector<aiVector2D*> &point2d_array )
  204. {
  205. float x, y;
  206. copyNextWord(m_buffer, BUFFERSIZE);
  207. x = (float) fast_atof(m_buffer);
  208. copyNextWord(m_buffer, BUFFERSIZE);
  209. y = (float) fast_atof(m_buffer);
  210. point2d_array.push_back(new aiVector2D(x, y));
  211. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  212. }
  213. // -------------------------------------------------------------------
  214. // Get values for a new face instance
  215. void ObjFileParser::getFace()
  216. {
  217. copyNextLine(m_buffer, BUFFERSIZE);
  218. if (m_DataIt == m_DataItEnd)
  219. return;
  220. char *pPtr = m_buffer;
  221. char *pEnd = &pPtr[BUFFERSIZE];
  222. pPtr = getNextToken<char*>(pPtr, pEnd);
  223. if (pPtr == '\0')
  224. return;
  225. std::vector<unsigned int> *pIndices = new std::vector<unsigned int>;
  226. std::vector<unsigned int> *pTexID = new std::vector<unsigned int>;
  227. std::vector<unsigned int> *pNormalID = new std::vector<unsigned int>;
  228. bool hasNormal = false;
  229. bool vt = (!m_pModel->m_TextureCoord.empty());
  230. bool vn = (!m_pModel->m_Normals.empty());
  231. int iStep = 0, iPos = 0;
  232. while (pPtr != pEnd)
  233. {
  234. iStep = 1;
  235. if (*pPtr == '\0')
  236. break;
  237. if (*pPtr=='\r')
  238. break;
  239. if (*pPtr=='/' )
  240. {
  241. if (iPos == 0)
  242. {
  243. //if there are no texturecoordinates in the obj file but normals
  244. if (!vt && vn) {
  245. iPos = 1;
  246. iStep++;
  247. }
  248. }
  249. iPos++;
  250. }
  251. else if (isSpace(*pPtr))
  252. {
  253. iPos = 0;
  254. }
  255. else
  256. {
  257. //OBJ USES 1 Base ARRAYS!!!!
  258. const int iVal = atoi( pPtr );
  259. int tmp = iVal;
  260. while ((tmp = tmp / 10)!=0)
  261. ++iStep;
  262. if ( 0 != iVal )
  263. {
  264. // Store parsed index
  265. if ( 0 == iPos )
  266. {
  267. pIndices->push_back( iVal-1 );
  268. }
  269. else if ( 1 == iPos )
  270. {
  271. pTexID->push_back( iVal-1 );
  272. }
  273. else if ( 2 == iPos )
  274. {
  275. pNormalID->push_back( iVal-1 );
  276. hasNormal = true;
  277. }
  278. else
  279. {
  280. reportErrorTokenInFace();
  281. }
  282. }
  283. }
  284. for ( int i=0; i<iStep; i++ )
  285. ++pPtr;
  286. }
  287. ObjFile::Face *face = new ObjFile::Face(pIndices, pNormalID, pTexID);
  288. // Set active material, if one set
  289. if (NULL != m_pModel->m_pCurrentMaterial)
  290. face->m_pMaterial = m_pModel->m_pCurrentMaterial;
  291. else
  292. face->m_pMaterial = m_pModel->m_pDefaultMaterial;
  293. // Create a default object, if nothing there
  294. if ( NULL == m_pModel->m_pCurrent )
  295. createObject("defaultobject");
  296. // Store the new instance
  297. m_pModel->m_pCurrent->m_Faces.push_back(face);
  298. // Assign face to mesh
  299. if ( NULL == m_pModel->m_pCurrentMesh )
  300. {
  301. m_pModel->m_pCurrentMesh = new ObjFile::Mesh();
  302. m_pModel->m_Meshes.push_back( m_pModel->m_pCurrentMesh );
  303. }
  304. // Store the face
  305. m_pModel->m_pCurrentMesh->m_Faces.push_back( face );
  306. m_pModel->m_pCurrentMesh->m_uiNumIndices += (unsigned int)face->m_pVertices->size();
  307. m_pModel->m_pCurrentMesh->m_uiUVCoordinates[ 0 ] += (unsigned int)face->m_pTexturCoords[0].size();
  308. if(!m_pModel->m_pCurrentMesh->m_hasNormals && hasNormal) {
  309. m_pModel->m_pCurrentMesh->m_hasNormals = true;
  310. }
  311. // Skip the rest of the line
  312. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  313. }
  314. // -------------------------------------------------------------------
  315. // Get values for a new material description
  316. void ObjFileParser::getMaterialDesc()
  317. {
  318. // Get next data for material data
  319. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  320. if (m_DataIt == m_DataItEnd)
  321. return;
  322. char *pStart = &(*m_DataIt);
  323. while ( !isSpace(*m_DataIt) && m_DataIt != m_DataItEnd )
  324. ++m_DataIt;
  325. // Get name
  326. std::string strName(pStart, &(*m_DataIt));
  327. if ( strName.empty())
  328. return;
  329. // Search for material
  330. std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strName );
  331. if ( it == m_pModel->m_MaterialMap.end() )
  332. {
  333. // Not found, use default material
  334. m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
  335. m_pModel->m_pCurrentMesh = new ObjFile::Mesh();
  336. m_pModel->m_Meshes.push_back( m_pModel->m_pCurrentMesh );
  337. m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( DEFAULT_MATERIAL );
  338. }
  339. else
  340. {
  341. // Found, using detected material
  342. m_pModel->m_pCurrentMaterial = (*it).second;
  343. // Create a new mesh for a new material
  344. m_pModel->m_pCurrentMesh = new ObjFile::Mesh();
  345. m_pModel->m_Meshes.push_back( m_pModel->m_pCurrentMesh );
  346. m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( strName );
  347. }
  348. // Skip rest of line
  349. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  350. }
  351. // -------------------------------------------------------------------
  352. // Get a comment, values will be skipped
  353. void ObjFileParser::getComment()
  354. {
  355. while (true)
  356. {
  357. if ('\n' == (*m_DataIt) || m_DataIt == m_DataItEnd)
  358. {
  359. ++m_DataIt;
  360. break;
  361. }
  362. else
  363. {
  364. ++m_DataIt;
  365. }
  366. }
  367. }
  368. // -------------------------------------------------------------------
  369. // Get material library from file.
  370. void ObjFileParser::getMaterialLib()
  371. {
  372. // Translate tuple
  373. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  374. if (m_DataIt == m_DataItEnd)
  375. return;
  376. char *pStart = &(*m_DataIt);
  377. while (!isNewLine(*m_DataIt))
  378. m_DataIt++;
  379. // TODO: fix path construction
  380. // CLEANUP ... who is resposible for *two* identical DefaultIOSystems
  381. // where the IOSystem passed to ReadFile() should be used???
  382. // Check for existence
  383. DefaultIOSystem IOSystem;
  384. std::string strMatName(pStart, &(*m_DataIt));
  385. std::string absName = m_strAbsPath + IOSystem.getOsSeparator() + strMatName;
  386. if ( !IOSystem.Exists( absName.c_str()) )
  387. {
  388. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  389. return;
  390. }
  391. // Extract the extention
  392. std::string strExt("");
  393. extractExtension( strMatName, strExt );
  394. static const std::string mat = "mtl";
  395. // Load the material library
  396. DefaultIOSystem FileSystem;
  397. IOStream *pFile = FileSystem.Open(absName.c_str());
  398. if (0L != pFile)
  399. {
  400. // Import material library data from file
  401. size_t size = pFile->FileSize();
  402. std::vector<char> buffer;
  403. buffer.resize( size );
  404. pFile->Read( &buffer[ 0 ], sizeof( char ), size );
  405. FileSystem.Close( pFile );
  406. // Importing the material library
  407. ObjFileMtlImporter mtlImporter( buffer, absName, m_pModel );
  408. }
  409. // Skip rest of line
  410. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  411. }
  412. // -------------------------------------------------------------------
  413. // Set a new material definition as the current material.
  414. void ObjFileParser::getNewMaterial()
  415. {
  416. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  417. m_DataIt = getNextWord<DataArrayIt>(m_DataIt, m_DataItEnd);
  418. if ( m_DataIt == m_DataItEnd )
  419. return;
  420. char *pStart = &(*m_DataIt);
  421. std::string strMat(pStart, *m_DataIt);
  422. while (isSpace(*m_DataIt))
  423. m_DataIt++;
  424. std::map<std::string, ObjFile::Material*>::iterator it = m_pModel->m_MaterialMap.find( strMat );
  425. if (it == m_pModel->m_MaterialMap.end())
  426. {
  427. // Show a warning, if material was not found
  428. std::string strWarn ("Unsupported material requested: ");
  429. strWarn += strMat;
  430. std::cerr << "Warning : " << strWarn << std::endl;
  431. m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
  432. }
  433. else
  434. {
  435. // Set new material
  436. m_pModel->m_pCurrentMaterial = (*it).second;
  437. m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( strMat );
  438. }
  439. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  440. }
  441. // -------------------------------------------------------------------
  442. int ObjFileParser::getMaterialIndex( const std::string &strMaterialName )
  443. {
  444. int mat_index = -1;
  445. if ( strMaterialName.empty() )
  446. return mat_index;
  447. for (size_t index = 0; index < m_pModel->m_MaterialLib.size(); ++index)
  448. {
  449. if ( strMaterialName == m_pModel->m_MaterialLib[ index ])
  450. {
  451. mat_index = (int)index;
  452. break;
  453. }
  454. }
  455. return mat_index;
  456. }
  457. // -------------------------------------------------------------------
  458. // Getter for a group name.
  459. void ObjFileParser::getGroupName()
  460. {
  461. // Get next word from data buffer
  462. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  463. m_DataIt = getNextWord<DataArrayIt>(m_DataIt, m_DataItEnd);
  464. if ( m_DataIt == m_DataItEnd )
  465. return;
  466. // Store groupname in group library
  467. char *pStart = &(*m_DataIt);
  468. while (!isSpace(*m_DataIt))
  469. m_DataIt++;
  470. std::string strGroupName(pStart, &(*m_DataIt));
  471. // Change active group, if necessary
  472. if (m_pModel->m_strActiveGroup != strGroupName)
  473. {
  474. // Search for already existing entry
  475. ObjFile::Model::ConstGroupMapIt it = m_pModel->m_Groups.find(&strGroupName);
  476. // New group name, creating a new entry
  477. //ObjFile::Object *pObject = m_pModel->m_pCurrent;
  478. if (it == m_pModel->m_Groups.end())
  479. {
  480. std::vector<unsigned int> *pFaceIDArray = new std::vector<unsigned int>;
  481. m_pModel->m_Groups[ &strGroupName ] = pFaceIDArray;
  482. m_pModel->m_pGroupFaceIDs = (pFaceIDArray);
  483. }
  484. else
  485. {
  486. m_pModel->m_pGroupFaceIDs = (*it).second;
  487. }
  488. m_pModel->m_strActiveGroup = strGroupName;
  489. }
  490. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  491. }
  492. // -------------------------------------------------------------------
  493. // Not supported
  494. void ObjFileParser::getGroupNumber()
  495. {
  496. // Not used
  497. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  498. }
  499. // -------------------------------------------------------------------
  500. // Stores values for a new object instance, name will be used to
  501. // identify it.
  502. void ObjFileParser::getObjectName()
  503. {
  504. m_DataIt = getNextToken<DataArrayIt>(m_DataIt, m_DataItEnd);
  505. if (m_DataIt == m_DataItEnd)
  506. return;
  507. char *pStart = &(*m_DataIt);
  508. while (!isSpace(*m_DataIt))
  509. m_DataIt++;
  510. std::string strObjectName(pStart, &(*m_DataIt));
  511. if (!strObjectName.empty())
  512. {
  513. // Reset current object
  514. m_pModel->m_pCurrent = NULL;
  515. // Search for actual object
  516. for (std::vector<ObjFile::Object*>::const_iterator it = m_pModel->m_Objects.begin();
  517. it != m_pModel->m_Objects.end();
  518. ++it)
  519. {
  520. if ((*it)->m_strObjName == strObjectName)
  521. {
  522. m_pModel->m_pCurrent = *it;
  523. break;
  524. }
  525. }
  526. // Allocate a new object, if current one wasn´t found before
  527. if (m_pModel->m_pCurrent == NULL)
  528. {
  529. createObject(strObjectName);
  530. /*m_pModel->m_pCurrent = new ObjFile::Object();
  531. m_pModel->m_pCurrent->m_strObjName = strObjectName;
  532. m_pModel->m_Objects.push_back(m_pModel->m_pCurrent);*/
  533. }
  534. }
  535. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  536. }
  537. // -------------------------------------------------------------------
  538. // Creates a new object instance
  539. void ObjFileParser::createObject(const std::string &strObjectName)
  540. {
  541. ai_assert (NULL != m_pModel);
  542. ai_assert (!strObjectName.empty());
  543. m_pModel->m_pCurrent = new ObjFile::Object();
  544. m_pModel->m_pCurrent->m_strObjName = strObjectName;
  545. m_pModel->m_Objects.push_back(m_pModel->m_pCurrent);
  546. }
  547. // -------------------------------------------------------------------
  548. // Shows an error in parsing process.
  549. void ObjFileParser::reportErrorTokenInFace()
  550. {
  551. std::string strErr("");
  552. m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
  553. std::cerr << "Not supported token in face desc. detected : " << strErr << std::endl;
  554. }
  555. // -------------------------------------------------------------------
  556. // Extracts the extention from a filename
  557. void ObjFileParser::extractExtension(const std::string &strFile,
  558. std::string &strExt)
  559. {
  560. strExt = "";
  561. if (strFile.empty())
  562. return;
  563. // Search for extention delimiter
  564. std::string::size_type pos = strFile.find_last_of(".");
  565. if ( pos == std::string::npos )
  566. return;
  567. strExt = strFile.substr(pos, strFile.size() - pos);
  568. }
  569. // -------------------------------------------------------------------
  570. } // Namespace Assimp
  571. #endif // !! ASSIMP_BUILD_NO_OBJ_IMPORTER