This file is indexed.

/usr/include/SurgSim/DataStructures/TriangleMeshPlyReaderDelegate-inl.h is in libopensurgsim-dev 0.7.0-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// This file is a part of the OpenSurgSim project.
// Copyright 2013, SimQuest Solutions Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H
#define SURGSIM_DATASTRUCTURES_TRIANGLEMESHPLYREADERDELEGATE_INL_H

#include <cstddef>

#include "SurgSim/Math/Vector.h"

template <class M>
SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::TriangleMeshPlyReaderDelegate() :
	m_mesh(std::make_shared<M>()),
	m_hasTextureCoordinates(false),
	m_hasFaces(false),
	m_hasEdges(false)

{

}

template <class M>
SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::TriangleMeshPlyReaderDelegate(std::shared_ptr<M> mesh) :
	m_mesh(mesh),
	m_hasTextureCoordinates(false),
	m_hasFaces(false),
	m_hasEdges(false)
{
	SURGSIM_ASSERT(mesh != nullptr) << "The mesh cannot be null.";
	mesh->clear();
}

template <class M>
std::shared_ptr<M> SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::getMesh()
{
	return m_mesh;
}

template <class M>
bool SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::registerDelegate(PlyReader* reader)
{
	// Vertex processing
	reader->requestElement("vertex",
						   std::bind(&TriangleMeshPlyReaderDelegate::beginVertices, this,
									 std::placeholders::_1, std::placeholders::_2),
						   std::bind(&TriangleMeshPlyReaderDelegate::processVertex, this, std::placeholders::_1),
						   std::bind(&TriangleMeshPlyReaderDelegate::endVertices, this, std::placeholders::_1));
	reader->requestScalarProperty("vertex", "x", PlyReader::TYPE_DOUBLE, offsetof(VertexData, x));
	reader->requestScalarProperty("vertex", "y", PlyReader::TYPE_DOUBLE, offsetof(VertexData, y));
	reader->requestScalarProperty("vertex", "z", PlyReader::TYPE_DOUBLE, offsetof(VertexData, z));

	// Normal processing
	m_hasTextureCoordinates = reader->hasProperty("vertex", "s") && reader->hasProperty("vertex", "t");

	if (m_hasTextureCoordinates)
	{
		reader->requestScalarProperty("vertex", "s", PlyReader::TYPE_DOUBLE, offsetof(VertexData, s));
		reader->requestScalarProperty("vertex", "t", PlyReader::TYPE_DOUBLE, offsetof(VertexData, t));
	}


	if (m_hasFaces)
	{
		// Face Processing
		reader->requestElement("face",
							   std::bind(&TriangleMeshPlyReaderDelegate::beginFaces, this,
										 std::placeholders::_1, std::placeholders::_2),
							   std::bind(&TriangleMeshPlyReaderDelegate::processFace, this, std::placeholders::_1),
							   std::bind(&TriangleMeshPlyReaderDelegate::endFaces, this, std::placeholders::_1));
		reader->requestListProperty("face", "vertex_indices",
									PlyReader::TYPE_UNSIGNED_INT,
									offsetof(ListData, indices),
									PlyReader::TYPE_UNSIGNED_INT,
									offsetof(ListData, count));
	}


	if (m_hasEdges)
	{
		// Edge Processing
		reader->requestElement("1d_element",
							   std::bind(&TriangleMeshPlyReaderDelegate::beginEdges, this,
										 std::placeholders::_1, std::placeholders::_2),
							   std::bind(&TriangleMeshPlyReaderDelegate::processEdge, this, std::placeholders::_1),
							   std::bind(&TriangleMeshPlyReaderDelegate::endEdges, this, std::placeholders::_1));
		reader->requestListProperty("1d_element", "vertex_indices",
									PlyReader::TYPE_UNSIGNED_INT,
									offsetof(ListData, indices),
									PlyReader::TYPE_UNSIGNED_INT,
									offsetof(ListData, count));
	}

	reader->setEndParseFileCallback(std::bind(&TriangleMeshPlyReaderDelegate::endFile, this));

	return true;
}

template <class M>
bool SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::fileIsAcceptable(const PlyReader& reader)
{
	bool result = true;

	m_hasFaces = reader.hasProperty("face", "vertex_indices") &&
				 !reader.isScalar("face", "vertex_indices");

	m_hasEdges = reader.hasProperty("1d_element", "vertex_indices") &&
				 !reader.isScalar("1d_element", "vertex_indices");

	// Shortcut test if one fails ...
	result = result && reader.hasProperty("vertex", "x");
	result = result && reader.hasProperty("vertex", "y");
	result = result && reader.hasProperty("vertex", "z");
	result = result && (m_hasFaces || m_hasEdges);

	return result;
}

template <class M>
void* SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::beginVertices(
	const std::string& elementName,
	size_t vertexCount)
{
	m_vertexData.overrun1 = 0l;
	m_vertexData.overrun2 = 0l;
	return &m_vertexData;
}

template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::processVertex(const std::string& elementName)
{
	typename M::VertexType vertex(SurgSim::Math::Vector3d(m_vertexData.x, m_vertexData.y, m_vertexData.z));
	m_mesh->addVertex(vertex);
}

template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::endVertices(const std::string& elementName)
{
	SURGSIM_ASSERT(m_vertexData.overrun1 == 0l && m_vertexData.overrun2 == 0l) <<
			"There was an overrun while reading the vertex structures, it is likely that data " <<
			"has become corrupted.";
}

template <class M>
void* SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::beginFaces(
	const std::string& elementName,
	size_t faceCount)
{
	m_listData.overrun = 0l;
	return &m_listData;
}

template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::processFace(const std::string& elementName)
{
	SURGSIM_ASSERT(m_listData.count == 3) << "Can only process triangle meshes.";
	std::copy(m_listData.indices, m_listData.indices + 3, m_face.begin());

	typename M::TriangleType triangle(m_face);
	m_mesh->addTriangle(triangle);
}

template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::endFaces(const std::string& elementName)
{
	SURGSIM_ASSERT(m_listData.overrun == 0l)
			<< "There was an overrun while reading the face structures, it is likely that data "
			<< "has become corrupted.";
}

template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::endFile()
{
	m_mesh->update();
}

template <class M>
bool SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::hasTextureCoordinates()
{
	return m_hasTextureCoordinates;
}

template <class M>
void* SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::beginEdges(const std::string& elementName,
		size_t edgeCount)
{
	m_listData.overrun = 0l;
	return &m_listData;
}


template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::processEdge(const std::string& elementName)
{
	SURGSIM_ASSERT(m_listData.count == 2) << "Edges have to have 2 points.";
	std::copy(m_listData.indices, m_listData.indices + 2, m_edge.begin());

	typename M::EdgeType edge(m_edge);
	m_mesh->addEdge(edge);
}


template <class M>
void SurgSim::DataStructures::TriangleMeshPlyReaderDelegate<M>::endEdges(const std::string& elementName)
{
	SURGSIM_ASSERT(m_listData.overrun == 0l)
			<< "There was an overrun while reading the face structures, it is likely that data "
			<< "has become corrupted.";
}


#endif