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 =
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)
#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
}*/
+
+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;
+}
+
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;
#pragma warning(disable:4786)
#endif
+#include "SMDS_SetIterator.hxx"
#include "SMDS_FaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
#include "SMDS_MeshNode.hxx"
//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
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;
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;
#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:
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 :
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;
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
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; };
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;
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;
#include "SMDS_PolygonalFaceOfNodes.hxx"
#include "SMDS_IteratorOfElements.hxx"
-//#include "SMDS_MeshNode.hxx"
+#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
//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
}
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 )];
+}
+
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;
+// 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"
return 3;
}
-
//=======================================================================
-//function : Iterator
+//function : ChangeNodes
//purpose :
//=======================================================================
-class SMDS_QuadraticEdge_MyNodeIterator:public SMDS_ElemIterator
+bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
+ const SMDS_MeshNode * node2,
+ const SMDS_MeshNode * node12)
{
- const SMDS_MeshNode *const* myNodes;
- int myIndex;
- public:
- SMDS_QuadraticEdge_MyNodeIterator(const SMDS_MeshNode * const* nodes):
- myNodes(nodes),myIndex(0) {}
+ myNodes[0]=node1;
+ myNodes[1]=node2;
+ myNodes[2]=node12;
+ return true;
+}
- bool more()
- {
- return myIndex<3;
- }
+//=======================================================================
+//function : IsMediumNode
+//purpose :
+//=======================================================================
- const SMDS_MeshElement* next()
- {
- myIndex++;
- return myNodes[myIndex-1];
- }
-};
+bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
+{
+ return (myNodes[2]==node);
+}
-SMDS_ElemIteratorPtr SMDS_QuadraticEdge::
- elementsIterator(SMDSAbs_ElementType type) const
+namespace
{
- switch(type)
+ //=======================================================================
+ //class : _MyInterlacedNodeIterator
+ //purpose :
+ //=======================================================================
+
+ class _MyInterlacedNodeIterator: public SMDS_NodeArrayIterator
{
- 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))));
- }
+ 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 : ChangeNodes
+//function : interlacedNodesIterator
//purpose :
//=======================================================================
-bool SMDS_QuadraticEdge::ChangeNodes(const SMDS_MeshNode * node1,
- const SMDS_MeshNode * node2,
- const SMDS_MeshNode * node12)
+SMDS_NodeIteratorPtr SMDS_QuadraticEdge::interlacedNodesIterator() const
{
- myNodes[0]=node1;
- myNodes[1]=node2;
- myNodes[2]=node12;
- return true;
+ return SMDS_NodeIteratorPtr (new _MyInterlacedNodeIterator (myNodes));
}
//=======================================================================
-//function : IsMediumNode
+//function : interlacedNodesElemIterator
//purpose :
//=======================================================================
-bool SMDS_QuadraticEdge::IsMediumNode(const SMDS_MeshNode * node) const
+SMDS_ElemIteratorPtr SMDS_QuadraticEdge::interlacedNodesElemIterator() const
{
- return (myNodes[2]==node);
+ 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))));
+ }
+}
{
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);
+
+ 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;
- virtual bool IsQuadratic() const { return true; }
-
- virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
+ SMDS_ElemIteratorPtr interlacedNodesElemIterator() const;
protected:
SMDS_ElemIteratorPtr
- elementsIterator(SMDSAbs_ElementType type) const;
+ elementsIterator(SMDSAbs_ElementType type) const;
};
#endif
+// 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"
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;
}
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;
}
return 1;
}
-
//=======================================================================
//function : Print
//purpose :
OS << myNodes[i] << ") " << endl;
}
+namespace {
-//=======================================================================
-//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();
- }
+ //=======================================================================
+ //class : _MyInterlacedNodeIterator
+ //purpose :
+ //=======================================================================
- const SMDS_MeshNode* next()
+ class _MyInterlacedNodeIterator:public SMDS_NodeIterator
{
- 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;
+ 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();
}
- 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;
+
+ const SMDS_MeshNode* next()
+ {
+ return mySet[ myInterlace[ myIndex++ ]];
}
- return mySet[num];
- }
-};
+ };
+
+ //=======================================================================
+ //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 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
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 )];
+}
+
#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:
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;
+// 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"
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;
}
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;
}
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;
}
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;
}
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;
- }
- }
- else if(NbNodes()==13) {
- int i=5;
- for(; i<13; 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()==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;
}
//=======================================================================
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;
//=======================================================================
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;
//=======================================================================
-//function : elementsIterator
+//private class : SMDS_QuadraticVolumeOfNodes_MyIterator
//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];
- }
+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
{
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 )];
+}
+
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;
--- /dev/null
+// 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
#include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_MeshNode.hxx"
+#include "SMDS_SetIterator.hxx"
#include "utilities.h"
using namespace std;
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)
{
{
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 )];
+}
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;