quadratic elements creation

This commit is contained in:
eap 2006-03-06 10:56:57 +00:00
parent a09af43c7d
commit 8671bc8018
7 changed files with 1192 additions and 0 deletions

View File

@ -0,0 +1,187 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticEdge.cxx
// Created: 16.01.06 16:25:42
// Author: Sergey KUUL
#include "SMDS_QuadraticEdge.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticEdge
//purpose :
//=======================================================================
SMDS_QuadraticEdge::SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12)
:SMDS_MeshEdge(node1,node2)
{
myNodes[2]=node12;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticEdge::Print(ostream & OS) const
{
OS << "quadratic edge <" << GetID() << "> : ( first-" << myNodes[0]
<< " , last-" << myNodes[1] << " , medium-" << myNodes[2] << ") " << endl;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticEdge::NbNodes() const
{
return 3;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12)
{
myNodes[0]=node1;
myNodes[1]=node2;
myNodes[2]=node12;
return true;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
{
return (myNodes[2]==node);
}
namespace
{
//=======================================================================
//class : _MyInterlacedNodeIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeIterator: public SMDS_NodeArrayIterator
{
const SMDS_MeshNode * myNodes[3];
public:
_MyInterlacedNodeIterator(const SMDS_MeshNode * const * nodes):
SMDS_NodeArrayIterator( myNodes, & myNodes[3] )
{
myNodes[0] = nodes[0];
myNodes[1] = nodes[2];
myNodes[2] = nodes[1];
}
};
//=======================================================================
//class : _MyInterlacedNodeElemIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeElemIterator : public SMDS_ElemIterator
{
SMDS_NodeIteratorPtr myItr;
public:
_MyInterlacedNodeElemIterator(SMDS_NodeIteratorPtr interlacedNodeItr):
myItr( interlacedNodeItr ) {}
bool more() { return myItr->more(); }
const SMDS_MeshElement* next() { return myItr->next(); }
};
//=======================================================================
//class : _MyNodeIterator
//purpose :
//=======================================================================
class _MyNodeIterator:public SMDS_NodeArrayElemIterator
{
public:
_MyNodeIterator(const SMDS_MeshNode * const * nodes):
SMDS_NodeArrayElemIterator( nodes, & nodes[3] ) {}
};
}
//=======================================================================
//function : interlacedNodesIterator
//purpose :
//=======================================================================
SMDS_NodeIteratorPtr SMDS_QuadraticEdge::interlacedNodesIterator() const
{
return SMDS_NodeIteratorPtr (new _MyInterlacedNodeIterator (myNodes));
}
//=======================================================================
//function : interlacedNodesElemIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticEdge::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr
(new _MyInterlacedNodeElemIterator ( interlacedNodesIterator() ));
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticEdge::elementsIterator(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Edge:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Edge);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type, SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes))));
}
}

View File

@ -0,0 +1,62 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticEdge.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticEdge_HeaderFile
#define _SMDS_QuadraticEdge_HeaderFile
#include "SMDS_MeshEdge.hxx"
#include <iostream>
class SMDS_WNT_EXPORT SMDS_QuadraticEdge: public SMDS_MeshEdge
{
public:
SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
bool ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
void Print(std::ostream & OS) const;
int NbNodes() const;
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;
};
#endif

View File

@ -0,0 +1,281 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticFaceOfNodes.cxx
// Created: 16.01.06 17:12:58
// Author: Sergey KUUL
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticFaceOfNodes()
//purpose : Constructor
//=======================================================================
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31)
{
myNodes.resize( 6 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n12;
myNodes[ 4 ] = n23;
myNodes[ 5 ] = n31;
}
//=======================================================================
//function : SMDS_QuadraticFaceOfNodes()
//purpose : Constructor
//=======================================================================
SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41)
{
myNodes.resize( 8 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n12;
myNodes[ 5 ] = n23;
myNodes[ 6 ] = n34;
myNodes[ 7 ] = n41;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticFaceOfNodes::IsMediumNode(const SMDS_MeshNode * node) const
{
int i=NbNodes()/2;
for(; i<NbNodes(); i++) {
if(myNodes[i]==node) return true;
}
return false;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticFaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if( nbNodes==6 || nbNodes==8 ) {
myNodes.resize(nbNodes);
int i=0;
for(; i<nbNodes; i++) {
myNodes[i] = nodes[i];
}
return true;
}
return false;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbNodes() const
{
return myNodes.size();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbEdges() const
{
return NbNodes()/2;
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_QuadraticFaceOfNodes::NbFaces() const
{
return 1;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticFaceOfNodes::Print(ostream & OS) const
{
OS << "quadratic face <" << GetID() << " > : ";
int i, nbNodes = myNodes.size();
for (i = 0; i < nbNodes - 1; i++)
OS << myNodes[i] << ",";
OS << myNodes[i] << ") " << endl;
}
namespace {
//=======================================================================
//class : _MyInterlacedNodeIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeIterator:public SMDS_NodeIterator
{
const vector<const SMDS_MeshNode *>& mySet;
int myIndex;
const int * myInterlace;
public:
_MyInterlacedNodeIterator(const vector<const SMDS_MeshNode *>& s,
const int * interlace):
mySet(s),myIndex(0),myInterlace(interlace) {}
bool more()
{
return myIndex < mySet.size();
}
const SMDS_MeshNode* next()
{
return mySet[ myInterlace[ myIndex++ ]];
}
};
//=======================================================================
//class : _MyInterlacedNodeElemIterator
//purpose :
//=======================================================================
class _MyInterlacedNodeElemIterator : public SMDS_ElemIterator
{
SMDS_NodeIteratorPtr myItr;
public:
_MyInterlacedNodeElemIterator(SMDS_NodeIteratorPtr interlacedNodeItr):
myItr( interlacedNodeItr ) {}
bool more() { return myItr->more(); }
const SMDS_MeshElement* next() { return myItr->next(); }
};
//=======================================================================
//class : _MyNodeIterator
//purpose :
//=======================================================================
class _MyNodeIterator : public SMDS_NodeVectorElemIterator
{
public:
_MyNodeIterator(const vector<const SMDS_MeshNode *>& s):
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
};
}
//=======================================================================
//function : interlacedNodesIterator
//purpose :
//=======================================================================
SMDS_NodeIteratorPtr SMDS_QuadraticFaceOfNodes::interlacedNodesIterator() const
{
static int triaInterlace [] = { 0, 3, 1, 4, 2, 5 };
static int quadInterlace [] = { 0, 4, 1, 5, 2, 6, 3, 7 };
return SMDS_NodeIteratorPtr
(new _MyInterlacedNodeIterator (myNodes, myNodes.size()==6 ? triaInterlace : quadInterlace));
}
//=======================================================================
//function : interlacedNodesElemIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::interlacedNodesElemIterator() const
{
return SMDS_ElemIteratorPtr
(new _MyInterlacedNodeElemIterator ( interlacedNodesIterator() ));
}
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Face:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new _MyNodeIterator(myNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_QuadraticFaceOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,SMDS_ElemIteratorPtr (new _MyNodeIterator(myNodes))));
}
return SMDS_ElemIteratorPtr();
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_QuadraticFaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -0,0 +1,84 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticVolumeOfNodes.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticFaceOfNodes_HeaderFile
#define _SMDS_QuadraticFaceOfNodes_HeaderFile
#include "SMDS_MeshFace.hxx"
class SMDS_WNT_EXPORT SMDS_QuadraticFaceOfNodes:public SMDS_MeshFace
{
public:
SMDS_QuadraticFaceOfNodes (const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31);
SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41);
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
virtual void Print (std::ostream & OS) const;
SMDS_NodeIteratorPtr interlacedNodesIterator() const;
SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
std::vector<const SMDS_MeshNode *> myNodes;
};
#endif

View File

@ -0,0 +1,347 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File: SMDS_QuadraticVolumeOfNodes.cxx
// Created: 17.01.06 09:46:11
// Author: Sergey KUUL
#include "SMDS_QuadraticVolumeOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor tetrahedron of 10 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34)
{
myNodes.resize( 10 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n12;
myNodes[ 5 ] = n23;
myNodes[ 6 ] = n31;
myNodes[ 7 ] = n14;
myNodes[ 8 ] = n24;
myNodes[ 9 ] = n34;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor pyramid of 13 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45)
{
myNodes.resize( 13 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n12;
myNodes[ 6 ] = n23;
myNodes[ 7 ] = n34;
myNodes[ 8 ] = n41;
myNodes[ 9 ] = n15;
myNodes[ 10 ] = n25;
myNodes[ 11 ] = n35;
myNodes[ 12 ] = n45;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor Pentahedron with 15 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36)
{
myNodes.resize( 15 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n6;
myNodes[ 6 ] = n12;
myNodes[ 7 ] = n23;
myNodes[ 8 ] = n31;
myNodes[ 9 ] = n45;
myNodes[ 10 ] = n56;
myNodes[ 11 ] = n64;
myNodes[ 12 ] = n14;
myNodes[ 13 ] = n25;
myNodes[ 14 ] = n36;
}
//=======================================================================
//function : SMDS_QuadraticVolumeOfNodes()
//purpose : Constructor Hexahedrons with 20 nodes
//=======================================================================
SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48)
{
myNodes.resize( 20 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n4;
myNodes[ 4 ] = n5;
myNodes[ 5 ] = n6;
myNodes[ 6 ] = n7;
myNodes[ 7 ] = n8;
myNodes[ 8 ] = n12;
myNodes[ 9 ] = n23;
myNodes[ 10 ] = n34;
myNodes[ 11 ] = n41;
myNodes[ 12 ] = n56;
myNodes[ 13 ] = n67;
myNodes[ 14 ] = n78;
myNodes[ 15 ] = n85;
myNodes[ 16 ] = n15;
myNodes[ 17 ] = n26;
myNodes[ 18 ] = n37;
myNodes[ 19 ] = n48;
}
//=======================================================================
//function : IsMediumNode
//purpose :
//=======================================================================
bool SMDS_QuadraticVolumeOfNodes::IsMediumNode(const SMDS_MeshNode* node) const
{
int nbCorners = 0;
switch (myNodes.size()) {
case 10: nbCorners = 4; break;
case 13: nbCorners = 5; break;
case 15: nbCorners = 6; break;
default: nbCorners = 8;
}
for ( int i = nbCorners; i<myNodes.size(); i++) {
if(myNodes[i]==node) return true;
}
return false;
}
//=======================================================================
//function : ChangeNodes
//purpose :
//=======================================================================
bool SMDS_QuadraticVolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes)
{
if( nbNodes==10 || nbNodes==13 || nbNodes==15 || nbNodes==20 ) {
myNodes.resize(nbNodes);
int i=0;
for(; i<nbNodes; i++) {
myNodes[i] = nodes[i];
}
return true;
}
return false;
}
//=======================================================================
//function : NbNodes
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbNodes() const
{
return myNodes.size();
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbEdges() const
{
if(myNodes.size()==10)
return 6;
else if(myNodes.size()==13)
return 8;
else if(myNodes.size()==15)
return 9;
else
return 12;
}
//=======================================================================
//function : NbFaces
//purpose :
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbFaces() const
{
if(myNodes.size()==10)
return 4;
else if(myNodes.size()==20)
return 6;
else
return 5;
}
//=======================================================================
//function : Print
//purpose :
//=======================================================================
void SMDS_QuadraticVolumeOfNodes::Print(ostream & OS) const
{
OS << "quadratic volume <" << GetID() << " > : ";
int i, nbNodes = myNodes.size();
for (i = 0; i < nbNodes - 1; i++)
OS << myNodes[i] << ",";
OS << myNodes[i] << ") " << endl;
}
//=======================================================================
//private class : SMDS_QuadraticVolumeOfNodes_MyIterator
//purpose :
//=======================================================================
class SMDS_QuadraticVolumeOfNodes_MyIterator : public SMDS_NodeVectorElemIterator
{
public:
SMDS_QuadraticVolumeOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
};
//=======================================================================
//function : elementsIterator
//purpose :
//=======================================================================
SMDS_ElemIteratorPtr SMDS_QuadraticVolumeOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
{
switch(type)
{
case SMDSAbs_Volume:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes));
case SMDSAbs_Edge:
MESSAGE("Error : edge iterator for SMDS_QuadraticVolumeOfNodes not implemented");
break;
case SMDSAbs_Face:
MESSAGE("Error : face iterator for SMDS_QuadraticVolumeOfNodes not implemented");
break;
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type,SMDS_ElemIteratorPtr
(new SMDS_QuadraticVolumeOfNodes_MyIterator(myNodes))));
}
return SMDS_ElemIteratorPtr();
}
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
const SMDS_MeshNode* SMDS_QuadraticVolumeOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -0,0 +1,130 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_QuadraticVolumeOfNodes.hxx
// Module : SMESH
#ifndef _SMDS_QuadraticVolumeOfNodes_HeaderFile
#define _SMDS_QuadraticVolumeOfNodes_HeaderFile
#include "SMDS_MeshVolume.hxx"
class SMDS_WNT_EXPORT SMDS_QuadraticVolumeOfNodes: public SMDS_MeshVolume
{
public:
// tetrahedron of 10 nodes
SMDS_QuadraticVolumeOfNodes (const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34);
// pyramid of 13 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45);
// Pentahedron with 15 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31,
const SMDS_MeshNode * n45,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n64,
const SMDS_MeshNode * n14,
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36);
// Hexahedrons with 20 nodes
SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3,
const SMDS_MeshNode * n4,
const SMDS_MeshNode * n5,
const SMDS_MeshNode * n6,
const SMDS_MeshNode * n7,
const SMDS_MeshNode * n8,
const SMDS_MeshNode * n12,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41,
const SMDS_MeshNode * n56,
const SMDS_MeshNode * n67,
const SMDS_MeshNode * n78,
const SMDS_MeshNode * n85,
const SMDS_MeshNode * n15,
const SMDS_MeshNode * n26,
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48);
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
bool ChangeNodes(const SMDS_MeshNode* nodes[],
const int nbNodes);
virtual int NbNodes() const;
virtual int NbEdges() const;
virtual int NbFaces() const;
virtual void Print (std::ostream & OS) const;
/*!
* \brief Return node by its index
* \param ind - node index
* \retval const SMDS_MeshNode* - the node
*
* Index is wrapped if it is out of a valid range
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
protected:
virtual SMDS_ElemIteratorPtr elementsIterator (SMDSAbs_ElementType type) const;
private:
std::vector<const SMDS_MeshNode *> myNodes;
};
#endif

View File

@ -0,0 +1,101 @@
// SMESH SMDS : implementaion of Salome mesh data structure
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
//
// File : SMDS_SetIterator.hxx
// Created : Mon Feb 27 16:57:43 2006
// Author : Edward AGAPOV (eap)
#ifndef SMDS_SetIterator_HeaderFile
#define SMDS_SetIterator_HeaderFile
#include "SMDS_Iterator.hxx"
///////////////////////////////////////////////////////////////////////////////
/// specific SMDS_Iterator iterating over abstract set of values like STL containers
///
/// BE CAREFUL: iterator pointed value is static_cast'ed to VALUE
///
///////////////////////////////////////////////////////////////////////////////
template<typename VALUE, typename VALUE_SET_ITERATOR>
class SMDS_SetIterator : public SMDS_Iterator<VALUE>
{
protected:
VALUE_SET_ITERATOR _beg, _end;
public:
SMDS_SetIterator(const VALUE_SET_ITERATOR & begin,
const VALUE_SET_ITERATOR & end)
{ init ( begin, end ); }
/// Initialization
virtual void init(const VALUE_SET_ITERATOR & begin,
const VALUE_SET_ITERATOR & end)
{ _beg = begin; _end = end; }
/// Return true if and only if there are other object in this iterator
virtual bool more() { return _beg != _end; }
/// Return the current object and step to the next one
virtual VALUE next() { return static_cast<VALUE>( *_beg++ ); }
};
// useful specifications
#include <vector>
class SMDS_MeshElement;
class SMDS_MeshNode;
typedef const SMDS_MeshElement* SMDS_pElement;
typedef const SMDS_MeshNode* SMDS_pNode;
// element iterators
typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pElement >::const_iterator>
SMDS_ElementVectorIterator;
typedef SMDS_SetIterator< SMDS_pElement, SMDS_pElement const *>
SMDS_ElementArrayIterator;
typedef SMDS_SetIterator< SMDS_pElement, std::vector< SMDS_pNode >::const_iterator>
SMDS_NodeVectorElemIterator;
typedef SMDS_SetIterator< SMDS_pElement, SMDS_pNode const * >
SMDS_NodeArrayElemIterator;
// node iterators
typedef SMDS_SetIterator< SMDS_pNode, std::vector< SMDS_pNode >::const_iterator >
SMDS_NodeVectorIterator;
typedef SMDS_SetIterator< SMDS_pNode, SMDS_pNode const * >
SMDS_NodeArrayIterator;
#endif