Utkarsh,

I am feeling really stupid at the moment as this seems simple but I cannot 
escape the ValueError:  setting an array element with a sequence error.

Here is my latest (250th?) edit, which now doesn't like the float assignment of 
Distance, but I give up.  I decided to loop over all nodes inside a loop over 
all nodes and just calculate all the distances and keep the smallest, but I 
can't seem to calculate a distance, then compare it to the min and assign it to 
the array.    I am testing it on a solid element model with a single block 
loaded, so bake.e, for instance, would work.

Thanks

Dennis

-----Original Message-----
From: Utkarsh Ayachit [mailto:[email protected]] 
Sent: Friday, January 22, 2016 4:18 PM
To: Dennis Conklin <[email protected]>
Cc: Paraview ([email protected]) <[email protected]>
Subject: [EXT] Re: [Paraview] How to find the distance to nearest node for each 
node in MultiBlockDataset

Dennis,

Any sample dataset that you can share to try this on?

Utkarsh

On Fri, Jan 22, 2016 at 1:05 PM, Dennis Conklin <[email protected]> 
wrote:
> All,
>
>
>
> I have tried vtk.vtkKdTree before and never got the right answer, so 
> before I write a bruteforce method I thought I should ask.
>
>
>
> The points are nodes for truss elements and I need to check if they are
> closer than a cord diameter, which would be physically impossible.   So I
> thought I would calculate a Point variable which is distance to the 
> nearest adjacent point, and then I could look at some statistics to 
> evaluate quality.
>
>
>
> Any quick and dirty ideas?
>
>
>
> Thanks
>
>
>
> Dennis
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
import math, numpy
 
def process_block(block):
   numNodes=output.GetNumberOfPoints()
   #print numNodes
   #print dir(output)
   x=zeros( (numNodes,1),dtype=float )
   y=zeros( (numNodes,1),dtype=float )
   z=zeros( (numNodes,1),dtype=float )
   pts=output.GetPoints()
   x = pts[:,0]
   y = pts[:,1] 
   z = pts[:,2]
   #print dir(x)
   print x[0]
   min_dist=zeros( (numNodes,1),dtype=float)
   for node in range(numNodes): 
      dist=zeros( (numNodes,1),dtype=float )
      dist[node]=900.0     
      print min_dist[node] 
      xx=(x[node])
      print xx
      for inner in range(numNodes):
         if (inner != node):
            distance    = ( ( (x[node]-x[inner])**2+
                              (y[node]-y[inner])**2+
                              (z[node]-z[inner])**2  )**.5)  
            print distance
            fdistance=float(distance)
            dist[inner]=fdistance
            #dist=map(float,distance)
            #print distance 
            if dist[inner] < min_dist[node]:
            #   continue  
               print dist[0]
               #print dir(min_dist)
               #min_dist[node]=distance
            #else:
               #print "not min"
      #min_dist[node]=dist.min()
      #print dist.min()
   #block.PointData.append(min_dist,"Min_distance")

for block in output:
   process_block(block) 
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to