-
Notifications
You must be signed in to change notification settings - Fork 0
/
cross_section.py
53 lines (39 loc) · 1.32 KB
/
cross_section.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
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 2 00:20:41 2021
@author: Jacob Adamczyk
To Zoom: Pinch fingers (right hand)
To Rotate: Set up an axis with first finger and thumb (left hand)
To Pan: Raise both hands, and move one (left/right has reversed controls)
"""
print(__doc__)
import cv2
import mediapipe as mp
from vedo import *
from time import sleep
from google.protobuf.json_format import MessageToDict
import time
import numpy as np
from utils import *
y_unit_vec = np.array([0, 1, 0])
z_unit_vec = np.array([0, 0, 1])
STL_name = r'A.stl'
v = Mesh(STL_name)
avg_model_size = v.averageSize()
v.scale(avg_model_size * 0.00001)
dim_scale = np.mean(v.scale())*100
print(avg_model_size)
cam = dict(pos=(1,0,0), focalPoint=(0,0,0), viewup=(1,1,1))
# Define a plane that goes through the origin and is parallel to the xy-plane
# plane = plane(pos=(0,0,0), normal=(0,0,1))
# Plot this plane
plt = show(v, axes=4, viewup='z', camera=cam, interactive=False)
zero = v.centerOfMass()
ax = np.linspace(-0.05,0.00,100)
for a in ax:
print(a)
orig = zero + [0,a,0]
v.cutWithPlane(origin=orig, normal=[0,1,0])
pl = Plane(orig, normal=[0,1,0], s=[dim_scale,dim_scale], c='black', alpha=0.7)
plt.show(v, pl, axes=4, viewup='z', camera=cam, interactive=False)
plt.show(v, pl, axes=4, viewup='z', camera=cam, interactive=True)