void ComponentPageUI::PopulateComboBox() { ComponentMap components; m_componentList->GetComponents(components); for (ComponentMap::iterator i = components.begin(); i != components.end(); ++i) { m_componentComboBox->AppendItem(i->second.name); } m_saveComponentBtn->Show(false); m_componentMainBox->Pack(m_saveComponentBtn, false); }
void ComponentListsCache::findComponents( int start, int indexCount, std::vector<int> &pointIndices, std::vector<std::vector<int>> &componentIndices, std::vector<std::vector<int>> &arrayIndices) const { // map of pairs (local dof index, array index) to local dof weights typedef int PointIndex; typedef int ComponentIndex; typedef int ArrayIndex; typedef std::pair<ComponentIndex, ArrayIndex> ComponentArrayIndexPair; typedef std::set<ComponentArrayIndexPair> ComponentSet; typedef std::map<PointIndex, ComponentSet> ComponentMap; // Temporary map: pointIndex -> set(componentIndex, arrayIndex) // with arrayIndex standing for the index of the row or column in the matrix // that needs to be returned to Ahmed. ComponentMap requiredComponents; // Retrieve lists of local DOFs corresponding to original indices, // treated either as global DOFs (if m_indexWithGlobalDofs is true) // or flat local DOFs (if m_indexWithGlobalDofs is false) for (int i = 0; i < indexCount; ++i) { PointIndex pointIndex = m_p2o[start + i] / m_componentCount; ComponentIndex componentIndex = m_p2o[start + i] % m_componentCount; requiredComponents[pointIndex].insert(std::make_pair(componentIndex, i)); } // Use the temporary map requiredComponents to build the three output vectors const int pointCount = requiredComponents.size(); // vector<EntityIndex> elementIndices; // elementIndices.reserve(elementCount); pointIndices.resize(pointCount); componentIndices.clear(); componentIndices.resize(pointCount); arrayIndices.clear(); arrayIndices.resize(pointCount); int p = 0; for (ComponentMap::const_iterator mapIt = requiredComponents.begin(); mapIt != requiredComponents.end(); ++mapIt, ++p) { pointIndices[p] = mapIt->first; for (ComponentSet::const_iterator setIt = mapIt->second.begin(); setIt != mapIt->second.end(); ++setIt) { componentIndices[p].push_back(setIt->first); arrayIndices[p].push_back(setIt->second); } } }
//ConnectedComponents PlannerPRM::connectedComponents(ComponentMap &componentMap, bool print) void PlannerPRM::connectedComponents(ComponentMap &componentMap, ConnectedComponents &compList, bool print) const { //qDebug() << __FUNCTION__; //create a vertex_index property map, since VertexList is listS and the graph does not have a "natural" index typedef std::map<Vertex, size_t> IMap; typedef boost::associative_property_map<IMap> IndexMap; IMap indexMap; IndexMap index( indexMap ); //indexing the vertices int i=0; BGL_FORALL_VERTICES(v, graph, Graph) boost::put(index, v, i++); std::vector<int> components(boost::num_vertices(graph)); boost::iterator_property_map< std::vector<int>::iterator, IndexMap> compIterMap( components.begin(), index ); int numComps = boost::connected_components(graph, compIterMap, vertex_index_map(index)); //Create a nice data structure to return info compList.resize(numComps); for(auto it : compList) it = std::make_pair(0, std::vector<Vertex>()); BGL_FORALL_VERTICES(v, graph, Graph) { compList[get(compIterMap, v)].second.push_back( v ); compList[get(compIterMap, v)].first++; componentMap.insert( std::pair<Vertex,int32_t>( v, get(compIterMap, v ))); }
void ComponentHolder::RemoveAll(){ //Wipe out component map data from memory components.clear(); ComponentMap clearMap; clearMap.swap(components); }