5 #include <DetailedVoxel.h>
11 namespace HeliosTests{
71 std::string path =
"SerializationTest.tmp";
79 std::vector<int>({0,1,2}),
80 std::vector<double>({1.0, 1.5, 2.0, 2.5, 3.0})
82 dv1.
part = std::make_shared<ScenePart>();
83 dv1.
part->mPrimitives.push_back(&dv1);
84 dv1.
part->onRayIntersectionMode =
"TRANSMITTIVE";
85 dv1.
material = std::make_shared<Material>();
94 if(!
validate(dv1,*dv2))
return false;
99 Vertex t1v1; t1v1.
pos = glm::dvec3(0.0, 0.0, 0.0);
100 Vertex t1v2; t1v2.
pos = glm::dvec3(0.0, 0.0, 4.0);
101 Vertex t1v3; t1v3.
pos = glm::dvec3(2.0, 0.0, 0.0);
103 Voxel v1(1.0, 1.0, 1.0, 1.0);
104 AABB box1(glm::dvec3(0.0, 0.0, 0.0), glm::dvec3(5.0, 5.0, 5.0));
109 for(
size_t i = 0 ; i < nRepeats ; i++)
111 shared_ptr<ScenePart> part = make_shared<ScenePart>();
114 part->mPrimitives.push_back(prim);
128 for(
size_t i = 0 ; i < nRepeats ; i++){
135 std::remove(path.c_str());
152 if(dv1c.x!=dv2c.x || dv1c.y!=dv2c.y || dv1c.z!=dv2c.z)
return false;
158 if(dv1[i]!=dv2[i])
return false;
163 for (
size_t i = 0; i < 4; i++) {
174 if(v1c.x!=v2c.x || v1c.y!=v2c.y || v1c.z!=v2c.z)
return false;
181 double minX1 = box1.
getMin().x;
double maxX1 = box1.
getMax().x;
182 double minY1 = box1.
getMin().y;
double maxY1 = box1.
getMax().y;
183 double minZ1 = box1.
getMin().z;
double maxZ1 = box1.
getMax().z;
184 double minX2 = box2.
getMin().x;
double maxX2 = box2.
getMax().x;
185 double minY2 = box2.
getMin().y;
double maxY2 = box2.
getMax().y;
186 double minZ2 = box2.
getMin().z;
double maxZ2 = box2.
getMax().z;
188 if (minX1 != minX2)
return false;
189 if (minY1 != minY2)
return false;
190 if (minZ1 != minZ2)
return false;
192 if (maxX1 != maxX2)
return false;
193 if (maxY1 != maxY2)
return false;
194 if (maxZ1 != maxZ2)
return false;
200 double x1, x2, y1, y2, z1, z2;
204 if(x1 != x2)
return false;
207 if(y1 != y2)
return false;
210 if(z1 != z2)
return false;
Class representing an Axis Aligned Bounding Box (AABB)
Definition: AABB.h:10
glm::dvec3 const & getMax() const
Get the max value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:109
glm::dvec3 const & getMin() const
Get the min value for each coordinate of the axis aligned bounding box.
Definition: AABB.h:103
Primitive * clone() override
Generate a clone of the primitive.
Definition: AABB.cpp:17
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:15
size_t getNumberOfDoubleValues() const
Obtain the number of double values defining the detailed voxel.
Definition: DetailedVoxel.h:191
int getIntValue(size_t index) const
Obtain integer value at given index.
Definition: DetailedVoxel.h:206
Primitive * clone() override
Definition: DetailedVoxel.cpp:6
size_t getNumberOfIntValues() const
Obtain the number of integer values defining the detailed voxel.
Definition: DetailedVoxel.h:185
BaseTest class.
Definition: BaseTest.h:20
Test serialization.
Definition: SerializationTest.h:19
SerializationTest()
Serialization test constructor.
Definition: SerializationTest.h:26
bool validate(DetailedVoxel &dv1, DetailedVoxel &dv2)
Check two detailed voxels are equal.
Definition: SerializationTest.h:147
bool run() override
Definition: SerializationTest.h:70
Abstract class defining the common behavior for all primitives.
Definition: Primitive.h:24
std::shared_ptr< ScenePart > part
Shared pointer to the scene part the primitive belongs to.
Definition: Primitive.h:57
std::shared_ptr< Material > material
Shared pointer to the material defining certain properties such as reflectance, specularity,...
Definition: Primitive.h:63
Class representing a scene asset.
Definition: Scene.h:28
virtual void setKDGroveFactory(std::shared_ptr< KDGroveFactory > const kdgf)
Set the KDGrove factory to be used by the scene.
Definition: Scene.h:399
static Scene * readObject(std::string path)
Read serialized scene from given file.
Definition: Scene.cpp:392
std::vector< Primitive * > primitives
Vector of primitives composing the scene.
Definition: Scene.h:132
virtual void writeObject(std::string path)
Serialize the scene and write it to given output file.
Definition: Scene.cpp:385
virtual std::shared_ptr< KDGroveFactory > getKDGroveFactory() const
Obtain the KDGrove factory used by the scene.
Definition: Scene.h:392
bool finalizeLoading(bool const safe=false)
Handle scene loading finish process.
Definition: Scene.cpp:69
Utils for Input/Output operations of serializable objects.
Definition: SerialIO.h:13
void write(std::string const &path, SerialClass const *object, bool fastCompression=true)
static SerialIO * getInstance()
Definition: SerialIO.cpp:6
SerialClass * read(std::string const &path, bool const fastCompression=true)
Class representing triangle primitive.
Definition: Triangle.h:13
Vertex verts[3]
The 3 vertices defining the triangle.
Definition: Triangle.h:66
Primitive * clone() override
Definition: Triangle.cpp:25
size_t getNumVertices() override
Definition: Triangle.h:108
Class representing a vertex.
Definition: Vertex.h:14
glm::dvec3 pos
Vertex 3D position.
Definition: Vertex.h:39
double getX() const
Get the X coordinate of vertex position.
Definition: Vertex.h:98
double getZ() const
Get the Z coordinate of vertex position.
Definition: Vertex.h:116
double getY() const
Get the Y coordinate of vertex position.
Definition: Vertex.h:107
Class representing a voxel primitive.
Definition: Voxel.h:11
Primitive * clone() override
Definition: Voxel.cpp:17
glm::dvec3 getCentroid() override
Definition: Voxel.cpp:41
double halfSize
Half of the voxel sizxe.
Definition: Voxel.h:64