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
23 // File : VISU_Prs3d_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_PipeLine.hxx"
28 #include "VISU_Result_i.hh"
29 #include "VISU_Prs3d_i.hh"
30 #include "VISU_Actor.h"
32 #include <vtkGeometryFilter.h>
38 static int MYDEBUG = 0;
39 static int MYDEBUGWITHFILES = 0;
41 static int MYDEBUG = 0;
42 static int MYDEBUGWITHFILES = 0;
45 VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) :
46 PrsObject_i(theResult->GetStudyDocument()),
50 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
53 CORBA::String_var aName = myStudy->Name();
54 INFOS("Prs3d_i - this = "<<this<<"; StudyId = "<<myStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
57 void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin)
59 Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin);
60 myPipeLine->ShallowCopy(aOrigin->GetPL());
63 VISU::Prs3d_i::~Prs3d_i() {
64 INFOS("~Prs3d_i() - this = "<<this<<"; GetReferenceCount() = "<<myPipeLine->GetReferenceCount());
69 void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
70 throw (std::runtime_error&)
75 Handle(SALOME_InteractiveObject) anIO = theIO;
77 CORBA::String_var anEntry = mySObject->GetID();
78 anIO = new SALOME_InteractiveObject(strdup(anEntry.in()),"VISU",strdup(GetName()));
80 theActor->setIO(anIO);
82 theActor->SetPipeLine(GetPipeLine());
83 theActor->SetPrs3d(this);
84 }catch(std::runtime_error& ex){
87 throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
91 void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) throw (std::runtime_error&){
93 vtkGeometryFilter* aGeometryFilter = vtkGeometryFilter::New();
94 vtkDataSet *aDataSet = theActor->GetMapper()->GetInput();
95 aGeometryFilter->SetInput(aDataSet);
96 vtkPolyData* aPolyData = aGeometryFilter->GetOutput();
98 static int INCMEMORY = 7;
99 float aSize = INCMEMORY*aPolyData->GetActualMemorySize()*1024.0;
100 int isPoss = VISU_PipeLine::CheckAvailableMemory(aSize);
101 INFOS("UpdateActor - aSize = "<<aSize<<"; isPoss = "<<isPoss);
104 throw std::runtime_error("Prs3d_i::UpdateActor >> Actor is empty !!!");
106 throw std::runtime_error("Prs3d_i::UpdateActor >> There is no enough memory !!!");
108 theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
109 theActor->Modified();
110 }catch(std::runtime_error& ex){
113 throw std::runtime_error("Prs3d_i::UpdateActor >> unexpected exception was caught!!!");
117 VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap)
118 throw(std::logic_error&)
120 myName = VISU::Storable::FindValue(theMap,"myName").latin1();
124 void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){
125 Storable::DataToStream( theStr, "myName", myName.c_str() );
128 void VISU::Prs3d_i::Update() throw (std::runtime_error&){
130 myPipeLine->Update();
132 throw std::runtime_error("Prs3d_i::Update >> unexpected exception was caught!!!");
136 VISU_PipeLine* VISU::Prs3d_i::GetPipeLine(){
140 VISU_PipeLine* VISU::Prs3d_i::GetPL(){
145 SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){
149 void VISU::Prs3d_i::GetBounds(float aBounds[6]){
150 myPipeLine->GetMapper()->GetBounds(aBounds);
153 VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_ptr theSObject){
154 VISU::Result_var aResult = FindResult(theSObject);
155 if(!aResult->_is_nil())
156 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());