Commit eec3ac3b authored by Jan Möbius's avatar Jan Möbius
Browse files

Made STL Reader work, with the clear = false flag.

Redundant lookup removed. 
( Thanks to Peter Newman for the patch)

closes #1370

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@783 fdac6126-5c0c-442c-9429-916003d36597
parent b025acaa
...@@ -222,7 +222,6 @@ read_stla(const std::string& _filename, BaseImporter& _bi) const ...@@ -222,7 +222,6 @@ read_stla(const std::string& _filename, BaseImporter& _bi) const
unsigned int i; unsigned int i;
OpenMesh::Vec3f v; OpenMesh::Vec3f v;
OpenMesh::Vec3f n; OpenMesh::Vec3f n;
unsigned int cur_idx(0);
BaseImporter::VHandles vhandles; BaseImporter::VHandles vhandles;
CmpVec comp(eps_); CmpVec comp(eps_);
...@@ -288,9 +287,9 @@ read_stla(const std::string& _filename, BaseImporter& _bi) const ...@@ -288,9 +287,9 @@ read_stla(const std::string& _filename, BaseImporter& _bi) const
if ((vMapIt=vMap.find(v)) == vMap.end()) if ((vMapIt=vMap.find(v)) == vMap.end())
{ {
// No : add vertex and remember idx/vector mapping // No : add vertex and remember idx/vector mapping
_bi.add_vertex(v); VertexHandle handle = _bi.add_vertex(v);
vhandles.push_back(VertexHandle(cur_idx)); vhandles.push_back(handle);
vMap[v] = VertexHandle(cur_idx++); vMap[v] = handle;
} }
else else
// Yes : get index from map // Yes : get index from map
...@@ -330,7 +329,6 @@ read_stla(std::istream& _in, BaseImporter& _bi) const ...@@ -330,7 +329,6 @@ read_stla(std::istream& _in, BaseImporter& _bi) const
unsigned int i; unsigned int i;
OpenMesh::Vec3f v; OpenMesh::Vec3f v;
OpenMesh::Vec3f n; OpenMesh::Vec3f n;
unsigned int cur_idx(0);
BaseImporter::VHandles vhandles; BaseImporter::VHandles vhandles;
CmpVec comp(eps_); CmpVec comp(eps_);
...@@ -395,9 +393,9 @@ read_stla(std::istream& _in, BaseImporter& _bi) const ...@@ -395,9 +393,9 @@ read_stla(std::istream& _in, BaseImporter& _bi) const
if ((vMapIt=vMap.find(v)) == vMap.end()) if ((vMapIt=vMap.find(v)) == vMap.end())
{ {
// No : add vertex and remember idx/vector mapping // No : add vertex and remember idx/vector mapping
_bi.add_vertex(v); VertexHandle handle = _bi.add_vertex(v);
vhandles.push_back(VertexHandle(cur_idx)); vhandles.push_back(handle);
vMap[v] = VertexHandle(cur_idx++); vMap[v] = handle;
} }
else else
// Yes : get index from map // Yes : get index from map
...@@ -444,7 +442,6 @@ read_stlb(const std::string& _filename, BaseImporter& _bi) const ...@@ -444,7 +442,6 @@ read_stlb(const std::string& _filename, BaseImporter& _bi) const
bool swapFlag; bool swapFlag;
unsigned int i, nT; unsigned int i, nT;
OpenMesh::Vec3f v; OpenMesh::Vec3f v;
unsigned int cur_idx(0);
BaseImporter::VHandles vhandles; BaseImporter::VHandles vhandles;
std::map<Vec3f, VertexHandle, CmpVec> vMap; std::map<Vec3f, VertexHandle, CmpVec> vMap;
...@@ -484,21 +481,21 @@ read_stlb(const std::string& _filename, BaseImporter& _bi) const ...@@ -484,21 +481,21 @@ read_stlb(const std::string& _filename, BaseImporter& _bi) const
// has vector been referenced before? // has vector been referenced before?
if ((vMapIt=vMap.find(v)) == vMap.end()) if ((vMapIt=vMap.find(v)) == vMap.end())
{ {
// No : add vertex and remember idx/vector mapping // No : add vertex and remember idx/vector mapping
_bi.add_vertex(v); VertexHandle handle = _bi.add_vertex(v);
vhandles.push_back(VertexHandle(cur_idx)); vhandles.push_back(handle);
vMap[v] = VertexHandle(cur_idx++); vMap[v] = handle;
} }
else else
// Yes : get index from map // Yes : get index from map
vhandles.push_back(vMapIt->second); vhandles.push_back(vMapIt->second);
} }
// Add face only if it is not degenerated // Add face only if it is not degenerated
if ((vhandles[0] != vhandles[1]) && if ((vhandles[0] != vhandles[1]) &&
(vhandles[0] != vhandles[2]) && (vhandles[0] != vhandles[2]) &&
(vhandles[1] != vhandles[2])) (vhandles[1] != vhandles[2]))
_bi.add_face(vhandles); _bi.add_face(vhandles);
fread(dummy, 1, 2, in); fread(dummy, 1, 2, in);
...@@ -522,7 +519,6 @@ read_stlb(std::istream& _in, BaseImporter& _bi) const ...@@ -522,7 +519,6 @@ read_stlb(std::istream& _in, BaseImporter& _bi) const
bool swapFlag; bool swapFlag;
unsigned int i, nT; unsigned int i, nT;
OpenMesh::Vec3f v; OpenMesh::Vec3f v;
unsigned int cur_idx(0);
BaseImporter::VHandles vhandles; BaseImporter::VHandles vhandles;
std::map<Vec3f, VertexHandle, CmpVec> vMap; std::map<Vec3f, VertexHandle, CmpVec> vMap;
...@@ -563,14 +559,14 @@ read_stlb(std::istream& _in, BaseImporter& _bi) const ...@@ -563,14 +559,14 @@ read_stlb(std::istream& _in, BaseImporter& _bi) const
// has vector been referenced before? // has vector been referenced before?
if ((vMapIt=vMap.find(v)) == vMap.end()) if ((vMapIt=vMap.find(v)) == vMap.end())
{ {
// No : add vertex and remember idx/vector mapping // No : add vertex and remember idx/vector mapping
_bi.add_vertex(v); VertexHandle handle = _bi.add_vertex(v);
vhandles.push_back(VertexHandle(cur_idx)); vhandles.push_back(handle);
vMap[v] = VertexHandle(cur_idx++); vMap[v] = handle;
} }
else else
// Yes : get index from map // Yes : get index from map
vhandles.push_back(vMapIt->second); vhandles.push_back(vMapIt->second);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment