5 #ifndef BALL_MATHS_SURFACE_H
6 #define BALL_MATHS_SURFACE_H
8 #ifndef BALL_MATHS_VECTOR3_H
48 return (v1 == triangle.
v1) && (v2 == triangle.
v2) && (v3 == triangle.
v3);
54 return !(v1 == triangle.
v1) && (v2 == triangle.
v2) && (v3 == triangle.
v3);
197 #ifdef BALL_COMPILER_MSVC
201 template <
typename T>
206 template <
typename T>
208 : vertex(surface.vertex),
209 normal(surface.normal),
210 triangle(surface.triangle)
214 template <
typename T>
219 template <
typename T>
227 template <
typename T>
235 template <
typename T>
244 template <
typename T>
252 template <
typename T>
260 std::ifstream file(vert_filename.
c_str());
279 vertex.push_back(
Vertex(s[0].toFloat(), s[1].toFloat(), s[2].toFloat()));
280 normal.push_back(
Normal(s[3].toFloat(), s[4].toFloat(), s[5].toFloat()));
290 file.open(face_filename.
c_str());
304 Size number_of_vertices = (
Size)vertex.size();
309 t.
v1 = (
Index)s[0].toInt() - 1;
310 t.
v2 = (
Index)s[1].toInt() - 1;
311 t.
v3 = (
Index)s[2].toInt() - 1;
314 if ((t.
v1 < (
Index)number_of_vertices) && (t.
v1 >= 0)
315 && (t.
v1 < (
Index)number_of_vertices) && (t.
v1 >= 0)
316 && (t.
v1 < (
Index)number_of_vertices) && (t.
v1 >= 0))
327 template <
typename T>
332 for (
Size i = 0; i < triangle.size(); i++)
336 area += ((vertex[triangle[i].v2] - vertex[triangle[i].v1]) % (vertex[triangle[i].v3] - vertex[triangle[i].v1])).getLength();
340 return (
float)( area * 0.5 );
343 template <
typename T>
346 return ((surface.
vertex == vertex)
347 && (surface.
normal == normal)
351 template <
typename T>
355 return (
Size)triangle.size();
358 template <
typename T>
362 return (
Size)vertex.size();
365 template <
typename T>
369 return (
Size)normal.size();
372 template <
typename T>
376 return triangle[index];
379 template <
typename T>
383 return triangle[index];
386 template <
typename T>
393 template <
typename T>
397 triangle.resize(size);
400 template <
typename T>
404 triangle.push_back(t);
408 template <
typename T>
412 return vertex[index];
415 template <
typename T>
419 return vertex[index];
422 template <
typename T>
429 template <
typename T>
437 template <
typename T>
441 vertex.push_back(position);
444 template <
typename T>
448 return normal[index];
451 template <
typename T>
455 return normal[index];
458 template <
typename T>
465 template <
typename T>
472 template <
typename T>
479 template <
typename T>
482 return !(*
this == surface);
492 #endif // BALL_MATHS_SURFACE_H
Size getNumberOfVertices() const
Return the number of vertices.
#define BALL_CREATE(name)
void resizeVertices(Size size)
Resize the vertex array.
Size getNumberOfNormals() const
Return the number of normals.
TVector3< T > Normal
A normal.
void pushBackNormal(const Normal &n)
Add a normal.
void clearVertices()
Clear all vertices.
TSurface< float > Surface
Size countFields(const char *delimiters=CHARACTER_CLASS__WHITESPACE) const
std::istream & getline(std::istream &s=std::cin, char delimiter= '\n')
TSurface & operator=(const TSurface &surface)
vector< Normal > normal
the normals for each vertex
Size split(String string_array[], Size array_size, const char *delimiters=CHARACTER_CLASS__WHITESPACE, Index from=0) const
Triangle & getTriangle(Position index)
Return a triangle with a given index.
Normal & getNormal(Position index)
Return the position of a normal.
const char * c_str() const BALL_NOEXCEPT
void clearTriangles()
Clear all triangles.
void clearNormals()
Clear all normals.
TVector3< T > Vertex
A vertex.
void pushBackTriangle(const Triangle &triangle)
Add a triangle.
void readMSMSFile(const String &vert_filename, const String &face_filename)
vector< Vertex > vertex
the vertices
void get(TSurface &surface) const
vector< Triangle > triangle
the triangles
bool operator!=(const TSurface &surface) const
void resizeNormals(Size size)
Resize the normal array.
Vertex & getVertex(Position index)
Return the position of a vertex.
void pushBackVertex(const Vertex &vertex)
Add a vertex.
Size getNumberOfTriangles() const
Return the number of triangles.
void resizeTriangles(Size size)
Resize the triangle array.
void set(const TSurface &surface)
bool operator==(const TSurface &surface) const