vector<Range<T> > RoutingTree<T>::splitRange(Range<T> range, Node<T> *parentNode){ vector<Node<T> *> childNodes = parentNode->getChildNodes(); vector<Range<T> > result; int i = 0; try{ for (; i < childNodes.size(); i++){ Range<T> curRange = childNodes[i]->getRange(); if (range.atLeft(curRange)){ result.push_back(range); break; } else if (range.leftOverlap(curRange)){ Range<T> tempResult(range.first, curRange.first); // overlap at the margin result.push_back(tempResult); break; } else if (range.isContainedBy(curRange)){ break; } else if (range.contains(curRange)){ if (range.first != curRange.first){ Range<T> tempResult(range.first, curRange.first); // overlap at the margin result.push_back(tempResult); } if (range.second != curRange.second){ range.first = curRange.second; } else{ break; } } else{ // right overlap or at right if (range.first < curRange.second){ range.first = curRange.second; } } } } catch (string e){ cerr<<e<<endl; } if (i == childNodes.size()){ result.push_back(range); } return result; }
bool RenderFlowThread::hitTestFlowThreadPortionInRegion(RenderRegion* region, LayoutRect flowThreadPortionRect, LayoutRect flowThreadPortionOverflowRect, const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset) const { LayoutRect regionClippingRect = computeRegionClippingRect(accumulatedOffset, flowThreadPortionRect, flowThreadPortionOverflowRect); if (!regionClippingRect.contains(locationInContainer.point())) return false; LayoutSize renderFlowThreadOffset; if (style()->isFlippedBlocksWritingMode()) { LayoutRect flippedFlowThreadPortionRect(flowThreadPortionRect); flipForWritingMode(flippedFlowThreadPortionRect); renderFlowThreadOffset = accumulatedOffset - flippedFlowThreadPortionRect.location(); } else renderFlowThreadOffset = accumulatedOffset - flowThreadPortionRect.location(); // Always ignore clipping, since the RenderFlowThread has nothing to do with the bounds of the FrameView. HitTestRequest newRequest(request.type() | HitTestRequest::IgnoreClipping); HitTestResult tempResult(result); // Make a new temporary HitTestLocation in the new region. HitTestLocation newHitTestLocation(locationInContainer, -renderFlowThreadOffset, region); bool isPointInsideFlowThread = layer()->hitTest(newRequest, newHitTestLocation, tempResult); // We want to make sure we hit a node from the content inside the flow thread. isPointInsideFlowThread = isPointInsideFlowThread && !tempResult.innerNode()->isDocumentNode(); if (isPointInsideFlowThread) result = tempResult; // FIXME: Should we set result.m_localPoint back to the RenderRegion's coordinate space or leave it in the RenderFlowThread's coordinate // space? Right now it's staying in the RenderFlowThread's coordinate space, which may end up being ok. We will know more when we get around to // patching positionForPoint. return isPointInsideFlowThread; }
bool RenderImage::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction hitTestAction) { HitTestResult tempResult(result.hitTestLocation()); bool inside = RenderReplaced::nodeAtPoint(request, tempResult, locationInContainer, accumulatedOffset, hitTestAction); if (!inside && result.isRectBasedTest()) result.append(tempResult); if (inside) result = tempResult; return inside; }
vector<string> letterCombinations(string digits) { string memory[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"}; vector<string> result; string tempResult(digits.size(), '0'); if(digits.size() == 0) return result; letter(result, tempResult, digits, memory, 0, digits.size()); return result; }
// multiply self by another matrix (must be of compatible dimensions) to // create a new matrix object Matrix & Matrix::operator*=(const Matrix &rhs) { assert(mCols == rhs.getrows()); // matrix multiplication is only defined if // rows in rhs are equal to columns in self Matrix tempResult(mRows, rhs.getcols()); // temp matrix with correct dimensions for (int row = 0; row < mRows; row++) { for (int col = 0; col < rhs.getcols(); col++) { // Multiply the row of self by the column of rhs to get the row, column of product. double value = 0; for (int inner = 0; inner < mCols; inner++) { value += p[row][inner] * rhs.p[inner][col]; } tempResult.p[row][col] = value; } } *this = tempResult; // Assign result to self return *this; }
void RunContext::handleFatalErrorCondition( StringRef message ) { // First notify reporter that bad things happened m_reporter->fatalErrorEncountered(message); // Don't rebuild the result -- the stringification itself can cause more fatal errors // Instead, fake a result data. AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); tempResult.message = message; AssertionResult result(m_lastAssertionInfo, tempResult); assertionEnded(result); handleUnfinishedSections(); // Recreate section for test case (as we will lose the one that was in scope) auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); Counts assertions; assertions.failed = 1; SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); m_reporter->sectionEnded(testCaseSectionStats); auto const& testInfo = m_activeTestCase->getTestCaseInfo(); Totals deltaTotals; deltaTotals.testCases.failed = 1; deltaTotals.assertions.failed = 1; m_reporter->testCaseEnded(TestCaseStats(testInfo, deltaTotals, std::string(), std::string(), false)); m_totals.testCases.failed++; testGroupEnded(std::string(), m_totals, 1, 1); m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- std::map<std::string, std::vector<float>> RifElementPropertyReader::readAllElementPropertiesInFileContainingField(const std::string& fieldName) { std::map<std::string, std::vector<float>> fieldAndData; if (m_fieldsMetaData.find(fieldName) == m_fieldsMetaData.end()) { return fieldAndData; } RifElementPropertyTable table; RifElementPropertyTableReader::readData(&m_fieldsMetaData[fieldName], &table); CVF_ASSERT(m_fieldsMetaData[fieldName].dataColumns.size() == table.data.size()); for (size_t i = 0; i < table.data.size(); i++) { CVF_ASSERT(table.data[i].size() == table.elementIds.size()); } const std::vector<int>& elementIdsFromFile = table.elementIds; if (elementIdsFromFile == m_elementIdxToId) { for (size_t i = 0; i < table.data.size(); i++) { const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); if (currentFieldFromFile == "MODULUS") { const std::vector<float>& currentColumn = table.data[i]; std::vector<float> tempResult(currentColumn.size(), 0); for (float resultItem : currentColumn) { tempResult[i] = resultItem * 0.000000001; } fieldAndData[currentFieldFromFile].swap(tempResult); } else { fieldAndData[currentFieldFromFile] = table.data[i]; } } } else if (elementIdsFromFile.size() > m_elementIdxToId.size() && elementIdsFromFile.size() > m_elementIdToIdx.size()) { RifElementPropertyReader::outputWarningAboutWrongFileData(); return fieldAndData; } else { if (m_elementIdToIdx.empty()) { makeElementIdToIdxMap(); } std::vector<int> fileIdxToElementIdx; fileIdxToElementIdx.reserve(elementIdsFromFile.size()); for (int elementId : elementIdsFromFile) { std::unordered_map<int /*elm ID*/, int /*elm idx*/>::const_iterator it = m_elementIdToIdx.find(elementId); if (it == m_elementIdToIdx.end()) { RifElementPropertyReader::outputWarningAboutWrongFileData(); return fieldAndData; } fileIdxToElementIdx.push_back(it->second); } for (size_t i = 0; i < table.data.size(); i++) { std::string currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); const std::vector<float>& currentColumn = table.data[i]; std::vector<float> tempResult(m_elementIdToIdx.size(), HUGE_VAL); if (currentFieldFromFile == "MODULUS") { for (size_t j = 0; j < currentColumn.size(); j++) { tempResult[fileIdxToElementIdx[j]] = currentColumn[j] * 0.000000001; } } else { for (size_t j = 0; j < currentColumn.size(); j++) { tempResult[fileIdxToElementIdx[j]] = currentColumn[j]; } } fieldAndData[currentFieldFromFile].swap(tempResult); } } return fieldAndData; }