Changes for working with quadratic elements.

This commit is contained in:
skl 2006-02-20 07:50:46 +00:00
parent ca9000e60d
commit 75b33910e0
28 changed files with 4251 additions and 1699 deletions

View File

@ -164,9 +164,9 @@ bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
// Get nodes of the element
if(anElem->IsQuadratic()) {
const SMDS_QuadraticFaceOfNodes* F =
static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
if(F) {
// use special nodes iterator
SMDS_NodeIteratorPtr anIter = F->interlacedNodesIterator();
if ( anIter != 0 ) {

View File

@ -616,15 +616,12 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType,
else if ( theNbNodes == 6 ) return VTK_WEDGE;
else if ( theNbNodes == 8 ) return VTK_HEXAHEDRON;
else if ( theNbNodes == 10 ) {
cout<<"QUADRATIC_TETRA"<<endl;
return VTK_QUADRATIC_TETRA;
}
else if ( theNbNodes == 20 ) {
cout<<"QUADRATIC_HEXAHEDRON"<<endl;
return VTK_QUADRATIC_HEXAHEDRON;
}
else if ( theNbNodes==13 || theNbNodes==15 ) {
cout<<"QUADRATIC - CONVEX_POINT_SET"<<endl;
return VTK_CONVEX_POINT_SET;
}
else return VTK_EMPTY_CELL;

View File

@ -1087,13 +1087,25 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
if ( edge )
Ok = const_cast<SMDS_MeshEdge*>( edge )->ChangeNodes( nodes[0], nodes[1] );
}
else if ( nbnodes == 3 ) {
const SMDS_QuadraticEdge* edge = dynamic_cast<const SMDS_QuadraticEdge*>( elem );
if ( edge )
Ok = const_cast<SMDS_QuadraticEdge*>( edge )->ChangeNodes( nodes[0], nodes[1], nodes[2] );
}
break;
}
case SMDSAbs_Face: {
const SMDS_FaceOfNodes* face = dynamic_cast<const SMDS_FaceOfNodes*>( elem );
if ( face ) {
Ok = const_cast<SMDS_FaceOfNodes*>( face )->ChangeNodes( nodes, nbnodes );
} else {
}
else {
const SMDS_QuadraticFaceOfNodes* QF =
dynamic_cast<const SMDS_QuadraticFaceOfNodes*>( elem );
if ( QF ) {
Ok = const_cast<SMDS_QuadraticFaceOfNodes*>( QF )->ChangeNodes( nodes, nbnodes );
}
else {
/// ??? begin
const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
if (face) {
@ -1101,6 +1113,7 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
}
/// ??? end
}
}
break;
}
//case SMDSAbs_PolygonalFace: {
@ -1112,8 +1125,15 @@ bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem,
//}
case SMDSAbs_Volume: {
const SMDS_VolumeOfNodes* vol = dynamic_cast<const SMDS_VolumeOfNodes*>( elem );
if ( vol )
if ( vol ) {
Ok = const_cast<SMDS_VolumeOfNodes*>( vol )->ChangeNodes( nodes, nbnodes );
}
else {
const SMDS_QuadraticVolumeOfNodes* QV = dynamic_cast<const SMDS_QuadraticVolumeOfNodes*>( elem );
if ( QV ) {
Ok = const_cast<SMDS_QuadraticVolumeOfNodes*>( QV )->ChangeNodes( nodes, nbnodes );
}
}
break;
}
default:
@ -1203,6 +1223,7 @@ bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
return Ok;
}
//=======================================================================
//function : FindEdge
//purpose :
@ -1226,15 +1247,11 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
SMDS_ElemIteratorPtr it1=node1->edgesIterator();
//PROFILER_Get(0);
//PROFILER_Set();
while(it1->more())
{
const SMDS_MeshEdge * e=static_cast<const SMDS_MeshEdge *>
(it1->next());
while(it1->more()) {
const SMDS_MeshEdge * e=static_cast<const SMDS_MeshEdge *> (it1->next());
SMDS_ElemIteratorPtr it2=e->nodesIterator();
while(it2->more())
{
if(it2->next()->GetID()==node2->GetID())
{
while(it2->more()) {
if(it2->next()->GetID()==node2->GetID()) {
toReturn = e;
break;
}
@ -1245,19 +1262,64 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
}
//=======================================================================
//function : FindEdgeOrCreate
//purpose :
//=======================================================================
SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
SMDS_MeshEdge * toReturn=NULL;
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
if(toReturn==NULL)
{
if(toReturn==NULL) {
toReturn=new SMDS_MeshEdge(node1,node2);
myEdges.Add(toReturn);
}
return toReturn;
}
//=======================================================================
//function : FindEdge
//purpose :
//=======================================================================
const SMDS_MeshEdge* SMDS_Mesh::FindEdge(int idnode1, int idnode2,
int idnode3) const
{
const SMDS_MeshNode * node1=FindNode(idnode1);
const SMDS_MeshNode * node2=FindNode(idnode2);
const SMDS_MeshNode * node3=FindNode(idnode3);
if( (node1==NULL) || (node2==NULL) || (node3==NULL) ) return NULL;
return FindEdge(node1,node2,node3);
}
const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2,
const SMDS_MeshNode * node3)
{
const SMDS_MeshEdge * toReturn = NULL;
SMDS_ElemIteratorPtr it1 = node1->edgesIterator();
while(it1->more()) {
const SMDS_MeshEdge * e = static_cast<const SMDS_MeshEdge *> (it1->next());
SMDS_ElemIteratorPtr it2 = e->nodesIterator();
int tmp = 0;
while(it2->more()) {
int nID = it2->next()->GetID();
if( nID==node2->GetID() || nID==node3->GetID() ) {
tmp++;
if(tmp==2) {
toReturn = e;
break;
}
}
}
}
return toReturn;
}
//=======================================================================
//function : FindFace
//purpose :
@ -1273,8 +1335,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2,
return FindFace(node1, node2, node3);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(
const SMDS_MeshNode *node1,
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3)
{
@ -1283,15 +1344,13 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
bool node2found, node3found;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more())
{
while(it1->more()) {
face = static_cast<const SMDS_MeshFace*>(it1->next());
if(face->NbNodes()!=3) continue;
SMDS_ElemIteratorPtr it2 = face->nodesIterator();
node2found = false;
node3found = false;
while(it2->more())
{
while(it2->more()) {
node = it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
@ -1302,38 +1361,37 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
return NULL;
}
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
const SMDS_MeshNode *node1,
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3)
{
SMDS_MeshFace * toReturn=NULL;
toReturn = const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3));
if(toReturn==NULL)
{
if(toReturn==NULL) {
toReturn = createTriangle(node1,node2,node3);
}
return toReturn;
}
//=======================================================================
//function : FindFace
//purpose :
//=======================================================================
const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2, int idnode3,
int idnode4) const
const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2,
int idnode3, int idnode4) const
{
const SMDS_MeshNode * node1=FindNode(idnode1);
const SMDS_MeshNode * node2=FindNode(idnode2);
const SMDS_MeshNode * node3=FindNode(idnode3);
const SMDS_MeshNode * node4=FindNode(idnode4);
if((node1==NULL)||(node2==NULL)||(node3==NULL)||(node4==NULL)) return NULL;
if( (node1==NULL) || (node2==NULL) || (node3==NULL) || (node4==NULL) )
return NULL;
return FindFace(node1, node2, node3, node4);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(
const SMDS_MeshNode *node1,
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4)
@ -1342,16 +1400,14 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
const SMDS_MeshElement * node;
bool node2found, node3found, node4found;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more())
{
while(it1->more()) {
face = static_cast<const SMDS_MeshFace *>(it1->next());
if(face->NbNodes()!=4) continue;
SMDS_ElemIteratorPtr it2 = face->nodesIterator();
node2found = false;
node3found = false;
node4found = false;
while(it2->more())
{
while(it2->more()) {
node=it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
@ -1363,21 +1419,128 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(
return NULL;
}
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
const SMDS_MeshNode *node1,
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4)
{
SMDS_MeshFace * toReturn=NULL;
toReturn=const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3,node4));
if(toReturn==NULL)
{
if(toReturn==NULL) {
toReturn=createQuadrangle(node1,node2,node3,node4);
}
return toReturn;
}
//=======================================================================
//function : FindFace
//purpose :quadratic triangle
//=======================================================================
const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2,
int idnode3, int idnode4,
int idnode5, int idnode6) const
{
const SMDS_MeshNode * node1 = FindNode(idnode1);
const SMDS_MeshNode * node2 = FindNode(idnode2);
const SMDS_MeshNode * node3 = FindNode(idnode3);
const SMDS_MeshNode * node4 = FindNode(idnode4);
const SMDS_MeshNode * node5 = FindNode(idnode5);
const SMDS_MeshNode * node6 = FindNode(idnode6);
if( (node1==NULL) || (node2==NULL) || (node3==NULL) ||
(node4==NULL) || (node5==NULL) || (node6==NULL) ) return NULL;
return FindFace(node1, node2, node3, node4, node5, node6);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4,
const SMDS_MeshNode *node5,
const SMDS_MeshNode *node6)
{
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) {
face = static_cast<const SMDS_MeshFace*>(it1->next());
if(face->NbNodes()!=6) continue;
SMDS_ElemIteratorPtr it2 = face->nodesIterator();
int tmp = 0;
while(it2->more()) {
node = it2->next();
if(node->GetID()==node2->GetID()) tmp++;
if(node->GetID()==node3->GetID()) tmp++;
if(node->GetID()==node4->GetID()) tmp++;
if(node->GetID()==node5->GetID()) tmp++;
if(node->GetID()==node6->GetID()) tmp++;
}
if( tmp==5 )
return static_cast<const SMDS_MeshFace*>(face);
}
return NULL;
}
//=======================================================================
//function : FindFace
//purpose : quadratic quadrangle
//=======================================================================
const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2,
int idnode3, int idnode4,
int idnode5, int idnode6,
int idnode7, int idnode8) const
{
const SMDS_MeshNode * node1 = FindNode(idnode1);
const SMDS_MeshNode * node2 = FindNode(idnode2);
const SMDS_MeshNode * node3 = FindNode(idnode3);
const SMDS_MeshNode * node4 = FindNode(idnode4);
const SMDS_MeshNode * node5 = FindNode(idnode5);
const SMDS_MeshNode * node6 = FindNode(idnode6);
const SMDS_MeshNode * node7 = FindNode(idnode7);
const SMDS_MeshNode * node8 = FindNode(idnode8);
if( (node1==NULL) || (node2==NULL) || (node3==NULL) || (node4==NULL) ||
(node5==NULL) || (node6==NULL) || (node7==NULL) || (node8==NULL) )
return NULL;
return FindFace(node1, node2, node3, node4, node5, node6, node7, node8);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4,
const SMDS_MeshNode *node5,
const SMDS_MeshNode *node6,
const SMDS_MeshNode *node7,
const SMDS_MeshNode *node8)
{
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
while(it1->more()) {
face = static_cast<const SMDS_MeshFace *>(it1->next());
if(face->NbNodes()!=8) continue;
SMDS_ElemIteratorPtr it2 = face->nodesIterator();
int tmp = 0;
while(it2->more()) {
node = it2->next();
if(node->GetID()==node2->GetID()) tmp++;
if(node->GetID()==node3->GetID()) tmp++;
if(node->GetID()==node4->GetID()) tmp++;
if(node->GetID()==node5->GetID()) tmp++;
if(node->GetID()==node6->GetID()) tmp++;
if(node->GetID()==node7->GetID()) tmp++;
if(node->GetID()==node8->GetID()) tmp++;
}
if( tmp==7 )
return face;
}
return NULL;
}
//=======================================================================
//function : FindElement
//purpose :

View File

@ -378,7 +378,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,
@ -399,7 +399,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,
@ -456,11 +456,19 @@ public:
const SMDS_MeshNode *FindNode(int idnode) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const;
const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2, int idnode3) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3,
int idnode4, int idnode5, int idnode6) const;
const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4,
int idnode5, int idnode6, int idnode7, int idnode8) const;
const SMDS_MeshElement *FindElement(int IDelem) const;
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2);
static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n2,
const SMDS_MeshNode * n3);
static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3);
@ -468,6 +476,20 @@ public:
const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4);
static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1,
const SMDS_MeshNode *n2,
const SMDS_MeshNode *n3,
const SMDS_MeshNode *n4,
const SMDS_MeshNode *n5,
const SMDS_MeshNode *n6);
static const SMDS_MeshFace* FindFace(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_MeshFace *FindFace(std::vector<int> nodes_ids) const;
static const SMDS_MeshFace* FindFace(std::vector<const SMDS_MeshNode *> nodes);

View File

@ -218,7 +218,7 @@ bool SMDS_MeshElement::IsQuadratic() const
return false;
}
bool SMDS_MeshElement::IsMediumNode(class SMDS_MeshNode* node) const
bool SMDS_MeshElement::IsMediumNode(const SMDS_MeshNode* node) const
{
return false;
}

View File

@ -82,7 +82,7 @@ public:
virtual bool IsPoly() const { return false; };
virtual bool IsQuadratic() const;
virtual bool IsMediumNode(class SMDS_MeshNode* node) const;
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *);
friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem);

View File

@ -970,7 +970,8 @@ bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, doub
XYZ aVec13( p3 - p1 );
XYZ cross = aVec12.Crossed( aVec13 );
if ( myFaceNbNodes == 4 ) {
//if ( myFaceNbNodes == 4 ) {
if ( myFaceNbNodes >3 ) {
XYZ p4 ( myFaceNodes[3] );
XYZ aVec14( p4 - p1 );
XYZ cross2 = aVec13.Crossed( aVec14 );
@ -1144,6 +1145,57 @@ bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
default:;
}
break;
case 10:
{
switch ( minInd ) {
case 0: if( maxInd==4 || maxInd==6 || maxInd==7 ) return true;
case 1: if( maxInd==4 || maxInd==5 || maxInd==8 ) return true;
case 2: if( maxInd==5 || maxInd==6 || maxInd==9 ) return true;
case 3: if( maxInd==7 || maxInd==8 || maxInd==9 ) return true;
default:;
}
break;
}
case 13:
{
switch ( minInd ) {
case 0: if( maxInd==5 || maxInd==8 || maxInd==9 ) return true;
case 1: if( maxInd==5 || maxInd==6 || maxInd==10 ) return true;
case 2: if( maxInd==6 || maxInd==7 || maxInd==11 ) return true;
case 3: if( maxInd==7 || maxInd==8 || maxInd==12 ) return true;
case 4: if( maxInd==9 || maxInd==10 || maxInd==11 || maxInd==12 ) return true;
default:;
}
break;
}
case 15:
{
switch ( minInd ) {
case 0: if( maxInd==6 || maxInd==8 || maxInd==12 ) return true;
case 1: if( maxInd==6 || maxInd==7 || maxInd==13 ) return true;
case 2: if( maxInd==7 || maxInd==8 || maxInd==14 ) return true;
case 3: if( maxInd==9 || maxInd==11 || maxInd==12 ) return true;
case 4: if( maxInd==9 || maxInd==10 || maxInd==13 ) return true;
case 5: if( maxInd==10 || maxInd==11 || maxInd==14 ) return true;
default:;
}
break;
}
case 20:
{
switch ( minInd ) {
case 0: if( maxInd==8 || maxInd==11 || maxInd==16 ) return true;
case 1: if( maxInd==8 || maxInd==9 || maxInd==17 ) return true;
case 2: if( maxInd==9 || maxInd==10 || maxInd==18 ) return true;
case 3: if( maxInd==10 || maxInd==11 || maxInd==19 ) return true;
case 4: if( maxInd==12 || maxInd==15 || maxInd==16 ) return true;
case 5: if( maxInd==12 || maxInd==13 || maxInd==17 ) return true;
case 6: if( maxInd==13 || maxInd==14 || maxInd==18 ) return true;
case 7: if( maxInd==14 || maxInd==15 || maxInd==19 ) return true;
default:;
}
break;
}
default:;
}
return false;
@ -1185,8 +1237,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
typedef map< const SMDS_MeshElement*, int > TElemIntMap;
TElemIntMap volNbShared;
TElemIntMap::iterator vNbIt;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
{
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
const SMDS_MeshNode* n = nodes[ iNode ];
SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator();
while ( eIt->more() ) {
@ -1194,10 +1245,12 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) {
int nbShared = 1;
vNbIt = volNbShared.find( elem );
if ( vNbIt == volNbShared.end() )
if ( vNbIt == volNbShared.end() ) {
volNbShared.insert ( TElemIntMap::value_type( elem, nbShared ));
else
}
else {
nbShared = ++(*vNbIt).second;
}
if ( nbShared > maxNbShared )
maxNbShared = nbShared;
}
@ -1213,8 +1266,7 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
if ( IsFaceExternal( faceIndex ))
intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z );
XYZ p0 ( nodes[0] ), baryCenter;
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ )
{
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
int nbShared = (*vNbIt).second;
if ( nbShared >= 3 ) {
SMDS_VolumeTool volume( (*vNbIt).first );
@ -1226,20 +1278,20 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
// remove a volume from volNbShared map
volNbShared.erase( vNbIt );
}
// here volNbShared contains only volumes laying on the
// opposite side of the face
if ( volNbShared.empty() )
if ( volNbShared.empty() ) {
return free; // is free
}
// check if the whole area of a face is shared
bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ )
{
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
SMDS_VolumeTool volume( (*vNbIt).first );
bool prevLinkShared = false;
int nbSharedLinks = 0;
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
{
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] );
if ( linkShared )
nbSharedLinks++;

View File

@ -29,7 +29,7 @@
using namespace std;
#include "SMESH_2D_Algo.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#include <TopExp.hxx>
#include "utilities.h"
@ -45,6 +45,7 @@ SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
// _compatibleHypothesis.push_back("hypothese_2D_bidon");
_type = ALGO_2D;
gen->_map2D_Algo[hypId] = this;
myCreateQuadratic = false;
}
//=============================================================================
@ -55,6 +56,7 @@ SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen)
SMESH_2D_Algo::~SMESH_2D_Algo()
{
myCreateQuadratic = false;
}
//=============================================================================
@ -80,13 +82,16 @@ int SMESH_2D_Algo::NumberOfWires(const TopoDS_Shape& S)
int SMESH_2D_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W)
{
int nbPoints = 0;
for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next())
{
for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if(myCreateQuadratic)
nb = nb/2;
//SCRUTE(nb);
nbPoints += nb +1; // internal points plus 1 vertex of 2 (last point ?)
}
//SCRUTE(nbPoints);
return nbPoints;
}

View File

@ -30,7 +30,8 @@
#define _SMESH_2D_ALGO_HXX_
#include "SMESH_Algo.hxx"
#include <TopoDS_Wire.hxx>
#include "SMESH_subMesh.hxx"
#include "TopoDS_Wire.hxx"
class SMESH_2D_Algo:
public SMESH_Algo
@ -41,6 +42,9 @@ public:
int NumberOfWires(const TopoDS_Shape& S);
int NumberOfPoints(SMESH_Mesh& aMesh,const TopoDS_Wire& W);
protected:
bool myCreateQuadratic;
};
#endif

View File

@ -29,7 +29,6 @@
using namespace std;
#include "SMESH_3D_Algo.hxx"
#include "SMESH_Gen.hxx"
#include "SMESH_subMesh.hxx"
#include "utilities.h"
@ -56,3 +55,5 @@ SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen)
SMESH_3D_Algo::~SMESH_3D_Algo()
{
}

View File

@ -37,6 +37,7 @@ class SMESH_3D_Algo:
public:
SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen);
virtual ~SMESH_3D_Algo();
};
#endif

View File

@ -33,15 +33,18 @@
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <gp_XY.hxx>
#include <string>
#include <vector>
#include <list>
#include <map>
class SMESH_Gen;
class SMESH_Mesh;
class TopoDS_Face;
class SMESHDS_Mesh;
class SMDS_MeshNode;
class SMESH_Algo:public SMESH_Hypothesis
{
@ -97,6 +100,7 @@ class SMESH_Algo:public SMESH_Hypothesis
std::vector<std::string> _compatibleHypothesis;
std::list<const SMESHDS_Hypothesis *> _appliedHypList;
std::list<const SMESHDS_Hypothesis *> _usedHypList;
};
#endif

View File

@ -861,7 +861,8 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception)
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 3) Nb++;
if ( !curFace->IsPoly() &&
( curFace->NbNodes()==3 || curFace->NbNodes()==6 ) ) Nb++;
}
return Nb;
}
@ -879,7 +880,8 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception)
const SMDS_MeshFace * curFace;
while (itFaces->more()) {
curFace = itFaces->next();
if (!curFace->IsPoly() && curFace->NbNodes() == 4) Nb++;
if ( !curFace->IsPoly() &&
( curFace->NbNodes() == 4 || curFace->NbNodes()==8 ) ) Nb++;
}
return Nb;
}
@ -917,7 +919,8 @@ int SMESH_Mesh::NbTetras() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 4) Nb++;
if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 4 || curVolume->NbNodes()==10 ) ) Nb++;
}
return Nb;
}
@ -931,7 +934,8 @@ int SMESH_Mesh::NbHexas() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 8) Nb++;
if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 8 || curVolume->NbNodes()==20 ) ) Nb++;
}
return Nb;
}
@ -945,7 +949,8 @@ int SMESH_Mesh::NbPyramids() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 5) Nb++;
if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 5 || curVolume->NbNodes()==13 ) ) Nb++;
}
return Nb;
}
@ -959,7 +964,8 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception)
const SMDS_MeshVolume * curVolume;
while (itVolumes->more()) {
curVolume = itVolumes->next();
if (!curVolume->IsPoly() && curVolume->NbNodes() == 6) Nb++;
if ( !curVolume->IsPoly() &&
( curVolume->NbNodes() == 6 || curVolume->NbNodes()==15 ) ) Nb++;
}
return Nb;
}

File diff suppressed because it is too large Load Diff

View File

@ -388,6 +388,35 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds()
anActor = myActor;
if (anActor != 0)
{
// skl 07.02.2006
SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh();
if( myFilterType == SMESHGUI_TriaFilter ||
myFilterType == SMESHGUI_QuadFilter ||
myFilterType == SMESHGUI_FaceFilter ) {
SMDS_FaceIteratorPtr it = aMesh->facesIterator();
while(it->more()) {
const SMDS_MeshFace* f = it->next();
if(myFilterType == SMESHGUI_FaceFilter) {
myIds.Add(f->GetID());
}
else if( myFilterType==SMESHGUI_TriaFilter &&
( f->NbNodes()==3 || f->NbNodes()==6 ) ) {
myIds.Add(f->GetID());
}
else if( myFilterType==SMESHGUI_QuadFilter &&
( f->NbNodes()==4 || f->NbNodes()==8 ) ) {
myIds.Add(f->GetID());
}
}
}
else if(myFilterType == SMESHGUI_VolumeFilter) {
SMDS_VolumeIteratorPtr it = aMesh->volumesIterator();
while(it->more()) {
const SMDS_MeshVolume* f = it->next();
myIds.Add(f->GetID());
}
}
/* commented by skl 07.02.2006
TVisualObjPtr aVisualObj = anActor->GetObject();
vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid();
if (aGrid != 0) {
@ -411,6 +440,7 @@ SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds()
}
}
}
*/
}
}

View File

@ -51,6 +51,7 @@ EXPORT_HEADERS = \
StdMeshers_AutomaticLength.hxx \
StdMeshers_Distribution.hxx \
StdMeshers_QuadranglePreference.hxx \
StdMeshers_Helper.hxx \
StdMeshers_QuadraticMesh.hxx
EXPORT_PYSCRIPTS =
@ -78,6 +79,7 @@ LIB_SRC = \
StdMeshers_AutomaticLength.cxx \
StdMeshers_Distribution.cxx \
StdMeshers_QuadranglePreference.cxx \
StdMeshers_Helper.cxx \
StdMeshers_QuadraticMesh.cxx
LIB_SERVER_IDL =

View File

@ -0,0 +1,433 @@
// File: StdMeshers_Helper.cxx
// Created: 15.02.06 15:22:41
// Author: Sergey KUUL
// Copyright: Open CASCADE 2006
#include "StdMeshers_Helper.hxx"
#include "TopTools_MapOfShape.hxx"
#include "BRepTools.hxx"
#include "BRepTools_WireExplorer.hxx"
#include "SMDS_FacePosition.hxx"
#include "SMDS_EdgePosition.hxx"
#include "SMESH_subMesh.hxx"
#include "Geom2d_Curve.hxx"
#include "Geom_Curve.hxx"
#include "Geom_Surface.hxx"
#include "BRep_Tool.hxx"
#include "gp_Pnt2d.hxx"
//=======================================================================
//function : CheckShape
//purpose :
//=======================================================================
bool StdMeshers_Helper::IsQuadraticSubMesh(const TopoDS_Shape& aSh,
const bool QuadMode)
{
SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS();
myShapeID = meshDS->ShapeToIndex(aSh);
myCreateQuadratic = false;
if(QuadMode) {
// we can create quadratic elements only if each elements
// created on given shape is quadratic
// also we have to fill myNLinkNodeMap
myCreateQuadratic = true;
if(aSh.ShapeType()!=TopAbs_FACE) {
for (TopExp_Explorer exp(aSh, TopAbs_FACE); exp.More() && myCreateQuadratic; exp.Next()) {
const TopoDS_Face& F = TopoDS::Face(exp.Current());
SMDS_ElemIteratorPtr itf = GetMesh()->GetSubMesh(F)->GetSubMeshDS()->GetElements();
while(itf->more()) {
const SMDS_MeshElement* f = itf->next();
if( f->GetType()==SMDSAbs_Face && !f->IsQuadratic() ) {
myCreateQuadratic = false;
break;
}
SMDS_ElemIteratorPtr itn = f->nodesIterator();
if(f->NbNodes()==6) {
const SMDS_MeshNode* Ns[6];
int i = 0;
while(itn->more()) {
Ns[i++] = static_cast<const SMDS_MeshNode*>( itn->next() );
}
AddNLinkNode(Ns[0],Ns[1],Ns[3]);
AddNLinkNode(Ns[1],Ns[2],Ns[4]);
AddNLinkNode(Ns[2],Ns[0],Ns[5]);
}
else if(f->NbNodes()==8) {
const SMDS_MeshNode* Ns[8];
int i = 0;
while(itn->more()) {
Ns[i++] = static_cast<const SMDS_MeshNode*>( itn->next() );
}
AddNLinkNode(Ns[0],Ns[1],Ns[4]);
AddNLinkNode(Ns[1],Ns[2],Ns[5]);
AddNLinkNode(Ns[2],Ns[3],Ns[6]);
AddNLinkNode(Ns[3],Ns[0],Ns[7]);
}
}
}
}
else {
TopTools_MapOfShape aMap;
// check edges
const TopoDS_Face& F = TopoDS::Face(aSh);
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
for (wexp.Init(W, F); wexp.More() && myCreateQuadratic; wexp.Next()) {
const TopoDS_Edge& E = wexp.Current();
if(aMap.Contains(E))
continue;
aMap.Add(E);
SMDS_ElemIteratorPtr it = GetMesh()->GetSubMesh(E)->GetSubMeshDS()->GetElements();
while(it->more()) {
const SMDS_MeshElement* e = it->next();
if( e->GetType()==SMDSAbs_Edge && !e->IsQuadratic() ) {
myCreateQuadratic = false;
break;
}
// fill NLinkNodeMap
SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3));
myNLinkNodeMap[link] = n3;
}
}
}
}
if(!myCreateQuadratic) {
myNLinkNodeMap.clear();
}
return myCreateQuadratic;
}
//=======================================================================
//function : IsMedium
//purpose :
//=======================================================================
bool StdMeshers_Helper::IsMedium(const SMDS_MeshNode* n)
{
SMDS_ElemIteratorPtr it = n->GetInverseElementIterator();
while (it->more()) {
const SMDS_MeshElement* elem = it->next();
return elem->IsMediumNode(n);
}
return false;
}
//=======================================================================
//function : AddNLinkNode
//purpose :
//=======================================================================
/*!
* Auxilary function for filling myNLinkNodeMap
*/
void StdMeshers_Helper::AddNLinkNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n12)
{
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
ItNLinkNode itLN = myNLinkNodeMap.find( link );
if ( itLN == myNLinkNodeMap.end() ) {
// add new record to map
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
}
}
//=======================================================================
//function : GetNodeUV
//purpose :
//=======================================================================
/*!
* Auxilary function for GetMediumNode()
*/
gp_XY StdMeshers_Helper::GetNodeUV(const TopoDS_Face& F,
const SMDS_MeshNode* n)
{
gp_Pnt2d p2d;
const SMDS_PositionPtr Pos = n->GetPosition();
if(Pos->GetTypeOfPosition()==SMDS_TOP_FACE) {
//cout<<"face"<<endl;
// node has position on face
const SMDS_FacePosition* fpos =
static_cast<const SMDS_FacePosition*>(n->GetPosition().get());
p2d = gp_Pnt2d(fpos->GetUParameter(),fpos->GetVParameter());
//cout<<"fpos->GetUParameter()="<<fpos->GetUParameter()<<" fpos->GetVParameter()="<<fpos->GetVParameter()<<endl;
}
else if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE) {
// node has position on edge => it is needed to find
// corresponding edge from face, get pcurve for this
// edge and recieve value from this pcurve
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(n->GetPosition().get());
double param = epos->GetUParameter();
SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS();
int edgeID = Pos->GetShapeId();
const TopoDS_Edge& E = TopoDS::Edge(meshDS->IndexToShape(edgeID));
double f, l;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
p2d = C2d->Value(param);
}
else { // vertex position
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
const TopoDS_Wire& W = BRepTools::OuterWire(F);
BRepTools_WireExplorer wexp (W, F);
TopoDS_Edge E;
for (wexp.Init(W, F); wexp.More(); wexp.Next()) {
E = wexp.Current();
TopoDS_Vertex V1 = TopExp::FirstVertex(E);
TopoDS_Vertex V2 = TopExp::LastVertex(E);
if( meshDS->ShapeToIndex(V1) != Pos->GetShapeId() &&
meshDS->ShapeToIndex(V2) != Pos->GetShapeId() ) continue;
double f2, l2;
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f2, l2);
double f, l;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, L, f, l);
gp_Pnt P = C->Value(f);
if(!L.IsIdentity()) P = P.Transformed(L.Transformation());
double tol = BRep_Tool::Tolerance(E);
double dx = n->X() - P.X();
double dy = n->Y() - P.Y();
double dz = n->Z() - P.Z();
double dist = sqrt(dx*dx + dy*dy + dz*dz);
if(dist<tol) {
p2d = C2d->Value(f2);
}
else {
p2d = C2d->Value(l2);
}
}
}
return p2d.XY();
}
//=======================================================================
//function : GetMediumNode
//purpose :
//=======================================================================
/*!
* Special function for search or creation medium node
*/
const SMDS_MeshNode* StdMeshers_Helper::GetMediumNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const bool force3d)
{
//cout<<"n1: "<<n1;
//cout<<"n2: "<<n2;
NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
ItNLinkNode itLN = myNLinkNodeMap.find( link );
if ( itLN != myNLinkNodeMap.end() ) {
return (*itLN).second;
}
else {
// create medium node
SMDS_MeshNode* n12;
SMESHDS_Mesh* meshDS = GetMesh()->GetMeshDS();
if(!force3d) {
// we try to create medium node using UV parameters of
// nodes, else - medium between corresponding 3d points
const SMDS_PositionPtr Pos1 = n1->GetPosition();
const SMDS_PositionPtr Pos2 = n2->GetPosition();
int faceID = -1;
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos1->GetShapeId();
}
else if( Pos2->GetTypeOfPosition()==SMDS_TOP_FACE ) {
faceID = Pos2->GetShapeId();
}
if(faceID>-1) {
TopoDS_Face F = TopoDS::Face(meshDS->IndexToShape(faceID));
gp_XY p1 = GetNodeUV(F,n1);
gp_XY p2 = GetNodeUV(F,n2);
double u = (p1.X()+p2.X())/2.;
double v = (p1.Y()+p2.Y())/2.;
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
gp_Pnt P = S->Value(u, v);
n12 = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnFace(n12, faceID, u, v);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
}
// 3d variant
double x = ( n1->X() + n2->X() )/2.;
double y = ( n1->Y() + n2->Y() )/2.;
double z = ( n1->Z() + n2->Z() )/2.;
n12 = meshDS->AddNode(x,y,z);
meshDS->SetNodeInVolume(n12, myShapeID);
myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n12));
return n12;
}
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
/*!
* Special function for creation quadratic triangle
*/
SMDS_MeshFace* StdMeshers_Helper::AddFace(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3)
{
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
if(!myCreateQuadratic) {
return meshDS->AddFace(n1, n2, n3);
}
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,false);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,false);
const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,false);
return meshDS->AddFace(n1, n2, n3, n12, n23, n31);
}
//=======================================================================
//function : AddFace
//purpose :
//=======================================================================
/*!
* Special function for creation quadratic quadrangle
*/
SMDS_MeshFace* StdMeshers_Helper::AddFace(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4)
{
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
if(!myCreateQuadratic) {
return meshDS->AddFace(n1, n2, n3, n4);
}
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,false);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,false);
const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,false);
const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,false);
return meshDS->AddFace(n1, n2, n3, n4, n12, n23, n34, n41);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
/*!
* Special function for creation quadratic volume
*/
SMDS_MeshVolume* StdMeshers_Helper::AddVolume(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4,
const SMDS_MeshNode* n5,
const SMDS_MeshNode* n6)
{
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
if(!myCreateQuadratic) {
return meshDS->AddVolume(n1, n2, n3, n4, n5, n6);
}
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,true);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,true);
const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,true);
const SMDS_MeshNode* n45 = GetMediumNode(n4,n5,true);
const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,true);
const SMDS_MeshNode* n64 = GetMediumNode(n6,n4,true);
const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,true);
const SMDS_MeshNode* n25 = GetMediumNode(n2,n5,true);
const SMDS_MeshNode* n36 = GetMediumNode(n3,n6,true);
return meshDS->AddVolume(n1, n2, n3, n4, n5, n6,
n12, n23, n31, n45, n56, n64, n14, n25, n36);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
/*!
* Special function for creation quadratic volume
*/
SMDS_MeshVolume* StdMeshers_Helper::AddVolume(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4)
{
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
if(!myCreateQuadratic) {
return meshDS->AddVolume(n1, n2, n3, n4);
}
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,true);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,true);
const SMDS_MeshNode* n31 = GetMediumNode(n3,n1,true);
const SMDS_MeshNode* n14 = GetMediumNode(n1,n4,true);
const SMDS_MeshNode* n24 = GetMediumNode(n2,n4,true);
const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,true);
return meshDS->AddVolume(n1, n2, n3, n4, n12, n23, n31, n14, n24, n34);
}
//=======================================================================
//function : AddVolume
//purpose :
//=======================================================================
/*!
* Special function for creation quadratic volume
*/
SMDS_MeshVolume* StdMeshers_Helper::AddVolume(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)
{
SMESHDS_Mesh * meshDS = GetMesh()->GetMeshDS();
if(!myCreateQuadratic) {
return meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8);
}
const SMDS_MeshNode* n12 = GetMediumNode(n1,n2,true);
const SMDS_MeshNode* n23 = GetMediumNode(n2,n3,true);
const SMDS_MeshNode* n34 = GetMediumNode(n3,n4,true);
const SMDS_MeshNode* n41 = GetMediumNode(n4,n1,true);
const SMDS_MeshNode* n56 = GetMediumNode(n5,n6,true);
const SMDS_MeshNode* n67 = GetMediumNode(n6,n7,true);
const SMDS_MeshNode* n78 = GetMediumNode(n7,n8,true);
const SMDS_MeshNode* n85 = GetMediumNode(n8,n5,true);
const SMDS_MeshNode* n15 = GetMediumNode(n1,n5,true);
const SMDS_MeshNode* n26 = GetMediumNode(n2,n6,true);
const SMDS_MeshNode* n37 = GetMediumNode(n3,n7,true);
const SMDS_MeshNode* n48 = GetMediumNode(n4,n8,true);
return meshDS->AddVolume(n1, n2, n3, n4, n5, n6, n7, n8,
n12, n23, n34, n41, n56, n67,
n78, n85, n15, n26, n37, n48);
}

View File

@ -0,0 +1,149 @@
// File: StdMeshers_Helper.hxx
// Created: 15.02.06 14:48:09
// Author: Sergey KUUL
// Copyright: Open CASCADE 2006
#ifndef StdMeshers_Helper_HeaderFile
#define StdMeshers_Helper_HeaderFile
#include <SMESH_Mesh.hxx>
#include <TopoDS_Shape.hxx>
#include <SMDS_MeshNode.hxx>
#include <TopoDS_Face.hxx>
#include <gp_XY.hxx>
#include <map>
typedef pair<const SMDS_MeshNode*, const SMDS_MeshNode*> NLink;
typedef map<NLink, const SMDS_MeshNode*> NLinkNodeMap;
typedef map<NLink, const SMDS_MeshNode*>::iterator ItNLinkNode;
/// Class StdMeshers_Helper
//
class StdMeshers_Helper
{
public:
// ---------- PUBLIC METHODS ----------
/// Empty constructor
StdMeshers_Helper(SMESH_Mesh& theMesh)
{ myMesh=(void *)&theMesh; myCreateQuadratic = false; }
SMESH_Mesh* GetMesh() const
{ return (SMESH_Mesh*)myMesh; }
/// Copy constructor
//Standard_EXPORT StdMeshers_Helper (const StdMeshers_Helper& theOther);
/// Destructor
//Standard_EXPORT virtual ~StdMeshers_Helper ();
/**
* Check submesh for given shape
* If QuadMode is true: check if all elements on this shape
* are quadratic, if yes => set true to myCreateQuadratic
* (default value is false). Also fill myNLinkNodeMap
* Returns myCreateQuadratic
*/
bool IsQuadraticSubMesh(const TopoDS_Shape& aSh, const bool QuadMode);
/**
* Returns true if given node is medium
*/
bool IsMedium(const SMDS_MeshNode* n);
/**
* Auxilary function for filling myNLinkNodeMap
*/
void AddNLinkNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n12);
/**
* Auxilary function for filling myNLinkNodeMap
*/
void AddNLinkNodeMap(const NLinkNodeMap& aMap)
{ myNLinkNodeMap.insert(aMap.begin(), aMap.end()); }
/**
* Returns myNLinkNodeMap
*/
const NLinkNodeMap& GetNLinkNodeMap() { return myNLinkNodeMap; }
/**
* Auxilary function for GetMediumNode()
*/
gp_XY GetNodeUV(const TopoDS_Face& F,
const SMDS_MeshNode* n);
/**
* Special function for search or creation medium node
*/
const SMDS_MeshNode* GetMediumNode(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const bool force3d);
/**
* Special function for creation quadratic triangle
*/
SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3);
/**
* Special function for creation quadratic quadrangle
*/
SMDS_MeshFace* AddFace(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4);
/**
* Special function for creation quadratic tetraahedron
*/
SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4);
/**
* Special function for creation quadratic pentahedron
*/
SMDS_MeshVolume* AddVolume(const SMDS_MeshNode* n1,
const SMDS_MeshNode* n2,
const SMDS_MeshNode* n3,
const SMDS_MeshNode* n4,
const SMDS_MeshNode* n5,
const SMDS_MeshNode* n6);
/**
* Special function for creation quadratic hexahedron
*/
SMDS_MeshVolume* AddVolume(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);
private:
void* myMesh;
int myShapeID;
// Key for creation quadratic faces
bool myCreateQuadratic;
// special map for using during creation quadratic faces
NLinkNodeMap myNLinkNodeMap;
};
#endif

View File

@ -45,6 +45,7 @@ using namespace std;
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
@ -146,6 +147,7 @@ static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int&
return true;
}
//=============================================================================
/*!
* Hexahedron mesh on hexaedron like form
@ -173,15 +175,18 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// 0.1 - shape must be a solid (or a shell) with 6 faces
//MESSAGE("---");
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
vector < SMESH_subMesh * >meshFaces;
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next())
{
for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current());
ASSERT(aSubMesh);
meshFaces.push_back(aSubMesh);
}
if (meshFaces.size() != 6)
{
if (meshFaces.size() != 6) {
SCRUTE(meshFaces.size());
// ASSERT(0);
return false;
@ -190,8 +195,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges)
//MESSAGE("---");
for (int i = 0; i < 6; i++)
{
for (int i = 0; i < 6; i++) {
TopoDS_Shape aFace = meshFaces[i]->GetSubShape();
SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace);
string algoName = algo->GetName();
@ -201,8 +205,10 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
if ( sm ) {
isAllQuad = true;
SMDS_ElemIteratorPtr eIt = sm->GetElements();
while ( isAllQuad && eIt->more() )
isAllQuad = ( eIt->next()->NbNodes() == 4 );
while ( isAllQuad && eIt->more() ) {
const SMDS_MeshElement* elem = eIt->next();
isAllQuad = ( elem->NbNodes()==4 ||(myCreateQuadratic && elem->NbNodes()==8) );
}
}
}
if ( ! isAllQuad ) {
@ -221,13 +227,15 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
StdMeshers_Quadrangle_2D *quadAlgo =
dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
ASSERT(quadAlgo);
try
{
_quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace);
try {
_quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace, myCreateQuadratic);
// add links created in quadAlgo into myNLinkNodeMap
// NLinkNodeMap aMap = quadAlgo->GetNLinkNodeMap();
// myNLinkNodeMap.insert(aMap.begin(), aMap.end());
myTool->AddNLinkNodeMap(quadAlgo->GetNLinkNodeMap());
// *** to delete after usage
}
catch(SALOME_Exception & S_ex)
{
catch(SALOME_Exception & S_ex) {
// *** delete _quads
// *** throw exception
// ASSERT(0);
@ -236,8 +244,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// 0.2.1 - number of points on the opposite edges must be the same
if (_quads[i]->nbPts[0] != _quads[i]->nbPts[2] ||
_quads[i]->nbPts[1] != _quads[i]->nbPts[3])
{
_quads[i]->nbPts[1] != _quads[i]->nbPts[3]) {
MESSAGE("different number of points on the opposite edges of face " << i);
// ASSERT(0);
return false;
@ -266,16 +273,13 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
TopoDS_Vertex VFirst, VLast;
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
bool isForward =
(((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
bool isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0);
if (isForward)
{
if (isForward) {
_cube.V000 = VFirst; // will be (0,0,0) on the unit cube
_cube.V100 = VLast; // will be (1,0,0) on the unit cube
}
else
{
else {
_cube.V000 = VLast;
_cube.V100 = VFirst;
}
@ -420,20 +424,19 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes();
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int j = cx0.ia * i1 + cx0.ib * j1 + cx0.ic; // j = x/face
int k = cx0.ja * i1 + cx0.jb * j1 + cx0.jc; // k = y/face
@ -454,17 +457,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int j = cx1.ia * i1 + cx1.ib * j1 + cx1.ic; // j = x/face
int k = cx1.ja * i1 + cx1.jb * j1 + cx1.jc; // k = y/face
@ -485,17 +488,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int i = cy0.ia * i1 + cy0.ib * j1 + cy0.ic; // i = x/face
int k = cy0.ja * i1 + cy0.jb * j1 + cy0.jc; // k = y/face
@ -516,17 +519,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int i = cy1.ia * i1 + cy1.ib * j1 + cy1.ic; // i = x/face
int k = cy1.ja * i1 + cy1.jb * j1 + cy1.jc; // k = y/face
@ -547,17 +550,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int i = cz0.ia * i1 + cz0.ib * j1 + cz0.ic; // i = x/face
int j = cz0.ja * i1 + cz0.jb * j1 + cz0.jc; // j = y/face
@ -578,17 +581,17 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int nbdown = quad->nbPts[0];
int nbright = quad->nbPts[1];
while(itf->more())
{
while(itf->more()) {
const SMDS_MeshNode * node = itf->next();
if(myTool->IsMedium(node))
continue;
findIJ( node, quad, i1, j1 );
int ij1 = j1 * nbdown + i1;
quad->uv_grid[ij1].node = node;
}
for (int i1 = 0; i1 < nbdown; i1++)
for (int j1 = 0; j1 < nbright; j1++)
{
for (int j1 = 0; j1 < nbright; j1++) {
int ij1 = j1 * nbdown + i1;
int i = cz1.ia * i1 + cz1.ib * j1 + cz1.ic; // i = x/face
int j = cz1.ja * i1 + cz1.jb * j1 + cz1.jc; // j = y/face
@ -623,12 +626,9 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
GetPoint(p110, nbx - 1, nby - 1, 0, nbx, nby, nbz, np, meshDS);
GetPoint(p111, nbx - 1, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS);
for (int i = 1; i < nbx - 1; i++)
{
for (int j = 1; j < nby - 1; j++)
{
for (int k = 1; k < nbz - 1; k++)
{
for (int i = 1; i < nbx - 1; i++) {
for (int j = 1; j < nby - 1; j++) {
for (int k = 1; k < nbz - 1; k++) {
// *** seulement maillage regulier
// 12 points on edges
GetPoint(px00, i, 0, 0, nbx, nby, nbz, np, meshDS);
@ -660,10 +660,8 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
double z = double (k) / double (nbz - 1); // *** regulier
Pt3 X;
for (int i = 0; i < 3; i++)
{
X[i] =
(1 - x) * p0yz[i] + x * p1yz[i]
for (int i = 0; i < 3; i++) {
X[i] = (1 - x) * p0yz[i] + x * p1yz[i]
+ (1 - y) * px0z[i] + y * px1z[i]
+ (1 - z) * pxy0[i] + z * pxy1[i]
- (1 - x) * ((1 - y) * p00z[i] + y * p01z[i])
@ -688,9 +686,8 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
// find orientation of furute volumes according to MED convention
vector< bool > forward( nbx * nby );
SMDS_VolumeTool vTool;
for (int i = 0; i < nbx - 1; i++)
for (int j = 0; j < nby - 1; j++)
{
for (int i = 0; i < nbx - 1; i++) {
for (int j = 0; j < nby - 1; j++) {
int n1 = j * nbx + i;
int n2 = j * nbx + i + 1;
int n3 = (j + 1) * nbx + i + 1;
@ -705,16 +702,15 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
vTool.Set( &tmpVol );
forward[ n1 ] = vTool.IsForward();
}
}
//2.1 - for each node of the cube (less 3 *1 Faces):
// - store hexahedron in SMESHDS
MESSAGE("Storing hexahedron into the DS");
for (int i = 0; i < nbx - 1; i++)
for (int j = 0; j < nby - 1; j++)
{
for (int i = 0; i < nbx - 1; i++) {
for (int j = 0; j < nby - 1; j++) {
bool isForw = forward.at( j * nbx + i );
for (int k = 0; k < nbz - 1; k++)
{
for (int k = 0; k < nbz - 1; k++) {
int n1 = k * nbx * nby + j * nbx + i;
int n2 = k * nbx * nby + j * nbx + i + 1;
int n3 = k * nbx * nby + (j + 1) * nbx + i + 1;
@ -725,28 +721,31 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh,
int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i;
SMDS_MeshVolume * elt;
if ( isForw )
elt = meshDS->AddVolume(np[n1].node,
np[n2].node,
np[n3].node,
np[n4].node,
np[n5].node,
np[n6].node,
np[n7].node,
np[n8].node);
else
elt = meshDS->AddVolume(np[n1].node,
np[n4].node,
np[n3].node,
np[n2].node,
np[n5].node,
np[n8].node,
np[n7].node,
np[n6].node);
if ( isForw ) {
//elt = meshDS->AddVolume(np[n1].node, np[n2].node,
// np[n3].node, np[n4].node,
// np[n5].node, np[n6].node,
// np[n7].node, np[n8].node);
elt = myTool->AddVolume(np[n1].node, np[n2].node,
np[n3].node, np[n4].node,
np[n5].node, np[n6].node,
np[n7].node, np[n8].node);
}
else {
//elt = meshDS->AddVolume(np[n1].node, np[n4].node,
// np[n3].node, np[n2].node,
// np[n5].node, np[n8].node,
// np[n7].node, np[n6].node);
elt = myTool->AddVolume(np[n1].node, np[n4].node,
np[n3].node, np[n2].node,
np[n5].node, np[n8].node,
np[n7].node, np[n6].node);
}
meshDS->SetMeshElementOnShape(elt, shapeID);
}
}
}
if ( np ) delete [] np;
//MESSAGE("End of StdMeshers_Hexa_3D::Compute()");
return true;
@ -1066,3 +1065,4 @@ bool ComputePentahedralMesh(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
return bOK;
}

View File

@ -35,6 +35,8 @@
#include "StdMeshers_Quadrangle_2D.hxx"
#include "Utils_SALOME_Exception.hxx"
#include "StdMeshers_Helper.hxx"
typedef struct point3Dstruct
{
const SMDS_MeshNode * node;
@ -135,6 +137,9 @@ protected:
int _indY1;
int _indZ0;
int _indZ1;
bool myCreateQuadratic;
StdMeshers_Helper* myTool; // toll for working with quadratic elements
};
#endif

View File

@ -220,17 +220,20 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
int iw = 1;
int nbpnt = 0;
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
myOuterWire = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, myOuterWire);
if ( nbpnt < 3 ) // ex: a circle with 2 segments
return false;
nudslf[iw++] = nbpnt;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) {
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!myOuterWire.IsSame(W))
{
if (!myOuterWire.IsSame(W)) {
nbpnt += NumberOfPoints(aMesh, W);
nudslf[iw++] = nbpnt;
}
@ -352,7 +355,8 @@ static bool fixCommonVertexUV (gp_Pnt2d & theUV,
const TopoDS_Wire& theOW,
const TopoDS_Face& theF,
const TopTools_IndexedDataMapOfShapeListOfShape & theVWMap,
SMESH_Mesh & theMesh)
SMESH_Mesh & theMesh,
bool CreateQuadratic)
{
if( theW.IsSame( theOW ) ||
!theVWMap.Contains( theV )) return false;
@ -415,10 +419,25 @@ static bool fixCommonVertexUV (gp_Pnt2d & theUV,
umin = l;
umax = f;
}
else
{
else {
while ( nIt->more() ) {
const SMDS_MeshNode* node = nIt->next();
if(CreateQuadratic) {
// check if node is medium
bool IsMedium = false;
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue;
}
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double u = epos->GetUParameter();
@ -486,8 +505,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD));
BRepTools_WireExplorer wexp(W, F);
for (wexp.Init(W, F), iEdge = 0; wexp.More(); wexp.Next(), iEdge++)
{
for (wexp.Init(W, F), iEdge = 0; wexp.More(); wexp.Next(), iEdge++) {
const TopoDS_Edge & E = wexp.Current();
// --- IDNodes of first and last Vertex
@ -514,6 +532,21 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
// --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
// const SMDS_MeshElement* elem = iter->next();
// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
// const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
// myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3));
// myNLinkNodeMap[link] = n3;
// }
// }
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
double f, l;
@ -524,16 +557,41 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
//bool isForward = (E.Orientation() == TopAbs_FORWARD);
map<double, const SMDS_MeshNode*> params;
while(ite->more())
{
if(!myCreateQuadratic) {
while(ite->more()) {
const SMDS_MeshNode * node = ite->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
if ( nbPoints != params.size())
{
}
else {
nbPoints = nbPoints/2;
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
// check if node is medium
bool IsMedium = false;
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
}
if ( nbPoints != params.size()) {
MESSAGE( "BAD NODE ON EDGE POSITIONS" );
return false;
}
@ -542,10 +600,9 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
// --- load 2D values into MEFISTO structure,
// add IDNodes in mefistoToDS map
if (E.Orientation() == TopAbs_FORWARD)
{
if (E.Orientation() == TopAbs_FORWARD) {
gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale ); // first point = Vertex Forward
if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh ))
if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh, myCreateQuadratic ))
myNodesOnCommonV.push_back( idFirst );
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
@ -554,8 +611,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
//MESSAGE("__ f "<<f<<" "<<uvslf[m].x <<" "<<uvslf[m].y);
m++;
map<double, const SMDS_MeshNode*>::iterator itp = params.begin();
for (int i = 1; i <= nbPoints; i++) // nbPoints internal
{
for (int i = 1; i <= nbPoints; i++) { // nbPoints internal
double param = (*itp).first;
gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale );
uvslf[m].x = p.X();
@ -567,10 +623,9 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
itp++;
}
}
else
{
else {
gp_Pnt2d p = C2d->Value(l).XY().Multiplied( scale ); // last point = Vertex Reversed
if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh ))
if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh, myCreateQuadratic ))
myNodesOnCommonV.push_back( idLast );
uvslf[m].x = p.X();
uvslf[m].y = p.Y();
@ -758,9 +813,11 @@ void StdMeshers_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh,
SMDS_MeshElement * elt;
if (triangleIsWellOriented)
elt = meshDS->AddFace(n1, n2, n3);
//elt = meshDS->AddFace(n1, n2, n3);
elt = myTool->AddFace(n1, n2, n3);
else
elt = meshDS->AddFace(n1, n3, n2);
//elt = meshDS->AddFace(n1, n3, n2);
elt = myTool->AddFace(n1, n3, n2);
meshDS->SetMeshElementOnShape(elt, faceID);
m++;

View File

@ -33,6 +33,8 @@
#include "SMESH_2D_Algo.hxx"
#include <TopoDS_Wire.hxx>
#include "StdMeshers_Helper.hxx"
class SMDS_MeshNode;
class TopTools_IndexedDataMapOfShapeListOfShape;
class TopoDS_Face;
@ -95,6 +97,8 @@ protected:
TopoDS_Wire myOuterWire;
std::list<const SMDS_MeshNode*> myNodesOnCommonV;
StdMeshers_Helper* myTool; // toll for working with quadratic elements
};
#endif

View File

@ -51,6 +51,9 @@
#include <TopoDS_Shell.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Pnt.hxx>
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <stdio.h>
#include <algorithm>
@ -71,6 +74,8 @@ StdMeshers_Penta_3D::StdMeshers_Penta_3D()
myWallNodesMaps.resize( SMESH_Block::NbFaces() );
myShapeXYZ.resize( SMESH_Block::NbSubShapes() );
}
//=======================================================================
//function : Compute
//purpose :
@ -91,12 +96,23 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
if (myErrorStatus){
return bOK;
}
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
//
MakeBlock();
if (myErrorStatus){
return bOK;
}
//
ClearMeshOnFxy1();
if (myErrorStatus) {
return bOK;
}
//
MakeNodes();
if (myErrorStatus){
return bOK;
@ -104,11 +120,6 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
//
MakeConnectingMap();
//
ClearMeshOnFxy1();
if (myErrorStatus) {
return bOK;
}
//
MakeMeshOnFxy1();
if (myErrorStatus) {
return bOK;
@ -118,6 +129,7 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh,
//
return !bOK;
}
//=======================================================================
//function : MakeNodes
//purpose :
@ -148,7 +160,19 @@ void StdMeshers_Penta_3D::MakeNodes()
SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
ASSERT(aSubMesh);
SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS();
if(!myCreateQuadratic) {
iNbN = aSM->NbNodes();
}
else {
iNbN = 0;
SMDS_NodeIteratorPtr itn = aSM->GetNodes();
while(itn->more()) {
const SMDS_MeshNode* aNode = itn->next();
if(myTool->IsMedium(aNode))
continue;
iNbN++;
}
}
myJSize += iNbN;
}
//printf("*** Horizontal: number of nodes summary=%d\n", myJSize);
@ -160,7 +184,19 @@ void StdMeshers_Penta_3D::MakeNodes()
SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
ASSERT(aSubMesh);
SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS();
if(!myCreateQuadratic) {
iNbN = aSM->NbNodes();
}
else {
iNbN = 0;
SMDS_NodeIteratorPtr itn = aSM->GetNodes();
while(itn->more()) {
const SMDS_MeshNode* aNode = itn->next();
if(myTool->IsMedium(aNode))
continue;
iNbN++;
}
}
myISize += iNbN;
}
//printf("*** Vertical: number of nodes on edges and vertices=%d\n", myISize);
@ -181,14 +217,15 @@ void StdMeshers_Penta_3D::MakeNodes()
SMDS_NodeIteratorPtr ite = pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
while(ite->more()) {
const SMDS_MeshNode* aNode = ite->next();
if(myTool->IsMedium(aNode))
continue;
aNodeID=aNode->GetID();
//
aTNode.SetNode(aNode);
aTNode.SetShapeSupportID(aSID);
aTNode.SetBaseNodeID(aNodeID);
//
if ( SMESH_Block::IsEdgeID (aSID))
{
if ( SMESH_Block::IsEdgeID (aSID)) {
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(aNode->GetPosition().get());
myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords );
@ -325,8 +362,7 @@ void StdMeshers_Penta_3D::MakeNodes()
// 3.3 set XYZ of vertices, and initialize of the rest
SMESHDS_Mesh* aMesh = GetMesh()->GetMeshDS();
for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id )
{
for ( int id = SMESH_Block::ID_V000; id < SMESH_Block::ID_Shell; ++id ) {
if ( SMESH_Block::IsVertexID( id )) {
TopoDS_Shape V = myBlock.Shape( id );
SMESHDS_SubMesh* sm = aMesh->MeshElements( V );
@ -344,8 +380,29 @@ void StdMeshers_Penta_3D::MakeNodes()
SMESH_Block::TShapeID aSSID, aBNSSID;
StdMeshers_TNode aTN;
//
for (j=0; j<myJSize; ++j)
{
// create top face and find UV for it's corners
const TopoDS_Face& TopFace = TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
SMESHDS_Mesh* meshDS = pMesh->GetMeshDS();
int topfaceID = meshDS->ShapeToIndex(TopFace);
const TopoDS_Vertex& v001 = TopoDS::Vertex(myBlock.Shape(SMESH_Block::ID_V001));
SMDS_NodeIteratorPtr itn = pMesh->GetSubMeshContaining(v001)->GetSubMeshDS()->GetNodes();
const SMDS_MeshNode* N = itn->next();
gp_XY UV001 = myTool->GetNodeUV(TopFace,N);
const TopoDS_Vertex& v101 = TopoDS::Vertex(myBlock.Shape(SMESH_Block::ID_V101));
itn = pMesh->GetSubMeshContaining(v101)->GetSubMeshDS()->GetNodes();
N = itn->next();
gp_XY UV101 = myTool->GetNodeUV(TopFace,N);
const TopoDS_Vertex& v011 = TopoDS::Vertex(myBlock.Shape(SMESH_Block::ID_V011));
itn = pMesh->GetSubMeshContaining(v011)->GetSubMeshDS()->GetNodes();
N = itn->next();
gp_XY UV011 = myTool->GetNodeUV(TopFace,N);
const TopoDS_Vertex& v111 = TopoDS::Vertex(myBlock.Shape(SMESH_Block::ID_V111));
itn = pMesh->GetSubMeshContaining(v111)->GetSubMeshDS()->GetNodes();
N = itn->next();
gp_XY UV111 = myTool->GetNodeUV(TopFace,N);
for (j=0; j<myJSize; ++j) {
// base node info
const StdMeshers_TNode& aBN = myTNodes[j];
aBNSSID = (SMESH_Block::TShapeID)aBN.ShapeSupportID();
@ -357,10 +414,12 @@ void StdMeshers_Penta_3D::MakeNodes()
// 2 columns for each face, between which a base node is located
vector<const SMDS_MeshNode*>* nColumns[8];
double ratio[4]; // base node position between columns [0.-1.]
if ( createNode )
for ( k = 0; k < 4; ++k )
if ( createNode ) {
for ( k = 0; k < 4; ++k ) {
ratio[ k ] = SetHorizEdgeXYZ (aBNXYZ, wallFaceID[ k ],
nColumns[k*2], nColumns[k*2+1]);
}
}
//
// XYZ on the bottom and top faces
const SMDS_MeshNode* n = aBN.Node();
@ -368,8 +427,9 @@ void StdMeshers_Penta_3D::MakeNodes()
myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( 0., 0., 0. );
//
// first create or find a top node, then the rest ones in a column
for (i=myISize-1; i>0; --i)
{
for (i=myISize-1; i>0; --i) {
bIsUpperLayer = (i==(myISize-1));
gp_XY UV_Ex01, UV_Ex11, UV_E0y1, UV_E1y1;
if ( createNode ) {
// set XYZ on vertical edges and faces
for ( k = 0; k < 4; ++k ) {
@ -377,11 +437,28 @@ void StdMeshers_Penta_3D::MakeNodes()
myShapeXYZ[ verticEdgeID[ k ] ].SetCoord( n->X(), n->Y(), n->Z() );
//
n = (*nColumns[k*2]) [ i ];
gp_XY tmp1;
if( i==myISize-1 ) {
tmp1 = myTool->GetNodeUV(TopFace,n);
tmp1 = ( 1. - ratio[ k ]) * tmp1;
}
gp_XYZ xyz( n->X(), n->Y(), n->Z() );
myShapeXYZ[ wallFaceID[ k ]] = ( 1. - ratio[ k ]) * xyz;
n = (*nColumns[k*2+1]) [ i ];
xyz.SetCoord( n->X(), n->Y(), n->Z() );
myShapeXYZ[ wallFaceID[ k ]] += ratio[ k ] * xyz;
if( i==myISize-1 ) {
gp_XY tmp2 = myTool->GetNodeUV(TopFace,n);
tmp1 += ratio[ k ] * tmp2;
if( k==0 )
UV_Ex01 = tmp1;
else if( k==1 )
UV_Ex11 = tmp1;
else if( k==2 )
UV_E0y1 = tmp1;
else
UV_E1y1 = tmp1;
}
}
}
// fill current node info
@ -395,7 +472,6 @@ void StdMeshers_Penta_3D::MakeNodes()
aCoords.SetCoord(aX, aY, aZ);
//
// suporting shape ID
bIsUpperLayer=(i==(myISize-1));
ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID);
if (myErrorStatus) {
MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
@ -418,6 +494,30 @@ void StdMeshers_Penta_3D::MakeNodes()
if ( bIsUpperLayer ) {
const SMDS_MeshNode* n = aTN.Node();
myShapeXYZ[ SMESH_Block::ID_Fxy1 ].SetCoord( n->X(), n->Y(), n->Z() );
// set node on top face:
// find UV parameter for this node
// UV_Ex11
// UV011+-----+----------+UV111
// | |
// | |
// UV_E0y1+ +node +UV_E1y1
// | |
// | |
// | |
// UV001+-----+----------+UV101
// UV_Ex01
gp_Pnt2d aP;
double u = aCoords.X(), v = aCoords.Y();
double u1 = ( 1. - u ), v1 = ( 1. - v );
aP.ChangeCoord() = UV_Ex01 * v1;
aP.ChangeCoord() += UV_Ex11 * v;
aP.ChangeCoord() += UV_E0y1 * u1;
aP.ChangeCoord() += UV_E1y1 * u;
aP.ChangeCoord() -= UV001 * u1 * v1;
aP.ChangeCoord() -= UV101 * u * v1;
aP.ChangeCoord() -= UV011 * u1 * v;
aP.ChangeCoord() -= UV111 * u * v;
meshDS->SetNodeOnFace((SMDS_MeshNode*)n, topfaceID, aP.X(), aP.Y());
}
}
if (myErrorStatus) {
@ -456,10 +556,13 @@ void StdMeshers_Penta_3D::MakeNodes()
*/
//DEB t
}
//=======================================================================
//function : FindNodeOnShape
//purpose :
//=======================================================================
void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
const gp_XYZ& aParams,
const int z,
@ -476,8 +579,7 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
SMDS_MeshNode* pNode = NULL;
//
if ( aS.ShapeType() == TopAbs_FACE ||
aS.ShapeType() == TopAbs_EDGE )
{
aS.ShapeType() == TopAbs_EDGE ) {
// find a face ID to which aTN belongs to
int faceID;
if ( aS.ShapeType() == TopAbs_FACE )
@ -510,6 +612,8 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
while(ite->more()) {
const SMDS_MeshNode* aNode = ite->next();
if(myTool->IsMedium(aNode))
continue;
aX=aNode->X();
aY=aNode->Y();
aZ=aNode->Z();
@ -532,6 +636,7 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
//myErrorStatus=11; // can not find the node;
}
//=======================================================================
//function : SetHorizEdgeXYZ
//purpose :
@ -583,6 +688,7 @@ double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ& aBase
return r;
}
//=======================================================================
//function : MakeVolumeMesh
//purpose :
@ -628,13 +734,19 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
const SMDS_MeshElement* pE0 = itf->next();
//
int nbFaceNodes = pE0->NbNodes();
if(myCreateQuadratic)
nbFaceNodes = nbFaceNodes/2;
if ( aN.size() < nbFaceNodes * 2 )
aN.resize( nbFaceNodes * 2 );
//
k=0;
aItNodes=pE0->nodesIterator();
while (aItNodes->more()) {
const SMDS_MeshElement* pNode=aItNodes->next();
//const SMDS_MeshElement* pNode = aItNodes->next();
const SMDS_MeshNode* pNode =
static_cast<const SMDS_MeshNode*> (aItNodes->next());
if(myTool->IsMedium(pNode))
continue;
aID0 = pNode->GetID();
aJ[k] = GetIndexOnLayer(aID0);
if (myErrorStatus) {
@ -685,20 +797,30 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
SMDS_MeshVolume* aV = 0;
switch ( nbFaceNodes ) {
case 3:
if ( forward )
aV = meshDS->AddVolume(aN[0], aN[1], aN[2],
aN[3], aN[4], aN[5]);
else
aV = meshDS->AddVolume(aN[0], aN[2], aN[1],
aN[3], aN[5], aN[4]);
if ( forward ) {
//aV = meshDS->AddVolume(aN[0], aN[1], aN[2],
// aN[3], aN[4], aN[5]);
aV = myTool->AddVolume(aN[0], aN[1], aN[2], aN[3], aN[4], aN[5]);
}
else {
//aV = meshDS->AddVolume(aN[0], aN[2], aN[1],
// aN[3], aN[5], aN[4]);
aV = myTool->AddVolume(aN[0], aN[2], aN[1], aN[3], aN[5], aN[4]);
}
break;
case 4:
if ( forward )
aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3],
if ( forward ) {
//aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3],
// aN[4], aN[5], aN[6], aN[7]);
aV = myTool->AddVolume(aN[0], aN[1], aN[2], aN[3],
aN[4], aN[5], aN[6], aN[7]);
else
aV = meshDS->AddVolume(aN[0], aN[3], aN[2], aN[1],
}
else {
//aV = meshDS->AddVolume(aN[0], aN[3], aN[2], aN[1],
// aN[4], aN[7], aN[6], aN[5]);
aV = myTool->AddVolume(aN[0], aN[3], aN[2], aN[1],
aN[4], aN[7], aN[6], aN[5]);
}
break;
default:
continue;
@ -738,21 +860,7 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
itn = aSM0->GetNodes();
aNbNodes = aSM0->NbNodes();
//printf("** aNbNodes=%d\n", aNbNodes);
while(itn->more()) {
const SMDS_MeshNode* aN0=itn->next();
aID0=aN0->GetID();
aJ=GetIndexOnLayer(aID0);
if (myErrorStatus) {
MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
return;
}
//
ij=aLevel*myJSize+aJ;
const StdMeshers_TNode& aTN1=myTNodes[ij];
SMDS_MeshNode* aN1=(SMDS_MeshNode*)aTN1.Node();
//
meshDS->SetNodeOnFace(aN1, aFxy1);
}
//
// set elements on aFxy1
vector<const SMDS_MeshNode*> aNodes1;
@ -765,6 +873,8 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
continue;
}
aNbNodes = pE0->NbNodes();
if(myCreateQuadratic)
aNbNodes = aNbNodes/2;
// if (aNbNodes!=3) {
// continue;
// }
@ -774,7 +884,11 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
k = aNbNodes-1; // reverse a face
aItNodes = pE0->nodesIterator();
while (aItNodes->more()) {
const SMDS_MeshElement* pNode=aItNodes->next();
//const SMDS_MeshElement* pNode = aItNodes->next();
const SMDS_MeshNode* pNode =
static_cast<const SMDS_MeshNode*> (aItNodes->next());
if(myTool->IsMedium(pNode))
continue;
aID0 = pNode->GetID();
aJ = GetIndexOnLayer(aID0);
if (myErrorStatus) {
@ -791,10 +905,12 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
SMDS_MeshFace * face = 0;
switch ( aNbNodes ) {
case 3:
face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
//face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]);
break;
case 4:
face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
//face = meshDS->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]);
break;
default:
continue;
@ -802,6 +918,7 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
meshDS->SetMeshElementOnShape(face, aFxy1);
}
}
//=======================================================================
//function : ClearMeshOnFxy1
//purpose :
@ -838,6 +955,7 @@ int StdMeshers_Penta_3D::GetIndexOnLayer(const int aID)
j=(*aMapIt).second;
return j;
}
//=======================================================================
//function : MakeConnectingMap
//purpose :
@ -852,6 +970,7 @@ void StdMeshers_Penta_3D::MakeConnectingMap()
myConnectingMap[aBNID]=j;
}
}
//=======================================================================
//function : CreateNode
//purpose :
@ -879,8 +998,7 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
// // point inside solid
// myBlock.Point(aParams, aP);
// }
if (bIsUpperLayer)
{
if (bIsUpperLayer) {
double u = aParams.X(), v = aParams.Y();
double u1 = ( 1. - u ), v1 = ( 1. - v );
aP.ChangeCoord() = myShapeXYZ[ SMESH_Block::ID_Ex01 ] * v1;
@ -893,8 +1011,7 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V011 ] * u1 * v;
aP.ChangeCoord() -= myShapeXYZ[ SMESH_Block::ID_V111 ] * u * v;
}
else
{
else {
SMESH_Block::ShellPoint( aParams, myShapeXYZ, aP.ChangeCoord() );
}
//
@ -910,8 +1027,10 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
SMESHDS_Mesh* pMeshDS = pMesh->GetMeshDS();
//
pNode = pMeshDS->AddNode(aX, aY, aZ);
aTN.SetNode(pNode);
}
//=======================================================================
//function : ShapeSupportID
//purpose :
@ -993,7 +1112,7 @@ void StdMeshers_Penta_3D::MakeBlock()
aElementType = pElement->GetType();
if (aElementType==SMDSAbs_Face) {
iNbNodes = pElement->NbNodes();
if (iNbNodes==3) {
if ( iNbNodes==3 || (myCreateQuadratic && iNbNodes==6) ) {
aFTr = aF;
++iCnt;
if (iCnt>1) {
@ -1154,10 +1273,10 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
bool rev1, CumOri = false;
TopExp_Explorer exp( theFace, TopAbs_EDGE );
int nbEdges = 0;
for ( ; exp.More(); exp.Next() )
{
if ( ++nbEdges > 4 )
for ( ; exp.More(); exp.Next() ) {
if ( ++nbEdges > 4 ) {
return false; // more than 4 edges in theFace
}
TopoDS_Edge e = TopoDS::Edge( exp.Current() );
if ( theBaseEdge.IsSame( e ))
continue;
@ -1174,8 +1293,9 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
else
e2 = e;
}
if ( nbEdges < 4 )
return false; // lass than 4 edges in theFace
if ( nbEdges < 4 ) {
return false; // less than 4 edges in theFace
}
// submeshes corresponding to shapes
SMESHDS_SubMesh* smFace = theMesh->MeshElements( theFace );
@ -1200,13 +1320,32 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
return false;
}
if ( sm1->NbNodes() * smb->NbNodes() != smFace->NbNodes() ) {
// check quadratic case
if ( myCreateQuadratic ) {
int n1 = sm1->NbNodes()/2;
int n2 = smb->NbNodes()/2;
int n3 = sm1->NbNodes() - n1;
int n4 = smb->NbNodes() - n2;
int nf = sm1->NbNodes()*smb->NbNodes() - n3*n4;
if( nf != smFace->NbNodes() ) {
MESSAGE( "Wrong nb face nodes: " <<
sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
return false;
}
}
else {
MESSAGE( "Wrong nb face nodes: " <<
sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
return false;
}
}
// IJ size
int vsize = sm1->NbNodes() + 2;
int hsize = smb->NbNodes() + 2;
if(myCreateQuadratic) {
vsize = vsize - sm1->NbNodes()/2 -1;
hsize = hsize - smb->NbNodes()/2 -1;
}
// load nodes from theBaseEdge
@ -1226,12 +1365,15 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
double range = l - f;
SMDS_NodeIteratorPtr nIt = smb->GetNodes();
const SMDS_MeshNode* node;
while ( nIt->more() )
{
while ( nIt->more() ) {
node = nIt->next();
if(myTool->IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
if ( !pos ) return false;
if ( !pos ) {
return false;
}
double u = ( pos->GetUParameter() - f ) / range;
vector<const SMDS_MeshNode*> & nVec = theIJNodes[ u ];
nVec.resize( vsize, nullNode );
@ -1246,19 +1388,21 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
map< double, const SMDS_MeshNode*> sortedNodes; // sort by param on edge
nIt = sm1->GetNodes();
while ( nIt->more() )
{
while ( nIt->more() ) {
node = nIt->next();
if(myTool->IsMedium(node))
continue;
const SMDS_EdgePosition* pos =
dynamic_cast<const SMDS_EdgePosition*>( node->GetPosition().get() );
if ( !pos ) return false;
if ( !pos ) {
return false;
}
sortedNodes.insert( make_pair( pos->GetUParameter(), node ));
}
loadedNodes.insert( nVecf[ vsize - 1 ] = smVft->GetNodes()->next() );
map< double, const SMDS_MeshNode*>::iterator u_n = sortedNodes.begin();
int row = rev1 ? vsize - 1 : 0;
for ( ; u_n != sortedNodes.end(); u_n++ )
{
for ( ; u_n != sortedNodes.end(); u_n++ ) {
if ( rev1 ) row--;
else row++;
loadedNodes.insert( nVecf[ row ] = u_n->second );
@ -1285,8 +1429,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
StdMeshers_IJNodeMap::iterator par_nVec_2 = par_nVec_1;
// loop on columns
int col = 0;
for ( par_nVec_2++; par_nVec_2 != theIJNodes.end(); par_nVec_1++, par_nVec_2++ )
{
for ( par_nVec_2++; par_nVec_2 != theIJNodes.end(); par_nVec_1++, par_nVec_2++ ) {
col++;
row = 0;
const SMDS_MeshNode* n1 = par_nVec_1->second[ row ];
@ -1295,10 +1438,10 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
do {
// look for a face by 2 nodes
face = SMESH_MeshEditor::FindFaceInSet( n1, n2, allFaces, foundFaces );
if ( face )
{
if ( face ) {
int nbFaceNodes = face->NbNodes();
if ( nbFaceNodes > 4 ) {
if ( (!myCreateQuadratic && nbFaceNodes>4) ||
(myCreateQuadratic && nbFaceNodes>8) ) {
MESSAGE(" Too many nodes in a face: " << nbFaceNodes );
return false;
}
@ -1308,6 +1451,8 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
eIt = face->nodesIterator() ;
while ( !found && eIt->more() ) {
node = static_cast<const SMDS_MeshNode*>( eIt->next() );
if(myTool->IsMedium(node))
continue;
found = loadedNodes.insert( node ).second;
if ( !found && node != n1 && node != n2 )
n3 = node;
@ -1320,18 +1465,21 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
par_nVec_2->second[ row ] = node;
foundFaces.insert( face );
n2 = node;
if ( nbFaceNodes == 4 )
if ( nbFaceNodes==4 || (myCreateQuadratic && nbFaceNodes==8) ) {
n1 = par_nVec_1->second[ row ];
}
else if (nbFaceNodes == 3 &&
n3 == par_nVec_1->second[ row ] )
}
else if ( (nbFaceNodes==3 || (myCreateQuadratic && nbFaceNodes==6) ) &&
n3 == par_nVec_1->second[ row ] ) {
n1 = n3;
}
else {
MESSAGE( "Not quad mesh, column "<< col );
return false;
}
}
} while ( face && n1 && n2 );
}
while ( face && n1 && n2 );
if ( row < vsize - 1 ) {
MESSAGE( "Too few nodes in column "<< col <<": "<< row+1);
@ -1390,17 +1538,18 @@ int StdMeshers_SMESHBlock::ErrorStatus() const
{
return myErrorStatus;
}
//=======================================================================
//function : Load
//purpose :
//=======================================================================
void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell)
{
TopoDS_Vertex aV000, aV001;
//
Load(theShell, aV000, aV001);
}
//=======================================================================
//function : Load
//purpose :
@ -1422,6 +1571,7 @@ void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell,
return;
}
}
//=======================================================================
//function : ComputeParameters
//purpose :
@ -1431,6 +1581,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
{
ComputeParameters(thePnt, myShell, theXYZ);
}
//=======================================================================
//function : ComputeParameters
//purpose :
@ -1492,6 +1643,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
//
Point(theParams, aS, aP3D);
}
//=======================================================================
//function : Point
//purpose :
@ -1534,6 +1686,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
}
aP3D.SetXYZ(aXYZ);
}
//=======================================================================
//function : ShapeID
//purpose :
@ -1561,6 +1714,7 @@ int StdMeshers_SMESHBlock::ShapeID(const TopoDS_Shape& theShape)
myErrorStatus=2; // unknown shape;
return aID;
}
//=======================================================================
//function : Shape
//purpose :
@ -1580,3 +1734,5 @@ const TopoDS_Shape& StdMeshers_SMESHBlock::Shape(const int theID)
const TopoDS_Shape& aS=myShapeIDMap.FindKey(theID);
return aS;
}

View File

@ -39,9 +39,12 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Shell.hxx>
#include <TopTools_IndexedMapOfOrientedShape.hxx>
#include <TColStd_MapOfInteger.hxx>
#include "SMESH_Block.hxx"
#include "StdMeshers_Helper.hxx"
typedef std::map< double, std::vector<const SMDS_MeshNode*> > StdMeshers_IJNodeMap;
class StdMeshers_SMESHBlock {
@ -181,7 +184,7 @@ class StdMeshers_Penta_3D {
return myTol3D;
}
static bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
const TopoDS_Face& theFace,
const TopoDS_Edge& theBaseEdge,
SMESHDS_Mesh* theMesh);
@ -251,6 +254,9 @@ class StdMeshers_Penta_3D {
//
vector<StdMeshers_IJNodeMap> myWallNodesMaps; // nodes on a face
vector<gp_XYZ> myShapeXYZ; // point on each sub-shape
bool myCreateQuadratic;
StdMeshers_Helper* myTool; // toll for working with quadratic elements
};
#endif

View File

@ -47,6 +47,7 @@ using namespace std;
#include <Geom2d_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GCPnts_UniformAbscissa.hxx>
#include <TopExp.hxx>
#include <Precision.hxx>
#include <gp_Pnt2d.hxx>
@ -128,6 +129,11 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
aMesh.GetSubMesh(aShape);
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
//FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape);
FaceQuadStruct* quad = CheckNbEdges(aMesh, aShape);
@ -212,7 +218,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
b = quad->uv_grid[j * nbhoriz + i + 1].node;
c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node;
d = quad->uv_grid[(j + 1) * nbhoriz + i].node;
SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
//SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
}
}
@ -259,7 +266,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
// right bound reached, link with the rightmost node
near = iup;
c = quad->uv_grid[nbhoriz + iup].node;
} else {
}
else {
// find in the grid node c, nearest to the b
double mind = RealLast();
for (int k = g; k <= iup; k++) {
@ -283,14 +291,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
}
if (near == g) { // make triangle
SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
SMDS_MeshFace* face = myTool->AddFace(a, b, c);
meshDS->SetMeshElementOnShape(face, geomFaceID);
} else { // make quadrangle
}
else { // make quadrangle
if (near - 1 < ilow)
d = uv_e3[1].node;
else
d = quad->uv_grid[nbhoriz + near - 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
// if node d is not at position g - make additional triangles
@ -301,7 +312,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
d = uv_e3[1].node;
else
d = quad->uv_grid[nbhoriz + k - 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
}
}
@ -363,14 +375,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
}
if (near == g) { // make triangle
SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
SMDS_MeshFace* face = myTool->AddFace(a, b, c);
meshDS->SetMeshElementOnShape(face, geomFaceID);
} else { // make quadrangle
}
else { // make quadrangle
if (near + 1 > iup)
d = uv_e1[nbright - 2].node;
else
d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
if (near + 1 < g) { // if d not is at g - make additional triangles
@ -380,7 +395,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
d = uv_e1[nbright - 2].node;
else
d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
}
}
@ -428,14 +444,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
}
if (near == g) { // make triangle
SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
SMDS_MeshFace* face = myTool->AddFace(a, b, c);
meshDS->SetMeshElementOnShape(face, geomFaceID);
} else { // make quadrangle
}
else { // make quadrangle
if (near - 1 < jlow)
d = uv_e0[nbdown - 2].node;
else
d = quad->uv_grid[nbhoriz*near - 2].node;
SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
if (near - 1 > g) { // if d not is at g - make additional triangles
@ -445,7 +464,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
d = uv_e0[nbdown - 2].node;
else
d = quad->uv_grid[nbhoriz*k - 2].node;
SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
}
}
@ -490,14 +510,17 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
}
if (near == g) { // make triangle
SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c);
SMDS_MeshFace* face = myTool->AddFace(a, b, c);
meshDS->SetMeshElementOnShape(face, geomFaceID);
} else { // make quadrangle
}
else { // make quadrangle
if (near + 1 > jup)
d = uv_e2[1].node;
else
d = quad->uv_grid[nbhoriz*(near + 1) + 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, b, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
if (near + 1 < g) { // if d not is at g - make additional triangles
@ -507,7 +530,8 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
d = uv_e2[1].node;
else
d = quad->uv_grid[nbhoriz*(k + 1) + 1].node;
SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
//SMDS_MeshFace* face = meshDS->AddFace(a, c, d);
SMDS_MeshFace* face = myTool->AddFace(a, c, d);
meshDS->SetMeshElementOnShape(face, geomFaceID);
}
}
@ -557,8 +581,14 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) {
quad->edge[nbEdges] = E;
if(!myCreateQuadratic) {
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
}
else {
int tmp = nb/2;
quad->nbPts[nbEdges] = tmp + 2; // internal not medium points + 2 extrema
}
}
nbEdges++;
}
@ -574,15 +604,35 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
//=============================================================================
/*!
*
* CheckAnd2Dcompute
*/
//=============================================================================
FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception)
{
bool QuadMode = true;
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
return CheckAnd2Dcompute(aMesh,aShape,myCreateQuadratic);
}
//=============================================================================
/*!
* CheckAnd2Dcompute
*/
//=============================================================================
FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute
(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const bool CreateQuadratic) throw(SALOME_Exception)
{
Unexpect aCatch(SalomeException);
myCreateQuadratic = CreateQuadratic;
FaceQuadStruct *quad = CheckNbEdges(aMesh, aShape);
if(!quad) return 0;
@ -1185,13 +1235,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref
for(j=1; j<nl; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i+1,j),
NodesL.Value(i+1,j+1), NodesL.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
myTool->AddFace(NodesL.Value(i,j), NodesL.Value(i,j+1),
NodesL.Value(i+1,j+1), NodesL.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
@ -1252,13 +1302,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref
for(j=1; j<nr; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i+1,j),
NodesR.Value(i+1,j+1), NodesR.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
myTool->AddFace(NodesR.Value(i,j), NodesR.Value(i,j+1),
NodesR.Value(i+1,j+1), NodesR.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
@ -1335,13 +1385,13 @@ bool StdMeshers_Quadrangle_2D::ComputeQuadPref
for(j=1; j<nbv; j++) {
if(WisF) {
SMDS_MeshFace* F =
meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i+1,j),
NodesC.Value(i+1,j+1), NodesC.Value(i,j+1));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
else {
SMDS_MeshFace* F =
meshDS->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
myTool->AddFace(NodesC.Value(i,j), NodesC.Value(i,j+1),
NodesC.Value(i+1,j+1), NodesC.Value(i+1,j));
meshDS->SetMeshElementOnShape(F, geomFaceID);
}
@ -1387,9 +1437,26 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
// --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
// const SMDS_MeshElement* elem = iter->next();
// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
// const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
// myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3));
// myNLinkNodeMap[link] = n3;
// }
// }
map<double, const SMDS_MeshNode *> params;
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if(!myCreateQuadratic) {
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos =
@ -1397,8 +1464,37 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints2 (SMESH_Mesh & aMesh,
double param = epos->GetUParameter();
params[param] = node;
}
}
else {
vector<const SMDS_MeshNode*> nodes(nbPoints+2);
nodes[0] = idFirst;
nodes[nbPoints+1] = idLast;
nbPoints = nbPoints/2;
int nn = 1;
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
nodes[nn++] = node;
// check if node is medium
bool IsMedium = false;
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
}
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbPoints != params.size()) {
MESSAGE( "BAD NODE ON EDGE POSITIONS" );
return 0;
@ -1523,21 +1619,60 @@ UVPtStruct* StdMeshers_Quadrangle_2D::LoadEdgePoints (SMESH_Mesh & aMesh,
// --- edge internal IDNodes (relies on good order storage, not checked)
// if(myCreateQuadratic) {
// fill myNLinkNodeMap
// SMDS_ElemIteratorPtr iter = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetElements();
// while(iter->more()) {
// const SMDS_MeshElement* elem = iter->next();
// SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator();
// const SMDS_MeshNode* n1 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n2 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// const SMDS_MeshNode* n3 = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
// NLink link(( n1 < n2 ? n1 : n2 ), ( n1 < n2 ? n2 : n1 ));
// myNLinkNodeMap.insert(NLinkNodeMap::value_type(link,n3));
// myNLinkNodeMap[link] = n3;
// }
// }
map<double, const SMDS_MeshNode *> params;
SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes();
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
while(ite->more())
{
if(!myCreateQuadratic) {
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
}
else {
nbPoints = nbPoints/2;
while(ite->more()) {
const SMDS_MeshNode* node = ite->next();
// check if node is medium
bool IsMedium = false;
SMDS_ElemIteratorPtr itn = node->GetInverseElementIterator();
while (itn->more()) {
const SMDS_MeshElement* elem = itn->next();
if ( elem->GetType() != SMDSAbs_Edge )
continue;
if(elem->IsMediumNode(node)) {
IsMedium = true;
break;
}
}
if(IsMedium)
continue;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double param = epos->GetUParameter();
params[param] = node;
}
}
int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbPoints != params.size())
{
if (nbPoints != params.size()) {
MESSAGE( "BAD NODE ON EDGE POSITIONS" );
return 0;
}

View File

@ -34,7 +34,11 @@
#include "SMESH_Mesh.hxx"
#include "Utils_SALOME_Exception.hxx"
class SMDS_MeshNode;
#include "gp_XY.hxx"
#include "StdMeshers_Helper.hxx"
//class SMDS_MeshNode;
typedef struct uvPtStruct
{
@ -78,8 +82,18 @@ public:
const TopoDS_Shape& aShape)
throw (SALOME_Exception);
FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape,
const bool CreateQuadratic)
throw (SALOME_Exception);
static void QuadDelete(FaceQuadStruct* quad);
/**
* Returns NLinkNodeMap from myTool
*/
const NLinkNodeMap& GetNLinkNodeMap() { return myTool->GetNLinkNodeMap(); }
ostream & SaveTo(ostream & save);
istream & LoadFrom(istream & load);
friend ostream & operator << (ostream & save, StdMeshers_Quadrangle_2D & hyp);
@ -120,6 +134,8 @@ protected:
// construction of quadrangles if the number of nodes on opposite edges
// is not the same in the case where the global number of nodes on edges is even
bool myQuadranglePreference;
StdMeshers_Helper* myTool; // toll for working with quadratic elements
};
#endif

View File

@ -42,7 +42,10 @@ StdMeshers_QuadraticMesh::StdMeshers_QuadraticMesh(int hypId,
:SMESH_Hypothesis(hypId, studyId, gen)
{
_name = "QuadraticMesh";
_param_algo_dim = 1; // is used by StdMeshers_Regular_1D
// only one hypo of the same dim can be assigned to the shape so
// we use -3 in order to distingush from any usual 1D hypothsis and
// from "NotConformAllowed" (-1) and "Propagation" (-2)
_param_algo_dim = -3;
}
//=============================================================================

View File

@ -510,7 +510,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
// quardatic mesh required?
SMESH_HypoFilter filter( SMESH_HypoFilter::HasName( "QuadraticMesh" ));
bool isQuadraticMesh = aMesh->GetHypothesis( aShape, filter, true );
bool QuadMode = aMesh.GetHypothesis( aShape, filter, true );
const TopoDS_Edge & EE = TopoDS::Edge(aShape);
TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD));
@ -533,15 +533,13 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
if (!lid->more())
{
if (!lid->more()) {
MESSAGE (" NO NODE BUILT ON VERTEX ");
return false;
}
const SMDS_MeshNode * idLast = lid->next();
if (!Curve.IsNull())
{
if (!Curve.IsNull()) {
list< double > params;
bool reversed = false;
if ( !_mainEdge.IsNull() )
@ -558,9 +556,14 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
// only internal nodes receive an edge position with param on curve
const SMDS_MeshNode * idPrev = idFirst;
double parPrev = f;
double parLast = l;
if(reversed) {
parPrev = l;
parLast = f;
}
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++)
{
for (list<double>::iterator itU = params.begin(); itU != params.end(); itU++) {
double param = *itU;
gp_Pnt P = Curve->Value(param);
@ -568,15 +571,37 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, shapeID, param);
if(QuadMode) {
// create medium node
double prm = ( parPrev + param )/2;
gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID);
idPrev = node;
}
idPrev = node;
parPrev = param;
}
if(QuadMode) {
double prm = ( parPrev + parLast )/2;
gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
else {
SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
else
{
}
else {
// Edge is a degenerated Edge : We put n = 5 points on the edge.
int NbPoints = 5;
BRep_Tool::Range(E, f, l);
@ -588,19 +613,39 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh
gp_Pnt P = BRep_Tool::Pnt(V1);
const SMDS_MeshNode * idPrev = idFirst;
for (int i = 2; i < NbPoints; i++)
{
for (int i = 2; i < NbPoints; i++) {
double param = f + (i - 1) * du;
SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z());
meshDS->SetNodeOnEdge(node, shapeID, param);
if(QuadMode) {
// create medium node
double prm = param - du/2.;
gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node, NM);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
meshDS->SetNodeOnEdge(node, shapeID, param);
idPrev = node;
}
if(QuadMode) {
// create medium node
double prm = l - du/2.;
gp_Pnt PM = Curve->Value(prm);
SMDS_MeshNode * NM = meshDS->AddNode(PM.X(), PM.Y(), PM.Z());
meshDS->SetNodeOnEdge(NM, shapeID, prm);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast, NM);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
else {
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, shapeID);
}
}
return true;
}