View Full Version : generate contour from the 3D model

05-09-2015, 02:50 PM
Hello forum,

I have to create contour around the 3D model . Can anyone refer me to any algorithms that does it efficiently ?


05-09-2015, 04:21 PM
Don't understand your question. Can U provide an example - perhaps pictures of a 3D model with and without the 'contour'?

05-09-2015, 06:49 PM
Contours, or a silhouette?

How is the model represented? Triangle mesh? Parametric surfaces? Voxels?

05-09-2015, 06:50 PM
I think I found a solution while googling it up.


What do you think ?

05-09-2015, 06:51 PM
so far started with the triangular mesh.

05-09-2015, 06:58 PM
I think I found a solution while googling it up.
Personally, I'd be inclined to do it via rasterisation rather than geometrically.

Essentially the same thing as glTexGen() in GL_OBJECT_LINEAR mode, but using a shader to avoid thickening of the contour lines on near-perpendicular surfaces.

05-09-2015, 07:03 PM
Any example opengl code you could refer me to ?

05-10-2015, 11:47 PM
from math, you should use a series of planes with equal distance to cut the 3D model, get their crossover points, then connect them, you will get the contour.

05-10-2015, 11:50 PM
if you have the model, you can discharge the z value, enough.

05-11-2015, 02:32 AM
There`s a simpler alternative.
Draw your model on a clear Z-buffer and save the resulting Z-buffer to a texture. You now have a depth mask of your model.
Now load it into a pixel shader and calculate the contour using dilation (http://en.wikipedia.org/wiki/Mathematical_morphology#Dilation) from mathematical morphology.

06-24-2015, 07:32 AM
If you export the lines as DXF, you should be able to load them into QGIS. Once they are in QGIS, you need to create an attribute that contains the elevation of each line (ie. a data column with a number). Depending on the total number of lines you could possibly do this manually.

If doing it manually is not an option, you could concievably do some Python sorcery to iterate through the lines in some intelligent way to calculate the elevation. However, the best scenario would be if you could get the contours as proper geodata with 3D coordinates from the person who originally created the PDF.

When you have the contours prepared with an elevation attribute (or 3D coordinates if you could get them from the source), you can use the interpolation tool in the raster menu in QGIS to turn them into a heightmap raster. After that you can use that raster as a displacement map in your 3D-modelling software.

As the tutorial also mentions, there is a Blender plugin to directly import a heightmap raster and turn it into a 3D-surface as well.

Note that I'm assuming you're not interested in keeping the original geographic coordinate system, but just want a model for visualisation.