<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<section xmlns="http://docbook.org/ns/docbook" version="5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="_model__shell_8cpp">
<title>/Users/bernard/b20/bsoft/src/model/model_shell.cpp File Reference</title>
<indexterm><primary>/Users/bernard/b20/bsoft/src/model/model_shell.cpp</primary></indexterm>
<para>

<para>Library routines used for shell model processing. </para>
 
</para>
<programlisting>#include &quot;model_create.h&quot;
#include &quot;model_shell.h&quot;
#include &quot;model_color.h&quot;
#include &quot;model_util.h&quot;
#include &quot;model_transform.h&quot;
#include &quot;model_select.h&quot;
#include &quot;random_numbers.h&quot;
#include &quot;utilities.h&quot;
</programlisting><simplesect>
    <title>Functions    </title>
        <itemizedlist>
            <listitem><para>long <link linkend="_model__shell_8cpp_1aecd18968852bbebbf7ef3be1272b3305">model_add_shell</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>, double add_distance, <link linkend="_class_bstring">Bstring</link> &amp;nutype)</para>

<para>Adds a shell to a model using selected components. </para>
</listitem>
            <listitem><para>int <link linkend="_model__shell_8cpp_1a24bbb7f6ecd5176719fdaa0b42c5cb41">model_adjust_shell_to_guide</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>, <link linkend="_struct_bmodel">Bmodel</link> *gmod, double fraction, int curv_flag)</para>

<para>Adjusts a shell model to the faces of a polyhedral guide model. </para>
</listitem>
            <listitem><para><link linkend="_struct_bmodel">Bmodel</link> * <link linkend="_model__shell_8cpp_1a98c8896a0e49f2860fb72ad89ffaef39">model_components_to_shells</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>, double <link linkend="__vector3_8h_1aa60745aa4e45acde64f733424e37dbb9">distance</link>, <link linkend="_class_bstring">Bstring</link> &amp;nutype, int twod)</para>

<para>Generates a new set of models by vonverting each component to a shell model. </para>
</listitem>
            <listitem><para>double <link linkend="_model__shell_8cpp_1ac4455d4fa35a775fc0e4df3e816e9563">model_sphericity</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>)</para>

<para>Calculates how close the model is to a spherical shape. </para>
</listitem>
            <listitem><para>double <link linkend="_model__shell_8cpp_1a6c62efac8e5100e442ff448e0d7d054a">model_ellipsoidicity</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>)</para>

<para>Calculates how close the model is to an ellipsoid shape. </para>
</listitem>
            <listitem><para>int <link linkend="_model__shell_8cpp_1af772e8542054fe6315980757020155f1">model_curvature</link> (<link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>)</para>

<para>Calculates the curvature associated with each link. </para>
</listitem>
            <listitem><para>double <link linkend="_model__shell_8cpp_1a604363103aec0120df59f6a4ecad3422">model_inside_outside_fast</link> (<link linkend="_class_vector3">Vector3</link>&lt; double &gt; vec, <link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>, int curv_flag)</para>

<para>Determines if a vector is inside or outside model boundaries. </para>
</listitem>
            <listitem><para>double <link linkend="_model__shell_8cpp_1a6aeb99e0a4012232714281472cd5554d">model_inside_outside</link> (<link linkend="_class_vector3">Vector3</link>&lt; double &gt; vec, <link linkend="_struct_bmodel">Bmodel</link> *<link linkend="_tcltk__bmodel_8cpp_1a828359eaa8de833b547ac96934f43841">model</link>, int curv_flag, int fast)</para>
</listitem>
        </itemizedlist>
</simplesect>
<simplesect>
    <title>Variables    </title>
        <itemizedlist>
            <listitem><para>int <link linkend="_model__shell_8cpp_1a0b2caeb4b6f130be43e5a2f0267dd453">verbose</link></para>
</listitem>
        </itemizedlist>
</simplesect>
<section>
<title>Detailed Description</title>

<para>Library routines used for shell model processing. </para>

<para><formalpara><title>Author: </title>

<para>Bernard Heymann </para>
</formalpara>
<formalpara><title>Date: </title>

<para>Created: 20060908 </para>

<para>Modified: 20161013 </para>
</formalpara>
</para>
</section>
<section>
<title>Function Documentation</title>
<anchor xml:id="_model__shell_8cpp_1aecd18968852bbebbf7ef3be1272b3305"/>    <section>
    <title>model_add_shell()</title>
<indexterm><primary>model_add_shell</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_add_shell</secondary></indexterm>
<para><computeroutput>long model_add_shell (<link linkend="_struct_bmodel">Bmodel</link> * model, double add_distance, <link linkend="_class_bstring">Bstring</link> &amp; nutype)</computeroutput></para><para>

<para>Adds a shell to a model using selected components. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure. </para>
</entry>
                            </row>
                            <row>
                                <entry>add_distance</entry>
                                <entry>
<para>distance to shift new components. </para>
</entry>
                            </row>
                            <row>
                                <entry>&amp;nutype</entry>
                                <entry>
<para>new component type. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>long number of components in new shell. <literallayout><computeroutput>Each selected component is duplicated and shifted radially.
Only the first model in the list is used.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 32 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1a24bbb7f6ecd5176719fdaa0b42c5cb41"/>    <section>
    <title>model_adjust_shell_to_guide()</title>
<indexterm><primary>model_adjust_shell_to_guide</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_adjust_shell_to_guide</secondary></indexterm>
<para><computeroutput>int model_adjust_shell_to_guide (<link linkend="_struct_bmodel">Bmodel</link> * model, <link linkend="_struct_bmodel">Bmodel</link> * gmod, double fraction, int curv_flag)</computeroutput></para><para>

<para>Adjusts a shell model to the faces of a polyhedral guide model. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>shell model. </para>
</entry>
                            </row>
                            <row>
                                <entry>*gmod</entry>
                                <entry>
<para>guide polyhedron model. </para>
</entry>
                            </row>
                            <row>
                                <entry>fraction</entry>
                                <entry>
<para>fraction to adjust. </para>
</entry>
                            </row>
                            <row>
                                <entry>curv_flag</entry>
                                <entry>
<para>flag to indicate curved surface. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>int 0. <literallayout><computeroutput>For each component, it is determined whether it is located inside or 
outside the appropriate polyhedral face, and its coordinates adjust
closer to the face by the indicated fraction.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 85 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1a98c8896a0e49f2860fb72ad89ffaef39"/>    <section>
    <title>model_components_to_shells()</title>
<indexterm><primary>model_components_to_shells</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_components_to_shells</secondary></indexterm>
<para><computeroutput><link linkend="_struct_bmodel">Bmodel</link>* model_components_to_shells (<link linkend="_struct_bmodel">Bmodel</link> * model, double distance, <link linkend="_class_bstring">Bstring</link> &amp; nutype, int twod)</computeroutput></para><para>

<para>Generates a new set of models by vonverting each component to a shell model. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure. </para>
</entry>
                            </row>
                            <row>
                                <entry>distance</entry>
                                <entry>
<para>distance between components. </para>
</entry>
                            </row>
                            <row>
                                <entry>&amp;nutype</entry>
                                <entry>
<para>new component type. </para>
</entry>
                            </row>
                            <row>
                                <entry>twod</entry>
                                <entry>
<para>flag to indicate a 2D model. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>Bmodel* new list of models. <literallayout><computeroutput>Each selected component is converted to a shell model.
The radius is taken from the original component radius.
The given distance defines the distance between the new
components and their radii.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 139 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1af772e8542054fe6315980757020155f1"/>    <section>
    <title>model_curvature()</title>
<indexterm><primary>model_curvature</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_curvature</secondary></indexterm>
<para><computeroutput>int model_curvature (<link linkend="_struct_bmodel">Bmodel</link> * model)</computeroutput></para><para>

<para>Calculates the curvature associated with each link. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure (views modified). </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>int 0. <literallayout><computeroutput>The difference angle in the normals or view vectors of each pair of
vertices of a link represents the curvature for that link.
Curvature at each component is calculated as the average of the 
curvature of the attached links and set as the component FOM.
The model curvature is calculated as the average component curvature
and set as the model FOM.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 279 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1a6c62efac8e5100e442ff448e0d7d054a"/>    <section>
    <title>model_ellipsoidicity()</title>
<indexterm><primary>model_ellipsoidicity</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_ellipsoidicity</secondary></indexterm>
<para><computeroutput>double model_ellipsoidicity (<link linkend="_struct_bmodel">Bmodel</link> * model)</computeroutput></para><para>

<para>Calculates how close the model is to an ellipsoid shape. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>double ellipsoidicity. <literallayout><computeroutput>The principle axes are calculated first.
Then the fit to an ellipsoid function is calculated.
Only the first model in the list is processed.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 234 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1a6aeb99e0a4012232714281472cd5554d"/>    <section>
    <title>model_inside_outside()</title>
<indexterm><primary>model_inside_outside</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_inside_outside</secondary></indexterm>
<para><computeroutput>double model_inside_outside (<link linkend="_class_vector3">Vector3</link>&lt; double &gt; vec, <link linkend="_struct_bmodel">Bmodel</link> * model, int curv_flag, int fast)</computeroutput></para><para>
Definition at line 401 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1a604363103aec0120df59f6a4ecad3422"/>    <section>
    <title>model_inside_outside_fast()</title>
<indexterm><primary>model_inside_outside_fast</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_inside_outside_fast</secondary></indexterm>
<para><computeroutput>double model_inside_outside_fast (<link linkend="_class_vector3">Vector3</link>&lt; double &gt; vec, <link linkend="_struct_bmodel">Bmodel</link> * model, int curv_flag)</computeroutput></para><para>

<para>Determines if a vector is inside or outside model boundaries. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>vec</entry>
                                <entry>
<para>vector to test for. </para>
</entry>
                            </row>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure. </para>
</entry>
                            </row>
                            <row>
                                <entry>curv_flag</entry>
                                <entry>
<para>flag to indicate curved surface. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>double distance from interface (inside positive). <literallayout><computeroutput>Whether a point is inside or outside is based on the model structure, 
where the intersection of a vector through the point with the plane through 
the three closest vertices is the dividing point. The following set of 
equations is solved:
    v/|v| = w0 * a0 + w1 * a1 + w2 * a2
where v is the point to be judged, and w&lt;n&gt; are the weights for the 
contributing vectors a&lt;n&gt;.
The distance to the triangle plane intersecting point is:
    d = 1/(w0 + w1 + w2)
The distance to the curved surface through the three vertices is:
    d = w0 * |a0| + w1 * |a1| + w2 * |a2|
where the weights have been normalized:
    w0 + w1 + w2 = 1
Requirement: The sampled component location vectors must be set up 
    in the component force vectors.
Only the first model in the linked list is used.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 341 of file model_shell.cpp.</para>
    </section><anchor xml:id="_model__shell_8cpp_1ac4455d4fa35a775fc0e4df3e816e9563"/>    <section>
    <title>model_sphericity()</title>
<indexterm><primary>model_sphericity</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>model_sphericity</secondary></indexterm>
<para><computeroutput>double model_sphericity (<link linkend="_struct_bmodel">Bmodel</link> * model)</computeroutput></para><para>

<para>Calculates how close the model is to a spherical shape. </para>
</para>

<para>
                <formalpara>
                    <title>
Parameters                    </title>
                    <para>
                    <table frame="all">
                        <tgroup cols="2" align="left" colsep="1" rowsep="1">
                        <colspec colwidth="1*"/>
                        <colspec colwidth="4*"/>
                        <tbody>
                            <row>
                                <entry>*model</entry>
                                <entry>
<para>model structure. </para>
</entry>
                            </row>
                        </tbody>
                        </tgroup>
                    </table>
                    </para>
                </formalpara>
                <formalpara><title>Returns: </title>

<para>double sphericity. <literallayout><computeroutput>The deviation of vertices from the average radius is calculated.
Only the first model in the list is processed.
</computeroutput></literallayout> </para>
</formalpara>
</para>
<para>
Definition at line 194 of file model_shell.cpp.</para>
</section>
</section>
<section>
<title>Variable Documentation</title>
<anchor xml:id="_model__shell_8cpp_1a0b2caeb4b6f130be43e5a2f0267dd453"/>    <section>
    <title>verbose</title>
<indexterm><primary>verbose</primary><secondary>model_shell.cpp</secondary></indexterm>
<indexterm><primary>model_shell.cpp</primary><secondary>verbose</secondary></indexterm>
<para><computeroutput>int verbose</computeroutput></para></section>
</section>
</section>
