Displayer of the mesh edition preview. More...
#include <SMESHGUI_MeshEditPreview.h>
Public Member Functions | |
| SMESHGUI_MeshEditPreview (SVTK_ViewWindow *) | |
| Constructor. | |
| ~SMESHGUI_MeshEditPreview () | |
| Destroy. | |
| void | SetData (const SMESH::MeshPreviewStruct *) |
| Set preview data. | |
| void | SetVisibility (bool) |
| Set visibility. | |
| void | SetColor (double, double, double) |
| Set preview color. | |
| SALOME_Actor * | GetActor () const |
| Get preview actor. | |
Private Attributes | |
| SVTK_ViewWindow * | myViewWindow |
| vtkUnstructuredGrid * | myGrid |
| SALOME_Actor * | myPreviewActor |
Displayer of the mesh edition preview.
Definition at line 45 of file SMESHGUI_MeshEditPreview.h.
| SMESHGUI_MeshEditPreview::SMESHGUI_MeshEditPreview | ( | SVTK_ViewWindow * | theViewWindow | ) |
Constructor.
Definition at line 62 of file SMESHGUI_MeshEditPreview.cxx.
References GetColor(), myGrid, myPreviewActor, myViewWindow, and SetColor().
: myViewWindow(theViewWindow) { myGrid = vtkUnstructuredGrid::New(); // Create and display actor vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); aMapper->SetInput( myGrid ); myPreviewActor = SALOME_Actor::New(); myPreviewActor->SetInfinitive(true); myPreviewActor->VisibilityOn(); myPreviewActor->PickableOff(); vtkFloatingPointType anRGB[3]; SMESH::GetColor( "SMESH", "selection_element_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); SetColor( anRGB[0], anRGB[1], anRGB[2] ); myPreviewActor->SetMapper( aMapper ); aMapper->Delete(); myViewWindow->AddActor(myPreviewActor); }
| SMESHGUI_MeshEditPreview::~SMESHGUI_MeshEditPreview | ( | ) |
Destroy.
Definition at line 93 of file SMESHGUI_MeshEditPreview.cxx.
References myGrid, myPreviewActor, and myViewWindow.
{
myGrid->Delete();
myViewWindow->RemoveActor(myPreviewActor);
myPreviewActor->Delete();
}
| SALOME_Actor * SMESHGUI_MeshEditPreview::GetActor | ( | ) | const |
Get preview actor.
Definition at line 255 of file SMESHGUI_MeshEditPreview.cxx.
References myPreviewActor.
Referenced by SMESHGUI_BaseComputeOp.onShowBadMesh(), SMESHGUI_MakeNodeAtPointOp.startOperation(), and SMESHGUI_FindElemByPointOp.startOperation().
{
return myPreviewActor;
}
| void SMESHGUI_MeshEditPreview::SetColor | ( | double | R, |
| double | G, | ||
| double | B | ||
| ) |
Set preview color.
Definition at line 245 of file SMESHGUI_MeshEditPreview.cxx.
References myPreviewActor.
Referenced by SMESHGUI_MeshEditPreview().
{
myPreviewActor->SetColor( R, G, B );
}
| void SMESHGUI_MeshEditPreview::SetData | ( | const SMESH::MeshPreviewStruct * | previewData | ) |
Set preview data.
Definition at line 158 of file SMESHGUI_MeshEditPreview.cxx.
References SMESH.MeshPreviewStruct.elementConnectivities, SMESH.MeshPreviewStruct.elementTypes, getCellType(), myGrid, myPreviewActor, SMESH.ElementSubType.nbNodesInElement, SMESH.MeshPreviewStruct.nodesXYZ, SetVisibility(), SMESH.ElementSubType.SMDS_ElementType, ex13_hole1partial.x, and ex13_hole1partial.y.
Referenced by SMESHGUI_TranslationDlg.onDisplaySimulation(), SMESHGUI_SymmetryDlg.onDisplaySimulation(), SMESHGUI_ScaleDlg.onDisplaySimulation(), SMESHGUI_RotationDlg.onDisplaySimulation(), SMESHGUI_RevolutionDlg.onDisplaySimulation(), SMESHGUI_ExtrusionDlg.onDisplaySimulation(), SMESHGUI_ExtrusionAlongPathDlg.onDisplaySimulation(), SMESHGUI_PrecomputeOp.onPreview(), SMESHGUI_BaseComputeOp.onShowBadMesh(), SMESHGUI_MakeNodeAtPointOp.redisplayPreview(), and SMESHGUI_FindElemByPointOp.redisplayPreview().
{
// Create points
const SMESH::nodes_array& aNodesXYZ = previewData->nodesXYZ;
vtkPoints* aPoints = vtkPoints::New();
aPoints->SetNumberOfPoints(aNodesXYZ.length());
for ( int i = 0; i < aNodesXYZ.length(); i++ ) {
aPoints->SetPoint( i, aNodesXYZ[i].x, aNodesXYZ[i].y, aNodesXYZ[i].z );
}
myGrid->SetPoints(aPoints);
aPoints->Delete();
// Create cells
const SMESH::long_array& anElemConnectivity = previewData->elementConnectivities;
const SMESH::types_array& anElemTypes = previewData->elementTypes;
vtkIdType aCellsSize = anElemConnectivity.length() + anElemTypes.length();
vtkIdType aNbCells = anElemTypes.length();
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate( aCellsSize, 0 );
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents( 1 );
aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
vtkIdList *anIdList = vtkIdList::New();
int aNodePos = 0;
for ( int i = 0; i < anElemTypes.length(); i++ ) {
const SMESH::ElementSubType& anElementSubType = anElemTypes[i];
SMDSAbs_ElementType aType = SMDSAbs_ElementType(anElementSubType.SMDS_ElementType);
vtkIdType aNbNodes = anElementSubType.nbNodesInElement;
anIdList->SetNumberOfIds( aNbNodes );
for ( vtkIdType aNodeId = 0; aNodeId < aNbNodes; aNodeId++ ){
anIdList->SetId( aNodeId, anElemConnectivity[aNodePos] );
aNodePos++;
}
aConnectivity->InsertNextCell( anIdList );
aCellTypesArray->InsertNextValue( getCellType( aType,
anElemTypes[i].isPoly,
aNbNodes ) );
}
anIdList->Delete();
// Insert cells in grid
VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
aCellLocationsArray->SetNumberOfComponents( 1 );
aCellLocationsArray->SetNumberOfTuples( aNbCells );
aConnectivity->InitTraversal();
for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
myGrid->SetCells( aCellTypesArray, aCellLocationsArray, aConnectivity );
myPreviewActor->GetMapper()->Update();
aCellTypesArray->Delete();
aCellLocationsArray->Delete();
aConnectivity->Delete();
SetVisibility(true);
}
| void SMESHGUI_MeshEditPreview::SetVisibility | ( | bool | theVisibility | ) |
Set visibility.
Definition at line 233 of file SMESHGUI_MeshEditPreview.cxx.
References myPreviewActor, and SMESH.RepaintCurrentView().
Referenced by SMESHGUI_RevolutionDlg.ConstructorsClicked(), SMESHGUI_BaseComputeOp.currentCellChanged(), SMESHGUI_PreviewDlg.hidePreview(), SMESHGUI_RevolutionDlg.onDisplaySimulation(), SMESHGUI_PrecomputeOp.onPreview(), SMESHGUI_RevolutionDlg.onSelectMesh(), SMESHGUI_MakeNodeAtPointOp.redisplayPreview(), SetData(), SMESHGUI_RevolutionDlg.SetEditCurrentArgument(), SMESHGUI_PreviewDlg.showPreview(), SMESHGUI_MakeNodeAtPointOp.stopOperation(), SMESHGUI_FindElemByPointOp.stopOperation(), SMESHGUI_PrecomputeOp.stopOperation(), and SMESHGUI_BaseComputeOp.stopOperation().
{
myPreviewActor->SetVisibility(theVisibility);
SMESH::RepaintCurrentView();
}
Definition at line 49 of file SMESHGUI_MeshEditPreview.h.
Referenced by SetData(), SMESHGUI_MeshEditPreview(), and ~SMESHGUI_MeshEditPreview().
Definition at line 50 of file SMESHGUI_MeshEditPreview.h.
Referenced by GetActor(), SetColor(), SetData(), SetVisibility(), SMESHGUI_MeshEditPreview(), and ~SMESHGUI_MeshEditPreview().
SVTK_ViewWindow* SMESHGUI_MeshEditPreview.myViewWindow [private] |
Definition at line 47 of file SMESHGUI_MeshEditPreview.h.
Referenced by SMESHGUI_MeshEditPreview(), and ~SMESHGUI_MeshEditPreview().