Fix for Bug IPAL10464:

SMESH: Add Polyhedron
This commit is contained in:
enk 2006-02-27 08:53:17 +00:00
parent fe4a33ed2e
commit 2ec6cc8c59
3 changed files with 111 additions and 25 deletions

View File

@ -524,7 +524,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnApply()
unsigned int anEntityMode = myActor->GetEntityMode(); unsigned int anEntityMode = myActor->GetEntityMode();
myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode); myActor->SetEntityMode(SMESH_Actor::eVolumes | anEntityMode);
} }
ConstructorsClicked( GetConstructorId() ); //ConstructorsClicked( GetConstructorId() );
busy = false; busy = false;
} }
} }
@ -566,6 +566,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::ClickOnCancel()
void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText) void SMESHGUI_CreatePolyhedralVolumeDlg::onTextChange(const QString& theNewText)
{ {
if ( busy ) return; if ( busy ) return;
if (checkEditLine() == -1) return;
busy = true; busy = true;
mySimulation->SetVisibility(false); mySimulation->SetVisibility(false);
@ -700,6 +701,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
} }
busy = true; busy = true;
myEditCurrentArgument->setText( aString ); myEditCurrentArgument->setText( aString );
if (checkEditLine() == -1) {busy = false;return;}
busy = false; busy = false;
break; break;
} }
@ -715,6 +717,7 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
} }
busy = true; busy = true;
myEditCurrentArgument->setText( aString ); myEditCurrentArgument->setText( aString );
if (checkEditLine() == -1) {busy = false;return;}
busy = false; busy = false;
// OK // OK
@ -727,6 +730,82 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::SelectionIntoArgument()
displaySimulation(); displaySimulation();
} }
/*\brief int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine()
* Checking of indices in edit line.
* If incorecct indices in edit line warning message appear and myEditCurrentArgument remove last index.
* \retval 1 - if all ok(or no indices in edit line), -1 - if there are incorrect indices.
*/
int SMESHGUI_CreatePolyhedralVolumeDlg::checkEditLine(bool checkLast)
{
QString aString = "";
SMDS_Mesh* aMesh = 0;
if(myMesh->_is_nil()) return 1;
if(!myActor){
myActor = SMESH::FindActorByObject(myMesh);
if(!myActor)
return 1;
}
aMesh = myActor->GetObject()->GetMesh();
// checking for nodes
if (checkLast && myEditCurrentArgument->text().right(1) != QString(" ") ) return 1;
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text() );
for ( int i = 0; i < aListId.count(); i++ ){
switch (GetConstructorId()){
case 0:{ // nodes
const SMDS_MeshNode * aNode = aMesh->FindNode( aListId[ i ].toInt() );
if( !aNode ){
std::string aWarning;
aWarning = "The incorrect indices of nodes!";
SUIT_MessageBox::warn1(SMESHGUI::desktop(),
QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"),
QObject::tr(aWarning.c_str()),
QObject::tr("SMESH_BUT_OK"));
myEditCurrentArgument->clear();
myEditCurrentArgument->setText( aString );
return -1;
}
break;
}
case 1:{ // faces
bool aElemIsOK = true;
const SMDS_MeshElement * aElem = aMesh->FindElement( aListId[ i ].toInt() );
if (!aElem)
{
aElemIsOK = false;
}
else
{
SMDSAbs_ElementType aType = aMesh->GetElementType( aElem->GetID(),true );
if (aType != SMDSAbs_Face){
aElemIsOK = false;
}
}
if (!aElemIsOK){
std::string aWarning;
aWarning = "The incorrect indices of faces!";
SUIT_MessageBox::warn1(SMESHGUI::desktop(),
QObject::tr("SMESH_POLYEDRE_CREATE_ERROR"),
QObject::tr(aWarning.c_str()),
QObject::tr("SMESH_BUT_OK"));
myEditCurrentArgument->clear();
myEditCurrentArgument->setText( aString );
return -1;
}
break;
}
}
aString += aListId[ i ] + " ";
}
return 1;
}
//======================================================================= //=======================================================================
//function : displaySimulation //function : displaySimulation
//purpose : //purpose :
@ -737,7 +816,11 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
{ {
SMESH::TPolySimulation::TVTKIds aVTKIds; SMESH::TPolySimulation::TVTKIds aVTKIds;
vtkIdType aType = VTK_CONVEX_POINT_SET ; vtkIdType aType = VTK_CONVEX_POINT_SET ;
if (GetConstructorId() == 0){ SMDS_Mesh* aMesh = 0;
if ( myActor ){
aMesh = myActor->GetObject()->GetMesh();
}
if (GetConstructorId() == 0 && aMesh){
if (!AddButton->isEnabled()){ if (!AddButton->isEnabled()){
QListBoxItem* anItem; QListBoxItem* anItem;
mySimulation->ResetGrid(true); mySimulation->ResetGrid(true);
@ -745,6 +828,8 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
QStringList anIds = QStringList::split(" ", anItem->text()); QStringList anIds = QStringList::split(" ", anItem->text());
SMESH::TPolySimulation::TVTKIds aVTKIds_faces; SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){ for (QStringList::iterator it = anIds.begin(); it != anIds.end(); ++it){
const SMDS_MeshNode * aNode = aMesh->FindNode( (*it).toInt() );
if (!aNode) continue;
vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ; vtkIdType aId = myActor->GetObject()->GetNodeVTKId( (*it).toInt() ) ;
aVTKIds.push_back(aId); aVTKIds.push_back(aId);
aVTKIds_faces.push_back(aId); aVTKIds_faces.push_back(aId);
@ -770,18 +855,14 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
aType = VTK_POLYGON; aType = VTK_POLYGON;
mySimulation->SetPosition(myActor, aType, aVTKIds); mySimulation->SetPosition(myActor, aType, aVTKIds);
} }
}else if(GetConstructorId() == 1){ }else if(GetConstructorId() == 1 && aMesh){
SMDS_Mesh* aMesh = 0;
if ( myActor ){
aMesh = myActor->GetObject()->GetMesh();
}
if ( aMesh ) {
QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false);
for ( int i = 0; i < aListId.count(); i++ ) for ( int i = 0; i < aListId.count(); i++ )
{ {
const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() ); const SMDS_MeshElement * anElem = aMesh->FindElement( aListId[ i ].toInt() );
if ( !anElem ) if ( !anElem ) continue;
return; SMDSAbs_ElementType aFaceType = aMesh->GetElementType( anElem->GetID(),true );
if (aFaceType != SMDSAbs_Face) continue;
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
SMESH::TPolySimulation::TVTKIds aVTKIds_faces; SMESH::TPolySimulation::TVTKIds aVTKIds_faces;
@ -799,7 +880,6 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::displaySimulation()
if(Preview->isChecked()) if(Preview->isChecked())
mySimulation->SetPosition(myActor, aType, aVTKIds); mySimulation->SetPosition(myActor, aType, aVTKIds);
} }
}
SMESH::UpdateView(); SMESH::UpdateView();
} }
} }
@ -912,8 +992,9 @@ void SMESHGUI_CreatePolyhedralVolumeDlg::onAdd()
int aNbSel = selected.Extent(); int aNbSel = selected.Extent();
if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return;
busy = true; if (this->checkEditLine(false) == -1) return;
busy = true;
if ( !(myEditCurrentArgument->text().isEmpty()) ) if ( !(myEditCurrentArgument->text().isEmpty()) )
{ {
myFacesByNodes->insertItem(myEditCurrentArgument->text()); myFacesByNodes->insertItem(myEditCurrentArgument->text());

View File

@ -76,6 +76,8 @@ private:
int GetConstructorId(); int GetConstructorId();
void displaySimulation(); void displaySimulation();
int checkEditLine(bool checkLast=true); /*! Checking for indices, return 1 if all ok, esle -1*/
SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */
LightApp_SelectionMgr* mySelectionMgr ; /* User shape selection */ LightApp_SelectionMgr* mySelectionMgr ; /* User shape selection */
SVTK_Selector* mySelector; SVTK_Selector* mySelector;

View File

@ -1799,6 +1799,9 @@ msgstr "Faces by nodes"
msgid "SMESHGUI_CreatePolyhedralVolumeDlg::SMESH_POLYEDRE_PREVIEW" msgid "SMESHGUI_CreatePolyhedralVolumeDlg::SMESH_POLYEDRE_PREVIEW"
msgstr "Polyhedron preview" msgstr "Polyhedron preview"
msgid "SMESHGUI_CreatePolyhedralVolumeDlg::SMESH_POLYEDRE_CREATE_ERROR"
msgstr "Polyhedron creation error."
msgid "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE" msgid "SMESH_CREATE_POLYHEDRAL_VOLUME_TITLE"
msgstr "Create polyhedral volume" msgstr "Create polyhedral volume"