ManifoldVertexCheckTest.java 3.31 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CityDoctor2 is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2.checks.geometry;

import static de.hft.stuttgart.citydoctor2.checks.util.GeometryTestUtils.addPolygon;
import static de.hft.stuttgart.citydoctor2.checks.util.GeometryTestUtils.createVertex;

import org.junit.Assert;
import org.junit.Test;

import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.checks.util.GeometryTestUtils;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.GeometryType;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;

/**
 * 
 * @author Matthias Betz
 *
 */
public class ManifoldVertexCheckTest {

	@Test
	public void testNonManifoldVertex() {
		Geometry geom = new Geometry(GeometryType.SOLID, Lod.LOD1);
		
		Vertex v12 = createVertex(10, 10, 3, geom);
		Vertex v13 = createVertex(10, 10, 0, geom);
		Vertex v9 = createVertex(10, 15, 0, geom);
		Vertex v10 = createVertex(10, 15, 3, geom);
		Vertex v14 = createVertex(11.5, 10, 4.5, geom);
		Vertex v11 = createVertex(11.5, 15, 4.5, geom);
		Vertex v0 = createVertex(13, 15, 0, geom);
		Vertex v1 = createVertex(13, 15, 3, geom);
		Vertex v2 = createVertex(13, 10, 3, geom);
		Vertex v3 = createVertex(13, 10, 0, geom);
		Vertex v8 = createVertex(13, 16, 3, geom);
		Vertex v5 = createVertex(13.5, 15.5, 3.5, geom);
		Vertex v6 = createVertex(14, 15, 3, geom);
		Vertex v7 = createVertex(14, 16, 3, geom);
		
		addPolygon(geom, v0, v1, v2, v3);
		addPolygon(geom, v1, v6, v5);
		addPolygon(geom, v6, v7, v5);
		addPolygon(geom, v7, v8, v5);
		addPolygon(geom, v8, v1, v5);
		addPolygon(geom, v1, v8, v7, v6);
		
		addPolygon(geom, v9, v10, v11, v1, v0);
		addPolygon(geom, v12, v10, v9, v13);
		addPolygon(geom, v3, v2, v14, v12, v13);
		addPolygon(geom, v12, v14, v11, v10);
		addPolygon(geom, v14, v2, v1, v11);
		addPolygon(geom, v13, v9, v0, v3);
74
75
		
		geom.updateEdgesAndVertices();
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
		
		ManifoldVertexCheck check = new ManifoldVertexCheck();
		check.check(geom);
		CheckResult cr = geom.getCheckResult(check);
		Assert.assertNotNull(cr);
		Assert.assertEquals(ResultStatus.ERROR, cr.getResultStatus());
		

	}
	
	@Test
	public void testGoodSolid() {
		Geometry g = GeometryTestUtils.createGoodGeometry();
		
		g.updateEdges();
		ManifoldVertexCheck check = new ManifoldVertexCheck();
		check.check(g);
		CheckResult cr = g.getCheckResult(check);
		Assert.assertNotNull(cr);
		Assert.assertEquals(ResultStatus.OK, cr.getResultStatus());
	}

}