1 /* file : Shape3D.java
2 *
3 * Project : geometry
4 *
5 * ===========================================
6 *
7 * This library is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 2.1 of the License, or (at
10 * your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE.
15 *
16 * See the GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library. if not, write to :
20 * The Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 * Boston, MA 02111-1307, USA.
22 *
23 * Created on 27 nov. 2005
24 *
25 */
26
27 package math.geom3d;
28
29 import java.io.Serializable;
30
31 import math.geom3d.transform.AffineTransform3D;
32
33 /**
34 * @author dlegland
35 */
36 public interface Shape3D extends Serializable {
37
38 public final static double ACCURACY = 1e-12;
39
40 public final static Shape3D EMPTY_SET = new EmptySet3D();
41
42 public abstract boolean isEmpty();
43
44 /**
45 * Returns true if the shape is bounded, that is if we can draw a finite
46 * rectangle enclosing the shape. For example, a straight line or a parabola
47 * are not bounded.
48 */
49 public abstract boolean isBounded();
50
51 public abstract Box3D getBoundingBox();
52
53 public abstract Shape3D clip(Box3D box);
54
55 public abstract Shape3D transform(AffineTransform3D trans);
56
57 /**
58 * Gets the distance of the shape to the given point, or the distance of
59 * point to the frontier of the shape in the case of a plain shape.
60 */
61 public abstract double getDistance(Point3D p);
62
63 public abstract boolean contains(Point3D point);
64
65 /**
66 *
67 */
68 public class EmptySet3D implements Shape3D {
69
70 protected EmptySet3D() {
71 }
72
73 /**
74 * return positive infinity.
75 */
76 public double getDistance(Point3D p) {
77 return Double.POSITIVE_INFINITY;
78 }
79
80 public boolean isEmpty() {
81 return true;
82 }
83
84 public boolean isBounded() {
85 return false;
86 }
87
88 public boolean contains(Point3D point) {
89 return false;
90 }
91
92 public Box3D getBoundingBox() {
93 return new Box3D(Double.NaN, Double.NaN, Double.NaN, Double.NaN,
94 Double.NaN, Double.NaN);
95 }
96
97 public Shape3D clip(Box3D box) {
98 return this;
99 }
100
101 public Shape3D transform(AffineTransform3D trans) {
102 return this;
103 }
104
105 }
106 }