void RS_DimAligned::updateDimPoint(){ // temporary construction line RS_ConstructionLine tmpLine( nullptr, RS_ConstructionLineData(edata.extensionPoint1, edata.extensionPoint2)); RS_Vector tmpP1 = tmpLine.getNearestPointOnEntity(data.definitionPoint); data.definitionPoint += edata.extensionPoint2 - tmpP1; }
int ParseIndiffCurves::getCurvePoints(const std::string& line, PointsContainer& points) { int count = 0; std::string tmpLine(line); while (true) { try { std::string substr = Utils::getSubString("(", ")", tmpLine); assert(!substr.empty()); points.push_back(std::make_pair<FPType, FPType>(getFirst(substr), getSecond(substr))); ++count; tmpLine = tmpLine.substr(tmpLine.find(")") + 1); } catch (Error e) { return count; } } return count; };
bool File::readDirectoryTree() { if (!m_Stream.good()) return false; const unsigned int bufferSize = 4096; std::unique_ptr<char[]> buffer(new char[bufferSize]); uint32_t i = 1; while (i < m_FirstHintLine) { std::memset(buffer.get(), 0, 4096); m_Stream.getline(buffer.get(), bufferSize-1, '\n'); if (!m_Stream.good()) { throw std::runtime_error("Unable to read next directory tree entry!"); return false; } std::string name = std::string(buffer.get()); removeTrailingCarriageReturn(name); name = Decryption::UHS88a(name); std::memset(buffer.get(), 0, 4096); m_Stream.getline(buffer.get(), bufferSize-1, '\n'); if (!m_Stream.good()) { throw std::runtime_error("Unable to read number directory tree's hint line from file!"); return false; } uint32_t lineNumber = 0; std::string tmpLine(std::string(buffer.get())); removeTrailingCarriageReturn(tmpLine); if (!stringToUnsignedInt<uint32_t>(tmpLine, lineNumber)) { throw std::runtime_error("\"" + tmpLine + "\" is not an integer!"); return false; } m_DirectoryTree.push_back(std::pair<std::string, uint32_t>(name, lineNumber)); //increase line counter by two, because two lines were read i = i + 2; } //while //The current line number should now be the first hint line's number. return (i == m_FirstHintLine); }
void CppCheckReportPage::AppendLine(const wxString& line) { wxString tmpLine(line); // Locate status messages: // 6/7 files checked 85% done static wxRegEx reProgress(wxT("([0-9]+)/([0-9]+)( files checked )([0-9]+%)( done)")); static wxRegEx reFileName(wxT("(Checking )([a-zA-Z:]{0,2}[ a-zA-Z\\.0-9_/\\+\\-]+ *)")); // Locate the progress messages and update our progress bar wxArrayString arrLines = wxStringTokenize(tmpLine, wxT("\n\r"), wxTOKEN_STRTOK); for(size_t i = 0; i < arrLines.GetCount(); i++) { if(reProgress.Matches(arrLines.Item(i))) { // Get the current progress wxString currentLine = reProgress.GetMatch(arrLines.Item(i), 1); long fileNo(0); currentLine.ToLong(&fileNo); } if(reFileName.Matches(arrLines.Item(i))) { // Get the file name wxString filename = reFileName.GetMatch(arrLines.Item(i), 2); m_mgr->SetStatusMessage("CppCheck: checking file " + filename); } } // Remove progress messages from the printed output reProgress.ReplaceAll(&tmpLine, wxEmptyString); tmpLine.Replace(wxT("\r"), wxT("")); tmpLine.Replace(wxT("\n\n"), wxT("\n")); m_stc->SetReadOnly(false); m_stc->AppendText(tmpLine); m_stc->SetReadOnly(true); m_stc->ScrollToLine(m_stc->GetLineCount() - 1); }
bool File::readHintLines() { //Do we even have nice hint line numbers yet? if (m_FirstHintLine == 0 || m_LastHintLine == 0 || m_FirstHintLine > m_LastHintLine) return false; if (!m_Stream.good()) return false; if (m_Stream.tellg() > 0) m_Stream.seekg(0); //jump to first hint line (header is four lines, so add three) if (!skipLines(m_FirstHintLine+3)) return false; uint32_t currentLine = m_FirstHintLine; const unsigned int bufferSize = 4096; std::unique_ptr<char[]> buffer(new char[bufferSize]); while (currentLine <= m_LastHintLine) { std::memset(buffer.get(), 0, bufferSize); m_Stream.getline(buffer.get(), bufferSize-1, '\n'); if (!m_Stream.good()) { throw std::runtime_error("Could not read next hint line from file!"); return false; } //if std::string tmpLine(std::string(buffer.get())); removeTrailingCarriageReturn(tmpLine); m_HintLines.push_back(Decryption::UHS88a(tmpLine)); ++currentLine; } //while return true; }
bool LineDetector::GetLines(Mat &rawHSV, Mat & fieldMask, Mat &guiImg, bool SHOWGUI, const Mat &lineBinary, vector<LineSegment> &resLines) { int MIN_LINE_DOUBLE_VOTE = params.line.lineVoteDouble->get(); int MIN_LINE_VOTE = params.line.lineVote->get(); int MIN_LINE_COLOR_VOTE = params.line.lineVoteColor->get(); vector<Vec4i> linesP; HoughLinesP(lineBinary, linesP, 1, M_PI / 45, 20, params.line.MinLineLength->get(), 20); for (size_t i = 0; i < linesP.size(); i++) { Vec4i lP = linesP[i]; LineSegment tmpLine(Point2d(lP[0], lP[1]), Point2d(lP[2], lP[3])); vector<cv::Point2d> midds = tmpLine.GetMidPoints(3); //2^3+1 = 16 int lineVoter = 0; int vote_for_double = 0; int vote_for_color = 0; uchar *dataImg = fieldMask.data; // printf("size= %d\n", midds.size()); for (size_t j = 0; j < midds.size(); j++) { int jumpMin = params.line.jumpMin->get(); int jumpMax = params.line.jumpMin->get(); double distanceToZero = GetDistance( cv::Point2d((params.camera.width->get() / 2), (params.camera.height->get())), midds[j]); LineInterpolation interP( LineSegment(cv::Point2d(0, jumpMax), cv::Point2d(params.camera.height->get(), jumpMin))); double jump; if (!interP.GetValue(distanceToZero, jump)) { //printh(CRed, "Error In Programming!"); continue; } LineSegment tocheck = tmpLine.PerpendicularLineSegment(jump, midds[j]); cv::LineIterator it(lineBinary, tocheck.P1, tocheck.P2, 8); vector<uchar> buf(it.count); int currentCounter = 0; for (int k = 0; k < it.count; k++, ++it) { uchar val=*(*it); if ( val > 10) { vote_for_double++; currentCounter++; } if (currentCounter >= 2) break; } cv::LineIterator itHSV(rawHSV, tocheck.P1, tocheck.P2, 8); vector<uchar> bufHSV(itHSV.count); for (int k = 0; k < itHSV.count; k++, ++itHSV) { cv::Vec3b hsvC = (cv::Vec3b) *itHSV; if (hsvC[0] >= params.line.h0->get() && hsvC[0] <= params.line.h1->get() && hsvC[1] >= params.line.s0->get() && hsvC[1] <= params.line.s1->get() && hsvC[2] >= params.line.v0->get() && hsvC[2] <= params.line.v1->get()) { vote_for_color++; break; } } int safeToShow = 0; if (tocheck.P1.x >= 0 && tocheck.P1.y >= 0 && tocheck.P1.x < params.camera.width->get() && tocheck.P1.y < params.camera.height->get()) { safeToShow++; uchar* pixelP = dataImg + ((((int) tocheck.P1.y * params.camera.width->get()) + (int) tocheck.P1.x) * 1); if (*pixelP > 50) lineVoter++; } if (tocheck.P2.x >= 0 && tocheck.P2.y >= 0 && tocheck.P2.x < params.camera.width->get() && tocheck.P2.y < params.camera.height->get()) { safeToShow++; uchar* pixelP = dataImg + ((((int) tocheck.P2.y * params.camera.width->get()) + (int) tocheck.P2.x) * 1); if (*pixelP > 50) lineVoter++; } if (safeToShow >= 2) { if (SHOWGUI && params.debug.showLineD->get()) { cv::line(guiImg, tocheck.P1, tocheck.P2, yellowColor(), 1); } } } if (lineVoter > MIN_LINE_VOTE && vote_for_double > MIN_LINE_DOUBLE_VOTE && vote_for_color > MIN_LINE_COLOR_VOTE) resLines.push_back(tmpLine); } return resLines.size() > 0; }