packages feed

bindings-gts 0.0.2 → 0.0.3

raw patch · 4 files changed

+107/−35 lines, 4 files

Files

bindings-gts.cabal view
@@ -10,33 +10,41 @@   .   NOTE: these bindings were not made by the author(s) of GTS so please   don't bug them about issues with the bindings! Any errors in these-  bindings are my responsibility not that of the GTS team. +  bindings are my responsibility not that of the GTS team.   .   NOTE: Not all functionality is covered by these bindings at this-  time, but there should be enough to be useful.  +  time, but there should be enough to be useful.   .   NOTE: Documentation does not build on Hackage DB (due to Hackage-  build hosts not having GTS on them) but can be built with +  build hosts not having GTS on them) but can be built with   /cabal haddock/   .-  Changelog: +  NOTE: Some warnings are produced during compilation; these appear+  to be the result of the Bindings-GTS macros and may safely be+  ignored (I hope!)   .-     * 0.0.1 Initial version. -  . +  Changelog:+  .+     * 0.0.1 Initial version.+  .      * 0.0.2 Improved documentation; added some missing functions; fixed a function name; bumped version of base to >=4   .--version: 0.0.2+     * 0.0.3 Adding missing GTS enumeration for CSG boolean operations; added some more missing functions; fixed some bad FunPtr references;+             added some helper methods+  .+version: 0.0.3 license: LGPL-3 license-file: LICENSE maintainer: Joel Crisp <joel.a.crisp@googlemail.com>-author: Maurício C. Antunes (Bindings-DSL), Joel Crisp (Bindings-GTS), Stephane Popinet <s.popinet at niwa.co.nz> (GTS) +author: Maurício C. Antunes (Bindings-DSL), Joel Crisp (Bindings-GTS), Stephane Popinet <s.popinet at niwa.co.nz> (GTS) build-type: Simple stability: prototype category: FFI+extra-source-files: src/Bindings/GTS_inline.h library   hs-source-dirs: src   c-sources: src/Bindings/GTS_inline.c+  includes: src/Bindings/GTS_inline.h   include-dirs: src/Bindings   extensions:     ForeignFunctionInterface@@ -44,12 +52,12 @@     base >= 4 && < 5,     bindings-DSL >= 1.0.6 && < 1.1,     bindings-glib >= 0.1.3 && < 0.2,-    bindings-gobject >= 0.2.1 && < 1.0 +    bindings-gobject >= 0.2.1 && < 1.0   include-dirs: src   exposed-modules:       Bindings.GTS   ghc-options: -Wall   pkgconfig-depends: gobject-2.0 >= 2.24.1, gthread-2.0 >= 2.24.1, gmodule-2.0 >=2.24.1, gts >=0.7.6-   -     ++
src/Bindings/GTS.hsc view
@@ -7,12 +7,17 @@ -- REMEMBER ForeignPtr for garbage collection!  -- | Bindings DSL file for the Gnu Triangulated Surface Library-module Bindings.GTS where +module Bindings.GTS where #strict_import -- import Bindings.GObject import Bindings.GLib.Fundamentals import Bindings.GLib.Fundamentals.BasicTypes +#num GTS_1_OUT_2+#num GTS_1_IN_2+#num GTS_2_OUT_1+#num GTS_2_IN_1+ #cinline GTS_CHECK_VERSION, <guint> -> <guint> -> <guint> -> IO <gboolean> #globalvar gts_allow_floating_vertices, IO <gboolean> @@ -21,11 +26,14 @@ #field next, Ptr <GSList> #stoptype --- | Allocate a node in a GSList from gobject. Note this function should not be used as the append/insert +#starttype GList+#stoptype++-- | Allocate a node in a GSList from gobject. Note this function should not be used as the append/insert --    functions call it internally #ccall g_slist_alloc, IO (Ptr <GSList>) --- | Free all the nodes in an GSList. See the glib library +-- | Free all the nodes in an GSList. See the glib library #ccall g_slist_free, Ptr <GSList> -> IO ()  -- | Free one node in a GSList@@ -43,10 +51,10 @@ -- | Get the n-th element of the GSList counting from 0 #ccall g_slist_nth, Ptr <GSList> -> <guint> -> IO (Ptr <GSList>) --- | Append a new node to a GSList +-- | Append a new node to a GSList #ccall g_slist_append, Ptr <GSList> -> <gpointer> -> IO (Ptr <GSList>) --- | Insert a new node in a GSList before the referenced node +-- | Insert a new node in a GSList before the referenced node #ccall g_slist_insert_before, Ptr <GSList> -> Ptr <GSList> -> <gpointer> -> IO (Ptr <GSList>)  -- | Insert a new node in a GSList at the specified position@@ -64,7 +72,7 @@ -- | Callback for the GTS argument get method - don't use this unless you know what you are doing #callback GtsArgGetFunc, Ptr <GtsObject> -> IO () -#num GTS_CLASS_NAME_LENGTH +#num GTS_CLASS_NAME_LENGTH  -- | Type of the GTS Vector object in Haskell #starttype GtsVector@@ -98,13 +106,13 @@ -- | Calculate the product of two matricies and return the newly allocated matrix #ccall gts_matrix_product, Ptr <GtsMatrix> -> Ptr <GtsMatrix> -> IO (Ptr <GtsMatrix>) --- | Scale a GTS Matrix in place +-- | Scale a GTS Matrix in place #ccall gts_matrix_scale, Ptr <GtsMatrix> -> Ptr <GtsVector> -> IO (Ptr <GtsMatrix>)  -- | Translate the GTS Matrix by the GTS Vector (If the Matrix is NULL a new one is allocated and translated) #ccall gts_matrix_translate, Ptr <GtsMatrix> -> Ptr <GtsVector> -> IO (Ptr <GtsMatrix>) --- | Rotate the GTS Matrix around the vector by the +-- | Rotate the GTS Matrix around the vector by the #ccall gts_matrix_rotate, Ptr <GtsMatrix> -> Ptr <GtsVector> -> <gdouble> -> IO (Ptr <GtsMatrix>)  -- | Type for an (r,g,b) triple in GTS (floating point)@@ -114,13 +122,13 @@ #field b, <gfloat> #stoptype --- | Callback for most GTS visitors +-- | Callback for most GTS visitors #callback GtsFunc, <gpointer> -> <gpointer> -> IO <gint>  -- | Callback for gts_vertices_merge #callback GtsVertexMergeFunc, Ptr <GtsVertex> -> Ptr <GtsVertex> -> IO <gboolean> --- | GTS formatted data file +-- | GTS formatted data file #starttype GtsFile #field line,<guint> #field pos,<guint>@@ -225,7 +233,7 @@ #ccall gts_triangle_area, Ptr <GtsTriangle> -> IO <gdouble>  -- | Get the perimeter of this triangle-#ccall gts_triangle_perimeter, Ptr <GtsTriangle> -> IO <gdouble> +#ccall gts_triangle_perimeter, Ptr <GtsTriangle> -> IO <gdouble>  -- | Get a measure of the quality of this triangle (how close to equilateral it is?) #ccall gts_triangle_quality, Ptr <GtsTriangle> -> IO <gdouble>@@ -241,7 +249,7 @@ #ccall gts_triangle_vertices_edges, Ptr <GtsTriangle> -> Ptr <GtsEdge> -> Ptr (Ptr <GtsVertex>) -> Ptr (Ptr <GtsVertex>) -> Ptr (Ptr <GtsVertex>) -> Ptr (Ptr <GtsEdge>) -> Ptr (Ptr <GtsEdge>) -> Ptr (Ptr <GtsEdge>) -> IO () #ccall gts_triangle_vertices, Ptr <GtsTriangle> -> Ptr <GtsEdge> -> Ptr (Ptr <GtsVertex>) -> Ptr (Ptr <GtsVertex>) -> Ptr (Ptr <GtsVertex>) -> IO () #ccall gts_triangle_vertex_opposite, Ptr <GtsTriangle> -> Ptr <GtsEdge> -> IO (Ptr <GtsVertex)-#ccall gts_triangle_edge_opposite, Ptr <GtsTriangle> -> Ptr <GtsVertex> -> IO (Ptr <GtsEdge) +#ccall gts_triangle_edge_opposite, Ptr <GtsTriangle> -> Ptr <GtsVertex> -> IO (Ptr <GtsEdge) #ccall gts_triangle_is_ok, Ptr <GtsTriangle> -> IO <gboolean> #ccall gts_triangle_circumcircle_center, Ptr <GtsTriangle> -> Ptr <GtsPointClass> -> IO (Ptr <GtsPoint>) #ccall gts_triangle_interpolate_height, Ptr <GtsTriangle> -> Ptr <GtsPoint> -> IO ()@@ -254,11 +262,11 @@ #starttype GtsVertexClass #stoptype --- | Clear a range +-- | Clear a range #ccall gts_range_init, Ptr <GtsRange> -> IO ()-#ccall gts_range_reset,Ptr <GtsRange> -> IO () -#ccall gts_range_add_value,Ptr <GtsRange> -> <gdouble> -> IO () -#ccall gts_range_update,Ptr <GtsRange> -> IO () +#ccall gts_range_reset,Ptr <GtsRange> -> IO ()+#ccall gts_range_add_value,Ptr <GtsRange> -> <gdouble> -> IO ()+#ccall gts_range_update,Ptr <GtsRange> -> IO ()  -- | GLib class pointer for the GTS point object class #ccall gts_point_class, IO (Ptr <GtsPointClass>)@@ -387,7 +395,7 @@ -- | Generate a surface which is a tessalated model of a sphere #ccall gts_surface_generate_sphere, Ptr <GtsSurface> -> <guint> -> IO ( Ptr <GtsSurface> ) --- |Add a copy of all the faces, edges and vertices of s2 to s1. +-- |Add a copy of all the faces, edges and vertices of s2 to s1. #ccall gts_surface_copy, Ptr <GtsSurface> -> Ptr <GtsSurface> -> IO (Ptr <GtsSurface> )  -- | Adds all the faces of with which do not already belong to s to s.@@ -425,6 +433,7 @@ #starttype GtsSurfaceInter #field s1,Ptr <GtsSurface> #field s2,Ptr <GtsSurface>+#field edges,Ptr <GSList> #stoptype  #starttype GNode@@ -456,14 +465,14 @@  #ccall gts_bb_tree_destroy, Ptr <GNode> -> <gboolean> -> IO () --- | TRUE if the ray starting at p and ending at (+infty, p->y, p->z) intersects with bb, FALSE otherwise.+-- | TRUE if the ray starting at p and ending at (+infty, p-> y, p-> z) intersects with bb, FALSE otherwise. #ccall gts_bb_tree_stabbed, Ptr <GNode> -> Ptr <GtsPoint> -> IO (Ptr <GSList>)  -- | Destroy a GTS object and free the associated memory. This is the generic version, see the typed helper functions #ccall gts_object_destroy, Ptr <GtsObject> -> IO ()  -- #starttype GtsConstraintClass--- #stoptype +-- #stoptype  -- #starttype GtsConstraint -- #stoptype@@ -477,7 +486,7 @@ -- | Create a new edge from a pair of vertices #ccall gts_edge_new, Ptr <GtsEdgeClass> -> Ptr <GtsVertex> -> Ptr <GtsVertex> -> IO (Ptr <GtsEdge>) --- | Replaces e with with. For each triangle which uses e as an edge, e is replaced with with. The with->triangles list is updated appropriately and the e->triangles list is freed and set to NULL+-- | Replaces e with with. For each triangle which uses e as an edge, e is replaced with with. The with-> triangles list is updated appropriately and the e-> triangles list is freed and set to NULL #ccall gts_edge_replace, Ptr <GtsEdge> -> Ptr <GtsEdge> -> IO ()  -- | Performs an "edge swap" on the two triangles sharing e and belonging to s.@@ -491,7 +500,7 @@ -- | Checks for orientation of the projection of three points on the (x,y) plane. The result is also an approximation of twice the signed area of the triangle defined by the three points. This function uses adaptive floating point arithmetic and is consequently geometrically robust. #ccall gts_point_orientation, Ptr <GtsPoint> -> Ptr <GtsPoint> -> Ptr <GtsPoint> -> IO <gdouble> --- | TRUE if p is inside the surface defined by tree, FALSE otherwise. +-- | TRUE if p is inside the surface defined by tree, FALSE otherwise. #ccall gts_point_is_inside_surface, Ptr <GtsPoint> -> Ptr <GNode> -> <gboolean> -> IO <gboolean>  -- | Tests if the planar projection (x, y) of p is inside or outside the circle defined by the planar projection of p1, p2 and p3.@@ -536,10 +545,10 @@ #ccall gts_delaunay_remove_hull, Ptr <GtsSurface> -> IO ()  -- | Recursively split constraints of surface which are encroached by vertices of surface (see Shewchuk 96 for details). The split constraints are destroyed and replaced by a set of new constraints of the same class. If gts_vertex_encroaches_edge() is used for encroaches, the resulting surface will be Delaunay conforming. If steiner_max is positive or nul, the recursive splitting procedure will stop when this maximum number of Steiner points is reached. In that case the resulting surface will not necessarily be Delaunay conforming.-#ccall gts_delaunay_conform,Ptr <GtsSurface> -> <gint> -> FunPtr <GtsEncroachFunc> -> <gpointer> -> IO <guint>+#ccall gts_delaunay_conform,Ptr <GtsSurface> -> <gint> -> <GtsEncroachFunc> -> <gpointer> -> IO <guint>  -- | An implementation of the refinement algorithm described in Ruppert (1995) and Shewchuk (1996).-#ccall gts_delaunay_refine,Ptr <GtsSurface> -> <gint> -> FunPtr <GtsEncroachFunc> -> <gpointer> -> FunPtr <GtsKeyFunc> -> <gpointer> -> IO <guint>+#ccall gts_delaunay_refine,Ptr <GtsSurface> -> <gint> -> <GtsEncroachFunc> -> <gpointer> -> <GtsKeyFunc> -> <gpointer> -> IO <guint>  -- | Add one vertex to a Delaunay triangulation preserving the Delaunay property #ccall gts_delaunay_add_vertex, Ptr <GtsSurface> -> Ptr <GtsVertex> -> Ptr <GtsFace> -> IO (Ptr <GtsVertex>)@@ -554,3 +563,41 @@ #ccall gts_surface_destroy, Ptr <GtsSurface> -> IO () #ccall gts_triangle_destroy, Ptr <GtsTriangle> -> IO () #ccall gts_vertex_destroy, Ptr <GtsVertex> -> IO ()++#opaque_t GtsSurfaceTraverse++#ccall gts_surface_traverse_new,Ptr <GtsSurface> -> Ptr <GtsFace> -> IO (Ptr <GtsSurfaceTraverse>)+#ccall gts_surface_traverse_next, Ptr <GtsSurfaceTraverse> -> Ptr <guint> -> IO (Ptr <GtsFace>)+#ccall gts_surface_traverse_destroy,Ptr <GtsSurfaceTraverse> -> IO ()++#callback GtsRefineFunc, Ptr <GtsEdge> -> Ptr <GtsVertexClass> -> <gpointer> -> IO (Ptr <GtsVertex>)+#callback GtsStopFunc, <gdouble> -> <guint> -> <gpointer> -> IO <gboolean>++#ccall gts_surface_tessellate,Ptr <GtsSurface> -> <GtsRefineFunc> -> <gpointer> -> IO ()+#ccall gts_surface_refine, Ptr <GtsSurface> -> <GtsKeyFunc> -> <gpointer> -> <GtsRefineFunc> -> <gpointer> -> <GtsStopFunc> -> <gpointer> -> IO ()++#ccall gts_edge_face_number, Ptr <GtsEdge> -> Ptr <GtsSurface> -> IO <guint>+#ccall gts_edge_manifold_faces, Ptr <GtsEdge> -> Ptr <GtsSurface> -> Ptr (Ptr <GtsFace>) -> Ptr (Ptr <GtsFace>) -> <gboolean>+#ccall gts_edge_belongs_to_tetrahedron, Ptr <GtsEdge> -> <gboolean>++#ccall gts_edges_from_vertices, Ptr <GSList> -> Ptr <GtsSurface> -> IO (Ptr <GSList>)+#ccall gts_edges_merge, Ptr <GList> -> IO (Ptr <GList>)++#ccall gts_edge_is_contact, Ptr <GtsEdge> -> IO <guint>+#ccall gts_edge_is_boundary, Ptr <GtsEdge> -> Ptr <GtsSurface> -> IO (Ptr <GtsFace>)+#ccall gts_edge_has_any_parent_surface, Ptr <GtsEdge> -> IO (Ptr <GtsFace>)+#ccall gts_edge_has_parent_surface, Ptr <GtsEdge> -> Ptr <GtsSurface> -> IO (Ptr <GtsFace>)+#ccall gts_edge_is_duplicate, Ptr <GtsEdge> -> IO (Ptr <GtsEdge>)++#cinline gts_edge_is_unattached, Ptr <GtsEdge> -> IO <gboolean>++#ccall gts_face_has_parent_surface, Ptr <GtsFace> -> Ptr <GtsSurface> -> IO <gboolean>++#ccall gts_triangle_revert_func, <gpointer> -> <gpointer> -> IO <gint>++-- | Shutdown GTS and free all memory+-- NOTE: after calling this method no other GTS functions may be called+#ccall gts_finalize, IO ()+#ccall gts_object_reset_reserved, Ptr <GtsObject> -> IO ()+#ccall gts_object_attributes, Ptr <GtsObject> -> Ptr <GtsObject> -> IO ()+#ccall gts_object_clone,Ptr <GtsObject> -> IO (Ptr <GtsObject>)
src/Bindings/GTS_inline.c view
@@ -6,6 +6,7 @@ BC_INLINE3(GTS_CHECK_VERSION,guint,guint,guint,gboolean) BC_INLINE3(gts_point_is_in_rectangle,GtsPoint*,GtsPoint*,GtsPoint*,gboolean) BC_INLINE1(g_slist_next,GSList*,GSList*)+BC_INLINE1(gts_edge_is_unattached,GtsEdge*,gboolean)  void gts_surface_destroy(GtsSurface* s) {   gts_object_destroy(GTS_OBJECT(s));@@ -17,4 +18,9 @@  void gts_vertex_destroy(GtsVertex *v) {   gts_object_destroy(GTS_OBJECT(v));+}++gint gts_triangle_revert_func(gpointer a,gpointer b) {+   gts_triangle_revert(a);+   return 0; }
+ src/Bindings/GTS_inline.h view
@@ -0,0 +1,11 @@+#ifndef H_GTS_INLINE_H+#include <gts.h>++/* Typed helper functions */++void gts_surface_destroy(GtsSurface*);+void gts_triangle_destroy(GtsTriangle*);+void gts_vertex_destroy(GtsVertex*);+gint gts_triangle_revert_func(gpointer,gpointer);++#endif