-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene3d.cpp
122 lines (91 loc) · 2.84 KB
/
scene3d.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
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
#include <string>
#include <vector>
#include <iostream>
#include "scene3d.hpp"
namespace scefig
{
// TransformNode
void Scene3D::TransformNode::addShape(Shape* pShape)
{
m_shapes.push_back(pShape);
pShape->setTransformNode(*this);
}
void Scene3D::TransformNode::addChildTransform(TransformNode* pChild)
{
m_children.push_back(pChild);
}
void Scene3D::TransformNode::getShapes(std::vector<const Shape*> & shapes) const
{
//shapes.clear();
for(std::vector<Shape*>::const_iterator shapeIt = m_shapes.begin(); shapeIt != m_shapes.end(); ++shapeIt)
{
//std::cout << "shape " << (*shapeIt)->getLabel() << std::endl;
shapes.push_back(*shapeIt);
}
for(std::vector<TransformNode*>::const_iterator childIt = m_children.begin(); childIt != m_children.end(); ++childIt)
{
const TransformNode* pChildTransformNode = *childIt;
std::vector<const Shape*> childShapes;
pChildTransformNode->getShapes(childShapes);
for(std::vector<const Shape*>::const_iterator shapeIt = childShapes.begin(); shapeIt != childShapes.end(); ++shapeIt)
{
shapes.push_back(*shapeIt);
}
}
}
// Shape
Scene3D::Shape::Shape(const LabelType & label, TransformNode * pTransformNode)
: m_label(label)
, m_pTransformNode(pTransformNode)
{}
// PointShape
Scene3D::PointShape::PointShape(const LabelType & label, const Vector3 & values) : super(label), m_position(values) {}
void Scene3D::PointShape::visit( IShapeVisitor & shapeVisitor) const
{
shapeVisitor.visitPoint(*this);
}
// PolyLine
Scene3D::PolyLineShape::PolyLineShape(const LabelType & label) : super(label), m_polyLine() {}
void Scene3D::PolyLineShape::visit( IShapeVisitor & shapeVisitor) const
{
shapeVisitor.visitPolyLine(*this);
}
void Scene3D::PolyLineShape::appendVertex(const Vector3 & vertex)
{
m_polyLine.appendVertex( vertex );
}
bool Scene3D::PolyLineShape::isClosed(void) const
{
return m_polyLine.isClosed();
}
// Line
Scene3D::LineShape::LineShape(const LabelType & label, const Vector3 & fromPos, const Vector3 & toPos) : PolyLineShape(label)
{
m_polyLine.appendVertex( fromPos );
m_polyLine.appendVertex( toPos );
}
// PlaneShape
Scene3D::PlaneShape::PlaneShape(const LabelType & label, const Plane & plane)
: Shape(label), m_plane(plane)
{
}
void Scene3D::PlaneShape::visit( IShapeVisitor & shapeVisitor) const
{
shapeVisitor.visitPlane(*this);
}
const Plane & Scene3D::PlaneShape::getPlane(void) const
{
return m_plane;
}
/*
class Scene(object):
def __init__(self):
self.m_rootNode = TransformNode()
def getRootNode(self):
return self.m_rootNode
# a generator that yields items instead of returning a list
def shapes(self):
return self.m_rootNode.shapes()
*/
//Point3D * createPoint(const LabelType & label, const Vector3f & values);
}