unsigned vertex(double* x, double* y) { if (tolerance_ == 0.0) return geom_.vertex(x, y); if (status_ == initial) init_vertices(); return output_vertex(x, y); }
unsigned vertex(double * x, double * y) { if (offset_ == 0.0) { return geom_.vertex(x, y); } if (status_ == initial) { init_vertices(); } if (pos_ >= vertices_.size()) { return SEG_END; } pre_ = (pos_ ? cur_ : pre_first_); cur_ = vertices_.at(pos_++); if (pos_ == vertices_.size()) { return output_vertex(x, y); } double const check_dist = offset_ * threshold_; double const check_dist2 = check_dist * check_dist; double t = 1.0; double vt, ut; for (size_t i = pos_; i+1 < vertices_.size(); ++i) { //break; // uncomment this to see all the curls vertex2d const& u0 = vertices_[i]; vertex2d const& u1 = vertices_[i+1]; double const dx = u0.x - cur_.x; double const dy = u0.y - cur_.y; if (dx*dx + dy*dy > check_dist2) { break; } if (!intersection(pre_, cur_, &vt, u0, u1, &ut)) { continue; } if (vt < 0.0 || vt > t || ut < 0.0 || ut > 1.0) { continue; } t = vt; pos_ = i+1; } cur_.x = pre_.x + t * (cur_.x - pre_.x); cur_.y = pre_.y + t * (cur_.y - pre_.y); return output_vertex(x, y); }
int call_pregraph ( int argc, char ** argv ) { time_t start_t, stop_t, time_bef, time_aft; time ( &start_t ); initenv ( argc, argv ); if ( overlaplen % 2 == 0 ) { overlaplen++; printf ( "K should be an odd number\n" ); } if ( overlaplen < 13 ) { overlaplen = 13; printf ( "K should not be less than 13\n" ); } else if ( overlaplen > 31 ) { overlaplen = 31; printf ( "K should not be greater than 31\n" ); } time ( &time_bef ); prlRead2HashTable ( shortrdsfile, graphfile ); time ( &time_aft ); printf ( "time spent on pre-graph construction: %ds\n\n", ( int ) ( time_aft - time_bef ) ); printf ( "deLowKmer %d, deLowEdge %d\n", deLowKmer, deLowEdge ); //analyzeTips(hash_table, graphfile); if ( !deLowKmer && cutTips ) { time ( &time_bef ); removeSingleTips(); removeMinorTips(); time ( &time_aft ); printf ( "time spent on cutTipe: %ds\n\n", ( int ) ( time_aft - time_bef ) ); } else { time ( &time_bef ); removeMinorTips(); time ( &time_aft ); printf ( "time spent on cutTipe: %ds\n\n", ( int ) ( time_aft - time_bef ) ); } initKmerSetSize = 0; //combine each linear part to an edge time ( &time_bef ); kmer2edges ( graphfile ); time ( &time_aft ); printf ( "time spent on making edges: %ds\n\n", ( int ) ( time_aft - time_bef ) ); //map read to edge one by one time ( &time_bef ); prlRead2edge ( shortrdsfile, graphfile ); time ( &time_aft ); printf ( "time spent on mapping reads: %ds\n\n", ( int ) ( time_aft - time_bef ) ); output_vertex ( graphfile ); free_Sets ( KmerSets, thrd_num ); free_Sets ( KmerSetsPatch, thrd_num ); time ( &stop_t ); printf ( "overall time for lightgraph: %dm\n\n", ( int ) ( stop_t - start_t ) / 60 ); return 0; }