void VolumeIOHelper::loadURL(const std::string& url, VolumeReader* reader) { tgtAssert(reader, "null pointer passed"); try { std::vector<VolumeURL> origins = reader->listVolumes(url); if (origins.size() > 1) { // if more than one volume listed at URL, show listing dialog tgtAssert(volumeListingDialog_, "no volumelistingdialog"); volumeListingDialog_->setOrigins(origins, reader); volumeListingDialog_->show(); } else if (origins.size() == 1) { // load single volume directly loadOrigin(origins.front(), reader); } else { LWARNING("No volumes found at URL '" << url << "'"); QErrorMessage* errorMessageDialog = new QErrorMessage(VoreenApplicationQt::qtApp()->getMainWindow()); errorMessageDialog->showMessage(QString::fromStdString("No volumes found at '" + url + "'")); } } catch (const tgt::FileException& e) { LWARNING(e.what()); QErrorMessage* errorMessageDialog = new QErrorMessage(VoreenApplicationQt::qtApp()->getMainWindow()); errorMessageDialog->showMessage(e.what()); } }
void OTBTextWriterProcessor::saveCSV() { std::string filename = CSVFile_.get(); if (!filename.empty()) { hasFileName = true; } if(this->isReady() && hasFileName) { //Connect with data inport inData = inPort_.getData(); //Write the csv header to file std::ofstream outfile; outfile.open(CSVFile_.get().c_str()); outfile << inData; outfile.close(); }else if(!this->isReady()){ LWARNING("Input Data not connected"); return; }else if(!hasFileName){ LWARNING("CSV File Name Not Set"); return; } LINFO("CSV written succesfully!"); }
void OTBVectorImageReaderProcessor::setSingleBandData() { if(hasImage && enableSingleBand_.get()){ //Image is loaded and single band output enabled reader->GenerateOutputInformation(); int bands = reader->GetOutput()->GetNumberOfComponentsPerPixel(); LINFO("Image has " << bands << " bands."); imageList = VectorImageToImageListType::New(); imageList->SetInput(reader->GetOutput()); imageList->UpdateOutputInformation(); if(outputBand_.get() <= bands && outputBand_.get() > 0){ outPort2_.setData(imageList->GetOutput()->GetNthElement(outputBand_.get()-1)); } else{ LWARNING("Selected band is out of range. Please select another value."); return; } } else if(!hasImage){ LWARNING("Image not loaded!"); return; } else if(!enableSingleBand_.get()){ LWARNING("Single Band Output not enabled."); return; } else{ return; } }
void OTBVectorDataWriterProcessor::saveVectorData() { std::string filename = vectorDataFile_.get(); if (!filename.empty()) { hasVectorData = true; } if(this->isReady() && hasVectorData) { writer->SetFileName(filename.c_str()); writer->SetInput(inPort_.getData()); try { writer->Update(); } catch (itk::ExceptionObject& err) { LWARNING("ExceptionObject caught ! " << err); return; } } else if(!this->isReady()) { LWARNING("Writer inport not connected"); return; } else if(!hasVectorData) { LWARNING("Vector Data file name not set correctly"); return; } LINFO("'" << filename << "'" << " written succesfully!"); }
bool CanvasRenderer::renderToImage(const std::string &filename, tgt::ivec2 dimensions) { if (!canvas_) { LWARNING("CanvasRenderer::renderToImage(): no canvas assigned"); renderToImageError_ = "No canvas assigned"; return false; } if (!inport_.hasRenderTarget()) { LWARNING("CanvasRenderer::renderToImage(): inport has no data"); renderToImageError_ = "No rendering"; return false; } tgt::ivec2 oldDimensions = inport_.getSize(); // resize texture container to desired image dimensions and propagate change if (oldDimensions != dimensions) { canvas_->getGLFocus(); inport_.requestSize(dimensions); } // render with adjusted viewport size bool success = renderToImage(filename); // reset texture container dimensions from canvas size if (oldDimensions != dimensions) { inport_.requestSize(oldDimensions); } return success; }
void SocketCan::canRead(CANFrame::PtrList &msgs) { int s = sizeof(can_frame); char buffer[sizeof(can_frame)]; int readbytes = read(this->socketHandler, buffer, s); if (readbytes == -1) { int nerr = errno; if (nerr == EAGAIN){ return; } else { LWARNING("Can") << "read: " << readbytes << " expected: " << s << " failed with: " << nerr << LE; throw Poco::Exception("can read failed"); } } if (readbytes == 0) { return; } if (readbytes != s) { LWARNING("Can") << "read: " << readbytes << " expected: " << s << LE; throw Poco::Exception("can read size missmatch"); } std::vector<Poco::UInt8> bytes(s, 0); for (int i = 0; i < s; i++) { bytes[i] = buffer[i]; } msgs.push_back(new CANFrame(bytes)); }
void VolumeReader::read(VolumeRAM* volume, FILE* fin) { if (progress_) { size_t max = tgt::max(volume->getDimensions()); // validate dimensions if (max == 0 || max > 1e5) { LERROR("Invalid dimensions: " << volume->getDimensions()); std::ostringstream stream; stream << volume->getDimensions(); throw VoreenException("Invalid dimensions: " + stream.str()); } // no remainder possible because getNumBytes is a multiple of max size_t sizeStep = volume->getNumBytes() / static_cast<size_t>(max); for (size_t i = 0; i < size_t(max); ++i) { if (fread(reinterpret_cast<char*>(volume->getData()) + sizeStep * i, 1, sizeStep, fin) == 0) LWARNING("fread() failed"); progress_->setProgress(static_cast<float>(i) / static_cast<float>(max)); } } else { if (fread(reinterpret_cast<char*>(volume->getData()), 1, volume->getNumBytes(), fin) == 0) LWARNING("fread() failed"); } }
void ProgressBar::setProgress(float progress) { if (!(progressRange_.x <= progressRange_.y && progressRange_.x >= 0.f && progressRange_.y <= 1.f)) { LERROR("invalid progress range"); } if (progress < 0.f) { if (!printedErrorMessage_) LWARNING("progress value " << progress << " out of valid range [0,1]"); printedErrorMessage_ = true; progress = 0.f; } else if (progress > 1.f) { if (!printedErrorMessage_) LWARNING("progress value " << progress << " out of valid range [0,1]"); printedErrorMessage_ = true; progress = 1.f; } else { printedErrorMessage_ = false; } progress_ = progressRange_.x + progress*(progressRange_.y - progressRange_.x); update(); }
VARIANT* GpuCapabilitiesWindows::WMIquery(std::string wmiClass, std::string attribute) { // Code based upon: "Example: Getting WMI Data from the Local Computer" // http://msdn2.microsoft.com/en-us/library/aa390423.aspx if (!isWMIinited()) { LWARNING("WMI not initiated"); return 0; } HRESULT hres; VARIANT* result = 0; // Step 6: -------------------------------------------------- // Use the IWbemServices pointer to make requests of WMI ---- IEnumWbemClassObject* pEnumerator = NULL; std::string query = "SELECT " + attribute + " FROM " + wmiClass; hres = pWbemServices_->ExecQuery( bstr_t("WQL"), bstr_t(query.c_str()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); if (FAILED(hres)) { LWARNING("ERROR: WMI query failed: " << query); return 0; } // Step 7: ------------------------------------------------- // Get the data from the query in step 6 ------------------- IWbemClassObject* pclsObj = 0; ULONG uReturn = 0; if (pEnumerator) { HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); if (uReturn) { // Get the value of the attribute and store it in result result = new VARIANT; hr = pclsObj->Get(LPCWSTR(str2wstr(attribute).c_str()), 0, result, 0, 0); } } if (!result) { LWARNING("No WMI query result"); } // Clean enumerator and pclsObject if (pEnumerator) pEnumerator->Release(); if (pclsObj) pclsObj->Release(); return result; }
void Processor::serialize(XmlSerializer& s) const { // meta data metaDataContainer_.serialize(s); // misc settings s.serialize("name", id_); // serialize properties PropertyOwner::serialize(s); // --- // the following entities are static resources (i.e. already existing at this point) // that should therefore not be dynamically created by the serializer // const bool usePointerContentSerialization = s.getUsePointerContentSerialization(); s.setUsePointerContentSerialization(true); // serialize inports using a temporary map std::map<std::string, Port*> inportMap; for (std::vector<Port*>::const_iterator it = inports_.begin(); it != inports_.end(); ++it) inportMap[(*it)->getID()] = *it; try { s.serialize("Inports", inportMap, "Port", "name"); } catch (SerializationException& e) { LWARNING(e.what()); } // serialize outports using a temporary map std::map<std::string, Port*> outportMap; for (std::vector<Port*>::const_iterator it = outports_.begin(); it != outports_.end(); ++it) outportMap[(*it)->getID()] = *it; try { s.serialize("Outports", outportMap, "Port", "name"); } catch (SerializationException& e) { LWARNING(e.what()); } // serialize interaction handlers using a temporary map map<string, InteractionHandler*> handlerMap; const std::vector<InteractionHandler*>& handlers = getInteractionHandlers(); for (vector<InteractionHandler*>::const_iterator it = handlers.begin(); it != handlers.end(); ++it) handlerMap[(*it)->getID()] = *it; try { s.serialize("InteractionHandlers", handlerMap, "Handler", "name"); } catch (SerializationException& e) { LWARNING(e.what()); } s.setUsePointerContentSerialization(usePointerContentSerialization); // --- static resources end --- }
void PythonModule::initialize() throw (VoreenException) { VoreenModule::initialize(); // // Initialize Python interpreter // LINFO("Python version: " << Py_GetVersion()); // Pass program name to the Python interpreter char str_pyvoreen[] = "PyVoreen"; Py_SetProgramName(str_pyvoreen); // Initialize the Python interpreter. Required. Py_InitializeEx(false); if (!Py_IsInitialized()) throw VoreenException("Failed to initialize Python interpreter"); // required in order to use threads. PyEval_InitThreads(); // init ResourceManager search path addPath(""); addPath(VoreenApplication::app()->getScriptPath()); addPath(VoreenApplication::app()->getModulePath("python/scripts")); // init Python's internal module search path addModulePath(VoreenApplication::app()->getScriptPath()); addModulePath(VoreenApplication::app()->getModulePath("python/scripts")); // // Redirect script output from std::cout to voreen_print function (see above) // // import helper module if (!Py_InitModule("voreen_internal", internal_methods)) { LWARNING("Failed to init helper module 'voreen_internal'"); } // load output redirector script and run it once std::string filename = "outputcatcher.py"; LDEBUG("Loading Python init script '" << filename << "'"); PythonScript* initScript = load(filename); if (initScript) { if (!initScript->run()) LWARNING("Failed to run init script '" << filename << "': " << initScript->getLog()); dispose(initScript); } else { LWARNING("Failed to load init script '" << filename << "'"); } // // Create actual Voreen Python bindings // pyVoreen_ = new PyVoreen(); }
void OTBKMeansImageClassificationProcessor::saveImage() { std::string filename = imageFile_.get(); if (!filename.empty()) { hasImage = true; } if(this->isReady() && hasImage) { try { writer->SetFileName(imageFile_.get()); const unsigned int sampleSize = ClassificationFilterType::MaxSampleDimension; const unsigned int parameterSize = numClasses_.get() * sampleSize; KMeansParametersType parameters; parameters.SetSize(parameterSize); parameters.Fill(0); for (unsigned int i = 0; i < numClasses_.get(); ++i) { for (unsigned int j = 0; j < inPort_.getData()->GetNumberOfComponentsPerPixel(); ++j) { parameters[i * sampleSize + j] = atof(argv[4 + i * inPort_.getData()->GetNumberOfComponentsPerPixel() + j]); } } filter->SetCentroids(parameters); filter->SetInput(inPort_.getData()); writer->SetInput(filter->GetOutput()); writer->Update(); } catch(itk::ExceptionObject& err) { LWARNING("ExceptionObject caught !"); return; } }else if(!this->isReady()){ LWARNING("Writer Inport not connected"); return; }else if(!hasImage){ LWARNING("Image Name Not Set"); return; } LINFO("Classiciaction written succesfully!"); }
VoreenApplication::~VoreenApplication() { if (initializedGL_) { if (tgt::LogManager::isInited()) LWARNING("~VoreenApplication(): OpenGL has not been deinitialized. Call deinitGL() before destruction."); return; } if (initialized_) { if (tgt::LogManager::isInited()) LWARNING("~VoreenApplication(): application has not been deinitialized. Call deinit() before destruction."); return; } }
bool Cache::store() { if(!initialized_) return false; std::string dir = getCurrentCacheDir(); if (!FileSys.dirExists(dir)) { if(!FileSys.createDirectoryRecursive(dir)) return false; //write property state: std::string propertyState = getPropertyState(); std::string fname = dir + "/propertystate.txt"; std::fstream out(fname.c_str(), std::ios::out | std::ios::binary); if (out.is_open() || !out.bad()) { out.write(propertyState.c_str(), propertyState.length()); } else { LERROR("Could not write propertystate file!"); FileSys.deleteDirectoryRecursive(dir); return false; } out.close(); return storeOutportsToDir(dir); } else { std::string fname = dir + "/propertystate.txt"; if(FileSys.fileExists(fname)) { std::string propertyState = getPropertyState(); if(stringEqualsFileContent(propertyState, fname)) return true; else { LWARNING("PropertyState Collision! Deleting cache entry."); FileSys.deleteDirectoryRecursive(dir); return storeOutportsToDir(dir); } } else { LWARNING("No PropertyState in cache entry! Deleting."); FileSys.deleteDirectoryRecursive(dir); return storeOutportsToDir(dir); } } }
bool VoreenVisualization::rebuildShaders() { if (sharedContext_) sharedContext_->getGLFocus(); else LWARNING("No shared context object"); bool allSuccessful = true; std::vector<Processor*> procs = workspace_->getProcessorNetwork()->getProcessors(); for(size_t i = 0; i < procs.size(); i++) { std::vector<ShaderProperty*> props = procs.at(i)->getPropertiesByType<ShaderProperty>(); for(size_t j = 0; j < props.size(); j++) { if(!props.at(j)->rebuild()) allSuccessful = false; } } if (!ShdrMgr.rebuildAllShadersFromFile()) allSuccessful = false; if (allSuccessful) { evaluator_->invalidateProcessors(); return true; } else { return false; } }
void VoreenApplication::addModule(VoreenModule* module) { tgtAssert(module, "null pointer passed"); if (std::find(modules_.begin(), modules_.end(), module) == modules_.end()) modules_.push_back(module); else LWARNING("Module '" << module->getName() << "' has already been registered. Skipping."); }
void FramebufferObject::detachTexture(GLenum attachment) { size_t index = decodeAttachment(attachment); if (attachments_[index] != 0) { switch (attachments_[index]->getType()) { case GL_TEXTURE_1D: glFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_1D, 0, 0); break; case GL_TEXTURE_2D_ARRAY: glFramebufferTextureLayerEXT(GL_FRAMEBUFFER_EXT, attachment, 0, 0, 0); break; case GL_TEXTURE_3D: glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_3D, 0, 0, 0); break; default: // GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, 0, 0); break; } attachments_[index] = 0; LGL_ERROR; if (index < CGT_FRAMEBUFFEROBJECT_MAX_SUPPORTED_COLOR_ATTACHMENTS) --numColorAttachments_; } else { LWARNING("Trying to detach unknown texture!"); } }
InstrumentDecoder::InstrumentDecoder(const ghoul::Dictionary& dictionary) { bool success = dictionary.getValue(keyDetector, _type); ghoul_assert(success, "Instrument has not provided detector type"); for_each(_type.begin(), _type.end(), [](char& in){ in = ::toupper(in); }); if (!dictionary.hasKeyAndValue<std::string>(keyStopCommand) && _type == "SCANNER"){ LWARNING("Scanner must provide stop command, please check mod file."); }else{ dictionary.getValue(keyStopCommand, _stopCommand); } std::vector<std::string> spice; ghoul::Dictionary spiceDictionary; success = dictionary.getValue(keySpice, spiceDictionary); ghoul_assert(success, "Instrument did not provide spice ids"); _spiceIDs.resize(spiceDictionary.size()); for (int i = 0; i < _spiceIDs.size(); ++i) { std::string id; spiceDictionary.getValue(std::to_string(i + 1), id); _spiceIDs[i] = id; } }
std::string Cache::getInterfaceString() { std::string interfaceStr; interfaceStr += "Inports:\n"; for(size_t i=0; i<inports_.size(); i++) { interfaceStr += inports_[i] + "\n"; } interfaceStr += "\n"; interfaceStr += "Outports:\n"; for(size_t i=0; i<outports_.size(); i++) { interfaceStr += outports_[i] + "\n"; } interfaceStr += "\n"; interfaceStr += "Properites:\n"; for(size_t i=0; i<properties_.size(); i++) { Property* prop = processor_->getProperty(properties_[i]); if(!prop) { LWARNING("Property " << properties_[i] << " is not registered at the processor!"); } interfaceStr += prop->getID() + " [" + prop->getClassName() + "]\n"; } return interfaceStr; }
std::string Cache::getPropertyState() { // create temporary property map for serialization std::map<std::string, Property*> propertyMap; for (size_t i=0; i < properties_.size(); ++i) { Property* p = processor_->getProperty(properties_[i]); if(p) propertyMap[properties_[i]] = p; } // serialize properties XmlSerializer s; const bool usePointerContentSerialization = s.getUsePointerContentSerialization(); s.setUsePointerContentSerialization(true); try { s.serialize("Properties", propertyMap, "Property", "name"); } catch (SerializationException& e) { LWARNING(e.what()); } s.setUsePointerContentSerialization(usePointerContentSerialization); std::stringstream stream; s.write(stream); return stream.str(); }
void Processor::removePort(Port* port) { tgtAssert(port, "Null pointer passed"); if (port->isInitialized()) { LWARNING("removePort() Port '" << getID() << "." << port->getID() << "' " << "has not been deinitialized"); } //port->setProcessor(NULL); CoProcessorPort* cpp = dynamic_cast<CoProcessorPort*>(port); if (port->isOutport()) { if (cpp) coProcessorOutports_.erase(std::find(coProcessorOutports_.begin(), coProcessorOutports_.end(), port)); else outports_.erase(std::find(outports_.begin(), outports_.end(), port)); } else { if (cpp) coProcessorInports_.erase(std::find(coProcessorInports_.begin(), coProcessorInports_.end(), port)); else inports_.erase(std::find(inports_.begin(), inports_.end(), port)); } map<std::string, Port*>::iterator it = portMap_.find(port->getID()); if (it != portMap_.end()) portMap_.erase(it); else { LERROR("Port with name " << port->getID() << " was not found in port map!"); tgtAssert(false, std::string("Port with name " + port->getID() + " was not found in port map!").c_str()); } notifyPortsChanged(); }
void OctreeBrickPoolManagerDisk::deserialize(XmlDeserializer& s) { OctreeBrickPoolManagerBase::deserialize(s); s.deserialize("maxSingleBufferSizeBytes", maxBufferSizeBytes_); s.deserialize("singleBufferSizeBytes", singleBufferSizeBytes_); s.deserialize("bufferFiles", bufferFiles_); s.deserialize("brickPoolExists", brickPoolExists_); s.deserialize("brickPoolPath", brickPoolPath_); s.deserialize("bufferFilePrefix", bufferFilePrefix_); // initialize/check brick pool if (brickPoolExists_) { if (!tgt::FileSystem::dirExists(brickPoolPath_)) throw VoreenException("Brick pool path does not exist: " + brickPoolPath_); // collect brick buffer files from pool path std::vector<std::string> files = tgt::FileSystem::listFiles(brickPoolPath_, true); for (size_t i=0; i<files.size(); i++) { if (startsWith(files.at(i), bufferFilePrefix_)) bufferFiles_.push_back(files.at(i)); } if (bufferFiles_.empty()) { LWARNING("No files with prefix '" + bufferFilePrefix_ + "' found at brick pool path: " + brickPoolPath_); } } }
bool TCPServer::initialize(int port) { #ifdef __WIN32__ if (!NetworkIsInitialized()) NetworkInitialize(); #endif if (isOpen()) { LWARNING("Already initialized, aborting initialize."); return false; } _serverSocket = socket(AF_INET, SOCK_STREAM, 0); if (_serverSocket < 0) return false; // set all values in structs to zero memset(&_serv_addr, 0, sizeof(_serv_addr)); _serv_addr.sin_family = AF_INET; _serv_addr.sin_addr.s_addr = INADDR_ANY; _serv_addr.sin_port = htons(port); if (bind(_serverSocket, (struct sockaddr *) &_serv_addr,sizeof(_serv_addr)) < 0) { LERROR("Could not bind port: " << port); return false; } // start listen listen(_serverSocket,5); LINFO("Successfully initialized socket on port " << port); return true; }
void VolumeURLListProperty::deserialize(XmlDeserializer& s) { Property::deserialize(s); std::vector<std::string> urlList = value_; std::map<std::string, bool> selectMap = selectionMap_; s.deserialize("VolumeURLs", urlList, "url"); try { s.deserialize("Selection", selectMap, "entry", "url"); } catch (SerializationException& e) { s.removeLastError(); LWARNING("Failed to deserialize selection map: " << e.what()); } // convert URLs to absolute path std::string basePath = tgt::FileSystem::dirName(s.getDocumentPath()); for (size_t i=0; i<urlList.size(); i++) { std::string url = urlList[i]; std::string urlConv = VolumeURL::convertURLToAbsolutePath(url, basePath); urlList[i] = urlConv; if (selectMap.find(url) != selectMap.end()) { bool selected = selectMap[url]; selectMap.erase(url); selectMap.insert(std::pair<std::string, bool>(urlConv, selected)); } } value_ = urlList; selectionMap_ = selectMap; invalidate(); }
void OTBVectorImageReaderProcessor::loadImage() { // necessary since the passed string reference might be changed during clearImage/invalidate, std::string filename = imageFile_.get(); outPort_.setImagePath(filename); // check for empty filename if (filename.empty()) return; // load image as texture hasImage = true; /*texture_ = TexMgr.load(filename, tgt::Texture::LINEAR, false, false, true, false);*/ reader->SetFileName(filename.c_str()); reader->GenerateOutputInformation(); if (!hasImage) { LWARNING("Failed to load image: " << filename); imageFile_.set(""); } setOutPortData(); //invalidate(); }
void TransFunc1DKeysEditor::loadTransferFunction() { if (!transferFuncIntensity_) { LWARNING("No valid transfer function assigned"); return; } //create filter with supported file formats QString filter = "transfer function ("; for (size_t i = 0; i < transferFuncIntensity_->getLoadFileFormats().size(); ++i) { std::string temp = "*." + transferFuncIntensity_->getLoadFileFormats()[i] + " "; filter.append(temp.c_str()); } filter.replace(filter.length()-1, 1, ")"); QString fileName = getOpenFileName(filter); if (!fileName.isEmpty()) { if (transferFuncIntensity_->load(fileName.toStdString())) { updateMappingSpin(true); updateThresholdFromProperty(); updateTransferFunction(); } else { QMessageBox::critical(this, tr("Error"), "The selected transfer function could not be loaded."); LERROR("The selected transfer function could not be loaded. Maybe the file is corrupt."); } } }
void OTBCSVReaderProcessor::loadCSV() { std::string filename = CSVFile_.get(); if (!filename.empty()) { hasFileName = true; } if(hasFileName) { //Read csv from file std::ifstream infile(CSVFile_.get().c_str()); std::stringstream buffer; buffer << infile.rdbuf(); infile.close(); outPort_.setData(buffer.str()); outPort_.setDataPath(filename); }else if(!hasFileName){ LWARNING("CSV File Name Not Set"); return; } LINFO("CSV data loaded"); }
void PythonModule::addOutputListener(PythonOutputListener* listener) { tgtAssert(listener, "null pointer passed"); if (std::find(outputListeners_.begin(), outputListeners_.end(), listener) == outputListeners_.end()) outputListeners_.push_back(listener); else LWARNING("Output listener already registered"); }
void DatVolumeWriter::write(const std::string& filename, const VolumeBase* volumeHandle) throw (tgt::IOException) { tgtAssert(volumeHandle, "No volume handle"); const VolumeRAM* volume = volumeHandle->getRepresentation<VolumeRAM>(); if (!volume) { LWARNING("No volume"); return; } std::string datname = filename; std::string rawname = getFileNameWithoutExtension(filename) + ".raw"; LINFO("saving " << datname << " and " << rawname); std::fstream datout(datname.c_str(), std::ios::out); std::fstream rawout(rawname.c_str(), std::ios::out | std::ios::binary); if (!datout.is_open() || !rawout.is_open() || datout.bad() || rawout.bad()) throw tgt::IOException(); datout << getDatFileString(volumeHandle, rawname); if (datout.bad()) throw tgt::IOException(); datout.close(); // write raw file const char* data = static_cast<const char*>(volume->getData()); size_t numbytes = volume->getNumBytes(); rawout.write(data, numbytes); if (rawout.bad()) throw tgt::IOException(); rawout.close(); }
void VisualizationProcessor::createAndAttachTexture(GLint internalFormat) { GLenum attachment = 0; switch(internalFormat) { case GL_R32F: case GL_RGB: case GL_RGB16F_ARB: case GL_RGBA: case GL_RGBA8: case GL_RGBA16: case GL_RGBA16F: case GL_RGBA32F: if (_fbo->getNumColorAttachments() >= static_cast<size_t>(GpuCaps.getMaxColorAttachments())) { cgtAssert(false, "Tried to attach more color textures to FBO than supported!"); LWARNING("Tried to attach more color textures to FBO than supported, aborted."); return; } attachment = static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + _fbo->getNumColorAttachments()); break; case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: #ifdef GL_DEPTH_COMPONENT32F case GL_DEPTH_COMPONENT32F: #endif cgtAssert(_fbo->getDepthAttachment() == 0, "Tried to attach more than one depth texture."); attachment = GL_DEPTH_ATTACHMENT; break; default: cgtAssert(false, "Unknown internal format!"); } createAndAttachTexture(internalFormat, attachment); }