diff --git a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComponent.java b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComponent.java index 7260880394d25cf7c841cafd9c4885fb0916ef6c..acbea11f6aeac0bca87c2f72555a64b70e146dcd 100644 --- a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComponent.java +++ b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComponent.java @@ -22,7 +22,7 @@ public abstract class MeshComponent { * @return true if newParent was successfully added, false otherwise */ public boolean addParent(MeshComponent newParent){ - if (parents.contains(newParent)) + if (newParent == null || parents.contains(newParent)) return false; parents.add(newParent); return true; diff --git a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComposite.java b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComposite.java index faf5270d065a5b3421406c0ff3632b34fdd33169..e4d1c57e9eef9a7d1faaabfa0944238f9fb62d9b 100644 --- a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComposite.java +++ b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshComposite.java @@ -19,7 +19,7 @@ public class MeshComposite extends MeshComponent { */ @Override public boolean addChild(MeshComponent newChild) { - if (children.contains(newChild)) + if (newChild == null || children.contains(newChild)) return false; children.add(newChild); diff --git a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshEdge.java b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshEdge.java index bb95f224ef1aa38969fa071a09ed0cd1a3c1b673..f9a4fd2b903ccbada158733d93d0c3f7d73cbc81 100644 --- a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshEdge.java +++ b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshEdge.java @@ -6,6 +6,8 @@ public class MeshEdge extends MeshComposite { public MeshEdge(MeshPoint point1, MeshPoint point2){ super(); + if (point1 == null || point2 == null) + throw new NullPointerException("point1 and point2 cannot be null"); super.addChild(point1); super.addChild(point2); } diff --git a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshFacet.java b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshFacet.java index db51d2d26036631928adc992a3ab8568f846a358..5afa5c8c30ac0e1f6980ea5b26ba5d0ffdf34c68 100644 --- a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshFacet.java +++ b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshFacet.java @@ -16,6 +16,9 @@ public class MeshFacet extends MeshComposite { * @return point from pointPool if it is in pointPool, null otherwise */ public MeshPoint getPoint(MeshPoint point) { + if (point == null) + return null; + MeshPoint result = pointPool.get(point); if (result == null) { pointPool.put(point, point); @@ -30,6 +33,9 @@ public class MeshFacet extends MeshComposite { * @return edge from edgePool if it is in edgePool, null otherwise */ public MeshEdge getEdge(MeshEdge edge) { + if (edge == null) + return null; + MeshEdge result = edgePool.get(edge); if (result == null) { edgePool.put(edge, edge); diff --git a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshPoint.java b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshPoint.java index 25d04b872189aac9984e6ad1d735649917a44c10..e066417bd5da776d06d6adddb6cc4081627d3b9d 100644 --- a/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshPoint.java +++ b/MeshModel/src/main/cz/fidentis/analyst/mesh/core/MeshPoint.java @@ -7,6 +7,9 @@ public class MeshPoint extends MeshLeaf { private final Vector3d position, normal, texCoord; public MeshPoint(Vector3d position, Vector3d normal , Vector3d texCoord) { + if (position == null || normal == null || texCoord == null) + throw new NullPointerException("position, normal and texCoord cannot be null"); + this.position = position; this.normal = normal; this.texCoord = texCoord;