return SMDS_ElemIteratorPtr(new SMDS_MeshNode_MyInvIterator(SMDS_Mesh::_meshList[myMeshId], l.cells, l.ncells, type));
}
-// Same as GetInverseElementIterator but the create iterator only return
+// Same as GetInverseElementIterator but the created iterator only returns
// wanted type elements.
class SMDS_MeshNode_MyIterator:public SMDS_ElemIterator
{
private:
- SMDS_Mesh* myMesh;
- vtkIdType* myCells;
- int myNcells;
- SMDSAbs_ElementType myType;
- int iter;
+ SMDS_Mesh* myMesh;
+ vtkIdType* myCells;
+ int myNcells;
+ SMDSAbs_ElementType myType;
+ int iter;
vector<SMDS_MeshElement*> myFiltCells;
public:
SMDSAbs_ElementType type):
myMesh(mesh), myCells(cells), myNcells(ncells), myType(type), iter(0)
{
- //MESSAGE("myNcells " << myNcells);
for (; iter<ncells; iter++)
{
int vtkId = myCells[iter];
int smdsId = myMesh->fromVtkToSmds(vtkId);
- //MESSAGE("vtkId " << vtkId << " smdsId " << smdsId);
const SMDS_MeshElement* elem = myMesh->FindElement(smdsId);
if (elem->GetType() == type)
myFiltCells.push_back((SMDS_MeshElement*)elem);
}
myNcells = myFiltCells.size();
- //MESSAGE("myNcells " << myNcells);
iter = 0;
- //MESSAGE("SMDS_MeshNode_MyIterator (filter) " << ncells << " " << myNcells);
}
bool more()
// --- if newNodeSize, create a new compacted vtkPoints
- vtkPoints *newPoints = vtkPoints::New();
- newPoints->SetDataType(VTK_DOUBLE);
- newPoints->SetNumberOfPoints(newNodeSize);
- if (newNodeSize)
+ if ( newNodeSize )
{
// rnv: to fix bug "21125: EDF 1233 SMESH: Degradation of precision in a test case for quadratic conversion"
// using double type for storing coordinates of nodes instead float.
+ vtkPoints *newPoints = vtkPoints::New();
+ newPoints->SetDataType(VTK_DOUBLE);
+ newPoints->SetNumberOfPoints(newNodeSize);
+
int oldNodeSize = idNodesOldToNew.size();
int i = 0;
int endBloc = i;
copyNodes(newPoints, idNodesOldToNew, alreadyCopied, startBloc, endBloc);
}
- newPoints->Squeeze();
- }
-
- if (1/*newNodeSize*/)
- {
this->SetPoints(newPoints);
+ newPoints->Delete();
}
- newPoints->Delete();
-
+ this->Points->Squeeze();
// --- create new compacted Connectivity, Locations and Types
int oldCellSize = this->Types->GetNumberOfTuples();
- if ( oldCellSize == newCellSize ) // no holes in elements
+ if ( !newNodeSize && oldCellSize == newCellSize ) // no holes in elements
{
this->Connectivity->Squeeze();
this->Locations->Squeeze();
}
}
if ( toNotify )
+ {
smToNotify.push_back( aSubMesh );
-
- if ( !aSubMesh->IsEmpty() &&
- aSubMesh->GetSubShape().ShapeType() == TopAbs_EDGE &&
- !toNotify )
- allMeshedEdgesNotified = false;
+ if ( aSubMesh->GetAlgoState() == SMESH_subMesh::MISSING_HYP )
+ allMeshedEdgesNotified = false; // update of algo state needed, not mesh clearing
+ }
+ else
+ {
+ if ( !aSubMesh->IsEmpty() &&
+ aSubMesh->GetSubShape().ShapeType() == TopAbs_EDGE )
+ allMeshedEdgesNotified = false;
+ }
}
+ if ( smToNotify.empty() )
+ return;
// if all meshed EDGEs will be notified then the notification is equivalent
// to the whole mesh clearing
if ( allMeshedEdgesNotified )
- Clear();
+ {
+ if ( NbNodes() > 0 )
+ Clear();
+ }
else
+ {
// notify in reverse order to avoid filling of the pool of IDs
for ( int i = smToNotify.size()-1; i >= 0; --i )
smToNotify[i]->AlgoStateEngine(SMESH_subMesh::MODIF_HYP,
const_cast< SMESH_Hypothesis*>( hyp ));
-
+ }
HasModificationsToDiscard(); // to reset _isModified flag if mesh becomes empty
GetMeshDS()->Modified();
}
if ( nbElems > 0 )
{
// start from elem with max ID to avoid filling the pool of IDs
- const SMDS_MeshElement * lastElem = subMeshDS->GetElement( nbElems-1 );
- bool rev = ( lastElem->GetID() == meshDS->MaxElementID() );
+ bool rev = true;
SMDS_ElemIteratorPtr ite = subMeshDS->GetElements( rev );
+ const SMDS_MeshElement * lastElem = ite->next();
+ rev = ( lastElem->GetID() == meshDS->MaxElementID() );
+ if ( !rev )
+ ite = subMeshDS->GetElements( rev );
+ else
+ meshDS->RemoveFreeElement( lastElem, subMeshDS );
while (ite->more()) {
const SMDS_MeshElement * elt = ite->next();
- meshDS->RemoveFreeElement(elt, 0);
+ meshDS->RemoveFreeElement( elt, subMeshDS );
}
}
int nbNodes = subMeshDS->NbNodes();
if ( nbNodes > 0 )
{
- const SMDS_MeshNode * lastNode = subMeshDS->GetNode( nbNodes-1 );
- bool rev = ( lastNode->GetID() == meshDS->MaxNodeID() );
+ bool rev = true;
SMDS_NodeIteratorPtr itn = subMeshDS->GetNodes( rev );
+ const SMDS_MeshNode * lastNode = itn->next();
+ rev = ( lastNode->GetID() == meshDS->MaxNodeID() );
+ if ( !rev )
+ itn = subMeshDS->GetNodes( rev );
+ else
+ meshDS->RemoveNode( lastNode );
while (itn->more()) {
const SMDS_MeshNode * node = itn->next();
if ( node->NbInverseElements() == 0 )
- meshDS->RemoveFreeNode(node, 0);
+ meshDS->RemoveFreeNode( node, subMeshDS );
else // for StdMeshers_CompositeSegment_1D: node in one submesh, edge in another
meshDS->RemoveNode(node);
}
SMDS_Mesh::compactMesh();
int newNodeSize = 0;
- int nbNodes = myNodes.size();
- int nbVtkNodes = myGrid->GetNumberOfPoints();
- int nbNodeTemp = nbVtkNodes;
- if (nbNodes > nbVtkNodes)
- nbNodeTemp = nbNodes;
- vector<int> idNodesOldToNew;
- idNodesOldToNew.clear();
- idNodesOldToNew.resize(nbNodeTemp, -1); // all unused id will be -1
+ int nbNodes = myNodes.size();
+ int nbVtkNodes = myGrid->GetNumberOfPoints();
+ int nbNodeTemp = Max( nbVtkNodes, nbNodes );
+ vector<int> idNodesOldToNew(nbNodeTemp, -1); // all unused id will be -1
for (int i = 0; i < nbNodes; i++)
{
newNodeSize++;
}
}
- bool areNodesModified = (newNodeSize < nbVtkNodes);
+ bool areNodesModified = (newNodeSize != nbVtkNodes);
areNodesModified = true;
int newCellSize = 0;
- int nbCells = myCells.size();
- int nbVtkCells = myGrid->GetNumberOfCells();
- int nbCellTemp = nbVtkCells;
- if (nbCells > nbVtkCells)
- nbCellTemp = nbCells;
- vector<int> idCellsOldToNew;
- idCellsOldToNew.clear();
- idCellsOldToNew.resize(nbCellTemp, -1); // all unused id will be -1
+ int nbCells = myCells.size();
+ int nbVtkCells = myGrid->GetNumberOfCells();
+ int nbCellTemp = Max( nbVtkCells, nbCells );
+ vector<int> idCellsOldToNew(nbCellTemp, -1); // all unused id will be -1
for (int i = 0; i < nbCells; i++)
{
if (nbVtkCells > newCellSize) newCellSize = nbVtkCells; // several cells with same SMDS Id
}
- // --- SMDS_MeshNode and myNodes (id in SMDS and in VTK are the same), myNodeIdFactory
+ // --- SMDS_MeshNode and myNodes, myNodeIdFactory
- if (areNodesModified)
+ if ( true )
{
- SetOfNodes newNodes;
- newNodes.resize(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
+ SetOfNodes newNodes(newNodeSize+1,0); // 0 not used, SMDS numbers 1..n
int newSmdsId = 0;
for (int i = 0; i < nbNodes; i++)
{
if (myNodes[i])
{
- newSmdsId++; // SMDS id start to 1
+ newSmdsId++; // SMDS id starts from 1
int oldVtkId = myNodes[i]->getVtkId();
int newVtkId = idNodesOldToNew[oldVtkId];
myNodes[i]->setVtkId(newVtkId);
// --- SMDS_MeshCell, myCellIdVtkToSmds, myCellIdSmdsToVtk, myCells
int vtkIndexSize = myCellIdVtkToSmds.size();
- int maxVtkId = -1;
for (int oldVtkId = 0; oldVtkId < vtkIndexSize; oldVtkId++)
{
int oldSmdsId = this->myCellIdVtkToSmds[oldVtkId];
if (oldSmdsId > 0)
{
int newVtkId = idCellsOldToNew[oldVtkId];
- if (newVtkId > maxVtkId)
- maxVtkId = newVtkId;
myCells[oldSmdsId]->setVtkId(newVtkId);
}
}
- SetOfCells newCells;
- vector<int> newVtkToSmds;
-
- assert(maxVtkId < newCellSize);
- newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
- newVtkToSmds.resize(newCellSize+1, -1);
+ SetOfCells newCells(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n
+ vector<int> newVtkToSmds(newCellSize+1, -1);
int myCellsSize = myCells.size();
int newSmdsId = 0;
{
if ( myCells[i] )
{
- newSmdsId++; // SMDS id start to 1
+ newSmdsId++; // SMDS id starts from 1
assert(newSmdsId <= newCellSize);
newCells[newSmdsId] = myCells[i];
newCells[newSmdsId]->setId(newSmdsId);
myElements.swap(newElems);
myUnusedIdElements = 0;
}
+ else
+ {
+ std::vector<const SMDS_MeshElement*>( myElements ).swap( myElements );
+ }
if ( myUnusedIdNodes > 0 )
{
myNodes.swap(newNodes);
myUnusedIdNodes = 0;
}
+ else
+ {
+ std::vector<const SMDS_MeshNode*>( myNodes ).swap( myNodes );
+ }
}
//=======================================================================
try {
OCC_CATCH_SIGNALS;
if (nulData)
- objModified = aVisualObj->NulData();
+ objModified = aVisualObj->NulData();
else
objModified = aVisualObj->Update();
}
int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
//MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" <<usedMB);
if ( freeMB > 0 && usedMB * 5 > freeMB ) {
- bool continu = false;
- if ( usedMB * 3 > freeMB )
- // even dont try to show
- SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
- else
- // there is a chance to succeed
- continu = SUIT_MessageBox::warning
- (SMESHGUI::desktop(),
- QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
- SUIT_MessageBox::Yes | SUIT_MessageBox::No,
- SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
- if ( !continu ) {
- // remove the corresponding actors from all views
- RemoveVisualObjectWithActors( theEntry );
- aVisualObj.reset();
- }
+ bool continu = false;
+ if ( usedMB * 3 > freeMB )
+ // even dont try to show
+ SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
+ else
+ // there is a chance to succeed
+ continu = SUIT_MessageBox::warning
+ (SMESHGUI::desktop(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
+ if ( !continu ) {
+ // remove the corresponding actors from all views
+ RemoveVisualObjectWithActors( theEntry );
+ aVisualObj.reset();
+ }
}
}
{
vector<int> color;
string str = value;
- // color must be presented as a string of next form:
+ // color must be presented as a string of following form:
if ( str.at(0) == '#' && str.length() == 7 ) { // hexadecimal color ("#ffaa00", for example)
str = str.substr(1);
for ( size_t i = 0; i < str.length()/2; i++ )
string algoType = algo->GetName();
if ( algoType.substr(0, 11) != "Projection_")
- return gen->Compute( *mesh, shape, /*shapeOnly=*/true );
+ return gen->Compute( *mesh, shape, SMESH_Gen::SHAPE_ONLY );
// try to compute source mesh
srcMesh = mesh;
if ( MakeComputed( srcMesh->GetSubMesh( srcShape ), iterationNb + 1 ) &&
- gen->Compute( *mesh, shape, /*shapeOnly=*/true ))
+ gen->Compute( *mesh, shape, SMESH_Gen::SHAPE_ONLY ))
return sm->IsMeshComputed();
return false;
return false;
}
+ // adjust length of extreme LE (test viscous_layers_01/B7)
+ gp_Vec vDiv0( pExtreme[0], pProj[0] );
+ gp_Vec vDiv1( pExtreme[1], pProj[1] );
+ double d0 = vDiv0.Magnitude();
+ double d1 = vDiv1.Magnitude();
+ if ( e[0]->_normal * vDiv0.XYZ() < 0 ) e[0]->_len += d0;
+ else e[0]->_len -= d0;
+ if ( e[1]->_normal * vDiv1.XYZ() < 0 ) e[1]->_len += d1;
+ else e[1]->_len -= d1;
+
// compute normalized length of the offset segments located between the projections
size_t iSeg = 0, nbSeg = _iSeg[1] - _iSeg[0] + 1;
vector< double > len( nbSeg + 1 );
len[ iSeg++ ] = 0;
- len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz );
+ len[ iSeg++ ] = pProj[ 0 ].Distance( _offPoints[ _iSeg[0]+1 ]._xyz )/* * e[0]->_lenFactor*/;
for ( size_t i = _iSeg[0]+1; i <= _iSeg[1]; ++i, ++iSeg )
{
len[ iSeg ] = len[ iSeg-1 ] + _offPoints[i].Distance( _offPoints[i+1] );
}
- len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz );
+ len[ nbSeg ] -= pProj[ 1 ].Distance( _offPoints[ _iSeg[1]+1 ]._xyz )/* * e[1]->_lenFactor*/;
- double d0 = pProj[0].Distance( pExtreme[0]);
- double d1 = pProj[1].Distance( pExtreme[1]);
+ // d0 *= e[0]->_lenFactor;
+ // d1 *= e[1]->_lenFactor;
double fullLen = len.back() - d0 - d1;
for ( iSeg = 0; iSeg < len.size(); ++iSeg )
len[iSeg] = ( len[iSeg] - d0 ) / fullLen;