mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-19 19:14:42 +00:00
copy&swap idiom for CMeshO
This commit is contained in:
parent
1d9b9c9d0d
commit
d20ff95a55
@ -37,35 +37,23 @@ CMeshO::CMeshO(const CMeshO& oth) :
|
||||
vcg::tri::Append<vcgTriMesh, vcgTriMesh>::MeshAppendConst(*this, oth);
|
||||
textures = oth.textures;
|
||||
normalmaps = oth.normalmaps;
|
||||
imark = oth.imark;
|
||||
}
|
||||
|
||||
/// TODO: make a proper implementation of a move constructor.
|
||||
/// Even if almost never used, this is very inefficient.
|
||||
CMeshO::CMeshO(CMeshO&& oth):
|
||||
vcgTriMesh(), sfn(oth.sfn), svn(oth.svn),
|
||||
pvn(oth.pvn), pfn(oth.pfn), Tr(oth.Tr)
|
||||
CMeshO::CMeshO(CMeshO&& oth)
|
||||
: CMeshO()
|
||||
{
|
||||
enableComponentsFromOtherMesh(oth);
|
||||
//I could take everything from oth and place it in
|
||||
//this mesh
|
||||
vcg::tri::Append<vcgTriMesh, vcgTriMesh>::Mesh(*this, oth);
|
||||
textures = oth.textures;
|
||||
normalmaps = oth.normalmaps;
|
||||
swap(*this, oth);
|
||||
}
|
||||
|
||||
/// TODO: change this and use the copy&swap idiom
|
||||
CMeshO& CMeshO::operator=(const CMeshO& oth)
|
||||
CMeshO::~CMeshO()
|
||||
{
|
||||
Clear();
|
||||
enableComponentsFromOtherMesh(oth);
|
||||
vcg::tri::Append<vcgTriMesh, vcgTriMesh>::MeshCopyConst(*this, oth);
|
||||
sfn = oth.sfn;
|
||||
svn = oth.svn;
|
||||
pvn = oth.pvn;
|
||||
pfn = oth.pfn;
|
||||
Tr = oth.Tr;
|
||||
textures = oth.textures;
|
||||
normalmaps = oth.normalmaps;
|
||||
//no need to call base class destructor. It is called automatically
|
||||
}
|
||||
|
||||
CMeshO& CMeshO::operator=(CMeshO oth)
|
||||
{
|
||||
swap(*this, oth);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -130,5 +118,3 @@ void CMeshO::enableComponentsFromOtherMesh(const CMeshO& oth)
|
||||
for(const std::string& attr : perFPointAttrs)
|
||||
vcg::tri::Allocator<CMeshO>::AddPerFaceAttribute<Point3m>(*this, attr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -139,8 +139,12 @@ public :
|
||||
CMeshO(const CMeshO& oth);
|
||||
|
||||
CMeshO(CMeshO&& oth);
|
||||
|
||||
virtual ~CMeshO();
|
||||
|
||||
CMeshO& operator=(const CMeshO& oth);
|
||||
CMeshO& operator=(CMeshO oth);
|
||||
|
||||
friend void swap(CMeshO& m1, CMeshO& m2);
|
||||
|
||||
Box3m trBB() const;
|
||||
|
||||
@ -156,4 +160,36 @@ private:
|
||||
void enableComponentsFromOtherMesh(const CMeshO& oth);
|
||||
};
|
||||
|
||||
//must be inlined
|
||||
inline void swap(CMeshO& m1, CMeshO& m2)
|
||||
{
|
||||
using std::swap;
|
||||
swap(m1.vn, m2.vn);
|
||||
swap(m1.vert, m2.vert);
|
||||
m1.vert._updateOVP(m1.vert.begin(), m1.vert.end());
|
||||
m2.vert._updateOVP(m2.vert.begin(), m2.vert.end());
|
||||
swap(m1.en, m2.en);
|
||||
swap(m1.edge, m2.edge);
|
||||
swap(m1.fn, m2.fn);
|
||||
swap(m1.face, m2.face);
|
||||
m1.face._updateOVP(m1.face.begin(), m1.face.end());
|
||||
m2.face._updateOVP(m2.face.begin(), m2.face.end());
|
||||
swap(m1.hn, m2.hn);
|
||||
swap(m1.hedge, m2.hedge);
|
||||
swap(m1.tn, m2.tn);
|
||||
swap(m1.tetra, m2.tetra);
|
||||
swap(m1.bbox, m2.bbox);
|
||||
swap(m1.textures, m2.textures);
|
||||
swap(m1.normalmaps, m2.normalmaps);
|
||||
swap(m1.attrn, m2.attrn);
|
||||
swap(m1.vert_attr, m2.vert_attr);
|
||||
swap(m1.edge_attr, m2.edge_attr);
|
||||
swap(m1.face_attr, m2.face_attr);
|
||||
swap(m1.mesh_attr, m2.mesh_attr);
|
||||
swap(m1.tetra_attr, m2.tetra_attr);
|
||||
swap(m1.shot, m2.shot);
|
||||
swap(m1.imark, m2.imark);
|
||||
}
|
||||
|
||||
|
||||
#endif //CMESH_H
|
||||
|
||||
@ -336,11 +336,16 @@ void MeshModel::enable(int openingFileMask)
|
||||
updateDataMask(MM_VERTCOLOR);
|
||||
if( openingFileMask & tri::io::Mask::IOM_FACECOLOR )
|
||||
updateDataMask(MM_FACECOLOR);
|
||||
if( openingFileMask & tri::io::Mask::IOM_VERTRADIUS ) updateDataMask(MM_VERTRADIUS);
|
||||
if( openingFileMask & tri::io::Mask::IOM_CAMERA ) updateDataMask(MM_CAMERA);
|
||||
if( openingFileMask & tri::io::Mask::IOM_VERTQUALITY ) updateDataMask(MM_VERTQUALITY);
|
||||
if( openingFileMask & tri::io::Mask::IOM_FACEQUALITY ) updateDataMask(MM_FACEQUALITY);
|
||||
if( openingFileMask & tri::io::Mask::IOM_BITPOLYGONAL ) updateDataMask(MM_POLYGONAL);
|
||||
if( openingFileMask & tri::io::Mask::IOM_VERTRADIUS )
|
||||
updateDataMask(MM_VERTRADIUS);
|
||||
if( openingFileMask & tri::io::Mask::IOM_CAMERA )
|
||||
updateDataMask(MM_CAMERA);
|
||||
if( openingFileMask & tri::io::Mask::IOM_VERTQUALITY )
|
||||
updateDataMask(MM_VERTQUALITY);
|
||||
if( openingFileMask & tri::io::Mask::IOM_FACEQUALITY )
|
||||
updateDataMask(MM_FACEQUALITY);
|
||||
if( openingFileMask & tri::io::Mask::IOM_BITPOLYGONAL )
|
||||
updateDataMask(MM_POLYGONAL);
|
||||
}
|
||||
|
||||
bool MeshModel::meshModified() const
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 735f93c256f960aa50ce3a0559c10b8eb1f2782a
|
||||
Subproject commit fdabe1aead524ce967bdca453fe36a94ab10c1a2
|
||||
Loading…
x
Reference in New Issue
Block a user