1 /** @file gsEdge.h 2 3 @brief Provides gsEdge class for an edge of a gsMesh. 4 5 This file is part of the G+Smo library. 6 7 This Source Code Form is subject to the terms of the Mozilla Public 8 License, v. 2.0. If a copy of the MPL was not distributed with this 9 file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 11 Author(s): A. Mantzaflaris, D. Mayer 12 */ 13 14 #pragma once 15 16 #include <gsUtils/gsMesh/gsMeshElement.h> 17 18 namespace gismo { 19 20 template <class T> 21 class gsEdge : public gsMeshElement<T> 22 { 23 public: 24 typedef gsMeshElement<T> MeshElement; 25 typedef typename MeshElement::scalar_t scalar_t; 26 typedef typename MeshElement::gsVertexHandle gsVertexHandle; 27 typedef typename MeshElement::gsEdgeHandle gsEdgeHandle; 28 typedef typename MeshElement::gsFaceHandle gsFaceHandle; 29 typedef gsVector3d<T> gsVector; 30 typedef gsVector * gsVectorHandle; 31 32 public: gsEdge()33 gsEdge() { } // : MeshElement() 34 gsEdge(gsVertexHandle const & v0,gsVertexHandle const & v1)35 gsEdge(gsVertexHandle const & v0, gsVertexHandle const & v1 ): 36 source(v0), target(v1) 37 { 38 // faceId1=0; 39 // faceId2=0; 40 // next = 0; 41 // prev = 0; 42 } 43 44 ~gsEdge()45 virtual ~gsEdge(){ } 46 print(std::ostream & os)47 std::ostream &print(std::ostream &os) const 48 { 49 os<<"gsEdge from "<< *source<<" to "<<*target ; 50 return os; 51 }; 52 53 orderVertices()54 void orderVertices() 55 { 56 if ( Xless<T>(source,target) ) 57 std::swap(source,target); 58 } 59 60 // Lex compare 61 bool operator< (gsEdge const & rhs) const 62 { 63 return ( Xless<T>(this->source,rhs.source) 64 65 || 66 ( (this->source->x() == rhs.source->x() && 67 this->source->y() == rhs.source->y() && 68 this->source->z() == rhs.source->z() ) && 69 Xless<T>(this->target,rhs.target) )); 70 } 71 72 bool operator == (gsEdge const & rhs) const 73 { 74 return (((this->source->x())==rhs.source->x())&& 75 ((this->source->y())==rhs.source->y())&& 76 ((this->source->z())==rhs.source->z())&& 77 ((this->target->x())==rhs.target->x())&& 78 ((this->target->y())==rhs.target->y())&& 79 ((this->target->z())==rhs.target->z())); 80 } 81 bool operator> (gsEdge const & rhs) const 82 { 83 return !(*this<rhs)&&!(*this==rhs); 84 } 85 bool operator != (gsEdge const & rhs) const 86 { 87 return !(*this==rhs); 88 } 89 90 public: 91 92 gsVertexHandle source, target; 93 std::vector<gsFaceHandle> nFaces; 94 bool sharp; 95 std::vector<int> numPatches; 96 }; 97 98 } //namespace gismo 99