Last change
on this file since 135 was
135,
checked in by sz, 10 years ago
|
neuron layout algorithm (for schematic drawing), usage example in frams/_demos/neuro_layout_test.cpp
|
-
Property svn:eol-style set to
native
|
File size:
937 bytes
|
Rev | Line | |
---|
[135] | 1 | #include "nn_layout_model.h" |
---|
| 2 | |
---|
| 3 | NNLayoutState_Model::NNLayoutState_Model(Model* m) |
---|
| 4 | { |
---|
| 5 | model = m; |
---|
| 6 | neuron_pos = (m->getNeuroCount() > 0) ? new NeuronPos[m->getNeuroCount()] : NULL; |
---|
| 7 | } |
---|
| 8 | |
---|
| 9 | NNLayoutState_Model::~NNLayoutState_Model() |
---|
| 10 | { |
---|
| 11 | if (neuron_pos) delete[] neuron_pos; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | int NNLayoutState_Model::GetElements() |
---|
| 15 | { |
---|
| 16 | return model->getNeuroCount(); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | int *NNLayoutState_Model::GetXYWH(int el) |
---|
| 20 | { |
---|
| 21 | return &neuron_pos[el].x; |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | void NNLayoutState_Model::SetXYWH(int el, int x, int y, int w, int h) |
---|
| 25 | { |
---|
| 26 | NeuronPos &np = neuron_pos[el]; |
---|
| 27 | np.x = x; np.y = y; np.w = w; np.h = h; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | int NNLayoutState_Model::GetInputs(int el) |
---|
| 31 | { |
---|
| 32 | return model->getNeuro(el)->getInputCount(); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | int NNLayoutState_Model::GetLink(int el, int i) |
---|
| 36 | { |
---|
| 37 | return model->getNeuro(el)->getInput(i)->refno; |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | int *NNLayoutState_Model::GetLinkXY(int el, int i) |
---|
| 41 | { |
---|
| 42 | static int XY[2]; |
---|
| 43 | int *xywh = GetXYWH(el); |
---|
| 44 | XY[0] = 0; |
---|
| 45 | XY[1] = ((1 + i)*xywh[3]) / (GetInputs(el) + 1); |
---|
| 46 | return XY; |
---|
| 47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.