GithubHelp home page GithubHelp logo

triangulate.jl's Introduction

Triangulate

Build status PkgEval

Julia wrapper for Jonathan Richard Shewchuk's Triangle mesh generator. The package tries to provide a 1:1 mapping of Triangle's functionality to Julia.

Useful information about Triangle:

Licensing

When installing Triangulate.jl, a compiled library version of the Triangle library will be downloaded from the Triangle_jll.jl repository. This library is freely available with Commercial Use Restriction, but the bindings to the library in this package, Triangulate.jl, are licensed under MIT. This means that code using the Triangle library via the Triangulate.jl bindings is subject to Triangle's licensing terms reproduced here:

These programs may be freely redistributed under the condition that the
copyright notices (including the copy of this notice in the code comments
and the copyright notice printed when the `-h' switch is selected) are
not removed, and no compensation is received.  Private, research, and
institutional use is free.  You may distribute modified versions of this
code UNDER THE CONDITION THAT THIS CODE AND ANY MODIFICATIONS MADE TO IT
IN THE SAME FILE REMAIN UNDER COPYRIGHT OF THE ORIGINAL AUTHOR, BOTH
SOURCE AND OBJECT CODE ARE MADE FREELY AVAILABLE WITHOUT CHARGE, AND
CLEAR NOTICE IS GIVEN OF THE MODIFICATIONS.  Distribution of this code as
part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT
WITH THE AUTHOR.  (If you are not directly supplying this code to a
customer, and you are instead telling them how they can obtain it for
free, then you are not required to make any arrangement with me.)

Acknowledgement

This package uses ideas from TriangleMesh.jl and Triangle.jl.

triangulate.jl's People

Contributors

chakravala avatar fonsp avatar j-fu avatar juliatagbot avatar ranocha avatar rschwarz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

triangulate.jl's Issues

Get neighbor list

Is there an option the get
a list of all neighbors of a node using the "-n" flag?

So here it is...

Hi, @SimonDanisch, @konsim83, @furio

so I started his package from the content of TriangleRaw,
at least tests are running.

First obstacle:
We cannot have a struct TriangulateIO.TriangulateIO. So naming the module after
the datastructure it exports was not my best idea.
Now it is TriangulateIO.JLTriangulateIO (there is also CTriangulateIO, so some consistency here).
We could keep this or otherwise perhaps we would need a different name of the package...

Read-only memory error on Windows

I am frequently encountering this error when I run Triangulate on Windows. I've seen it on both Julia 1.7.x and 1.8.x. The same cases on Linux work fine. I notice that this occurred during one of your CI tests (see here) and I wanted you to know that this isn't just an isolated example.

Plotting stuff needs to move elesewhere

Plotting (with PyPlot and now Makie) was added here for convenience. Dependencies are weak, as the Plotter module is passed to the plotting methods, so not much overhead when this is ignored. With the extension mechanism, finally there is a way to check for version consistency. As wee see in bdfb889, this now requires to track updates of plotting packages which is completely out of scope of this package.

So this needs to be cleaned up.

The plan:

  • Copy the plotting stuff elsewhere. I consider GridVisualize.jl (which then would get a GridVisualizeTriangulateExt extension) the right place as IMHO a TriangulatePlotting package would be over the top.
  • Deprecate plotting methods in Triangulate.jl (perhaps in v2.3)
  • After a grace period (a couple of weeks), remove the plotting methods from Triangulate.jl. As this would be breaking, this will be v3.0.

Julia-style kwargs?

Really cool! I'm using this package to play around with generative art for my pen plotter ๐Ÿ˜Ž

One thing that I was thinking: I have not used the original CLI program before, so this API:

triangulate(triin; planar_straight_graph=true, maxarea=maxarea, quiet=true)

would be more natural than the current API (example from docs):

area=@sprintf("%.15f",maxarea) # Don't use exponential format!
triangulate("pa$(area)Q", triin)

What do you think?

More generally, a more high-level API (without IO, with GeometryBasics or Vector{SVector{Float64,2}} input/output instead of Matrix) would be nice to make this package slightly easier to use for my purposes (very small number of points, sunday afternoon entertainment). I already wrote some functions that I can turn into a PR if you like!

Thread safety

When using the unsuitable callback, the unsuitable method is passed to C through a global variable. Therefore at least in this case, the code is not thread-safe. It should be thread-safe (not tested though) if -u is not used.

For making the code thread-safe, the unsuitable callback should be made part of TriangulateIO in the C library after checking if this is possible withot mayor modification of triangle.c .

Meanwhile the advise is to put a lock around triangulate calls in multithreaded code.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Typo in TriangulateIO

Hello,

Thanks for the package it works pretty well for my needs so far!

I'm trying to perform linear interpolation on scattered data using a triangulation, and for this I need to set some weight to each point. It feels like the attribute pointattributelist in the TriangulateIO struct has exactly this purpose, but when I try to set the attribute I get the following error:

ERROR: LoadError: type CTriangulateIO has no field pointattributelistlist

I downloaded the package the usual way using Pkg.add("Triangulate"), and I am on MacOS 12.1.

I think this comes from typo in:

tio.pointattributelist=convert(Array{Cdouble,2}, Base.unsafe_wrap(Array, ctio.pointattributelistlist, (Int(ctio.numberofpointattributes),Int(ctio.numberofpoints)), own=true))

where pointattributelist has been replaced by pointattributelistlist (notice that it ends with listlist instead of the expected list).

Below is a MWE to recreate the error:

using Triangulate
x = rand(10) .+ 1
y = rand(10) .+ 1
z = rand(10) .+ 1
pointset = Triangulate.TriangulateIO(; pointlist=[x'; y'])
pointset.pointattributelist = z' # comment to fix the error
Triangulate.triangulate("Q", pointset);

I'm pretty new to github so I'm not sure how to make a pull request, but I hope I gave sufficient information for the developers to make a quick fix.

Handling of o2 nodes

Hi everyone,
I was wondering whether anyone uses the "o2" option. This adds mid-faces nodes (o2 nodes) to the list of points.
I have tried this option with Triangulate.jl and it seems that using the "o2" option messes up the triangle to node numbering.
The usual behaviour of Triangle is that when o2 is not parsed in, the triangle list has a size of 3n_triangles (n_triangles being the number of triangles in the mesh). If o2 is parse in then the size of the triangle list 6n_triangles as it also includes the o2 nodes. From what I see, using the o2 option with Triangulate.jl does result in having o2 nodes in the point list but the triangle list remains of size 3*n_triangles and mixes indices of vertex nodes with those of mid-face nodes.
Can you please let me know if I'm doing anything wrong there?
Below is a minimum example:
Cheers

using Triangulate

# Without second order triangles
triin=Triangulate.TriangulateIO()
triin.pointlist=Matrix{Cdouble}([0.0 0.0 ; 1.0 0.0 ; 1.0  1.0; 0.0 1.0]')
triin.segmentlist=Matrix{Cint}([1 2 ; 2 3 ; 3 4 ; 4 1 ]')
triin.segmentmarkerlist=Vector{Int32}([1, 2, 3, 4])
(triout, vorout)=triangulate("pq", triin)  
x = triout.pointlist[1,:]
y = triout.pointlist[2,:]
display(x)
display(y)
display(triout.trianglelist)

# With second order triangles
triin=Triangulate.TriangulateIO()
triin.pointlist=Matrix{Cdouble}([0.0 0.0 ; 1.0 0.0 ; 1.0  1.0; 0.0 1.0]')
triin.segmentlist=Matrix{Cint}([1 2 ; 2 3 ; 3 4 ; 4 1 ]')
triin.segmentmarkerlist=Vector{Int32}([1, 2, 3, 4])
(triout, vorout)=triangulate("pqo2", triin)  #           <------- here o2  is parsed in as input argument
x = triout.pointlist[1,:]
y = triout.pointlist[2,:]
display(x')                                                     #           <------- correct size and point positions
display(y')                                                     #           <------- correct size and point positions
display(triout.trianglelist)                            #           <------- wrong size and mixed up numbering

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.