improve performance for small vectors/faces
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@1269 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -106,25 +106,15 @@ void trimString( std::string& _string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template<typename Handle>
|
|
||||||
class HasSeen : public std::unary_function <Handle, bool>
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
HasSeen () : seen_ () { }
|
|
||||||
|
|
||||||
bool operator ()(const Handle& i) const
|
|
||||||
{
|
|
||||||
return (!seen_.insert(i.idx()).second);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
mutable std::set<int> seen_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// remove duplicated indices from one face
|
// remove duplicated indices from one face
|
||||||
void remove_duplicated_vertices(BaseImporter::VHandles& _indices)
|
void remove_duplicated_vertices(BaseImporter::VHandles& _indices)
|
||||||
{
|
{
|
||||||
_indices.erase(std::remove_if(_indices.begin(),_indices.end(),HasSeen<BaseImporter::VHandles::value_type>()),_indices.end());
|
BaseImporter::VHandles::iterator endIter = _indices.end();
|
||||||
|
for (BaseImporter::VHandles::iterator iter = _indices.begin(); iter != endIter; ++iter)
|
||||||
|
endIter = std::remove(iter+1, endIter, *(iter));
|
||||||
|
|
||||||
|
_indices.erase(endIter,_indices.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ TEST_F(OpenMeshReadWriteOBJ, LoadDegeneratedOBJ) {
|
|||||||
|
|
||||||
mesh_.clear();
|
mesh_.clear();
|
||||||
|
|
||||||
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal.obj");
|
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube-minimal-degenerated.obj");
|
||||||
|
|
||||||
EXPECT_TRUE(ok) << "Unable to load cube-minimal.obj";
|
EXPECT_TRUE(ok) << "Unable to load cube-minimal-degenerated.obj";
|
||||||
|
|
||||||
EXPECT_EQ(8u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
EXPECT_EQ(8u , mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
||||||
EXPECT_EQ(18u , mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
EXPECT_EQ(18u , mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
||||||
|
|||||||
Reference in New Issue
Block a user