From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/polygon_8h-source.html | 211 ++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 docs/doxygen/nel/polygon_8h-source.html (limited to 'docs/doxygen/nel/polygon_8h-source.html') diff --git a/docs/doxygen/nel/polygon_8h-source.html b/docs/doxygen/nel/polygon_8h-source.html new file mode 100644 index 00000000..34869fcc --- /dev/null +++ b/docs/doxygen/nel/polygon_8h-source.html @@ -0,0 +1,211 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

polygon.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_POLYGON_H
+00027 #define NL_POLYGON_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/misc/matrix.h"
+00031 #include "nel/misc/stream.h"
+00032 #include "nel/misc/vector_2f.h"
+00033 #include <vector>
+00034 
+00035 
+00036 namespace NLMISC 
+00037 {
+00038 
+00039 using NLMISC::CVector;
+00040 using NLMISC::CPlane;
+00041 using NLMISC::CMatrix;
+00042 
+00043 
+00044 class CTriangle;
+00045 
+00046 // Used by the method toConvexPolygons
+00047 class CBSPNode2v;
+00048 
+00049 // ***************************************************************************
+00056 class CPolygon
+00057 {
+00058 public:
+00059         std::vector<CVector>    Vertices;
+00060 
+00061 public:
+00062 
+00064         CPolygon() {}
+00066         CPolygon(const CVector &a, const CVector &b, const CVector &c);
+00067 
+00068         sint                    getNumVertices() const {return Vertices.size();}
+00069 
+00071         void                    clip(const CPlane *planes, uint nPlanes);
+00073         void                    clip(const std::vector<CPlane> &planes);
+00074 
+00076         void                    serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00077 
+00091         bool                    toConvexPolygons (std::list<CPolygon>& outputPolygons, const CMatrix& basis) const;
+00092 
+00103         bool                    chain (const std::vector<CPolygon> &other, const CMatrix& basis);
+00104 
+00106         void            getBestTriplet(uint &index0, uint &index1, uint &index2);       
+00107 
+00112         void            buildBasis(CMatrix &dest);
+00113 
+00114         // Used by the method toConvexPolygons and chain
+00115         void                    toConvexPolygonsLocalAndBSP (std::vector<CVector> &localVertices, CBSPNode2v &root, const CMatrix &basis) const;
+00116         static bool             toConvexPolygonsEdgeIntersect (const CVector2f& a0, const CVector2f& a1, const CVector2f& b0, const CVector2f& b1);
+00117         static bool             toConvexPolygonsLeft (const std::vector<CVector> &vertex, uint a, uint b, uint c);
+00118         static bool             toConvexPolygonsLeftOn (const std::vector<CVector> &vertex, uint a, uint b, uint c);
+00119         static bool             toConvexPolygonsInCone (const std::vector<CVector> &vertex, uint a, uint b);
+00120         static bool             toConvexPolygonsDiagonal (const std::vector<CVector> &vertex, const CBSPNode2v &bsp, uint a, uint b);
+00121 };
+00122 
+00126 class CPolygon2D
+00127 {
+00128 public:
+00129         typedef std::vector<CVector2f> TVec2fVect;
+00130         TVec2fVect Vertices;
+00131 public:
+00133         CPolygon2D() {}
+00134         
+00138         CPolygon2D(const CPolygon &src, const CMatrix &projMat = CMatrix::Identity);
+00139 
+00143         CPolygon2D(const CTriangle &tri, const CMatrix &projMat = CMatrix::Identity);   
+00144 
+00146         bool            isConvex();
+00147 
+00152         void            buildConvexHull(CPolygon2D &dest) const;
+00153 
+00155         void            getBestTriplet(uint &index0, uint &index1, uint &index2);       
+00156         
+00158         void            serial(NLMISC::IStream &f) throw(NLMISC::EStream);
+00159 
+00160         typedef std::pair<sint, sint> TRaster;
+00161         typedef std::vector<TRaster>  TRasterVect;
+00162 
+00169         void            computeBorders(TRasterVect &borders, sint &minimumY);
+00170 
+00172         bool        intersect(const CPolygon2D &other) const;
+00173 
+00175         bool            contains(const CVector2f &p) const;
+00176 
+00180         bool  getNonNullSeg(uint &seg) const;
+00181 
+00183         void  getLineEquation(uint index, float &a, float &b, float &c) const;
+00184 
+00185 private:
+00187         float sumDPAgainstLine(float a, float b, float c) const;
+00188 
+00190         const CVector2f &getSegRef0(uint index) const 
+00191         { 
+00192                 nlassert(index < Vertices.size()); return Vertices[index]; 
+00193         }
+00194         const CVector2f &getSegRef1(uint index) const 
+00195         { 
+00196                 nlassert(index < Vertices.size());              
+00197                 return index == Vertices.size() - 1 ?
+00198                            Vertices[0]                 :
+00199                        Vertices[index + 1];
+00200         }
+00201 
+00202 
+00203         
+00204 };
+00205 
+00206 
+00207 } // NLMISC
+00208 
+00209 
+00210 #endif // NL_POLYGON_H
+00211 
+00212 /* End of polygon.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1