4 #include <DetailedVoxel.h> 70 std::string path(
"SerializationTest.tmp");
78 std::vector<int>({0,1,2}),
79 std::vector<double>({1.0, 1.5, 2.0, 2.5, 3.0})
81 dv1.
part = std::make_shared<ScenePart>();
82 dv1.
part->onRayIntersectionMode =
"TRANSMITTIVE";
83 dv1.
material = std::make_shared<Material>();
90 if(!
validate(dv1,*dv2))
return false;
95 Vertex t1v1; t1v1.
pos = glm::dvec3(0.0, 0.0, 0.0);
96 Vertex t1v2; t1v2.
pos = glm::dvec3(0.0, 0.0, 4.0);
97 Vertex t1v3; t1v3.
pos = glm::dvec3(2.0, 0.0, 0.0);
99 Voxel v1(1.0, 1.0, 1.0, 1.0);
100 AABB box1(glm::dvec3(0.0, 0.0, 0.0), glm::dvec3(5.0, 5.0, 5.0));
105 for(
size_t i = 0 ; i < nRepeats ; i++)
116 for(
size_t i = 0 ; i < nRepeats ; i++){
123 std::remove(path.c_str());
136 if(dv1c.x!=dv2c.x || dv1c.y!=dv2c.y || dv1c.z!=dv2c.z)
return false;
142 if(dv1[i]!=dv2[i])
return false;
147 for (
size_t i = 0; i < 4; i++) {
158 if(v1c.x!=v2c.x || v1c.y!=v2c.y || v1c.z!=v2c.z)
return false;
165 double minX1 = box1.
getMin().x;
double maxX1 = box1.
getMax().x;
166 double minY1 = box1.
getMin().y;
double maxY1 = box1.
getMax().y;
167 double minZ1 = box1.
getMin().z;
double maxZ1 = box1.
getMax().z;
168 double minX2 = box2.
getMin().x;
double maxX2 = box2.
getMax().x;
169 double minY2 = box2.
getMin().y;
double maxY2 = box2.
getMax().y;
170 double minZ2 = box2.
getMin().z;
double maxZ2 = box2.
getMax().z;
172 if (minX1 != minX2)
return false;
173 if (minY1 != minY2)
return false;
174 if (minZ1 != minZ2)
return false;
176 if (maxX1 != maxX2)
return false;
177 if (maxY1 != maxY2)
return false;
178 if (maxZ1 != maxZ2)
return false;
184 double x1, x2, y1, y2, z1, z2;
188 if(x1 != x2)
return false;
191 if(y1 != y2)
return false;
194 if(z1 != z2)
return false;
glm::dvec3 const & getMin() const
Get the min value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:75
glm::dvec3 getCentroid() override
Definition: Voxel.cpp:41
bool run() override
Definition: SerializationTest.h:69
size_t getNumberOfIntValues() const
Obtain the number of integer values defining the detailed voxel.
Definition: DetailedVoxel.h:182
Primitive * clone() override
Definition: Voxel.cpp:17
int getIntValue(size_t index) const
Obtain integer value at given index.
Definition: DetailedVoxel.h:203
void writeObject(std::string path)
Serialize the scene and write it to given output file.
Definition: Scene.cpp:231
Test serialization.
Definition: SerializationTest.h:18
std::shared_ptr< Material > material
Shared pointer to the material defining certain properties such as reflectance, specularity, ...
Definition: Primitive.h:43
std::vector< Primitive * > primitives
Vector of primitives composing the scene.
Definition: Scene.h:66
BaseTest class.
Definition: BaseTest.h:19
glm::dvec3 const & getMax() const
Get the max value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:81
SerialClass * read(std::string &path, bool fastCompression=true)
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:12
size_t getNumVertices() override
Definition: Triangle.h:98
bool finalizeLoading()
Handle scene loading finish process.
Definition: Scene.cpp:59
static Scene * readObject(std::string path)
Read serialized scene from given file.
Definition: Scene.cpp:238
Class representing an Axis Aligned Bounding Box (AABB)
Definition: AABB.h:10
Primitive * clone() override
Definition: Triangle.cpp:26
SerializationTest()
Serialization test constructor.
Definition: SerializationTest.h:25
bool validate(DetailedVoxel &dv1, DetailedVoxel &dv2)
Check two detailed voxels are equal.
Definition: SerializationTest.h:131
Class representing a voxel primitive.
Definition: Voxel.h:11
Class representing triangle primitive.
Definition: Triangle.h:13
double getX() const
Get the X coordinate of vertex position.
Definition: Vertex.h:84
double halfSize
Half of the voxel sizxe.
Definition: Voxel.h:67
glm::dvec3 pos
Vertex 3D position.
Definition: Vertex.h:32
void write(std::string &path, SerialClass *object, bool fastCompression=true)
double getZ() const
Get the Z coordinate of vertex position.
Definition: Vertex.h:102
Vertex verts[3]
The 3 vertices defining the triangle.
Definition: Triangle.h:54
Class representing a scene asset.
Definition: Scene.h:25
std::shared_ptr< ScenePart > part
Shared pointer to the scene part the primitive belongs to.
Definition: Primitive.h:37
static SerialIO * getInstance()
Definition: SerialIO.cpp:6
Primitive * clone() override
Generate a clone of the primitive.
Definition: AABB.cpp:17
size_t getNumberOfDoubleValues() const
Obtain the number of double values defining the detailed voxel.
Definition: DetailedVoxel.h:188
Primitive * clone() override
Definition: DetailedVoxel.cpp:6
Class representing a vertex.
Definition: Vertex.h:14
double getY() const
Get the Y coordinate of vertex position.
Definition: Vertex.h:93