Skip to content

Commit

Permalink
Merge pull request #23 from dnkrtz/master
Browse files Browse the repository at this point in the history
Exposing voronoi edges and facets.
  • Loading branch information
inducer committed Aug 25, 2016
2 parents e2b41fe + 154d383 commit a1b6eb3
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 20 deletions.
6 changes: 6 additions & 0 deletions doc/tri-tet.rst
Expand Up @@ -285,6 +285,12 @@ Some common notions
.. attribute:: edge_adjacent_elements

.. versionadded:: 2016.1
.. attribute:: voro_edges

.. versionadded:: 2016.2
.. attribute:: voro_facets

.. versionadded:: 2016.2
.. attribute:: number_of_point_attributes
.. attribute:: number_of_element_attributes

Expand Down
70 changes: 50 additions & 20 deletions src/cpp/wrap_tetgen.cpp
Expand Up @@ -34,22 +34,25 @@ namespace
tForeignArray<REAL> ElementVolumes; // out
tForeignArray<int> Neighbors; // out

tForeignArray<tetgenio::facet> Facets;
tForeignArray<int> FacetMarkers;
tForeignArray<tetgenio::facet> Facets;
tForeignArray<int> FacetMarkers;

tForeignArray<REAL> Holes;
tForeignArray<REAL> Regions;
tForeignArray<REAL> Holes;
tForeignArray<REAL> Regions;

tForeignArray<REAL> FacetConstraints;
tForeignArray<REAL> SegmentConstraints;
tForeignArray<REAL> FacetConstraints;
tForeignArray<REAL> SegmentConstraints;

tForeignArray<int> Faces;
tForeignArray<int> AdjacentElements;
tForeignArray<int> FaceMarkers;
tForeignArray<int> Faces;
tForeignArray<int> AdjacentElements;
tForeignArray<int> FaceMarkers;

tForeignArray<int> Edges;
tForeignArray<int> EdgeMarkers;
tForeignArray<int> EdgeAdjTetList;
tForeignArray<int> Edges;
tForeignArray<int> EdgeMarkers;
tForeignArray<int> EdgeAdjTetList;

tForeignArray<tetgenio::voroedge> VoroEdges;
tForeignArray<tetgenio::vorofacet> VoroFacets;

public:
tMeshInfo()
Expand Down Expand Up @@ -80,7 +83,10 @@ namespace

Edges(edgelist, numberofedges, 2),
EdgeMarkers(edgemarkerlist, numberofedges, 1, &Edges),
EdgeAdjTetList(edgeadjtetlist, numberofedges, 1, &Edges)
EdgeAdjTetList(edgeadjtetlist, numberofedges, 1, &Edges),

VoroEdges(vedgelist, numberofvedges, 2),
VoroFacets(vfacetlist, numberofvfacets, 2)
{
Elements.fixUnit(numberofcorners);
}
Expand Down Expand Up @@ -249,25 +255,30 @@ namespace
self.polygonlist, self.numberofpolygons);
}




tForeignArray<REAL> *facet_get_holes(tetgenio::facet &self)
{
return new tForeignArray<REAL>(self.holelist, self.numberofholes, 3);
}





tForeignArray<int> *polygon_get_vertices(tetgenio::polygon &self)
{
return new tForeignArray<int>(self.vertexlist, self.numberofvertices);
}
}

int *voro_get_edge(tetgenio::voroedge &self)
{
int edge[2] = { self.v1, self.v2 };
return edge;
}

int *voro_get_facet(tetgenio::vorofacet &self)
{
int facet[2] = { self.c1, self.c2 };
return facet;
}

}



Expand Down Expand Up @@ -314,6 +325,9 @@ BOOST_PYTHON_MODULE(_tetgen)
.def_readonly("edge_markers", &cl::EdgeMarkers)
.def_readonly("edge_adjacent_elements", &cl::EdgeAdjTetList)

.def_readonly("voro_edges", &cl::VoroEdges)
.def_readonly("voro_facets", &cl::VoroFacets)

.add_property("number_of_point_attributes",
&cl::numberOfPointAttributes,
&cl::setNumberOfPointAttributes)
Expand Down Expand Up @@ -368,6 +382,22 @@ BOOST_PYTHON_MODULE(_tetgen)
;
}

{
typedef tetgenio::voroedge cl;
class_<cl, boost::noncopyable>("VoroEdge", no_init)
.add_property("v",
make_function(voro_get_edge, manage_new_internal_reference<>()))
;
}

{
typedef tetgenio::vorofacet cl;
class_<cl, boost::noncopyable>("VoroFacet", no_init)
.add_property("c",
make_function(voro_get_facet, manage_new_internal_reference<>()))
;
}

{
typedef tetgenbehavior cl;
class_<cl, boost::noncopyable>("Options", init<>())
Expand Down

0 comments on commit a1b6eb3

Please sign in to comment.