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

@ -1390,15 +1390,6 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element)
if (vtkId == -1)
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
{
MESSAGE(" --------------------- resize myCellIdVtkToSmds " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize);
@ -3095,7 +3086,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem)
{
int elemId = elem->GetID();
int vtkId = elem->getVtkId();
//MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId);
//MESSAGE("RemoveFreeElement " << elemId);
SMDSAbs_ElementType aType = elem->GetType();
SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem);
if (aType == SMDSAbs_Node) {

View File

@ -7298,6 +7298,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
}
// Regular elements
// TODO not all the possible cases are solved. Find something more generic?
switch ( nbNodes ) {
case 2: ///////////////////////////////////// EDGE
isOk = false; break;
@ -7675,14 +7676,14 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
//MESSAGE("Change regular element or polygon " << elemId);
SMDSAbs_ElementType etyp = elem->GetType();
uniqueNodes.resize(nbUniqueNodes);
aMesh->RemoveElement(elem);
SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false, elemId);
SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false);
if (newElem)
{
myLastCreatedElems.Append(newElem);
if ( aShapeId )
aMesh->SetMeshElementOnShape( newElem, aShapeId );
}
aMesh->RemoveElement(elem);
}
}
else {
@ -7693,10 +7694,10 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} // loop on elements
// Remove equal nodes and bad elements
// Remove bad elements, then equal nodes (order important)
Remove( rmNodeIds, true );
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 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_Face F; gp_XY uv[2];
bool uvOK[2] = { false, false };
if (onGeom) {
if( myShape.IsNull() )
{
if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) {
@ -843,7 +834,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1,
}
}
}
} // onGeom
// 3d variant
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.;
n12 = meshDS->AddNode(x,y,z);
if (onGeom) {
if ( !F.IsNull() )
{
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);
}
} // onGeom
myTLinkNodeMap.insert( make_pair( link, n12 ));
return n12;

View File

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

View File

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