PR: debug autotests in progress, still 98 bugs

This commit is contained in:
prascle 2010-10-20 15:21:51 +00:00
parent a9f0b60709
commit 53a9669e91
16 changed files with 525 additions and 345 deletions

View File

@ -65,7 +65,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
for(; anIter != aDataSet2411.end(); anIter++){ for(; anIter != aDataSet2411.end(); anIter++){
const TNodeLab& aLabel = anIter->first; const TNodeLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second; const TRecord& aRec = anIter->second;
MESSAGE("AddNodeWithID " << aLabel << " " << aRec.coord[0] << " " << aRec.coord[1] << " " << aRec.coord[2]); //MESSAGE("AddNodeWithID " << aLabel << " " << aRec.coord[0] << " " << aRec.coord[1] << " " << aRec.coord[2]);
myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel); myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
} }
} }
@ -83,13 +83,13 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
if(IsBeam(aRec.fe_descriptor_id)) { if(IsBeam(aRec.fe_descriptor_id)) {
switch ( aRec.node_labels.size() ) { switch ( aRec.node_labels.size() ) {
case 2: // edge with two nodes case 2: // edge with two nodes
MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1]); //MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0], anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[1], aRec.node_labels[1],
aLabel); aLabel);
break; break;
case 3: // quadratic edge (with 3 nodes) case 3: // quadratic edge (with 3 nodes)
MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2]); //MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0], anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[1], aRec.node_labels[1],
@ -97,7 +97,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
} }
} }
else if(IsFace(aRec.fe_descriptor_id)) { else if(IsFace(aRec.fe_descriptor_id)) {
MESSAGE("add face " << aLabel); //MESSAGE("add face " << aLabel);
switch(aRec.fe_descriptor_id){ switch(aRec.fe_descriptor_id){
case 71: // TRI3 case 71: // TRI3
case 72: case 72:
@ -113,7 +113,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
case 42: // Plane Stress Quadratic Triangle - TRI6 case 42: // Plane Stress Quadratic Triangle - TRI6
case 92: // Thin Shell Quadratic Triangle - TRI6 case 92: // Thin Shell Quadratic Triangle - TRI6
MESSAGE("add face " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2] << " " << aRec.node_labels[3] << " " << aRec.node_labels[4] << " " << aRec.node_labels[5]); //MESSAGE("add face " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2] << " " << aRec.node_labels[3] << " " << aRec.node_labels[4] << " " << aRec.node_labels[5]);
anElement = myMesh->AddFaceWithID(aRec.node_labels[0], anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[2], aRec.node_labels[2],
aRec.node_labels[4], aRec.node_labels[4],
@ -147,7 +147,7 @@ Driver_Mesh::Status DriverUNV_R_SMDS_Mesh::Perform()
} }
} }
else if(IsVolume(aRec.fe_descriptor_id)){ else if(IsVolume(aRec.fe_descriptor_id)){
MESSAGE("add volume " << aLabel); //MESSAGE("add volume " << aLabel);
switch(aRec.fe_descriptor_id){ switch(aRec.fe_descriptor_id){
case 111: // Solid Linear Tetrahedron - TET4 case 111: // Solid Linear Tetrahedron - TET4

View File

@ -20,7 +20,7 @@
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
// //
// SMESH SMDS : implementaion of Salome mesh data structure // SMESH SMDS : implementation of Salome mesh data structure
// //
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(disable:4786) #pragma warning(disable:4786)
@ -373,7 +373,7 @@ SMDS_MeshFace* SMDS_Mesh::AddFaceWithID(const SMDS_MeshNode * n1,
const SMDS_MeshNode * n3, const SMDS_MeshNode * n3,
int ID) int ID)
{ {
//MESSAGE("AddFaceWithID " << ID) //MESSAGE("AddFaceWithID " << ID)
SMDS_MeshFace * face=createTriangle(n1, n2, n3, ID); SMDS_MeshFace * face=createTriangle(n1, n2, n3, ID);
// if (face && !registerElement(ID, face)) { // if (face && !registerElement(ID, face)) {
@ -1145,28 +1145,50 @@ SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID
SMDS_MeshFace * face; SMDS_MeshFace * face;
//if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); //if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
MESSAGE("AddPolygonalFaceWithID " << ID);
if (hasConstructionEdges()) if (hasConstructionEdges())
{ {
MESSAGE("Error : Not implemented"); MESSAGE("Error : Not implemented");
return NULL; return NULL;
} }
else else
{ {
for ( int i = 0; i < nodes.size(); ++i ) #ifdef VTK_HAVE_POLYHEDRON
if ( !nodes[ i ] ) return 0; MESSAGE("AddPolygonalFaceWithID vtk " << ID);
face = new SMDS_PolygonalFaceOfNodes(nodes); vector<vtkIdType> nodeIds;
adjustmyCellsCapacity(ID); nodeIds.clear();
myCells[ID] = face; vector<const SMDS_MeshNode*>::iterator it = nodes.begin();
myInfo.myNbPolygons++; for ( ; it != nodes.end(); ++it)
} nodeIds.push_back((*it)->getId());
if (!registerElement(ID, face)) { SMDS_VtkFace *facevtk = myFacePool->getNew();
registerElement(myElementIDFactory->GetFreeID(), face); facevtk->initPoly(nodeIds, this);
//RemoveElement(face, false); if (!this->registerElement(ID,facevtk))
//face = NULL; {
} this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
return face; myFacePool->destroy(facevtk);
return 0;
}
face = facevtk;
#else
MESSAGE("AddPolygonalFaceWithID smds " << ID);
for ( int i = 0; i < nodes.size(); ++i )
if ( !nodes[ i ] ) return 0;
face = new SMDS_PolygonalFaceOfNodes(nodes);
#endif
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbPolygons++;
}
#ifndef VTK_HAVE_POLYHEDRON
if (!registerElement(ID, face))
{
registerElement(myElementIDFactory->GetFreeID(), face);
//RemoveElement(face, false);
//face = NULL;
}
#endif
return face;
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -1211,48 +1233,55 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolumeWithID
vector<int> quantities, vector<int> quantities,
const int ID) const int ID)
{ {
MESSAGE("AddPolyhedralVolumeWithID" << ID);
SMDS_MeshVolume* volume; SMDS_MeshVolume* volume;
//if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); //if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionFaces()) { if (hasConstructionFaces())
MESSAGE("Error : Not implemented"); {
return NULL; MESSAGE("Error : Not implemented");
} else if (hasConstructionEdges()) { return NULL;
MESSAGE("Error : Not implemented"); }
return NULL; else if (hasConstructionEdges())
} else { {
MESSAGE("Error : Not implemented");
return NULL;
}
else
{
#ifdef VTK_HAVE_POLYHEDRON #ifdef VTK_HAVE_POLYHEDRON
vector<vtkIdType> nodeIds; MESSAGE("AddPolyhedralVolumeWithID vtk " << ID);
nodeIds.clear(); vector<vtkIdType> nodeIds;
vector<const SMDS_MeshNode*>::iterator it = nodes.begin(); nodeIds.clear();
for ( ; it != nodes.end(); ++it) vector<const SMDS_MeshNode*>::iterator it = nodes.begin();
nodeIds.push_back((*it)->getId()); for (; it != nodes.end(); ++it)
nodeIds.push_back((*it)->getId());
SMDS_VtkVolume *volvtk = myVolumePool->getNew(); SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->initPoly(nodeIds, quantities, this); volvtk->initPoly(nodeIds, quantities, this);
if (!this->registerElement(ID,volvtk)) if (!this->registerElement(ID, volvtk))
{ {
this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
myVolumePool->destroy(volvtk); myVolumePool->destroy(volvtk);
return 0; return 0;
} }
volume = volvtk; volume = volvtk;
#else #else
for ( int i = 0; i < nodes.size(); ++i ) MESSAGE("AddPolyhedralVolumeWithID smds " << ID);
for ( int i = 0; i < nodes.size(); ++i )
if ( !nodes[ i ] ) return 0; if ( !nodes[ i ] ) return 0;
volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities); volume = new SMDS_PolyhedralVolumeOfNodes(nodes, quantities);
#endif #endif
adjustmyCellsCapacity(ID); adjustmyCellsCapacity(ID);
myCells[ID] = volume; myCells[ID] = volume;
myInfo.myNbPolyhedrons++; myInfo.myNbPolyhedrons++;
} }
#ifndef VTK_HAVE_POLYHEDRON #ifndef VTK_HAVE_POLYHEDRON
if (!registerElement(ID, volume)) { if (!registerElement(ID, volume))
registerElement(myElementIDFactory->GetFreeID(), volume); {
//RemoveElement(volume, false); registerElement(myElementIDFactory->GetFreeID(), volume);
//volume = NULL; //RemoveElement(volume, false);
} //volume = NULL;
}
#endif #endif
return volume; return volume;
} }
@ -2721,7 +2750,7 @@ void SMDS_Mesh::addChildrenWithNodes(set<const SMDS_MeshElement*>& setOfChildren
switch(element->GetType()) switch(element->GetType())
{ {
case SMDSAbs_Node: case SMDSAbs_Node:
MESSAGE("Internal Error: This should not happend"); MESSAGE("Internal Error: This should not happen");
break; break;
case SMDSAbs_0DElement: case SMDSAbs_0DElement:
{ {
@ -2803,130 +2832,140 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem,
//MESSAGE("SMDS_Mesh::RemoveElement " << elem->GetID() << " " << removenodes); //MESSAGE("SMDS_Mesh::RemoveElement " << elem->GetID() << " " << removenodes);
// get finite elements built on elem // get finite elements built on elem
set<const SMDS_MeshElement*> * s1; set<const SMDS_MeshElement*> * s1;
if (elem->GetType() == SMDSAbs_0DElement || if (elem->GetType() == SMDSAbs_0DElement || elem->GetType() == SMDSAbs_Edge && !hasConstructionEdges()
elem->GetType() == SMDSAbs_Edge && !hasConstructionEdges() || || elem->GetType() == SMDSAbs_Face && !hasConstructionFaces() || elem->GetType() == SMDSAbs_Volume)
elem->GetType() == SMDSAbs_Face && !hasConstructionFaces() || {
elem->GetType() == SMDSAbs_Volume) s1 = new set<const SMDS_MeshElement*> ();
{ s1->insert(elem);
s1 = new set<const SMDS_MeshElement*>(); }
s1->insert(elem);
}
else else
s1 = getFinitElements(elem); s1 = getFinitElements(elem);
// get exclusive nodes (which would become free afterwards) // get exclusive nodes (which would become free afterwards)
set<const SMDS_MeshElement*> * s2; set<const SMDS_MeshElement*> * s2;
if (elem->GetType() == SMDSAbs_Node) // a node is removed if (elem->GetType() == SMDSAbs_Node) // a node is removed
{ {
// do not remove nodes except elem // do not remove nodes except elem
s2 = new set<const SMDS_MeshElement*>(); s2 = new set<const SMDS_MeshElement*> ();
s2->insert(elem); s2->insert(elem);
removenodes = true; removenodes = true;
} }
else else
s2 = getExclusiveNodes(*s1); s2 = getExclusiveNodes(*s1);
// form the set of finite and construction elements to remove // form the set of finite and construction elements to remove
set<const SMDS_MeshElement*> s3; set<const SMDS_MeshElement*> s3;
set<const SMDS_MeshElement*>::iterator it=s1->begin(); set<const SMDS_MeshElement*>::iterator it = s1->begin();
while(it!=s1->end()) while (it != s1->end())
{
addChildrenWithNodes(s3, *it ,*s2);
s3.insert(*it);
it++;
}
if(elem->GetType()!=SMDSAbs_Node) s3.insert(elem);
// remove finite and construction elements
it=s3.begin();
while(it!=s3.end())
{
// Remove element from <InverseElements> of its nodes
SMDS_ElemIteratorPtr itn=(*it)->nodesIterator();
while(itn->more())
{ {
SMDS_MeshNode * n = static_cast<SMDS_MeshNode *> addChildrenWithNodes(s3, *it, *s2);
(const_cast<SMDS_MeshElement *>(itn->next())); s3.insert(*it);
n->RemoveInverseElement( (*it) );
}
int IdToRemove = (*it)->GetID();
MESSAGE("elem Id to remove " << IdToRemove << " vtktype " << (*it)->GetVtkType());
switch((*it)->GetType())
{
case SMDSAbs_Node:
MYASSERT("Internal Error: This should not happen");
break;
case SMDSAbs_0DElement:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ?
myInfo.remove(*it);
}
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID(IdToRemove);
delete (*it);
break;
case SMDSAbs_Edge:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveEdge(*it);
}
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkEdge* vtkElem = dynamic_cast<const SMDS_VtkEdge*>(*it))
myEdgePool->destroy((SMDS_VtkEdge*)vtkElem);
else delete (*it);
break;
case SMDSAbs_Face:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveFace(*it);
}
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkFace* vtkElem = dynamic_cast<const SMDS_VtkFace*>(*it))
myFacePool->destroy((SMDS_VtkFace*)vtkElem);
else delete (*it);
break;
case SMDSAbs_Volume:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveVolume(*it);
}
removedElems.push_back( (*it) );
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkVolume* vtkElem = dynamic_cast<const SMDS_VtkVolume*>(*it))
myVolumePool->destroy((SMDS_VtkVolume*)vtkElem);
else delete (*it);
break;
}
it++;
}
// remove exclusive (free) nodes
if(removenodes)
{
it=s2->begin();
while(it!=s2->end())
{
int IdToRemove = (*it)->GetID();
MESSAGE( "SMDS: RM node " << IdToRemove);
if (IdToRemove >= 0)
{
myNodes[IdToRemove] = 0;
myInfo.myNbNodes--;
}
myNodeIDFactory->ReleaseID((*it)->GetID());
removedNodes.push_back( (*it) );
if (const SMDS_MeshNode* vtkElem = dynamic_cast<const SMDS_MeshNode*>(*it))
myNodePool->destroy((SMDS_MeshNode*)vtkElem);
else delete (*it);
it++; it++;
} }
} if (elem->GetType() != SMDSAbs_Node)
s3.insert(elem);
// remove finite and construction elements
it = s3.begin();
while (it != s3.end())
{
// Remove element from <InverseElements> of its nodes
SMDS_ElemIteratorPtr itn = (*it)->nodesIterator();
while (itn->more())
{
SMDS_MeshNode * n = static_cast<SMDS_MeshNode *> (const_cast<SMDS_MeshElement *> (itn->next()));
n->RemoveInverseElement((*it));
}
int IdToRemove = (*it)->GetID();
int vtkid = this->fromSmdsToVtk(IdToRemove);
//MESSAGE("elem Id to remove " << IdToRemove << " vtkid " << vtkid <<
// " vtktype " << (*it)->GetVtkType() << " type " << (*it)->GetType());
switch ((*it)->GetType())
{
case SMDSAbs_Node:
MYASSERT("Internal Error: This should not happen")
;
break;
case SMDSAbs_0DElement:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ?
myInfo.remove(*it);
}
removedElems.push_back((*it));
myElementIDFactory->ReleaseID(IdToRemove);
delete (*it);
break;
case SMDSAbs_Edge:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveEdge(*it);
}
removedElems.push_back((*it));
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkEdge* vtkElem = dynamic_cast<const SMDS_VtkEdge*>(*it))
myEdgePool->destroy((SMDS_VtkEdge*) vtkElem);
else
delete (*it);
break;
case SMDSAbs_Face:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveFace(*it);
}
removedElems.push_back((*it));
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkFace* vtkElem = dynamic_cast<const SMDS_VtkFace*>(*it))
myFacePool->destroy((SMDS_VtkFace*) vtkElem);
else
delete (*it);
break;
case SMDSAbs_Volume:
if (IdToRemove >= 0)
{
myCells[IdToRemove] = 0;
myInfo.RemoveVolume(*it);
}
removedElems.push_back((*it));
myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkVolume* vtkElem = dynamic_cast<const SMDS_VtkVolume*>(*it))
myVolumePool->destroy((SMDS_VtkVolume*) vtkElem);
else
delete (*it);
break;
}
if (vtkid >= 0)
{
//MESSAGE("VTK_EMPTY_CELL in " << vtkid);
this->myGrid->GetCellTypesArray()->SetValue(vtkid, VTK_EMPTY_CELL);
}
it++;
}
// remove exclusive (free) nodes
if (removenodes)
{
it = s2->begin();
while (it != s2->end())
{
int IdToRemove = (*it)->GetID();
//MESSAGE( "SMDS: RM node " << IdToRemove);
if (IdToRemove >= 0)
{
myNodes[IdToRemove] = 0;
myInfo.myNbNodes--;
}
myNodeIDFactory->ReleaseID((*it)->GetID());
removedNodes.push_back((*it));
if (const SMDS_MeshNode* vtkElem = dynamic_cast<const SMDS_MeshNode*>(*it))
myNodePool->destroy((SMDS_MeshNode*) vtkElem);
else
delete (*it);
it++;
}
}
delete s2; delete s2;
delete s1; delete s1;

View File

@ -134,7 +134,7 @@ void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{ {
if (ID < 0) if (ID < 0)
{ {
MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
return; return;
} }
int vtkId = myMesh->myIDElements[ID]; int vtkId = myMesh->myIDElements[ID];

View File

@ -264,7 +264,7 @@ void SMDS_UnstructuredGrid::compactGrid(std::vector<int>& idNodesOldToNew, int n
MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize); MESSAGE(" -------- newCellSize, endBloc " << endBloc << " " << oldCellSize);
copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell, copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell,
alreadyCopied, startBloc, endBloc); alreadyCopied, startBloc, endBloc);
compactState = lookHoleStart; compactState = lookHoleEnd;
} }
break; break;
} }

View File

@ -104,7 +104,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh,
_cellId = vtkCellId; _cellId = vtkCellId;
_index = 0; _index = 0;
_type = aType; _type = aType;
MESSAGE("SMDS_VtkCellInterlacedIterator " << _type); //MESSAGE("SMDS_VtkCellInterlacedIterator " << _type);
_vtkIdList = vtkIdList::New(); _vtkIdList = vtkIdList::New();
vtkIdType* pts; vtkIdType* pts;
@ -164,19 +164,11 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh,
} }
case SMDSEntity_Polygon: case SMDSEntity_Polygon:
case SMDSEntity_Quad_Polygon: case SMDSEntity_Quad_Polygon:
{
MESSAGE("SMDS_VtkCellIterator polygon");
break;
}
case SMDSEntity_Polyhedra: case SMDSEntity_Polyhedra:
case SMDSEntity_Quad_Polyhedra: case SMDSEntity_Quad_Polyhedra:
{
MESSAGE("SMDS_VtkCellIterator Polyhedra");
break;
}
default: default:
{ {
static int id[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; static int id[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29};
ids = id; ids = id;
break; break;
} }

View File

@ -58,6 +58,15 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
return true; return true;
} }
bool SMDS_VtkEdge::IsMediumNode(const SMDS_MeshNode* node) const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType npts = 0;
vtkIdType* pts = 0;
grid->GetCellPoints(myVtkID, npts, pts);
return ((npts == 3) && (node->GetID() == pts[2]));
}
void SMDS_VtkEdge::Print(std::ostream & OS) const void SMDS_VtkEdge::Print(std::ostream & OS) const
{ {
OS << "edge <" << GetID() << "> : "; OS << "edge <" << GetID() << "> : ";
@ -101,7 +110,8 @@ vtkIdType SMDS_VtkEdge::GetVtkType() const
const SMDS_MeshNode* const SMDS_MeshNode*
SMDS_VtkEdge::GetNode(const int ind) const SMDS_VtkEdge::GetNode(const int ind) const
{ {
return SMDS_MeshElement::GetNode(ind); // --- a optimiser ! // TODO optimize !!
return SMDS_MeshElement::GetNode(ind);
} }
bool SMDS_VtkEdge::IsQuadratic() const bool SMDS_VtkEdge::IsQuadratic() const

View File

@ -17,6 +17,7 @@ public:
void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh); void init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2); bool ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2);
virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); virtual bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
virtual bool IsMediumNode(const SMDS_MeshNode* node) const;
void Print(std::ostream & OS) const; void Print(std::ostream & OS) const;
int NbNodes() const; int NbNodes() const;

View File

@ -43,12 +43,20 @@ void SMDS_VtkFace::init(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
aType = VTK_QUADRATIC_QUAD; aType = VTK_QUADRATIC_QUAD;
break; break;
default: default:
aType = VTK_TRIANGLE; aType = VTK_POLYGON;
break; break;
} }
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
} }
void SMDS_VtkFace::initPoly(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh)
{
vtkUnstructuredGrid* grid = mesh->getGrid();
myIdInShape = -1;
myMeshId = mesh->getMeshId();
myVtkID = grid->InsertNextLinkedCell(VTK_POLYGON, nodeIds.size(), &nodeIds[0]);
}
bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{ {
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid(); vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
@ -60,7 +68,7 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes); MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
return false; return false;
} }
for (int i=0; i<nbNodes; i++) for (int i = 0; i < nbNodes; i++)
{ {
pts[i] = nodes[i]->GetID(); pts[i] = nodes[i]->GetID();
} }
@ -69,24 +77,31 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
void SMDS_VtkFace::Print(std::ostream & OS) const void SMDS_VtkFace::Print(std::ostream & OS) const
{ {
OS << "edge <" << GetID() << "> : "; OS << "face <" << GetID() << "> : ";
} }
int SMDS_VtkFace::NbEdges() const int SMDS_VtkFace::NbEdges() const
{ {
switch (NbNodes()) // TODO quadratic polygons ?
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbEdges = 3;
switch (aVtkType)
{ {
case 3: case VTK_TRIANGLE:
case 6: case VTK_QUADRATIC_TRIANGLE:
return 3; nbEdges = 3;
case 4: break;
case 8: case VTK_QUAD:
return 4; case VTK_QUADRATIC_QUAD:
nbEdges = 4;
break;
case VTK_POLYGON:
default: default:
MESSAGE("invalid number of nodes") nbEdges = grid->GetCell(myVtkID)->GetNumberOfPoints();
; break;
} }
return 0; return nbEdges;
} }
int SMDS_VtkFace::NbFaces() const int SMDS_VtkFace::NbFaces() const
@ -114,63 +129,73 @@ SMDS_VtkFace::GetNode(const int ind) const
bool SMDS_VtkFace::IsQuadratic() const bool SMDS_VtkFace::IsQuadratic() const
{ {
if (this->NbNodes() > 5) vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
return true; vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
else // TODO quadratic polygons ?
return false; switch (aVtkType)
{
case VTK_QUADRATIC_TRIANGLE:
case VTK_QUADRATIC_QUAD:
return true;
break;
default:
return false;
}
}
bool SMDS_VtkFace::IsPoly() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return (aVtkType == VTK_POLYGON);
} }
SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
{ {
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
SMDSAbs_EntityType aType = SMDSEntity_Polygon; SMDSAbs_EntityType aType = SMDSEntity_Polygon;
switch (NbNodes()) switch (aVtkType)
{ {
case 3: case VTK_TRIANGLE:
aType = SMDSEntity_Triangle; aType = SMDSEntity_Triangle;
break; break;
case 6: case VTK_QUAD:
aType = SMDSEntity_Quad_Triangle;
break;
case 4:
aType = SMDSEntity_Quadrangle; aType = SMDSEntity_Quadrangle;
break; break;
case 8: case VTK_QUADRATIC_TRIANGLE:
aType = SMDSEntity_Quad_Triangle;
break;
case VTK_QUADRATIC_QUAD:
aType = SMDSEntity_Quad_Quadrangle; aType = SMDSEntity_Quad_Quadrangle;
break; break;
default:
aType = SMDSEntity_Polygon;
} }
return aType; return aType;
} }
vtkIdType SMDS_VtkFace::GetVtkType() const vtkIdType SMDS_VtkFace::GetVtkType() const
{
switch (NbNodes())
{ {
case 3: vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
return VTK_TRIANGLE; vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
case 6: return aVtkType;
return VTK_QUADRATIC_TRIANGLE;
case 4:
return VTK_QUAD;
case 8:
return VTK_QUADRATIC_QUAD;
default:
return VTK_POLYGON;
} }
}
SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const SMDS_ElemIteratorPtr SMDS_VtkFace::elementsIterator(SMDSAbs_ElementType type) const
{
switch (type)
{ {
case SMDSAbs_Node: switch (type)
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); {
default: case SMDSAbs_Node:
MESSAGE("ERROR : Iterator not implemented"); return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL); default:
MESSAGE("ERROR : Iterator not implemented")
;
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
} }
}
SMDS_ElemIteratorPtr SMDS_VtkFace::nodesIteratorToUNV() const SMDS_ElemIteratorPtr SMDS_VtkFace::nodesIteratorToUNV() const
{ {
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType())); return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
} }

View File

@ -14,6 +14,7 @@ public:
SMDS_VtkFace(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh); SMDS_VtkFace(std::vector<vtkIdType> nodeIds, SMDS_Mesh* mesh);
~SMDS_VtkFace(); ~SMDS_VtkFace();
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);
bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes);
void Print(std::ostream & OS) const; void Print(std::ostream & OS) const;
@ -25,6 +26,7 @@ public:
virtual SMDSAbs_EntityType GetEntityType() const; virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const; virtual bool IsQuadratic() const;
virtual bool IsPoly() const;
protected: protected:
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -63,6 +63,9 @@ void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> n
{ {
MESSAGE("SMDS_VtkVolume::initPoly"); MESSAGE("SMDS_VtkVolume::initPoly");
SMDS_UnstructuredGrid* grid = mesh->getGrid(); SMDS_UnstructuredGrid* grid = mesh->getGrid();
// TODO is it useful to orient faces ?
double center[3];
this->gravityCenter(grid, &nodeIds[0], nodeIds.size(), &center[0]);
vector<vtkIdType> ptIds; vector<vtkIdType> ptIds;
ptIds.clear(); ptIds.clear();
vtkIdType nbFaces = nbNodesPerFace.size(); vtkIdType nbFaces = nbNodesPerFace.size();
@ -71,11 +74,22 @@ void SMDS_VtkVolume::initPoly(std::vector<vtkIdType> nodeIds, std::vector<int> n
{ {
int nf = nbNodesPerFace[i]; int nf = nbNodesPerFace[i];
ptIds.push_back(nf); ptIds.push_back(nf);
for (int n = 0; n < nf; n++) double a[3];
{ double b[3];
ptIds.push_back(nodeIds[k]); double c[3];
k++; grid->GetPoints()->GetPoint(nodeIds[k],a);
} grid->GetPoints()->GetPoint(nodeIds[k+1],b);
grid->GetPoints()->GetPoint(nodeIds[k+2],c);
bool isFaceForward = this->isForward(a, b, c, center);
//MESSAGE("isFaceForward " << i << " " << isFaceForward);
vtkIdType *facePts = &nodeIds[k];
if (isFaceForward)
for (int n = 0; n < nf; n++)
ptIds.push_back(facePts[n]);
else
for (int n = nf-1; n >= 0; n--)
ptIds.push_back(facePts[n]);
k += nf;
} }
myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]); myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]);
} }
@ -110,26 +124,38 @@ void SMDS_VtkVolume::Print(ostream & OS) const
int SMDS_VtkVolume::NbFaces() const int SMDS_VtkVolume::NbFaces() const
{ {
// TODO polyedres vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
switch (NbNodes()) vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbFaces = 4;
switch (aVtkType)
{ {
case 4: case VTK_TETRA:
case 10: case VTK_QUADRATIC_TETRA:
return 4; nbFaces = 4;
case 5: break;
case 13: case VTK_PYRAMID:
return 5; case VTK_WEDGE:
case 6: case VTK_QUADRATIC_PYRAMID:
case 15: case VTK_QUADRATIC_WEDGE:
return 5; nbFaces = 5;
case 8: break;
case 20: case VTK_HEXAHEDRON:
return 6; case VTK_QUADRATIC_HEXAHEDRON:
nbFaces = 6;
break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
nbFaces = nFaces;
}
default: default:
MESSAGE("invalid number of nodes") MESSAGE("invalid volume type");
; nbFaces = 0;
break;
} }
return 0; return nbFaces;
} }
int SMDS_VtkVolume::NbNodes() const int SMDS_VtkVolume::NbNodes() const
@ -141,26 +167,49 @@ int SMDS_VtkVolume::NbNodes() const
int SMDS_VtkVolume::NbEdges() const int SMDS_VtkVolume::NbEdges() const
{ {
// TODO polyedres vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
switch (NbNodes()) vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
int nbEdges = 6;
switch (aVtkType)
{ {
case 4: case VTK_TETRA:
case 10: case VTK_QUADRATIC_TETRA:
return 6; nbEdges = 6;
case 5: break;
case 13: case VTK_PYRAMID:
return 8; case VTK_QUADRATIC_PYRAMID:
case 6: nbEdges = 8;
case 15: break;
return 9; case VTK_WEDGE:
case 8: case VTK_QUADRATIC_WEDGE:
case 20: nbEdges = 9;
return 12; break;
case VTK_HEXAHEDRON:
case VTK_QUADRATIC_HEXAHEDRON:
nbEdges = 12;
break;
case VTK_POLYHEDRON:
{
vtkIdType nFaces = 0;
vtkIdType* ptIds = 0;
grid->GetFaceStream(this->myVtkID, nFaces, ptIds);
nbEdges = 0;
int id = 0;
for (int i = 0; i < nFaces; i++)
{
int edgesInFace = ptIds[id];
id += (edgesInFace + 1);
nbEdges += edgesInFace;
}
nbEdges = nbEdges / 2;
break;
}
default: default:
MESSAGE("invalid number of nodes") MESSAGE("invalid volume type");
; nbEdges = 0;
break;
} }
return 0; return nbEdges;
} }
SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const SMDS_ElemIteratorPtr SMDS_VtkVolume::elementsIterator(SMDSAbs_ElementType type) const
@ -198,17 +247,33 @@ const SMDS_MeshNode* SMDS_VtkVolume::GetNode(const int ind) const
bool SMDS_VtkVolume::IsQuadratic() const bool SMDS_VtkVolume::IsQuadratic() const
{ {
// TODO polyedres vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
if (this->NbNodes() > 9) vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return true; // TODO quadratic polyhedrons ?
else switch (aVtkType)
return false; {
case VTK_QUADRATIC_TETRA:
case VTK_QUADRATIC_PYRAMID:
case VTK_QUADRATIC_WEDGE:
case VTK_QUADRATIC_HEXAHEDRON:
return true;
break;
default:
return false;
}
}
bool SMDS_VtkVolume::IsPoly() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
return (aVtkType == VTK_POLYHEDRON);
} }
SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const SMDSAbs_EntityType SMDS_VtkVolume::GetEntityType() const
{ {
// TODO see SMDS_MeshElementIDFactory::GetVtkCellType vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
vtkIdType aVtkType = this->GetVtkType(); vtkIdType aVtkType = grid->GetCellType(this->myVtkID);
SMDSAbs_EntityType aType = SMDSEntity_Tetra; SMDSAbs_EntityType aType = SMDSEntity_Tetra;
switch (aVtkType) switch (aVtkType)
@ -255,3 +320,38 @@ vtkIdType SMDS_VtkVolume::GetVtkType() const
vtkIdType aType = grid->GetCellType(myVtkID); vtkIdType aType = grid->GetCellType(myVtkID);
return aType; return aType;
} }
void SMDS_VtkVolume::gravityCenter(SMDS_UnstructuredGrid* grid, vtkIdType *nodeIds, int nbNodes, double* result)
{
for (int j=0; j<3; j++)
result[j] = 0;
if (nbNodes <= 0)
return;
for (int i =0; i< nbNodes; i++)
{
double *coords = grid->GetPoint(nodeIds[i]);
for (int j=0; j<3; j++)
result[j] += coords[j];
}
for (int j=0; j<3; j++)
result[j] = result[j]/nbNodes;
//MESSAGE("center " << result[0] << " " << result[1] << " " << result[2]);
return;
}
bool SMDS_VtkVolume::isForward(double* a,double* b,double* c,double* d)
{
double u[3], v[3], w[3];
for (int j = 0; j < 3; j++)
{
//MESSAGE("a,b,c,d " << a[j] << " " << b[j] << " " << c[j] << " " << d[j]);
u[j] = b[j] - a[j];
v[j] = c[j] - a[j];
w[j] = d[j] - a[j];
//MESSAGE("u,v,w " << u[j] << " " << v[j] << " " << w[j]);
}
double prodmixte = (u[2] * v[3] - u[3] * v[2]) * w[1]
+ (u[3] * v[1] - u[1] * v[3]) * w[2]
+ (u[1] * v[2] - u[2] * v[1]) * w[3];
return (prodmixte >= 0);
}

View File

@ -28,6 +28,12 @@ public:
virtual SMDSAbs_EntityType GetEntityType() const; virtual SMDSAbs_EntityType GetEntityType() const;
virtual const SMDS_MeshNode* GetNode(const int ind) const; virtual const SMDS_MeshNode* GetNode(const int ind) const;
virtual bool IsQuadratic() const; virtual bool IsQuadratic() const;
virtual bool IsPoly() const;
static void gravityCenter(SMDS_UnstructuredGrid* grid,
vtkIdType *nodeIds,
int nbNodes,
double* result);
static bool isForward(double* a,double* b,double* c,double* d);
protected: protected:
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;

View File

@ -124,75 +124,76 @@ SMESH_MeshEditor::AddElement(const vector<const SMDS_MeshNode*> & node,
const bool isPoly, const bool isPoly,
const int ID) const int ID)
{ {
//MESSAGE("AddElement " <<node.size() << " " << type << " " << isPoly << " " << ID);
SMDS_MeshElement* e = 0; SMDS_MeshElement* e = 0;
int nbnode = node.size(); int nbnode = node.size();
SMESHDS_Mesh* mesh = GetMeshDS(); SMESHDS_Mesh* mesh = GetMeshDS();
switch ( type ) { switch ( type ) {
case SMDSAbs_0DElement: case SMDSAbs_0DElement:
if ( nbnode == 1 ) if ( nbnode == 1 )
if ( ID ) e = mesh->Add0DElementWithID(node[0], ID); if ( ID >= 0 ) e = mesh->Add0DElementWithID(node[0], ID);
else e = mesh->Add0DElement (node[0] ); else e = mesh->Add0DElement (node[0] );
break; break;
case SMDSAbs_Edge: case SMDSAbs_Edge:
if ( nbnode == 2 ) if ( nbnode == 2 )
if ( ID ) e = mesh->AddEdgeWithID(node[0], node[1], ID); if ( ID >= 0 ) e = mesh->AddEdgeWithID(node[0], node[1], ID);
else e = mesh->AddEdge (node[0], node[1] ); else e = mesh->AddEdge (node[0], node[1] );
else if ( nbnode == 3 ) else if ( nbnode == 3 )
if ( ID ) e = mesh->AddEdgeWithID(node[0], node[1], node[2], ID); if ( ID >= 0 ) e = mesh->AddEdgeWithID(node[0], node[1], node[2], ID);
else e = mesh->AddEdge (node[0], node[1], node[2] ); else e = mesh->AddEdge (node[0], node[1], node[2] );
break; break;
case SMDSAbs_Face: case SMDSAbs_Face:
if ( !isPoly ) { if ( !isPoly ) {
if (nbnode == 3) if (nbnode == 3)
if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], ID); if ( ID >= 0 ) e = mesh->AddFaceWithID(node[0], node[1], node[2], ID);
else e = mesh->AddFace (node[0], node[1], node[2] ); else e = mesh->AddFace (node[0], node[1], node[2] );
else if (nbnode == 4) else if (nbnode == 4)
if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3], ID); if ( ID >= 0 ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3], ID);
else e = mesh->AddFace (node[0], node[1], node[2], node[3] ); else e = mesh->AddFace (node[0], node[1], node[2], node[3] );
else if (nbnode == 6) else if (nbnode == 6)
if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3],
node[4], node[5], ID); node[4], node[5], ID);
else e = mesh->AddFace (node[0], node[1], node[2], node[3], else e = mesh->AddFace (node[0], node[1], node[2], node[3],
node[4], node[5] ); node[4], node[5] );
else if (nbnode == 8) else if (nbnode == 8)
if ( ID ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddFaceWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], ID); node[4], node[5], node[6], node[7], ID);
else e = mesh->AddFace (node[0], node[1], node[2], node[3], else e = mesh->AddFace (node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7] ); node[4], node[5], node[6], node[7] );
} else { } else {
if ( ID ) e = mesh->AddPolygonalFaceWithID(node, ID); if ( ID >= 0 ) e = mesh->AddPolygonalFaceWithID(node, ID);
else e = mesh->AddPolygonalFace (node ); else e = mesh->AddPolygonalFace (node );
} }
break; break;
case SMDSAbs_Volume: case SMDSAbs_Volume:
if ( !isPoly ) { if ( !isPoly ) {
if (nbnode == 4) if (nbnode == 4)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], ID); if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], ID);
else e = mesh->AddVolume (node[0], node[1], node[2], node[3] ); else e = mesh->AddVolume (node[0], node[1], node[2], node[3] );
else if (nbnode == 5) else if (nbnode == 5)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], ID); node[4], ID);
else e = mesh->AddVolume (node[0], node[1], node[2], node[3], else e = mesh->AddVolume (node[0], node[1], node[2], node[3],
node[4] ); node[4] );
else if (nbnode == 6) else if (nbnode == 6)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], ID); node[4], node[5], ID);
else e = mesh->AddVolume (node[0], node[1], node[2], node[3], else e = mesh->AddVolume (node[0], node[1], node[2], node[3],
node[4], node[5] ); node[4], node[5] );
else if (nbnode == 8) else if (nbnode == 8)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], ID); node[4], node[5], node[6], node[7], ID);
else e = mesh->AddVolume (node[0], node[1], node[2], node[3], else e = mesh->AddVolume (node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7] ); node[4], node[5], node[6], node[7] );
else if (nbnode == 10) else if (nbnode == 10)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], node[4], node[5], node[6], node[7],
node[8], node[9], ID); node[8], node[9], ID);
else e = mesh->AddVolume (node[0], node[1], node[2], node[3], else e = mesh->AddVolume (node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], node[4], node[5], node[6], node[7],
node[8], node[9] ); node[8], node[9] );
else if (nbnode == 13) else if (nbnode == 13)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], node[4], node[5], node[6], node[7],
node[8], node[9], node[10],node[11], node[8], node[9], node[10],node[11],
node[12],ID); node[12],ID);
@ -201,7 +202,7 @@ SMESH_MeshEditor::AddElement(const vector<const SMDS_MeshNode*> & node,
node[8], node[9], node[10],node[11], node[8], node[9], node[10],node[11],
node[12] ); node[12] );
else if (nbnode == 15) else if (nbnode == 15)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], node[4], node[5], node[6], node[7],
node[8], node[9], node[10],node[11], node[8], node[9], node[10],node[11],
node[12],node[13],node[14],ID); node[12],node[13],node[14],ID);
@ -210,7 +211,7 @@ SMESH_MeshEditor::AddElement(const vector<const SMDS_MeshNode*> & node,
node[8], node[9], node[10],node[11], node[8], node[9], node[10],node[11],
node[12],node[13],node[14] ); node[12],node[13],node[14] );
else if (nbnode == 20) else if (nbnode == 20)
if ( ID ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3], if ( ID >= 0 ) e = mesh->AddVolumeWithID(node[0], node[1], node[2], node[3],
node[4], node[5], node[6], node[7], node[4], node[5], node[6], node[7],
node[8], node[9], node[10],node[11], node[8], node[9], node[10],node[11],
node[12],node[13],node[14],node[15], node[12],node[13],node[14],node[15],
@ -551,7 +552,7 @@ bool SMESH_MeshEditor::InverseDiag (const SMDS_MeshElement * theTria1,
// check case of quadratic faces // check case of quadratic faces
if (theTria1->GetEntityType() != SMDSEntity_Quad_Triangle) if (theTria1->GetEntityType() != SMDSEntity_Quad_Triangle)
return false; return false;
if (theTria2->GetEntityType() == SMDSEntity_Quad_Triangle) if (theTria2->GetEntityType() != SMDSEntity_Quad_Triangle)
return false; return false;
// 5 // 5
@ -7079,10 +7080,12 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
list<const SMDS_MeshNode*>& nodes = *grIt; list<const SMDS_MeshNode*>& nodes = *grIt;
list<const SMDS_MeshNode*>::iterator nIt = nodes.begin(); list<const SMDS_MeshNode*>::iterator nIt = nodes.begin();
const SMDS_MeshNode* nToKeep = *nIt; const SMDS_MeshNode* nToKeep = *nIt;
//MESSAGE("node to keep " << nToKeep->GetID());
for ( ++nIt; nIt != nodes.end(); nIt++ ) { for ( ++nIt; nIt != nodes.end(); nIt++ ) {
const SMDS_MeshNode* nToRemove = *nIt; const SMDS_MeshNode* nToRemove = *nIt;
nodeNodeMap.insert( TNodeNodeMap::value_type( nToRemove, nToKeep )); nodeNodeMap.insert( TNodeNodeMap::value_type( nToRemove, nToKeep ));
if ( nToRemove != nToKeep ) { if ( nToRemove != nToKeep ) {
//MESSAGE(" node to remove " << nToRemove->GetID());
rmNodeIds.push_back( nToRemove->GetID() ); rmNodeIds.push_back( nToRemove->GetID() );
AddToSameGroups( nToKeep, nToRemove, aMesh ); AddToSameGroups( nToKeep, nToRemove, aMesh );
} }
@ -7099,6 +7102,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
set<const SMDS_MeshElement*>::iterator eIt = elems.begin(); set<const SMDS_MeshElement*>::iterator eIt = elems.begin();
for ( ; eIt != elems.end(); eIt++ ) { for ( ; eIt != elems.end(); eIt++ ) {
const SMDS_MeshElement* elem = *eIt; const SMDS_MeshElement* elem = *eIt;
//MESSAGE(" ---- inverse elem on node to remove " << elem->GetID());
int nbNodes = elem->NbNodes(); int nbNodes = elem->NbNodes();
int aShapeId = FindShape( elem ); int aShapeId = FindShape( elem );
@ -7148,6 +7152,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
bool isOk = true; bool isOk = true;
int nbUniqueNodes = nodeSet.size(); int nbUniqueNodes = nodeSet.size();
//MESSAGE("nbNodes nbUniqueNodes " << nbNodes << " " << nbUniqueNodes);
if ( nbNodes != nbUniqueNodes ) { // some nodes stick if ( nbNodes != nbUniqueNodes ) { // some nodes stick
// Polygons and Polyhedral volumes // Polygons and Polyhedral volumes
if (elem->IsPoly()) { if (elem->IsPoly()) {
@ -7251,6 +7256,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
isOk = false; isOk = false;
else if ( nbRepl == 2 && iRepl[ 1 ] - iRepl[ 0 ] == 2 ) else if ( nbRepl == 2 && iRepl[ 1 ] - iRepl[ 0 ] == 2 )
isOk = false; // opposite nodes stick isOk = false; // opposite nodes stick
//MESSAGE("isOk " << isOk);
} }
break; break;
case 6: ///////////////////////////////////// PENTAHEDRON case 6: ///////////////////////////////////// PENTAHEDRON
@ -7600,28 +7606,10 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} }
} }
else { else {
// Change regular element or polygon //MESSAGE("Change regular element or polygon " << elem->GetID());
SMDS_MeshElement* newElem = 0; SMDSAbs_ElementType etyp = elem->GetType();
switch (nbUniqueNodes) uniqueNodes.resize(nbUniqueNodes);
{ SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false);
case 3:
newElem = aMesh->AddFace(uniqueNodes[0], uniqueNodes[1], uniqueNodes[2]);
break;
case 4:
newElem = aMesh->AddVolume(uniqueNodes[0], uniqueNodes[1], uniqueNodes[2],
uniqueNodes[3]);
break;
case 5:
newElem = aMesh->AddVolume(uniqueNodes[0], uniqueNodes[1], uniqueNodes[2],
uniqueNodes[3], uniqueNodes[4]);
break;
case 6:
newElem = aMesh->AddVolume(uniqueNodes[0], uniqueNodes[1], uniqueNodes[2],
uniqueNodes[3], uniqueNodes[4], uniqueNodes[5]);
break;
default:
MESSAGE("invalid number of nodes:" << nbUniqueNodes);
}
if (newElem) if (newElem)
{ {
myLastCreatedElems.Append(newElem); myLastCreatedElems.Append(newElem);
@ -7633,6 +7621,7 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
} }
else { else {
// Remove invalid regular element or invalid polygon // Remove invalid regular element or invalid polygon
//MESSAGE("Remove invalid " << elem->GetID());
rmElemIds.push_back( elem->GetID() ); rmElemIds.push_back( elem->GetID() );
} }
@ -8088,7 +8077,7 @@ SMESH_MeshEditor::SewFreeBorder (const SMDS_MeshNode* theBordFirstNode,
// links of the free border // links of the free border
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// 1. Since sewing may brake if there are volumes to split on the side 2, // 1. Since sewing may break if there are volumes to split on the side 2,
// we wont move nodes but just compute new coordinates for them // we wont move nodes but just compute new coordinates for them
typedef map<const SMDS_MeshNode*, gp_XYZ> TNodeXYZMap; typedef map<const SMDS_MeshNode*, gp_XYZ> TNodeXYZMap;
TNodeXYZMap nBordXYZ; TNodeXYZMap nBordXYZ;
@ -8627,6 +8616,7 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace,
return; return;
} }
SMESHDS_Mesh *aMesh = GetMeshDS();
if( !theFace->IsQuadratic() ) { if( !theFace->IsQuadratic() ) {
// put aNodesToInsert between theBetweenNode1 and theBetweenNode2 // put aNodesToInsert between theBetweenNode1 and theBetweenNode2
@ -8677,7 +8667,6 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace,
} }
// create new elements // create new elements
SMESHDS_Mesh *aMesh = GetMeshDS();
int aShapeId = FindShape( theFace ); int aShapeId = FindShape( theFace );
i1 = 0; i2 = 1; i1 = 0; i2 = 1;
@ -8703,10 +8692,16 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace,
newNodes[ 1 ] = linkNodes[ i2 ]; newNodes[ 1 ] = linkNodes[ i2 ];
newNodes[ 2 ] = nodes[ iSplit >= iBestQuad ? i3 : i4 ]; newNodes[ 2 ] = nodes[ iSplit >= iBestQuad ? i3 : i4 ];
newNodes[ 3 ] = nodes[ i4 ]; newNodes[ 3 ] = nodes[ i4 ];
// TODO problem ChangeElementNodes : not the same number of nodes, not the same type //aMesh->ChangeElementNodes( theFace, newNodes, iSplit == iBestQuad ? 4 : 3 );
MESSAGE("ChangeElementNodes"); const SMDS_MeshElement* newElem = 0;
aMesh->ChangeElementNodes( theFace, newNodes, iSplit == iBestQuad ? 4 : 3 ); if (iSplit == iBestQuad)
} // end if(!theFace->IsQuadratic()) newElem = aMesh->AddFace( newNodes[0], newNodes[1], newNodes[2], newNodes[3] );
else
newElem = aMesh->AddFace( newNodes[0], newNodes[1], newNodes[2] );
myLastCreatedElems.Append(newElem);
if ( aShapeId && newElem )
aMesh->SetMeshElementOnShape( newElem, aShapeId );
} // end if(!theFace->IsQuadratic())
else { // theFace is quadratic else { // theFace is quadratic
// we have to split theFace on simple triangles and one simple quadrangle // we have to split theFace on simple triangles and one simple quadrangle
int tmp = il1/2; int tmp = il1/2;
@ -8733,7 +8728,6 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace,
// n4 n6 n5 n4 // n4 n6 n5 n4
// create new elements // create new elements
SMESHDS_Mesh *aMesh = GetMeshDS();
int aShapeId = FindShape( theFace ); int aShapeId = FindShape( theFace );
int n1,n2,n3; int n1,n2,n3;
@ -8816,9 +8810,9 @@ void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace,
if ( aShapeId && newElem ) if ( aShapeId && newElem )
aMesh->SetMeshElementOnShape( newElem, aShapeId ); aMesh->SetMeshElementOnShape( newElem, aShapeId );
} }
// remove old quadratic face
aMesh->RemoveElement(theFace);
} }
// remove old face
aMesh->RemoveElement(theFace);
} }
//======================================================================= //=======================================================================
@ -9250,7 +9244,7 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1,
// 1. Build set of faces representing each side: // 1. Build set of faces representing each side:
// ======================================================================= // =======================================================================
// a. build set of nodes belonging to faces // a. build set of nodes belonging to faces
// b. complete set of faces: find missing fices whose nodes are in set of nodes // b. complete set of faces: find missing faces whose nodes are in set of nodes
// c. create temporary faces representing side of volumes if correspondent // c. create temporary faces representing side of volumes if correspondent
// face does not exist // face does not exist
@ -9292,7 +9286,7 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1,
// ----------------------------------------------------------- // -----------------------------------------------------------
// 1a. Collect nodes of existing faces // 1a. Collect nodes of existing faces
// and build set of face nodes in order to detect missing // and build set of face nodes in order to detect missing
// faces corresponing to sides of volumes // faces corresponding to sides of volumes
// ----------------------------------------------------------- // -----------------------------------------------------------
set< set <const SMDS_MeshNode*> > setOfFaceNodeSet; set< set <const SMDS_MeshNode*> > setOfFaceNodeSet;
@ -9316,7 +9310,7 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1,
volSet->insert( elem ); volSet->insert( elem );
} }
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// 1b. Complete set of faces: find missing fices whose nodes are in set of nodes // 1b. Complete set of faces: find missing faces whose nodes are in set of nodes
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
for ( nIt = nodeSet->begin(); nIt != nodeSet->end(); nIt++ ) { // loop on nodes of iSide for ( nIt = nodeSet->begin(); nIt != nodeSet->end(); nIt++ ) { // loop on nodes of iSide
@ -9425,7 +9419,7 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1,
fIt++; fIt++;
} }
else else
freeFaceList.erase( fIt++ ); // here fIt++ occures before erase freeFaceList.erase( fIt++ ); // here fIt++ occurs before erase
} }
if ( freeFaceList.size() > 1 ) if ( freeFaceList.size() > 1 )
{ {
@ -9803,9 +9797,14 @@ SMESH_MeshEditor::SewSideElements (TIDSortedElemSet& theSide1,
// else // else
if ( nbReplaced ) if ( nbReplaced )
{ {
// TODO problem ChangeElementNodes : not the same number of nodes, not the same type SMDSAbs_ElementType etyp = e->GetType();
MESSAGE("ChangeElementNodes"); SMDS_MeshElement* newElem = this->AddElement(nodes, etyp, false);
aMesh->ChangeElementNodes( e, & nodes[0], nbNodes ); if (newElem)
{
myLastCreatedElems.Append(newElem);
AddToSameGroups(newElem, e, aMesh);
}
aMesh->RemoveElement(e);
} }
} }
} }

View File

@ -162,14 +162,14 @@ public:
SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes, SMDS_MeshElement* AddElement(const std::vector<const SMDS_MeshNode*> & nodes,
const SMDSAbs_ElementType type, const SMDSAbs_ElementType type,
const bool isPoly, const bool isPoly,
const int ID = 0); const int ID = -1);
/*! /*!
* \brief Add element * \brief Add element
*/ */
SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs, SMDS_MeshElement* AddElement(const std::vector<int> & nodeIDs,
const SMDSAbs_ElementType type, const SMDSAbs_ElementType type,
const bool isPoly, const bool isPoly,
const int ID = 0); const int ID = -1);
bool Remove (const std::list< int >& theElemIDs, const bool isNodes); bool Remove (const std::list< int >& theElemIDs, const bool isNodes);
// Remove a node or an element. // Remove a node or an element.

View File

@ -1931,6 +1931,7 @@ void SMESHDS_Mesh::compactMesh()
myIDElements.swap(newSmdsToVtk); myIDElements.swap(newSmdsToVtk);
myVtkIndex.swap(newVtkToSmds); myVtkIndex.swap(newVtkToSmds);
MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() ); MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
this->myElementIDFactory->emptyPool(newSmdsId);
// ---TODO: myNodes, myElements in submeshes // ---TODO: myNodes, myElements in submeshes

View File

@ -49,11 +49,16 @@ SMESHDS_SubMesh::SMESHDS_SubMesh()
//======================================================================= //=======================================================================
void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME)
{ {
if ( !IsComplexSubmesh() ) if (!IsComplexSubmesh())
{ {
int idInSubShape = ME->getIdInShape(); int idInSubShape = ME->getIdInShape();
assert(idInSubShape == -1); if (idInSubShape != -1)
SMDS_MeshElement* elem = (SMDS_MeshElement*)(ME); {
MESSAGE("add element in subshape already belonging to a subshape "
<< ME->GetID() << " " << ME->getIdInShape() << " " << ME->getshapeId());
throw SALOME_Exception(LOCALIZED("add element in subshape already belonging to a subshape"));
}
SMDS_MeshElement* elem = (SMDS_MeshElement*) (ME);
elem->setIdInShape(myElements.size()); elem->setIdInShape(myElements.size());
myElements.push_back(ME); myElements.push_back(ME);
} }

View File

@ -1159,10 +1159,10 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh,
const TopoDS_Shape& aShape, const TopoDS_Shape& aShape,
FaceQuadStruct* & quad) //throw (SALOME_Exception) FaceQuadStruct* & quad) //throw (SALOME_Exception)
{ {
// Algorithme décrit dans "Génération automatique de maillages" // Algorithme décrit dans "Génération automatique de maillages"
// P.L. GEORGE, MASSON, § 6.4.1 p. 84-85 // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85
// traitement dans le domaine paramétrique 2d u,v // traitement dans le domaine paramétrique 2d u,v
// transport - projection sur le carré unité // transport - projection sur le carré unité
// MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid"); // MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid");
// const TopoDS_Face& F = TopoDS::Face(aShape); // const TopoDS_Face& F = TopoDS::Face(aShape);