|
16 | 16 | ##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 |
|
18 | 18 | from functools import wraps |
| 19 | +from math import radians |
19 | 20 |
|
20 | 21 | from OCC.BRepBndLib import brepbndlib_Add |
21 | 22 | from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox, BRepPrimAPI_MakePrism |
|
29 | 30 | from OCC.GeomAbs import GeomAbs_C0 |
30 | 31 | from OCC.GeomAPI import GeomAPI_PointsToBSpline |
31 | 32 | from OCC.TColgp import TColgp_Array1OfPnt |
32 | | -from OCC.gp import gp_Vec, gp_Pnt, gp_Trsf |
| 33 | +from OCC.gp import gp_Vec, gp_Pnt, gp_Trsf, gp_OX, gp_OY, gp_OZ |
33 | 34 |
|
34 | 35 |
|
35 | 36 | def make_edge(*args): |
@@ -77,7 +78,6 @@ def make_face(*args): |
77 | 78 | return result |
78 | 79 |
|
79 | 80 |
|
80 | | - |
81 | 81 | class assert_isdone(object): |
82 | 82 | ''' |
83 | 83 | raises an assertion error when IsDone() returns false, with the error |
@@ -200,6 +200,29 @@ def translate_shp(shp, vec, copy=False): |
200 | 200 | return brep_trns.Shape() |
201 | 201 |
|
202 | 202 |
|
| 203 | +def rotate_shp_3_axis(shape, rx, ry, rz, unity="deg"): |
| 204 | + """ Rotate a shape around (O,x), (O,y) and (O,z). |
| 205 | +
|
| 206 | + @param rx_degree : rotation around (O,x) |
| 207 | + @param ry_degree : rotation around (O,y) |
| 208 | + @param rz_degree : rotation around (O,z) |
| 209 | +
|
| 210 | + @return : the rotated shape. |
| 211 | + """ |
| 212 | + if unity == "deg": # convert angle to radians |
| 213 | + rx = radians(rx) |
| 214 | + ry = radians(ry) |
| 215 | + rz = radians(rz) |
| 216 | + alpha = gp_Trsf() |
| 217 | + alpha.SetRotation(gp_OX(), rx) |
| 218 | + beta = gp_Trsf() |
| 219 | + beta.SetRotation(gp_OY(), ry) |
| 220 | + gamma = gp_Trsf() |
| 221 | + gamma.SetRotation(gp_OZ(), rz) |
| 222 | + brep_trns = BRepBuilderAPI_Transform(shape, alpha*beta*gamma, False) |
| 223 | + shp = brep_trns.Shape() |
| 224 | + return shp |
| 225 | + |
203 | 226 | def make_extrusion(face, length, vector=gp_Vec(0., 0., 1.)): |
204 | 227 | ''' creates a extrusion from a face, along the vector vector. |
205 | 228 | with a distance legnth. Note that the normal vector does not |
|
0 commit comments