Package theia :: Package rendering :: Module shapes
[hide private]
[frames] | no frames]

Source Code for Module theia.rendering.shapes

 1  '''Shapes module for theia, provides shape-calculating for 3D rendering.''' 
 2   
 3  # Provides: 
 4  #   mirrorShape 
 5  #   lensShape 
 6  #   beamDumpShape 
 7  #   ghostShape 
 8  #   beamShape 
 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   
16 -def mirrorShape(mirror):
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 = 0.001 #factor for units in CAD 25 return Part.makeCylinder((mirror.Dia/2.)/fact, mirror.Thick/fact, 26 Base.Vector(0,0,0), 27 Base.Vector(tuple(-mirror.HRNorm)))
28
29 -def lensShape(lens):
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 = 0.001 #factor for units in CAD 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
42 -def beamDumpShape(beamDump):
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 = 0.001 #factor for units in CAD 51 return Part.makeCylinder((beamDump.Dia/2.)/fact, beamDump.Thick/fact, 52 Base.Vector(0,0,0), 53 Base.Vector(tuple(-beamDump.HRNorm)))
54
55 -def ghostShape(ghost):
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 = 0.001 #factor for units in CAD 64 return Part.makeCylinder((ghost.Dia/2.)/fact, 0.01/fact, 65 Base.Vector(0,0,0), 66 Base.Vector(tuple(-ghost.HRNorm)))
67
68 -def beamShape(beam):
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 = 0.001 #factor for units in CAD 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