};
+ //-------------------------------------------------------
+ /*! \brief Deformation interface
+ *
+ * This is base interface for building of the deformed presentations
+ */
+ interface Deformation{
+ /*!
+ * Sets the scale of the presentatable object.
+ * \param theScale Double value defining the scale of this presentable object.
+ */
+ void SetScale(in double theScale);
+
+ /*!
+ * Gets the scale of the presentatable object.
+ */
+ double GetScale();
+
+ /*!
+ * Sets the vectorial field
+ * \param theEntity - entity of vectorial field
+ * \param theFieldName - the name of vectorial field
+ */
+ void SetVectorialField(in Entity theEntity,
+ in string theFieldName);
+
+ /*!
+ * Get vectorial entity
+ */
+ Entity GetVectorialFieldEntity();
+
+ /*!
+ * Get scalar field name
+ */
+ string GetVectorialFieldName();
+
+ };
+
+ //-------------------------------------------------------
+ /*! \brief OptionalDeformation interface
+ *
+ * This is interface for switch on/off of the deformation of the presentation
+ */
+ interface OptionalDeformation : Deformation{
+
+ /*!
+ * Sets the deformation flag of the presentatable object.
+ * \param theFlag Boolean value defining the deformation flag of this presentable object.
+ */
+ void UseDeformation(in boolean theFlag);
+
+ /*!
+ * Gets the deformation flag of the presentatable object.
+ */
+ boolean IsDeformed();
+ };
//-------------------------------------------------------
/*! \brief Scalar Map on Deformed shape presentation interface
* consists of cutting your initial mesh by a definite number of planes. As the
* result you will see these planes which will be cutted by the borders of the mesh.
*/
- interface CutPlanes : ScalarMap {
+ interface CutPlanes : ScalarMap, OptionalDeformation {
/*!
* This enumeration contains a set of elements defining the type of orientation in 3D space
* of the cut planes.
vtkCellData *anOutputCellData = theOutput->GetCellData();
anOutputCellData->CopyAllocate(aCellData);
+ if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet)
+ anOutputCellData->CopyVectorsOff();
+
vtkIdType aNbTuples = anIntersection.size();
theOutput->Allocate(aNbTuples);
vtkIdList *aCellIds = vtkIdList::New();
aCellIds->Delete();
theOutput->SetPoints(theInput->GetPoints());
+
}else{
theOutput->CopyStructure(theInput);
theOutput->GetCellData()->ShallowCopy(theScalarsDataSet->GetCellData());
}
theOutput->GetPointData()->ShallowCopy(theInput->GetPointData());
+
+ //If need, copy vectors data.
+ if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
+ bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
+ bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
+ if(isVectorsOnCells) {
+ CopyVectorsOnCells(theVectorsDataSet,theOutput);
+ }
+ else if(isVectorsDataOnPoints){
+ CopyVectorsOnPoints(theVectorsDataSet,theOutput);
+ }
+ }
}
+ void CopyVectorsOnCells(vtkDataSet *theVectorsDataSet,
+ vtkDataSet *theOutput)
+ {
+ vtkDataArray *anInputVectors = theVectorsDataSet->GetCellData()->GetVectors();
+ vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+
+ //Clear output vector data
+ theOutput->GetCellData()->SetVectors(NULL);
+
+ //Copy vectors data
+ vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ TObjectIdArray anIntersection;
+ GetIntersection(anOutputIDMapper,
+ anInputIDMapper,
+ anIntersection);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+ anOutputVectors->SetNumberOfTuples(aNbTuples);
+ theOutput->GetCellData()->SetVectors(anOutputVectors);
+ anOutputVectors->Delete();
+
+ TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+
+ for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+ TObjectId &anObjectId = anIntersection[iTupleId];
+ vtkIdType anOutputCellId = anOutputObjectId2TupleIdMap[anObjectId];
+ vtkIdType anInputCellId = anInputObjectId2TupleIdMap[anObjectId];
+ anOutputVectors->SetTuple(anOutputCellId,anInputVectors->GetTuple(anInputCellId));
+ }
+ }
//---------------------------------------------------------------
template<class TDataSet>
theOutput->GetCellData()->ShallowCopy(theInput->GetCellData());
}
theOutput->GetPointData()->ShallowCopy(theScalarsDataSet->GetPointData());
+
+ //If need, copy vectors data.
+ if(theVectorsDataSet && theVectorsDataSet != theScalarsDataSet){
+ bool isVectorsOnCells = theVectorsDataSet->GetCellData()->GetVectors() != NULL;
+ bool isVectorsDataOnPoints = theVectorsDataSet->GetPointData()->GetVectors() != NULL;
+
+ //Merge cells if need
+ //rnv
+ if(!IsDifferent(theGeometryPointMapper, theDataPointMapper)){
+ vtkIntArray* theGeometryCellMapper = GetIDMapper(theVectorsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+ vtkIntArray* theDataCellMapper = GetIDMapper(theScalarsDataSet,
+ TGetCellData(),
+ "VISU_CELLS_MAPPER");
+
+
+ if(IsDifferent(theGeometryCellMapper, theDataCellMapper)){
+ TObjectIdArray anIntersection;
+
+ GetIntersection(theGeometryCellMapper,
+ theDataCellMapper,
+ anIntersection);
+
+ TObjectId2TupleIdMap aGeomObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theGeometryCellMapper, aGeomObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap aDataObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(theDataCellMapper, aDataObjectId2TupleIdMap);
+
+ vtkCellData *aCellData = theScalarsDataSet->GetCellData();
+ vtkCellData *anOutputCellData = theOutput->GetCellData();
+ anOutputCellData->CopyAllocate(aCellData);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ theOutput->Allocate(aNbTuples);
+ vtkIdList *aCellIds = vtkIdList::New();
+ for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
+ TObjectId& anObjectId = anIntersection[aTupleId];
+ vtkIdType aCellId = aGeomObjectId2TupleIdMap[anObjectId];
+ vtkCell *aCell = theInput->GetCell(aCellId);
+ aCellIds->Reset();
+ vtkIdType aNbPointIds = aCell->PointIds->GetNumberOfIds();
+ for(vtkIdType anId = 0; anId < aNbPointIds; anId++)
+ aCellIds->InsertNextId(aCell->GetPointIds()->GetId(anId));
+ vtkIdType aCellType = theInput->GetCellType(aCellId);
+ vtkIdType aNewCellId = theOutput->InsertNextCell(aCellType, aCellIds);
+ vtkIdType aDataCellId = aDataObjectId2TupleIdMap[anObjectId];
+ anOutputCellData->CopyData(aCellData, aDataCellId, aNewCellId);
+ }
+ aCellIds->Delete();
+
+ }
+ }
+
+ if(isVectorsOnCells) {
+ CopyVectorsOnCells(theVectorsDataSet,theOutput);
+ }
+ else if(isVectorsDataOnPoints){
+ CopyVectorsOnPoints(theVectorsDataSet,theOutput);
+ }
+ }
}
+
+ void CopyVectorsOnPoints(vtkDataSet *theVectorsDataSet,
+ vtkDataSet *theOutput)
+ {
+ vtkDataArray *anInputVectors = theVectorsDataSet->GetPointData()->GetVectors();
+
+ //Clear output vector data
+ theOutput->GetPointData()->SetVectors(NULL);
+
+ vtkDataArray *anOutputVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
+
+ //Copy vectors data
+ vtkIntArray* anOutputIDMapper = GetIDMapper(theOutput,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+
+ vtkIntArray* anInputIDMapper = GetIDMapper(theVectorsDataSet,
+ TGetPointData(),
+ "VISU_POINTS_MAPPER");
+ TObjectIdArray anIntersection;
+
+ GetIntersection(anOutputIDMapper,
+ anInputIDMapper,
+ anIntersection);
+
+ vtkIdType aNbTuples = anIntersection.size();
+ anOutputVectors->SetNumberOfComponents(anInputVectors->GetNumberOfComponents());
+ anOutputVectors->SetNumberOfTuples(aNbTuples);
+
+
+
+ TObjectId2TupleIdMap anOutputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anOutputIDMapper, anOutputObjectId2TupleIdMap);
+
+ TObjectId2TupleIdMap anInputObjectId2TupleIdMap;
+ GetObjectId2TupleIdMap(anInputIDMapper, anInputObjectId2TupleIdMap);
+
+ for(vtkIdType iTupleId = 0; iTupleId < aNbTuples; iTupleId++ ){
+ TObjectId& anObjectId = anIntersection[iTupleId];
+ vtkIdType anOutputPointId = anOutputObjectId2TupleIdMap[anObjectId];
+ vtkIdType anInputPointId = anInputObjectId2TupleIdMap[anObjectId];
+ anOutputVectors->SetTuple(anOutputPointId,anInputVectors->GetTuple(anInputPointId));
+ }
+
+ theOutput->GetPointData()->SetVectors(anOutputVectors);
+ anOutputVectors->Delete();
+ }
+
//---------------------------------------------------------------
typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
VISU_WidgetCtrl.hxx \
VISU_DeformedShapeAndScalarMapPL.hxx \
VISUPipeline.hxx \
- VISU_LabelPointsFilter.hxx
+ VISU_LabelPointsFilter.hxx \
+ VISU_DeformationPL.hxx \
+ VISU_OptionalDeformationPL.hxx
dist_libVisuPipeLine_la_SOURCES= \
VISU_MapperHolder.cxx \
VISU_WidgetCtrl.cxx \
VISU_ScalarBarCtrl.cxx \
VISU_DeformedShapeAndScalarMapPL.cxx \
- VISU_LabelPointsFilter.cxx
+ VISU_LabelPointsFilter.cxx \
+ VISU_DeformationPL.cxx \
+ VISU_OptionalDeformationPL.cxx
libVisuPipeLine_la_CPPFLAGS= \
$(VTK_INCLUDES) \
Modified();
}
+vtkDataSet*
+VISU_CutLinesPL
+::InsertCustomPL()
+{
+ return myAppendPolyData->GetOutput();
+}
//----------------------------------------------------------------------------
vtkFloatingPointType
void
Init();
+ vtkDataSet*
+ InsertCustomPL();
+
virtual
void
Update();
#include "VISU_FieldTransform.hxx"
#include "VISU_PipeLineUtils.hxx"
#include "VTKViewer_GeometryFilter.h"
+#include "VISU_MapperHolder.hxx"
+#include "VISU_DeformationPL.hxx"
#include <vtkAppendPolyData.h>
#include <vtkCutter.h>
#include <vtkPlane.h>
+//#include <vtkUnstructuredGrid.h>
+
static vtkFloatingPointType EPS = 1.0E-3;
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
//----------------------------------------------------------------------------
vtkStandardNewMacro(VISU_CutPlanesPL);
//----------------------------------------------------------------------------
VISU_CutPlanesPL
-::VISU_CutPlanesPL()
+::VISU_CutPlanesPL():
+ VISU_OptionalDeformationPL()
{
SetIsShrinkable(false);
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0;
+ UseDeformation(false);
}
::GetMTime()
{
unsigned long int aTime = Superclass::GetMTime();
-
+
+ if(IsDeformed()) {
+ aTime = std::max(aTime, VISU_OptionalDeformationPL::GetMTime());
+ }
+
aTime = std::max(aTime, myAppendPolyData->GetMTime());
return aTime;
::Init()
{
Superclass::Init();
-
SetNbParts(10);
myBasePlane[0] = YZ;
myDisplacement[0] = 0.5;
myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0;
+ SetScale(VISU_DeformationPL::GetDefaultScaleFactor(this));
}
VISU_CutPlanesPL
::InsertCustomPL()
{
- return myAppendPolyData->GetOutput();
+ return GetWarpVectorOutput();
}
{
ClearAppendPolyData(myAppendPolyData);
- SetPartPosition();
+ if(!myVectorialField || !IsDeformed()){
+ SetMergeFilterInput(GetMergedInput(),GetMergedInput());
+ }
+
+
+ if(VISU::IsDataOnCells(GetMergedInput()))
+ GetMapper()->SetScalarModeToUseCellData();
+ else
+ GetMapper()->SetScalarModeToUsePointData();
+
+ SetPartPosition();
+
vtkFloatingPointType aDir[3];
GetDir(aDir,
myAng[0],
myBasePlane[0]);
-
+
vtkFloatingPointType aBounds[6];
- GetMergedInput()->GetBounds(aBounds);
+
+ GetMergeFilterOutput()->GetBounds(aBounds);
CutWithPlanes(myAppendPolyData,
- GetMergedInput(),
+ GetMergeFilterOutput(),
myNbParts,
aDir,
aBounds,
myPartCondition,
myDisplacement[0]);
+
+
+ SetWarpVectorInput(myAppendPolyData->GetOutput());
Superclass::Update();
}
vtkFloatingPointType aPosition = myPartPosition[thePartNumber];
if(myPartCondition[thePartNumber]){
vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3];
- GetMergedInput()->GetBounds(aBounds);
+ if(!IsDeformed())
+ GetMergedInput()->GetBounds(aBounds);
+ else
+ GetMergeFilterOutput()->GetBounds(aBounds);
+
GetDir(aDir,
myAng[theNum],
//----------------------------------------------------------------------------
+
+void
+VISU_CutPlanesPL::SetVectorialField(VISU::PUnstructuredGridIDMapper theMapper)
+{
+ if(myVectorialField == theMapper)
+ return;
+
+ if(CheckCanDeformate(theMapper->GetOutput())){
+ myVectorialField = theMapper;
+
+ SetMergeFilterInput(GetMergedInput(),theMapper->GetOutput());
+ }
+ else
+ UseDeformation(false);
+
+ Modified();
+}
+
+VISU::PUnstructuredGridIDMapper VISU_CutPlanesPL::
+getVectorialField()
+{
+ return myVectorialField;
+}
#include "VISUPipeline.hxx"
#include "VISU_ScalarMapPL.hxx"
+#include "VISU_OptionalDeformationPL.hxx"
+#include "VISU_MapperHolder.hxx"
#include <vector>
//----------------------------------------------------------------------------
-class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL
+class VISU_PIPELINE_EXPORT VISU_CutPlanesPL : public VISU_ScalarMapPL,
+ public VISU_OptionalDeformationPL
{
public:
vtkTypeMacro(VISU_CutPlanesPL, VISU_ScalarMapPL);
const std::vector<int>& thePlaneCondition,
vtkFloatingPointType theDisplacement);
+ virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper);
+ VISU::PUnstructuredGridIDMapper getVectorialField();
+
protected:
VISU_CutPlanesPL();
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File: VISU_ScalarMapPL.cxx
+// Author: Roman NIKOLAEV
+// Module : VISU
+
+//Salome includes
+#include "VISU_DeformationPL.hxx"
+#include "VISU_MergeFilter.hxx"
+
+//VTK includes
+#include <vtkDataSet.h>
+#include <vtkPassThroughFilter.h>
+#include <vtkWarpVector.h>
+#include <vtkCellDataToPointData.h>
+#include <vtkUnstructuredGrid.h>
+
+
+//----------------------------------------------------------------------------
+VISU_DeformationPL::VISU_DeformationPL()
+{
+ myWarpVector = vtkWarpVector::New();
+ myWarpVector->SetScaleFactor(0.0);
+
+ myVectorMergeFilter = VISU_MergeFilter::New();
+ myVectorMergeFilter->SetMergingInputs(true);
+ myInputPassFilter = vtkPassThroughFilter::New();
+ myOutputPassFiler = vtkPassThroughFilter::New();
+ myCellDataToPointData = vtkCellDataToPointData::New();
+ myCellDataToPointData->PassCellDataOn();
+
+ myInputPassFilter->SetInput(vtkUnstructuredGrid::New());
+
+ myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
+
+ myWarpVector->SetInput(myCellDataToPointData->GetOutput());
+
+ myOutputPassFiler->SetInput(myWarpVector->GetOutput());
+}
+
+//----------------------------------------------------------------------------
+VISU_DeformationPL::~VISU_DeformationPL()
+{
+ myWarpVector->Delete();
+ myVectorMergeFilter->Delete();
+ myInputPassFilter->Delete();
+ myOutputPassFiler->Delete();
+ myCellDataToPointData->Delete();
+}
+
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_DeformationPL::GetMTime(){
+ unsigned long int aTime = std::max(myWarpVector->GetMTime(),
+ myVectorMergeFilter->GetMTime());
+
+ aTime = std::max(aTime,myInputPassFilter->GetMTime());
+ aTime = std::max(aTime,myOutputPassFiler->GetMTime());
+ aTime = std::max(aTime,myCellDataToPointData->GetMTime());
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetScale(vtkFloatingPointType theScaleFactor)
+{
+ myWarpVector->SetScaleFactor(theScaleFactor);
+}
+
+vtkFloatingPointType VISU_DeformationPL::GetScale()
+{
+ return myWarpVector->GetScaleFactor();
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetWarpVectorInput(vtkDataSet *theInput)
+{
+ myInputPassFilter->SetInput(theInput);
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet* VISU_DeformationPL::GetWarpVectorOutput()
+{
+ return myOutputPassFiler->GetOutput();
+}
+
+//----------------------------------------------------------------------------
+void VISU_DeformationPL::SetMergeFilterInput(vtkDataSet* ScalarInput,
+ vtkDataSet* VectorialInput)
+{
+ myVectorMergeFilter->SetScalars(ScalarInput);
+ myVectorMergeFilter->AddField("VISU_CELLS_MAPPER",ScalarInput);
+ myVectorMergeFilter->AddField("VISU_POINTS_MAPPER",ScalarInput);
+
+ myVectorMergeFilter->SetGeometry(VectorialInput);
+ myVectorMergeFilter->SetVectors(VectorialInput);
+}
+
+//----------------------------------------------------------------------------
+vtkDataSet* VISU_DeformationPL::GetMergeFilterOutput(){
+ return myVectorMergeFilter->GetOutput();
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType VISU_DeformationPL::GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine)
+{
+ if(!thePipeLine || !thePipeLine->GetMergeFilterOutput())
+ return 0.0;
+
+ vtkFloatingPointType aSourceRange[2];
+ thePipeLine->GetMergeFilterOutput()->GetScalarRange(aSourceRange);
+
+ static vtkFloatingPointType EPS = 1.0 / VTK_LARGE_FLOAT;
+ if(fabs(aSourceRange[1]) > EPS){
+ vtkDataSet* aDataSet = thePipeLine->GetMergeFilterOutput();
+ vtkFloatingPointType aScaleFactor = VISU_DeformationPL::ComputeScaleFactor(aDataSet);
+ return aScaleFactor / aSourceRange[1];
+ }
+ return 0.0;
+}
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType VISU_DeformationPL::ComputeScaleFactor(vtkDataSet* theDataSet)
+{
+ if(!theDataSet)
+ return 0.0;
+
+ theDataSet->Update();
+
+ int aNbCells = theDataSet->GetNumberOfCells();
+ int aNbPoints = theDataSet->GetNumberOfPoints();
+ int aNbElem = aNbCells? aNbCells: aNbPoints;
+
+ vtkFloatingPointType* aBounds = theDataSet->GetBounds();
+ vtkFloatingPointType aVolume = 1, aVol, idim = 0;
+ for(int i = 0; i < 6; i += 2){
+ aVol = fabs(aBounds[i+1] - aBounds[i]);
+ if(aVol > 0) {
+ idim++;
+ aVolume *= aVol;
+ }
+ }
+ aVolume /= aNbElem;
+ return pow(aVolume, vtkFloatingPointType(1.0/idim));
+}
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VISU_DeformationPL.hxx
+// Author :
+// Module : SALOME
+
+#ifndef VISU_DeformationPL_HeaderFile
+#define VISU_DeformationPL_HeaderFile
+
+#include "VISUPipeline.hxx"
+#include "VISU_MapperHolder.hxx"
+#include <vtkSmartPointer.h>
+
+class vtkDataSet;
+class VISU_MergeFilter;
+class vtkPassThroughFilter;
+class vtkWarpVector;
+class vtkCellDataToPointData;
+
+class VISU_PIPELINE_EXPORT VISU_DeformationPL {
+
+public:
+ VISU_DeformationPL();
+ virtual ~VISU_DeformationPL();
+
+ //-----------------------------------------------------------
+ virtual void SetScale(vtkFloatingPointType theScaleFactor);
+ virtual vtkFloatingPointType GetScale();
+
+ //-----------------------------------------------------------
+ virtual void SetVectorialField(VISU::PUnstructuredGridIDMapper theIdMapper) = 0;
+ virtual VISU::PUnstructuredGridIDMapper getVectorialField() = 0;
+
+
+ //-----------------------------------------------------------
+ virtual
+ unsigned
+ long int
+ GetMTime();
+
+ static vtkFloatingPointType GetDefaultScaleFactor(VISU_DeformationPL *thePipeLine);
+ static vtkFloatingPointType ComputeScaleFactor(vtkDataSet* theDataSet);
+
+ void SetWarpVectorInput(vtkDataSet *theInput);
+ vtkDataSet* GetWarpVectorOutput();
+
+ //-----------------------------------------------------------
+ void SetMergeFilterInput(vtkDataSet* ScalarInput,
+ vtkDataSet* VectorialInput);
+
+ vtkDataSet* GetMergeFilterOutput();
+
+protected:
+
+ VISU::PUnstructuredGridIDMapper myVectorialField;
+ vtkWarpVector *myWarpVector;
+ vtkSmartPointer<VISU_MergeFilter> myVectorMergeFilter;
+ vtkPassThroughFilter *myInputPassFilter;
+ vtkPassThroughFilter *myOutputPassFiler;
+ vtkCellDataToPointData *myCellDataToPointData;
+
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File: VISU_ScalarMapPL.cxx
+// Author: Roman NIKOLAEV
+// Module : VISU
+
+//Salome includes
+#include "VISU_OptionalDeformationPL.hxx"
+#include "VISU_PipeLineUtils.hxx"
+
+//VTK includes
+#include <vtkDataSet.h>
+#include <vtkPassThroughFilter.h>
+#include <vtkWarpVector.h>
+#include <vtkCellDataToPointData.h>
+
+//----------------------------------------------------------------------------
+VISU_OptionalDeformationPL::VISU_OptionalDeformationPL():
+ VISU_DeformationPL(),
+ myIsDeformed(true)
+{}
+
+//----------------------------------------------------------------------------
+VISU_OptionalDeformationPL::~VISU_OptionalDeformationPL(){
+
+}
+
+//----------------------------------------------------------------------------
+unsigned long int
+VISU_OptionalDeformationPL::GetMTime(){
+ return Superclass::GetMTime();
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::UseDeformation(bool flag){
+ if(myIsDeformed == flag)
+ return;
+
+ myIsDeformed = flag;
+ if(myIsDeformed)
+ OnDeformation();
+ else
+ OffDeformation();
+}
+
+//----------------------------------------------------------------------------
+bool VISU_OptionalDeformationPL::IsDeformed(){
+ return myIsDeformed;
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::OnDeformation(){
+
+ myCellDataToPointData->SetInput(myInputPassFilter->GetOutput());
+ myWarpVector->SetInput(myCellDataToPointData->GetOutput());
+ myOutputPassFiler->SetInput(myWarpVector->GetOutput());
+}
+
+//----------------------------------------------------------------------------
+void VISU_OptionalDeformationPL::OffDeformation(){
+ myOutputPassFiler->SetInput(myInputPassFilter->GetOutput());
+}
+
+
+
+bool VISU_OptionalDeformationPL::CheckCanDeformate(vtkDataSet* theInput){
+ if(theInput) {
+ if(VISU::IsDataOnCells(theInput))
+ return theInput->GetCellData()->GetVectors() != NULL;
+ else if(VISU::IsDataOnPoints(theInput))
+ return theInput->GetPointData()->GetVectors() != NULL;
+ }
+ return false;
+}
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : VISU_OptionalDeformationPL.hxx
+// Author :
+// Module : SALOME
+
+#ifndef VISU_OptionalDeformationPL_HeaderFile
+#define VISU_OptionalDeformationPL_HeaderFile
+
+#include "VISUPipeline.hxx"
+#include "VISU_DeformationPL.hxx"
+
+class VISU_PIPELINE_EXPORT VISU_OptionalDeformationPL: public VISU_DeformationPL
+{
+public:
+ VISU_OptionalDeformationPL();
+ virtual ~VISU_OptionalDeformationPL();
+
+ typedef VISU_DeformationPL Superclass;
+
+ void UseDeformation(bool flag);
+ bool IsDeformed();
+
+ virtual
+ unsigned
+ long int
+ GetMTime();
+
+protected:
+ bool CheckCanDeformate(vtkDataSet* theInput);
+
+private:
+ void OnDeformation();
+ void OffDeformation();
+
+private:
+ bool myIsDeformed;
+};
+
+#endif
msgid "VisuGUI_CutPlanesPane::LBL_ROTATION"
msgstr "Rotations"
+msgid "VisuGUI_CutPlanesPane::LBL_DEFORMATION"
+msgstr "Deformation"
+
+msgid "VisuGUI_CutPlanesPane::LBL_DEFROMATION_VECT"
+msgstr "Vectors :"
+
+msgid "VisuGUI_CutPlanesPane::LBL_DEFROMATION_SCALE"
+msgstr "Scale Factor :"
+
#: VisuGUI_DeformedShapeDlg.cxx
#include "VISU_ColoredPrs3dFactory.hh"
#include "VISU_CutPlanes_i.hh"
+#include "VISU_Result_i.hh"
#include "VISU_CutPlanesPL.hxx"
#include "OB_Browser.h"
#include <vtkPolyData.h>
#include <vtkAppendPolyData.h>
#include <vtkDataSetMapper.h>
+#include <vtkDataSet.h>
using namespace std;
QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
myPosSpn = new QtxDblSpinBox( 0, 1, 0.1, this );
+ GDeformation = new QGroupBox (tr("LBL_DEFORMATION"), this, "GDeformation");
+ GDeformation->setCheckable(true);
+ GDeformation->setChecked(false);
+ GDeformation->setColumnLayout(0, Qt::Horizontal);
+ GDeformation->layout()->setSpacing( 0 );
+ GDeformation->layout()->setMargin( 0 );
+ QGridLayout* GDeformationLayout = new QGridLayout( GDeformation->layout() );
+ GDeformationLayout->setAlignment( Qt::AlignTop );
+ GDeformationLayout->setSpacing( 6 );
+ GDeformationLayout->setMargin( 11 );
+ connect(GDeformation, SIGNAL(toggled(bool)), this, SLOT(onDeformationCheck(bool)));
+
+ QLabel* LabelDeformation1 = new QLabel (tr("LBL_DEFROMATION_VECT"), GDeformation, "LabelDeformation1");
+ GDeformationLayout->addWidget( LabelDeformation1, 0, 0 );
+
+
+ myVectorialFieldCombo = new QComboBox (GDeformation,"myVectorialFieldCombo");
+ GDeformationLayout->addWidget( myVectorialFieldCombo, 0, 1 );
+
+ QLabel* LabelDeformation2 = new QLabel (tr("LBL_DEFROMATION_SCALE"), GDeformation, "LabelDeformation2");
+ GDeformationLayout->addWidget( LabelDeformation2, 1, 0 );
+ myScaleSpn = new QtxDblSpinBox (0.0, 1.0E+38, 0.1, GDeformation);
+ myScaleSpn->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+ myScaleSpn->setPrecision(38);
+ myScaleSpn->setValue(0.1);
+ GDeformationLayout->addWidget( myScaleSpn, 1, 1 );
+ connect(myVectorialFieldCombo, SIGNAL(activated(int)), this, SLOT(onVectorialFieldChanged(int)));
+ connect(myScaleSpn, SIGNAL(valueChanged(double)), this, SLOT(onScaleFactorChanged(double)));
+
+
myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this);
myPreviewCheck->setChecked(false);
connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
TopLayout->setRowStretch ( 3, 3 );
TopLayout->addWidget(aPosLbl, 4, 0 );
TopLayout->addWidget(myPosSpn, 4, 1 );
- TopLayout->addMultiCellWidget( myPreviewCheck, 5, 5, 0, 1 );
+ TopLayout->addMultiCellWidget( GDeformation, 5, 5, 0, 1 );
+ TopLayout->addMultiCellWidget( myPreviewCheck, 6, 6, 0, 1 );
// signals and slots connections
connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) );
setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
setPlanePos(thePrs->GetOrientationType());
myPosSpn->setValue(thePrs->GetDisplacement());
+ InitEntity2VectorialFieldsMap(thePrs);
+ InsertAllVectorialFields();
+ setScaleFactor(thePrs->GetScale());
+ if(myEntity2VectorialFields.size() < 1)
+ GDeformation->setDisabled(true);
+ else{
+ if(thePrs->IsDeformed()){
+ GDeformation->setChecked(true);
+ myVectorialFieldCombo->setCurrentText(thePrs->GetVectorialFieldName());
+ }
+ }
+
hasInit = true;
// init table
myCutPlanes = VISU::TSameAsFactory<VISU::TCUTPLANES>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
myCutPlanes->SameAs(thePrs);
DrawTable();
-
+
// Draw Preview
if (myPreviewCheck->isChecked()) {
createPlanes();
}
}
+
+void VisuGUI_CutPlanesPane::InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs){
+
+ VISU::Result_var theResult = thePrs->GetResultObject();
+ VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(GetServant(theResult).in());
+ VISU::Result::Entities_var aEntities = aResult->GetEntities(thePrs->GetMeshName());
+ VISU::Result::TimeStampNumbers_var aScalarTimeStamp = aResult->GetTimeStampNumbers(thePrs->GetMeshName(),
+ thePrs->GetEntity(),
+ thePrs->GetFieldName());
+ CORBA::Long aTimeStampNumber = aScalarTimeStamp->length();
+
+ for(size_t iEntity = 0; iEntity < aEntities->length(); iEntity++){
+ VISU::Entity aEntity = aEntities[iEntity];
+ VISU::Result::EntityNames_var aFields = aResult->GetFields(thePrs->GetMeshName(),aEntity);
+ for(size_t iField = 0; iField < aFields->length(); iField++){
+
+ TVectorialFieldsList aVectorialFields;
+ VISU::Result::TimeStampNumbers_var aTimeStamps = aResult->GetTimeStampNumbers(thePrs->GetMeshName(),aEntity,aFields[iField] );
+
+ if((aResult->GetNumberOfComponents(thePrs->GetMeshName(),aEntity,aFields[iField] ) > 1) &&
+ (aTimeStamps->length() >= aTimeStampNumber)){
+ aVectorialFields.push_back(QString(aFields[iField].in()));
+ }
+ if(aVectorialFields.size() > 0){
+ myEntity2VectorialFields.insert(TEntVectPair(aEntity,aVectorialFields));
+ }
+ }
+ }
+}
+
+void VisuGUI_CutPlanesPane::InsertAllVectorialFields(){
+ TEntity2VectorialFields::const_iterator aFieldIter = myEntity2VectorialFields.begin();
+ for( ;aFieldIter != myEntity2VectorialFields.end();aFieldIter++ ){
+ TVectorialFieldsList aVectorialFields = aFieldIter->second;
+ for(size_t iField = 0;iField < aVectorialFields.size(); iField++)
+ myVectorialFieldCombo->insertItem(aVectorialFields[iField]);
+ }
+}
+
+double VisuGUI_CutPlanesPane::getScaleFactor(){
+ return myScaleSpn->value();
+}
+
+void VisuGUI_CutPlanesPane::setScaleFactor(double theFactor){
+ return myScaleSpn->setValue(theFactor);
+}
+
+
void VisuGUI_CutPlanesPane::createPlanes()
{
if (VISU::GetActiveViewWindow<SVTK_ViewWindow>() == NULL) return;
if (!myCutPlanes) return;
if (myPreviewActor != 0) return;
- vtkAppendPolyData* aPolyData = myCutPlanes->GetSpecificPL()->GetAppendPolyData();
- if (!aPolyData->GetOutput()->GetNumberOfCells()) {
+ vtkDataSet* aDataSet = myCutPlanes->GetSpecificPL()->GetWarpVectorOutput();
+ if (!aDataSet->GetNumberOfCells()) {
onPreviewCheck(false);
return;
}
vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
- aPlaneMapper->SetInput(aPolyData->GetOutput());
+ aPlaneMapper->SetInput(aDataSet);
aPlaneMapper->ScalarVisibilityOff();
myPreviewActor = SALOME_Actor::New();
else
thePrs->SetDefault(i);
}
+
+ thePrs->UseDeformation(GDeformation->isChecked());
+
+ if(GDeformation->isChecked()){
+ TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin();
+ VISU::Entity anEntity;
+ QString aFieldName;
+ bool isInited = false;
+ for(;anIter != myEntity2VectorialFields.end();anIter++){
+ TVectorialFieldsList aFields = anIter->second;
+ for(int it = 0;it < aFields.size();it++)
+ if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){
+ anEntity = anIter->first;
+ aFieldName = aFields[it];
+ isInited = true;
+ break;
+ }
+ if(isInited)
+ break;
+ }
+ if(isInited)
+ thePrs->SetVectorialField(anEntity,aFieldName.latin1());
+
+ thePrs->SetScale(myScaleSpn->value());
+ }
return 1;
}
Rot2->setValue( r2 );
}
+void VisuGUI_CutPlanesPane::onScaleFactorChanged(double theFactor){
+ DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::onVectorialFieldChanged(int pos){
+ InitVectorialField();
+ DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::onDeformationCheck(bool Flag){
+ if(!myCutPlanes || !hasInit) return;
+ myCutPlanes->UseDeformation(Flag);
+ InitVectorialField();
+ DrawTable();
+}
+
+void VisuGUI_CutPlanesPane::InitVectorialField(){
+ if(myCutPlanes->IsDeformed()){
+ TEntity2VectorialFields::const_iterator anIter = myEntity2VectorialFields.begin();
+ VISU::Entity anEntity;
+ QString aFieldName;
+ bool isInited = false;
+ for(;anIter != myEntity2VectorialFields.end();anIter++){
+ TVectorialFieldsList aFields = anIter->second;
+ for(int it = 0;it < aFields.size();it++)
+ if(!QString::compare(aFields[it], myVectorialFieldCombo->currentText ())){
+ anEntity = anIter->first;
+ aFieldName = aFields[it];
+ isInited = true;
+ break;
+ }
+ if(isInited)
+ break;
+ }
+ if(isInited)
+ myCutPlanes->SetVectorialField(anEntity,aFieldName.latin1());
+ }
+}
+
/*!
Draw the table of planes positions
*/
myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
myCutPlanes->SetNbPlanes(aNbPlanes);
myCutPlanes->SetDisplacement(myPosSpn->value());
+ myCutPlanes->SetScale(getScaleFactor());
if (aNbRows>0)
for (int i = 0; i < aNbRows; ++i) {
QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
myCutPane->initFromPrsObject(myPrsCopy);
-
+
if( !theInit )
return;
#include <qradiobutton.h>
#include <qtable.h>
#include <qtabwidget.h>
+#include <qcombobox.h>
#include <QtxDblSpinBox.h>
#include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(VISU_Gen)
+#include <map>
+#include <vector>
+
+
namespace VISU
{
class CutPlanes_i;
+ class Result_i;
};
class SUIT_ViewWindow;
class SalomeApp_Module;
class VisuGUI_InputPane;
+
class VisuGUI_CutPlanesPane : public QFrame
{
Q_OBJECT
double getRotation1() {return Rot1->value();}
double getRotation2() {return Rot2->value();}
+ double getScaleFactor();
+ void setScaleFactor(double factor);
+
void initFromPrsObject(VISU::CutPlanes_i* thePrs);
int storeToPrsObject(VISU::CutPlanes_i* thePrs);
private:
+
+ typedef std::vector<QString> TVectorialFieldsList;
+ typedef std::map<VISU::Entity, TVectorialFieldsList> TEntity2VectorialFields;
+ typedef std::pair<VISU::Entity,TVectorialFieldsList> TEntVectPair;
+ TEntity2VectorialFields myEntity2VectorialFields;
+
void createPlanes();
void deletePlanes();
+ void InitEntity2VectorialFieldsMap(VISU::ColoredPrs3d_i* thePrs);
+ void InsertAllVectorialFields();
+ void InitVectorialField();
+
+
QLabel* LabelRot1;
QLabel* LabelRot2;
+ QGroupBox* GDeformation;
QSpinBox* nbPlan;
QtxDblSpinBox* Rot1;
QtxDblSpinBox* Rot2;
QTable* myPosTable;
SALOME::GenericObjPtr<VISU::CutPlanes_i> myCutPlanes;
QCheckBox* myPreviewCheck;
+ QComboBox* myVectorialFieldCombo;
+ QtxDblSpinBox* myScaleSpn;
double X1, X2;
double Y1, Y2;
double Z1, Z2;
void onValueChanged(int theRow, int theCol);
void onRotation(double theValue);
void onPreviewCheck(bool thePreview);
+ void onScaleFactorChanged(double);
+ void onDeformationCheck(bool);
+ void onVectorialFieldChanged(int);
};
VISU_DeformedShapeAndScalarMap_i.hh \
VISU_ColoredPrs3dFactory.hh \
VISU_MonoColorPrs_i.hh \
+ VISU_Deformation_i.hh \
+ VISU_OptionalDeformation_i.hh \
SALOME_GenericObjPointer.hh
+
libVISUEngineImpl_la_SOURCES = \
VISUConfig.cc \
VISU_Result_i.cc \
VISU_PointMap3d_i.cc \
VISU_DumpPython.cc \
VISU_MonoColorPrs_i.cc \
+ VISU_Deformation_i.cc \
+ VISU_OptionalDeformation_i.cc \
SALOME_GenericObjPointer.cc
MOC_FILES = VISU_TimeAnimation_moc.cxx
// Module : VISU
#include "VISU_CutPlanesPL.hxx"
+#include "VISU_Convertor.hxx"
#include "VISU_Prs3dUtils.hh"
#include "VISU_CutPlanes_i.hh"
#endif
+
//----------------------------------------------------------------------------
size_t
VISU::CutPlanes_i
::CutPlanes_i(EPublishInStudyMode thePublishInStudyMode):
ColoredPrs3d_i(thePublishInStudyMode),
ScalarMap_i(thePublishInStudyMode),
- myCutPlanesPL(NULL)
-{}
+ myCutPlanesPL(NULL),
+ Deformation_i(this),
+ OptionalDeformation_i(this)
+{
+ if(MYDEBUG) MESSAGE("CutPlanes_i::CutPlanes_i()");
+}
//----------------------------------------------------------------------------
if(aCondList[i].toInt() == 0)
SetPlanePosition(i,aPosList[i].toDouble());
+ OptionalDeformation_i::RestoreDeformation(theSObject,theMap);
+
return this;
}
}
Storable::DataToStream( theStr, "myPlanePosition", aStrPos.latin1());
Storable::DataToStream( theStr, "myPlaneCondition", aStrCon.latin1());
+ OptionalDeformation_i::DeformationToStream(theStr);
}
}else
myCutPlanesPL = dynamic_cast<VISU_CutPlanesPL*>(thePipeLine);
+ InitDeformedPipeLine(myCutPlanesPL);
TSuperClass::CreatePipeLine(myCutPlanesPL);
}
return NULL;
}
+void
+VISU::CutPlanes_i::
+SameAs(const Prs3d_i* theOrigin){
+ if(MYDEBUG) MESSAGE("CutPlanes_i::SameAs()");
+ TSuperClass::SameAs(theOrigin);
+ OptionalDeformation_i::SameAsDeformation(dynamic_cast<const Deformation_i*>(theOrigin));
+}
+
+void VISU::CutPlanes_i::SetVectorialField(Entity theEntity, const char* theFieldName){
+ if(MYDEBUG) MESSAGE("CutPlanes_i::SetVectorialField()");
+
+ bool anIsModified = false;
+ if(!anIsModified)
+ anIsModified |= GetVectorialFieldEntity() != theEntity;
+
+ if(!anIsModified)
+ anIsModified |= GetVectorialFieldName() != theFieldName;
+
+ if(!anIsModified)
+ return;
+
+ int aTimeStampNumber = GetTimeStampNumber();
+
+ VISU::TEntity aEntity = VISU::TEntity(theEntity);
+ VISU::Result_i::PInput anInput = GetCResult()->GetInput(GetCMeshName(),
+ theEntity,
+ theFieldName,
+ aTimeStampNumber);
+
+ PField aVectorialField = anInput->GetField(GetCMeshName(), aEntity, theFieldName);
+
+ VISU::PUnstructuredGridIDMapper anIDMapper =
+ anInput->GetTimeStampOnMesh(GetCMeshName(),
+ aEntity,
+ theFieldName,
+ aTimeStampNumber);
+
+ SetVField(theEntity,
+ theFieldName,
+ anIDMapper,
+ aVectorialField);
+
+};
#define VISU_CutPlanes_i_HeaderFile
#include "VISU_ScalarMap_i.hh"
+#include "VISU_OptionalDeformation_i.hh"
class VISU_CutPlanesPL;
{
//----------------------------------------------------------------------------
class VISU_I_EXPORT CutPlanes_i : public virtual POA_VISU::CutPlanes,
- public virtual ScalarMap_i
+ public virtual ScalarMap_i,
+ public virtual OptionalDeformation_i
{
static int myNbPresent;
CutPlanes_i(const CutPlanes_i&);
{
return myCutPlanesPL;
}
+
+ virtual void SetVectorialField(Entity theEntity, const char* theFieldName);
protected:
//! Redefines VISU_ColoredPrs3d_i::CreatePipeLine
Restore(SALOMEDS::SObject_ptr theSObject,
const Storable::TRestoringMap& theMap);
+ virtual
+ void
+ SameAs(const Prs3d_i* theOrigin);
+
//! Redefines VISU_ColoredPrs3d_i::CreateActor
virtual
VISU_Actor*
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_Deformation_i.cc
+// Author :
+// Module : VISU
+
+#include "VISU_Deformation_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Prs3dUtils.hh"
+
+#include "VISU_DeformationPL.hxx"
+#include "VISU_Convertor.hxx"
+#include "VISU_DeformationPL.hxx"
+#include "VISUConfig.hh"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+VISU::Deformation_i::Deformation_i(VISU::Prs3d_i *theModifiedEngine):
+ myModifiedEngine(theModifiedEngine)
+{
+ if(MYDEBUG) MESSAGE("Deformation_i::Deformation_i()");
+}
+
+//---------------------------------------------------------------
+VISU::Deformation_i::~Deformation_i()
+{
+ if(MYDEBUG) MESSAGE("Deformation_i::~Deformation_i()");
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::SetScale(CORBA::Double theScale)
+{
+ if(MYDEBUG) MESSAGE("Deformation_i::SetScale()");
+
+ VISU::TSetModified aModified(GetModifiedEngine());
+
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, vtkFloatingPointType>
+ (GetSpecificDeformedPL(), &VISU_DeformationPL::SetScale, theScale));
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
+
+ if(MYDEBUG) MESSAGE("Deformation_i::InitDeformedPipeLine()");
+ myDeformationPL = theDeformedPipeLine;
+}
+
+//---------------------------------------------------------------
+CORBA::Double
+VISU::Deformation_i
+::GetScale()
+{
+ if(MYDEBUG) MESSAGE("Deformation_i::GetScale()");
+ return GetSpecificDeformedPL()->GetScale();
+}
+
+//---------------------------------------------------------------
+void VISU::
+Deformation_i::SetVField(VISU::Entity theEntity,
+ const char* theFieldName,
+ VISU::PUnstructuredGridIDMapper anIDMapper,
+ PField theVectorialField)
+{
+
+ if(MYDEBUG) MESSAGE("Deformation_i::SetVField()");
+
+
+ VISU::TSetModified aModified(GetModifiedEngine());
+ myVectorialField = theVectorialField;
+ if(GetSpecificDeformedPL() && anIDMapper)
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_DeformationPL, VISU::PUnstructuredGridIDMapper>
+ (GetSpecificDeformedPL(), &VISU_DeformationPL::SetVectorialField, anIDMapper));
+
+ myVectorialEntity = theEntity;
+ myVectorialFieldName = theFieldName;
+}
+
+
+//---------------------------------------------------------------
+VISU::Entity VISU::Deformation_i::GetVectorialFieldEntity(){
+ return myVectorialEntity;
+}
+
+//---------------------------------------------------------------
+char* VISU::Deformation_i::GetVectorialFieldName(){
+ return CORBA::string_dup(myVectorialFieldName.c_str());
+}
+
+//---------------------------------------------------------------
+void VISU::Deformation_i::
+DeformationToStream(std::ostringstream& theStr)
+{
+ Storable::DataToStream(theStr,"myScaleFactor", GetScale());
+ Storable::DataToStream(theStr,"myVectorialField", GetVectorialFieldName());
+ Storable::DataToStream(theStr,"myVectorialEntiry", GetVectorialFieldEntity());
+
+}
+
+//---------------------------------------------------------------
+void
+VISU::Deformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap)
+{
+ SetScale(VISU::Storable::FindValue(theMap,"myScaleFactor").toDouble());
+ VISU::Entity anEntity = VISU::Entity(VISU::Storable::FindValue(theMap, "myVectorialEntiry").toInt());
+
+ SetVectorialField(anEntity,
+ VISU::Storable::FindValue(theMap, "myVectorialField"));
+}
+
+//---------------------------------------------------------------
+void
+VISU::Deformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
+ if(const Deformation_i* aPrs = dynamic_cast<const Deformation_i*>(aDeformedPrs)) {
+ Deformation_i* anOrigin = const_cast<Deformation_i*>(aPrs);
+
+ CORBA::String_var aVectorialFieldName = anOrigin->GetVectorialFieldName();
+ VISU::Entity anEntity = anOrigin->GetVectorialFieldEntity();
+ this->SetVectorialField(anEntity,
+ aVectorialFieldName);
+ this->SetScale(anOrigin->GetScale());
+ }
+}
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_Deformation_i.hxx
+// Author :
+// Module : VISU
+
+#ifndef VISU_Deformation_i_HeaderFile
+#define VISU_Deformation_i_HeaderFile
+
+#include "VISU_I.hxx"
+#include "VISU_Prs3d_i.hh"
+#include "VISU_DeformationPL.hxx"
+
+
+
+namespace VISU{
+
+ class VISU_I_EXPORT Deformation_i : public virtual POA_VISU::Deformation
+ {
+ Deformation_i(const Deformation_i&);
+ public:
+ typedef VISU::Deformation TInterface;
+
+ Deformation_i(Prs3d_i* theModifiedEngine);
+ virtual ~Deformation_i();
+
+ virtual
+ void
+ SetScale(CORBA::Double theScale);
+
+ virtual
+ CORBA::Double
+ GetScale();
+
+ virtual
+ void
+ DeformationToStream(std::ostringstream& theStr);
+
+ virtual
+ void
+ RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap);
+
+ virtual
+ void
+ SameAsDeformation(const Deformation_i *aDeformedPrs);
+
+ virtual
+ VISU::Entity
+ GetVectorialFieldEntity();
+
+ virtual
+ char*
+ GetVectorialFieldName();
+
+ protected:
+ virtual
+ void
+ InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine);
+
+ VISU_DeformationPL*
+ GetSpecificDeformedPL() const
+ {
+ return myDeformationPL;
+ }
+
+ void SetVField(VISU::Entity theEntity,
+ const char* theFieldName,
+ PUnstructuredGridIDMapper,
+ PField theVectorialField);
+
+ Prs3d_i* GetModifiedEngine(){
+ return myModifiedEngine;
+ }
+
+
+ private:
+ VISU_DeformationPL *myDeformationPL;
+
+ PField myVectorialField;
+ VISU::Entity myVectorialEntity;
+ std::string myVectorialFieldName;
+ Prs3d_i *myModifiedEngine;
+
+ };
+}
+
+#endif
theStr<<thePrefix<<theName<<".SetPlanePosition("<<anId<<", "<<theServant->GetPlanePosition(anId)<<")"<<endl;
}
+ theStr<<thePrefix<<theName<<".UseDeformation("<<GetBoolean(theServant->IsDeformed())<<")"<<endl;
+ if(theServant->IsDeformed()){
+ theStr<< thePrefix << theName << ".SetScale(" << theServant->GetScale()<<")"<<endl;
+ std::string aStringEntity;
+ VISU::Entity anEntity = theServant->GetVectorialFieldEntity();
+ switch(anEntity){
+ case NODE:
+ aStringEntity = "VISU.NODE";
+ break;
+ case EDGE:
+ aStringEntity = "VISU.EDGE";
+ break;
+ case FACE:
+ aStringEntity = "VISU.FACE";
+ break;
+ case CELL:
+ aStringEntity = "VISU.CELL";
+ break;
+ }
+ theStr<< thePrefix << theName << ".SetVectorialField("<<aStringEntity<<", '" << theServant->GetVectorialFieldName() <<"')"<<endl;
+ }
return thePrefix;
}
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_OptionalDeformation_i.cc
+// Author :
+// Module : VISU
+
+#include "VISU_OptionalDeformation_i.hh"
+#include "VISU_Result_i.hh"
+#include "VISU_Prs3dUtils.hh"
+#include "VISUConfig.hh"
+
+#include "VISU_OptionalDeformationPL.hxx"
+
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//---------------------------------------------------------------
+VISU::OptionalDeformation_i::OptionalDeformation_i(VISU::Prs3d_i *theModifiedEngine):
+ Deformation_i(theModifiedEngine)
+{
+ if(MYDEBUG) MESSAGE("OptionalDeformation_i::OptionalDeformation_i()");
+}
+
+//---------------------------------------------------------------
+VISU::OptionalDeformation_i::~OptionalDeformation_i()
+{
+ if(MYDEBUG) MESSAGE("OptionalDeformation_i::~OptionalDeformation_i()");
+}
+
+//---------------------------------------------------------------
+void VISU::OptionalDeformation_i::UseDeformation(CORBA::Boolean theFlag){
+ if(MYDEBUG) MESSAGE("OptionalDeformation_i::UseDeformation()");
+
+ VISU::TSetModified aModified(GetModifiedEngine());
+
+ ProcessVoidEvent(new TVoidMemFun1ArgEvent<VISU_OptionalDeformationPL, bool>
+ (GetSpecificDeformedPL(), &VISU_OptionalDeformationPL::UseDeformation, theFlag));
+}
+
+//---------------------------------------------------------------
+CORBA::Boolean VISU::OptionalDeformation_i::IsDeformed(){
+
+ if(MYDEBUG) MESSAGE("OptionalDeformation_i::IsDeformed()");
+ return GetSpecificDeformedPL()->IsDeformed();
+}
+
+
+void VISU::OptionalDeformation_i::InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine){
+
+ if(MYDEBUG) MESSAGE("OptionalDeformation_i::InitDeformedPipeLine()");
+ myOptionalDeformationPL = dynamic_cast<VISU_OptionalDeformationPL*>(theDeformedPipeLine);
+
+ TSuperClass::InitDeformedPipeLine(myOptionalDeformationPL);
+}
+
+//---------------------------------------------------------------
+void VISU::OptionalDeformation_i::
+DeformationToStream(std::ostringstream& theStr)
+{
+ Storable::DataToStream(theStr,"IsDeformed", IsDeformed());
+ if(IsDeformed())
+ TSuperClass::DeformationToStream(theStr);
+}
+
+//---------------------------------------------------------------
+void
+VISU::OptionalDeformation_i::RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap)
+{
+ UseDeformation(Storable::FindValue(theMap,"IsDeformed").toInt());
+ if(IsDeformed())
+ TSuperClass::RestoreDeformation(theSObject,theMap);
+}
+
+
+
+void
+VISU::OptionalDeformation_i::SameAsDeformation(const Deformation_i *aDeformedPrs){
+
+ if(const OptionalDeformation_i* aPrs3d = dynamic_cast<const OptionalDeformation_i*>(aDeformedPrs)){
+ OptionalDeformation_i* anOrigin = const_cast<OptionalDeformation_i*>(aPrs3d);
+ UseDeformation(anOrigin->IsDeformed());
+
+ if(anOrigin->IsDeformed()){
+ TSuperClass::SameAsDeformation(aDeformedPrs);
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2008 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : VISU_Deformation_i.hxx
+// Author :
+// Module : VISU
+
+#ifndef VISU_OptionalDeformation_i_HeaderFile
+#define VISU_OptionalDeformation_i_HeaderFile
+
+#include "VISU_I.hxx"
+#include "VISU_Deformation_i.hh"
+#include "VISU_OptionalDeformationPL.hxx"
+
+namespace VISU {
+ class VISU_I_EXPORT OptionalDeformation_i : public virtual POA_VISU::OptionalDeformation,
+ public virtual Deformation_i
+ {
+ OptionalDeformation_i(const OptionalDeformation_i&);
+ public:
+ typedef VISU::OptionalDeformation TInterface;
+ typedef Deformation_i TSuperClass;
+
+ OptionalDeformation_i(Prs3d_i* theModifiedEngine);
+ virtual ~OptionalDeformation_i();
+
+ virtual void UseDeformation(CORBA::Boolean theFlag);
+ virtual CORBA::Boolean IsDeformed();
+
+
+ virtual
+ void
+ DeformationToStream(std::ostringstream& theStr);
+
+ virtual
+ void
+ RestoreDeformation(SALOMEDS::SObject_ptr theSObject,
+ const Storable::TRestoringMap& theMap);
+
+ virtual
+ void
+ SameAsDeformation(const Deformation_i *aDeformedPrs);
+
+ protected:
+ virtual
+ void InitDeformedPipeLine(VISU_DeformationPL* theDeformedPipeLine);
+
+ VISU_OptionalDeformationPL*
+ GetSpecificDeformedPL() const
+ {
+ return myOptionalDeformationPL;
+ }
+
+ private:
+ VISU_OptionalDeformationPL* myOptionalDeformationPL;
+
+ };
+}
+#endif
{
anEntities->length(aMeshOnEntityMap.size());
- VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.end();
+ VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
const VISU::TEntity& anEntity = anIter->first;
anEntities[anId] = VISU::Entity(anEntity);
{
aResult->length(aFamilyMap.size());
- VISU::TFamilyMap::const_iterator anIter = aFamilyMap.end();
+ VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
const std::string& aName = anIter->first;
aResult[anId] = aName.c_str();
{
aResult->length(aGroupMap.size());
- VISU::TGroupMap::const_iterator anIter = aGroupMap.end();
+ VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
const std::string& aName = anIter->first;
aResult[anId] = aName.c_str();
{
aResult->length(aFieldMap.size());
- VISU::TFieldMap::const_iterator anIter = aFieldMap.end();
+ VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
const std::string& aName = anIter->first;
aResult[anId] = aName.c_str();
{
aResult->length(aValField.size());
- VISU::TValField::const_iterator anIter = aValField.end();
+ VISU::TValField::const_iterator anIter = aValField.begin();
for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
const vtkIdType& aTimeStampNumber = anIter->first;
aResult[anId] = aTimeStampNumber;