Merge pull request #6 from adam-urbanczyk/CapableRobot-cq1_pythonocc
Initial support for cqparts in cadquery-occ
This commit is contained in:
@ -199,7 +199,20 @@ class Matrix:
|
|||||||
|
|
||||||
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):
|
class Plane(object):
|
||||||
"""A 2D coordinate system in space
|
"""A 2D coordinate system in space
|
||||||
|
|||||||
@ -100,6 +100,8 @@ from OCC.ShapeUpgrade import ShapeUpgrade_UnifySameDomain
|
|||||||
|
|
||||||
from OCC.BRepTools import breptools_Write
|
from OCC.BRepTools import breptools_Write
|
||||||
|
|
||||||
|
from OCC.Visualization import Tesselator
|
||||||
|
|
||||||
from math import pi, sqrt
|
from math import pi, sqrt
|
||||||
|
|
||||||
TOLERANCE = 1e-6
|
TOLERANCE = 1e-6
|
||||||
@ -993,7 +995,22 @@ class Shell(Shape):
|
|||||||
class Mixin3D(object):
|
class Mixin3D(object):
|
||||||
|
|
||||||
def tessellate(self, tolerance):
|
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):
|
def fillet(self, radius, edgeList):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user