diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a03100.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a03100.html | 1389 |
1 files changed, 1389 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a03100.html b/docs/doxygen/nel/a03100.html new file mode 100644 index 00000000..17c16dc5 --- /dev/null +++ b/docs/doxygen/nel/a03100.html @@ -0,0 +1,1389 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLMISC::CPolygon class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Data Structures</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLMISC::CPolygon Class Reference</h1><code>#include <<a class="el" href="a06191.html">polygon.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +A polygon, with an unlimited size of vertices. <dl compact><dt><b>Author:</b></dt><dd>Lionel Berenguier <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2000 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a06191.html#l00052">52</a> of file <a class="el" href="a06191.html">polygon.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona0">buildBasis</a> (<a class="el" href="a02851.html">CMatrix</a> &dest)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona1">chain</a> (const std::vector< <a class="el" href="a03100.html">CPolygon</a> > &other, const <a class="el" href="a02851.html">CMatrix</a> &basis)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona2">clip</a> (const std::vector< <a class="el" href="a03082.html">CPlane</a> > &planes)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes. <a href="#NLMISC_1_1CPolygona2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona3">clip</a> (const <a class="el" href="a03082.html">CPlane</a> *planes, <a class="el" href="a04558.html#a15">uint</a> nPlanes)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes. <a href="#NLMISC_1_1CPolygona3"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona4">CPolygon</a> (const <a class="el" href="a03128.html">CVector</a> &a, const <a class="el" href="a03128.html">CVector</a> &b, const <a class="el" href="a03128.html">CVector</a> &c)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. Init with a triangle. <a href="#NLMISC_1_1CPolygona4"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> ()</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Constructor. <a href="#NLMISC_1_1CPolygona5"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona6">getBestTriplet</a> (<a class="el" href="a04558.html#a15">uint</a> &index0, <a class="el" href="a04558.html#a15">uint</a> &index1, <a class="el" href="a04558.html#a15">uint</a> &index2)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">get the best triplet from this poly (the one that has the highest area) <a href="#NLMISC_1_1CPolygona6"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a14">sint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a> () const </td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona8">serial</a> (<a class="el" href="a02270.html">NLMISC::IStream</a> &f) throw (NLMISC::EStream)</td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">Serial this polygon. <a href="#NLMISC_1_1CPolygona8"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona9">toConvexPolygons</a> (std::list< <a class="el" href="a03100.html">CPolygon</a> > &outputPolygons, const <a class="el" href="a02851.html">CMatrix</a> &basis) const </td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (std::vector< <a class="el" href="a03128.html">CVector</a> > &localVertices, <a class="el" href="a02292.html">CBSPNode2v</a> &root, const <a class="el" href="a02851.html">CMatrix</a> &basis) const </td></tr> + +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (const std::vector< <a class="el" href="a03128.html">CVector</a> > &vertex, const <a class="el" href="a02292.html">CBSPNode2v</a> &bsp, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone1">toConvexPolygonsEdgeIntersect</a> (const <a class="el" href="a03660.html">CVector2f</a> &a0, const <a class="el" href="a03660.html">CVector2f</a> &a1, const <a class="el" href="a03660.html">CVector2f</a> &b0, const <a class="el" href="a03660.html">CVector2f</a> &b1)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (const std::vector< <a class="el" href="a03128.html">CVector</a> > &vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> (const std::vector< <a class="el" href="a03128.html">CVector</a> > &vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b, <a class="el" href="a04558.html#a15">uint</a> c)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygone4">toConvexPolygonsLeftOn</a> (const std::vector< <a class="el" href="a03128.html">CVector</a> > &vertex, <a class="el" href="a04558.html#a15">uint</a> a, <a class="el" href="a04558.html#a15">uint</a> b, <a class="el" href="a04558.html#a15">uint</a> c)</td></tr> + +<tr><td colspan=2><br><h2>Data Fields</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a03128.html">CVector</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a></td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPolygona5" doxytag="NLMISC::CPolygon::CPolygon" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CPolygon::CPolygon </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. +<p> + +<p> +Definition at line <a class="el" href="a06191.html#l00060">60</a> of file <a class="el" href="a06191.html">polygon.h</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>. +<p> +<div class="fragment"><pre>00060 {} +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona4" doxytag="NLMISC::CPolygon::CPolygon" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CPolygon::CPolygon </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03128.html">CVector</a> & </td> + <td class="mdname" nowrap> <em>a</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03128.html">CVector</a> & </td> + <td class="mdname" nowrap> <em>b</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03128.html">CVector</a> & </td> + <td class="mdname" nowrap> <em>c</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Constructor. Init with a triangle. +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00046">46</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +<div class="fragment"><pre>00047 { +00048 <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.reserve(3); +00049 <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(a); +00050 <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(b); +00051 <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.push_back(c); +00052 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPolygona0" doxytag="NLMISC::CPolygon::buildBasis" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::buildBasis </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02851.html">CMatrix</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>dest</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Takes the best triplet from this poly to build a normal. From this normal and a points, build a basis (the normal is the K vector of the basis) This can be used to transform the poly in 2D after it has been inverted +<p> +Definition at line <a class="el" href="a06190.html#l00141">141</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06190.html#l00106">getBestTriplet()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05972.html#l00267">NLMISC::CMatrix::setPos()</a>, <a class="el" href="a05972.html#l00209">NLMISC::CMatrix::setRot()</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00142 { +00143 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size() > 3); +00144 <a class="code" href="a04558.html#a15">uint</a> i1, i2, i3; +00145 <a class="code" href="a03100.html#NLMISC_1_1CPolygona6">getBestTriplet</a>(i1, i2, i3); +00146 CVector v1 = (<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[i2] - Vertices[i1]).normed(); +00147 CVector v2 = (Vertices[i3] - Vertices[i1]).normed(); +00148 CVector K = v2 ^ v1; +00149 CVector I = v1 - (v1 * K) * v1; +00150 CVector J = K ^ I; +00151 dest.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_10">setRot</a>(I, J, K); +00152 dest.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1961_4">setPos</a>(Vertices[i1]); +00153 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona1" doxytag="NLMISC::CPolygon::chain" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::chain </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03100.html">CPolygon</a> > & </td> + <td class="mdname" nowrap> <em>other</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a02851.html">CMatrix</a> & </td> + <td class="mdname" nowrap> <em>basis</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Chain the arg polygons with this polygon testing 2d intersections. The 2d intersection test has been done in the XY plane of the basis passed at the function.<p> +The polygon a-b-c-d-e chained with f-g-h-i-j will give the polygon a-b-f-g-h-i-j-f-b-c-d-e if the edge b-f is not 2d clipped by any edge plane in the XY plane of basis.<p> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>basis</em> </td><td>is the basis of the polygon projection. </td></tr> + </table> +</dl> +<dl compact><dt><b>Returns:</b></dt><dd>false if chain failed. else true.</dd></dl> + +<p> +Definition at line <a class="el" href="a06190.html#l00624">624</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a05646.html#l00225">index</a>, <a class="el" href="a06190.html#l00299">NLMISC::CBSPNode2v::intersect()</a>, <a class="el" href="a06190.html#l00392">toConvexPolygonsLocalAndBSP()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a06191.html#l00055">Vertices</a>. +<p> +<div class="fragment"><pre>00625 { +00626 <span class="comment">// Local vertices</span> +00627 std::vector<CVector> localVertices; +00628 +00629 <span class="comment">// Build the BSP root</span> +00630 <a class="code" href="a02292.html">CBSPNode2v</a> root; +00631 +00632 <span class="comment">// Build the local array and the BSP</span> +00633 <a class="code" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (localVertices, root, basis); +00634 +00635 <span class="comment">// Local vertices</span> +00636 std::vector<std::vector<CVector> > localVerticesOther (other.size()); +00637 +00638 <span class="comment">// Build the BSP root</span> +00639 std::vector<CBSPNode2v> rootOther (other.size()); +00640 +00641 <span class="comment">// Build a copy of the polygons</span> +00642 std::vector<CPolygon> copy = other; +00643 +00644 <span class="comment">// Main copy</span> +00645 <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> mainCopy = *<span class="keyword">this</span>; +00646 +00647 <span class="comment">// For each other polygons</span> +00648 <a class="code" href="a04558.html#a15">uint</a> o; +00649 <span class="keywordflow">for</span> (o=0; o<other.size(); o++) +00650 { +00651 <span class="comment">// Build the local array and the BSP</span> +00652 other[o].toConvexPolygonsLocalAndBSP (localVerticesOther[o], rootOther[o], basis); +00653 } +00654 +00655 <span class="comment">// Look for a couple..</span> +00656 <a class="code" href="a04558.html#a15">uint</a> thisCount = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); +00657 <a class="code" href="a04558.html#a15">uint</a> i, j; +00658 <span class="keywordflow">for</span> (o=0; o<other.size(); o++) +00659 { +00660 <a class="code" href="a04558.html#a15">uint</a> otherCount = other[o].Vertices.size(); +00661 +00662 <span class="comment">// Try to link in the main polygon</span> +00663 <span class="keywordflow">for</span> (i=0; i<thisCount; i++) +00664 { +00665 <span class="keywordflow">for</span> (j=0; j<otherCount; j++) +00666 { +00667 <span class="comment">// Test this segement</span> +00668 <span class="keywordflow">if</span> (!root.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va3">intersect</a> (localVertices[i], localVerticesOther[o][j], i, 0xffffffff)) +00669 { +00670 <span class="comment">// Test each other polygons</span> +00671 <a class="code" href="a04558.html#a15">uint</a> otherO; +00672 <span class="keywordflow">for</span> (otherO=0; otherO<other.size(); otherO++) +00673 { +00674 <span class="comment">// Intersect ?</span> +00675 <span class="keywordflow">if</span> (rootOther[otherO].intersect (localVertices[i], localVerticesOther[o][j], 0xffffffff, (otherO == o)?j:0xffffffff)) +00676 <span class="keywordflow">break</span>; +00677 } +00678 +00679 <span class="comment">// Continue ?</span> +00680 <span class="keywordflow">if</span> (otherO==other.size()) +00681 { +00682 <span class="comment">// Insert new vertices</span> +00683 mainCopy.Vertices.insert (mainCopy.Vertices.begin()+i, 2+otherCount, CVector()); +00684 +00685 <span class="comment">// Copy the first vertex</span> +00686 mainCopy.Vertices[i] = mainCopy.Vertices[i+otherCount+2]; +00687 +00688 <span class="comment">// Copy the new vertices</span> +00689 <a class="code" href="a04558.html#a15">uint</a> k; +00690 <span class="keywordflow">for</span> (k=0; k<otherCount; k++) +00691 { +00692 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = j+k; +00693 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a566">index</a>>=otherCount) +00694 <a class="code" href="a04223.html#a566">index</a> -= otherCount; +00695 mainCopy.Vertices[i+k+1] = copy[o].Vertices[<a class="code" href="a04223.html#a566">index</a>]; +00696 } +00697 +00698 <span class="comment">// Copy the last one</span> +00699 mainCopy.Vertices[i+otherCount+1] = copy[o].Vertices[j]; +00700 <span class="keywordflow">break</span>; +00701 } +00702 } +00703 } +00704 <span class="keywordflow">if</span> (j!=otherCount) +00705 <span class="keywordflow">break</span>; +00706 } +00707 +00708 <span class="comment">// Not found ?</span> +00709 <span class="keywordflow">if</span> (i==thisCount) +00710 { +00711 <span class="comment">// Try to link in the sub polygons</span> +00712 <a class="code" href="a04558.html#a15">uint</a> otherToCheck; +00713 <span class="keywordflow">for</span> (otherToCheck=o+1; otherToCheck<other.size(); otherToCheck++) +00714 { +00715 <a class="code" href="a04558.html#a15">uint</a> otherToCheckCount = other[otherToCheck].Vertices.size(); +00716 <span class="keywordflow">for</span> (i=0; i<otherToCheckCount; i++) +00717 { +00718 <span class="keywordflow">for</span> (j=0; j<otherCount; j++) +00719 { +00720 <span class="comment">// Test this segement</span> +00721 <span class="keywordflow">if</span> (!rootOther[otherToCheck].intersect (localVerticesOther[otherToCheck][i], localVerticesOther[o][j], i, 0xffffffff)) +00722 { +00723 <span class="comment">// Test each other polygons</span> +00724 <a class="code" href="a04558.html#a15">uint</a> otherO; +00725 <span class="keywordflow">for</span> (otherO=0; otherO<other.size(); otherO++) +00726 { +00727 <span class="comment">// Intersect ?</span> +00728 <span class="keywordflow">if</span> (rootOther[otherO].intersect (localVerticesOther[otherToCheck][i], localVerticesOther[o][j], (otherToCheck == otherO)?i:0xffffffff, (otherO == o)?j:0xffffffff)) +00729 <span class="keywordflow">break</span>; +00730 } +00731 +00732 <span class="comment">// Continue ?</span> +00733 <span class="keywordflow">if</span> (otherO==other.size()) +00734 { +00735 <span class="comment">// Insert new vertices</span> +00736 copy[otherToCheck].Vertices.insert (copy[otherToCheck].<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin()+i, 2+otherCount, CVector()); +00737 +00738 <span class="comment">// Copy the first vertex</span> +00739 copy[otherToCheck].Vertices[i] = copy[otherToCheck].Vertices[i+otherCount+2]; +00740 +00741 <span class="comment">// Copy the new vertices</span> +00742 <a class="code" href="a04558.html#a15">uint</a> k; +00743 <span class="keywordflow">for</span> (k=0; k<otherCount; k++) +00744 { +00745 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a566">index</a> = j+k; +00746 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a566">index</a>>=otherCount) +00747 <a class="code" href="a04223.html#a566">index</a> -= otherCount; +00748 copy[otherToCheck].Vertices[i+k+1] = copy[otherO].Vertices[<a class="code" href="a04223.html#a566">index</a>]; +00749 } +00750 +00751 <span class="comment">// Copy the last one</span> +00752 copy[otherToCheck].Vertices[i+otherCount+1] = copy[otherO].Vertices[j]; +00753 <span class="keywordflow">break</span>; +00754 } +00755 } +00756 } +00757 <span class="keywordflow">if</span> (j!=otherCount) +00758 <span class="keywordflow">break</span>; +00759 } +00760 <span class="keywordflow">if</span> (i!=otherToCheckCount) +00761 <span class="keywordflow">break</span>; +00762 } +00763 <span class="keywordflow">if</span> (otherToCheck==other.size()) +00764 { +00765 <span class="comment">// Not ok</span> +00766 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00767 } +00768 } +00769 } +00770 +00771 <span class="comment">// Ok</span> +00772 *<span class="keyword">this</span> = mainCopy; +00773 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00774 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona2" doxytag="NLMISC::CPolygon::clip" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::clip </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03082.html">CPlane</a> > & </td> + <td class="mdname1" valign="top" nowrap> <em>planes</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Clip a polygon with a set of planes. Cohen-sutherland clipping... clipPolygonBack() is used on planes. +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00089">89</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06190.html#l00056">clip()</a>. +<p> +<div class="fragment"><pre>00090 { +00091 <span class="keywordflow">if</span>(planes.size()==0) +00092 <span class="keywordflow">return</span>; +00093 <a class="code" href="a03100.html#NLMISC_1_1CPolygona3">clip</a>(&(*planes.begin()), planes.size()); +00094 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona3" doxytag="NLMISC::CPolygon::clip" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::clip </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03082.html">CPlane</a> * </td> + <td class="mdname" nowrap> <em>planes</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>nPlanes</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Clip a polygon with a set of planes. Cohen-sutherland... clipPolygonBack() is used on planes. +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00056">56</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06170.html#l00097">NLMISC::CPlane::clipPolygonBack()</a>, <a class="el" href="a06191.html#l00064">getNumVertices()</a>, <a class="el" href="a05646.html#l01122">in</a>, <a class="el" href="a05981.html#l00104">sint</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00089">clip()</a>, <a class="el" href="a06193.html#l00083">NL3D::CPortal::clipPyramid()</a>, <a class="el" href="a06737.html#l01054">NL3D::CWaterModel::computeClippedPoly()</a>, <a class="el" href="a06737.html#l01026">NL3D::CWaterModel::computeSimpleClippedPoly()</a>, <a class="el" href="a06350.html#l01224">NL3D::CInstanceGroup::displayDebugClusters()</a>, and <a class="el" href="a05384.html#l00121">NLMISC::CAABBox::intersect()</a>. +<p> +<div class="fragment"><pre>00057 { +00058 <span class="keywordflow">if</span>(nPlanes==0 || <a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()==0) +00059 <span class="keywordflow">return</span>; +00060 +00061 <span class="comment">// The final polygon has at maximum currentVertices+number of clipping planes.</span> +00062 <span class="comment">// For performance, the vectors are static, so reallocation rarely occurs.</span> +00063 <span class="keyword">static</span> vector<CVector> tab0, tab1; +00064 tab0.resize(<a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()+nPlanes); +00065 tab1.resize(<a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>()+nPlanes); +00066 <span class="comment">// Init tab0 with Vertices.</span> +00067 copy(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin(), <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.end(), tab0.begin()); +00068 CVector *<a class="code" href="a04223.html#a647">in</a>=&(*tab0.begin()), *out= &(*tab1.begin()); +00069 <a class="code" href="a04558.html#a14">sint</a> nin= <a class="code" href="a03100.html#NLMISC_1_1CPolygona7">getNumVertices</a>(), nout; +00070 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a14">sint</a> i=0;i<(<a class="code" href="a04558.html#a14">sint</a>)nPlanes;i++) +00071 { +00072 nout= planes[i].clipPolygonBack(in, out, nin); +00073 swap(in, out); +00074 nin= nout; +00075 <span class="keywordflow">if</span>(nin==0) +00076 <span class="keywordflow">break</span>; +00077 } +00078 +00079 <span class="comment">// Final result in "in".</span> +00080 <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.resize(nin); +00081 <span class="keywordflow">if</span>(nin>0) +00082 { +00083 memcpy(&(*<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.begin()), <a class="code" href="a04223.html#a647">in</a>, nin*<span class="keyword">sizeof</span>(CVector)); +00084 } +00085 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona6" doxytag="NLMISC::CPolygon::getBestTriplet" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::getBestTriplet </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a04558.html#a15">uint</a> & </td> + <td class="mdname" nowrap> <em>index0</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> & </td> + <td class="mdname" nowrap> <em>index1</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> & </td> + <td class="mdname" nowrap> <em>index2</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +get the best triplet from this poly (the one that has the highest area) +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00106">106</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06682.html#l00115">NLMISC::CVector::norm()</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00141">buildBasis()</a>. +<p> +<div class="fragment"><pre>00107 { +00108 <a class="code" href="a04199.html#a6">nlassert</a>(<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size() >= 3); +00109 <a class="code" href="a04558.html#a15">uint</a> i, j, k; +00110 <span class="keywordtype">float</span> bestArea = 0.f; +00111 <span class="keyword">const</span> <a class="code" href="a04558.html#a15">uint</a> numVerts = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); +00112 <span class="keywordflow">for</span> (i = 0; i < numVerts; ++i) +00113 { +00114 <span class="keywordflow">for</span> (j = 0; j < numVerts; ++j) +00115 { +00116 <span class="keywordflow">if</span> (i != j) +00117 { +00118 <span class="keywordflow">for</span> (k = 0; k < numVerts; ++k) +00119 { +00120 <span class="keywordflow">if</span> (k != i && k != j) +00121 { +00122 CVector v0 = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[j] - Vertices[i]; +00123 CVector v1 = Vertices[k] - Vertices[i]; +00124 <span class="keywordtype">float</span> area = (v0 ^ v1).norm(); +00125 <span class="keywordflow">if</span> (area > bestArea) +00126 { +00127 bestArea = area; +00128 index0 = i; +00129 index1 = j; +00130 index2 = k; +00131 } +00132 } +00133 } +00134 } +00135 } +00136 } +00137 +00138 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona7" doxytag="NLMISC::CPolygon::getNumVertices" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a14">sint</a> NLMISC::CPolygon::getNumVertices </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">void </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> const<code> [inline]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06191.html#l00064">64</a> of file <a class="el" href="a06191.html">polygon.h</a>. +<p> +References <a class="el" href="a05981.html#l00104">sint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00056">clip()</a>, <a class="el" href="a05384.html#l00121">NLMISC::CAABBox::intersect()</a>, and <a class="el" href="a06768.html#l02927">NL3D::CZoneLighter::lightWater()</a>. +<p> +<div class="fragment"><pre>00064 {<span class="keywordflow">return</span> <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size();} +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona8" doxytag="NLMISC::CPolygon::serial" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::serial </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top"><a class="el" href="a02270.html">NLMISC::IStream</a> & </td> + <td class="mdname1" valign="top" nowrap> <em>f</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap> throw (<a class="el" href="a03781.html">NLMISC::EStream</a>)</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Serial this polygon. +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00099">99</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +<div class="fragment"><pre>00100 { +00101 f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2035_8">serialVersion</a>(0); +00102 f.<a class="code" href="a02270.html#NLMISC_1_1IStreamz2033_9">serialCont</a>(Vertices); +00103 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona9" doxytag="NLMISC::CPolygon::toConvexPolygons" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygons </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::list< <a class="el" href="a03100.html">CPolygon</a> > & </td> + <td class="mdname" nowrap> <em>outputPolygons</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a02851.html">CMatrix</a> & </td> + <td class="mdname" nowrap> <em>basis</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Convert a concave polygon into a list of convex polygons using a 2d projection. The polygon mustn't overlap itself in the XY plane of the basis passed in parameter. The polygon must be direct in the XY plane of the basis passed in parameter. (Counter clock wise)<p> +The subdivison is in non-constant n*log(n) with n is the number of vertices.<p> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>outputPolygons</em> </td><td>is the list filled with clipped convex polygons. The list is not cleared at the begining. New polygons are just appended at the end. </td></tr> + <tr><td valign=top><em>basis</em> </td><td>is the basis of the polygon projection. </td></tr> + </table> +</dl> +<dl compact><dt><b>Returns:</b></dt><dd>true if the polygon has been subdivided. false if the polygon overlap itself in the XY plane of the basis or if the polygon is not direct (clock wise).</dd></dl> + +<p> +Definition at line <a class="el" href="a06190.html#l00440">440</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06191.html#l00060">CPolygon()</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06190.html#l00375">toConvexPolygonsDiagonal()</a>, <a class="el" href="a06190.html#l00392">toConvexPolygonsLocalAndBSP()</a>, <a class="el" href="a05981.html#l00105">uint</a>, and <a class="el" href="a06191.html#l00055">Vertices</a>. +<p> +<div class="fragment"><pre>00441 { +00442 <span class="comment">// Some vertices ?</span> +00443 <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size()>2) +00444 { +00445 <span class="comment">// Local vertices</span> +00446 std::vector<CVector> localVertices; +00447 +00448 <span class="comment">// Build the BSP root</span> +00449 <a class="code" href="a02292.html">CBSPNode2v</a> root; +00450 +00451 <span class="comment">// Build the local array and the BSP</span> +00452 <a class="code" href="a03100.html#NLMISC_1_1CPolygona10">toConvexPolygonsLocalAndBSP</a> (localVertices, root, basis); +00453 +00454 <span class="comment">// Build a vertex list</span> +00455 std::list<uint> vertexList; +00456 <a class="code" href="a04558.html#a15">uint</a> i; +00457 <span class="keywordflow">for</span> (i=0; i<<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); i++) +00458 vertexList.push_back (i); +00459 +00460 <span class="comment">// Clip ears while there is some polygons</span> +00461 std::list<uint>::iterator current=vertexList.begin(); +00462 std::list<uint>::iterator begin=vertexList.begin(); +00463 <span class="keywordflow">do</span> +00464 { +00465 again:; +00466 <span class="comment">// Search for a diagonal</span> +00467 <span class="keywordtype">bool</span> found = <span class="keyword">false</span>; +00468 +00469 <span class="comment">// Get next vertex</span> +00470 std::list<uint>::iterator first = current; +00471 std::list<uint>::iterator lastPreviousPrevious=current; +00472 std::list<uint>::iterator lastPrevious=current; +00473 lastPrevious++; +00474 <span class="keywordflow">if</span> (lastPrevious==vertexList.end()) +00475 lastPrevious = vertexList.begin(); +00476 std::list<uint>::iterator currentNext = lastPrevious; +00477 std::list<uint>::iterator last = lastPrevious; +00478 last++; +00479 <span class="keywordflow">if</span> (last==vertexList.end()) +00480 last = vertexList.begin(); +00481 <span class="keywordflow">while</span> (last != current) +00482 { +00483 <span class="comment">// Is a diagonal ?</span> +00484 <span class="keywordflow">if</span> ( +00485 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *lastPreviousPrevious, *last)) && +00486 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *currentNext, *last)) && +00487 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *last, *current)) +00488 ) +00489 { +00490 <span class="comment">// Find one</span> +00491 found = <span class="keyword">true</span>; +00492 } +00493 <span class="keywordflow">else</span> +00494 { +00495 <span class="comment">// Come back</span> +00496 last = lastPrevious; +00497 lastPrevious = lastPreviousPrevious; +00498 <span class="keywordflow">break</span>; +00499 } +00500 +00501 <span class="comment">// Next vertex</span> +00502 lastPreviousPrevious = lastPrevious; +00503 lastPrevious = last++; +00504 <span class="keywordflow">if</span> (last==vertexList.end()) +00505 last = vertexList.begin(); +00506 } +00507 +00508 <span class="comment">// Last polygon ?</span> +00509 <span class="keywordflow">if</span> (last==current) +00510 { +00511 <span class="comment">// Add a polygon</span> +00512 outputPolygons.push_back (<a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a>()); +00513 <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> &back = outputPolygons.back (); +00514 back.Vertices.reserve (vertexList.size()); +00515 +00516 <span class="comment">// Add each vertex in the new polygon</span> +00517 current=vertexList.begin(); +00518 <span class="keywordflow">while</span> (current!=vertexList.end()) +00519 { +00520 back.Vertices.push_back (Vertices[*current]); +00521 current++; +00522 } +00523 +00524 <span class="comment">// Exit</span> +00525 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00526 } +00527 <span class="keywordflow">else</span> +00528 { +00529 std::list<uint>::iterator firstNext = current; +00530 std::list<uint>::iterator firstNextNext = currentNext; +00531 <span class="keywordflow">if</span> (first != vertexList.begin()) +00532 first--; +00533 <span class="keywordflow">else</span> +00534 { +00535 first = vertexList.end(); +00536 first--; +00537 } +00538 +00539 <span class="keywordflow">while</span> (current != first) +00540 { +00541 <span class="comment">// Is a diagonal ?</span> +00542 <span class="keywordflow">if</span> ( +00543 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *firstNextNext, *first)) && +00544 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *lastPrevious, *first)) && +00545 (<a class="code" href="a03100.html#NLMISC_1_1CPolygone0">toConvexPolygonsDiagonal</a> (localVertices, root, *last, *first)) +00546 ) +00547 { +00548 <span class="comment">// Find one</span> +00549 found = <span class="keyword">true</span>; +00550 } +00551 <span class="keywordflow">else</span> +00552 { +00553 <span class="comment">// Come back</span> +00554 first = firstNext; +00555 <span class="keywordflow">break</span>; +00556 } +00557 +00558 <span class="comment">// Next vertex</span> +00559 firstNextNext = firstNext; +00560 firstNext = first; +00561 <span class="keywordflow">if</span> (first==vertexList.begin()) +00562 { +00563 first = vertexList.end(); +00564 first--; +00565 } +00566 <span class="keywordflow">else</span> +00567 first--; +00568 } +00569 } +00570 +00571 <span class="comment">// Found ?</span> +00572 <span class="keywordflow">if</span> (found) +00573 { +00574 <span class="comment">// Count vertex</span> +00575 outputPolygons.push_back (<a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a>()); +00576 <a class="code" href="a03100.html#NLMISC_1_1CPolygona5">CPolygon</a> &back = outputPolygons.back (); +00577 +00578 <span class="comment">// Vertex count</span> +00579 <a class="code" href="a04558.html#a15">uint</a> vertexCount = 1; +00580 current = first; +00581 <span class="keywordflow">while</span> (current != last) +00582 { +00583 vertexCount++; +00584 current++; +00585 <span class="keywordflow">if</span> (current == vertexList.end()) +00586 current = vertexList.begin(); +00587 } +00588 +00589 <span class="comment">// Alloc vertices</span> +00590 back.Vertices.reserve (vertexCount); +00591 +00592 <span class="comment">// Copy and remove vertices</span> +00593 back.Vertices.push_back (Vertices[*first]); +00594 first++; +00595 <span class="keywordflow">if</span> (first == vertexList.end()) +00596 first = vertexList.begin(); +00597 <span class="keywordflow">while</span> (first != last) +00598 { +00599 back.Vertices.push_back (Vertices[*first]); +00600 +00601 <span class="comment">// Remove from list</span> +00602 first = vertexList.erase (first); +00603 <span class="keywordflow">if</span> (first == vertexList.end()) +00604 first = vertexList.begin(); +00605 <a class="code" href="a04199.html#a6">nlassert</a> (first != vertexList.end()); +00606 } +00607 back.Vertices.push_back (Vertices[*first]); +00608 current = begin = last; +00609 <span class="keywordflow">goto</span> again; +00610 } +00611 +00612 <span class="comment">// Next current</span> +00613 current++; +00614 <span class="keywordflow">if</span> (current == vertexList.end()) +00615 current = vertexList.begin (); +00616 } +00617 <span class="keywordflow">while</span> (current != begin); +00618 } +00619 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00620 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygone0" doxytag="NLMISC::CPolygon::toConvexPolygonsDiagonal" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygonsDiagonal </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03128.html">CVector</a> > & </td> + <td class="mdname" nowrap> <em>vertex</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a02292.html">CBSPNode2v</a> & </td> + <td class="mdname" nowrap> <em>bsp</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>a</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>b</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00375">375</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06190.html#l00299">NLMISC::CBSPNode2v::intersect()</a>, <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>. +<p> +<div class="fragment"><pre>00376 { +00377 <span class="comment">// Check it is a border</span> +00378 <span class="keywordflow">if</span> ( ( (b - a) == 1) || ( (a - b) == 1) || ( (a==0) && (b ==(vertex.size()-1))) || ( (b==0) && (a ==(vertex.size()-1))) ) +00379 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00380 +00381 <span class="comment">// Check visibility</span> +00382 <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (vertex, a, b) && <a class="code" href="a03100.html#NLMISC_1_1CPolygone2">toConvexPolygonsInCone</a> (vertex, b, a)) +00383 { +00384 <span class="comment">// Intersection ?</span> +00385 <span class="keywordflow">return</span> !bsp.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va3">intersect</a> (vertex[a], vertex[b], a, b); +00386 } +00387 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00388 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygone1" doxytag="NLMISC::CPolygon::toConvexPolygonsEdgeIntersect" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygonsEdgeIntersect </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const <a class="el" href="a03660.html">CVector2f</a> & </td> + <td class="mdname" nowrap> <em>a0</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> & </td> + <td class="mdname" nowrap> <em>a1</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> & </td> + <td class="mdname" nowrap> <em>b0</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a03660.html">CVector2f</a> & </td> + <td class="mdname" nowrap> <em>b1</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00177">177</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::x</a>, and <a class="el" href="a06677.html#l00052">NLMISC::CVector2f::y</a>. +<p> +<div class="fragment"><pre>00178 { +00179 <span class="keywordtype">float</span> Aa = (a0.y - a1.y) / (a0.x - a1.x); +00180 <span class="keywordtype">float</span> Ba = a0.y - a0.x * Aa; +00181 <span class="keywordtype">float</span> Ab = (b0.y - b1.y) / (b0.x - b1.x); +00182 <span class="keywordtype">float</span> Bb = b0.y - b0.x * Ab; +00183 +00184 <span class="comment">// Intersection </span> +00185 CVector2f intersection; +00186 intersection.x = (Bb - Ba) / (Aa - Ab); +00187 intersection.y = Aa * intersection.x + Ba; +00188 +00189 <span class="comment">// In it ?</span> +00190 <span class="keywordflow">return</span> ( ( (a0-intersection)*(a1-intersection) < 0 ) && ( (b0-intersection)*(b1-intersection) < 0 ) ); +00191 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygone2" doxytag="NLMISC::CPolygon::toConvexPolygonsInCone" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygonsInCone </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03128.html">CVector</a> > & </td> + <td class="mdname" nowrap> <em>vertex</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>a</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>b</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00351">351</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06190.html#l00337">toConvexPolygonsLeft()</a>, <a class="el" href="a06190.html#l00344">toConvexPolygonsLeftOn()</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00375">toConvexPolygonsDiagonal()</a>. +<p> +<div class="fragment"><pre>00352 { +00353 <span class="comment">// Prev and next</span> +00354 <a class="code" href="a04558.html#a15">uint</a> a0 = a+1; +00355 <span class="keywordflow">if</span> (a0==vertex.size()) +00356 a0=0; +00357 <a class="code" href="a04558.html#a15">uint</a> a1; +00358 <span class="keywordflow">if</span> (a==0) +00359 a1=vertex.size()-1; +00360 <span class="keywordflow">else</span> +00361 a1= a-1; +00362 +00363 <span class="keywordflow">if</span> (<a class="code" href="a03100.html#NLMISC_1_1CPolygone4">toConvexPolygonsLeftOn</a> (vertex, a, a1, a0) ) +00364 { +00365 <span class="keywordflow">return</span> <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, a, b, a0) && <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, b, a, a1); +00366 } +00367 <span class="keywordflow">else</span> +00368 { +00369 <span class="keywordflow">return</span> !( <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, a, b, a1) && <a class="code" href="a03100.html#NLMISC_1_1CPolygone3">toConvexPolygonsLeft</a> ( vertex, b, a, a0) ); +00370 } +00371 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygone3" doxytag="NLMISC::CPolygon::toConvexPolygonsLeft" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygonsLeft </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03128.html">CVector</a> > & </td> + <td class="mdname" nowrap> <em>vertex</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>a</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>b</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>c</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00337">337</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>. +<p> +<div class="fragment"><pre>00338 { +00339 <span class="keywordflow">return</span> ( (vertex[b].x - vertex[a].x) * (vertex[c].y - vertex[a].y) - (vertex[c].x - vertex[a].x) * (vertex[b].y - vertex[a].y) ) < 0; +00340 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygone4" doxytag="NLMISC::CPolygon::toConvexPolygonsLeftOn" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPolygon::toConvexPolygonsLeftOn </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::vector< <a class="el" href="a03128.html">CVector</a> > & </td> + <td class="mdname" nowrap> <em>vertex</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>a</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>b</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a04558.html#a15">uint</a> </td> + <td class="mdname" nowrap> <em>c</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00344">344</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00351">toConvexPolygonsInCone()</a>. +<p> +<div class="fragment"><pre>00345 { +00346 <span class="keywordflow">return</span> ( (vertex[b].x - vertex[a].x) * (vertex[c].y - vertex[a].y) - (vertex[c].x - vertex[a].x) * (vertex[b].y - vertex[a].y) ) <= 0; +00347 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPolygona10" doxytag="NLMISC::CPolygon::toConvexPolygonsLocalAndBSP" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPolygon::toConvexPolygonsLocalAndBSP </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">std::vector< <a class="el" href="a03128.html">CVector</a> > & </td> + <td class="mdname" nowrap> <em>localVertices</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap><a class="el" href="a02292.html">CBSPNode2v</a> & </td> + <td class="mdname" nowrap> <em>root</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const <a class="el" href="a02851.html">CMatrix</a> & </td> + <td class="mdname" nowrap> <em>basis</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"> const</td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06190.html#l00392">392</a> of file <a class="el" href="a06190.html">polygon.cpp</a>. +<p> +References <a class="el" href="a06190.html#l00219">NLMISC::CBSPNode2v::insert()</a>, <a class="el" href="a05972.html#l00914">NLMISC::CMatrix::invert()</a>, <a class="el" href="a06170.html#l00036">NLMISC::CPlane::make()</a>, <a class="el" href="a06190.html#l00173">NLMISC::TCConcavePolygonsVertexMap</a>, <a class="el" href="a05981.html#l00105">uint</a>, <a class="el" href="a06673.html#l00051">NLMISC::CVector::x</a>, and <a class="el" href="a06673.html#l00051">NLMISC::CVector::y</a>. +<p> +Referenced by <a class="el" href="a06190.html#l00624">chain()</a>, and <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>. +<p> +<div class="fragment"><pre>00393 { +00394 <span class="comment">// Invert matrix</span> +00395 <a class="code" href="a02851.html">CMatrix</a> invert = basis; +00396 invert.<a class="code" href="a02851.html#NLMISC_1_1CMatrixz1967_0">invert</a> (); +00397 +00398 <span class="comment">// Insert vertices in an ordered table</span> +00399 <a class="code" href="a04558.html#a15">uint</a> vertexCount = <a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); +00400 <a class="code" href="a05378.html#a33">TCConcavePolygonsVertexMap</a> vertexMap; +00401 localVertices.resize (vertexCount); +00402 <a class="code" href="a04558.html#a15">uint</a> i, j; +00403 +00404 <span class="comment">// Transform the vertex</span> +00405 <span class="keywordflow">for</span> (i=0; i<vertexCount; i++) +00406 { +00407 CVector local = invert*<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>[i]; +00408 localVertices[i] = CVector (local.x, local.y, 0); +00409 } +00410 +00411 <span class="comment">// Plane direction</span> +00412 i=0; +00413 j=<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size()-1; +00414 CVector normal = localVertices[i] - localVertices[j]; +00415 normal = normal ^ CVector::K; +00416 CPlane clipPlane; +00417 clipPlane.make(normal, localVertices[i]); +00418 +00419 <span class="comment">// Build the BSP root</span> +00420 root = <a class="code" href="a02292.html">CBSPNode2v</a> (clipPlane, localVertices[i], localVertices[j], i, j); +00421 +00422 <span class="comment">// Insert all others edges</span> +00423 j=i++; +00424 <span class="keywordflow">for</span> (; i<<a class="code" href="a03100.html#NLMISC_1_1CPolygono0">Vertices</a>.size(); i++) +00425 { +00426 <span class="comment">// Plane direction</span> +00427 normal = localVertices[i] - localVertices[j]; +00428 normal = normal ^ CVector::K; +00429 clipPlane.make(normal, localVertices[i]); +00430 +00431 <span class="comment">// Build the BSP root</span> +00432 root.<a class="code" href="a02292.html#NLMISC_1_1CBSPNode2va2">insert</a> ( <span class="keyword">new</span> CBSPNode2v (clipPlane, localVertices[i], localVertices[j], i, j) ); +00433 +00434 j=i; +00435 } +00436 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPolygono0" doxytag="NLMISC::CPolygon::Vertices" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a03128.html">CVector</a>> <a class="el" href="a03100.html#NLMISC_1_1CPolygono0">NLMISC::CPolygon::Vertices</a> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06191.html#l00055">55</a> of file <a class="el" href="a06191.html">polygon.h</a>. +<p> +Referenced by <a class="el" href="a05929.html#l00714">NLPACS::CLocalRetriever::build3dSurfacePolygons()</a>, <a class="el" href="a05929.html#l00655">NLPACS::CLocalRetriever::buildSurfacePolygons()</a>, <a class="el" href="a06190.html#l00624">chain()</a>, <a class="el" href="a06737.html#l01130">NL3D::CWaterModel::clip()</a>, <a class="el" href="a06193.html#l00083">NL3D::CPortal::clipPyramid()</a>, <a class="el" href="a06737.html#l01054">NL3D::CWaterModel::computeClippedPoly()</a>, <a class="el" href="a06737.html#l01026">NL3D::CWaterModel::computeSimpleClippedPoly()</a>, <a class="el" href="a06768.html#l03563">NL3D::CZoneLighter::computeTileFlagsForPositionTowardWater()</a>, <a class="el" href="a06350.html#l01224">NL3D::CInstanceGroup::displayDebugClusters()</a>, <a class="el" href="a06737.html#l01170">NL3D::CWaterModel::doSimpleRender()</a>, <a class="el" href="a06737.html#l00387">NL3D::DrawPoly2D()</a>, <a class="el" href="a06741.html#l00609">NL3D::CWaterShape::getShapeInWorldSpace()</a>, <a class="el" href="a06768.html#l02927">NL3D::CZoneLighter::lightWater()</a>, <a class="el" href="a06190.html#l00440">toConvexPolygons()</a>, and <a class="el" href="a06737.html#l00437">NL3D::CWaterModel::traverseRender()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a06191.html">polygon.h</a><li><a class="el" href="a06190.html">polygon.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:27:57 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |