int Graphs::breadthFirstSearch(std::vector<T> &items, std::vector<std::vector<int> > &graph, int &source, std::vector<int> &target) { resetVertices(); std::list<int> file; int current = source; items[current].mark = 1; file.push_back(current); while (!file.empty()) { current = file.front(); file.pop_front(); for (int i = 0; i < (int) graph[current].size(); ++i) { if (items[graph[current][i]].mark == 0) { items[graph[current][i]].mark = 1; items[graph[current][i]].father = current; items[graph[current][i]].distance = items[current].distance + 1; file.push_back(graph[current][i]); } } // test if vertex is among targets for (int k = 0; k < (int) target.size(); ++k) if (current == target[k]) return current; } return -1; }
void BezierPatch::resetPoints() { int u, v; for (u = 0; u < 4; u++) { for (v = 0; v < 4; v++) { Points[u][v].x = 20.0*((GLfloat)u - 1.5); Points[u][v].y = 20.0*((GLfloat)v - 1.5); if ( (u == 1 || u == 2) && (v == 1 || v == 2)) Points[u][v].z = 40.0; else Points[u][v].z = -30.0; if ( ( u==2) && v==0) Points[u][v].z = 30.0; if ( ( u==1) && v==0) Points[u][v].z = -30.0; } } resetVertices(); resetMesh(); calculateBezierTextureCoords(); setBoundingBoxes(); }
void ModelLoadingProgressDialog::setupForNewModel(int type, int nvertices, int npolygons, int npolyhedrons){ modelType = type; ui->progressBar->setEnabled(true); ui->pushButton->setVisible(false); resetVertices(nvertices); resetPolygons(npolygons); resetPolyhedrons(npolyhedrons); ui->progressBar->setValue(0); progressStages = 0; ui->plainTextEdit->clear(); totalelements = totalVertices+totalPolygons+totalPolyhedrons; switch(type){ case vis::CONSTANTS::VERTEX_CLOUD:{ ui->widget_polygon->setVisible(false); ui->widget_polyhedron->setVisible(false); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.3f); break; } case vis::CONSTANTS::POLYGON_MESH:{ ui->widget_polygon->setVisible(true); ui->widget_polyhedron->setVisible(false); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.6f); break; } case vis::CONSTANTS::POLYHEDRON_MESH:{ ui->widget_polygon->setVisible(true); ui->widget_polyhedron->setVisible(true); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.9f); break; } case vis::CONSTANTS::LIGHT_WEIGHT_VERTEX_CLOUD:{ ui->widget_polygon->setVisible(false); ui->widget_polyhedron->setVisible(false); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.3f); break; } case vis::CONSTANTS::LIGHT_WEIGHT_POLYGON_MESH:{ ui->widget_polygon->setVisible(true); ui->widget_polyhedron->setVisible(false); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.4f); break; } case vis::CONSTANTS::LIGHT_WEIGHT_POLYHEDRON_MESH:{ ui->widget_polygon->setVisible(true); ui->widget_polyhedron->setVisible(true); progressVarMax = (int)((nvertices+npolygons+npolyhedrons)*1.5f); break; } default: std::cerr << "Error [ModelLoadingProgressDialog]:"<< "Invalid model type: "<<type<<std::endl; } ui->progressBar->setMaximum(progressVarMax); updateProgressBar(); }
void BezierPatch::resetPoints(float newctlPoints[4][4][3]) { for(int i=0;i<4;i++) for(int j=0;j<4;j++) { Points[i][j].x=newctlPoints[i][j][0]; Points[i][j].y=newctlPoints[i][j][1]; Points[i][j].z=newctlPoints[i][j][2]; } resetVertices(); resetMesh(); calculateBezierTextureCoords(); setBoundingBoxes(); }