void ComponentConversion::vertexToPolygon(const std::vector<unsigned> & src, std::vector<unsigned> & polyIds, std::vector<unsigned> & vppIds) const { if(src.size() < 2) return; std::vector<unsigned>::const_iterator it0; std::vector<unsigned>::const_iterator it1 = src.begin(); it1++; for(; it1 != src.end(); ++it1) { it0 = it1; it0--; VertexAdjacency & adj = m_topology->getAdjacency(*it0); char found = 0; Edge * e = adj.connectedToVertexBy(*it1, found); if(found) { Facet *f = (Facet *)e->getFace(); if(appendUnique(f->getPolygonIndex(), polyIds)) { vppIds.push_back(*it0); vppIds.push_back(*it1); } Edge *opp = e->getTwin(); if(opp) { f = (Facet *)opp->getFace(); if(appendUnique(f->getPolygonIndex(), polyIds)) { vppIds.push_back(*it0); vppIds.push_back(*it1); } } } } }
void QAudioDeviceInfoInternal::getSupportedFormats() const { if (!m_updated) { QScopedPointer<SymbianAudio::DevSoundWrapper> devsound(new SymbianAudio::DevSoundWrapper(m_mode)); connect(devsound.data(), SIGNAL(initializeComplete(int)), this, SLOT(devsoundInitializeComplete(int))); foreach (const QString& codec, devsound->supportedCodecs()) { m_initializing = true; devsound->initialize(codec); while (m_initializing) QCoreApplication::instance()->processEvents(QEventLoop::WaitForMoreEvents); if (KErrNone == m_intializationResult) { m_capabilities[codec].m_frequencies = devsound->supportedFrequencies(); appendUnique(m_unionCapabilities.m_frequencies, devsound->supportedFrequencies()); m_capabilities[codec].m_channels = devsound->supportedChannels(); appendUnique(m_unionCapabilities.m_channels, devsound->supportedChannels()); m_capabilities[codec].m_sampleSizes = devsound->supportedSampleSizes(); appendUnique(m_unionCapabilities.m_sampleSizes, devsound->supportedSampleSizes()); m_capabilities[codec].m_byteOrders = devsound->supportedByteOrders(); appendUnique(m_unionCapabilities.m_byteOrders, devsound->supportedByteOrders()); m_capabilities[codec].m_sampleTypes = devsound->supportedSampleTypes(); appendUnique(m_unionCapabilities.m_sampleTypes, devsound->supportedSampleTypes()); } } m_updated = true; }
void ComponentConversion::edgeToVertex(const std::vector<unsigned> & src, std::vector<unsigned> & dst) const { std::vector<unsigned>::const_iterator it = src.begin(); for(; it != src.end(); ++it) { Edge * e = m_topology->getEdge(*it); appendUnique(e->v0()->getIndex(), dst); appendUnique(e->v1()->getIndex(), dst); } }
void ComponentConversion::facetToPolygon(const std::vector<unsigned> & src, std::vector<unsigned> & polyIds) const { std::vector<unsigned>::const_iterator it; for(it = src.begin(); it != src.end(); ++it) { appendUnique(m_topology->getFacet(*it)->getPolygonIndex(), polyIds); } }
void ComponentConversion::vertexToEdge(const std::vector<unsigned> & src, std::vector<unsigned> & dst) const { if(src.size() < 2) return; std::vector<unsigned>::const_iterator it0; std::vector<unsigned>::const_iterator it1 = src.begin(); it1++; for(; it1 != src.end(); ++it1) { it0 = it1; it0--; VertexAdjacency & adj = m_topology->getAdjacency(*it0); char found = 0; Edge * e = adj.connectedToVertexBy(*it1, found); if(found) { appendUnique(e->getIndex(), dst); Edge * opp = e->getTwin(); if(opp) appendUnique(opp->getIndex(), dst); } } }
/* * Creates a set of edges generated by every possible combination of edges * in the given hyperEdge */ edgeSet * buildEdgesFromHyperEdge(edgeSet * hyperEdge) { int numEdges = 0; edgeSet * newEdges = NULL; llnode * u = hyperEdge->vertices; while(u!=NULL) { llnode * v = u->next; while(v!=NULL) { edgeSet * newEdge = appendUniqueEdgeSet(&newEdges, numEdges); appendUnique(&newEdge->vertices, u->data); appendUnique(&newEdge->vertices, v->data); numEdges++; v=v->next; } u=u->next; } return newEdges; }
void teleop_tracking::combineVertices(const std::vector<teleop_tracking::StlLoader::Facet> &facets, EigenSTL::vector_Vector3d &vertices, EigenSTL::vector_Vector3d &face_normals, std::vector<unsigned> &face_indices) { // The assumption is that these source are empty assert(vertices.empty()); assert(face_normals.empty()); assert(face_indices.empty()); EigenSTL::vector_Vector3f float_vector; for (std::size_t i = 0; i < facets.size(); ++i) { const StlLoader::Facet& f = facets[i]; face_normals.push_back(toEigend(f.normal).normalized()); unsigned v0 = appendUnique(float_vector, toEigenf(f.vertices[0])); unsigned v1 = appendUnique(float_vector, toEigenf(f.vertices[1])); unsigned v2 = appendUnique(float_vector, toEigenf(f.vertices[2])); // Small triangles should not have edges collapsed together assert(v0 != v1); assert(v0 != v2); assert(v1 != v2); face_indices.push_back(v0); face_indices.push_back(v1); face_indices.push_back(v2); } // copy the vector of single precision floats to double precision output for (std::size_t i = 0; i < float_vector.size(); ++i) { Eigen::Vector3d v = float_vector[i].cast<double>(); vertices.push_back(v); } }
void ComponentConversion::edgeRing(const unsigned & src, std::vector<unsigned> & edgeIds) const { Edge * e = m_topology->getEdge(src); Edge *para = m_topology->parallelEdge(e); if(!para) return; printf("para %i %i\n", para->v0()->getIndex(), para->v1()->getIndex()); if(!appendUnique(para->getIndex(), edgeIds)) return; Edge * opp = para->getTwin(); if(!opp) return; for(unsigned i = 0; i < 50; i++) { para = m_topology->parallelEdge(opp); if(!para) return; printf("para %i %i\n", para->v0()->getIndex(), para->v1()->getIndex()); if(!appendUnique(para->getIndex(), edgeIds)) return; opp = para->getTwin(); if(!opp) return; } }
/* * updates the vertex list when a new edge is added so that * the vertex list contains the proper new edges for the * corresponding vertices */ void addEdgetoVertices(edgeSet * edge, vertexSet * head) { llnode * currentVertex = edge->vertices; vertexSet * headOfList= head; while(currentVertex != NULL) { vertexSet * updateVertex = findVertex(headOfList, currentVertex->data); if(updateVertex != NULL) { appendUnique(&updateVertex->edges, edge->id); } else { printf("Error, vertex V%d not found, cannot add edge\n", currentVertex->data); } currentVertex = currentVertex->next; } }
/* * Loads a hypergraph from an input file * Format of the file: * - A list of the vertices in each edge separated by commas with * each edge on a new line */ hypergraph * loadHyperGraph(char * file) { //Initialize the hypergraph hypergraph * tmp = newHyperGraph(); edgeSet * currentEdgeSet=NULL; vertexSet * currentVertexSet=NULL; int numEdges=0; //Open the file FILE * input_file = fopen(file, "r"); char line[1024];//buffer for input int comma_position, v_id, placeholder, newlen, counter; if(input_file == NULL) { printf("Error opening input file, closing program"); exit(0); } //Read in one line at a time while(fscanf(input_file, "%s", line) != EOF) { //add a new edge to the graph numEdges++; currentEdgeSet = appendUniqueEdgeSet(&tmp->edgeSets, numEdges); //Grab each vertex off line the line one at a time separated by commas while(strlen(line) > 0) { comma_position = 0; //reset comma position for new line //Determine location of comma in the string for(counter=0;counter<strlen(line);counter++) { if(line[counter] == ',') { comma_position = counter; break; } } //At end of line we have no comma if (comma_position == 0) comma_position = strlen(line); //copy the vertex number into a temp string char temp[1024]; strncpy(temp, line, comma_position); temp[comma_position] = '\0'; //adjust for v_id > 9 placeholder = 0; v_id = 0; for(counter=strlen(temp)-1; counter>=0; counter--) { v_id = v_id + ( pow(10, placeholder) * ( (int)temp[counter] - 48) ); placeholder ++; } //modify the line to remove the last vertex removed from it newlen = strlen(line) - comma_position; strncpy(line, &line[comma_position+1], newlen); line[newlen] = '\0'; //Add the vertex to the current edge appendUnique(¤tEdgeSet->vertices, v_id); //Add the current edge to the vertex currentVertexSet = appendUniqueVertexSet(&tmp->vertexSets, v_id); //if the vertex is new this will not be null if(currentVertexSet != NULL) appendUnique(¤tVertexSet->edges, currentEdgeSet->id); //if the vertex has already been added to the hypergrah then we //must find it to add the edge to the vertex else { currentVertexSet = findVertex(tmp->vertexSets, v_id); if(currentVertexSet != NULL) appendUnique(¤tVertexSet->edges, currentEdgeSet->id); } } } //Close the file fclose(input_file); return tmp; }