Showing results for 
Search instead for 
Do you mean 
Reply

Delaunay triangulation or convex hull

Hi all.

 

I have field of points. This field lie on part of a 3D surface. I need create a surface by these points or at least create convex hull (closed curve) by these points.


I know about reverse engineering functions (some sort of Fit surface). But this function creates a not limited surface, but I need a limited one.


I can create it manually, but if NXOpen(Python better) has similar function I think it will be productively.

 

Could you help me?

2 REPLIES

Re: Delaunay triangulation or convex hull

[ Edited ]

The NX Open API does not have any built in classes/methods for Delaunay triangulation or convex hull but you can integrate scipy.spatial which does. http://docs.scipy.org/doc/scipy/reference/spatial.html

 

Attached is a tutorial I wrote on how to integrate Anaconda. PM me if there is anything unclear

 

Below is some example code using matplotlib and scipy.spatial. Be sure to include the space between "nx: "and "threaded"!

 

#nx: threaded

import NXOpen
import NXOpen.BlockStyler
import NXOpen.Features
import NXOpen.UF
import NXOpen.GeometricAnalysis
import NXOpen.Facet

import math
import numpy as np
import scipy.spatial as sp

class 3d_points:

    #scipy spatial function
    def convexhull(self, vertices):
        
        tri = sp.Delaunay(vertices)
        
       
        hull = sp.ConvexHull(vertices)

        # Indices of points forming the vertices of the convex hull
         edges= list(zip(vertices))

        #various attributes of the convex hull method
        hull_points=hull.points
        hull_vertices=hull.vertices
        hull_simplices=hull.simplices
        hull_equations=hull.equations

       #plot it using mat plot lib
        for i in hull.simplices:
            plt.plot(vertices[i,0], vertices[i,1], vertices[i,2], 'r-')

        ax.plot(edges[0],edges[1],edges[2],'bo') 

        ax.set_xlabel('x')
        ax.set_ylabel('y')
        ax.set_zlabel('z')

        ax.set_xlim3d(-2,2)
        ax.set_ylim3d(-2,2)
        ax.set_zlim3d(-2,2)

        plt.show()

 

 

Re: Delaunay triangulation or convex hull

[ Edited ]

Thank you. The instalation guide is really good! But I think qhull library http://www.qhull.org could be better. There is python wrapper: https://github.com/materialsvirtuallab/pyhull

But I could not install pyhull on windows, I caught an error Smiley Sad