#include <vtkMath.h>
#include <vtkPlane.h>
#include <vtkImplicitBoolean.h>
+#include <vtkImplicitFunctionCollection.h>
#include "utilities.h"
myBaseActor->myGeomFilter->SetInside(true);
myPickableActor = myBaseActor;
-
+
myHighlightProp = vtkProperty::New();
myHighlightProp->SetAmbient(1.0);
myHighlightProp->SetDiffuse(0.0);
}
-void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled){
+void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
+{
vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
if(myIsCellsLabeled){
setName(theName);
myVisualObj = theVisualObj;
- myNodeActor->myVisualObj = myVisualObj;
- myBaseActor->myVisualObj = myVisualObj;
-
- myHighlitableActor->myVisualObj = myVisualObj;
- myNodeHighlitableActor->myVisualObj = myVisualObj;
-
- my1DActor->myVisualObj = myVisualObj;
- my1DExtActor->myVisualObj = myVisualObj;
-
- my2DActor->myVisualObj = myVisualObj;
- my3DActor->myVisualObj = myVisualObj;
-
myVisualObj->Update(theIsClear);
myNodeActor->Init(myVisualObj,myImplicitBoolean);
my3DActor->VisibilityOn();
}
- if(myIsPointsLabeled){
+ if(myIsPointsLabeled){
myPointLabels->VisibilityOn();
myNodeActor->VisibilityOn();
}
case ePoint:
myPickableActor = myNodeActor;
myNodeActor->SetVisibility(true);
-
+
aProp = aBackProp = myNodeProp;
aReperesent = SMESH_DeviceActor::ePoint;
break;
return myVisualObj->GetElemDimension( theObjId );
}
+bool
+SMESH_ActorDef::
+IsImplicitFunctionUsed() const
+{
+ return myBaseActor->IsImplicitFunctionUsed();
+}
+
+void
+SMESH_ActorDef::
+SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
+{
+ myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ myNodeHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+
+ my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+ my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
+}
+
+vtkIdType
+SMESH_ActorDef::
+AddClippingPlane(vtkPlane* thePlane)
+{
+ if(thePlane){
+ myImplicitBoolean->GetFunction()->AddItem(thePlane);
+ myCippingPlaneCont.push_back(thePlane);
+ if(!IsImplicitFunctionUsed())
+ SetImplicitFunctionUsed(true);
+ }
+ return myCippingPlaneCont.size();
+}
+
+void
+SMESH_ActorDef::
+RemoveAllClippingPlanes()
+{
+ myImplicitBoolean->GetFunction()->RemoveAllItems();
+ myImplicitBoolean->GetFunction()->Modified(); // VTK bug
+ myCippingPlaneCont.clear();
+ SetImplicitFunctionUsed(false);
+}
-vtkImplicitBoolean* SMESH_ActorDef::GetPlaneContainer(){
- return myImplicitBoolean;
+vtkIdType
+SMESH_ActorDef::
+GetNumberOfClippingPlanes()
+{
+ return myCippingPlaneCont.size();
+}
+
+vtkPlane*
+SMESH_ActorDef::
+GetClippingPlane(vtkIdType theID)
+{
+ if(theID >= myCippingPlaneCont.size())
+ return NULL;
+ return myCippingPlaneCont[theID].Get();
}
virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane) = 0;
virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane) = 0;
- virtual vtkImplicitBoolean* GetPlaneContainer() = 0;
+ virtual void RemoveAllClippingPlanes() = 0;
+ virtual vtkIdType GetNumberOfClippingPlanes() = 0;
+ virtual vtkPlane* GetClippingPlane(vtkIdType theID) = 0;
+ virtual vtkIdType AddClippingPlane(vtkPlane* thePlane) = 0;
virtual TVisualObjPtr GetObject() = 0;
#include "SMESH_Actor.h"
#include "SMESH_Object.h"
+#include <vtkSmartPointer.h>
+
+template <class T>
+class TVTKSmartPtr: public vtkSmartPointer<T>
+{
+public:
+ TVTKSmartPtr() {}
+ TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer<T>(r) {
+ if(r && theIsOwner)
+ r->Delete();
+ }
+ TVTKSmartPtr& operator()(T* r, bool theIsOwner = false){
+ vtkSmartPointer<T>::operator=(r);
+ if(r && theIsOwner)
+ r->Delete();
+ return *this;
+ }
+ TVTKSmartPtr& operator=(T* r){ vtkSmartPointer<T>::operator=(r); return *this;}
+ T* Get() const { return GetPointer();}
+};
+
+
class vtkProperty;
class vtkShrinkFilter;
class vtkPolyDataMapper;
virtual void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane);
virtual void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane);
- virtual vtkImplicitBoolean* GetPlaneContainer();
+ virtual void RemoveAllClippingPlanes();
+ virtual vtkIdType GetNumberOfClippingPlanes();
+ virtual vtkPlane* GetClippingPlane(vtkIdType theID);
+ virtual vtkIdType AddClippingPlane(vtkPlane* thePlane);
virtual TVisualObjPtr GetObject() { return myVisualObj;}
virtual long GetControlsPrecision() const { return myControlsPrecision; }
protected:
+ void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
+ bool IsImplicitFunctionUsed() const;
+
TVisualObjPtr myVisualObj;
vtkTimeStamp* myTimeStamp;
vtkSelectVisiblePoints* myClsSelectVisiblePoints;
vtkImplicitBoolean* myImplicitBoolean;
-
+ typedef TVTKSmartPtr<vtkPlane> TPlanePtr;
+ typedef std::vector<TPlanePtr> TCippingPlaneCont;
+ TCippingPlaneCont myCippingPlaneCont;
long myControlsPrecision;
SMESH_ActorDef();
//
//
//
-// File : SMESH_Actor.cxx
-// Author : Nicolas REJNERI
+// File : SMESH_DeviceActor.cxx
+// Author :
// Module : SMESH
-// $Header$Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_DeviceActor.cxx,v 1.7 2005/02/02 12:17:51 apo Exp $
+// $Header$
#include "SMESH_DeviceActor.h"
SMESH_DeviceActor::SMESH_DeviceActor(){
- if(MYDEBUG) MESSAGE("SMESH_DeviceActor");
myIsShrunk = false;
myIsShrinkable = false;
myRepresentation = eSurface;
myShrinkFilter = vtkShrinkFilter::New();
myExtractGeometry = SMESH_ExtractGeometry::New();
+ myExtractGeometry->SetReleaseDataFlag(true);
myExtractGeometry->SetStoreMapping(true);
+ myIsImplicitFunctionUsed = false;
myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New();
myExtractUnstructuredGrid->SetStoreMapping(true);
}
+void
+SMESH_DeviceActor::
+SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
+{
+ if(myIsImplicitFunctionUsed == theIsImplicitFunctionUsed)
+ return;
+
+ int anId = 0;
+ if(theIsImplicitFunctionUsed)
+ myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
+ else
+ myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
+
+ myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
+}
+
+
void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){
if(theGrid){
//myIsShrinkable = theGrid->GetNumberOfCells() > 10;
myExtractGeometry->SetInput(myMergeFilter->GetOutput());
int anId = 0;
- myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
+ myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
anId++; // 1
}
-void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
+void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){
switch(theMode){
- case ePoint:
+ case ePoint:
myGeomFilter->SetInside(true);
GetProperty()->SetRepresentation(0);
break;
GetProperty()->SetRepresentation(1);
break;
default :
- GetProperty()->SetRepresentation(theMode);
myGeomFilter->SetInside(false);
+ GetProperty()->SetRepresentation(theMode);
}
myRepresentation = theMode;
GetProperty()->Modified();
int SMESH_DeviceActor::GetNodeObjId(int theVtkID){
- vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID);
+ vtkIdType anID = theVtkID;
+
+ if(IsImplicitFunctionUsed())
+ anID = myExtractGeometry->GetNodeObjId(theVtkID);
+
vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; aRetID = "<<aRetID);
return aRetID;
}
float* SMESH_DeviceActor::GetNodeCoord(int theObjID){
- vtkDataSet* aDataSet = myExtractGeometry->GetInput();
+ vtkDataSet* aDataSet = myMergeFilter->GetOutput();
vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
float* aCoord = aDataSet->GetPoint(anID);
if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
if(anId < 0)
return -1;
- vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId);
+
+ 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);
virtual void Render(vtkRenderer *, vtkMapper *);
+ void SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed);
+ bool IsImplicitFunctionUsed() const{ return myIsImplicitFunctionUsed;}
+
protected:
void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean);
void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid);
EReperesent myRepresentation;
SMESH_ExtractGeometry* myExtractGeometry;
+ bool myIsImplicitFunctionUsed;
vtkMergeFilter* myMergeFilter;
SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid;
}
-//=======================================================================
-// function : ClickOnApply()
-// purpose :
-//=======================================================================
void SMESHGUI_ClippingDlg::ClickOnApply()
{
if (!myActor)
if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
QAD_WaitCursor wc;
- vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
- vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
- aCollection->RemoveAllItems();
- aBoolean->Modified(); // VTK bug
- aCollection->InitTraversal();
-
+ myActor->RemoveAllClippingPlanes();
+
SMESH::TPlanes::iterator anIter = myPlanes.begin();
for (;anIter != myPlanes.end();anIter++){
OrientedPlane* anOrientedPlane = OrientedPlane::New();
anOrientedPlane->ShallowCopy(anIter->GetPointer());
- aCollection->AddItem(anOrientedPlane);
+ myActor->AddClippingPlane(anOrientedPlane);
anOrientedPlane->Delete();
}
Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject();
myActor = SMESH::FindActorByEntry(IOS->getEntry());
if ( myActor ){
- vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer();
- vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction();
- aCollection->InitTraversal();
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
myPlanes.clear();
- while(vtkImplicitFunction* aFunction = aCollection->GetNextItem()){
- if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
- OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy());
- SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
- anOrientedPlane->Delete();
- aTVTKPlane->ShallowCopy(aPlane);
- myPlanes.push_back(aTVTKPlane);
+
+ vtkIdType anId = 0, anEnd = myActor->GetNumberOfClippingPlanes();
+ for(; anId < anEnd; anId++){
+ if(vtkImplicitFunction* aFunction = myActor->GetClippingPlane(anId)){
+ if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){
+ OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy());
+ SMESH::TVTKPlane aTVTKPlane(anOrientedPlane);
+ anOrientedPlane->Delete();
+ aTVTKPlane->ShallowCopy(aPlane);
+ myPlanes.push_back(aTVTKPlane);
+ }
}
}
+
std::for_each(myPlanes.begin(),myPlanes.end(),
TSetVisiblity(PreviewCheckBox->isChecked()));
}
// function : SetCurrentPlaneParam
// purpose :
//=======================================================================
-void SMESHGUI_ClippingDlg::SetCurrentPlaneParam()
+void
+SMESHGUI_ClippingDlg::
+SetCurrentPlaneParam()
{
if(myPlanes.empty() || myIsSelectPlane)
return;