/*! Read data from the file */ void Preferences::readData() { // open file QFile datafile(d->file_); if (!datafile.open(IO_ReadOnly)) { // error opening file qWarning("Error: cannot open preferences file " + d->file_); datafile.close(); d->filestate_ = false; return; } d->filestate_ = true; // open dom document QDomDocument doc("preferences"); if (!doc.setContent(&datafile)) { qWarning("Error: " + d->file_ + " is not a proper preferences file"); datafile.close(); d->formatstate_ = false; return; } datafile.close(); // check the doc type and stuff if (doc.doctype().name() != "preferences") { // wrong file type qWarning("Error: " + d->file_ + " is not a valid preferences file"); d->formatstate_ = false; return; } QDomElement root = doc.documentElement(); if (root.attribute("application") != d->format_) { // right file type, wrong application qWarning("Error: " + d->file_ + " is not a preferences file for " + d->format_); d->formatstate_ = false; return; } // We don't care about application version... // get list of groups QDomNodeList nodes = root.elementsByTagName("group"); // iterate through the groups QDomNodeList options; for ( uint n = 0; n < nodes.count(); ++n ) { if ( nodes.item(n).isElement() && !nodes.item(n).isComment() ) { processGroup( nodes.item(n).toElement() ); } } d->formatstate_ = true; }
//virtual void LLViewerOctreeCull::visit(const OctreeNode* branch) { LLViewerOctreeGroup* group = (LLViewerOctreeGroup*) branch->getListener(0); preprocess(group); if (checkObjects(branch, group)) { processGroup(group); } }
JNIEXPORT jint JNICALL Java_org_yegor_reader_PreviewProcessor_processFrame( JNIEnv* env,jobject thiz, jbyteArray jdata, jint width, jint height) { jbyte* yuv= (*env).GetByteArrayElements(jdata,NULL); if (yuv == NULL) { return -1; } create_count= 0; merge_count= 0; add_count= 0; Bitmap bitmap(yuv, width,height); ManagerOfGroups manager(bitmap.width,bitmap.height); groupPixels(manager, bitmap); /* for (size_t y= 0; y< height; y++) { for (size_t x= 0; x < width; x++) { Pixel pixel= bitmap.pixel(x,y); uint32_t number = manager.isInGroup(pixel) ? manager.getGroupNumber(pixel) : 0; //uint8_t color= number*255/manager.getLastGroupNumber(); uint8_t color= number*100 % 256; pixel.setColor(color); } } */ LOG("create count = %d",create_count); LOG("merge_count = %d",merge_count); LOG("add_count = %d",add_count); uint32_t countOfAnclaves= 0; for (size_t y= 0; y< height; y++) { for (size_t x= 0; x < width; x++) { Pixel pixel= bitmap.pixel(x,y); if (manager.getGroupNumber(pixel) == y*width+x+1) { if (processGroup(bitmap,manager,pixel)) { countOfAnclaves++; } } } } LOG("Count of anclaves = %d",countOfAnclaves); (*env).ReleaseByteArrayElements(jdata,yuv,0); return 0; }
bool ObjParser::parse( std::istream& input ) { reset(); // Read each line of the .obj file while ( readNextLine( input ) && !hasErrors() ) { // Skip lines that are empty if ( isCurrentLineEmpty() ) { continue; } // Split the input line into "words' that are separated by // spaces. The first word is the next obj file command, the others // that follow are arguments to that command std::vector<std::string> tokens; tokenizeCommandString( lineText(), tokens ); assert( tokens.size() > 0 ); // What kind of command is this? if ( tokens[0] == "v" ) { processVertexPosition( tokens ); } else if ( tokens[0] == "vt" ) { processVertexTexCoord( tokens ); } else if ( tokens[0] == "vn" ) { processVertexNormal( tokens ); } else if ( tokens[0] == "g" ) { processGroup( tokens ); } else if ( tokens[0] == "f" ) { processFace( tokens ); } else if ( tokens[0] == "usemtl" ) { processMaterial( tokens ); } else if ( tokens[0] == "mtllib" ) { processMaterialLib( tokens ); } else if ( tokens[0] == "s" ) { // ignore smoothing groups } else { raiseError("Unknown .obj command encountered"); continue; } } // Make sure the last group has at least one face in it if ( m_objdata->currentGroup.empty() == false ) { if ( m_objdata->groups[ m_objdata->currentGroupIndex ].count == 0 ) { raiseError("The last active group didn't have any faces"); } } // Now we're done, make sure to return if the parsing was successful or // not return !hasErrors(); }