Back to index

salome-smesh  6.5.0
SMDS_QuadraticEdge.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMDS : implementaion of Salome mesh data structure
00024 // File:      SMDS_QuadraticEdge.cxx
00025 // Created:   16.01.06 16:25:42
00026 // Author:    Sergey KUUL
00027 //
00028 #include "SMDS_QuadraticEdge.hxx"
00029 
00030 #include "SMDS_SetIterator.hxx"
00031 #include "SMDS_IteratorOfElements.hxx"
00032 #include "SMDS_MeshNode.hxx"
00033 #include "utilities.h"
00034 
00035 using namespace std;
00036 
00037 //=======================================================================
00038 //function : SMDS_QuadraticEdge
00039 //purpose  : 
00040 //=======================================================================
00041 
00042 SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
00043                                        const SMDS_MeshNode * node2,
00044                                        const SMDS_MeshNode * node12)
00045      :SMDS_LinearEdge(node1,node2)
00046 {
00047   //MESSAGE("******************************************************* SMDS_QuadraticEdge");
00048   myNodes[2]=node12;
00049 }
00050 
00051 
00052 //=======================================================================
00053 //function : Print
00054 //purpose  : 
00055 //=======================================================================
00056 
00057 void SMDS_QuadraticEdge::Print(ostream & OS) const
00058 {
00059   OS << "quadratic edge <" << GetID() << "> : ( first-" << myNodes[0]
00060      << " , last-" << myNodes[1] << " , medium-" << myNodes[2] << ") " << endl;
00061 }
00062 
00063 
00064 //=======================================================================
00065 //function : NbNodes
00066 //purpose  : 
00067 //=======================================================================
00068 
00069 int SMDS_QuadraticEdge::NbNodes() const
00070 {
00071   return 3;
00072 }
00073 
00074 //=======================================================================
00075 //function : ChangeNodes
00076 //purpose  : 
00077 //=======================================================================
00078 
00079 bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
00080                                      const SMDS_MeshNode * node2,
00081                                      const SMDS_MeshNode * node12)
00082 {
00083   myNodes[0]=node1;
00084   myNodes[1]=node2;
00085   myNodes[2]=node12;
00086   return true;
00087 }
00088 
00089 //=======================================================================
00090 //function : IsMediumNode
00091 //purpose  : 
00092 //=======================================================================
00093 
00094 bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
00095 {
00096   return (myNodes[2]==node);
00097 }
00098 
00099 namespace
00100 {
00101   //=======================================================================
00102   //class : _MyInterlacedNodeIterator
00103   //purpose  : 
00104   //=======================================================================
00105 
00106   class _MyInterlacedNodeIterator: public SMDS_NodeArrayIterator
00107   {
00108     const SMDS_MeshNode * myNodes[3];
00109   public:
00110     _MyInterlacedNodeIterator(const SMDS_MeshNode * const * nodes):
00111       SMDS_NodeArrayIterator( myNodes, & myNodes[3] )
00112     {
00113       myNodes[0] = nodes[0];
00114       myNodes[1] = nodes[2];
00115       myNodes[2] = nodes[1];
00116     }
00117   };
00118 
00119   //=======================================================================
00120   //class : _MyInterlacedNodeElemIterator
00121   //purpose  : 
00122   //=======================================================================
00123 
00124   class _MyInterlacedNodeElemIterator : public SMDS_ElemIterator
00125   {
00126     SMDS_NodeIteratorPtr myItr;
00127   public:
00128     _MyInterlacedNodeElemIterator(SMDS_NodeIteratorPtr interlacedNodeItr):
00129       myItr( interlacedNodeItr ) {}
00130     bool more()                    { return myItr->more(); }
00131     const SMDS_MeshElement* next() { return myItr->next(); }
00132   };
00133 
00134   //=======================================================================
00135   //class : _MyNodeIterator
00136   //purpose  : 
00137   //=======================================================================
00138 
00139   class _MyNodeIterator:public SMDS_NodeArrayElemIterator
00140   {
00141   public:
00142     _MyNodeIterator(const SMDS_MeshNode * const * nodes):
00143       SMDS_NodeArrayElemIterator( nodes, & nodes[3] ) {}
00144   };
00145 }
00146 
00147 //=======================================================================
00148 //function : interlacedNodesIterator
00149 //purpose  : 
00150 //=======================================================================
00151 
00152 SMDS_NodeIteratorPtr SMDS_QuadraticEdge::interlacedNodesIterator() const
00153 {
00154   return SMDS_NodeIteratorPtr (new _MyInterlacedNodeIterator (myNodes));
00155 }
00156 
00157 
00158 //=======================================================================
00159 //function : interlacedNodesElemIterator
00160 //purpose  : 
00161 //=======================================================================
00162 
00163 SMDS_ElemIteratorPtr SMDS_QuadraticEdge::interlacedNodesElemIterator() const
00164 {
00165   return SMDS_ElemIteratorPtr
00166     (new _MyInterlacedNodeElemIterator ( interlacedNodesIterator() ));
00167 }
00168 
00169 //=======================================================================
00170 //function : elementsIterator
00171 //purpose  : 
00172 //=======================================================================
00173 
00174 SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType type) const
00175 {
00176   switch(type)
00177   {
00178   case SMDSAbs_Edge:
00179     return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge); 
00180   case SMDSAbs_Node:
00181     return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
00182   default:
00183     return SMDS_ElemIteratorPtr
00184       (new SMDS_IteratorOfElements
00185        (this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes))));
00186   }
00187 }