static PyObject* is_boundary(PygtsVertex* self, PyObject *args) { PyObject *s_; PygtsObject *s; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "O", &s_) ) { return NULL; } /* Convert to PygtsObjects */ if(!pygts_surface_check(s_)) { PyErr_SetString(PyExc_TypeError,"expected a Surface"); return NULL; } s = PYGTS_OBJECT(s_); if( gts_vertex_is_boundary(PYGTS_VERTEX_AS_GTS_VERTEX(self), PYGTS_SURFACE_AS_GTS_SURFACE(s)) ) { Py_INCREF(Py_True); return Py_True; } else { Py_INCREF(Py_False); return Py_False; } }
inGtsSurface(py::object _surf, bool _noPad=false): pySurf(_surf), noPad(_noPad), noPadWarned(false) { if(!pygts_surface_check(_surf.ptr())) throw std::invalid_argument("Ctor must receive a gts.Surface() instance."); surf=PYGTS_SURFACE_AS_GTS_SURFACE(PYGTS_SURFACE(_surf.ptr())); if(!gts_surface_is_closed(surf)) throw std::invalid_argument("Surface is not closed."); is_open=gts_surface_volume(surf)<0.; if((tree=gts_bb_tree_surface(surf))==NULL) throw std::runtime_error("Could not create GTree."); }
static PyObject* neighbor_number(PygtsFace *self, PyObject *args) { PyObject *s_=NULL; PygtsSurface *s=NULL; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "O", &s_) ) return NULL; /* Convert to PygtsObjects */ if( pygts_surface_check(s_) ) { s = PYGTS_SURFACE(s_); } else { PyErr_SetString(PyExc_TypeError, "expected a Surface"); return NULL; } return Py_BuildValue("i", gts_face_neighbor_number(PYGTS_FACE_AS_GTS_FACE(self), PYGTS_SURFACE_AS_GTS_SURFACE(s))); }
static PyObject* is_on(PygtsFace *self, PyObject *args) { PyObject *s_=NULL; PygtsSurface *s=NULL; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "O", &s_) ) return NULL; /* Convert to PygtsObjects */ if( pygts_surface_check(s_) ) { s = PYGTS_SURFACE(s_); } else { PyErr_SetString(PyExc_TypeError, "expected a Surface"); return NULL; } if( gts_face_has_parent_surface(PYGTS_FACE_AS_GTS_FACE(self), PYGTS_SURFACE_AS_GTS_SURFACE(s)) ) { Py_INCREF(Py_True); return Py_True; } else { Py_INCREF(Py_False); return Py_False; } }
static PyObject* is_compatible(PygtsFace *self, PyObject *args) { PyObject *o1_=NULL; GtsEdge *e=NULL; PygtsTriangle *t=NULL; PygtsSurface *s=NULL; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "O", &o1_) ) return NULL; /* Convert to PygtsObjects */ if( pygts_triangle_check(o1_) ) { t = PYGTS_TRIANGLE(o1_); } else { if( pygts_surface_check(o1_) ) { s = PYGTS_SURFACE(o1_); } else { PyErr_SetString(PyExc_TypeError, "expected a Triangle or Surface"); return NULL; } } if(t!=NULL) { if( (e = gts_triangles_common_edge(PYGTS_TRIANGLE_AS_GTS_TRIANGLE(self), PYGTS_TRIANGLE_AS_GTS_TRIANGLE(t))) == NULL ) { PyErr_SetString(PyExc_RuntimeError, "Faces do not share common edge"); return NULL; } if(gts_triangles_are_compatible(PYGTS_TRIANGLE_AS_GTS_TRIANGLE(self), PYGTS_TRIANGLE_AS_GTS_TRIANGLE(t), e)==TRUE) { Py_INCREF(Py_True); return Py_True; } } else { if(gts_face_is_compatible(PYGTS_FACE_AS_GTS_FACE(self), PYGTS_SURFACE_AS_GTS_SURFACE(s))==TRUE) { Py_INCREF(Py_True); return Py_True; } } Py_INCREF(Py_False); return Py_False; }
static PyObject* faces(PygtsVertex* self, PyObject *args) { PyObject *s_=NULL; GtsSurface *s=NULL; GSList *faces,*f; PygtsFace *face; PyObject *tuple; guint n,N; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "|O", &s_) ) { return NULL; } /* Convert */ if( s_ != NULL ) { if(!pygts_surface_check(s_)) { PyErr_SetString(PyExc_TypeError,"expected a Surface"); return NULL; } s = PYGTS_SURFACE_AS_GTS_SURFACE(s_); } /* Get the faces */ faces = gts_vertex_faces(PYGTS_VERTEX_AS_GTS_VERTEX(self),s,NULL); N = g_slist_length(faces); /* Create the tuple */ if( (tuple=PyTuple_New(N)) == NULL) { PyErr_SetString(PyExc_MemoryError,"expected a tuple"); return NULL; } /* Put PygtsVertex objects into the tuple */ f = faces; for(n=0;n<N;n++) { if( (face = pygts_face_new(GTS_FACE(f->data))) == NULL ) { Py_DECREF(tuple); return NULL; } PyTuple_SET_ITEM(tuple, n, (PyObject*)face); f = g_slist_next(f); } return tuple; }
static PyObject* neighbors(PygtsFace *self, PyObject *args) { PyObject *s_=NULL; PygtsSurface *s=NULL; guint i,N; PyObject *tuple; GSList *faces,*f; PygtsFace *face; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "O", &s_) ) return NULL; /* Convert to PygtsObjects */ if( pygts_surface_check(s_) ) { s = PYGTS_SURFACE(s_); } else { PyErr_SetString(PyExc_TypeError, "expected a Surface"); return NULL; } N = gts_face_neighbor_number(PYGTS_FACE_AS_GTS_FACE(self), PYGTS_SURFACE_AS_GTS_SURFACE(s)); if( (tuple=PyTuple_New(N)) == NULL) { PyErr_SetString(PyExc_MemoryError, "Could not create tuple"); return NULL; } /* Get the neighbors */ faces = gts_face_neighbors(PYGTS_FACE_AS_GTS_FACE(self), PYGTS_SURFACE_AS_GTS_SURFACE(s)); f = faces; for(i=0;i<N;i++) { if( (face = pygts_face_new(GTS_FACE(f->data))) == NULL ) { Py_DECREF(tuple); return NULL; } PyTuple_SET_ITEM(tuple, i, (PyObject*)face); f = g_slist_next(f); } return (PyObject*)tuple; }
static PyObject* neighbors(PygtsVertex* self, PyObject *args) { PyObject *s_=NULL; GtsSurface *s=NULL; GSList *vertices,*v; PygtsVertex *vertex; PyObject *tuple; guint n,N; SELF_CHECK /* Parse the args */ if(! PyArg_ParseTuple(args, "|O", &s_) ) { return NULL; } /* Convert */ if( s_ != NULL ) { if(!pygts_surface_check(s_)) { PyErr_SetString(PyExc_TypeError,"expected a Surface"); return NULL; } s = PYGTS_SURFACE_AS_GTS_SURFACE(s_); } /* Get the neighbors */ vertices = gts_vertex_neighbors(PYGTS_VERTEX_AS_GTS_VERTEX(self), NULL,s); N = g_slist_length(vertices); /* Create the tuple */ if( (tuple=PyTuple_New(N)) == NULL) { PyErr_SetString(PyExc_MemoryError,"could not create tuple"); return NULL; } /* Put PygtsVertex objects into the tuple */ v = vertices; for(n=0;n<N;n++) { /* Skip this vertex if it is a parent */ while( v!=NULL && PYGTS_IS_PARENT_VERTEX(GTS_VERTEX(v->data)) ) { v = g_slist_next(v); } if( v==NULL ) break; if( (vertex = pygts_vertex_new(GTS_VERTEX(v->data))) == NULL ) { Py_DECREF((PyObject*)tuple); return NULL; } PyTuple_SET_ITEM(tuple, n, (PyObject*)vertex); v = g_slist_next(v); } if(_PyTuple_Resize(&tuple,n)!=0) { Py_DECREF(tuple); return NULL; } return tuple; }