wo80 / Triangle

CMake project for Jonathan Shewchuk's Triangle mesh generator.
Other
63 stars 26 forks source link

triangle_mesh_create Fail #43

Closed kingui1106 closed 3 years ago

kingui1106 commented 3 years ago

Hi. I meet some error, Is there any solution. I use 'triangle_mesh_create' return TRI_SEG_INTERSECT. I find blow in the code:TODO: Internal error: insertsegment().

kingui1106 commented 3 years ago

https://drive.google.com/file/d/1v5fWCiZPEXfIzEeGfcVW_Rgmg1c3IAtV/view?usp=sharing

my input triangle

wo80 commented 3 years ago

Please post your input polygon (as text, see below) and the Triangle options used.

Here's what I came up with:

# issue-43.poly
9 2 0 1
0  0.0 0.0  1
1  1.0 1.0  1
2  0.0 2.0  1
3  2.0 0.0  2
4  2.0 2.0  2
5  0.5 1.0  2
6  3.0 0.0  3
7  0.0 3.0  3
8  1.5 1.0  3
# segments
9 1
0  0 1  1
1  1 2  1
2  2 0  1
3  3 4  2
4  4 5  2
5  5 3  2
6  6 7  3
7  7 8  3
8  8 6  3
# holes
0

Triangulating with triangle-cli -pqz issue-43.poly works just fine.

kingui1106 commented 3 years ago

Thanks. I've set all the data into triangleio in. I wander how can i write it to poly file

wo80 commented 3 years ago

Then just post the code.

Compiling in debug mode (_DEBUG symbol present) might give you a hint whats going wrong.

wo80 commented 3 years ago

I wander how can i write it to poly file

There's actually no api method for this. Might be worth adding one.

wo80 commented 3 years ago

Just a guess: Are you numbering your nodes starting from 0 and forgot to set behavior->firstnumber = 0?

EDIT: this would probably not produce an error, just a warning and wrong mesh.

kingui1106 commented 3 years ago
char* params = (char*)("jpzQYY");
int tristatus;
tristatus = triangle_context_options(ctx, params);

I use the params .It will set behavior->firstnumber = 0.

Just a guess: Are you numbering your nodes starting from 0 and forgot to set behavior->firstnumber = 0?

EDIT: this would probably not produce an error, just a warning and wrong mesh.

kingui1106 commented 3 years ago
# issue-43.poly
18 2 1 0
0  0.5 1.0  1
1  2.0 2.0  1
2  2.0 0.0  1
3  1.5 1.0  1
4  3.0 0.0  1
5  0.0 3.0  1
6  0.0 0.0  1
7  1.0 1.0  1
8  0.0 2.0  1
9  1.1666666666666667  1.4444444444444444 1
10 1.3999999999999999 1.6000000000000001 1
11 2.00  0.66666666666666663 1
12 2.0000000000000000  1.0000000000000000  1
13  1.3833333333333333 1.5888888888888890 1
14 1.3499999999999994  1.5666666666666664 1
15 1.4333333333333338  1.5666666666666662 1
16  2.0000000000000000  0.76666666666666727 1
17  2.0000000000000000  1.5666666666666662 1
# segments
9 0
0  0 1 
1  1 2  
2  2 0  
3  3 4  
4  4 5  
5  5 3
6  6 7
7  7 8
8  8 6 
# holes
0
wo80 commented 3 years ago

https://www.cs.cmu.edu/~quake/triangle.trouble.html

Strange things can happen if you've taken liberties with your PSLG. Do you have a vertex lying in the middle of a segment? Triangle sometimes copes poorly with that sort of thing. Do you want to lay out a collinear row of evenly spaced, segment-connected vertices? Have you simply defined one long segment connecting the leftmost vertex to the rightmost vertex, and a bunch of vertices lying along it? This method occasionally works, especially with horizontal and vertical lines, but often it doesn't, and you'll have to connect each adjacent pair of vertices with a separate segment. If you don't like it, tough.

kingui1106 commented 3 years ago

OK!Thanks!!!

---Original--- From: @.> Date: Wed, Aug 4, 2021 18:21 PM To: @.>; Cc: @.**@.>; Subject: Re: [wo80/Triangle] triangle_mesh_create Fail (#43)

https://www.cs.cmu.edu/~quake/triangle.trouble.html

Strange things can happen if you've taken liberties with your PSLG. Do you have a vertex lying in the middle of a segment? Triangle sometimes copes poorly with that sort of thing. Do you want to lay out a collinear row of evenly spaced, segment-connected vertices? Have you simply defined one long segment connecting the leftmost vertex to the rightmost vertex, and a bunch of vertices lying along it? This method occasionally works, especially with horizontal and vertical lines, but often it doesn't, and you'll have to connect each adjacent pair of vertices with a separate segment. If you don't like it, tough.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.

wo80 commented 3 years ago

You're welcome! Hope you find a way to handle the input.

If you think we're done here, please close the issue.

kingui1106 commented 3 years ago

I think can add a small (1e-9) to the a vertex lying in the middle of a segment. Or, Break the line first with a vertex . I close the issue by accident. 😭

kingui1106 commented 3 years ago

I test add a small (1e-9) to the a vertex lying in the middle of a segment. And then get the result triangles ,judge that three points are collinear by tolerance. It is userful and simple.