1 '''Shapes module for theia, provides shape-calculating for 3D rendering.'''
2
3
4
5
6
7
8
9
10 import numpy as np
11 import Part
12 import FreeCAD as App
13 from FreeCAD import Base
14 from ..helpers import settings
15
17 '''Computes the 3D representation of the beam, a shape for a CAD file obj.
18
19 beam: beam to represent. [GaussianBeam]
20
21 Returns a shape for a CAD file object.
22
23 '''
24 fact = settings.FCFactor
25 return Part.makeCylinder((mirror.Dia/2.)/fact, mirror.Thick/fact,
26 Base.Vector(0,0,0),
27 Base.Vector(tuple(-mirror.HRNorm)))
28
30 '''Computes the 3D representation of the lens, a shape for a CAD file obj.
31
32 lens: lens to represent. [GaussianBeam]
33
34 Returns a shape for a CAD file object.
35
36 '''
37 fact = settings.FCFactor
38 return Part.makeCylinder((lens.Dia/2.)/fact, max(lens.Thick/fact, 0.001),
39 Base.Vector(0,0,0),
40 Base.Vector(tuple(-lens.HRNorm)))
41
43 '''Computes the 3D representation of the beam, a shape for a CAD file obj.
44
45 beam: beam to represent. [GaussianBeam]
46
47 Returns a shape for a CAD file object.
48
49 '''
50 fact = settings.FCFactor
51 return Part.makeCylinder((beamDump.Dia/2.)/fact, beamDump.Thick/fact,
52 Base.Vector(0,0,0),
53 Base.Vector(tuple(-beamDump.HRNorm)))
54
56 '''Computes the 3D representation of the beam, a shape for a CAD file obj.
57
58 beam: beam to represent. [GaussianBeam]
59
60 Returns a shape for a CAD file object.
61
62 '''
63 fact = settings.FCFactor
64 return Part.makeCylinder((ghost.Dia/2.)/fact, 0.01/fact,
65 Base.Vector(0,0,0),
66 Base.Vector(tuple(-ghost.HRNorm)))
67
69 '''Computes the 3D representation of the beam, a shape for a CAD file obj.
70
71 beam: beam to represent. [GaussianBeam]
72
73 Returns a shape for a CAD file object.
74
75 '''
76 fact = settings.FCFactor
77 line = Part.Line()
78 line.StartPoint = Base.Vector(0,0,0)
79 zero = np.array([0., 0., 0.])
80 if beam.Length > 0.:
81 line.EndPoint = Base.Vector(tuple(zero + beam.Length/fact * beam.Dir))
82 else:
83 line.EndPoint = Base.Vector(tuple(zero + 1.e7/fact * beam.Dir))
84
85 return line.toShape()
86