Repository: DCC-Lab/RayTracing

Issue:
Generating unnecessary images 
illumination = ImagingPath()

illumination.append(Space(d=10))
illumination.append(Lens(f=10, diameter=100, label="Collector"))
illumination.append(Space(d=10+30))
illumination.append(Lens(f=30, diameter=100, label="Condenser"))
illumination.append(Space(d=30+7))
illumination.append(Lens(f=7, diameter=100, label="Objective"))
illumination.append(Space(d=7+30))
illumination.append(Lens(f=30, diameter=100, label="Tube"))
illumination.append(Space(d=30+10))
illumination.append(Lens(f=10, diameter=100, label="Eyepiece"))
illumination.append(Space(d=10))
illumination.append(Aperture(diameter=20, label="Eye entrance"))
illumination.append(Space(d=10))

illumination.display(limitObjectToFieldOfView=True, onlyChiefAndMarginalRays=True)

Gives this : 

![what](https://user-images.githubusercontent.com/40174887/83067914-71223700-a035-11ea-865e-819e0cc073fc.png)

Because of this : 

![image (1)](https://user-images.githubusercontent.com/40174887/83067938-7aab9f00-a035-11ea-8d95-b2aab1c2b0db.png)


Discussion:

Patch:
diff --git a/raytracing/figure.py b/raytracing/figure.py
index a0b9014..dee5eb4 100644
--- a/raytracing/figure.py
+++ b/raytracing/figure.py
@@ -180,6 +180,8 @@ class Figure:
         conjugates = self.path.intermediateConjugates()
         if len(conjugates) != 0:
             for (planePosition, magnification) in conjugates:
+                if not 0 <= planePosition <= self.path.L:
+                    continue
                 magnification = abs(magnification)
                 if displayRange < self.path._objectHeight * magnification:
                     displayRange = self.path._objectHeight * magnification


Test patch:
diff --git a/raytracing/tests/testsFigure.py b/raytracing/tests/testsFigure.py
index daf1098..0c29ffd 100644
--- a/raytracing/tests/testsFigure.py
+++ b/raytracing/tests/testsFigure.py
@@ -14,12 +14,12 @@ class TestFigure(unittest.TestCase):
 
         self.assertEqual(path.figure.displayRange(), largestDiameter)
 
-    def testDisplayRange(self):
+    def testDisplayRangeImageOutOfView(self):
         path = ImagingPath()
         path.append(Space(2))
         path.append(CurvedMirror(-5, 10))
 
-        self.assertAlmostEqual(path.figure.displayRange(), 5 * 10)
+        self.assertAlmostEqual(path.figure.displayRange(), 20)
 
         path.objectHeight = 1
         self.assertEqual(path.figure.displayRange(), 10)