Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert polygons into mesh

I have a lot of polygons. Ideally, all the polygons must not overlap one other, but they can be located adjacent to one another.

But practically, I would have to allow for slight polygon overlap ( defined by a certain tolerance) because all these polygons are obtained from user hand drawing input, which is not as machine-precised as I want them to be.

My question is, is there any software library components that:

  1. Allows one to input a range of polygons
  2. Check if the polygons are overlapped more than a prespecified tolerance
  3. If yes, then stop, or else, continue
  4. Create mesh in terms of coordinates and elements for the polygons by grouping common vertex and edges together?
  5. More importantly, link back the mesh edges to the original polygon(s)'s edge?

Or is there anyone tackle this issue before?

like image 268
Graviton Avatar asked Sep 21 '11 06:09

Graviton


People also ask

How do you convert surface to mesh?

To convert 3D Face objects into a single mesh object follow the steps: Use the Convert to Surface command (CONVTOSSURFACE) to convert the 3D faces into surfaces. Use the UNION command to join the surfaces together. Use the Smooth Object command (MESHSMOOTH) to create a mesh from the resulting surface.

How do I change NURBS to mesh?

Select the NURBS surface and choose Modify > Convert > NURBS to Polygons. A polygonal representation of the surface is created at the same position as the NURBS surface.

Can you convert polygons to NURBS?

Note: To convert polygons to NURBs, you must to perform a two-step conversion where you first convert the polygons to a subdivision surface, and then convert the resulting subdivision surface to NURBs.


2 Answers

This issue is a daily "bread" of GIS applications - this is what is exactly done there. We also learned that at a GIS course. Look into GIS systems how they address this issue. E.g. ArcGIS define so called topology rules and has some functions to check if the edited features are topologically correct. See http://webhelp.esri.com/arcgisdesktop/9.2/index.cfm?TopicName=Topology_rules

like image 54
Tomas Avatar answered Sep 22 '22 02:09

Tomas


This is pretty long, only because the question is so big. I've tried to group my comments based on your bullet points.

Components to draw polygons

My guess is that you'll have limited success without providing more information - a component to draw polygons will be very much coupled to the language and UI paradigm you are using for the rest of your project, ie. code for a web component will look very different to a native component.

Perhaps an alternative is to separate this element of the process out from the rest of what you're trying to do. There are some absolutely fantastic pre-existing editors that you can use to create 2d and 3d polygons.

Inkscape is an example of a vector graphics editor that makes it easy to enter 2d polygons, and has the advantage of producing output SVG, which is reasonably easy to parse.

In three dimensions Blender is an open source editor that can be used to produce arbitrary geometries that can be exported to a number of formats.

If you can use a google-maps API (possibly in an native HTML rendering control), and you are interested in adding spatial points on a map overlay, you may be interested in related click-to-draw polygon question on stackoverflow. From past experience, other map APIs like OpenLayers support similar approaches.

Check whether polygons are overlapped

Thomas T made the point in his answer, that there are families of related predicates that can be used to address this and related queries. If you are literally just looking for overlaps and other set theoretic operations (union, intersection, set difference) in two dimensions you can use the General Polygon Clipper

You may also need to consider the slightly more generic problem when two polygons that don't overlap or share a vertex when they should. You can use a Minkowski sum to dilate (enlarge) two and three dimensional polygons to avoid such problems. The Computational Geometry Algorithms Library has robust implementations of these algorithms.

I think that it's more likely that you are really looking for a piece of software that can perform vertex welding, Christer Ericson's book Real-time Collision Detection includes extensive and very readable description of the basics in this field, and also on related issues of edge snapping, crack detection, T-junctions and more. However, even though code snippets are included for that book, I know of no ready made library that addresses these problems, in particular, no complete implementation is given for anything beyond basic vertex welding.

Obviously all 3D packages (blender, maya, max, rhino) all include built in software and tools to solve this problem.

Group polygons based on vertices

From past experience, this turned out to be one of the most time consuming parts of developing software to solve problems in this area. It requires reasonable understanding of graph theory and algorithms to traverse boundaries. It is worth relying upon a solid geometry or graph library to do the heavy lifting for you. In the past I've had success with igraph.

Link the updated polygons back to the originals.

Again, from past experience, this is just a case of careful bookkeeping, and some very careful design of your mesh classes up-front. I'd like to give more advice, but even after spending a big chunk of the last six months on this, I'm still struggling to find a "nice" way to do this.

Other Comments

If you're interacting with users, I would strongly recommend avoiding this issue where possible by using an editor that "snaps", rounding all user entered points onto a grid. This will hopefully significantly reduce the amount of work that you have to do.

like image 39
Andrew Walker Avatar answered Sep 23 '22 02:09

Andrew Walker