Back to index

salome-smesh  6.5.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes
SMESH::TShapeDisplayer Class Reference

Class showing shapes without publishing. More...

Collaboration diagram for SMESH::TShapeDisplayer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TShapeDisplayer ()
 ~TShapeDisplayer ()
void DeleteActors ()
void SetVisibility (bool theVisibility)
bool HasReadyActorsFor (int subShapeID, GEOM::GEOM_Object_var aMainShape)
void Show (int subShapeID, GEOM::GEOM_Object_var aMainShape, bool only=false)

Private Types

typedef std::vector< GEOM_Actor * > TActorVec
typedef SMDS_SetIterator
< GEOM_Actor
*, TActorVec::const_iterator > 
TActorIterator

Private Member Functions

TActorIterator actorIterator ()
TActorIterator shownIterator ()
GEOM_Actor * getActor (const TopoDS_Shape &shape)
void checkTriangulation (const TopoDS_Shape &shape)
bool hasViewWindow () const

Private Attributes

TActorVec myActors
TActorVec myShownActors
TopTools_IndexedMapOfShape myIndexToShape
std::string myMainEntry
SVTK_ViewWindow * myViewWindow
vtkProperty * myProperty
std::set< int > myBuiltSubs

Detailed Description

Class showing shapes without publishing.

Definition at line 147 of file SMESHGUI_ComputeDlg.cxx.


Member Typedef Documentation

typedef SMDS_SetIterator< GEOM_Actor*, TActorVec::const_iterator> SMESH::TShapeDisplayer::TActorIterator [private]

Definition at line 262 of file SMESHGUI_ComputeDlg.cxx.

typedef std::vector<GEOM_Actor*> SMESH::TShapeDisplayer::TActorVec [private]

Definition at line 252 of file SMESHGUI_ComputeDlg.cxx.


Constructor & Destructor Documentation

Definition at line 151 of file SMESHGUI_ComputeDlg.cxx.

                     : myViewWindow(0)
    {
      myProperty = vtkProperty::New();
      myProperty->SetRepresentationToWireframe();
      myProperty->SetColor( 250, 0, 250 );
      myProperty->SetAmbientColor( 250, 0, 250 );
      myProperty->SetDiffuseColor( 250, 0, 250 );
      //myProperty->SetSpecularColor( 250, 0, 250 );
      myProperty->SetLineWidth( 5 );
    }

Definition at line 162 of file SMESHGUI_ComputeDlg.cxx.

    {
      DeleteActors();
      myProperty->Delete();
    }

Here is the call graph for this function:


Member Function Documentation

Definition at line 263 of file SMESHGUI_ComputeDlg.cxx.

                                   {
      return TActorIterator( myActors.begin(), myActors.end() );
    }

Here is the caller graph for this function:

void SMESH::TShapeDisplayer::checkTriangulation ( const TopoDS_Shape &  shape) [inline, private]

Definition at line 293 of file SMESHGUI_ComputeDlg.cxx.

    {
      TopLoc_Location aLoc;
      Standard_Boolean alreadymesh = Standard_True;
      TopExp_Explorer ex(shape, TopAbs_FACE);
      if ( ex.More() )
        for ( ; ex.More(); ex.Next()) {
          const TopoDS_Face& aFace = TopoDS::Face(ex.Current());
          Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(aFace,aLoc);
          if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
        }
      else
        for (ex.Init(shape, TopAbs_EDGE); ex.More(); ex.Next()) {
          const TopoDS_Edge& edge = TopoDS::Edge(ex.Current());
          Handle(Poly_Polygon3D) aPoly = BRep_Tool::Polygon3D(edge, aLoc);
          if(aPoly.IsNull()) { alreadymesh = Standard_False; break; }
        }
      if (alreadymesh) return;
      // Compute default deflection
      Bnd_Box B;
      BRepBndLib::Add(shape, B);
      Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
      B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
      double deflection = Max( aXmax-aXmin, Max ( aYmax-aYmin, aZmax-aZmin)) * 0.01 *4;
      BRepMesh_IncrementalMesh MESH(shape,deflection);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 168 of file SMESHGUI_ComputeDlg.cxx.

    {
      if ( hasViewWindow() ) {
        TActorIterator actorIt = actorIterator();
        while ( actorIt.more() )
          if (VTKViewer_Actor* anActor = actorIt.next()) {
            myViewWindow->RemoveActor( anActor );
            //anActor->Delete();
          }
      }
      myIndexToShape.Clear();
      myActors.clear();
      myShownActors.clear();
      myBuiltSubs.clear();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

GEOM_Actor* SMESH::TShapeDisplayer::getActor ( const TopoDS_Shape &  shape) [inline, private]

Definition at line 270 of file SMESHGUI_ComputeDlg.cxx.

    {
      int index = myIndexToShape.FindIndex( shape ) - 1;
      if ( index < 0 || index >= myActors.size() )
        return 0;
      GEOM_Actor* & actor = myActors[ index ];
      if ( !actor ) {
        actor = GEOM_Actor::New();
        if ( actor ) {
          actor->SetShape(shape,0,0);
          actor->SetProperty(myProperty);
          actor->SetShadingProperty(myProperty);
          actor->SetWireframeProperty(myProperty);
          actor->SetPreviewProperty(myProperty);
          actor->PickableOff();
          //         if ( shape.ShapeType() == TopAbs_EDGE )
          //           actor->SubShapeOn();
          myViewWindow->AddActor( actor );
        }
      }
      return actor;
    }

Here is the caller graph for this function:

bool SMESH::TShapeDisplayer::HasReadyActorsFor ( int  subShapeID,
GEOM::GEOM_Object_var  aMainShape 
) [inline]

Definition at line 193 of file SMESHGUI_ComputeDlg.cxx.

    {
      std::string mainEntry;
      if ( !aMainShape->_is_nil() )
        mainEntry = aMainShape->GetStudyEntry();
      return ( myMainEntry == mainEntry &&
               myBuiltSubs.find( subShapeID ) != myBuiltSubs.end() );
    }
bool SMESH::TShapeDisplayer::hasViewWindow ( ) const [inline, private]

Definition at line 320 of file SMESHGUI_ComputeDlg.cxx.

    {
      if ( !myViewWindow ) return false;

      if ( SalomeApp_Application* anApp = SMESHGUI::GetSMESHGUI()->getApp() )
        return FindVtkViewWindow( anApp->getViewManager(SVTK_Viewer::Type(), false ),
                                  myViewWindow );
      return false;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESH::TShapeDisplayer::SetVisibility ( bool  theVisibility) [inline]

Definition at line 184 of file SMESHGUI_ComputeDlg.cxx.

    {
      TActorIterator actorIt = shownIterator();
      while ( actorIt.more() )
        if (VTKViewer_Actor* anActor = actorIt.next())
          anActor->SetVisibility(theVisibility);
      SMESH::RepaintCurrentView();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void SMESH::TShapeDisplayer::Show ( int  subShapeID,
GEOM::GEOM_Object_var  aMainShape,
bool  only = false 
) [inline]

Definition at line 202 of file SMESHGUI_ComputeDlg.cxx.

    {
      SVTK_ViewWindow* aViewWindow  = SMESH::GetViewWindow( SMESHGUI::GetSMESHGUI() );
      std::string mainEntry;
      if ( !aMainShape->_is_nil() )
        mainEntry = aMainShape->GetStudyEntry();
      if ( myMainEntry != mainEntry || aViewWindow != myViewWindow ) { // remove actors
        DeleteActors();
        TopoDS_Shape aShape;
        if ( !aMainShape->_is_nil() && GEOMBase::GetShape(aMainShape, aShape)) {
          checkTriangulation( aShape );
          TopExp::MapShapes(aShape, myIndexToShape);
          myActors.resize( myIndexToShape.Extent(), 0 );
          myShownActors.reserve( myIndexToShape.Extent() );
        }
        myMainEntry  = mainEntry;
        myViewWindow = aViewWindow;
      }
      if ( only ) { // hide shown actors
        TActorIterator actorIt = shownIterator();
        while ( actorIt.more() )
          if (VTKViewer_Actor* anActor = actorIt.next())
            anActor->SetVisibility(false);
        myShownActors.clear();
      }
      // find actors to show
      TopoDS_Shape aShape = myIndexToShape( subShapeID );
      if ( !aShape.IsNull() ) {
        TopAbs_ShapeEnum type( aShape.ShapeType() >= TopAbs_WIRE ? TopAbs_EDGE : TopAbs_FACE );
        for ( TopExp_Explorer exp( aShape, type ); exp.More(); exp.Next() ) {
          //checkTriangulation( exp.Current() );
          if ( GEOM_Actor* anActor = getActor( exp.Current() ))
            myShownActors.push_back( anActor );
        }
        if ( type == TopAbs_FACE ) {
          for ( TopExp_Explorer exp( aShape, TopAbs_EDGE ); exp.More(); exp.Next() ) {
            const TopoDS_Edge & edge = TopoDS::Edge( exp.Current() );
            if ( !BRep_Tool::Degenerated( edge ))
              if ( GEOM_Actor* anActor = getActor( exp.Current() ))
                myShownActors.push_back( anActor );
          }
        }
      }
      myBuiltSubs.insert( subShapeID );
      SetVisibility(true);
    }

Here is the call graph for this function:

Definition at line 266 of file SMESHGUI_ComputeDlg.cxx.

                                   {
      return TActorIterator( myShownActors.begin(), myShownActors.end() );
    }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 253 of file SMESHGUI_ComputeDlg.cxx.

std::set<int> SMESH::TShapeDisplayer::myBuiltSubs [private]

Definition at line 259 of file SMESHGUI_ComputeDlg.cxx.

TopTools_IndexedMapOfShape SMESH::TShapeDisplayer::myIndexToShape [private]

Definition at line 255 of file SMESHGUI_ComputeDlg.cxx.

std::string SMESH::TShapeDisplayer::myMainEntry [private]

Definition at line 256 of file SMESHGUI_ComputeDlg.cxx.

vtkProperty* SMESH::TShapeDisplayer::myProperty [private]

Definition at line 258 of file SMESHGUI_ComputeDlg.cxx.

Definition at line 254 of file SMESHGUI_ComputeDlg.cxx.

SVTK_ViewWindow* SMESH::TShapeDisplayer::myViewWindow [private]

Definition at line 257 of file SMESHGUI_ComputeDlg.cxx.


The documentation for this class was generated from the following file: