Skip to content

"there are more than one objects at vertex" #1

Description

@jsbtic

Hi (and apologies if this is a silly question)

Is it possible to force karambola to ignore whether a vertex point is share by two or more objects (or perhaps it requires labeling)?

mwe

I'm trying to export a large isosurface from Matlab as *.poly file, and sometimes isosurface regions might be connected only by a common edge, (cf. the blue edge in the image). The resultant poly file will cause an error

$ karambola -i isosurf.poly --no-labels
Converting Polyfile to Minkowski triangulation format ...     done
check surface ...
terminate called after throwing an instance of 'std::runtime_error'
  what():  your polyfile is damaged
there are more than one objects at vertex 6: (3, 2 , 1.55694305694)
neighbour unassigned = 0
surface.get_triangles_of_vertex(i).size() = 9
sum_of_triangles = 10

The problem can be circumvented using 'noshare' option in Matlab's isosurface function, but it will produce huge amount of redundant vertices...

Here's MWE (for Matlab)

I = [0.7398, 0.7868, 0.8917, 0.3731, 0.4621, 0.7413, 0.3193, 0.3885, ...
    0.7073, 0.5036, 0.5580, 0.8095, 0.9468, 0.9478, 0.9563, 0.8541, ...
    0.8469, 0.9063, 0.7246, 0.5887, 0.7106, 0.6820, 0.4306, 0.5328, ...
    0.9726, 0.9720, 0.9694, 0.9491, 0.9152, 0.9162, 0.7689, 0.5137, ...
    0.5311, 0.5541, 0.1598, 0.1748];

I = reshape(I,3,4,3);
% threshold
th = 0.5;

clf

%% plot
isosurface(I,th);
isocaps(I,th,'below');


%% store vertices and faces

% isosurface
[f,v] = isosurface(I,th);
[f2,v2,c] = isocaps(I,th,'below');

% join surface and surface caps
f3 = [f; f2+length(v(:,1))];
v3 = [v; v2];

%% export isosurface as *.POLY
filename = ['isosurf.poly'];
fid = fopen(filename, 'wt');

% vertices
fprintf(fid, 'POINTS\n'); 
N = size(v3,1);
fprintf(fid, '%d: %.15f %.15f %.15f\n', [[1:N]', v3]');

% faces
N = size(f3,1);
fprintf(fid, 'POLYS\n');
fprintf(fid, '%d: %d %d %d\n', [[1:N]', f3]');
fprintf(fid, 'END\n');

fclose(fid);

% unix("karambola -i isosurf.poly --no-labels --reference_centroid")

and here's the resulting POLY file

POINTS
1: 1.653940550859013 1.000000000000000 1.000000000000000
2: 2.000000000000000 1.000000000000000 1.263825363825364
3: 1.883276870957807 2.000000000000000 1.000000000000000
4: 2.000000000000000 2.000000000000000 1.098492723492724
5: 2.000000000000000 2.135744985673353 1.000000000000000
6: 3.000000000000000 1.000000000000000 1.445842585738959
7: 3.000000000000000 2.000000000000000 1.556943056943057
8: 3.000000000000000 2.349749058971142 1.000000000000000
9: 3.980466630493760 1.000000000000000 1.000000000000000
10: 3.657817109144542 2.000000000000000 1.000000000000000
11: 4.000000000000000 2.000000000000000 1.455259026687598
12: 4.000000000000000 1.723945902943516 2.000000000000000
13: 3.561037318153068 2.000000000000000 2.000000000000000
14: 4.000000000000000 2.679060665362035 2.000000000000000
15: 4.000000000000000 1.137205173725590 3.000000000000000
16: 3.038711500423849 2.000000000000000 3.000000000000000
17: 3.087285994948077 3.000000000000000 3.000000000000000
18: 4.000000000000000 3.000000000000000 2.091620111731844
19: 4.000000000000000 2.000000000000000 1.455259026687598
20: 4.000000000000000 2.000000000000000 2.000000000000000
21: 4.000000000000000 1.723945902943516 2.000000000000000
22: 4.000000000000000 2.679060665362035 2.000000000000000
23: 4.000000000000000 1.137205173725590 3.000000000000000
24: 4.000000000000000 2.000000000000000 3.000000000000000
25: 4.000000000000000 3.000000000000000 2.091620111731844
26: 4.000000000000000 3.000000000000000 3.000000000000000
27: 2.000000000000000 1.000000000000000 1.000000000000000
28: 2.000000000000000 1.000000000000000 1.263825363825364
29: 1.653940550859013 1.000000000000000 1.000000000000000
30: 3.000000000000000 1.000000000000000 1.000000000000000
31: 3.000000000000000 1.000000000000000 1.445842585738959
32: 3.980466630493760 1.000000000000000 1.000000000000000
33: 4.000000000000000 3.000000000000000 2.091620111731844
34: 3.087285994948077 3.000000000000000 3.000000000000000
35: 4.000000000000000 3.000000000000000 3.000000000000000
36: 2.000000000000000 1.000000000000000 1.000000000000000
37: 1.653940550859013 1.000000000000000 1.000000000000000
38: 2.000000000000000 2.000000000000000 1.000000000000000
39: 1.883276870957807 2.000000000000000 1.000000000000000
40: 2.000000000000000 2.135744985673353 1.000000000000000
41: 3.000000000000000 1.000000000000000 1.000000000000000
42: 3.000000000000000 2.000000000000000 1.000000000000000
43: 3.000000000000000 2.349749058971142 1.000000000000000
44: 3.980466630493760 1.000000000000000 1.000000000000000
45: 3.657817109144542 2.000000000000000 1.000000000000000
46: 4.000000000000000 1.137205173725590 3.000000000000000
47: 4.000000000000000 2.000000000000000 3.000000000000000
48: 3.038711500423849 2.000000000000000 3.000000000000000
49: 3.087285994948077 3.000000000000000 3.000000000000000
50: 4.000000000000000 3.000000000000000 3.000000000000000
POLYS
1: 1 2 3
2: 3 2 4
3: 3 4 5
4: 2 6 4
5: 4 6 7
6: 8 5 7
7: 7 5 4
8: 9 10 6
9: 6 10 11
10: 6 11 7
11: 7 11 12
12: 7 12 13
13: 10 8 11
14: 11 8 7
15: 11 7 14
16: 14 7 13
17: 12 15 13
18: 13 15 16
19: 13 16 14
20: 14 16 17
21: 14 17 18
22: 19 20 21
23: 19 22 20
24: 21 20 23
25: 23 20 24
26: 20 22 24
27: 24 22 25
28: 24 25 26
29: 27 28 29
30: 30 31 27
31: 27 31 28
32: 30 32 31
33: 33 34 35
34: 36 37 38
35: 38 37 39
36: 38 39 40
37: 36 38 41
38: 41 38 42
39: 38 40 42
40: 42 40 43
41: 41 42 44
42: 44 42 45
43: 42 43 45
44: 46 47 48
45: 48 47 49
46: 49 47 50
END

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions