Exemple #1
0
PyObject* nrnpy_pushsec(PyObject* sec) {
	if (PyObject_TypeCheck(sec, psection_type)) {
		nrn_pushsec(((NPySecObj*)sec)->sec_);
		return sec;
	}
	return NULL;
}
Exemple #2
0
static void call(Symbol* s, Node* nd, Prop* p) {
	Section* sec = nd->sec;
	Object* ob = p->ob;
	double x = nrn_arc_position(sec, nd);
	nrn_pushsec(sec);
	hoc_pushx(x);
//printf("hoc_call_objfunc %s ob=%s\n", s->name, hoc_object_name(ob));
	hoc_call_objfunc(s, 1, ob);
	nrn_popsec();
}
Exemple #3
0
static PyObject* NPySecObj_connect(NPySecObj* self, PyObject*  args) {
	PyObject* p;
	NPySecObj* parent;
	double parentx, childend;
	parentx = -1000.; childend = 0.;
	if (!PyArg_ParseTuple(args, "O|dd", &p, &parentx, &childend)) {
		return NULL;
	}
	if (PyObject_TypeCheck(p, psection_type)) {
		parent = (NPySecObj*)p;
		if (parentx == -1000.) { parentx = 1.; }
	}else if (PyObject_TypeCheck(p, psegment_type)) {
		parent = ((NPySegObj*)p)->pysec_;
		if (parentx != -1000.) { childend = parentx; }
		parentx = ((NPySegObj*)p)->x_;
	}else{
		PyErr_SetString(PyExc_TypeError, "first arg not a nrn.Section or nrn.Segment");
		return NULL;
	}
//printf("NPySecObj_connect %s %g %g\n", parent, parentx, childend);
	if (parentx > 1. || parentx < 0.) {
		PyErr_SetString(PyExc_ValueError, "out of range 0 <= parentx <= 1.");
		return NULL;
	}
	if (childend != 0. && childend != 1.) {
		PyErr_SetString(PyExc_ValueError, "child connection end must be  0 or 1");
		return NULL;
	}
	Py_INCREF(self);
	hoc_pushx(childend);
	hoc_pushx(parentx);
	nrn_pushsec(self->sec_);
	nrn_pushsec(parent->sec_);
	simpleconnectsection();
	return (PyObject*)self;
}
Exemple #4
0
double* NrnSection::var_pointer(const char* var) {
	nrn_pushsec(nsi_->sec_);
	double* pval = hoc_val_pointer(var);
	nrn_popsec();
	return pval;
}
Exemple #5
0
static PyObject* NPySecObj_push(NPySecObj* self, PyObject*  args) {
	nrn_pushsec(self->sec_);
	Py_INCREF(self);
	return (PyObject*)self;
}