MOAB: Mesh Oriented datABase  (version 5.4.1)
MsqFreeVertexIndexIteratorTest.cpp
Go to the documentation of this file.
00001 /* *****************************************************************
00002     MESQUITE -- The Mesh Quality Improvement Toolkit
00003 
00004     Copyright 2004 Sandia Corporation and Argonne National
00005     Laboratory.  Under the terms of Contract DE-AC04-94AL85000
00006     with Sandia Corporation, the U.S. Government retains certain
00007     rights in this software.
00008 
00009     This library is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU Lesser General Public
00011     License as published by the Free Software Foundation; either
00012     version 2.1 of the License, or (at your option) any later version.
00013 
00014     This library is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017     Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     (lgpl.txt) along with this library; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 
00023     [email protected], [email protected], [email protected],
00024     [email protected], [email protected], [email protected]
00025 
00026   ***************************************************************** */
00027 // -*- Mode : c++; tab-width: 3; c-tab-always-indent: t; indent-tabs-mode: nil; c-basic-offset: 3
00028 // -*-
00029 //
00030 //   SUMMARY:
00031 //     USAGE:
00032 //
00033 //    AUTHOR: Thomas Leurent <[email protected]>
00034 //       ORG: Argonne National Laboratory
00035 //    E-MAIL: [email protected]
00036 //
00037 // ORIG-DATE: 12-Nov-02 at 18:05:56
00038 //  LAST-MOD:  5-May-03 at 15:59:29 by Thomas Leurent
00039 //
00040 // DESCRIPTION:
00041 // ============
00042 /*! \file MsqFreeVertexIndexIteratorTest.cpp
00043 
00044 Unit testing of various functions in the MsqFreeVertexIndexIterator class.
00045 
00046  */
00047 // DESCRIP-END.
00048 //
00049 
00050 #include "MsqFreeVertexIndexIterator.hpp"
00051 #include "PatchDataInstances.hpp"
00052 
00053 #include <cmath>
00054 #include <iostream>
00055 
00056 #include "cppunit/extensions/HelperMacros.h"
00057 
00058 using namespace MBMesquite;
00059 using std::cerr;
00060 using std::cout;
00061 using std::endl;
00062 
00063 class MsqFreeVertexIndexIteratorTest : public CppUnit::TestFixture
00064 {
00065 
00066   private:
00067     CPPUNIT_TEST_SUITE( MsqFreeVertexIndexIteratorTest );
00068     CPPUNIT_TEST( test_hard_fixed_flags );
00069     CPPUNIT_TEST( test_soft_fixed_flags );
00070     CPPUNIT_TEST_SUITE_END();
00071 
00072   private:
00073     PatchData pd;
00074 
00075   public:
00076     void setUp()
00077     {
00078         MsqPrintError err( cout );
00079 
00080         /*      7____6____5___11
00081                 |    |    |    |
00082                 | 2  |  3 | 5  |
00083                 8-_  |  _-4---10       vertex 1 is at (0,0)
00084                 |  -_0_-  |    |       vertex 11 is at (3,2)
00085                 | 0  |  1 | 4  |
00086                 1----2----3----9
00087         */
00088         create_six_quads_patch_with_domain( pd, err );
00089     }
00090 
00091     void tearDown()
00092     {
00093         destroy_patch_with_domain( pd );
00094     }
00095 
00096   public:
00097     MsqFreeVertexIndexIteratorTest() {}
00098 
00099     void test_hard_fixed_flags()
00100     {
00101         MsqPrintError err( cout );
00102         int indices[10];
00103         int i = 0;
00104         MsqFreeVertexIndexIterator ind( pd, err );
00105         ind.reset();
00106         while( ind.next() )
00107         {
00108             indices[i] = ind.value();
00109             //         cout << i << "th free vertex value: " << ind.value() << endl;
00110             ++i;
00111         }
00112 
00113         CPPUNIT_ASSERT( i == 2 );  // number of free vertices.
00114         CPPUNIT_ASSERT( pd.vertex_by_index( indices[0] ).is_free_vertex() );
00115         CPPUNIT_ASSERT( pd.vertex_by_index( indices[1] ).is_free_vertex() );
00116     }
00117 
00118     void test_soft_fixed_flags()
00119     {
00120         MsqPrintError err( cout );
00121         pd.set_vertex_culled( 0 );
00122 
00123         int indices[10];
00124         int i = 0;
00125         MsqFreeVertexIndexIterator ind( pd, err );
00126         ind.reset();
00127         while( ind.next() )
00128         {
00129             indices[i] = ind.value();
00130             ++i;
00131         }
00132 
00133         CPPUNIT_ASSERT( i == 1 );  // number of free vertices.
00134         CPPUNIT_ASSERT( pd.vertex_by_index( indices[0] ).is_free_vertex() );
00135     }
00136 };
00137 
00138 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MsqFreeVertexIndexIteratorTest, "MsqFreeVertexIndexIteratorTest" );
00139 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( MsqFreeVertexIndexIteratorTest, "Unit" );
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines