NEURON
sections.cpp
Go to the documentation of this file.
1 /* NOTE: this assumes neuronapi.h is on your CPLUS_INCLUDE_PATH */
2 #include "neuronapi.h"
3 #include <stdio.h>
4 #include <dlfcn.h>
5 #include <stdlib.h>
6 #include <assert.h>
7 
8 extern "C" void modl_reg(){};
9 
10 int main(void) {
11  static const char* argv[] = {"sections", "-nogui", "-nopython", NULL};
12  nrn_init(3, argv);
13 
14  // topology
15  Section* soma = nrn_section_new("soma");
16  Section* dend1 = nrn_section_new("dend1");
17  Section* dend2 = nrn_section_new("dend2");
18  Section* dend3 = nrn_section_new("dend3");
19  Section* axon = nrn_section_new("axon");
20  nrn_section_connect(dend1, 0, soma, 1);
21  nrn_section_connect(dend2, 0, dend1, 1);
22  nrn_section_connect(dend3, 0, dend1, 1);
23  nrn_section_connect(axon, 0, soma, 0);
24  nrn_nseg_set(axon, 5);
25 
26  // print out the morphology
27  nrn_function_call(nrn_symbol("topology"), 0);
28 
29  /* create a SectionList that is dend1 and its children */
30  Object* seclist = nrn_object_new(nrn_symbol("SectionList"), 0);
31  nrn_section_push(dend1);
32  nrn_method_call(seclist, nrn_method_symbol(seclist, "subtree"), 0);
34 
35  /* loop over allsec, print out */
36  printf("allsec:\n");
38  while (!nrn_sectionlist_iterator_done(sli)) {
40  printf(" %s\n", nrn_secname(sec));
41  }
43 
44  printf("\ndend1's subtree:\n");
46  while (!nrn_sectionlist_iterator_done(sli)) {
48  printf(" %s\n", nrn_secname(sec));
49  }
51 }
#define sec
Definition: md1redef.h:20
static char ** argv
Definition: inithoc.cpp:46
static void nrn_init(neuron::model_sorted_token const &, NrnThread *nt, Memb_list *ml, int type)
Definition: kschan.cpp:69
printf
Definition: extdef.h:5
SectionListIterator * nrn_sectionlist_iterator_new(nrn_Item *my_sectionlist)
Definition: neuronapi.cpp:532
void nrn_section_pop(void)
Definition: neuronapi.cpp:142
Symbol * nrn_symbol(char const *const name)
Definition: neuronapi.cpp:232
void nrn_nseg_set(Section *const sec, const int nseg)
Definition: neuronapi.cpp:180
void nrn_method_call(Object *obj, Symbol *method_sym, int narg)
Definition: neuronapi.cpp:352
Symbol * nrn_method_symbol(const Object *obj, char const *const name)
Definition: neuronapi.cpp:348
void nrn_section_push(Section *sec)
Definition: neuronapi.cpp:138
Section * nrn_section_new(char const *const name)
Definition: neuronapi.cpp:75
nrn_Item * nrn_sectionlist_data(const Object *obj)
Definition: neuronapi.cpp:223
Object * nrn_object_new(Symbol *sym, int narg)
Definition: neuronapi.cpp:344
nrn_Item * nrn_allsec(void)
Definition: neuronapi.cpp:219
void nrn_section_connect(Section *child_sec, double child_x, Section *parent_sec, double parent_x)
Definition: neuronapi.cpp:88
Section * nrn_sectionlist_iterator_next(SectionListIterator *sl)
Definition: neuronapi.cpp:540
char const * nrn_secname(Section *sec)
Definition: neuronapi.cpp:134
int nrn_sectionlist_iterator_done(SectionListIterator *sl)
Definition: neuronapi.cpp:544
void nrn_function_call(Symbol *sym, int narg)
Definition: neuronapi.cpp:356
void nrn_sectionlist_iterator_free(SectionListIterator *sl)
Definition: neuronapi.cpp:536
void modl_reg()
Definition: sections.cpp:8
int main(void)
Definition: sections.cpp:10
#define NULL
Definition: spdefs.h:105
Definition: hocdec.h:173