Merge pull request #6 from adam-urbanczyk/CapableRobot-cq1_pythonocc

Initial support for cqparts in cadquery-occ
This commit is contained in:
Adam Urbańczyk
2018-10-22 06:37:11 +02:00
committed by GitHub
2 changed files with 42 additions and 12 deletions

View File

@ -197,9 +197,22 @@ class Matrix:
return Matrix(self.wrapped.Inverted())
def multiply(self,other):
def multiply(self, other):
return Matrix(self.wrapped*other.wrapped)
if isinstance(other, Vector):
return other.transform(self)
return Matrix(self.wrapped.Multiplied(other.wrapped))
def transposed_list(self):
"""Needed by the cqparts gltf exporter
"""
trsf = self.wrapped
data = [[trsf.Value(i,j) for j in range(1,5)] for i in range(1,4)] + \
[[0.,0.,0.,1.]]
return [data[j][i] for i in range(4) for j in range(4)]
class Plane(object):
"""A 2D coordinate system in space

View File

@ -100,6 +100,8 @@ from OCC.ShapeUpgrade import ShapeUpgrade_UnifySameDomain
from OCC.BRepTools import breptools_Write
from OCC.Visualization import Tesselator
from math import pi, sqrt
TOLERANCE = 1e-6
@ -993,7 +995,22 @@ class Shell(Shape):
class Mixin3D(object):
def tessellate(self, tolerance):
return self.wrapped.tessellate(tolerance)
tess = Tesselator(self.wrapped)
tess.Compute(compute_edges=True, mesh_quality=tolerance)
vertices = []
indexes = []
# add vertices
for i_vert in range(tess.ObjGetVertexCount()):
xyz = tess.GetVertex(i_vert)
vertices.append(Vector(*xyz))
# add triangles
for i_tr in range(tess.ObjGetTriangleCount()):
indexes.append(tess.GetTriangleIndex(i_tr))
return vertices, indexes
def fillet(self, radius, edgeList):
"""