<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.8.14">
  <compounddef id="PlySerialize_8h" kind="file" language="C++">
    <compoundname>PlySerialize.h</compoundname>
    <includes refid="tools_8h" local="no">../tools.h</includes>
    <includedby refid="serialize_8h" local="yes">/root/cis_interface/cis_interface/cis_interface/serialize/serialize.h</includedby>
    <incdepgraph>
      <node id="2827">
        <label>stdint.h</label>
        <link refid="stdint_8h_source"/>
        <childnode refid="2828" relation="include">
        </childnode>
        <childnode refid="2829" relation="include">
        </childnode>
      </node>
      <node id="2822">
        <label>stdarg.h</label>
      </node>
      <node id="2821">
        <label>stdlib.h</label>
      </node>
      <node id="2823">
        <label>errno.h</label>
      </node>
      <node id="2829">
        <label>stddef.h</label>
      </node>
      <node id="2818">
        <label>../tools.h</label>
        <link refid="tools_8h_source"/>
        <childnode refid="2819" relation="include">
        </childnode>
        <childnode refid="2820" relation="include">
        </childnode>
        <childnode refid="2821" relation="include">
        </childnode>
        <childnode refid="2822" relation="include">
        </childnode>
        <childnode refid="2823" relation="include">
        </childnode>
        <childnode refid="2824" relation="include">
        </childnode>
        <childnode refid="2825" relation="include">
        </childnode>
        <childnode refid="2827" relation="include">
        </childnode>
        <childnode refid="2830" relation="include">
        </childnode>
      </node>
      <node id="2817">
        <label>/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h</label>
        <link refid="PlySerialize_8h"/>
        <childnode refid="2818" relation="include">
        </childnode>
      </node>
      <node id="2828">
        <label>wchar.h</label>
      </node>
      <node id="2819">
        <label>string.h</label>
      </node>
      <node id="2830">
        <label>unistd.h</label>
      </node>
      <node id="2825">
        <label>regex_posix.h</label>
        <link refid="regex__posix_8h_source"/>
        <childnode refid="2826" relation="include">
        </childnode>
        <childnode refid="2827" relation="include">
        </childnode>
      </node>
      <node id="2824">
        <label>time.h</label>
      </node>
      <node id="2826">
        <label>regex.h</label>
      </node>
      <node id="2820">
        <label>stdio.h</label>
      </node>
    </incdepgraph>
    <invincdepgraph>
      <node id="2836">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/PsiInterface.hpp</label>
        <link refid="PsiInterface_8hpp_source"/>
      </node>
      <node id="2834">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/CisInterface.h</label>
        <link refid="CisInterface_8h_source"/>
        <childnode refid="2835" relation="include">
        </childnode>
        <childnode refid="2837" relation="include">
        </childnode>
      </node>
      <node id="2832">
        <label>/root/cis_interface/cis_interface/cis_interface/serialize/serialize.h</label>
        <link refid="serialize_8h_source"/>
        <childnode refid="2833" relation="include">
        </childnode>
      </node>
      <node id="2831">
        <label>/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h</label>
        <link refid="PlySerialize_8h"/>
        <childnode refid="2832" relation="include">
        </childnode>
      </node>
      <node id="2837">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/PsiInterface.h</label>
        <link refid="PsiInterface_8h_source"/>
      </node>
      <node id="2835">
        <label>/root/cis_interface/cis_interface/cis_interface/interface/CisInterface.hpp</label>
        <link refid="CisInterface_8hpp_source"/>
        <childnode refid="2836" relation="include">
        </childnode>
      </node>
      <node id="2833">
        <label>/root/cis_interface/cis_interface/cis_interface/communication/communication.h</label>
        <link refid="communication_8h_source"/>
        <childnode refid="2834" relation="include">
        </childnode>
        <childnode refid="2837" relation="include">
        </childnode>
      </node>
    </invincdepgraph>
    <innerclass refid="structply__t" prot="public">ply_t</innerclass>
      <sectiondef kind="typedef">
      <memberdef kind="typedef" id="PlySerialize_8h_1ad63dccc87d840cd560dfd72040928f3c" prot="public" static="no">
        <type>struct <ref refid="structply__t" kindref="compound">ply_t</ref></type>
        <definition>typedef struct ply_t  ply_t</definition>
        <argsstring></argsstring>
        <name>ply_t</name>
        <briefdescription>
<para>Ply structure. </para>        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="18" column="1"/>
      </memberdef>
      </sectiondef>
      <sectiondef kind="func">
      <memberdef kind="function" id="PlySerialize_8h_1a6cbeaea58a38e4f8f4ac0248bb840d93" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type><ref refid="structply__t" kindref="compound">ply_t</ref></type>
        <definition>static ply_t init_ply</definition>
        <argsstring>()</argsstring>
        <name>init_ply</name>
        <briefdescription>
<para>Initialize empty ply structure. </para>        </briefdescription>
        <detaileddescription>
<para><simplesect kind="return"><para><ref refid="structply__t" kindref="compound">ply_t</ref> Ply structure. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="25" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" bodystart="25" bodyend="34"/>
      </memberdef>
      <memberdef kind="function" id="PlySerialize_8h_1a8a353e186e1c6b9fd41c48fc94a75116" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>void</type>
        <definition>static void free_ply</definition>
        <argsstring>(ply_t *p)</argsstring>
        <name>free_ply</name>
        <param>
          <type><ref refid="structply__t" kindref="compound">ply_t</ref> *</type>
          <declname>p</declname>
        </param>
        <briefdescription>
<para>Free ply structure. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">p</parametername>
</parameternamelist>
<parameterdescription>
<para>*ply_t Pointer to ply structure. </para></parameterdescription>
</parameteritem>
</parameterlist>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="41" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" bodystart="41" bodyend="77"/>
      </memberdef>
      <memberdef kind="function" id="PlySerialize_8h_1a0f020b1aa230d2719f64dd1f48b9ca0a" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int alloc_ply</definition>
        <argsstring>(ply_t *p, int nvert, int nface, int do_color)</argsstring>
        <name>alloc_ply</name>
        <param>
          <type><ref refid="structply__t" kindref="compound">ply_t</ref> *</type>
          <declname>p</declname>
        </param>
        <param>
          <type>int</type>
          <declname>nvert</declname>
        </param>
        <param>
          <type>int</type>
          <declname>nface</declname>
        </param>
        <param>
          <type>int</type>
          <declname>do_color</declname>
        </param>
        <briefdescription>
<para>Allocate ply structure. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="inout">p</parametername>
</parameternamelist>
<parameterdescription>
<para>*ply_t Pointer to ply structure that should be allocated. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">nvert</parametername>
</parameternamelist>
<parameterdescription>
<para>int Number of vertices that should be allocated for. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">nface</parametername>
</parameternamelist>
<parameterdescription>
<para>int Number of faces that should be allocated for. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">do_color</parametername>
</parameternamelist>
<parameterdescription>
<para>int 1 if vertex colors should be allocated, 0 if not. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>int 0 if successful, -1 otherwise. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="88" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" bodystart="88" bodyend="163"/>
      </memberdef>
      <memberdef kind="function" id="PlySerialize_8h_1aca490c7522722d17e2c3d071d5950653" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int serialize_ply</definition>
        <argsstring>(const seri_t s, char *buf, const size_t buf_size, int *args_used, va_list ap)</argsstring>
        <name>serialize_ply</name>
        <param>
          <type>const <ref refid="structseri__t" kindref="compound">seri_t</ref></type>
          <declname>s</declname>
        </param>
        <param>
          <type>char *</type>
          <declname>buf</declname>
        </param>
        <param>
          <type>const size_t</type>
          <declname>buf_size</declname>
        </param>
        <param>
          <type>int *</type>
          <declname>args_used</declname>
        </param>
        <param>
          <type>va_list</type>
          <declname>ap</declname>
        </param>
        <briefdescription>
<para>Serialize ply information to create a message. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">s</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structseri__t" kindref="compound">seri_t</ref> Structure sepcifying how to serialize arguments. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">buf</parametername>
</parameternamelist>
<parameterdescription>
<para>character pointer to memory where serialized message should be stored. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">buf_siz</parametername>
</parameternamelist>
<parameterdescription>
<para>size_t Size of memory allocated to buf. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="out">args_used</parametername>
</parameternamelist>
<parameterdescription>
<para>int Number of arguments formatted. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">ap</parametername>
</parameternamelist>
<parameterdescription>
<para>va_list Arguments to be formatted. </para></parameterdescription>
</parameteritem>
</parameterlist>
<simplesect kind="return"><para>: int The length of the serialized message or -1 if there is an error. </para></simplesect>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="176" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" bodystart="176" bodyend="274"/>
      </memberdef>
      <memberdef kind="function" id="PlySerialize_8h_1a232c7f001466b8d236bd08b9a9160e7d" prot="public" static="yes" const="no" explicit="no" inline="yes" virt="non-virtual">
        <type>int</type>
        <definition>static int deserialize_ply</definition>
        <argsstring>(const seri_t s, const char *buf, const size_t buf_siz, va_list ap)</argsstring>
        <name>deserialize_ply</name>
        <param>
          <type>const <ref refid="structseri__t" kindref="compound">seri_t</ref></type>
          <declname>s</declname>
        </param>
        <param>
          <type>const char *</type>
          <declname>buf</declname>
        </param>
        <param>
          <type>const size_t</type>
          <declname>buf_siz</declname>
        </param>
        <param>
          <type>va_list</type>
          <declname>ap</declname>
        </param>
        <briefdescription>
<para>Deserialize message to populate ply structure. </para>        </briefdescription>
        <detaileddescription>
<para><parameterlist kind="param"><parameteritem>
<parameternamelist>
<parametername direction="in">s</parametername>
</parameternamelist>
<parameterdescription>
<para><ref refid="structseri__t" kindref="compound">seri_t</ref> Structure sepcifying how to deserialize message. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">buf</parametername>
</parameternamelist>
<parameterdescription>
<para>character pointer to serialized message. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="in">buf_siz</parametername>
</parameternamelist>
<parameterdescription>
<para>size_t Size of buf. </para></parameterdescription>
</parameteritem>
<parameteritem>
<parameternamelist>
<parametername direction="out">ap</parametername>
</parameternamelist>
<parameterdescription>
<para>va_list Arguments to be parsed from message. returns: int The number of populated arguments. -1 indicates an error. </para></parameterdescription>
</parameteritem>
</parameterlist>
</para>        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" line="286" column="1" bodyfile="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h" bodystart="286" bodyend="462"/>
      </memberdef>
      </sectiondef>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="preprocessor">#ifndef<sp/>CISPLYSERIALIZE_H_</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2"><highlight class="normal"></highlight><highlight class="preprocessor">#define<sp/>CISPLYSERIALIZE_H_</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="3"><highlight class="normal"></highlight></codeline>
<codeline lineno="4"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;../tools.h&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="5"><highlight class="normal"></highlight></codeline>
<codeline lineno="6"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>__cplusplus<sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>C++<sp/>compiler,<sp/>use<sp/>C<sp/>linkage<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="7"><highlight class="normal"></highlight><highlight class="keyword">extern</highlight><highlight class="normal"><sp/></highlight><highlight class="stringliteral">&quot;C&quot;</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="8"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="9"><highlight class="normal"></highlight></codeline>
<codeline lineno="11" refid="structply__t" refkind="compound"><highlight class="keyword">typedef</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">struct<sp/></highlight><highlight class="normal"><ref refid="structply__t" kindref="compound">ply_t</ref><sp/>{</highlight></codeline>
<codeline lineno="12" refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/></highlight></codeline>
<codeline lineno="13" refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/><ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/></highlight></codeline>
<codeline lineno="14" refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>**<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>;<sp/></highlight></codeline>
<codeline lineno="15" refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>**<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>;<sp/></highlight></codeline>
<codeline lineno="16" refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>**<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>;<sp/></highlight></codeline>
<codeline lineno="17" refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" refkind="member"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>;<sp/></highlight></codeline>
<codeline lineno="18"><highlight class="normal">}<sp/><ref refid="structply__t" kindref="compound">ply_t</ref>;</highlight></codeline>
<codeline lineno="19"><highlight class="normal"></highlight></codeline>
<codeline lineno="24"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="25"><highlight class="normal"><ref refid="structply__t" kindref="compound">ply_t</ref><sp/>init_ply()<sp/>{</highlight></codeline>
<codeline lineno="26"><highlight class="normal"><sp/><sp/><ref refid="structply__t" kindref="compound">ply_t</ref><sp/>x;</highlight></codeline>
<codeline lineno="27"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="28"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref><sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="29"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="30"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="32"><highlight class="normal"><sp/><sp/>x.<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>x;</highlight></codeline>
<codeline lineno="34"><highlight class="normal">};</highlight></codeline>
<codeline lineno="35"><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>free_ply(<ref refid="structply__t" kindref="compound">ply_t</ref><sp/>*p)<sp/>{</highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="45"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i]<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i]);</highlight></codeline>
<codeline lineno="47"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>);</highlight></codeline>
<codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="53"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i]<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i]);</highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="58"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>);</highlight></codeline>
<codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i]<sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i]);</highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>);</highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/>free(p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>);</highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref><sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="77"><highlight class="normal">};</highlight></codeline>
<codeline lineno="78"><highlight class="normal"></highlight></codeline>
<codeline lineno="87"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="88"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>alloc_ply(<ref refid="structply__t" kindref="compound">ply_t</ref><sp/>*p,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nvert,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nface,<sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>do_color)<sp/>{</highlight></codeline>
<codeline lineno="89"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i;</highlight></codeline>
<codeline lineno="90"><highlight class="normal"><sp/><sp/>free_ply(p);<sp/></highlight><highlight class="comment">//<sp/>Ensure<sp/>that<sp/>existing<sp/>data<sp/>is<sp/>freed</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="91"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref><sp/>=<sp/>nvert;</highlight></codeline>
<codeline lineno="92"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref><sp/>=<sp/>nface;</highlight></codeline>
<codeline lineno="93"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Allocate<sp/>vertices</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="94"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>**new_vert<sp/>=<sp/>(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal">**)malloc(p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal">*));</highlight></codeline>
<codeline lineno="95"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_vert<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="96"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>vertices.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="97"><highlight class="normal"><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="98"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="99"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="100"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref><sp/>=<sp/>new_vert;</highlight></codeline>
<codeline lineno="101"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="102"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>*ivert<sp/>=<sp/>(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal">*)malloc(3*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="103"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ivert<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="104"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>vertex<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="105"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="106"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="107"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="108"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i]<sp/>=<sp/>ivert;</highlight></codeline>
<codeline lineno="109"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="110"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Allocated<sp/>%d<sp/>vertices.&quot;</highlight><highlight class="normal">,<sp/>nvert);</highlight></codeline>
<codeline lineno="111"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Allocate<sp/>vertex<sp/>colors</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="112"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(do_color)<sp/>{</highlight></codeline>
<codeline lineno="113"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>**new_vert<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">**)malloc(p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*));</highlight></codeline>
<codeline lineno="114"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_vert<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="115"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>vertex_colors.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="116"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="117"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="118"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="119"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>=<sp/>new_vert;</highlight></codeline>
<codeline lineno="120"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="121"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*ivert<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)malloc(3*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="122"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ivert<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="123"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>vertex<sp/>color<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="124"><highlight class="normal"><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="125"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="126"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="127"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i]<sp/>=<sp/>ivert;</highlight></codeline>
<codeline lineno="128"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="129"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Allocated<sp/>%d<sp/>vertex<sp/>colors.&quot;</highlight><highlight class="normal">,<sp/>nvert);</highlight></codeline>
<codeline lineno="130"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="131"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Allocate<sp/>faces</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="132"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>**new_face<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">**)malloc(p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*));</highlight></codeline>
<codeline lineno="133"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_face<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="134"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>faces.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="135"><highlight class="normal"><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="136"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="137"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="138"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref><sp/>=<sp/>new_face;</highlight></codeline>
<codeline lineno="139"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="140"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i]<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="141"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>int<sp/>*iface<sp/>=<sp/>(int*)malloc(3*sizeof(int));<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="142"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>if<sp/>(iface<sp/>==<sp/>NULL)<sp/>{<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="143"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>cislog_error(&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>face<sp/>%d.&quot;,<sp/>i);<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="144"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>free_ply(p);<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="145"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/><sp/><sp/>return<sp/>-1;<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="146"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">/*<sp/>}<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="147"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="148"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Allocated<sp/>%d<sp/>faces.&quot;</highlight><highlight class="normal">,<sp/>nface);</highlight></codeline>
<codeline lineno="149"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Allocate<sp/>nvert_in_face</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="150"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*new_nvert<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)malloc(p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="151"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(new_nvert<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="152"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Failed<sp/>to<sp/>allocate<sp/>nvert_in_face.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="153"><highlight class="normal"><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="154"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="155"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="156"><highlight class="normal"><sp/><sp/>p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref><sp/>=<sp/>new_nvert;</highlight></codeline>
<codeline lineno="157"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="158"><highlight class="normal"><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>[i]<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="159"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="160"><highlight class="normal"><sp/><sp/>cislog_debug(</highlight><highlight class="stringliteral">&quot;alloc_ply:<sp/>Allocate<sp/>for<sp/>%d<sp/>vertices<sp/>and<sp/>%d<sp/>faces.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="161"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>,<sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>);</highlight></codeline>
<codeline lineno="162"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>0;</highlight></codeline>
<codeline lineno="163"><highlight class="normal">};</highlight></codeline>
<codeline lineno="164"><highlight class="normal"></highlight></codeline>
<codeline lineno="175"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="176"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>serialize_ply(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structseri__t" kindref="compound">seri_t</ref><sp/>s,<sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*buf,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>buf_size,</highlight></codeline>
<codeline lineno="177"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*args_used,<sp/>va_list<sp/>ap)<sp/>{</highlight></codeline>
<codeline lineno="178"><highlight class="normal"><sp/><sp/>args_used[0]<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="179"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>msg_len<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="180"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ilen;</highlight></codeline>
<codeline lineno="181"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>argument</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="182"><highlight class="normal"><sp/><sp/><ref refid="structply__t" kindref="compound">ply_t</ref><sp/>p<sp/>=<sp/>va_arg(ap,<sp/><ref refid="structply__t" kindref="compound">ply_t</ref>);</highlight></codeline>
<codeline lineno="183"><highlight class="normal"><sp/><sp/>args_used[0]<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="184"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Format<sp/>header</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="185"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>header_format[500]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;ply\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="186"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;format<sp/>ascii<sp/>1.0\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="187"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;comment<sp/>author<sp/>cis_auto\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="188"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;comment<sp/>File<sp/>generated<sp/>by<sp/>cis_interface\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="189"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;element<sp/>vertex<sp/>%d\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="190"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>float<sp/>x\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="191"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>float<sp/>y\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="192"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>float<sp/>z\n&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="193"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="194"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>header_format_colors[100]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;property<sp/>uchar<sp/>diffuse_red\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="195"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>uchar<sp/>diffuse_green\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="196"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>uchar<sp/>diffuse_blue\n&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="197"><highlight class="normal"><sp/><sp/><sp/><sp/>strcat(header_format,<sp/>header_format_colors);</highlight></codeline>
<codeline lineno="198"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="199"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>header_format2[100]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;element<sp/>face<sp/>%d\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="200"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;property<sp/>list<sp/>uchar<sp/>int<sp/>vertex_indices\n&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="201"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;end_header\n&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="202"><highlight class="normal"><sp/><sp/>strcat(header_format,<sp/>header_format2);</highlight></codeline>
<codeline lineno="203"><highlight class="normal"><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf,<sp/>buf_size,<sp/>header_format,<sp/>p.<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>,<sp/>p.<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>);</highlight></codeline>
<codeline lineno="204"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="205"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Error<sp/>formatting<sp/>header.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="206"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="207"><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&gt;=<sp/>buf_size)<sp/>{</highlight></codeline>
<codeline lineno="208"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Buffer<sp/>(size<sp/>=<sp/>%d)<sp/>is<sp/>not<sp/>large<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="209"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;enough<sp/>to<sp/>contain<sp/>the<sp/>header<sp/>(size<sp/>=<sp/>%d).&quot;</highlight><highlight class="normal">,<sp/>buf_size,<sp/>ilen);</highlight></codeline>
<codeline lineno="210"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="211"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="212"><highlight class="normal"><sp/><sp/>msg_len<sp/>=<sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="213"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Add<sp/>vertex<sp/>information</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="214"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i,<sp/>j;</highlight></codeline>
<codeline lineno="215"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p.<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="216"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(p.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref><sp/>!=<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="217"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf<sp/>+<sp/>msg_len,<sp/>buf_size<sp/>-<sp/>msg_len,<sp/></highlight><highlight class="stringliteral">&quot;%f<sp/>%f<sp/>%f<sp/>%d<sp/>%d<sp/>%d\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="218"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][0],<sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][1],<sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][2],</highlight></codeline>
<codeline lineno="219"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i][0],<sp/>p.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i][1],<sp/>p.<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i][2]);</highlight></codeline>
<codeline lineno="220"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="221"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf<sp/>+<sp/>msg_len,<sp/>buf_size<sp/>-<sp/>msg_len,<sp/></highlight><highlight class="stringliteral">&quot;%f<sp/>%f<sp/>%f\n&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="222"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][0],<sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][1],<sp/>p.<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][2]);</highlight></codeline>
<codeline lineno="223"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="224"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="225"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Error<sp/>formatting<sp/>vertex<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="226"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="227"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&gt;=<sp/>(buf_size<sp/>-<sp/>msg_len))<sp/>{</highlight></codeline>
<codeline lineno="228"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Buffer<sp/>(size<sp/>=<sp/>%d)<sp/>is<sp/>not<sp/>large<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="229"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;enough<sp/>to<sp/>contain<sp/>vertex<sp/>%d<sp/>(size<sp/>=<sp/>%d).&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="230"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buf_size,<sp/>i,<sp/>ilen<sp/>+<sp/>msg_len);</highlight></codeline>
<codeline lineno="231"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="232"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="233"><highlight class="normal"><sp/><sp/><sp/><sp/>msg_len<sp/>=<sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="234"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="235"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Add<sp/>face<sp/>information</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="236"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p.<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="237"><highlight class="normal"><sp/><sp/><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf<sp/>+<sp/>msg_len,<sp/>buf_size<sp/>-<sp/>msg_len,<sp/></highlight><highlight class="stringliteral">&quot;%d&quot;</highlight><highlight class="normal">,<sp/>p.<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>[i]);</highlight></codeline>
<codeline lineno="238"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="239"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Error<sp/>formatting<sp/>number<sp/>of<sp/>verts<sp/>for<sp/>face<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="240"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="241"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&gt;<sp/>(buf_size<sp/>-<sp/>msg_len))<sp/>{</highlight></codeline>
<codeline lineno="242"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Buffer<sp/>(size<sp/>=<sp/>%d)<sp/>is<sp/>not<sp/>large<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="243"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;enough<sp/>to<sp/>contain<sp/>number<sp/>of<sp/>verts<sp/>for<sp/>face<sp/>%d<sp/>(size<sp/>=<sp/>%d).&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="244"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buf_size,<sp/>i,<sp/>ilen<sp/>+<sp/>msg_len);</highlight></codeline>
<codeline lineno="245"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="246"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="247"><highlight class="normal"><sp/><sp/><sp/><sp/>msg_len<sp/>=<sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="248"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(j<sp/>=<sp/>0;<sp/>j<sp/>&lt;<sp/>p.<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>[i];<sp/>j++)<sp/>{</highlight></codeline>
<codeline lineno="249"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf<sp/>+<sp/>msg_len,<sp/>buf_size<sp/>-<sp/>msg_len,<sp/></highlight><highlight class="stringliteral">&quot;<sp/>%d&quot;</highlight><highlight class="normal">,<sp/>p.<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i][j]);</highlight></codeline>
<codeline lineno="250"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="251"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Error<sp/>formatting<sp/>element<sp/>%d<sp/>of<sp/>face<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>j,<sp/>i);</highlight></codeline>
<codeline lineno="252"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="253"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&gt;<sp/>(buf_size<sp/>-<sp/>msg_len))<sp/>{</highlight></codeline>
<codeline lineno="254"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Buffer<sp/>(size<sp/>=<sp/>%d)<sp/>is<sp/>not<sp/>large<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="255"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;enough<sp/>to<sp/>contain<sp/>element<sp/>%d<sp/>of<sp/>face<sp/>%d<sp/>(size<sp/>=<sp/>%d).&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="256"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buf_size,<sp/>j,<sp/>i,<sp/>ilen<sp/>+<sp/>msg_len);</highlight></codeline>
<codeline lineno="257"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="258"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="259"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>msg_len<sp/>=<sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="260"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="261"><highlight class="normal"><sp/><sp/><sp/><sp/>ilen<sp/>=<sp/>snprintf(buf<sp/>+<sp/>msg_len,<sp/>buf_size<sp/>-<sp/>msg_len,<sp/></highlight><highlight class="stringliteral">&quot;\n&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="262"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="263"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Error<sp/>formatting<sp/>newline<sp/>for<sp/>face<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="264"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>-1;</highlight></codeline>
<codeline lineno="265"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ilen<sp/>&gt;<sp/>(buf_size<sp/>-<sp/>msg_len))<sp/>{</highlight></codeline>
<codeline lineno="266"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;serialize_ply:<sp/>Buffer<sp/>(size<sp/>=<sp/>%d)<sp/>is<sp/>not<sp/>large<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="267"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;enough<sp/>to<sp/>contain<sp/>newline<sp/>for<sp/>face<sp/>%d<sp/>(size<sp/>=<sp/>%d).&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="268"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>buf_size,<sp/>i,<sp/>ilen<sp/>+<sp/>msg_len);</highlight></codeline>
<codeline lineno="269"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="270"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="271"><highlight class="normal"><sp/><sp/><sp/><sp/>msg_len<sp/>=<sp/>msg_len<sp/>+<sp/>ilen;</highlight></codeline>
<codeline lineno="272"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="273"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>msg_len;</highlight></codeline>
<codeline lineno="274"><highlight class="normal">};</highlight></codeline>
<codeline lineno="275"><highlight class="normal"></highlight></codeline>
<codeline lineno="276"><highlight class="normal"></highlight></codeline>
<codeline lineno="285"><highlight class="keyword">static</highlight><highlight class="normal"><sp/></highlight><highlight class="keyword">inline</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="286"><highlight class="normal"></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>deserialize_ply(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="structseri__t" kindref="compound">seri_t</ref><sp/>s,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>*buf,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>buf_siz,</highlight></codeline>
<codeline lineno="287"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>va_list<sp/>ap)<sp/>{</highlight></codeline>
<codeline lineno="288"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>out<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="289"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>do_colors<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="290"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>n_sub_matches;</highlight></codeline>
<codeline lineno="291"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>*sind<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="292"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>*eind<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="293"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>*sind_body<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="294"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>*eind_body<sp/>=<sp/>NULL;</highlight></codeline>
<codeline lineno="295"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>value_size;</highlight></codeline>
<codeline lineno="296"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>value[100];</highlight></codeline>
<codeline lineno="297"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>begin_body<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="298"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nlines<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="299"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i,<sp/>j;</highlight></codeline>
<codeline lineno="300"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nvert<sp/>=<sp/>0,<sp/>nface<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="301"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>line_no;</highlight></codeline>
<codeline lineno="302"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>line_size;</highlight></codeline>
<codeline lineno="303"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>iline[100];</highlight></codeline>
<codeline lineno="304"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>argument</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="305"><highlight class="normal"><sp/><sp/><ref refid="structply__t" kindref="compound">ply_t</ref><sp/>*p<sp/>=<sp/>va_arg(ap,<sp/><ref refid="structply__t" kindref="compound">ply_t</ref>*);</highlight></codeline>
<codeline lineno="306"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>info<sp/>from<sp/>the<sp/>header.</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="307"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Number<sp/>of<sp/>vertices</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="308"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="309"><highlight class="normal"><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(</highlight><highlight class="stringliteral">&quot;element<sp/>vertex<sp/>([[:digit:]]+)\n&quot;</highlight><highlight class="normal">,<sp/>buf,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="310"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>&lt;<sp/>2)<sp/>{</highlight></codeline>
<codeline lineno="311"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Could<sp/>not<sp/>locate<sp/>number<sp/>of<sp/>vertices<sp/>in<sp/>ply<sp/>header.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="312"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="313"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="314"><highlight class="normal"><sp/><sp/><sp/><sp/>value_size<sp/>=<sp/>eind[1]<sp/>-<sp/>sind[1];</highlight></codeline>
<codeline lineno="315"><highlight class="normal"><sp/><sp/><sp/><sp/>memcpy(value,<sp/>buf<sp/>+<sp/>sind[1],<sp/>value_size);</highlight></codeline>
<codeline lineno="316"><highlight class="normal"><sp/><sp/><sp/><sp/>value[value_size]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="317"><highlight class="normal"><sp/><sp/><sp/><sp/>nvert<sp/>=<sp/>atoi(value);</highlight></codeline>
<codeline lineno="318"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="319"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Number<sp/>of<sp/>faces</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="320"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="321"><highlight class="normal"><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(</highlight><highlight class="stringliteral">&quot;element<sp/>face<sp/>([[:digit:]]+)\n&quot;</highlight><highlight class="normal">,<sp/>buf,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="322"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>&lt;<sp/>2)<sp/>{</highlight></codeline>
<codeline lineno="323"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Could<sp/>not<sp/>locate<sp/>number<sp/>of<sp/>faces<sp/>in<sp/>ply<sp/>header.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="324"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="325"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="326"><highlight class="normal"><sp/><sp/><sp/><sp/>value_size<sp/>=<sp/>eind[1]<sp/>-<sp/>sind[1];</highlight></codeline>
<codeline lineno="327"><highlight class="normal"><sp/><sp/><sp/><sp/>memcpy(value,<sp/>buf<sp/>+<sp/>sind[1],<sp/>value_size);</highlight></codeline>
<codeline lineno="328"><highlight class="normal"><sp/><sp/><sp/><sp/>value[value_size]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="329"><highlight class="normal"><sp/><sp/><sp/><sp/>nface<sp/>=<sp/>atoi(value);</highlight></codeline>
<codeline lineno="330"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="331"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Color</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="332"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="333"><highlight class="normal"><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(</highlight><highlight class="stringliteral">&quot;green&quot;</highlight><highlight class="normal">,<sp/>buf,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="334"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>!=<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="335"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>do_colors<sp/>=<sp/>1;</highlight></codeline>
<codeline lineno="336"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="337"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="338"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>End<sp/>of<sp/>header</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="339"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="340"><highlight class="normal"><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(</highlight><highlight class="stringliteral">&quot;end_header\n&quot;</highlight><highlight class="normal">,<sp/>buf,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="341"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>&lt;<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="342"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Could<sp/>not<sp/>locate<sp/>end<sp/>of<sp/>header.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="343"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="344"><highlight class="normal"><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="345"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>begin_body<sp/>=<sp/>eind[0];</highlight></codeline>
<codeline lineno="346"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="347"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="348"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Locate<sp/>lines</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="349"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="350"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nlines_expected<sp/>=<sp/>nvert<sp/>+<sp/>nface;</highlight></codeline>
<codeline lineno="351"><highlight class="normal"><sp/><sp/><sp/><sp/>nlines<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="352"><highlight class="normal"><sp/><sp/><sp/><sp/>sind_body<sp/>=<sp/>(</highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal">*)realloc(sind_body,<sp/>(nlines_expected+1)*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(size_t));</highlight></codeline>
<codeline lineno="353"><highlight class="normal"><sp/><sp/><sp/><sp/>eind_body<sp/>=<sp/>(</highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal">*)realloc(eind_body,<sp/>(nlines_expected+1)*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(size_t));</highlight></codeline>
<codeline lineno="354"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">size_t</highlight><highlight class="normal"><sp/>cur_pos<sp/>=<sp/>begin_body;</highlight></codeline>
<codeline lineno="355"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">while</highlight><highlight class="normal"><sp/>(1)<sp/>{</highlight></codeline>
<codeline lineno="356"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(</highlight><highlight class="stringliteral">&quot;([^\n]*)\n&quot;</highlight><highlight class="normal">,<sp/>buf<sp/>+<sp/>cur_pos,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="357"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>&lt;<sp/>2)<sp/>{</highlight></codeline>
<codeline lineno="358"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="359"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="360"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(nlines<sp/>&gt;<sp/>nlines_expected)<sp/>{</highlight></codeline>
<codeline lineno="361"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="362"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>nlines_expected<sp/>=<sp/>nlines_expected<sp/>+<sp/>50;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="363"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>sind_body<sp/>=<sp/>(size_t*)realloc(sind_body,<sp/>(nlines_expected+1)*sizeof(size_t));</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="364"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>eind_body<sp/>=<sp/>(size_t*)realloc(eind_body,<sp/>(nlines_expected+1)*sizeof(size_t));</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="365"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="366"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sind_body[nlines]<sp/>=<sp/>cur_pos<sp/>+<sp/>sind[1];</highlight></codeline>
<codeline lineno="367"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>eind_body[nlines]<sp/>=<sp/>cur_pos<sp/>+<sp/>eind[1];</highlight></codeline>
<codeline lineno="368"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>nlines++;</highlight></codeline>
<codeline lineno="369"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cur_pos<sp/>=<sp/>cur_pos<sp/>+<sp/>eind[0];</highlight></codeline>
<codeline lineno="370"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="371"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>((nvert<sp/>+<sp/>nface)<sp/>&gt;<sp/>nlines)<sp/>{</highlight></codeline>
<codeline lineno="372"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Not<sp/>enough<sp/>lines<sp/>(%d)<sp/>for<sp/>%d<sp/>vertices<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="373"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;and<sp/>%d<sp/>faces.&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline lineno="374"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>nlines,<sp/>nvert,<sp/>nface);</highlight></codeline>
<codeline lineno="375"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="376"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="377"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="378"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Allocate</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="379"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="380"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>ret<sp/>=<sp/>alloc_ply(p,<sp/>nvert,<sp/>nface,<sp/>do_colors);</highlight></codeline>
<codeline lineno="381"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(ret<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="382"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Error<sp/>allocating<sp/>ply<sp/>structure.&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="383"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="384"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="385"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="386"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>vertices</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="387"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="388"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nexpected<sp/>=<sp/>3;</highlight></codeline>
<codeline lineno="389"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(do_colors)<sp/>{</highlight></codeline>
<codeline lineno="390"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>nexpected<sp/>=<sp/>6;</highlight></codeline>
<codeline lineno="391"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="392"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>vert_re[80]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;([^<sp/>]+)<sp/>([^<sp/>]+)<sp/>([^<sp/>]+)&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="393"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Parse<sp/>each<sp/>line</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="394"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="395"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>line_no<sp/>=<sp/>i;</highlight></codeline>
<codeline lineno="396"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>line_size<sp/>=<sp/>eind_body[line_no]<sp/>-<sp/>sind_body[line_no];</highlight></codeline>
<codeline lineno="397"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>memcpy(iline,<sp/>buf<sp/>+<sp/>sind_body[line_no],<sp/>line_size);</highlight></codeline>
<codeline lineno="398"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>iline[line_size]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="399"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(vert_re,<sp/>iline,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="400"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>!=<sp/>nexpected<sp/>+<sp/>1)<sp/>{</highlight></codeline>
<codeline lineno="401"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Vertex<sp/>should<sp/>contain<sp/>%d<sp/>entries.<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="402"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;%d<sp/>were<sp/>found&quot;</highlight><highlight class="normal">,<sp/>nexpected,<sp/>n_sub_matches<sp/>-<sp/>1);</highlight></codeline>
<codeline lineno="403"><highlight class="normal"><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="404"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="405"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="406"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(j<sp/>=<sp/>0;<sp/>j<sp/>&lt;<sp/>3;<sp/>j++)<sp/>{</highlight></codeline>
<codeline lineno="407"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1ae369adb99bfa7d4ce6c0de17375ceca5" kindref="member">vertices</ref>[i][j]<sp/>=<sp/>atof(iline<sp/>+<sp/>sind[j<sp/>+<sp/>1]);</highlight></codeline>
<codeline lineno="408"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="409"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(do_colors)<sp/>{</highlight></codeline>
<codeline lineno="410"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(j<sp/>=<sp/>0;<sp/>j<sp/>&lt;<sp/>3;<sp/>j++)<sp/>{</highlight></codeline>
<codeline lineno="411"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1a8070ee061d8bc3ae6067aaa52310c0fa" kindref="member">vertex_colors</ref>[i][j]<sp/>=<sp/>atoi(iline<sp/>+<sp/>sind[j<sp/>+<sp/>4]);</highlight></codeline>
<codeline lineno="412"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="413"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="414"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="415"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="416"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="417"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Get<sp/>faces</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="418"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&gt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="419"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>nexpected<sp/>=<sp/>0;</highlight></codeline>
<codeline lineno="420"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Parse<sp/>each<sp/>line</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="421"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/>p-&gt;<ref refid="structply__t_1a193a6563568843d5c9b21fc9b6f729ce" kindref="member">nface</ref>;<sp/>i++)<sp/>{</highlight></codeline>
<codeline lineno="422"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>line_no<sp/>=<sp/>i<sp/>+<sp/>p-&gt;<ref refid="structply__t_1a8958bfc57c4354ce663eb39972efb08f" kindref="member">nvert</ref>;</highlight></codeline>
<codeline lineno="423"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>line_size<sp/>=<sp/>eind_body[line_no]<sp/>-<sp/>sind_body[line_no];</highlight></codeline>
<codeline lineno="424"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>memcpy(iline,<sp/>buf<sp/>+<sp/>sind_body[line_no],<sp/>line_size);</highlight></codeline>
<codeline lineno="425"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>iline[line_size]<sp/>=<sp/></highlight><highlight class="charliteral">&apos;\0&apos;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="426"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>nexpected<sp/>=<sp/>atoi(iline);</highlight></codeline>
<codeline lineno="427"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1acb3aaad9679629140b24855a262d5cf8" kindref="member">nvert_in_face</ref>[i]<sp/>=<sp/>nexpected;</highlight></codeline>
<codeline lineno="428"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal"><sp/>face_re[80]<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;([^<sp/>]+)&quot;</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="429"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(j<sp/>=<sp/>0;<sp/>j<sp/>&lt;<sp/>nexpected;<sp/>j++)<sp/>{</highlight></codeline>
<codeline lineno="430"><highlight class="normal"><sp/><sp/><sp/><sp/>strcat(face_re,<sp/></highlight><highlight class="stringliteral">&quot;<sp/>([^<sp/>]+)&quot;</highlight><highlight class="normal">);</highlight></codeline>
<codeline lineno="431"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="432"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>n_sub_matches<sp/>=<sp/>find_matches(face_re,<sp/>iline,<sp/>&amp;sind,<sp/>&amp;eind);</highlight></codeline>
<codeline lineno="433"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(n_sub_matches<sp/>&lt;<sp/>(nexpected<sp/>+<sp/>2))<sp/>{</highlight></codeline>
<codeline lineno="434"><highlight class="normal"><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Face<sp/>should<sp/>contain<sp/>%d<sp/>entries.<sp/>&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="435"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;%d<sp/>were<sp/>found.&quot;</highlight><highlight class="normal">,<sp/>nexpected,<sp/>n_sub_matches<sp/>-<sp/>2);</highlight></codeline>
<codeline lineno="436"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="437"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="438"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="439"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>*iface<sp/>=<sp/>(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">*)realloc(p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i],<sp/>nexpected*</highlight><highlight class="keyword">sizeof</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal">));</highlight></codeline>
<codeline lineno="440"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(iface<sp/>==<sp/>NULL)<sp/>{</highlight></codeline>
<codeline lineno="441"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>cislog_error(</highlight><highlight class="stringliteral">&quot;deserialize_ply:<sp/>Could<sp/>not<sp/>allocate<sp/>face<sp/>%d.&quot;</highlight><highlight class="normal">,<sp/>i);</highlight></codeline>
<codeline lineno="442"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>out<sp/>=<sp/>-1;</highlight></codeline>
<codeline lineno="443"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">break</highlight><highlight class="normal">;</highlight></codeline>
<codeline lineno="444"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="445"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i]<sp/>=<sp/>iface;</highlight></codeline>
<codeline lineno="446"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal"><sp/>(j<sp/>=<sp/>0;<sp/>j<sp/>&lt;<sp/>nexpected;<sp/>j++)<sp/>{</highlight></codeline>
<codeline lineno="447"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>p-&gt;<ref refid="structply__t_1af1d30fca2604f6db56811f4708fe2e4f" kindref="member">faces</ref>[i][j]<sp/>=<sp/>atoi(iline<sp/>+<sp/>sind[j<sp/>+<sp/>2]);</highlight></codeline>
<codeline lineno="448"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="449"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="450"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="451"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="452"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="453"><highlight class="normal"><sp/><sp/></highlight><highlight class="comment">//<sp/>Return</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="454"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sind<sp/>!=<sp/>NULL)<sp/>free(sind);<sp/></highlight></codeline>
<codeline lineno="455"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(eind<sp/>!=<sp/>NULL)<sp/>free(eind);</highlight></codeline>
<codeline lineno="456"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(sind_body<sp/>!=<sp/>NULL)<sp/>free(sind_body);<sp/></highlight></codeline>
<codeline lineno="457"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(eind_body<sp/>!=<sp/>NULL)<sp/>free(eind_body);</highlight></codeline>
<codeline lineno="458"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal"><sp/>(out<sp/>&lt;<sp/>0)<sp/>{</highlight></codeline>
<codeline lineno="459"><highlight class="normal"><sp/><sp/><sp/><sp/>free_ply(p);</highlight></codeline>
<codeline lineno="460"><highlight class="normal"><sp/><sp/>}</highlight></codeline>
<codeline lineno="461"><highlight class="normal"><sp/><sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>out;</highlight></codeline>
<codeline lineno="462"><highlight class="normal">};</highlight></codeline>
<codeline lineno="463"><highlight class="normal"></highlight></codeline>
<codeline lineno="464"><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>__cplusplus<sp/></highlight><highlight class="comment">/*<sp/>If<sp/>this<sp/>is<sp/>a<sp/>C++<sp/>compiler,<sp/>end<sp/>C<sp/>linkage<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="465"><highlight class="normal">}</highlight></codeline>
<codeline lineno="466"><highlight class="normal"></highlight><highlight class="preprocessor">#endif</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="467"><highlight class="normal"></highlight></codeline>
<codeline lineno="468"><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*CISPLYSERIALIZE_H_*/</highlight><highlight class="preprocessor"></highlight></codeline>
    </programlisting>
    <location file="/root/cis_interface/cis_interface/cis_interface/serialize/PlySerialize.h"/>
  </compounddef>
</doxygen>
