void processRegistryFile(wchar_t * regFilePath) { try { RegistryHiveFile registryFile(regFilePath); REGFHeader * header = registryFile.getHeader(); std::wcout << "hive name: " << header->getHiveName() << std::endl; std::wcout << "major version: " << header->getMajorVersion() << std::endl; std::wcout << "minor version: " << header->getMinorVersion() << std::endl; HBIN::AutoHBINPtrList hbinList (header->getHBINs()); std::wcout << "number of hbins: " << hbinList.size() << std::endl; std::wcout << "last hbin offset: " << header->getLastHbinOffset() << std::endl; HBIN::HBINPtrList::iterator it; int i = 0; for (it = hbinList.begin(); it != hbinList.end(); ++it) { std::wcout << "hbin " << i << ", relative offset first hbin: " << (*it)->getRelativeOffsetFirstHBIN() << std::endl; std::wcout << "hbin " << i << ", relative offset next hbin: " << (*it)->getRelativeOffsetNextHBIN() << std::endl; Cell::AutoCellPtrList cellList((*it)->getCells()); Cell::CellPtrList::iterator cellIter; int j = 0; for (cellIter = cellList.begin(); cellIter != cellList.end(); ++cellIter) { std::wcout << "hbin " << i << ", cell " << j << ", is allocated: " << ((*cellIter)->isActive() ? "yes" : "no") << std::endl; std::wcout << "hbin " << i << ", cell " << j << ", length: " << (*cellIter)->getLength() << std::endl; j++; } i++; } printNKRecord(header->getRootNKRecord(), L"root "); NKRecord::AutoNKRecordPtrList nkRecordList((header->getRootNKRecord()->getSubkeyList()->getSubkeys())); NKRecord::NKRecordPtrList::iterator keyIter = nkRecordList.begin(); for (; keyIter != nkRecordList.end(); ++keyIter) { std::wcout << L" " << (*keyIter)->getName() << std::endl; printNKRecord((*keyIter), L" "); } recurseNKRecord(header->getRootNKRecord(), L""); } catch (std::exception& ex) { std::wcout << ex.what() << std::endl; } }
// _____________________________________________________________________________ void UniformGrid::insertShapeIntoMatchingCells(const AABB& aabb, Shape* shape) { ivec3 minCellIndex; ivec3 maxCellIndex; Mesh* mesh; std::vector<std::pair<ivec3, ivec3> > minMaxIndices; m_AABB.min.x = std::min(m_AABB.min.x, aabb.min.x); m_AABB.min.y = std::min(m_AABB.min.y, aabb.min.y); m_AABB.min.z = std::min(m_AABB.min.z, aabb.min.z); m_AABB.max.x = std::max(m_AABB.max.x, aabb.max.x); m_AABB.max.y = std::max(m_AABB.max.y, aabb.max.y); m_AABB.max.z = std::max(m_AABB.max.z, aabb.max.z); if ((mesh = dynamic_cast<Mesh*>(shape))) { // For meshs we loop multiple times. const std::vector<vec3>& vertices = mesh->getVertices(); const size_t vertCount = vertices.size(); const glm::mat4& transformation = mesh->getTransformMatrix(); minMaxIndices.reserve(vertCount / 3); // loop over all the faces. for (size_t i = 0; i < vertCount; i += 3) { // Get the indices of this face. AABB triangleAABB = aabbOfTriangle(vertices, i, transformation); m_AABB.min.x = std::min(m_AABB.min.x, triangleAABB.min.x); m_AABB.min.y = std::min(m_AABB.min.y, triangleAABB.min.y); m_AABB.min.z = std::min(m_AABB.min.z, triangleAABB.min.z); m_AABB.max.x = std::max(m_AABB.max.x, triangleAABB.max.x); m_AABB.max.y = std::max(m_AABB.max.y, triangleAABB.max.y); m_AABB.max.z = std::max(m_AABB.max.z, triangleAABB.max.z); getIndecesForAABBInGrid( triangleAABB, &minCellIndex, &maxCellIndex, m_CellSize); // add the indices. minMaxIndices.push_back(std::make_pair(minCellIndex, maxCellIndex)); } } else { // Calculate the indeces. getIndecesForAABBInGrid(aabb, &minCellIndex, &maxCellIndex, m_CellSize); minMaxIndices.push_back(std::make_pair(minCellIndex, maxCellIndex)); } // Insert the shape into matching cells. // Order irrelevant cause we hash anyways. for (size_t i = 0; i < minMaxIndices.size(); ++i) { minCellIndex = minMaxIndices.at(i).first; maxCellIndex = minMaxIndices.at(i).second; for (int x = minCellIndex.x; x <= maxCellIndex.x; ++x) { for (int y = minCellIndex.y; y <= maxCellIndex.y; ++y) { for (int z = minCellIndex.z; z <= maxCellIndex.z; ++z) { // printf("Shape in (%d,%d,%d)\n", x,y,z); ivec3 key = ivec3(x, y, z); auto it = m_Shapes.find(key); // Key is not in the map. Create a empty vector of shapes. if (it == m_Shapes.end()) { auto p = m_Shapes.insert({ key, cellList() }); if (!p.second) { perror("Abort insert: could not insert key"); return; } it = p.first; } it->second.push_back(std::make_pair(shape, 3 * i)); } } } } printf("GridAABB: (%.2f,%.2f,%.2f,%.2f,%.2f,%.2f)\n", m_AABB.min.x, m_AABB.min.y, m_AABB.min.z, m_AABB.max.x, m_AABB.max.y, m_AABB.max.z); }