std::string Generator::interchangeTypeStr(const CXType &type) const { switch (type.kind) { case CXType_Int: return "int"; case CXType_Float: return "float"; case CXType_Double: return "double"; case CXType_Bool: return "bool"; case CXType_Unexposed: if (stringize(type) == "CCPointer<CCArray>") return "CCArray *"; else if (stringize(type) == "CCPointer<CCDictionary>") return "CCDictionary *"; else if (stringize(type) == "string") return "const std::string &"; else reportWarning("Unexposed type: " + stringize(type)); break; default: reportWarning("Unhandled type: " + stringize(type)); break; } return ""; }
void ViewWrapper3D::setTranslucentRenderingToDepthPeeling(bool setDepthPeeling) { bool success = true; if(setDepthPeeling) { //IsDepthPeelingSupported function don't seem to work on OSX (error messages or seg. fault) #ifndef __APPLE__ if (!IsDepthPeelingSupported(mView->getRenderWindow(), mView->getRenderer(), true)) { reportWarning("GPU do not support depth peeling. Rendering of translucent surfaces is not supported"); success = false; } #endif if (success && !SetupEnvironmentForDepthPeeling(mView->getRenderWindow(), mView->getRenderer(), 100, 0.1)) { reportWarning("Error setting depth peeling"); success = false; } else { report("Set GPU depth peeling"); } if(!success) settings()->setValue("View3D/depthPeeling", false); } else { TurnOffDepthPeeling(mView->getRenderWindow(), mView->getRenderer()); // if (TurnOffDepthPeeling(mView->getRenderWindow(), mView->getRenderer())) // report("Depth peeling turned off"); } }
bool FileParser::parseName (const std::string& name, const TokenLoc& loc, Scanner& scanner) { if (mState==NameState) { mName = name; mState = BeginCompleteState; return true; } if (mState==EndNameState) { // optional repeated name after end statement if (mName!=name) reportWarning ("Names for script " + mName + " do not match", loc); mState = EndCompleteState; return false; // we are stopping here, because there might be more garbage on the end line, // that we must ignore. // /// \todo allow this workaround to be disabled for newer scripts } if (mState==BeginCompleteState) { reportWarning ("Stray string (" + name + ") after begin statement", loc); return true; } return Parser::parseName (name, loc, scanner); }
bool NxuPhysicsExport::Write(const ::NxSceneDesc *scene,const char *userProperties,const char *id) { bool ret = false; ::NxSceneDesc sdesc = *scene; NxSceneDesc *sd = new NxSceneDesc; sd->mUserProperties = getGlobalString(userProperties); if ( id ) { sd->mId = id; } else { char scratch[512]; sprintf(scratch,"Scene_%d", mCollection->mScenes.size() ); sd->mId = getGlobalString(scratch); } CustomCopy cc; sd->copyFrom(sdesc,cc); if ( 1 ) { if ( sdesc.maxTimestep < 0.00001f ) { reportWarning("Scene Descriptor had an invalid maxTimestep of %f; changing it to 0.02", sdesc.maxTimestep); sdesc.maxTimestep = 0.02f; } if ( sdesc.maxIter < 1 || sdesc.maxIter > 1024 ) { reportWarning("Scene Descriptor had an invalid maxIter value of %d; changing it to the default of 8", sdesc.maxIter ); sdesc.maxIter = 8; } bool isValid = sdesc.isValid(); if ( !isValid ) { reportWarning("Supplied scene descriptor is invalid. Switching to the default settings."); ::NxSceneDesc def; sdesc = def; } } sd->mUserProperties = getGlobalString(userProperties); mCollection->mCurrentScene = sd; mCollection->mScenes.push_back(sd); ret = true; return ret; }
RepPtr ViewWrapper3D::createTrackedStreamRep(TrackedStreamPtr trackedStream) { if(!trackedStream->hasVideo()) { connect(trackedStream.get(), &TrackedStream::streamChanged, this, &ViewWrapper3D::dataViewPropertiesChangedSlot); return RepPtr(); } else disconnect(trackedStream.get(), &TrackedStream::streamChanged, this, &ViewWrapper3D::dataViewPropertiesChangedSlot); if(trackedStream->is3D()) { StreamRep3DPtr rep = StreamRep3D::New(mServices->spaceProvider(), mServices->patient()); rep->setTrackedStream(trackedStream); return rep; } else if (trackedStream->is2D()) { Stream2DRep3DPtr rep = Stream2DRep3D::New(mServices->spaceProvider()); rep->setTrackedStream(trackedStream); return rep; } else { reportWarning("ViewWrapper3D::createDataRep3D. TrackedStream is not 2D or 3D"); return RepPtr(); } }
void Pipeline::setOption(PropertyPtr adapter, QVariant value) { if (value.canConvert<bool>()) { BoolPropertyBasePtr specific = boost::dynamic_pointer_cast<BoolPropertyBase>(adapter); if (specific) specific->setValue(qvariant_cast<bool>(value)); } else if (value.canConvert<double>()) { DoublePropertyBasePtr specific = boost::dynamic_pointer_cast<DoublePropertyBase>(adapter); if (specific) specific->setValue(qvariant_cast<double>(value)); } else if (value.canConvert<QColor>()) { ColorPropertyBasePtr specific = boost::dynamic_pointer_cast<ColorPropertyBase>(adapter); if (specific) specific->setValue(qvariant_cast<QColor>(value)); } else if (value.canConvert<QString>()) { StringPropertyBasePtr specific = boost::dynamic_pointer_cast<StringPropertyBase>(adapter); if (specific) specific->setValue(qvariant_cast<QString>(value)); } else { reportWarning(QString("Attempt to set option of type %2 is not supported").arg(value.typeName())); } }
bool FileParser::parseKeyword (int keyword, const TokenLoc& loc, Scanner& scanner) { if (mState==BeginState && keyword==Scanner::K_begin) { mState = NameState; scanner.allowNameStartingwithDigit(); return true; } if (mState==NameState) { // keywords can be used as script names too. Thank you Morrowind for another // syntactic perversity :( mName = loc.mLiteral; mState = BeginCompleteState; return true; } if (mState==EndNameState) { // optional repeated name after end statement if (mName!=loc.mLiteral) reportWarning ("Names for script " + mName + " do not match", loc); mState = EndCompleteState; return false; // we are stopping here, because there might be more garbage on the end line, // that we must ignore. // /// \todo allow this workaround to be disabled for newer scripts } return Parser::parseKeyword (keyword, loc, scanner); }
void TrackingSystemIGSTKService::initialize() { if (!this->isConfigured()) { connect(this, SIGNAL(configured()), this, SLOT(initializeAfterConfigSlot())); this->configure(); return; } if (!this->isConfigured()) { reportWarning("Please configure before trying to initialize."); return; } #ifndef WIN32 if (!this->createSymlink()) { reportError("Initialization of tracking failed."); return; } #endif if (mTrackerThread) mTrackerThread->initialize(true); else reportError("Cannot initialize the tracking system because the tracking thread does not exist."); }
void TrackingSystemIGSTKService::configure() { if (mConfigurationFilePath.isEmpty() || !QFile::exists(mConfigurationFilePath)) { reportWarning(QString("Configuration file [%1] is not valid, could not configure the toolmanager.").arg(mConfigurationFilePath)); return; } //parse ConfigurationFileParser configParser(mConfigurationFilePath, mLoggingFolder); std::vector<IgstkTracker::InternalStructure> trackers = configParser.getTrackers(); if (trackers.empty()) { reportWarning("Failed to configure tracking."); return; } IgstkTracker::InternalStructure trackerStructure = trackers[0]; //we only support one tracker atm IgstkTool::InternalStructure referenceToolStructure; std::vector<IgstkTool::InternalStructure> toolStructures; QString referenceToolFile = configParser.getAbsoluteReferenceFilePath(); std::vector<QString> toolfiles = configParser.getAbsoluteToolFilePaths(); for (std::vector<QString>::iterator it = toolfiles.begin(); it != toolfiles.end(); ++it) { ToolFileParser toolParser(*it, mLoggingFolder); IgstkTool::InternalStructure internalTool = toolParser.getTool(); if ((*it) == referenceToolFile) referenceToolStructure = internalTool; else toolStructures.push_back(internalTool); } //new thread mTrackerThread.reset(new IgstkTrackerThread(trackerStructure, toolStructures, referenceToolStructure)); connect(mTrackerThread.get(), SIGNAL(configured(bool)), this, SLOT(trackerConfiguredSlot(bool))); connect(mTrackerThread.get(), SIGNAL(initialized(bool)), this, SLOT(initializedSlot(bool))); connect(mTrackerThread.get(), SIGNAL(tracking(bool)), this, SLOT(trackerTrackingSlot(bool))); connect(mTrackerThread.get(), SIGNAL(error()), this, SLOT(uninitialize())); //start threads if (mTrackerThread) mTrackerThread->start(); }
void IgstkToolManager::createTracker(ToolFileParser::TrackerInternalStructure trackerStructure) { TrackerPtr tracker(new IgstkTracker(trackerStructure)); if (tracker->isValid()) mTracker = tracker; else reportWarning("Invalid tracker."); }
DataPtr DataManagerImpl::loadData(QDomElement node, QString rootPath) { QString uid = node.toElement().attribute("uid"); QString name = node.toElement().attribute("name"); QString type = node.toElement().attribute("type"); QDir relativePath = this->findRelativePath(node, rootPath); QString absolutePath = this->findAbsolutePath(relativePath, rootPath); if (mData.count(uid)) // dont load same image twice return mData[uid]; DataPtr data = mDataFactory->create(type, uid, name); if (!data) { reportWarning(QString("Unknown type: %1 for file %2").arg(type).arg(absolutePath)); return DataPtr(); } bool loaded = data->load(absolutePath); if (!loaded) { reportWarning("Unknown file: " + absolutePath); return DataPtr(); } if (!name.isEmpty()) data->setName(name); data->setFilename(relativePath.path()); this->loadData(data); // conversion for change in format 2013-10-29 QString newPath = rootPath+"/"+data->getFilename(); if (QDir::cleanPath(absolutePath) != QDir::cleanPath(newPath)) { reportWarning(QString("Detected old data format, converting from %1 to %2").arg(absolutePath).arg(newPath)); data->save(rootPath); } return data; }
void MainWindowActions::savePatientFileSlot() { if (patientService()->getActivePatientFolder().isEmpty()) { reportWarning("No patient selected, select or create patient before saving!"); this->newPatientSlot(); return; } mServices->session()->save(); }
void RegistrationServiceProxy::onServiceAdded(RegistrationService* service) { mRegistrationService.reset(service, null_deleter()); connect(mRegistrationService.get(), SIGNAL(fixedDataChanged(QString)), this, SIGNAL(fixedDataChanged(QString))); connect(mRegistrationService.get(), SIGNAL(movingDataChanged(QString)), this, SIGNAL(movingDataChanged(QString))); if(mRegistrationService->isNull()) reportWarning("RegistrationServiceProxy::onServiceAdded mRegistrationService->isNull()"); emit fixedDataChanged(mRegistrationService->getFixedDataUid()); emit movingDataChanged(mRegistrationService->getMovingDataUid()); }
bool ProcessedUSInputData::validate() const { std::vector<TimedPosition> frameInfo = this->getFrames(); Eigen::Array3i inputDims = this->getDimensions(); if (inputDims[2] != static_cast<int>(frameInfo.size())) { QString msg("Mismatch in US input data: inputDims[2] != frameInfo.size() : %1 != %2"); reportWarning(msg.arg(inputDims[2]).arg(frameInfo.size())); return false; } if (inputDims[2]==0) { reportWarning("Empty US input data"); return false; } return true; }
ToolPtr PatientModelImplService::getProbeTool(QString videoSourceUid) { for (std::map<QString, ToolPtr>::const_iterator iter = mProbeTools.begin(); iter != mProbeTools.end(); ++iter) { ToolPtr tool = iter->second; ProbePtr probe = tool->getProbe(); if(probe && probe->getAvailableVideoSources().contains(videoSourceUid)) return tool; } reportWarning("Found no probe for stream" + videoSourceUid); return ToolPtr(); }
void Pipeline::execute(QString uid) { // generate |startIndex, endIndex>, pointing to the filters to be executed int endIndex = -1; int startIndex = endIndex; if (uid.isEmpty()) // execute entire pipeline, if necessary { endIndex = mFilters->size(); startIndex = endIndex; } else // execute at least one given filter, more if necessary { for (unsigned i=0; i<mFilters->size(); ++i) if (mFilters->get(i)->getUid()==uid) endIndex = i+1; // set end index to after filter to execute; startIndex = endIndex-1; } if (endIndex<0) // input filter not found: ignore return; // // filter i require node i as input // int startIndex = endIndex; // index now counts filters <0...N-1> // nodes are <0...N> for ( ; startIndex>=-1; --startIndex) { if (startIndex<0) break; if (mNodes[startIndex]->getData()) // index output node for filter[startIndex] break; // found node with data: stop here } std::cout << "Pipeline::execute filter range s=|" << startIndex << "," << endIndex << ">" << std::endl; if (startIndex<0) { reportWarning(QString("Cannot execute filter %1: No input data set").arg(uid)); return; } mCompositeTimedAlgorithm->clear(); for (unsigned i=startIndex; i<endIndex; ++i) mCompositeTimedAlgorithm->append(mTimedAlgorithm[mFilters->get(i)->getUid()]); // run all filters mCompositeTimedAlgorithm->execute(); }
void UsReconstructionImplService::selectData(QString filename, QString calFilesPath) { if (filename.isEmpty()) { reportWarning("no file selected"); return; } cx::UsReconstructionFileReaderPtr fileReader(new cx::UsReconstructionFileReader()); USReconstructInputData fileData = fileReader->readAllFiles(filename, calFilesPath); fileData.mFilename = filename; this->selectData(fileData); }
bool TemporalCalibration::checkFrameMovementQuality(std::vector<double> pos) { int count = 0; for (unsigned i=0; i<pos.size(); ++i) if (similar(pos[i], 0)) count++; // accept if less than 20% zeros. double error = double(count)/pos.size(); if (error > 0.05) reportWarning(QString("Found %1 % zeros in frame movement").arg(error*100)); return error < 0.2; }
void Slices3DRep::setImages(std::vector<ImagePtr> images) { if (images.empty()) { reportWarning("Slices3DRep::setImages: No input images (in ViewGroup)"); return; } for (unsigned i=0; i<mProxy.size(); ++i) { mProxy[i]->setImages(images); mProxy[i]->getSliceProxy()->setDefaultCenter(images[0]->get_rMd().coord(images[0]->boundingBox().center())); } }
void ProbeImpl::initConfigId() { QStringList configs = this->getConfigIdList(); if (!configs.isEmpty()) this->applyNewConfigurationWithId(configs[0]); else { reportWarning(QString("Found no probe configuration for:\n" "scanner=[%1] instrument=[%2].\n" "Check that your %3 file contains entries\n" "<USScanner> <Name>%1</Name> ... <USProbe> <Name>%2</Name>").arg(mScannerUid).arg(mInstrumentUid).arg(mXml->getFileName())); } }
/**Create and return the structure that would have been read by UsReconstructFileReader, * if written from this object. * */ USReconstructInputData UsReconstructionFileMaker::getReconstructData(ImageDataContainerPtr imageData, std::vector<TimeInfo> imageTimestamps, TimedTransformMap trackerRecordedData, std::map<double, ToolPositionMetadata> trackerRecordedMetadata, std::map<double, ToolPositionMetadata> referenceRecordedMetadata, ToolPtr tool, QString streamUid, bool writeColor, Transform3D rMpr) { if(trackerRecordedData.empty()) reportWarning("No tracking data for writing to reconstruction file."); USReconstructInputData retval; retval.mFilename = mSessionDescription; // not saved yet - no filename retval.mUsRaw = USFrameData::create(mSessionDescription, imageData); retval.rMpr = rMpr; retval.mTrackerRecordedMetadata = trackerRecordedMetadata; retval.mReferenceRecordedMetadata = referenceRecordedMetadata; for (TimedTransformMap::iterator it = trackerRecordedData.begin(); it != trackerRecordedData.end(); ++it) { TimedPosition current; current.mTime = it->first; current.mTimeInfo.setAcquisitionTime(it->first); current.mPos = it->second; retval.mPositions.push_back(current); } std::vector<TimeInfo> fts = imageTimestamps; for (unsigned i=0; i<fts.size(); ++i) { TimedPosition current; current.mTimeInfo = fts[i]; current.mTime = current.mTimeInfo.getAcquisitionTime(); current.mPos = Transform3D::Identity(); // current.mPos = not written - will be found from track positions during reconstruction. retval.mFrames.push_back(current); } if (tool && tool->getProbe()) { retval.mProbeDefinition.setData(tool->getProbe()->getProbeDefinition(streamUid)); } if (tool) retval.mProbeUid = tool->getUid(); this->fillFramePositions(&retval); return retval; }
//given a word, find what category it belongs to and create a token obj to return void Scanner::categorizeToken(string word) { int status; //we want to make sure that we are looking at the correct characters //word = filterWord(word); //1.) check if its a numbers if ((status = checkWordForNumbers(word))) { if (status == 2) { reportWarning("I think you have some operators in your numbers of numbers in your operators"); token.tokenType = "error"; } else token.tokenType = "number"; //2.) check if its a string } else if (checkWordForStrings(word)) { token.tokenType = "string"; //3. check if its an operator } else if (checkWordForOperators(word)) { token.tokenType = "operator"; //4.) check if its an identifier } else if ((status = checkWordForIdentifiers(word))) { //3.a) check if its a reserved word if (status == 2) { reportWarning("I think you have some operators in your numbers of numbers in your operators"); token.tokenType = "error"; } else { if ((status = checkWordForReservedWords(word))) token.tokenType = "reserved_word"; else { token.tokenType = "identifier"; } } //5.) if it is not any of these, it must be unknown or whitespace } else { token.tokenType = "whitespace"; } token.lexeme = word; }//categorizeToken
void IgstkToolManager::setReferenceAndTrackerOnTools() { if (!mReferenceTool) { reportWarning("Tracking is configured without a reference tool."); } std::map<QString, IgstkToolPtr>::iterator it; for (it = mTools.begin(); it != mTools.end(); ++it) { if (mReferenceTool) it->second->setReference(mReferenceTool); if (mTracker) it->second->setTracker(mTracker); } }
void FiltersWidget::runFilterSlot() { if (!mCurrentFilter) return; if (mThread) { reportWarning(QString("Last operation on %1 is not finished. Could not start filtering").arg(mThread->getFilter()->getName())); return; } mThread.reset(new FilterTimedAlgorithm(mCurrentFilter)); connect(mThread.get(), SIGNAL(finished()), this, SLOT(finishedSlot())); mTimedAlgorithmProgressBar->attach(mThread); mThread->execute(); }
void FilePreviewWidget::saveSlot() { if(!mCurrentFile) return; if(!mCurrentFile->open(QIODevice::WriteOnly | QIODevice::Truncate)) { reportWarning("Could not open file "+mCurrentFile->fileName()); return; } mCurrentFile->write(mTextDocument->toPlainText().toLatin1()); mCurrentFile->close(); mTextDocument->setModified(false); }
bool BinaryThinningImageFilter3DFilter::preProcess() { bool retval = FilterImpl::preProcess(); if (!retval) return false; ImagePtr input = this->getCopiedInputImage(); if (!input) return false; if (input->getMax() != 1 || input->getMin() != 0) { reportWarning(QString("Centerline: Input image %1 must be binary, aborting.").arg(input->getName())); return false; } return true; }
void JointElement::exitElementScope() { JointElement::JointInfo info; info.joint = nullptr; std::unordered_map<std::string, JointElement::JointInfo>* map = nullptr; if (m_jointType == "fixed") { info.joint = std::make_shared<FixedJoint>(m_jointFrame); map = &m_fixedJoints; } else if (m_jointType == "revolute" || m_jointType == "continuous") { RevoluteJoint* rev_joint = new RevoluteJoint(); rev_joint->setRestTransform(m_jointFrame); info.joint = std::shared_ptr<IJoint>(rev_joint); map = &m_joints; } else if (m_jointType == "prismatic") { PrismaticJoint* prism_joint = new PrismaticJoint(); prism_joint->setRestTransform(m_jointFrame); info.joint = std::shared_ptr<IJoint>(prism_joint); map = &m_joints; } if (info.joint && map) { info.parentLinkName = m_parentLink; info.childLinkName = m_childLink; info.axis = m_axis; if (m_limits) { // Limits found info.joint->enablePosLimits(true); info.joint->setPosLimits(0, m_limits->positionLower, m_limits->positionUpper); } else if (m_jointType == "revolute" || m_jointType == "prismatic") { std::string errStr = "Joint " + m_jointName + " misses the limit tag."; reportWarning("JointElement", "", errStr.c_str()); } map->insert(std::unordered_map<std::string, JointElement::JointInfo>::value_type(m_jointName, info)); } }
void TemporalCalibration::selectData(QString filename) { mFilename = filename; mFileData = USReconstructInputData(); if (!QFileInfo(filename).exists()) return; UsReconstructionFileReader fileReader; mFileData = fileReader.readAllFiles(filename); if (!mFileData.mUsRaw) { reportWarning("Failed to load data from " + filename); return; } report("Temporal Calibration: Successfully loaded data from " + filename); }
void Image::resetTransferFunctions(bool _2D, bool _3D) { if (!mBaseImageData) { reportWarning("Image has no image data"); return; } mBaseImageData->GetScalarRange(); // this line updates some internal vtk value, and (on fedora) removes 4.5s in the second render(). mMaxRGBIntensity = -1; ImageDefaultTFGenerator tfGenerator(ImagePtr(this, null_deleter())); if (_3D) { this->resetTransferFunction(tfGenerator.generate3DTFPreset()); tfGenerator.resetShading(); } if (_2D) this->resetTransferFunction(tfGenerator.generate2DTFPreset()); }
void AcquisitionServiceProxy::onServiceAdded(AcquisitionService* service) { mAcquisitionService.reset(service, null_deleter()); connect(service, &AcquisitionService::started, this, &AcquisitionService::started); connect(service, &AcquisitionService::cancelled, this, &AcquisitionService::cancelled); connect(service, &AcquisitionService::stateChanged, this, &AcquisitionService::stateChanged); connect(service, &AcquisitionService::usReadinessChanged, this, &AcquisitionService::usReadinessChanged); connect(service, &AcquisitionService::acquisitionStopped, this, &AcquisitionService::acquisitionStopped); connect(service, &AcquisitionService::recordedSessionsChanged, this, &AcquisitionService::recordedSessionsChanged); connect(service, &AcquisitionService::acquisitionDataReady, this, &AcquisitionService::acquisitionDataReady); connect(service, &AcquisitionService::saveDataCompleted, this, &AcquisitionService::saveDataCompleted); if(mAcquisitionService->isNull()) reportWarning("AcquisitionServiceProxy::onServiceAdded mAcquisitionService->isNull()"); emit stateChanged(); emit usReadinessChanged(); emit recordedSessionsChanged(); }