void TriStripper::addTriangle(Vertex *v1, Vertex *v2, Vertex *v3){ // First we assign indices to these vertex, by searching if we already have them v1 = assignIndex(v1); v2 = assignIndex(v2); v3 = assignIndex(v3); // Then we find or create the egdes // Edge 1 is v1-v2, Edge 2 is v2-v3 and Edge 3 is v3-v1 Edge *e1 = findOrAddEdge(v1, v2); Edge *e2 = findOrAddEdge(v2, v3); Edge *e3 = findOrAddEdge(v3, v1); Triangle *t = new Triangle(e1, e2, e3, v1, v2, v3, triangleCount++); triangleList.push_back(t); }
/** this will be called from the SEAS action dispatcher * when it receives the action from the socket */ inline void action_stat(struct cell *t) { unsigned int seas_dispatch; //unsigned int as_delay; struct timeval *t1,*t2; //struct timeval *t3; struct statscell *s; struct totag_elem *to; if(t==0) return; if(t->fwded_totags == 0){ LM_DBG("seas:event_stat() unable to set the event_stat timeval:" " no payload found at cell!! (fwded_totags=0)\n"); return; } to=t->fwded_totags; while(to){ if(to->acked==STATS_PAY){ s=(struct statscell *)to->tag.s; gettimeofday(&(s->u.uas.action_recvd),NULL); break; }else to=to->next; } /**no statistics found**/ if(to==0) return; t1=&(s->u.uas.as_relay); t2=&(s->u.uas.event_sent); //t3=&(s->u.uas.action_recvd); seas_dispatch = (t2->tv_sec - t1->tv_sec)*1000 + (t2->tv_usec-t1->tv_usec)/1000; //as_delay = (t3->tv_sec - t2->tv_sec)*1000 + (t3->tv_usec-t2->tv_usec)/1000; lock_get(seas_stats_table->mutex); { seas_stats_table->dispatch[assignIndex(seas_dispatch)]++; seas_stats_table->event[assignIndex(seas_dispatch)]++; (seas_stats_table->finished_transactions)++; } lock_release(seas_stats_table->mutex); }
int main(int argc, char **argv) { double min_x; double max_x; double min_y; double max_y; if (! assignIndex(atoi(argv[1]), atoi(argv[2])) ) { cerr << "Invalid arguments for field indices" << endl; return -1; } // initlize the GEOS ibjects gf = new GeometryFactory(new PrecisionModel(),0); wkt_reader= new WKTReader(gf); // process input data map<int,Geometry*> geom_polygons; string input_line; vector<string> fields; cerr << "Reading input from stdin..." <<endl; id_type id ; Geometry* geom; const Envelope * env; while(cin && getline(cin, input_line) && !cin.eof()){ fields = parse(input_line); if (fields[ID_IDX].length() <1 ) continue ; // skip lines which has empty id field id = std::strtoul(fields[ID_IDX].c_str(), NULL, 0); if (fields[GEOM_IDX].length() <2 ) { #ifndef NDEBUG cerr << "skipping record [" << id <<"]"<< endl; #endif continue ; // skip lines which has empty geometry } // try { geom = wkt_reader->read(fields[GEOM_IDX]); env = geom->getEnvelopeInternal(); cout << fields[ID_IDX] << TAB << env->getMinX() << TAB << env->getMinY() << TAB << env->getMaxX() << TAB << env->getMaxY() << endl; } cout.flush(); cerr.flush(); freeObjects(); return 0; // success }
/* * buildPreamble */ static tSuccess buildPreamble(char ** ppzDef, char ** ppzOut, char const * pzFile, int line) { char * pzDef = *ppzDef; char * pzOut = *ppzOut; char zDefText[ MAXNAMELEN ]; char * pzDefText = zDefText; char zNameText[ MAXNAMELEN ]; char * pzNameText = zNameText; char * pzIfText = NULL; /* * Copy out the name of the entry type */ *pzDefText++ = '`'; while (isalnum(*pzDef) || (*pzDef == '_') || (*pzDef == '.') || (*pzDef == '[') || (*pzDef == ']')) *pzDefText++ = *pzDef++; *pzDefText = NUL; pzDef += strspn(pzDef, "* \t"); /* * Copy out the name for this entry of the above entry type. */ while (isalnum(*pzDef) || (*pzDef == '_')) *pzNameText++ = *pzDef++; *pzNameText = NUL; if ( (zDefText[1] == NUL) || (zNameText[0] == NUL) ) { fprintf(stderr, zNoData, pzFile, line); return FAILURE; } pzDef += strspn(pzDef, " \t"); /* * IF these names are followed by a comma and an "if" clause, * THEN we emit the definition with "#if..."/"#endif" around it */ if (*pzDef == ',') { pzDef += strspn(pzDef+1, " \t")+1; if ((pzDef[0] == 'i') && (pzDef[1] == 'f')) pzIfText = pzDef; } pzDef = strchr(pzDef, '\n'); if (pzDef == NULL) { fprintf(stderr, zNoData, pzFile, line); return FAILURE; } *pzDef = NUL; /* * Now start the output. First, the "#line" directive, * then any "#ifdef..." line and finally put the * entry type name into the output. */ pzOut += sprintf(pzOut, zLineId, line, pzFile); if (pzIfText != NULL) pzOut += sprintf(pzOut, "#%s\n", pzIfText); { char* pz = zDefText+1; while (*pz != NUL) *pzOut++ = *pz++; } /* * IF we are indexing the entries, * THEN build the string by which we are indexing * and insert the index into the output. */ if (pzIndexText != NULL) { sprintf(pzDefText, " %s'", zNameText); pzOut = assignIndex(pzOut, zDefText); } /* * Now insert the name with a consistent name string prefix * that we use to locate the sort key later. */ pzOut += sprintf(pzOut, "%s%s';\n", zNameTag, zNameText); *ppzOut = pzOut; *ppzDef = pzDef; *pzDef = '\n'; /* restore the newline. Used in pattern match */ /* * Returning "PROBLEM" means the caller must emit the "#endif\n" * at the end of the definition. */ return (pzIfText != NULL) ? PROBLEM : SUCCESS; }