Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove Duplicates in Vector?
    text
    copied!<p>I have a vertex defined like this:</p> <pre><code>struct VERTEX { XMFLOAT3 Pos XMFLOAT2 UV }; </code></pre> <p>And I defined an indices, Textures coordinated indices, UVcoordinate and Vertices like this</p> <pre><code>vector &lt;int&gt; indices ; vector &lt;int&gt; Texcoordindex ; vector &lt;XMFLOAT2&gt; UVCoinate ; vector &lt;XMFLOAT3&gt; Verices; </code></pre> <p>OK. I set up the indices, Textures coordinated indices, UVcoordinate and Vertices from a 3D file (an obj file in this case).</p> <p>Now when I want to define a faces array, I find some of the vertices are defined with multiple UV coordinates. I want to remove the duplicated vertices that have the same UV coordinates and make new index and vertex vectors to store only non-duplicate vertices with new indices of the vertex.</p> <p>Here is the obj file:</p> <pre><code># This file uses centimeters as units for non-parametric coordinates. v -12.830015 0.000000 12.061520 v 12.027525 0.000000 12.061520 v -12.830015 15.862570 12.061520 v 12.027525 15.862570 12.061520 v -12.830015 15.862570 -12.622024 v 12.027525 15.862570 -12.622024 v -12.830015 0.000000 -12.622024 v 12.027525 0.000000 -12.622024 vt 0.375000 0.000000 vt 0.625000 0.000000 vt 0.375000 0.250000 vt 0.625000 0.250000 vt 0.375000 0.500000 vt 0.625000 0.500000 vt 0.375000 0.750000 vt 0.625000 0.750000 vt 0.375000 1.000000 vt 0.625000 1.000000 vt 0.875000 0.000000 vt 0.875000 0.250000 vt 0.125000 0.000000 vt 0.125000 0.250000 f 1/1 2/2 3/3 f 3/3 2/2 4/4 f 3/3 4/4 5/5 f 5/5 4/4 6/6 f 5/5 6/6 7/7 f 7/7 6/6 8/8 f 7/7 8/8 1/9 f 1/9 8/8 2/10 f 2/2 8/11 4/4 f 4/4 8/11 6/12 f 7/13 1/1 5/14 f 5/14 1/1 3/3 </code></pre> <p>I want the result to be something like this </p> <pre><code># This file uses centimeters as units for non-parametric coordinates. v -12.830015 0.000000 12.061520 v 12.027525 0.000000 12.061520 v -12.830015 15.862570 12.061520 v 12.027525 15.862570 12.061520 v -12.830015 15.862570 -12.622024 v 12.027525 15.862570 -12.622024 v -12.830015 0.000000 -12.622024 v 12.027525 0.000000 -12.622024 vt 0.375000 0.000000 vt 0.625000 0.000000 vt 0.375000 0.250000 vt 0.625000 0.250000 vt 0.375000 0.500000 vt 0.625000 0.500000 vt 0.375000 0.750000 vt 0.625000 0.750000 vt 0.375000 1.000000 vt 0.625000 1.000000 vt 0.875000 0.000000 vt 0.875000 0.250000 vt 0.125000 0.000000 vt 0.125000 0.250000 </code></pre> <h1>the new vertices after delete the duplicate</h1> <pre><code>f 1/1 2/2 3/3 f 4/4 5/5 6/6 f 7/7 8/8 1/9 f 2/10 8/116/12 f7/13 5/14 </code></pre> <p>I tried using sort and unique but I get compilation errors:</p> <pre><code>error C2784: 'bool std::operator &lt;(const std::list&lt;_Ty,_Ax&gt; &amp;,const std::list&lt;_Ty,_Ax&gt; &amp;)' : could not deduce template argument for 'const std::list&lt;_Ty,_Ax&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;,const _Elem *)' : could not deduce template argument for 'const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const _Elem *,const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;)' : could not deduce template argument for 'const _Elem *' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;,const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;)' : could not deduce template argument for 'const std::basic_string&lt;_Elem,_Traits,_Alloc&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::vector&lt;_Ty,_Ax&gt; &amp;,const std::vector&lt;_Ty,_Ax&gt; &amp;)' : could not deduce template argument for 'const std::vector&lt;_Ty,_Ax&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::unique_ptr&lt;_Ty,_Dx&gt; &amp;,const std::unique_ptr&lt;_Ty2,_Dx2&gt; &amp;)' : could not deduce template argument for 'const std::unique_ptr&lt;_Ty,_Dx&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::reverse_iterator&lt;_RanIt&gt; &amp;,const std::reverse_iterator&lt;_RanIt2&gt; &amp;)' : could not deduce template argument for 'const std::reverse_iterator&lt;_RanIt&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::_Revranit&lt;_RanIt,_Base&gt; &amp;,const std::_Revranit&lt;_RanIt2,_Base2&gt; &amp;)' : could not deduce template argument for 'const std::_Revranit&lt;_RanIt,_Base&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2784: 'bool std::operator &lt;(const std::pair&lt;_Ty1,_Ty2&gt; &amp;,const std::pair&lt;_Ty1,_Ty2&gt; &amp;)' : could not deduce template argument for 'const std::pair&lt;_Ty1,_Ty2&gt; &amp;' from 'VERTEX' c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C2676: binary '&lt;' : 'VERTEX' does not define this operator or a conversion to a type acceptable to the predefined operator c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test error C1903: unable to recover from previous error(s); stopping compilation c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm 3559 1 Mesh_test </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload