| 100 | } |
| 101 | |
| 102 | bool NParticleReader::open() |
| 103 | { |
| 104 | if( !m_iffFile || m_iffFileName!=fileName() ) |
| 105 | { |
| 106 | m_iffFile = new IFFFile( fileName().c_str() ); |
| 107 | |
| 108 | IFFFile::Chunk *root = m_iffFile->root(); |
| 109 | IFFFile::Chunk::ChunkIterator headerIt = root->childrenBegin(); |
| 110 | |
| 111 | if ( !headerIt->isGroup() || headerIt->groupName().id() != kCACH ) |
| 112 | { |
| 113 | m_header.valid = false; |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | IFFFile::Chunk::ChunkIterator child = headerIt->childrenBegin(); |
| 118 | for ( ; child != headerIt->childrenEnd(); child++ ) |
| 119 | { |
| 120 | if ( child->type().id() == kVRSN ) |
| 121 | { |
| 122 | child->read( m_header.version ); |
| 123 | } |
| 124 | else if ( child->type().id() == kSTIM ) |
| 125 | { |
| 126 | child->read( m_header.startTime ); |
| 127 | } |
| 128 | else if ( child->type().id() == kETIM ) |
| 129 | { |
| 130 | child->read( m_header.endTime ); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | m_frames->writable().clear(); |
| 135 | frameToRootChildren.clear(); |
| 136 | |
| 137 | // single frame per file |
| 138 | if ( m_header.startTime == m_header.endTime && (headerIt+1)->groupName().id() == kMYCH ) |
| 139 | { |
| 140 | frameToRootChildren[m_header.startTime] = headerIt + 1; |
| 141 | m_frames->writable().push_back( m_header.startTime ); |
| 142 | } |
| 143 | // multiple frames per file |
| 144 | else |
| 145 | { |
| 146 | IFFFile::Chunk::ChunkIterator bodyIt = headerIt; |
| 147 | for ( ; bodyIt != root->childrenEnd(); bodyIt++ ) |
| 148 | { |
| 149 | if ( bodyIt->groupName().id() == kMYCH ) |
| 150 | { |
| 151 | // check children for TIME |
| 152 | IFFFile::Chunk::ChunkIterator bodyChild = bodyIt->childrenBegin(); |
| 153 | for ( ; bodyChild != bodyIt->childrenEnd(); bodyChild++ ) |
| 154 | { |
| 155 | if ( bodyChild->type().id() == kTIME ) |
| 156 | { |
| 157 | int time = 0; |
| 158 | bodyChild->read( time ); |
| 159 | frameToRootChildren[time] = bodyIt; |
nothing calls this directly
no test coverage detected