From e4f721477b9d4b9b4c025a6e423af474a89b0b1a Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 23 Jan 2006 14:07:26 +0000 Subject: [PATCH] Implement quadratic classes --- src/SMDS/SMDS_Mesh.cxx | 597 ++++++++++++++++++++++- src/SMDS/SMDS_Mesh.hxx | 4 +- src/SMDS/SMDS_MeshEdge.hxx | 4 +- src/SMDS/SMDS_QuadraticEdge.cxx | 120 +++++ src/SMDS/SMDS_QuadraticEdge.hxx | 37 +- src/SMDS/SMDS_QuadraticFaceOfNodes.cxx | 233 +++++++++ src/SMDS/SMDS_QuadraticFaceOfNodes.hxx | 9 +- src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx | 329 +++++++++++++ src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx | 9 +- 9 files changed, 1314 insertions(+), 28 deletions(-) create mode 100644 src/SMDS/SMDS_QuadraticEdge.cxx create mode 100644 src/SMDS/SMDS_QuadraticFaceOfNodes.cxx create mode 100644 src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 6381e547e..5bc8cd544 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -31,6 +31,9 @@ #include "SMDS_FaceOfEdges.hxx" #include "SMDS_PolyhedralVolumeOfNodes.hxx" #include "SMDS_PolygonalFaceOfNodes.hxx" +#include "SMDS_QuadraticEdge.hxx" +#include "SMDS_QuadraticFaceOfNodes.hxx" +#include "SMDS_QuadraticVolumeOfNodes.hxx" #include #include @@ -2200,4 +2203,596 @@ SMDSAbs_ElementType SMDS_Mesh::GetElementType( const int id, const bool iselem ) } else return elem->GetType(); -} \ No newline at end of file +} + + + +//******************************************************************** +//******************************************************************** +//******** ********* +//***** Methods for addition of quadratic elements ****** +//******** ********* +//******************************************************************** +//******************************************************************** + +//======================================================================= +//function : AddEdgeWithID +//purpose : +//======================================================================= +SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(int n1, int n2, int n12, int ID) +{ + SMDS_MeshNode* node1 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1); + SMDS_MeshNode* node2 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2); + SMDS_MeshNode* node12 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12); + if(!node1 || !node2 || !node12) return NULL; + return SMDS_Mesh::AddEdgeWithID(node1, node2, node12, ID); +} + +//======================================================================= +//function : AddEdge +//purpose : +//======================================================================= +SMDS_MeshEdge* SMDS_Mesh::AddEdge(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const SMDS_MeshNode* n12) +{ + return SMDS_Mesh::AddEdgeWithID(n1, n2, n12, myElementIDFactory->GetFreeID()); +} + +//======================================================================= +//function : AddEdgeWithID +//purpose : +//======================================================================= +SMDS_MeshEdge* SMDS_Mesh::AddEdgeWithID(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n12, + int ID) +{ + cout<<"SMDS_Mesh::AddEdgeWithID"<BindID(ID, edge)) { + SMDS_MeshNode *node1,*node2, *node12; + node1 = const_cast(n1); + node2 = const_cast(n2); + node12 = const_cast(n12); + node1->AddInverseElement(edge); + node2->AddInverseElement(edge); + node12->AddInverseElement(edge); + myEdges.Add(edge); + return edge; + } + else { + delete edge; + return NULL; + } +} + + +//======================================================================= +//function : AddFace +//purpose : +//======================================================================= +SMDS_MeshFace* SMDS_Mesh::AddFace(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31) +{ + return SMDS_Mesh::AddFaceWithID(n1,n2,n3,n12,n23,n31, + myElementIDFactory->GetFreeID()); +} + +//======================================================================= +//function : AddFaceWithID +//purpose : +//======================================================================= +SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int n1, int n2, int n3, + int n12,int n23,int n31, int ID) +{ + SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n1); + SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n2); + SMDS_MeshNode * node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n3); + SMDS_MeshNode * node12 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n12); + SMDS_MeshNode * node23 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n23); + SMDS_MeshNode * node31 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n31); + if(!node1 || !node2 || !node3 || !node12 || !node23 || !node31) return NULL; + return SMDS_Mesh::AddFaceWithID(node1, node2, node3, + node12, node23, node31, ID); +} + +//======================================================================= +//function : AddFaceWithID +//purpose : +//======================================================================= +SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2, + const SMDS_MeshNode * n3, + const SMDS_MeshNode * n12, + const SMDS_MeshNode * n23, + const SMDS_MeshNode * n31, + int ID) +{ + cout<<"SMDS_Mesh::AddFaceWithID"<GetFreeID()); +} + +//======================================================================= +//function : AddFaceWithID +//purpose : +//======================================================================= +SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(int n1, int n2, int n3, int n4, + int n12,int n23,int n34,int n41, int ID) +{ + SMDS_MeshNode * node1 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n1); + SMDS_MeshNode * node2 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n2); + SMDS_MeshNode * node3 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n3); + SMDS_MeshNode * node4 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n4); + SMDS_MeshNode * node12 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n12); + SMDS_MeshNode * node23 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n23); + SMDS_MeshNode * node34 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n34); + SMDS_MeshNode * node41 = (SMDS_MeshNode *)myNodeIDFactory->MeshElement(n41); + if(!node1 || !node2 || !node3 || !node4 || + !node12 || !node23 || !node34 || !node41) return NULL; + return SMDS_Mesh::AddFaceWithID(node1, node2, node3, node4, + node12, node23, node34, node41, ID); +} + +//======================================================================= +//function : AddFaceWithID +//purpose : +//======================================================================= +SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(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, + int ID) +{ + cout<<"SMDS_Mesh::AddFaceWithID"<GetFreeID(); + SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n12, n23, + n31, n14, n24, n34, ID); + if(v==NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, + int n12,int n23,int n31, + int n14,int n24,int n34, int ID) +{ + SMDS_MeshNode *node1, *node2, *node3, *node4, *node12, *node23; + SMDS_MeshNode *node31, *node14, *node24, *node34; + node1 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1); + node2 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2); + node3 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n3); + node4 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n4); + node12 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12); + node23 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n23); + node31 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n31); + node14 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n14); + node24 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n24); + node34 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n34); + if( !node1 || !node2 || !node3 || !node4 || !node12 || !node23 || + !node31 || !node14 || !node24 || !node34 ) return NULL; + return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node12, node23, + node31, node14, node24, node34, ID); +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order tetrahedron of 10 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(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, + int ID) +{ + cout<<"SMDS_Mesh::AddVolumeWithID"<GetFreeID(); + SMDS_MeshVolume * v = + SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n12, n23, n34, n41, + n15, n25, n35, n45, ID); + if(v==NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, int n5, + int n12,int n23,int n34,int n41, + int n15,int n25,int n35,int n45, int ID) +{ + SMDS_MeshNode *node1, *node2, *node3, *node4, *node5; + SMDS_MeshNode *node12, *node23, *node34, *node41; + SMDS_MeshNode *node15, *node25, *node35, *node45; + node1 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1); + node2 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2); + node3 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n3); + node4 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n4); + node5 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n5); + node12 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12); + node23 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n23); + node34 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n34); + node41 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n41); + node15 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n15); + node25 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n25); + node35 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n35); + node45 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n45); + if( !node1 || !node2 || !node3 || !node4 || !node5 || + !node12 || !node23 || !node34 || !node41 || + !node15 || !node25 || !node35 || !node45 ) return NULL; + return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, + node12, node23, node34, node41, + node15, node25, node35, node45, ID); +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order pyramid of 13 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(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, + int ID) +{ + cout<<"SMDS_Mesh::AddVolumeWithID"<GetFreeID(); + SMDS_MeshVolume * v = + SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n12, n23, n31, + n45, n56, n64, n14, n25, n36, ID); + if(v==NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, + int n4, int n5, int n6, + int n12,int n23,int n31, + int n45,int n56,int n64, + int n14,int n25,int n36, int ID) +{ + SMDS_MeshNode *node1, *node2, *node3, *node4, *node5, *node6; + SMDS_MeshNode *node12, *node23, *node31; + SMDS_MeshNode *node45, *node56, *node64; + SMDS_MeshNode *node14, *node25, *node36; + node1 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1); + node2 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2); + node3 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n3); + node4 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n4); + node5 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n5); + node6 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n6); + node12 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12); + node23 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n23); + node31 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n31); + node45 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n45); + node56 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n56); + node64 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n64); + node14 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n14); + node25 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n25); + node36 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n36); + if( !node1 || !node2 || !node3 || !node4 || !node5 || !node6 || + !node12 || !node23 || !node31 || !node45 || !node56 || + !node64 || !node14 || !node25 || !node36 ) return NULL; + return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, node5, node6, + node12, node23, node31, node45, node56, + node64, node14, node25, node36, ID); +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order Pentahedron with 15 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(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, + int ID) +{ + cout<<"SMDS_Mesh::AddVolumeWithID"<GetFreeID(); + SMDS_MeshVolume * v = + SMDS_Mesh::AddVolumeWithID(n1, n2, n3, n4, n5, n6, n7, n8, n12, n23, n34, n41, + n56, n67, n78, n85, n15, n26, n37, n48, ID); + if(v==NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(int n1, int n2, int n3, int n4, + int n5, int n6, int n7, int n8, + int n12,int n23,int n34,int n41, + int n56,int n67,int n78,int n85, + int n15,int n26,int n37,int n48, int ID) +{ + SMDS_MeshNode *node1, *node2, *node3, *node4; + SMDS_MeshNode *node5, *node6, *node7, *node8; + SMDS_MeshNode *node12, *node23, *node34, *node41; + SMDS_MeshNode *node56, *node67, *node78, *node85; + SMDS_MeshNode *node15, *node26, *node37, *node48; + node1 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n1); + node2 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n2); + node3 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n3); + node4 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n4); + node5 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n5); + node6 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n6); + node7 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n7); + node8 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n8); + node12 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n12); + node23 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n23); + node34 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n34); + node41 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n41); + node56 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n56); + node67 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n67); + node78 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n78); + node85 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n85); + node15 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n15); + node26 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n26); + node37 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n37); + node48 = (SMDS_MeshNode*) myNodeIDFactory->MeshElement(n48); + if( !node1 || !node2 || !node3 || !node4 || + !node5 || !node6 || !node7 || !node8 || + !node12 || !node23 || !node34 || !node41 || + !node56 || !node67 || !node78 || !node85 || + !node15 || !node26 || !node37 || !node48 ) return NULL; + return SMDS_Mesh::AddVolumeWithID(node1, node2, node3, node4, + node5, node6, node7, node8, + node12, node23, node34, node41, + node56, node67, node78, node85, + node15, node26, node37, node48, ID); +} + +//======================================================================= +//function : AddVolumeWithID +//purpose : 2d order Hexahedrons with 20 nodes +//======================================================================= +SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(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, + int ID) +{ + cout<<"SMDS_Mesh::AddVolumeWithID"< : ( first-" << myNodes[0] + << " , last-" << myNodes[1] << " , medium-" << myNodes[2] << ") " << endl; +} + + +//======================================================================= +//function : NbNodes +//purpose : +//======================================================================= + +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 : +//======================================================================= + +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); +} + + + diff --git a/src/SMDS/SMDS_QuadraticEdge.hxx b/src/SMDS/SMDS_QuadraticEdge.hxx index 6bb9b2be4..0319c1cc4 100644 --- a/src/SMDS/SMDS_QuadraticEdge.hxx +++ b/src/SMDS/SMDS_QuadraticEdge.hxx @@ -28,26 +28,31 @@ #define _SMDS_QuadraticEdge_HeaderFile #include "SMDS_MeshEdge.hxx" +#include 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; - protected: - SMDS_ElemIteratorPtr - elementsIterator(SMDSAbs_ElementType type) const; - - private: - const SMDS_MeshNode* myNodes[3]; +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; + +protected: + SMDS_ElemIteratorPtr + elementsIterator(SMDSAbs_ElementType type) const; }; #endif diff --git a/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx new file mode 100644 index 000000000..6d8e55156 --- /dev/null +++ b/src/SMDS/SMDS_QuadraticFaceOfNodes.cxx @@ -0,0 +1,233 @@ +// File: SMDS_QuadraticFaceOfNodes.cxx +// Created: 16.01.06 17:12:58 +// Author: Sergey KUUL +// Copyright: Open CASCADE 2006 + +#include "SMDS_QuadraticFaceOfNodes.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.push_back(n1); + myNodes.push_back(n2); + myNodes.push_back(n3); + myNodes.push_back(n12); + myNodes.push_back(n23); + myNodes.push_back(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.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); +} + + +//======================================================================= +//function : IsMediumNode +//purpose : +//======================================================================= + +bool SMDS_QuadraticFaceOfNodes::IsMediumNode(const SMDS_MeshNode * node) const +{ + int i=NbNodes()/2; + for(; i : "; + int i, nbNodes = myNodes.size(); + for (i = 0; i < nbNodes - 1; i++) + OS << myNodes[i] << ","; + OS << myNodes[i] << ") " << endl; +} + + +//======================================================================= +//function : interlacedNodesIterator +//purpose : +//======================================================================= +class SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator:public SMDS_NodeIterator +{ + const std::vector mySet; + int index; + public: + SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator(const std::vector 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 +{ + return SMDS_NodeIteratorPtr + (new SMDS_QuadraticFaceOfNodes_MyInterlacedNodeIterator(myNodes)); +} + + + +//======================================================================= +//function : elementsIterator +//purpose : +//======================================================================= +class SMDS_QuadraticFaceOfNodes_MyIterator:public SMDS_ElemIterator +{ + const std::vector mySet; + int index; + public: + SMDS_QuadraticFaceOfNodes_MyIterator(const std::vector 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 +{ + switch(type) + { + case SMDSAbs_Face: + return SMDS_MeshElement::elementsIterator(SMDSAbs_Face); + case SMDSAbs_Node: + return SMDS_ElemIteratorPtr(new SMDS_QuadraticFaceOfNodes_MyIterator(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)))); + } + return SMDS_ElemIteratorPtr(); +} diff --git a/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx b/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx index bf699748c..8ce72f3fb 100644 --- a/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx +++ b/src/SMDS/SMDS_QuadraticFaceOfNodes.hxx @@ -24,11 +24,14 @@ // File : SMDS_QuadraticVolumeOfNodes.hxx // Module : SMESH -#ifndef _SMDS_QuadraticVolumeOfNodes_HeaderFile -#define _SMDS_QuadraticVolumeOfNodes_HeaderFile +#ifndef _SMDS_QuadraticFaceOfNodes_HeaderFile +#define _SMDS_QuadraticFaceOfNodes_HeaderFile #include "SMDS_MeshFace.hxx" +typedef SMDS_Iterator SMDS_NodeIterator; +typedef boost::shared_ptr > SMDS_NodeIteratorPtr; + class SMDS_WNT_EXPORT SMDS_QuadraticFaceOfNodes:public SMDS_MeshFace { public: @@ -50,7 +53,7 @@ public: virtual bool IsQuadratic() const { return true; } - virtual bool IsMediumNode(class SMDS_MeshNode* node) const; + virtual bool IsMediumNode(const SMDS_MeshNode* node) const; bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); diff --git a/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx new file mode 100644 index 000000000..1da0c13bf --- /dev/null +++ b/src/SMDS/SMDS_QuadraticVolumeOfNodes.cxx @@ -0,0 +1,329 @@ +// 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 "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.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); +} + + +//======================================================================= +//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.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); +} + + +//======================================================================= +//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.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); +} + + +//======================================================================= +//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.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); +} + + +//======================================================================= +//function : IsMediumNode +//purpose : +//======================================================================= + +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; + } + } + 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; + } + } + 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 : "; + int i, nbNodes = myNodes.size(); + for (i = 0; i < nbNodes - 1; i++) + OS << myNodes[i] << ","; + OS << myNodes[i] << ") " << endl; +} + + +//======================================================================= +//function : elementsIterator +//purpose : +//======================================================================= +class SMDS_QuadraticVolumeOfNodes_MyIterator:public SMDS_ElemIterator +{ + const std::vector mySet; + int index; + public: + SMDS_QuadraticVolumeOfNodes_MyIterator(const std::vector 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 +{ + 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(); +} + diff --git a/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx b/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx index 9964f2fc8..7ab5c796b 100644 --- a/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx +++ b/src/SMDS/SMDS_QuadraticVolumeOfNodes.hxx @@ -29,7 +29,7 @@ #include "SMDS_MeshVolume.hxx" -class SMDS_WNT_EXPORT SMDS_QuadraticVolumeOfNodes:public SMDS_MeshVolume +class SMDS_WNT_EXPORT SMDS_QuadraticVolumeOfNodes: public SMDS_MeshVolume { public: // tetrahedron of 10 nodes @@ -41,8 +41,9 @@ public: const SMDS_MeshNode * n23, const SMDS_MeshNode * n31, const SMDS_MeshNode * n14, - const SMDS_MeshNode * n23, + const SMDS_MeshNode * n24, const SMDS_MeshNode * n34); + // pyramid of 13 nodes SMDS_QuadraticVolumeOfNodes(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2, @@ -87,7 +88,7 @@ public: const SMDS_MeshNode * n12, const SMDS_MeshNode * n23, const SMDS_MeshNode * n34, - const SMDS_MeshNode * n51, + const SMDS_MeshNode * n41, const SMDS_MeshNode * n56, const SMDS_MeshNode * n67, const SMDS_MeshNode * n78, @@ -99,7 +100,7 @@ public: virtual bool IsQuadratic() const { return true; } - virtual bool IsMediumNode(class SMDS_MeshNode* node) const; + virtual bool IsMediumNode(const SMDS_MeshNode* node) const; bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); -- 2.39.2