mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-19 21:13:07 +05:00
PR: fix QuadToTriaAdaptor
This commit is contained in:
parent
a541693f06
commit
259cd96526
@ -309,9 +309,12 @@ vtkIdType SMDS_MeshNode::GetVtkType() const
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
void SMDS_MeshNode::AddInverseElement(const SMDS_MeshElement* ME)
|
||||||
{
|
{
|
||||||
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*>(ME);
|
const SMDS_MeshCell *cell = dynamic_cast<const SMDS_MeshCell*> (ME);
|
||||||
assert(cell);
|
assert(cell);
|
||||||
SMDS_Mesh::_meshList[myMeshId]->getGrid()->AddReferenceToCell(myVtkID, cell->getVtkId());
|
SMDS_UnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||||
|
vtkCellLinks *Links = grid->GetCellLinks();
|
||||||
|
Links->ResizeCellList(myVtkID, 1);
|
||||||
|
Links->AddCellReference(cell->getVtkId(), myVtkID);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
friend class SMESHDS_Mesh;
|
friend class SMESHDS_Mesh;
|
||||||
friend class SMDS_Mesh;
|
friend class SMDS_Mesh;
|
||||||
friend class ObjectPool<SMDS_MeshNode>;
|
friend class ObjectPool<SMDS_MeshNode>;
|
||||||
|
friend class SMDS_VtkFace;
|
||||||
|
|
||||||
void Print(std::ostream & OS) const;
|
void Print(std::ostream & OS) const;
|
||||||
double X() const;
|
double X() const;
|
||||||
|
@ -249,7 +249,7 @@ SMDS_ElemIteratorPtr SMDS_VtkFace::interlacedNodesElemIterator() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//! change only the first node, used for temporary triangles in quadrangle to triangle adaptor
|
//! change only the first node, used for temporary triangles in quadrangle to triangle adaptor
|
||||||
void SMDS_VtkFace::ChangeApex(const SMDS_MeshNode* node)
|
void SMDS_VtkFace::ChangeApex(SMDS_MeshNode* node)
|
||||||
{
|
{
|
||||||
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
|
||||||
vtkIdType npts = 0;
|
vtkIdType npts = 0;
|
||||||
@ -257,6 +257,6 @@ void SMDS_VtkFace::ChangeApex(const SMDS_MeshNode* node)
|
|||||||
grid->GetCellPoints(myVtkID, npts, pts);
|
grid->GetCellPoints(myVtkID, npts, pts);
|
||||||
grid->RemoveReferenceToCell(pts[0], myVtkID);
|
grid->RemoveReferenceToCell(pts[0], myVtkID);
|
||||||
pts[0] = node->getVtkId();
|
pts[0] = node->getVtkId();
|
||||||
grid->AddReferenceToCell(pts[0], myVtkID);
|
node->AddInverseElement(this),
|
||||||
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
SMDS_Mesh::_meshList[myMeshId]->setMyModified();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public:
|
|||||||
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
|
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
|
||||||
void initPoly(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
|
void initPoly(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
|
||||||
bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
|
||||||
void ChangeApex(const SMDS_MeshNode* node); // to use only for tmp triangles
|
void ChangeApex(SMDS_MeshNode* node); // to use only for tmp triangles
|
||||||
void Print(std::ostream & OS) const;
|
void Print(std::ostream & OS) const;
|
||||||
int NbEdges() const;
|
int NbEdges() const;
|
||||||
int NbFaces() const;
|
int NbFaces() const;
|
||||||
|
@ -82,10 +82,10 @@ namespace
|
|||||||
SMESH_MeshEditor::TNodeXYZ Pj( Nrem );
|
SMESH_MeshEditor::TNodeXYZ Pj( Nrem );
|
||||||
|
|
||||||
// an apex node to make common to all merged pyramids
|
// an apex node to make common to all merged pyramids
|
||||||
|
if (PrmI->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
SMDS_MeshNode* CommonNode = const_cast<SMDS_MeshNode*>(PrmI->GetNode(4));
|
SMDS_MeshNode* CommonNode = const_cast<SMDS_MeshNode*>(PrmI->GetNode(4));
|
||||||
if ( CommonNode == Nrem ) return; // already merged
|
if ( CommonNode == Nrem ) return; // already merged
|
||||||
int nbI = CommonNode->NbInverseElements( SMDSAbs_Volume );
|
int nbI = CommonNode->NbInverseElements( SMDSAbs_Volume );
|
||||||
//cerr << __LINE__ << " " << nbI << " " << nbJ << endl;
|
|
||||||
SMESH_MeshEditor::TNodeXYZ Pi( CommonNode );
|
SMESH_MeshEditor::TNodeXYZ Pi( CommonNode );
|
||||||
gp_XYZ Pnew = ( nbI*Pi + nbJ*Pj ) / (nbI+nbJ);
|
gp_XYZ Pnew = ( nbI*Pi + nbJ*Pj ) / (nbI+nbJ);
|
||||||
CommonNode->setXYZ( Pnew.X(), Pnew.Y(), Pnew.Z() );
|
CommonNode->setXYZ( Pnew.X(), Pnew.Y(), Pnew.Z() );
|
||||||
@ -116,7 +116,6 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set the common apex node to pyramids and triangles merged with J
|
// set the common apex node to pyramids and triangles merged with J
|
||||||
//cerr << __LINE__ << " NbInverseElements " << Nrem->NbInverseElements() << endl;
|
|
||||||
SMDS_ElemIteratorPtr itJ = Nrem->GetInverseElementIterator();
|
SMDS_ElemIteratorPtr itJ = Nrem->GetInverseElementIterator();
|
||||||
while ( itJ->more() )
|
while ( itJ->more() )
|
||||||
{
|
{
|
||||||
@ -124,22 +123,15 @@ namespace
|
|||||||
if ( elem->GetType() == SMDSAbs_Volume ) // pyramid
|
if ( elem->GetType() == SMDSAbs_Volume ) // pyramid
|
||||||
{
|
{
|
||||||
vector< const SMDS_MeshNode* > nodes( elem->begin_nodes(), elem->end_nodes() );
|
vector< const SMDS_MeshNode* > nodes( elem->begin_nodes(), elem->end_nodes() );
|
||||||
//cerr << __LINE__ << " volId " << elem->GetID() << " nbNodes " << nodes.size() << endl;
|
|
||||||
nodes[4] = CommonNode;
|
nodes[4] = CommonNode;
|
||||||
MESSAGE("ChangeElementNodes");
|
MESSAGE("ChangeElementNodes");
|
||||||
meshDS->ChangeElementNodes( elem, &nodes[0], nodes.size());
|
meshDS->ChangeElementNodes( elem, &nodes[0], nodes.size());
|
||||||
}
|
}
|
||||||
else if ( tempTrias.count(elem) ) // tmp triangles
|
else if ( tempTrias.count(elem) ) // tmp triangles
|
||||||
{
|
{
|
||||||
//cerr << __LINE__ << " triaId " << elem->GetID() << endl;
|
|
||||||
((SMDS_VtkFace*) elem )->ChangeApex( CommonNode );
|
((SMDS_VtkFace*) elem )->ChangeApex( CommonNode );
|
||||||
}
|
}
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// cerr << __LINE__ << " other " << elem->GetVtkType() << endl;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
//cerr << __LINE__ << " NbInverseElements " << Nrem->NbInverseElements() << endl;
|
|
||||||
ASSERT( Nrem->NbInverseElements() == 0 );
|
ASSERT( Nrem->NbInverseElements() == 0 );
|
||||||
meshDS->RemoveFreeNode( Nrem,
|
meshDS->RemoveFreeNode( Nrem,
|
||||||
meshDS->MeshElements( Nrem->getshapeId()),
|
meshDS->MeshElements( Nrem->getshapeId()),
|
||||||
@ -157,6 +149,8 @@ namespace
|
|||||||
const SMDS_MeshElement* PrmJ,
|
const SMDS_MeshElement* PrmJ,
|
||||||
const bool hasShape)
|
const bool hasShape)
|
||||||
{
|
{
|
||||||
|
if (PrmI->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
|
if (PrmJ->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
const SMDS_MeshNode* nApexI = PrmI->GetNode(4);
|
const SMDS_MeshNode* nApexI = PrmI->GetNode(4);
|
||||||
const SMDS_MeshNode* nApexJ = PrmJ->GetNode(4);
|
const SMDS_MeshNode* nApexJ = PrmJ->GetNode(4);
|
||||||
if ( nApexI == nApexJ ||
|
if ( nApexI == nApexJ ||
|
||||||
@ -264,6 +258,7 @@ namespace
|
|||||||
TRemTrias & tempTrias,
|
TRemTrias & tempTrias,
|
||||||
set<const SMDS_MeshNode*>& nodesToMove)
|
set<const SMDS_MeshNode*>& nodesToMove)
|
||||||
{
|
{
|
||||||
|
if (PrmI->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
TIDSortedElemSet adjacentPyrams, mergedPyrams;
|
TIDSortedElemSet adjacentPyrams, mergedPyrams;
|
||||||
for(int k=0; k<4; k++) // loop on 4 base nodes of PrmI
|
for(int k=0; k<4; k++) // loop on 4 base nodes of PrmI
|
||||||
{
|
{
|
||||||
@ -302,6 +297,8 @@ namespace
|
|||||||
StdMeshers_QuadToTriaAdaptor::StdMeshers_QuadToTriaAdaptor():
|
StdMeshers_QuadToTriaAdaptor::StdMeshers_QuadToTriaAdaptor():
|
||||||
myElemSearcher(0), myNbTriangles(0)
|
myElemSearcher(0), myNbTriangles(0)
|
||||||
{
|
{
|
||||||
|
myResMap.clear();
|
||||||
|
myTempTriangles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -1003,6 +1000,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
|
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
|
||||||
|
if (myPyramids[0]->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
int i, j, k, myShapeID = myPyramids[0]->GetNode(4)->getshapeId();
|
int i, j, k, myShapeID = myPyramids[0]->GetNode(4)->getshapeId();
|
||||||
|
|
||||||
if ( !myElemSearcher )
|
if ( !myElemSearcher )
|
||||||
@ -1016,6 +1014,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
for ( i = 0; i < myPyramids.size(); ++i )
|
for ( i = 0; i < myPyramids.size(); ++i )
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* PrmI = myPyramids[i];
|
const SMDS_MeshElement* PrmI = myPyramids[i];
|
||||||
|
if (PrmI->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
MergeAdjacent( PrmI, aMesh, myTempTriangles, nodesToMove );
|
MergeAdjacent( PrmI, aMesh, myTempTriangles, nodesToMove );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1023,6 +1022,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
for ( i = 0; i < myPyramids.size(); ++i )
|
for ( i = 0; i < myPyramids.size(); ++i )
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* PrmI = myPyramids[i];
|
const SMDS_MeshElement* PrmI = myPyramids[i];
|
||||||
|
if (PrmI->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
|
|
||||||
// compare PrmI with all the rest pyramids
|
// compare PrmI with all the rest pyramids
|
||||||
|
|
||||||
@ -1051,6 +1051,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
for ( j = 0; j < suspectPyrams.size(); ++j )
|
for ( j = 0; j < suspectPyrams.size(); ++j )
|
||||||
{
|
{
|
||||||
const SMDS_MeshElement* PrmJ = suspectPyrams[j];
|
const SMDS_MeshElement* PrmJ = suspectPyrams[j];
|
||||||
|
//if (PrmJ->GetVtkType() != VTK_PYRAMID) throw SALOME_Exception(LOCALIZED("not a pyramid"));
|
||||||
if ( PrmJ == PrmI || PrmJ->NbCornerNodes() != 5 )
|
if ( PrmJ == PrmI || PrmJ->NbCornerNodes() != 5 )
|
||||||
continue;
|
continue;
|
||||||
if ( myShapeID != PrmJ->GetNode(4)->getshapeId())
|
if ( myShapeID != PrmJ->GetNode(4)->getshapeId())
|
||||||
@ -1135,12 +1136,12 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
|
|
||||||
} // loop on all pyramids
|
} // loop on all pyramids
|
||||||
|
|
||||||
if( !nodesToMove.empty() && !meshDS->IsEmbeddedMode() )
|
// if( !nodesToMove.empty() && !meshDS->IsEmbeddedMode() )
|
||||||
{
|
// {
|
||||||
set<const SMDS_MeshNode*>::iterator n = nodesToMove.begin();
|
// set<const SMDS_MeshNode*>::iterator n = nodesToMove.begin();
|
||||||
for ( ; n != nodesToMove.end(); ++n )
|
// for ( ; n != nodesToMove.end(); ++n )
|
||||||
meshDS->MoveNode( *n, (*n)->X(), (*n)->Y(), (*n)->Z() );
|
// meshDS->MoveNode( *n, (*n)->X(), (*n)->Y(), (*n)->Z() );
|
||||||
}
|
// }
|
||||||
|
|
||||||
// rebind triangles of pyramids sharing the same base quadrangle to the first
|
// rebind triangles of pyramids sharing the same base quadrangle to the first
|
||||||
// entrance of the base quadrangle
|
// entrance of the base quadrangle
|
||||||
@ -1148,31 +1149,30 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
|
|||||||
for ( ++q2t; q2t != myResMap.end(); ++q2t, ++q2tPrev )
|
for ( ++q2t; q2t != myResMap.end(); ++q2t, ++q2tPrev )
|
||||||
{
|
{
|
||||||
if ( q2t->first == q2tPrev->first )
|
if ( q2t->first == q2tPrev->first )
|
||||||
{
|
q2tPrev->second.splice( q2tPrev->second.end(), q2t->second );
|
||||||
//cerr << __LINE__ << " splice" << endl;
|
|
||||||
q2tPrev->second.splice( q2tPrev->second.end(), q2t->second );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// delete removed triangles and count resulting nb of triangles
|
// delete removed triangles and count resulting nb of triangles
|
||||||
for (q2t = myResMap.begin(); q2t != myResMap.end(); ++q2t)
|
for (q2t = myResMap.begin(); q2t != myResMap.end(); ++q2t)
|
||||||
{
|
{
|
||||||
TTriaList & trias = q2t->second;
|
TTriaList & trias = q2t->second;
|
||||||
vector<const SMDS_MeshFace*> faceToErase;
|
set<const SMDS_MeshFace*> faceToErase;
|
||||||
faceToErase.clear();
|
faceToErase.clear();
|
||||||
//cerr << __LINE__ << " " << trias.size() << endl;
|
|
||||||
for (TTriaList::iterator tri = trias.begin(); tri != trias.end(); ++tri)
|
for (TTriaList::iterator tri = trias.begin(); tri != trias.end(); ++tri)
|
||||||
{
|
{
|
||||||
//cerr << " " << __LINE__ << endl;
|
|
||||||
const SMDS_MeshFace* face = *tri;
|
const SMDS_MeshFace* face = *tri;
|
||||||
if (myTempTriangles.count(face) && (myTempTriangles[face] == false))
|
if (myTempTriangles.count(face) && (myTempTriangles[face] == false))
|
||||||
faceToErase.push_back(face);
|
faceToErase.insert(face);
|
||||||
else
|
else
|
||||||
myNbTriangles++;
|
myNbTriangles++;
|
||||||
}
|
}
|
||||||
for (vector<const SMDS_MeshFace*>::iterator it = faceToErase.begin(); it != faceToErase.end(); ++it)
|
for (set<const SMDS_MeshFace*>::iterator it = faceToErase.begin(); it != faceToErase.end(); ++it)
|
||||||
{
|
{
|
||||||
const SMDS_MeshFace *face = dynamic_cast<const SMDS_MeshFace*>(*it);
|
const SMDS_MeshFace *face = dynamic_cast<const SMDS_MeshFace*>(*it);
|
||||||
if (face) trias.remove(face);
|
if (face)
|
||||||
|
{
|
||||||
|
trias.remove(face);
|
||||||
|
myTempTriangles.erase(face);
|
||||||
|
}
|
||||||
meshDS->RemoveFreeElement(face, 0, false);
|
meshDS->RemoveFreeElement(face, 0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user