# 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  

exterior_mesh.cpp

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 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 #include "stdpacs.h"
00027 
00028 #include "pacs/exterior_mesh.h"
00029 #include "pacs/local_retriever.h"
00030 #include "pacs/collision_desc.h"
00031 
00032 
00033 using namespace std;
00034 using namespace NLMISC;
00035 
00036 namespace NLPACS
00037 {
00038         // Functions for vertices comparison.
00039         // total order relation
00040         static inline bool      isStrictlyLess(const CVector &a, const CVector &b)
00041         {
00042                 if (a.x < b.x)  return true;
00043                 if (a.x > b.x)  return false;
00044                 if (a.y < b.y)  return true;
00045                 if (a.y > b.y)  return false;
00046                 if (a.z < b.y)  return true;
00047                 return false;
00048         }
00049 
00050         static inline bool      isStrictlyGreater(const CVector &a, const CVector &b)
00051         {
00052                 if (a.x > b.x)  return true;
00053                 if (a.x < b.x)  return false;
00054                 if (a.y > b.y)  return true;
00055                 if (a.y < b.y)  return false;
00056                 if (a.z > b.y)  return true;
00057                 return false;
00058         }
00059 
00060         CExteriorMesh::CExteriorMesh() { }
00061 
00062         void    CExteriorMesh::setEdges(const vector<CExteriorMesh::CEdge> &edges)
00063         {
00064                 _Edges = edges;
00065                 _OrderedEdges.clear();
00066 
00067                 uint    i;
00068                 for (i=0; i+1<_Edges.size(); )
00069                 {
00070                         _OrderedEdges.resize(_OrderedEdges.size()+1);
00071                         COrderedEdges   &edges = _OrderedEdges.back();
00072                         edges.Start = i;
00073                         if (isStrictlyLess(_Edges[i].Start, _Edges[i+1].Start))
00074                         {
00075                                 edges.Forward = true;
00076                                 do
00077                                 {
00078                                         ++i;
00079                                 }
00080                                 while (i+1<_Edges.size() && isStrictlyLess(_Edges[i].Start, _Edges[i+1].Start));
00081                         }
00082                         else
00083                         {
00084                                 edges.Forward = false;
00085                                 do
00086                                 {
00087                                         ++i;
00088                                 }
00089                                 while (i+1<_Edges.size() && isStrictlyGreater(_Edges[i].Start, _Edges[i+1].Start));
00090                         }
00091                         edges.End = i;
00092                 }
00093         }
00094 
00095         void    CExteriorMesh::serial(NLMISC::IStream &f)
00096         {
00097                 /*
00098                 Version 0:
00099                         - base version.
00100                 */
00101                 (void)f.serialVersion(0);
00102 
00103                 f.serialCont(_Edges);
00104                 f.serialCont(_OrderedEdges);
00105                 f.serialCont(_Links);
00106                 f.serial(_BBox);
00107         }
00108 };