Version: 6.3.1
Public Types | Public Member Functions | Private Attributes

SMESH.TElementSimulation Class Reference

Public Types

typedef std::vector< vtkIdType > TVTKIds
typedef std::vector< vtkIdType > TVTKIds

Public Member Functions

 TElementSimulation (SalomeApp_Application *theApplication)
void SetPosition (SMESH_Actor *theActor, vtkIdType theType, const TVTKIds &theIds)
void SetVisibility (bool theVisibility, bool theShowOrientation=false)
 ~TElementSimulation ()
 TElementSimulation (SalomeApp_Application *theApplication)
void SetPosition (SMESH_Actor *theActor, const int theType, TVTKIds &theIds, const int theMode, const bool theReverse)
void SetVisibility (bool theVisibility, bool theShowOrientation=false)
 ~TElementSimulation ()

Private Attributes

SalomeApp_Application * myApplication
SUIT_ViewWindow * myViewWindow
SVTK_ViewWindow * myVTKViewWindow
SALOME_ActormyPreviewActor
vtkDataSetMapper * myMapper
vtkUnstructuredGridmyGrid
SALOME_ActormyFaceOrientation
vtkPolyDataMapper * myFaceOrientationDataMapper
SMESH_FaceOrientationFiltermyFaceOrientationFilter

Detailed Description

Definition at line 88 of file SMESHGUI_AddMeshElementDlg.cxx.


Member Typedef Documentation

typedef std::vector<vtkIdType> SMESH.TElementSimulation.TVTKIds

Definition at line 158 of file SMESHGUI_AddMeshElementDlg.cxx.

typedef std::vector<vtkIdType> SMESH.TElementSimulation.TVTKIds

Definition at line 223 of file SMESHGUI_AddQuadraticElementDlg.cxx.


Constructor & Destructor Documentation

SMESH.TElementSimulation.TElementSimulation ( SalomeApp_Application *  theApplication)

Definition at line 103 of file SMESHGUI_AddMeshElementDlg.cxx.

References SMESH.GetColor(), SMESH.GetVtkViewWindow(), SMESH.TElementSimulation.myApplication, SMESH.TElementSimulation.myFaceOrientation, SMESH.TElementSimulation.myFaceOrientationDataMapper, SMESH.TElementSimulation.myFaceOrientationFilter, SMESH.TElementSimulation.myGrid, SMESH.TElementSimulation.myMapper, SMESH.TElementSimulation.myPreviewActor, SMESH.TElementSimulation.myViewWindow, SMESH.TElementSimulation.myVTKViewWindow, and SMESH_FaceOrientationFilter.New().

    {
      myApplication = theApplication;
      SUIT_ViewManager* mgr = theApplication->activeViewManager();
      if (!mgr) return;
      myViewWindow = mgr->getActiveView();
      myVTKViewWindow = GetVtkViewWindow(myViewWindow);

      myGrid = vtkUnstructuredGrid::New();

      // Create and display actor
      myMapper = vtkDataSetMapper::New();
      myMapper->SetInput(myGrid);

      myPreviewActor = SALOME_Actor::New();
      myPreviewActor->PickableOff();
      myPreviewActor->VisibilityOff();
      myPreviewActor->SetMapper(myMapper);

      vtkFloatingPointType anRGB[3];
      vtkProperty* aProp = vtkProperty::New();
      GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
      aProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
      myPreviewActor->SetProperty( aProp );
      aProp->Delete();

      vtkProperty* aBackProp = vtkProperty::New();
      GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
      aBackProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
      myPreviewActor->SetBackfaceProperty( aBackProp );
      aBackProp->Delete();

      myVTKViewWindow->AddActor(myPreviewActor);

      // Orientation of faces
      myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
      myFaceOrientationFilter->SetInput(myGrid);

      myFaceOrientationDataMapper = vtkPolyDataMapper::New();
      myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());

      myFaceOrientation = SALOME_Actor::New();
      myFaceOrientation->PickableOff();
      myFaceOrientation->VisibilityOff();
      myFaceOrientation->SetMapper(myFaceOrientationDataMapper);

      vtkProperty* anOrientationProp = vtkProperty::New();
      GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
      anOrientationProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
      myFaceOrientation->SetProperty( anOrientationProp );
      anOrientationProp->Delete();

      myVTKViewWindow->AddActor(myFaceOrientation);
    }
SMESH.TElementSimulation.~TElementSimulation ( )
SMESH.TElementSimulation.TElementSimulation ( SalomeApp_Application *  theApplication)

Definition at line 168 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESH.GetColor(), SMESH.GetVtkViewWindow(), SMESH.TElementSimulation.myApplication, SMESH.TElementSimulation.myFaceOrientation, SMESH.TElementSimulation.myFaceOrientationDataMapper, SMESH.TElementSimulation.myFaceOrientationFilter, SMESH.TElementSimulation.myGrid, SMESH.TElementSimulation.myMapper, SMESH.TElementSimulation.myPreviewActor, SMESH.TElementSimulation.myViewWindow, SMESH.TElementSimulation.myVTKViewWindow, and SMESH_FaceOrientationFilter.New().

    {
      myApplication = theApplication;
      SUIT_ViewManager* mgr = theApplication->activeViewManager();
      if (!mgr) return;
      myViewWindow = mgr->getActiveView();
      myVTKViewWindow = GetVtkViewWindow(myViewWindow);

      myGrid = vtkUnstructuredGrid::New();

      // Create and display actor
      myMapper = vtkDataSetMapper::New();
      myMapper->SetInput(myGrid);

      myPreviewActor = SALOME_Actor::New();
      myPreviewActor->PickableOff();
      myPreviewActor->VisibilityOff();
      myPreviewActor->SetMapper(myMapper);

      vtkProperty* myProp = vtkProperty::New();
      vtkFloatingPointType aRGB[3], aBackRGB[3];
      GetColor( "SMESH", "fill_color", aRGB[0], aRGB[1], aRGB[2], QColor( 0, 170, 255 ) );
      myProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
      myPreviewActor->SetProperty( myProp );
      myProp->Delete();

      vtkProperty* myBackProp = vtkProperty::New();
      GetColor( "SMESH", "backface_color", aBackRGB[0], aBackRGB[1], aBackRGB[2], QColor( 0, 0, 255 ) );
      myBackProp->SetColor( aBackRGB[0], aBackRGB[1], aBackRGB[2] );
      myPreviewActor->SetBackfaceProperty( myBackProp );
      myBackProp->Delete();

      myVTKViewWindow->AddActor(myPreviewActor);

      // Orientation of faces
      myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
      myFaceOrientationFilter->SetInput(myGrid);

      myFaceOrientationDataMapper = vtkPolyDataMapper::New();
      myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());

      myFaceOrientation = SALOME_Actor::New();
      myFaceOrientation->PickableOff();
      myFaceOrientation->VisibilityOff();
      myFaceOrientation->SetMapper(myFaceOrientationDataMapper);

      vtkProperty* anOrientationProp = vtkProperty::New();
      GetColor( "SMESH", "orientation_color", aRGB[0], aRGB[1], aRGB[2], QColor( 255, 255, 255 ) );
      anOrientationProp->SetColor( aRGB[0], aRGB[1], aRGB[2] );
      myFaceOrientation->SetProperty( anOrientationProp );
      anOrientationProp->Delete();

      myVTKViewWindow->AddActor(myFaceOrientation);
    }
SMESH.TElementSimulation.~TElementSimulation ( )

Member Function Documentation

void SMESH.TElementSimulation.SetPosition ( SMESH_Actor theActor,
vtkIdType  theType,
const TVTKIds theIds 
)

Definition at line 159 of file SMESHGUI_AddMeshElementDlg.cxx.

References SMESH_BelongToGeom.anIds, SMESH_Actor.GetFacesOriented(), SMESH_Actor.GetUnstructuredGrid(), SMESH.TElementSimulation.myGrid, and SMESH.TElementSimulation.SetVisibility().

Referenced by SMESHGUI_AddQuadraticElementDlg.displaySimulation(), and SMESHGUI_AddMeshElementDlg.displaySimulation().

    {
      vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
      myGrid->SetPoints(aGrid->GetPoints());

      const int* aConn = NULL;
      switch (theType) {
      case VTK_TETRA:
        {
          static int anIds[] = {0,2,1,3};
          aConn = anIds;
          break;
        }
      case VTK_PYRAMID:
        {
          static int anIds[] = {0,3,2,1,4};
          aConn = anIds;
          break;
        }
      case VTK_HEXAHEDRON:
        {
          static int anIds[] = {0,3,2,1,4,7,6,5};
          aConn = anIds;
          break;
        }
      }

      myGrid->Reset();
      vtkIdList *anIds = vtkIdList::New();

      if(aConn)
        for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
          anIds->InsertId(i,theIds[aConn[i]]);
      else
        for (int i = 0, iEnd = theIds.size(); i < iEnd; i++)
          anIds->InsertId(i,theIds[i]);

      myGrid->InsertNextCell(theType,anIds);
      anIds->Delete();

      myGrid->Modified();

      SetVisibility(true, theActor->GetFacesOriented());
    }
void SMESH.TElementSimulation.SetPosition ( SMESH_Actor theActor,
const int  theType,
TVTKIds theIds,
const int  theMode,
const bool  theReverse 
)

Definition at line 224 of file SMESHGUI_AddQuadraticElementDlg.cxx.

References SMESH_BelongToGeom.anIds, SMESH_Actor.GetFacesOriented(), SMESH_Actor.GetUnstructuredGrid(), SMESH.TElementSimulation.myGrid, SMESH.TElementSimulation.myPreviewActor, QUAD_EDGE, QUAD_HEXAHEDRON, QUAD_PENTAHEDRON, QUAD_PYRAMID, QUAD_QUADRANGLE, QUAD_TETRAHEDRON, QUAD_TRIANGLE, SMESH.ReverseConnectivity(), and SMESH.TElementSimulation.SetVisibility().

    {
      vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid();
      myGrid->SetPoints(aGrid->GetPoints());

      //add points

      vtkIdType aType = 0;

      switch (theType) {
      case QUAD_EDGE:
        aType = VTK_QUADRATIC_EDGE;
        break;
      case QUAD_TRIANGLE:
        aType = VTK_QUADRATIC_TRIANGLE; 
        break;
      case QUAD_QUADRANGLE:
        aType = VTK_QUADRATIC_QUAD; 
        break;
      case QUAD_TETRAHEDRON:
        aType = VTK_QUADRATIC_TETRA; 
        break;
      case QUAD_PYRAMID:
        //aType = VTK_QUADRATIC_PYRAMID; // NOT SUPPORTED IN VTK4.2
        aType = VTK_CONVEX_POINT_SET;
        break;
      case QUAD_PENTAHEDRON:
        aType = VTK_QUADRATIC_WEDGE;
        //aType = VTK_CONVEX_POINT_SET;
        break; 
      case QUAD_HEXAHEDRON:
        aType = VTK_QUADRATIC_HEXAHEDRON;
        break;
      }

      // take care of orientation
      if ( aType == VTK_CONVEX_POINT_SET ) {
        if ( theReverse && theMode == VTK_SURFACE ) {
          //myPreviewActor->GetProperty()->SetColor( myBackRGB[0], myBackRGB[1], myBackRGB[2] );
        }
      }
      else {
        // VTK cell connectivity opposites the MED one for volumic elements
        if( aType != VTK_QUADRATIC_WEDGE) {
          if ( theIds.size() > 8 ? !theReverse : theReverse ) {
            ReverseConnectivity( theIds, theType );
          }
        }
        else if(theReverse)
          ReverseConnectivity( theIds, theType );          
      }
            
      myGrid->Reset();
      vtkIdList *anIds = vtkIdList::New();
      
      for (int i = 0, iEnd = theIds.size(); i < iEnd; i++) {
        anIds->InsertId(i,theIds[i]);
        //std::cout << i<< ": " << theIds[i] << std::endl;
      }
      
      myGrid->InsertNextCell(aType,anIds);
      anIds->Delete();
      
      myGrid->Modified();

      myPreviewActor->GetMapper()->Update();
      myPreviewActor->SetRepresentation( theMode );
      SetVisibility(true, theActor->GetFacesOriented());

      // restore normal orientation
      if ( aType == VTK_CONVEX_POINT_SET ) {
        if ( theReverse  && theMode == VTK_SURFACE ) {
          //myPreviewActor->GetProperty()->SetColor( myRGB[0], myRGB[1], myRGB[2] );
        }
      }
    }
void SMESH.TElementSimulation.SetVisibility ( bool  theVisibility,
bool  theShowOrientation = false 
)
void SMESH.TElementSimulation.SetVisibility ( bool  theVisibility,
bool  theShowOrientation = false 
)

Field Documentation

SalomeApp_Application * SMESH.TElementSimulation::myApplication [private]
vtkDataSetMapper * SMESH.TElementSimulation::myMapper [private]
SUIT_ViewWindow * SMESH.TElementSimulation::myViewWindow [private]
SVTK_ViewWindow * SMESH.TElementSimulation::myVTKViewWindow [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