#include <stdlib.h>
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
if(anIsNodeNum) {
aNode = myMesh->AddNodeWithID
(aCoords[0],aCoords[1],aCoords[2],aNodeInfo->GetElemNum(iElem));
+ //MESSAGE("AddNodeWithID " << aNodeInfo->GetElemNum(iElem));
} else {
- aNode = myMesh->AddNode
- (aCoords[0],aCoords[1],aCoords[2]);
+ aNode = myMesh->AddNodeWithID
+ (aCoords[0],aCoords[1],aCoords[2], iElem+1);
+ //MESSAGE("AddNode " << aNode->GetID());
}
//cout<<aNode->GetID()<<": "<<aNode->X()<<", "<<aNode->Y()<<", "<<aNode->Z()<<endl;
if(anIsElemNum){
TInt anElemId = aPolygoneInfo->GetElemNum(iElem);
anElement = myMesh->AddPolygonalFaceWithID(aNodeIds,anElemId);
+ //MESSAGE("AddPolygonalFaceWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbConn);
for(TInt iConn = 0; iConn < aNbConn; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolygonalFace(aNodes);
+ //MESSAGE("AddPolygonalFace " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
if(anIsElemNum){
TInt anElemId = aPolyedreInfo->GetElemNum(iElem);
anElement = myMesh->AddPolyhedralVolumeWithID(aNodeIds,aQuantities,anElemId);
+ //MESSAGE("AddPolyhedralVolumeWithID " << anElemId);
}
if(!anElement){
vector<const SMDS_MeshNode*> aNodes(aNbNodes);
for(TInt iConn = 0; iConn < aNbNodes; iConn++)
aNodes[iConn] = FindNode(myMesh,aNodeIds[iConn]);
anElement = myMesh->AddPolyhedralVolume(aNodes,aQuantities);
+ //MESSAGE("AddPolyhedralVolume " << anElement->GetID());
isRenum = anIsElemNum;
}
#ifndef _DEXCEPT_
anIsValidConnect = true;
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- //INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was cought !!!");
aResult = DRS_FAIL;
}
#endif
break;
case ePYRA13:
aNbNodes = 13;
- // There is some differnce between SMDS and MED
+ // There is some difference between SMDS and MED
if(anIsElemNum)
anElement = myMesh->AddVolumeWithID(aNodeIds[0], aNodeIds[1],
aNodeIds[2], aNodeIds[3],
}
break;
}
-
+// if (anIsElemNum) {
+// MESSAGE("add element with id " << aCellInfo->GetElemNum(iElem));
+// }
+// else {
+// MESSAGE("add element "<< anElement->GetID());
+// }
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- //INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Following exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- //INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
}
#ifndef _DEXCEPT_
}catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Follow exception was caught:\n\t"<<exc.what());
aResult = DRS_FAIL;
}catch(...){
- INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
aResult = DRS_FAIL;
}
#endif
+ if (myMesh)
+ myMesh->compactMesh();
if(MYDEBUG) MESSAGE("Perform - aResult status = "<<aResult);
return aResult;
}
}
}
}catch(const std::exception& exc){
- INFOS("Follow exception was cought:\n\t"<<exc.what());
+ INFOS("Follow exception was caught:\n\t"<<exc.what());
theStatus = DRS_FAIL;
}catch(...){
- INFOS("Unknown exception was cought !!!");
+ INFOS("Unknown exception was caught !!!");
theStatus = DRS_FAIL;
}
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
for(; anIter != aDataSet2411.end(); anIter++){
const TNodeLab& aLabel = anIter->first;
const TRecord& aRec = anIter->second;
+ MESSAGE("AddNodeWithID " << aLabel << " " << aRec.coord[0] << " " << aRec.coord[1] << " " << aRec.coord[2]);
myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel);
}
}
if(IsBeam(aRec.fe_descriptor_id)) {
switch ( aRec.node_labels.size() ) {
case 2: // edge with two nodes
+ MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[1],
aLabel);
break;
case 3: // quadratic edge (with 3 nodes)
+ MESSAGE("add edge " << aLabel << " " << aRec.node_labels[0] << " " << aRec.node_labels[1] << " " << aRec.node_labels[2]);
anElement = myMesh->AddEdgeWithID(aRec.node_labels[0],
aRec.node_labels[2],
aRec.node_labels[1],
}
}
else if(IsFace(aRec.fe_descriptor_id)) {
+ MESSAGE("add face " << aLabel);
switch(aRec.fe_descriptor_id){
case 71: // TRI3
case 72:
case 42: // Plane Stress 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]);
anElement = myMesh->AddFaceWithID(aRec.node_labels[0],
aRec.node_labels[2],
aRec.node_labels[4],
}
}
else if(IsVolume(aRec.fe_descriptor_id)){
+ MESSAGE("add volume " << aLabel);
switch(aRec.fe_descriptor_id){
case 111: // Solid Linear Tetrahedron - TET4
catch(...){
INFOS("Unknown exception was cought !!!");
}
+ if (myMesh)
+ myMesh->compactMesh();
return aResult;
}
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
+ aNodesIter = anElem->nodesIteratorToUNV();
if( anElem->IsQuadratic() ) {
- aNodesIter = static_cast<const SMDS_QuadraticEdge* >
- ( anElem )->interlacedNodesElemIterator();
aRec.fe_descriptor_id = 22;
} else {
- aNodesIter = anElem->nodesIterator();
aRec.fe_descriptor_id = 11;
}
for(; aNodesIter->more();){
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
- if( anElem->IsQuadratic() )
- aNodesIter = static_cast<const SMDS_QuadraticFaceOfNodes* >
- ( anElem )->interlacedNodesElemIterator();
- else
- aNodesIter = anElem->nodesIterator();
+ aNodesIter = anElem->nodesIteratorToUNV();
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
TElementLab aLabel = anElem->GetID();
int aNbNodes = anElem->NbNodes();
- SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator();
+ MESSAGE("aNbNodes="<<aNbNodes);
+ SMDS_ElemIteratorPtr aNodesIter;
+ aNodesIter = anElem->nodesIteratorToUNV();
if ( anElem->IsPoly() ) {
+ MESSAGE("anElem->IsPoly");
if ( const SMDS_PolyhedralVolumeOfNodes* ph =
dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*> (anElem))
{
aNodesIter = ph->uniqueNodesIterator();
}
}
- aConnect.resize(aNbNodes);
- GetConnect(aNodesIter,aConnect);
int anId = -1;
- int* aConn = NULL;
switch(aNbNodes){
case 4: {
- static int anIds[] = {0,2,1,3};
- aConn = anIds;
anId = 111;
break;
}
case 6: {
- static int anIds[] = {0,2,1,3,5,4};
- aConn = anIds;
anId = 112;
break;
}
case 8: {
- static int anIds[] = {0,3,2,1,4,7,6,5};
- aConn = anIds;
anId = 115;
break;
}
case 10: {
- static int anIds[] = {0,4,2,9,5,3, 1,6,8, 7};
- aConn = anIds;
anId = 118;
break;
}
case 13: {
- static int anIds[] = {0,6,4,2,7,5,3,1,8,11,10,9,12};
- aConn = anIds;
anId = 114;
break;
}
case 15: {
- static int anIds[] = {0,4,2,9,13,11,5,3,1,14,12,10,6,8,7};
- aConn = anIds;
anId = 113;
break;
}
case 20: {
- static int anIds[] = {0,6, 4,2, 12,18,16,14,7, 5, 3, 1, 19,17,15,13,8, 11,10,9};
- aConn = anIds;
anId = 116;
break;
}
default:
continue;
}
- if(aConn){
+ if(anId>0){
TRecord aRec;
aRec.fe_descriptor_id = anId;
- aRec.node_labels.resize(aNbNodes);
- for(int aNodeId = 0; aNodeId < aNbNodes; aNodeId++){
- aRec.node_labels[aConn[aNodeId]] = aConnect[aNodeId];
+ aRec.node_labels.reserve(aNbNodes);
+ for(; aNodesIter->more();){
+ const SMDS_MeshElement* aNode = aNodesIter->next();
+ aRec.node_labels.push_back(aNode->GetID());
}
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
}
SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,edgevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL);
+ myEdgePool->destroy(edgevtk);
+ return 0;
+ }
edge = edgevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = edge;
myInfo.myNbEdges++;
- if (edge && !registerElement(ID, edge))
- {
- RemoveElement(edge, false);
- edge = NULL;
- }
+// if (edge && !registerElement(ID, edge))
+// {
+// RemoveElement(edge, false);
+// edge = NULL;
+// }
return edge;
}
//MESSAGE("AddFaceWithID " << ID)
SMDS_MeshFace * face=createTriangle(n1, n2, n3, ID);
- if (face && !registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
- }
+// if (face && !registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
return face;
}
//MESSAGE("AddFaceWithID " << ID);
SMDS_MeshFace * face=createQuadrangle(n1, n2, n3, n4, ID);
- if (face && !registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
- }
+// if (face && !registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
return face;
}
if ( !e1 || !e2 || !e3 ) return 0;
//if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
- //MESSAGE("AddFaceWithID" << ID);
+ MESSAGE("AddFaceWithID" << ID);
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3);
adjustmyCellsCapacity(ID);
myInfo.myNbTriangles++;
if (!registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), face);
+ //RemoveElement(face, false);
+ //face = NULL;
}
return face;
}
{
if (!hasConstructionEdges())
return NULL;
- //MESSAGE("AddFaceWithID" << ID);
+ MESSAGE("AddFaceWithID" << ID);
if ( !e1 || !e2 || !e3 || !e4 ) return 0;
//if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
SMDS_MeshFace * face = new SMDS_FaceOfEdges(e1,e2,e3,e4);
if (!registerElement(ID, face))
{
- RemoveElement(face, false);
- face = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), face);
+ //RemoveElement(face, false);
+ //face = NULL;
}
return face;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
volume = volvtk;
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
myInfo.myNbTetras++;
}
- if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
- }
+// if (!registerElement(ID, volume)) {
+// RemoveElement(volume, false);
+// volume = NULL;
+// }
return volume;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
volume = volvtk;
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
myInfo.myNbPyramids++;
}
- if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
- }
+// if (!registerElement(ID, volume)) {
+// RemoveElement(volume, false);
+// volume = NULL;
+// }
return volume;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
volume = volvtk;
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
myInfo.myNbPrisms++;
}
- if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
- }
+// if (!registerElement(ID, volume)) {
+// RemoveElement(volume, false);
+// volume = NULL;
+// }
return volume;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
volume = volvtk;
adjustmyCellsCapacity(ID);
myCells[ID] = volume;
myInfo.myNbHexas++;
}
- if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
- }
+// if (!registerElement(ID, volume)) {
+// RemoveElement(volume, false);
+// volume = NULL;
+// }
return volume;
}
const SMDS_MeshFace * f4,
int ID)
{
- //MESSAGE("AddVolumeWithID" << ID);
+ MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4) return 0;
myInfo.myNbTetras++;
if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
}
return volume;
}
const SMDS_MeshFace * f5,
int ID)
{
- //MESSAGE("AddVolumeWithID" << ID);
+ MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5) return 0;
myInfo.myNbPyramids++;
if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
}
return volume;
}
const SMDS_MeshFace * f6,
int ID)
{
- //MESSAGE("AddVolumeWithID" << ID);
+ MESSAGE("AddVolumeWithID" << ID);
if (!hasConstructionFaces())
return NULL;
if ( !f1 || !f2 || !f3 || !f4 || !f5 || !f6) return 0;
myInfo.myNbPrisms++;
if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
}
return volume;
}
SMDS_MeshFace * face;
//if ( myFaces.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
+ MESSAGE("AddPolygonalFaceWithID " << ID);
if (hasConstructionEdges())
{
MESSAGE("Error : Not implemented");
}
if (!registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), face);
+ //RemoveElement(face, false);
+ //face = NULL;
}
return face;
}
vector<int> quantities,
const int ID)
{
+ MESSAGE("AddPolyhedralVolumeWithID" << ID);
SMDS_MeshVolume* volume;
//if ( myVolumes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory();
if (hasConstructionFaces()) {
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->initPoly(nodeIds, quantities, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
volume = volvtk;
#else
for ( int i = 0; i < nodes.size(); ++i )
myInfo.myNbPolyhedrons++;
}
+#ifndef VTK_HAVE_POLYHEDRON
if (!registerElement(ID, volume)) {
- RemoveElement(volume, false);
- volume = NULL;
+ registerElement(myElementIDFactory->GetFreeID(), volume);
+ //RemoveElement(volume, false);
+ //volume = NULL;
}
+#endif
return volume;
}
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
- facevtk->init(nodeIds, this);
+ facevtk->init(nodeIds, this); // put in vtkUnstructuredGrid
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
const SMDS_MeshNode * nodes[],
const int nbnodes)
{
- // TODO use polymorphism, check number of nodes and type are unchanged.
- MYASSERT(0); // REVOIR LES TYPES
+ MESSAGE("SMDS_Mesh::ChangeElementNodes");
// keep current nodes of elem
set<const SMDS_MeshElement*> oldNodes;
SMDS_ElemIteratorPtr itn = element->nodesIterator();
while(itn->more())
oldNodes.insert( itn->next() );
- if ( !element->IsPoly() )
- myInfo.remove( element ); // element may change type
-
// change nodes
bool Ok = false;
SMDS_MeshCell* cell = dynamic_cast<SMDS_MeshCell*>((SMDS_MeshElement*) element);
if (cell)
Ok = cell->ChangeNodes(nodes, nbnodes);
-// SMDS_MeshElement* elem = const_cast<SMDS_MeshElement*>(element);
-// switch ( elem->GetType() )
-// {
-// case SMDSAbs_0DElement: {
-// if ( SMDS_Mesh0DElement* elem0d = dynamic_cast<SMDS_Mesh0DElement*>( elem ))
-// Ok = elem0d->ChangeNode( nodes[0] );
-// break;
-// }
-// case SMDSAbs_Edge: {
-// if ( nbnodes == 2 ) {
-// if ( SMDS_VtkEdge* edge = dynamic_cast<SMDS_VtkEdge*>( elem ))
-// Ok = edge->ChangeNodes( nodes[0], nodes[1] );
-// }
-// else if ( nbnodes == 3 ) {
-// if ( SMDS_QuadraticEdge* edge = dynamic_cast<SMDS_QuadraticEdge*>( elem ))
-// Ok = edge->ChangeNodes( nodes[0], nodes[1], nodes[2] );
-// }
-// break;
-// }
-// case SMDSAbs_Face: {
-// if ( SMDS_FaceOfNodes* face = dynamic_cast<SMDS_FaceOfNodes*>( elem ))
-// Ok = face->ChangeNodes( nodes, nbnodes );
-// else
-// if ( SMDS_QuadraticFaceOfNodes* QF = dynamic_cast<SMDS_QuadraticFaceOfNodes*>( elem ))
-// Ok = QF->ChangeNodes( nodes, nbnodes );
-// else
-// if (SMDS_PolygonalFaceOfNodes* face = dynamic_cast<SMDS_PolygonalFaceOfNodes*>(elem))
-// Ok = face->ChangeNodes(nodes, nbnodes);
-// break;
-// }
-// case SMDSAbs_Volume: {
-// if ( SMDS_VolumeOfNodes* vol = dynamic_cast<SMDS_VolumeOfNodes*>( elem ))
-// Ok = vol->ChangeNodes( nodes, nbnodes );
-// else
-// if ( SMDS_QuadraticVolumeOfNodes* QV = dynamic_cast<SMDS_QuadraticVolumeOfNodes*>( elem ))
-// Ok = QV->ChangeNodes( nodes, nbnodes );
-// break;
-// }
-// default:
-// MESSAGE ( "WRONG ELEM TYPE");
-// }
-
if ( Ok ) { // update InverseElements
set<const SMDS_MeshElement*>::iterator it;
}
}
- if ( !element->IsPoly() )
- myInfo.add( element ); // element may change type
-
return Ok;
}
SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,edgevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL);
+ myEdgePool->destroy(edgevtk);
+ return 0;
+ }
toReturn = edgevtk;
myCells[ID] = toReturn;
myInfo.myNbEdges++;
(const_cast<SMDS_MeshElement *>(itn->next()));
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:
- myCells[(*it)->GetID()] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ?
- myInfo.remove(*it);
+ if (IdToRemove >= 0)
+ {
+ myCells[IdToRemove] = 0; // -PR- ici ou dans myElementIDFactory->ReleaseID ?
+ myInfo.remove(*it);
+ }
removedElems.push_back( (*it) );
- myElementIDFactory->ReleaseID((*it)->GetID());
+ myElementIDFactory->ReleaseID(IdToRemove);
delete (*it);
break;
case SMDSAbs_Edge:
- myCells[(*it)->GetID()] = 0;
- myInfo.RemoveEdge(*it);
+ if (IdToRemove >= 0)
+ {
+ myCells[IdToRemove] = 0;
+ myInfo.RemoveEdge(*it);
+ }
removedElems.push_back( (*it) );
- myElementIDFactory->ReleaseID((*it)->GetID());
+ 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:
- myCells[(*it)->GetID()] = 0;
- myInfo.RemoveFace(*it);
+ if (IdToRemove >= 0)
+ {
+ myCells[IdToRemove] = 0;
+ myInfo.RemoveFace(*it);
+ }
removedElems.push_back( (*it) );
- myElementIDFactory->ReleaseID((*it)->GetID());
+ 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:
- myCells[(*it)->GetID()] = 0;
- myInfo.RemoveVolume(*it);
+ if (IdToRemove >= 0)
+ {
+ myCells[IdToRemove] = 0;
+ myInfo.RemoveVolume(*it);
+ }
removedElems.push_back( (*it) );
- myElementIDFactory->ReleaseID((*it)->GetID());
+ myElementIDFactory->ReleaseID(IdToRemove);
if (const SMDS_VtkVolume* vtkElem = dynamic_cast<const SMDS_VtkVolume*>(*it))
myVolumePool->destroy((SMDS_VtkVolume*)vtkElem);
else delete (*it);
it=s2->begin();
while(it!=s2->end())
{
- //MESSAGE( "SMDS: RM node " << (*it)->GetID() );
- myNodes[(*it)->GetID()] = 0;
- myInfo.myNbNodes--;
+ 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))
SMDS_MeshEdge * edge = 0;
SMDS_VtkEdge *edgevtk = myEdgePool->getNew();
edgevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,edgevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(edgevtk->getVtkId(), VTK_EMPTY_CELL);
+ myEdgePool->destroy(edgevtk);
+ return 0;
+ }
edge = edgevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = edge;
myInfo.myNbQuadEdges++;
- if (!registerElement(ID, edge)) {
- RemoveElement(edge, false);
- edge = NULL;
- }
+// if (!registerElement(ID, edge)) {
+// RemoveElement(edge, false);
+// edge = NULL;
+// }
return edge;
}
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadTriangles++;
- if (!registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
- }
+// if (!registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
return face;
}
}
SMDS_MeshFace * face = 0;
SMDS_VtkFace *facevtk = myFacePool->getNew();
facevtk->init(nodeIds, this);
+ if (!this->registerElement(ID,facevtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(facevtk->getVtkId(), VTK_EMPTY_CELL);
+ myFacePool->destroy(facevtk);
+ return 0;
+ }
face = facevtk;
adjustmyCellsCapacity(ID);
myCells[ID] = face;
myInfo.myNbQuadQuadrangles++;
- if (!registerElement(ID, face)) {
- RemoveElement(face, false);
- face = NULL;
- }
+// if (!registerElement(ID, face)) {
+// RemoveElement(face, false);
+// face = NULL;
+// }
return face;
}
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadTetras++;
- if (!registerElement(ID, volvtk)) {
- RemoveElement(volvtk, false);
- volvtk = NULL;
- }
+// if (!registerElement(ID, volvtk)) {
+// RemoveElement(volvtk, false);
+// volvtk = NULL;
+// }
return volvtk;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadPyramids++;
- if (!registerElement(ID, volvtk)) {
- RemoveElement(volvtk, false);
- volvtk = NULL;
- }
+// if (!registerElement(ID, volvtk)) {
+// RemoveElement(volvtk, false);
+// volvtk = NULL;
+// }
return volvtk;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadPrisms++;
- if (!registerElement(ID, volvtk)) {
- RemoveElement(volvtk, false);
- volvtk = NULL;
- }
+// if (!registerElement(ID, volvtk)) {
+// RemoveElement(volvtk, false);
+// volvtk = NULL;
+// }
return volvtk;
}
SMDS_VtkVolume *volvtk = myVolumePool->getNew();
volvtk->init(nodeIds, this);
+ if (!this->registerElement(ID,volvtk))
+ {
+ this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL);
+ myVolumePool->destroy(volvtk);
+ return 0;
+ }
adjustmyCellsCapacity(ID);
myCells[ID] = volvtk;
myInfo.myNbQuadHexas++;
- if (!registerElement(ID, volvtk)) {
- RemoveElement(volvtk, false);
- volvtk = NULL;
- }
+// if (!registerElement(ID, volvtk)) {
+// RemoveElement(volvtk, false);
+// volvtk = NULL;
+// }
return volvtk;
}
ficcon.close();
}
+
+void SMDS_Mesh::compactMesh()
+{
+ MESSAGE("SMDS_Mesh::compactMesh do nothing!");
+}
virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1);
// Renumber all nodes or elements.
+ virtual void compactMesh();
const SMDS_MeshNode *FindNode(int idnode) const;
const SMDS_Mesh0DElement* Find0DElement(int idnode) const;
return myElement;
}
};
+
SMDS_ElemIteratorPtr SMDS_MeshElement::
elementsIterator(SMDSAbs_ElementType type) const
{
}
}
+//! virtual, redefined in vtkEdge, vtkFace and vtkVolume classes
+SMDS_ElemIteratorPtr SMDS_MeshElement::nodesIteratorToUNV() const
+{
+ MESSAGE("Iterator not implemented");
+ return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
+}
+
///////////////////////////////////////////////////////////////////////////////
///Return the ID of the element
///////////////////////////////////////////////////////////////////////////////
SMDS_ElemIteratorPtr edgesIterator() const;
SMDS_ElemIteratorPtr facesIterator() const;
virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
// std-like iteration on nodes
typedef SMDS_StdIterator< const SMDS_MeshNode*, SMDS_ElemIteratorPtr > iterator;
int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem)
{
- // --- retreive nodes ID
+ // --- retrieve nodes ID
vector<vtkIdType> nodeIds;
SMDS_ElemIteratorPtr it = elem->nodesIterator();
//=======================================================================
void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
{
+ if (ID < 0)
+ {
+ MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID);
+ return;
+ }
int vtkId = myMesh->myIDElements[ID];
//MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId);
- myMesh->myIDElements[ID] = -1;
- myMesh->myVtkIndex[vtkId] = -1;
+ if (ID >=0)
+ {
+ myMesh->myIDElements[ID] = -1;
+ myMesh->myVtkIndex[vtkId] = -1;
+ }
SMDS_MeshIDFactory::ReleaseID(ID);
if (ID == myMax)
myMax = 0;
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (!elem)
{
- assert(0);
+ MESSAGE("SMDS_MeshNode_MyInvIterator problem Null element");
throw SALOME_Exception("SMDS_MeshNode_MyInvIterator problem Null element");
}
//MESSAGE("vtkId " << vtkId << " smdsId " << smdsId << " " << elem->GetType());
for (int i = 0; i < oldNodeSize; i++)
{
+ //MESSAGE(" " << i << " " << idNodesOldToNew[i]);
switch (compactState)
{
case lookHoleStart:
{
MESSAGE("-------------- newNodeSize, endbloc " << endBloc << " " << oldNodeSize);
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
- compactState = lookHoleStart;
+ compactState = lookHoleEnd;
startHole = i;
endHole = 0;
startBloc = 0;
#include "SMDS_VtkCellIterator.hxx"
#include "utilities.h"
-
SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) :
_mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType)
{
- vtkUnstructuredGrid* grid = _mesh->getGrid();
+ //MESSAGE("SMDS_VtkCellIterator " << _type);
_vtkIdList = vtkIdList::New();
+ vtkUnstructuredGrid* grid = _mesh->getGrid();
grid->GetCellPoints(_cellId, _vtkIdList);
_nbNodes = _vtkIdList->GetNumberOfIds();
- vtkIdType tempid;
switch (_type)
{
case SMDSEntity_Tetra:
vtkIdType id = _vtkIdList->GetId(_index++);
return _mesh->FindNode(id);
}
+
+SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh,
+ int vtkCellId,
+ SMDSAbs_EntityType aType)
+: SMDS_VtkCellIterator()
+{
+ _mesh = mesh;
+ _cellId = vtkCellId;
+ _index = 0;
+ _type = aType;
+ MESSAGE("SMDS_VtkCellInterlacedIterator " << _type);
+
+ _vtkIdList = vtkIdList::New();
+ vtkIdType* pts;
+ vtkUnstructuredGrid* grid = _mesh->getGrid();
+ grid->GetCellPoints(_cellId, _nbNodes, pts);
+ _vtkIdList->SetNumberOfIds(_nbNodes);
+ int *ids = 0;
+ switch (_type)
+ {
+ case SMDSEntity_Quad_Edge:
+ {
+ static int id[] = {0,2,1};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Triangle:
+ {
+ static int id[] = {0,3,1,4,2,5};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Quadrangle:
+ {
+ static int id[] = {0,4,1,5,2,6,3,7};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Tetra:
+ {
+ static int id[] = {0,4,1,5,2,6,7,8,9,3};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Pyramid:
+ {
+ static int id[] = {0,5,1,6,2,7,3,8,9,10,11,12,4};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Penta:
+ {
+ static int id[] = {0,2,1,3,5,4};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Penta:
+ {
+ static int id[] = {0,8,2,7,1,6,12,14,13,3,11,5,10,4,9};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Quad_Hexa:
+ {
+ static int id[] = {0,8,1,9,2,10,3,11,16,17,18,19,4,12,5,13,6,14,7,15};
+ ids = id;
+ break;
+ }
+ case SMDSEntity_Polygon:
+ case SMDSEntity_Quad_Polygon:
+ {
+ MESSAGE("SMDS_VtkCellIterator polygon");
+ break;
+ }
+ case SMDSEntity_Polyhedra:
+ case SMDSEntity_Quad_Polyhedra:
+ {
+ MESSAGE("SMDS_VtkCellIterator Polyhedra");
+ break;
+ }
+ default:
+ {
+ static int id[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19};
+ ids = id;
+ break;
+ }
+ }
+ //MESSAGE("_nbNodes " << _nbNodes);
+ for (int i=0; i<_nbNodes; i++)
+ _vtkIdList->SetId(i, pts[ids[i]]);
+}
+
+SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV()
+{
+}
+
class SMDS_VtkCellIterator: public SMDS_ElemIterator
{
public:
- SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId,
- SMDSAbs_EntityType aType);
+ SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
virtual ~SMDS_VtkCellIterator();
virtual bool more();
virtual const SMDS_MeshElement* next();
}
protected:
+ SMDS_VtkCellIterator() {};
+
SMDS_Mesh* _mesh;
int _cellId;
int _index;
vtkIdList* _vtkIdList;
};
+class SMDS_VtkCellIteratorToUNV: public SMDS_VtkCellIterator
+{
+public:
+ SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType);
+ virtual ~SMDS_VtkCellIteratorToUNV();
+};
+
#endif
myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]);
}
-bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1,
- const SMDS_MeshNode * node2)
+bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2)
{
- // TODO remove
- return true;
+ const SMDS_MeshNode* nodes[] = { node1, node2 };
+ return ChangeNodes(nodes, 2);
}
bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
- // TODO
+ vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ vtkIdType npts = 0;
+ vtkIdType* pts = 0;
+ grid->GetCellPoints(myVtkID, npts, pts);
+ if (nbNodes != npts)
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
+ for (int i = 0; i < nbNodes; i++)
+ {
+ pts[i] = nodes[i]->GetID();
+ }
return true;
}
switch (type)
{
case SMDSAbs_Node:
- return SMDS_ElemIteratorPtr(
- new SMDS_VtkCellIterator(
- SMDS_Mesh::_meshList[myMeshId],
- myVtkID,
- GetEntityType()));
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
default:
MESSAGE("ERROR : Iterator not implemented")
;
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
+
+SMDS_ElemIteratorPtr SMDS_VtkEdge::nodesIteratorToUNV() const
+{
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
virtual bool IsQuadratic() const;
protected:
- SMDS_ElemIteratorPtr
- elementsIterator(SMDSAbs_ElementType type) const;
-
+ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
};
#endif
bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
- // TODO
+ vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ vtkIdType npts = 0;
+ vtkIdType* pts = 0;
+ grid->GetCellPoints(myVtkID, npts, pts);
+ if (nbNodes != npts)
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
+ for (int i=0; i<nbNodes; i++)
+ {
+ pts[i] = nodes[i]->GetID();
+ }
return true;
}
SMDSAbs_EntityType SMDS_VtkFace::GetEntityType() const
{
- SMDSAbs_EntityType aType = SMDSEntity_Triangle;
+ SMDSAbs_EntityType aType = SMDSEntity_Polygon;
switch (NbNodes())
{
case 3:
- case 6:
aType = SMDSEntity_Triangle;
break;
+ case 6:
+ aType = SMDSEntity_Quad_Triangle;
+ break;
case 4:
- case 8:
aType = SMDSEntity_Quadrangle;
break;
+ case 8:
+ aType = SMDSEntity_Quad_Quadrangle;
+ break;
}
return aType;
}
return VTK_QUAD;
case 8:
return VTK_QUADRATIC_QUAD;
+ default:
+ return VTK_POLYGON;
}
}
switch (type)
{
case SMDSAbs_Node:
- return SMDS_ElemIteratorPtr(
- new SMDS_VtkCellIterator(
- SMDS_Mesh::_meshList[myMeshId],
- myVtkID,
- GetEntityType()));
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
default:
- MESSAGE("ERROR : Iterator not implemented")
- ;
+ MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
+SMDS_ElemIteratorPtr SMDS_VtkFace::nodesIteratorToUNV() const
+{
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
virtual bool IsQuadratic() const;
protected:
- SMDS_ElemIteratorPtr
- elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
};
#endif
bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes)
{
- // TODO utilise dans SMDS_Mesh
+ vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
+ vtkIdType npts = 0;
+ vtkIdType* pts = 0;
+ grid->GetCellPoints(myVtkID, npts, pts);
+ if (nbNodes != npts)
+ {
+ MESSAGE("ChangeNodes problem: not the same number of nodes " << npts << " -> " << nbNodes);
+ return false;
+ }
+ for (int i=0; i<nbNodes; i++)
+ {
+ pts[i] = nodes[i]->GetID();
+ }
return true;
}
case SMDSAbs_Node:
return SMDS_ElemIteratorPtr(new SMDS_VtkCellIterator(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
default:
- MESSAGE("ERROR : Iterator not implemented")
- ;
+ MESSAGE("ERROR : Iterator not implemented");
return SMDS_ElemIteratorPtr((SMDS_ElemIterator*) NULL);
}
}
+SMDS_ElemIteratorPtr SMDS_VtkVolume::nodesIteratorToUNV() const
+{
+ return SMDS_ElemIteratorPtr(new SMDS_VtkCellIteratorToUNV(SMDS_Mesh::_meshList[myMeshId], myVtkID, GetEntityType()));
+}
+
+
SMDSAbs_ElementType SMDS_VtkVolume::GetType() const
{
return SMDSAbs_Volume;
virtual bool IsQuadratic() const;
protected:
- SMDS_ElemIteratorPtr
- elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const;
+ virtual SMDS_ElemIteratorPtr nodesIteratorToUNV() const;
};
#endif
bool SMESH_MeshEditor::InverseDiag (const SMDS_MeshElement * theTria1,
const SMDS_MeshElement * theTria2 )
{
+ MESSAGE("InverseDiag");
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
if (!theTria1 || !theTria2)
return false;
- const SMDS_FaceOfNodes* F1 = dynamic_cast<const SMDS_FaceOfNodes*>( theTria1 );
- const SMDS_FaceOfNodes* F2 = dynamic_cast<const SMDS_FaceOfNodes*>( theTria2 );
- if (F1 && F2) {
+ const SMDS_VtkFace* F1 = dynamic_cast<const SMDS_VtkFace*>( theTria1 );
+ if (!F1) return false;
+ const SMDS_VtkFace* F2 = dynamic_cast<const SMDS_VtkFace*>( theTria2 );
+ if (!F2) return false;
+ if ((theTria1->GetEntityType() == SMDSEntity_Triangle) &&
+ (theTria2->GetEntityType() == SMDSEntity_Triangle)) {
// 1 +--+ A theTria1: ( 1 A B ) A->2 ( 1 2 B ) 1 +--+ A
// | /| theTria2: ( B A 2 ) B->1 ( 1 A 2 ) |\ |
// theTria2: B->1
aNodes[ sameInd[ iB ]] = aNodes[ i1 ];
- //MESSAGE( theTria1 << theTria2 );
-
GetMeshDS()->ChangeElementNodes( theTria1, aNodes, 3 );
GetMeshDS()->ChangeElementNodes( theTria2, &aNodes[ 3 ], 3 );
- //MESSAGE( theTria1 << theTria2 );
-
return true;
} // end if(F1 && F2)
// check case of quadratic faces
- const SMDS_QuadraticFaceOfNodes* QF1 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (theTria1);
- if(!QF1) return false;
- const SMDS_QuadraticFaceOfNodes* QF2 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (theTria2);
- if(!QF2) return false;
+ if (theTria1->GetEntityType() != SMDSEntity_Quad_Triangle)
+ return false;
+ if (theTria2->GetEntityType() == SMDSEntity_Quad_Triangle)
+ return false;
// 5
// 1 +--+--+ 2 theTria1: (1 2 4 5 9 7) or (2 4 1 9 7 5) or (4 1 2 7 5 9)
if ( !findTriangles( theNode1, theNode2, tr1, tr2 ))
return false;
- const SMDS_FaceOfNodes* F1 = dynamic_cast<const SMDS_FaceOfNodes*>( tr1 );
- //if (!F1) return false;
- const SMDS_FaceOfNodes* F2 = dynamic_cast<const SMDS_FaceOfNodes*>( tr2 );
- //if (!F2) return false;
- if (F1 && F2) {
+ const SMDS_VtkFace* F1 = dynamic_cast<const SMDS_VtkFace*>( tr1 );
+ if (!F1) return false;
+ const SMDS_VtkFace* F2 = dynamic_cast<const SMDS_VtkFace*>( tr2 );
+ if (!F2) return false;
+ if ((tr1->GetEntityType() == SMDSEntity_Triangle) &&
+ (tr2->GetEntityType() == SMDSEntity_Triangle)) {
// 1 +--+ A tr1: ( 1 A B ) A->2 ( 1 2 B ) 1 +--+ A
// | /| tr2: ( B A 2 ) B->1 ( 1 A 2 ) |\ |
// tr2: B->1
aNodes2[ iB2 ] = aNodes1[ i1 ];
- //MESSAGE( tr1 << tr2 );
-
GetMeshDS()->ChangeElementNodes( tr1, aNodes1, 3 );
GetMeshDS()->ChangeElementNodes( tr2, aNodes2, 3 );
- //MESSAGE( tr1 << tr2 );
-
return true;
}
// check case of quadratic faces
- const SMDS_QuadraticFaceOfNodes* QF1 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (tr1);
- if(!QF1) return false;
- const SMDS_QuadraticFaceOfNodes* QF2 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (tr2);
- if(!QF2) return false;
return InverseDiag(tr1,tr2);
}
if ( !findTriangles( theNode1, theNode2, tr1, tr2 ))
return false;
- const SMDS_FaceOfNodes* F1 = dynamic_cast<const SMDS_FaceOfNodes*>( tr1 );
- //if (!F1) return false;
- const SMDS_FaceOfNodes* F2 = dynamic_cast<const SMDS_FaceOfNodes*>( tr2 );
- //if (!F2) return false;
- if (F1 && F2) {
+ const SMDS_VtkFace* F1 = dynamic_cast<const SMDS_VtkFace*>( tr1 );
+ if (!F1) return false;
+ const SMDS_VtkFace* F2 = dynamic_cast<const SMDS_VtkFace*>( tr2 );
+ if (!F2) return false;
+ SMESHDS_Mesh * aMesh = GetMeshDS();
+
+ if ((tr1->GetEntityType() == SMDSEntity_Triangle) &&
+ (tr2->GetEntityType() == SMDSEntity_Triangle)) {
const SMDS_MeshNode* aNodes [ 4 ];
if ( ! getQuadrangleNodes( aNodes, theNode1, theNode2, tr1, tr2 ))
return false;
- //MESSAGE( endl << tr1 << tr2 );
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr1, aNodes, 4 );
- myLastCreatedElems.Append(tr1);
- GetMeshDS()->RemoveElement( tr2 );
-
- //MESSAGE( endl << tr1 );
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace( aNodes[0], aNodes[1], aNodes[2], aNodes[3] );
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr2 );
return true;
}
// check case of quadratic faces
- const SMDS_QuadraticFaceOfNodes* QF1 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (tr1);
- if(!QF1) return false;
- const SMDS_QuadraticFaceOfNodes* QF2 =
- dynamic_cast<const SMDS_QuadraticFaceOfNodes*> (tr2);
- if(!QF2) return false;
+ if (tr1->GetEntityType() != SMDSEntity_Quad_Triangle)
+ return false;
+ if (tr2->GetEntityType() != SMDSEntity_Quad_Triangle)
+ return false;
// 5
// 1 +--+--+ 2 tr1: (1 2 4 5 9 7) or (2 4 1 9 7 5) or (4 1 2 7 5 9)
aNodes[6] = N2[3];
aNodes[7] = N1[5];
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr1, aNodes, 8 );
- myLastCreatedElems.Append(tr1);
- GetMeshDS()->RemoveElement( tr2 );
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace( aNodes[0], aNodes[1], aNodes[2], aNodes[3],
+ aNodes[4], aNodes[5], aNodes[6], aNodes[7]);
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr2 );
// remove middle node (9)
GetMeshDS()->RemoveNode( N1[4] );
bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theElem)
{
+ MESSAGE("Reorient");
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
}
case SMDSAbs_Volume: {
if (theElem->IsPoly()) {
+ // TODO reorient vtk polyhedron
+ MESSAGE("reorient vtk polyhedron ?");
const SMDS_PolyhedralVolumeOfNodes* aPolyedre =
static_cast<const SMDS_PolyhedralVolumeOfNodes*>( theElem );
if (!aPolyedre) {
if ( !vTool.Set( theElem ))
return false;
vTool.Inverse();
+ MESSAGE("ChangeElementNodes reorient: check vTool.Inverse");
return GetMeshDS()->ChangeElementNodes( theElem, vTool.GetNodes(), vTool.NbNodes() );
}
}
aBadRate2 = getBadRate( &tr3, theCrit ) + getBadRate( &tr4, theCrit );
int aShapeId = FindShape( elem );
- const SMDS_MeshElement* newElem = 0;
+ const SMDS_MeshElement* newElem1 = 0;
+ const SMDS_MeshElement* newElem2 = 0;
if( !elem->IsQuadratic() ) {
// split liner quadrangle
-
if ( aBadRate1 <= aBadRate2 ) {
// tr1 + tr2 is better
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, aNodes, 3 );
- newElem = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] );
+ newElem1 = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] );
+ newElem2 = aMesh->AddFace( aNodes[2], aNodes[0], aNodes[1] );
}
else {
// tr3 + tr4 is better
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, &aNodes[1], 3 );
- newElem = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] );
+ newElem1 = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] );
+ newElem2 = aMesh->AddFace( aNodes[3], aNodes[1], aNodes[2] );
}
}
else {
N[3] = aNodes[4];
N[4] = aNodes[5];
N[5] = newN;
- newElem = aMesh->AddFace(aNodes[2], aNodes[3], aNodes[0],
- aNodes[6], aNodes[7], newN );
+ newElem1 = aMesh->AddFace(aNodes[2], aNodes[3], aNodes[0],
+ aNodes[6], aNodes[7], newN );
+ newElem2 = aMesh->AddFace(aNodes[2], aNodes[0], aNodes[1],
+ newN, aNodes[4], aNodes[5] );
}
else {
N[0] = aNodes[1];
N[3] = aNodes[5];
N[4] = aNodes[6];
N[5] = newN;
- newElem = aMesh->AddFace(aNodes[3], aNodes[0], aNodes[1],
- aNodes[7], aNodes[4], newN );
+ newElem1 = aMesh->AddFace(aNodes[3], aNodes[0], aNodes[1],
+ aNodes[7], aNodes[4], newN );
+ newElem2 = aMesh->AddFace(aNodes[3], aNodes[1], aNodes[2],
+ newN, aNodes[5], aNodes[6] );
}
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, N, 6 );
-
} // quadratic case
// care of a new element
- myLastCreatedElems.Append(newElem);
- AddToSameGroups( newElem, elem, aMesh );
+ myLastCreatedElems.Append(newElem1);
+ myLastCreatedElems.Append(newElem2);
+ AddToSameGroups( newElem1, elem, aMesh );
+ AddToSameGroups( newElem2, elem, aMesh );
// put a new triangle on the same shape
if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
+ {
+ aMesh->SetMeshElementOnShape( newElem1, aShapeId );
+ aMesh->SetMeshElementOnShape( newElem2, aShapeId );
+ }
+ aMesh->RemoveElement( elem );
}
return true;
}
aNodes[ i++ ] = static_cast<const SMDS_MeshNode*>( itN->next() );
int aShapeId = FindShape( elem );
- const SMDS_MeshElement* newElem = 0;
+ const SMDS_MeshElement* newElem1 = 0;
+ const SMDS_MeshElement* newElem2 = 0;
if ( the13Diag ) {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, aNodes, 3 );
- newElem = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] );
+ newElem1 = aMesh->AddFace( aNodes[2], aNodes[0], aNodes[1] );
+ newElem2 = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] );
}
else {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, &aNodes[1], 3 );
- newElem = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] );
+ newElem1 = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] );
+ newElem2 = aMesh->AddFace( aNodes[3], aNodes[1], aNodes[2] );
}
- myLastCreatedElems.Append(newElem);
+ myLastCreatedElems.Append(newElem1);
+ myLastCreatedElems.Append(newElem2);
// put a new triangle on the same shape and add to the same groups
if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- AddToSameGroups( newElem, elem, aMesh );
+ {
+ aMesh->SetMeshElementOnShape( newElem1, aShapeId );
+ aMesh->SetMeshElementOnShape( newElem2, aShapeId );
+ }
+ AddToSameGroups( newElem1, elem, aMesh );
+ AddToSameGroups( newElem2, elem, aMesh );
+ //aMesh->RemoveFreeElement(elem, aMesh->MeshElements(aShapeId), true);
+ aMesh->RemoveElement( elem );
}
// Quadratic quadrangle
myLastCreatedNodes.Append(newN);
// create a new element
- const SMDS_MeshElement* newElem = 0;
+ const SMDS_MeshElement* newElem1 = 0;
+ const SMDS_MeshElement* newElem2 = 0;
const SMDS_MeshNode* N[6];
if ( the13Diag ) {
N[0] = aNodes[0];
N[3] = aNodes[4];
N[4] = aNodes[5];
N[5] = newN;
- newElem = aMesh->AddFace(aNodes[2], aNodes[3], aNodes[0],
- aNodes[6], aNodes[7], newN );
+ newElem1 = aMesh->AddFace(aNodes[2], aNodes[3], aNodes[0],
+ aNodes[6], aNodes[7], newN );
+ newElem2 = aMesh->AddFace(aNodes[2], aNodes[0], aNodes[1],
+ newN, aNodes[4], aNodes[5] );
}
else {
N[0] = aNodes[1];
N[3] = aNodes[5];
N[4] = aNodes[6];
N[5] = newN;
- newElem = aMesh->AddFace(aNodes[3], aNodes[0], aNodes[1],
- aNodes[7], aNodes[4], newN );
+ newElem1 = aMesh->AddFace(aNodes[3], aNodes[0], aNodes[1],
+ aNodes[7], aNodes[4], newN );
+ newElem2 = aMesh->AddFace(aNodes[3], aNodes[1], aNodes[2],
+ newN, aNodes[5], aNodes[6] );
}
- myLastCreatedElems.Append(newElem);
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( elem, N, 6 );
+ myLastCreatedElems.Append(newElem1);
+ myLastCreatedElems.Append(newElem2);
// put a new triangle on the same shape and add to the same groups
if ( aShapeId )
- aMesh->SetMeshElementOnShape( newElem, aShapeId );
- AddToSameGroups( newElem, elem, aMesh );
+ {
+ aMesh->SetMeshElementOnShape( newElem1, aShapeId );
+ aMesh->SetMeshElementOnShape( newElem2, aShapeId );
+ }
+ AddToSameGroups( newElem1, elem, aMesh );
+ AddToSameGroups( newElem2, elem, aMesh );
+ aMesh->RemoveElement( elem );
}
}
mapEl_setLi.erase( tr2 );
mapLi_listEl.erase( *link12 );
if(tr1->NbNodes()==3) {
- if( tr1->GetID() < tr2->GetID() ) {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( tr1, n12, 4 );
- myLastCreatedElems.Append(tr1);
- aMesh->RemoveElement( tr2 );
- }
- else {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( tr2, n12, 4 );
- myLastCreatedElems.Append(tr2);
- aMesh->RemoveElement( tr1);
- }
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace(n12[0], n12[1], n12[2], n12[3] );
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr2 );
}
else {
const SMDS_MeshNode* N1 [6];
aNodes[5] = N2[5];
aNodes[6] = N2[3];
aNodes[7] = N1[5];
- if( tr1->GetID() < tr2->GetID() ) {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr1, aNodes, 8 );
- myLastCreatedElems.Append(tr1);
- GetMeshDS()->RemoveElement( tr2 );
- }
- else {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr2, aNodes, 8 );
- myLastCreatedElems.Append(tr2);
- GetMeshDS()->RemoveElement( tr1 );
- }
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace(aNodes[0], aNodes[1], aNodes[2], aNodes[3],
+ aNodes[4], aNodes[5], aNodes[6], aNodes[7]);
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr2 );
// remove middle node (9)
GetMeshDS()->RemoveNode( N1[4] );
}
mapEl_setLi.erase( tr3 );
mapLi_listEl.erase( *link13 );
if(tr1->NbNodes()==3) {
- if( tr1->GetID() < tr2->GetID() ) {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( tr1, n13, 4 );
- myLastCreatedElems.Append(tr1);
- aMesh->RemoveElement( tr3 );
- }
- else {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( tr3, n13, 4 );
- myLastCreatedElems.Append(tr3);
- aMesh->RemoveElement( tr1 );
- }
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace(n13[0], n13[1], n13[2], n13[3] );
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr3 );
}
else {
const SMDS_MeshNode* N1 [6];
aNodes[5] = N2[5];
aNodes[6] = N2[3];
aNodes[7] = N1[5];
- if( tr1->GetID() < tr2->GetID() ) {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr1, aNodes, 8 );
- myLastCreatedElems.Append(tr1);
- GetMeshDS()->RemoveElement( tr3 );
- }
- else {
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- GetMeshDS()->ChangeElementNodes( tr3, aNodes, 8 );
- myLastCreatedElems.Append(tr3);
- GetMeshDS()->RemoveElement( tr1 );
- }
+ const SMDS_MeshElement* newElem = 0;
+ newElem = aMesh->AddFace(aNodes[0], aNodes[1], aNodes[2], aNodes[3],
+ aNodes[4], aNodes[5], aNodes[6], aNodes[7]);
+ myLastCreatedElems.Append(newElem);
+ AddToSameGroups( newElem, tr1, aMesh );
+ aMesh->RemoveElement( tr1 );
+ aMesh->RemoveElement( tr3 );
// remove middle node (9)
GetMeshDS()->RemoveNode( N1[4] );
}
const int nbSteps,
SMESH_SequenceOfElemPtr& srcElements)
{
+ MESSAGE("makeWalls");
ASSERT( newElemsMap.size() == elemNewNodesMap.size() );
SMESHDS_Mesh* aMesh = GetMeshDS();
if ( !f )
myLastCreatedElems.Append(aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] ));
else if ( nodes[ 1 ] != f->GetNodeWrap( f->GetNodeIndex( nodes[ 0 ] ) + 1 ))
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( f, nodes, nbn );
+ {
+ myLastCreatedElems.Append(aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] ));
+ aMesh->RemoveElement(f);
+ }
break;
}
case 4: { ///// quadrangle
if ( !f )
myLastCreatedElems.Append(aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] ));
else if ( nodes[ 1 ] != f->GetNodeWrap( f->GetNodeIndex( nodes[ 0 ] ) + 1 ))
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( f, nodes, nbn );
+ {
+ myLastCreatedElems.Append(aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ], nodes[ 3 ] ));
+ aMesh->RemoveElement(f);
+ }
break;
}
default:
tmpnodes[3] = nodes[1];
tmpnodes[4] = nodes[3];
tmpnodes[5] = nodes[5];
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( f, tmpnodes, nbn );
+ myLastCreatedElems.Append(aMesh->AddFace(nodes[0], nodes[2], nodes[4],
+ nodes[1], nodes[3], nodes[5]));
+ aMesh->RemoveElement(f);
}
}
else { /////// quadratic quadrangle
tmpnodes[5] = nodes[3];
tmpnodes[6] = nodes[5];
tmpnodes[7] = nodes[7];
- // TODO problem ChangeElementNodes : not the same number of nodes, not the same type
- aMesh->ChangeElementNodes( f, tmpnodes, nbn );
+ myLastCreatedElems.Append(aMesh->AddFace(nodes[0], nodes[2], nodes[4], nodes[6],
+ nodes[1], nodes[3], nodes[5], nodes[7]));
+ aMesh->RemoveElement(f);
}
}
}
if ( !f )
myLastCreatedElems.Append(aMesh->AddPolygonalFace(polygon_nodes));
else if ( nodes[ 1 ] != f->GetNodeWrap( f->GetNodeIndex( nodes[ 0 ] ) + 1 ))
+ {
// TODO problem ChangeElementNodes : not the same number of nodes, not the same type
+ MESSAGE("ChangeElementNodes");
aMesh->ChangeElementNodes( f, nodes, nbn );
+ }
}
}
while ( srcElements.Length() < myLastCreatedElems.Length() )
theElems.insert( *invElemIt );
// replicate or reverse elements
-
+ // TODO revoir ordre reverse vtk
enum {
REV_TETRA = 0, // = nbNodes - 4
REV_PYRAMID = 1, // = nbNodes - 4
const bool theMakeGroups,
SMESH_Mesh* theTargetMesh)
{
+ MESSAGE("Scale");
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes)
{
+ MESSAGE("MergeNodes");
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
if (aShapeId)
aMesh->SetMeshElementOnShape(newElem, aShapeId);
}
+ MESSAGE("ChangeElementNodes MergeNodes Poly");
aMesh->ChangeElementNodes(elem, &polygons_nodes[inode], quantities[nbNew - 1]);
}
else {
}
else {
// Change regular element or polygon
- aMesh->ChangeElementNodes( elem, & uniqueNodes[0], nbUniqueNodes );
+ SMDS_MeshElement* newElem = 0;
+ switch (nbUniqueNodes)
+ {
+ 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)
+ {
+ myLastCreatedElems.Append(newElem);
+ if ( aShapeId )
+ aMesh->SetMeshElementOnShape( newElem, aShapeId );
+ }
+ aMesh->RemoveElement(elem);
}
}
else {
newNodes[ 2 ] = nodes[ iSplit >= iBestQuad ? i3 : i4 ];
newNodes[ 3 ] = nodes[ i4 ];
// TODO problem ChangeElementNodes : not the same number of nodes, not the same type
+ MESSAGE("ChangeElementNodes");
aMesh->ChangeElementNodes( theFace, newNodes, iSplit == iBestQuad ? 4 : 3 );
} // end if(!theFace->IsQuadratic())
else { // theFace is quadratic
if( NewElem )
theSm->AddElement( NewElem );
}
+ GetMeshDS()->compactMesh();
return nbElem;
}
aHelper.SetSubShape(0); // apply to the whole mesh
aHelper.FixQuadraticElements();
}
+ GetMeshDS()->compactMesh();
}
//=======================================================================
// elemIDsToRemove.push_back( e->GetID() );
// else
if ( nbReplaced )
+ {
// TODO problem ChangeElementNodes : not the same number of nodes, not the same type
+ MESSAGE("ChangeElementNodes");
aMesh->ChangeElementNodes( e, & nodes[0], nbNodes );
+ }
}
}
const SMDS_MeshNode* >& theNodeNodeMap,
const bool theIsDoubleElem )
{
+ MESSAGE("doubleNodes");
// iterate on through element and duplicate them (by nodes duplication)
bool res = false;
TIDSortedElemSet::const_iterator elemItr = theElems.begin();
if ( theIsDoubleElem )
myLastCreatedElems.Append( AddElement(newNodes, anElem->GetType(), anElem->IsPoly()) );
else
+ {
+ MESSAGE("ChangeElementNodes");
theMeshDS->ChangeElementNodes( anElem, &newNodes[ 0 ], anElem->NbNodes() );
-
+ }
res = true;
}
return res;
bool SMESH_MeshEditor::DoubleNodes( const std::list< int >& theListOfNodes,
const std::list< int >& theListOfModifiedElems )
{
+ MESSAGE("DoubleNodes");
myLastCreatedElems.Clear();
myLastCreatedNodes.Clear();
const SMDS_MeshElement* anElem = anElemToNodesIter->first;
vector<const SMDS_MeshNode*> aNodeArr = anElemToNodesIter->second;
if ( anElem )
+ {
+ MESSAGE("ChangeElementNodes");
aMeshDS->ChangeElementNodes( anElem, &aNodeArr[ 0 ], anElem->NbNodes() );
+ }
}
return true;
const SMDS_MeshNode * nodes[],
const int nbnodes)
{
+ MESSAGE("SMESHDS_Mesh::ChangeElementNodes");
if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes ))
return false;
void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID)
{
- SMDS_Mesh::Renumber( isNodes, startID, deltaID );
- myScript->Renumber( isNodes, startID, deltaID );
+ // TODO not possible yet to have node numbers not starting to O and continuous.
+ this->compactMesh();
+// SMDS_Mesh::Renumber( isNodes, startID, deltaID );
+// myScript->Renumber( isNodes, startID, deltaID );
}
//=======================================================================
void SMESHDS_Mesh::compactMesh()
{
- int newNodeSize = 0;
- int nbNodes = myNodes.size();
- int nbVtkNodes = myGrid->GetNumberOfPoints();
- MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
- int nbNodeTemp = nbVtkNodes;
- if (nbNodes > nbVtkNodes) nbNodeTemp = nbNodes;
- vector<int> idNodesOldToNew;
- idNodesOldToNew.clear();
- idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
-
- bool areNodesModified = ! myNodeIDFactory->isPoolIdEmpty();
- MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified);
- if (areNodesModified)
- {
- for (int i=0; i<nbNodes; i++)
- {
- if (myNodes[i])
- {
- idNodesOldToNew[i] = i; // all valid id are >= 0
- newNodeSize++;
- }
- }
- }
- else
- {
- for (int i=0; i<nbNodes; i++)
- idNodesOldToNew[i] = i;
- if (nbNodes > nbVtkNodes)
- newNodeSize = nbVtkNodes; // else 0 means nothing to change (no need to compact vtkPoints)
- }
-
- int newCellSize = 0;
- int nbCells = myCells.size();
- int nbVtkCells = myGrid->GetNumberOfCells();
- MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
- int nbCellTemp = nbVtkCells;
- if (nbCells > nbVtkCells) nbCellTemp = nbCells;
- vector<int> idCellsOldToNew;
- idCellsOldToNew.clear();
- idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
-
- for (int i=0; i<nbCells; i++)
- {
- if (myCells[i])
- {
- idCellsOldToNew[i] = myVtkIndex[i]; // valid vtk indexes are > = 0
- newCellSize++;
- }
- }
- myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
-
- // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
-
- if (areNodesModified)
- {
- MESSAGE("-------------- modify myNodes");
- SetOfNodes newNodes;
- newNodes.resize(newNodeSize);
-
- for (int i=0; i<nbNodes; i++)
- {
- if (myNodes[i])
- {
- int newid = idNodesOldToNew[i];
- //MESSAGE(i << " --> " << newid);;
- myNodes[i]->setId(newid);
- newNodes[newid] = myNodes[i];
- }
- }
- myNodes.swap(newNodes);
- this->myNodeIDFactory->emptyPool(newNodeSize);
- }
-
- // --- SMDS_MeshCell, myIDElements and myVtkIndex (myCells and myElementIdFactory are not compacted)
-
- int vtkIndexSize = myVtkIndex.size();
- int maxVtkId = 0;
- for (int oldVtkId=0; oldVtkId<vtkIndexSize; oldVtkId++)
- {
- int smdsId = this->myVtkIndex[oldVtkId];
- if (smdsId >=0)
- {
- int newVtkId = idCellsOldToNew[oldVtkId];
- if (newVtkId > maxVtkId) maxVtkId = newVtkId;
- //MESSAGE("===========> smdsId newVtkId " << smdsId << " " << newVtkId);
- myCells[smdsId]->setVtkId(newVtkId);
- myIDElements[smdsId] = newVtkId;
- myVtkIndex[newVtkId] = smdsId;
- }
- }
- maxVtkId++;
- MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
- MESSAGE("maxVtkId=" << maxVtkId);
-
- SetOfCells newCells;
- vector<int> newSmdsToVtk;
- vector<int> newVtkToSmds;
-
- newCells.resize(maxVtkId,0);
- newSmdsToVtk.resize(maxVtkId,-1);
- newVtkToSmds.resize(maxVtkId,-1);
-
- int myCellsSize = myCells.size();
- int newSmdsId =0;
- for (int i=0; i<myCellsSize; i++)
- {
- if (myCells[i])
- {
- //MESSAGE(newSmdsId << " " << i);
- newCells[newSmdsId] = myCells[i];
- int idvtk = myCells[i]->getVtkId();
- newSmdsToVtk[newSmdsId] = idvtk;
- assert(idvtk < maxVtkId);
- newVtkToSmds[idvtk] = newSmdsId;
- myCells[i]->setId(newSmdsId);
- newSmdsId++;
- assert(newSmdsId <= maxVtkId);
- }
- }
-
- myCells.swap(newCells);
- myIDElements.swap(newSmdsToVtk);
- myVtkIndex.swap(newVtkToSmds);
- MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
-
- // ---TODO: myNodes, myElements in submeshes
-
-// map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.begin();
-// for(; it != myShapeIndexToSubMesh.end(); ++it)
+ int newNodeSize = 0;
+ int nbNodes = myNodes.size();
+ int nbVtkNodes = myGrid->GetNumberOfPoints();
+ MESSAGE("nbNodes=" << nbNodes << " nbVtkNodes=" << nbVtkNodes);
+ int nbNodeTemp = nbVtkNodes;
+ if (nbNodes > nbVtkNodes)
+ nbNodeTemp = nbNodes;
+ vector<int> idNodesOldToNew;
+ idNodesOldToNew.clear();
+ idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
+
+ for (int i = 0; i < nbNodes; i++)
+ {
+ if (myNodes[i])
+ {
+ idNodesOldToNew[i] = i; // all valid id are >= 0
+ newNodeSize++;
+ }
+ }
+ bool areNodesModified = (newNodeSize < nbVtkNodes);
+ MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified);
+
+// bool areNodesModified = !myNodeIDFactory->isPoolIdEmpty();
+// MESSAGE("------------------------------------------------- SMESHDS_Mesh::compactMesh " << areNodesModified);
+// if (areNodesModified)
// {
-// (*it).second->compactList(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
+// for (int i = 0; i < nbNodes; i++)
+// {
+// if (myNodes[i])
+// {
+// idNodesOldToNew[i] = i; // all valid id are >= 0
+// newNodeSize++;
+// }
+// }
// }
+// else
+// {
+// for (int i = 0; i < nbNodes; i++)
+// idNodesOldToNew[i] = i;
+// if (nbNodes > nbVtkNodes)
+// newNodeSize = nbVtkNodes; // else 0 means nothing to change (no need to compact vtkPoints)
+// }
+
+ int newCellSize = 0;
+ int nbCells = myCells.size();
+ int nbVtkCells = myGrid->GetNumberOfCells();
+ MESSAGE("nbCells=" << nbCells << " nbVtkCells=" << nbVtkCells);
+ int nbCellTemp = nbVtkCells;
+ if (nbCells > nbVtkCells)
+ nbCellTemp = nbCells;
+ vector<int> idCellsOldToNew;
+ idCellsOldToNew.clear();
+ idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
+
+ for (int i = 0; i < nbCells; i++)
+ {
+ if (myCells[i])
+ {
+ idCellsOldToNew[i] = myVtkIndex[i]; // valid vtk indexes are > = 0
+ newCellSize++;
+ }
+ }
+ myGrid->compactGrid(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
+
+ // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
+
+ if (areNodesModified)
+ {
+ MESSAGE("-------------- modify myNodes");
+ SetOfNodes newNodes;
+ newNodes.resize(newNodeSize);
+
+ for (int i = 0; i < nbNodes; i++)
+ {
+ if (myNodes[i])
+ {
+ int newid = idNodesOldToNew[i];
+ //MESSAGE(i << " --> " << newid);;
+ myNodes[i]->setId(newid);
+ newNodes[newid] = myNodes[i];
+ }
+ }
+ myNodes.swap(newNodes);
+ this->myNodeIDFactory->emptyPool(newNodeSize);
+ }
+
+ // --- SMDS_MeshCell, myIDElements and myVtkIndex (myCells and myElementIdFactory are not compacted)
+
+ int vtkIndexSize = myVtkIndex.size();
+ int maxVtkId = 0;
+ for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
+ {
+ int smdsId = this->myVtkIndex[oldVtkId];
+ if (smdsId >= 0)
+ {
+ int newVtkId = idCellsOldToNew[oldVtkId];
+ if (newVtkId > maxVtkId)
+ maxVtkId = newVtkId;
+ //MESSAGE("===========> smdsId newVtkId " << smdsId << " " << newVtkId);
+ myCells[smdsId]->setVtkId(newVtkId);
+ myIDElements[smdsId] = newVtkId;
+ myVtkIndex[newVtkId] = smdsId;
+ }
+ }
+ maxVtkId++;
+ MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
+ MESSAGE("maxVtkId=" << maxVtkId);
+
+ SetOfCells newCells;
+ vector<int> newSmdsToVtk;
+ vector<int> newVtkToSmds;
+
+ newCells.resize(maxVtkId, 0);
+ newSmdsToVtk.resize(maxVtkId, -1);
+ newVtkToSmds.resize(maxVtkId, -1);
+
+ int myCellsSize = myCells.size();
+ int newSmdsId = 0;
+ for (int i = 0; i < myCellsSize; i++)
+ {
+ if (myCells[i])
+ {
+ //MESSAGE(newSmdsId << " " << i);
+ newCells[newSmdsId] = myCells[i];
+ int idvtk = myCells[i]->getVtkId();
+ newSmdsToVtk[newSmdsId] = idvtk;
+ assert(idvtk < maxVtkId);
+ newVtkToSmds[idvtk] = newSmdsId;
+ myCells[i]->setId(newSmdsId);
+ newSmdsId++;
+ assert(newSmdsId <= maxVtkId);
+ }
+ }
+
+ myCells.swap(newCells);
+ myIDElements.swap(newSmdsToVtk);
+ myVtkIndex.swap(newVtkToSmds);
+ MESSAGE("myCells.size()=" << myCells.size() << " myIDElements.size()=" << myIDElements.size() << " myVtkIndex.size()=" << myVtkIndex.size() );
+
+ // ---TODO: myNodes, myElements in submeshes
+
+ // map<int,SMESHDS_SubMesh*>::iterator it = myShapeIndexToSubMesh.begin();
+ // for(; it != myShapeIndexToSubMesh.end(); ++it)
+ // {
+ // (*it).second->compactList(idNodesOldToNew, newNodeSize, idCellsOldToNew, newCellSize);
+ // }
}
bool IsGroupOfSubShapes (const TopoDS_Shape& aSubShape) const;
- void compactMesh();
+ virtual void compactMesh();
void BuildDownWardConnectivity(bool withEdges);
~SMESHDS_Mesh();
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
import smesh
import math
+salome.salome_init()
+
def GetNewNodes(mesh,Elems,OldNodes):
"""
Auxilary function, which return list of nodes from
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
#
# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
import geompy
import smesh
+salome.salome_init()
# ---------------------------- GEOM --------------------------------------
# ---- define contigous arcs and segment to define a closed wire
mesh.SplitQuadObject(submesh2, 1)
#2 cutting of triangles of the group
-FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422]
+FacesTriToQuad = [ 2391, 2824, 2825, 2826, 2827, 2828, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2841, 2844, 2845, 2847, 2854, 2861, 2863, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2946, 2951, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985 ]
GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad)
mesh.TriToQuadObject(GroupTriToQuad, None , 1.57)