void RawModel::reloadFiffData(bool before) { m_bReloadBefore = before; //update scroll position fiff_int_t start,end; if(before) { m_iAbsFiffCursor -= m_iWindowSize; start = m_iAbsFiffCursor; end = m_iAbsFiffCursor+m_iWindowSize-1; //check if start of fiff file is reached if(start == firstSample()) { m_bStartReached = true; qDebug() << "RawModel: Start of fiff file reached."; m_iAbsFiffCursor = firstSample(); } } else { start = m_iAbsFiffCursor + sizeOfPreloadedData(); end = start + m_iWindowSize -1; //check if end of fiff file is reached if(end > lastSample()) { if(m_bEndReached) return; else m_bEndReached = true; end = lastSample(); qDebug() << "RawModel: End of fiff file reached."; } } m_bReloading = true; //read data with respect to start and end point QFuture<QPair<MatrixXd,MatrixXd> > future = QtConcurrent::run(this,&RawModel::readSegment,start,end); m_reloadFutureWatcher.setFuture(future); }
void Foam::polyLineSet::calcSamples ( DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<label>& samplingSegments, DynamicList<scalar>& samplingCurveDist ) const { // Check sampling points if (sampleCoords_.size() < 2) { FatalErrorInFunction << "Incorrect sample specification. Too few points:" << sampleCoords_ << exit(FatalError); } point oldPoint = sampleCoords_[0]; for (label sampleI = 1; sampleI < sampleCoords_.size(); sampleI++) { if (mag(sampleCoords_[sampleI] - oldPoint) < SMALL) { FatalErrorInFunction << "Incorrect sample specification." << " Point " << sampleCoords_[sampleI-1] << " at position " << sampleI-1 << " and point " << sampleCoords_[sampleI] << " at position " << sampleI << " are too close" << exit(FatalError); } oldPoint = sampleCoords_[sampleI]; } // Force calculation of cloud addressing on all processors const bool oldMoving = const_cast<polyMesh&>(mesh()).moving(false); passiveParticleCloud particleCloud(mesh()); // current segment number label segmentI = 0; // starting index of current segment in samplePts label startSegmentI = 0; label sampleI = 0; point lastSample(GREAT, GREAT, GREAT); while (true) { // Get boundary intersection point trackPt; label trackCelli = -1; label trackFacei = -1; do { const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI]; const scalar smallDist = mag(tol*offset); // Get all boundary intersections List<pointIndexHit> bHits = searchEngine().intersections ( sampleCoords_[sampleI], sampleCoords_[sampleI+1] ); point bPoint(GREAT, GREAT, GREAT); label bFacei = -1; if (bHits.size()) { bPoint = bHits[0].hitPoint(); bFacei = bHits[0].index(); } // Get tracking point bool isSample = getTrackingPoint ( sampleCoords_[sampleI], bPoint, bFacei, smallDist, trackPt, trackCelli, trackFacei ); if (isSample && (mag(lastSample - trackPt) > smallDist)) { //Info<< "calcSamples : getTrackingPoint returned valid sample " // << " trackPt:" << trackPt // << " trackFacei:" << trackFacei // << " trackCelli:" << trackCelli // << " sampleI:" << sampleI // << " dist:" << dist // << endl; samplingPts.append(trackPt); samplingCells.append(trackCelli); samplingFaces.append(trackFacei); // Convert sampling position to unique curve parameter. Get // fraction of distance between sampleI and sampleI+1. scalar dist = mag(trackPt - sampleCoords_[sampleI]) / mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]); samplingCurveDist.append(sampleI + dist); lastSample = trackPt; } if (trackCelli == -1) { // No intersection found. Go to next point sampleI++; } } while ((trackCelli == -1) && (sampleI < sampleCoords_.size() - 1)); if (sampleI == sampleCoords_.size() - 1) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } // // Segment sampleI .. sampleI+1 intersected by domain // // Initialize tracking starting from sampleI passiveParticle singleParticle ( mesh(), trackPt, trackCelli ); bool bReached = trackToBoundary ( particleCloud, singleParticle, sampleI, samplingPts, samplingCells, samplingFaces, samplingCurveDist ); // fill sampleSegments for (label i = samplingPts.size() - 1; i >= startSegmentI; --i) { samplingSegments.append(segmentI); } if (!bReached) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } lastSample = singleParticle.position(); // Find next boundary. sampleI++; if (sampleI == sampleCoords_.size() - 1) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } segmentI++; startSegmentI = samplingPts.size(); } const_cast<polyMesh&>(mesh()).moving(oldMoving); }