-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMeshVisitor.cpp
132 lines (119 loc) · 3.29 KB
/
MeshVisitor.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
123
124
125
126
127
128
129
130
131
132
/**
* @file MeshVisitor.cpp
* Implements the MeshVisitor class.
* @ingroup meshtex-util
*/
/*
* Copyright 2012 Joel Baxter
*
* This file is part of MeshTex.
*
* MeshTex is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* MeshTex is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MeshTex. If not, see <http://www.gnu.org/licenses/>.
*/
#include "MeshVisitor.h"
#include "GenericPluginUI.h"
#include "PluginUIMessages.h"
/**
* Use GenericPluginUI::InfoReportDialog as MeshEntity info callback.
*/
const MeshEntity::MessageCallback MeshVisitor::_infoReportCallback(
PointerCaller1<const char,
const char *,
&GenericPluginUI::InfoReportDialog>(DIALOG_MESH_INFO_TITLE));
/**
* Use GenericPluginUI::WarningReportDialog as MeshEntity warning callback.
*/
const MeshEntity::MessageCallback MeshVisitor::_warningReportCallback(
PointerCaller1<const char,
const char *,
&GenericPluginUI::WarningReportDialog>(DIALOG_WARNING_TITLE));
/**
* Use GenericPluginUI::ErrorReportDialog as MeshEntity error callback.
*/
const MeshEntity::MessageCallback MeshVisitor::_errorReportCallback(
PointerCaller1<const char,
const char *,
&GenericPluginUI::ErrorReportDialog>(DIALOG_ERROR_TITLE));
/**
* Default constructor.
*/
MeshVisitor::MeshVisitor() :
_visitedCount(0)
{
}
/**
* Virtual destructor.
*/
MeshVisitor::~MeshVisitor()
{
}
/**
* Reset the visited count to zero.
*/
void
MeshVisitor::ResetVisitedCount()
{
_visitedCount = 0;
}
/**
* Get the visited count. This is the number of times Execute has been
* invoked since visitor construction or the most recent reset of the count.
*
* @return The visited count.
*/
unsigned
MeshVisitor::GetVisitedCount()
{
return _visitedCount;
}
/**
* Visit a specified scene graph node.
*
* @param [in,out] instance The scene graph node.
*/
void
MeshVisitor::visit(scene::Instance& instance) const
{
if (Node_isPatch(instance.path().top()))
{
// If it's a patch mesh, try creating a MeshEntity.
MeshEntity meshEntity(instance.path().top(),
_infoReportCallback,
_warningReportCallback,
_errorReportCallback);
if (meshEntity.IsValid())
{
// If we have a valid MeshEntity, invoke Execute.
if (Execute(meshEntity))
{
// Count the number of affected meshes.
_visitedCount++;
}
}
}
}
/**
* Execute function performed for visited meshes. This implementation does
* nothing; subclasses should override it.
*
* @param meshEntity The MeshEntity.
*
* @return true if the mesh was successfully visited; always the case in this
* skeleton implementation.
*/
bool
MeshVisitor::Execute(MeshEntity& meshEntity) const
{
return true;
}