-
Notifications
You must be signed in to change notification settings - Fork 9
/
waysToMoveShape.txt
48 lines (37 loc) · 1.31 KB
/
waysToMoveShape.txt
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
Ways to move a TopoDS_shape:
# TopLoc_Location
# as shown in
tFace = BRepBuilderAPI_MakeFace(mFace).Face()
faceNormal = Construct.face_normal(mFace)
vctr = gp_Vec(faceNormal).Multiplied(value)
trsf = gp_Trsf()
trsf.SetTranslation(vctr)
tFace.Move(TopLoc_Location(trsf))
# BRepBuilderAPI_Transform
# as shown in core_topology_boolean.py
def translate_topods_from_vector(brep_or_iterable, vec, copy=False):
'''
translate a brep over a vector
@param brep: the Topo_DS to translate
@param vec: the vector defining the translation
@param copy: copies to brep if True
'''
trns = gp_Trsf()
trns.SetTranslation(vec)
brep_trns = BRepBuilderAPI_Transform(brep_or_iterable, trns, copy)
brep_trns.Build()
return brep_trns.Shape()
# as shown in core_classic_occ_bottle.py
# Create a wire out of the edges
aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge(), aEdge2.Edge(), aEdge3.Edge())
# Quick way to specify the X axis
xAxis = gp_OX()
# Set up the mirror
aTrsf = gp_Trsf()
aTrsf.SetMirror(xAxis)
# Apply the mirror transformation
aBRespTrsf = BRepBuilderAPI_Transform(aWire.Wire(), aTrsf)
# Get the mirrored shape back out of the transformation and convert back to a wire
aMirroredShape = aBRespTrsf.Shape()
# A wire instead of a generic shape now
aMirroredWire = topods.Wire(aMirroredShape)