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
const SMDS_QuadraticFaceOfNodes* F =
static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
if(F) {
if(anElem->IsQuadratic()) {
const SMDS_QuadraticFaceOfNodes* F =
static_cast<const SMDS_QuadraticFaceOfNodes*>(anElem);
// 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,19 +1087,32 @@ 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 {
/// ??? begin
const SMDS_PolygonalFaceOfNodes* face = dynamic_cast<const SMDS_PolygonalFaceOfNodes*>(elem);
if (face) {
Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
}
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) {
Ok = const_cast<SMDS_PolygonalFaceOfNodes*>(face)->ChangeNodes(nodes, nbnodes);
}
/// ??? end
}
/// ??? end
}
break;
}
@ -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 :
@ -1210,54 +1231,95 @@ bool SMDS_Mesh::ChangePolyhedronNodes (const SMDS_MeshElement * elem,
const SMDS_MeshEdge* SMDS_Mesh::FindEdge(int idnode1, int idnode2) const
{
const SMDS_MeshNode * node1=FindNode(idnode1);
const SMDS_MeshNode * node2=FindNode(idnode2);
if((node1==NULL)||(node2==NULL)) return NULL;
return FindEdge(node1,node2);
const SMDS_MeshNode * node1=FindNode(idnode1);
const SMDS_MeshNode * node2=FindNode(idnode2);
if((node1==NULL)||(node2==NULL)) return NULL;
return FindEdge(node1,node2);
}
//#include "Profiler.h"
const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
{
const SMDS_MeshEdge * toReturn=NULL;
//PROFILER_Init();
//PROFILER_Set();
SMDS_ElemIteratorPtr it1=node1->edgesIterator();
//PROFILER_Get(0);
//PROFILER_Set();
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())
{
toReturn=e;
break;
}
}
}
//PROFILER_Get(1);
return toReturn;
const SMDS_MeshEdge * toReturn=NULL;
//PROFILER_Init();
//PROFILER_Set();
SMDS_ElemIteratorPtr it1=node1->edgesIterator();
//PROFILER_Get(0);
//PROFILER_Set();
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()) {
toReturn = e;
break;
}
}
}
//PROFILER_Get(1);
return toReturn;
}
//=======================================================================
//function : FindEdgeOrCreate
//purpose :
//=======================================================================
SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
const SMDS_MeshNode * node2)
const SMDS_MeshNode * node2)
{
SMDS_MeshEdge * toReturn=NULL;
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
if(toReturn==NULL)
{
toReturn=new SMDS_MeshEdge(node1,node2);
myEdges.Add(toReturn);
}
return toReturn;
SMDS_MeshEdge * toReturn=NULL;
toReturn=const_cast<SMDS_MeshEdge*>(FindEdge(node1,node2));
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 :
@ -1266,118 +1328,219 @@ SMDS_MeshEdge* SMDS_Mesh::FindEdgeOrCreate(const SMDS_MeshNode * node1,
const SMDS_MeshFace* SMDS_Mesh::FindFace(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 FindFace(node1, node2, node3);
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 FindFace(node1, node2, node3);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(
const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3)
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3)
{
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found;
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found;
SMDS_ElemIteratorPtr it1=node1->facesIterator();
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())
{
node=it2->next();
if(node->GetID()==node2->GetID()) node2found=true;
if(node->GetID()==node3->GetID()) node3found=true;
}
if(node2found&&node3found)
return face;
}
return NULL;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
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()) {
node = it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
}
if( node2found && node3found )
return face;
}
return NULL;
}
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3)
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)
{
toReturn=createTriangle(node1,node2,node3);
}
return toReturn;
SMDS_MeshFace * toReturn=NULL;
toReturn = const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3));
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;
return FindFace(node1, node2, node3, node4);
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;
return FindFace(node1, node2, node3, node4);
}
const SMDS_MeshFace* SMDS_Mesh::FindFace(
const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4)
const SMDS_MeshFace* SMDS_Mesh::FindFace(const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4)
{
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found, node4found;
SMDS_ElemIteratorPtr it1=node1->facesIterator();
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())
{
node=it2->next();
if(node->GetID()==node2->GetID()) node2found=true;
if(node->GetID()==node3->GetID()) node3found=true;
if(node->GetID()==node4->GetID()) node4found=true;
}
if(node2found&&node3found&&node4found)
return face;
}
return NULL;
const SMDS_MeshFace * face;
const SMDS_MeshElement * node;
bool node2found, node3found, node4found;
SMDS_ElemIteratorPtr it1 = node1->facesIterator();
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()) {
node=it2->next();
if(node->GetID()==node2->GetID()) node2found = true;
if(node->GetID()==node3->GetID()) node3found = true;
if(node->GetID()==node4->GetID()) node4found = true;
}
if( node2found && node3found && node4found )
return face;
}
return NULL;
}
SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
const SMDS_MeshNode *node1,
const SMDS_MeshNode *node2,
const SMDS_MeshNode *node3,
const SMDS_MeshNode *node4)
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)
{
toReturn=createQuadrangle(node1,node2,node3,node4);
}
return toReturn;
SMDS_MeshFace * toReturn=NULL;
toReturn=const_cast<SMDS_MeshFace*>(FindFace(node1,node2,node3,node4));
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 :
@ -1385,7 +1548,7 @@ SMDS_MeshFace* SMDS_Mesh::FindFaceOrCreate(
const SMDS_MeshElement* SMDS_Mesh::FindElement(int IDelem) const
{
return myElementIDFactory->MeshElement(IDelem);
return myElementIDFactory->MeshElement(IDelem);
}
//=======================================================================

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 );
@ -1106,7 +1107,7 @@ bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1,
bool SMDS_VolumeTool::IsLinked (const int theNode1Index,
const int theNode2Index) const
{
if (myVolume->IsPoly()) {
if ( myVolume->IsPoly() ) {
return IsLinked(myVolumeNodes[theNode1Index], myVolumeNodes[theNode2Index]);
}
@ -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())
{
const TopoDS_Edge& E = TopoDS::Edge(exp.Current());
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
//SCRUTE(nb);
nbPoints += nb +1; // internal points plus 1 vertex of 2 (last point ?)
}
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

File diff suppressed because it is too large Load Diff

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

@ -184,73 +184,76 @@ bool StdMeshers_MEFISTO_2D::CheckHypothesis
bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
{
MESSAGE("StdMeshers_MEFISTO_2D::Compute");
MESSAGE("StdMeshers_MEFISTO_2D::Compute");
if (_hypLengthFromEdges)
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
if (_hypLengthFromEdges)
_edgeLength = ComputeEdgeElementLength(aMesh, aShape);
bool isOk = false;
//const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
//SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
bool isOk = false;
//const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
//SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
const TopoDS_Face & FF = TopoDS::Face(aShape);
bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD);
TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD));
Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf = NULL;
Z nbpti = 0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti = NULL;
Z nbst;
R2 *uvst = NULL;
Z nbt;
Z *nust = NULL;
Z ierr = 0;
Z nblf; //nombre de lignes fermees (enveloppe en tete)
Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee
R2 *uvslf = NULL;
Z nbpti = 0; //nombre points internes futurs sommets de la triangulation
R2 *uvpti = NULL;
Z nutysu = 1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx
R aretmx = _edgeLength; // longueur max aretes future triangulation
nblf = NumberOfWires(F);
nudslf = new Z[1 + nblf];
nudslf[0] = 0;
int iw = 1;
int nbpnt = 0;
Z nbst;
R2 *uvst = NULL;
Z nbt;
Z *nust = NULL;
Z ierr = 0;
bool QuadMode = true;
Z nutysu = 1; // 1: il existe un fonction areteideale_()
// Z nutysu=0; // 0: on utilise aretmx
R aretmx = _edgeLength; // longueur max aretes future triangulation
myTool = new StdMeshers_Helper(aMesh);
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape,QuadMode);
nblf = NumberOfWires(F);
myOuterWire = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, myOuterWire);
if ( nbpnt < 3 ) // ex: a circle with 2 segments
return false;
nudslf[iw++] = nbpnt;
nudslf = new Z[1 + nblf];
nudslf[0] = 0;
int iw = 1;
int nbpnt = 0;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) {
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!myOuterWire.IsSame(W)) {
nbpnt += NumberOfPoints(aMesh, W);
nudslf[iw++] = nbpnt;
}
}
myOuterWire = BRepTools::OuterWire(F);
nbpnt += NumberOfPoints(aMesh, myOuterWire);
if ( nbpnt < 3 ) // ex: a circle with 2 segments
return false;
nudslf[iw++] = nbpnt;
// avoid passing same uv points for a vertex common to 2 wires
TopTools_IndexedDataMapOfShapeListOfShape VWMap;
if ( iw - 1 > 1 ) // nbofWires > 1
TopExp::MapShapesAndAncestors( F , TopAbs_VERTEX, TopAbs_WIRE, VWMap );
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
const TopoDS_Wire & W = TopoDS::Wire(exp.Current());
if (!myOuterWire.IsSame(W))
{
nbpnt += NumberOfPoints(aMesh, W);
nudslf[iw++] = nbpnt;
}
}
uvslf = new R2[nudslf[nblf]];
int m = 0;
// avoid passing same uv points for a vertex common to 2 wires
TopTools_IndexedDataMapOfShapeListOfShape VWMap;
if ( iw - 1 > 1 ) // nbofWires > 1
TopExp::MapShapesAndAncestors( F , TopAbs_VERTEX, TopAbs_WIRE, VWMap );
double scalex, scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley);
uvslf = new R2[nudslf[nblf]];
int m = 0;
double scalex, scaley;
ComputeScaleOnFace(aMesh, F, scalex, scaley);
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m,
mefistoToDS, scalex, scaley, VWMap))
return false;
map<int, const SMDS_MeshNode*> mefistoToDS; // correspondence mefisto index--> points IDNodes
if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m,
mefistoToDS, scalex, scaley, VWMap) )
return false;
for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next())
{
@ -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
@ -496,7 +514,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l
ASSERT(!VFirst.IsNull());
SMDS_NodeIteratorPtr lid=
SMDS_NodeIteratorPtr lid =
aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes();
if ( !lid->more() ) {
MESSAGE (" NO NODE BUILT ON VERTEX ");
@ -505,7 +523,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh,
const SMDS_MeshNode* idFirst = lid->next();
ASSERT(!VLast.IsNull());
lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes();
if ( !lid->more() ) {
MESSAGE (" NO NODE BUILT ON VERTEX ");
return false;
@ -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())
{
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(!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,9 +96,20 @@ 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){
if (myErrorStatus){
return bOK;
}
//
ClearMeshOnFxy1();
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 :
@ -144,12 +156,24 @@ void StdMeshers_Penta_3D::MakeNodes()
// 1.1 Horizontal size
myJSize=0;
for (i=0; i<aNbSIDs; ++i) {
const TopoDS_Shape& aS=myBlock.Shape(aSIDs[i]);
const TopoDS_Shape& aS = myBlock.Shape(aSIDs[i]);
SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
ASSERT(aSubMesh);
SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
iNbN=aSM->NbNodes();
myJSize+=iNbN;
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);
//
@ -159,9 +183,21 @@ void StdMeshers_Penta_3D::MakeNodes()
const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_E00z);
SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aS);
ASSERT(aSubMesh);
SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
iNbN=aSM->NbNodes();
myISize+=iNbN;
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);
//
@ -177,18 +213,19 @@ void StdMeshers_Penta_3D::MakeNodes()
// vertices
for (k=0; k<aNbSIDs; ++k) {
aSID=aSIDs[k];
const TopoDS_Shape& aS=myBlock.Shape(aSID);
SMDS_NodeIteratorPtr ite =pMesh->GetSubMeshContaining(aS)->GetSubMeshDS()->GetNodes();
const TopoDS_Shape& aS = myBlock.Shape(aSID);
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 );
@ -200,7 +237,7 @@ void StdMeshers_Penta_3D::MakeNodes()
aP3D.SetCoord(aX, aY, aZ);
myBlock.ComputeParameters(aP3D, aS, aCoords);
}
iErr=myBlock.ErrorStatus();
iErr = myBlock.ErrorStatus();
if (iErr) {
MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
"SMESHBlock: ComputeParameters operation failed");
@ -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,23 +380,46 @@ 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();
iBNID=aBN.BaseNodeID();
const gp_XYZ& aBNXYZ=aBN.NormCoord();
const StdMeshers_TNode& aBN = myTNodes[j];
aBNSSID = (SMESH_Block::TShapeID)aBN.ShapeSupportID();
iBNID = aBN.BaseNodeID();
const gp_XYZ& aBNXYZ = aBN.NormCoord();
bool createNode = ( aBNSSID == SMESH_Block::ID_Fxy0 );
//
// set XYZ on horizontal edges and get node columns of faces:
// 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,
@ -470,14 +573,13 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
double aX, aY, aZ, aD, aTol2, minD;
gp_Pnt aP1, aP2;
//
SMESH_Mesh* pMesh=GetMesh();
aTol2=myTol3D*myTol3D;
SMESH_Mesh* pMesh = GetMesh();
aTol2 = myTol3D*myTol3D;
minD = 1.e100;
SMDS_MeshNode* pNode=NULL;
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 )
@ -492,13 +594,13 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
}
ASSERT( SMESH_Block::IsFaceID( faceID ));
int fIndex = SMESH_Block::ShapeIndex( faceID );
StdMeshers_IJNodeMap & ijNodes= myWallNodesMaps[ fIndex ];
StdMeshers_IJNodeMap & ijNodes = myWallNodesMaps[ fIndex ];
// look for a base node in ijNodes
const SMDS_MeshNode* baseNode = pMesh->GetMeshDS()->FindNode( aTN.BaseNodeID() );
StdMeshers_IJNodeMap::const_iterator par_nVec = ijNodes.begin();
for ( ; par_nVec != ijNodes.end(); par_nVec++ )
if ( par_nVec->second[ 0 ] == baseNode ) {
pNode=(SMDS_MeshNode*)par_nVec->second.at( z );
pNode = (SMDS_MeshNode*)par_nVec->second.at( z );
aTN.SetNode(pNode);
return;
}
@ -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 :
@ -593,20 +699,20 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
//
int i, j, ij, ik, i1, i2, aSSID;
//
SMESH_Mesh* pMesh =GetMesh();
SMESHDS_Mesh* meshDS=pMesh->GetMeshDS();
SMESH_Mesh* pMesh = GetMesh();
SMESHDS_Mesh* meshDS = pMesh->GetMeshDS();
//
int shapeID = meshDS->ShapeToIndex( myShape );
//
// 1. Set Node In Volume
ik=myISize-1;
ik = myISize-1;
for (i=1; i<ik; ++i){
for (j=0; j<myJSize; ++j){
ij=i*myJSize+j;
const StdMeshers_TNode& aTN=myTNodes[ij];
const StdMeshers_TNode& aTN = myTNodes[ij];
aSSID=aTN.ShapeSupportID();
if (aSSID==SMESH_Block::ID_NONE) {
SMDS_MeshNode* aNode=(SMDS_MeshNode*)aTN.Node();
SMDS_MeshNode* aNode = (SMDS_MeshNode*)aTN.Node();
meshDS->SetNodeInVolume(aNode, shapeID);
}
}
@ -621,22 +727,28 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
const TopoDS_Face& aFxy0=
TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy0));
SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
SMESHDS_SubMesh *aSM0 = aSubMesh0->GetSubMeshDS();
//
itf=aSM0->GetElements();
itf = aSM0->GetElements();
while(itf->more()) {
const SMDS_MeshElement* pE0=itf->next();
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();
aID0=pNode->GetID();
aJ[k]=GetIndexOnLayer(aID0);
//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) {
MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh");
return;
@ -646,19 +758,19 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
}
//
bool forward = true;
for (i=0; i<ik; ++i){
for (i=0; i<ik; ++i) {
i1=i;
i2=i+1;
for(j=0; j<nbFaceNodes; ++j) {
ij=i1*myJSize+aJ[j];
const StdMeshers_TNode& aTN1=myTNodes[ij];
const SMDS_MeshNode* aN1=aTN1.Node();
ij = i1*myJSize+aJ[j];
const StdMeshers_TNode& aTN1 = myTNodes[ij];
const SMDS_MeshNode* aN1 = aTN1.Node();
aN[j]=aN1;
//
ij=i2*myJSize+aJ[j];
const StdMeshers_TNode& aTN2=myTNodes[ij];
const SMDS_MeshNode* aN2=aTN2.Node();
aN[j+nbFaceNodes]=aN2;
const StdMeshers_TNode& aTN2 = myTNodes[ij];
const SMDS_MeshNode* aN2 = aTN2.Node();
aN[j+nbFaceNodes] = aN2;
}
// check if volume orientation will be ok
if ( i == 0 ) {
@ -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;
@ -727,74 +849,68 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1()
const TopoDS_Face& aFxy1=
TopoDS::Face(myBlock.Shape(SMESH_Block::ID_Fxy1));
//
SMESH_Mesh* pMesh=GetMesh();
SMESH_Mesh* pMesh = GetMesh();
SMESHDS_Mesh * meshDS = pMesh->GetMeshDS();
//
SMESH_subMesh *aSubMesh0 = pMesh->GetSubMeshContaining(aFxy0);
SMESHDS_SubMesh *aSM0=aSubMesh0->GetSubMeshDS();
SMESHDS_SubMesh *aSM0 = aSubMesh0->GetSubMeshDS();
//
// set nodes on aFxy1
aLevel=myISize-1;
itn=aSM0->GetNodes();
aNbNodes=aSM0->NbNodes();
aLevel = myISize-1;
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;
//
itf=aSM0->GetElements();
itf = aSM0->GetElements();
while(itf->more()) {
const SMDS_MeshElement * pE0=itf->next();
aElementType=pE0->GetType();
const SMDS_MeshElement* pE0 = itf->next();
aElementType = pE0->GetType();
if (!aElementType==SMDSAbs_Face) {
continue;
}
aNbNodes=pE0->NbNodes();
aNbNodes = pE0->NbNodes();
if(myCreateQuadratic)
aNbNodes = aNbNodes/2;
// if (aNbNodes!=3) {
// continue;
// }
if ( aNodes1.size() < aNbNodes )
aNodes1.resize( aNbNodes );
//
k=aNbNodes-1; // reverse a face
aItNodes=pE0->nodesIterator();
k = aNbNodes-1; // reverse a face
aItNodes = pE0->nodesIterator();
while (aItNodes->more()) {
const SMDS_MeshElement* pNode=aItNodes->next();
aID0=pNode->GetID();
aJ=GetIndexOnLayer(aID0);
//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) {
MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
return;
}
//
ij=aLevel*myJSize+aJ;
const StdMeshers_TNode& aTN1=myTNodes[ij];
const SMDS_MeshNode* aN1=aTN1.Node();
aNodes1[k]=aN1;
ij = aLevel*myJSize + aJ;
const StdMeshers_TNode& aTN1 = myTNodes[ij];
const SMDS_MeshNode* aN1 = aTN1.Node();
aNodes1[k] = aN1;
--k;
}
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() );
}
//
@ -906,12 +1023,14 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer,
//
aX=aP.X(); aY=aP.Y(); aZ=aP.Z();
//
SMESH_Mesh* pMesh=GetMesh();
SMESHDS_Mesh* pMeshDS=pMesh->GetMeshDS();
SMESH_Mesh* pMesh = GetMesh();
SMESHDS_Mesh* pMeshDS = pMesh->GetMeshDS();
//
pNode = pMeshDS->AddNode(aX, aY, aZ);
aTN.SetNode(pNode);
}
//=======================================================================
//function : ShapeSupportID
//purpose :
@ -980,21 +1099,21 @@ void StdMeshers_Penta_3D::MakeBlock()
SMDSAbs_ElementType aElementType;
SMESH_Mesh* pMesh=GetMesh();
//
iCnt=0;
iNbF=aM.Extent();
iCnt = 0;
iNbF = aM.Extent();
for (i=1; i<=iNbF; ++i) {
const TopoDS_Shape& aF=aM(i);
const TopoDS_Shape& aF = aM(i);
SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF);
ASSERT(aSubMesh);
SMESHDS_SubMesh *aSM=aSubMesh->GetSubMeshDS();
SMDS_ElemIteratorPtr itf=aSM->GetElements();
SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS();
SMDS_ElemIteratorPtr itf = aSM->GetElements();
while(itf->more()) {
const SMDS_MeshElement * pElement=itf->next();
aElementType=pElement->GetType();
const SMDS_MeshElement * pElement = itf->next();
aElementType = pElement->GetType();
if (aElementType==SMDSAbs_Face) {
iNbNodes=pElement->NbNodes();
if (iNbNodes==3) {
aFTr=aF;
iNbNodes = pElement->NbNodes();
if ( iNbNodes==3 || (myCreateQuadratic && iNbNodes==6) ) {
aFTr = aF;
++iCnt;
if (iCnt>1) {
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
@ -1013,7 +1132,7 @@ void StdMeshers_Penta_3D::MakeBlock()
TopExp::MapShapesAndAncestors(myShape, TopAbs_VERTEX, TopAbs_EDGE, aMVES);
//
// 1.1 Base vertex V000
iNbE=aME.Extent();
iNbE = aME.Extent();
if (iNbE!=4){
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
myErrorStatus=7; // too few edges are in base face aFTr
@ -1080,7 +1199,7 @@ void StdMeshers_Penta_3D::MakeBlock()
// 2. Load Block
const TopoDS_Shell& aShell=TopoDS::Shell(aME(1));
myBlock.Load(aShell, aV000, aV001);
iErr=myBlock.ErrorStatus();
iErr = myBlock.ErrorStatus();
if (iErr) {
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
myErrorStatus=100; // SMESHBlock: Load operation failed
@ -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() ) {
MESSAGE( "Wrong nb face nodes: " <<
sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
return false;
// 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 :
@ -1416,12 +1565,13 @@ void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell,
bool bOk;
//
myShapeIDMap.Clear();
bOk=myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
bOk = myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
if (!bOk) {
myErrorStatus=2;
return;
}
}
//=======================================================================
//function : ComputeParameters
//purpose :
@ -1431,24 +1581,25 @@ void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
{
ComputeParameters(thePnt, myShell, theXYZ);
}
//=======================================================================
//function : ComputeParameters
//purpose :
//=======================================================================
void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt,
const TopoDS_Shape& theShape,
gp_XYZ& theXYZ)
gp_XYZ& theXYZ)
{
myErrorStatus=0;
//
int aID;
bool bOk;
//
aID=ShapeID(theShape);
aID = ShapeID(theShape);
if (myErrorStatus) {
return;
}
bOk=myTBlock.ComputeParameters(thePnt, theXYZ, aID);
bOk = myTBlock.ComputeParameters(thePnt, theXYZ, aID);
if (!bOk) {
myErrorStatus=4; // problems with computation Parameters
return;
@ -1469,12 +1620,12 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
int aID;
bool bOk=false;
//
aID=ShapeID(theShape);
aID = ShapeID(theShape);
if (myErrorStatus) {
return;
}
if ( SMESH_Block::IsEdgeID( aID ))
bOk=myTBlock.EdgeParameters( aID, theU, theXYZ );
bOk = myTBlock.EdgeParameters( aID, theU, theXYZ );
if (!bOk) {
myErrorStatus=4; // problems with computation Parameters
return;
@ -1492,6 +1643,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
//
Point(theParams, aS, aP3D);
}
//=======================================================================
//function : Point
//purpose :
@ -1500,15 +1652,15 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
const TopoDS_Shape& theShape,
gp_Pnt& aP3D)
{
myErrorStatus=0;
myErrorStatus = 0;
//
int aID;
bool bOk=false;
bool bOk = false;
gp_XYZ aXYZ(99.,99.,99.);
aP3D.SetXYZ(aXYZ);
//
if (theShape.IsNull()) {
bOk=myTBlock.ShellPoint(theParams, aXYZ);
bOk = myTBlock.ShellPoint(theParams, aXYZ);
}
//
else {
@ -1518,14 +1670,14 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU,
}
//
if (SMESH_Block::IsVertexID(aID)) {
bOk=myTBlock.VertexPoint(aID, aXYZ);
bOk = myTBlock.VertexPoint(aID, aXYZ);
}
else if (SMESH_Block::IsEdgeID(aID)) {
bOk=myTBlock.EdgePoint(aID, theParams, aXYZ);
bOk = myTBlock.EdgePoint(aID, theParams, aXYZ);
}
//
else if (SMESH_Block::IsFaceID(aID)) {
bOk=myTBlock.FacePoint(aID, theParams, aXYZ);
bOk = myTBlock.FacePoint(aID, theParams, aXYZ);
}
}
if (!bOk) {
@ -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,10 +184,10 @@ class StdMeshers_Penta_3D {
return myTol3D;
}
static bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
const TopoDS_Face& theFace,
const TopoDS_Edge& theBaseEdge,
SMESHDS_Mesh* theMesh);
bool LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
const TopoDS_Face& theFace,
const TopoDS_Edge& theBaseEdge,
SMESHDS_Mesh* theMesh);
// Load nodes bound to theFace into column (vectors) and rows
// of theIJNodes.
// The value of theIJNodes map is a vector of ordered nodes so
@ -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);
@ -180,7 +186,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
quad->uv_grid[ij].node = node;
}
}
// mesh faces
// [2]
@ -194,16 +200,16 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
// 0 > > > > > > > > nbhoriz
// i
// [0]
i = 0;
int ilow = 0;
int iup = nbhoriz - 1;
if (quad->isEdgeOut[3]) { ilow++; } else { if (quad->isEdgeOut[1]) iup--; }
int jlow = 0;
int jup = nbvertic - 1;
if (quad->isEdgeOut[0]) { jlow++; } else { if (quad->isEdgeOut[2]) jup--; }
// regular quadrangles
for (i = ilow; i < iup; i++) {
for (j = jlow; j < jup; j++) {
@ -212,11 +218,12 @@ 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);
}
}
UVPtStruct *uv_e0 = quad->uv_edges[0];
UVPtStruct *uv_e1 = quad->uv_edges[1];
UVPtStruct *uv_e2 = quad->uv_edges[2];
@ -225,7 +232,7 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
double eps = Precision::Confusion();
// Boundary quadrangles
if (quad->isEdgeOut[0]) {
// Down edge is out
//
@ -237,14 +244,14 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
// . . . . . . . . . __ down edge nodes
//
// >->->->->->->->->->->->-> -- direction of processing
int g = 0; // number of last processed node in the regular grid
// number of last node of the down edge to be processed
int stop = nbdown - 1;
// if right edge is out, we will stop at a node, previous to the last one
if (quad->isEdgeOut[1]) stop--;
// for each node of the down edge find nearest node
// in the first row of the regular grid and link them
for (i = 0; i < stop; i++) {
@ -252,18 +259,19 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh,
a = uv_e0[i].node;
b = uv_e0[i + 1].node;
gp_Pnt pb (b->X(), b->Y(), b->Z());
// find node c in the regular grid, which will be linked with node b
int near = g;
if (i == stop - 1) {
// 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++) {
const SMDS_MeshNode *nk;
if (k < ilow) // this can be, if left edge is out
nk = uv_e3[1].node; // get node from the left edge
@ -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,7 +581,13 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMesh,
int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes();
if (nbEdges < 4) {
quad->edge[nbEdges] = E;
quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema
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,18 +1437,64 @@ 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();
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(!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 {
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())
{
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(!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);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID);
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;
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);
}
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,18 +613,38 @@ 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());
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);
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node);
meshDS->SetMeshElementOnShape(edge, shapeID);
idPrev = node;
}
SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast);
meshDS->SetMeshElementOnShape(edge, shapeID);
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;
}