// VISU OBJECT : interactive object for VISU entities implementation
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
//
//
// File : VISU_Prs3d_i.cc
#include "VISU_Actor.h"
#include <vtkGeometryFilter.h>
+#include <vtkDataSetMapper.h>
using namespace VISU;
using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#else
static int MYDEBUG = 0;
-static int MYDEBUGWITHFILES = 0;
#endif
-VISU::Prs3d_i::Prs3d_i(Result_i* theResult, SALOMEDS::SObject_ptr theSObject) :
- PrsObject_i(theResult->GetStudyDocument()),
- myResult(theResult)
+VISU::Prs3d_i::
+Prs3d_i(Result_i* theResult,
+ SALOMEDS::SObject_ptr theSObject) :
+ PrsObject_i(theResult->GetStudyDocument()),
+ myResult(theResult),
+ mySObject(SALOMEDS::SObject::_duplicate(theSObject)),
+ myAddToStudy(true),
+ myPipeLine(NULL)
+{
+ myOffset[0] = myOffset[1] = myOffset[2] = 0;
+ myResult->Register();
+}
+
+VISU::Prs3d_i::
+Prs3d_i(Result_i* theResult,
+ bool theAddToStudy) :
+ PrsObject_i(theResult->GetStudyDocument()),
+ myResult(theResult),
+ mySObject(SALOMEDS::SObject::_nil()),
+ myAddToStudy(theAddToStudy),
+ myPipeLine(NULL)
{
+ myOffset[0] = myOffset[1] = myOffset[2] = 0;
myResult->Register();
- mySObject = SALOMEDS::SObject::_duplicate(theSObject);
- myAddToStudy = true;
- myPipeLine = NULL;
- CORBA::String_var aName = myStudy->Name();
- INFOS("Prs3d_i - this = "<<this<<"; StudyId = "<<myStudy->StudyId()<<"; Name = '"<<aName.in()<<"'");
}
void VISU::Prs3d_i::SameAs(const Prs3d_i* theOrigin)
{
- Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin);
- myPipeLine->ShallowCopy(aOrigin->GetPL());
+ if (Prs3d_i* aOrigin = const_cast<Prs3d_i*>(theOrigin)) {
+ myPipeLine->SameAs(aOrigin->GetPL());
+ aOrigin->GetOffset(myOffset);
+ }
}
VISU::Prs3d_i::~Prs3d_i() {
- INFOS("~Prs3d_i() - this = "<<this<<"; GetReferenceCount() = "<<myPipeLine->GetReferenceCount());
+ if(MYDEBUG) MESSAGE("~Prs3d_i() - this = "<<this
+ <<"; GetReferenceCount() = "<<myPipeLine->GetReferenceCount());
myPipeLine->Delete();
myResult->Destroy();
}
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()){
- CORBA::String_var anEntry = mySObject->GetID();
- anIO = new SALOME_InteractiveObject(strdup(anEntry.in()),"VISU",strdup(GetName()));
- }
- theActor->setIO(anIO);
+ // if(myAddToStudy){
+ Handle(SALOME_InteractiveObject) anIO = theIO;
+ if(anIO.IsNull() && (!mySObject->_is_nil())){
+ anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
+ theActor->setIO(anIO);
}
+ // }
theActor->SetPipeLine(GetPipeLine());
theActor->SetPrs3d(this);
- }catch(std::runtime_error& ex){
+ theActor->SetPosition(myOffset);
+ }catch(std::bad_alloc& ex){
+ throw std::runtime_error("CreateActor >> No enough memory");
throw ex;
- }catch(...){
+ } catch(std::exception& ex){
+ throw ex;
+ }catch(...) {
throw std::runtime_error("CreateActor >> unexpected exception was caught!!!");
}
}
-void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) throw (std::runtime_error&){
- try{
- vtkGeometryFilter* aGeometryFilter = vtkGeometryFilter::New();
- vtkDataSet *aDataSet = theActor->GetMapper()->GetInput();
- aGeometryFilter->SetInput(aDataSet);
- vtkPolyData* aPolyData = aGeometryFilter->GetOutput();
- aPolyData->Update();
- static int INCMEMORY = 7;
- float aSize = INCMEMORY*aPolyData->GetActualMemorySize()*1024.0;
- int isPoss = VISU_PipeLine::CheckAvailableMemory(aSize);
- INFOS("UpdateActor - aSize = "<<aSize<<"; isPoss = "<<isPoss);
- aPolyData->Delete();
- if (aSize <= 0)
- throw std::runtime_error("Prs3d_i::UpdateActor >> Actor is empty !!!");
- if(!isPoss)
- throw std::runtime_error("Prs3d_i::UpdateActor >> There is no enough memory !!!");
-
- theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
- theActor->Modified();
- }catch(std::runtime_error& ex){
- throw ex;
- }catch(...){
- throw std::runtime_error("Prs3d_i::UpdateActor >> unexpected exception was caught!!!");
- }
+void VISU::Prs3d_i::UpdateActor(VISU_Actor* theActor) {
+ if(MYDEBUG) MESSAGE("Prs3d_i::UpdateActor() - this = "<<this);
+ theActor->GetMapper()->ShallowCopy(myPipeLine->GetMapper());
+ theActor->SetPosition(myOffset);
+ theActor->Modified();
}
VISU::Storable* VISU::Prs3d_i::Restore(const Storable::TRestoringMap& theMap)
- throw(std::logic_error&)
{
myName = VISU::Storable::FindValue(theMap,"myName").latin1();
+ myOffset[0] = VISU::Storable::FindValue(theMap,"myOffset[0]").toFloat();
+ myOffset[1] = VISU::Storable::FindValue(theMap,"myOffset[1]").toFloat();
+ myOffset[2] = VISU::Storable::FindValue(theMap,"myOffset[2]").toFloat();
return this;
}
void VISU::Prs3d_i::ToStream(std::ostringstream& theStr){
Storable::DataToStream( theStr, "myName", myName.c_str() );
+ Storable::DataToStream( theStr, "myOffset[0]", myOffset[0] );
+ Storable::DataToStream( theStr, "myOffset[1]", myOffset[1] );
+ Storable::DataToStream( theStr, "myOffset[2]", myOffset[2] );
}
-void VISU::Prs3d_i::Update() throw (std::runtime_error&){
+void VISU::Prs3d_i::Update() {
+ if(MYDEBUG) MESSAGE("Prs3d_i::Update() - this = "<<this);
try{
myPipeLine->Update();
}catch(...){
return myPipeLine;
}
+vtkUnstructuredGrid* VISU::Prs3d_i::GetInput(){
+ return myPipeLine->GetInput();
+}
+
SALOMEDS::SObject_var VISU::Prs3d_i::GetSObject(){
+ if (CORBA::is_nil(mySObject.in())) {
+ const SALOMEDS::Study_var& aStudy = myResult->GetStudyDocument();
+ CORBA::String_var anIOR = GetID();
+ mySObject = aStudy->FindObjectIOR(anIOR);
+ }
return mySObject;
}
myPipeLine->GetMapper()->GetBounds(aBounds);
}
+// Clipping planes
+
+void VISU::Prs3d_i::RemoveAllClippingPlanes(){
+ myPipeLine->RemoveAllClippingPlanes();
+}
+
+vtkIdType VISU::Prs3d_i::GetNumberOfClippingPlanes() const{
+ return myPipeLine->GetNumberOfClippingPlanes();
+}
+
+bool VISU::Prs3d_i::AddClippingPlane(vtkPlane* thePlane){
+ return myPipeLine->AddClippingPlane(thePlane);
+}
+
+vtkPlane* VISU::Prs3d_i::GetClippingPlane(vtkIdType theID) const{
+ return myPipeLine->GetClippingPlane(theID);
+}
+
+void VISU::Prs3d_i::SetPlaneParam (float theDir[3], float theDist, vtkPlane* thePlane) {
+ myPipeLine->SetPlaneParam(theDir, theDist, thePlane);
+}
+
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()).in());
return NULL;
}
+
+void VISU::Prs3d_i::SetOffset(const float* theOffsets)
+{
+ myOffset[0] = theOffsets[0];
+ myOffset[1] = theOffsets[1];
+ myOffset[2] = theOffsets[2];
+}
+
+void VISU::Prs3d_i::SetOffset(float theDx, float theDy, float theDz)
+{
+ myOffset[0] = theDx;
+ myOffset[1] = theDy;
+ myOffset[2] = theDz;
+}
+
+void VISU::Prs3d_i::GetOffset(float* theOffsets)
+{
+ theOffsets[0] = myOffset[0];
+ theOffsets[1] = myOffset[1];
+ theOffsets[2] = myOffset[2];
+}
+void VISU::Prs3d_i::GetOffset(float& theDx, float& theDy, float& theDz)
+{
+ theDx = myOffset[0];
+ theDy = myOffset[1];
+ theDz = myOffset[2];
+}