• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PolyVoxCore/source/SurfaceEdge.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002 Copyright (c) 2005-2009 David Williams
00003 
00004 This software is provided 'as-is', without any express or implied
00005 warranty. In no event will the authors be held liable for any damages
00006 arising from the use of this software.
00007 
00008 Permission is granted to anyone to use this software for any purpose,
00009 including commercial applications, and to alter it and redistribute it
00010 freely, subject to the following restrictions:
00011 
00012     1. The origin of this software must not be misrepresented; you must not
00013     claim that you wrote the original software. If you use this software
00014     in a product, an acknowledgment in the product documentation would be
00015     appreciated but is not required.
00016 
00017     2. Altered source versions must be plainly marked as such, and must not be
00018     misrepresented as being the original software.
00019 
00020     3. This notice may not be removed or altered from any source
00021     distribution.   
00022 *******************************************************************************/
00023 
00024 #include <sstream>
00025 
00026 #include "SurfaceEdge.h"
00027 #include "SurfaceTriangle.h"
00028 #include "SurfaceVertex.h"
00029 
00030 namespace PolyVox
00031 {
00032     SurfaceEdge::SurfaceEdge(const SurfaceVertexIterator& targetToSet,const SurfaceVertexIterator& sourceToSet)
00033     {
00034         target = targetToSet;
00035         source = sourceToSet;
00036     }
00037 
00038     std::string SurfaceEdge::tostring(void)
00039     {
00040         std::stringstream ss;
00041         ss << "SurfaceEdge: Target Vertex = " << target->tostring() << "Source Vertex = " << source->tostring();
00042         return ss.str();
00043     }
00044 
00045     bool operator == (const SurfaceEdge& lhs, const SurfaceEdge& rhs)
00046     {
00047         //Vertices are unique in the set, so if the two positions are the same the 
00048         //two iterators must also be the same. So we just check the iterators.
00049         return
00050         (
00051             (lhs.target == rhs.target) &&
00052             (lhs.source == rhs.source)
00053         );
00054     }
00055 
00056     bool SurfaceEdge::isDegenerate(void)
00057     {
00058         return (target == source);
00059     }
00060 
00061     bool operator < (const SurfaceEdge& lhs, const SurfaceEdge& rhs)
00062     {
00063         //Unlike the equality operator, we can't compare iterators.
00064         //So dereference and compare the results.
00065         if ((*lhs.target) < (*rhs.target))
00066             return true;
00067         if ((*rhs.target) < (*lhs.target))
00068             return false;
00069 
00070         if ((*lhs.source) < (*rhs.source))
00071             return true;
00072         if ((*rhs.source) < (*lhs.source))
00073             return false;
00074 
00075         return false;
00076     }
00077 
00078     const SurfaceVertexIterator& SurfaceEdge::getTarget(void) const
00079     {
00080         return target;
00081     }
00082 
00083     const SurfaceVertexIterator& SurfaceEdge::getSource(void) const
00084     {
00085         return source;
00086     }
00087 
00088     void SurfaceEdge::pairWithOtherHalfEdge(const SurfaceEdgeIterator& otherHalfEdgeToPair)
00089     {
00090         otherHalfEdge = otherHalfEdgeToPair;
00091         previousHalfEdge = otherHalfEdgeToPair;
00092         nextHalfEdge = otherHalfEdgeToPair;
00093     }
00094 
00095     const SurfaceEdgeIterator& SurfaceEdge::getOtherHalfEdge(void) const
00096     {
00097         return otherHalfEdge;
00098     }
00099 
00100     const SurfaceEdgeIterator& SurfaceEdge::getPreviousHalfEdge(void) const
00101     {
00102         return previousHalfEdge;
00103     }
00104 
00105     const SurfaceEdgeIterator& SurfaceEdge::getNextHalfEdge(void) const
00106     {
00107         return nextHalfEdge;
00108     }
00109 
00110     const SurfaceTriangleIterator& SurfaceEdge::getTriangle(void) const
00111     {
00112         return triangle;
00113     }
00114 
00115     void SurfaceEdge::setPreviousHalfEdge(const SurfaceEdgeIterator& previousHalfEdgeToSet)
00116     {
00117         previousHalfEdge = previousHalfEdgeToSet;
00118     }
00119 
00120     void SurfaceEdge::setNextHalfEdge(const SurfaceEdgeIterator& nextHalfEdgeToSet)
00121     {
00122         nextHalfEdge = nextHalfEdgeToSet;
00123     }
00124 
00125     void SurfaceEdge::setTriangle(const SurfaceTriangleIterator& triangleToSet)
00126     {
00127         triangle = triangleToSet;
00128     }
00129 }

Generated on Sat Nov 19 2011 00:27:31 for PolyVox by  doxygen 1.7.1