SMESH_FaceOrientationFilter.h \
SMESH_ScalarBarActor.h \
SMESH_NodeLabelActor.h \
- SMESH_CellLabelActor.h
+ SMESH_CellLabelActor.h \
+ SMESH_SVTKActor.h
+
# Libraries targets
SMESH_FaceOrientationFilter.cxx \
SMESH_ScalarBarActor.cxx \
SMESH_NodeLabelActor.cxx \
- SMESH_CellLabelActor.cxx
+ SMESH_CellLabelActor.cxx \
+ SMESH_SVTKActor.cxx
libSMESHObject_la_CPPFLAGS = \
$(QT_INCLUDES) \
#include "VTKViewer_ExtractUnstructuredGrid.h"
#include "VTKViewer_FramedTextActor.h"
#include "SALOME_InteractiveObject.hxx"
+#include "SMESH_SVTKActor.h"
#include "SUIT_Session.h"
#include "SUIT_ResourceMgr.h"
myIsPointsVisible = false;
myIsEntityModeCache = false;
+ myHighlightActor = SMESH_SVTKActor::New();
+ myHighlightActor->Initialize();
+
+ myPreHighlightActor = SMESH_SVTKActor::New();
+ myPreHighlightActor->Initialize();
+
myIsShrinkable = false;
myIsShrunk = false;
//Definition 0D device of the actor (ball elements)
//-----------------------------------------------
myBallProp = vtkProperty::New();
- SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
+ SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
myBallProp->SetPointSize(aBallElemSize);
myBallActor->SetProperty(myBallProp);
myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
aFilter = myBallActor->GetExtractUnstructuredGrid();
- //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
- aFilter->RegisterCellsWithType(VTK_VERTEX);
aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
//my0DExtProp = vtkProperty::New();
myHighlightProp->SetLineWidth(aLineWidth);
myHighlightProp->SetRepresentation(1);
+ myBallHighlightProp = vtkProperty::New();
+ myBallHighlightProp->DeepCopy(myHighlightProp);
+ myBallHighlightProp->SetPointSize(aBallElemSize);
+
+
myOutLineProp = vtkProperty::New();
myOutLineProp->SetAmbient(1.0);
myOutLineProp->SetDiffuse(0.0);
myOutLineProp->SetSpecular(0.0);
SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
- myOutLineProp->SetPointSize(aElem0DSize); // ??
myOutLineProp->SetLineWidth(aLineWidth);
myOutLineProp->SetRepresentation(1);
myPreselectProp->SetLineWidth(aLineWidth);
myPreselectProp->SetRepresentation(1);
+ myBallPreselectProp = vtkProperty::New();
+ myBallPreselectProp->DeepCopy(myPreselectProp);
+ myBallPreselectProp->SetPointSize(aBallElemSize);
+
myHighlitableActor = SMESH_DeviceActor::New();
myHighlitableActor->SetUserMatrix(aMatrix);
myHighlitableActor->PickableOff();
my2dHistogram = 0;
#endif
+ SetBallSize(aBallElemSize);
+ Set0DSize(aElem0DSize);
}
myImplicitBoolean->Delete();
myTimeStamp->Delete();
+ myBallHighlightProp->Delete();
+ myBallPreselectProp->Delete();
+
}
void SMESH_ActorDef::Delete()
void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
+
+ //myHighlightActor->AddToRender(theRenderer);
+
theRenderer->AddActor(myBaseActor);
theRenderer->AddActor(myNodeExtActor);
theRenderer->AddActor(my1DExtActor);
myNodeActor->VisibilityOn();
}
- if(myEntityMode & e0DElements){
+ if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
my0DActor->VisibilityOn();
}
- if(myEntityMode & eBallElem){
+ if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
myBallActor->VisibilityOn();
}
int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
+ int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
+ int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
if (theMode < 0) {
myRepresentation = eSurface;
} else {
switch (theMode) {
case eEdge:
- if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
+ if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
break;
case eSurface:
- if (!aNbFaces && !aNbVolumes) return;
+ if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
break;
}
myRepresentation = theMode;
{
if(myIsHighlighted) {
myHighlitableActor->SetProperty(myHighlightProp);
+ myBallActor->SetProperty(myBallHighlightProp);
}else if(myIsPreselected){
myHighlitableActor->SetProperty(myPreselectProp);
+ myBallActor->SetProperty(myBallPreselectProp);
} else if(anIsVisible){
+ myBallActor->SetProperty(myBallProp);
(myRepresentation == eSurface) ?
myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
}
myNodeProp->SetOpacity(theValue);
my1DProp->SetOpacity(theValue);
+ my0DProp->SetOpacity(theValue);
+ myBallProp->SetOpacity(theValue);
}
void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myHighlightProp->SetColor(r,g,b);
+ myBallHighlightProp->SetColor(r,g,b);
Modified();
}
void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
myPreselectProp->SetColor(r,g,b);
+ myBallPreselectProp->SetColor(r,g,b);
Modified();
}
void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
my0DProp->SetPointSize(theVal);
+ myHighlightProp->SetPointSize(theVal);
+ myPreselectProp->SetPointSize(theVal);
+
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
+ aCustom->Set0DSize(theVal);
+ }
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
+ aCustom->Set0DSize(theVal);
+ }
+
Modified();
}
void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
myBallProp->SetPointSize(theVal);
+ myBallHighlightProp->SetPointSize(theVal);
+ myBallPreselectProp->SetPointSize(theVal);
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
+ aCustom->SetBallSize(theVal);
+ }
+ if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
+ aCustom->SetBallSize(theVal);
+ }
+
Modified();
}
vtkProperty* myHighlightProp;
vtkProperty* myOutLineProp;
vtkProperty* myPreselectProp;
+
+ vtkProperty* myBallHighlightProp;
+ vtkProperty* myBallPreselectProp;
SMESH_DeviceActor* myHighlitableActor;
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SMESH OBJECT : interactive object for SMESH visualization
+// File : SMESH_SVTKActor.cxx
+// Author : Roman NIKOLAEV
+// Module : SMESH
+//
+
+#include "SMESH_SVTKActor.h"
+
+#include <SVTK_Utils.h>
+#include <SALOME_Actor.h>
+
+
+#include <SVTK_DeviceActor.h>
+#include <vtkPoints.h>
+#include <vtkRenderer.h>
+#include <vtkObjectFactory.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkCell.h>
+#include <vtkDataSetMapper.h>
+
+vtkStandardNewMacro(SMESH_SVTKActor);
+
+/*!
+ Constructor
+*/
+SMESH_SVTKActor::SMESH_SVTKActor():
+ my0DGrid(vtkUnstructuredGrid::New()),
+ myBallGrid(vtkUnstructuredGrid::New())
+{
+ my0DActor = SVTK_DeviceActor::New();
+ myBallActor = SVTK_DeviceActor::New();
+
+ myBallActor->SetResolveCoincidentTopology(false);
+ myBallActor->SetCoincident3DAllowed(true);
+ myBallActor->PickableOff();
+ my0DActor->SetResolveCoincidentTopology(false);
+ my0DActor->SetCoincident3DAllowed(true);
+ my0DActor->PickableOff();
+
+ my0DGrid->Allocate();
+ myBallGrid->Allocate();
+}
+
+/*!
+ Constructor
+*/
+SMESH_SVTKActor::~SMESH_SVTKActor() {
+ my0DActor->Delete();
+ myBallActor->Delete();
+ my0DGrid->Delete();
+ myBallGrid->Delete();
+}
+
+/*!
+ Publishes the actor in all its internal devices
+*/
+void SMESH_SVTKActor::AddToRender(vtkRenderer* theRenderer) {
+ Superclass::AddToRender(theRenderer);
+ float a0D = my0DActor->GetProperty()->GetPointSize();
+ float aBall = myBallActor->GetProperty()->GetPointSize();
+ my0DActor->GetProperty()->DeepCopy(GetProperty());
+ myBallActor->GetProperty()->DeepCopy(GetProperty());
+ my0DActor->GetProperty()->SetPointSize(a0D);
+ myBallActor->GetProperty()->SetPointSize(aBall);
+ theRenderer->AddActor(my0DActor);
+ theRenderer->AddActor(myBallActor);
+
+}
+
+/*!
+ Removes the actor from all its internal devices
+*/
+void
+SMESH_SVTKActor
+::RemoveFromRender(vtkRenderer* theRenderer)
+{
+ Superclass::RemoveFromRender(theRenderer);
+ theRenderer->RemoveActor( myBallActor );
+ theRenderer->RemoveActor( my0DActor );
+}
+
+void
+SMESH_SVTKActor
+::MapCells(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex)
+{
+ myUnstructuredGrid->Initialize();
+ myUnstructuredGrid->Allocate();
+
+ my0DGrid->Initialize();
+ my0DGrid->Allocate();
+
+ myBallGrid->Initialize();
+ myBallGrid->Allocate();
+
+ vtkDataSet *aSourceDataSet = theMapActor->GetInput();
+ SVTK::CopyPoints( GetSource(), aSourceDataSet );
+ SVTK::CopyPoints( myBallGrid, aSourceDataSet );
+ SVTK::CopyPoints( my0DGrid, aSourceDataSet );
+
+ int aNbOfParts = theMapIndex.Extent();
+ for(int ind = 1; ind <= aNbOfParts; ind++){
+ int aPartId = theMapIndex( ind );
+ if(vtkCell* aCell = theMapActor->GetElemCell(aPartId))
+ {
+#if VTK_XVERSION > 50700
+ if (aCell->GetCellType() != VTK_POLYHEDRON)
+#endif
+ if(aCell->GetCellType() == VTK_VERTEX ) {
+ my0DGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ } else if(aCell->GetCellType() == VTK_POLY_VERTEX ) {
+ myBallGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ } else {
+ myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
+ }
+#if VTK_XVERSION > 50700
+ else
+ {
+ vtkPolyhedron *polyhedron = dynamic_cast<vtkPolyhedron*>(aCell);
+ if (!polyhedron)
+ throw SALOME_Exception(LOCALIZED ("not a polyhedron"));
+ vtkIdType *pts = polyhedron->GetFaces();
+ myUnstructuredGrid->InsertNextCell(aCell->GetCellType(),pts[0], pts+1);
+ }
+#endif
+ }
+
+ UnShrink();
+ if(theMapActor->IsShrunk()){
+ SetShrinkFactor(theMapActor->GetShrinkFactor());
+ SetShrink();
+ }
+
+ myMapIndex = theMapIndex;
+ }
+}
+
+void
+SMESH_SVTKActor
+::Initialize()
+{
+ Superclass::Initialize();
+ my0DActor->SetInput(my0DGrid);
+ myBallActor->SetInput(myBallGrid);
+}
+
+
+void SMESH_SVTKActor::SetVisibility( int theVisibility ) {
+ Superclass::SetVisibility( theVisibility );
+ my0DActor->SetVisibility( theVisibility );
+ myBallActor->SetVisibility( theVisibility );
+}
+
+
+void SMESH_SVTKActor::Set0DSize(float theSize) {
+ my0DActor->GetProperty()->SetPointSize(theSize);
+}
+
+void SMESH_SVTKActor::SetBallSize(float theSize) {
+ myBallActor->GetProperty()->SetPointSize(theSize);
+}
+
--- /dev/null
+// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// SMESH OBJECT : interactive object for SMESH visualization
+// File : SMESH_SVTKActor.h
+// Author : Roman NIKOLAEV
+// Module : SMESH
+//
+#ifndef SMESH_SVTKACTOR_H
+#define SMESH_SVTKACTOR_H
+
+#include "SMESH_Object.h"
+#include <SVTK_Actor.h>
+
+
+class SVTK_Actor;
+class vtkUnstructureGrid;
+class vtkDataSetMapper;
+
+class SMESHOBJECT_EXPORT SMESH_SVTKActor : public SVTK_Actor {
+
+public:
+ static SMESH_SVTKActor* New();
+
+ vtkTypeMacro(SMESH_SVTKActor, SVTK_Actor);
+
+ void SetBallSize(float theSize);
+ void Set0DSize(float theSize);
+
+ //! To publish the actor an all its internal devices
+ virtual
+ void
+ AddToRender(vtkRenderer* theRendere);
+
+ virtual void SetVisibility( int theVisibility );
+
+ //! Initialiaze the instance completely
+ virtual void
+ Initialize();
+
+ //! Allow to recostruct selected cells from source SALOME_Actor and map of subindexes
+ virtual void
+ MapCells(SALOME_Actor* theMapActor,
+ const TColStd_IndexedMapOfInteger& theMapIndex);
+
+
+ //! To remove the actor an all its internal devices
+ virtual
+ void
+ RemoveFromRender(vtkRenderer* theRendere);
+
+ protected:
+ SVTK_DeviceActor* my0DActor;
+ SVTK_DeviceActor* myBallActor;
+
+ vtkUnstructuredGrid* my0DGrid;
+ vtkUnstructuredGrid* myBallGrid;
+
+ SMESH_SVTKActor();
+ virtual ~SMESH_SVTKActor();
+};
+
+#endif
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : EdgeSelection);
break;
case grpBallSelection:
- //if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : BallSelection);
+ if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : CellSelection);
break;
case grpFaceSelection:
if ( aViewWindow ) aViewWindow->SetSelectionMode(isSelectAll ? ActorSelection : FaceSelection);
break;
case grpBallSelection:
aType = SMESH::BALL;
- //mySelector->SetSelectionMode(BallSelection);
+ mySelector->SetSelectionMode(CellSelection);
break;
case grpEdgeSelection:
aType = SMESH::EDGE;