Implementation: Show a link of quadratic element

This commit is contained in:
imn 2014-07-11 12:33:38 +04:00
parent 14fc167a53
commit 2b96c0d911
2 changed files with 137 additions and 15 deletions

View File

@ -36,6 +36,7 @@
#include <SMESH_Actor.h> #include <SMESH_Actor.h>
#include <SMESH_ActorUtils.h> #include <SMESH_ActorUtils.h>
#include <SMESH_DeviceActor.h>
#include <SMESH_FaceOrientationFilter.h> #include <SMESH_FaceOrientationFilter.h>
#include <SMDS_Mesh.hxx> #include <SMDS_Mesh.hxx>
@ -52,6 +53,8 @@
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <SALOME_ListIO.hxx> #include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <VTKViewer_PolyDataMapper.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
@ -65,12 +68,14 @@
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
// VTK includes // VTK includes
#include <vtkCell.h>
#include <vtkIdList.h> #include <vtkIdList.h>
#include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h> #include <vtkDataSetMapper.h>
#include <vtkPolyDataMapper.h> #include <vtkPolyDataMapper.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkCellType.h> #include <vtkCellType.h>
#include <vtkCellData.h>
// Qt includes // Qt includes
#include <QComboBox> #include <QComboBox>
@ -121,7 +126,14 @@ namespace SMESH
SALOME_Actor* myPreviewActor; SALOME_Actor* myPreviewActor;
vtkDataSetMapper* myMapper; vtkDataSetMapper* myMapper;
vtkUnstructuredGrid* myGrid; vtkUnstructuredGrid* myGrid;
//vtkProperty* myBackProp, *myProp;
SALOME_Actor* myCornerActor;
VTKViewer_PolyDataMapper* myCornerMapper;
vtkPolyData* myCornerPolyData;
SALOME_Actor* mySelectCornerActor;
VTKViewer_PolyDataMapper* mySelectCornerMapper;
vtkPolyData* mySelectCornerPolyData;
//double myRGB[3], myBackRGB[3]; //double myRGB[3], myBackRGB[3];
@ -186,6 +198,45 @@ namespace SMESH
anOrientationProp->Delete(); anOrientationProp->Delete();
myVTKViewWindow->AddActor(myFaceOrientation); myVTKViewWindow->AddActor(myFaceOrientation);
// Create and display actor with corner nodes
myCornerPolyData = vtkPolyData::New();
myCornerPolyData->Allocate();
myCornerMapper = VTKViewer_PolyDataMapper::New();
myCornerMapper->SetInputData(myCornerPolyData);
myCornerMapper->SetMarkerEnabled(true);
myCornerActor = SALOME_Actor::New();
myCornerActor->PickableOff();
myCornerActor->VisibilityOff();
myCornerActor->SetMapper(myCornerMapper);
vtkProperty* myCornerProp = vtkProperty::New();
myCornerProp->SetColor( 50 / 255. , 100 / 255. , 0 / 255. );
myCornerActor->SetProperty( myCornerProp );
myCornerProp->Delete();
myVTKViewWindow->AddActor(myCornerActor);
// Create and display actor with selected corner nodes
mySelectCornerPolyData = vtkPolyData::New();
mySelectCornerPolyData->Allocate();
mySelectCornerMapper = VTKViewer_PolyDataMapper::New();
mySelectCornerMapper->SetInputData(mySelectCornerPolyData);
mySelectCornerMapper->SetMarkerEnabled(true);
mySelectCornerActor = SALOME_Actor::New();
mySelectCornerActor->PickableOff();
mySelectCornerActor->VisibilityOff();
mySelectCornerActor->SetMapper(mySelectCornerMapper);
vtkProperty* mySelectCornerProp = vtkProperty::New();
mySelectCornerProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
mySelectCornerActor->SetProperty( mySelectCornerProp );
mySelectCornerProp->Delete();
myVTKViewWindow->AddActor(mySelectCornerActor);
} }
typedef std::vector<vtkIdType> TVTKIds; typedef std::vector<vtkIdType> TVTKIds;
@ -218,26 +269,76 @@ namespace SMESH
myPreviewActor->GetMapper()->Update(); myPreviewActor->GetMapper()->Update();
myPreviewActor->SetRepresentation( theMode ); myPreviewActor->SetRepresentation( theMode );
SetVisibility(true, theActor->GetFacesOriented()); }
void SetCornerNodes (SMESH_Actor* theActor,
TVTKIds& theIds)
{
vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
myCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale());
myCornerPolyData->Reset();
myCornerPolyData->DeleteCells();
myCornerPolyData->SetPoints(aGrid->GetPoints());
vtkIdList *anIds = vtkIdList::New();
for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) {
anIds->InsertId(i,theIds[i]);
myCornerPolyData->InsertNextCell(VTK_VERTEX, anIds);
anIds->Reset();
}
anIds->Delete();
myCornerPolyData->Modified();
myCornerActor->GetMapper()->Update();
myCornerActor->SetRepresentation(SMESH_Actor::ePoint);
}
void SetSelectedNodes (SMESH_Actor* theActor,
TVTKIds& theIds)
{
vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
mySelectCornerMapper->SetMarkerStd(theActor->GetMarkerType(), theActor->GetMarkerScale());
mySelectCornerPolyData->Reset();
mySelectCornerPolyData->DeleteCells();
mySelectCornerPolyData->SetPoints(aGrid->GetPoints());
vtkIdList *anIds = vtkIdList::New();
for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) {
anIds->InsertId(i,theIds[i]);
mySelectCornerPolyData->InsertNextCell(VTK_VERTEX, anIds);
anIds->Reset();
}
anIds->Delete();
mySelectCornerPolyData->Modified();
mySelectCornerActor->GetMapper()->Update();
mySelectCornerActor->SetRepresentation(SMESH_Actor::ePoint);
} }
void SetVisibility ( bool theVisibility,
void SetVisibility (bool theVisibility, bool theShowOrientation = false) bool theCornerVisibility = false,
bool theSelectCornerVisibility = false,
bool theShowOrientation = false )
{ {
myPreviewActor->SetVisibility(theVisibility); myPreviewActor->SetVisibility(theVisibility);
myFaceOrientation->SetVisibility(theShowOrientation); myFaceOrientation->SetVisibility(theShowOrientation);
myCornerActor->SetVisibility(theCornerVisibility);
mySelectCornerActor->SetVisibility(theSelectCornerVisibility);
RepaintCurrentView(); RepaintCurrentView();
} }
~TElementSimulationQuad() ~TElementSimulationQuad()
{ {
if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) { if (FindVtkViewWindow(myApplication->activeViewManager(), myViewWindow)) {
myVTKViewWindow->RemoveActor(myPreviewActor); myVTKViewWindow->RemoveActor(myPreviewActor);
myVTKViewWindow->RemoveActor(myFaceOrientation); myVTKViewWindow->RemoveActor(myFaceOrientation);
myVTKViewWindow->RemoveActor(myCornerActor);
myVTKViewWindow->RemoveActor(mySelectCornerActor);
} }
myPreviewActor->Delete(); myPreviewActor->Delete();
myFaceOrientation->Delete(); myFaceOrientation->Delete();
myCornerActor->Delete();
mySelectCornerActor->Delete();
myMapper->RemoveAllInputs(); myMapper->RemoveAllInputs();
myMapper->Delete(); myMapper->Delete();
@ -249,6 +350,14 @@ namespace SMESH
myGrid->Delete(); myGrid->Delete();
myCornerMapper->RemoveAllInputs();
myCornerMapper->Delete();
myCornerPolyData->Delete();
mySelectCornerMapper->RemoveAllInputs();
mySelectCornerMapper->Delete();
mySelectCornerPolyData->Delete();
// myProp->Delete(); // myProp->Delete();
// myBackProp->Delete(); // myBackProp->Delete();
} }
@ -1031,9 +1140,10 @@ void SMESHGUI_AddQuadraticElementDlg::SelectionIntoArgument()
// purpose : // purpose :
//================================================================================= //=================================================================================
void SMESHGUI_AddQuadraticElementDlg::displaySimulation() void SMESHGUI_AddQuadraticElementDlg::displaySimulation(int theRow, int theCol)
{ {
if ( IsValid() ) bool isValid = IsValid();
if ( ( isValid || myTable->isEnabled() ) && myActor )
{ {
SMESH::TElementSimulationQuad::TVTKIds anIds; SMESH::TElementSimulationQuad::TVTKIds anIds;
@ -1041,7 +1151,6 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation()
int anID; int anID;
bool ok; bool ok;
int aDisplayMode = VTK_SURFACE; int aDisplayMode = VTK_SURFACE;
if ( myGeomType == SMDSEntity_Quad_Edge ) if ( myGeomType == SMDSEntity_Quad_Edge )
{ {
anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) ); anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(0, 0)->text().toInt() ) );
@ -1065,20 +1174,33 @@ void SMESHGUI_AddQuadraticElementDlg::displaySimulation()
} }
anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) ); anIds.push_back( myActor->GetObject()->GetNodeVTKId(anID) );
} }
if ( myNbMidFaceNodes ) if ( myNbMidFaceNodes && isValid)
{ {
QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts); QStringList aListId = myMidFaceNodes->text().split(" ", QString::SkipEmptyParts);
for (int i = 0; i < aListId.count(); i++) for (int i = 0; i < aListId.count(); i++)
anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() )); anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() ));
} }
if ( myNbCenterNodes ) if ( myNbCenterNodes && isValid)
{ {
QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts); QStringList aListId = myCenterNode->text().split(" ", QString::SkipEmptyParts);
anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() )); anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ 0 ].toInt() ));
} }
} }
if ( isValid )
mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked()); mySimulation->SetPosition(myActor,myGeomType,anIds,aDisplayMode,myReverseCB->isChecked());
mySimulation->SetCornerNodes(myActor, anIds);
if ( theCol == 1 ) {
anIds.clear();
anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 0)->text().toInt() ) );
anIds.push_back( myActor->GetObject()->GetNodeVTKId( myTable->item(theRow, 2)->text().toInt() ) );
bool ok;
int anID;
anID = myTable->item(theRow, 1)->text().toInt(&ok);
if (ok)
anIds.push_back(myActor->GetObject()->GetNodeVTKId(anID));
mySimulation->SetSelectedNodes(myActor, anIds);
}
mySimulation->SetVisibility(isValid, true, true, myActor->GetFacesOriented());
} }
else else
{ {
@ -1300,7 +1422,7 @@ void SMESHGUI_AddQuadraticElementDlg::UpdateTable( bool theConersValidity )
void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol ) void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCol )
{ {
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
displaySimulation(); displaySimulation(theRow, theCol);
updateButtons(); updateButtons();
} }
@ -1312,7 +1434,7 @@ void SMESHGUI_AddQuadraticElementDlg::onCellDoubleClicked( int theRow, int theCo
void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol) void SMESHGUI_AddQuadraticElementDlg::onCellTextChange(int theRow, int theCol)
{ {
myCurrentLineEdit = 0; myCurrentLineEdit = 0;
displaySimulation(); displaySimulation(theRow, theCol);
updateButtons(); updateButtons();
} }

View File

@ -75,7 +75,7 @@ private:
void Init(); void Init();
void enterEvent( QEvent* ); /* mouse enter the QWidget */ void enterEvent( QEvent* ); /* mouse enter the QWidget */
void keyPressEvent( QKeyEvent* ); void keyPressEvent( QKeyEvent* );
void displaySimulation(); void displaySimulation(int = -1, int = -1);
void UpdateTable( bool = true ); void UpdateTable( bool = true );
bool IsValid(); bool IsValid();
void updateButtons(); void updateButtons();