BR: debug on merge nodes and quadratic mixed operations

This commit is contained in:
prascle 2010-11-24 15:31:13 +00:00
parent 405a5b87ab
commit e910b10186
5 changed files with 52 additions and 48 deletions

View File

@ -1389,15 +1389,6 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
int vtkId = cell->getVtkId(); int vtkId = cell->getVtkId();
if (vtkId == -1) if (vtkId == -1)
vtkId = myElementIDFactory->SetInVtkGrid(element); vtkId = myElementIDFactory->SetInVtkGrid(element);
// if (ID >= myCellIdSmdsToVtk.size()) // --- resize local vector
// {
// MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << ID << " --> " << ID + SMDS_Mesh::chunkSize);
// myCellIdSmdsToVtk.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1
// }
//
// myCellIdSmdsToVtk[ID] = vtkId;
// //MESSAGE("smds:" << ID << " vtk:" << vtkId );
if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector
{ {
@ -3095,7 +3086,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
{ {
int elemId = elem->GetID(); int elemId = elem->GetID();
int vtkId = elem->getVtkId(); int vtkId = elem->getVtkId();
//MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId); //MESSAGE("RemoveFreeElement " << elemId);
SMDSAbs_ElementType aType = elem->GetType(); SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) { if (aType == SMDSAbs_Node) {

View File

@ -7298,6 +7298,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} }
// Regular elements // Regular elements
// TODO not all the possible cases are solved. Find something more generic?
switch ( nbNodes ) { switch ( nbNodes ) {
case 2: ///////////////////////////////////// EDGE case 2: ///////////////////////////////////// EDGE
isOk = false; break; isOk = false; break;
@ -7675,14 +7676,14 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
//MESSAGE("Change regular element or polygon " << elemId); //MESSAGE("Change regular element or polygon " << elemId);
SMDSAbs_ElementType etyp = elem->GetType(); SMDSAbs_ElementType etyp = elem->GetType();
uniqueNodes.resize(nbUniqueNodes); uniqueNodes.resize(nbUniqueNodes);
aMesh->RemoveElement(elem); SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false);
SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false, elemId);
if (newElem) if (newElem)
{ {
myLastCreatedElems.Append(newElem); myLastCreatedElems.Append(newElem);
if ( aShapeId ) if ( aShapeId )
aMesh->SetMeshElementOnShape( newElem, aShapeId ); aMesh->SetMeshElementOnShape( newElem, aShapeId );
} }
aMesh->RemoveElement(elem);
} }
} }
else { else {
@ -7693,10 +7694,10 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} // loop on elements } // loop on elements
// Remove equal nodes and bad elements // Remove bad elements, then equal nodes (order important)
Remove( rmNodeIds, true );
Remove( rmElemIds, false ); Remove( rmElemIds, false );
Remove( rmNodeIds, true );
} }

View File

@ -740,19 +740,10 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
const SMDS_PositionPtr Pos1 = n1->GetPosition(); const SMDS_PositionPtr Pos1 = n1->GetPosition();
const SMDS_PositionPtr Pos2 = n2->GetPosition(); const SMDS_PositionPtr Pos2 = n2->GetPosition();
bool onGeom = true;
if ((Pos1->GetTypeOfPosition() != SMDS_TOP_FACE) &&
(Pos1->GetTypeOfPosition() != SMDS_TOP_EDGE))
onGeom = false;
if ((Pos2->GetTypeOfPosition() != SMDS_TOP_FACE) &&
(Pos2->GetTypeOfPosition() != SMDS_TOP_EDGE))
onGeom = false;
TopoDS_Edge E; double u [2]; TopoDS_Edge E; double u [2];
TopoDS_Face F; gp_XY uv[2]; TopoDS_Face F; gp_XY uv[2];
bool uvOK[2] = { false, false }; bool uvOK[2] = { false, false };
if (onGeom) {
if( myShape.IsNull() ) if( myShape.IsNull() )
{ {
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) { if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
@ -843,7 +834,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
} }
} }
} }
} // onGeom
// 3d variant // 3d variant
double x = ( n1->X() + n2->X() )/2.; double x = ( n1->X() + n2->X() )/2.;
@ -851,7 +841,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
double z = ( n1->Z() + n2->Z() )/2.; double z = ( n1->Z() + n2->Z() )/2.;
n12 = meshDS->AddNode(x,y,z); n12 = meshDS->AddNode(x,y,z);
if (onGeom) {
if ( !F.IsNull() ) if ( !F.IsNull() )
{ {
gp_XY UV = ( uv[0] + uv[1] ) / 2.; gp_XY UV = ( uv[0] + uv[1] ) / 2.;
@ -868,7 +857,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
{ {
meshDS->SetNodeInVolume(n12, myShapeID); meshDS->SetNodeInVolume(n12, myShapeID);
} }
} // onGeom
myTLinkNodeMap.insert( make_pair( link, n12 )); myTLinkNodeMap.insert( make_pair( link, n12 ));
return n12; return n12;

View File

@ -801,7 +801,7 @@ void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt)
for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ ) for ( ; !subMesh && SubIt != myShapeIndexToSubMesh.end(); SubIt++ )
if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt )) if (!SubIt->second->IsComplexSubmesh() && SubIt->second->Contains( elt ))
subMesh = SubIt->second; subMesh = SubIt->second;
//MESSAGE("subMesh " << elt->getshapeId());
RemoveFreeElement( elt, subMesh, true); RemoveFreeElement( elt, subMesh, true);
return; return;
} }

View File

@ -54,6 +54,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
{ {
if (!IsComplexSubmesh()) if (!IsComplexSubmesh())
{ {
//MESSAGE("in " << myIndex << " AddElement "<< ME->GetID());
int idInSubShape = ME->getIdInShape(); int idInSubShape = ME->getIdInShape();
if (idInSubShape != -1) if (idInSubShape != -1)
{ {
@ -74,24 +75,29 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
//======================================================================= //=======================================================================
bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted) bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDeleted)
{ {
// MESSAGE("--------------------------------------> RemoveElement " << isElemDeleted); if (!ME)
{
MESSAGE("-----------------> Remove Null Element " << isElemDeleted);
return false;
}
//MESSAGE("-----------------> RemoveElement "<< ME->GetID() << " " << isElemDeleted);
if (!IsComplexSubmesh()) if (!IsComplexSubmesh())
{ {
if (!isElemDeleted) // alive element has valid ID and can be found // if (!isElemDeleted) // alive element has valid ID and can be found
// {
int idInSubShape = ME->getIdInShape();
//MESSAGE("in "<< myIndex << " RemoveElement " << ME->GetID() << " " << idInSubShape << " " << myUnusedIdElements);
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(0);
elem->setIdInShape(-1);
if ((idInSubShape >= 0) && (idInSubShape < myElements.size()))
{ {
int idInSubShape = ME->getIdInShape();
//MESSAGE("SMESHDS_SubMesh::RemoveElement " << idInSubShape << " " << ME->GetID() << " " << myUnusedIdElements);
assert(idInSubShape >= 0);
assert(idInSubShape < myElements.size());
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setShapeId(0);
elem->setIdInShape(-1);
myElements[idInSubShape] = 0; // this vector entry is no more used myElements[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdElements++; myUnusedIdElements++;
return true; return true;
} }
//MESSAGE("Try to remove an already deleted element from a submesh ");
return false; return false;
// }
} }
MESSAGE("Try to remove an element from a complex submesh "); MESSAGE("Try to remove an element from a complex submesh ");
return false; return false;
@ -117,6 +123,7 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N)
node->setShapeId(myIndex); node->setShapeId(myIndex);
node->setIdInShape(myNodes.size()); node->setIdInShape(myNodes.size());
myNodes.push_back(N); myNodes.push_back(N);
//MESSAGE("in "<< myIndex << " AddNode " << node->GetID());
} }
//MESSAGE("try to add node in a complex submesh " << N->GetID()); //MESSAGE("try to add node in a complex submesh " << N->GetID());
} }
@ -130,22 +137,22 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted)
{ {
if (!IsComplexSubmesh()) if (!IsComplexSubmesh())
{ {
if (!isNodeDeleted) // alive node has valid ID and can be found // if (!isNodeDeleted) // alive node has valid ID and can be found
// {
int idInSubShape = N->getIdInShape();
int shapeId = N->getshapeId();
//MESSAGE("in "<< myIndex << " RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
node->setShapeId(0);
node->setIdInShape(-1);
if ((idInSubShape >= 0) && (idInSubShape < myNodes.size()))
{ {
int idInSubShape = N->getIdInShape();
int shapeId = N->getshapeId();
MESSAGE("SMESHDS_SubMesh::RemoveNode " << shapeId << " " << idInSubShape << " " << N->GetID());
//assert(idInSubShape >= 0);
//assert(idInSubShape < myNodes.size());
SMDS_MeshNode* node = (SMDS_MeshNode*) (N);
node->setShapeId(0);
node->setIdInShape(-1);
myNodes[idInSubShape] = 0; // this vector entry is no more used myNodes[idInSubShape] = 0; // this vector entry is no more used
myUnusedIdNodes++; myUnusedIdNodes++;
return true; return true;
} }
//MESSAGE("Try to remove an already deleted node from a submesh");
return false; return false;
// }
} }
MESSAGE("Try to remove a node from a complex submesh"); MESSAGE("Try to remove a node from a complex submesh");
return false; return false;
@ -424,7 +431,12 @@ int SMESHDS_SubMesh::getSize()
void SMESHDS_SubMesh::compactList() void SMESHDS_SubMesh::compactList()
{ {
MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size()); //MESSAGE("compactList old: nodes " << myNodes.size() << " elements " << myElements.size());
//stringstream a;
//stringstream b;
//stringstream c;
//stringstream d;
std::vector<const SMDS_MeshElement*> newElems; std::vector<const SMDS_MeshElement*> newElems;
newElems.clear(); newElems.clear();
for (int i = 0; i < myElements.size(); i++) for (int i = 0; i < myElements.size(); i++)
@ -433,9 +445,15 @@ void SMESHDS_SubMesh::compactList()
SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i]; SMDS_MeshElement* elem = (SMDS_MeshElement*)myElements[i];
elem->setIdInShape(newElems.size()); elem->setIdInShape(newElems.size());
newElems.push_back(elem); newElems.push_back(elem);
//a << elem->GetID() << " ";
//b << elem->GetID() << " ";
} }
//else
// a << "_ ";
myElements.swap(newElems); myElements.swap(newElems);
myUnusedIdElements = 0; myUnusedIdElements = 0;
//MESSAGE("in " << myIndex << " oldElems " << a.str());
//MESSAGE("in " << myIndex << " newElems " << b.str());
std::vector<const SMDS_MeshNode*> newNodes; std::vector<const SMDS_MeshNode*> newNodes;
newNodes.clear(); newNodes.clear();
@ -445,8 +463,14 @@ void SMESHDS_SubMesh::compactList()
SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i]; SMDS_MeshNode* node = (SMDS_MeshNode*)myNodes[i];
node->setIdInShape(newNodes.size()); node->setIdInShape(newNodes.size());
newNodes.push_back(node); newNodes.push_back(node);
//c << node->GetID() << " ";
//d << node->GetID() << " ";
} }
//else
// c << "_ ";
myNodes.swap(newNodes); myNodes.swap(newNodes);
myUnusedIdNodes = 0; myUnusedIdNodes = 0;
//MESSAGE("in " << myIndex << " oldNodes " << c.str());
//MESSAGE("in " << myIndex << " newNodes " << d.str());
//MESSAGE("compactList new: nodes " << myNodes.size() << " elements " << myElements.size()); //MESSAGE("compactList new: nodes " << myNodes.size() << " elements " << myElements.size());
} }