Game::Game(int width, int height, char pattern, int xOffset, int yOffset, int generations, int pauseLength) { // hard-coded because the user shouldn't be concerned with a buffer buffer = 5; this->width = width + 2 * buffer; this->height = height + 2 * buffer; this->generations = generations; this->pauseLength = pauseLength; // build that grid grid = new int*[this->width]; for (int col = 0; col < this->width; ++col) { grid[col] = new int[this->height]; } // make sure everything is DEAD clearGrid(); // on that bed of dead cells, throw a picture of life setPatternVector(pattern, xOffset, yOffset); initializePattern(); }
void DateIntervalFormat::setDateIntervalInfo(const DateIntervalInfo& newItvPattern, UErrorCode& status) { delete fInfo; fInfo = new DateIntervalInfo(newItvPattern); if ( fDateFormat ) { initializePattern(status); } }
DateIntervalFormat::DateIntervalFormat(const Locale& locale, DateIntervalInfo* dtItvInfo, const UnicodeString* skeleton, UErrorCode& status) : fInfo(NULL), fDateFormat(NULL), fFromCalendar(NULL), fToCalendar(NULL), fDtpng(NULL) { if ( U_FAILURE(status) ) { delete dtItvInfo; return; } fDtpng = DateTimePatternGenerator::createInstance(locale, status); SimpleDateFormat* dtfmt = createSDFPatternInstance(*skeleton, locale, fDtpng, status); if ( U_FAILURE(status) ) { delete dtItvInfo; delete fDtpng; delete dtfmt; return; } if ( dtfmt == NULL || dtItvInfo == NULL || fDtpng == NULL ) { status = U_MEMORY_ALLOCATION_ERROR; // safe to delete NULL delete dtfmt; delete dtItvInfo; delete fDtpng; return; } if ( skeleton ) { fSkeleton = *skeleton; } fInfo = dtItvInfo; fDateFormat = dtfmt; if ( dtfmt->getCalendar() ) { fFromCalendar = dtfmt->getCalendar()->clone(); fToCalendar = dtfmt->getCalendar()->clone(); } else { fFromCalendar = NULL; fToCalendar = NULL; } initializePattern(status); }
void PatternExtractor::extract(const cv::Mat &img, Pattern &pattern) { initializePattern(img, pattern); extractFeatures(img, pattern.keypoints, pattern.descriptors); }