void render(double time) { logErrors(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); scene->render(time); logErrors(); }
bool OplsScanner::readInOpls(string filename) { fileName = filename; if (filename.empty()) { std::cerr << "Error: readInOpls(): empty filename given" << std::endl; return false; } int numOfLines=0; ifstream oplsScanner(filename.c_str()); if (!oplsScanner.is_open()) { std::cerr << "Error: readInOpls(): could not open file (" << filename << ")" << std::endl; return false; } else { string line; while (oplsScanner.good()) { numOfLines++; getline (oplsScanner,line); try { if (line.at(0) != '#' && numOfLines > 1) { addLineToTable(line,numOfLines); } } catch (std::out_of_range& e) { // Eat the exception and continue...why aren't we failing? } } oplsScanner.close(); logErrors(); } return true; }
int Opls_Scan::scanInOpls(string filename) { int numOfLines=0; ifstream oplsScanner(filename.c_str()); if( !oplsScanner.is_open() ) return -1; else { string line; while( oplsScanner.good() ) { numOfLines++; getline(oplsScanner,line); //check if it is a commented line, //or if it is a title line try { if(line.at(0) != '#' && numOfLines > 1) addLineToTable(line,numOfLines); } catch (std::out_of_range& e) {} } oplsScanner.close(); logErrors(); } return 0; }
void Sunrise::render(double time) { render_init(); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glShadeModel(GL_SMOOTH); glDrawArrays(GL_TRIANGLE_FAN, 0, mesh.vertexCount()); logErrors(); }
void render(double time) { //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); selectRenderTexture(1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); logErrors(); normal_projection(); logErrors(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); double scale = 8.0; glScaled(scale, scale, scale); glTranslated(0, -1, 0); float pos[] = {1, 1, 2, 1}; glLightfv(GL_LIGHT0, GL_POSITION, pos); glRotated(5, 1, 0, 0); float tree_pos[] = {-1.6, 0, 0, 10, 1.0, 1.8, 0, -4, 111, 1.0, 0.7, 0, -10, 48, 0.5, -0.6, 0.05, -14, 92, 0.3}; for (int i = 0 ; i < 4 ; ++i) { glPushMatrix(); glTranslated(tree_pos[i * 5], tree_pos[i * 5 + 1], tree_pos[i * 5 + 2]); glScaled(tree_pos[i * 5 + 4], tree_pos[i * 5 + 4], tree_pos[i * 5 + 4]); glRotated(tree_pos[i * 5 + 3], 0, 1, 0); tree->render(time); leaves->render(time); glPopMatrix(); } glScaled(0.1, 0.3, 0.1); glTranslated(-256, 0, -256); ground->render(time); logErrors(); //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); selectRenderTexture(0); edges.colour_texture = texture[0]; edges.depth_texture = texture[1]; edges.render(time); }
void Edges::render(double /*time*/) { logErrors(); glShadeModel(GL_SMOOTH); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); render_init(); uniform_i("colour", 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, colour_texture); uniform_i("depth", 1); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, depth_texture); glDrawArrays(mesh.meshType(), 0, mesh.vertexCount()); logErrors(); glActiveTexture(GL_TEXTURE0); logErrors(); }
/** Executes the algorithm * @throw NullPointerException if a getDetector() returns NULL or pressure or wall thickness is not set * @throw invalid_argument if the shape of a detector is isn't a cylinder aligned on axis or there is no baseInstrument * @throw runtime_error if the SpectraDetectorMap had not been filled */ void DetectorEfficiencyCor::exec() { //gets and checks the values passed to the algorithm retrieveProperties(); // wave number that the neutrons originally had m_ki = std::sqrt(m_Ei/KSquaredToE); // Store some information about the instrument setup that will not change m_samplePos = m_inputWS->getInstrument()->getSample()->getPos(); int64_t numHists = m_inputWS->getNumberHistograms(); double numHists_d = static_cast<double>(numHists); const int64_t progStep = static_cast<int64_t>(ceil(numHists_d/100.0)); PARALLEL_FOR2(m_inputWS,m_outputWS) for (int64_t i = 0; i < numHists; ++i ) { PARALLEL_START_INTERUPT_REGION m_outputWS->setX(i, m_inputWS->refX(i)); try { correctForEfficiency(i); } catch (Exception::NotFoundError &) { // if we don't have all the data there will be spectra we can't correct, avoid leaving the workspace part corrected MantidVec& dud = m_outputWS->dataY(i); std::transform(dud.begin(),dud.end(),dud.begin(), std::bind2nd(std::multiplies<double>(),0)); PARALLEL_CRITICAL(deteff_invalid) { m_spectraSkipped.push_back(m_inputWS->getAxis(1)->spectraNo(i)); } } // make regular progress reports and check for cancelling the algorithm if ( i % progStep == 0 ) { progress(static_cast<double>(i)/numHists_d); interruption_point(); } PARALLEL_END_INTERUPT_REGION } PARALLEL_CHECK_INTERUPT_REGION logErrors(); setProperty("OutputWorkspace", m_outputWS); }
// Initialize using an XML file. //---------------------------------------- bool ofxOpenNIContext::setupUsingXMLFile(std::string sFile) { xn::EnumerationErrors errors; if(sFile == "") sFile = ofToDataPath("openni/config/ofxopenni_config.xml",true); printf("Using file: %s\n", sFile.c_str()); XnStatus result = context.InitFromXmlFile(sFile.c_str(), &errors); if(result != XN_STATUS_OK) logErrors(errors); BOOL_RC(result, "ofxOpenNIContext.setupUsingXMLFile()"); }
void PhongModel::render(double /*time*/) { render_init(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); glEnable(GL_CULL_FACE); uniform("ambient", ambient); uniform("diffuse", diffuse); uniform("specular", specular); uniform("shininess", shininess); uniform("colour", colour); glDrawArrays(mesh.meshType(), 0, mesh.vertexCount()); logErrors(); }
// Initialize using an .ONI recording. //---------------------------------------- bool ofxOpenNIContext::setupUsingRecording(std::string sFileRecording) { xn::EnumerationErrors errors; initContext(); addLicense("PrimeSense", "0KOIk2JeIBYClPWVnMoRKn5cdY4="); is_using_recording = true; std::string file_path = ofToDataPath(sFileRecording.c_str(), true); printf("Attempting to open file: %s\n", file_path.c_str()); XnStatus result = context.OpenFileRecording(file_path.c_str()); if(result != XN_STATUS_OK) logErrors(errors); BOOL_RC(result, "Loading file"); }
// Just initialize; use this when you"re creating nodes yourself. //---------------------------------------- bool ofxOpenNIContext::initContext(){ xn::EnumerationErrors errors; XnStatus result = context.Init(); if(result != XN_STATUS_OK) logErrors(errors); BOOL_RC(result, "ofxOpenNIContext.setup()"); }