-
Notifications
You must be signed in to change notification settings - Fork 30
/
TorusPrimitiveShapeConstructor.cpp
49 lines (43 loc) · 1.25 KB
/
TorusPrimitiveShapeConstructor.cpp
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
#include "TorusPrimitiveShapeConstructor.h"
#include "TorusPrimitiveShape.h"
#include "ScoreComputer.h"
#include <GfxTL/NullClass.h>
size_t TorusPrimitiveShapeConstructor::Identifier() const
{
return 4;
}
unsigned int TorusPrimitiveShapeConstructor::RequiredSamples() const
{
return 4;
}
PrimitiveShape *TorusPrimitiveShapeConstructor::Construct(
const MiscLib::Vector< Vec3f > &points,
const MiscLib::Vector< Vec3f > &normals) const
{
MiscLib::Vector< Vec3f > samples;
for(size_t i = 0; i < points.size(); ++i)
samples.push_back(points[i]);
for(size_t i = 0; i < normals.size(); ++i)
samples.push_back(normals[i]);
return Construct(samples);
}
PrimitiveShape *TorusPrimitiveShapeConstructor::Construct(
const MiscLib::Vector< Vec3f > &samples) const
{
Torus torus;
if(!torus.Init(samples))
return NULL;
return new TorusPrimitiveShape(torus);
}
PrimitiveShape *TorusPrimitiveShapeConstructor::Deserialize(std::istream *i,
bool binary) const
{
TorusPrimitiveShape *shape = new TorusPrimitiveShape();
shape->Deserialize(i, binary);
return shape;
}
size_t TorusPrimitiveShapeConstructor::SerializedSize() const
{
return Torus::SerializedSize() +
TorusPrimitiveShape::ParametrizationType::SerializedSize();
}