Include header cleaning and reordering.
This commit is contained in:
parent
d4eb599a66
commit
84c80a1972
|
|
@ -1,46 +1,64 @@
|
||||||
|
/****************************************************************************
|
||||||
|
* VCGLib o o *
|
||||||
|
* Visual and Computer Graphics Library o o *
|
||||||
|
* _ O _ *
|
||||||
|
* Copyright(C) 2004-2012 \/)\/ *
|
||||||
|
* Visual Computing Lab /\/| *
|
||||||
|
* ISTI - Italian National Research Council | *
|
||||||
|
* \ *
|
||||||
|
* All rights reserved. *
|
||||||
|
* *
|
||||||
|
* This program 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 2 of the License, or *
|
||||||
|
* (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* This program is distributed in the hope that it will be useful, *
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||||
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||||
|
* for more details. *
|
||||||
|
* *
|
||||||
|
****************************************************************************/
|
||||||
#ifndef VCG_TRI_ATTRIBUTE_SEAM_H
|
#ifndef VCG_TRI_ATTRIBUTE_SEAM_H
|
||||||
#define VCG_TRI_ATTRIBUTE_SEAM_H
|
#define VCG_TRI_ATTRIBUTE_SEAM_H
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <vcg/complex/allocate.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
// sample extract functor
|
// sample extract functor
|
||||||
void v_extract(const src_mesh_t & wm, const src_face_t & f, int k, const dst_mesh_t & vm, dst_vertex_t & v)
|
void v_extract(const src_mesh_t & wm, const src_face_t & f, int k, const dst_mesh_t & vm, dst_vertex_t & v)
|
||||||
{
|
{
|
||||||
(void)wm;
|
(void)wm;
|
||||||
(void)vm;
|
(void)vm;
|
||||||
|
|
||||||
v.P() = f.cP (k);
|
v.P() = f.cP (k);
|
||||||
v.N() = f.cWN(k);
|
v.N() = f.cWN(k);
|
||||||
v.C() = f.cWC(k);
|
v.C() = f.cWC(k);
|
||||||
v.T() = f.cWT(k);
|
v.T() = f.cWT(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sample compare functor
|
// sample compare functor
|
||||||
bool v_compare(const dst_mesh_t & vm, const dst_vertex_t & u, const dst_vertex_t & v)
|
bool v_compare(const dst_mesh_t & vm, const dst_vertex_t & u, const dst_vertex_t & v)
|
||||||
{
|
{
|
||||||
(void)vm;
|
(void)vm;
|
||||||
|
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
(u.cN() == v.cN())
|
(u.cN() == v.cN())
|
||||||
&& (u.cC() == v.cC())
|
&& (u.cC() == v.cC())
|
||||||
&& (u.cT() == v.cT())
|
&& (u.cT() == v.cT())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sample copy functor
|
// sample copy functor
|
||||||
void v_copy(const dst_mesh_t & vm, const dst_vertex_t & u, dst_vertex_t & v)
|
void v_copy(const dst_mesh_t & vm, const dst_vertex_t & u, dst_vertex_t & v)
|
||||||
{
|
{
|
||||||
(void)vm;
|
(void)vm;
|
||||||
|
|
||||||
v.P() = u.cP();
|
v.P() = u.cP();
|
||||||
v.N() = u.cN();
|
v.N() = u.cN();
|
||||||
v.C() = u.cC();
|
v.C() = u.cC();
|
||||||
v.T() = u.cT();
|
v.T() = u.cT();
|
||||||
}
|
}
|
||||||
|
|
||||||
// create seams
|
// create seams
|
||||||
|
|
@ -56,310 +74,310 @@ namespace tri
|
||||||
|
|
||||||
class AttributeSeam
|
class AttributeSeam
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef AttributeSeam ThisType;
|
typedef AttributeSeam ThisType;
|
||||||
|
|
||||||
enum ASMask
|
enum ASMask
|
||||||
{
|
{
|
||||||
POSITION_PER_VERTEX = (1 << 0),
|
POSITION_PER_VERTEX = (1 << 0),
|
||||||
|
|
||||||
NORMAL_PER_VERTEX = (1 << 1),
|
NORMAL_PER_VERTEX = (1 << 1),
|
||||||
NORMAL_PER_WEDGE = (1 << 2),
|
NORMAL_PER_WEDGE = (1 << 2),
|
||||||
NORMAL_PER_FACE = (1 << 3),
|
NORMAL_PER_FACE = (1 << 3),
|
||||||
|
|
||||||
COLOR_PER_VERTEX = (1 << 4),
|
COLOR_PER_VERTEX = (1 << 4),
|
||||||
COLOR_PER_WEDGE = (1 << 5),
|
COLOR_PER_WEDGE = (1 << 5),
|
||||||
COLOR_PER_FACE = (1 << 6),
|
COLOR_PER_FACE = (1 << 6),
|
||||||
|
|
||||||
TEXCOORD_PER_VERTEX = (1 << 7),
|
TEXCOORD_PER_VERTEX = (1 << 7),
|
||||||
TEXCOORD_PER_WEDGE = (1 << 8)
|
TEXCOORD_PER_WEDGE = (1 << 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename src_trimesh_t, typename dst_trimesh_t>
|
template <typename src_trimesh_t, typename dst_trimesh_t>
|
||||||
struct ASExtract
|
struct ASExtract
|
||||||
{
|
{
|
||||||
const unsigned int mask;
|
const unsigned int mask;
|
||||||
|
|
||||||
ASExtract(unsigned int vmask = 0) : mask(vmask)
|
ASExtract(unsigned int vmask = 0) : mask(vmask)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator () (const src_trimesh_t & sm, const typename src_trimesh_t::FaceType & f, int k, const dst_trimesh_t & dm, typename dst_trimesh_t::VertexType & v) const
|
void operator () (const src_trimesh_t & sm, const typename src_trimesh_t::FaceType & f, int k, const dst_trimesh_t & dm, typename dst_trimesh_t::VertexType & v) const
|
||||||
{
|
{
|
||||||
(void)sm;
|
(void)sm;
|
||||||
(void)dm;
|
(void)dm;
|
||||||
|
|
||||||
const unsigned int m = this->mask;
|
const unsigned int m = this->mask;
|
||||||
const typename src_trimesh_t::VertexType & u = *(f.cV(k));
|
const typename src_trimesh_t::VertexType & u = *(f.cV(k));
|
||||||
|
|
||||||
if ((m & AttributeSeam::POSITION_PER_VERTEX) != 0) v.P() = f.cP (k);
|
if ((m & AttributeSeam::POSITION_PER_VERTEX) != 0) v.P() = f.cP (k);
|
||||||
|
|
||||||
if ((m & AttributeSeam::NORMAL_PER_VERTEX) != 0) v.N() = u.cN ( );
|
if ((m & AttributeSeam::NORMAL_PER_VERTEX) != 0) v.N() = u.cN ( );
|
||||||
if ((m & AttributeSeam::NORMAL_PER_WEDGE) != 0) v.N() = f.cWN(k);
|
if ((m & AttributeSeam::NORMAL_PER_WEDGE) != 0) v.N() = f.cWN(k);
|
||||||
if ((m & AttributeSeam::NORMAL_PER_FACE) != 0) v.N() = f.cN ( );
|
if ((m & AttributeSeam::NORMAL_PER_FACE) != 0) v.N() = f.cN ( );
|
||||||
|
|
||||||
if ((m & AttributeSeam::COLOR_PER_VERTEX) != 0) v.C() = u.cC ( );
|
if ((m & AttributeSeam::COLOR_PER_VERTEX) != 0) v.C() = u.cC ( );
|
||||||
if ((m & AttributeSeam::COLOR_PER_WEDGE) != 0) v.C() = f.cWC(k);
|
if ((m & AttributeSeam::COLOR_PER_WEDGE) != 0) v.C() = f.cWC(k);
|
||||||
if ((m & AttributeSeam::COLOR_PER_FACE) != 0) v.C() = f.cC ( );
|
if ((m & AttributeSeam::COLOR_PER_FACE) != 0) v.C() = f.cC ( );
|
||||||
|
|
||||||
if ((m & AttributeSeam::TEXCOORD_PER_VERTEX) != 0) v.T() = u.cT ( );
|
if ((m & AttributeSeam::TEXCOORD_PER_VERTEX) != 0) v.T() = u.cT ( );
|
||||||
if ((m & AttributeSeam::TEXCOORD_PER_WEDGE) != 0) v.T() = f.cWT(k);
|
if ((m & AttributeSeam::TEXCOORD_PER_WEDGE) != 0) v.T() = f.cWT(k);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename dst_trimesh_t>
|
template <typename dst_trimesh_t>
|
||||||
struct ASCompare
|
struct ASCompare
|
||||||
{
|
{
|
||||||
const unsigned int mask;
|
const unsigned int mask;
|
||||||
|
|
||||||
ASCompare(unsigned int vmask = 0) : mask(vmask)
|
ASCompare(unsigned int vmask = 0) : mask(vmask)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator () (const dst_trimesh_t & sm, const typename dst_trimesh_t::VertexType & u, const typename dst_trimesh_t::VertexType & v) const
|
bool operator () (const dst_trimesh_t & sm, const typename dst_trimesh_t::VertexType & u, const typename dst_trimesh_t::VertexType & v) const
|
||||||
{
|
{
|
||||||
(void)sm;
|
(void)sm;
|
||||||
|
|
||||||
const unsigned int m = this->mask;
|
const unsigned int m = this->mask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ((m & (AttributeSeam::POSITION_PER_VERTEX)) != 0)
|
if ((m & (AttributeSeam::POSITION_PER_VERTEX)) != 0)
|
||||||
{
|
{
|
||||||
if (u.cP() != v.cP()) return false;
|
if (u.cP() != v.cP()) return false;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((m & (AttributeSeam::NORMAL_PER_VERTEX | AttributeSeam::NORMAL_PER_WEDGE | AttributeSeam::NORMAL_PER_FACE)) != 0)
|
if ((m & (AttributeSeam::NORMAL_PER_VERTEX | AttributeSeam::NORMAL_PER_WEDGE | AttributeSeam::NORMAL_PER_FACE)) != 0)
|
||||||
{
|
{
|
||||||
if (u.cN() != v.cN()) return false;
|
if (u.cN() != v.cN()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m & (AttributeSeam::COLOR_PER_VERTEX | AttributeSeam::COLOR_PER_WEDGE | AttributeSeam::COLOR_PER_FACE)) != 0)
|
if ((m & (AttributeSeam::COLOR_PER_VERTEX | AttributeSeam::COLOR_PER_WEDGE | AttributeSeam::COLOR_PER_FACE)) != 0)
|
||||||
{
|
{
|
||||||
if (u.cC() != v.cC()) return false;
|
if (u.cC() != v.cC()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m & (AttributeSeam::TEXCOORD_PER_VERTEX | AttributeSeam::TEXCOORD_PER_WEDGE)) != 0)
|
if ((m & (AttributeSeam::TEXCOORD_PER_VERTEX | AttributeSeam::TEXCOORD_PER_WEDGE)) != 0)
|
||||||
{
|
{
|
||||||
if (u.cT() != v.cT()) return false;
|
if (u.cT() != v.cT()) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// in-place version
|
// in-place version
|
||||||
template <typename src_trimesh_t, typename extract_wedge_attribs_t, typename compare_vertex_attribs_t>
|
template <typename src_trimesh_t, typename extract_wedge_attribs_t, typename compare_vertex_attribs_t>
|
||||||
static inline bool SplitVertex(src_trimesh_t & src, extract_wedge_attribs_t v_extract, compare_vertex_attribs_t & v_compare)
|
static inline bool SplitVertex(src_trimesh_t & src, extract_wedge_attribs_t v_extract, compare_vertex_attribs_t & v_compare)
|
||||||
{
|
{
|
||||||
typedef typename src_trimesh_t::VertexType src_vertex_t;
|
typedef typename src_trimesh_t::VertexType src_vertex_t;
|
||||||
typedef typename src_trimesh_t::VertexIterator src_vertex_i;
|
typedef typename src_trimesh_t::VertexIterator src_vertex_i;
|
||||||
typedef typename src_trimesh_t::FaceType src_face_t;
|
typedef typename src_trimesh_t::FaceType src_face_t;
|
||||||
typedef typename src_trimesh_t::FaceIterator src_face_i;
|
typedef typename src_trimesh_t::FaceIterator src_face_i;
|
||||||
typedef typename src_trimesh_t::VertContainer src_vertex_container_t;
|
typedef typename src_trimesh_t::VertContainer src_vertex_container_t;
|
||||||
|
|
||||||
typedef vcg::tri::Allocator<src_trimesh_t> src_mesh_allocator_t;
|
typedef vcg::tri::Allocator<src_trimesh_t> src_mesh_allocator_t;
|
||||||
typedef typename src_mesh_allocator_t :: template PointerUpdater<typename src_trimesh_t::VertexPointer> src_pointer_updater_t;
|
typedef typename src_mesh_allocator_t :: template PointerUpdater<typename src_trimesh_t::VertexPointer> src_pointer_updater_t;
|
||||||
|
|
||||||
if ((src.vn <= 0) || (src.fn <= 0))
|
if ((src.vn <= 0) || (src.fn <= 0))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_pointer_updater_t pt_upd;
|
src_pointer_updater_t pt_upd;
|
||||||
src_vertex_i vi = src_mesh_allocator_t::AddVertices(src, 1, pt_upd);
|
src_vertex_i vi = src_mesh_allocator_t::AddVertices(src, 1, pt_upd);
|
||||||
src_vertex_t * vtx = &(*vi);
|
src_vertex_t * vtx = &(*vi);
|
||||||
src_vertex_t * vtxbase = &(src.vert[0]);
|
src_vertex_t * vtxbase = &(src.vert[0]);
|
||||||
|
|
||||||
const size_t vertex_count = src.vert.size();
|
const size_t vertex_count = src.vert.size();
|
||||||
const size_t vertex_pool_size = vertex_count;
|
const size_t vertex_pool_size = vertex_count;
|
||||||
|
|
||||||
std::vector<int> vloc;
|
std::vector<int> vloc;
|
||||||
vloc.reserve(vertex_pool_size);
|
vloc.reserve(vertex_pool_size);
|
||||||
vloc.resize(vertex_count, -2);
|
vloc.resize(vertex_count, -2);
|
||||||
|
|
||||||
int vcount = int(src.vert.size());
|
int vcount = int(src.vert.size());
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
for (src_face_i it=src.face.begin(); it!=src.face.end(); ++it)
|
for (src_face_i it=src.face.begin(); it!=src.face.end(); ++it)
|
||||||
{
|
{
|
||||||
src_face_t & f = (*it);
|
src_face_t & f = (*it);
|
||||||
if (f.IsD()) continue;
|
if (f.IsD()) continue;
|
||||||
|
|
||||||
for (int k=0; k<3; ++k)
|
for (int k=0; k<3; ++k)
|
||||||
{
|
{
|
||||||
idx = (f.cV(k) - vtxbase);
|
idx = (f.cV(k) - vtxbase);
|
||||||
v_extract(src, f, k, src, *vtx);
|
v_extract(src, f, k, src, *vtx);
|
||||||
|
|
||||||
if (vloc[idx] == -2)
|
if (vloc[idx] == -2)
|
||||||
{
|
{
|
||||||
vloc[idx] = -1;
|
vloc[idx] = -1;
|
||||||
src.vert[idx].ImportData(*vtx);
|
src.vert[idx].ImportData(*vtx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int vidx = idx;
|
int vidx = idx;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (v_compare(src, src.vert[vidx], *vtx)) break;
|
if (v_compare(src, src.vert[vidx], *vtx)) break;
|
||||||
vidx = vloc[vidx];
|
vidx = vloc[vidx];
|
||||||
} while (vidx >= 0);
|
} while (vidx >= 0);
|
||||||
|
|
||||||
if (vidx < 0)
|
if (vidx < 0)
|
||||||
{
|
{
|
||||||
vloc.push_back(vloc[idx]);
|
vloc.push_back(vloc[idx]);
|
||||||
vloc[idx] = vcount;
|
vloc[idx] = vcount;
|
||||||
|
|
||||||
vi = src_mesh_allocator_t::AddVertices(src, 1, pt_upd);
|
vi = src_mesh_allocator_t::AddVertices(src, 1, pt_upd);
|
||||||
pt_upd.Update(vtx);
|
pt_upd.Update(vtx);
|
||||||
pt_upd.Update(vtxbase);
|
pt_upd.Update(vtxbase);
|
||||||
|
|
||||||
(*vi).ImportData(*vtx);
|
(*vi).ImportData(*vtx);
|
||||||
|
|
||||||
idx = vcount;
|
idx = vcount;
|
||||||
vcount++;
|
vcount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
idx = vidx;
|
idx = vidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
f.V(k) = &(src.vert[idx]);
|
f.V(k) = &(src.vert[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
src_mesh_allocator_t::DeleteVertex(src, *vtx);
|
src_mesh_allocator_t::DeleteVertex(src, *vtx);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// out-of-place version
|
// out-of-place version
|
||||||
template <typename src_trimesh_t, typename dst_trimesh_t, typename extract_wedge_attribs_t, typename compare_vertex_attribs_t, typename copy_vertex_t>
|
template <typename src_trimesh_t, typename dst_trimesh_t, typename extract_wedge_attribs_t, typename compare_vertex_attribs_t, typename copy_vertex_t>
|
||||||
static inline bool SplitVertex(const src_trimesh_t & src, dst_trimesh_t & dst, extract_wedge_attribs_t & v_extract, compare_vertex_attribs_t & v_compare, copy_vertex_t & v_copy)
|
static inline bool SplitVertex(const src_trimesh_t & src, dst_trimesh_t & dst, extract_wedge_attribs_t & v_extract, compare_vertex_attribs_t & v_compare, copy_vertex_t & v_copy)
|
||||||
{
|
{
|
||||||
typedef typename src_trimesh_t::VertexType src_vertex_t;
|
typedef typename src_trimesh_t::VertexType src_vertex_t;
|
||||||
typedef typename src_trimesh_t::FaceType src_face_t;
|
typedef typename src_trimesh_t::FaceType src_face_t;
|
||||||
typedef typename src_trimesh_t::ConstFaceIterator src_face_ci;
|
typedef typename src_trimesh_t::ConstFaceIterator src_face_ci;
|
||||||
|
|
||||||
typedef typename dst_trimesh_t::VertContainer dst_vertex_container_t;
|
typedef typename dst_trimesh_t::VertContainer dst_vertex_container_t;
|
||||||
typedef typename dst_trimesh_t::VertexType dst_vertex_t;
|
typedef typename dst_trimesh_t::VertexType dst_vertex_t;
|
||||||
typedef typename dst_trimesh_t::VertexIterator dst_vertex_i;
|
typedef typename dst_trimesh_t::VertexIterator dst_vertex_i;
|
||||||
typedef typename dst_trimesh_t::FaceType dst_face_t;
|
typedef typename dst_trimesh_t::FaceType dst_face_t;
|
||||||
typedef typename dst_trimesh_t::FaceIterator dst_face_i;
|
typedef typename dst_trimesh_t::FaceIterator dst_face_i;
|
||||||
|
|
||||||
typedef vcg::tri::Allocator<dst_trimesh_t> dst_mesh_allocator_t;
|
typedef vcg::tri::Allocator<dst_trimesh_t> dst_mesh_allocator_t;
|
||||||
|
|
||||||
/* GCC gets in troubles and need some hints ("template") to parse the following line */
|
/* GCC gets in troubles and need some hints ("template") to parse the following line */
|
||||||
typedef typename dst_mesh_allocator_t :: template PointerUpdater<typename dst_trimesh_t::VertexPointer> dst_pointer_updater_t;
|
typedef typename dst_mesh_allocator_t :: template PointerUpdater<typename dst_trimesh_t::VertexPointer> dst_pointer_updater_t;
|
||||||
|
|
||||||
if (reinterpret_cast<const void *>(&src) == reinterpret_cast<const void *>(&dst))
|
if (reinterpret_cast<const void *>(&src) == reinterpret_cast<const void *>(&dst))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.Clear();
|
dst.Clear();
|
||||||
|
|
||||||
if ((src.vn <= 0) || (src.fn <= 0))
|
if ((src.vn <= 0) || (src.fn <= 0))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t vertex_count = src.vert.size();
|
const size_t vertex_count = src.vert.size();
|
||||||
const size_t vertex_pool_size = vertex_count;
|
const size_t vertex_pool_size = vertex_count;
|
||||||
|
|
||||||
const src_vertex_t * vtxbase = &(src.vert[0]);
|
const src_vertex_t * vtxbase = &(src.vert[0]);
|
||||||
|
|
||||||
std::vector<int> vloc;
|
std::vector<int> vloc;
|
||||||
vloc.reserve(vertex_pool_size);
|
vloc.reserve(vertex_pool_size);
|
||||||
vloc.resize(vertex_count, -2);
|
vloc.resize(vertex_count, -2);
|
||||||
|
|
||||||
dst_vertex_i vv;
|
dst_vertex_i vv;
|
||||||
dst_pointer_updater_t pt_upd;
|
dst_pointer_updater_t pt_upd;
|
||||||
pt_upd.preventUpdateFlag = true;
|
pt_upd.preventUpdateFlag = true;
|
||||||
dst_mesh_allocator_t::AddVertices(dst, 1 + int(vertex_count), pt_upd);
|
dst_mesh_allocator_t::AddVertices(dst, 1 + int(vertex_count), pt_upd);
|
||||||
dst_vertex_t * vtx = &(dst.vert[0]);
|
dst_vertex_t * vtx = &(dst.vert[0]);
|
||||||
|
|
||||||
dst_face_i fbase = dst_mesh_allocator_t::AddFaces(dst, src.fn);
|
dst_face_i fbase = dst_mesh_allocator_t::AddFaces(dst, src.fn);
|
||||||
dst_face_i fi = fbase;
|
dst_face_i fi = fbase;
|
||||||
|
|
||||||
int vcount = int(dst.vert.size());
|
int vcount = int(dst.vert.size());
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
for (src_face_ci it=src.face.begin(); it!=src.face.end(); ++it)
|
for (src_face_ci it=src.face.begin(); it!=src.face.end(); ++it)
|
||||||
{
|
{
|
||||||
const src_face_t & wf = (*it);
|
const src_face_t & wf = (*it);
|
||||||
if (wf.IsD()) continue;
|
if (wf.IsD()) continue;
|
||||||
|
|
||||||
dst_face_t & vf = (*fi);
|
dst_face_t & vf = (*fi);
|
||||||
|
|
||||||
for (int k=0; k<3; ++k)
|
for (int k=0; k<3; ++k)
|
||||||
{
|
{
|
||||||
idx = (wf.cV(k) - vtxbase);
|
idx = (wf.cV(k) - vtxbase);
|
||||||
|
|
||||||
v_extract(src, wf, k, dst, *vtx);
|
v_extract(src, wf, k, dst, *vtx);
|
||||||
|
|
||||||
if (vloc[idx] == -2)
|
if (vloc[idx] == -2)
|
||||||
{
|
{
|
||||||
vloc[idx] = -1;
|
vloc[idx] = -1;
|
||||||
v_copy(dst, *vtx, dst.vert[idx]);
|
v_copy(dst, *vtx, dst.vert[idx]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int vidx = idx;
|
int vidx = idx;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (v_compare(dst, dst.vert[vidx], *vtx)) break;
|
if (v_compare(dst, dst.vert[vidx], *vtx)) break;
|
||||||
vidx = vloc[vidx];
|
vidx = vloc[vidx];
|
||||||
} while (vidx >= 0);
|
} while (vidx >= 0);
|
||||||
|
|
||||||
if (vidx < 0)
|
if (vidx < 0)
|
||||||
{
|
{
|
||||||
vloc.push_back(vloc[idx]);
|
vloc.push_back(vloc[idx]);
|
||||||
vloc[idx] = vcount;
|
vloc[idx] = vcount;
|
||||||
|
|
||||||
vv = dst_mesh_allocator_t::AddVertices(dst, 1, pt_upd);
|
vv = dst_mesh_allocator_t::AddVertices(dst, 1, pt_upd);
|
||||||
pt_upd.Update(vtx);
|
pt_upd.Update(vtx);
|
||||||
v_copy(dst, *vtx, *vv);
|
v_copy(dst, *vtx, *vv);
|
||||||
|
|
||||||
idx = vcount;
|
idx = vcount;
|
||||||
vcount++;
|
vcount++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
idx = vidx;
|
idx = vidx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vf.V(k) = reinterpret_cast<dst_vertex_t *>(idx);
|
vf.V(k) = reinterpret_cast<dst_vertex_t *>(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fi++;
|
fi++;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::vector<int> tmp;
|
std::vector<int> tmp;
|
||||||
vloc.swap(tmp);
|
vloc.swap(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
dst_vertex_t * vstart = &(dst.vert[0]);
|
dst_vertex_t * vstart = &(dst.vert[0]);
|
||||||
|
|
||||||
for (dst_face_i it=fbase; it!=dst.face.end(); ++it)
|
for (dst_face_i it=fbase; it!=dst.face.end(); ++it)
|
||||||
{
|
{
|
||||||
dst_face_t & vf = (*it);
|
dst_face_t & vf = (*it);
|
||||||
|
|
||||||
vf.V(0) = vstart + reinterpret_cast<const int>(vf.V(0));
|
vf.V(0) = vstart + reinterpret_cast<const int>(vf.V(0));
|
||||||
vf.V(1) = vstart + reinterpret_cast<const int>(vf.V(1));
|
vf.V(1) = vstart + reinterpret_cast<const int>(vf.V(1));
|
||||||
vf.V(2) = vstart + reinterpret_cast<const int>(vf.V(2));
|
vf.V(2) = vstart + reinterpret_cast<const int>(vf.V(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
dst_mesh_allocator_t::DeleteVertex(dst, *vtx);
|
dst_mesh_allocator_t::DeleteVertex(dst, *vtx);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace tri
|
} // end namespace tri
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,29 @@
|
||||||
#include <vcg/complex/algorithms/bitquad_support.h>
|
#include <vcg/complex/algorithms/bitquad_support.h>
|
||||||
#include <vcg/complex/allocate.h>
|
|
||||||
|
|
||||||
/** BIT-QUAD creation support:
|
/** BIT-QUAD creation support:
|
||||||
a collection of methods that,
|
a collection of methods that,
|
||||||
starting from a triangular mesh, will create your quad-pure or quad-domainant mesh.
|
starting from a triangular mesh, will create your quad-pure or quad-domainant mesh.
|
||||||
|
|
||||||
They all require:
|
They all require:
|
||||||
- per face Q, and FF connectivity, 2-manyfold meshes,
|
- per face Q, and FF connectivity, 2-manyfold meshes,
|
||||||
- and tri- or quad- meshes (no penta, etc) (if in need, use MakeBitTriOnly)
|
- and tri- or quad- meshes (no penta, etc) (if in need, use MakeBitTriOnly)
|
||||||
|
|
||||||
|
|
||||||
[ list of available methods: ]
|
[ list of available methods: ]
|
||||||
|
|
||||||
void MakePureByRefine(Mesh &m)
|
void MakePureByRefine(Mesh &m)
|
||||||
- adds a vertex for each tri or quad present
|
- adds a vertex for each tri or quad present
|
||||||
- thus, miminal complexity increase is the mesh is quad-dominant already
|
- thus, miminal complexity increase is the mesh is quad-dominant already
|
||||||
- old non-border edges are made faux
|
- old non-border edges are made faux
|
||||||
- never fails
|
- never fails
|
||||||
|
|
||||||
void MakePureByCatmullClark(MeshType &m)
|
void MakePureByCatmullClark(MeshType &m)
|
||||||
- adds a vertex in each (non-faux) edge.
|
- adds a vertex in each (non-faux) edge.
|
||||||
- twice complexity increase w.r.t. "ByRefine" method.
|
- twice complexity increase w.r.t. "ByRefine" method.
|
||||||
- preserves edges: old edges are still edges
|
- preserves edges: old edges are still edges
|
||||||
- never fails
|
- never fails
|
||||||
|
|
||||||
bool MakePureByFlip(MeshType &m [, int maxdist] )
|
bool MakePureByFlip(MeshType &m [, int maxdist] )
|
||||||
- does not increase # vertices, just flips edges
|
- does not increase # vertices, just flips edges
|
||||||
- call in a loop until it returns true (temporary hack)
|
- call in a loop until it returns true (temporary hack)
|
||||||
- fails if number of triangle is odd (only happens in open meshes)
|
- fails if number of triangle is odd (only happens in open meshes)
|
||||||
|
|
@ -65,9 +64,9 @@ namespace vcg{namespace tri{
|
||||||
template <class _MeshType,
|
template <class _MeshType,
|
||||||
class Interpolator = GeometricInterpolator<typename _MeshType::VertexType> >
|
class Interpolator = GeometricInterpolator<typename _MeshType::VertexType> >
|
||||||
class BitQuadCreation{
|
class BitQuadCreation{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef _MeshType MeshType;
|
typedef _MeshType MeshType;
|
||||||
typedef typename MeshType::ScalarType ScalarType;
|
typedef typename MeshType::ScalarType ScalarType;
|
||||||
typedef typename MeshType::CoordType CoordType;
|
typedef typename MeshType::CoordType CoordType;
|
||||||
|
|
@ -84,37 +83,37 @@ typedef BitQuad<MeshType> BQ; // static class to make basic quad operations
|
||||||
// given a triangle, merge it with its best neightboord to form a quad
|
// given a triangle, merge it with its best neightboord to form a quad
|
||||||
template <bool override>
|
template <bool override>
|
||||||
static void selectBestDiag(FaceType *fi){
|
static void selectBestDiag(FaceType *fi){
|
||||||
|
|
||||||
if (!override) {
|
if (!override) {
|
||||||
if (fi->IsAnyF()) return;
|
if (fi->IsAnyF()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// select which edge to make faux (if any)...
|
// select which edge to make faux (if any)...
|
||||||
int whichEdge = -1;
|
int whichEdge = -1;
|
||||||
ScalarType bestScore = fi->Q();
|
ScalarType bestScore = fi->Q();
|
||||||
|
|
||||||
whichEdge=-1;
|
whichEdge=-1;
|
||||||
|
|
||||||
for (int k=0; k<3; k++){
|
for (int k=0; k<3; k++){
|
||||||
|
|
||||||
// todo: check creases? (continue if edge k is a crease)
|
// todo: check creases? (continue if edge k is a crease)
|
||||||
|
|
||||||
if (!override) {
|
if (!override) {
|
||||||
if (fi->FFp(k)->IsAnyF()) continue;
|
if (fi->FFp(k)->IsAnyF()) continue;
|
||||||
}
|
}
|
||||||
if (fi->FFp(k)==fi) continue; // never make a border faux
|
if (fi->FFp(k)==fi) continue; // never make a border faux
|
||||||
|
|
||||||
ScalarType score = BQ::quadQuality( &*fi, k );
|
ScalarType score = BQ::quadQuality( &*fi, k );
|
||||||
if (override) {
|
if (override) {
|
||||||
// don't override anyway iff other face has a better match
|
// don't override anyway iff other face has a better match
|
||||||
if (score < fi->FFp(k)->Q()) continue;
|
if (score < fi->FFp(k)->Q()) continue;
|
||||||
}
|
}
|
||||||
if (score>bestScore) {
|
if (score>bestScore) {
|
||||||
bestScore = score;
|
bestScore = score;
|
||||||
whichEdge = k;
|
whichEdge = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...and make it faux
|
// ...and make it faux
|
||||||
if (whichEdge>=0) {
|
if (whichEdge>=0) {
|
||||||
//if (override && fi->FFp(whichEdge)->IsAnyF()) {
|
//if (override && fi->FFp(whichEdge)->IsAnyF()) {
|
||||||
|
|
@ -122,8 +121,8 @@ static void selectBestDiag(FaceType *fi){
|
||||||
// fi->Q() = fi->FFp(whichEdge)->Q() = ( bestScore + fi->FFp(whichEdge)->Q() ) /2;
|
// fi->Q() = fi->FFp(whichEdge)->Q() = ( bestScore + fi->FFp(whichEdge)->Q() ) /2;
|
||||||
//} else {
|
//} else {
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (override) {
|
if (override) {
|
||||||
// clear any faux edge of the other face
|
// clear any faux edge of the other face
|
||||||
for (int k=0; k<3; k++)
|
for (int k=0; k<3; k++)
|
||||||
if (fi->FFp(whichEdge)->IsF(k)) {
|
if (fi->FFp(whichEdge)->IsF(k)) {
|
||||||
|
|
@ -131,7 +130,7 @@ static void selectBestDiag(FaceType *fi){
|
||||||
fi->FFp(whichEdge)->FFp(k)->ClearF( fi->FFp(whichEdge)->FFi(k) );
|
fi->FFp(whichEdge)->FFp(k)->ClearF( fi->FFp(whichEdge)->FFi(k) );
|
||||||
fi->FFp(whichEdge)->FFp(k)->Q()=0.0; // other face's ex-buddy is now single and sad :(
|
fi->FFp(whichEdge)->FFp(k)->Q()=0.0; // other face's ex-buddy is now single and sad :(
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all faux edges of this face...
|
// clear all faux edges of this face...
|
||||||
for (int k=0; k<3; k++)
|
for (int k=0; k<3; k++)
|
||||||
if (fi->IsF(k)) {
|
if (fi->IsF(k)) {
|
||||||
|
|
@ -143,11 +142,11 @@ static void selectBestDiag(FaceType *fi){
|
||||||
// set (new?) quad
|
// set (new?) quad
|
||||||
fi->SetF(whichEdge);
|
fi->SetF(whichEdge);
|
||||||
fi->FFp(whichEdge)->SetF( fi->FFi(whichEdge) );
|
fi->FFp(whichEdge)->SetF( fi->FFi(whichEdge) );
|
||||||
fi->Q() = fi->FFp(whichEdge)->Q() = bestScore;
|
fi->Q() = fi->FFp(whichEdge)->Q() = bestScore;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -156,11 +155,11 @@ static void selectBestDiag(FaceType *fi){
|
||||||
// a pass though all triangles to merge triangle pairs into quads
|
// a pass though all triangles to merge triangle pairs into quads
|
||||||
template <bool override> // override previous decisions?
|
template <bool override> // override previous decisions?
|
||||||
static void MakeDominantPass(MeshType &m){
|
static void MakeDominantPass(MeshType &m){
|
||||||
|
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
selectBestDiag<override>(&(*fi));
|
selectBestDiag<override>(&(*fi));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This function split a face along the specified border edge it does not compute any property of the new vertex. It only do the topological work.
|
* This function split a face along the specified border edge it does not compute any property of the new vertex. It only do the topological work.
|
||||||
|
|
@ -265,9 +264,9 @@ static bool MakeTriEvenBySplit(MeshType& m){
|
||||||
|
|
||||||
// make tri count even by delete...
|
// make tri count even by delete...
|
||||||
static bool MakeTriEvenByDelete(MeshType& m)
|
static bool MakeTriEvenByDelete(MeshType& m)
|
||||||
{
|
{
|
||||||
if (m.fn%2==0) return false; // it's already Even
|
if (m.fn%2==0) return false; // it's already Even
|
||||||
|
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) {
|
||||||
for (int k=0; k<3; k++) {
|
for (int k=0; k<3; k++) {
|
||||||
if (face::IsBorder(*fi,k) ) {
|
if (face::IsBorder(*fi,k) ) {
|
||||||
|
|
@ -304,7 +303,7 @@ static int SplitNonFlatQuads(MeshType &m, ScalarType deg=0){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Given a mesh, makes it bit trianglular (makes all edges NOT faux)
|
Given a mesh, makes it bit trianglular (makes all edges NOT faux)
|
||||||
*/
|
*/
|
||||||
static void MakeBitTriOnly(MeshType &m){
|
static void MakeBitTriOnly(MeshType &m){
|
||||||
|
|
@ -331,7 +330,7 @@ static bool IsBitTriQuadConventional(const MeshType &m){
|
||||||
if (fi->IsAnyF())
|
if (fi->IsAnyF())
|
||||||
if ( (fi->Flags() & FaceType::FAUX012 ) != FaceType::FAUX2 ) {
|
if ( (fi->Flags() & FaceType::FAUX012 ) != FaceType::FAUX2 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -347,11 +346,11 @@ static bool IsTriOnly(const MeshType &m){
|
||||||
/* returns true if mesh is a pure quad-mesh. */
|
/* returns true if mesh is a pure quad-mesh. */
|
||||||
static bool IsQuadOnly(const MeshType &m){
|
static bool IsQuadOnly(const MeshType &m){
|
||||||
for (ConstFaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (ConstFaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (fi->IsF(0)) count++;
|
if (fi->IsF(0)) count++;
|
||||||
if (fi->IsF(1)) count++;
|
if (fi->IsF(1)) count++;
|
||||||
if (fi->IsF(2)) count++;
|
if (fi->IsF(2)) count++;
|
||||||
if (count!=1) return false;
|
if (count!=1) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -359,11 +358,11 @@ static bool IsQuadOnly(const MeshType &m){
|
||||||
/* returns true if mesh has only tris and quads (no penta etc) */
|
/* returns true if mesh has only tris and quads (no penta etc) */
|
||||||
static bool IsTriQuadOnly(const MeshType &m){
|
static bool IsTriQuadOnly(const MeshType &m){
|
||||||
for (ConstFaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (ConstFaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (fi->IsF(0)) count++;
|
if (fi->IsF(0)) count++;
|
||||||
if (fi->IsF(1)) count++;
|
if (fi->IsF(1)) count++;
|
||||||
if (fi->IsF(2)) count++;
|
if (fi->IsF(2)) count++;
|
||||||
if (count>1) return false;
|
if (count>1) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -384,20 +383,20 @@ static void CopyTopology(FaceType *fnew, FaceType * fold)
|
||||||
requires that the mesh is made only of quads and tris.
|
requires that the mesh is made only of quads and tris.
|
||||||
*/
|
*/
|
||||||
static void MakePureByRefine(MeshType &m){
|
static void MakePureByRefine(MeshType &m){
|
||||||
|
|
||||||
// todo: update VF connectivity if present
|
// todo: update VF connectivity if present
|
||||||
|
|
||||||
|
|
||||||
int ev = 0; // EXTRA vertices (times 2)
|
int ev = 0; // EXTRA vertices (times 2)
|
||||||
int ef = 0; // EXTRA faces
|
int ef = 0; // EXTRA faces
|
||||||
|
|
||||||
// first pass: count triangles to be added
|
// first pass: count triangles to be added
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
int k=0;
|
int k=0;
|
||||||
if (face::IsBorder(*fi,0)) k++;
|
if (face::IsBorder(*fi,0)) k++;
|
||||||
if (face::IsBorder(*fi,1)) k++;
|
if (face::IsBorder(*fi,1)) k++;
|
||||||
if (face::IsBorder(*fi,2)) k++;
|
if (face::IsBorder(*fi,2)) k++;
|
||||||
if (!fi->IsAnyF()) {
|
if (!fi->IsAnyF()) {
|
||||||
// it's a triangle
|
// it's a triangle
|
||||||
if (k==0) // add a vertex in the center of the face, splitting it in 3
|
if (k==0) // add a vertex in the center of the face, splitting it in 3
|
||||||
{ ev+=2; ef+=2; }
|
{ ev+=2; ef+=2; }
|
||||||
|
|
@ -410,17 +409,17 @@ static void MakePureByRefine(MeshType &m){
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// assuming is a quad (not a penta, etc), i.e. only one faux
|
// assuming is a quad (not a penta, etc), i.e. only one faux
|
||||||
// add a vertex in the center of the faux edge, splitting the face in 2
|
// add a vertex in the center of the faux edge, splitting the face in 2
|
||||||
ev+=1; ef+=1;
|
ev+=1; ef+=1;
|
||||||
assert(k!=3);
|
assert(k!=3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(ev%2==0); // should be even by now
|
assert(ev%2==0); // should be even by now
|
||||||
ev/=2; // I was counting each of them twice
|
ev/=2; // I was counting each of them twice
|
||||||
|
|
||||||
//int originalFaceNum = m.fn;
|
//int originalFaceNum = m.fn;
|
||||||
FaceIterator nfi = tri::Allocator<MeshType>::AddFaces(m,ef);
|
FaceIterator nfi = tri::Allocator<MeshType>::AddFaces(m,ef);
|
||||||
VertexIterator nvi = tri::Allocator<MeshType>::AddVertices(m,ev);
|
VertexIterator nvi = tri::Allocator<MeshType>::AddVertices(m,ev);
|
||||||
|
|
||||||
tri::UpdateFlags<MeshType>::FaceClearV(m);
|
tri::UpdateFlags<MeshType>::FaceClearV(m);
|
||||||
|
|
||||||
|
|
@ -429,10 +428,10 @@ static void MakePureByRefine(MeshType &m){
|
||||||
for (FaceIterator fi = m.face.begin(), fend = nfi; fi!=fend; fi++) if (!fi->IsD() && !fi->IsV() ) {
|
for (FaceIterator fi = m.face.begin(), fend = nfi; fi!=fend; fi++) if (!fi->IsD() && !fi->IsV() ) {
|
||||||
|
|
||||||
fi->SetV();
|
fi->SetV();
|
||||||
|
|
||||||
if (!fi->IsAnyF()) {
|
if (!fi->IsAnyF()) {
|
||||||
// it's a triangle
|
// it's a triangle
|
||||||
|
|
||||||
int k=0; // number of borders
|
int k=0; // number of borders
|
||||||
if (face::IsBorder(*fi,0)) k++;
|
if (face::IsBorder(*fi,0)) k++;
|
||||||
if (face::IsBorder(*fi,1)) k++;
|
if (face::IsBorder(*fi,1)) k++;
|
||||||
|
|
@ -443,31 +442,31 @@ static void MakePureByRefine(MeshType &m){
|
||||||
assert(nvi!=m.vert.end());
|
assert(nvi!=m.vert.end());
|
||||||
VertexType *nv = &*nvi; nvi++;
|
VertexType *nv = &*nvi; nvi++;
|
||||||
//*nv = *fi->V0( 0 ); // lazy: copy everything from the old vertex
|
//*nv = *fi->V0( 0 ); // lazy: copy everything from the old vertex
|
||||||
nv->ImportData(*(fi->V0( 0 ))); // lazy: copy everything from the old vertex
|
nv->ImportData(*(fi->V0( 0 ))); // lazy: copy everything from the old vertex
|
||||||
|
|
||||||
nv->P() = ( fi->V(0)->P() + fi->V(1)->P() + fi->V(2)->P() ) /3.0;
|
nv->P() = ( fi->V(0)->P() + fi->V(1)->P() + fi->V(2)->P() ) /3.0;
|
||||||
FaceType *fa = &*fi;
|
FaceType *fa = &*fi;
|
||||||
FaceType *fb = &*nfi; nfi++;
|
FaceType *fb = &*nfi; nfi++;
|
||||||
FaceType *fc = &*nfi; nfi++;
|
FaceType *fc = &*nfi; nfi++;
|
||||||
|
|
||||||
fb->ImportData(*fa); CopyTopology(fb,fa);
|
fb->ImportData(*fa); CopyTopology(fb,fa);
|
||||||
fc->ImportData(*fa); CopyTopology(fc,fa);
|
fc->ImportData(*fa); CopyTopology(fc,fa);
|
||||||
|
|
||||||
fa->V(0) = nv;
|
fa->V(0) = nv;
|
||||||
fb->V(1) = nv;
|
fb->V(1) = nv;
|
||||||
fc->V(2) = nv;
|
fc->V(2) = nv;
|
||||||
|
|
||||||
fb->FFp(2)=fa->FFp(2); fb->FFi(2)=fa->FFi(2);
|
fb->FFp(2)=fa->FFp(2); fb->FFi(2)=fa->FFi(2);
|
||||||
fc->FFp(0)=fa->FFp(0); fc->FFi(0)=fa->FFi(0);
|
fc->FFp(0)=fa->FFp(0); fc->FFi(0)=fa->FFi(0);
|
||||||
|
|
||||||
assert( fa->FFp(1)->FFp(fa->FFi(1)) == fa );
|
assert( fa->FFp(1)->FFp(fa->FFi(1)) == fa );
|
||||||
/* */fb->FFp(2)->FFp(fb->FFi(2)) = fb;
|
/* */fb->FFp(2)->FFp(fb->FFi(2)) = fb;
|
||||||
/* */fc->FFp(0)->FFp(fc->FFi(0)) = fc;
|
/* */fc->FFp(0)->FFp(fc->FFi(0)) = fc;
|
||||||
|
|
||||||
fa->FFp(0) = fc; fa->FFp(2) = fb; fa->FFi(0) = fa->FFi(2) = 1;
|
fa->FFp(0) = fc; fa->FFp(2) = fb; fa->FFi(0) = fa->FFi(2) = 1;
|
||||||
fb->FFp(1) = fa; fb->FFp(0) = fc; fb->FFi(0) = fb->FFi(1) = 2;
|
fb->FFp(1) = fa; fb->FFp(0) = fc; fb->FFi(0) = fb->FFi(1) = 2;
|
||||||
fc->FFp(1) = fa; fc->FFp(2) = fb; fc->FFi(1) = fc->FFi(2) = 0;
|
fc->FFp(1) = fa; fc->FFp(2) = fb; fc->FFi(1) = fc->FFi(2) = 0;
|
||||||
|
|
||||||
if (fb->FFp(2)==fa) fb->FFp(2)=fb; // recover border status
|
if (fb->FFp(2)==fa) fb->FFp(2)=fb; // recover border status
|
||||||
if (fc->FFp(0)==fa) fc->FFp(0)=fc;
|
if (fc->FFp(0)==fa) fc->FFp(0)=fc;
|
||||||
|
|
||||||
|
|
@ -477,7 +476,7 @@ static void MakePureByRefine(MeshType &m){
|
||||||
fa->SetF(1);
|
fa->SetF(1);
|
||||||
fb->SetF(2);
|
fb->SetF(2);
|
||||||
fc->SetF(0);
|
fc->SetF(0);
|
||||||
|
|
||||||
fa->SetV();fb->SetV();fc->SetV();
|
fa->SetV();fb->SetV();fc->SetV();
|
||||||
}
|
}
|
||||||
if (k==1) { // make a border face faux, anf other two as well
|
if (k==1) { // make a border face faux, anf other two as well
|
||||||
|
|
@ -487,18 +486,18 @@ static void MakePureByRefine(MeshType &m){
|
||||||
nsplit++;
|
nsplit++;
|
||||||
}
|
}
|
||||||
if (k==2) // do nothing, just mark the non border edge as faux
|
if (k==2) // do nothing, just mark the non border edge as faux
|
||||||
{
|
{
|
||||||
fi->ClearAllF();
|
fi->ClearAllF();
|
||||||
for (int w=0; w<3; w++) if (fi->FFp(w) != &*fi) fi->SetF(w);
|
for (int w=0; w<3; w++) if (fi->FFp(w) != &*fi) fi->SetF(w);
|
||||||
}
|
}
|
||||||
if (k==3) // disconnected single triangle (all borders): use catmull-clark (tree vertices, split it in 6
|
if (k==3) // disconnected single triangle (all borders): use catmull-clark (tree vertices, split it in 6
|
||||||
{
|
{
|
||||||
fi->ClearAllF();
|
fi->ClearAllF();
|
||||||
fi->SetF(2);
|
fi->SetF(2);
|
||||||
nsplit++;
|
nsplit++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// assuming is a part of quad (not a penta, etc), i.e. only one faux
|
// assuming is a part of quad (not a penta, etc), i.e. only one faux
|
||||||
FaceType *fa = &*fi;
|
FaceType *fa = &*fi;
|
||||||
int ea2 = BQ::FauxIndex(fa); // index of the only faux edge
|
int ea2 = BQ::FauxIndex(fa); // index of the only faux edge
|
||||||
|
|
@ -507,7 +506,7 @@ static void MakePureByRefine(MeshType &m){
|
||||||
assert(fb->FFp(eb2)==fa) ;
|
assert(fb->FFp(eb2)==fa) ;
|
||||||
assert(fa->IsF(ea2));
|
assert(fa->IsF(ea2));
|
||||||
//assert(fb->IsF(eb2)); // reciprocal faux edge
|
//assert(fb->IsF(eb2)); // reciprocal faux edge
|
||||||
|
|
||||||
int ea0 = (ea2+1) %3;
|
int ea0 = (ea2+1) %3;
|
||||||
int ea1 = (ea2+2) %3;
|
int ea1 = (ea2+2) %3;
|
||||||
int eb0 = (eb2+1) %3;
|
int eb0 = (eb2+1) %3;
|
||||||
|
|
@ -517,7 +516,7 @@ static void MakePureByRefine(MeshType &m){
|
||||||
assert(nvi!=m.vert.end());
|
assert(nvi!=m.vert.end());
|
||||||
VertexType *nv = &*nvi; nvi++;
|
VertexType *nv = &*nvi; nvi++;
|
||||||
// *nv = * fa->V0( ea2 );
|
// *nv = * fa->V0( ea2 );
|
||||||
nv->ImportData(*(fa->V0( ea2 ) )); // lazy: copy everything from the old vertex
|
nv->ImportData(*(fa->V0( ea2 ) )); // lazy: copy everything from the old vertex
|
||||||
//nv->P() = ( fa->V(ea2)->P() + fa->V(ea0)->P() ) /2.0;
|
//nv->P() = ( fa->V(ea2)->P() + fa->V(ea0)->P() ) /2.0;
|
||||||
Interpolator::Apply(*(fa->V(ea2)),*(fa->V(ea0)),0.5,*nv);
|
Interpolator::Apply(*(fa->V(ea2)),*(fa->V(ea0)),0.5,*nv);
|
||||||
// split faces: add 2 faces (one per side)
|
// split faces: add 2 faces (one per side)
|
||||||
|
|
@ -526,33 +525,33 @@ static void MakePureByRefine(MeshType &m){
|
||||||
assert(nfi!=m.face.end());
|
assert(nfi!=m.face.end());
|
||||||
FaceType *fd = &*nfi; nfi++;
|
FaceType *fd = &*nfi; nfi++;
|
||||||
|
|
||||||
fc->ImportData(*fa ); CopyTopology(fc,fa); // lazy: copy everything from the old vertex
|
fc->ImportData(*fa ); CopyTopology(fc,fa); // lazy: copy everything from the old vertex
|
||||||
fd->ImportData(*fb ); CopyTopology(fd,fb);// lazy: copy everything from the old vertex
|
fd->ImportData(*fb ); CopyTopology(fd,fb);// lazy: copy everything from the old vertex
|
||||||
|
|
||||||
fa->V(ea2) = fc->V(ea0) =
|
fa->V(ea2) = fc->V(ea0) =
|
||||||
fb->V(eb2) = fd->V(eb0) = nv ;
|
fb->V(eb2) = fd->V(eb0) = nv ;
|
||||||
|
|
||||||
fa->FFp(ea1)->FFp( fa->FFi(ea1) ) = fc;
|
fa->FFp(ea1)->FFp( fa->FFi(ea1) ) = fc;
|
||||||
fb->FFp(eb1)->FFp( fb->FFi(eb1) ) = fd;
|
fb->FFp(eb1)->FFp( fb->FFi(eb1) ) = fd;
|
||||||
|
|
||||||
fa->FFp(ea1) = fc ; fa->FFp(ea2) = fd;
|
fa->FFp(ea1) = fc ; fa->FFp(ea2) = fd;
|
||||||
fa->FFi(ea1) = ea0; fa->FFi(ea2) = eb2;
|
fa->FFi(ea1) = ea0; fa->FFi(ea2) = eb2;
|
||||||
fb->FFp(eb1) = fd ; fb->FFp(eb2) = fc;
|
fb->FFp(eb1) = fd ; fb->FFp(eb2) = fc;
|
||||||
fb->FFi(eb1) = eb0; fb->FFi(eb2) = ea2;
|
fb->FFi(eb1) = eb0; fb->FFi(eb2) = ea2;
|
||||||
fc->FFp(ea0) = fa ; fc->FFp(ea2) = fb;
|
fc->FFp(ea0) = fa ; fc->FFp(ea2) = fb;
|
||||||
fc->FFi(ea0) = ea1; fc->FFi(ea2) = eb2;
|
fc->FFi(ea0) = ea1; fc->FFi(ea2) = eb2;
|
||||||
fd->FFp(eb0) = fb ; fd->FFp(eb2) = fa;
|
fd->FFp(eb0) = fb ; fd->FFp(eb2) = fa;
|
||||||
fd->FFi(eb0) = eb1; fd->FFi(eb2) = ea2;
|
fd->FFi(eb0) = eb1; fd->FFi(eb2) = ea2;
|
||||||
|
|
||||||
// detect boundaries
|
// detect boundaries
|
||||||
bool ba = fa->FFp(ea0)==fa;
|
bool ba = fa->FFp(ea0)==fa;
|
||||||
bool bc = fc->FFp(ea1)==fa;
|
bool bc = fc->FFp(ea1)==fa;
|
||||||
bool bb = fb->FFp(eb0)==fb;
|
bool bb = fb->FFp(eb0)==fb;
|
||||||
bool bd = fd->FFp(eb1)==fb;
|
bool bd = fd->FFp(eb1)==fb;
|
||||||
|
|
||||||
if (bc) fc->FFp(ea1)=fc; // repristinate boundary status
|
if (bc) fc->FFp(ea1)=fc; // repristinate boundary status
|
||||||
if (bd) fd->FFp(eb1)=fd; // of new faces
|
if (bd) fd->FFp(eb1)=fd; // of new faces
|
||||||
|
|
||||||
fa->SetV();
|
fa->SetV();
|
||||||
fb->SetV();
|
fb->SetV();
|
||||||
fc->SetV();
|
fc->SetV();
|
||||||
|
|
@ -562,103 +561,103 @@ static void MakePureByRefine(MeshType &m){
|
||||||
fb->ClearAllF();
|
fb->ClearAllF();
|
||||||
fc->ClearAllF();
|
fc->ClearAllF();
|
||||||
fd->ClearAllF();
|
fd->ClearAllF();
|
||||||
|
|
||||||
fa->SetF( ea0 );
|
fa->SetF( ea0 );
|
||||||
fb->SetF( eb0 );
|
fb->SetF( eb0 );
|
||||||
fc->SetF( ea1 );
|
fc->SetF( ea1 );
|
||||||
fd->SetF( eb1 );
|
fd->SetF( eb1 );
|
||||||
|
|
||||||
// fix faux mesh boundary... if two any consecutive, merge it in a quad
|
// fix faux mesh boundary... if two any consecutive, merge it in a quad
|
||||||
if (ba&&bc) {
|
if (ba&&bc) {
|
||||||
fa->ClearAllF(); fa->SetF(ea1);
|
fa->ClearAllF(); fa->SetF(ea1);
|
||||||
fc->ClearAllF(); fc->SetF(ea0);
|
fc->ClearAllF(); fc->SetF(ea0);
|
||||||
ba = bc = false;
|
ba = bc = false;
|
||||||
}
|
}
|
||||||
if (bc&&bb) {
|
if (bc&&bb) {
|
||||||
fc->ClearAllF(); fc->SetF(ea2);
|
fc->ClearAllF(); fc->SetF(ea2);
|
||||||
fb->ClearAllF(); fb->SetF(eb2);
|
fb->ClearAllF(); fb->SetF(eb2);
|
||||||
bc = bb = false;
|
bc = bb = false;
|
||||||
}
|
}
|
||||||
if (bb&&bd) {
|
if (bb&&bd) {
|
||||||
fb->ClearAllF(); fb->SetF(eb1);
|
fb->ClearAllF(); fb->SetF(eb1);
|
||||||
fd->ClearAllF(); fd->SetF(eb0);
|
fd->ClearAllF(); fd->SetF(eb0);
|
||||||
bb = bd = false;
|
bb = bd = false;
|
||||||
}
|
}
|
||||||
if (bd&&ba) {
|
if (bd&&ba) {
|
||||||
fd->ClearAllF(); fd->SetF(eb2);
|
fd->ClearAllF(); fd->SetF(eb2);
|
||||||
fa->ClearAllF(); fa->SetF(ea2);
|
fa->ClearAllF(); fa->SetF(ea2);
|
||||||
bd = ba = false;
|
bd = ba = false;
|
||||||
}
|
}
|
||||||
// remaninig boudaries will be fixed by splitting in the last pass
|
// remaninig boudaries will be fixed by splitting in the last pass
|
||||||
if (ba) nsplit++;
|
if (ba) nsplit++;
|
||||||
if (bb) nsplit++;
|
if (bb) nsplit++;
|
||||||
if (bc) nsplit++;
|
if (bc) nsplit++;
|
||||||
if (bd) nsplit++;
|
if (bd) nsplit++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(nfi==m.face.end());
|
assert(nfi==m.face.end());
|
||||||
assert(nvi==m.vert.end());
|
assert(nvi==m.vert.end());
|
||||||
|
|
||||||
// now and there are no tris left, but there can be faces with ONE edge border & faux ()
|
// now and there are no tris left, but there can be faces with ONE edge border & faux ()
|
||||||
|
|
||||||
|
|
||||||
// last pass: add vertex on faux border faces... (if any)
|
// last pass: add vertex on faux border faces... (if any)
|
||||||
if (nsplit>0) {
|
if (nsplit>0) {
|
||||||
FaceIterator nfi = tri::Allocator<MeshType>::AddFaces(m,nsplit);
|
FaceIterator nfi = tri::Allocator<MeshType>::AddFaces(m,nsplit);
|
||||||
VertexIterator nvi = tri::Allocator<MeshType>::AddVertices(m,nsplit);
|
VertexIterator nvi = tri::Allocator<MeshType>::AddVertices(m,nsplit);
|
||||||
for (FaceIterator fi = m.face.begin(), fend = nfi; fi!=fend; fi++) if (!fi->IsD()) {
|
for (FaceIterator fi = m.face.begin(), fend = nfi; fi!=fend; fi++) if (!fi->IsD()) {
|
||||||
FaceType* fa = &*fi;
|
FaceType* fa = &*fi;
|
||||||
int ea2 = -1; // border and faux face (if any)
|
int ea2 = -1; // border and faux face (if any)
|
||||||
if (fa->FFp(0)==fa && fa->IsF(0) ) ea2=0;
|
if (fa->FFp(0)==fa && fa->IsF(0) ) ea2=0;
|
||||||
if (fa->FFp(1)==fa && fa->IsF(1) ) ea2=1;
|
if (fa->FFp(1)==fa && fa->IsF(1) ) ea2=1;
|
||||||
if (fa->FFp(2)==fa && fa->IsF(2) ) ea2=2;
|
if (fa->FFp(2)==fa && fa->IsF(2) ) ea2=2;
|
||||||
|
|
||||||
if (ea2 != -1) { // ea2 edge is naughty (border AND faux)
|
if (ea2 != -1) { // ea2 edge is naughty (border AND faux)
|
||||||
|
|
||||||
int ea0 = (ea2+1) %3;
|
int ea0 = (ea2+1) %3;
|
||||||
int ea1 = (ea2+2) %3;
|
int ea1 = (ea2+2) %3;
|
||||||
|
|
||||||
// create new vert in center of faux edge
|
// create new vert in center of faux edge
|
||||||
VertexType *nv = &*nvi; nvi++;
|
VertexType *nv = &*nvi; nvi++;
|
||||||
//*nv = * fa->V0( ea2 );
|
//*nv = * fa->V0( ea2 );
|
||||||
nv->ImportData(*(fa->V0( ea2 ) )); // lazy: copy everything from the old vertex
|
nv->ImportData(*(fa->V0( ea2 ) )); // lazy: copy everything from the old vertex
|
||||||
nv->P() = ( fa->V(ea2)->P() + fa->V(ea0)->P() ) /2.0;
|
nv->P() = ( fa->V(ea2)->P() + fa->V(ea0)->P() ) /2.0;
|
||||||
Interpolator::Apply(*(fa->V(ea2)),*(fa->V(ea0)),0.5,*nv);
|
Interpolator::Apply(*(fa->V(ea2)),*(fa->V(ea0)),0.5,*nv);
|
||||||
// split face: add 1 face
|
// split face: add 1 face
|
||||||
FaceType *fc = &*nfi; nfi++;
|
FaceType *fc = &*nfi; nfi++;
|
||||||
|
|
||||||
fc->ImportData(*fa);CopyTopology(fc,fa); // lazy: copy everything from the old vertex
|
fc->ImportData(*fa);CopyTopology(fc,fa); // lazy: copy everything from the old vertex
|
||||||
|
|
||||||
fa->V(ea2) = fc->V(ea0) = nv ;
|
fa->V(ea2) = fc->V(ea0) = nv ;
|
||||||
|
|
||||||
fc->FFp(ea2) = fc;
|
fc->FFp(ea2) = fc;
|
||||||
|
|
||||||
fa->FFp(ea1)->FFp( fa->FFi(ea1) ) = fc;
|
fa->FFp(ea1)->FFp( fa->FFi(ea1) ) = fc;
|
||||||
|
|
||||||
fa->FFp(ea1) = fc ;
|
fa->FFp(ea1) = fc ;
|
||||||
fa->FFi(ea1) = ea0;
|
fa->FFi(ea1) = ea0;
|
||||||
fc->FFp(ea0) = fa ; fc->FFp(ea2) = fc;
|
fc->FFp(ea0) = fa ; fc->FFp(ea2) = fc;
|
||||||
fc->FFi(ea0) = ea1;
|
fc->FFi(ea0) = ea1;
|
||||||
|
|
||||||
if (fc->FFp(ea1)==fa) fc->FFp(ea1)=fc; // recover border status
|
if (fc->FFp(ea1)==fa) fc->FFp(ea1)=fc; // recover border status
|
||||||
|
|
||||||
assert(fa->IsF(ea0) == fa->IsF(ea1) );
|
assert(fa->IsF(ea0) == fa->IsF(ea1) );
|
||||||
bool b = fa->IsF(ea1);
|
bool b = fa->IsF(ea1);
|
||||||
|
|
||||||
fa->ClearAllF();
|
fa->ClearAllF();
|
||||||
fc->ClearAllF();
|
fc->ClearAllF();
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
fa->SetF( ea0 );
|
fa->SetF( ea0 );
|
||||||
fc->SetF( ea1 );
|
fc->SetF( ea1 );
|
||||||
} else {
|
} else {
|
||||||
fa->SetF( ea1 );
|
fa->SetF( ea1 );
|
||||||
fc->SetF( ea0 );
|
fc->SetF( ea0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -676,13 +675,13 @@ static void MakePureByCatmullClark(MeshType &m){
|
||||||
// Stops at maxDist or at the distance when a triangle is found
|
// Stops at maxDist or at the distance when a triangle is found
|
||||||
static FaceType * MarkEdgeDistance(MeshType &m, FaceType *startF, int maxDist){
|
static FaceType * MarkEdgeDistance(MeshType &m, FaceType *startF, int maxDist){
|
||||||
assert(tri::HasPerFaceQuality(m));
|
assert(tri::HasPerFaceQuality(m));
|
||||||
|
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
fi->Q()=maxDist;
|
fi->Q()=maxDist;
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceType * firstTriangleFound = NULL;
|
FaceType * firstTriangleFound = NULL;
|
||||||
|
|
||||||
startF->Q() = 0;
|
startF->Q() = 0;
|
||||||
std::vector<FaceType*> stack;
|
std::vector<FaceType*> stack;
|
||||||
int stackPos=0;
|
int stackPos=0;
|
||||||
|
|
@ -707,65 +706,65 @@ static FaceType * MarkEdgeDistance(MeshType &m, FaceType *startF, int maxDist){
|
||||||
|
|
||||||
/*
|
/*
|
||||||
given a tri-quad mesh,
|
given a tri-quad mesh,
|
||||||
uses edge rotates to make a tri move toward another tri and to merges them into a quad.
|
uses edge rotates to make a tri move toward another tri and to merges them into a quad.
|
||||||
|
|
||||||
Retunrs number of surviving triangles (0, or 1), or -1 if not done yet.
|
Retunrs number of surviving triangles (0, or 1), or -1 if not done yet.
|
||||||
StepbyStep: makes just one step!
|
StepbyStep: makes just one step!
|
||||||
use it in a loop as long as it returns 0 or 1.
|
use it in a loop as long as it returns 0 or 1.
|
||||||
|
|
||||||
maxdist is the maximal edge distance where to look for a companion triangle
|
maxdist is the maximal edge distance where to look for a companion triangle
|
||||||
*/
|
*/
|
||||||
static int MakePureByFlipStepByStep(MeshType &m, int maxdist=10000, int restart=false){
|
static int MakePureByFlipStepByStep(MeshType &m, int maxdist=10000, int restart=false){
|
||||||
|
|
||||||
static FaceType *ta, *tb; // faces to be matched into a quad
|
static FaceType *ta, *tb; // faces to be matched into a quad
|
||||||
|
|
||||||
static int step = 0; // hack
|
static int step = 0; // hack
|
||||||
|
|
||||||
if (restart) { step=0; return false; }
|
if (restart) { step=0; return false; }
|
||||||
if (step==0) {
|
if (step==0) {
|
||||||
|
|
||||||
// find a triangular face ta
|
// find a triangular face ta
|
||||||
ta = NULL;
|
ta = NULL;
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) if (!fi->IsD()) {
|
||||||
if (!fi->IsAnyF()) { ta=&*fi; break; }
|
if (!fi->IsAnyF()) { ta=&*fi; break; }
|
||||||
}
|
}
|
||||||
if (!ta) return 0; // success: no triangle left (done?)
|
if (!ta) return 0; // success: no triangle left (done?)
|
||||||
|
|
||||||
|
|
||||||
tb = MarkEdgeDistance(m,ta,maxdist);
|
tb = MarkEdgeDistance(m,ta,maxdist);
|
||||||
if (!tb) return 1; // fail: no matching triagle found (increase maxdist?)
|
if (!tb) return 1; // fail: no matching triagle found (increase maxdist?)
|
||||||
|
|
||||||
step=1;
|
step=1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int marriageEdge=-1;
|
int marriageEdge=-1;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
|
|
||||||
int bestScore = int(tb->Q());
|
int bestScore = int(tb->Q());
|
||||||
int edge = -1;
|
int edge = -1;
|
||||||
bool mustDoFlip;
|
bool mustDoFlip;
|
||||||
|
|
||||||
// select which edge to use
|
// select which edge to use
|
||||||
for (int k=0; k<3; k++) {
|
for (int k=0; k<3; k++) {
|
||||||
if (tb->FFp(k) == tb) continue; // border
|
if (tb->FFp(k) == tb) continue; // border
|
||||||
|
|
||||||
FaceType* tbk = tb->FFp(k);
|
FaceType* tbk = tb->FFp(k);
|
||||||
|
|
||||||
if (!tbk->IsAnyF()) {done=true; marriageEdge=k; break; } // found my match
|
if (!tbk->IsAnyF()) {done=true; marriageEdge=k; break; } // found my match
|
||||||
|
|
||||||
int back = tb->FFi(k);
|
int back = tb->FFi(k);
|
||||||
int faux = BQ::FauxIndex(tbk);
|
int faux = BQ::FauxIndex(tbk);
|
||||||
int other = 3-back-faux;
|
int other = 3-back-faux;
|
||||||
|
|
||||||
int scoreA = int(tbk->FFp(other)->Q());
|
int scoreA = int(tbk->FFp(other)->Q());
|
||||||
|
|
||||||
FaceType* tbh = tbk->FFp(faux);
|
FaceType* tbh = tbk->FFp(faux);
|
||||||
int fauxh = BQ::FauxIndex(tbh);
|
int fauxh = BQ::FauxIndex(tbh);
|
||||||
|
|
||||||
int scoreB = int(tbh->FFp( (fauxh+1)%3 )->Q());
|
int scoreB = int(tbh->FFp( (fauxh+1)%3 )->Q());
|
||||||
int scoreC = int(tbh->FFp( (fauxh+2)%3 )->Q());
|
int scoreC = int(tbh->FFp( (fauxh+2)%3 )->Q());
|
||||||
|
|
||||||
int scoreABC = std::min( scoreC, std::min( scoreA, scoreB ) );
|
int scoreABC = std::min( scoreC, std::min( scoreA, scoreB ) );
|
||||||
if (scoreABC<bestScore) {
|
if (scoreABC<bestScore) {
|
||||||
bestScore = scoreABC;
|
bestScore = scoreABC;
|
||||||
|
|
@ -775,43 +774,43 @@ if (step==0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done) break;
|
if (done) break;
|
||||||
|
|
||||||
// use that edge to proceed
|
// use that edge to proceed
|
||||||
if (mustDoFlip) {
|
if (mustDoFlip) {
|
||||||
BQ::FlipDiag( *(tb->FFp(edge)) );
|
BQ::FlipDiag( *(tb->FFp(edge)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
FaceType* next = tb->FFp(edge)->FFp( BQ::FauxIndex(tb->FFp(edge)) );
|
FaceType* next = tb->FFp(edge)->FFp( BQ::FauxIndex(tb->FFp(edge)) );
|
||||||
|
|
||||||
// create new edge
|
// create new edge
|
||||||
next->ClearAllF();
|
next->ClearAllF();
|
||||||
tb->FFp(edge)->ClearAllF();
|
tb->FFp(edge)->ClearAllF();
|
||||||
|
|
||||||
// dissolve old edge
|
// dissolve old edge
|
||||||
tb->SetF(edge);
|
tb->SetF(edge);
|
||||||
tb->FFp(edge)->SetF( tb->FFi(edge) );
|
tb->FFp(edge)->SetF( tb->FFi(edge) );
|
||||||
tb->FFp(edge)->Q() = tb->Q();
|
tb->FFp(edge)->Q() = tb->Q();
|
||||||
|
|
||||||
tb = next;
|
tb = next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marriageEdge!=-1) {
|
if (marriageEdge!=-1) {
|
||||||
// consume the marriage (two tris = one quad)
|
// consume the marriage (two tris = one quad)
|
||||||
assert(!(tb->IsAnyF()));
|
assert(!(tb->IsAnyF()));
|
||||||
assert(!(tb->FFp(marriageEdge)->IsAnyF()));
|
assert(!(tb->FFp(marriageEdge)->IsAnyF()));
|
||||||
tb->SetF(marriageEdge);
|
tb->SetF(marriageEdge);
|
||||||
tb->FFp(marriageEdge)->SetF(tb->FFi(marriageEdge));
|
tb->FFp(marriageEdge)->SetF(tb->FFi(marriageEdge));
|
||||||
|
|
||||||
step=0;
|
step=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1; // not done yet
|
return -1; // not done yet
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
given a tri-quad mesh,
|
given a tri-quad mesh,
|
||||||
uses edge rotates to make a tri move toward another tri and to merges them into a quad.
|
uses edge rotates to make a tri move toward another tri and to merges them into a quad.
|
||||||
- maxdist is the maximal edge distance where to look for a companion triangle
|
- maxdist is the maximal edge distance where to look for a companion triangle
|
||||||
- retunrs true if all triangles are merged (always, unless they are odd, or maxdist not enough).
|
- retunrs true if all triangles are merged (always, unless they are odd, or maxdist not enough).
|
||||||
*/
|
*/
|
||||||
|
|
@ -825,18 +824,18 @@ static bool MakePureByFlip(MeshType &m, int maxdist=10000)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
given a triangle mesh, makes it quad dominant by merging triangle pairs into quads
|
given a triangle mesh, makes it quad dominant by merging triangle pairs into quads
|
||||||
various euristics:
|
various euristics:
|
||||||
level = 0: maximally greedy. Leaves fewest triangles
|
level = 0: maximally greedy. Leaves fewest triangles
|
||||||
level = 1: smarter: leaves more triangles, but makes better quality quads
|
level = 1: smarter: leaves more triangles, but makes better quality quads
|
||||||
level = 2: even more so (marginally)
|
level = 2: even more so (marginally)
|
||||||
*/
|
*/
|
||||||
static void MakeDominant(MeshType &m, int level){
|
static void MakeDominant(MeshType &m, int level){
|
||||||
|
|
||||||
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) {
|
for (FaceIterator fi = m.face.begin(); fi!=m.face.end(); fi++) {
|
||||||
fi->ClearAllF();
|
fi->ClearAllF();
|
||||||
fi->Q() = 0;
|
fi->Q() = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MakeDominantPass<false> (m);
|
MakeDominantPass<false> (m);
|
||||||
if (level>0) MakeDominantPass<true> (m);
|
if (level>0) MakeDominantPass<true> (m);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
#ifndef VCG_BITQUAD_SUPPORT
|
#ifndef VCG_BITQUAD_SUPPORT
|
||||||
#define VCG_BITQUAD_SUPPORT
|
#define VCG_BITQUAD_SUPPORT
|
||||||
#include <vector>
|
|
||||||
#include <set>
|
|
||||||
#include <vcg/simplex/face/jumping_pos.h>
|
#include <vcg/simplex/face/jumping_pos.h>
|
||||||
#include <vcg/simplex/face/topology.h>
|
#include <vcg/simplex/face/topology.h>
|
||||||
#include <vcg/space/planar_polygon_tessellation.h>
|
#include <vcg/space/planar_polygon_tessellation.h>
|
||||||
|
|
@ -811,8 +809,8 @@ static bool CollapseDiag(FaceType &f, ScalarType interpol, MeshType& m, Pos* aff
|
||||||
pf = t;
|
pf = t;
|
||||||
} while ((pf!=fb));
|
} while ((pf!=fb));
|
||||||
|
|
||||||
pi = fauxb;
|
pi = fauxb;
|
||||||
pf = fb;
|
pf = fb;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pf->V(pi) = va;
|
pf->V(pi) = va;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -15,27 +15,27 @@ namespace vcg {
|
||||||
* v0, v1 the active edge
|
* v0, v1 the active edge
|
||||||
* v2 internal vertex
|
* v2 internal vertex
|
||||||
*/
|
*/
|
||||||
class FrontEdge {
|
class FrontEdge {
|
||||||
public:
|
public:
|
||||||
int v0, v1, v2; //v0, v1 represent the FrontEdge, v2 the other vertex
|
int v0, v1, v2; //v0, v1 represent the FrontEdge, v2 the other vertex
|
||||||
//in the face this FrontEdge belongs to
|
//in the face this FrontEdge belongs to
|
||||||
bool active; //keep tracks of wether it is in front or in deads
|
bool active; //keep tracks of wether it is in front or in deads
|
||||||
|
|
||||||
//the loops in the front are mantained as a double linked list
|
//the loops in the front are mantained as a double linked list
|
||||||
std::list<FrontEdge>::iterator next;
|
std::list<FrontEdge>::iterator next;
|
||||||
std::list<FrontEdge>::iterator previous;
|
std::list<FrontEdge>::iterator previous;
|
||||||
|
|
||||||
FrontEdge() {}
|
FrontEdge() {}
|
||||||
FrontEdge(int _v0, int _v1, int _v2):
|
FrontEdge(int _v0, int _v1, int _v2):
|
||||||
v0(_v0), v1(_v1), v2(_v2), active(true) {
|
v0(_v0), v1(_v1), v2(_v2), active(true) {
|
||||||
assert(v0 != v1 && v1 != v2 && v0 != v2);
|
assert(v0 != v1 && v1 != v2 && v0 != v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const FrontEdge& f) const
|
bool operator==(const FrontEdge& f) const
|
||||||
{
|
{
|
||||||
return ((v0 == f.v0) && (v1 == f.v1) && (v2 == f.v2) );
|
return ((v0 == f.v0) && (v1 == f.v1) && (v2 == f.v2) );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class MESH> class AdvancingFront {
|
template <class MESH> class AdvancingFront {
|
||||||
public:
|
public:
|
||||||
|
|
@ -45,58 +45,58 @@ template <class MESH> class AdvancingFront {
|
||||||
typedef typename MESH::FaceIterator FaceIterator;
|
typedef typename MESH::FaceIterator FaceIterator;
|
||||||
typedef typename MESH::ScalarType ScalarType;
|
typedef typename MESH::ScalarType ScalarType;
|
||||||
typedef typename MESH::VertexType::CoordType Point3x;
|
typedef typename MESH::VertexType::CoordType Point3x;
|
||||||
|
|
||||||
//class FrontEdgeLists
|
//class FrontEdgeLists
|
||||||
//{
|
//{
|
||||||
|
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|
||||||
// protected:
|
// protected:
|
||||||
std::list<FrontEdge> front;
|
std::list<FrontEdge> front;
|
||||||
std::list<FrontEdge> deads;
|
std::list<FrontEdge> deads;
|
||||||
std::vector<int> nb; //number of fronts a vertex is into,
|
std::vector<int> nb; //number of fronts a vertex is into,
|
||||||
//this is used for the Visited and Border flags
|
//this is used for the Visited and Border flags
|
||||||
//but adding topology may not be needed anymore
|
//but adding topology may not be needed anymore
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MESH &mesh; //this structure will be filled by the algorithm
|
MESH &mesh; //this structure will be filled by the algorithm
|
||||||
|
|
||||||
AdvancingFront(MESH &_mesh): mesh(_mesh) {
|
AdvancingFront(MESH &_mesh): mesh(_mesh) {
|
||||||
|
|
||||||
|
|
||||||
UpdateFlags<MESH>::FaceBorderFromNone(mesh);
|
UpdateFlags<MESH>::FaceBorderFromNone(mesh);
|
||||||
UpdateFlags<MESH>::VertexBorderFromFace(mesh);
|
UpdateFlags<MESH>::VertexBorderFromFace(mesh);
|
||||||
|
|
||||||
nb.clear();
|
nb.clear();
|
||||||
nb.resize(mesh.vert.size(), 0);
|
nb.resize(mesh.vert.size(), 0);
|
||||||
|
|
||||||
CreateLoops();
|
CreateLoops();
|
||||||
}
|
}
|
||||||
virtual ~AdvancingFront() {}
|
virtual ~AdvancingFront() {}
|
||||||
|
|
||||||
void BuildMesh(CallBackPos call = NULL, int interval = 512)
|
void BuildMesh(CallBackPos call = NULL, int interval = 512)
|
||||||
{
|
{
|
||||||
float finalfacesext = mesh.vert.size() * 2.0f;
|
float finalfacesext = mesh.vert.size() * 2.0f;
|
||||||
if(call) call(0, "Advancing front");
|
if(call) call(0, "Advancing front");
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
for(int i = 0; i < interval; i++) {
|
for(int i = 0; i < interval; i++) {
|
||||||
if(!front.size() && !SeedFace()) return;
|
if(!front.size() && !SeedFace()) return;
|
||||||
AddFace();
|
AddFace();
|
||||||
if(call)
|
if(call)
|
||||||
{
|
{
|
||||||
float rap = float(mesh.face.size()) / finalfacesext;
|
float rap = float(mesh.face.size()) / finalfacesext;
|
||||||
int perc = (int) (100.0f * rap);
|
int perc = (int) (100.0f * rap);
|
||||||
(*call)(perc,"Adding Faces");
|
(*call)(perc,"Adding Faces");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//Implement these functions in your subclass
|
//Implement these functions in your subclass
|
||||||
enum ListID {FRONT,DEADS};
|
enum ListID {FRONT,DEADS};
|
||||||
typedef std::pair< ListID,std::list<FrontEdge>::iterator > ResultIterator;
|
typedef std::pair< ListID,std::list<FrontEdge>::iterator > ResultIterator;
|
||||||
virtual bool Seed(int &v0, int &v1, int &v2) = 0;
|
virtual bool Seed(int &v0, int &v1, int &v2) = 0;
|
||||||
|
|
@ -109,20 +109,20 @@ protected:
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < mesh.face.size(); i++)
|
for(size_t i = 0; i < mesh.face.size(); i++)
|
||||||
{
|
{
|
||||||
FaceType &f = mesh.face[i];
|
FaceType &f = mesh.face[i];
|
||||||
if(f.IsD()) continue;
|
if(f.IsD()) continue;
|
||||||
|
|
||||||
for(int k = 0; k < 3; k++) {
|
for(int k = 0; k < 3; k++) {
|
||||||
if(f.IsB(k)) {
|
if(f.IsB(k)) {
|
||||||
addNewEdge(FrontEdge(tri::Index(mesh,f.V0(k)),tri::Index(mesh,f.V1(k)),tri::Index(mesh,f.V2(k))) );
|
addNewEdge(FrontEdge(tri::Index(mesh,f.V0(k)),tri::Index(mesh,f.V1(k)),tri::Index(mesh,f.V2(k))) );
|
||||||
nb[tri::Index(mesh,f.V0(k))]++;
|
nb[tri::Index(mesh,f.V0(k))]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
||||||
(*s).previous = front.end();
|
(*s).previous = front.end();
|
||||||
(*s).next = front.end();
|
(*s).next = front.end();
|
||||||
}
|
}
|
||||||
//now create loops:
|
//now create loops:
|
||||||
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
||||||
|
|
@ -131,90 +131,90 @@ protected:
|
||||||
if((*s).v1 != (*j).v0) continue;
|
if((*s).v1 != (*j).v0) continue;
|
||||||
if((*j).previous != front.end()) continue;
|
if((*j).previous != front.end()) continue;
|
||||||
(*s).next = j;
|
(*s).next = j;
|
||||||
(*j).previous = s;
|
(*j).previous = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
for(std::list<FrontEdge>::iterator s = front.begin(); s != front.end(); s++) {
|
||||||
assert((*s).next != front.end());
|
assert((*s).next != front.end());
|
||||||
assert((*s).previous != front.end());
|
assert((*s).previous != front.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SeedFace() {
|
bool SeedFace() {
|
||||||
int v[3];
|
int v[3];
|
||||||
bool success = Seed(v[0], v[1], v[2]);
|
bool success = Seed(v[0], v[1], v[2]);
|
||||||
if(!success) return false;
|
if(!success) return false;
|
||||||
|
|
||||||
nb.resize(mesh.vert.size(), 0);
|
nb.resize(mesh.vert.size(), 0);
|
||||||
|
|
||||||
//create the border of the first face
|
//create the border of the first face
|
||||||
std::list<FrontEdge>::iterator e = front.end();
|
std::list<FrontEdge>::iterator e = front.end();
|
||||||
std::list<FrontEdge>::iterator last = e;
|
std::list<FrontEdge>::iterator last = e;
|
||||||
std::list<FrontEdge>::iterator first;
|
std::list<FrontEdge>::iterator first;
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++) {
|
for(int i = 0; i < 3; i++) {
|
||||||
int v0 = v[i];
|
int v0 = v[i];
|
||||||
int v1 = v[((i+1)%3)];
|
int v1 = v[((i+1)%3)];
|
||||||
int v2 = v[((i+2)%3)];
|
int v2 = v[((i+2)%3)];
|
||||||
|
|
||||||
mesh.vert[v0].SetB();
|
mesh.vert[v0].SetB();
|
||||||
nb[v[i]]++;
|
nb[v[i]]++;
|
||||||
|
|
||||||
e = front.insert(front.begin(), FrontEdge(v0, v1, v2));
|
e = front.insert(front.begin(), FrontEdge(v0, v1, v2));
|
||||||
if(i != 0) {
|
if(i != 0) {
|
||||||
(*last).next = e;
|
(*last).next = e;
|
||||||
(*e).previous = last;
|
(*e).previous = last;
|
||||||
} else
|
} else
|
||||||
first = e;
|
first = e;
|
||||||
|
|
||||||
last = e;
|
last = e;
|
||||||
}
|
}
|
||||||
//connect last and first
|
//connect last and first
|
||||||
(*last).next = first;
|
(*last).next = first;
|
||||||
(*first).previous = last;
|
(*first).previous = last;
|
||||||
|
|
||||||
AddFace(v[0], v[1], v[2]);
|
AddFace(v[0], v[1], v[2]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool AddFace() {
|
bool AddFace() {
|
||||||
if(!front.size()) return false;
|
if(!front.size()) return false;
|
||||||
|
|
||||||
std::list<FrontEdge>::iterator ei = front.begin();
|
std::list<FrontEdge>::iterator ei = front.begin();
|
||||||
FrontEdge ¤t = *ei;
|
FrontEdge ¤t = *ei;
|
||||||
FrontEdge &previous = *current.previous;
|
FrontEdge &previous = *current.previous;
|
||||||
FrontEdge &next = *current.next;
|
FrontEdge &next = *current.next;
|
||||||
|
|
||||||
int v0 = current.v0, v1 = current.v1;
|
int v0 = current.v0, v1 = current.v1;
|
||||||
assert(nb[v0] < 10 && nb[v1] < 10);
|
assert(nb[v0] < 10 && nb[v1] < 10);
|
||||||
|
|
||||||
ResultIterator touch;
|
ResultIterator touch;
|
||||||
touch.first = FRONT;
|
touch.first = FRONT;
|
||||||
touch.second = front.end();
|
touch.second = front.end();
|
||||||
int v2 = Place(current, touch);
|
int v2 = Place(current, touch);
|
||||||
|
|
||||||
if(v2 == -1) {
|
if(v2 == -1) {
|
||||||
KillEdge(ei);
|
KillEdge(ei);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(v2 != v0 && v2 != v1);
|
|
||||||
|
|
||||||
if ((touch.first == FRONT) && (touch.second != front.end()) ||
|
|
||||||
(touch.first == DEADS) && (touch.second != deads.end()))
|
|
||||||
|
|
||||||
{
|
assert(v2 != v0 && v2 != v1);
|
||||||
//check for orientation and manifoldness
|
|
||||||
|
if ( ( (touch.first == FRONT) && (touch.second != front.end()) ) ||
|
||||||
//touch == current.previous?
|
( (touch.first == DEADS) && (touch.second != deads.end()) ) )
|
||||||
if(v2 == previous.v0) {
|
|
||||||
|
{
|
||||||
|
//check for orientation and manifoldness
|
||||||
|
|
||||||
|
//touch == current.previous?
|
||||||
|
if(v2 == previous.v0) {
|
||||||
if(!CheckEdge(v2, v1)) {
|
if(!CheckEdge(v2, v1)) {
|
||||||
KillEdge(ei);
|
KillEdge(ei);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*touching previous FrontEdge (we reuse previous)
|
/*touching previous FrontEdge (we reuse previous)
|
||||||
next
|
next
|
||||||
------->v2 -----> v1------>
|
------->v2 -----> v1------>
|
||||||
\ /
|
\ /
|
||||||
|
|
@ -222,9 +222,9 @@ public:
|
||||||
previous \ / current
|
previous \ / current
|
||||||
\ /
|
\ /
|
||||||
v0 */
|
v0 */
|
||||||
|
|
||||||
Detach(v0);
|
Detach(v0);
|
||||||
|
|
||||||
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v2, v1, v0));
|
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v2, v1, v0));
|
||||||
MoveFront(up);
|
MoveFront(up);
|
||||||
(*up).previous = previous.previous;
|
(*up).previous = previous.previous;
|
||||||
|
|
@ -235,21 +235,21 @@ public:
|
||||||
Erase(ei);
|
Erase(ei);
|
||||||
Glue(up);
|
Glue(up);
|
||||||
|
|
||||||
//touch == (*current.next).next
|
//touch == (*current.next).next
|
||||||
} else if(v2 == next.v1) {
|
} else if(v2 == next.v1) {
|
||||||
if(!CheckEdge(v0, v2)) {
|
if(!CheckEdge(v0, v2)) {
|
||||||
KillEdge(ei);
|
KillEdge(ei);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/*touching next FrontEdge (we reuse next)
|
/*touching next FrontEdge (we reuse next)
|
||||||
previous
|
previous
|
||||||
------->v0 -----> v2------>
|
------->v0 -----> v2------>
|
||||||
\ /
|
\ /
|
||||||
\ /
|
\ /
|
||||||
\ / next
|
\ / next
|
||||||
\ /
|
\ /
|
||||||
v1 */
|
v1 */
|
||||||
|
|
||||||
Detach(v1);
|
Detach(v1);
|
||||||
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
||||||
MoveFront(up);
|
MoveFront(up);
|
||||||
|
|
@ -264,10 +264,10 @@ public:
|
||||||
if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) {
|
if(!CheckEdge(v0, v2) || !CheckEdge(v2, v1)) {
|
||||||
KillEdge(ei);
|
KillEdge(ei);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//touching some loop: split (or merge it is local does not matter.
|
//touching some loop: split (or merge it is local does not matter.
|
||||||
//like this
|
//like this
|
||||||
/*
|
/*
|
||||||
left right
|
left right
|
||||||
<--------v2-<------
|
<--------v2-<------
|
||||||
/|\
|
/|\
|
||||||
|
|
@ -276,44 +276,44 @@ public:
|
||||||
/ \
|
/ \
|
||||||
/ V
|
/ V
|
||||||
----v0 - - - > v1---------
|
----v0 - - - > v1---------
|
||||||
current */
|
current */
|
||||||
std::list<FrontEdge>::iterator left = touch.second;
|
std::list<FrontEdge>::iterator left = touch.second;
|
||||||
std::list<FrontEdge>::iterator right = (*touch.second).previous;
|
std::list<FrontEdge>::iterator right = (*touch.second).previous;
|
||||||
|
|
||||||
//this would be a really bad join
|
//this would be a really bad join
|
||||||
if(v1 == (*right).v0 || v0 == (*left).v1) {
|
if(v1 == (*right).v0 || v0 == (*left).v1) {
|
||||||
KillEdge(ei);
|
KillEdge(ei);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nb[v2]++;
|
nb[v2]++;
|
||||||
|
|
||||||
std::list<FrontEdge>::iterator down = addNewEdge(FrontEdge(v2, v1, v0));
|
std::list<FrontEdge>::iterator down = addNewEdge(FrontEdge(v2, v1, v0));
|
||||||
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
||||||
|
|
||||||
(*right).next = down;
|
(*right).next = down;
|
||||||
(*down).previous = right;
|
(*down).previous = right;
|
||||||
|
|
||||||
(*down).next = current.next;
|
(*down).next = current.next;
|
||||||
next.previous = down;
|
next.previous = down;
|
||||||
|
|
||||||
(*left).previous = up;
|
(*left).previous = up;
|
||||||
(*up).next = left;
|
(*up).next = left;
|
||||||
|
|
||||||
(*up).previous = current.previous;
|
(*up).previous = current.previous;
|
||||||
previous.next = up;
|
previous.next = up;
|
||||||
Erase(ei);
|
Erase(ei);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if ((touch.first == FRONT) && (touch.second == front.end()) ||
|
else if (((touch.first == FRONT) && (touch.second == front.end())) ||
|
||||||
(touch.first == DEADS) && (touch.second == deads.end()))
|
((touch.first == DEADS) && (touch.second == deads.end())) )
|
||||||
{
|
{
|
||||||
// assert(CheckEdge(v0, v2));
|
// assert(CheckEdge(v0, v2));
|
||||||
// assert(CheckEdge(v2, v1));
|
// assert(CheckEdge(v2, v1));
|
||||||
/* adding a new vertex
|
/* adding a new vertex
|
||||||
|
|
||||||
v2
|
v2
|
||||||
/|\
|
/|\
|
||||||
/ \
|
/ \
|
||||||
|
|
@ -322,12 +322,12 @@ public:
|
||||||
/ V
|
/ V
|
||||||
----v0 - - - > v1--------- */
|
----v0 - - - > v1--------- */
|
||||||
assert(!mesh.vert[v2].IsB()); //fatal error! a new point is already a border?
|
assert(!mesh.vert[v2].IsB()); //fatal error! a new point is already a border?
|
||||||
nb[v2]++;
|
nb[v2]++;
|
||||||
mesh.vert[v2].SetB();
|
mesh.vert[v2].SetB();
|
||||||
|
|
||||||
std::list<FrontEdge>::iterator down = addNewEdge(FrontEdge(v2, v1, v0));
|
std::list<FrontEdge>::iterator down = addNewEdge(FrontEdge(v2, v1, v0));
|
||||||
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
std::list<FrontEdge>::iterator up = addNewEdge(FrontEdge(v0, v2, v1));
|
||||||
|
|
||||||
(*down).previous = up;
|
(*down).previous = up;
|
||||||
(*up).next = down;
|
(*up).next = down;
|
||||||
(*down).next = current.next;
|
(*down).next = current.next;
|
||||||
|
|
@ -339,11 +339,11 @@ public:
|
||||||
|
|
||||||
AddFace(v0, v2, v1);
|
AddFace(v0, v2, v1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddFace(int v0, int v1, int v2) {
|
void AddFace(int v0, int v1, int v2) {
|
||||||
assert(v0 < (int)mesh.vert.size() && v1 < (int)mesh.vert.size() && v2 < (int)mesh.vert.size());
|
assert(v0 < (int)mesh.vert.size() && v1 < (int)mesh.vert.size() && v2 < (int)mesh.vert.size());
|
||||||
FaceIterator fi = vcg::tri::Allocator<MESH>::AddFaces(mesh,1);
|
FaceIterator fi = vcg::tri::Allocator<MESH>::AddFaces(mesh,1);
|
||||||
fi->ClearFlags();
|
fi->ClearFlags();
|
||||||
fi->V(0) = &mesh.vert[v0];
|
fi->V(0) = &mesh.vert[v0];
|
||||||
|
|
@ -361,17 +361,17 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddVertex(VertexType &vertex) {
|
void AddVertex(VertexType &vertex) {
|
||||||
VertexType *oldstart = NULL;
|
VertexType *oldstart = NULL;
|
||||||
if(mesh.vert.size()) oldstart = &*mesh.vert.begin();
|
if(mesh.vert.size()) oldstart = &*mesh.vert.begin();
|
||||||
mesh.vert.push_back(vertex);
|
mesh.vert.push_back(vertex);
|
||||||
mesh.vn++;
|
mesh.vn++;
|
||||||
VertexType *newstart = &*mesh.vert.begin();
|
VertexType *newstart = &*mesh.vert.begin();
|
||||||
if(oldstart && oldstart != newstart) {
|
if(oldstart && oldstart != newstart) {
|
||||||
for(int i = 0; i < mesh.face.size(); i++) {
|
for(int i = 0; i < mesh.face.size(); i++) {
|
||||||
FaceType &face = mesh.face[i];
|
FaceType &face = mesh.face[i];
|
||||||
for(int k = 0; k < 3; k++)
|
for(int k = 0; k < 3; k++)
|
||||||
face.V(k) = newstart + (face.V(k) - oldstart);
|
face.V(k) = newstart + (face.V(k) - oldstart);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -386,7 +386,7 @@ protected:
|
||||||
bool CheckEdge(int v0, int v1) {
|
bool CheckEdge(int v0, int v1) {
|
||||||
int tot = 0;
|
int tot = 0;
|
||||||
VertexType *vv0 = &(mesh.vert[v0]);
|
VertexType *vv0 = &(mesh.vert[v0]);
|
||||||
VertexType *vv1 = &(mesh.vert[v1]);
|
VertexType *vv1 = &(mesh.vert[v1]);
|
||||||
if(tri::HasVFAdjacency(mesh))
|
if(tri::HasVFAdjacency(mesh))
|
||||||
{
|
{
|
||||||
face::VFIterator<FaceType> vfi(vv0);
|
face::VFIterator<FaceType> vfi(vv0);
|
||||||
|
|
@ -401,11 +401,11 @@ protected:
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < (int)mesh.face.size(); i++) {
|
for(int i = 0; i < (int)mesh.face.size(); i++) {
|
||||||
FaceType &f = mesh.face[i];
|
FaceType &f = mesh.face[i];
|
||||||
for(int k = 0; k < 3; k++) {
|
for(int k = 0; k < 3; k++) {
|
||||||
if(vv0 == f.V0(k) && vv1 == f.V1(k)) //orientation non constistent
|
if(vv0 == f.V0(k) && vv1 == f.V1(k)) //orientation non constistent
|
||||||
return false;
|
return false;
|
||||||
else if(vv1 == f.V0(k) && vv0 == f.V1(k)) ++tot;
|
else if(vv1 == f.V0(k) && vv0 == f.V1(k)) ++tot;
|
||||||
}
|
}
|
||||||
if(tot >= 2) { //non manifold
|
if(tot >= 2) { //non manifold
|
||||||
|
|
@ -413,71 +413,71 @@ protected:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//front management:
|
//front management:
|
||||||
|
|
||||||
//Add a new FrontEdge to the back of the queue
|
//Add a new FrontEdge to the back of the queue
|
||||||
std::list<FrontEdge>::iterator addNewEdge(FrontEdge e) {
|
std::list<FrontEdge>::iterator addNewEdge(FrontEdge e) {
|
||||||
return front.insert(front.end(), e);
|
return front.insert(front.end(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//move an Edge among the dead ones
|
//move an Edge among the dead ones
|
||||||
void KillEdge(std::list<FrontEdge>::iterator e)
|
void KillEdge(std::list<FrontEdge>::iterator e)
|
||||||
{
|
{
|
||||||
if (e->active)
|
if (e->active)
|
||||||
{
|
{
|
||||||
(*e).active = false;
|
(*e).active = false;
|
||||||
//std::list<FrontEdge>::iterator res = std::find(front.begin(),front.end(),e);
|
//std::list<FrontEdge>::iterator res = std::find(front.begin(),front.end(),e);
|
||||||
FrontEdge tmp = *e;
|
FrontEdge tmp = *e;
|
||||||
deads.splice(deads.end(), front, e);
|
deads.splice(deads.end(), front, e);
|
||||||
std::list<FrontEdge>::iterator newe = std::find(deads.begin(),deads.end(),tmp);
|
std::list<FrontEdge>::iterator newe = std::find(deads.begin(),deads.end(),tmp);
|
||||||
tmp.previous->next = newe;
|
tmp.previous->next = newe;
|
||||||
tmp.next->previous = newe;
|
tmp.next->previous = newe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Erase(std::list<FrontEdge>::iterator e) {
|
void Erase(std::list<FrontEdge>::iterator e) {
|
||||||
if((*e).active) front.erase(e);
|
if((*e).active) front.erase(e);
|
||||||
else deads.erase(e);
|
else deads.erase(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//move an FrontEdge to the back of the queue
|
//move an FrontEdge to the back of the queue
|
||||||
void MoveBack(std::list<FrontEdge>::iterator e) {
|
void MoveBack(std::list<FrontEdge>::iterator e) {
|
||||||
front.splice(front.end(), front, e);
|
front.splice(front.end(), front, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveFront(std::list<FrontEdge>::iterator e) {
|
void MoveFront(std::list<FrontEdge>::iterator e) {
|
||||||
front.splice(front.begin(), front, e);
|
front.splice(front.begin(), front, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if e can be sewed with one of oits neighbours
|
//check if e can be sewed with one of oits neighbours
|
||||||
bool Glue(std::list<FrontEdge>::iterator e) {
|
bool Glue(std::list<FrontEdge>::iterator e) {
|
||||||
return Glue((*e).previous, e) || Glue(e, (*e).next);
|
return Glue((*e).previous, e) || Glue(e, (*e).next);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Glue toghether a and b (where a.next = b
|
//Glue toghether a and b (where a.next = b
|
||||||
bool Glue(std::list<FrontEdge>::iterator a, std::list<FrontEdge>::iterator b) {
|
bool Glue(std::list<FrontEdge>::iterator a, std::list<FrontEdge>::iterator b) {
|
||||||
if((*a).v0 != (*b).v1) return false;
|
if((*a).v0 != (*b).v1) return false;
|
||||||
|
|
||||||
std::list<FrontEdge>::iterator previous = (*a).previous;
|
std::list<FrontEdge>::iterator previous = (*a).previous;
|
||||||
std::list<FrontEdge>::iterator next = (*b).next;
|
std::list<FrontEdge>::iterator next = (*b).next;
|
||||||
(*previous).next = next;
|
(*previous).next = next;
|
||||||
(*next).previous = previous;
|
(*next).previous = previous;
|
||||||
Detach((*a).v1);
|
Detach((*a).v1);
|
||||||
Detach((*a).v0);
|
Detach((*a).v0);
|
||||||
Erase(a);
|
Erase(a);
|
||||||
Erase(b);
|
Erase(b);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detach(int v) {
|
void Detach(int v) {
|
||||||
assert(nb[v] > 0);
|
assert(nb[v] > 0);
|
||||||
if(--nb[v] == 0) {
|
if(--nb[v] == 0) {
|
||||||
mesh.vert[v].ClearB();
|
mesh.vert[v].ClearB();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class MESH> class AdvancingTest: public AdvancingFront<MESH> {
|
template <class MESH> class AdvancingTest: public AdvancingFront<MESH> {
|
||||||
public:
|
public:
|
||||||
typedef typename MESH::VertexType VertexType;
|
typedef typename MESH::VertexType VertexType;
|
||||||
|
|
@ -487,10 +487,10 @@ template <class MESH> class AdvancingTest: public AdvancingFront<MESH> {
|
||||||
|
|
||||||
typedef typename MESH::ScalarType ScalarType;
|
typedef typename MESH::ScalarType ScalarType;
|
||||||
typedef typename MESH::VertexType::CoordType Point3x;
|
typedef typename MESH::VertexType::CoordType Point3x;
|
||||||
|
|
||||||
AdvancingTest(MESH &_mesh): AdvancingFront<MESH>(_mesh) {}
|
AdvancingTest(MESH &_mesh): AdvancingFront<MESH>(_mesh) {}
|
||||||
|
|
||||||
bool Seed(int &v0, int &v1, int &v2) {
|
bool Seed(int &v0, int &v1, int &v2) {
|
||||||
VertexType v[3];
|
VertexType v[3];
|
||||||
v[0].P() = Point3x(0, 0, 0);
|
v[0].P() = Point3x(0, 0, 0);
|
||||||
v[1].P() = Point3x(1, 0, 0);
|
v[1].P() = Point3x(1, 0, 0);
|
||||||
|
|
@ -507,7 +507,7 @@ template <class MESH> class AdvancingTest: public AdvancingFront<MESH> {
|
||||||
AddVertex(v[2]);
|
AddVertex(v[2]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Place(FrontEdge &e, typename AdvancingFront<MESH>::ResultIterator &touch)
|
int Place(FrontEdge &e, typename AdvancingFront<MESH>::ResultIterator &touch)
|
||||||
{
|
{
|
||||||
Point3f p[3];
|
Point3f p[3];
|
||||||
|
|
@ -517,31 +517,31 @@ template <class MESH> class AdvancingTest: public AdvancingFront<MESH> {
|
||||||
Point3f point = p[0] + p[1] - p[2];
|
Point3f point = p[0] + p[1] - p[2];
|
||||||
|
|
||||||
int vn = this->mesh.vert.size();
|
int vn = this->mesh.vert.size();
|
||||||
for(int i = 0; i < this->mesh.vert.size(); i++)
|
for(int i = 0; i < this->mesh.vert.size(); i++)
|
||||||
{
|
{
|
||||||
if((this->mesh.vert[i].P() - point).Norm() < 0.1)
|
if((this->mesh.vert[i].P() - point).Norm() < 0.1)
|
||||||
{
|
{
|
||||||
vn = i;
|
vn = i;
|
||||||
//find the border
|
//find the border
|
||||||
assert(this->mesh.vert[i].IsB());
|
assert(this->mesh.vert[i].IsB());
|
||||||
for(std::list<FrontEdge>::iterator k = this->front.begin(); k != this->front.end(); k++)
|
for(std::list<FrontEdge>::iterator k = this->front.begin(); k != this->front.end(); k++)
|
||||||
if((*k).v0 == i)
|
if((*k).v0 == i)
|
||||||
{
|
{
|
||||||
touch.first = AdvancingFront<MESH>::FRONT;
|
touch.first = AdvancingFront<MESH>::FRONT;
|
||||||
touch.second = k;
|
touch.second = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<FrontEdge>::iterator k = this->deads.begin(); k != this->deads.end(); k++)
|
for(std::list<FrontEdge>::iterator k = this->deads.begin(); k != this->deads.end(); k++)
|
||||||
if((*k).v0 == i)
|
if((*k).v0 == i)
|
||||||
if((*k).v0 == i)
|
if((*k).v0 == i)
|
||||||
{
|
{
|
||||||
touch.first = AdvancingFront<MESH>::FRONT;
|
touch.first = AdvancingFront<MESH>::FRONT;
|
||||||
touch.second = k;
|
touch.second = k;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(vn == this->mesh.vert.size()) {
|
if(vn == this->mesh.vert.size()) {
|
||||||
VertexType v;
|
VertexType v;
|
||||||
v.P() = point;
|
v.P() = point;
|
||||||
v.ClearFlags();
|
v.ClearFlags();
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -8,7 +8,7 @@
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
|
|
@ -24,10 +24,6 @@
|
||||||
#ifndef __VCGLIB_APPEND
|
#ifndef __VCGLIB_APPEND
|
||||||
#define __VCGLIB_APPEND
|
#define __VCGLIB_APPEND
|
||||||
|
|
||||||
#include <vcg/complex/algorithms/update/flag.h>
|
|
||||||
#include <vcg/complex/algorithms/update/selection.h>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
namespace vcg {
|
namespace vcg {
|
||||||
namespace tri {
|
namespace tri {
|
||||||
/** \ingroup trimesh */
|
/** \ingroup trimesh */
|
||||||
|
|
@ -68,7 +64,7 @@ public:
|
||||||
typedef typename ConstMeshRight::FacePointer FacePointerRight;
|
typedef typename ConstMeshRight::FacePointer FacePointerRight;
|
||||||
|
|
||||||
struct Remap{
|
struct Remap{
|
||||||
std::vector<int> vert,face,edge, hedge;
|
std::vector<int> vert,face,edge, hedge;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ImportVertexAdj(MeshLeft &ml, ConstMeshRight &mr, VertexLeft &vl, VertexRight &vr, Remap &remap ){
|
static void ImportVertexAdj(MeshLeft &ml, ConstMeshRight &mr, VertexLeft &vl, VertexRight &vr, Remap &remap ){
|
||||||
|
|
@ -175,7 +171,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append Right Mesh to the Left Mesh
|
// Append Right Mesh to the Left Mesh
|
||||||
// Append::Mesh(ml, mr) is equivalent to ml += mr.
|
// Append::Mesh(ml, mr) is equivalent to ml += mr.
|
||||||
// Note MeshRigth could be costant...
|
// Note MeshRigth could be costant...
|
||||||
/*! \brief %Append the second mesh to the first one.
|
/*! \brief %Append the second mesh to the first one.
|
||||||
|
|
||||||
|
|
@ -316,60 +312,60 @@ static void Mesh(MeshLeft& ml, ConstMeshRight& mr, const bool selected = false,
|
||||||
ImportHEdgeAdj(ml,mr,ml.hedge[remap.hedge[Index(mr,*hi)]],*hi,remap,selected);
|
ImportHEdgeAdj(ml,mr,ml.hedge[remap.hedge[Index(mr,*hi)]],*hi,remap,selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// phase 3.
|
// phase 3.
|
||||||
// take care of other per mesh data: textures, attributes
|
// take care of other per mesh data: textures, attributes
|
||||||
|
|
||||||
// At the end concatenate the vector with texture names.
|
// At the end concatenate the vector with texture names.
|
||||||
ml.textures.insert(ml.textures.end(),mr.textures.begin(),mr.textures.end());
|
ml.textures.insert(ml.textures.end(),mr.textures.begin(),mr.textures.end());
|
||||||
|
|
||||||
// Attributes. Copy only those attributes that are present in both meshes
|
// Attributes. Copy only those attributes that are present in both meshes
|
||||||
// Two attributes in different meshes are considered the same if they have the same
|
// Two attributes in different meshes are considered the same if they have the same
|
||||||
// name and the same type. This may be deceiving because they could in fact have
|
// name and the same type. This may be deceiving because they could in fact have
|
||||||
// different semantic, but this is up to the developer.
|
// different semantic, but this is up to the developer.
|
||||||
// If the left mesh has attributes that are not in the right mesh, their values for the elements
|
// If the left mesh has attributes that are not in the right mesh, their values for the elements
|
||||||
// of the right mesh will be uninitialized
|
// of the right mesh will be uninitialized
|
||||||
|
|
||||||
unsigned int id_r;
|
unsigned int id_r;
|
||||||
typename std::set< PointerToAttribute >::iterator al, ar;
|
typename std::set< PointerToAttribute >::iterator al, ar;
|
||||||
|
|
||||||
// per vertex attributes
|
// per vertex attributes
|
||||||
for(al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al)
|
for(al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al)
|
||||||
if(!(*al)._name.empty()){
|
if(!(*al)._name.empty()){
|
||||||
ar = mr.vert_attr.find(*al);
|
ar = mr.vert_attr.find(*al);
|
||||||
if(ar!= mr.vert_attr.end()){
|
if(ar!= mr.vert_attr.end()){
|
||||||
id_r = 0;
|
id_r = 0;
|
||||||
for(vi=mr.vert.begin();vi!=mr.vert.end();++vi,++id_r)
|
for(vi=mr.vert.begin();vi!=mr.vert.end();++vi,++id_r)
|
||||||
if( !(*vi).IsD() && (!selected || (*vi).IsS()))
|
if( !(*vi).IsD() && (!selected || (*vi).IsS()))
|
||||||
memcpy((*al)._handle->At(remap.vert[Index(mr,*vi)]),(*ar)._handle->At(id_r),
|
memcpy((*al)._handle->At(remap.vert[Index(mr,*vi)]),(*ar)._handle->At(id_r),
|
||||||
(*al)._handle->SizeOf());
|
(*al)._handle->SizeOf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// per edge attributes
|
// per edge attributes
|
||||||
for(al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al)
|
for(al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al)
|
||||||
if(!(*al)._name.empty()){
|
if(!(*al)._name.empty()){
|
||||||
ar = mr.edge_attr.find(*al);
|
ar = mr.edge_attr.find(*al);
|
||||||
if(ar!= mr.edge_attr.end()){
|
if(ar!= mr.edge_attr.end()){
|
||||||
id_r = 0;
|
id_r = 0;
|
||||||
for(ei=mr.edge.begin();ei!=mr.edge.end();++ei,++id_r)
|
for(ei=mr.edge.begin();ei!=mr.edge.end();++ei,++id_r)
|
||||||
if( !(*ei).IsD() && (!selected || (*ei).IsS()))
|
if( !(*ei).IsD() && (!selected || (*ei).IsS()))
|
||||||
memcpy((*al)._handle->At(remap.edge[Index(mr,*ei)]),(*ar)._handle->At(id_r),
|
memcpy((*al)._handle->At(remap.edge[Index(mr,*ei)]),(*ar)._handle->At(id_r),
|
||||||
(*al)._handle->SizeOf());
|
(*al)._handle->SizeOf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// per face attributes
|
// per face attributes
|
||||||
for(al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al)
|
for(al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al)
|
||||||
if(!(*al)._name.empty()){
|
if(!(*al)._name.empty()){
|
||||||
ar = mr.face_attr.find(*al);
|
ar = mr.face_attr.find(*al);
|
||||||
if(ar!= mr.face_attr.end()){
|
if(ar!= mr.face_attr.end()){
|
||||||
id_r = 0;
|
id_r = 0;
|
||||||
for(fi=mr.face.begin();fi!=mr.face.end();++fi,++id_r)
|
for(fi=mr.face.begin();fi!=mr.face.end();++fi,++id_r)
|
||||||
if( !(*fi).IsD() && (!selected || (*fi).IsS()))
|
if( !(*fi).IsD() && (!selected || (*fi).IsS()))
|
||||||
memcpy((*al)._handle->At(remap.face[Index(mr,*fi)]),(*ar)._handle->At(id_r),
|
memcpy((*al)._handle->At(remap.face[Index(mr,*fi)]),(*ar)._handle->At(id_r),
|
||||||
(*al)._handle->SizeOf());
|
(*al)._handle->SizeOf());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// per mesh attributes
|
// per mesh attributes
|
||||||
// if both ml and mr have an attribute with the same name, no action is done
|
// if both ml and mr have an attribute with the same name, no action is done
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
* \ *
|
* \ *
|
||||||
* All rights reserved. *
|
* All rights reserved. *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
|
|
@ -21,21 +21,30 @@
|
||||||
* *
|
* *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __VCG_MESH
|
#ifndef __VCG_MESH_H
|
||||||
|
#define __VCG_MESH_H
|
||||||
#define __VCG_MESH
|
#define __VCG_MESH
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <exception>
|
#include <stack>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <map>
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdexcept>
|
||||||
|
#include <limits>
|
||||||
|
#include <set>
|
||||||
#include <vcg/complex/exception.h>
|
#include <vcg/complex/exception.h>
|
||||||
#include <vcg/container/simple_temporary_data.h>
|
#include <vcg/container/simple_temporary_data.h>
|
||||||
#include <vcg/complex/used_types.h>
|
#include <vcg/complex/used_types.h>
|
||||||
#include <vcg/complex/base.h>
|
#include <vcg/complex/base.h>
|
||||||
#include <vcg/complex/allocate.h>
|
#include <vcg/complex/allocate.h>
|
||||||
|
#include <vcg/complex/algorithms/update/flag.h>
|
||||||
|
#include <vcg/complex/algorithms/update/selection.h>
|
||||||
#include <vcg/complex/append.h>
|
#include <vcg/complex/append.h>
|
||||||
|
|
||||||
|
#undef __VCG_MESH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue