diff options
Diffstat (limited to 'Build/source/utils/asymptote/guide.cc')
-rw-r--r-- | Build/source/utils/asymptote/guide.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/Build/source/utils/asymptote/guide.cc b/Build/source/utils/asymptote/guide.cc index b46c269290d..6479a00ba56 100644 --- a/Build/source/utils/asymptote/guide.cc +++ b/Build/source/utils/asymptote/guide.cc @@ -8,28 +8,44 @@ namespace camp { +multiguide::multiguide(guidevector& v) +{ + // This constructor tests if the first subguide is also a multiguide and, + // if possible, uses the same base, extending it beyond what is used. + multiguide *rg = v.empty() ? 0 : dynamic_cast<multiguide *>(v[0]); + if (rg && rg->base->size() == rg->length) { + base = rg->base; + base->insert(base->end(), v.begin()+1, v.end()); + } + else + base = new guidevector(v); + + length = base->size(); +} + void multiguide::flatten(flatguide& g, bool allowsolve) { - size_t n=v.size(); + size_t n=length; if(n > 0) { for(size_t i=0; i+1 < n; ++i) { - v[i]->flatten(g,allowsolve); - if(!allowsolve && v[i]->cyclic()) { + subguide(i)->flatten(g,allowsolve); + if(!allowsolve && subguide(i)->cyclic()) { g.precyclic(true); g.resolvecycle(); } } - v[n-1]->flatten(g,allowsolve); + subguide(n-1)->flatten(g,allowsolve); } } void multiguide::print(ostream& out) const { side lastLoc=JOIN; - for(size_t i=0; i < v.size(); ++i) { - side loc=v[i]->printLocation(); + for(size_t i=0; i < length; ++i) { + guide *g = subguide(i); + side loc = g->printLocation(); adjustLocation(out,lastLoc,loc); - v[i]->print(out); + g->print(out); lastLoc=loc; } } |