HarmonicExampleT.hh 6.18 KB
Newer Older
Henrik Zimmer's avatar
Henrik Zimmer committed
1 2
/*===========================================================================*\
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
3
 *                          Plugin-HarmonicExample                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
4 5 6 7
 *      Copyright (C) 2008-2009 by Computer Graphics Group, RWTH Aachen      *
 *                           www.rwth-graphics.de                            *
 *                                                                           *
 *---------------------------------------------------------------------------* 
Henrik Zimmer's avatar
Henrik Zimmer committed
8
 *  This file is part of Plugin-HarmonicExample                              *
Henrik Zimmer's avatar
Henrik Zimmer committed
9
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
10 11 12 13
 *  Plugin-HarmonicExample is free software: you can redistribute it and/or  *
 *  modify it under the terms of the GNU General Public License as published *
 *  by the Free Software Foundation, either version 3 of the License, or     *
 *  (at your option) any later version.                                      *
Henrik Zimmer's avatar
Henrik Zimmer committed
14
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
15
 *  Plugin-HarmonicExample is distributed in the hope that it will be useful,*
Henrik Zimmer's avatar
Henrik Zimmer committed
16 17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
Henrik Zimmer's avatar
Henrik Zimmer committed
18
 *  GNU General Public License for more details.                             *
Henrik Zimmer's avatar
Henrik Zimmer committed
19
 *                                                                           *
Henrik Zimmer's avatar
Henrik Zimmer committed
20 21 22
 *  You should have received a copy of the GNU General Public License        *
 *  along with Plugin-HarmonicExample.                                       *
 *  If not, see <http://www.gnu.org/licenses/>.                              *
Henrik Zimmer's avatar
Henrik Zimmer committed
23 24 25
 *                                                                           *
\*===========================================================================*/ 

26 27 28 29 30 31 32
//=============================================================================
//
//  CLASS HarmonicExampleT
//
//=============================================================================


33 34
#ifndef COMISO_HARMONICEXAMPLET_HH
#define COMISO_HARMONICEXAMPLET_HH
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52


//== INCLUDES =================================================================
#include <gmm/gmm.h>

#include <OpenMesh/Core/Utils/Property.hh>
#include <OpenMesh/Core/System/omstream.hh>

#include <vector>
#include <string>
#include <iostream>
#include <cfloat> //for FLT_{MIN, MAX}
#include <CoMISo/Utils/StopWatch.hh>
#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <CoMISo/Solver/GMM_Tools.hh>
#include <OpenMesh/Core/Geometry/VectorT.hh>
#include <CoMISo/Solver/ConstrainedSolver.hh>
Henrik Zimmer's avatar
Henrik Zimmer committed
53
#include "ColorCoder.hh"
54 55 56 57 58

//== FORWARDDECLARATIONS ======================================================

//== NAMESPACES ===============================================================

59
namespace COMISO {
60 61 62 63 64

//== CLASS DEFINITION =========================================================


	      
65
/** \class HarmonicExampleT HarmonicExampleT.hh <COMISO/.../HarmonicExampleT.hh>
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

    Brief Description.
  
    A more elaborate description follows.
*/

template <class MeshT>
class HarmonicExampleT
{
public:

  typedef typename MeshT::Scalar         Scalar;
	typedef typename MeshT::Point          Point;
	typedef typename OpenMesh::Vec2d      Vec2d;
	typedef typename MeshT::VertexHandle   VH;
	typedef typename MeshT::FaceHandle     FH;
	typedef typename MeshT::EdgeHandle     EH;
	typedef typename MeshT::HalfedgeHandle HEH;
	typedef typename MeshT::FaceIter				FIter;
	typedef typename MeshT::EdgeIter				EIter;
	typedef typename MeshT::VertexIter			VIter;
	typedef typename MeshT::HalfedgeIter		HIter;
	typedef typename MeshT::FaceFaceIter	FFIter;
	typedef typename MeshT::FaceVertexIter	FVIter;
	typedef typename MeshT::VertexFaceIter	VFIter;
	typedef typename MeshT::VertexEdgeIter	VEIter;
	typedef typename MeshT::FaceHalfedgeIter FHIter;
	typedef typename MeshT::VertexOHalfedgeIter VOHIter;
	typedef typename MeshT::VertexIHalfedgeIter VIHIter;
	typedef typename MeshT::TexCoord2D			TexCoord2D;
	typedef unsigned int uint;
	typedef typename gmm::linalg_traits< gmm::rsvector< Scalar > > GMMRSTRAIT;
	typedef typename gmm::linalg_traits< gmm::wsvector< Scalar > > GMMWSTRAIT;
	typedef typename GMMRSTRAIT::iterator GMMColIter;
	typedef typename GMMWSTRAIT::iterator wGMMColIter;

  typedef typename gmm::wsvector< double > SVectorT;
  typedef gmm::linalg_traits<SVectorT>::const_iterator SVIter;
  typedef typename gmm::col_matrix< gmm::wsvector< Scalar > > CMatrixT;
  typedef typename gmm::row_matrix< gmm::wsvector< Scalar > > RMatrixT;
  typedef typename std::vector< Scalar > VectorT;
  typedef typename std::vector< int >    VectorIT;
  typedef gmm::dense_matrix<Scalar>      DenseMatrix;
  typedef gmm::csc_matrix<double>        CSCMatrix;
110
  //  typedef COMISO::MCSCMatrix                MCSCMatrix;
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

 

  /// Constructor
  HarmonicExampleT( MeshT& _mesh) : mesh_(_mesh)
  {}
 
  /// Destructor
  ~HarmonicExampleT() {}

  void compute();

private:

  // create a simple connectivity-based laplace matrix
  void init_laplace_matrix();

  int  add_laplace_row( VH _vh, int _row);
  void add_integer_constraints();

  /// adds some constraints to the laplace system.
  /// The vertices of each boundary are constrained to the same value. 
  /// The different boundaries are constrained to differ by e.g. 5
  int  add_boundary_constraints();
  
  void color_mesh();

  // laplace matrix 
  CMatrixT laplace_;

  // solution
  std::vector< double > x_;
  
  // right hand side
  std::vector< double > rhs_;

  // constraints
  RMatrixT constraints_;

  // integer constraints (indices of variables to be rounded)
  std::vector< int > ids_to_round_;

  MeshT& mesh_;
};


//=============================================================================
158
} // namespace COMISO
159
//=============================================================================
160 161
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_HARMONICEXAMPLET_C)
#define COMISO_HARMONICEXAMPLE_TEMPLATES
162 163 164
#include "HarmonicExampleT.cc"
#endif
//=============================================================================
165
#endif // COMISO_HARMONICEXAMPLET_HH defined
166 167
//=============================================================================