unittests_trimesh_vec2i.cc 1.93 KB
Newer Older
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
#include <gtest/gtest.h>
#include <Unittests/unittests_common.hh>

#include <iostream>

struct CustomTraitsVec2i : OpenMesh::DefaultTraits
{
    typedef OpenMesh::Vec2i Point;
};


typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraitsVec2i> TriMeshVec2i;


/*
 * OpenMesh Triangular with Vec2i
 */

class OpenMeshBaseTriVec2i : public testing::Test {

    protected:

        // This function is called before each test is run
        virtual void SetUp() {

            // Do some initial stuff with the member data here...
        }

        // This function is called after all tests are through
        virtual void TearDown() {

            // Do some final stuff with the member data here...
        }

    // This member will be accessible in all tests
   TriMeshVec2i mesh_;
};


namespace {

/*
 * ====================================================================
 * Define tests below
 * ====================================================================
 */

/*
 * Checking for feature edges based on angle
 */
TEST_F(OpenMeshBaseTriVec2i, Instance_Vec2i_Mesh) {

  mesh_.clear();

  // Add some vertices
  TriMeshVec2i::VertexHandle vhandle[4];

  vhandle[0] = mesh_.add_vertex(TriMeshVec2i::Point(0, 0));
  vhandle[1] = mesh_.add_vertex(TriMeshVec2i::Point(0, 1));
  vhandle[2] = mesh_.add_vertex(TriMeshVec2i::Point(1, 1));

  // Add face
  std::vector<TriMeshVec2i::VertexHandle> face_vhandles;

  face_vhandles.push_back(vhandle[0]);
  face_vhandles.push_back(vhandle[1]);
  face_vhandles.push_back(vhandle[2]);
  mesh_.add_face(face_vhandles);

  // ===============================================
  // Setup complete
  // ===============================================

  // Check one Request only vertex normals
  // Face normals are required for vertex and halfedge normals, so 
  // that prevent access to non existing properties are in place

  mesh_.request_vertex_normals();
  mesh_.request_halfedge_normals();
  mesh_.request_face_normals();

}

}