43 #ifndef GEOMETRYKERNEL_HH_
44 #define GEOMETRYKERNEL_HH_
48 #include "../Geometry/VectorT.hh"
49 #include "TopologyKernel.hh"
51 namespace OpenVolumeMesh {
53 template <
class VecT,
class TopologyKernelT = TopologyKernel>
58 typedef TopologyKernelT KernelT;
73 vertices_.push_back(_p);
82 assert(_vh.idx() < (int)vertices_.size());
84 vertices_[_vh.idx()] = _p;
89 return vertices_[_vh.idx()];
95 VertexIter nV = TopologyKernelT::delete_vertex(_h);
97 vertices_.erase(vertices_.begin() + _h.idx());
104 virtual void delete_multiple_vertices(
const std::vector<bool>& _tag) {
106 assert(_tag.size() == TopologyKernelT::n_vertices());
108 std::vector<VecT> newVertices;
110 typename std::vector<VecT>::const_iterator v_it = vertices_.begin();
112 for(std::vector<bool>::const_iterator t_it = _tag.begin(),
113 t_end = _tag.end(); t_it != t_end; ++t_it, ++v_it) {
118 newVertices.push_back(*v_it);
123 vertices_.swap(newVertices);
125 TopologyKernelT::delete_multiple_vertices(_tag);
130 virtual void clear(
bool _clearProps =
true) {
133 TopologyKernelT::clear(_clearProps);
136 typename PointT::value_type length(
const EdgeHandle& _eh)
const {
138 const typename TopologyKernelT::Edge& e = TopologyKernelT::edge(_eh);
139 return (
vertex(e.to_vertex()) -
vertex(e.from_vertex())).length();
142 PointT vector(
const EdgeHandle& _eh)
const {
144 const typename TopologyKernelT::Edge& e = TopologyKernelT::edge(_eh);
145 return (
vertex(e.to_vertex()) -
vertex(e.from_vertex()));
148 PointT barycenter(
const EdgeHandle& _eh)
const {
149 return PointT(0.5 *
vertex(TopologyKernelT::edge(_eh).from_vertex()) +
150 0.5 *
vertex(TopologyKernelT::edge(_eh).to_vertex()));
153 PointT barycenter(
const FaceHandle& _fh)
const {
154 PointT p(
typename PointT::value_type(0));
155 typename PointT::value_type valence = 0;
156 HalfFaceVertexIter hfv_it =
157 TopologyKernelT::hfv_iter(TopologyKernelT::halfface_handle(_fh, 0));
158 for(; hfv_it.valid(); ++hfv_it, valence += 1) {
165 PointT barycenter(
const CellHandle& _ch)
const {
166 PointT p(
typename PointT::value_type(0));
167 typename PointT::value_type valence = 0;
168 CellVertexIter cv_it = TopologyKernelT::cv_iter(_ch);
169 for(; cv_it.valid(); ++cv_it, valence += 1) {
176 void clone_vertices(std::vector<VecT>& _copy)
const {
178 _copy.reserve(vertices_.size());
179 std::copy(vertices_.begin(), vertices_.end(), std::back_inserter(_copy));
182 void swap_vertices(std::vector<VecT>& _copy) {
183 if(_copy.size() != vertices_.size()) {
184 std::cerr <<
"Vertex vectors differ in size!" << std::endl;
187 std::swap(vertices_, _copy);
192 std::vector<VecT> vertices_;