Restored JavaDoc support
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / renderer / raster / shapes / composite / wireframe / Grid3D.java
1 /*
2  * Sixth 3D engine. Copyright ©2012-2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 3 of the GNU Lesser General Public License
6  * or later as published by the Free Software Foundation.
7  *
8  */
9
10 package eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.wireframe;
11
12 import eu.svjatoslav.sixth.e3d.geometry.Point3D;
13 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.basic.line.LineAppearance;
14 import eu.svjatoslav.sixth.e3d.renderer.raster.shapes.composite.base.AbstractCompositeShape;
15
16 public class Grid3D extends AbstractCompositeShape {
17
18     public Grid3D(final Point3D p1t, final Point3D p2t, final double step,
19                   final LineAppearance appearance) {
20
21         super();
22
23         final Point3D p1 = new Point3D(p1t);
24         final Point3D p2 = new Point3D(p2t);
25
26         if (p1.x > p2.x) {
27             final double tmp = p1.x;
28             p1.x = p2.x;
29             p2.x = tmp;
30         }
31
32         if (p1.y > p2.y) {
33             final double tmp = p1.y;
34             p1.y = p2.y;
35             p2.y = tmp;
36         }
37
38         if (p1.z > p2.z) {
39             final double tmp = p1.z;
40             p1.z = p2.z;
41             p2.z = tmp;
42         }
43
44         for (double x = p1.x; x <= p2.x; x += step)
45             for (double y = p1.y; y <= p2.y; y += step)
46                 for (double z = p1.z; z <= p2.z; z += step) {
47
48                     final Point3D p3 = new Point3D(x, y, z);
49
50                     if ((x + step) <= p2.x) {
51                         final Point3D point3d2 = new Point3D(x + step, y, z);
52                         addShape(appearance.getLine(p3, point3d2));
53                     }
54
55                     if ((y + step) <= p2.y) {
56                         final Point3D point3d3 = new Point3D(x, y + step, z);
57                         addShape(appearance.getLine(p3, point3d3));
58                     }
59
60                     if ((z + step) <= p2.z) {
61                         final Point3D point3d4 = new Point3D(x, y, z + step);
62                         addShape(appearance.getLine(p3, point3d4));
63                     }
64
65                 }
66     }
67 }