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

SMESH.TShapeDisplayer Class Reference

Class showing shapes without publishing. More...

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< intmyBuiltSubs

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

SMESH.TShapeDisplayer.TShapeDisplayer ( )

Definition at line 151 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.TShapeDisplayer.myProperty.

                     : 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 );
    }
SMESH.TShapeDisplayer.~TShapeDisplayer ( )

Member Function Documentation

TActorIterator SMESH.TShapeDisplayer.actorIterator ( ) [private]

Definition at line 263 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.TShapeDisplayer.myActors.

Referenced by SMESH.TShapeDisplayer.DeleteActors().

                                   {
      return TActorIterator( myActors.begin(), myActors.end() );
    }
void SMESH.TShapeDisplayer.checkTriangulation ( const TopoDS_Shape &  shape) [private]

Definition at line 293 of file SMESHGUI_ComputeDlg.cxx.

References deflection(), SMESH_test.edge, SMESH.Handle(), Max(), and MESH.

Referenced by SMESH.TShapeDisplayer.Show().

    {
      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);
    }
void SMESH.TShapeDisplayer.DeleteActors ( )
GEOM_Actor* SMESH.TShapeDisplayer.getActor ( const TopoDS_Shape &  shape) [private]

Definition at line 270 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.TShapeDisplayer.myActors, SMESH.TShapeDisplayer.myIndexToShape, SMESH.TShapeDisplayer.myProperty, and SMESH.TShapeDisplayer.myViewWindow.

Referenced by SMESH.TShapeDisplayer.Show().

    {
      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;
    }
bool SMESH.TShapeDisplayer.HasReadyActorsFor ( int  subShapeID,
GEOM::GEOM_Object_var  aMainShape 
)

Definition at line 193 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.TShapeDisplayer.myBuiltSubs, and SMESH.TShapeDisplayer.myMainEntry.

Referenced by SMESHGUI_BaseComputeOp.currentCellChanged().

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

Definition at line 320 of file SMESHGUI_ComputeDlg.cxx.

References SMESH.FindVtkViewWindow(), SMESHGUI.GetSMESHGUI(), and SMESH.TShapeDisplayer.myViewWindow.

Referenced by SMESH.TShapeDisplayer.DeleteActors().

    {
      if ( !myViewWindow ) return false;

      if ( SalomeApp_Application* anApp = SMESHGUI::GetSMESHGUI()->getApp() )
        return FindVtkViewWindow( anApp->getViewManager(SVTK_Viewer::Type(), false ),
                                  myViewWindow );
      return false;
    }
void SMESH.TShapeDisplayer.SetVisibility ( bool  theVisibility)
void SMESH.TShapeDisplayer.Show ( int  subShapeID,
GEOM::GEOM_Object_var  aMainShape,
bool  only = false 
)

Definition at line 202 of file SMESHGUI_ComputeDlg.cxx.

References SMESH_fixation.aShape, SMESH.TShapeDisplayer.checkTriangulation(), SMESH.TShapeDisplayer.DeleteActors(), SMESH_test.edge, SMESH.TShapeDisplayer.getActor(), SMESHGUI.GetSMESHGUI(), SMESH.GetViewWindow(), SMDS_SetIterator< VALUE, VALUE_SET_ITERATOR, ACCESOR >.more(), SMESH.TShapeDisplayer.myActors, SMESH.TShapeDisplayer.myBuiltSubs, SMESH.TShapeDisplayer.myIndexToShape, SMESH.TShapeDisplayer.myMainEntry, SMESH.TShapeDisplayer.myShownActors, SMESH.TShapeDisplayer.myViewWindow, SMDS_SetIterator< VALUE, VALUE_SET_ITERATOR, ACCESOR >.next(), SMESH.TShapeDisplayer.SetVisibility(), and SMESH.TShapeDisplayer.shownIterator().

Referenced by SMESHGUI_BaseComputeOp.currentCellChanged(), and SMESHGUI_BaseComputeOp.onPreviewShape().

    {
      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);
    }
TActorIterator SMESH.TShapeDisplayer.shownIterator ( ) [private]

Field Documentation

TopTools_IndexedMapOfShape SMESH.TShapeDisplayer.myIndexToShape [private]
std::string SMESH.TShapeDisplayer.myMainEntry [private]
vtkProperty* SMESH.TShapeDisplayer.myProperty [private]
SVTK_ViewWindow* SMESH.TShapeDisplayer.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