1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File: VISU_PipeLine.cxx
25 // Author: Alexey PETROV
29 #include "VISU_PipeLine.hxx"
30 #include "VISU_PipeLineUtils.hxx"
34 #include <vtkObjectFactory.h>
35 #include <vtkDataSetMapper.h>
36 #include <vtkUnstructuredGrid.h>
38 static int MYVTKDEBUG = 0;
41 static int MYDEBUG = 0;
42 static int MYDEBUGWITHFILES = 0;
44 static int MYDEBUG = 0;
45 static int MYDEBUGWITHFILES = 0;
48 VISU_PipeLine::VISU_PipeLine(){
49 myMapper = TMapper::New();
54 VISU_PipeLine::~VISU_PipeLine(){
55 if(MYDEBUG) MESSAGE("~VISU_PipeLine - myInput = "<<myInput->GetReferenceCount());
57 myMapper->RemoveAllInputs();
61 void VISU_PipeLine::ShallowCopy(VISU_PipeLine *thePipeLine){
62 SetInput(thePipeLine->GetInput());
63 myMapper->ShallowCopy(thePipeLine->GetMapper());
67 void VISU_PipeLine::SetInput(TInput* theInput){
68 if(myInput != theInput){
69 if (myInput != NULL) myInput->UnRegister(this);
72 myInput->Register(this);
75 myMapper->SetInput(NULL);
80 VISU_PipeLine::TMapper* VISU_PipeLine::GetMapper() {
82 if(!myMapper->GetInput()){
91 void VISU_PipeLine::Update(){
95 int VISU_PipeLine::CheckAvailableMemory(const float& theSize){
97 if(theSize > ULONG_MAX) return 0;
98 size_t aSize = size_t(theSize);
99 char *aCheck = new char[aSize];
100 if(aCheck) delete [] aCheck;
101 if(MYDEBUG && aCheck == NULL)
102 MESSAGE("CheckAvailableMemory("<<theSize<<") - cannot alloacate such amount of memory!!!");
103 return aCheck != NULL;
104 //return theSize < 1000*1024*1024;
105 }catch(std::bad_alloc& exc){
107 MESSAGE("CheckAvailableMemory("<<theSize<<") " << exc.what());
110 MESSAGE("CheckAvailableMemory("<<theSize<<") - unexpected exception was caught!!!");
116 float VISU_PipeLine::GetAvailableMemory(float theSize, float theMinSize){
117 while(!CheckAvailableMemory(theSize))
118 if(theSize > theMinSize)