Version: 6.3.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends

SMESH_DeviceActor Class Reference

#include <SMESH_DeviceActor.h>

Inheritance diagram for SMESH_DeviceActor:
Inheritance graph
[legend]

Public Types

enum  EReperesent { ePoint, eWireframe, eSurface, eInsideframe }

Public Member Functions

 vtkTypeMacro (SMESH_DeviceActor, vtkLODActor)
void SetStoreClippingMapping (bool theStoreMapping)
void SetStoreGemetryMapping (bool theStoreMapping)
void SetStoreIDMapping (bool theStoreMapping)
virtual int GetNodeObjId (int theVtkID)
virtual vtkFloatingPointType * GetNodeCoord (int theObjID)
virtual int GetElemObjId (int theVtkID)
virtual vtkCell * GetElemCell (int theObjID)
virtual void SetTransform (VTKViewer_Transform *theTransform)
virtual unsigned long int GetMTime ()
virtual void SetFacesOriented (bool theIsFacesOriented)
virtual bool GetFacesOriented ()
virtual void SetFacesOrientationColor (vtkFloatingPointType theColor[3])
virtual void GetFacesOrientationColor (vtkFloatingPointType theColor[3])
virtual void SetFacesOrientationScale (vtkFloatingPointType theScale)
virtual vtkFloatingPointType GetFacesOrientationScale ()
virtual void SetFacesOrientation3DVectors (bool theState)
virtual bool GetFacesOrientation3DVectors ()
virtual void SetQuadraticArcMode (bool theFlag)
 Setting for displaying quadratic elements.
virtual bool GetQuadraticArcMode ()
 Return true if 2D quadratic element displayed as arked polygon.
virtual void SetQuadraticArcAngle (vtkFloatingPointType theMaxAngle)
 Set Max angle for representation 2D quadratic element as arked polygon.
virtual vtkFloatingPointType GetQuadraticArcAngle ()
 Return Max angle of the representation 2D quadratic element as arked polygon.
void UpdateFaceOrientation ()
vtkFloatingPointType GetShrinkFactor ()
void SetShrinkFactor (vtkFloatingPointType value)
bool IsShrunkable ()
bool IsShrunk ()
void SetShrink ()
void UnShrink ()
EReperesent GetRepresentation ()
void SetRepresentation (EReperesent theMode)
virtual void SetVisibility (int theMode)
virtual int GetVisibility ()
virtual void AddToRender (vtkRenderer *theRenderer)
virtual void RemoveFromRender (vtkRenderer *theRenderer)
VTKViewer_ExtractUnstructuredGrid * GetExtractUnstructuredGrid ()
vtkUnstructuredGridGetUnstructuredGrid ()
void SetControlMode (SMESH::Controls::FunctorPtr theFunctor, SMESH_ScalarBarActor *theScalarBarActor, vtkLookupTable *theLookupTable)
void SetExtControlMode (SMESH::Controls::FunctorPtr theFunctor, SMESH_ScalarBarActor *theScalarBarActor, vtkLookupTable *theLookupTable)
void SetExtControlMode (SMESH::Controls::FunctorPtr theFunctor)
bool IsHighlited ()
void SetHighlited (bool theIsHighlited)
virtual void Render (vtkRenderer *, vtkMapper *)
void SetImplicitFunctionUsed (bool theIsImplicitFunctionUsed)
bool IsImplicitFunctionUsed () const
void SetMarkerEnabled (bool)
 Set point marker enabled.
void SetMarkerStd (VTK::MarkerType, VTK::MarkerScale)
 Set standard point marker.
void SetMarkerTexture (int, VTK::MarkerTexture)
 Set custom point marker.
VTK::MarkerType GetMarkerType ()
 Get type of the point marker.
VTK::MarkerScale GetMarkerScale ()
 Get scale of the point marker.
int GetMarkerTexture ()
 Get texture identifier of the point marker.

Static Public Member Functions

static SMESH_DeviceActorNew ()

Protected Member Functions

void Init (TVisualObjPtr theVisualObj, vtkImplicitBoolean *theImplicitBoolean)
void SetUnstructuredGrid (vtkUnstructuredGrid *theGrid)
void SetPolygonOffsetParameters (vtkFloatingPointType factor, vtkFloatingPointType units)
void GetPolygonOffsetParameters (vtkFloatingPointType &factor, vtkFloatingPointType &units)
 SMESH_DeviceActor ()
 ~SMESH_DeviceActor ()
 SMESH_DeviceActor (const SMESH_DeviceActor &)
void operator= (const SMESH_DeviceActor &)

Protected Attributes

VTKViewer_PolyDataMapper * myMapper
TVisualObjPtr myVisualObj
vtkProperty * myProperty
EReperesent myRepresentation
SMESH_ExtractGeometrymyExtractGeometry
bool myIsImplicitFunctionUsed
vtkMergeFilter * myMergeFilter
VTKViewer_ExtractUnstructuredGrid * myExtractUnstructuredGrid
bool myIsFacesOriented
SMESH_FaceOrientationFiltermyFaceOrientationFilter
vtkPolyDataMapper * myFaceOrientationDataMapper
vtkActor * myFaceOrientation
bool myStoreClippingMapping
VTKViewer_GeometryFilter * myGeomFilter
VTKViewer_TransformFilter * myTransformFilter
std::vector
< vtkPassThroughFilter * > 
myPassFilter
vtkShrinkFilter * myShrinkFilter
bool myIsShrinkable
bool myIsShrunk
bool myIsHighlited
vtkFloatingPointType myPolygonOffsetFactor
vtkFloatingPointType myPolygonOffsetUnits

Friends

class SMESH_ActorDef

Detailed Description

Definition at line 59 of file SMESH_DeviceActor.h.


Member Enumeration Documentation

Enumerator:
ePoint 
eWireframe 
eSurface 
eInsideframe 

Definition at line 109 of file SMESH_DeviceActor.h.


Constructor & Destructor Documentation

SMESH_DeviceActor::SMESH_DeviceActor ( ) [protected]

Definition at line 81 of file SMESH_DeviceActor.cxx.

References GetColor(), MESSAGE, SMESH_FaceOrientationFilter.New(), and SMESH_ExtractGeometry.New().

{
  if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);

  myIsShrinkable = false;
  myIsShrunk = false;
  myIsHighlited = false;

  myRepresentation = eSurface;

  myProperty = vtkProperty::New();
  myMapper = VTKViewer_PolyDataMapper::New();

  vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
                                                                 myPolygonOffsetUnits);

  myMapper->UseLookupTableScalarRangeOn();
  myMapper->SetColorModeToMapScalars();

  myShrinkFilter = vtkShrinkFilter::New();

  myStoreClippingMapping = false;

  myExtractGeometry = SMESH_ExtractGeometry::New();
  myExtractGeometry->SetReleaseDataFlag(true);
  myIsImplicitFunctionUsed = false;

  myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
    
  myMergeFilter = vtkMergeFilter::New();

  myGeomFilter = VTKViewer_GeometryFilter::New();

  myTransformFilter = VTKViewer_TransformFilter::New();

  for(int i = 0; i < 6; i++)
    myPassFilter.push_back(vtkPassThroughFilter::New());

  // Orientation of faces
  myIsFacesOriented = false;

  vtkFloatingPointType anRGB[3] = { 1, 1, 1 };
  SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );

  myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();

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

  myFaceOrientation = vtkActor::New();
  myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
  myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
}
SMESH_DeviceActor::~SMESH_DeviceActor ( ) [protected]

Definition at line 137 of file SMESH_DeviceActor.cxx.

References MESSAGE.

{
  if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);

  myProperty->Delete();

  myMapper->Delete();

  myShrinkFilter->Delete();

  myExtractUnstructuredGrid->Delete();

  myMergeFilter->Delete();

  myGeomFilter->Delete();

  myExtractGeometry->Delete();

  myTransformFilter->Delete();

  for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
    myPassFilter[i]->Delete();
  }

  // Orientation of faces
  myFaceOrientationFilter->Delete();

  myFaceOrientationDataMapper->RemoveAllInputs();
  myFaceOrientationDataMapper->Delete();

  myFaceOrientation->Delete();
}
SMESH_DeviceActor.SMESH_DeviceActor ( const SMESH_DeviceActor ) [protected]

Member Function Documentation

void SMESH_DeviceActor::AddToRender ( vtkRenderer *  theRenderer) [virtual]

Definition at line 753 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.AddToRender().

{
  theRenderer->AddActor(this);
  theRenderer->AddActor(myFaceOrientation);
}
vtkCell * SMESH_DeviceActor::GetElemCell ( int  theObjID) [virtual]

Definition at line 820 of file SMESH_DeviceActor.cxx.

References MESSAGE.

Referenced by SMESH_ActorDef.GetElemCell().

{
  vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
  vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
  vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
  if(MYDEBUG) 
    MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
  return aCell;
}
int SMESH_DeviceActor::GetElemObjId ( int  theVtkID) [virtual]

Definition at line 796 of file SMESH_DeviceActor.cxx.

References MESSAGE.

Referenced by SMESH_ActorDef.GetElemObjId().

{
  vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
  if(anId < 0) 
    return -1;

  vtkIdType anId2 = anId;
  if(IsImplicitFunctionUsed())
    anId2 = myExtractGeometry->GetElemObjId(anId);
  if(anId2 < 0) 
    return -1;

  vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
  if(anId3 < 0) 
    return -1;

  vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
  if(MYDEBUG) 
     MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
  return aRetID;
}
VTKViewer_ExtractUnstructuredGrid * SMESH_DeviceActor::GetExtractUnstructuredGrid ( )
bool SMESH_DeviceActor::GetFacesOrientation3DVectors ( ) [virtual]
void SMESH_DeviceActor::GetFacesOrientationColor ( vtkFloatingPointType  theColor[3]) [virtual]

Definition at line 647 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.GetFacesOrientationColor().

{
  myFaceOrientation->GetProperty()->GetColor( theColor );
}
vtkFloatingPointType SMESH_DeviceActor::GetFacesOrientationScale ( ) [virtual]
virtual bool SMESH_DeviceActor.GetFacesOriented ( ) [virtual]

Definition at line 80 of file SMESH_DeviceActor.h.

References SMESH_ActorDef.myIsFacesOriented.

{ return myIsFacesOriented; }
VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale ( )

Get scale of the point marker.

Returns:
scale of the point marker

Definition at line 957 of file SMESH_DeviceActor.cxx.

{
  return myMapper->GetMarkerScale();
}
int SMESH_DeviceActor::GetMarkerTexture ( )

Get texture identifier of the point marker.

Returns:
texture identifier of the point marker

Definition at line 966 of file SMESH_DeviceActor.cxx.

{
  return myMapper->GetMarkerTexture();
}
VTK::MarkerType SMESH_DeviceActor::GetMarkerType ( )

Get type of the point marker.

Returns:
type of the point marker

Definition at line 948 of file SMESH_DeviceActor.cxx.

{
  return myMapper->GetMarkerType();
}
unsigned long int SMESH_DeviceActor::GetMTime ( ) [virtual]

Definition at line 576 of file SMESH_DeviceActor.cxx.

{
  unsigned long mTime = this->Superclass::GetMTime();
  mTime = max(mTime,myExtractGeometry->GetMTime());
  mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
  mTime = max(mTime,myMergeFilter->GetMTime());
  mTime = max(mTime,myGeomFilter->GetMTime());
  mTime = max(mTime,myTransformFilter->GetMTime());
  mTime = max(mTime,myFaceOrientationFilter->GetMTime());
  return mTime;
}
vtkFloatingPointType * SMESH_DeviceActor::GetNodeCoord ( int  theObjID) [virtual]

Definition at line 784 of file SMESH_DeviceActor.cxx.

References MESSAGE.

Referenced by SMESH_ActorDef.GetNodeCoord().

{
  vtkDataSet* aDataSet = myMergeFilter->GetOutput();
  vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
  vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
  if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
  return aCoord;
}
int SMESH_DeviceActor::GetNodeObjId ( int  theVtkID) [virtual]

Definition at line 770 of file SMESH_DeviceActor.cxx.

References MESSAGE.

Referenced by SMESH_ActorDef.GetNodeObjId().

{
  vtkIdType anID = theVtkID;

  if(IsImplicitFunctionUsed())
    anID = myExtractGeometry->GetNodeObjId(theVtkID);

  vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
  if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
  return aRetID;
}
void SMESH_DeviceActor.GetPolygonOffsetParameters ( vtkFloatingPointType &  factor,
vtkFloatingPointType &  units 
) [protected]

Definition at line 185 of file SMESH_DeviceActor.h.

Referenced by SMESH_ActorDef.Init().

vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle ( ) [virtual]

Return Max angle of the representation 2D quadratic element as arked polygon.

Definition at line 912 of file SMESH_DeviceActor.cxx.

                                                            {
  return myGeomFilter->GetQuadraticArcAngle();
}
bool SMESH_DeviceActor::GetQuadraticArcMode ( ) [virtual]

Return true if 2D quadratic element displayed as arked polygon.

Definition at line 899 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.GetQuadratic2DRepresentation().

                                           {
  return myGeomFilter->GetQuadraticArcMode();
}
EReperesent SMESH_DeviceActor.GetRepresentation ( )

Definition at line 110 of file SMESH_DeviceActor.h.

{ return myRepresentation;}
vtkFloatingPointType SMESH_DeviceActor::GetShrinkFactor ( )

Definition at line 833 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.GetShrinkFactor().

{
  return myShrinkFilter->GetShrinkFactor();
}
vtkUnstructuredGrid * SMESH_DeviceActor::GetUnstructuredGrid ( )
int SMESH_DeviceActor::GetVisibility ( ) [virtual]

Definition at line 742 of file SMESH_DeviceActor.cxx.

{
  if(!GetUnstructuredGrid()->GetNumberOfCells()){
    vtkLODActor::SetVisibility(false);
  }
  return vtkLODActor::GetVisibility();
}
void SMESH_DeviceActor::Init ( TVisualObjPtr  theVisualObj,
vtkImplicitBoolean *  theImplicitBoolean 
) [protected]

Definition at line 200 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.Init().

{
  myVisualObj = theVisualObj;
  myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
  SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
}
bool SMESH_DeviceActor.IsHighlited ( )

Definition at line 130 of file SMESH_DeviceActor.h.

{ return myIsHighlited;}
bool SMESH_DeviceActor.IsImplicitFunctionUsed ( ) const

Definition at line 136 of file SMESH_DeviceActor.h.

Referenced by SMESH_ActorDef.IsImplicitFunctionUsed().

bool SMESH_DeviceActor.IsShrunk ( )

Definition at line 105 of file SMESH_DeviceActor.h.

References SMESH_ActorDef.myIsShrunk.

{ return myIsShrunk;}
bool SMESH_DeviceActor.IsShrunkable ( )

Definition at line 104 of file SMESH_DeviceActor.h.

References SMESH_ActorDef.myIsShrinkable.

{ return myIsShrinkable;}
static SMESH_DeviceActor* SMESH_DeviceActor.New ( ) [static]
void SMESH_DeviceActor.operator= ( const SMESH_DeviceActor ) [protected]
void SMESH_DeviceActor::RemoveFromRender ( vtkRenderer *  theRenderer) [virtual]

Definition at line 761 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.RemoveFromRender().

{
  theRenderer->RemoveActor(this);
  theRenderer->RemoveActor(myFaceOrientation);
}
void SMESH_DeviceActor::Render ( vtkRenderer *  ren,
vtkMapper *  m 
) [virtual]

Definition at line 860 of file SMESH_DeviceActor.cxx.

{
  int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
  vtkFloatingPointType aStoredFactor, aStoredUnit; 
  vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);

  vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
  vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
  if(myIsHighlited){
    static vtkFloatingPointType EPS = .01;
    aUnits *= (1.0-EPS);
  }
  vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
  vtkLODActor::Render(ren,m);

  vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
  vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
}
void SMESH_DeviceActor::SetControlMode ( SMESH::Controls::FunctorPtr  theFunctor,
SMESH_ScalarBarActor theScalarBarActor,
vtkLookupTable *  theLookupTable 
)

Definition at line 284 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetControlMode().

{
  bool anIsInitialized = theFunctor;
  if(anIsInitialized){
    vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();

    SetStoreIDMapping(true);
    myExtractUnstructuredGrid->Update();
    vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();

    aDataSet->ShallowCopy(aGrid);
    
    vtkDoubleArray *aScalars = vtkDoubleArray::New();
    vtkIdType aNbCells = aGrid->GetNumberOfCells();
    aScalars->SetNumberOfComponents(1);
    aScalars->SetNumberOfTuples(aNbCells);
    
    myVisualObj->UpdateFunctor(theFunctor);

    using namespace SMESH::Controls;
    if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
      for(vtkIdType i = 0; i < aNbCells; i++){
        vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
        vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
        double aValue = aNumericalFunctor->GetValue(anObjId);
        aScalars->SetValue(i,aValue);
      }
    }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
      for(vtkIdType i = 0; i < aNbCells; i++){
        vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
        vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
        bool aValue = aPredicate->IsSatisfy(anObjId);
        aScalars->SetValue(i,aValue);
      }
    }

    aDataSet->GetCellData()->SetScalars(aScalars);
    aScalars->Delete();
        
    theLookupTable->SetRange(aScalars->GetRange());
    theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
    theLookupTable->Build();
    
    myMergeFilter->SetScalars(aDataSet);
    aDataSet->Delete();
  }
  GetMapper()->SetScalarVisibility(anIsInitialized);
  theScalarBarActor->SetVisibility(anIsInitialized);
}
void SMESH_DeviceActor::SetExtControlMode ( SMESH::Controls::FunctorPtr  theFunctor,
SMESH_ScalarBarActor theScalarBarActor,
vtkLookupTable *  theLookupTable 
)

Definition at line 338 of file SMESH_DeviceActor.cxx.

References SMESH.Controls.Length2D.Value.myLength, SMESH.Controls.MultiConnection2D.Value.myPntId, and SMESH.Controls.Length2D.Value.myPntId.

Referenced by SMESH_ActorDef.SetControlMode().

{
  bool anIsInitialized = theFunctor;
  myExtractUnstructuredGrid->ClearRegisteredCells();
  myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
  myVisualObj->UpdateFunctor(theFunctor);

  using namespace SMESH::Controls;
  if (anIsInitialized){
    if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
      SMESH::Controls::Length2D::TValues aValues;

      aLength2D->GetValues(aValues);
      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();

      aDataSet->SetPoints(aGrid->GetPoints());
      
      vtkIdType aNbCells = aValues.size();
      
      vtkDoubleArray *aScalars = vtkDoubleArray::New();
      aScalars->SetNumberOfComponents(1);
      aScalars->SetNumberOfTuples(aNbCells);

      vtkIdType aCellsSize = 3*aNbCells;
      vtkCellArray* aConnectivity = vtkCellArray::New();
      aConnectivity->Allocate( aCellsSize, 0 );
      
      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
      aCellTypesArray->SetNumberOfComponents( 1 );
      aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
      
      vtkIdList *anIdList = vtkIdList::New();
      anIdList->SetNumberOfIds(2);
      
      Length2D::TValues::const_iterator anIter = aValues.begin();
      for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
        const Length2D::Value& aValue = *anIter;
        int aNode[2] = {
          myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
          myVisualObj->GetNodeVTKId(aValue.myPntId[1])
        };
        if(aNode[0] >= 0 && aNode[1] >= 0){
          anIdList->SetId( 0, aNode[0] );
          anIdList->SetId( 1, aNode[1] );
          aConnectivity->InsertNextCell( anIdList );
          aCellTypesArray->InsertNextValue( VTK_LINE );
          aScalars->SetValue(aVtkId,aValue.myLength);
        }
      }
      
      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 ) );
      
      aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
      SetUnstructuredGrid(aDataSet);

      aDataSet->GetCellData()->SetScalars(aScalars);
      aScalars->Delete();
      
      theLookupTable->SetRange(aScalars->GetRange());
      theLookupTable->Build();
      
      myMergeFilter->SetScalars(aDataSet);
      aDataSet->Delete();
    }
    else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
      SMESH::Controls::MultiConnection2D::MValues aValues;

      aMultiConnection2D->GetValues(aValues);
      vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
      vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
      aDataSet->SetPoints(aGrid->GetPoints());
      
      vtkIdType aNbCells = aValues.size();
      vtkDoubleArray *aScalars = vtkDoubleArray::New();
      aScalars->SetNumberOfComponents(1);
      aScalars->SetNumberOfTuples(aNbCells);

      vtkIdType aCellsSize = 3*aNbCells;
      vtkCellArray* aConnectivity = vtkCellArray::New();
      aConnectivity->Allocate( aCellsSize, 0 );
      
      vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
      aCellTypesArray->SetNumberOfComponents( 1 );
      aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
      
      vtkIdList *anIdList = vtkIdList::New();
      anIdList->SetNumberOfIds(2);
      
      MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
      for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
        const MultiConnection2D::Value& aValue = (*anIter).first;
        int aNode[2] = {
          myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
          myVisualObj->GetNodeVTKId(aValue.myPntId[1])
        };
        if(aNode[0] >= 0 && aNode[1] >= 0){
          anIdList->SetId( 0, aNode[0] );
          anIdList->SetId( 1, aNode[1] );
          aConnectivity->InsertNextCell( anIdList );
          aCellTypesArray->InsertNextValue( VTK_LINE );
          aScalars->SetValue(aVtkId,(*anIter).second);
        }
      }
      
      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 ) );
      
      aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
      SetUnstructuredGrid(aDataSet);

      aDataSet->GetCellData()->SetScalars(aScalars);
      aScalars->Delete();
      
      theLookupTable->SetRange(aScalars->GetRange());
      theLookupTable->Build();
      
      myMergeFilter->SetScalars(aDataSet);
      aDataSet->Delete();
    }
  }
  GetMapper()->SetScalarVisibility(anIsInitialized);
  theScalarBarActor->SetVisibility(anIsInitialized);
}
void SMESH_DeviceActor::SetExtControlMode ( SMESH::Controls::FunctorPtr  theFunctor)

Definition at line 479 of file SMESH_DeviceActor.cxx.

References SMESH.Controls.Predicate.IsSatisfy(), SMESH.Controls.FreeEdges.Border.myPntId, and SMDSAbs_Node.

{
  myExtractUnstructuredGrid->ClearRegisteredCells();
  myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
  myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
  myVisualObj->UpdateFunctor(theFunctor);

  using namespace SMESH::Controls;
  if ( dynamic_cast<FreeBorders          *>(theFunctor.get()) ||
       dynamic_cast<FreeFaces            *>(theFunctor.get()) ||
       dynamic_cast<BareBorderVolume     *>(theFunctor.get()) ||
       dynamic_cast<BareBorderFace       *>(theFunctor.get()) ||
       dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
       dynamic_cast<OverConstrainedFace  *>(theFunctor.get()))
  {
    Predicate* aFreePredicate = dynamic_cast<Predicate*>(theFunctor.get());
    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
    vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
    vtkIdType aNbCells = aGrid->GetNumberOfCells();
    for( vtkIdType i = 0; i < aNbCells; i++ ){
      vtkIdType anObjId = myVisualObj->GetElemObjId(i);
      if(aFreePredicate->IsSatisfy(anObjId))
        myExtractUnstructuredGrid->RegisterCell(i);
    }
    if(!myExtractUnstructuredGrid->IsCellsRegistered())
      myExtractUnstructuredGrid->RegisterCell(-1);
    SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
  }
  else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
  {
    SMESH::Controls::FreeEdges::TBorders aBorders;
    aFreeEdges->GetBoreders(aBorders);
    vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
    vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
    aDataSet->SetPoints(aGrid->GetPoints());

    vtkIdType aNbCells = aBorders.size();
    vtkIdType aCellsSize = 3*aNbCells;
    vtkCellArray* aConnectivity = vtkCellArray::New();
    aConnectivity->Allocate( aCellsSize, 0 );
    
    vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
    aCellTypesArray->SetNumberOfComponents( 1 );
    aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
    
    vtkIdList *anIdList = vtkIdList::New();
    anIdList->SetNumberOfIds(2);
    
    FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
    for(; anIter != aBorders.end(); anIter++){
      const FreeEdges::Border& aBorder = *anIter;
      int aNode[2] = {
        myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
        myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
      };
      //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
      if(aNode[0] >= 0 && aNode[1] >= 0){
        anIdList->SetId( 0, aNode[0] );
        anIdList->SetId( 1, aNode[1] );
        aConnectivity->InsertNextCell( anIdList );
        aCellTypesArray->InsertNextValue( VTK_LINE );
      }
    }
    
    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 ) );
    
    aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );

    SetUnstructuredGrid(aDataSet);
    aDataSet->Delete();
  }
  else if(FreeNodes* aFreeNodes = dynamic_cast<FreeNodes*>(theFunctor.get()))
  {
    myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
    vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
    for( vtkIdType i = 0; i < aNbNodes; i++ ){
      vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
      if(aFreeNodes->IsSatisfy(anObjId))
        myExtractUnstructuredGrid->RegisterCell(i);
    }
    if(!myExtractUnstructuredGrid->IsCellsRegistered())
      myExtractUnstructuredGrid->RegisterCell(-1);
    SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
  }
}
void SMESH_DeviceActor::SetFacesOrientation3DVectors ( bool  theState) [virtual]
void SMESH_DeviceActor::SetFacesOrientationColor ( vtkFloatingPointType  theColor[3]) [virtual]

Definition at line 640 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetFacesOrientationColor().

{
  myFaceOrientation->GetProperty()->SetColor( theColor );
}
void SMESH_DeviceActor::SetFacesOrientationScale ( vtkFloatingPointType  theScale) [virtual]
void SMESH_DeviceActor::SetFacesOriented ( bool  theIsFacesOriented) [virtual]

Definition at line 627 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetFacesOriented().

{
  if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() )
  {
    myIsFacesOriented = theIsFacesOriented;
    if( theIsFacesOriented )
      myFaceOrientationFilter->SetInput( aDataSet );
    UpdateFaceOrientation();
  }
}
void SMESH_DeviceActor::SetHighlited ( bool  theIsHighlited)

Definition at line 850 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SMESH_ActorDef(), and SMESH_ActorDef.UpdateHighlight().

{
  if ( myIsHighlited == theIsHighlited )
    return;
  myIsHighlited = theIsHighlited;
  Modified();
}
void SMESH_DeviceActor::SetImplicitFunctionUsed ( bool  theIsImplicitFunctionUsed)

Definition at line 211 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetImplicitFunctionUsed().

{
  int anId = 0;
  if(theIsImplicitFunctionUsed)
    myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
  else
    myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
    
  myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
  SetStoreClippingMapping(myStoreClippingMapping);
}
void SMESH_DeviceActor::SetMarkerEnabled ( bool  theMarkerEnabled)

Set point marker enabled.

Parameters:
theMarkerEnabledflag to enable/disable point marker

Definition at line 920 of file SMESH_DeviceActor.cxx.

{
  myMapper->SetMarkerEnabled( theMarkerEnabled );
}
void SMESH_DeviceActor::SetMarkerStd ( VTK::MarkerType  theMarkerType,
VTK::MarkerScale  theMarkerScale 
)

Set standard point marker.

Parameters:
theMarkerTypetype of the marker

Definition at line 929 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetMarkerStd(), and SMESH_ActorDef.UpdateHighlight().

{
  myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
}
void SMESH_DeviceActor::SetMarkerTexture ( int  theMarkerId,
VTK::MarkerTexture  theMarkerTexture 
)

Set custom point marker.

Parameters:
theMarkerIdid of the marker texture
theMarkerTexturemarker texture

Definition at line 939 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetMarkerTexture(), and SMESH_ActorDef.UpdateHighlight().

{
  myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
}
void SMESH_DeviceActor::SetPolygonOffsetParameters ( vtkFloatingPointType  factor,
vtkFloatingPointType  units 
) [protected]

Definition at line 882 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.Init().

void SMESH_DeviceActor::SetQuadraticArcAngle ( vtkFloatingPointType  theMaxAngle) [virtual]

Set Max angle for representation 2D quadratic element as arked polygon.

Definition at line 905 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SMESH_ActorDef().

                                                                            {
  myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
}
void SMESH_DeviceActor::SetQuadraticArcMode ( bool  theFlag) [virtual]

Setting for displaying quadratic elements.

On/Off representation 2D quadratic element as arked polygon.

Definition at line 892 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetQuadratic2DRepresentation(), SMESH_ActorDef.SetRepresentation(), and SMESH_ActorDef.SMESH_ActorDef().

                                                       {
  myGeomFilter->SetQuadraticArcMode(theFlag);
}
void SMESH_DeviceActor::SetRepresentation ( EReperesent  theMode)

Definition at line 693 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetRepresentation(), SMESH_ActorDef.SMESH_ActorDef(), and SMESH_ActorDef.UpdateHighlight().

{
  switch(theMode){
  case ePoint:
    myGeomFilter->SetInside(true);
    myGeomFilter->SetWireframeMode(false);
    GetProperty()->SetRepresentation(0);
    break;
  case eWireframe:
    myGeomFilter->SetInside(false);
    myGeomFilter->SetWireframeMode(true);
    GetProperty()->SetRepresentation(theMode);
    break;
  case eInsideframe:
    myGeomFilter->SetInside(true);
    myGeomFilter->SetWireframeMode(true);
    GetProperty()->SetRepresentation(1);
    break;
  case eSurface:
    myGeomFilter->SetInside(false);
    myGeomFilter->SetWireframeMode(false);
    GetProperty()->SetRepresentation(theMode);
  }
  SetMarkerEnabled(theMode == ePoint);
  myRepresentation = theMode;
  UpdateFaceOrientation();
  GetProperty()->Modified();
  myMapper->Modified();
  Modified();
}
void SMESH_DeviceActor::SetShrink ( )

Definition at line 599 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetShrink().

{
  if ( !myIsShrinkable ) return;
  if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
  {
    myShrinkFilter->SetInput( aDataSet );
    myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
    myIsShrunk = true;
  }
}
void SMESH_DeviceActor::SetShrinkFactor ( vtkFloatingPointType  value)

Definition at line 840 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetShrinkFactor().

{
  theValue = theValue > 0.1? theValue: 0.8;
  myShrinkFilter->SetShrinkFactor(theValue);
  Modified();
}
void SMESH_DeviceActor::SetStoreClippingMapping ( bool  theStoreMapping)

Definition at line 182 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SMESH_ActorDef().

{
  myStoreClippingMapping = theStoreMapping;
  myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
  SetStoreIDMapping(theStoreMapping);
}
void SMESH_DeviceActor::SetStoreGemetryMapping ( bool  theStoreMapping)

Definition at line 173 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SMESH_ActorDef().

{
  myGeomFilter->SetStoreMapping(theStoreMapping);
  SetStoreClippingMapping(theStoreMapping);
}
void SMESH_DeviceActor::SetStoreIDMapping ( bool  theStoreMapping)

Definition at line 192 of file SMESH_DeviceActor.cxx.

{
  myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
}
void SMESH_DeviceActor::SetTransform ( VTKViewer_Transform *  theTransform) [virtual]

Definition at line 591 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.SetTransform().

{
  myTransformFilter->SetTransform(theTransform);
}
void SMESH_DeviceActor::SetUnstructuredGrid ( vtkUnstructuredGrid theGrid) [protected]

Definition at line 226 of file SMESH_DeviceActor.cxx.

{
  if(theGrid){
    //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
    myIsShrinkable = true;

    myExtractUnstructuredGrid->SetInput(theGrid);

    myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());

    myExtractGeometry->SetInput(myMergeFilter->GetOutput());

    int anId = 0;
    SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
    myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
    
    anId++; // 1
    myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );

    anId++; // 2
    myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); 
    myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );

    anId++; // 3
    myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );

    anId++; // 4
    myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
    myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );

    anId++; // 5
    myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );

    vtkLODActor::SetMapper( myMapper );
    Modified();
  }
}
void SMESH_DeviceActor::SetVisibility ( int  theMode) [virtual]
void SMESH_DeviceActor::UnShrink ( )

Definition at line 612 of file SMESH_DeviceActor.cxx.

Referenced by SMESH_ActorDef.UnShrink().

{
  if ( !myIsShrunk ) return;
  if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
  {    
    myPassFilter[ 1 ]->SetInput( aDataSet );
    myPassFilter[ 1 ]->Modified();
    myIsShrunk = false;
    Modified();
  }
}
void SMESH_DeviceActor::UpdateFaceOrientation ( )

Definition at line 682 of file SMESH_DeviceActor.cxx.

{
  bool aShowFaceOrientation = myIsFacesOriented;
  aShowFaceOrientation &= GetVisibility();
  aShowFaceOrientation &= myRepresentation == eSurface;
  myFaceOrientation->SetVisibility(aShowFaceOrientation);
}
SMESH_DeviceActor.vtkTypeMacro ( SMESH_DeviceActor  ,
vtkLODActor   
)

Friends And Related Function Documentation

friend class SMESH_ActorDef [friend]

Definition at line 60 of file SMESH_DeviceActor.h.


Field Documentation

Definition at line 155 of file SMESH_DeviceActor.h.

VTKViewer_ExtractUnstructuredGrid* SMESH_DeviceActor.myExtractUnstructuredGrid [protected]

Definition at line 159 of file SMESH_DeviceActor.h.

vtkActor* SMESH_DeviceActor.myFaceOrientation [protected]

Definition at line 164 of file SMESH_DeviceActor.h.

vtkPolyDataMapper* SMESH_DeviceActor.myFaceOrientationDataMapper [protected]

Definition at line 163 of file SMESH_DeviceActor.h.

Definition at line 162 of file SMESH_DeviceActor.h.

VTKViewer_GeometryFilter* SMESH_DeviceActor.myGeomFilter [protected]

Definition at line 167 of file SMESH_DeviceActor.h.

Referenced by SMESH_ActorDef.SetEntityMode().

Definition at line 161 of file SMESH_DeviceActor.h.

Definition at line 175 of file SMESH_DeviceActor.h.

Definition at line 156 of file SMESH_DeviceActor.h.

Definition at line 172 of file SMESH_DeviceActor.h.

Definition at line 173 of file SMESH_DeviceActor.h.

VTKViewer_PolyDataMapper* SMESH_DeviceActor.myMapper [protected]

Definition at line 149 of file SMESH_DeviceActor.h.

vtkMergeFilter* SMESH_DeviceActor.myMergeFilter [protected]

Definition at line 158 of file SMESH_DeviceActor.h.

std::vector<vtkPassThroughFilter*> SMESH_DeviceActor.myPassFilter [protected]

Definition at line 169 of file SMESH_DeviceActor.h.

vtkFloatingPointType SMESH_DeviceActor.myPolygonOffsetFactor [protected]

Definition at line 177 of file SMESH_DeviceActor.h.

vtkFloatingPointType SMESH_DeviceActor.myPolygonOffsetUnits [protected]

Definition at line 178 of file SMESH_DeviceActor.h.

vtkProperty* SMESH_DeviceActor.myProperty [protected]

Definition at line 152 of file SMESH_DeviceActor.h.

Definition at line 153 of file SMESH_DeviceActor.h.

vtkShrinkFilter* SMESH_DeviceActor.myShrinkFilter [protected]

Definition at line 171 of file SMESH_DeviceActor.h.

Definition at line 166 of file SMESH_DeviceActor.h.

VTKViewer_TransformFilter* SMESH_DeviceActor.myTransformFilter [protected]

Definition at line 168 of file SMESH_DeviceActor.h.

Definition at line 150 of file SMESH_DeviceActor.h.

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