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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#include <BALL/CONCEPT/classTest.h>
#include <BALLTestConfig.h>
///////////////////////////
#include <BALL/DATATYPE/contourSurface.h>
///////////////////////////
START_TEST(ContourSurface)
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
using namespace BALL;
ContourSurface* cs_ptr = 0;
CHECK(TContourSurface() throw())
cs_ptr = new ContourSurface;
TEST_NOT_EQUAL(cs_ptr, 0)
RESULT
CHECK(~TContourSurface() throw())
delete cs_ptr;
RESULT
CHECK(TContourSurface<T>::operator << (TRegularData3D<T>& data))
// Create a grid with just the middle point at 1.0 and the
// remainder at -1.0.
RegularData3D data(RegularData3D::IndexType(5, 5, 5), Vector3(-2.0), Vector3(4.0));
STATUS("grid size: " << data.getSize().x << "/" << data.getSize().y << "/" << data.getSize().z)
for (Position i = 0; i < data.size(); i++)
{
data[i] = -1.0;
}
data[2 + 2 * 5 + 2 * 25] = 1.0;
STATUS("Coordinate: " << data.getCoordinates(62))
STATUS("min: " << data.getOrigin())
STATUS("max: " << data.getOrigin() + data.getDimension())
STATUS("grid constructed")
ContourSurface cs;
STATUS("ContourSurface constructed.")
cs << data;
TEST_EQUAL(cs.vertex.size(), 6)
TEST_EQUAL(cs.normal.size(), 6)
TEST_EQUAL(cs.triangle.size(), 8)
ABORT_IF(cs.vertex.size() != 6)
ABORT_IF(cs.normal.size() != 6)
Vector3 ref_pos;
for (Position i = 0; i < cs.vertex.size(); i++)
{
switch (i)
{
case 0: ref_pos = Vector3(0.0, -0.5, 0.0); break;
case 1: ref_pos = Vector3(-0.5, 0.0, 0.0); break;
case 2: ref_pos = Vector3(0.0, 0.0, -0.5); break;
case 3: ref_pos = Vector3(0.5, 0.0, 0.0); break;
case 4: ref_pos = Vector3(0.0, 0.5, 0.0); break;
case 5: ref_pos = Vector3(0.0, 0.0, 0.5); break;
}
TEST_REAL_EQUAL(cs.vertex[i].x, ref_pos.x)
TEST_REAL_EQUAL(cs.vertex[i].y, ref_pos.y)
TEST_REAL_EQUAL(cs.vertex[i].z, ref_pos.z)
STATUS(i << " " << cs.vertex[i] * -2.0 << " " << cs.normal[i])
}
ABORT_IF(cs.triangle.size() != 8)
Index t[8][3] = {{0, 1, 2}, {0, 2, 3}, {4, 2, 1}, {4, 3, 2}, {0, 5, 1}, {0, 3, 5}, {4, 1, 5}, {4, 5, 3}};
for (Position i = 0; i < cs.triangle.size(); i++)
{
TEST_EQUAL(cs.triangle[i].v1, t[i][0])
TEST_EQUAL(cs.triangle[i].v2, t[i][1])
TEST_EQUAL(cs.triangle[i].v3, t[i][2])
}
// Do it again and make sure we get identical results.
// This shall test whether everything is cleared correctly
// prior to constructing the new surface.
cs << data;
TEST_EQUAL(cs.vertex.size(), 6)
TEST_EQUAL(cs.normal.size(), 6)
TEST_EQUAL(cs.triangle.size(), 8)
ABORT_IF(cs.vertex.size() != 6)
ABORT_IF(cs.normal.size() != 6)
for (Position i = 0; i < cs.vertex.size(); i++)
{
switch (i)
{
case 0: ref_pos = Vector3(0.0, -0.5, 0.0); break;
case 1: ref_pos = Vector3(-0.5, 0.0, 0.0); break;
case 2: ref_pos = Vector3(0.0, 0.0, -0.5); break;
case 3: ref_pos = Vector3(0.5, 0.0, 0.0); break;
case 4: ref_pos = Vector3(0.0, 0.5, 0.0); break;
case 5: ref_pos = Vector3(0.0, 0.0, 0.5); break;
}
TEST_REAL_EQUAL(cs.vertex[i].x, ref_pos.x)
TEST_REAL_EQUAL(cs.vertex[i].y, ref_pos.y)
TEST_REAL_EQUAL(cs.vertex[i].z, ref_pos.z)
TEST_REAL_EQUAL(cs.normal[i].x, ref_pos.x * -2.0)
TEST_REAL_EQUAL(cs.normal[i].y, ref_pos.y * -2.0)
TEST_REAL_EQUAL(cs.normal[i].z, ref_pos.z * -2.0)
}
ABORT_IF(cs.triangle.size() != 8)
for (Position i = 0; i < cs.triangle.size(); i++)
{
TEST_EQUAL(cs.triangle[i].v1, t[i][0])
TEST_EQUAL(cs.triangle[i].v2, t[i][1])
TEST_EQUAL(cs.triangle[i].v3, t[i][2])
}
RESULT
CHECK([EXTRA]Exceptions)
RegularData3D rd;
std::ifstream is("2ptc2.loc");
is >> rd;
is.close();
STATUS("read grid")
ContourSurface cs(0.02);
STATUS("cs ctor")
cs << rd;
STATUS("done")
STATUS(cs.vertex.size())
STATUS(cs.triangle.size())
RESULT
CHECK(Cube(const TRegularData3D<T>& grid) throw())
// ???
RESULT
CHECK(Position computeTopology(double threshold) throw())
// ???
RESULT
CHECK(Position getIndex(Position corner) const)
// ???
RESULT
CHECK(TContourSurface(T threshold))
// ???
RESULT
CHECK(TContourSurface(const TContourSurface& surface))
// ???
RESULT
CHECK((TContourSurface(const TRegularData3D<T>& data, T threshold = 0.0)))
// ???
RESULT
CHECK(Vector3 getCoordinates(Position index) const)
// ???
RESULT
CHECK(Vector3 getOrigin() const)
// ???
RESULT
CHECK(bool operator == (const TContourSurface<T>& surface) const)
// ???
RESULT
CHECK(const TContourSurface& operator = (const TContourSurface<T>& surface))
// ???
RESULT
CHECK(const TContourSurface<T> & operator << (const TRegularData3D<T>& data))
// ???
RESULT
CHECK(const Vector3& getSpacing() const)
// ???
RESULT
CHECK(void clear())
// ???
RESULT
CHECK(void setTo(Position p))
// ???
RESULT
CHECK(void shift() throw())
// ???
RESULT
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
END_TEST
|