#include "VISU_PipeLine.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+#include <limits.h>
#include <vtkObjectFactory.h>
#include <vtkDataSetMapper.h>
#include <vtkUnstructuredGrid.h>
+static int MYVTKDEBUG = 0;
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
VISU_PipeLine::VISU_PipeLine(){
myMapper = TMapper::New();
myInput = NULL;
+ SetDebug(MYVTKDEBUG);
}
VISU_PipeLine::~VISU_PipeLine(){
- myMapper->Delete();
+ if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<<myInput->GetReferenceCount());
SetInput(NULL);
+ myMapper->RemoveAllInputs();
+ myMapper->Delete();
}
void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
}
void VISU_PipeLine::SetInput(TInput* theInput){
- if (myInput != theInput){
+ if(myInput != theInput){
if (myInput != NULL) myInput->UnRegister(this);
myInput = theInput;
- if (myInput != NULL) {
+ if(myInput != NULL){
myInput->Register(this);
myInput->Update();
- }
+ }else
+ myMapper->SetInput(NULL);
Modified();
}
}
myMapper->Update();
}
-
-size_t VISU_PipeLine::CheckAvailableMemory(const size_t& theSize){
+int VISU_PipeLine::CheckAvailableMemory(const float& theSize){
try{
- char *aCheck = new char[theSize];
+ if(theSize > ULONG_MAX) return 0;
+ size_t aSize = size_t(theSize);
+ char *aCheck = new char[aSize];
if(aCheck) delete [] aCheck;
if(MYDEBUG && aCheck == NULL)
- cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!\n";
+ MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
return aCheck != NULL;
//return theSize < 1000*1024*1024;
- }catch(...){
- if(MYDEBUG)
- cout<<"VISU_PipeLine::CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!\n";
+ }catch(std::bad_alloc& exc){
+ if(MYDEBUG)
+ MESSAGE("CheckAvailableMemory("<<theSize<<") " << exc.what());
+ } catch(...) {
+ if(MYDEBUG)
+ MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
}
return 0;
}
-size_t VISU_PipeLine::GetAvailableMemory(size_t theSize, size_t theMinSize){
+float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize){
while(!CheckAvailableMemory(theSize))
if(theSize > theMinSize)
theSize /= 2;