void Hypergraph::drawPartitions() { srand(NULL); int nPartitions = *max_element(_partitions.begin(), _partitions.end())+1; ColorTable * colTable = new ColorTable(); vector<float> colBuf (nPartitions); for (int i=0; i<nPartitions; ++i) { colBuf[i] = i*1.0/(nPartitions-1); } for (int i=0; i<_nVertices+_edges.size(); ++i) { glPushMatrix(); /*label the vertex*/ glPushName(i); glTranslatef(_layout[i](0), _layout[i](1), 0); glColor3f(1,1,1); glutSolidSphere(7, 10, 10); glColor3ubv(colTable->getColor(colBuf[_partitions[i]])); glutSolidSphere(5, 10, 10); glPopName(); glPopMatrix(); } }
int main(int argc, const char * argv[]) { ColorTable* colorTable = new ColorTable(); /* * 3) read the table, then allow the user to interactively query colors */ colorTable->readColorTable("src/colors.txt"); bool quit = false; string input; while (!quit) { cout << "Please enter a color name: "; cin >> input; Color* foundColor = new Color(); if (input == "quit") { quit = true; } else if (colorTable->getColor(input, foundColor)) { cout << foundColor->name << " = (" << foundColor->r << ", " << foundColor->g << ", " << foundColor->b << ")" << endl; } else { cout << "Could not find color \"" << input << "\"" << endl; } } cout << "Thanks and goodbye!" << endl; delete colorTable; return 0; }