-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPathExtractor.h
More file actions
97 lines (75 loc) · 2.33 KB
/
PathExtractor.h
File metadata and controls
97 lines (75 loc) · 2.33 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* PathExtractor.h
* Morph
*
* Created by Christian Brunschen on 27/11/2011.
* Copyright 2011 Christian Brunschen. All rights reserved.
*
*/
#ifndef __PathExtractor_h__
#define __PathExtractor_h__
#include "Primitives.h"
#include "Bitmap.h"
#include "GreyImage.h"
#include "Chain.h"
#include "Progress.h"
#include <iostream>
#include <list>
#include <map>
using namespace std;
using namespace Images;
using namespace Primitives;
using namespace Progress;
namespace Extraction {
#if 0
}
#endif
class PathExtractor {
protected:
Stepper *stepper_;
Approximator *approximator_;
ostream *out_;
shared_ptr<Workers> workers_;
public:
PathExtractor() : stepper_(NULL), approximator_(NULL), out_(NULL), workers_(NULL) {}
void setStepper(Stepper *stepper) { stepper_ = stepper; }
Stepper *stepper() { return stepper_; }
bool steps() { return stepper_ != NULL; }
void setApproximator(Approximator *approximator) { approximator_ = approximator; }
Approximator *approximator() { return approximator_; }
bool approximate() { return approximator_ != NULL; }
void setOut(ostream *out) { out_ = out; }
ostream *out() { return out_; }
void setThreads(int n) { workers_ = shared_ptr<Workers>::make_shared(n); }
void setWorkers(shared_ptr<Workers> &workers) { workers_ = workers; }
shared_ptr<Workers> getWorkers() { return workers_; }
int getThreads() { if (workers_) { return workers_->n(); } else { return 1; } }
};
class CanRetractWhenDeltaIsSetInReference {
const Bitmap &reference_;
const Circle &circle_;
public:
CanRetractWhenDeltaIsSetInReference(const Bitmap &thinInsetReference, const Circle &circle)
: reference_(thinInsetReference), circle_(circle) { }
bool operator()(const IPoint &p, int neighbours) const {
const list<IPoint> &delta = circle_.getDelta(neighbours);
bool result = true;
for (list<IPoint>::const_iterator i = delta.begin();
result && i != delta.end();
++i) {
IPoint q(p + *i);
result = reference_.get(q);
}
return result;
}
};
extern ostream &preparePS(ostream &a, int width, int height);
extern ostream &drawChainPixels(ostream &a, Chains &chains);
extern ostream &strokeChains(ostream &a, Chains chains);
extern ostream &strokeBetween(ostream &a, Chains chains);
extern void finishPS(ostream &a);
#if 0
{
#endif
}
#endif // __PathExtractor_h__