blob: 6479a00ba56c4c5af30e9b43253459202fc4fddc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*****
* guide.cc
* Andy Hammerlindl 2005/02/23
*
*****/
#include "guide.h"
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=length;
if(n > 0) {
for(size_t i=0; i+1 < n; ++i) {
subguide(i)->flatten(g,allowsolve);
if(!allowsolve && subguide(i)->cyclic()) {
g.precyclic(true);
g.resolvecycle();
}
}
subguide(n-1)->flatten(g,allowsolve);
}
}
void multiguide::print(ostream& out) const
{
side lastLoc=JOIN;
for(size_t i=0; i < length; ++i) {
guide *g = subguide(i);
side loc = g->printLocation();
adjustLocation(out,lastLoc,loc);
g->print(out);
lastLoc=loc;
}
}
} // namespace camp
|