Add SMDS_SetIterator.hxx, element->GetNode(index), fix some errors

This commit is contained in:
eap 2006-03-03 13:50:03 +00:00
parent 75b33910e0
commit 28b1248d96
23 changed files with 693 additions and 353 deletions

View File

@ -63,20 +63,6 @@ LIB_SRC = \
SMDS_QuadraticEdge.cxx \
SMDS_QuadraticFaceOfNodes.cxx \
SMDS_QuadraticVolumeOfNodes.cxx
# SMDS_Tria3OfNodes.cxx \
# SMDS_HexahedronOfNodes.cxx
#SMDSControl_BoundaryEdges.cxx \
#SMDSControl_BoundaryFaces.cxx \
#SMDSControl.cxx \
#SMDSControl_MeshBoundary.cxx \
#SMDSEdit_Transform.cxx \
#SMDS_MeshNodeIDFactory.cxx \
#SMDS_MeshPrism.cxx \
#SMDS_MeshPyramid.cxx \
#SMDS_MeshQuadrangle.cxx \
#SMDS_MeshTetrahedron.cxx \
#SMDS_MeshTriangle.cxx \
LIB_CLIENT_IDL =
@ -119,21 +105,8 @@ EXPORT_HEADERS= \
SMDS_VolumeTool.hxx \
SMDS_QuadraticEdge.hxx \
SMDS_QuadraticFaceOfNodes.hxx \
SMDS_QuadraticVolumeOfNodes.hxx
# SMDS_Tria3OfNodes.hxx \
# SMDS_HexahedronOfNodes.hxx
#SMDSControl_BoundaryEdges.hxx \
#SMDSControl_BoundaryFaces.hxx \
#SMDSControl.hxx \
#SMDSControl_MeshBoundary.hxx \
#SMDSEdit_Transform.hxx \
#SMDS_MeshPrism.hxx \
#SMDS_MeshPyramid.hxx \
#SMDS_MeshQuadrangle.hxx \
#SMDS_MeshTetrahedron.hxx \
#SMDS_MeshTriangle.hxx \
#SMDS_MeshNodeIDFactory.hxx
SMDS_QuadraticVolumeOfNodes.hxx \
SMDS_SetIterator.hxx
# additionnal information to compil and link file
CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(OCC_INCLUDES) $(BOOST_CPPFLAGS)

View File

@ -33,8 +33,24 @@
#include <boost/shared_ptr.hpp>
class SMDS_MeshElement;
class SMDS_MeshNode;
class SMDS_MeshEdge;
class SMDS_MeshFace;
class SMDS_MeshVolume;
typedef SMDS_Iterator<const SMDS_MeshElement *> SMDS_ElemIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshElement *> > SMDS_ElemIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshFace *> SMDS_FaceIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshFace *> > SMDS_FaceIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshVolume *> SMDS_VolumeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshVolume *> > SMDS_VolumeIteratorPtr;
#endif

View File

@ -155,3 +155,29 @@ SMDS_FaceOfEdges::SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1,
}*/
int SMDS_FaceOfEdges::NbNodes() const
{
return myEdges[0]->NbNodes() + myEdges[1]->NbNodes() + myEdges[2]->NbNodes() +
( myNbEdges == 4 ? myEdges[3]->NbNodes() : 0 ) - myNbEdges;
}
/*!
* \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_FaceOfEdges::GetNode(const int ind) const
{
int index = WrappedIndex( ind );
for ( int i = 0; i < myNbEdges; ++i ) {
if ( index >= myEdges[ i ]->NbNodes() )
index -= myEdges[ i ]->NbNodes();
else
return myEdges[ i ]->GetNode( index );
}
return 0;
}

View File

@ -42,10 +42,21 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace
const SMDS_MeshEdge* edge4);
SMDSAbs_ElementType GetType() const;
int NbNodes() const;
int NbEdges() const;
int NbFaces() const;
// friend bool operator<(const SMDS_FaceOfEdges& e1, const SMDS_FaceOfEdges& e2);
/*!
* \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:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -23,6 +23,7 @@
#pragma warning(disable:4786)
#endif
#include "SMDS_SetIterator.hxx"
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
@ -68,25 +69,11 @@ void SMDS_FaceOfNodes::Print(ostream & OS) const
//purpose :
//=======================================================================
class SMDS_FaceOfNodes_MyIterator:public SMDS_ElemIterator
class SMDS_FaceOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
{
const SMDS_MeshNode* const *mySet;
int myLength;
int index;
public:
SMDS_FaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
mySet(s),myLength(l),index(0) {}
bool more()
{
return index<myLength;
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
SMDS_NodeArrayElemIterator( s, & s[ l ] ) {}
};
SMDS_ElemIteratorPtr SMDS_FaceOfNodes::elementsIterator
@ -147,6 +134,18 @@ bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[],
return true;
}
/*!
* \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_FaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}
/*bool operator<(const SMDS_FaceOfNodes& f1, const SMDS_FaceOfNodes& f2)
{
set<SMDS_MeshNode> set1,set2;

View File

@ -44,6 +44,16 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace
int NbEdges() const;
int NbFaces() const;
int NbNodes() 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:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -50,15 +50,6 @@
#include <set>
#include <list>
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshEdge *> SMDS_EdgeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshEdge *> > SMDS_EdgeIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshFace *> SMDS_FaceIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshFace *> > SMDS_FaceIteratorPtr;
typedef SMDS_Iterator<const SMDS_MeshVolume *> SMDS_VolumeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshVolume *> > SMDS_VolumeIteratorPtr;
class SMDS_WNT_EXPORT SMDS_Mesh:public SMDS_MeshObject{
public:

View File

@ -135,6 +135,18 @@ bool operator<(const SMDS_MeshEdge & e1, const SMDS_MeshEdge & e2)
else return false;
}
/*!
* \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_MeshEdge::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}
//=======================================================================
//function : ChangeNodes
//purpose :

View File

@ -44,6 +44,16 @@ class SMDS_MeshEdge:public SMDS_MeshElement
int NbNodes() const;
int NbEdges() const;
friend bool operator<(const SMDS_MeshEdge& e1, const SMDS_MeshEdge& e2);
/*!
* \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:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -200,17 +200,11 @@ bool SMDS_MeshElement::IsValidIndex(const int ind) const
const SMDS_MeshNode* SMDS_MeshElement::GetNode(const int ind) const
{
SMDS_MeshNode* N;
if(IsValidIndex(ind)) {
int nbe = 0;
SMDS_ElemIteratorPtr it=edgesIterator();
while(nbe<ind) {
it->next();
nbe++;
}
return static_cast<const SMDS_MeshNode*> (it->next());
}
return N;
SMDS_ElemIteratorPtr it = nodesIterator();
int i = 0, index = WrappedIndex( ind );
while ( index != i++ )
it->next();
return static_cast<const SMDS_MeshNode*> (it->next());
}
bool SMDS_MeshElement::IsQuadratic() const

View File

@ -68,15 +68,6 @@ public:
virtual int NbFaces() const;
int GetID() const;
/**
* Return true if index of node is valid (0...NbNodes()-1)
*/
virtual bool IsValidIndex(const int ind) const;
/**
* Return node by it index (if index is valid)
*/
virtual const SMDS_MeshNode* GetNode(const int ind) const;
///Return the type of the current element
virtual SMDSAbs_ElementType GetType() const = 0;
virtual bool IsPoly() const { return false; };
@ -87,6 +78,36 @@ public:
friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);
// ===========================
// Access to nodes by index
// ===========================
/*!
* \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;
/*!
* \brief Return true if index of node is valid (0 <= ind < NbNodes())
* \param ind - node index
* \retval bool - index check result
*/
virtual bool IsValidIndex(const int ind) const;
/*!
* \brief Make index valid
* \param ind - node index
* \retval int - valid node index
*/
int WrappedIndex(const int ind) const {
if ( ind < 0 ) return -( ind % NbNodes());
if ( ind >= NbNodes() ) return ind % NbNodes();
return ind;
}
protected:
SMDS_MeshElement(int ID=-1);
virtual void Print(std::ostream & OS) const;

View File

@ -64,6 +64,15 @@ class SMDS_WNT_EXPORT SMDS_MeshNode:public SMDS_MeshElement
void setXYZ(double x, double y, double z);
friend bool operator<(const SMDS_MeshNode& e1, const SMDS_MeshNode& e2);
/*!
* \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) const { return this; }
protected:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -26,7 +26,7 @@
#include "SMDS_PolygonalFaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
//#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
@ -128,28 +128,11 @@ void SMDS_PolygonalFaceOfNodes::Print(ostream & OS) const
//function : elementsIterator
//purpose :
//=======================================================================
class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_ElemIterator
class SMDS_PolygonalFaceOfNodes_MyIterator:public SMDS_NodeVectorElemIterator
{
//const SMDS_MeshNode* const *mySet;
const std::vector<const SMDS_MeshNode *> mySet;
//int myLength;
int index;
public:
//SMDS_PolygonalFaceOfNodes_MyIterator(const SMDS_MeshNode* const *s, int l):
// mySet(s),myLength(l),index(0) {}
SMDS_PolygonalFaceOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
SMDS_PolygonalFaceOfNodes_MyIterator(const vector<const SMDS_MeshNode *>& s):
SMDS_NodeVectorElemIterator( s.begin(), s.end() ) {}
};
SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
@ -172,3 +155,16 @@ SMDS_ElemIteratorPtr SMDS_PolygonalFaceOfNodes::elementsIterator
}
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_PolygonalFaceOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -50,6 +50,15 @@ class SMDS_PolygonalFaceOfNodes:public SMDS_MeshFace
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;

View File

@ -1,11 +1,34 @@
// 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
// Copyright: Open CASCADE 2006
#include "SMDS_QuadraticEdge.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
@ -47,49 +70,6 @@ int SMDS_QuadraticEdge::NbNodes() const
return 3;
}
//=======================================================================
//function : Iterator
//purpose :
//=======================================================================
class SMDS_QuadraticEdge_MyNodeIterator:public SMDS_ElemIterator
{
const SMDS_MeshNode *const* myNodes;
int myIndex;
public:
SMDS_QuadraticEdge_MyNodeIterator(const SMDS_MeshNode * const* nodes):
myNodes(nodes),myIndex(0) {}
bool more()
{
return myIndex<3;
}
const SMDS_MeshElement* next()
{
myIndex++;
return myNodes[myIndex-1];
}
};
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 SMDS_QuadraticEdge_MyNodeIterator(myNodes));
default:
return SMDS_ElemIteratorPtr
(new SMDS_IteratorOfElements
(this,type, SMDS_ElemIteratorPtr(new SMDS_QuadraticEdge_MyNodeIterator(myNodes))));
}
}
//=======================================================================
//function : ChangeNodes
//purpose :
@ -105,7 +85,6 @@ bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
return true;
}
//=======================================================================
//function : IsMediumNode
//purpose :
@ -116,5 +95,93 @@ 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

@ -34,25 +34,29 @@ 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,
SMDS_QuadraticEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
void Print(std::ostream & OS) const;
int NbNodes() const;
bool ChangeNodes(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node12);
virtual bool IsQuadratic() const { return true; }
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
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;
elementsIterator(SMDSAbs_ElementType type) const;
};
#endif

View File

@ -1,10 +1,33 @@
// 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
// Copyright: Open CASCADE 2006
#include "SMDS_QuadraticFaceOfNodes.hxx"
#include "SMDS_SetIterator.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
@ -25,12 +48,13 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n23,
const SMDS_MeshNode * n31)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n31);
myNodes.resize( 6 );
myNodes[ 0 ] = n1;
myNodes[ 1 ] = n2;
myNodes[ 2 ] = n3;
myNodes[ 3 ] = n12;
myNodes[ 4 ] = n23;
myNodes[ 5 ] = n31;
}
@ -48,14 +72,15 @@ SMDS_QuadraticFaceOfNodes::SMDS_QuadraticFaceOfNodes(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n34,
const SMDS_MeshNode * n41)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n4);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n34);
myNodes.push_back(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;
}
@ -123,7 +148,6 @@ int SMDS_QuadraticFaceOfNodes::NbFaces() const
return 1;
}
//=======================================================================
//function : Print
//purpose :
@ -137,79 +161,91 @@ void SMDS_QuadraticFaceOfNodes::Print(ostream & OS) const
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 :
//=======================================================================
class SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator:public SMDS_NodeIterator
{
const std::vector<const SMDS_MeshNode *> mySet;
int index;
public:
SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshNode* next()
{
index++;
int num=0;
if(mySet.size()==6) {
if(index==2) num=3;
else if(index==3) num=1;
else if(index==4) num=4;
else if(index==5) num=2;
else if(index==6) num=5;
}
else {
if(index==2) num=4;
else if(index==3) num=1;
else if(index==4) num=5;
else if(index==5) num=2;
else if(index==6) num=6;
else if(index==7) num=3;
else if(index==8) num=7;
}
return mySet[num];
}
};
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 SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator(myNodes));
(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 :
//=======================================================================
class SMDS_QuadraticFaceOfNodes_MyIterator:public SMDS_ElemIterator
{
const std::vector<const SMDS_MeshNode *> mySet;
int index;
public:
SMDS_QuadraticFaceOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
};
SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
@ -219,15 +255,27 @@ SMDS_ElemIteratorPtr SMDS_QuadraticFaceOfNodes::elementsIterator
case SMDSAbs_Face:
return SMDS_MeshElement::elementsIterator(SMDSAbs_Face);
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_QuadraticFaceOfNodes_MyIterator(myNodes));
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 SMDS_QuadraticFaceOfNodes_MyIterator(myNodes))));
(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

@ -29,9 +29,6 @@
#include "SMDS_MeshFace.hxx"
typedef SMDS_Iterator<const SMDS_MeshNode *> SMDS_NodeIterator;
typedef boost::shared_ptr<SMDS_Iterator<const SMDS_MeshNode *> > SMDS_NodeIteratorPtr;
class SMDS_WNT_EXPORT SMDS_QuadraticFaceOfNodes:public SMDS_MeshFace
{
public:
@ -66,6 +63,17 @@ public:
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;

View File

@ -1,12 +1,35 @@
// 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
// Copyright: Open CASCADE 2006
#include "SMDS_QuadraticVolumeOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h"
@ -30,16 +53,17 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n24,
const SMDS_MeshNode * n34)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n4);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n31);
myNodes.push_back(n14);
myNodes.push_back(n24);
myNodes.push_back(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;
}
@ -63,19 +87,20 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n35,
const SMDS_MeshNode * n45)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n4);
myNodes.push_back(n5);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n34);
myNodes.push_back(n41);
myNodes.push_back(n15);
myNodes.push_back(n25);
myNodes.push_back(n35);
myNodes.push_back(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;
}
@ -101,21 +126,22 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n25,
const SMDS_MeshNode * n36)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n4);
myNodes.push_back(n5);
myNodes.push_back(n6);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n31);
myNodes.push_back(n45);
myNodes.push_back(n56);
myNodes.push_back(n64);
myNodes.push_back(n14);
myNodes.push_back(n25);
myNodes.push_back(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;
}
@ -146,26 +172,27 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
const SMDS_MeshNode * n37,
const SMDS_MeshNode * n48)
{
myNodes.push_back(n1);
myNodes.push_back(n2);
myNodes.push_back(n3);
myNodes.push_back(n4);
myNodes.push_back(n5);
myNodes.push_back(n6);
myNodes.push_back(n7);
myNodes.push_back(n8);
myNodes.push_back(n12);
myNodes.push_back(n23);
myNodes.push_back(n34);
myNodes.push_back(n41);
myNodes.push_back(n56);
myNodes.push_back(n67);
myNodes.push_back(n78);
myNodes.push_back(n85);
myNodes.push_back(n15);
myNodes.push_back(n26);
myNodes.push_back(n37);
myNodes.push_back(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;
}
@ -176,29 +203,15 @@ SMDS_QuadraticVolumeOfNodes::SMDS_QuadraticVolumeOfNodes
bool SMDS_QuadraticVolumeOfNodes::IsMediumNode(const SMDS_MeshNode* node) const
{
if(NbNodes()==10) {
int i=4;
for(; i<10; i++) {
if(myNodes[i]==node) return true;
}
int nbCorners = 0;
switch (myNodes.size()) {
case 10: nbCorners = 4; break;
case 13: nbCorners = 5; break;
case 15: nbCorners = 6; break;
default: nbCorners = 8;
}
else if(NbNodes()==13) {
int i=5;
for(; i<13; i++) {
if(myNodes[i]==node) return true;
}
}
else if(NbNodes()==15) {
int i=6;
for(; i<15; i++) {
if(myNodes[i]==node) return true;
}
}
else {
int i=8;
for(; i<20; i++) {
if(myNodes[i]==node) return true;
}
for ( int i = nbCorners; i<myNodes.size(); i++) {
if(myNodes[i]==node) return true;
}
return false;
}
@ -240,11 +253,11 @@ int SMDS_QuadraticVolumeOfNodes::NbNodes() const
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbEdges() const
{
if(NbNodes()==10)
if(myNodes.size()==10)
return 6;
else if(NbNodes()==13)
else if(myNodes.size()==13)
return 8;
else if(NbNodes()==15)
else if(myNodes.size()==15)
return 9;
else
return 12;
@ -257,9 +270,9 @@ int SMDS_QuadraticVolumeOfNodes::NbEdges() const
//=======================================================================
int SMDS_QuadraticVolumeOfNodes::NbFaces() const
{
if(NbNodes()==10)
if(myNodes.size()==10)
return 4;
else if(NbNodes()==20)
else if(myNodes.size()==20)
return 6;
else
return 5;
@ -279,29 +292,22 @@ void SMDS_QuadraticVolumeOfNodes::Print(ostream & OS) const
}
//=======================================================================
//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 :
//=======================================================================
class SMDS_QuadraticVolumeOfNodes_MyIterator:public SMDS_ElemIterator
{
const std::vector<const SMDS_MeshNode *> mySet;
int index;
public:
SMDS_QuadraticVolumeOfNodes_MyIterator(const std::vector<const SMDS_MeshNode *> s):
mySet(s),index(0) {}
bool more()
{
return index < mySet.size();
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
};
SMDS_ElemIteratorPtr SMDS_QuadraticVolumeOfNodes::elementsIterator
(SMDSAbs_ElementType type) const
@ -327,3 +333,15 @@ SMDS_ElemIteratorPtr SMDS_QuadraticVolumeOfNodes::elementsIterator
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

@ -111,6 +111,15 @@ public:
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;

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

View File

@ -25,6 +25,7 @@
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
@ -170,29 +171,14 @@ int SMDS_VolumeOfNodes::NbEdges() const
return 0;
}
class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator
class SMDS_VolumeOfNodes_MyIterator:public SMDS_NodeArrayElemIterator
{
const SMDS_MeshNode* const* mySet;
int myLength;
int index;
public:
SMDS_VolumeOfNodes_MyIterator(const SMDS_MeshNode* const* s, int l):
mySet(s),myLength(l),index(0) {}
bool more()
{
return index<myLength;
}
const SMDS_MeshElement* next()
{
index++;
return mySet[index-1];
}
SMDS_NodeArrayElemIterator( s, & s[ l ]) {}
};
SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::
elementsIterator(SMDSAbs_ElementType type) const
SMDS_ElemIteratorPtr SMDS_VolumeOfNodes::elementsIterator(SMDSAbs_ElementType type) const
{
switch(type)
{
@ -210,3 +196,15 @@ SMDSAbs_ElementType SMDS_VolumeOfNodes::GetType() const
{
return SMDSAbs_Volume;
}
/*!
* \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_VolumeOfNodes::GetNode(const int ind) const
{
return myNodes[ WrappedIndex( ind )];
}

View File

@ -70,6 +70,16 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume
int NbNodes() const;
int NbEdges() const;
SMDSAbs_ElementType GetType() 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:
SMDS_ElemIteratorPtr
elementsIterator(SMDSAbs_ElementType type) const;