GEODE_UNUSED static void check_bsp(const TriangleTopology& mesh, RawArray<const Node> bsp, RawField<const Vector<int,2>,FaceId> face_to_bsp, RawField<const Perturbed2,VertexId> X_) { if (self_check) { cout << "bsp:\n"; #define CHILD(c) format("%c%d",(c<0?'f':'n'),(c<0?~c:c)) for (const int n : range(bsp.size())) cout << " "<<n<<" : test "<<bsp[n].test<<", children "<<CHILD(bsp[n].children[0])<<" "<<CHILD(bsp[n].children[1])<<endl; cout << "tris = "<<mesh.elements()<<endl; cout << "X = "<<X_.flat<<endl; } for (const int n : range(bsp.size())) for (const int i : range(2)) if (bsp[n].children[i]<0) GEODE_ASSERT(face_to_bsp[FaceId(~bsp[n].children[i])].contains(2*n+i)); auto X = X_.copy(); for (const auto f : mesh.faces()) { int i0,i1; face_to_bsp[f].get(i0,i1); if (bsp.size()) GEODE_ASSERT(bsp[i0/2].children[i0&1]==~f.id); if (i1>=0) GEODE_ASSERT(bsp[i1/2].children[i1&1]==~f.id); const auto v = mesh.vertices(f); if (!is_sentinel(X[v.x]) && !is_sentinel(X[v.y]) && !is_sentinel(X[v.z])) { const auto center = X.append(Perturbed2(X.size(),(X[v.x].value()+X[v.y].value()+X[v.z].value())/3)); const auto found = bsp_search(bsp,X,center); if (found!=f) { cout << "bsp search failed: f "<<f<<", v "<<v<<", found "<<found<<endl; GEODE_ASSERT(false); } X.flat.pop(); } } }
bool equal(common_cursor<I2, S2> const &that) const { return is_sentinel() ? (that.is_sentinel() || that.it() == se()) : (that.is_sentinel() ? it() == that.se() : it() == that.it()); }
// Test whether an edge containing sentinels is Delaunay GEODE_COLD GEODE_PURE static inline bool is_delaunay_sentinels(Perturbed2 x0, Perturbed2 x1, Perturbed2 x2, Perturbed2 x3) { // Unfortunately, the sentinels need to be at infinity for purposes of Delaunay testing, and our SOS predicates // don't support infinities. Therefore, we need some case analysis. First, we move all the sentinels to the end, // sorted in decreasing order of index. Different sentinels will be placed at different orders of infinity, // with earlier indices further away, so our order will place larger infinities last. bool parity = 0; COMPARATOR(0,1) COMPARATOR(2,3) COMPARATOR(0,2) COMPARATOR(1,3) COMPARATOR(1,2) if (!is_sentinel(x2)) // One infinity: A finite circle contains infinity iff it is inside out, so we reduce to an orientation test return parity^triangle_oriented(x0,x1,x2); else if (!is_sentinel(x1)) // Two infinities: also an orientation test, but with the last point at infinity return parity^segment_to_direction_oriented(x0,x1,x2); else // Three infinities: the finite point no longer matters. return parity^directions_oriented(x1,x2); }
GEODE_COLD GEODE_PURE static inline bool triangle_oriented_sentinels(Perturbed2 x0, Perturbed2 x1, Perturbed2 x2) { // Move large sentinels last bool parity = 0; COMPARATOR(0,1) COMPARATOR(1,2) COMPARATOR(0,1) // Triangle orientation tests reduce to segment vs. direction and direction vs. direction when infinities are involved return parity ^ (!is_sentinel(x1) ? segment_to_direction_oriented(x0,x1,x2) // one sentinel : directions_oriented( x1,x2)); // two or three sentinels }
void CacheStat::dump_stat(cache_stat* stats, int32_t count, cache_stat* last_stats, cache_stat* total_stat, const StatDumpFilter* filter, bool& should_dump) { cache_stat* pstat; for (int i = 0; i < count; ++i) { pstat = stats + i; if (is_sentinel(pstat)) // reach one stat record start { if (sentinel_valid(pstat)) { should_dump = filter->ok(get_time(pstat)); } else // sentinel is invalid. it's the end of whole last stat. { memset(last_stats, 0, CACHE_STAT_SIZE * TAIR_MAX_AREA_COUNT); if (should_dump) { print_total_stat(total_stat); // print last total stat total_stat->reset(); fprintf(stderr, "\t============== ONE WHOLE STAT END ================\n"); } should_dump = false; } if (should_dump) { print_total_stat(total_stat); // print last total stat total_stat->reset(); print_sentinel(pstat); // print sentinel } } else if (should_dump) { print_and_add_total_stat(pstat, last_stats, total_stat); // just print } } }
remaining_time remaining_milliseconds() const { if(is_sentinel()) { return remaining_time(win32::infinite); } else if(relative) { unsigned long const now=win32::GetTickCount(); unsigned long const elapsed=now-start; return remaining_time((elapsed<milliseconds)?(milliseconds-elapsed):0); } else { system_time const now=get_system_time(); if(abs_time<=now) { return remaining_time(0); } return remaining_time((abs_time-now).total_milliseconds()+1); } }
S const & se() const { RANGES_ASSERT(is_sentinel()); return ranges::get<1>(data_); }
I const & it() const { RANGES_ASSERT(!is_sentinel()); return ranges::get<0>(data_); }