MOAB: Mesh Oriented datABase
(version 5.4.1)
|
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 /*! 00028 \file LaplacianSmoother.cpp 00029 \brief 00030 00031 The LaplacianSmoother Class is the concrete class 00032 that performs Laplacian Smoothing 00033 00034 \author Thomas Leurent 00035 \date 2002-01-17 00036 */ 00037 00038 #include "LaplacianSmoother.hpp" 00039 #include "PatchData.hpp" 00040 #include "MsqVertex.hpp" 00041 00042 namespace MBMesquite 00043 { 00044 00045 std::string LaplacianSmoother::get_name() const 00046 { 00047 return "LaplacianSmoother"; 00048 } 00049 00050 LaplacianSmoother::~LaplacianSmoother() {} 00051 00052 void LaplacianSmoother::optimize_vertex_positions( PatchData& pd, MsqError& err ) 00053 { 00054 assert( pd.num_free_vertices() == 1 ); 00055 const size_t center_vtx_index = 0; 00056 00057 adjVtxList.clear(); 00058 pd.get_adjacent_vertex_indices( center_vtx_index, adjVtxList, err );MSQ_ERRRTN( err ); 00059 00060 if( adjVtxList.empty() ) return; 00061 00062 const MsqVertex* verts = pd.get_vertex_array( err ); 00063 const size_t n = adjVtxList.size(); 00064 00065 Vector3D new_pos = verts[adjVtxList[0]]; 00066 for( size_t i = 1; i < n; ++i ) 00067 new_pos += verts[adjVtxList[i]]; 00068 new_pos *= 1.0 / n; 00069 pd.set_vertex_coordinates( new_pos, center_vtx_index, err ); 00070 pd.snap_vertex_to_domain( center_vtx_index, err );MSQ_ERRRTN( err ); 00071 } 00072 00073 } // namespace MBMesquite