Version: 6.3.1
Public Member Functions | Private Attributes

SMESHGUI_MeshEditPreview Class Reference

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_ActorGetActor () const
 Get preview actor.

Private Attributes

SVTK_ViewWindow * myViewWindow
vtkUnstructuredGridmyGrid
SALOME_ActormyPreviewActor

Detailed Description

Displayer of the mesh edition preview.

Definition at line 45 of file SMESHGUI_MeshEditPreview.h.


Constructor & Destructor Documentation

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();

}

Member Function Documentation

SALOME_Actor * SMESHGUI_MeshEditPreview::GetActor ( ) const
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)

Field Documentation

SVTK_ViewWindow* SMESHGUI_MeshEditPreview.myViewWindow [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS