2006-01-11 16:45:21 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* 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 __VCGLIB_APPEND
|
|
|
|
#define __VCGLIB_APPEND
|
|
|
|
|
2011-04-01 19:06:52 +02:00
|
|
|
#include <vcg/complex/allocate.h>
|
|
|
|
#include <vcg/complex/algorithms/update/flag.h>
|
2011-06-01 15:39:31 +02:00
|
|
|
#include <set>
|
2006-01-11 16:45:21 +01:00
|
|
|
|
|
|
|
namespace vcg {
|
|
|
|
namespace tri {
|
|
|
|
|
|
|
|
template<class MeshLeft, class MeshRight>
|
|
|
|
class Append
|
|
|
|
{
|
|
|
|
public:
|
2010-06-16 18:30:24 +02:00
|
|
|
typedef typename MeshLeft::ScalarType ScalarLeft;
|
|
|
|
typedef typename MeshLeft::CoordType CoordLeft;
|
|
|
|
typedef typename MeshLeft::VertexType VertexLeft;
|
|
|
|
typedef typename MeshLeft::EdgeType EdgeLeft;
|
|
|
|
typedef typename MeshLeft::FaceType FaceLeft;
|
|
|
|
typedef typename MeshLeft::HEdgeType HEdgeLeft;
|
|
|
|
typedef typename MeshLeft::VertexPointer VertexPointerLeft;
|
|
|
|
typedef typename MeshLeft::VertexIterator VertexIteratorLeft;
|
|
|
|
typedef typename MeshLeft::EdgeIterator EdgeIteratorLeft;
|
|
|
|
typedef typename MeshLeft::HEdgeIterator HEdgeIteratorLeft;
|
|
|
|
typedef typename MeshLeft::FaceIterator FaceIteratorLeft;
|
|
|
|
|
|
|
|
|
|
|
|
typedef typename MeshRight::ScalarType ScalarRight;
|
|
|
|
typedef typename MeshRight::CoordType CoordRight;
|
|
|
|
typedef typename MeshRight::VertexType VertexRight;
|
|
|
|
typedef typename MeshRight::EdgeType EdgeRight;
|
|
|
|
typedef typename MeshRight::HEdgeType HEdgeRight;
|
|
|
|
typedef typename MeshRight::FaceType FaceRight;
|
2006-01-11 16:45:21 +01:00
|
|
|
typedef typename MeshRight::VertexPointer VertexPointerRight;
|
|
|
|
typedef typename MeshRight::VertexIterator VertexIteratorRight;
|
2010-06-16 18:30:24 +02:00
|
|
|
typedef typename MeshRight::EdgeIterator EdgeIteratorRight;
|
|
|
|
typedef typename MeshRight::HEdgeIterator HEdgeIteratorRight;
|
2006-01-11 16:45:21 +01:00
|
|
|
typedef typename MeshRight::FaceIterator FaceIteratorRight;
|
2010-06-16 18:30:24 +02:00
|
|
|
typedef typename MeshRight::FacePointer FacePointerRight;
|
2006-01-11 16:45:21 +01:00
|
|
|
|
2010-06-16 18:30:24 +02:00
|
|
|
struct Remap{
|
|
|
|
std::vector<int> vert,face,edge, hedge;
|
|
|
|
};
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
static void ImportVertexAdj(MeshLeft &ml, MeshRight &mr, VertexLeft &vl, VertexRight &vr, Remap &remap, bool sel ){
|
2010-06-16 18:30:24 +02:00
|
|
|
// Vertex to Edge Adj
|
|
|
|
if(vcg::tri::HasVEAdjacency(ml) && vcg::tri::HasVEAdjacency(mr)){
|
|
|
|
size_t i = Index(mr,vr.cVEp());
|
2010-06-18 16:40:36 +02:00
|
|
|
vl.VEp() = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]];
|
2010-06-16 18:30:24 +02:00
|
|
|
vl.VEi() = vr.VEi();
|
|
|
|
}
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
if(!sel){
|
|
|
|
// Vertex to Face Adj
|
|
|
|
if(vcg::tri::HasPerVertexVFAdjacency(ml) && vcg::tri::HasPerVertexVFAdjacency(mr) &&
|
|
|
|
vcg::tri::HasPerFaceVFAdjacency(ml) && vcg::tri::HasPerFaceVFAdjacency(mr)
|
|
|
|
){
|
|
|
|
size_t i = Index(mr,vr.cVFp());
|
|
|
|
vl.VFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]];
|
|
|
|
vl.VFi() = vr.VFi();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Vertex to HEdge Adj
|
|
|
|
if(vcg::tri::HasVHAdjacency(ml) && vcg::tri::HasVHAdjacency(mr)){
|
|
|
|
vl.VHp() = &ml.hedge[remap.hedge[Index(mr,vr.cVHp())]];
|
|
|
|
vl.VHi() = vr.VHi();
|
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
static void ImportEdgeAdj(MeshLeft &ml, MeshRight &mr, EdgeLeft &el, const EdgeRight &er, Remap &remap, bool sel ){
|
2010-06-16 18:30:24 +02:00
|
|
|
|
|
|
|
// Edge to Vertex Adj
|
|
|
|
if(vcg::tri::HasEVAdjacency(ml) && vcg::tri::HasEVAdjacency(mr)){
|
2011-05-31 10:46:38 +02:00
|
|
|
el.V(0) = &ml.vert[remap.vert[Index(mr,er.cV(0))]];
|
|
|
|
el.V(1) = &ml.vert[remap.vert[Index(mr,er.cV(1))]];
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
if(!sel){
|
|
|
|
// Edge to Edge Adj
|
|
|
|
if(vcg::tri::HasEEAdjacency(ml) && vcg::tri::HasEEAdjacency(mr))
|
|
|
|
for(unsigned int vi = 0; vi < 2; ++vi)
|
|
|
|
{
|
|
|
|
size_t i = Index(mr,er.cEEp(vi));
|
|
|
|
el.EEp(i) = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]];
|
|
|
|
el.EEi(i) = er.cEEi(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edge to Face Adj
|
|
|
|
if(vcg::tri::HasEFAdjacency(ml) && vcg::tri::HasEFAdjacency(mr)){
|
|
|
|
size_t i = Index(mr,er.cEFp());
|
|
|
|
el.EFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]];
|
|
|
|
el.EFi() = er.cEFi();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Edge to HEdge Adj
|
|
|
|
if(vcg::tri::HasEHAdjacency(ml) && vcg::tri::HasEHAdjacency(mr))
|
|
|
|
el.EHp() = &ml.hedge[remap.hedge[Index(mr,er.cEHp())]];
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
static void ImportFaceAdj(MeshLeft &ml, MeshRight &mr, FaceLeft &fl, const FaceRight &fr, Remap &remap, bool sel ){
|
2010-06-16 18:30:24 +02:00
|
|
|
// Face to Vertex Adj
|
|
|
|
if(vcg::tri::HasFVAdjacency(ml) && vcg::tri::HasFVAdjacency(mr)){
|
|
|
|
assert(fl.VN() == fr.VN());
|
2010-08-11 17:54:37 +02:00
|
|
|
for( int i = 0; i < fl.VN(); ++i )
|
2010-06-16 18:30:24 +02:00
|
|
|
fl.V(i) = &ml.vert[remap.vert[Index(mr,fr.V(i))]];
|
|
|
|
}
|
|
|
|
|
2010-08-11 17:54:37 +02:00
|
|
|
if(!sel){
|
|
|
|
// Face to Edge Adj
|
|
|
|
if(vcg::tri::HasFEAdjacency(ml) && vcg::tri::HasFEAdjacency(mr)){
|
|
|
|
assert(fl.VN() == fr.VN());
|
|
|
|
for( int vi = 0; vi < fl.VN(); ++vi ){
|
|
|
|
size_t i = Index(mr,fr.cFEp(vi));
|
|
|
|
fl.FEp(i) = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Face to Face Adj
|
|
|
|
if(vcg::tri::HasFFAdjacency(ml) && vcg::tri::HasFFAdjacency(mr)){
|
|
|
|
assert(fl.VN() == fr.VN());
|
|
|
|
for( int vi = 0; vi < fl.VN(); ++vi ){
|
|
|
|
size_t i = Index(mr,fr.cFFp(vi));
|
|
|
|
fl.FFp(vi) = (i>ml.face.size()) ? 0 :&ml.face[remap.face[i]];
|
|
|
|
fl.FFi(vi) = fr.cFFi(vi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Face to HEedge Adj
|
|
|
|
if(vcg::tri::HasFHAdjacency(ml) && vcg::tri::HasFHAdjacency(mr))
|
|
|
|
fl.FHp() = &ml.hedge[remap.hedge[Index(mr,fr.cFHp())]];
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-07 12:31:04 +02:00
|
|
|
static void ImportHEdgeAdj(MeshLeft &ml, MeshRight &mr, HEdgeLeft &hl, const HEdgeRight &hr, Remap &remap, bool /*sel*/ ){
|
2010-06-16 18:30:24 +02:00
|
|
|
// HEdge to Vertex Adj
|
|
|
|
if(vcg::tri::HasHVAdjacency(ml) && vcg::tri::HasHVAdjacency(mr))
|
|
|
|
hl.HVp() = &ml.vert[remap.vert[Index(mr,hr.cHVp())]];
|
|
|
|
|
|
|
|
// HEdge to Edge Adj
|
|
|
|
if(vcg::tri::HasHEAdjacency(ml) && vcg::tri::HasHEAdjacency(mr)){
|
|
|
|
size_t i = Index(mr,hr.cHEp()) ;
|
2010-06-18 16:40:36 +02:00
|
|
|
hl.HEp() = (i>ml.edge.size())? 0 : &ml.edge[remap.edge[i]];
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// HEdge to Face Adj
|
2010-06-16 19:28:18 +02:00
|
|
|
if(vcg::tri::HasHFAdjacency(ml) && vcg::tri::HasHFAdjacency(mr)){
|
|
|
|
size_t i = Index(mr,hr.cHFp());
|
2010-06-18 16:40:36 +02:00
|
|
|
hl.HFp() = (i>ml.face.size())? 0 :&ml.face[remap.face[i]];
|
2010-06-16 19:28:18 +02:00
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
// HEdge to Opposite HEdge Adj
|
|
|
|
if(vcg::tri::HasHOppAdjacency(ml) && vcg::tri::HasHOppAdjacency(mr))
|
|
|
|
hl.HOp() = &ml.hedge[remap.hedge[Index(mr,hr.cHOp())]];
|
|
|
|
|
|
|
|
// HEdge to Next HEdge Adj
|
|
|
|
if(vcg::tri::HasHNextAdjacency(ml) && vcg::tri::HasHNextAdjacency(mr))
|
|
|
|
hl.HNp() = &ml.hedge[remap.hedge[Index(mr,hr.cHNp())]];
|
|
|
|
|
|
|
|
// HEdge to Next HEdge Adj
|
|
|
|
if(vcg::tri::HasHPrevAdjacency(ml) && vcg::tri::HasHPrevAdjacency(mr))
|
|
|
|
hl.HPp() = &ml.hedge[remap.hedge[Index(mr,hr.cHPp())]];
|
|
|
|
}
|
|
|
|
|
2009-04-04 18:58:21 +02:00
|
|
|
// Append Right Mesh to the Left Mesh
|
|
|
|
// Append::Mesh(ml, mr) is equivalent to ml += mr.
|
|
|
|
// Note MeshRigth could be costant...
|
2006-01-11 16:45:21 +01:00
|
|
|
|
2010-06-16 18:30:24 +02:00
|
|
|
static void Mesh(MeshLeft& ml, MeshRight& mr, const bool selected = false){
|
|
|
|
|
|
|
|
// phase 1. allocate on ml vert,edge,face, hedge to accomodat those of mr
|
|
|
|
// and build the remapping for all
|
|
|
|
|
|
|
|
Remap remap;
|
|
|
|
|
|
|
|
// vertex
|
|
|
|
remap.vert.resize(mr.vert.size(),-1);
|
|
|
|
VertexIteratorRight vi;
|
|
|
|
for(vi=mr.vert.begin();vi!=mr.vert.end();++vi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*vi).IsD() && (!selected || (*vi).IsS())){
|
2010-07-27 16:20:12 +02:00
|
|
|
int ind=Index(mr,*vi);
|
|
|
|
assert(remap.vert[ind]==-1);
|
|
|
|
VertexIteratorLeft vp;
|
|
|
|
vp=Allocator<MeshLeft>::AddVertices(ml,1);
|
|
|
|
(*vp).ImportData(*(vi));
|
|
|
|
remap.vert[ind]=Index(ml,*vp);
|
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
|
|
|
|
// edge
|
|
|
|
remap.edge.resize(mr.edge.size(),-1);
|
|
|
|
EdgeIteratorRight ei;
|
|
|
|
for(ei=mr.edge.begin(); ei!=mr.edge.end();++ei)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*ei).IsD() && (!selected || (*ei).IsS())){
|
2010-07-27 16:20:12 +02:00
|
|
|
int ind=Index(mr,*ei);
|
|
|
|
assert(remap.edge[ind]==-1);
|
|
|
|
EdgeIteratorLeft ep;
|
|
|
|
ep=Allocator<MeshLeft>::AddEdges(ml,1);
|
|
|
|
(*ep).ImportData(*(ei));
|
|
|
|
remap.edge[ind]=Index(ml,*ep);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// face
|
2010-08-11 16:43:16 +02:00
|
|
|
vcg::tri::Allocator<MeshRight>::CompactFaceVector(mr);
|
2010-06-16 18:30:24 +02:00
|
|
|
remap.face.resize(mr.face.size(),-1);
|
|
|
|
FaceIteratorRight fi;
|
|
|
|
for(fi=mr.face.begin();fi!=mr.face.end();++fi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*fi).IsD() && (!selected || (*fi).IsS())){
|
2010-07-27 16:20:12 +02:00
|
|
|
int ind=Index(mr,*fi);
|
|
|
|
assert(remap.face[ind]==-1);
|
|
|
|
FaceIteratorLeft fp;
|
|
|
|
fp=Allocator<MeshLeft>::AddFaces(ml,1);
|
|
|
|
(*fp).ImportData(*(fi));
|
|
|
|
remap.face[ind]=Index(ml,*fp);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// hedge
|
|
|
|
remap.hedge.resize(mr.hedge.size(),-1);
|
|
|
|
HEdgeIteratorRight hi;
|
|
|
|
for(hi=mr.hedge.begin();hi!=mr.hedge.end();++hi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*hi).IsD() && (!selected || (*hi).IsS())){
|
2010-07-27 16:20:12 +02:00
|
|
|
int ind=Index(mr,*hi);
|
|
|
|
assert(remap.hedge[ind]==-1);
|
|
|
|
HEdgeIteratorLeft hp;
|
|
|
|
hp=Allocator<MeshLeft>::AddHEdges(ml,1);
|
|
|
|
(*hp).ImportData(*(hi));
|
|
|
|
remap.hedge[ind]=Index(ml,*hp);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// phase 2.
|
|
|
|
// copy data from ml to its corresponding elements in ml and adjacencies
|
2006-01-11 16:45:21 +01:00
|
|
|
|
2010-06-16 18:30:24 +02:00
|
|
|
// vertex
|
|
|
|
for(vi=mr.vert.begin();vi!=mr.vert.end();++vi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if( !(*vi).IsD() && (!selected || (*vi).IsS())){
|
2010-06-16 18:30:24 +02:00
|
|
|
ml.vert[remap.vert[Index(mr,*vi)]].ImportData(*vi);
|
2010-08-11 17:54:37 +02:00
|
|
|
ImportVertexAdj(ml,mr,ml.vert[remap.vert[Index(mr,*vi)]],*vi,remap,selected);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// edge
|
|
|
|
for(ei=mr.edge.begin();ei!=mr.edge.end();++ei)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*ei).IsD() && (!selected || (*ei).IsS())){
|
2010-06-16 18:30:24 +02:00
|
|
|
ml.edge[remap.edge[Index(mr,*ei)]].ImportData(*ei);
|
2010-08-11 17:54:37 +02:00
|
|
|
ImportEdgeAdj(ml,mr,ml.edge[remap.edge[Index(mr,*ei)]],*ei,remap,selected);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// face
|
2010-09-27 16:40:24 +02:00
|
|
|
bool wedgetexcoord = vcg::tri::HasPerWedgeTexCoord(mr);
|
2010-06-16 18:30:24 +02:00
|
|
|
for(fi=mr.face.begin();fi!=mr.face.end();++fi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*fi).IsD() && (!selected || (*fi).IsS())){
|
2010-09-27 16:40:24 +02:00
|
|
|
if(wedgetexcoord)
|
|
|
|
for(int i = 0; i < (*fi).VN(); ++i)
|
|
|
|
(*fi).WT(i).n() += ml.textures.size();
|
2010-06-16 18:30:24 +02:00
|
|
|
ml.face[remap.face[Index(mr,*fi)]].ImportData(*fi);
|
2010-08-11 17:54:37 +02:00
|
|
|
ImportFaceAdj(ml,mr,ml.face[remap.face[Index(mr,*fi)]],*fi,remap,selected);
|
2010-09-27 16:40:24 +02:00
|
|
|
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// hedge
|
|
|
|
for(hi=mr.hedge.begin();hi!=mr.hedge.end();++hi)
|
2010-08-11 16:43:16 +02:00
|
|
|
if(!(*hi).IsD() && (!selected || (*hi).IsS())){
|
2010-06-16 18:30:24 +02:00
|
|
|
ml.hedge[remap.hedge[Index(mr,*hi)]].ImportData(*hi);
|
2010-08-11 17:54:37 +02:00
|
|
|
ImportHEdgeAdj(ml,mr,ml.hedge[remap.hedge[Index(mr,*hi)]],*hi,remap,selected);
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// phase 3.
|
|
|
|
// take care of other per mesh data: textures, attributes
|
|
|
|
|
|
|
|
// At the end concatenate the vector with texture names.
|
|
|
|
ml.textures.insert(ml.textures.end(),mr.textures.begin(),mr.textures.end());
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// name and the same type. This may be deceiving because they could in fact have
|
|
|
|
// 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
|
|
|
|
// of the right mesh will be uninitialized
|
|
|
|
|
2011-06-01 15:39:31 +02:00
|
|
|
unsigned int id_r;
|
2011-06-14 16:52:38 +02:00
|
|
|
typename std::set< PointerToAttribute >::iterator al, ar;
|
2011-06-01 15:39:31 +02:00
|
|
|
|
|
|
|
// per vertex attributes
|
|
|
|
for(al = ml.vert_attr.begin(); al != ml.vert_attr.end(); ++al)
|
|
|
|
if(!(*al)._name.empty()){
|
|
|
|
ar = mr.vert_attr.find(*al);
|
|
|
|
if(ar!= mr.vert_attr.end()){
|
|
|
|
id_r = 0;
|
|
|
|
for(vi=mr.vert.begin();vi!=mr.vert.end();++vi,++id_r)
|
|
|
|
if( !(*vi).IsD() && (!selected || (*vi).IsS()))
|
|
|
|
memcpy((*al)._handle->At(remap.vert[Index(mr,*vi)]),(*ar)._handle->At(id_r),
|
|
|
|
(*al)._handle->SizeOf());
|
|
|
|
}
|
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
|
2011-06-01 15:39:31 +02:00
|
|
|
// per edge attributes
|
|
|
|
for(al = ml.edge_attr.begin(); al != ml.edge_attr.end(); ++al)
|
|
|
|
if(!(*al)._name.empty()){
|
|
|
|
ar = mr.edge_attr.find(*al);
|
|
|
|
if(ar!= mr.edge_attr.end()){
|
|
|
|
id_r = 0;
|
|
|
|
for(ei=mr.edge.begin();ei!=mr.edge.end();++ei,++id_r)
|
|
|
|
if( !(*ei).IsD() && (!selected || (*ei).IsS()))
|
|
|
|
memcpy((*al)._handle->At(remap.vert[Index(mr,*ei)]),(*ar)._handle->At(id_r),
|
|
|
|
(*al)._handle->SizeOf());
|
|
|
|
}
|
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
|
2011-06-01 15:39:31 +02:00
|
|
|
// per face attributes
|
|
|
|
for(al = ml.face_attr.begin(); al != ml.face_attr.end(); ++al)
|
|
|
|
if(!(*al)._name.empty()){
|
|
|
|
ar = mr.face_attr.find(*al);
|
|
|
|
if(ar!= mr.face_attr.end()){
|
|
|
|
id_r = 0;
|
|
|
|
for(fi=mr.face.begin();fi!=mr.face.end();++fi,++id_r)
|
|
|
|
if( !(*fi).IsD() && (!selected || (*fi).IsS()))
|
|
|
|
memcpy((*al)._handle->At(remap.vert[Index(mr,*fi)]),(*ar)._handle->At(id_r),
|
|
|
|
(*al)._handle->SizeOf());
|
|
|
|
}
|
|
|
|
}
|
2010-06-16 18:30:24 +02:00
|
|
|
|
2011-06-01 15:39:31 +02:00
|
|
|
// per mesh attributes
|
|
|
|
// if both ml and mr have an attribute with the same name, no action is done
|
|
|
|
// if mr has an attribute that is NOT present in ml, the attribute is added to ml
|
|
|
|
//for(ar = mr.mesh_attr.begin(); ar != mr.mesh_attr.end(); ++ar)
|
|
|
|
// if(!(*ar)._name.empty()){
|
|
|
|
// al = ml.mesh_attr.find(*ar);
|
|
|
|
// if(al== ml.mesh_attr.end())
|
|
|
|
// //...
|
|
|
|
// }
|
2010-06-16 18:30:24 +02:00
|
|
|
}
|
2006-01-11 16:45:21 +01:00
|
|
|
|
2011-06-03 16:37:50 +02:00
|
|
|
static void MeshCopy(MeshLeft& ml, MeshRight& mr, bool selected=false)
|
|
|
|
{
|
|
|
|
ml.Clear();
|
|
|
|
Mesh(ml,mr,selected);
|
|
|
|
ml.bbox=mr.bbox;
|
|
|
|
}
|
2011-06-01 15:39:31 +02:00
|
|
|
|
2006-01-11 16:45:21 +01:00
|
|
|
static void Selected(MeshLeft& ml, MeshRight& mr)
|
|
|
|
{
|
2008-08-07 18:19:31 +02:00
|
|
|
Mesh(ml,mr,true);
|
2006-01-11 16:45:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}; // end of class Append
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // End Namespace TriMesh
|
|
|
|
} // End Namespace vcg
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|