#include "VISU_Result_i.hh"
#include "VISU_Prs3d_i.hh"
#include "VISU_Actor.h"
+
+#include <vtkGeometryFilter.h>
+#include <vtkDataSetMapper.h>
+
using namespace VISU;
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 1;
-static int MYDEBUGWITHFILES = 0;
+static int MYDEBUG = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
-VISU::Prs3d_i::Prs3d_i(Result_i* theResult) :
- PrsObject_i(theResult->GetStudyDocument()),
- myResult(theResult)
+VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) :
+ PrsObject_i(theResult->GetStudyDocument()),
+ myResult(theResult)
{
+ myResult->Register();
+ mySObject = SALOMEDS::SObject::_duplicate(theSObject);
myAddToStudy = true;
myPipeLine = NULL;
+ CORBA::String_var aName = myStudy->Name();
+ if(MYDEBUG) MESSAGE("Prs3d_i - this = "<<this<<"; StudyId = "<<myStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
}
void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin)
}
VISU::Prs3d_i::~Prs3d_i() {
- if(MYDEBUG) MESSAGE("Prs3d_i::~Prs3d_i()");
+ if(MYDEBUG) MESSAGE("~Prs3d_i() - this = "<<this<<"; GetReferenceCount() = "<<myPipeLine->GetReferenceCount());
myPipeLine->Delete();
+ myResult->Destroy();
}
-void VISU::Prs3d_i::Destroy() {
- CORBA::Object_var anObj = _this();
- PortableServer::POA_ptr aPOA = Base_i::GetPOA();
- PortableServer::ObjectId_var anId = aPOA->reference_to_id(anObj);
- aPOA->deactivate_object(anId.in());
- this->_remove_ref();
-}
-
-
void VISU::Prs3d_i::CreateActor(VISU_Actor* theActor, const Handle(SALOME_InteractiveObject)& theIO)
- throw (std::runtime_error&)
{
try{
Update();
if(myAddToStudy){
Handle(SALOME_InteractiveObject) anIO = theIO;
- if (anIO.IsNull())
- anIO = new SALOME_InteractiveObject(strdup(GetEntry()),"VISU",strdup(GetName()));
+ if(anIO.IsNull()){
+ anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
+ }
theActor->setIO(anIO);
}
theActor->SetPipeLine(GetPipeLine());
theActor->SetPrs3d(this);
- }catch(std::runtime_error& ex){
+ }catch(std::bad_alloc& ex){
+ throw std::runtime_error("CreateActor >> No enough memory");
throw ex;
- }catch(...){
- throw std::runtime_error("Prs3d_i::CreateActor >> unexpected exception was caught!!!");
- }
+ } catch(std::exception& ex){
+ throw ex;
+ }catch(...) {
+ throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
+ }
}
-void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor){
+void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) {
+ if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<<this);
theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
theActor->Modified();
}
VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap)
- throw(std::logic_error&)
{
myName = VISU::Storable::FindValue(theMap,"myName").latin1();
return this;
Storable::DataToStream( theStr, "myName", myName.c_str() );
}
-void VISU::Prs3d_i::Update(){
- myPipeLine->Update();
+void VISU::Prs3d_i::Update() {
+ if(MYDEBUG) MESSAGE("Prs3d_i::Update() - this = "<<this);
+ try{
+ myPipeLine->Update();
+ }catch(...){
+ throw std::runtime_error("Prs3d_i::Update >> unexpected exception was caught!!!");
+ }
}
VISU_PipeLine* VISU::Prs3d_i::GetPipeLine(){
return myPipeLine;
}
-VISU::Result_i* VISU::Prs3d_i::GetResult(SALOMEDS::SObject_ptr theSObject){
+
+SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){
+ return mySObject;
+}
+
+void VISU::Prs3d_i::GetBounds(float aBounds[6]){
+ myPipeLine->GetMapper()->GetBounds(aBounds);
+}
+
+VISU::Result_i* VISU::GetResult(SALOMEDS::SObject_ptr theSObject){
VISU::Result_var aResult = FindResult(theSObject);
if(!aResult->_is_nil())
- return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()));
+ return dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
return NULL;
}