AREXPORT std::map<int, ArPose> *ArLineFinder::getNonLinePoints(void) { std::map<int, ArLineFinderSegment *>::iterator lineIt; ArLineFinderSegment *segment; int i; getLines(); if (myLines == NULL) return NULL; if (myNonLinePoints != NULL) delete myNonLinePoints; myNonLinePoints = new std::map<int, ArPose>; *myNonLinePoints = *myPoints; for (lineIt = myLines->begin(); lineIt != myLines->end(); lineIt++) { segment = (*lineIt).second; for (i = segment->getStartPoint(); i <= segment->getEndPoint(); i++) { myNonLinePoints->erase(i); } } return myNonLinePoints; }
int main(int argc, char* argv[]){ FILE *file = openFile(argc, argv); int noOfVertices = readNoOfVertices(file); struct Node nodes[noOfVertices]; getLines(file, noOfVertices, nodes); int startNodeIdx = eulerCheck(noOfVertices, nodes); int noOfPassedEdges = 0; int counter = 0; int *backMeup = malloc((noOfEdges+1)*sizeof(int)); memset(backMeup, -1, noOfEdges*sizeof(int)); backMeup[counter] = startNodeIdx; printf("%d\n", startNodeIdx); struct EdgeEnd *currentConnection = nodes[startNodeIdx].edge; while(noOfPassedEdges != noOfEdges) { if((!currentConnection->visited) && (currentConnection->targetNodeIdx != backMeup[noOfPassedEdges+1])) { currentConnection->visited = 1; currentConnection->otherSide->visited = 1; noOfPassedEdges++; backMeup[noOfPassedEdges] = currentConnection->targetNodeIdx; currentConnection = nodes[currentConnection->targetNodeIdx].edge; printf("We are at %d\n", backMeup[noOfPassedEdges]); } else if (currentConnection->next != NULL) { currentConnection = currentConnection->next; } else { //currentConnection->visited = -1; //currentConnection->otherSide->visited = -1; noOfPassedEdges--; currentConnection = nodes[noOfPassedEdges].edge; } } printf("Current Path: \t"); for (int i = 0; i <= noOfPassedEdges; i++){ printf("%d ",backMeup[i]); } printf("\n"); //small check in // int nodeMe = 97; // struct EdgeEnd *tryingmyBest = nodes[nodeMe].edge; // printf("all connections from 97: \n"); // while(tryingmyBest->next != NULL){ // tryingmyBest = tryingmyBest->next; // printf(" DEBUG %d - %d visited tag: %d\n", nodeMe, tryingmyBest->targetNodeIdx, tryingmyBest->visited); // } //free(backMeup); printf("done\n"); }
void mode2 (FILE *in, FILE *out) { int ln = 0, pn = 0; TLine *lines = getLines(in, &ln); //build tree using lines Tree T = buildTree(lines, ln); free(lines); lines = NULL; //reads points after building tree (better memory usage) TPoint *points = getPoints(in, &pn); labelRegions(T, points, pn); free(points); points = NULL; printTree(out, T); fprintf(out, "\n"); localizePoints(in, out, T); destroyTree(&T); }
void *reader(void *info) { int i = 0; clientNode *thisClient = (clientNode*) info; char recvLine[MAXLINE + 1]; char **lines = NULL; ssize_t n; printf("[Uma conexao aberta]\n"); //Loop de leitura de mensagens while ((n=read(thisClient->socket, recvLine, MAXLINE)) > 0) { recvLine[n] = '\0'; printf("[Cliente %d enviou:] ", thisClient->socket); if ((fputs(recvLine, stdout)) == EOF) { perror("fputs :( \n"); exit(6); } lines = getLines(recvLine); //Quebra a mensagem em linhas for(i = 0; lines[i] != NULL; i++) { parseMessage(lines[i], thisClient); } free(lines); } delNode(thisClient); printf("[Uma conexao fechada]\n"); return NULL; }
void mode1 (FILE *in, FILE *out) { //line number and point number int ln = 0, pn = 0; //get lines TLine *lines = getLines(in, &ln); //get points TPoint *points = getPoints(in, &pn); //read tree from file Tree T = readTree(in, lines); //need lines no longer free(lines); lines = NULL; //label regions using points labelRegions(T, points, pn); //need points no longer free(points); points = NULL; //print tree printTree(out, T); fprintf(out, "\n"); //solve all points localizePoints(in, out, T); destroyTree(&T); }
int main(int argc, char *argv[]) { /// current_line_length = 0; end_of_command = false; shift = false; start = end = line_end = 0; buffer_position = buffer_to_parse_position = 0; bool syntax_error = 0; bool printed_syntax_error = 0; struct stat stdin_buffer; int check = fstat(0, &stdin_buffer); if(check == -1) exit(1); /** makro testuje czy czytamy z terminala czy nie, jak zwraca nie zero to tak. */ if(S_ISCHR(stdin_buffer.st_mode)) stdin_status = true; else stdin_status = false; while(1) { if(stdin_status) /** czytamy z terminala */ { printf("$ "); fflush(stdout); } getLines(stdin_status); fflush(stdout); } }
//-------------------------------------------------- string ofBuffer::getNextLine(){ if(currentLine.empty()){ currentLine = getLines().begin(); }else{ ++currentLine; } return currentLine.asString(); }
void Poly::getLines(vector<Vector2d> &lines, Vector2d &startPoint) const { if (size()<2) return; double mindist = 1000000; uint index = nearestDistanceSqTo(startPoint, mindist); getLines(lines,index); startPoint = Vector2d(lines.back().x,lines.back().y); }
bool HistoryScrollFile::isWrappedLine(int lineno) { if (lineno>=0 && lineno <= getLines()) { unsigned char flag; lineflags.get((unsigned char*)&flag,sizeof(unsigned char),(lineno)*sizeof(unsigned char)); return flag; } return false; }
//checks to see if it can retrieve any more packets. //returns true if there are no more packets to make. bool Packetizer::outOfData () { // ----------- testing char t[512]; _itoa_s (temp_buffer.length (), t, 10); OutputDebugString (t); // ------------------- return (currentLine >= getLines (&RreadFrom) && temp_buffer.length() == 0); }
void OLabel::init() { m_Position = maths::vec2(0, 0); m_Size = maths::vec2(180, 50); m_TextColor = OColorRGBA8(); m_Color = OColorRGBA8(0, 0, 0, 0); borders = maths::vec4(2, 2, 2, 2); getLines(); }
AREXPORT std::set<ArLineFinderSegment*> ArLineFinder::getLinesAsSet() { std::map<int, ArLineFinderSegment*> *lines = getLines(); std::set<ArLineFinderSegment*> lineSegPtrs; for(std::map<int, ArLineFinderSegment*>::const_iterator i = lines->begin(); i != lines->end(); ++i) { lineSegPtrs.insert( (*i).second ); } return lineSegPtrs; }
int main(int argc, char* argv[]) { struct sockaddr_in serverAddress; //Contains info for server address char *buffer = (char*) malloc(1024); //buffer for sending commands FILE* cmds; //file pointer to commands.txt unsigned int sleeptime; int sock; //socket if(argc > 2) { err_n_die("Arguments: ./program <ip address>"); } //create socket sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); memset(&serverAddress, 0, sizeof(serverAddress)); serverAddress.sin_family = AF_INET; serverAddress.sin_port = htons(5000); if(inet_pton(AF_INET, argv[1], &serverAddress.sin_addr.s_addr) == -1) { err_n_die("inet_pton() failed\n"); } //read commands from text file. cmds = fopen("commands.txt", "r"); size_t len = 0; while(getLines(&buffer, cmds,&len) != -1) { //Get sleep time if(strstr(buffer, "sleep") != NULL){ //Get ready for bed. int i = 0; for(i = 0; i < strlen(buffer); i++) { if((int)buffer[i] < 10) { //good night sleeptime = (unsigned int)buffer[i]; sleep(sleeptime); break; } //if } //for } //if //send regular command else { if(sendto(sock, buffer, MAX, 0, (struct sockaddr *)&serverAddress, sizeof(serverAddress)) < 0) { err_n_die("sendto() failed\n"); } //if } //else //Block until we get response getResponse(); } //while //TODO: Receive data and save data. infinite loop? free(buffer); fclose(cmds); return 0; } //main
NormalizerPerformanceTest::NormalizerPerformanceTest(int32_t argc, const char* argv[], UErrorCode& status) : UPerfTest(argc,argv,status), options(0) { NFDBuffer = NULL; NFCBuffer = NULL; NFDBufferLen = 0; NFCBufferLen = 0; NFDFileLines = NULL; NFCFileLines = NULL; if(status== U_ILLEGAL_ARGUMENT_ERROR){ fprintf(stderr,gUsageString, "normperf"); return; } if(U_FAILURE(status)){ fprintf(stderr, "FAILED to create UPerfTest object. Error: %s\n", u_errorName(status)); return; } _remainingArgc = u_parseArgs(_remainingArgc, (char **)argv, (int32_t)(LENGTHOF(cmdLineOptions)), cmdLineOptions); if(cmdLineOptions[0].doesOccur && cmdLineOptions[0].value!=NULL) { options=(int32_t)strtol(cmdLineOptions[0].value, NULL, 16); } if(line_mode){ ULine* filelines = getLines(status); if(U_FAILURE(status)){ fprintf(stderr, "FAILED to read lines from file and create UPerfTest object. Error: %s\n", u_errorName(status)); return; } NFDFileLines = new ULine[numLines]; NFCFileLines = new ULine[numLines]; for(int32_t i=0;i<numLines;i++){ normalizeInput(&NFDFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFD, options); normalizeInput(&NFCFileLines[i],filelines[i].name,filelines[i].len,UNORM_NFC, options); } }else if(bulk_mode){ int32_t srcLen = 0; const UChar* src = getBuffer(srcLen,status); NFDBufferLen = 0; NFCBufferLen = 0; if(U_FAILURE(status)){ fprintf(stderr, "FAILED to read buffer from file and create UPerfTest object. Error: %s\n", u_errorName(status)); return; } NFDBuffer = normalizeInput(NFDBufferLen,src,srcLen,UNORM_NFD, options); NFCBuffer = normalizeInput(NFCBufferLen,src,srcLen,UNORM_NFC, options); } }
int HistoryScroll::startOfLine(int lineno) { if (lineno <= 0) return 0; if (!hasScroll()) return 0; if (lineno <= getLines()) { int res; index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int)); return res; } return cells.len(); }
void UnifiedModel::evaluate(const MatrixXd& inputs, MatrixXd& output) const { MatrixXd lines; getLines(inputs, lines); // Weight the values for each line with the normalized basis function activations MatrixXd activations; kernelActivations(inputs,activations); output = (lines.array()*activations.array()).rowwise().sum(); }
Context::Text Context::getText() const { Text s; auto lines = getLines(); for (auto &line : lines) { Text space; for (int i = 0; i < line.n_indents; i++) space += indent; s += space + line.text + newline; } return s; }
Ground3DDrawable::Ground3DDrawable(const std::string& n, Point3d posi, Point3d vel, int w, int l, int lD): Obj3DDrawable(n, posi, vel), width(w), length(l), lineDistance(lD) { for(int x = X()-length/2; x <=X()+length/2; x +=lineDistance){ getLines().push_back(Line3d(Point3d(x, 0, Z() -width/2), Point3d(x, 0, Z()+ width/2))); } for(int z = Z() - width/2; z <= Z() + width/2; z += lineDistance){ getLines().push_back(Line3d(Point3d(X()-length/2,0,z), Point3d(X() +length/2, 0, z))); } for(std::vector<Line3d>::iterator i = getLines().begin();i != getLines().end();i ++){ getProjectedLines(). push_back(Viewpoint::getInstance().lookAtLine3D(*i)); } }
void DrawableStatsAttachment::operator -=(DrawableStatsAttachment *arg) { setVertices (getVertices() - arg->getVertices()); setPoints (getPoints() - arg->getPoints()); setLines (getLines() - arg->getLines()); setTriangles (getTriangles() - arg->getTriangles()); setPatches (getPatches () - arg->getPatches ()); setProcessedAttributeBytes(getProcessedAttributeBytes() - arg->getProcessedAttributeBytes()); setStoredAttributeBytes (getStoredAttributeBytes() - arg->getStoredAttributeBytes()); setValid(true); }
int HistoryScrollFile::startOfLine(int lineno) { if (lineno <= 0) return 0; if (lineno <= getLines()) { if (!index.isMapped()) index.map(); int res; index.get((unsigned char*)&res,sizeof(int),(lineno-1)*sizeof(int)); return res; } return cells.len(); }
QueryData genMDDrives(QueryContext& context) { QueryData results; MDStat mds; MD md; std::vector<std::string> lines; getLines(lines); md.parseMDStat(lines, mds); for (const auto& device : mds.devices) { getDrivesForArray(device.name, md, results); } return results; }
char avoid_edge() { sensorCheck = 1; char status = getLines(); if(status == 1)//no lines were sensed return 0; switch(status) { case 2://TL triggered //spin CW(from top view) set_speed(255,-255); //delayMicroseconds(20); //we'll see if we need this short delay break; case 3://TR triggered //spin CCW set_speed(-255, 255); break; case 5://BL triggered //spin CCW set_speed(-255,255); break; case 7://BR triggered //spin CW set_speed(255,-255); break; case 6: //Top triggered //get the f**k back set_speed(-255,-255); break; case 10://Left triggered set_speed(255,205); break; case 35://Bottom triggered //get the f**k forward set_speed(255,255); break; case 21://Right triggered set_speed(205,255); break; default: set_speed(255,-255); return 0; break; } sensorCheck = 0; return status; }
void ossimQtIgenController::handleRectangleROIEvent( ossimROIEvent& event) { if (event.getEventType() == ossimROIEvent::OSSIM_RECTANGLE_ROI) { if (event.getMovingFlag() == false) { // Mouse drag, update lines and samples. theLines = getLines(); theSamples = getSamples(); } // Update the geo rect from ROI rect. updateOutputGrect(); updateDialog(); } }
void ossimQtIgenController::setSceneBoundingRect() { if (!theWidget) return; //--- // theWidget is actually on a tile boundary so we want the fitted // rect and not any null buffer pixels. //--- setWidgetRect(theWidget->getSceneBoundingRect()); theLines = getLines(); theSamples = getSamples(); updateOutputGrect(); updateDialog(); }
vector<Mesh*> ModelLoaderOBJ::loadKeyFrame(const FileName &fileName) const { FileText::LINES rawLines = FileText::readLines(fileName); const LINES lines = getLines(rawLines); const LINES nc = stripComments(lines); const vector<vec3> verticesArray = read<vec3>(nc,"v", parseVertex); const vector<vec3> normalsArray = read<vec3>(nc,"vn",parseVertex); const vector<vec2> texcoordsArray = read<vec2>(nc,"vt",parseTexCoord); const vector<Face> facesArray = read<Face>(nc,"f", parseFace); return createKeyFrame(new Mesh(verticesArray, normalsArray, texcoordsArray, facesArray)); }
bool UnifiedModel::saveGridData(const VectorXd& min, const VectorXd& max, const VectorXi& n_samples_per_dim, string save_directory, bool overwrite) const { if (save_directory.empty()) return true; #ifndef NDEBUG // Variables below are only required for asserts; check for NDEBUG to avoid warnings. int n_dims = min.size(); assert(n_dims==max.size()); assert(n_dims==n_samples_per_dim.size()); #endif MatrixXd inputs; FunctionApproximator::generateInputsGrid(min, max, n_samples_per_dim, inputs); MatrixXd lines; getLines(inputs, lines); MatrixXd activations; if (cosine_basis_functions_) { BasisFunction::Cosine::activations(covars_,centers_,inputs,activations); } else { BasisFunction::Gaussian::activations(centers_,covars_,priors_,inputs,activations,normalized_basis_functions_); if (normalized_basis_functions_) { MatrixXd unnormalized_activations; BasisFunction::Gaussian::activations(centers_,covars_,priors_,inputs,unnormalized_activations,false); saveMatrix(save_directory,"activations_unnormalized_grid.txt",unnormalized_activations,overwrite); } } MatrixXd predictions; evaluate(inputs,predictions); saveMatrix(save_directory,"n_samples_per_dim.txt",n_samples_per_dim,overwrite); saveMatrix(save_directory,"inputs_grid.txt",inputs,overwrite); saveMatrix(save_directory,"lines_grid.txt",lines,overwrite); saveMatrix(save_directory,"activations_grid.txt",activations,overwrite); saveMatrix(save_directory,"predictions_grid.txt",predictions,overwrite); return true; }
QueryData genMDPersonalities(QueryContext& context) { QueryData results; MDStat mds; std::vector<std::string> lines; MD md; getLines(lines); md.parseMDStat(lines, mds); for (const auto& name : mds.personalities) { Row r = {{"name", name}}; results.push_back(r); } return results; }
DictionaryTriePerfTest(int32_t argc, const char *argv[], UErrorCode &status) : UPerfTest(argc, argv, NULL, 0, "", status), numTextLines(0) { if(hasFile()) { getLines(status); for(int32_t i=0; i<numLines; ++i) { // Skip comment lines (start with a character below 'A'). if(lines[i].name[0]>=0x41) { ++numTextLines; // Remove trailing CR LF. int32_t len=lines[i].len; UChar c; while(len>0 && ((c=lines[i].name[len-1])==0xa || c==0xd)) { --len; } lines[i].len=len; } } } }
//retrieves the first 512 characters from the temp_buffer and removes them from the buffer. std::string Packetizer::buildPacket () { std::string tmp; while (packet_list.size () < PACKET_LIST_MAX && temp_buffer.length() < BUFFER_CHAR_SIZE && currentLine < getLines (&RreadFrom)) {//&& outOfData ()) { populateBuffer (); } tmp = temp_buffer.substr(0, BUFFER_CHAR_SIZE); temp_buffer.erase (0, BUFFER_CHAR_SIZE); return tmp; }
int http_parse_packet(char *tcp_payload, int length, http_packet *http_t){ if(length == 0 || http_t == NULL || tcp_payload == NULL) return -1; http_alloc(http_t); int no_data = 0; char *aux_hdr = NULL; struct _internal_http_packet *http = *http_t; http->headers = NULL; http->data = NULL; http->op = http_which_method(tcp_payload); if(http->op == ERR){ return -1; } char *cadena = (char*) calloc(length+1, sizeof(char)); strncpy(cadena, tcp_payload, length); tcp_payload = cadena; if(http->op != RESPONSE){ sscanf(tcp_payload, "%32s %2048s %32s\r\nHost: %256s\r\n", http->method, http->uri, http->version, http->host); }else{ strcpy(http->method, "RESPONSE"); sscanf(tcp_payload, "%32s %d %[^\n]\r\n", http->version, &http->response_code, http->response_msg); char *hdr = strstr(tcp_payload, "\r\n"); if(hdr == NULL){ return -1; } char *data = strstr(tcp_payload, "\r\n\r\n"); if(data == NULL){ no_data = 1; data = tcp_payload+strlen(tcp_payload); } //Copy HTTP headers if(no_data == 0){ data+=2; //Jump \r\n, THE HEADERS MUST END WITH \r\n } hdr+=2; //Jump \r\n aux_hdr = (char*) calloc(((data-hdr)+1),sizeof(char)); if(aux_hdr == NULL){ return -1; } memcpy(aux_hdr, hdr, data-hdr); if(no_data == 0 && *data == '\r') data+=2; //Jump \r\n of the empty line http->headers = (http_header *) calloc(sizeof(http_header), 1); if(http->headers == NULL){ return -1; } if(getLines(aux_hdr, http->headers) == -1){ return -1; } if(no_data == 0){ //Copy HTTP data // http->data = strdup(data); // if(http->data == NULL){ // return -1; // } } } free(cadena); return 0; }