//returns 1 for collapsed, 0 for not collapsed int check_collapsed() { if(is_collapsed() != collapsed) { collapsed = is_collapsed(); if(collapsed) message("info", "The rock column stops emitting light, trembles and shakes, then collapses into a pile of rubble.", environment(this_object())); else message("info", "The pile of rubble builds itself into a large column and begins emitting a beam of light, which shoots out of the room.", environment(this_object())); } return collapsed; }
void on_toggle() { if(is_collapsed()) expand(); else collapse(); }
void reduce(Route& src, Route& sink, double maxDistance) { if(maxDistance == 0) return; LOG_DEBUG(src.size()); typedef SegmentGraphImpl<boost::setS, boost::setS> UniqueSegmentGraph; UniqueSegmentGraph g; for(const SegmentPtr seg : segments(src)) { g.addSegment(*seg.get()); } std::map<Point, UniqueSegmentGraph::Vertex> index; BOOST_FOREACH(UniqueSegmentGraph::Vertex v, vertices(g)) { index[g[v]] = v; } for(Path& path : src) { Path singleBranch; Path simplified; Point last = path.front(); Point current; for(const SegmentPtr segPtr : segments(path)) { const Segment& seg = *segPtr.get(); concat(singleBranch,seg); if(last == seg.first) current = seg.second; else assert(false); last = current; if(boost::degree(index[current],g) > 2) { boost::geometry::simplify(singleBranch, simplified, maxDistance); if(!is_collapsed(singleBranch, simplified)) add(sink, simplified); else { Box b; boost::geometry::envelope(simplified, b); if(b.width() > maxDistance && b.height() > maxDistance) { add(sink, simplified); } } singleBranch.clear(); simplified.clear(); } } if (!singleBranch.empty()) { boost::geometry::simplify(singleBranch, simplified, maxDistance); if (!is_collapsed(singleBranch, simplified)) add(sink, simplified); else { Box b; boost::geometry::envelope(simplified, b); if(b.width() > maxDistance && b.height() > maxDistance) { add(sink, simplified); } } } singleBranch.clear(); simplified.clear(); } LOG_DEBUG(sink.size()); }
void set_number(int num) { if(num > 0) myBeamNumber = num; if(is_collapsed()) collapsed = 1; else collapsed = 0; }