MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 /* ***************************************************************** 00002 MESQUITE -- The Mesh Quality Improvement Toolkit 00003 00004 Copyright 2006 Lawrence Livermore National Laboratory. Under 00005 the terms of Contract B545069 with the University of Wisconsin -- 00006 Madison, Lawrence Livermore National Laboratory 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 (2006) [email protected] 00024 00025 ***************************************************************** */ 00026 00027 /** \file TagVertexMesh.hpp 00028 * \brief Definition of MBMesquite::TagVertexMesh class 00029 * \author Jason Kraftcheck 00030 */ 00031 00032 #ifndef MSQ_TAG_VERTEX_MESH_HPP 00033 #define MSQ_TAG_VERTEX_MESH_HPP 00034 00035 #include "Mesquite.hpp" 00036 #include "MeshDecorator.hpp" 00037 #include "Instruction.hpp" 00038 00039 namespace MBMesquite 00040 { 00041 00042 /**\brief Store alternate vertex coordinates in tags. 00043 * 00044 * This class implements a decorator pattern for the MBMesquite::Mesh 00045 * interface where alternate vertex coordinates are stored in a tag 00046 * on the original mesh. The vertex coordinates are the same as that 00047 * of the decorated Mesh interface until they are set. Once the coorindates 00048 * of a vertex are set using an instance of this class, the modified 00049 * vertex coordinates will be stored in a tag and returned from subsequent 00050 * queries of the vertex coordinates through this interface. 00051 * 00052 * The tag used to store alternate vertex coordinates is created and set 00053 * for all vertices when the coordinates of the any vertex are changed. 00054 * The tag type is a vector of three doubles. 00055 * 00056 * Inserting an instance of this class into an InstructionQueue will result 00057 * in true vertex coordinates being copied into the alternate coordinate 00058 * values maintained by this class at that point in the instruction queue. 00059 */ 00060 class MESQUITE_EXPORT TagVertexMesh : public MeshDecorator, public Instruction 00061 { 00062 private: 00063 std::string tagName; //< Name of tag storing vertex coordinates 00064 TagHandle tagHandle; //< Handle of tag storing vertex coordinates 00065 bool haveTagHandle; //< True if tagHandle is set 00066 bool cleanUpTag; //< If true, destroy tag in destructor 00067 00068 /**\brief common code for constructor, set_mesh, and set_tag_name */ 00069 void initialize( Mesh* mesh, std::string name, MsqError& ); 00070 /**\brief copy real coordinate values into tag data */ 00071 void copy_all_coordinates( MsqError& err ); 00072 /**\brief if cleanUpTag, delete tag and clear handle */ 00073 void check_remove_tag( MsqError& err ); 00074 00075 public: 00076 /** 00077 *\param real_mesh The mesh from which to aquire topology information 00078 * and vertex coordinates, and upon which to store 00079 * tags. 00080 *\param clean_up_tag_data If true, tag storing alternate vertex 00081 * coordinates will be removed when this object 00082 * is destroyed. 00083 *\param tag_name Name of tag in which to store alternate vertex coordinates. 00084 */ 00085 TagVertexMesh( MsqError& err, Mesh* real_mesh, bool clean_up_tag_data = true, std::string tag_name = "" ); 00086 00087 /** Destroy tag data for alternate coordinates if 00088 * clean_up_tag_data is true. 00089 */ 00090 virtual ~TagVertexMesh(); 00091 00092 /**\brief Change the Mesh instance used as the real mesh. 00093 * 00094 * Change the Mesh instance orignially specified in the 00095 * constructor. 00096 * Note: Calling this function changes the handle space for 00097 * mesh entities, invalidating any previous handle values, 00098 * iterators, etc. returned by the class instance. 00099 * Note: If clean_up_tag_data is true, calling this function 00100 * will remove any stored alternate vertex coordinates 00101 * from the previous mesh. 00102 */ 00103 void set_mesh( Mesh* real_mesh, MsqError& err ); 00104 00105 /**\brief Set tag cleanup behavior 00106 * 00107 * If true, class will remove any tag data storing alternate 00108 * vertex coordinates from the real mesh when a) the real Mesh 00109 * instance is changed or b) this object instance is destroted. 00110 */ 00111 void should_clean_up_tag_data( bool value ) 00112 { 00113 cleanUpTag = value; 00114 } 00115 00116 /**\brief Will tag storing alternate coordinates be destroyed. */ 00117 bool will_clean_up_tag_data() const 00118 { 00119 return cleanUpTag; 00120 } 00121 00122 /**\brief Get name of tag used to store alternate vertex coordinates. */ 00123 std::string get_tag_name() const 00124 { 00125 return tagName; 00126 } 00127 00128 /**\brief Set tag name used to store alternate vertex coordinates 00129 * 00130 * Change the tag name used to store alternate vertex coordinates. 00131 * Note: Changing the tag name will result in the loss of any 00132 * alternate vertex coordinates saved using the previous 00133 * tag name. 00134 * Note: If clean_up_tag_data is true, calling this function 00135 * will result in the removal of the previous tag and 00136 * any coordinates stored using that tag. 00137 *\param init If the new tag already exists, any 00138 * coordinates stored in that tag will be used if this 00139 * argument is false. If this argument is true, the 00140 * alternate coordinate values will be initialized to 00141 * the true coordinate values in the real Mesh. 00142 */ 00143 void set_tag_name( std::string name, MsqError& err ); 00144 00145 /**\brief clear all alternate vertex coordinate values 00146 * 00147 * Clear all alternate vertex coordinate values and 00148 * revert to coordinates as stored in real mesh. 00149 */ 00150 void clear( MsqError& err ); 00151 00152 virtual void vertices_get_coordinates( const VertexHandle vert_array[], 00153 MsqVertex* coordinates, 00154 size_t num_vtx, 00155 MsqError& err ); 00156 00157 virtual void vertex_set_coordinates( VertexHandle vertex, const Vector3D& coordinates, MsqError& err ); 00158 00159 //*************** Tags *********** 00160 00161 virtual TagHandle tag_create( const std::string& tag_name, 00162 TagType type, 00163 unsigned length, 00164 const void* default_value, 00165 MsqError& err ); 00166 00167 virtual TagHandle tag_get( const std::string& name, MsqError& err ); 00168 00169 //**************** Memory Management **************** 00170 00171 virtual void release(); 00172 00173 //**************** Instruction **************** 00174 00175 virtual double loop_over_mesh( MeshDomainAssoc* mesh_and_domain, const Settings* settings, MsqError& err ); 00176 00177 virtual std::string get_name() const; 00178 00179 //!\brief Called at start of instruction queue processing 00180 //! 00181 //! Do any preliminary global initialization, consistency checking, 00182 //! etc. Default implementation does nothing. 00183 virtual void initialize_queue( MeshDomainAssoc* mesh_and_domain, const Settings* settings, MsqError& err ); 00184 }; 00185 00186 } // namespace MBMesquite 00187 00188 #endif