int Color(ColorVector& colors) { int maxColorUsed = 0; //Reset all the colors for(ColorVertex* cVertex: adjacencyList) { cVertex->setColor(-1); } for(ColorVertex* cVertex: adjacencyList) { ColorMap cmap; for(Edge* edge: cVertex->edges) { cmap[((ColorVertex *)(edge->getVertex()))->getColor()] = true; } for(color_t color: colors) { if(cmap.find(color) == cmap.end()) { cout << color << endl; cVertex->setColor(color); if(color > maxColorUsed) { maxColorUsed = color; } break; } } } return maxColorUsed; }
static const Color *create_named_color(std::string str){ toLowerI(str); static ColorMap cm; ColorMap::iterator it = cm.find(str); if(it != cm.end()) return &it->second; else return 0; }
void addXmlColors( TiXmlElement *rootElement, const ColorMap &colors, bool /*old*/) { TiXmlElement *colorsElement = new TiXmlElement("Colors"); for (ColorMap::const_iterator it = colors.begin(); it != colors.end(); it++) { unsigned int ldrawNum = it->first; const Color &color = it->second; TiXmlElement *colorElement = new TiXmlElement("Color"); char numberBuf[128]; sprintf(numberBuf, "%d", ldrawNum); addElement(colorElement, "LDrawNumber", numberBuf); addElement(colorElement, "POVName", color.lgeoName); //if (old) //{ // addElement(colorElement, "POVVersion", "3.0"); //} addElement(colorElement, "Dependency", "LGColors"); if (color.transparent) { addElement(colorElement, "IoR", "lg_ior"); } colorsElement->LinkEndChild(colorElement); } rootElement->LinkEndChild(colorsElement); }
// ---------------------------------------------------------------------------- // bool RGBWA::getColorByName( LPCSTR color_name, RGBWA& rgb ) { ColorMap::iterator it = predefinedColors.find( color_name ); if ( it == predefinedColors.end() ) return false; rgb = (*it).second; return true; }