Пример #1
0
	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.");
	}
Пример #2
0
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)));
}
Пример #3
0
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;
  }
}
Пример #4
0
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;
}
Пример #5
0
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;
}