forked from 541435721/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputeABPointsFromBoundsAndCenter.py
48 lines (37 loc) · 1.55 KB
/
computeABPointsFromBoundsAndCenter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2012-2016 ###
### ###
### University of California at San Francisco (UCSF), USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import numpy
import vtk
import myVTKPythonLibrary as myVTK
########################################################################
def computeABPointsFromBoundsAndCenter(
mesh,
AB=[0,0,1],
verbose=1):
myVTK.myPrint(verbose, "*** computeABPointsFromBoundsAndCenter ***")
C = numpy.array(mesh.GetCenter())
#print "C ="+str(C)
bounds = mesh.GetBounds()
diag = numpy.array([bounds[1]-bounds[0], bounds[3]-bounds[2], bounds[5]-bounds[4]])
AB = numpy.array(AB)
AB = abs(numpy.dot(diag, AB)) * AB
#print "bounds ="+str(bounds)
#print "diag ="+str(diag)
#print "AB ="+str(AB)
point_A = C - AB/2
point_B = C + AB/2
#print "point_A ="+str(point_A)
#print "point_B ="+str(point_B)
points_AB = vtk.vtkPoints()
points_AB.InsertNextPoint(point_A)
points_AB.InsertNextPoint(point_B)
#print points_AB
return points_AB