Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7055101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:42:27+00:00 2026-05-28T03:42:27+00:00

I have a mesh in a form like this . with a list of

  • 0

I have a mesh in a form like this.
with a list of indices representing each polygon at the end. I need to generate a list of neighboring polygons for each polygon, and was wondering if anyone knows of an efficient algorithm to do this?

The simplest way that comes to mind is for each polygon, check if every other polygon has two matching indices – but this looks like it involves a few nested loops. I don’t mind using this, performance isn’t a huge issue here, but yeah I’m just scouting for alternatives.

There isnt any limitation on the max indices/vertices per polygon, but for simplicity’s sake, lets just assume its 3 (so triangle polygons).

Thanks for any help! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:42:28+00:00Added an answer on May 28, 2026 at 3:42 am

    Ouch, XML meshes :).

    I actually had a good look at this, my first answer was pretty lazy. you can write better (as posted above), and it’s not that complicated, I wouldn’t fork out $40 for a journal article over this. Here’s a pseudo-code solution which should work for you.

    Note: When I say table, I mean ‘lookup table’.

    Assume each triangle is numbered and composed of vertices, v1, v2, v3, which are uniquely numbered and can be compared using the < operator (so we can obtain unique key-combinations).

    We need two look-up tables:

    • An edge->(triangle list) table called edge_triangles.
    • A triangle->(edges list) table called triangle_edges.

    A table which tells us which triangles use a given edge, and another which tells us which edges a a given triangle is comprised of. We build these lists as follows:

    for t = next triangle
        // Determine the ordering of vertices.
        min_vertex = min(t.v1, t.v2, t.v3);
        mid_vertex = median(p.v1, t.v2, t.v3);
        max_vertex = max(t.v1, t.v2, t.v3);
    
        // Register which edges this triangle uses.
        edge_triangles[min_vertex][mid_vertex].append(t);
        edge_triangles[mid_vertex][max_vertex].append(t);
        edge_triangles[min_vertex][max_vertex].append(t);
    
        // Set the edges that make up this triangle.
        triangle_edges[t].append({min_vertex, mid_vertex});
        triangle_edges[t].append({mid_vertex, max_vertex});
        triangle_edges[t].append({min_vertex, max_vertex});
    for next t
    

    Using these lists, we can take the edges in a given triangle, use these as the key into the edge table, and see which polygons share that edge. Thus, the adjacent triangles. So for a triangle t we could do the following:

    adjacent = edge_faces[face_edges[t][0]];
    

    which is pseudo-code for ‘adjacent is equal to the list of triangles that share the 0th edge of the triangle t’, where 0th is just the first.

    We use min, median and max to make sure that that we don’t have different entries for identical edges: for example {v1, v2} and {v2, v1}, where v1 and v2 are two vertices. We could actually ignore this and add a ‘compact’ step, where we concatenate lists which correspond to different entries in our edge list but actually correspond to the same edge.

    One other possible problem with this is if you have two edges which are coincident but don’t share common vertices. In this case, you could reduce either edge to a parametric equation, compare them for coincidence, and form a lookup table which tells you, for a given edge, which edges are coincident, so map:

    • edge->(edges list) table called edge_coincident_edges.

    We use yet another look-up table because we can’t concatenate the edge->faces table. Cosider if edges e1 and e2 are adjacent, e2 and e3 are, but e1 and e3 aren’t. if we concatenated the e1, e2 and e3 entries in the edge->face list, you’d end up with some wildly incorrect data. This a probably bit more than you want to do, but it’s the problem I had to solve this morning :).

    In the case where each edge can only correspond to at most 2 triangles, we can do away with the ‘list’ in the traditional sense that we can append, and use a fixed-size array of size 2. This will reduce your memory overhead and improve memory efficiency. so our edge table would be more akin to:

    • An edge->(first triangle, second triangle) table called edge_triangles.

    Anyway, the basic algorithm is extensible to any number of polygons with any number of edges (not necessarily the same between all polygons), and is O(N) time with respect to the number of triangles (or polygons in the general case). Space complexity is O(E + N) Where E is edges and N is the number of polygons. The look-up time should be close to O(1), assuming you have good hashing algorithms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a two dimensional polygon mesh made of connected triangles represented like this:
I have 3d mesh and I would like to draw each face a 2d
I have a list a vertices and a list of triangles. I'd like to
I have a mesh defined by 4 points in 3D space. I need an
I have to render a mesh of a few thousand polygons in Google Sketchup.
I have something like this in my code typedef struct ts_fem_mesh { double **vertices;
i have created this class for mesh loading it works but i added this
I have an irregular mesh which is described by two variables - a faces
Does anyone have any pointers to good resources concerning mesh networks? Maybe I'm not
Have you managed to get Aptana Studio debugging to work? I tried following this,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.