From a5b889a539952d44c6c4e43c86c8cc946d444a04 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 15 Jan 2007 07:58:47 +0000 Subject: [PATCH] First implementation of "To use customized data format at entry of visualization pipeline" taks --- src/CONVERTOR/Makefile.in | 23 +- src/CONVERTOR/VISU_AppendPolyData.cxx | 483 ++++ src/CONVERTOR/VISU_AppendPolyData.hxx | 102 + src/CONVERTOR/VISU_Convertor.cxx | 47 +- src/CONVERTOR/VISU_Convertor.hxx | 225 +- src/CONVERTOR/VISU_ConvertorDef.hxx | 62 +- src/CONVERTOR/VISU_ConvertorDef_impl.hxx | 158 ++ src/CONVERTOR/VISU_ConvertorUtils.cxx | 155 +- src/CONVERTOR/VISU_ConvertorUtils.hxx | 40 +- src/CONVERTOR/VISU_Convertor_impl.cxx | 2450 ++--------------- src/CONVERTOR/VISU_Convertor_impl.hxx | 1098 +------- src/CONVERTOR/VISU_IDMapper.cxx | 27 +- src/CONVERTOR/VISU_IDMapper.hxx | 54 +- src/CONVERTOR/VISU_MedConvertor.cxx | 589 ++-- src/CONVERTOR/VISU_MedConvertor.hxx | 31 +- src/CONVERTOR/VISU_MeshValue.cxx | 615 +++++ src/CONVERTOR/VISU_MeshValue.hxx | 219 ++ src/CONVERTOR/VISU_PointCoords.cxx | 381 +++ src/CONVERTOR/VISU_PointCoords.hxx | 258 ++ src/CONVERTOR/VISU_Structures.cxx | 78 + src/CONVERTOR/VISU_Structures.hxx | 243 ++ src/CONVERTOR/VISU_Structures_impl.cxx | 1157 ++++++++ src/CONVERTOR/VISU_Structures_impl.hxx | 816 ++++++ src/OBJECT/VISU_DataSetActor.cxx | 12 +- src/OBJECT/VISU_GaussPtsAct.cxx | 38 +- src/OBJECT/VISU_GaussPtsDeviceActor.cxx | 4 +- src/OBJECT/VISU_GaussPtsDeviceActor.h | 2 +- src/OBJECT/VISU_ScalarMapAct.cxx | 3 +- src/PIPELINE/Makefile.in | 41 +- src/PIPELINE/SALOME_ExtractGeometry.cxx | 57 +- src/PIPELINE/SALOME_ExtractGeometry.h | 14 +- .../SALOME_ExtractPolyDataGeometry.cxx | 363 +++ src/PIPELINE/SALOME_ExtractPolyDataGeometry.h | 95 + src/PIPELINE/VISUPipeLine.cxx | 124 +- src/PIPELINE/VISU_ColoredPL.cxx | 308 +++ src/PIPELINE/VISU_ColoredPL.hxx | 155 ++ src/PIPELINE/VISU_CutLinesPL.cxx | 117 +- src/PIPELINE/VISU_CutLinesPL.hxx | 2 + src/PIPELINE/VISU_CutPlanesPL.cxx | 119 +- src/PIPELINE/VISU_CutPlanesPL.hxx | 12 +- src/PIPELINE/VISU_DataSetMapperHolder.cxx | 348 +++ src/PIPELINE/VISU_DataSetMapperHolder.hxx | 165 ++ src/PIPELINE/VISU_DeformedShapePL.cxx | 56 +- src/PIPELINE/VISU_DeformedShapePL.hxx | 8 +- src/PIPELINE/VISU_Extractor.cxx | 14 +- src/PIPELINE/VISU_Extractor.hxx | 28 +- src/PIPELINE/VISU_FieldTransform.hxx | 68 +- src/PIPELINE/VISU_GaussPointsPL.cxx | 349 ++- src/PIPELINE/VISU_GaussPointsPL.hxx | 85 +- src/PIPELINE/VISU_IsoSurfacesPL.cxx | 67 +- src/PIPELINE/VISU_IsoSurfacesPL.hxx | 10 +- src/PIPELINE/VISU_MapperHolder.cxx | 252 ++ src/PIPELINE/VISU_MapperHolder.hxx | 186 ++ src/PIPELINE/VISU_MeshPL.cxx | 37 +- src/PIPELINE/VISU_MeshPL.hxx | 33 +- src/PIPELINE/VISU_PipeLine.cxx | 523 ++-- src/PIPELINE/VISU_PipeLine.hxx | 231 +- src/PIPELINE/VISU_PipeLineUtils.cxx | 139 +- src/PIPELINE/VISU_PipeLineUtils.hxx | 58 +- src/PIPELINE/VISU_Plot3DPL.cxx | 148 +- src/PIPELINE/VISU_Plot3DPL.hxx | 32 +- src/PIPELINE/VISU_PointSpriteMapperHolder.cxx | 122 + src/PIPELINE/VISU_PointSpriteMapperHolder.hxx | 81 + src/PIPELINE/VISU_PolyDataMapperHolder.cxx | 348 +++ src/PIPELINE/VISU_PolyDataMapperHolder.hxx | 165 ++ src/PIPELINE/VISU_PolyDataPL.cxx | 331 +++ src/PIPELINE/VISU_PolyDataPL.hxx | 153 + .../VISU_ScalarMapOnDeformedShapePL.cxx | 77 +- .../VISU_ScalarMapOnDeformedShapePL.hxx | 5 +- src/PIPELINE/VISU_ScalarMapPL.cxx | 273 +- src/PIPELINE/VISU_ScalarMapPL.hxx | 125 +- src/PIPELINE/VISU_StreamLinesPL.cxx | 274 +- src/PIPELINE/VISU_StreamLinesPL.hxx | 63 +- src/PIPELINE/VISU_UnstructuredGridPL.cxx | 81 + src/PIPELINE/VISU_UnstructuredGridPL.hxx | 66 + src/PIPELINE/VISU_UsedPointsFilter.cxx | 29 +- src/PIPELINE/VISU_UsedPointsFilter.hxx | 31 +- src/PIPELINE/VISU_VectorsPL.cxx | 51 +- src/PIPELINE/VISU_VectorsPL.hxx | 19 +- src/VISUGUI/VisuGUI_ClippingDlg.cxx | 4 +- src/VISUGUI/VisuGUI_Prs3dDlg.cxx | 1 + src/VISU_I/VISU_ColoredPrs3d_i.cc | 20 +- src/VISU_I/VISU_ColoredPrs3d_i.hh | 8 +- src/VISU_I/VISU_CorbaMedConvertor.cxx | 20 +- src/VISU_I/VISU_CorbaMedConvertor.hxx | 19 +- src/VISU_I/VISU_DumpPython.cc | 35 - src/VISU_I/VISU_GaussPoints_i.cc | 3 +- src/VISU_I/VISU_Gen_i.cc | 6 +- src/VISU_I/VISU_Mesh_i.cc | 5 +- src/VISU_I/VISU_Prs3d_i.cc | 2 +- src/VISU_I/VISU_Prs3d_i.hh | 4 +- src/VISU_I/VISU_Result_i.cc | 6 +- src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc | 13 +- src/VISU_I/VISU_ScalarMap_i.cc | 22 +- src/VISU_I/VISU_ScalarMap_i.hh | 16 + src/VISU_I/VISU_StreamLines_i.cc | 12 +- src/VISU_SWIG/VISU_Gen_s.cc | 13 +- 97 files changed, 10558 insertions(+), 5559 deletions(-) create mode 100644 src/CONVERTOR/VISU_AppendPolyData.cxx create mode 100644 src/CONVERTOR/VISU_AppendPolyData.hxx create mode 100644 src/CONVERTOR/VISU_ConvertorDef_impl.hxx create mode 100644 src/CONVERTOR/VISU_MeshValue.cxx create mode 100644 src/CONVERTOR/VISU_MeshValue.hxx create mode 100644 src/CONVERTOR/VISU_PointCoords.cxx create mode 100644 src/CONVERTOR/VISU_PointCoords.hxx create mode 100644 src/CONVERTOR/VISU_Structures.cxx create mode 100644 src/CONVERTOR/VISU_Structures.hxx create mode 100644 src/CONVERTOR/VISU_Structures_impl.cxx create mode 100644 src/CONVERTOR/VISU_Structures_impl.hxx create mode 100644 src/PIPELINE/SALOME_ExtractPolyDataGeometry.cxx create mode 100644 src/PIPELINE/SALOME_ExtractPolyDataGeometry.h create mode 100644 src/PIPELINE/VISU_ColoredPL.cxx create mode 100644 src/PIPELINE/VISU_ColoredPL.hxx create mode 100644 src/PIPELINE/VISU_DataSetMapperHolder.cxx create mode 100644 src/PIPELINE/VISU_DataSetMapperHolder.hxx create mode 100644 src/PIPELINE/VISU_MapperHolder.cxx create mode 100644 src/PIPELINE/VISU_MapperHolder.hxx create mode 100644 src/PIPELINE/VISU_PointSpriteMapperHolder.cxx create mode 100644 src/PIPELINE/VISU_PointSpriteMapperHolder.hxx create mode 100644 src/PIPELINE/VISU_PolyDataMapperHolder.cxx create mode 100644 src/PIPELINE/VISU_PolyDataMapperHolder.hxx create mode 100644 src/PIPELINE/VISU_PolyDataPL.cxx create mode 100644 src/PIPELINE/VISU_PolyDataPL.hxx create mode 100644 src/PIPELINE/VISU_UnstructuredGridPL.cxx create mode 100644 src/PIPELINE/VISU_UnstructuredGridPL.hxx diff --git a/src/CONVERTOR/Makefile.in b/src/CONVERTOR/Makefile.in index dd855414..ba11b72f 100644 --- a/src/CONVERTOR/Makefile.in +++ b/src/CONVERTOR/Makefile.in @@ -35,11 +35,17 @@ BOOST_LIBSUFFIX=@BOOST_LIBSUFFIX@ EXPORT_HEADERS = \ VISU_TypeList.hxx \ VISU_IDMapper.hxx \ - VISU_Convertor.hxx \ - VISU_ConvertorDef.hxx \ - VISU_Convertor_impl.hxx \ - VISU_ConvertorUtils.hxx \ + VISU_ConvertorDef.hxx \ + VISU_Structures.hxx \ + VISU_Convertor.hxx \ + VISU_ConvertorDef_impl.hxx \ + VISU_Structures_impl.hxx \ + VISU_MeshValue.hxx \ + VISU_PointCoords.hxx \ + VISU_Convertor_impl.hxx \ + VISU_ConvertorUtils.hxx \ VISU_MergeFilter.hxx \ + VISU_AppendPolyData.hxx \ VISU_ExtractUnstructuredGrid.hxx # Libraries targets @@ -47,12 +53,17 @@ EXPORT_HEADERS = \ LIB = libVisuConvertor.la LIB_SRC = \ VISU_IDMapper.cxx \ + VISU_Structures.cxx \ VISU_Convertor.cxx \ + VISU_Structures_impl.cxx \ + VISU_MeshValue.cxx \ + VISU_PointCoords.cxx \ VISU_Convertor_impl.cxx \ + VISU_MedConvertor.cxx \ VISU_ConvertorUtils.cxx \ VISU_ExtractUnstructuredGrid.cxx \ - VISU_MergeFilter.cxx \ - VISU_MedConvertor.cxx + VISU_AppendPolyData.cxx \ + VISU_MergeFilter.cxx # Executables targets BIN = VISUConvertor diff --git a/src/CONVERTOR/VISU_AppendPolyData.cxx b/src/CONVERTOR/VISU_AppendPolyData.cxx new file mode 100644 index 00000000..76db3a28 --- /dev/null +++ b/src/CONVERTOR/VISU_AppendPolyData.cxx @@ -0,0 +1,483 @@ +// SALOME OBJECT : kernel of SALOME component +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VTKViewer_GeometryFilter.cxx +// Author : +// Module : SALOME +// $Header$ + +#include "VISU_AppendPolyData.hxx" + +#include +#include +#include +#include +#include +#include +#include + +#include + +vtkCxxRevisionMacro(VISU_AppendPolyData, "$Revision$"); +vtkStandardNewMacro(VISU_AppendPolyData); + +VISU_AppendPolyData +::VISU_AppendPolyData() +{ + myDoMappingFlag = false; +} + +VISU_AppendPolyData +::~VISU_AppendPolyData() +{} + +void +VISU_AppendPolyData +::SetDoMappingFlag(const bool theFlag) +{ + if(myDoMappingFlag == theFlag) + return; + + myDoMappingFlag = theFlag; + + this->Modified(); +} + +bool +VISU_AppendPolyData +::DoMappingFlag() const +{ + return myDoMappingFlag; +} + +void +VISU_AppendPolyData +::SetPoints(vtkPoints* thePoints) +{ + if(GetPoints() == thePoints) + return; + + myPoints = thePoints; + + this->Modified(); +} + +vtkPoints* +VISU_AppendPolyData +::GetPoints() +{ + return myPoints.GetPointer(); +} + +void +VISU_AppendPolyData +::Execute() +{ + if(myPoints.GetPointer()) + MakeOutput(); + else + Superclass::Execute(); + + if(myDoMappingFlag) + DoMapping(); +} + + +void +VISU_AppendPolyData +::DoMapping() +{ + myNodeRanges.clear(); + myCellRanges.clear(); + + vtkIdType aPntStartId = 0; + vtkIdType aCellStartId = 0; + + for(vtkIdType aDataSetId = 0; aDataSetId < this->NumberOfInputs; ++aDataSetId){ + vtkDataSet* aDataSet = (vtkDataSet *)(this->Inputs[aDataSetId]); + // Do mapping of the nodes + if(!myPoints.GetPointer()){ + vtkIdType aNbPnts = aDataSet->GetNumberOfPoints(); + myNodeRanges.push_back(aPntStartId + aNbPnts); + aPntStartId += aNbPnts; + } + // Do mapping of the cells + vtkIdType aNbCells = aDataSet->GetNumberOfCells(); + myCellRanges.push_back(aCellStartId + aNbCells); + aCellStartId += aNbCells; + } +} + +namespace +{ + inline + vtkIdType + GetOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID, + const VISU_AppendPolyData::TVectorIds& theRanges) + { + theInputID = theInputDataSetID = -1; + + vtkIdType aNbInputs = theRanges.size(); + if(theInputDataSetID < 0 || theInputDataSetID >= aNbInputs) + return -1; + + vtkIdType aStartId = theRanges[theInputDataSetID]; + return aStartId + theInputID; + } +} + +vtkIdType +VISU_AppendPolyData +::GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) +{ + if(myPoints.GetPointer()) + return theInputID; + + return GetOutputID(theInputID,theInputDataSetID,myNodeRanges); +} + + +vtkIdType +VISU_AppendPolyData +::GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID) +{ + if(myPoints.GetPointer()) + return theInputID; + + return GetOutputID(theInputID,theInputDataSetID,myCellRanges); +} + + +namespace +{ + void + GetInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID, + const VISU_AppendPolyData::TVectorIds& theRanges) + { + theInputID = theStartID = theInputDataSetID = -1; + + if(theRanges.empty()) + return; + + const vtkIdType& aRangeEnd = theRanges.back(); + if(theOutputID < 0 || theOutputID >= aRangeEnd) + return; + + vtkIdType aStartId = 0; + vtkIdType aNbInputs = theRanges.size(); + for(vtkIdType aDataSetId = 0; aDataSetId < aNbInputs; ++aDataSetId){ + vtkIdType aRange = theRanges[aDataSetId]; + if(aRange > theOutputID){ + theInputID = theOutputID - aStartId; + theInputDataSetID = aDataSetId; + theStartID = aStartId; + break; + } + aStartId = aRange; + } + } +} + +void +VISU_AppendPolyData +::GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID) +{ + if(myPoints.GetPointer()) { + theStartID = theInputDataSetID = 0; + theInputID = theOutputID; + return; + } + + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myNodeRanges); +} + + +void +VISU_AppendPolyData +::GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID) +{ + ::GetInputID(theOutputID, + theInputID, + theStartID, + theInputDataSetID, + myCellRanges); +} + + +void +VISU_AppendPolyData +::MakeOutput() +{ + // loop over all data sets, checking to see what point data is available. + vtkIdType numPts = 0; + + // These Field lists are very picky. Count the number of non empty inputs + // so we can initialize them properly. + int idx; + int countCD = 0; + for (idx = 0; idx < this->NumberOfInputs; ++idx) + { + vtkPolyData *ds = (vtkPolyData *)(this->Inputs[idx]); + if (ds != NULL) + { + if (ds->GetNumberOfCells() > 0 ) + { + ++countCD; + } // for a data set that has cells + } // for a non NULL input + } // for each input + + // These are used to determine which fields are available for appending + vtkDataSetAttributes::FieldList cellList(countCD); + + countCD = 0; + vtkIdType numCells = 0; + vtkIdType numPolys = 0; + vtkIdType sizePolys = 0; + for (idx = 0; idx < this->NumberOfInputs; ++idx) + { + vtkPolyData *ds = (vtkPolyData *)(this->Inputs[idx]); + if (ds != NULL) + { + // Although we cannot have cells without points ... let's not nest. + if (ds->GetNumberOfCells() > 0 ) + { + // keep track of the size of the poly cell array + if (ds->GetPolys()) + { + numPolys += ds->GetPolys()->GetNumberOfCells(); + sizePolys += ds->GetPolys()->GetNumberOfConnectivityEntries(); + } + numCells += ds->GetNumberOfCells(); + + vtkCellData *inCD = ds->GetCellData(); + if ( countCD == 0 ) + { + cellList.InitializeFieldList(inCD); + } + else + { + cellList.IntersectFieldList(inCD); + } + ++countCD; + } // for a data set that has cells + } // for a non NULL input + } // for each input + + if ( numPts < 1 || numCells < 1 ) + { + return; + } + this->UpdateProgress(0.10); + + // Allocate geometry/topology + vtkCellArray* newVerts = vtkCellArray::New(); + newVerts->Allocate(numCells*4); + + vtkCellArray* newLines = vtkCellArray::New(); + newLines->Allocate(numCells*4); + + vtkCellArray* newStrips = vtkCellArray::New(); + newStrips->Allocate(numCells*4); + + vtkCellArray* newPolys = vtkCellArray::New(); + vtkIdType *pPolys = newPolys->WritePointer(numPolys, sizePolys); + + // Allocate the point and cell data + vtkPolyData *output = this->GetOutput(); + vtkCellData *outputCD = output->GetCellData(); + outputCD->CopyAllocate(cellList,numCells); + + // loop over all input sets + vtkIdType ptOffset = 0; + vtkIdType cellOffset = 0; + countCD = 0; + for (idx = 0; idx < this->NumberOfInputs; ++idx) + { + this->UpdateProgress(0.2 + 0.8*idx/this->NumberOfInputs); + vtkPolyData *ds = (vtkPolyData *)(this->Inputs[idx]); + // this check is not necessary, but I'll put it in anyway + if (ds != NULL) + { + vtkIdType numPts = ds->GetNumberOfPoints(); + vtkIdType numCells = ds->GetNumberOfCells(); + if ( numPts <= 0 && numCells <= 0 ) + { + continue; //no input, just skip + } + + vtkCellData *inCD = ds->GetCellData(); + + vtkCellArray *inVerts = ds->GetVerts(); + vtkCellArray *inLines = ds->GetLines(); + vtkCellArray *inPolys = ds->GetPolys(); + vtkCellArray *inStrips = ds->GetStrips(); + + if (ds->GetNumberOfCells() > 0) + { + // cell data could be made efficient like the point data, + // but I will wait on that. + // copy cell data + vtkIdType cellId; + for (cellId=0; cellId < numCells; cellId++) + { + outputCD->CopyData(cellList,inCD,countCD,cellId,cellId+cellOffset); + } + ++countCD; + + // copy the cells + pPolys = this->AppendCells(pPolys, inPolys, ptOffset); + + // These other cell arrays could be made efficient like polys ... + int i; + vtkIdType *pts = 0; + vtkIdType npts = 0; + for (inVerts->InitTraversal(); inVerts->GetNextCell(npts,pts); ) + { + newVerts->InsertNextCell(npts); + for (i=0; i < npts; i++) + { + newVerts->InsertCellPoint(pts[i]+ptOffset); + } + } + + for (inLines->InitTraversal(); inLines->GetNextCell(npts,pts); ) + { + newLines->InsertNextCell(npts); + for (i=0; i < npts; i++) + { + newLines->InsertCellPoint(pts[i]+ptOffset); + } + } + + for (inStrips->InitTraversal(); inStrips->GetNextCell(npts,pts); ) + { + newStrips->InsertNextCell(npts); + for (i=0; i < npts; i++) + { + newStrips->InsertCellPoint(pts[i]+ptOffset); + } + } + } + cellOffset += numCells; + } + } + + if ( newVerts->GetNumberOfCells() > 0 ) + { + output->SetVerts(newVerts); + } + newVerts->Delete(); + + if ( newLines->GetNumberOfCells() > 0 ) + { + output->SetLines(newLines); + } + newLines->Delete(); + + if ( newPolys->GetNumberOfCells() > 0 ) + { + output->SetPolys(newPolys); + } + newPolys->Delete(); + + if ( newStrips->GetNumberOfCells() > 0 ) + { + output->SetStrips(newStrips); + } + newStrips->Delete(); + + // When all optimizations are complete, this squeeze will be unecessary. + // (But it does not seem to cost much.) + output->Squeeze(); + + /* + int idx; + vtkIdType numPts, numCells, newCellId, cellId; + vtkCellData *cd; + vtkIdList *ptIds; + vtkDataSet *ds; + vtkPolyData *output = this->GetOutput(); + // + numPts = myPoints->GetNumberOfPoints(); + if (numPts < 1) { + return; + } + // + numCells = 0; + for (idx = 0; idx < this->NumberOfInputs; ++idx) { + ds = (vtkDataSet *)(this->Inputs[idx]); + if (ds != NULL) { + if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 ) { + continue; //no input, just skip + } + numCells += ds->GetNumberOfCells(); + }//if non-empty dataset + }//for all inputs + if (numCells < 1) { + return; + } + // + // Now can allocate memory + output->Allocate(numCells); + ptIds = vtkIdList::New(); + ptIds->Allocate(VTK_CELL_SIZE); + // + // Append each input dataset together + // + // 1.points + output->SetPoints(myPoints.GetPointer()); + // 2.cells + for (idx = 0; idx < this->NumberOfInputs; ++idx) { + ds = (vtkDataSet *)(this->Inputs[idx]); + if (ds != NULL) { + numCells = ds->GetNumberOfCells(); + cd = ds->GetCellData(); + // copy cell and cell data + for (cellId=0; cellIdGetCellPoints(cellId, ptIds); + newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds); + } + } + } + // + ptIds->Delete(); + */ +} + diff --git a/src/CONVERTOR/VISU_AppendPolyData.hxx b/src/CONVERTOR/VISU_AppendPolyData.hxx new file mode 100644 index 00000000..d07757fa --- /dev/null +++ b/src/CONVERTOR/VISU_AppendPolyData.hxx @@ -0,0 +1,102 @@ +// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D +// +// 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 +// +#ifndef VISU_APPENDPOLYDATA_H +#define VISU_APPENDPOLYDATA_H + +#include +#include + +#include +#include + +class vtkPoints; + +/*! \brief This class used same as vtkAppendFilter. See documentation on VTK for more information. + */ +class VISU_AppendPolyData : public vtkAppendPolyData +{ +public: + /*! \fn static VTKViewer_AppendFilter *New() + */ + static VISU_AppendPolyData *New(); + + /*! \fn vtkTypeRevisionMacro(VTKViewer_AppendFilter, vtkAppendFilter) + * \brief VTK type revision macros. + */ + vtkTypeRevisionMacro(VISU_AppendPolyData, vtkAppendPolyData); + + void SetDoMappingFlag(const bool theFlag); + + bool DoMappingFlag() const; + + void + SetPoints(vtkPoints* thePoints); + + vtkPoints* + GetPoints(); + + vtkIdType + GetPointOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); + + vtkIdType + GetCellOutputID(vtkIdType theInputID, + vtkIdType theInputDataSetID); + + void + GetPointInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); + + void + GetCellInputID(vtkIdType theOutputID, + vtkIdType& theInputID, + vtkIdType& theStartID, + vtkIdType& theInputDataSetID); + + typedef std::vector TVectorIds; + +protected: + /*! \fn VTKViewer_AppendFilter(); + * \brief Constructor + */ + VISU_AppendPolyData(); + /*! \fn ~VTKViewer_AppendFilter(); + * \brief Destructor. + */ + ~VISU_AppendPolyData(); + /*! \fn void Execute(); + * \brief Filter culculation method. + */ + virtual void Execute(); + // + void DoMapping(); + + void Reset(); + + void MakeOutput(); + + bool myDoMappingFlag; + TVectorIds myNodeRanges; + TVectorIds myCellRanges; + vtkSmartPointer myPoints; +}; + +#endif diff --git a/src/CONVERTOR/VISU_Convertor.cxx b/src/CONVERTOR/VISU_Convertor.cxx index c18100d3..e630d14e 100644 --- a/src/CONVERTOR/VISU_Convertor.cxx +++ b/src/CONVERTOR/VISU_Convertor.cxx @@ -29,29 +29,10 @@ #include -using namespace std; - -namespace VISU{ - - inline - int - GetNbOfPoints(int theVTKCellType) - { - switch(theVTKCellType){ - case VTK_VERTEX : return 1; - case VTK_LINE : return 2; - case VTK_TRIANGLE : return 3; - case VTK_QUAD : return 4; - case VTK_TETRA : return 4; - case VTK_HEXAHEDRON : return 8; - case VTK_WEDGE : return 6; - case VTK_PYRAMID : return 5; - default: return -1; - } - } -} +#include +//--------------------------------------------------------------- const VISU::TMeshMap& VISU_Convertor ::GetMeshMap() @@ -60,23 +41,26 @@ VISU_Convertor } -string +//--------------------------------------------------------------- +std::string VISU_Convertor ::GenerateName(const VISU::TTime& aTime) { static QString aName; - const string aUnits = aTime.second, tmp(aUnits.size(),' '); + const std::string aUnits = aTime.second, tmp(aUnits.size(), ' '); if(aUnits == "" || aUnits == tmp) - aName.sprintf("%g, -",aTime.first); + aName.sprintf("%g, -", aTime.first); else - aName.sprintf("%g, %s",aTime.first,aTime.second.c_str()); + aName.sprintf("%g, %s", aTime.first, aTime.second.c_str()); aName = aName.simplifyWhiteSpace(); return aName.latin1(); } -string + +//--------------------------------------------------------------- +std::string VISU_Convertor -::GenerateName(const string& theName, +::GenerateName(const std::string& theName, unsigned int theTimeId) { static QString aName; @@ -86,11 +70,14 @@ VISU_Convertor if(iEnd > VtkHighLevelLength) iEnd = VtkHighLevelLength; char aNewName[iEnd+1]; aNewName[iEnd] = '\0'; - strncpy(aNewName,aName,iEnd); - replace(aNewName,aNewName+iEnd,' ','_'); + strncpy(aNewName, aName, iEnd); + std::replace(aNewName, aNewName + iEnd, ' ', '_'); if(true || theTimeId == 0) aName = aNewName; else - aName.sprintf("%s_%d",aNewName,theTimeId); + aName.sprintf("%s_%d", aNewName, theTimeId); return aName.latin1(); } + + +//--------------------------------------------------------------- diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index ad38703b..ba84f66a 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -29,211 +29,10 @@ /*! \file VISU_Convertor.hxx - \brief The file contains definitions for basic classes of the VISU CONVERTER package + \brief The file represents definition of basic interface of the VISU CONVERTER package */ -#include "VISU_IDMapper.hxx" -#include "VISU_ConvertorDef.hxx" - -#include "MED_Vector.hxx" - -#include -#include -#include -#include -#include - -namespace VISU -{ - using MED::TVector; - - //--------------------------------------------------------------- - typedef std::string TName; - - typedef TVector TNames; - - //--------------------------------------------------------------- - //! Define a basic class for all MED entites which can be identified by its number - struct TIntId: virtual TBaseStructure - { - vtkIdType myId; - - TIntId(): myId(0) - {} - }; - - - //--------------------------------------------------------------- - typedef std::map TMeshOnEntityMap; - typedef std::map TGroupMap; - - //! Define a basic class which corresponds to MED MESH entity - /*! - This class in its turn contains map of TMeshOnEntity and TGroup substructures, - also it keeps name and dimention of corresponding MED MESH entity. - */ - struct TMesh: virtual TBaseStructure - { - TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES - TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS - TName myName; //! Name of the corresponding MED MESH - vtkIdType myDim; //! Dimension of the corresponding MED MESH - - std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree - std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree - - TMesh(): myDim(0) - {} - }; - typedef std::map TMeshMap; - - - //--------------------------------------------------------------- - //! Define a basic class which corresponds to MED PROFILE entity - struct TSubProfile: virtual TBaseStructure - {}; - - - //--------------------------------------------------------------- - //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY - struct TProfile: virtual TNamedIDMapper - {}; - - - //--------------------------------------------------------------- - bool - operator<(const PSubProfile& theLeft, const PSubProfile& theRight); - - typedef std::set TProfileKey; - typedef std::map TProfileMap; - - - //--------------------------------------------------------------- - //! Define a basic class for MED GAUSS entity - struct TGauss: virtual TBaseStructure - {}; - - - //--------------------------------------------------------------- - //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE - struct TGaussSubMesh: virtual TBaseStructure - { - PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located - }; - - - //--------------------------------------------------------------- - //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY - struct TGaussMesh: virtual TGaussPtsIDMapper - {}; - - - //--------------------------------------------------------------- - bool - operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight); - - typedef std::set TGaussKey; - typedef std::map TGaussMeshMap; - - - //--------------------------------------------------------------- - - typedef std::map TFamilyMap; - typedef std::map TFieldMap; - - //! Define a basic class which corresponds to MED ENTITY - /*! - This class in its turn contains map of TGaussMesh and TProfile substructures, - also it keeps corresponding map of MED FAMILIES and FIELDS. - */ - struct TMeshOnEntity: virtual TNamedIDMapper - { - TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it - TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it - - TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it - TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it - - TName myMeshName; //!< Contains name of the MED MESH where the it belongs to. - TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to. - }; - - - //--------------------------------------------------------------- - //! Define a basic class for MED FAMILY entity - struct TFamily: virtual TIntId, - virtual TIDMapper - { - TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to. - TName myName; //!< Contains name of the corresponding MED FAMILY - }; - - - //--------------------------------------------------------------- - typedef std::set TFamilySet; - - //! Define a basic class for MED GROUP entity - struct TGroup: virtual TIDMapper - { - TFamilySet myFamilySet; - }; - - - //--------------------------------------------------------------- - typedef std::map TValField; - typedef std::pair TMinMax; - - //! Define a basic class for MED FIELD entity - struct TField: virtual TIntId - { - TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. - TName myName; //!< Contains name of the corresponding MED FIELD - TName myMeshName; //!< Contains name of the MED MESH where it belongs to. - TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS - TNames myCompNames; //!< Contains names of components of the MED FIELD - TNames myUnitNames; //!< Contains names of units of the MED FIELD - vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD - - //! Calculate min/max values for each of the MED FIELD components among all its timestamps - /*! - Numeration of the components starts from 1. - Zero component contains min/max value for modulus of corresponding vector - */ - virtual - TMinMax - GetMinMax(vtkIdType theCompID) = 0; - - bool myIsMinMaxInitilized; //!< Is the min / max values are calculated - - TField(): - myNbComp(0), - myIsMinMaxInitilized(false) - {} - }; - - - //--------------------------------------------------------------- - typedef std::pair TTime; - - //! Define a basic class for MED TIMESTAMP entity - struct TValForTime: virtual TIntId - { - TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. - TName myMeshName; //!< Contains name of the MED MESH where it belongs to. - TName myFieldName; //!< Contains name of the MED FIELD where it belongs to. - TTime myTime; - - PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to - PGaussMesh myGaussMesh; - }; - - - //--------------------------------------------------------------- - //! The utility function allows to write vtkUnstructuredGrid to a file with defined name - void - WriteToFile(vtkUnstructuredGrid* theDataSet, - const std::string& theFileName); -}; +#include "VISU_Structures.hxx" //--------------------------------------------------------------- @@ -249,15 +48,9 @@ namespace VISU 1. Perfrom parsing of MED file to get known what MED entities are pressent in it 2. Get VTK representation for any existing MED entity Also, it can perform some additional work to calculate expected amount of memory to build defined VTK representation - */ class VISU_Convertor { -protected: - std::string myName; - VISU::TMeshMap myMeshMap; - int myIsDone; - public: virtual ~VISU_Convertor() @@ -273,9 +66,6 @@ public: int IsDone() const { return myIsDone; } - //! Defines what subtype of vtkDataSet is used for MED to VTK mapping - typedef VISU::TVTKOutput TOutput; - //! This method perform first parsing of MED file to get known what MED entities are pressent in it virtual VISU_Convertor* @@ -325,7 +115,7 @@ public: //! Get mesh for corresponding MED FAMILY virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName) = 0; @@ -339,7 +129,7 @@ public: //! Get mesh for corresponding MED GROUP virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName) = 0; @@ -351,7 +141,7 @@ public: //! Get mesh with attached values for corresponding MED TIMESTAMP virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetTimeStampOnMesh(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, @@ -411,6 +201,11 @@ public: static std::string GenerateName(const std::string& theName, unsigned int theTimeId); + +protected: + std::string myName; + VISU::TMeshMap myMeshMap; + int myIsDone; }; extern "C" diff --git a/src/CONVERTOR/VISU_ConvertorDef.hxx b/src/CONVERTOR/VISU_ConvertorDef.hxx index 1e54cdb6..1be0aafc 100644 --- a/src/CONVERTOR/VISU_ConvertorDef.hxx +++ b/src/CONVERTOR/VISU_ConvertorDef.hxx @@ -36,46 +36,80 @@ namespace VISU { - using MED::SharedPtr; - //--------------------------------------------------------------- enum TEntity {NODE_ENTITY, EDGE_ENTITY, FACE_ENTITY, CELL_ENTITY}; + + //--------------------------------------------------------------- + //! Defines VISU enumeration of geometrical types + enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, + eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304, + ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, + ePYRA13=313, ePENTA15=315, eHEXA20=320, + ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1}; + + + //--------------------------------------------------------------- struct TMesh; - typedef SharedPtr PMesh; + typedef MED::SharedPtr PMesh; + + //--------------------------------------------------------------- struct TGaussSubMesh; - typedef SharedPtr PGaussSubMesh; + typedef MED::SharedPtr PGaussSubMesh; + + //--------------------------------------------------------------- struct TGaussMesh; - typedef SharedPtr PGaussMesh; + typedef MED::SharedPtr PGaussMesh; + + //--------------------------------------------------------------- struct TSubProfile; - typedef SharedPtr PSubProfile; + typedef MED::SharedPtr PSubProfile; + + //--------------------------------------------------------------- struct TProfile; - typedef SharedPtr PProfile; + typedef MED::SharedPtr PProfile; + + //--------------------------------------------------------------- struct TMeshOnEntity; - typedef SharedPtr PMeshOnEntity; + typedef MED::SharedPtr PMeshOnEntity; + + //--------------------------------------------------------------- struct TFamily; - typedef SharedPtr PFamily; + typedef MED::SharedPtr PFamily; + + //--------------------------------------------------------------- struct TGroup; - typedef SharedPtr PGroup; + typedef MED::SharedPtr PGroup; + + //--------------------------------------------------------------- struct TField; - typedef SharedPtr PField; + typedef MED::SharedPtr PField; + + //--------------------------------------------------------------- struct TGauss; - typedef SharedPtr PGauss; + typedef MED::SharedPtr PGauss; + + //--------------------------------------------------------------- struct TValForTime; - typedef SharedPtr PValForTime; + typedef MED::SharedPtr PValForTime; + + //--------------------------------------------------------------- struct TGrille; - typedef SharedPtr PGrille; + typedef MED::SharedPtr PGrille; + + + //--------------------------------------------------------------- } #endif diff --git a/src/CONVERTOR/VISU_ConvertorDef_impl.hxx b/src/CONVERTOR/VISU_ConvertorDef_impl.hxx new file mode 100644 index 00000000..441b206b --- /dev/null +++ b/src/CONVERTOR/VISU_ConvertorDef_impl.hxx @@ -0,0 +1,158 @@ +// VISU CONVERTOR : +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : +// Author : +// Module : + +#ifndef VISU_ConvertorDef_impl_HeaderFile +#define VISU_ConvertorDef_impl_HeaderFile + +/*! + \file VISU_ConvertorDef_impl.hxx + \brief The file contains predeclarations for basic classes of the VISU CONVERTOR package +*/ + +#include "VISU_ConvertorDef.hxx" + +#include + +class vtkCell; +class vtkPoints; + +class vtkPolyData; +class VISU_AppendPolyData; + +class vtkUnstructuredGrid; +class VTKViewer_AppendFilter; + +class VISU_MergeFilter; + +namespace VISU +{ + //--------------------------------------------------------------- + typedef vtkSmartPointer PMergeFilter; + + + //--------------------------------------------------------------- + typedef vtkSmartPointer PPolyData; + typedef vtkSmartPointer PAppendPolyData; + + struct TAppendPolyDataHolder; + typedef MED::SharedPtr PAppendPolyDataHolder; + + struct TPolyDataIDMapperImpl; + typedef MED::SharedPtr PPolyDataIDMapperImpl; + + + //--------------------------------------------------------------- + typedef vtkSmartPointer PUnstructuredGrid; + typedef vtkSmartPointer PAppendFilter; + + struct TAppendFilterHolder; + typedef MED::SharedPtr PAppendFilterHolder; + + struct TUnstructuredGridIDMapperImpl; + typedef MED::SharedPtr PUnstructuredGridIDMapperImpl; + + + //--------------------------------------------------------------- + struct TPointCoords; + typedef MED::SharedPtr PPointCoords; + + + //--------------------------------------------------------------- + struct TNamedPointCoords; + typedef MED::SharedPtr PNamedPointCoords; + + + //--------------------------------------------------------------- + struct TMeshValueBase; + typedef MED::SharedPtr PMeshValue; + + + //--------------------------------------------------------------- + struct TMeshImpl; + typedef MED::SharedPtr PMeshImpl; + + + //--------------------------------------------------------------- + struct TSubProfileImpl; + typedef MED::SharedPtr PSubProfileImpl; + + + //--------------------------------------------------------------- + struct TProfileImpl; + typedef MED::SharedPtr PProfileImpl; + + + //--------------------------------------------------------------- + struct TGaussImpl; + typedef MED::SharedPtr PGaussImpl; + + + //--------------------------------------------------------------- + struct TGaussSubMeshImpl; + typedef MED::SharedPtr PGaussSubMeshImpl; + + + //--------------------------------------------------------------- + struct TGaussMeshImpl; + typedef MED::SharedPtr PGaussMeshImpl; + + + //--------------------------------------------------------------- + struct TGaussPtsIDFilter; + typedef MED::SharedPtr PGaussPtsIDFilter; + + + //--------------------------------------------------------------- + struct TSubMeshImpl; + typedef MED::SharedPtr PSubMeshImpl; + + + //--------------------------------------------------------------- + struct TMeshOnEntityImpl; + typedef MED::SharedPtr PMeshOnEntityImpl; + + + //--------------------------------------------------------------- + struct TFamilyImpl; + typedef MED::SharedPtr PFamilyImpl; + + + //--------------------------------------------------------------- + struct TGroupImpl; + typedef MED::SharedPtr PGroupImpl; + + + //--------------------------------------------------------------- + struct TFieldImpl; + typedef MED::SharedPtr PFieldImpl; + + + //--------------------------------------------------------------- + struct TValForTimeImpl; + typedef MED::SharedPtr PValForTimeImpl; +} + +#endif diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index f406e557..4bf738c5 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -26,7 +26,9 @@ #include "VISU_ConvertorUtils.hxx" +#include #include +#include #include #ifdef _DEBUG_ @@ -37,9 +39,142 @@ static int MYDEBUG = 0; namespace VISU { + //--------------------------------------------------------------- + vtkIdType + VISUGeom2NbNodes(EGeometry theGeom) + { + switch(theGeom){ +#ifndef VISU_ENABLE_QUADRATIC + case VISU::eSEG3: + return 2; + case VISU::eTRIA6: + return 3; + case VISU::eQUAD8: + return 4; + case VISU::eTETRA10: + return 4; + case VISU::eHEXA20: + return 8; + case VISU::ePENTA15: + return 6; + case VISU::ePYRA13: + return 5; +#endif + case VISU::ePOLYGONE: + case VISU::ePOLYEDRE: + return -1; + default: + return theGeom % 100; + } + } + + + //--------------------------------------------------------------- + vtkIdType + VISUGeom2VTK(EGeometry theGeom) + { + switch(theGeom){ + case VISU::ePOINT1: + return VTK_VERTEX; + case VISU::eSEG2: + return VTK_LINE; + case VISU::eTRIA3: + return VTK_TRIANGLE; + case VISU::eQUAD4: + return VTK_QUAD; + case VISU::eTETRA4: + return VTK_TETRA; + case VISU::eHEXA8: + return VTK_HEXAHEDRON; + case VISU::ePENTA6: + return VTK_WEDGE; + case VISU::ePYRA5: + return VTK_PYRAMID; + + case VISU::ePOLYGONE: + return VTK_POLYGON; + case VISU::ePOLYEDRE: + return VTK_CONVEX_POINT_SET; + +#ifndef VISU_ENABLE_QUADRATIC + case VISU::eSEG3: + return VTK_LINE; + case VISU::eTRIA6: + return VTK_TRIANGLE; + case VISU::eQUAD8: + return VTK_QUAD; + case VISU::eTETRA10: + return VTK_TETRA; + case VISU::eHEXA20: + return VTK_HEXAHEDRON; + case VISU::ePENTA15: + return VTK_WEDGE; + case VISU::ePYRA13: + return VTK_PYRAMID; + +#else + + case VISU::eSEG3: +#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_EDGE; +#else + return VTK_POLY_LINE; +#endif + + case VISU::eTRIA6: +#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_TRIANGLE; +#else + return VTK_POLYGON; +#endif + + case VISU::eQUAD8: +#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_QUAD; +#else + return VTK_POLYGON; +#endif + + case VISU::eTETRA10: +#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_TETRA; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::eHEXA20: +#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_HEXAHEDRON; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePENTA15: +#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_WEDGE; +#else + return VTK_CONVEX_POINT_SET; +#endif + + case VISU::ePYRA13: +#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC) + return VTK_QUADRATIC_PYRAMID; +#else + return VTK_CONVEX_POINT_SET; +#endif + +#endif //VISU_ENABLE_QUADRATIC + + default: + return -1; + } + } + + //--------------------------------------------------------------- void - WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName) + WriteToFile(vtkUnstructuredGrid* theDataSet, + const std::string& theFileName) { vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); //aWriter->SetFileType(VTK_BINARY); @@ -50,6 +185,21 @@ namespace VISU } + //--------------------------------------------------------------- + void + WriteToFile(vtkPolyData* theDataSet, + const std::string& theFileName) + { + vtkPolyDataWriter* aWriter = vtkPolyDataWriter::New(); + //aWriter->SetFileType(VTK_BINARY); + aWriter->SetFileName(theFileName.c_str()); + aWriter->SetInput(theDataSet); + aWriter->Write(); + aWriter->Delete(); + } + + + //--------------------------------------------------------------- TTimerLog ::TTimerLog(int theIsDebug, const std::string& theName): @@ -62,6 +212,7 @@ namespace VISU BEGMSG(myIsDebug > 1,"{\n"); } + //--------------------------------------------------------------- TTimerLog ::~TTimerLog() { @@ -77,4 +228,6 @@ namespace VISU myTimerLog = NULL; } + + //--------------------------------------------------------------- } diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index c44d5c43..34857268 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -20,32 +20,59 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File : VISU_Convertor_impl.hxx +// File : VISU_ConvertorUtils.hxx // Author : Alexey PETROV // Module : VISU #ifndef VISU_ConvertorUtils_HeaderFile #define VISU_ConvertorUtils_HeaderFile -#include +#include "VISU_ConvertorDef.hxx" +#include "MED_Utilities.hxx" -#include +#include -#include "MED_Utilities.hxx" +#include class vtkUnstructuredGrid; +class vtkPolyData; class vtkTimerLog; +#ifndef VISU_ENABLE_QUADRATIC + #define VISU_ENABLE_QUADRATIC + #define VISU_USE_VTK_QUADRATIC +#endif + namespace MED { class PrefixPrinter; } -namespace VISU{ +namespace VISU +{ + //--------------------------------------------------------------- + //! Get number of nodes for defined geometrical type + vtkIdType + VISUGeom2NbNodes(EGeometry theGeom); + + //! Maps VISU geometrical type to VTK one + vtkIdType + VISUGeom2VTK(EGeometry theGeom); + //--------------------------------------------------------------- + //! The utility function allows to write vtkUnstructuredGrid to a file with defined name void - WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName); + WriteToFile(vtkUnstructuredGrid* theDataSet, + const std::string& theFileName); + //--------------------------------------------------------------- + //! The utility function allows to write vtkPolyData to a file with defined name + void + WriteToFile(vtkPolyData* theDataSet, + const std::string& theFileName); + + //--------------------------------------------------------------- + //! The utility class that allows to perform perfomance mesurement class TTimerLog { int myIsDebug; @@ -54,6 +81,7 @@ namespace VISU{ vtkTimerLog* myTimerLog; MED::PrefixPrinter myPrefixPrinter; public: + TTimerLog(int theIsDebug, const std::string& theName); ~TTimerLog(); diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index 9f5ef876..323216f9 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -25,2003 +25,47 @@ // Module : VISU #include "VISU_Convertor_impl.hxx" -#include "VISU_ConvertorUtils.hxx" -#include "VTKViewer_AppendFilter.h" -#include "VISU_MergeFilter.hxx" -#include "VTKViewer_CellLocationsArray.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -using namespace std; -using namespace VISU; - -static vtkFloatingPointType ERR_SIZE_CALC = 1.00; - -static int MYVTKDEBUG = 0; - -#ifdef _DEBUG_ -static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; -//#define _DEXCEPT_ -#else -static int MYDEBUG = 0; -static int MYDEBUGWITHFILES = 0; -#endif - -namespace VISU -{ - //--------------------------------------------------------------- - std::string - GenerateFieldName(const PFieldImpl& theField, - const PValForTimeImpl& theValForTime) - { - const VISU::TTime& aTime = theValForTime->myTime; - string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + - VISU_Convertor::GenerateName(aTime); - return aFieldName; - } - - - //--------------------------------------------------------------- - /*! Computes number of points by the given number of cells - * in assumption of regular hexahedral mesh structure - */ - size_t - GetNumberofPoints(size_t theNbCells) - { - return size_t(pow(pow(theNbCells, 1.0/3.0) + 1.0, 3.0)); - } - - //--------------------------------------------------------------- - /*! Computes size dataset the given number of mesh macro metrics - * in assumption of regular hexahedral mesh structure - */ - size_t - GetDataSetSize(size_t theNbOfPoints, - size_t theNbOfCells, - size_t theCellsSize, - bool theComputeLinks) - { - size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord); - size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType); - size_t aLocationsSize = theNbOfCells*sizeof(int); - vtkFloatingPointType aNbCellsPerPoint = theCellsSize / theNbOfCells - 1; - size_t aLinksSize = theNbOfPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short)); - if(!theComputeLinks) - aLinksSize = 0; - size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize; - return aResult; - } - - //--------------------------------------------------------------- - TIsVTKDone::TIsVTKDone(): - myIsVTKDone(false), - myIsDone(false) - {} - - - //--------------------------------------------------------------- - TSizeCounter::TSizeCounter(): - myNbCells(0), - myCellsSize(0) - {} - - - //--------------------------------------------------------------- - TSource::TSource() - {} - - const TVTKSource& - TSource - ::GetSource() const - { - if(!mySource.GetPointer()){ - mySource = vtkUnstructuredGrid::New(); - mySource->Delete(); - } - return mySource; - } - - TVTKOutput* - TSource - ::GetVTKOutput() - { - return GetSource().GetPointer(); - } - - unsigned long int - TSource - ::GetMemorySize() - { - if(TVTKOutput* anOutput = GetVTKOutput()){ - anOutput->Update(); - return GetVTKOutput()->GetActualMemorySize() * 1024; - } - if(myIsDone){ - size_t aNbPoints = GetNumberofPoints(myNbCells); - return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false); - } - throw std::runtime_error("TSource::GetMemorySize - myIsDone == false !!!"); - return 0; - } - - //--------------------------------------------------------------- - unsigned long int - TMemoryCheckIDMapper - ::GetMemorySize() - { - if(myIsVTKDone){ - GetVTKOutput()->Update(); - return GetVTKOutput()->GetActualMemorySize() * 1024; - }else - throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!"); - return 0; - } - - - //--------------------------------------------------------------- - TAppendFilter::TAppendFilter() - {} - - const TVTKAppendFilter& - TAppendFilter - ::GetFilter() const - { - if(!myFilter.GetPointer()){ - myFilter = VTKViewer_AppendFilter::New(); - myFilter->Delete(); - myFilter->SetDoMappingFlag(true); - } - return myFilter; - } - - TVTKOutput* - TAppendFilter - ::GetVTKOutput() - { - GetFilter()->Update(); - return GetFilter()->GetOutput(); - } - - //--------------------------------------------------------------- - TMergeFilter::TMergeFilter() - {} - - const TVTKMergeFilter& - TMergeFilter - ::GetFilter() const - { - if(!myFilter.GetPointer()){ - myFilter = VISU_MergeFilter::New(); - myFilter->Delete(); - } - return myFilter; - } - - TVTKOutput* - TMergeFilter - ::GetVTKOutput() - { - GetFilter()->Update(); - return GetFilter()->GetUnstructuredGridOutput(); - } - - - //--------------------------------------------------------------- - void - TCoordHolderBase - ::Init(vtkIdType theNbPoints, - vtkIdType theDim) - { - myDim = theDim; - myNbPoints = theNbPoints; - } - - vtkIdType - TCoordHolderBase - ::GetNbPoints() const - { - return myNbPoints; - } - - vtkIdType - TCoordHolderBase - ::GetDim() const - { - return myDim; - } - - size_t - TCoordHolderBase - ::size() const - { - return GetNbPoints() * GetDim(); - } - - unsigned long int - TCoordHolderBase - ::GetMemorySize() - { - return sizeof(TCoord) * size(); - } - - - //--------------------------------------------------------------- - TPointCoords - ::TPointCoords(): - myPoints(vtkPoints::New()) - { - myPoints->SetDataType(VTK_DOUBLE); - myPoints->Delete(); - } - - void - TPointCoords - ::Init(const PCoordHolder& theCoord) - { - myPoints->SetNumberOfPoints(theCoord->GetNbPoints()); - myCoord = theCoord; - } - - vtkIdType - TPointCoords - ::GetNbPoints() const - { - return myCoord->GetNbPoints(); - } - - vtkIdType - TPointCoords - ::GetDim() const - { - return myCoord->GetDim(); - } - - TCCoordSlice - TPointCoords - ::GetCoordSlice(vtkIdType theNodeId) const - { - return myCoord->GetCoordSlice(theNodeId); - } - - TCoordSlice - TPointCoords - ::GetCoordSlice(vtkIdType theNodeId) - { - return myCoord->GetCoordSlice(theNodeId); - } - - void - TPointCoords - ::SetVoidArray() const - { - vtkDataArray* aDataArray = myPoints->GetData(); - aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), true); - } - - vtkPoints* - TPointCoords - ::GetPoints() const - { - if(!myIsVTKDone){ - TTimerLog aTimerLog(MYDEBUG,"TPointCoords::GetPoints()"); - vtkIdType aNbPoints = GetNbPoints(); - vtkIdType aDim = GetDim(); - - INITMSG(MYDEBUG,"TPointCoords::GetPoints - aNbPoints = "<SetPoint(aPointId, aCoords); - } - } - - myIsVTKDone = true; - } - - return myPoints.GetPointer(); - } - - unsigned long int - TPointCoords - ::GetMemorySize() - { - size_t aSize = myCoord->GetMemorySize(); - aSize += myPoints->GetActualMemorySize() * 1024; - return aSize; - } - - - //--------------------------------------------------------------- - void - TNamedPointCoords - ::Init(const PCoordHolder& theCoord) - { - TPointCoords::Init(theCoord); - myPointsDim.resize(theCoord->GetDim()); - } - - std::string& - TNamedPointCoords - ::GetName(vtkIdType theDim) - { - return myPointsDim[theDim]; - } - - const std::string& - TNamedPointCoords - ::GetName(vtkIdType theDim) const - { - return myPointsDim[theDim]; - } - - vtkIdType - TNamedPointCoords - ::GetObjID(vtkIdType theID) const - { - return theID; - } - - vtkIdType - TNamedPointCoords - ::GetVTKID(vtkIdType theID) const - { - return theID; - } - - std::string - TNamedPointCoords - ::GetNodeName(vtkIdType theObjID) const - { - return ""; - } - - - //--------------------------------------------------------------- - enum ECoordName{eX, eY, eZ, eNoneCoord}; - typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice); - - template - VISU::TCoord - GetCoord(const VISU::TCCoordSlice& theCoordSlice) - { - return theCoordSlice[TCoordId]; - } - - template<> - VISU::TCoord - GetCoord(const VISU::TCCoordSlice& theCoordSlice) - { - return 0.0; - } - - - TGetCoord aXYZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - - TGetCoord aXYGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - TGetCoord aYZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - TGetCoord aXZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - - TGetCoord aXGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - TGetCoord aYGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - TGetCoord aZGetCoord[3] = { - &GetCoord, - &GetCoord, - &GetCoord - }; - - - class TCoordHelper{ - TGetCoord* myGetCoord; - public: - TCoordHelper(TGetCoord* theGetCoord): - myGetCoord(theGetCoord) - {} - - virtual - ~TCoordHelper() - {} - - VISU::TCoord - GetCoord(VISU::TCCoordSlice& theCoordSlice, - int theCoordId) - { - return (*myGetCoord[theCoordId])(theCoordSlice); - } - }; - typedef std::auto_ptr TCoordHelperPtr; - - - //--------------------------------------------------------------- - vtkPoints* - TNamedPointCoords - ::GetPoints() const - { - if(!myIsVTKDone){ - TTimerLog aTimerLog(MYDEBUG,"TNamedPointCoords::GetPoints()"); - TCoordHelperPtr aCoordHelperPtr; - bool anIsDimPresent[3] = {false, false, false}; - for(int iDim = 0; iDim < GetDim(); iDim++){ - std::string aName = GetName(iDim); - if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16 - aName = aName.substr(0,1); - if(aName == "x" || aName == "X") - anIsDimPresent[eX] = true; - else if(aName == "y" || aName == "Y") - anIsDimPresent[eY] = true; - else if(aName == "z" || aName == "Z") - anIsDimPresent[eZ] = true; - } - - switch(GetDim()){ - case 3: - aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord)); - break; - case 2: - if(anIsDimPresent[eY] && anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord)); - else if(anIsDimPresent[eX] && anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord)); - else - aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord)); - break; - case 1: - if(anIsDimPresent[eY]) - aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord)); - else if(anIsDimPresent[eZ]) - aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord)); - else - aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord)); - break; - } - - INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - aNbPoints = "<SetPoint(aNodeId, - aCoordHelperPtr->GetCoord(aCoordSlice,eX), - aCoordHelperPtr->GetCoord(aCoordSlice,eY), - aCoordHelperPtr->GetCoord(aCoordSlice,eZ)); - } - } - - myIsVTKDone = true; - } - - return myPoints.GetPointer(); - } - - unsigned long int - TNamedPointCoords - ::GetMemorySize() - { - return TPointCoords::GetMemorySize(); - } - - - //--------------------------------------------------------------- - vtkIdType - TMeshImpl:: - GetNbPoints() const - { - return myNbPoints; - } - - vtkIdType - TMeshImpl:: - GetDim() const - { - return myDim; - } - - vtkPoints* - TMeshImpl:: - GetPoints() - { - return myNamedPointCoords->GetPoints(); - } - - - //--------------------------------------------------------------- - TSubProfileImpl::TSubProfileImpl(): - myStatus(eNone), - myGeom(eNONE) - {} - - - vtkIdType - TSubProfileImpl - ::GetElemObjID(vtkIdType theID) const - { - return theID; - } - - unsigned long int - TSubProfileImpl - ::GetMemorySize() - { - size_t aSize = TSource::GetMemorySize(); - aSize += sizeof(vtkIdType) * mySubMeshID.size(); - return aSize; - } - - - //--------------------------------------------------------------- - bool - operator<(const PSubProfile& theLeft, const PSubProfile& theRight) - { - PSubProfileImpl aLeft(theLeft), aRight(theRight); - - if(aLeft->myGeom != aRight->myGeom) - return aLeft->myGeom < aRight->myGeom; - - if(aLeft->myStatus != aRight->myStatus) - return aLeft->myStatus < aRight->myStatus; - - return aLeft->myName < aRight->myName; - } - - - //--------------------------------------------------------------- - TProfileImpl::TProfileImpl(): - myIsAll(true), - myMeshOnEntity(NULL) - {} - - vtkIdType - TProfileImpl - ::GetNodeObjID(vtkIdType theID) const - { - return myNamedPointCoords->GetObjID(theID); - } - - vtkIdType - TProfileImpl - ::GetNodeVTKID(vtkIdType theID) const - { - return myNamedPointCoords->GetVTKID(theID); - } - - vtkFloatingPointType* - TProfileImpl - ::GetNodeCoord(vtkIdType theObjID) - { - if(myIsAll) - return myMeshOnEntity->GetNodeCoord(theObjID); - - vtkIdType aVtkID = GetNodeVTKID(theObjID); - return GetFilter()->GetOutput()->GetPoint(aVtkID); - } - - vtkIdType - TProfileImpl - ::GetElemObjID(vtkIdType theID) const - { - if(myIsAll) - return myMeshOnEntity->GetElemObjID(theID); - - vtkIdType anInputID, aStartID, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(theID,anInputID,aStartID,anInputDataSetID); - PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID]; - return aSubProfileImpl->GetElemObjID(anInputID); - } - - vtkIdType - TProfileImpl - ::GetElemVTKID(vtkIdType theID) const - { - if(myIsAll) - return myMeshOnEntity->GetElemVTKID(theID); - - if(myElemObj2VTKID.empty()) - return theID; - else{ - TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); - if(anIter != myElemObj2VTKID.end()) - return anIter->second; - } - return -1; - } - - vtkCell* - TProfileImpl - ::GetElemCell(vtkIdType theObjID) - { - if(myIsAll) - return myMeshOnEntity->GetElemCell(theObjID); - - vtkIdType aVtkID = GetElemVTKID(theObjID); - return GetFilter()->GetOutput()->GetCell(aVtkID); - } - - TVTKOutput* - TProfileImpl - ::GetVTKOutput() - { - const TVTKAppendFilter& anAppendFilter = GetFilter(); - return anAppendFilter->GetOutput(); - } - - unsigned long int - TProfileImpl - ::GetMemorySize() - { - size_t aSize = TAppendFilter::GetMemorySize(); - aSize += myNamedPointCoords->GetMemorySize(); - aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); - TGeom2SubProfile::const_iterator anIter = myGeom2SubProfile.begin(); - TGeom2SubProfile::const_iterator anIterEnd = myGeom2SubProfile.end(); - for(; anIter != anIterEnd; anIter++){ - const PSubProfileImpl& aSubProfile = anIter->second; - aSize += aSubProfile->GetMemorySize(); - aSize += sizeof(EGeometry); - } - return aSize; - } - - std::string - TProfileImpl - ::GetNodeName(vtkIdType theObjID) const - { - return myNamedPointCoords->GetNodeName(theObjID); - } - - std::string - TProfileImpl - ::GetElemName(vtkIdType theObjID) const - { - if(myIsAll) - return myMeshOnEntity->GetElemName(theObjID); - - vtkIdType aVTKId = GetElemVTKID(theObjID); - vtkIdType anInputID, aStartID, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartID,anInputDataSetID); - PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID]; - vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(anInputID); - return myMeshOnEntity->GetElemName(anEntityObjId); - } - - - //--------------------------------------------------------------- - TVTKOutput* - TIDMapperFilter - ::GetVTKOutput() - { - if(!myFilter.GetPointer()){ - const TVTKAppendFilter& anAppendFilter = myIDMapper->GetFilter(); - TVTKOutput* aGeometry = anAppendFilter->GetOutput(); - - const TVTKSource& aSource = mySource.GetSource(); - TDataSet* aDataSet = aSource.GetPointer(); - aDataSet->ShallowCopy(aGeometry); - - const TVTKMergeFilter& aFilter = GetFilter(); - aFilter->SetGeometry(aGeometry); - aFilter->SetScalars(aDataSet); - aFilter->SetVectors(aDataSet); - aFilter->AddField("VISU_FIELD",aDataSet); - } - return myFilter->GetUnstructuredGridOutput(); - } - - unsigned long int - TIDMapperFilter - ::GetMemorySize() - { - size_t aSize = myIDMapper->GetMemorySize(); - aSize += mySource.GetMemorySize(); - return aSize; - } - - vtkIdType - TIDMapperFilter - ::GetNodeObjID(vtkIdType theID) const - { - return myIDMapper->GetNodeObjID(theID); - } - - vtkIdType - TIDMapperFilter - ::GetNodeVTKID(vtkIdType theID) const - { - return myIDMapper->GetNodeVTKID(theID); - } - - vtkFloatingPointType* - TIDMapperFilter - ::GetNodeCoord(vtkIdType theObjID) - { - return myIDMapper->GetNodeCoord(theObjID); - } - - vtkIdType - TIDMapperFilter - ::GetElemObjID(vtkIdType theID) const - { - return myIDMapper->GetElemObjID(theID); - } - - vtkIdType - TIDMapperFilter - ::GetElemVTKID(vtkIdType theID) const - { - return myIDMapper->GetElemVTKID(theID); - } - - vtkCell* - TIDMapperFilter - ::GetElemCell(vtkIdType theObjID) - { - return myIDMapper->GetElemCell(theObjID); - } - - - //--------------------------------------------------------------- - void - TGaussImpl - ::LessThan(const PGaussImpl& theGauss, - bool& theResult) const - { - theResult = false; - } - - - //--------------------------------------------------------------- - TGaussSubMeshImpl::TGaussSubMeshImpl(): - myStatus(eNone) - {} - - TGaussPointID - TGaussSubMeshImpl - ::GetObjID(vtkIdType theID, - vtkIdType theStartID) const - { - TCellID aCellID = theStartID + theID / myGauss->myNbPoints; - TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; - - return TGaussPointID(aCellID,aLocalPntID); - } - - unsigned long int - TGaussSubMeshImpl - ::GetMemorySize() - { - size_t aSize = TSource::GetMemorySize(); - aSize += myPointCoords.GetMemorySize(); - return aSize; - } - - //--------------------------------------------------------------- - bool - operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) - { - PGaussSubMeshImpl aLeft(theLeft), aRight(theRight); - const PGaussImpl& aGaussLeft = aLeft->myGauss; - const PGaussImpl& aGaussRight = aRight->myGauss; - - if(aGaussLeft->myGeom != aGaussRight->myGeom) - return aGaussLeft->myGeom < aGaussRight->myGeom; - - if(aLeft->mySubProfile != aRight->mySubProfile) - return aLeft->mySubProfile < aRight->mySubProfile; - - bool aResult; - aGaussLeft->LessThan(aGaussRight,aResult); - - return aResult; - } - - - //--------------------------------------------------------------- - TGaussMeshImpl - ::TGaussMeshImpl(): - myParent(NULL) - {} - - TGaussPointID - TGaussMeshImpl - ::GetObjID(vtkIdType theID) const - { - vtkIdType anInputID, aStartId, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID); - const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID]; - - return aSubMeshImpl.GetObjID(anInputID,aStartId); - } - - TVTKOutput* - TGaussMeshImpl - ::GetVTKOutput() - { - return mySource.GetVTKOutput(); - } - - unsigned long int - TGaussMeshImpl - ::GetMemorySize() - { - size_t aSize = TAppendFilter::GetMemorySize(); - aSize += mySource.GetMemorySize(); - TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.begin(); - TGeom2GaussSubMesh::const_iterator anIterEnd = myGeom2GaussSubMesh.end(); - for(; anIter != anIterEnd; anIter++){ - const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; - aSize += aGaussSubMesh->GetMemorySize(); - aSize += sizeof(EGeometry); - } - return aSize; - } - - TNamedIDMapper* - TGaussMeshImpl:: - GetParent() - { - return myParent; - } - - - //--------------------------------------------------------------- - TGaussPointID - TGaussPtsIDFilter - ::GetObjID(vtkIdType theID) const - { - return myGaussPtsIDMapper->GetObjID(theID); - } - - TNamedIDMapper* - TGaussPtsIDFilter:: - GetParent() - { - return myGaussPtsIDMapper->GetParent(); - } - - - //--------------------------------------------------------------- - vtkIdType - TSubMeshImpl - ::GetElemObjID(vtkIdType theID) const - { - return myStartID + theID; - } - - std::string - TSubMeshImpl - ::GetElemName(vtkIdType theObjID) const - { - return ""; - } - - unsigned long int - TSubMeshImpl - ::GetMemorySize() - { - size_t aSize = TSource::GetMemorySize(); - for(size_t anId = 0; anId < myCell2Connect.size(); anId++){ - const TConnect& aConnect = myCell2Connect[anId]; - aSize += aConnect.size() * sizeof(vtkIdType); - } - return aSize; - } - - //--------------------------------------------------------------- - vtkIdType - TMeshOnEntityImpl - ::GetNodeVTKID(vtkIdType theID) const - { - return myNamedPointCoords->GetVTKID(theID); - } - - vtkIdType - TMeshOnEntityImpl - ::GetNodeObjID(vtkIdType theID) const - { - return myNamedPointCoords->GetObjID(theID); - } - - vtkIdType - TMeshOnEntityImpl - ::GetElemVTKID(vtkIdType theID) const - { - if(myElemObj2VTKID.empty()) - return theID; - else{ - TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); - if(anIter != myElemObj2VTKID.end()) - return anIter->second; - } - return -1; - } - - vtkIdType - TMeshOnEntityImpl - ::GetElemObjID(vtkIdType theID) const - { - vtkIdType anInputID, aStartId, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID); - const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID]; - return aSubMesh->GetElemObjID(anInputID); - } - - std::string - TMeshOnEntityImpl - ::GetNodeName(vtkIdType theObjID) const - { - return myNamedPointCoords->GetNodeName(theObjID); - } - - std::string - TMeshOnEntityImpl - ::GetElemName(vtkIdType theObjID) const - { - vtkIdType aVTKId = GetElemVTKID(theObjID); - vtkIdType anInputID, aStartId, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartId,anInputDataSetID); - const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID]; - return aSubMesh->GetElemName(anInputID); - } - - unsigned long int - TMeshOnEntityImpl - ::GetMemorySize() - { - size_t aSize = TAppendFilter::GetMemorySize(); - aSize += myNamedPointCoords->GetMemorySize(); - aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); - TGeom2SubMesh::const_iterator anIter = myGeom2SubMesh.begin(); - TGeom2SubMesh::const_iterator anIterEnd = myGeom2SubMesh.end(); - for(; anIter != anIterEnd; anIter++){ - const PSubMeshImpl& aSubMesh = anIter->second; - aSize += aSubMesh->GetMemorySize(); - aSize += sizeof(EGeometry); - } - return aSize; - } - - //--------------------------------------------------------------- - vtkIdType - TFamilyImpl - ::GetElemVTKID(vtkIdType theID) const - { - if(myElemObj2VTKID.empty()) - return theID; - else{ - TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); - if(anIter != myElemObj2VTKID.end()) - return anIter->second; - } - return -1; - } - - vtkIdType - TFamilyImpl - ::GetElemObjID(vtkIdType theID) const - { - return myMeshID[theID]; - } - - vtkIdType - TFamilyImpl - ::GetNodeObjID(vtkIdType theID) const - { - return myNamedPointCoords->GetObjID(theID); - } - - vtkIdType - TFamilyImpl - ::GetNodeVTKID(vtkIdType theID) const - { - return myNamedPointCoords->GetVTKID(theID); - } - - TVTKOutput* - TFamilyImpl - ::GetVTKOutput() - { - return TSource::GetVTKOutput(); - } - - unsigned long int - TFamilyImpl - ::GetMemorySize() - { - size_t aSize = TSource::GetMemorySize(); - aSize += myNamedPointCoords->GetMemorySize(); - aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); - aSize += myMeshID.size() * sizeof(vtkIdType); - TGeom2SubMeshID::const_iterator anIter = myGeom2SubMeshID.begin(); - TGeom2SubMeshID::const_iterator anIterEnd = myGeom2SubMeshID.end(); - for(; anIter != anIterEnd; anIter++){ - const TSubMeshID& aSubMeshID = anIter->second; - aSize += aSubMeshID.size() * sizeof(vtkIdType); - aSize += sizeof(EGeometry); - } - return aSize; - } - +#include "VISU_Structures_impl.hxx" +#include "VISU_PointCoords.hxx" +#include "VISU_MeshValue.hxx" - //--------------------------------------------------------------- - TNbASizeCells - TGroupImpl - ::GetNbASizeCells() const - { - vtkIdType aNbCells = 0, aCellsSize = 0; - TFamilySet::const_iterator anIter = myFamilySet.begin(); - for(; anIter != myFamilySet.end(); anIter++){ - PFamilyImpl aFamily = *anIter; - aNbCells += aFamily->myNbCells; - aCellsSize += aFamily->myCellsSize; - } - return make_pair(aNbCells,aCellsSize); - } - - vtkIdType - TGroupImpl - ::GetElemVTKID(vtkIdType theID) const - { - if(myElemObj2VTKID.empty()) - return theID; - else{ - TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); - if(anIter != myElemObj2VTKID.end()) - return anIter->second; - } - return -1; - } - - vtkIdType - TGroupImpl - ::GetElemObjID(vtkIdType theID) const - { - vtkIdType anInputID, aStartId, anInputDataSetID; - const TVTKAppendFilter& anAppendFilter = GetFilter(); - anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID); - const PFamilyImpl& aFamily = myFamilyArr[anInputDataSetID]; - return aFamily->GetElemObjID(anInputID); - } - - vtkIdType - TGroupImpl - ::GetNodeObjID(vtkIdType theID) const - { - return myNamedPointCoords->GetObjID(theID); - } - - vtkIdType - TGroupImpl - ::GetNodeVTKID(vtkIdType theID) const - { - return myNamedPointCoords->GetVTKID(theID); - } - - unsigned long int - TGroupImpl - ::GetMemorySize() - { - size_t aSize = TAppendFilter::GetMemorySize(); - aSize += myNamedPointCoords->GetMemorySize(); - aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); - for(size_t anId = 0; anId < myFamilyArr.size(); anId++){ - const PFamilyImpl& aFamily = myFamilyArr[anId]; - aSize += aFamily->GetMemorySize(); - } - return aSize; - } - - - - //--------------------------------------------------------------- - TFieldImpl - ::TFieldImpl(): - myDataSize(0), - myDataType(0) - {} - - void - TFieldImpl - ::Init(vtkIdType theNbComp, - vtkIdType theDataType) - { - myNbComp = theNbComp; - myDataType = theDataType; - myCompNames.resize(theNbComp); - myUnitNames.resize(theNbComp); - myMinMaxArr.resize(theNbComp + 1); - for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){ - TMinMax& aMinMax = myMinMaxArr[iComp]; - aMinMax.first = VTK_LARGE_FLOAT; - aMinMax.second = -VTK_LARGE_FLOAT; - } - } - - vtkIdType - TFieldImpl - ::GetDataType() const - { - return myDataType; - } - - TMinMax - TFieldImpl - ::GetMinMax(vtkIdType theCompID) - { - return myMinMaxArr[theCompID]; - } - - - //--------------------------------------------------------------- - void - TMeshValueBase - ::Init(vtkIdType theNbElem, - vtkIdType theNbGauss, - vtkIdType theNbComp) - { - myNbElem = theNbElem; - myNbGauss = theNbGauss; - myNbComp = theNbComp; - myStep = theNbComp*theNbGauss; - } - - vtkIdType - TMeshValueBase - ::GetNbElem() const - { - return myNbElem; - } - - vtkIdType - TMeshValueBase - ::GetNbComp() const - { - return myNbComp; - } - - vtkIdType - TMeshValueBase - ::GetNbGauss() const - { - return myNbGauss; - } - - size_t - TMeshValueBase - ::size() const - { - return myNbElem * myStep; - } - - - //---------------------------------------------------------------------------- - const PMeshValue& - TGeom2Value - ::GetMeshValue(EGeometry theGeom) const - { - TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom); - if(anIter == myGeom2MeshValue.end()) - EXCEPTION(runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails"); - return anIter->second; - } - - PMeshValue& - TGeom2Value - ::GetMeshValue(EGeometry theGeom) - { - return myGeom2MeshValue[theGeom]; - } - - - //---------------------------------------------------------------------------- - TGeom2MeshValue& - TGeom2Value - ::GetGeom2MeshValue() - { - return myGeom2MeshValue; - } - - const TGeom2MeshValue& - TGeom2Value - ::GetGeom2MeshValue() const - { - return myGeom2MeshValue; - } - - PMeshValue - TGeom2Value - ::GetFirstMeshValue() const - { - if(myGeom2MeshValue.size() == 1) - return myGeom2MeshValue.begin()->second; - return PMeshValue(); - } - - namespace TL - { - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > > > > - TVTKBasicTypeList; - - - //---------------------------------------------------------------------------- - typedef TList > > > > > > > > > > > > - TVTKArrayTypeList; - - - typedef TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TList, - TNullType> > > > > > > > > > > > > - TVTKBasicEnumList; - - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKBasicType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TEnum2VTKArrayType - { - typedef typename TTypeAt >::value >::TResult TResult; - }; - - //---------------------------------------------------------------------------- - template - struct TVTKBasicType2Enum - { - typedef typename TTypeAt::value >::TResult TResult; - }; - - } - - - //---------------------------------------------------------------------------- - template - void - InitTimeStampOnProfile(const TVTKSource& theSource, - const PFieldImpl& theField, - const PValForTimeImpl& theValForTime, - const VISU::TEntity& theEntity); - - - //---------------------------------------------------------------------------- - void - GetTimeStampOnProfile(const TVTKSource& theSource, - const PFieldImpl& theField, - const PValForTimeImpl& theValForTime, - const VISU::TEntity& theEntity) - { - vtkIdType aDataType = theField->GetDataType(); - switch(aDataType){ - case VTK_DOUBLE: - InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); - break; - case VTK_FLOAT: - InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); - break; - case VTK_INT: - InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); - break; - case VTK_LONG: - InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); - break; - default: - EXCEPTION(runtime_error, - "GetTimeStampOnProfile - handling unsupported data type - "< - struct TDataArrayHolder - { - typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - TVTKDataArray* myDataArray; - - TDataArrayHolder(TVTKDataArray* theDataArray): - myDataArray(theDataArray) - {} - - void - WritePointer(TVTKDataArray* theDataArray, - vtkIdType theTupleId, - TVTKBasicType* thePointer) - { - vtkIdType aNumberOfComponents = theDataArray->GetNumberOfComponents(); - vtkIdType aPosition = theTupleId * aNumberOfComponents; - TVTKBasicType *aPtr = theDataArray->WritePointer(aPosition, aNumberOfComponents); - for(vtkIdType anId = 0; anId < aNumberOfComponents; anId++) - *aPtr++ = *thePointer++; - } - - virtual - void - SetTuple(vtkIdType theTupleId, - TVTKBasicType* thePointer) - { - this->WritePointer(myDataArray, theTupleId, thePointer); - } - }; - - - //---------------------------------------------------------------------------- - template - struct TDataArrayHolder2: TDataArrayHolder - { - typedef TDataArrayHolder TSuperClass; - typedef typename TSuperClass::TVTKDataArray TVTKDataArray; - typedef typename TSuperClass::TVTKBasicType TVTKBasicType; - TVTKDataArray* myDataArray2; - - TDataArrayHolder2(TVTKDataArray* theDataArray, - TVTKDataArray* theDataArray2): - TSuperClass(theDataArray), - myDataArray2(theDataArray2) - {} - - virtual - void - SetTuple(vtkIdType theTupleId, - TVTKBasicType* thePointer) - { - this->WritePointer(this->myDataArray, theTupleId, thePointer); - this->WritePointer(this->myDataArray2, theTupleId, thePointer); - } - }; - - - //---------------------------------------------------------------------------- - template - struct TTimeStampOnProfileInitArray - { - typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef SharedPtr TMeshValuePtr; - - typedef TDataArrayHolder TTDataArrayHolder; - typedef SharedPtr PDataArrayHolder; - PDataArrayHolder myDataArrayHolder; - - TTimeStampOnProfileInitArray(const PDataArrayHolder& theDataArrayHolder): - myDataArrayHolder(theDataArrayHolder) - {} - - void - Execute(const PFieldImpl& theField, - const PValForTimeImpl& theValForTime) - { - vtkIdType aNbComp = theField->myNbComp; - vtkIdType aSize = max(3, aNbComp); - TVector aDataValues(aSize); - - const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue(); - TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); - for(int aTupleId = 0; anIter != aGeom2MeshValue.end(); anIter++){ - EGeometry aEGeom = anIter->first; - const TMeshValuePtr aMeshValue = anIter->second; - - vtkIdType aNbElem = aMeshValue->GetNbElem(); - vtkIdType aNbGauss = aMeshValue->GetNbGauss(); - - INITMSG(MYDEBUG, - "- aEGeom = "<AddArray(aFullDataArray); - - INITMSG(MYDEBUG,"InitTimeStampOnProfile "<< - "- theEntity = "<GetGeom2MeshValue(); - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef SharedPtr TMeshValuePtr; - - typedef TDataArrayHolder TTDataArrayHolder; - typedef SharedPtr PDataArrayHolder; - - TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); - if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){ - aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); - INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); - INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<(aDataArrayHolder).Execute(theField, theValForTime); - } - }else{ - typedef TDataArrayHolder2 TTDataArrayHolder2; - PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray)); - TTimeStampOnProfileInitArray(aDataArrayHolder).Execute(theField, theValForTime); - } - - aSelectedDataArray->Delete(); - aFullDataArray->Delete(); - } - - - //---------------------------------------------------------------------------- - template - void - InitTimeStampOnGaussMesh(const TVTKSource& theSource, - const PFieldImpl& theField, - const PValForTimeImpl& theValForTime); - - void - GetTimeStampOnGaussMesh(const TVTKSource& theSource, - const PFieldImpl& theField, - const PValForTimeImpl& theValForTime) - { - vtkIdType aDataType = theField->GetDataType(); - switch(aDataType){ - case VTK_DOUBLE: - InitTimeStampOnGaussMesh(theSource, theField, theValForTime); - break; - case VTK_FLOAT: - InitTimeStampOnGaussMesh(theSource, theField, theValForTime); - break; - case VTK_INT: - InitTimeStampOnGaussMesh(theSource, theField, theValForTime); - break; - case VTK_LONG: - InitTimeStampOnGaussMesh(theSource, theField, theValForTime); - break; - default: - EXCEPTION(runtime_error, - "GetTimeStampOnGaussMesh - handling unsupported data type - "< - struct TTimeStampOnGaussMeshInitArray - { - typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef SharedPtr TMeshValuePtr; - - typedef TDataArrayHolder TTDataArrayHolder; - typedef SharedPtr PDataArrayHolder; - PDataArrayHolder myDataArrayHolder; - - TTimeStampOnGaussMeshInitArray(const PDataArrayHolder& theDataArrayHolder): - myDataArrayHolder(theDataArrayHolder) - {} - - void - Execute(const PFieldImpl& theField, - const PValForTimeImpl& theValForTime) - { - vtkIdType aNbComp = theField->myNbComp; - vtkIdType aSize = max(3, aNbComp); - TVector aDataValues(aSize); - - const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue(); - - PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh; - const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; - TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); - for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){ - EGeometry aEGeom = anIter->first; - - PGaussSubMeshImpl aGaussSubMesh = anIter->second; - if(!aGaussSubMesh->myIsDone) - continue; - - TGeom2MeshValue::const_iterator anIter2 = aGeom2MeshValue.find(aEGeom); - if(anIter2 == aGeom2MeshValue.end()){ - EXCEPTION(runtime_error, - "TTimeStampOnGaussMeshInitArray >> Can't find values for corresponding Gauss Points SubMesh"); - } - TMeshValuePtr aMeshValue = anIter2->second; - vtkIdType aNbGauss = aMeshValue->GetNbGauss(); - vtkIdType aNbElem = aMeshValue->GetNbElem(); - - if(aNbGauss < 1) - continue; - - const TPointCoords& aCoords = aGaussSubMesh->myPointCoords; - - INITMSG(MYDEBUG, - "- aEGeom = "<AddArray(aFullDataArray); - - INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh "<< - "- aNbTuples = "<GetGeom2MeshValue(); - typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; - typedef TTMeshValue TMeshValue; - typedef SharedPtr TMeshValuePtr; - - typedef TDataArrayHolder TTDataArrayHolder; - typedef SharedPtr PDataArrayHolder; - - TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); - if(aGeom2MeshValue.size() == 1){ - aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); - INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), - aMeshValue->size(), - true); - INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aSelectedDataArray->SetVoidArray()"<(aDataArrayHolder).Execute(theField, theValForTime); - } - }else{ - typedef TDataArrayHolder2 TTDataArrayHolder2; - PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray)); - TTimeStampOnGaussMeshInitArray(aDataArrayHolder).Execute(theField, theValForTime); - } - - aSelectedDataArray->Delete(); - aFullDataArray->Delete(); - } - - //--------------------------------------------------------------- - TValForTimeImpl - ::TValForTimeImpl(): - myGaussPtsIDFilter(new TGaussPtsIDFilter()), - myIDMapperFilter(new TIDMapperFilter()) - {} - - const PMeshValue& - TValForTimeImpl - ::GetMeshValue(EGeometry theGeom) const - { - return myGeom2Value.GetMeshValue(theGeom); - } - - PMeshValue& - TValForTimeImpl - ::GetMeshValue(EGeometry theGeom) - { - return myGeom2Value.GetMeshValue(theGeom); - } - - TGeom2MeshValue& - TValForTimeImpl - ::GetGeom2MeshValue() - { - return myGeom2Value.GetGeom2MeshValue(); - } - - const TGeom2MeshValue& - TValForTimeImpl - ::GetGeom2MeshValue() const - { - return myGeom2Value.GetGeom2MeshValue(); - } - - PMeshValue - TValForTimeImpl - ::GetFirstMeshValue() const - { - return myGeom2Value.GetFirstMeshValue(); - } - - int - TValForTimeImpl - ::GetNbGauss(EGeometry theGeom) const - { - TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom); - if(anIter == myGeom2NbGauss.end()){ - return 1; - } - return anIter->second; - } - - unsigned long int - TValForTimeImpl - ::GetMemorySize() - { - size_t aSize = sizeof(TValForTimeImpl); - const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue(); - TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); - TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end(); - for(; anIter != anIterEnd; anIter++){ - const PMeshValue& aMeshValue = anIter->second; - aSize += aMeshValue->GetMemorySize(); - aSize += sizeof(EGeometry); - } - return aSize; - } - - - - //--------------------------------------------------------------- - vtkIdType - VISUGeom2NbNodes(EGeometry theGeom) - { - switch(theGeom){ -#ifndef VISU_ENABLE_QUADRATIC - case VISU::eSEG3: - return 2; - case VISU::eTRIA6: - return 3; - case VISU::eQUAD8: - return 4; - case VISU::eTETRA10: - return 4; - case VISU::eHEXA20: - return 8; - case VISU::ePENTA15: - return 6; - case VISU::ePYRA13: - return 5; -#endif - case VISU::ePOLYGONE: - case VISU::ePOLYEDRE: - return -1; - default: - return theGeom % 100; - } - } +#include "VISU_AppendPolyData.hxx" +#include "VTKViewer_AppendFilter.h" +#include "VTKViewer_CellLocationsArray.h" - vtkIdType - VISUGeom2VTK(EGeometry theGeom) - { - switch(theGeom){ - case VISU::ePOINT1: - return VTK_VERTEX; - case VISU::eSEG2: - return VTK_LINE; - case VISU::eTRIA3: - return VTK_TRIANGLE; - case VISU::eQUAD4: - return VTK_QUAD; - case VISU::eTETRA4: - return VTK_TETRA; - case VISU::eHEXA8: - return VTK_HEXAHEDRON; - case VISU::ePENTA6: - return VTK_WEDGE; - case VISU::ePYRA5: - return VTK_PYRAMID; - - case VISU::ePOLYGONE: - return VTK_POLYGON; - case VISU::ePOLYEDRE: - return VTK_CONVEX_POINT_SET; - -#ifndef VISU_ENABLE_QUADRATIC - case VISU::eSEG3: - return VTK_LINE; - case VISU::eTRIA6: - return VTK_TRIANGLE; - case VISU::eQUAD8: - return VTK_QUAD; - case VISU::eTETRA10: - return VTK_TETRA; - case VISU::eHEXA20: - return VTK_HEXAHEDRON; - case VISU::ePENTA15: - return VTK_WEDGE; - case VISU::ePYRA13: - return VTK_PYRAMID; +#include "VISU_ConvertorUtils.hxx" -#else +#include +#include - case VISU::eSEG3: -#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_EDGE; -#else - return VTK_POLY_LINE; -#endif +#include +#include +#include - case VISU::eTRIA6: -#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_TRIANGLE; -#else - return VTK_POLYGON; -#endif +#include +#include +#include +#include +#include - case VISU::eQUAD8: -#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_QUAD; -#else - return VTK_POLYGON; -#endif +#include +#include - case VISU::eTETRA10: -#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_TETRA; -#else - return VTK_CONVEX_POINT_SET; -#endif +#include - case VISU::eHEXA20: -#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_HEXAHEDRON; -#else - return VTK_CONVEX_POINT_SET; -#endif +static vtkFloatingPointType ERR_SIZE_CALC = 1.00; - case VISU::ePENTA15: -#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_WEDGE; -#else - return VTK_CONVEX_POINT_SET; -#endif +static int MYVTKDEBUG = 0; - case VISU::ePYRA13: -#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC) - return VTK_QUADRATIC_PYRAMID; +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +//#define _DEXCEPT_ #else - return VTK_CONVEX_POINT_SET; +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; #endif -#endif //VISU_ENABLE_QUADRATIC - - default: - return -1; - } - } -} - namespace { @@ -2054,12 +98,12 @@ namespace //--------------------------------------------------------------- void - GetCellsOnSubMesh(const TVTKSource& theSource, - const PMeshOnEntityImpl& theMeshOnEntity, - const PSubMeshImpl& theSubMesh, + GetCellsOnSubMesh(const VISU::PUnstructuredGrid& theSource, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PSubMeshImpl& theSubMesh, const vtkIdType theGeom) { - TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh"); + VISU::TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh"); const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect; vtkIdType aCellsSize = theSubMesh->myCellsSize; vtkIdType aNbCells = theSubMesh->myNbCells; @@ -2099,9 +143,9 @@ namespace //--------------------------------------------------------------- void - GetCellsOnFamily(const TVTKSource& theSource, - const PMeshOnEntityImpl& theMeshOnEntity, - const PFamilyImpl& theFamily) + GetCellsOnFamily(const VISU::PUnstructuredGrid& theSource, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PFamilyImpl& theFamily) { INITMSG(MYDEBUG,"GetCellsOnFamily"<SetNumberOfComponents(1); aCellTypesArray->SetNumberOfTuples(aNbCells); - TSubMeshID& aMeshID = theFamily->myMeshID; + VISU::TSubMeshID& aMeshID = theFamily->myMeshID; aMeshID.resize(aNbCells); VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID; @@ -2130,7 +174,7 @@ namespace const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; if(aGeom2SubMeshID.empty()) - EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!"); + EXCEPTION(std::runtime_error,"GetCells >> There is no elements on the family !!!"); VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom); if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end()) @@ -2173,10 +217,10 @@ namespace //--------------------------------------------------------------- void - GetCells(const TVTKSource& theSource, - const PSubProfileImpl& theSubProfile, - const PProfileImpl& theProfile, - const PMeshOnEntityImpl& theMeshOnEntity) + GetCells(const VISU::PUnstructuredGrid& theSource, + const VISU::PSubProfileImpl& theSubProfile, + const VISU::PProfileImpl& theProfile, + const VISU::PMeshOnEntityImpl& theMeshOnEntity) { vtkIdType aNbCells = theSubProfile->myNbCells; vtkIdType aCellsSize = theSubProfile->myCellsSize; @@ -2186,15 +230,15 @@ namespace INITMSG(MYDEBUG,"GetCells - aVGeom = "<mySubMeshID; + const VISU::TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID; const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom); if(anIter == aGeom2SubMesh.end()) - EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<> There is no elements for the GEOM("<second; - const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; + const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect; vtkCellArray* aConnectivity = vtkCellArray::New(); aConnectivity->Allocate(aCellsSize,0); @@ -2202,10 +246,10 @@ namespace aCellTypesArray->SetNumberOfComponents(1); aCellTypesArray->SetNumberOfTuples(aNbCells); - if(theSubProfile->myStatus == eAddAll){ + if(theSubProfile->myStatus == VISU::eAddAll){ VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin(); for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){ - const TConnect& anArray = aCell2Connect[anId]; + const VISU::TConnect& anArray = aCell2Connect[anId]; PrintCells(aConnId,aConnectivity,anArray); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; @@ -2215,7 +259,7 @@ namespace VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin(); for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){ vtkIdType aSubId = *anIter; - const TConnect& anArray = aCell2Connect[aSubId]; + const VISU::TConnect& anArray = aCell2Connect[aSubId]; PrintCells(aConnId,aConnectivity,anArray); aCellTypesArray->SetValue(anId,(unsigned char)aVGeom); aConnId += aNbNodes; @@ -2241,14 +285,14 @@ namespace //--------------------------------------------------------------- void - GetMeshOnSubProfile(const PMeshImpl& theMesh, - const PMeshOnEntityImpl& theMeshOnEntity, - const PProfileImpl& theProfile, - const PSubProfileImpl& theSubProfile) + GetMeshOnSubProfile(const VISU::PMeshImpl& theMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PProfileImpl& theProfile, + const VISU::PSubProfileImpl& theSubProfile) { INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<myGeom<GetSource(); + const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource(); if(theSubProfile->myIsVTKDone) return; @@ -2263,35 +307,35 @@ namespace //--------------------------------------------------------------- void - GetMeshOnProfile(const PMeshImpl& theMesh, - const PMeshOnEntityImpl& theMeshOnEntity, - const PProfileImpl& theProfile) + GetMeshOnProfile(const VISU::PMeshImpl& theMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PProfileImpl& theProfile) { if(theProfile->myIsVTKDone) return; - TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile"); + VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile"); INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<myEntity<myMeshOnEntity = theMeshOnEntity.get(); - const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter(); + const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter(); anAppendFilter->SetPoints(theMesh->GetPoints()); if(theProfile->myIsAll){ - TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput(); + vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput(); anAppendFilter->AddInput(aDataSet); }else{ - const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; + const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile; - TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID; + VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID; - TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr; + VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr; aSubProfileArr.resize(aGeom2SubProfile.size()); - TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); + VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){ - PSubProfileImpl aSubProfile = anIter->second; - if(aSubProfile->myStatus == eRemoveAll) + VISU::PSubProfileImpl aSubProfile = anIter->second; + if(aSubProfile->myStatus == VISU::eRemoveAll) continue; GetMeshOnSubProfile(theMesh, @@ -2299,7 +343,7 @@ namespace theProfile, aSubProfile); - const TVTKSource& aSource = aSubProfile->GetSource(); + const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource(); anAppendFilter->AddInput(aSource.GetPointer()); vtkIdType aNbCells = aSource->GetNumberOfCells(); @@ -2319,58 +363,41 @@ namespace //--------------------------------------------------------------- void - GetSource(const TVTKSource& theSource, - const PGaussSubMeshImpl& theGaussSubMesh, - const PMeshOnEntityImpl& theMeshOnEntity) + GetSource(const VISU::PPolyData& theSource, + const VISU::PGaussSubMeshImpl& theGaussSubMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity) { - const TPointCoords& aCoords = theGaussSubMesh->myPointCoords; - vtkIdType aNbPoints = aCoords.GetNbPoints(); - - vtkIdType aNbCells = theGaussSubMesh->myNbCells; - vtkIdType aCellsSize = theGaussSubMesh->myCellsSize; - vtkCellArray* aConnectivity = vtkCellArray::New(); - aConnectivity->Allocate(aCellsSize,0); - vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); - aCellTypesArray->SetNumberOfComponents(1); - aCellTypesArray->SetNumberOfTuples(aNbCells); + vtkIdType aCellsSize = theGaussSubMesh->myCellsSize; + aConnectivity->Allocate(aCellsSize, 0); vtkIdList *anIdList = vtkIdList::New(); anIdList->SetNumberOfIds(1); + + const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords; + vtkIdType aNbPoints = aCoords.GetNbPoints(); for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){ anIdList->SetId(0, aPointId); aConnectivity->InsertNextCell(anIdList); - aCellTypesArray->SetValue(aPointId, (unsigned char)VTK_VERTEX); } anIdList->Delete(); - VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); - aCellLocationsArray->SetNumberOfComponents(1); - aCellLocationsArray->SetNumberOfTuples(aNbCells); - - vtkIdType *pts = 0, npts = 0; - aConnectivity->InitTraversal(); - for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++) - aCellLocationsArray->SetValue(i, aConnectivity->GetTraversalLocation(npts)); - - const TVTKSource& aSource = theGaussSubMesh->GetSource(); - aSource->SetCells(aCellTypesArray, aCellLocationsArray, aConnectivity); + const VISU::PPolyData& aSource = theGaussSubMesh->GetSource(); + aSource->SetVerts(aConnectivity); aSource->SetPoints(aCoords.GetPoints()); - aCellLocationsArray->Delete(); - aCellTypesArray->Delete(); aConnectivity->Delete(); } //--------------------------------------------------------------- void - GetGaussSubMesh(const PMeshImpl& theMesh, - const PMeshOnEntityImpl& theMeshOnEntity, - const PGaussMeshImpl& theGaussMesh, - const PGaussSubMeshImpl& theGaussSubMesh) + GetGaussSubMesh(const VISU::PMeshImpl& theMesh, + const VISU::PMeshOnEntityImpl& theMeshOnEntity, + const VISU::PGaussMeshImpl& theGaussMesh, + const VISU::PGaussSubMeshImpl& theGaussSubMesh) { - PGaussImpl aGauss = theGaussSubMesh->myGauss; + VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss; if(!theGaussSubMesh->myIsDone) return; @@ -2378,11 +405,11 @@ namespace if(theGaussSubMesh->myIsVTKDone) return; - TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh"); + VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh"); INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<myGeom<GetSource(); - GetSource(aSource,theGaussSubMesh,theMeshOnEntity); + const VISU::PPolyData& aSource = theGaussSubMesh->GetSource(); + GetSource(aSource, theGaussSubMesh, theMeshOnEntity); INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<GetNumberOfPoints()<GetNumberOfCells()<myIsVTKDone) return; - TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh"); - const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter(); - const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh; - TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh"); + const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter(); + const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh; + VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); for(; anIter != aGeom2GaussSubMesh.end(); anIter++){ - PGaussSubMeshImpl aGaussSubMesh = anIter->second; - if(aGaussSubMesh->myStatus == eRemoveAll) + VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second; + if(aGaussSubMesh->myStatus == VISU::eRemoveAll) continue; GetGaussSubMesh(theMesh, @@ -2414,13 +441,13 @@ namespace theGaussMesh, aGaussSubMesh); - const TVTKSource& aSource = aGaussSubMesh->GetSource(); + const VISU::PPolyData& aSource = aGaussSubMesh->GetSource(); anAppendFilter->AddInput(aSource.GetPointer()); } anAppendFilter->Update(); // Fix on VTK - theMeshOnEntity->GetVTKOutput()->Update(); + theMeshOnEntity->GetOutput()->Update(); vtkDataSet* aSource = anAppendFilter->GetOutput(); INITMSGA(MYDEBUG,0,"aNbPoints - "<GetNumberOfPoints()<(aFindMeshOnEntity);; - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); //Main part of code #ifndef _DEXCEPT_ try{ #endif if(!aMeshOnEntity->myIsVTKDone){ - TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity"); - const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter(); + VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity"); + const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter(); if(MYVTKDEBUG) anAppendFilter->DebugOn(); LoadMeshOnEntity(aMesh,aMeshOnEntity); anAppendFilter->SetPoints(aMesh->GetPoints()); - const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; - TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin(); + const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin(); - TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID; - TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr; + VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID; + VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr; aSubMeshArr.resize(aGeom2SubMesh.size()); for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){ - EGeometry aEGeom = anIter->first; + VISU::EGeometry aEGeom = anIter->first; vtkIdType aVGeom = VISUGeom2VTK(aEGeom); - PSubMeshImpl aSubMesh = anIter->second; - const TVTKSource& aSource = aSubMesh->GetSource(); + VISU::PSubMeshImpl aSubMesh = anIter->second; + const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource(); aSource->SetPoints(aMesh->GetPoints()); GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom); anAppendFilter->AddInput(aSource.GetPointer()); @@ -2566,7 +593,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-"; + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); } @@ -2588,7 +615,7 @@ VISU_Convertor_impl //--------------------------------------------------------------- -VISU::PIDMapper +VISU::PUnstructuredGridIDMapper VISU_Convertor_impl ::GetFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, @@ -2604,16 +631,16 @@ VISU_Convertor_impl TFindFamilyOnEntity aFindFamilyOnEntity = FindFamilyOnEntity(theMeshName,theEntity,theFamilyName); - PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);; - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity); - PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); + VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);; + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity); + VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); //Main part of code #ifndef _DEXCEPT_ try{ #endif if(!aFamily->myIsVTKDone){ - const TVTKSource& aSource = aFamily->GetSource(); + const VISU::PUnstructuredGrid& aSource = aFamily->GetSource(); if(MYVTKDEBUG) aSource->DebugOn(); GetMeshOnEntity(theMeshName,theEntity); @@ -2629,7 +656,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-"; + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk"; VISU::WriteToFile(aSource.GetPointer(),aFileName); } @@ -2651,10 +678,10 @@ VISU_Convertor_impl //--------------------------------------------------------------- -VISU::PIDMapper +VISU::PUnstructuredGridIDMapper VISU_Convertor_impl -::GetMeshOnGroup(const string& theMeshName, - const string& theGroupName) +::GetMeshOnGroup(const std::string& theMeshName, + const std::string& theGroupName) { INITMSG(MYDEBUG,"GetMeshOnGroup\n"); INITMSGA(MYDEBUG,0, @@ -2664,33 +691,33 @@ VISU_Convertor_impl //Cheching possibility do the query TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName); - PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); - PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); + VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); //Main part of code #ifndef _DEXCEPT_ try{ #endif if(!aGroup->myIsVTKDone){ - const TVTKAppendFilter& anAppendFilter = aGroup->GetFilter(); + const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter(); const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet; LoadMeshOnGroup(aMesh,aFamilySet); anAppendFilter->SetPoints(aMesh->GetPoints()); - TFamilySet::const_iterator anIter = aFamilySet.begin(); + VISU::TFamilySet::const_iterator anIter = aFamilySet.begin(); - TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID; - TFamilyArr& aFamilyArr = aGroup->myFamilyArr; + VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID; + VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr; aFamilyArr.resize(aFamilySet.size()); for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){ - PFamilyImpl aFamily = *anIter; + VISU::PFamilyImpl aFamily = *anIter; const std::string& aFamilyName = aFamily->myName; const VISU::TEntity& anEntity = aFamily->myEntity; VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName); - VISU::TVTKOutput* anOutput = anIDMapper->GetVTKOutput(); + vtkDataSet* anOutput = anIDMapper->GetOutput(); anAppendFilter->AddInput(anOutput); vtkIdType aStartID = anElemObj2VTKID.size(); @@ -2707,7 +734,7 @@ VISU_Convertor_impl if(MYDEBUGWITHFILES){ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1(); - std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-"; + std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk"; VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName); } @@ -2723,13 +750,13 @@ VISU_Convertor_impl //--------------------------------------------------------------- -VISU::TVTKOutput* +vtkUnstructuredGrid* VISU_Convertor_impl ::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh, const VISU::PMeshOnEntityImpl& theMeshOnEntity, const VISU::PFieldImpl& theField, const VISU::PValForTimeImpl& theValForTime, - const VISU::PIDMapperFilter& theIDMapperFilter, + const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper, const VISU::PProfileImpl& theProfile, const VISU::TEntity& theEntity) { @@ -2737,20 +764,20 @@ VISU_Convertor_impl GetMeshOnEntity(theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity); GetMeshOnProfile(theMesh, theMeshOnEntity, theProfile); - theIDMapperFilter->myIDMapper = theProfile; - TVTKOutput* anOutput = theIDMapperFilter->GetVTKOutput(); - const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource(); - ::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity); + theUnstructuredGridIDMapper->myIDMapper = theProfile; + vtkUnstructuredGrid* anOutput = theUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + const VISU::PUnstructuredGrid& aSource = theUnstructuredGridIDMapper->mySource.GetSource(); + VISU::GetTimeStampOnProfile(aSource, theField, theValForTime, theEntity); return anOutput; } //--------------------------------------------------------------- -VISU::PIDMapper +VISU::PUnstructuredGridIDMapper VISU_Convertor_impl -::GetTimeStampOnMesh(const string& theMeshName, +::GetTimeStampOnMesh(const std::string& theMeshName, const VISU::TEntity& theEntity, - const string& theFieldName, + const std::string& theFieldName, int theStampsNum) { INITMSG(MYDEBUG,"GetTimeStampOnMesh"<< @@ -2766,28 +793,28 @@ VISU_Convertor_impl theFieldName, theStampsNum); - PMeshImpl aMesh = boost::get<0>(aFindTimeStamp); - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp); - PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); - PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); - PFieldImpl aField = boost::get<3>(aFindTimeStamp); + VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp); + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp); + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); + VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); + VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp); //Main part of code - PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter; + VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper; #ifndef _DEXCEPT_ try{ #endif - if(!anIDMapperFilter->myIsVTKDone){ - TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh"); - LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime); + if(!anUnstructuredGridIDMapper->myIsVTKDone){ + VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh"); + LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime); - TVTKOutput* anOutput; + vtkUnstructuredGrid* anOutput = NULL; try{ anOutput = GetTimeStampOnProfile(aMesh, aVTKMeshOnEntity, aField, aValForTime, - anIDMapperFilter, + anUnstructuredGridIDMapper, aValForTime->myProfile, aMeshOnEntity->myEntity); }catch(std::exception& exc){ @@ -2796,23 +823,23 @@ VISU_Convertor_impl aMeshOnEntity, aField, aValForTime, - anIDMapperFilter, + anUnstructuredGridIDMapper, aValForTime->myProfile, aVTKMeshOnEntity->myEntity); } - anIDMapperFilter->myIsVTKDone = true; + anUnstructuredGridIDMapper->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); - string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-"; - string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + - aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; + std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); + std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); + std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; + std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + + aFieldName + dtos("-%d", theStampsNum) + "-Conv.vtk"; VISU::WriteToFile(anOutput,aFileName); } if(MYVTKDEBUG){ - GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum); + GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); anOutput->Update(); if(theEntity == VISU::NODE_ENTITY) BEGMSG(MYVTKDEBUG,"GetPointData() = "<GetPointData()->GetActualMemorySize()*1000)<(aFindTimeStamp); - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp); - PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; - PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); - PFieldImpl aField = boost::get<3>(aFindTimeStamp); + VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp); + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp); + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; + VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); + VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp); //Main part of code - PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter; + VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter; #ifndef _DEXCEPT_ try{ #endif if(!aGaussPtsIDFilter->myIsVTKDone){ - TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts"); - LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime); + VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts"); + LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime); - GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity); + GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity); - PProfileImpl aProfile = aValForTime->myProfile; - GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile); + VISU::PProfileImpl aProfile = aValForTime->myProfile; + GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile); - PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh; - TSource& aGaussPtsSource = aGaussMesh->mySource; + VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh; + VISU::TPolyDataHolder& aGaussPtsSource = aGaussMesh->mySource; if(!aGaussPtsSource.myIsVTKDone){ - BuildGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh); + BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh); aGaussMesh->myParent = aProfile.get(); aGaussPtsSource.myIsVTKDone = true; } aGaussPtsIDFilter->myIDMapper = aGaussMesh; aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh; - TVTKOutput* anOutput = aGaussPtsIDFilter->GetVTKOutput(); - const TVTKSource& aSource = aGaussPtsIDFilter->mySource.GetSource(); - GetTimeStampOnGaussMesh(aSource,aField,aValForTime); + vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput(); + const VISU::PPolyData& aSource = aGaussPtsIDFilter->mySource.GetSource(); + VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime); aGaussPtsIDFilter->myIsVTKDone = true; if(MYDEBUGWITHFILES){ - string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); - string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); - string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-"; - string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + + std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1(); + std::string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1(); + std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-"; + std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) + aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk"; - VISU::WriteToFile(anOutput,aFileName); + VISU::WriteToFile(anOutput, aFileName); } if(MYVTKDEBUG){ - GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum); + GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); anOutput->Update(); if(theEntity == VISU::NODE_ENTITY) BEGMSG(MYVTKDEBUG,"GetPointData() = "<GetPointData()->GetActualMemorySize()*1000)<> There is no mesh with the name - '"<> There is no mesh with the name - '"<second; + VISU::PMeshImpl aMesh = aMeshMapIter->second; return aMesh; } @@ -2937,16 +967,16 @@ VISU_Convertor_impl //--------------------------------------------------------------- VISU_Convertor_impl::TFindMeshOnEntity VISU_Convertor_impl -::FindMeshOnEntity(const string& theMeshName, +::FindMeshOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity) { - PMeshImpl aMesh = FindMesh(theMeshName); + VISU::PMeshImpl aMesh = FindMesh(theMeshName); VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity); if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) - EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<> There is no mesh on the entity - "<second; + VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second; return TFindMeshOnEntity(aMesh, aMeshOnEntity); @@ -2956,23 +986,23 @@ VISU_Convertor_impl //--------------------------------------------------------------- VISU_Convertor_impl::TFindFamilyOnEntity VISU_Convertor_impl -::FindFamilyOnEntity(const string& theMeshName, +::FindFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, - const string& theFamilyName) + const std::string& theFamilyName) { if(theFamilyName != ""){ - PMeshImpl aMesh = FindMesh(theMeshName); + VISU::PMeshImpl aMesh = FindMesh(theMeshName); VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity); if(aMeshOnEntityMapIter == aMeshOnEntityMap.end()) - EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<> There is no mesh on the entity - "<second; + VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second; - TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName); if(aFamilyMapIter != aFamilyMap.end()){ - const PFamily& aFamily = aFamilyMapIter->second; + const VISU::PFamily& aFamily = aFamilyMapIter->second; return TFindFamilyOnEntity(aMesh, aMeshOnEntity, aFamily); @@ -2991,7 +1021,7 @@ VISU_Convertor_impl const VISU::TMeshMap& aMeshMap = GetMeshMap(); VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin(); for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){ - const string& aMeshName = aMeshMapIter->first; + const std::string& aMeshName = aMeshMapIter->first; const VISU::PMesh aMesh = aMeshMapIter->second; const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter; @@ -3003,7 +1033,7 @@ VISU_Convertor_impl const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ - const string& aFieldName = aFieldMapIter->first; + const std::string& aFieldName = aFieldMapIter->first; const VISU::PField aField = aFieldMapIter->second; const VISU::TValField& aValField = aField->myValField; VISU::TValField::const_iterator aValFieldIter = aValField.begin(); @@ -3016,14 +1046,14 @@ VISU_Convertor_impl const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin(); for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){ - const string& aGroupName = aGroupMapIter->first; + const std::string& aGroupName = aGroupMapIter->first; aResult += GetMeshOnGroupSize(aMeshName,aGroupName); } //Import families const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ - const string& aFamilyName = aFamilyMapIter->first; + const std::string& aFamilyName = aFamilyMapIter->first; aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName); } //Import mesh on entity @@ -3044,8 +1074,8 @@ VISU_Convertor_impl TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName, theEntity); - PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity); - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity); + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord); size_t aNbCells = aMeshOnEntity->myNbCells; @@ -3086,9 +1116,9 @@ VISU_Convertor_impl { TFindFamilyOnEntity aFindFamilyOnEntity = FindFamilyOnEntity(theMeshName,theEntity,theFamilyName); - PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity); - PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity); + VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity); + VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity); + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity); size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord); size_t aNbCells = aFamily->myNbCells; @@ -3127,11 +1157,11 @@ VISU_Convertor_impl ::FindMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName) { - PMeshImpl aMesh = FindMesh(theMeshName); + VISU::PMeshImpl aMesh = FindMesh(theMeshName); VISU::TGroupMap& aGroupMap = aMesh->myGroupMap; VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName); if(aGroupMapIter == aGroupMap.end()) - EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<> There is no the group in the mesh!!! - '"<second; return TFindMeshOnGroup(aMesh,aGroup); @@ -3144,11 +1174,11 @@ VISU_Convertor_impl const std::string& theGroupName) { TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName); - PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); - PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); + VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup); + VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup); size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord); - TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells(); + VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells(); size_t aNbCells = aNbASizeCells.first; size_t aCellsSize = aNbASizeCells.second; size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType); @@ -3174,18 +1204,18 @@ VISU_Convertor_impl VISU_Convertor_impl::TFindField VISU_Convertor_impl -::FindField(const string& theMeshName, +::FindField(const std::string& theMeshName, const VISU::TEntity& theEntity, - const string& theFieldName) + const std::string& theFieldName) { TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity); - PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); + VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);; + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity); VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap; - PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity; if(theEntity == VISU::NODE_ENTITY){ if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end()) aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY]; @@ -3198,9 +1228,9 @@ VISU_Convertor_impl VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName); if(aFieldIter == aFieldMap.end()) - EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!"); + EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!"); - PFieldImpl aField = aFieldIter->second; + VISU::PFieldImpl aField = aFieldIter->second; return TFindField(aMesh, aMeshOnEntity, @@ -3216,8 +1246,8 @@ VISU_Convertor_impl const std::string& theFieldName) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); - PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); - PFieldImpl aField = boost::get<3>(aFindField); + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + VISU::PFieldImpl aField = boost::get<3>(aFindField); size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity); size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC); @@ -3239,17 +1269,17 @@ VISU_Convertor_impl int theStampsNum) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); - PField aField = boost::get<3>(aFindField); + VISU::PField aField = boost::get<3>(aFindField); VISU::TValField& aValField = aField->myValField; VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum); if(aValFieldIter == aValField.end()) - EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!"); + EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!"); - PMeshImpl aMesh = boost::get<0>(aFindField); - PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField); - PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); - PValForTimeImpl aValForTime = aValFieldIter->second; + VISU::PMeshImpl aMesh = boost::get<0>(aFindField); + VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField); + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField); + VISU::PValForTimeImpl aValForTime = aValFieldIter->second; return TFindTimeStamp(aMesh, aMeshOnEntity, @@ -3268,8 +1298,8 @@ VISU_Convertor_impl { TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); - PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); - PFieldImpl aField = boost::get<3>(aFindTimeStamp); + VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp); + VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp); size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity); size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC); @@ -3299,14 +1329,14 @@ VISU_Convertor_impl theFieldName, theStampsNum); - PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); - PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter; - if(anIDMapperFilter->myIsVTKDone){ + VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); + VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper; + if(anUnstructuredGridIDMapper->myIsVTKDone){ VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName, theEntity, theFieldName, theStampsNum); - anIDMapper->GetVTKOutput(); + anIDMapper->GetOutput(); aSize += anIDMapper->GetMemorySize(); }else aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); @@ -3331,14 +1361,14 @@ VISU_Convertor_impl theFieldName, theStampsNum); - PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); - PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter; + VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp); + VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter; if(aGaussPtsIDFilter->myIsVTKDone){ VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName, theEntity, theFieldName, theStampsNum); - aGaussPtsIDMapper->GetVTKOutput(); + aGaussPtsIDMapper->GetOutput(); aSize += aGaussPtsIDMapper->GetMemorySize(); }else aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); @@ -3350,12 +1380,12 @@ VISU_Convertor_impl const VISU::PField VISU_Convertor_impl -::GetField(const string& theMeshName, +::GetField(const std::string& theMeshName, VISU::TEntity theEntity, - const string& theFieldName) + const std::string& theFieldName) { TFindField aFindField = FindField(theMeshName,theEntity,theFieldName); - PField aField = boost::get<3>(aFindField); + VISU::PField aField = boost::get<3>(aFindField); return aField; } @@ -3369,6 +1399,6 @@ VISU_Convertor_impl { TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum); - PValForTime aValForTime = boost::get<4>(aFindTimeStamp); + VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp); return aValForTime; } diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 0ea7c194..7912b79b 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -29,1086 +29,13 @@ #ifndef VISU_Convertor_impl_HeaderFile #define VISU_Convertor_impl_HeaderFile -#include - -#include - -class vtkCell; -class vtkPoints; -class vtkUnstructuredGrid; -class VTKViewer_AppendFilter; -class VISU_MergeFilter; - #include "VISU_Convertor.hxx" -#include "MED_SliceArray.hxx" -#include "MED_Structures.hxx" - -#ifndef VISU_ENABLE_QUADRATIC -#define VISU_ENABLE_QUADRATIC -#define VISU_USE_VTK_QUADRATIC -#endif - -namespace VISU -{ - //! Defines VISU enumeration of geometrical types - enum EGeometry {ePOINT1=1, eSEG2=102, eSEG3=103, eTRIA3=203, - eQUAD4=204, eTRIA6=206,eQUAD8=208, eTETRA4=304, - ePYRA5=305, ePENTA6=306, eHEXA8=308, eTETRA10=310, - ePYRA13=313, ePENTA15=315, eHEXA20=320, - ePOLYGONE=400, ePOLYEDRE=500, eNONE=-1}; - - //! Get number of nodes for defined geometrical type - vtkIdType - VISUGeom2NbNodes(EGeometry theGeom); - - //! Maps VISU geometrical type to VTK one - vtkIdType - VISUGeom2VTK(EGeometry theGeom); - - //--------------------------------------------------------------- - using MED::TCSlice; - using MED::TSlice; - - typedef vtkUnstructuredGrid TDataSet; - - typedef vtkSmartPointer TVTKSource; - typedef vtkSmartPointer TVTKPoints; - typedef vtkSmartPointer TVTKMergeFilter; - - typedef vtkSmartPointer TVTKAppendFilter; - - //--------------------------------------------------------------- - //! Define an utility base class which is repsonsible for preventing repetion - struct TIsVTKDone: virtual TBaseStructure - { - TIsVTKDone(); - mutable bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure - mutable bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation - }; - - - //--------------------------------------------------------------- - //! Define an utility base class which allow to keep calculated number of cells and their size - struct TSizeCounter: virtual TIsVTKDone - { - TSizeCounter(); - vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass - vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass - }; - - - //--------------------------------------------------------------- - //! Define a container for VTK representation - class TSource: public virtual TSizeCounter - { - protected: - mutable TVTKSource mySource; - public: - TSource(); - - //! This method allow to create corresponding VTK data set by demand (not at once) - const TVTKSource& - GetSource() const; - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - - - //--------------------------------------------------------------- - //! Define an intermediate class which unifies memory size calculation - struct TMemoryCheckIDMapper: public virtual TIsVTKDone, - public virtual TIDMapper - { - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - - - //--------------------------------------------------------------- - //! Define a container for VTK representation - /*! - This container allow to combine other VTK representation into single one. - */ - class TAppendFilter: public virtual TMemoryCheckIDMapper - { - protected: - mutable TVTKAppendFilter myFilter; - public: - TAppendFilter(); - - //! This method allow to create corresponding VTK filter by demand (not at once) - const TVTKAppendFilter& - GetFilter() const; - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - }; - - - //--------------------------------------------------------------- - //! Define a container for VTK representation - /*! - This container allow to assign data to mesh and represent them into single VTK representation - */ - class TMergeFilter: public virtual TMemoryCheckIDMapper - { - protected: - mutable TVTKMergeFilter myFilter; - public: - TMergeFilter(); - - //! This method allow to create corresponding VTK filter by demand (not at once) - const TVTKMergeFilter& - GetFilter() const; - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - }; - typedef SharedPtr PAppendFilter; - - - //--------------------------------------------------------------- - typedef MED::TFloat TCoord; - using MED::TCoordSlice; - using MED::TCCoordSlice; - - //! This class is responsible for keeping the mesh node coordinates - class TCoordHolderBase: public virtual TBaseStructure - { - vtkIdType myDim; //!< Dimension of the nodal coordinates - vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh - - public: - //! To initilize the instance - void - Init(vtkIdType theNbPoints, - vtkIdType theDim); - - vtkIdType - GetNbPoints() const; - - vtkIdType - GetDim() const; - - size_t - size() const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //! Get slice of coordinates for defined node (const version) - virtual - TCCoordSlice - GetCoordSlice(vtkIdType theNodeId) const = 0; - - //! Get slice of coordinates for defined node - virtual - TCoordSlice - GetCoordSlice(vtkIdType theNodeId) = 0; - - virtual - unsigned char* - GetValuePtr() = 0; - }; - typedef SharedPtr PCoordHolder; - - - //--------------------------------------------------------------- - template - class TCoordHolder: public virtual TCoordHolderBase - { - protected: - mutable TContainerType myCoord; //!< Keeps the node coordinates container itself - - public: - //! To initilize the class instance - void - Init(vtkIdType theNbPoints, - vtkIdType theDim, - const TContainerType& theCoord) - { - TCoordHolderBase::Init(theNbPoints, theDim); - myCoord = theCoord; - } - - //! Gets pointer to the first element in the node coordinates array - virtual - TCoord* - GetPointer() = 0; - - //! Gets pointer to the first element in the node coordinates array (const version) - virtual - const TCoord* - GetPointer() const = 0; - - //! Get slice of coordinates for defined node (const version) - virtual - TCCoordSlice - GetCoordSlice(vtkIdType theNodeId) const - { - return TCCoordSlice(this->GetPointer(), - this->size(), - std::slice(theNodeId * this->GetDim(), this->GetDim(), 1)); - } - - //! Get slice of coordinates for defined node - virtual - TCoordSlice - GetCoordSlice(vtkIdType theNodeId) - { - return TCoordSlice(this->GetPointer(), - this->size(), - std::slice(theNodeId * this->GetDim(), this->GetDim(), 1)); - } - - virtual - unsigned char* - GetValuePtr() - { - return (unsigned char*)this->GetPointer(); - } - }; - - - //--------------------------------------------------------------- - //! This class is responsible for representation of mesh nodes - class TPointCoords: public virtual TIsVTKDone - { - protected: - //! An container for coordinates of the nodes - /*! - Usage of slices allow to minimize amount of memory to store the nodal coordinates and - provide unifirm way of conversation with this coordinates (independant from mesh dimension) - */ - PCoordHolder myCoord; //!< A pointer to the coordinates container holder - TVTKPoints myPoints; //!< VTK representation for the mesh nodes - - void - SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK - - public: - TPointCoords(); - - //! To initilize the class - void - Init(const PCoordHolder& theCoord); - - vtkIdType - GetNbPoints() const; - - vtkIdType - GetDim() const; - - //! Get slice of coordinates for defined node (const version) - TCCoordSlice - GetCoordSlice(vtkIdType theNodeId) const; - - //! Get slice of coordinates for defined node - TCoordSlice - GetCoordSlice(vtkIdType theNodeId); - - virtual - vtkPoints* - GetPoints() const; //!< Gets corresponding VTK structure - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - typedef SharedPtr PPointCoords; - - - //--------------------------------------------------------------- - //! This class is responsible for representation of mesh nodes - /*! - In additition to its base functionlity it support mapping of VTK to object numeration and - keeps names for each of nodes. - */ - class TNamedPointCoords: public virtual TPointCoords - { - protected: - typedef TVector TPointsDim; - TPointsDim myPointsDim; //!< Keeps name of each dimension - - public: - - //! To initilize the class (numeration of the nodes can be missed) - void - Init(const PCoordHolder& theCoord); - - //! Get name for defined dimension - std::string& - GetName(vtkIdType theDim); - - //! Get name for defined dimension (const version) - const std::string& - GetName(vtkIdType theDim) const; - - //! Get object number for node by its VTK one - virtual - vtkIdType - GetObjID(vtkIdType theID) const; - - //! Get VTK number for node by its object one - virtual - vtkIdType - GetVTKID(vtkIdType theID) const; - - //! Get name of node by its object number - virtual - std::string - GetNodeName(vtkIdType theObjID) const; - - virtual - vtkPoints* - GetPoints() const; //!< Gets initialized corresponding VTK structure - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - typedef SharedPtr PNamedPointCoords; - - - //--------------------------------------------------------------- - //! Specialize TMesh to provide VTK mapping for nodes - struct TMeshImpl: virtual TMesh, - virtual TIsVTKDone - { - PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes - vtkIdType myNbPoints; //!< Keeps number of the nodes - - TMeshImpl(): myNbPoints(0) - {} - - vtkIdType - GetNbPoints() const; - - vtkIdType - GetDim() const; - - vtkPoints* - GetPoints(); //!< Gets initialized corresponding VTK structure - }; - typedef SharedPtr PMeshImpl; - - - //--------------------------------------------------------------- - typedef TVector TSubMeshID; - typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; - - //! Specialize TSubProfile to provide VTK mapping - struct TSubProfileImpl: virtual TSubProfile, - virtual TSource - { - TSubProfileImpl(); - - EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to - std::string myName; //!< Keeps its name - - //! Get object number of mesh cell by its VTK one - virtual - vtkIdType - GetElemObjID(int theVtkI) const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //! Keeps status of the structure - /*! - In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre - in order to construct mesh for MED TIEMSTAMPS in uniform way. - */ - ESubMeshStatus myStatus; - TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE - }; - typedef SharedPtr PSubProfileImpl; - - - //--------------------------------------------------------------- - struct TMeshOnEntityImpl; - - typedef std::map TID2ID; - typedef TVector TSubProfileArr; - typedef std::map TGeom2SubProfile; - - //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh - struct TProfileImpl: virtual TProfile, - virtual TAppendFilter - { - TProfileImpl(); - bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not - - //! Reimplement the TIDMapper::GetNodeObjID - virtual - vtkIdType - GetNodeObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeVTKID - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeCoord - virtual - vtkFloatingPointType* - GetNodeCoord(vtkIdType theObjID); - - //! Reimplement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemVTKID - virtual - vtkIdType - GetElemVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemCell - virtual - vtkCell* - GetElemCell(vtkIdType theObjID); - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //! Reimplement the TNamedIDMapper::GetNodeName - virtual - std::string - GetNodeName(vtkIdType theObjID) const; - - //! Reimplement the TNamedIDMapper::GetElemName - virtual - std::string - GetElemName(vtkIdType theObjID) const; - - TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping - TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilter - PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh - TMeshOnEntityImpl* myMeshOnEntity; // PProfileImpl; - - - //--------------------------------------------------------------- - //! Specialize TIDMapper to provide VTK mapping for MED TIMESTAMP mesh - struct TIDMapperFilter: virtual TMergeFilter - { - PAppendFilter myIDMapper; //!< Responsible for numbering - TSource mySource; //!< Keeps assigned data - - //! Reimplement the TIDMapper::GetNodeObjID - virtual - vtkIdType - GetNodeObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeVTKID - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeCoord - virtual - vtkFloatingPointType* - GetNodeCoord(vtkIdType theObjID); - - //! Reimplement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemVTKID - virtual - vtkIdType - GetElemVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemCell - virtual - vtkCell* - GetElemCell(vtkIdType theObjID); - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); +#include "VISU_ConvertorDef_impl.hxx" - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - typedef SharedPtr PIDMapperFilter; - - - //--------------------------------------------------------------- - struct TGaussImpl; - typedef SharedPtr PGaussImpl; - - //! Specialize TGauss to provide more detail information of the MED GAUSS entity for VTK mapping - struct TGaussImpl: virtual TGauss - { - EGeometry myGeom; //!< Define, to which geometrical type the MED GAUSS entity belongs - std::string myName; //!< Keeps name of the MED GAUSS entity - vtkIdType myNbPoints; // PGaussSubMeshImpl; - - - //--------------------------------------------------------------- - typedef TVector TGaussSubMeshArr; - typedef std::map TGeom2GaussSubMesh; - - //! Specialize TGaussMesh to provide VTK mapping for the entity - struct TGaussMeshImpl: virtual TGaussMesh, - virtual TAppendFilter - { - TGaussMeshImpl(); - - //! Reimplement the TGaussPtsIDMapper::GetObjID - virtual - TGaussPointID - GetObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - //! Reimplement the TGaussPtsIDMapper::GetParent - virtual - TNamedIDMapper* - GetParent(); - - TSource mySource; //!< Keeps VTK representation of the Gauss Points - TNamedIDMapper* myParent; //!< Refer to parent mesh - TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilter - TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type - }; - typedef SharedPtr PGaussMeshImpl; - - - //--------------------------------------------------------------- - //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh - struct TGaussPtsIDFilter: virtual TIDMapperFilter, - virtual TGaussPtsIDMapper - { - PGaussPtsIDMapper myGaussPtsIDMapper; - - //! Reimplement the TGaussPtsIDMapper::GetObjID - virtual - TGaussPointID - GetObjID(vtkIdType theID) const; - - //! Reimplement the TGaussPtsIDMapper::GetParent - virtual - TNamedIDMapper* - GetParent(); - }; - typedef SharedPtr PGaussPtsIDFilter; - - - //--------------------------------------------------------------- - typedef TVector TConnect; - typedef TVector TCell2Connect; - - //! The class is responsible for mapping of cells of defined geometrical type - struct TSubMeshImpl: virtual TSource - { - - //! To implement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! To implement the TNamedIDMapper::GetElemName - virtual - std::string - GetElemName(vtkIdType theObjID) const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - vtkIdType myStartID; - TCell2Connect myCell2Connect; //!< Contains connectivity for the cells - }; - typedef SharedPtr PSubMeshImpl; - - - //--------------------------------------------------------------- - typedef std::map TGeom2SubMesh; - typedef TVector TSubMeshArr; - - //! Specialize TMeshOnEntity to provide VTK mapping for the entity - struct TMeshOnEntityImpl: virtual TMeshOnEntity, - virtual TAppendFilter, - virtual TSizeCounter - { - //! Reimplement the TIDMapper::GetNodeVTKID - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeObjID - virtual - vtkIdType - GetNodeObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemVTKID - virtual - vtkIdType - GetElemVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! Reimplement the TNamedIDMapper::GetNodeName - virtual - std::string - GetNodeName(vtkIdType theObjID) const; - - //! Reimplement the TNamedIDMapper::GetElemName - virtual - std::string - GetElemName(vtkIdType theObjID) const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping - TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilter - PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping - - TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type - }; - typedef SharedPtr PMeshOnEntityImpl; - - - //--------------------------------------------------------------- - typedef std::map TGeom2SubMeshID; - - //! Specialize TFamily to provide VTK mapping for the entity - struct TFamilyImpl: virtual TFamily, - virtual TSource - { - //! Reimplement the TIDMapper::GetNodeObjID - vtkIdType - GetNodeObjID(vtkIdType theID) const ; - - //! Reimplement the TIDMapper::GetNodeVTKID - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID) const ; - - //! Reimplement the TIDMapper::GetElemVTKID - virtual - vtkIdType - GetElemVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetVTKOutput - virtual - TVTKOutput* - GetVTKOutput(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping - TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping - TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY - - TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type - }; - typedef SharedPtr PFamilyImpl; - - - //--------------------------------------------------------------- - typedef std::pair TNbASizeCells; - typedef TVector TFamilyArr; - - //! Specialize TGroup to provide VTK mapping for the entity - struct TGroupImpl: virtual TGroup, - virtual TAppendFilter - { - //! Calculate pair of values - number of cells and its size - TNbASizeCells - GetNbASizeCells() const; - - //! Reimplement the TIDMapper::GetElemVTKID - virtual - vtkIdType - GetElemVTKID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetElemObjID - virtual - vtkIdType - GetElemObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeObjID - virtual - vtkIdType - GetNodeObjID(vtkIdType theID) const; - - //! Reimplement the TIDMapper::GetNodeVTKID - virtual - vtkIdType - GetNodeVTKID(vtkIdType theID) const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping - TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilter - PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping - }; - typedef SharedPtr PGroupImpl; - - - //--------------------------------------------------------------- - typedef TVector TMinMaxArr; - - //! Specialize TField to provide VTK mapping for the entity - struct TFieldImpl: virtual TField - { - TFieldImpl(); - - //! To initialize the data structure - void - Init(vtkIdType theNbComp, - vtkIdType theDataType); - - //! Gets type idetificator of the mesh data. - vtkIdType - GetDataType() const; - - //! Implement the TField::GetMinMax - virtual - TMinMax - GetMinMax(vtkIdType theCompID); - - vtkIdType myDataSize; //!< Keeps size of the assigned data - vtkIdType myDataType; //!< Keeps type idetificator of the mesh data - TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD - }; - typedef SharedPtr PFieldImpl; - - - //--------------------------------------------------------------- - //! Define a base class for the container to get access to data assigned to mesh - class TMeshValueBase - { - public: - //! To intitilize the data strucutre - void - Init(vtkIdType theNbElem, - vtkIdType theNbGauss, - vtkIdType theNbComp); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize() const = 0; - - //! Gets number of mesh elements where the data assigned to. - vtkIdType - GetNbElem() const; - - //! Gets number of components of corresponding MED FIELD. - vtkIdType - GetNbComp() const; - - //! Gets number of Gauss Points. - vtkIdType - GetNbGauss() const; - - size_t - size() const; - - protected: - vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to - vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD - vtkIdType myNbGauss; //!< Defines number of Gauss Points - vtkIdType myStep; //!< Internal variable - }; - typedef SharedPtr PMeshValue; - - - //--------------------------------------------------------------- - //! Define a container to get access to data assigned to mesh - template - class TTMeshValue: public virtual TMeshValueBase - { - public: - typedef TSlice TValueSlice; - typedef TCSlice TCValueSlice; - - typedef TVector TCValueSliceArr; - typedef TVector TValueSliceArr; - - virtual - const TValueType* - GetPointer() const = 0; - - virtual - TValueType* - GetPointer() = 0; - - //! To get assigned values first by Gauss Points and then by components (constant version) - TCValueSliceArr - GetGaussValueSliceArr(vtkIdType theElemId) const - { - TCValueSliceArr aValueSliceArr(this->myNbGauss); - vtkIdType anId = theElemId * this->myStep; - for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){ - aValueSliceArr[aGaussId] = - TCValueSlice(this->GetPointer(), - this->size(), - std::slice(anId, this->myNbComp, 1)); - anId += this->myNbComp; - } - return aValueSliceArr; - } - - //! To get assigned values first by Gauss Points and then by components - TValueSliceArr - GetGaussValueSliceArr(vtkIdType theElemId) - { - TValueSliceArr aValueSliceArr(this->myNbGauss); - vtkIdType anId = theElemId * this->myStep; - for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){ - aValueSliceArr[aGaussId] = - TValueSlice(this->GetPointer(), - this->size(), - std::slice(anId, this->myNbComp, 1)); - anId += this->myNbComp; - } - return aValueSliceArr; - } - - //! To get assigned values first by components and then by Gauss Points (constant version) - TCValueSliceArr - GetCompValueSliceArr(vtkIdType theElemId) const - { - TCValueSliceArr aValueSliceArr(this->myNbComp); - vtkIdType anId = theElemId * this->myStep; - for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){ - aValueSliceArr[aCompId] = - TCValueSlice(this->GetPointer(), - this->size(), - std::slice(anId, this->myNbGauss, this->myNbComp)); - anId += 1; - } - return aValueSliceArr; - } - - //! To get assigned values first by components and then by Gauss Points - TValueSliceArr - GetCompValueSliceArr(vtkIdType theElemId) - { - TValueSliceArr aValueSliceArr(this->myNbComp); - vtkIdType anId = theElemId * this->myStep; - for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){ - aValueSliceArr[aCompId] = - TValueSlice(this->GetPointer(), - this->size(), - std::slice(anId, this->myNbGauss, this->myNbComp)); - anId += 1; - } - return aValueSliceArr; - } - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize() const - { - return this->size() * sizeof(TValueType); - } - }; - - - //--------------------------------------------------------------- - //! Define a container to get access to data assigned to mesh - template - class TTMeshValueHolder: public virtual TTMeshValue - { - protected: - mutable TContainerType myContainer; //!< Keeps the mesh values container itself - - public: - //! To initilize the class instance - void - Init(vtkIdType theNbElem, - vtkIdType theNbGauss, - vtkIdType theNbComp, - const TContainerType& theContainer) - { - TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp); - myContainer = theContainer; - } - }; - - - //--------------------------------------------------------------- - typedef std::map TGeom2MeshValue; - - class TGeom2Value: public virtual TBaseStructure - { - TGeom2MeshValue myGeom2MeshValue; - public: - - //! Gets mesh data for defined geometrical type (constant version) - const PMeshValue& - GetMeshValue(EGeometry theGeom) const; - - //! Gets mesh data for defined geometrical type - PMeshValue& - GetMeshValue(EGeometry theGeom); - - //! Gets container of the whole mesh data - TGeom2MeshValue& - GetGeom2MeshValue(); - - //! Gets container of the whole mesh data (constant version) - const TGeom2MeshValue& - GetGeom2MeshValue() const; - - //! Gets mesh data for the first geometry - PMeshValue - GetFirstMeshValue() const; - }; - - - //--------------------------------------------------------------- - typedef std::map TGeom2NbGauss; - - //! Specialize TValForTime to provide VTK mapping for the entity - struct TValForTimeImpl: virtual TValForTime - { - PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points - PIDMapperFilter myIDMapperFilter; //!< Keep VTK representation for ordinary mesh and data - TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh - TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points - - TValForTimeImpl(); - - TGeom2MeshValue& - GetGeom2MeshValue(); - - const TGeom2MeshValue& - GetGeom2MeshValue() const; - - //! Get mesh data for defined geometrical type (constant version) - const PMeshValue& - GetMeshValue(EGeometry theGeom) const; - - //! Get mesh data for defined geometrical type - PMeshValue& - GetMeshValue(EGeometry theGeom); - - //! Gets mesh data for the first geometry - PMeshValue - GetFirstMeshValue() const; - - //! Get number of Gauss Points for defined geometrical type - virtual - int - GetNbGauss(EGeometry theGeom) const; - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - }; - typedef SharedPtr PValForTimeImpl; -} +#include +//--------------------------------------------------------------- //! This class perfroms mapping of intermediate data strucutres into corresponding VTK representation /*! It implements VISU_Convertor public interface and declare new pure virtual functions @@ -1166,7 +93,7 @@ public: //! Implemention of the VISU_Convertor::GetFamilyOnEntity virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName); @@ -1180,7 +107,7 @@ public: //! Implemention of the VISU_Convertor::GetMeshOnGroup virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName); @@ -1192,7 +119,7 @@ public: //! Implemention of the VISU_Convertor::GetTimeStampOnMesh virtual - VISU::PIDMapper + VISU::PUnstructuredGridIDMapper GetTimeStampOnMesh(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFieldName, @@ -1250,20 +177,23 @@ protected: FindMesh(const std::string& theMeshName); //! An utility method to find TMeshOnEntity by name of its parent mesh and entity - typedef boost::tuple TFindMeshOnEntity; + typedef boost::tuple TFindMeshOnEntity; TFindMeshOnEntity FindMeshOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity); //! An utility method to find TFamily by name of its parent mesh, corresponding entity and its name - typedef boost::tuple TFindFamilyOnEntity; + typedef boost::tuple TFindFamilyOnEntity; TFindFamilyOnEntity FindFamilyOnEntity(const std::string& theMeshName, const VISU::TEntity& theEntity, const std::string& theFamilyName); //! An utility method to find Group by name of its parent mesh and its name - typedef boost::tuple TFindMeshOnGroup; + typedef boost::tuple TFindMeshOnGroup; TFindMeshOnGroup FindMeshOnGroup(const std::string& theMeshName, const std::string& theGroupName); @@ -1290,12 +220,12 @@ protected: const std::string& theFieldName, int theStampsNum); - VISU::TVTKOutput* + vtkUnstructuredGrid* GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh, const VISU::PMeshOnEntityImpl& theMeshOnEntity, const VISU::PFieldImpl& theField, const VISU::PValForTimeImpl& theValForTime, - const VISU::PIDMapperFilter& theIDMapperFilter, + const VISU::PUnstructuredGridIDMapperImpl& theIDMapperFilter, const VISU::PProfileImpl& theProfile, const VISU::TEntity& theEntity); diff --git a/src/CONVERTOR/VISU_IDMapper.cxx b/src/CONVERTOR/VISU_IDMapper.cxx index 2a70b379..66dfae5b 100644 --- a/src/CONVERTOR/VISU_IDMapper.cxx +++ b/src/CONVERTOR/VISU_IDMapper.cxx @@ -27,6 +27,8 @@ #include "VISU_IDMapper.hxx" #include +#include +#include namespace VISU { @@ -36,7 +38,7 @@ namespace VISU ::GetNodeCoord(vtkIdType theObjID) { vtkIdType aVTKID = GetNodeVTKID(theObjID); - return GetVTKOutput()->GetPoint(aVTKID); + return GetOutput()->GetPoint(aVTKID); } vtkIdType @@ -58,7 +60,7 @@ namespace VISU ::GetElemCell(int theObjID) { vtkIdType aVtkID = GetElemVTKID(theObjID); - return GetVTKOutput()->GetCell(aVtkID); + return GetOutput()->GetCell(aVtkID); } vtkIdType @@ -74,4 +76,25 @@ namespace VISU { return theID; } + //--------------------------------------------------------------- + + + vtkDataSet* + TUnstructuredGridIDMapper + ::GetOutput() + { + return GetUnstructuredGridOutput(); + } + //--------------------------------------------------------------- + + + vtkDataSet* + TPolyDataIDMapper + ::GetOutput() + { + return GetPolyDataOutput(); + } + + + //--------------------------------------------------------------- } diff --git a/src/CONVERTOR/VISU_IDMapper.hxx b/src/CONVERTOR/VISU_IDMapper.hxx index 9614bc82..53960d77 100644 --- a/src/CONVERTOR/VISU_IDMapper.hxx +++ b/src/CONVERTOR/VISU_IDMapper.hxx @@ -38,12 +38,12 @@ #include class vtkUnstructuredGrid; +class vtkPolyData; +class vtkDataSet; class vtkCell; namespace VISU { - using MED::SharedPtr; - //--------------------------------------------------------------- //! Defines a basic class for intemediate data structures struct TBaseStructure @@ -54,11 +54,9 @@ namespace VISU std::string myEntry; //!< To simplify publication of the object tree }; - typedef SharedPtr PBaseStructure; + typedef MED::SharedPtr PBaseStructure; //--------------------------------------------------------------- - typedef vtkUnstructuredGrid TVTKOutput; - //! Defines a basic abstract interface for VTK to object ID's and backward mapping /*! Where object ID means ID which attached to corresponding MED entity. @@ -98,15 +96,31 @@ namespace VISU //! Get VTK representation of mesh for corresponding MED entity virtual - TVTKOutput* - GetVTKOutput() = 0; + vtkDataSet* + GetOutput() = 0; //! Gets memory size used by the instance (bytes). virtual unsigned long int GetMemorySize() = 0; }; - typedef SharedPtr PIDMapper; + typedef MED::SharedPtr PIDMapper; + + + //--------------------------------------------------------------- + struct TUnstructuredGridIDMapper: virtual TIDMapper + { + //! Get VTK representation of mesh for corresponding MED entity + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput() = 0; + + //! Reimplement the TIDMapper::GetOutput + virtual + vtkDataSet* + GetOutput(); + }; + typedef MED::SharedPtr PUnstructuredGridIDMapper; //--------------------------------------------------------------- @@ -114,7 +128,7 @@ namespace VISU /*! This class defines some additional methods that allow get names for corresponding mesh elements */ - struct TNamedIDMapper: virtual TIDMapper + struct TNamedIDMapper: virtual TUnstructuredGridIDMapper { //! Get name of mesh node for corresponding object ID virtual @@ -126,7 +140,23 @@ namespace VISU std::string GetElemName(vtkIdType theObjID) const = 0; }; - typedef SharedPtr PNamedIDMapper; + typedef MED::SharedPtr PNamedIDMapper; + + + //--------------------------------------------------------------- + struct TPolyDataIDMapper: virtual TIDMapper + { + //! Get VTK representation of mesh for corresponding MED entity + virtual + vtkPolyData* + GetPolyDataOutput() = 0; + + //! Reimplement the TIDMapper::GetOutput + virtual + vtkDataSet* + GetOutput(); + }; + typedef MED::SharedPtr PPolyDataIDMapper; //--------------------------------------------------------------- @@ -135,7 +165,7 @@ namespace VISU //! Defines a type that represent complex ID for defined Gauss Point typedef std::pair TGaussPointID; - struct TGaussPtsIDMapper: virtual TIDMapper + struct TGaussPtsIDMapper: virtual TPolyDataIDMapper { //! Gets complex Gauss Point ID by its VTK ID virtual @@ -147,7 +177,7 @@ namespace VISU TNamedIDMapper* GetParent() = 0; }; - typedef SharedPtr PGaussPtsIDMapper; + typedef MED::SharedPtr PGaussPtsIDMapper; //--------------------------------------------------------------- } diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 449b0e30..1c668074 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -26,7 +26,6 @@ #include "VISU_MedConvertor.hxx" -#include "VISU_Convertor.hxx" #include "VISU_ConvertorUtils.hxx" #include "MED_Factory.hxx" @@ -48,9 +47,6 @@ #include -using namespace std; -using namespace VISU; - using MED::TInt; using MED::TFloat; using MED::EBooleen; @@ -144,10 +140,10 @@ namespace MEDEntityToVTK(MED::EEntiteMaillage theMEDEntity) { switch(theMEDEntity){ - case MED::eNOEUD: return NODE_ENTITY; - case MED::eARETE: return EDGE_ENTITY; - case MED::eFACE: return FACE_ENTITY; - case MED::eMAILLE: return CELL_ENTITY; + case MED::eNOEUD: return VISU::NODE_ENTITY; + case MED::eARETE: return VISU::EDGE_ENTITY; + case MED::eFACE: return VISU::FACE_ENTITY; + case MED::eMAILLE: return VISU::CELL_ENTITY; } return VISU::TEntity(-1); } @@ -155,20 +151,20 @@ namespace //--------------------------------------------------------------- MED::EEntiteMaillage - VTKEntityToMED(TEntity theVTKEntity) + VTKEntityToMED(VISU::TEntity theVTKEntity) { switch(theVTKEntity){ - case NODE_ENTITY: return MED::eNOEUD; - case EDGE_ENTITY: return MED::eARETE; - case FACE_ENTITY: return MED::eFACE; - case CELL_ENTITY: return MED::eMAILLE; + case VISU::NODE_ENTITY: return MED::eNOEUD; + case VISU::EDGE_ENTITY: return MED::eARETE; + case VISU::FACE_ENTITY: return MED::eFACE; + case VISU::CELL_ENTITY: return MED::eMAILLE; } return MED::EEntiteMaillage(-1); } //--------------------------------------------------------------- - PMEDSubProfile + VISU::PMEDSubProfile CrSubProfile(const MED::PWrapper& theMEDWrapper, const MED::PMeshInfo& theMeshInfo, MED::EEntiteMaillage theMEntity, @@ -179,21 +175,21 @@ namespace VISU::EGeometry aEGeom = MEDGeom2VISU(theMGeom); vtkIdType aVNbNodes = VISUGeom2NbNodes(aEGeom); - PMEDSubProfile aSubProfile(new TMEDSubProfile()); + VISU::PMEDSubProfile aSubProfile(new VISU::TMEDSubProfile()); aSubProfile->myGeom = aEGeom; aSubProfile->myMGeom = theMGeom; - aSubProfile->myStatus = eAddAll; + aSubProfile->myStatus = VISU::eAddAll; MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(theMGeom); if(aTimeStampIter == theGeom2Size.end()) - aSubProfile->myStatus = eRemoveAll; + aSubProfile->myStatus = VISU::eRemoveAll; else{ MED::TGeom2Profile::const_iterator aProfileIter = theGeom2Profile.find(theMGeom); if(aProfileIter != theGeom2Profile.end()){ MED::PProfileInfo aProfileInfo = aProfileIter->second; aSubProfile->myName = aProfileInfo->GetName(); - aSubProfile->myStatus = eAddPart; + aSubProfile->myStatus = VISU::eAddPart; const MED::TElemNum& anElemNum = aProfileInfo->myElemNum; TInt aNbElem = anElemNum.size(); @@ -277,7 +273,7 @@ namespace //--------------------------------------------------------------- - TProfileKey + VISU::TProfileKey GetProfileKey(const MED::PWrapper& theMEDWrapper, const MED::PMeshInfo& theMeshInfo, const MED::PTimeStampValueBase& theTimeStampValue, @@ -287,19 +283,19 @@ namespace { INITMSG(MYDEBUG,"GetProfileKey"<GetGeom2Profile(); const MED::TGeom2Size& aGeom2Size = theMeshOnEntity.myGeom2Size; MED::TGeom2Size::const_iterator anIter = aGeom2Size.begin(); for(; anIter != aGeom2Size.end(); anIter++){ MED::EGeometrieElement aMGeom = anIter->first; - PSubProfile aSubProfile = CrSubProfile(theMEDWrapper, - theMeshInfo, - theMEntity, - aMGeom, - theGeom2Size, - aGeom2Profile); + VISU::PSubProfile aSubProfile = CrSubProfile(theMEDWrapper, + theMeshInfo, + theMEntity, + aMGeom, + theGeom2Size, + aGeom2Profile); aProfileKey.insert(aSubProfile); } @@ -317,31 +313,31 @@ namespace const MED::TGeom2Size& theGeom2Size, VISU::TMEDValForTime& theValForTime) { - TTimerLog aTimerLog(MYDEBUG,"InitProfile"); + VISU::TTimerLog aTimerLog(MYDEBUG,"InitProfile"); INITMSG(MYDEBUG,"InitProfile"<second; INITMSG(MYDEBUG,"aProfileMap.find(aProfileKey)"<myGeom2SubProfile; + VISU::PMEDProfile aProfile(new VISU::TMEDProfile()); + VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; - TProfileKey::const_iterator anIter = aProfileKey.begin(); + VISU::TProfileKey::const_iterator anIter = aProfileKey.begin(); for(; anIter != aProfileKey.end(); anIter++){ - PMEDSubProfile aSubProfile(*anIter); + VISU::PMEDSubProfile aSubProfile(*anIter); - if(aProfile->myIsAll && aSubProfile->myStatus != eAddAll) + if(aProfile->myIsAll && aSubProfile->myStatus != VISU::eAddAll) aProfile->myIsAll = false; VISU::EGeometry aEGeom = aSubProfile->myGeom; @@ -355,18 +351,18 @@ namespace //--------------------------------------------------------------- - TGaussKey + VISU::TGaussKey GetGaussKey(const MED::PTimeStampValueBase& theTimeStampValue, const VISU::TMEDMeshOnEntity& theMeshOnEntity, const MED::TGeom2Size& theGeom2Size, VISU::TMEDValForTime& theValForTime) { - TTimerLog aTimerLog(MYDEBUG,"GetGaussKey"); + VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussKey"); INITMSG(MYDEBUG,"GetGaussKey"<myGeom2SubProfile; + VISU::TGaussKey aGaussKey; + VISU::PMEDProfile aProfile = theValForTime.myProfile; + VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo(); const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss(); @@ -377,24 +373,24 @@ namespace MED::EGeometrieElement aMGeom = anIter->first; VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); - TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom); + VISU::TGeom2SubProfile::iterator anIter2 = aGeom2SubProfile.find(aEGeom); if(anIter2 == aGeom2SubProfile.end()){ INITMSG(MYDEBUG,"anIter2 == aGeom2SubProfile.end!!"<second; + VISU::PMEDSubProfile aSubProfile = anIter2->second; MED::TGeom2Size::const_iterator aTimeStampIter = theGeom2Size.find(aMGeom); if(aTimeStampIter != theGeom2Size.end()){ TInt aNbCells = aTimeStampIter->second; - if(aSubProfile->myStatus == eAddPart) + if(aSubProfile->myStatus == VISU::eAddPart) aNbCells = aSubProfile->myNbCells; - PMEDGaussSubMesh aGaussSubMesh(new TMEDGaussSubMesh()); + VISU::PMEDGaussSubMesh aGaussSubMesh(new VISU::TMEDGaussSubMesh()); aGaussSubMesh->mySubProfile = aSubProfile; aGaussSubMesh->myStatus = aSubProfile->myStatus; - PMEDGauss aGauss(new TMEDGauss()); + VISU::PMEDGauss aGauss(new VISU::TMEDGauss()); aGaussSubMesh->myGauss = aGauss; aGauss->myGeom = aEGeom; aGauss->myNbPoints = 1; @@ -436,45 +432,45 @@ namespace const MED::TGeom2Size& theGeom2Size, VISU::TMEDValForTime& theValForTime) { - TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh"); + VISU::TTimerLog aTimerLog(MYDEBUG,"InitGaussMesh"); INITMSG(MYDEBUG,"InitGaussMesh"<second; INITMSG(MYDEBUG,"aGaussMeshMap.find(aGaussKey)"<myGeom2GaussSubMesh; + VISU::PMEDGaussMesh aGaussMesh(new VISU::TMEDGaussMesh()); + VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; { - TGaussKey::const_iterator anIter = aGaussKey.begin(); + VISU::TGaussKey::const_iterator anIter = aGaussKey.begin(); for(; anIter != aGaussKey.end(); anIter++){ - PMEDGaussSubMesh aGaussSubMesh(*anIter); - PMEDGauss aGauss = aGaussSubMesh->myGauss; + VISU::PMEDGaussSubMesh aGaussSubMesh(*anIter); + VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss; VISU::EGeometry aEGeom = aGauss->myGeom; aGeom2GaussSubMesh[aEGeom] = aGaussSubMesh; } } { - TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr; + VISU::TGaussSubMeshArr& aGaussSubMeshArr = aGaussMesh->myGaussSubMeshArr; aGaussSubMeshArr.resize(aGeom2GaussSubMesh.size()); - TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); + VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); for(TInt anID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++, anID++){ - const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; + const VISU::PGaussSubMeshImpl& aGaussSubMesh = anIter->second; aGaussSubMeshArr[anID] = aGaussSubMesh; } } - INITMSG(MYDEBUG,"aGaussMeshMap[aGaussKey] = aGaussMesh"<myMeshInfo; const std::string& aMeshName = theMesh->myName; - TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin(); for(; anEntityIter != theEntityInfo.end(); anEntityIter++){ const MED::EEntiteMaillage& aMEntity = anEntityIter->first; const MED::TGeom2Size& aGeom2Size = anEntityIter->second; - TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = + aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity()); aMeshOnEntity->myEntity = aVEntity; aMeshOnEntity->myMeshName = aMeshName; aMeshOnEntity->myGeom2Size = aGeom2Size; - TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; INITMSG(MYDEBUG, "- aMEntity = "<myMeshInfo; const std::string& aMeshName = theMesh->myName; - TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; MED::TEntityInfo::const_iterator anEntityIter = theEntityInfo.begin(); for(; anEntityIter != theEntityInfo.end(); anEntityIter++){ const MED::EEntiteMaillage& aMEntity = anEntityIter->first; const MED::TGeom2Size& aGeom2Size = anEntityIter->second; - TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity = aMeshOnEntityMap[aVEntity](new TMEDMeshOnEntity()); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = + aMeshOnEntityMap[aVEntity](new VISU::TMEDMeshOnEntity()); aMeshOnEntity->myEntity = aVEntity; aMeshOnEntity->myMeshName = aMeshName; aMeshOnEntity->myGeom2Size = aGeom2Size; - TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; INITMSG(MYDEBUG, "- aMEntity = "<GetNbFields(); MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo; const std::string& aMeshName = theMesh->myName; INITMSG(MYDEBUG,"BuildFieldMap: aNbFields = "<GetPFieldInfo(aMeshInfo,iField); TInt aNbComp = aFieldInfo->GetNbComp(); std::string aFieldName = aFieldInfo->GetName(); @@ -741,13 +739,13 @@ namespace if(aNbTimeStamps < 1) continue; - TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); vtkIdType aDataType = VTK_DOUBLE; if(aFieldInfo->GetType() != MED::eFLOAT64) aDataType = VTK_INT; - PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; - TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - PMEDField aField = aFieldMap[aFieldName](new TMEDField()); + VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::PMEDField aField = aFieldMap[aFieldName](new VISU::TMEDField()); aField->myId = iField; aField->Init(aNbComp, aDataType); aField->myEntity = aVEntity; @@ -767,7 +765,7 @@ namespace } for(TInt iTimeStamp = 1; iTimeStamp <= aNbTimeStamps; iTimeStamp++){ - TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo"); + VISU::TTimerLog aTimerLog(MYDEBUG,"GetPTimeStampInfo"); MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(aFieldInfo, aMEntity, aGeom2Size, @@ -775,8 +773,8 @@ namespace TFloat aDt = aTimeStampInfo->GetDt(); std::string anUnitDt = aTimeStampInfo->GetUnitDt(); - TValField& aValField = aField->myValField; - PMEDValForTime aValForTime = aValField[iTimeStamp](new TMEDValForTime()); + VISU::TValField& aValField = aField->myValField; + VISU::PMEDValForTime aValForTime = aValField[iTimeStamp](new VISU::TMEDValForTime()); aValForTime->myId = iTimeStamp; aValForTime->myFieldName = aField->myName; aValForTime->myEntity = aField->myEntity; @@ -784,12 +782,12 @@ namespace aValForTime->myTime = VISU::TTime(aDt,anUnitDt); INITMSG(MYDEBUG,"aDt = '"<myGeom2NbGauss; + VISU::TGeom2NbGauss& aVGeom2NbGauss = aValForTime->myGeom2NbGauss; const MED::TGeom2NbGauss& aMGeom2NbGauss = aTimeStampInfo->myGeom2NbGauss; MED::TGeom2NbGauss::const_iterator anIter = aMGeom2NbGauss.begin(); for(; anIter != aMGeom2NbGauss.end(); anIter++){ const MED::EGeometrieElement& aMGeom = anIter->first; - EGeometry aEGeom = MEDGeom2VISU(aMGeom); + VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); TInt aNbGauss = anIter->second; aVGeom2NbGauss[aEGeom] = aNbGauss; } @@ -800,13 +798,13 @@ namespace //--------------------------------------------------------------- void - BuildFamilyMap(PMEDMesh theMesh, + BuildFamilyMap(VISU::PMEDMesh theMesh, const MED::TEntityInfo& theEntityInfo, const MED::TEntity2TGeom2ElemInfo& theEntity2TGeom2ElemInfo, const MED::TFamilyInfoSet& theFamilyInfoSet, MED::PWrapper theMEDWrapper) { - TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildFamilyMap"); INITMSG(MYDEBUG,"BuildFamilyMap\n"); MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo; @@ -816,10 +814,10 @@ namespace const MED::EEntiteMaillage& aMEntity = aEntity2FamilySetIter->first; const MED::TFamilyTSizeSet& aFamilyTSizeSet = aEntity2FamilySetIter->second; - TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; - const TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; - TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity]; + const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; if(aFamilyTSizeSet.empty()) continue; @@ -840,14 +838,14 @@ namespace std::string aFamilyName = aFamilyInfo->GetName(); - PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily()); aFamily->myId = anId; aFamily->myEntity = aVEntity; aFamily->myName = aFamilyName; aFamily->myNbCells = aSize; aFamily->myCellsSize = 0; - TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId); + VISU::TFamilyID2CellsSize::const_iterator anIter = aFamilyID2CellsSize.find(anId); if(anIter != aFamilyID2CellsSize.end()) aFamily->myCellsSize = anIter->second; @@ -877,15 +875,15 @@ namespace * Build grille family map */ void - BuildGrilleFamilyMap(PMEDMesh theMesh, + BuildGrilleFamilyMap(VISU::PMEDMesh theMesh, const MED::TEntityInfo& theEntityInfo, const MED::TFamilyInfoSet& theFamilyInfoSet, MED::PWrapper theMEDWrapper) { - TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGrilleFamilyMap"); INITMSG(MYDEBUG,"BuildGrilleFamilyMap\n"); - TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; MED::TEntityInfo::const_iterator aEntityIter = theEntityInfo.begin(); @@ -894,33 +892,35 @@ namespace const MED::TFamilyID2NbCells& aFam2NbCells = MED::GetFamilyID2NbCells(aGrilleInfo); - MED::TFamilyInfoSet::iterator aFamInter = theFamilyInfoSet.begin(); - for(;aFamInter != theFamilyInfoSet.end();aFamInter++){ - TInt anId = (*aFamInter)->GetId(); + MED::TFamilyInfoSet::const_iterator aFamInter = theFamilyInfoSet.begin(); + for(; aFamInter != theFamilyInfoSet.end(); aFamInter++){ + const MED::PFamilyInfo& aFamilyInfo = *aFamInter; + TInt anId = aFamilyInfo->GetId(); if(anId == 0) continue; - std::string aFamilyName = (*aFamInter)->GetName(); + std::string aFamilyName = aFamilyInfo->GetName(); const MED::EEntiteMaillage& aMEntity = MED::GetEntityByFamilyId(aGrilleInfo, anId); - TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); - PMEDMeshOnEntity aMeshOnEntity; - TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity; + VISU::TMeshOnEntityMap::iterator aMeshOnEntityIter = aMeshOnEntityMap.find(aVEntity); if(aMeshOnEntityIter != aMeshOnEntityMap.end()) aMeshOnEntity = aMeshOnEntityIter->second; - TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - PMEDFamily aFamily = aFamilyMap[aFamilyName](new TMEDFamily()); + VISU::PMEDFamily aFamily = aFamilyMap[aFamilyName](new VISU::TMEDFamily()); aFamily->myId = anId; aFamily->myEntity = aVEntity; aFamily->myName = aFamilyName; aFamily->myNbCells = 0; aFamily->myCellsSize = 0; - TFamilyID2CellsSize::iterator aFamilyid2CellsSizeIter = (aMeshOnEntity->myFamilyID2CellsSize).find(anId); + const VISU::TFamilyID2CellsSize& aFamilyID2CellsSize = aMeshOnEntity->myFamilyID2CellsSize; + VISU::TFamilyID2CellsSize::const_iterator aFamilyid2CellsSizeIter = aFamilyID2CellsSize.find(anId); if(aFamilyid2CellsSizeIter != (aMeshOnEntity->myFamilyID2CellsSize).end()) aFamily->myCellsSize = aFamilyid2CellsSizeIter->second; MED::TFamilyID2NbCells::const_iterator aFam2NbCellsIter = aFam2NbCells.find(anId); @@ -930,8 +930,8 @@ namespace INITMSG(MY_FAMILY_DEBUG, "- aFamilyName =|"<myName<<"|" << "; myId = "<myId - << "; aNbAttr = "<<(*aFamInter)->GetNbAttr() - << "; aNbGroup = "<<(*aFamInter)->GetNbGroup() + << "; aNbAttr = "<GetNbAttr() + << "; aNbGroup = "<GetNbGroup() << "; aVEntity = "<myGroupMap; + VISU::TGroupMap& aGroupMap = theMesh->myGroupMap; MED::TGroupInfo aGroupInfo = MED::GetGroupInfo(theFamilyInfoSet); MED::TGroupInfo::const_iterator aGroupInfoIter = aGroupInfo.begin(); for(; aGroupInfoIter != aGroupInfo.end(); aGroupInfoIter++){ const std::string& aGroupName = aGroupInfoIter->first; INITMSG(MY_GROUP_DEBUG,"aGroupName = '"<myFamilySet; + VISU::PMEDGroup aGroup(new VISU::TMEDGroup()); + VISU::TFamilySet& aFamilySet = aGroup->myFamilySet; const MED::TFamilyInfoSet& aFamilyInfoSet = aGroupInfoIter->second; MED::TFamilyInfoSet::const_iterator aFamilyIter = aFamilyInfoSet.begin(); @@ -965,16 +965,16 @@ namespace const MED::PFamilyInfo& aFamilyInfo = *aFamilyIter; std::string aFamilyName = aFamilyInfo->GetName(); - TEntity aVEntity = TEntity(-1); - PMEDFamily aFamily; + VISU::TEntity aVEntity = VISU::TEntity(-1); + VISU::PMEDFamily aFamily; // Find aVisuEntity - const TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; - TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); + const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap; + VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityIter = aMeshOnEntityMap.begin(); for(; aMeshOnEntityIter != aMeshOnEntityMap.end(); aMeshOnEntityIter++){ - const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; - const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; - TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); + const VISU::PMeshOnEntity& aMeshOnEntity = aMeshOnEntityIter->second; + const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap; + VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin(); for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){ const std::string& aName = aFamilyMapIter->first; aFamily = aFamilyMapIter->second; @@ -999,6 +999,27 @@ namespace } + //--------------------------------------------------------------- + struct TSetIsDone + { + bool& myIsDone; + TSetIsDone(bool& theIsDone): + myIsDone(theIsDone) + {} + + ~TSetIsDone() + { + myIsDone = true; + } + + }; + + + //--------------------------------------------------------------- +} + +namespace VISU +{ //--------------------------------------------------------------- void TMEDNamedPointCoords @@ -1012,12 +1033,12 @@ namespace TNamedPointCoords::Init(PCoordHolder(aCoordHolder)); myVersion = theVersion; + for(TInt iDim = 0; iDim < aDim; iDim++) + myPointsDim[iDim] = theNodeInfo->GetCoordName(iDim); + myIsElemNum = theNodeInfo->IsElemNum(); - if(theNodeInfo->IsElemNum()){ + if(theNodeInfo->IsElemNum()) myElemNum = theNodeInfo->myElemNum; - for(vtkIdType anID = 0, anEnd = myElemNum->size(); anID < anEnd; anID++) - myObj2VTKID[(*myElemNum)[anID]] = anID; - } myIsElemNames = theNodeInfo->IsElemNames(); if(theNodeInfo->IsElemNames()) @@ -1034,6 +1055,17 @@ namespace MED::PNodeCoord aCoord(new MED::TNodeCoord(aNbElem * aDim)); aCoordHolder->Init(aNbElem, aDim, aCoord); TNamedPointCoords::Init(PCoordHolder(aCoordHolder)); + + for(TInt iDim = 0; iDim < aDim; iDim++) + myPointsDim[iDim] = theGrilleInfo->GetCoordName(iDim); + + for(TInt iElem = 0; iElem < aNbElem; iElem++){ + VISU::TCoordSlice aVCoordSlice = GetCoordSlice(iElem); + MED::TNodeCoord aMCoord = theGrilleInfo->GetCoord(iElem); + for(TInt iDim = 0; iDim < aDim; iDim++){ + aVCoordSlice[iDim] = aMCoord[iDim]; + } + } } vtkIdType @@ -1051,6 +1083,12 @@ namespace ::GetVTKID(vtkIdType theID) const { if(myIsElemNum){ + // To prepare corresponding mapper engine + if(myObj2VTKID.empty()){ + vtkIdType anEnd = myElemNum->size(); + for(vtkIdType anID = 0; anID < anEnd; anID++) + myObj2VTKID[(*myElemNum)[anID]] = anID; + } TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID); if(anIter != myObj2VTKID.end()) return anIter->second; @@ -1215,20 +1253,8 @@ namespace return aSize; } - //--------------------------------------------------------------- - struct TSetIsDone - { - bool& myIsDone; - TSetIsDone(bool& theIsDone): - myIsDone(theIsDone) - {} - ~TSetIsDone() - { - myIsDone = true; - } - - }; + //--------------------------------------------------------------- } @@ -1263,11 +1289,11 @@ VISU_MedConvertor return this; TSetIsDone aSetIsDone(myIsEntitiesDone); - TTimerLog aTimerLog(MYDEBUG,"BuildEntities"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildEntities"); MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); TInt aNbMeshes = aMed->GetNbMeshes(); - TMeshMap& aMeshMap = myMeshMap; + VISU::TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildEntities aNbMeshes = "<GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); @@ -1283,12 +1309,12 @@ VISU_MedConvertor MED::EMaillage aType = aMeshInfo->GetType(); // creating TMesh structure and TMeshOnEntityMap - PMEDMesh aMesh = aMeshMap[aMeshName](new TMEDMesh()); + VISU::PMEDMesh aMesh = aMeshMap[aMeshName](new VISU::TMEDMesh()); aMesh->myDim = aDim; aMesh->myName = aMeshName; aMesh->myMeshInfo = aMeshInfo; - aMesh->myNamedPointCoords(new TMEDNamedPointCoords()); + aMesh->myNamedPointCoords(new VISU::TMEDNamedPointCoords()); INITMSG(MYDEBUG,"aMeshName = '"<GetNbMeshes(); - TMeshMap& aMeshMap = myMeshMap; + VISU::TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildFields - aNbMeshes = "<GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); - TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); if(anIter == aMeshMap.end()) continue; - PMEDMesh aMesh = anIter->second; + VISU::PMEDMesh aMesh = anIter->second; INITMSG(MYDEBUG,"aMeshName = '"< void BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, const MED::TGeom2Gauss& theGeom2Gauss, - TMinMaxArr& theMinMaxArr, + VISU::TMinMaxArr& theMinMaxArr, TInt theNbComp, TInt theNbComp2) { @@ -1460,7 +1486,7 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, typename TimeStampValueType::TTMeshValue::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem); for(TInt iComp = 0; iComp < theNbComp; iComp++){ const typename TimeStampValueType::TTMeshValue::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp]; - TMinMax& aMinMax = theMinMaxArr[iComp+1]; + VISU::TMinMax& aMinMax = theMinMaxArr[iComp+1]; vtkFloatingPointType& aMin = aMinMax.first; vtkFloatingPointType& aMax = aMinMax.second; for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){ @@ -1472,7 +1498,7 @@ BuildTimeStampMinMax(MED::SharedPtr theTimeStampValue, } // To calculate min/max per vector modulus - TMinMax& aMinMax = theMinMaxArr[0]; + VISU::TMinMax& aMinMax = theMinMaxArr[0]; vtkFloatingPointType& aMin = aMinMax.first; vtkFloatingPointType& aMax = aMinMax.second; for(TInt iElem = 0; iElem < aNbElem; iElem++){ @@ -1502,14 +1528,14 @@ VISU_MedConvertor return this; TSetIsDone aSetIsDone(myIsMinMaxDone); - TTimerLog aTimerLog(MYDEBUG,"BuildMinMax"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax"); MED::PWrapper aMed = MED::CrWrapper(myFileInfo.absFilePath().latin1()); MED::TKey2Gauss aKey2Gauss = MED::GetKey2Gauss(aMed); MED::TMKey2Profile aMKey2Profile = MED::GetMKey2Profile(aMed); TInt aNbMeshes = aMed->GetNbMeshes(); - TMeshMap& aMeshMap = myMeshMap; + VISU::TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildMinMax - aNbMeshes = "<GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); - TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); if(anIter == aMeshMap.end()) continue; - PMEDMesh aMesh = anIter->second; + VISU::PMEDMesh aMesh = anIter->second; #ifndef _DEXCEPT_ try{ @@ -1539,7 +1565,7 @@ VISU_MedConvertor MED::TEntityInfo anEntityInfo = aMed->GetEntityInfo(aMeshInfo); for(TInt iField = 1; iField <= aNbFields; iField++){ - TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPFieldInfo()"); MED::PFieldInfo aFieldInfo = aMed->GetPFieldInfo(aMeshInfo,iField); std::string aFieldName = aFieldInfo->GetName(); INITMSG(MYDEBUG,"- aFieldName = '"<myMeshOnEntityMap[aVEntity]; - TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; - PMEDField aField = aFieldMap[aFieldName]; + VISU::TEntity aVEntity = MEDEntityToVTK(aMEntity); + VISU::PMEDMeshOnEntity aMeshOnEntity = aMesh->myMeshOnEntityMap[aVEntity]; + VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap; + VISU::PMEDField aField = aFieldMap[aFieldName]; TInt aNbComp = aField->myNbComp; int aNbComp2 = aNbComp; @@ -1565,10 +1591,10 @@ VISU_MedConvertor else if(aNbComp > 4) aNbComp2 = 3; - TMinMaxArr& aMinMaxArr = aField->myMinMaxArr; + VISU::TMinMaxArr& aMinMaxArr = aField->myMinMaxArr; TSetIsDone aSetIsDone(aField->myIsMinMaxInitilized); for(TInt iTimeStamp = aNbTimeStamps; iTimeStamp >= 1; iTimeStamp--){ - TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()"); + VISU::TTimerLog aTimerLog(MYDEBUG,"BuildMinMax - GetPTimeStampInfo()"); INITMSG(MYDEBUG,"- iTimeStamp = "<GetNbMeshes(); - TMeshMap& aMeshMap = myMeshMap; + VISU::TMeshMap& aMeshMap = myMeshMap; INITMSG(MYDEBUG,"BuildGroups - aNbMeshes = "<GetPMeshInfo(iMesh); std::string aMeshName = aMeshInfo->GetName(); - TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); + VISU::TMeshMap::const_iterator anIter = aMeshMap.find(aMeshName); if(anIter == aMeshMap.end()) continue; - PMEDMesh aMesh = anIter->second; + VISU::PMEDMesh aMesh = anIter->second; INITMSG(MYDEBUG,"aMeshName = '"<myEntity; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; - if(anEntity == NODE_ENTITY){ + if(anEntity == VISU::NODE_ENTITY){ isPointsUpdated += LoadPoints(aMed,theMesh); }else{ isPointsUpdated += LoadPoints(aMed,theMesh); @@ -1766,14 +1792,14 @@ VISU_MedConvertor VISU::PMeshOnEntityImpl theMeshOnEntity, VISU::PFamilyImpl theFamily) { - TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadFamilyOnEntity"); INITMSG(MYDEBUG,"LoadFamilyOnEntity"<myEntity; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; - if(anEntity == NODE_ENTITY){ + if(anEntity == VISU::NODE_ENTITY){ isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,theFamily); }else{ isPointsUpdated += LoadPoints(aMed,theMesh); @@ -1790,18 +1816,18 @@ VISU_MedConvertor ::LoadMeshOnGroup(VISU::PMeshImpl theMesh, const VISU::TFamilySet& theFamilySet) { - TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadMeshOnGroup"); INITMSG(MYDEBUG,"LoadMeshOnGroup"<myEntity; - const PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; + VISU::PMEDFamily aFamily = *aFamilyIter; + const VISU::TEntity& anEntity = aFamily->myEntity; + const VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity]; isPointsUpdated += LoadPoints(aMed,theMesh); - if(anEntity == NODE_ENTITY){ + if(anEntity == VISU::NODE_ENTITY){ isPointsUpdated += LoadPointsOnFamily(aMed,theMesh,aFamily); }else{ isCellsOnEntityUpdated += LoadCellsOnFamily(aMed,theMesh,aMeshOnEntity,aFamily); @@ -1820,15 +1846,15 @@ VISU_MedConvertor VISU::PFieldImpl theField, VISU::PValForTimeImpl theValForTime) { - TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnMesh"); INITMSG(MYDEBUG,"LoadValForTimeOnMesh"<myEntity; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; isPointsUpdated += LoadPoints(aMed,theMesh); - if(anEntity != NODE_ENTITY) + if(anEntity != VISU::NODE_ENTITY) isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); int isFieldUpdated = LoadValForTimeOnMesh(aMed,theMesh,theMeshOnEntity,theField,theValForTime); @@ -1844,14 +1870,14 @@ VISU_MedConvertor VISU::PFieldImpl theField, VISU::PValForTimeImpl theValForTime) { - TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTimeOnGaussPts"); INITMSG(MYDEBUG,"LoadValForTimeOnGaussPts"<myEntity; + const VISU::TEntity& anEntity = theMeshOnEntity->myEntity; int isPointsUpdated = 0, isCellsOnEntityUpdated = 0; - if(anEntity != NODE_ENTITY) + if(anEntity != VISU::NODE_ENTITY) isCellsOnEntityUpdated += LoadCellsOnEntity(aMed,theMesh,theMeshOnEntity); int isFieldUpdated = LoadValForTimeOnGaussPts(aMed,theMesh,theMeshOnEntity,theField,theValForTime); @@ -1865,12 +1891,12 @@ VISU_MedConvertor ::LoadPoints(const MED::PWrapper& theMed, VISU::PMEDMesh theMesh) { - TTimerLog aTimerLog(MYDEBUG,"LoadPoints"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPoints"); try{ //Check on existing family - PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; + VISU::PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[VISU::NODE_ENTITY]; aMeshOnEntity->myMeshName = theMesh->myName; - aMeshOnEntity->myEntity = NODE_ENTITY; + aMeshOnEntity->myEntity = VISU::NODE_ENTITY; INITMSG(MYDEBUG,"LoadPoints - theMesh->myIsDone = "<myIsDone<<"'\n"); @@ -1884,30 +1910,18 @@ VISU_MedConvertor //Main part of code MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); TInt aNbElem = aNodeInfo->GetNbElem(); - TInt aDim = theMesh->myDim; - PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; - TMEDNamedPointCoords& aCoords = aNamedPointCoords; - aCoords.Init(aNodeInfo, theMed->GetVersion()); - - for(int iDim = 0; iDim < aDim; iDim++) - aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim); - - for(int iElem = 0; iElem < aNbElem; iElem++){ - TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); - MED::TCCoordSlice aMCoordSlice = aNodeInfo->GetCoordSlice(iElem); - for(int iDim = 0; iDim < aDim; iDim++) - aVCoordSlice[iDim] = aMCoordSlice[iDim]; - } + VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; + aNamedPointCoords->Init(aNodeInfo, theMed->GetVersion()); - TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; - PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); + VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh()); - aSubMesh->Init(MED::PElemInfo(aNodeInfo),theMed->GetVersion()); + aSubMesh->Init(MED::PElemInfo(aNodeInfo), theMed->GetVersion()); aSubMesh->myNbCells = theMesh->myNbPoints; aSubMesh->myCellsSize = 2*theMesh->myNbPoints; - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); for (int iElem = 0; iElem < aNbElem; iElem++) aCell2Connect[iElem] = VISU::TConnect(1,iElem); @@ -1916,33 +1930,20 @@ VISU_MedConvertor //Main part of code MED::PGrilleInfo aGrilleInfo = theMed->GetPGrilleInfo(theMesh->myMeshInfo); TInt aNbElem = aGrilleInfo->GetNbNodes(); - TInt aDim = theMesh->myDim; - PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; - TMEDNamedPointCoords& aCoords = aNamedPointCoords; - aCoords.Init(aGrilleInfo); + VISU::PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; + aNamedPointCoords->Init(aGrilleInfo); - for(int iDim = 0; iDim < aDim; iDim++) - aCoords.GetName(iDim) = aGrilleInfo->GetCoordName(iDim); - - for(int iElem = 0; iElem < aNbElem; iElem++){ - TCoordSlice aVCoordSlice = aCoords.GetCoordSlice(iElem); - MED::TNodeCoord aMCoord = aGrilleInfo->GetCoord(iElem); - for(int iDim = 0; iDim < aDim; iDim++){ - aVCoordSlice[iDim] = aMCoord[iDim]; - } - } - - TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; - PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); + VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new VISU::TMEDSubMesh()); aSubMesh->Init(aGrilleInfo); aSubMesh->myNbCells = theMesh->myNbPoints; aSubMesh->myCellsSize = 2*theMesh->myNbPoints; - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); - for (int iElem = 0; iElem < aNbElem; iElem++) + for(int iElem = 0; iElem < aNbElem; iElem++) aCell2Connect[iElem] = VISU::TConnect(1,iElem); } @@ -1968,7 +1969,7 @@ VISU_MedConvertor const VISU::PMEDMesh theMesh, const VISU::PMEDFamily theFamily) { - TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadPointsOnFamily"); try{ if(theFamily->myIsDone) return 0; @@ -1977,13 +1978,13 @@ VISU_MedConvertor MED::EMaillage aType = aMeshInfo->GetType(); //Main part of code - if(aType==MED::eNON_STRUCTURE){ + if(aType == MED::eNON_STRUCTURE){ MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(theMesh->myMeshInfo); TInt aNbElem = aNodeInfo->GetNbElem(); if(aNbElem > 0){ TInt anId = theFamily->myId; - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; + VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; for(TInt iElem = 0; iElem < aNbElem; iElem++) if(aNodeInfo->GetFamNum(iElem) == anId) aSubMeshID.push_back(iElem); @@ -1995,7 +1996,7 @@ VISU_MedConvertor if(aNbElem > 0){ TInt anId = theFamily->myId; - TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; + VISU::TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1]; for(TInt iElem = 0; iElem < aNbElem; iElem++) if(aGrilleInfo->GetFamNumNode(iElem) == anId) aSubMeshID.push_back(iElem); @@ -2023,11 +2024,11 @@ VISU_MedConvertor const VISU::PMEDMesh theMesh, const VISU::PMEDMeshOnEntity theMeshOnEntity) { - TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnEntity"); #ifndef _DEXCEPT_ try{ #endif - const TEntity& aVEntity = theMeshOnEntity->myEntity; + const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity; const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity); INITMSG(MYDEBUG,"LoadCellsOnEntity - aVEntity = "<myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); - TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; + VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; @@ -2062,21 +2063,21 @@ VISU_MedConvertor TInt aNbElem = aGrilleInfo->GetNbCells(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh()); aSubMesh->Init(aGrilleInfo); aSubMesh->myNbCells = aNbElem; aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1); - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); TInt aMNbNodes = MEDGeom2NbNodes(aMGeom); - TVector aConnect(aMNbNodes); + VISU::TVector aConnect(aMNbNodes); for(TInt iElem = 0; iElem < aNbElem; iElem++) { MED::TIntVector aConn = aGrilleInfo->GetConn(iElem); - TConnect& anArray = aCell2Connect[iElem]; + VISU::TConnect& anArray = aCell2Connect[iElem]; anArray.resize(aVNbNodes); if(anIsNodeNum){ @@ -2146,7 +2147,7 @@ VISU_MedConvertor const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; MED::TGeom2Size::const_iterator aGeom2SizeIter = aGeom2Size.begin(); - TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; + VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh; for(; aGeom2SizeIter != aGeom2Size.end(); aGeom2SizeIter++){ const MED::EGeometrieElement& aMGeom = aGeom2SizeIter->first; @@ -2157,19 +2158,19 @@ VISU_MedConvertor MED::PPolygoneInfo aPolygoneInfo = theMed->GetPPolygoneInfo(aMeshInfo,aMEntity,aMGeom); TInt aNbElem = aPolygoneInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh()); aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); for(TInt iElem = 0; iElem < aNbElem; iElem++) { MED::TCConnSlice aConnSlice = aPolygoneInfo->GetConnSlice(iElem); TInt aNbConn = aPolygoneInfo->GetNbConn(iElem); aSubMesh->myCellsSize += aNbConn; - TConnect& anArray = aCell2Connect[iElem]; + VISU::TConnect& anArray = aCell2Connect[iElem]; anArray.resize(aNbConn); for(TInt iConn = 0; iConn < aNbConn; iConn++) anArray[iConn] = aConnSlice[iConn] - 1; @@ -2182,17 +2183,17 @@ VISU_MedConvertor TInt aNbElem = aPolyedreInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh()); aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); for(TInt iElem = 0; iElem < aNbElem; iElem++){ MED::TCConnSliceArr aConnSliceArr = aPolyedreInfo->GetConnSliceArr(iElem); - TConnect& anArray = aCell2Connect[iElem]; + VISU::TConnect& anArray = aCell2Connect[iElem]; typedef std::set TConnectSet; TConnectSet aConnectSet; TInt aNbFaces = aConnSliceArr.size(); @@ -2225,21 +2226,21 @@ VISU_MedConvertor TInt aNbElem = aCellInfo->GetNbElem(); if(aNbElem > 0){ - PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); + VISU::PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new VISU::TMEDSubMesh()); aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1); - TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; + VISU::TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; aCell2Connect.resize(aNbElem); TInt aMNbNodes = MEDGeom2NbNodes(aMGeom); - TVector aConnect(aMNbNodes); + VISU::TVector aConnect(aMNbNodes); for(TInt iElem = 0; iElem < aNbElem; iElem++) { MED::TCConnSlice aConnSlice = aCellInfo->GetConnSlice(iElem); - TConnect& anArray = aCell2Connect[iElem]; + VISU::TConnect& anArray = aCell2Connect[iElem]; anArray.resize(aVNbNodes); if(anIsNodeNum){ @@ -2375,11 +2376,11 @@ VISU_MedConvertor const VISU::PMEDMeshOnEntity theMeshOnEntity, const VISU::PMEDFamily theFamily) { - TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadCellsOnFamily"); #ifndef _DEXCEPT_ try{ #endif - const TEntity& aVEntity = theMeshOnEntity->myEntity; + const VISU::TEntity& aVEntity = theMeshOnEntity->myEntity; const MED::EEntiteMaillage& aMEntity = VTKEntityToMED(aVEntity); INITMSG(MYDEBUG,"LoadCellsOnFamily - aVEntity = "<myId; const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; - TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; + VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID; MED::EMaillage aType = aMeshInfo->GetType(); const MED::TGeom2Size& aGeom2Size = theMeshOnEntity->myGeom2Size; @@ -2414,14 +2415,14 @@ VISU_MedConvertor }} if(anElemInfo){ if(TInt aNbElem = anElemInfo->GetNbElem()){ - TSubMeshID aSubMeshID; + VISU::TSubMeshID aSubMeshID; for(TInt iElem = 0; iElem < aNbElem; iElem++) if(anElemInfo->GetFamNum(iElem) == anId) aSubMeshID.push_back(iElem); if(!aSubMeshID.empty()){ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); INITMSG(MYDEBUG,"aMGeom = "<GetNbCells(); if(aNbElem>0 && (aMGeom == anElemInfo->GetGeom()) ){ - TSubMeshID aSubMeshID; + VISU::TSubMeshID aSubMeshID; for(TInt iElem = 0; iElem < aNbElem; iElem++) if(anElemInfo->GetFamNum(iElem) == anId) aSubMeshID.push_back(iElem); if(!aSubMeshID.empty()){ VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); INITMSG(MYDEBUG,"aMGeom = "<myIsDone) return; - const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; const MED::TGeom2Profile& aGeom2Profile = theTimeStampValue->GetGeom2Profile(); MED::TGeom2Profile::const_iterator anIter = aGeom2Profile.begin(); for(; anIter != aGeom2Profile.end(); anIter++){ @@ -2483,13 +2484,13 @@ LoadProfile(const MED::PWrapper& theMed, MED::EGeometrieElement aMGeom = anIter->first; VISU::EGeometry aEGeom = MEDGeom2VISU(aMGeom); - TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom); + VISU::TGeom2SubProfile::const_iterator anIter2 = aGeom2SubProfile.find(aEGeom); if(anIter2 != aGeom2SubProfile.end()){ - PMEDSubProfile aSubProfile = anIter2->second; + VISU::PMEDSubProfile aSubProfile = anIter2->second; MED::TElemNum& anElemNum = aProfileInfo->myElemNum; if(!anElemNum.empty()){ - TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID; + VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID; TInt aSize = anElemNum.size(); aSubMeshID.resize(aSize); for(TInt anId = 0; anId < aSize; anId++) @@ -2505,13 +2506,13 @@ LoadProfile(const MED::PWrapper& theMed, { const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; - TEntity aVEntity = theMeshOnEntity.myEntity; + VISU::TEntity aVEntity = theMeshOnEntity.myEntity; MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity); - const TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; - TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); + const VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin(); for(; anIter != aGeom2SubProfile.end(); anIter++){ - const PMEDSubProfile& aSubProfile = anIter->second; + const VISU::PMEDSubProfile& aSubProfile = anIter->second; MED::EGeometrieElement aMGeom = aSubProfile->myMGeom; MED::PElemInfo anElemInfo; anElemInfo = theMed->GetPElemInfo(aMeshInfo,aMEntity,aMGeom); @@ -2532,37 +2533,37 @@ LoadGaussMesh(const MED::PWrapper& theMed, VISU::TMEDValForTime& theValForTime, VISU::TMEDMeshOnEntity& theMeshOnEntity) { - TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadGaussMesh"); INITMSG(MYDEBUG,"LoadGaussMesh"<myMeshInfo->GetType() == MED::eSTRUCTURE) - EXCEPTION(runtime_error,"LoadGaussMesh - Gauss Points localization error!!!"); + EXCEPTION(std::runtime_error,"LoadGaussMesh - Gauss Points localization error!!!"); - PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh; + VISU::PMEDGaussMesh aGaussMesh = theValForTime.myGaussMesh; if(!aGaussMesh || aGaussMesh->myIsDone) return; const MED::PMeshInfo& aMeshInfo = theMesh->myMeshInfo; MED::PNodeInfo aNodeInfo = theMed->GetPNodeInfo(aMeshInfo); - TEntity aVEntity = theMeshOnEntity.myEntity; + VISU::TEntity aVEntity = theMeshOnEntity.myEntity; MED::EEntiteMaillage aMEntity = VTKEntityToMED(aVEntity); - const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; + const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; const MED::TTimeStampInfo& aTimeStampInfo = theTimeStampValue->GetTimeStampInfo(); const MED::TGeom2Gauss& aGeom2Gauss = aTimeStampInfo.GetGeom2Gauss(); - TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin(); + VISU::TGeom2GaussSubMesh::const_iterator aSubMeshIter = aGeom2GaussSubMesh.begin(); for(; aSubMeshIter != aGeom2GaussSubMesh.end(); aSubMeshIter++){ - PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second; + VISU::PMEDGaussSubMesh aGaussSubMesh = aSubMeshIter->second; VISU::EGeometry aEGeom = aSubMeshIter->first; if(aGaussSubMesh->myIsDone) continue; - PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile; - const TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID; + VISU::PMEDSubProfile aSubProfile = aGaussSubMesh->mySubProfile; + const VISU::TSubMeshID& aSubMeshID = aSubProfile->mySubMeshID; MED::EGeometrieElement aMGeom = aSubProfile->myMGeom; MED::PPolygoneInfo aPolygoneInfo; @@ -2599,7 +2600,7 @@ LoadGaussMesh(const MED::PWrapper& theMed, MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom); if(aGaussIter != aGeom2Gauss.end()){ - PMEDGauss aGauss = aGaussSubMesh->myGauss; + VISU::PMEDGauss aGauss = aGaussSubMesh->myGauss; MED::PGaussInfo aGaussInfo = aGauss->myGaussInfo; if(aGaussInfo){ aName = aGaussInfo->GetName(); @@ -2668,10 +2669,10 @@ LoadGaussMesh(const MED::PWrapper& theMed, } if(anIsGaussCoord3D){ - TPointCoords& aCoords = aGaussSubMesh->myPointCoords; - TMEDGaussCoordHolder* aCoordHolder = new TMEDGaussCoordHolder(); + VISU::TPointCoords& aCoords = aGaussSubMesh->myPointCoords; + VISU::TMEDGaussCoordHolder* aCoordHolder = new VISU::TMEDGaussCoordHolder(); aCoordHolder->Init(aGaussCoordPtr); - aCoords.Init(PCoordHolder(aCoordHolder)); + aCoords.Init(VISU::PCoordHolder(aCoordHolder)); aGaussSubMesh->myIsDone = true; @@ -2688,7 +2689,7 @@ LoadGaussMesh(const MED::PWrapper& theMed, "; aNbCells = "<myIsDone = true; @@ -2699,22 +2700,22 @@ LoadGaussMesh(const MED::PWrapper& theMed, template void FillValForTime(MED::SharedPtr theTimeStampValue, - const TGeom2SubProfile& theGeom2SubProfile, + const VISU::TGeom2SubProfile& theGeom2SubProfile, VISU::PMEDValForTime theValForTime, VISU::PMEDField theField) { theField->myDataSize = 0; TInt aNbComp = theField->myNbComp; - TGeom2SubProfile::const_iterator anIter = theGeom2SubProfile.begin(); + VISU::TGeom2SubProfile::const_iterator anIter = theGeom2SubProfile.begin(); for(; anIter != theGeom2SubProfile.end(); anIter++){ VISU::EGeometry aEGeom = anIter->first; - PMEDSubProfile aSubProfile(anIter->second); + VISU::PMEDSubProfile aSubProfile(anIter->second); TInt aNbElem = aSubProfile->myNbCells; theField->myDataSize += aNbElem * aNbComp; - if(aSubProfile->myStatus != eRemoveAll){ + if(aSubProfile->myStatus != VISU::eRemoveAll){ TInt aNbGauss = theValForTime->GetNbGauss(aEGeom); INITMSG(MYDEBUG, @@ -2723,9 +2724,9 @@ FillValForTime(MED::SharedPtr theTimeStampValue, "; aNbGauss = "<GetMeshValue(aEGeom); + VISU::PMeshValue& aVMeshValue = theValForTime->GetMeshValue(aEGeom); typedef typename TimeStampValueType::TElement TElement; - typedef TTMEDMeshValue TVMeshValue; + typedef VISU::TTMEDMeshValue TVMeshValue; TVMeshValue* aMeshValue = new TVMeshValue(); MED::EGeometrieElement aMGeom = aSubProfile->myMGeom; @@ -2747,7 +2748,7 @@ LoadValForTime(const MED::PWrapper& theMed, bool theIsGauss, bool& theIsDone) { - TTimerLog aTimerLog(MYDEBUG,"LoadValForTime"); + VISU::TTimerLog aTimerLog(MYDEBUG,"LoadValForTime"); INITMSG(MYDEBUG,"LoadValForTime - theIsGauss = "<myProfile; - TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; + VISU::PMEDProfile aProfile = theValForTime->myProfile; + VISU::TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile; INITMSGA(MYDEBUG,0, "- aMeshName = '"<myIDMapperFilter; + VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper; return LoadValForTime(theMed, theMesh, theMeshOnEntity, theField, theValForTime, false, - anIDMapperFilter->myIsVTKDone); + anUnstructuredGridIDMapper->myIsVTKDone); } @@ -2857,7 +2858,7 @@ VISU_MedConvertor VISU::PMEDField theField, VISU::PMEDValForTime theValForTime) { - PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter; + VISU::PGaussPtsIDFilter aGaussPtsIDFilter = theValForTime->myGaussPtsIDFilter; return LoadValForTime(theMed, theMesh, theMeshOnEntity, diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 7836ea5a..0f3fa042 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -20,6 +20,9 @@ #define VISU_MedConvertor_HeaderFile #include "VISU_Convertor_impl.hxx" +#include "VISU_Structures_impl.hxx" +#include "VISU_PointCoords.hxx" +#include "VISU_MeshValue.hxx" #include "MED_Common.hxx" #include "MED_Structures.hxx" @@ -125,7 +128,7 @@ namespace VISU { MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not MED::PElemNum myElemNum; //!< Keeps objects numeration - TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one + mutable TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one MED::EVersion myVersion; MED::PString myElemNames; //!< Keeps whether the names exists or not @@ -164,7 +167,7 @@ namespace VISU unsigned long int GetMemorySize(); }; - typedef SharedPtr PMEDNamedPointCoords; + typedef MED::SharedPtr PMEDNamedPointCoords; //--------------------------------------------------------------- @@ -173,7 +176,7 @@ namespace VISU MED::PMeshInfo myMeshInfo; MED::TEntityInfo myEntityInfo; }; - typedef SharedPtr PMEDMesh; + typedef MED::SharedPtr PMEDMesh; //--------------------------------------------------------------- @@ -197,13 +200,13 @@ namespace VISU unsigned long int GetMemorySize(); }; - typedef SharedPtr PMEDSubProfile; + typedef MED::SharedPtr PMEDSubProfile; //--------------------------------------------------------------- struct TMEDProfile: virtual TProfileImpl {}; - typedef SharedPtr PMEDProfile; + typedef MED::SharedPtr PMEDProfile; //--------------------------------------------------------------- @@ -217,7 +220,7 @@ namespace VISU LessThan(const PGaussImpl& theGauss, bool& theResult) const; }; - typedef SharedPtr PMEDGauss; + typedef MED::SharedPtr PMEDGauss; //--------------------------------------------------------------- @@ -240,13 +243,13 @@ namespace VISU unsigned long int GetMemorySize(); }; - typedef SharedPtr PMEDGaussSubMesh; + typedef MED::SharedPtr PMEDGaussSubMesh; //--------------------------------------------------------------- struct TMEDGaussMesh: virtual TGaussMeshImpl {}; - typedef SharedPtr PMEDGaussMesh; + typedef MED::SharedPtr PMEDGaussMesh; //--------------------------------------------------------------- @@ -284,7 +287,7 @@ namespace VISU unsigned long int GetMemorySize(); }; - typedef SharedPtr PMEDSubMesh; + typedef MED::SharedPtr PMEDSubMesh; //--------------------------------------------------------------- @@ -295,31 +298,31 @@ namespace VISU TFamilyID2CellsSize myFamilyID2CellsSize; MED::TGeom2Size myGeom2Size; }; - typedef SharedPtr PMEDMeshOnEntity; + typedef MED::SharedPtr PMEDMeshOnEntity; //--------------------------------------------------------------- struct TMEDFamily: virtual TFamilyImpl {}; - typedef SharedPtr PMEDFamily; + typedef MED::SharedPtr PMEDFamily; //--------------------------------------------------------------- struct TMEDGroup: virtual TGroupImpl {}; - typedef SharedPtr PMEDGroup; + typedef MED::SharedPtr PMEDGroup; //--------------------------------------------------------------- struct TMEDField: virtual TFieldImpl {}; - typedef SharedPtr PMEDField; + typedef MED::SharedPtr PMEDField; //--------------------------------------------------------------- struct TMEDValForTime: virtual TValForTimeImpl {}; - typedef SharedPtr PMEDValForTime; + typedef MED::SharedPtr PMEDValForTime; } diff --git a/src/CONVERTOR/VISU_MeshValue.cxx b/src/CONVERTOR/VISU_MeshValue.cxx new file mode 100644 index 00000000..4b7a2785 --- /dev/null +++ b/src/CONVERTOR/VISU_MeshValue.cxx @@ -0,0 +1,615 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: +// Author: +// Module : VISU + +#include "VISU_MeshValue.hxx" +#include "VISU_Structures_impl.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include "VISU_PointCoords.hxx" +#include "VISU_TypeList.hxx" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace VISU +{ + //--------------------------------------------------------------- + std::string + GenerateFieldName(const PFieldImpl& theField, + const PValForTimeImpl& theValForTime) + { + const VISU::TTime& aTime = theValForTime->myTime; + std::string aFieldName = theField->myMeshName + ", " + theField->myName + ": " + + VISU_Convertor::GenerateName(aTime); + return aFieldName; + } + + + //--------------------------------------------------------------- + void + TMeshValueBase + ::Init(vtkIdType theNbElem, + vtkIdType theNbGauss, + vtkIdType theNbComp) + { + myNbElem = theNbElem; + myNbGauss = theNbGauss; + myNbComp = theNbComp; + myStep = theNbComp*theNbGauss; + } + + vtkIdType + TMeshValueBase + ::GetNbElem() const + { + return myNbElem; + } + + vtkIdType + TMeshValueBase + ::GetNbComp() const + { + return myNbComp; + } + + vtkIdType + TMeshValueBase + ::GetNbGauss() const + { + return myNbGauss; + } + + size_t + TMeshValueBase + ::size() const + { + return myNbElem * myStep; + } + + + namespace TL + { + //---------------------------------------------------------------------------- + typedef TList > > > > > > > > > + TVTKBasicTypeList; + + + //---------------------------------------------------------------------------- + typedef TList > > > > > > > > > + TVTKArrayTypeList; + + + typedef TList, + TList, + TList, + TList, + TList, + TList, + TList, + TList, + TList, + TList, + TNullType> > > > > > > > > > + TVTKBasicEnumList; + + + //---------------------------------------------------------------------------- + template + struct TEnum2VTKBasicType + { + typedef typename TTypeAt >::value >::TResult TResult; + }; + + //---------------------------------------------------------------------------- + template + struct TEnum2VTKArrayType + { + typedef typename TTypeAt >::value >::TResult TResult; + }; + + //---------------------------------------------------------------------------- + template + struct TVTKBasicType2Enum + { + typedef typename TTypeAt::value >::TResult TResult; + }; + + } + + + //---------------------------------------------------------------------------- + template + void + InitTimeStampOnProfile(const PUnstructuredGrid& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime, + const VISU::TEntity& theEntity); + + + //---------------------------------------------------------------------------- + void + GetTimeStampOnProfile(const PUnstructuredGrid& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime, + const VISU::TEntity& theEntity) + { + vtkIdType aDataType = theField->GetDataType(); + switch(aDataType){ + case VTK_DOUBLE: + InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); + break; + case VTK_FLOAT: + InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); + break; + case VTK_INT: + InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); + break; + case VTK_LONG: + InitTimeStampOnProfile(theSource, theField, theValForTime, theEntity); + break; + default: + EXCEPTION(std::runtime_error, + "GetTimeStampOnProfile - handling unsupported data type - "< + struct TDataArrayHolder + { + typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; + TVTKDataArray* myDataArray; + + TDataArrayHolder(TVTKDataArray* theDataArray): + myDataArray(theDataArray) + {} + + void + WritePointer(TVTKDataArray* theDataArray, + vtkIdType theTupleId, + TVTKBasicType* thePointer) + { + vtkIdType aNumberOfComponents = theDataArray->GetNumberOfComponents(); + vtkIdType aPosition = theTupleId * aNumberOfComponents; + TVTKBasicType *aPtr = theDataArray->WritePointer(aPosition, aNumberOfComponents); + for(vtkIdType anId = 0; anId < aNumberOfComponents; anId++) + *aPtr++ = *thePointer++; + } + + virtual + void + SetTuple(vtkIdType theTupleId, + TVTKBasicType* thePointer) + { + this->WritePointer(myDataArray, theTupleId, thePointer); + } + }; + + + //---------------------------------------------------------------------------- + template + struct TDataArrayHolder2: TDataArrayHolder + { + typedef TDataArrayHolder TSuperClass; + typedef typename TSuperClass::TVTKDataArray TVTKDataArray; + typedef typename TSuperClass::TVTKBasicType TVTKBasicType; + TVTKDataArray* myDataArray2; + + TDataArrayHolder2(TVTKDataArray* theDataArray, + TVTKDataArray* theDataArray2): + TSuperClass(theDataArray), + myDataArray2(theDataArray2) + {} + + virtual + void + SetTuple(vtkIdType theTupleId, + TVTKBasicType* thePointer) + { + this->WritePointer(this->myDataArray, theTupleId, thePointer); + this->WritePointer(this->myDataArray2, theTupleId, thePointer); + } + }; + + + //---------------------------------------------------------------------------- + template + struct TTimeStampOnProfileInitArray + { + typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; + typedef TTMeshValue TMeshValue; + typedef MED::SharedPtr TMeshValuePtr; + + typedef TDataArrayHolder TTDataArrayHolder; + typedef MED::SharedPtr PDataArrayHolder; + PDataArrayHolder myDataArrayHolder; + + TTimeStampOnProfileInitArray(const PDataArrayHolder& theDataArrayHolder): + myDataArrayHolder(theDataArrayHolder) + {} + + void + Execute(const PFieldImpl& theField, + const PValForTimeImpl& theValForTime) + { + vtkIdType aNbComp = theField->myNbComp; + vtkIdType aSize = std::max(3, aNbComp); + TVector aDataValues(aSize); + + const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue(); + TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); + for(int aTupleId = 0; anIter != aGeom2MeshValue.end(); anIter++){ + EGeometry aEGeom = anIter->first; + const TMeshValuePtr aMeshValue = anIter->second; + + vtkIdType aNbElem = aMeshValue->GetNbElem(); + vtkIdType aNbGauss = aMeshValue->GetNbGauss(); + + INITMSG(MYDEBUG, + "- aEGeom = "<AddArray(aFullDataArray); + + INITMSG(MYDEBUG,"InitTimeStampOnProfile "<< + "- theEntity = "<GetGeom2MeshValue(); + typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; + typedef TTMeshValue TMeshValue; + typedef MED::SharedPtr TMeshValuePtr; + + typedef TDataArrayHolder TTDataArrayHolder; + typedef MED::SharedPtr PDataArrayHolder; + + TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); + if(aGeom2MeshValue.size() == 1 && aMeshValue->GetNbGauss() == 1){ + aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), + aMeshValue->size(), + true); + INITMSG(MYDEBUG,"InitTimeStampOnProfile - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), + aMeshValue->size(), + true); + INITMSG(MYDEBUG,"InitTimeStampOnProfile - aSelectedDataArray->SetVoidArray()"<(aDataArrayHolder).Execute(theField, theValForTime); + } + }else{ + typedef TDataArrayHolder2 TTDataArrayHolder2; + PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray)); + TTimeStampOnProfileInitArray(aDataArrayHolder).Execute(theField, theValForTime); + } + + aSelectedDataArray->Delete(); + aFullDataArray->Delete(); + } + + + //---------------------------------------------------------------------------- + template + void + InitTimeStampOnGaussMesh(const PPolyData& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime); + + void + GetTimeStampOnGaussMesh(const PPolyData& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime) + { + vtkIdType aDataType = theField->GetDataType(); + switch(aDataType){ + case VTK_DOUBLE: + InitTimeStampOnGaussMesh(theSource, theField, theValForTime); + break; + case VTK_FLOAT: + InitTimeStampOnGaussMesh(theSource, theField, theValForTime); + break; + case VTK_INT: + InitTimeStampOnGaussMesh(theSource, theField, theValForTime); + break; + case VTK_LONG: + InitTimeStampOnGaussMesh(theSource, theField, theValForTime); + break; + default: + EXCEPTION(std::runtime_error, + "GetTimeStampOnGaussMesh - handling unsupported data type - "< + struct TTimeStampOnGaussMeshInitArray + { + typedef typename TL::TEnum2VTKArrayType::TResult TVTKDataArray; + typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; + typedef TTMeshValue TMeshValue; + typedef MED::SharedPtr TMeshValuePtr; + + typedef TDataArrayHolder TTDataArrayHolder; + typedef MED::SharedPtr PDataArrayHolder; + PDataArrayHolder myDataArrayHolder; + + TTimeStampOnGaussMeshInitArray(const PDataArrayHolder& theDataArrayHolder): + myDataArrayHolder(theDataArrayHolder) + {} + + void + Execute(const PFieldImpl& theField, + const PValForTimeImpl& theValForTime) + { + vtkIdType aNbComp = theField->myNbComp; + vtkIdType aSize = std::max(3, aNbComp); + TVector aDataValues(aSize); + + const TGeom2MeshValue& aGeom2MeshValue = theValForTime->GetGeom2MeshValue(); + + PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh; + const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh; + TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin(); + for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){ + EGeometry aEGeom = anIter->first; + + PGaussSubMeshImpl aGaussSubMesh = anIter->second; + if(!aGaussSubMesh->myIsDone) + continue; + + TGeom2MeshValue::const_iterator anIter2 = aGeom2MeshValue.find(aEGeom); + if(anIter2 == aGeom2MeshValue.end()){ + EXCEPTION(std::runtime_error, + "TTimeStampOnGaussMeshInitArray >> Can't find values for corresponding Gauss Points SubMesh"); + } + TMeshValuePtr aMeshValue = anIter2->second; + vtkIdType aNbGauss = aMeshValue->GetNbGauss(); + vtkIdType aNbElem = aMeshValue->GetNbElem(); + + if(aNbGauss < 1) + continue; + + const TPointCoords& aCoords = aGaussSubMesh->myPointCoords; + + INITMSG(MYDEBUG, + "- aEGeom = "<AddArray(aFullDataArray); + + INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh "<< + "- aNbTuples = "<GetGeom2MeshValue(); + typedef typename TL::TEnum2VTKBasicType::TResult TVTKBasicType; + typedef TTMeshValue TMeshValue; + typedef MED::SharedPtr TMeshValuePtr; + + typedef TDataArrayHolder TTDataArrayHolder; + typedef MED::SharedPtr PDataArrayHolder; + + TMeshValuePtr aMeshValue = theValForTime->GetFirstMeshValue(); + if(aGeom2MeshValue.size() == 1){ + aFullDataArray->SetVoidArray(aMeshValue->GetPointer(), + aMeshValue->size(), + true); + INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aFullDataArray->SetVoidArray()"<SetVoidArray(aMeshValue->GetPointer(), + aMeshValue->size(), + true); + INITMSG(MYDEBUG,"InitTimeStampOnGaussMesh - aSelectedDataArray->SetVoidArray()"<(aDataArrayHolder).Execute(theField, theValForTime); + } + }else{ + typedef TDataArrayHolder2 TTDataArrayHolder2; + PDataArrayHolder aDataArrayHolder(new TTDataArrayHolder2(aSelectedDataArray, aFullDataArray)); + TTimeStampOnGaussMeshInitArray(aDataArrayHolder).Execute(theField, theValForTime); + } + + aSelectedDataArray->Delete(); + aFullDataArray->Delete(); + } + + + //--------------------------------------------------------------- +} diff --git a/src/CONVERTOR/VISU_MeshValue.hxx b/src/CONVERTOR/VISU_MeshValue.hxx new file mode 100644 index 00000000..70c1df6a --- /dev/null +++ b/src/CONVERTOR/VISU_MeshValue.hxx @@ -0,0 +1,219 @@ +// VISU CONVERTOR : +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_Convertor.hxx +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_MeshValue_HeaderFile +#define VISU_MeshValue_HeaderFile + +/*! + \file VISU_MeshValue.hxx + \brief The file contains declarations for basic interfaces that defines mesh value of mesh elements +*/ + +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorDef_impl.hxx" + +#include "MED_SliceArray.hxx" +#include "MED_Vector.hxx" + +namespace VISU +{ + //--------------------------------------------------------------- + //! Define a base class for the container to get access to data assigned to mesh + class TMeshValueBase + { + public: + //! To intitilize the data strucutre + void + Init(vtkIdType theNbElem, + vtkIdType theNbGauss, + vtkIdType theNbComp); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize() const = 0; + + //! Gets number of mesh elements where the data assigned to. + vtkIdType + GetNbElem() const; + + //! Gets number of components of corresponding MED FIELD. + vtkIdType + GetNbComp() const; + + //! Gets number of Gauss Points. + vtkIdType + GetNbGauss() const; + + size_t + size() const; + + protected: + vtkIdType myNbElem; //!< Defines number of mesh elements where the data assigned to + vtkIdType myNbComp; //!< Keeps number of components of corresponding MED FIELD + vtkIdType myNbGauss; //!< Defines number of Gauss Points + vtkIdType myStep; //!< Internal variable + }; + typedef MED::SharedPtr PMeshValue; + + + //--------------------------------------------------------------- + //! Define a container to get access to data assigned to mesh + template + class TTMeshValue: public virtual TMeshValueBase + { + public: + typedef MED::TSlice TValueSlice; + typedef MED::TCSlice TCValueSlice; + + typedef TVector TCValueSliceArr; + typedef TVector TValueSliceArr; + + virtual + const TValueType* + GetPointer() const = 0; + + virtual + TValueType* + GetPointer() = 0; + + //! To get assigned values first by Gauss Points and then by components (constant version) + TCValueSliceArr + GetGaussValueSliceArr(vtkIdType theElemId) const + { + TCValueSliceArr aValueSliceArr(this->myNbGauss); + vtkIdType anId = theElemId * this->myStep; + for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TCValueSlice(this->GetPointer(), + this->size(), + std::slice(anId, this->myNbComp, 1)); + anId += this->myNbComp; + } + return aValueSliceArr; + } + + //! To get assigned values first by Gauss Points and then by components + TValueSliceArr + GetGaussValueSliceArr(vtkIdType theElemId) + { + TValueSliceArr aValueSliceArr(this->myNbGauss); + vtkIdType anId = theElemId * this->myStep; + for(vtkIdType aGaussId = 0; aGaussId < this->myNbGauss; aGaussId++){ + aValueSliceArr[aGaussId] = + TValueSlice(this->GetPointer(), + this->size(), + std::slice(anId, this->myNbComp, 1)); + anId += this->myNbComp; + } + return aValueSliceArr; + } + + //! To get assigned values first by components and then by Gauss Points (constant version) + TCValueSliceArr + GetCompValueSliceArr(vtkIdType theElemId) const + { + TCValueSliceArr aValueSliceArr(this->myNbComp); + vtkIdType anId = theElemId * this->myStep; + for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){ + aValueSliceArr[aCompId] = + TCValueSlice(this->GetPointer(), + this->size(), + std::slice(anId, this->myNbGauss, this->myNbComp)); + anId += 1; + } + return aValueSliceArr; + } + + //! To get assigned values first by components and then by Gauss Points + TValueSliceArr + GetCompValueSliceArr(vtkIdType theElemId) + { + TValueSliceArr aValueSliceArr(this->myNbComp); + vtkIdType anId = theElemId * this->myStep; + for(vtkIdType aCompId = 0; aCompId < this->myNbComp; aCompId++){ + aValueSliceArr[aCompId] = + TValueSlice(this->GetPointer(), + this->size(), + std::slice(anId, this->myNbGauss, this->myNbComp)); + anId += 1; + } + return aValueSliceArr; + } + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize() const + { + return this->size() * sizeof(TValueType); + } + }; + + + //--------------------------------------------------------------- + //! Define a container to get access to data assigned to mesh + template + class TTMeshValueHolder: public virtual TTMeshValue + { + public: + //! To initilize the class instance + void + Init(vtkIdType theNbElem, + vtkIdType theNbGauss, + vtkIdType theNbComp, + const TContainerType& theContainer) + { + TMeshValueBase::Init(theNbElem, theNbGauss, theNbComp); + myContainer = theContainer; + } + + protected: + mutable TContainerType myContainer; //!< Keeps the mesh values container itself + }; + + + //--------------------------------------------------------------- + // Initilize corresponding vtkDataSetAttributes for TValForTime + void + GetTimeStampOnProfile(const PUnstructuredGrid& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime, + const VISU::TEntity& theEntity); + + + //--------------------------------------------------------------- + // Initilize corresponding vtkDataSetAttributes for TValForTime + void + GetTimeStampOnGaussMesh(const PPolyData& theSource, + const PFieldImpl& theField, + const PValForTimeImpl& theValForTime); + + + //--------------------------------------------------------------- +} + +#endif diff --git a/src/CONVERTOR/VISU_PointCoords.cxx b/src/CONVERTOR/VISU_PointCoords.cxx new file mode 100644 index 00000000..31c4ea42 --- /dev/null +++ b/src/CONVERTOR/VISU_PointCoords.cxx @@ -0,0 +1,381 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: +// Author: +// Module : VISU + +#include "VISU_PointCoords.hxx" +#include "VISU_ConvertorUtils.hxx" + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace VISU +{ + //--------------------------------------------------------------- + void + TCoordHolderBase + ::Init(vtkIdType theNbPoints, + vtkIdType theDim) + { + myDim = theDim; + myNbPoints = theNbPoints; + } + + vtkIdType + TCoordHolderBase + ::GetNbPoints() const + { + return myNbPoints; + } + + vtkIdType + TCoordHolderBase + ::GetDim() const + { + return myDim; + } + + size_t + TCoordHolderBase + ::size() const + { + return GetNbPoints() * GetDim(); + } + + unsigned long int + TCoordHolderBase + ::GetMemorySize() + { + return sizeof(TCoord) * size(); + } + + + //--------------------------------------------------------------- + TPointCoords + ::TPointCoords(): + myPoints(vtkPoints::New()) + { + myPoints->SetDataType(VTK_DOUBLE); + myPoints->Delete(); + } + + void + TPointCoords + ::Init(const PCoordHolder& theCoord) + { + myPoints->SetNumberOfPoints(theCoord->GetNbPoints()); + myCoord = theCoord; + } + + vtkIdType + TPointCoords + ::GetNbPoints() const + { + return myCoord->GetNbPoints(); + } + + vtkIdType + TPointCoords + ::GetDim() const + { + return myCoord->GetDim(); + } + + TCCoordSlice + TPointCoords + ::GetCoordSlice(vtkIdType theNodeId) const + { + return myCoord->GetCoordSlice(theNodeId); + } + + TCoordSlice + TPointCoords + ::GetCoordSlice(vtkIdType theNodeId) + { + return myCoord->GetCoordSlice(theNodeId); + } + + void + TPointCoords + ::SetVoidArray() const + { + vtkDataArray* aDataArray = myPoints->GetData(); + aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), true); + } + + vtkPoints* + TPointCoords + ::GetPoints() const + { + if(!myIsVTKDone){ + TTimerLog aTimerLog(MYDEBUG,"TPointCoords::GetPoints()"); + vtkIdType aNbPoints = GetNbPoints(); + vtkIdType aDim = GetDim(); + + INITMSG(MYDEBUG,"TPointCoords::GetPoints - aNbPoints = "<SetPoint(aPointId, aCoords); + } + } + + myIsVTKDone = true; + } + + return myPoints.GetPointer(); + } + + unsigned long int + TPointCoords + ::GetMemorySize() + { + size_t aSize = myCoord->GetMemorySize(); + aSize += myPoints->GetActualMemorySize() * 1024; + return aSize; + } + + + //--------------------------------------------------------------- + void + TNamedPointCoords + ::Init(const PCoordHolder& theCoord) + { + TPointCoords::Init(theCoord); + myPointsDim.resize(theCoord->GetDim()); + } + + std::string& + TNamedPointCoords + ::GetName(vtkIdType theDim) + { + return myPointsDim[theDim]; + } + + const std::string& + TNamedPointCoords + ::GetName(vtkIdType theDim) const + { + return myPointsDim[theDim]; + } + + vtkIdType + TNamedPointCoords + ::GetObjID(vtkIdType theID) const + { + return theID; + } + + vtkIdType + TNamedPointCoords + ::GetVTKID(vtkIdType theID) const + { + return theID; + } + + std::string + TNamedPointCoords + ::GetNodeName(vtkIdType theObjID) const + { + return ""; + } + + + //--------------------------------------------------------------- + enum ECoordName{eX, eY, eZ, eNoneCoord}; + typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice); + + template + VISU::TCoord + GetCoord(const VISU::TCCoordSlice& theCoordSlice) + { + return theCoordSlice[TCoordId]; + } + + template<> + VISU::TCoord + GetCoord(const VISU::TCCoordSlice& theCoordSlice) + { + return 0.0; + } + + + TGetCoord aXYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aXZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + class TCoordHelper{ + TGetCoord* myGetCoord; + public: + TCoordHelper(TGetCoord* theGetCoord): + myGetCoord(theGetCoord) + {} + + virtual + ~TCoordHelper() + {} + + VISU::TCoord + GetCoord(VISU::TCCoordSlice& theCoordSlice, + int theCoordId) + { + return (*myGetCoord[theCoordId])(theCoordSlice); + } + }; + typedef std::auto_ptr TCoordHelperPtr; + + + //--------------------------------------------------------------- + vtkPoints* + TNamedPointCoords + ::GetPoints() const + { + if(!myIsVTKDone){ + TTimerLog aTimerLog(MYDEBUG,"TNamedPointCoords::GetPoints()"); + TCoordHelperPtr aCoordHelperPtr; + bool anIsDimPresent[3] = {false, false, false}; + for(int iDim = 0; iDim < GetDim(); iDim++){ + std::string aName = GetName(iDim); + if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16 + aName = aName.substr(0,1); + if(aName == "x" || aName == "X") + anIsDimPresent[eX] = true; + else if(aName == "y" || aName == "Y") + anIsDimPresent[eY] = true; + else if(aName == "z" || aName == "Z") + anIsDimPresent[eZ] = true; + } + + switch(GetDim()){ + case 3: + aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord)); + break; + case 2: + if(anIsDimPresent[eY] && anIsDimPresent[eZ]) + aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord)); + else if(anIsDimPresent[eX] && anIsDimPresent[eZ]) + aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord)); + else + aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord)); + break; + case 1: + if(anIsDimPresent[eY]) + aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord)); + else if(anIsDimPresent[eZ]) + aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord)); + else + aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord)); + break; + } + + INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - aNbPoints = "<SetPoint(aNodeId, + aCoordHelperPtr->GetCoord(aCoordSlice,eX), + aCoordHelperPtr->GetCoord(aCoordSlice,eY), + aCoordHelperPtr->GetCoord(aCoordSlice,eZ)); + } + } + + myIsVTKDone = true; + } + + return myPoints.GetPointer(); + } + + unsigned long int + TNamedPointCoords + ::GetMemorySize() + { + return TPointCoords::GetMemorySize(); + } + + + //--------------------------------------------------------------- +} diff --git a/src/CONVERTOR/VISU_PointCoords.hxx b/src/CONVERTOR/VISU_PointCoords.hxx new file mode 100644 index 00000000..1ef68772 --- /dev/null +++ b/src/CONVERTOR/VISU_PointCoords.hxx @@ -0,0 +1,258 @@ +// VISU CONVERTOR : +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : VISU_Convertor.hxx +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_PointCoords_HeaderFile +#define VISU_PointCoords_HeaderFile + +/*! + \file VISU_PointCoords.hxx + \brief The file contains declarations for basic interfaces that defines point coords of mesh elements +*/ + +#include "VISU_Convertor.hxx" +#include "VISU_ConvertorDef_impl.hxx" + +#include "MED_SliceArray.hxx" +#include "MED_Structures.hxx" + +#include + +class vtkPoints; + +namespace VISU +{ + //--------------------------------------------------------------- + typedef vtkSmartPointer PPoints; + + typedef MED::TFloat TCoord; + using MED::TCoordSlice; + using MED::TCCoordSlice; + + //--------------------------------------------------------------- + //! This class is responsible for keeping the mesh node coordinates + class TCoordHolderBase: public virtual TBaseStructure + { + public: + //! To initilize the instance + void + Init(vtkIdType theNbPoints, + vtkIdType theDim); + + vtkIdType + GetNbPoints() const; + + vtkIdType + GetDim() const; + + size_t + size() const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Get slice of coordinates for defined node (const version) + virtual + TCCoordSlice + GetCoordSlice(vtkIdType theNodeId) const = 0; + + //! Get slice of coordinates for defined node + virtual + TCoordSlice + GetCoordSlice(vtkIdType theNodeId) = 0; + + virtual + unsigned char* + GetValuePtr() = 0; + + protected: + vtkIdType myDim; //!< Dimension of the nodal coordinates + vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh + }; + typedef MED::SharedPtr PCoordHolder; + + + //--------------------------------------------------------------- + template + class TCoordHolder: public virtual TCoordHolderBase + { + public: + //! To initilize the class instance + void + Init(vtkIdType theNbPoints, + vtkIdType theDim, + const TContainerType& theCoord) + { + TCoordHolderBase::Init(theNbPoints, theDim); + myCoord = theCoord; + } + + //! Gets pointer to the first element in the node coordinates array + virtual + TCoord* + GetPointer() = 0; + + //! Gets pointer to the first element in the node coordinates array (const version) + virtual + const TCoord* + GetPointer() const = 0; + + //! Get slice of coordinates for defined node (const version) + virtual + TCCoordSlice + GetCoordSlice(vtkIdType theNodeId) const + { + return TCCoordSlice(this->GetPointer(), + this->size(), + std::slice(theNodeId * this->GetDim(), this->GetDim(), 1)); + } + + //! Get slice of coordinates for defined node + virtual + TCoordSlice + GetCoordSlice(vtkIdType theNodeId) + { + return TCoordSlice(this->GetPointer(), + this->size(), + std::slice(theNodeId * this->GetDim(), this->GetDim(), 1)); + } + + virtual + unsigned char* + GetValuePtr() + { + return (unsigned char*)this->GetPointer(); + } + + protected: + mutable TContainerType myCoord; //!< Keeps the node coordinates container itself + }; + + + //--------------------------------------------------------------- + //! This class is responsible for representation of mesh nodes + class TPointCoords: public virtual TIsVTKDone + { + public: + TPointCoords(); + + //! To initilize the class + void + Init(const PCoordHolder& theCoord); + + vtkIdType + GetNbPoints() const; + + vtkIdType + GetDim() const; + + virtual + vtkPoints* + GetPoints() const; //!< Gets corresponding VTK structure + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Get slice of coordinates for defined node (const version) + TCCoordSlice + GetCoordSlice(vtkIdType theNodeId) const; + + //! Get slice of coordinates for defined node + TCoordSlice + GetCoordSlice(vtkIdType theNodeId); + + protected: + //! An container for coordinates of the nodes + /*! + Usage of slices allow to minimize amount of memory to store the nodal coordinates and + provide unifirm way of conversation with this coordinates (independant from mesh dimension) + */ + PCoordHolder myCoord; //!< A pointer to the coordinates container holder + PPoints myPoints; //!< VTK representation for the mesh nodes + + void + SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK + }; + + + //--------------------------------------------------------------- + //! This class is responsible for representation of mesh nodes + /*! + In additition to its base functionlity it support mapping of VTK to object numeration and + keeps names for each of nodes. + */ + class TNamedPointCoords: public virtual TPointCoords + { + public: + //! To initilize the class (numeration of the nodes can be missed) + void + Init(const PCoordHolder& theCoord); + + //! Get name for defined dimension + std::string& + GetName(vtkIdType theDim); + + //! Get name for defined dimension (const version) + const std::string& + GetName(vtkIdType theDim) const; + + //! Get object number for node by its VTK one + virtual + vtkIdType + GetObjID(vtkIdType theID) const; + + //! Get VTK number for node by its object one + virtual + vtkIdType + GetVTKID(vtkIdType theID) const; + + //! Get name of node by its object number + virtual + std::string + GetNodeName(vtkIdType theObjID) const; + + virtual + vtkPoints* + GetPoints() const; //!< Gets initialized corresponding VTK structure + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + protected: + typedef TVector TPointsDim; + TPointsDim myPointsDim; //!< Keeps name of each dimension + }; + + + //--------------------------------------------------------------- +} + +#endif diff --git a/src/CONVERTOR/VISU_Structures.cxx b/src/CONVERTOR/VISU_Structures.cxx new file mode 100644 index 00000000..6e751caa --- /dev/null +++ b/src/CONVERTOR/VISU_Structures.cxx @@ -0,0 +1,78 @@ +// +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: +// Author: Alexey PETROV +// Module : VISU + +#include "VISU_Structures.hxx" + + +namespace VISU +{ + //--------------------------------------------------------------- + TIntId + ::TIntId(): + myId(0) + {} + + + //--------------------------------------------------------------- + TIsVTKDone + ::TIsVTKDone(): + myIsVTKDone(false), + myIsDone(false) + {} + + + //--------------------------------------------------------------- + TMesh + ::TMesh(): + myDim(0) + {} + + + //--------------------------------------------------------------- + TMeshOnEntity + ::TMeshOnEntity(): + myEntity(TEntity(-1)) + {} + + + //--------------------------------------------------------------- + TFamily + ::TFamily(): + myEntity(TEntity(-1)) + {} + + + //--------------------------------------------------------------- + TField + ::TField(): + myNbComp(0), + myEntity(TEntity(-1)), + myIsMinMaxInitilized(false) + {} + + + //--------------------------------------------------------------- +} diff --git a/src/CONVERTOR/VISU_Structures.hxx b/src/CONVERTOR/VISU_Structures.hxx new file mode 100644 index 00000000..7ad936e0 --- /dev/null +++ b/src/CONVERTOR/VISU_Structures.hxx @@ -0,0 +1,243 @@ +// +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_Structures_HeaderFile +#define VISU_Structures_HeaderFile + +/*! + \file VISU_Structures.hxx + \brief The file contains definitions for basic classes of the VISU CONVERTER package +*/ + +#include "VISU_IDMapper.hxx" +#include "VISU_ConvertorDef.hxx" + +#include "MED_Vector.hxx" + +#include +#include +#include +#include + +namespace VISU +{ + using MED::TVector; + + //--------------------------------------------------------------- + typedef std::string TName; + typedef TVector TNames; + + //--------------------------------------------------------------- + //! Define a basic class for all MED entites which can be identified by its number + struct TIntId: virtual TBaseStructure + { + vtkIdType myId; + + TIntId(); + }; + + + //--------------------------------------------------------------- + //! Define an utility base class which is repsonsible for preventing repetion + struct TIsVTKDone: virtual TBaseStructure + { + mutable bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure + mutable bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation + + TIsVTKDone(); + }; + + + //--------------------------------------------------------------- + typedef std::map TMeshOnEntityMap; + typedef std::map TGroupMap; + + //! Define a basic class which corresponds to MED MESH entity + /*! + This class in its turn contains map of TMeshOnEntity and TGroup substructures, + also it keeps name and dimention of corresponding MED MESH entity. + */ + struct TMesh: virtual TBaseStructure + { + TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES + TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS + TName myName; //! Name of the corresponding MED MESH + vtkIdType myDim; //! Dimension of the corresponding MED MESH + + std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree + std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree + + TMesh(); + }; + typedef std::map TMeshMap; + + + //--------------------------------------------------------------- + //! Define a basic class which corresponds to MED PROFILE entity + struct TSubProfile: virtual TBaseStructure + {}; + + + //--------------------------------------------------------------- + //! Define a containerfor MED PROFILE entities which belongs to the same MED ENTITY + struct TProfile: virtual TNamedIDMapper + {}; + + + //--------------------------------------------------------------- + bool + operator<(const PSubProfile& theLeft, const PSubProfile& theRight); + + typedef std::set TProfileKey; + typedef std::map TProfileMap; + + + //--------------------------------------------------------------- + //! Define a basic class for MED GAUSS entity + struct TGauss: virtual TBaseStructure + {}; + + + //--------------------------------------------------------------- + //! Define a container for mesh generated from MED GAUSS and corresponding MED PROFILE + struct TGaussSubMesh: virtual TBaseStructure + { + PSubProfile mySubProfile; //!< Keeps reference on what submesh the Gauss Points are located + }; + + + //--------------------------------------------------------------- + //! Define a container for all TGaussSubMesh that belongs to the same MED ENTITY + struct TGaussMesh: virtual TGaussPtsIDMapper + {}; + + + //--------------------------------------------------------------- + bool + operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight); + + typedef std::set TGaussKey; + typedef std::map TGaussMeshMap; + + + //--------------------------------------------------------------- + + typedef std::map TFamilyMap; + typedef std::map TFieldMap; + + //! Define a basic class which corresponds to MED ENTITY + /*! + This class in its turn contains map of TGaussMesh and TProfile substructures, + also it keeps corresponding map of MED FAMILIES and FIELDS. + */ + struct TMeshOnEntity: virtual TNamedIDMapper + { + TGaussMeshMap myGaussMeshMap; //!< Contains map of Gauss mesh which exist on it + TProfileMap myProfileMap; //!< Contains map of Profile mesh which exist on it + + TFamilyMap myFamilyMap; //!< Contains map of MED FAMILIES which belongs to it + TFieldMap myFieldMap; //!< Contains map of MED FIELDS which belongs to it + + TName myMeshName; //!< Contains name of the MED MESH where the it belongs to. + TEntity myEntity; //!< Referes to MED ENTITY where the it belongs to. + + TMeshOnEntity(); + }; + + + //--------------------------------------------------------------- + //! Define a basic class for MED FAMILY entity + struct TFamily: virtual TIntId, + virtual TUnstructuredGridIDMapper + { + TEntity myEntity; //!< Referes to MED ENTITY where the TFamily belongs to. + TName myName; //!< Contains name of the corresponding MED FAMILY + + TFamily(); + }; + + + //--------------------------------------------------------------- + typedef std::set TFamilySet; + + //! Define a basic class for MED GROUP entity + struct TGroup: virtual TUnstructuredGridIDMapper + { + TFamilySet myFamilySet; + }; + + + //--------------------------------------------------------------- + typedef std::map TValField; + typedef std::pair TMinMax; + + //! Define a basic class for MED FIELD entity + struct TField: virtual TIntId + { + TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. + TName myName; //!< Contains name of the corresponding MED FIELD + TName myMeshName; //!< Contains name of the MED MESH where it belongs to. + TValField myValField; //!< Contains sequence of values for corresponding MED TIMESTAMPS + TNames myCompNames; //!< Contains names of components of the MED FIELD + TNames myUnitNames; //!< Contains names of units of the MED FIELD + vtkIdType myNbComp; //!< Keeps number of components for the MED FIELD + + //! Calculate min/max values for each of the MED FIELD components among all its timestamps + /*! + Numeration of the components starts from 1. + Zero component contains min/max value for modulus of corresponding vector + */ + virtual + TMinMax + GetMinMax(vtkIdType theCompID) = 0; + + bool myIsMinMaxInitilized; //!< Is the min / max values are calculated + + TField(); + }; + + + //--------------------------------------------------------------- + typedef std::pair TTime; + + //! Define a basic class for MED TIMESTAMP entity + struct TValForTime: virtual TIntId + { + TEntity myEntity; //!< Referes to MED ENTITY where it belongs to. + TName myMeshName; //!< Contains name of the MED MESH where it belongs to. + TName myFieldName; //!< Contains name of the MED FIELD where it belongs to. + TTime myTime; + + PProfile myProfile; //!< Contains corresponding MED PROFILE where the MED TIEMSTMAP attached to + PGaussMesh myGaussMesh; + }; + + + //--------------------------------------------------------------- +} + + +#endif diff --git a/src/CONVERTOR/VISU_Structures_impl.cxx b/src/CONVERTOR/VISU_Structures_impl.cxx new file mode 100644 index 00000000..2a65b133 --- /dev/null +++ b/src/CONVERTOR/VISU_Structures_impl.cxx @@ -0,0 +1,1157 @@ +// +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: +// Author: Alexey PETROV +// Module : VISU + +#include "VISU_Structures_impl.hxx" +#include "VISU_PointCoords.hxx" +#include "VISU_MeshValue.hxx" + +#include "VTKViewer_AppendFilter.h" +#include "VISU_AppendPolyData.hxx" +#include "VISU_MergeFilter.hxx" + +#include +#include +#include + +namespace VISU +{ + //--------------------------------------------------------------- + /*! Computes number of points by the given number of cells + * in assumption of regular hexahedral mesh structure + */ + size_t + GetNumberOfPoints(size_t theNbCells) + { + return size_t(pow(pow(theNbCells, 1.0/3.0) + 1.0, 3.0)); + } + + //--------------------------------------------------------------- + /*! Computes size dataset the given number of mesh macro metrics + * in assumption of regular hexahedral mesh structure + */ + size_t + GetDataSetSize(size_t theNbOfPoints, + size_t theNbOfCells, + size_t theCellsSize, + bool theComputeLinks) + { + size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord); + size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType); + size_t aLocationsSize = theNbOfCells*sizeof(int); + vtkFloatingPointType aNbCellsPerPoint = theCellsSize / theNbOfCells - 1; + size_t aLinksSize = theNbOfPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short)); + if(!theComputeLinks) + aLinksSize = 0; + size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize; + return aResult; + } + + //--------------------------------------------------------------- + TSizeCounter + ::TSizeCounter(): + myNbCells(0), + myCellsSize(0) + {} + + + //--------------------------------------------------------------- + TPolyDataHolder + ::TPolyDataHolder() + {} + + const PPolyData& + TPolyDataHolder + ::GetSource() const + { + if(!mySource.GetPointer()){ + mySource = vtkPolyData::New(); + mySource->Delete(); + } + return mySource; + } + + vtkPolyData* + TPolyDataHolder + ::GetPolyDataOutput() + { + return GetSource().GetPointer(); + } + + unsigned long int + TPolyDataHolder + ::GetMemorySize() + { + if(vtkDataSet* anOutput = GetPolyDataOutput()){ + anOutput->Update(); + return anOutput->GetActualMemorySize() * 1024; + } + if(myIsDone){ + size_t aNbPoints = GetNumberOfPoints(myNbCells); + return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false); + } + throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!"); + return 0; + } + + //--------------------------------------------------------------- + TUnstructuredGridHolder + ::TUnstructuredGridHolder() + {} + + const PUnstructuredGrid& + TUnstructuredGridHolder + ::GetSource() const + { + if(!mySource.GetPointer()){ + mySource = vtkUnstructuredGrid::New(); + mySource->Delete(); + } + return mySource; + } + + vtkUnstructuredGrid* + TUnstructuredGridHolder + ::GetUnstructuredGridOutput() + { + return GetSource().GetPointer(); + } + + unsigned long int + TUnstructuredGridHolder + ::GetMemorySize() + { + if(vtkDataSet* anOutput = GetUnstructuredGridOutput()){ + anOutput->Update(); + return anOutput->GetActualMemorySize() * 1024; + } + if(myIsDone){ + size_t aNbPoints = GetNumberOfPoints(myNbCells); + return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false); + } + throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!"); + return 0; + } + + + //--------------------------------------------------------------- + unsigned long int + TMemoryCheckIDMapper + ::GetMemorySize() + { + if(myIsVTKDone){ + if(vtkDataSet* anOutput = GetOutput()){ + anOutput->Update(); + return anOutput->GetActualMemorySize() * 1024; + } + } + throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!"); + return 0; + } + + + //--------------------------------------------------------------- + TAppendFilterHolder + ::TAppendFilterHolder() + {} + + const PAppendFilter& + TAppendFilterHolder + ::GetFilter() const + { + if(!myFilter.GetPointer()){ + myFilter = VTKViewer_AppendFilter::New(); + myFilter->Delete(); + myFilter->SetDoMappingFlag(true); + } + return myFilter; + } + + vtkUnstructuredGrid* + TAppendFilterHolder + ::GetUnstructuredGridOutput() + { + GetFilter()->Update(); + return GetFilter()->GetOutput(); + } + + //--------------------------------------------------------------- + TAppendPolyDataHolder + ::TAppendPolyDataHolder() + {} + + const PAppendPolyData& + TAppendPolyDataHolder + ::GetFilter() const + { + if(!myFilter.GetPointer()){ + myFilter = VISU_AppendPolyData::New(); + myFilter->Delete(); + myFilter->SetDoMappingFlag(true); + } + return myFilter; + } + + vtkPolyData* + TAppendPolyDataHolder + ::GetPolyDataOutput() + { + GetFilter()->Update(); + return GetFilter()->GetOutput(); + } + + + //--------------------------------------------------------------- + TMergeFilterHolder + ::TMergeFilterHolder() + {} + + const PMergeFilter& + TMergeFilterHolder + ::GetFilter() const + { + if(!myFilter.GetPointer()){ + myFilter = VISU_MergeFilter::New(); + myFilter->Delete(); + } + return myFilter; + } + + vtkDataSet* + TMergeFilterHolder + ::GetOutput() + { + GetFilter()->Update(); + return GetFilter()->GetOutput(); + } + + + //--------------------------------------------------------------- + TMeshImpl + ::TMeshImpl(): + myNbPoints(0) + {} + + vtkIdType + TMeshImpl:: + GetNbPoints() const + { + return myNbPoints; + } + + vtkIdType + TMeshImpl:: + GetDim() const + { + return myDim; + } + + vtkPoints* + TMeshImpl:: + GetPoints() + { + return myNamedPointCoords->GetPoints(); + } + + + //--------------------------------------------------------------- + TSubProfileImpl::TSubProfileImpl(): + myStatus(eNone), + myGeom(eNONE) + {} + + + vtkIdType + TSubProfileImpl + ::GetElemObjID(vtkIdType theID) const + { + return theID; + } + + unsigned long int + TSubProfileImpl + ::GetMemorySize() + { + size_t aSize = TUnstructuredGridHolder::GetMemorySize(); + aSize += sizeof(vtkIdType) * mySubMeshID.size(); + return aSize; + } + + + //--------------------------------------------------------------- + bool + operator<(const PSubProfile& theLeft, const PSubProfile& theRight) + { + PSubProfileImpl aLeft(theLeft), aRight(theRight); + + if(aLeft->myGeom != aRight->myGeom) + return aLeft->myGeom < aRight->myGeom; + + if(aLeft->myStatus != aRight->myStatus) + return aLeft->myStatus < aRight->myStatus; + + return aLeft->myName < aRight->myName; + } + + + //--------------------------------------------------------------- + TProfileImpl + ::TProfileImpl(): + myIsAll(true), + myMeshOnEntity(NULL) + {} + + vtkIdType + TProfileImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myNamedPointCoords->GetObjID(theID); + } + + vtkIdType + TProfileImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myNamedPointCoords->GetVTKID(theID); + } + + vtkFloatingPointType* + TProfileImpl + ::GetNodeCoord(vtkIdType theObjID) + { + if(myIsAll) + return myMeshOnEntity->GetNodeCoord(theObjID); + + vtkIdType aVtkID = GetNodeVTKID(theObjID); + return GetFilter()->GetOutput()->GetPoint(aVtkID); + } + + vtkIdType + TProfileImpl + ::GetElemObjID(vtkIdType theID) const + { + if(myIsAll) + return myMeshOnEntity->GetElemObjID(theID); + + vtkIdType anInputID, aStartID, anInputDataSetID; + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->GetCellInputID(theID,anInputID,aStartID,anInputDataSetID); + PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID]; + return aSubProfileImpl->GetElemObjID(anInputID); + } + + vtkIdType + TProfileImpl + ::GetElemVTKID(vtkIdType theID) const + { + if(myIsAll) + return myMeshOnEntity->GetElemVTKID(theID); + + if(myElemObj2VTKID.empty()) + return theID; + else{ + TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); + if(anIter != myElemObj2VTKID.end()) + return anIter->second; + } + return -1; + } + + vtkCell* + TProfileImpl + ::GetElemCell(vtkIdType theObjID) + { + if(myIsAll) + return myMeshOnEntity->GetElemCell(theObjID); + + vtkIdType aVtkID = GetElemVTKID(theObjID); + return GetFilter()->GetOutput()->GetCell(aVtkID); + } + + vtkUnstructuredGrid* + TProfileImpl + ::GetUnstructuredGridOutput() + { + const PAppendFilter& anAppendFilter = GetFilter(); + return anAppendFilter->GetOutput(); + } + + unsigned long int + TProfileImpl + ::GetMemorySize() + { + size_t aSize = TAppendFilterHolder::GetMemorySize(); + aSize += myNamedPointCoords->GetMemorySize(); + aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); + TGeom2SubProfile::const_iterator anIter = myGeom2SubProfile.begin(); + TGeom2SubProfile::const_iterator anIterEnd = myGeom2SubProfile.end(); + for(; anIter != anIterEnd; anIter++){ + const PSubProfileImpl& aSubProfile = anIter->second; + aSize += aSubProfile->GetMemorySize(); + aSize += sizeof(EGeometry); + } + return aSize; + } + + std::string + TProfileImpl + ::GetNodeName(vtkIdType theObjID) const + { + return myNamedPointCoords->GetNodeName(theObjID); + } + + std::string + TProfileImpl + ::GetElemName(vtkIdType theObjID) const + { + if(myIsAll) + return myMeshOnEntity->GetElemName(theObjID); + + vtkIdType aVTKId = GetElemVTKID(theObjID); + vtkIdType anInputID, aStartID, anInputDataSetID; + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartID,anInputDataSetID); + PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID]; + vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(anInputID); + return myMeshOnEntity->GetElemName(anEntityObjId); + } + + + //--------------------------------------------------------------- + vtkIdType + TUnstructuredGridIDMapperImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myIDMapper->GetNodeObjID(theID); + } + + vtkIdType + TUnstructuredGridIDMapperImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myIDMapper->GetNodeVTKID(theID); + } + + vtkFloatingPointType* + TUnstructuredGridIDMapperImpl + ::GetNodeCoord(vtkIdType theObjID) + { + return myIDMapper->GetNodeCoord(theObjID); + } + + vtkIdType + TUnstructuredGridIDMapperImpl + ::GetElemObjID(vtkIdType theID) const + { + return myIDMapper->GetElemObjID(theID); + } + + vtkIdType + TUnstructuredGridIDMapperImpl + ::GetElemVTKID(vtkIdType theID) const + { + return myIDMapper->GetElemVTKID(theID); + } + + vtkCell* + TUnstructuredGridIDMapperImpl + ::GetElemCell(vtkIdType theObjID) + { + return myIDMapper->GetElemCell(theObjID); + } + + vtkUnstructuredGrid* + TUnstructuredGridIDMapperImpl + ::GetUnstructuredGridOutput() + { + if(!myFilter.GetPointer()){ + const PAppendFilter& anAppendFilter = myIDMapper->GetFilter(); + vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput(); + + const PUnstructuredGrid& aSource = mySource.GetSource(); + vtkUnstructuredGrid* aDataSet = aSource.GetPointer(); + aDataSet->ShallowCopy(aGeometry); + + const PMergeFilter& aFilter = GetFilter(); + aFilter->SetGeometry(aGeometry); + aFilter->SetScalars(aDataSet); + aFilter->SetVectors(aDataSet); + aFilter->AddField("VISU_FIELD",aDataSet); + } + return myFilter->GetUnstructuredGridOutput(); + } + + vtkDataSet* + TUnstructuredGridIDMapperImpl + ::GetOutput() + { + return GetUnstructuredGridOutput(); + } + + unsigned long int + TUnstructuredGridIDMapperImpl + ::GetMemorySize() + { + size_t aSize = myIDMapper->GetMemorySize(); + aSize += mySource.GetMemorySize(); + return aSize; + } + + + //--------------------------------------------------------------- + vtkIdType + TPolyDataIDMapperImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myIDMapper->GetNodeObjID(theID); + } + + vtkIdType + TPolyDataIDMapperImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myIDMapper->GetNodeVTKID(theID); + } + + vtkFloatingPointType* + TPolyDataIDMapperImpl + ::GetNodeCoord(vtkIdType theObjID) + { + return myIDMapper->GetNodeCoord(theObjID); + } + + vtkIdType + TPolyDataIDMapperImpl + ::GetElemObjID(vtkIdType theID) const + { + return myIDMapper->GetElemObjID(theID); + } + + vtkIdType + TPolyDataIDMapperImpl + ::GetElemVTKID(vtkIdType theID) const + { + return myIDMapper->GetElemVTKID(theID); + } + + vtkCell* + TPolyDataIDMapperImpl + ::GetElemCell(vtkIdType theObjID) + { + return myIDMapper->GetElemCell(theObjID); + } + + vtkPolyData* + TPolyDataIDMapperImpl + ::GetPolyDataOutput() + { + if(!myFilter.GetPointer()){ + const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter(); + vtkPolyData* aGeometry = anAppendFilter->GetOutput(); + + const PPolyData& aSource = mySource.GetSource(); + vtkPolyData* aDataSet = aSource.GetPointer(); + aDataSet->ShallowCopy(aGeometry); + + const PMergeFilter& aFilter = GetFilter(); + aFilter->SetGeometry(aGeometry); + aFilter->SetScalars(aDataSet); + aFilter->SetVectors(aDataSet); + aFilter->AddField("VISU_FIELD",aDataSet); + } + return myFilter->GetPolyDataOutput(); + } + + vtkDataSet* + TPolyDataIDMapperImpl + ::GetOutput() + { + return GetPolyDataOutput(); + } + + unsigned long int + TPolyDataIDMapperImpl + ::GetMemorySize() + { + size_t aSize = myIDMapper->GetMemorySize(); + aSize += mySource.GetMemorySize(); + return aSize; + } + + + //--------------------------------------------------------------- + TGaussImpl + ::TGaussImpl(): + myGeom(EGeometry(-1)), + myNbPoints(0) + {} + + void + TGaussImpl + ::LessThan(const PGaussImpl& theGauss, + bool& theResult) const + { + theResult = false; + } + + + //--------------------------------------------------------------- + TGaussSubMeshImpl + ::TGaussSubMeshImpl(): + myPointCoords(new TPointCoords()), + myStatus(eNone) + {} + + TGaussPointID + TGaussSubMeshImpl + ::GetObjID(vtkIdType theID, + vtkIdType theStartID) const + { + TCellID aCellID = theStartID + theID / myGauss->myNbPoints; + TLocalPntID aLocalPntID = theID % myGauss->myNbPoints; + + return TGaussPointID(aCellID,aLocalPntID); + } + + unsigned long int + TGaussSubMeshImpl + ::GetMemorySize() + { + size_t aSize = TPolyDataHolder::GetMemorySize(); + aSize += myPointCoords->GetMemorySize(); + return aSize; + } + + //--------------------------------------------------------------- + bool + operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight) + { + PGaussSubMeshImpl aLeft(theLeft), aRight(theRight); + const PGaussImpl& aGaussLeft = aLeft->myGauss; + const PGaussImpl& aGaussRight = aRight->myGauss; + + if(aGaussLeft->myGeom != aGaussRight->myGeom) + return aGaussLeft->myGeom < aGaussRight->myGeom; + + if(aLeft->mySubProfile != aRight->mySubProfile) + return aLeft->mySubProfile < aRight->mySubProfile; + + bool aResult; + aGaussLeft->LessThan(aGaussRight,aResult); + + return aResult; + } + + + //--------------------------------------------------------------- + TGaussMeshImpl + ::TGaussMeshImpl(): + myParent(NULL) + {} + + TGaussPointID + TGaussMeshImpl + ::GetObjID(vtkIdType theID) const + { + vtkIdType anInputID, aStartId, anInputDataSetID; + const PAppendPolyData& aFilter = GetFilter(); + aFilter->GetCellInputID(theID, anInputID, aStartId, anInputDataSetID); + const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID]; + + return aSubMeshImpl.GetObjID(anInputID,aStartId); + } + + vtkPolyData* + TGaussMeshImpl + ::GetPolyDataOutput() + { + return mySource.GetPolyDataOutput(); + } + + vtkDataSet* + TGaussMeshImpl + ::GetOutput() + { + return GetPolyDataOutput(); + } + + unsigned long int + TGaussMeshImpl + ::GetMemorySize() + { + size_t aSize = TAppendPolyDataHolder::GetMemorySize(); + aSize += mySource.GetMemorySize(); + TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.begin(); + TGeom2GaussSubMesh::const_iterator anIterEnd = myGeom2GaussSubMesh.end(); + for(; anIter != anIterEnd; anIter++){ + const PGaussSubMeshImpl& aGaussSubMesh = anIter->second; + aSize += aGaussSubMesh->GetMemorySize(); + aSize += sizeof(EGeometry); + } + return aSize; + } + + TNamedIDMapper* + TGaussMeshImpl + ::GetParent() + { + return myParent; + } + + + //--------------------------------------------------------------- + TGaussPointID + TGaussPtsIDFilter + ::GetObjID(vtkIdType theID) const + { + return myGaussPtsIDMapper->GetObjID(theID); + } + + TNamedIDMapper* + TGaussPtsIDFilter + ::GetParent() + { + return myGaussPtsIDMapper->GetParent(); + } + + vtkPolyData* + TGaussPtsIDFilter + ::GetPolyDataOutput() + { + return TPolyDataIDMapperImpl::GetPolyDataOutput(); + } + + vtkDataSet* + TGaussPtsIDFilter + ::GetOutput() + { + return GetPolyDataOutput(); + } + + + //--------------------------------------------------------------- + vtkIdType + TSubMeshImpl + ::GetElemObjID(vtkIdType theID) const + { + return myStartID + theID; + } + + std::string + TSubMeshImpl + ::GetElemName(vtkIdType theObjID) const + { + return ""; + } + + unsigned long int + TSubMeshImpl + ::GetMemorySize() + { + size_t aSize = TUnstructuredGridHolder::GetMemorySize(); + for(size_t anId = 0; anId < myCell2Connect.size(); anId++){ + const TConnect& aConnect = myCell2Connect[anId]; + aSize += aConnect.size() * sizeof(vtkIdType); + } + return aSize; + } + + //--------------------------------------------------------------- + vtkIdType + TMeshOnEntityImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myNamedPointCoords->GetVTKID(theID); + } + + vtkIdType + TMeshOnEntityImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myNamedPointCoords->GetObjID(theID); + } + + vtkIdType + TMeshOnEntityImpl + ::GetElemVTKID(vtkIdType theID) const + { + if(myElemObj2VTKID.empty()) + return theID; + else{ + TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); + if(anIter != myElemObj2VTKID.end()) + return anIter->second; + } + return -1; + } + + vtkIdType + TMeshOnEntityImpl + ::GetElemObjID(vtkIdType theID) const + { + vtkIdType anInputID, aStartId, anInputDataSetID; + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID); + const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID]; + return aSubMesh->GetElemObjID(anInputID); + } + + std::string + TMeshOnEntityImpl + ::GetNodeName(vtkIdType theObjID) const + { + return myNamedPointCoords->GetNodeName(theObjID); + } + + std::string + TMeshOnEntityImpl + ::GetElemName(vtkIdType theObjID) const + { + vtkIdType aVTKId = GetElemVTKID(theObjID); + vtkIdType anInputID, aStartId, anInputDataSetID; + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartId,anInputDataSetID); + const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID]; + return aSubMesh->GetElemName(anInputID); + } + + vtkUnstructuredGrid* + TMeshOnEntityImpl + ::GetUnstructuredGridOutput() + { + return TAppendFilterHolder::GetUnstructuredGridOutput(); + } + + unsigned long int + TMeshOnEntityImpl + ::GetMemorySize() + { + size_t aSize = TAppendFilterHolder::GetMemorySize(); + aSize += myNamedPointCoords->GetMemorySize(); + aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); + TGeom2SubMesh::const_iterator anIter = myGeom2SubMesh.begin(); + TGeom2SubMesh::const_iterator anIterEnd = myGeom2SubMesh.end(); + for(; anIter != anIterEnd; anIter++){ + const PSubMeshImpl& aSubMesh = anIter->second; + aSize += aSubMesh->GetMemorySize(); + aSize += sizeof(EGeometry); + } + return aSize; + } + + //--------------------------------------------------------------- + vtkIdType + TFamilyImpl + ::GetElemVTKID(vtkIdType theID) const + { + if(myElemObj2VTKID.empty()) + return theID; + else{ + TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); + if(anIter != myElemObj2VTKID.end()) + return anIter->second; + } + return -1; + } + + vtkIdType + TFamilyImpl + ::GetElemObjID(vtkIdType theID) const + { + return myMeshID[theID]; + } + + vtkIdType + TFamilyImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myNamedPointCoords->GetObjID(theID); + } + + vtkIdType + TFamilyImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myNamedPointCoords->GetVTKID(theID); + } + + vtkUnstructuredGrid* + TFamilyImpl + ::GetUnstructuredGridOutput() + { + return TUnstructuredGridHolder::GetUnstructuredGridOutput(); + } + + unsigned long int + TFamilyImpl + ::GetMemorySize() + { + size_t aSize = TUnstructuredGridHolder::GetMemorySize(); + aSize += myNamedPointCoords->GetMemorySize(); + aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); + aSize += myMeshID.size() * sizeof(vtkIdType); + TGeom2SubMeshID::const_iterator anIter = myGeom2SubMeshID.begin(); + TGeom2SubMeshID::const_iterator anIterEnd = myGeom2SubMeshID.end(); + for(; anIter != anIterEnd; anIter++){ + const TSubMeshID& aSubMeshID = anIter->second; + aSize += aSubMeshID.size() * sizeof(vtkIdType); + aSize += sizeof(EGeometry); + } + return aSize; + } + + + //--------------------------------------------------------------- + TNbASizeCells + TGroupImpl + ::GetNbASizeCells() const + { + vtkIdType aNbCells = 0, aCellsSize = 0; + TFamilySet::const_iterator anIter = myFamilySet.begin(); + for(; anIter != myFamilySet.end(); anIter++){ + PFamilyImpl aFamily = *anIter; + aNbCells += aFamily->myNbCells; + aCellsSize += aFamily->myCellsSize; + } + return std::make_pair(aNbCells,aCellsSize); + } + + vtkIdType + TGroupImpl + ::GetElemVTKID(vtkIdType theID) const + { + if(myElemObj2VTKID.empty()) + return theID; + else{ + TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID); + if(anIter != myElemObj2VTKID.end()) + return anIter->second; + } + return -1; + } + + vtkIdType + TGroupImpl + ::GetElemObjID(vtkIdType theID) const + { + vtkIdType anInputID, aStartId, anInputDataSetID; + const PAppendFilter& anAppendFilter = GetFilter(); + anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID); + const PFamilyImpl& aFamily = myFamilyArr[anInputDataSetID]; + return aFamily->GetElemObjID(anInputID); + } + + vtkIdType + TGroupImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myNamedPointCoords->GetObjID(theID); + } + + vtkIdType + TGroupImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myNamedPointCoords->GetVTKID(theID); + } + + vtkUnstructuredGrid* + TGroupImpl + ::GetUnstructuredGridOutput() + { + return TAppendFilterHolder::GetUnstructuredGridOutput(); + } + + unsigned long int + TGroupImpl + ::GetMemorySize() + { + size_t aSize = TAppendFilterHolder::GetMemorySize(); + aSize += myNamedPointCoords->GetMemorySize(); + aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType); + for(size_t anId = 0; anId < myFamilyArr.size(); anId++){ + const PFamilyImpl& aFamily = myFamilyArr[anId]; + aSize += aFamily->GetMemorySize(); + } + return aSize; + } + + + + //--------------------------------------------------------------- + TFieldImpl + ::TFieldImpl(): + myDataSize(0), + myDataType(0) + {} + + void + TFieldImpl + ::Init(vtkIdType theNbComp, + vtkIdType theDataType) + { + myNbComp = theNbComp; + myDataType = theDataType; + myCompNames.resize(theNbComp); + myUnitNames.resize(theNbComp); + myMinMaxArr.resize(theNbComp + 1); + for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){ + TMinMax& aMinMax = myMinMaxArr[iComp]; + aMinMax.first = VTK_LARGE_FLOAT; + aMinMax.second = -VTK_LARGE_FLOAT; + } + } + + vtkIdType + TFieldImpl + ::GetDataType() const + { + return myDataType; + } + + TMinMax + TFieldImpl + ::GetMinMax(vtkIdType theCompID) + { + return myMinMaxArr[theCompID]; + } + + + //---------------------------------------------------------------------------- + const PMeshValue& + TGeom2Value + ::GetMeshValue(EGeometry theGeom) const + { + TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom); + if(anIter == myGeom2MeshValue.end()) + EXCEPTION(std::runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails"); + return anIter->second; + } + + PMeshValue& + TGeom2Value + ::GetMeshValue(EGeometry theGeom) + { + return myGeom2MeshValue[theGeom]; + } + + + //---------------------------------------------------------------------------- + TGeom2MeshValue& + TGeom2Value + ::GetGeom2MeshValue() + { + return myGeom2MeshValue; + } + + const TGeom2MeshValue& + TGeom2Value + ::GetGeom2MeshValue() const + { + return myGeom2MeshValue; + } + + PMeshValue + TGeom2Value + ::GetFirstMeshValue() const + { + if(myGeom2MeshValue.size() == 1) + return myGeom2MeshValue.begin()->second; + return PMeshValue(); + } + + + //--------------------------------------------------------------- + TValForTimeImpl + ::TValForTimeImpl(): + myGaussPtsIDFilter(new TGaussPtsIDFilter()), + myUnstructuredGridIDMapper(new TUnstructuredGridIDMapperImpl()) + {} + + const PMeshValue& + TValForTimeImpl + ::GetMeshValue(EGeometry theGeom) const + { + return myGeom2Value.GetMeshValue(theGeom); + } + + PMeshValue& + TValForTimeImpl + ::GetMeshValue(EGeometry theGeom) + { + return myGeom2Value.GetMeshValue(theGeom); + } + + TGeom2MeshValue& + TValForTimeImpl + ::GetGeom2MeshValue() + { + return myGeom2Value.GetGeom2MeshValue(); + } + + const TGeom2MeshValue& + TValForTimeImpl + ::GetGeom2MeshValue() const + { + return myGeom2Value.GetGeom2MeshValue(); + } + + PMeshValue + TValForTimeImpl + ::GetFirstMeshValue() const + { + return myGeom2Value.GetFirstMeshValue(); + } + + int + TValForTimeImpl + ::GetNbGauss(EGeometry theGeom) const + { + TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom); + if(anIter == myGeom2NbGauss.end()){ + return 1; + } + return anIter->second; + } + + unsigned long int + TValForTimeImpl + ::GetMemorySize() + { + size_t aSize = sizeof(TValForTimeImpl); + const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue(); + TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin(); + TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end(); + for(; anIter != anIterEnd; anIter++){ + const PMeshValue& aMeshValue = anIter->second; + aSize += aMeshValue->GetMemorySize(); + aSize += sizeof(EGeometry); + } + return aSize; + } + + + //--------------------------------------------------------------- +} diff --git a/src/CONVERTOR/VISU_Structures_impl.hxx b/src/CONVERTOR/VISU_Structures_impl.hxx new file mode 100644 index 00000000..dc2e7b9b --- /dev/null +++ b/src/CONVERTOR/VISU_Structures_impl.hxx @@ -0,0 +1,816 @@ +// +// +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File : +// Author : Alexey PETROV +// Module : VISU + +#ifndef VISU_Structures_impl_HeaderFile +#define VISU_Structures_impl_HeaderFile + +/*! + \file VISU_Structures_impl.hxx + \brief The file contains definitions for basic classes of the implementation of VISU CONVERTER package +*/ + +#include "VISU_Structures.hxx" +#include "VISU_ConvertorDef_impl.hxx" + +namespace VISU +{ + //--------------------------------------------------------------- + //! Define an utility base class which allow to keep calculated number of cells and their size + struct TSizeCounter: virtual TIsVTKDone + { + TSizeCounter(); + vtkIdType myNbCells; //!< Number of cells contained into corresponding sublclass + vtkIdType myCellsSize; //!< Size of cells contained into corresponding sublclass + }; + + + //--------------------------------------------------------------- + //! Define a container for VTK representation + class TPolyDataHolder: public virtual TSizeCounter + { + protected: + mutable PPolyData mySource; + public: + TPolyDataHolder(); + + //! This method allow to create corresponding VTK data set by demand (not at once) + const PPolyData& + GetSource() const; + + virtual + vtkPolyData* + GetPolyDataOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + }; + + + //--------------------------------------------------------------- + //! Define a container for VTK representation + class TUnstructuredGridHolder: public virtual TSizeCounter + { + public: + TUnstructuredGridHolder(); + + //! This method allow to create corresponding VTK data set by demand (not at once) + const PUnstructuredGrid& + GetSource() const; + + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + protected: + mutable PUnstructuredGrid mySource; + }; + + + //--------------------------------------------------------------- + //! Define an intermediate class which unifies memory size calculation + struct TMemoryCheckIDMapper: public virtual TIsVTKDone, + public virtual TIDMapper + { + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + }; + + + //--------------------------------------------------------------- + //! Define a container for VTK representation + /*! + This container allow to combine other VTK representation into single one. + */ + class TAppendFilterHolder: public virtual TMemoryCheckIDMapper + { + protected: + mutable PAppendFilter myFilter; + public: + TAppendFilterHolder(); + + //! This method allow to create corresponding VTK filter by demand (not at once) + const PAppendFilter& + GetFilter() const; + + //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + }; + + + //--------------------------------------------------------------- + //! Define a container for VTK representation + /*! + This container allow to combine other VTK representation into single one. + */ + class TAppendPolyDataHolder: public virtual TMemoryCheckIDMapper + { + protected: + mutable PAppendPolyData myFilter; + public: + TAppendPolyDataHolder(); + + //! This method allow to create corresponding VTK filter by demand (not at once) + const PAppendPolyData& + GetFilter() const; + + //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput + virtual + vtkPolyData* + GetPolyDataOutput(); + }; + + + //--------------------------------------------------------------- + //! Define a container for VTK representation + /*! + This container allow to assign data to mesh and represent them into single VTK representation + */ + class TMergeFilterHolder: public virtual TMemoryCheckIDMapper + { + protected: + mutable PMergeFilter myFilter; + public: + TMergeFilterHolder(); + + //! This method allow to create corresponding VTK filter by demand (not at once) + const PMergeFilter& + GetFilter() const; + + //! Gets output of the filter as vtkDataSet + virtual + vtkDataSet* + GetOutput(); + }; + + + //--------------------------------------------------------------- + //! Specialize TMesh to provide VTK mapping for nodes + struct TMeshImpl: virtual TMesh, + virtual TIsVTKDone + { + PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes + vtkIdType myNbPoints; //!< Keeps number of the nodes + + TMeshImpl(); + + vtkIdType + GetNbPoints() const; + + vtkIdType + GetDim() const; + + vtkPoints* + GetPoints(); //!< Gets initialized corresponding VTK structure + }; + + + //--------------------------------------------------------------- + typedef TVector TSubMeshID; + typedef enum {eRemoveAll, eAddAll, eAddPart, eNone} ESubMeshStatus; + + //! Specialize TSubProfile to provide VTK mapping + struct TSubProfileImpl: virtual TSubProfile, + virtual TUnstructuredGridHolder + { + TSubProfileImpl(); + + EGeometry myGeom; //!< Defines to what geometrical type the MED PROFILE belong to + std::string myName; //!< Keeps its name + + //! Get object number of mesh cell by its VTK one + virtual + vtkIdType + GetElemObjID(int theVtkI) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Keeps status of the structure + /*! + In some cases MED file does not use MED PROFILES, but at VISU creates corresponding data strucutre + in order to construct mesh for MED TIEMSTAMPS in uniform way. + */ + ESubMeshStatus myStatus; + TSubMeshID mySubMeshID; //!< Keeps numbers of mesh cell which contain the MED PROFILE + }; + + + //--------------------------------------------------------------- + typedef std::map TID2ID; + typedef TVector TSubProfileArr; + typedef std::map TGeom2SubProfile; + + //! Specialize TProfile to provide VTK mapping for MED TIMESTAMP mesh + struct TProfileImpl: virtual TProfile, + virtual TAppendFilterHolder + { + TProfileImpl(); + bool myIsAll; //!< Say, whether the MED TIMESTAMP defined on all MED ENTITY or not + + //! Reimplement the TIDMapper::GetNodeObjID + virtual + vtkIdType + GetNodeObjID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetNodeVTKID + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetNodeCoord + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + //! Reimplement the TIDMapper::GetElemObjID + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemCell + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + + //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Reimplement the TNamedIDMapper::GetNodeName + virtual + std::string + GetNodeName(vtkIdType theObjID) const; + + //! Reimplement the TNamedIDMapper::GetElemName + virtual + std::string + GetElemName(vtkIdType theObjID) const; + + TID2ID myElemObj2VTKID; //!< Keeps object to VTK numeration mapping + TSubProfileArr mySubProfileArr; //!< Keeps sequence of TSubProfiles as they were added into TAppendFilterHolder + PNamedPointCoords myNamedPointCoords; //!< Keeps reference on the same TNamedPointCoords as TMesh + TMeshOnEntityImpl* myMeshOnEntity; // TGaussSubMeshArr; + typedef std::map TGeom2GaussSubMesh; + + //! Specialize TGaussMesh to provide VTK mapping for the entity + struct TGaussMeshImpl: virtual TGaussMesh, + virtual TAppendPolyDataHolder + { + TGaussMeshImpl(); + + //! Reimplement the TGaussPtsIDMapper::GetObjID + virtual + TGaussPointID + GetObjID(vtkIdType theID) const; + + //! Reimplement the TGaussPtsIDMapper::GetPolyDataOutput + virtual + vtkPolyData* + GetPolyDataOutput(); + + //! Reimplement the TIDMapper::GetOutput + virtual + vtkDataSet* + GetOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //! Reimplement the TGaussPtsIDMapper::GetParent + virtual + TNamedIDMapper* + GetParent(); + + TPolyDataHolder mySource; //!< Keeps VTK representation of the Gauss Points + TNamedIDMapper* myParent; //!< Refer to parent mesh + TGaussSubMeshArr myGaussSubMeshArr; //!< Keeps sequence of TGaussSubMesh as they were added into TAppendFilterHolder + TGeom2GaussSubMesh myGeom2GaussSubMesh; //!< Keeps TGaussSubMesh according to their geometrical type + }; + + + //--------------------------------------------------------------- + //! Specialize TGaussPtsIDMapper to provide VTK mapping for MED TIMESTAMP mesh + struct TGaussPtsIDFilter: virtual TPolyDataIDMapperImpl, + virtual TGaussPtsIDMapper + { + PGaussPtsIDMapper myGaussPtsIDMapper; + + //! Reimplement the TGaussPtsIDMapper::GetObjID + virtual + TGaussPointID + GetObjID(vtkIdType theID) const; + + //! Reimplement the TGaussPtsIDMapper::GetParent + virtual + TNamedIDMapper* + GetParent(); + + //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput + virtual + vtkPolyData* + GetPolyDataOutput(); + + //! Reimplement the TIDMapper::GetOutput + virtual + vtkDataSet* + GetOutput(); + }; + + + //--------------------------------------------------------------- + typedef TVector TConnect; + typedef TVector TCell2Connect; + + //! The class is responsible for mapping of cells of defined geometrical type + struct TSubMeshImpl: virtual TUnstructuredGridHolder + { + //! To implement the TIDMapper::GetElemObjID + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + //! To implement the TNamedIDMapper::GetElemName + virtual + std::string + GetElemName(vtkIdType theObjID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + vtkIdType myStartID; + TCell2Connect myCell2Connect; //!< Contains connectivity for the cells + }; + + + //--------------------------------------------------------------- + typedef std::map TGeom2SubMesh; + typedef TVector TSubMeshArr; + + //! Specialize TMeshOnEntity to provide VTK mapping for the entity + struct TMeshOnEntityImpl: virtual TMeshOnEntity, + virtual TAppendFilterHolder, + virtual TSizeCounter + { + //! Reimplement the TIDMapper::GetNodeVTKID + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetNodeObjID + virtual + vtkIdType + GetNodeObjID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemObjID + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TNamedIDMapper::GetNodeName + virtual + std::string + GetNodeName(vtkIdType theObjID) const; + + //! Reimplement the TNamedIDMapper::GetElemName + virtual + std::string + GetElemName(vtkIdType theObjID) const; + + //! Reimplement the TNamedIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TSubMeshArr mySubMeshArr; //!< Keeps sequence of TSubMeshImpl as they were added into TAppendFilterHolder + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping + + TGeom2SubMesh myGeom2SubMesh; //!< Keeps TSubMeshImpl according to their geometrical type + }; + + + //--------------------------------------------------------------- + typedef std::map TGeom2SubMeshID; + + //! Specialize TFamily to provide VTK mapping for the entity + struct TFamilyImpl: virtual TFamily, + virtual TUnstructuredGridHolder + { + //! Reimplement the TIDMapper::GetNodeObjID + vtkIdType + GetNodeObjID(vtkIdType theID) const ; + + //! Reimplement the TIDMapper::GetNodeVTKID + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID) const ; + + //! Reimplement the TIDMapper::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemObjID + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TSubMeshID myMeshID; //!< Keeps numbers of mesh elements that belongs to the MED FAMILY + + TGeom2SubMeshID myGeom2SubMeshID; //!< Keeps TSubMeshID according to their geometrical type + }; + + + //--------------------------------------------------------------- + typedef std::pair TNbASizeCells; + typedef TVector TFamilyArr; + + //! Specialize TGroup to provide VTK mapping for the entity + struct TGroupImpl: virtual TGroup, + virtual TAppendFilterHolder + { + //! Calculate pair of values - number of cells and its size + TNbASizeCells + GetNbASizeCells() const; + + //! Reimplement the TIDMapper::GetElemVTKID + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetElemObjID + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetNodeObjID + virtual + vtkIdType + GetNodeObjID(vtkIdType theID) const; + + //! Reimplement the TIDMapper::GetNodeVTKID + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID) const; + + //! Reimplement the TUnstructuredGridIDMapper::GetUnstructuredGridOutput + virtual + vtkUnstructuredGrid* + GetUnstructuredGridOutput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + TID2ID myElemObj2VTKID; //!< To support object to VTK number mapping + TFamilyArr myFamilyArr; //!< Keeps sequence of TFamily as they were added into TAppendFilterHolder + PNamedPointCoords myNamedPointCoords; //!< Share the same instance with TMesh to implement nodal mapping + }; + + + //--------------------------------------------------------------- + typedef TVector TMinMaxArr; + + //! Specialize TField to provide VTK mapping for the entity + struct TFieldImpl: virtual TField + { + TFieldImpl(); + + //! To initialize the data structure + void + Init(vtkIdType theNbComp, + vtkIdType theDataType); + + //! Gets type idetificator of the mesh data. + vtkIdType + GetDataType() const; + + //! Implement the TField::GetMinMax + virtual + TMinMax + GetMinMax(vtkIdType theCompID); + + vtkIdType myDataSize; //!< Keeps size of the assigned data + vtkIdType myDataType; //!< Keeps type idetificator of the mesh data + TMinMaxArr myMinMaxArr; //!< Keeps min/max values for each component of the MED FIELD + }; + + + //--------------------------------------------------------------- + typedef std::map TGeom2MeshValue; + + class TGeom2Value: public virtual TBaseStructure + { + TGeom2MeshValue myGeom2MeshValue; + public: + + //! Gets mesh data for defined geometrical type (constant version) + const PMeshValue& + GetMeshValue(EGeometry theGeom) const; + + //! Gets mesh data for defined geometrical type + PMeshValue& + GetMeshValue(EGeometry theGeom); + + //! Gets container of the whole mesh data + TGeom2MeshValue& + GetGeom2MeshValue(); + + //! Gets container of the whole mesh data (constant version) + const TGeom2MeshValue& + GetGeom2MeshValue() const; + + //! Gets mesh data for the first geometry + PMeshValue + GetFirstMeshValue() const; + }; + + + //--------------------------------------------------------------- + typedef std::map TGeom2NbGauss; + + //! Specialize TValForTime to provide VTK mapping for the entity + struct TValForTimeImpl: virtual TValForTime + { + PGaussPtsIDFilter myGaussPtsIDFilter; //!< Keep VTK representation for mesh and data on Gauss Points + PUnstructuredGridIDMapperImpl myUnstructuredGridIDMapper; //!< Keep VTK representation for ordinary mesh and data + TGeom2Value myGeom2Value; //!< Keep value that is assigned to the mesh + TGeom2NbGauss myGeom2NbGauss; //!< Keep number of Gauss Points + + TValForTimeImpl(); + + TGeom2MeshValue& + GetGeom2MeshValue(); + + const TGeom2MeshValue& + GetGeom2MeshValue() const; + + //! Get mesh data for defined geometrical type (constant version) + const PMeshValue& + GetMeshValue(EGeometry theGeom) const; + + //! Get mesh data for defined geometrical type + PMeshValue& + GetMeshValue(EGeometry theGeom); + + //! Gets mesh data for the first geometry + PMeshValue + GetFirstMeshValue() const; + + //! Get number of Gauss Points for defined geometrical type + virtual + int + GetNbGauss(EGeometry theGeom) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + }; + + + //--------------------------------------------------------------- +} + + +#endif diff --git a/src/OBJECT/VISU_DataSetActor.cxx b/src/OBJECT/VISU_DataSetActor.cxx index e24b8a99..1b282c01 100644 --- a/src/OBJECT/VISU_DataSetActor.cxx +++ b/src/OBJECT/VISU_DataSetActor.cxx @@ -26,7 +26,7 @@ // Module : VISU #include "VISU_DataSetActor.h" -#include "VISU_PipeLine.hxx" +#include "VISU_UnstructuredGridPL.hxx" #include "VISU_PipeLineUtils.hxx" #include @@ -69,10 +69,12 @@ VISU_DataSetActor { Superclass::ShallowCopyPL(thePipeLine); - vtkDataSetMapper* aTarget = GetDataSetMapper(); - vtkDataSetMapper* aSource = thePipeLine->GetDataSetMapper(); - VISU::CopyDataSetMapper(aTarget, aSource, true); - aTarget->SetLookupTable(aSource->GetLookupTable()); + if(VISU_UnstructuredGridPL* aPipeLine = dynamic_cast(thePipeLine)){ + vtkDataSetMapper* aTarget = GetDataSetMapper(); + vtkDataSetMapper* aSource = aPipeLine->GetDataSetMapper(); + VISU::CopyDataSetMapper(aTarget, aSource, true); + aTarget->SetLookupTable(aSource->GetLookupTable()); + } } //---------------------------------------------------------------------------- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 564cda16..4ad22030 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -36,8 +36,6 @@ #include "VISU_ScalarBarCtrl.hxx" #include "VISU_ScalarBarActor.hxx" -#include "SALOME_ExtractGeometry.h" - #include "VISU_Event.h" #include "SVTK_Actor.h" @@ -219,7 +217,7 @@ vtkMapper* VISU_GaussPtsAct ::GetMapper() { - //vtkMapper* aMapper = myCurrentPL->GetPSMapper(); + //vtkMapper* aMapper = myCurrentPL->GetPointSpriteMapper(); //aMapper->Update(); //return aMapper; myMapper->Update(); @@ -399,7 +397,7 @@ VISU_GaussPtsAct myDeviceActor->SetPipeLine(GetGaussPointsPL()); myCurrentPL = myDeviceActor->GetPipeLine(); - //SetMapper(myCurrentPL->GetPSMapper()); + //SetMapper(myCurrentPL->GetPointSpriteMapper()); myMapper->SetInput(myCurrentPL->GetPickableDataSet()); SetMapper(myMapper.GetPointer()); @@ -416,7 +414,7 @@ namespace VISU_GaussPointsPL* theGaussPointsPL) { vtkFloatingPointType aRadius = 0.5; - if(theGaussPointsPL->GetPSMapper()->GetPointSpriteMode() == 1) // Geometry mode + if(theGaussPointsPL->GetPointSpriteMapper()->GetPointSpriteMode() == 1) // Geometry mode aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize(); else if(theGaussPointsPL->GetBicolor()){ vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID); @@ -996,7 +994,8 @@ VISU_GaussPtsAct myCellSource->Reset(); myCellSource->Modified(); // a VTK bug - myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints()); + vtkUnstructuredGrid* aDataSet = aParent->GetUnstructuredGridOutput(); + myCellSource->SetPoints(aDataSet->GetPoints()); VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId); vtkIdType aCellID = aGaussPointID.first; @@ -1091,8 +1090,7 @@ VISU_GaussPtsAct VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine(); - SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter(); - vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction(); + vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction(); aPipeline->ShallowCopy(GetGaussPointsPL(), true); @@ -1126,7 +1124,7 @@ VISU_GaussPtsAct ::GetMTime() { unsigned long int aTime = Superclass::GetMTime(); - aTime = std::max(aTime, myGaussPointsPL->GetPSMapper()->GetMTime() ); + aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() ); return aTime; } @@ -1257,9 +1255,8 @@ VISU_GaussPtsAct1 myOutsideDeviceActor->SetPipeLine(aPipeLine); aPipeLine->Delete(); - SALOME_ExtractGeometry* anExtractGeometry = aPipeLine->GetExtractGeometryFilter(); - anExtractGeometry->SetExtractBoundaryCells(true); - anExtractGeometry->SetExtractInside(true); + aPipeLine->SetExtractBoundaryCells(true); + aPipeLine->SetExtractInside(true); } } @@ -1377,15 +1374,14 @@ VISU_GaussPtsAct1 VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine(); - SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter(); - vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction(); + vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction(); vtkFloatingPointType aMagnification = aPipeline->GetMagnification(); aPipeline->ShallowCopy(GetGaussPointsPL(), true); aPipeline->SetImplicitFunction(anImplicitFunction); // To restore - anExtractGeometry->SetExtractBoundaryCells(true); - anExtractGeometry->SetExtractInside(true); + aPipeline->SetExtractBoundaryCells(true); + aPipeline->SetExtractInside(true); aPipeline->SetMagnification( aMagnification ); aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() ); @@ -1405,15 +1401,15 @@ VISU_GaussPtsAct1 if( myOutsideCursorSettings->GetUniform() ) { - myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOff(); - myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 1 ); // Geometry mode + myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff(); + myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() ); } else { - myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode - myOutsideDeviceActor->GetPSMapper()->SetColorModeToMapScalars(); - myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOn(); + myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode + myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars(); + myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn(); } aPipeline->Update(); diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx index 55e32709..5e44009f 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.cxx +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.cxx @@ -147,7 +147,7 @@ VISU_GaussPtsDeviceActor VISU_OpenGLPointSpriteMapper* VISU_GaussPtsDeviceActor -::GetPSMapper() +::GetPointSpriteMapper() { return myMapper.GetPointer(); } @@ -189,7 +189,7 @@ VISU_GaussPtsDeviceActor ::SetPipeLine(VISU_GaussPointsPL* thePipeLine) { myPipeLine = thePipeLine; - myMapper = thePipeLine->GetPSMapper(); + myMapper = thePipeLine->GetPointSpriteMapper(); vtkPolyData* aDataSet = myMapper->GetInput(); int anId = 0; diff --git a/src/OBJECT/VISU_GaussPtsDeviceActor.h b/src/OBJECT/VISU_GaussPtsDeviceActor.h index 633ac01b..ee5bcf66 100644 --- a/src/OBJECT/VISU_GaussPtsDeviceActor.h +++ b/src/OBJECT/VISU_GaussPtsDeviceActor.h @@ -77,7 +77,7 @@ class VISU_GaussPtsDeviceActor: public vtkLODActor ShallowCopyPL(VISU_GaussPointsPL* thePipeLine); VISU_OpenGLPointSpriteMapper* - GetPSMapper(); + GetPointSpriteMapper(); //! Gets memory size used by the instance (bytes). virtual diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index bc938f98..b7c76f27 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -129,7 +129,8 @@ VISU_ScalarMapAct ::SetBarVisibility(bool theMode) { myBarVisibility = theMode; - if(myScalarBar) myScalarBar->SetVisibility(myBarVisibility); + if(myScalarBar) + myScalarBar->SetVisibility(myBarVisibility); } diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index 198eadde..bd742c2b 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -33,61 +33,74 @@ VPATH=.:@srcdir@ @COMMENCE@ EXPORT_HEADERS = \ + VISU_MapperHolder.hxx \ + VISU_DataSetMapperHolder.hxx \ + VISU_PolyDataMapperHolder.hxx \ + VISU_PointSpriteMapperHolder.hxx \ VISU_PipeLine.hxx \ + VISU_ColoredPL.hxx \ + VISU_UnstructuredGridPL.hxx \ + VISU_ScalarMapPL.hxx \ + VISU_DeformedShapePL.hxx \ + VISU_GaussPointsPL.hxx \ VISU_PipeLineUtils.hxx \ VISU_MeshPL.hxx \ - VISU_ScalarMapPL.hxx \ VISU_CutPlanesPL.hxx \ VISU_CutLinesPL.hxx \ VISU_IsoSurfacesPL.hxx \ - VISU_DeformedShapePL.hxx \ VISU_VectorsPL.hxx \ VISU_StreamLinesPL.hxx \ + VISU_Plot3DPL.hxx \ + VISU_ScalarMapOnDeformedShapePL.hxx \ VISU_LookupTable.hxx \ VISU_ScalarBarActor.hxx \ VISU_Extractor.hxx \ VISU_FieldTransform.hxx \ VISU_UsedPointsFilter.hxx \ - VISU_GaussPointsPL.hxx \ - VISU_Plot3DPL.hxx \ VISU_OpenGLPointSpriteMapper.hxx \ VISU_ImplicitFunctionWidget.hxx \ SALOME_ExtractGeometry.h \ + SALOME_ExtractPolyDataGeometry.h \ VISU_ScalarBarCtrl.hxx \ VISU_PlanesWidget.hxx \ VISU_SphereWidget.hxx \ - VISU_WidgetCtrl.hxx \ - VISU_ScalarMapOnDeformedShapePL.hxx + VISU_WidgetCtrl.hxx # Libraries targets - LIB = libVisuPipeLine.la LIB_SRC = \ + VISU_MapperHolder.cxx \ + VISU_DataSetMapperHolder.cxx \ + VISU_PolyDataMapperHolder.cxx \ + VISU_PointSpriteMapperHolder.cxx \ + VISU_Extractor.cxx \ VISU_PipeLine.cxx \ - VISU_PipeLineUtils.cxx \ - VISU_MeshPL.cxx \ + VISU_ColoredPL.cxx \ + VISU_UnstructuredGridPL.cxx \ VISU_ScalarMapPL.cxx \ + VISU_DeformedShapePL.cxx \ + VISU_GaussPointsPL.cxx \ + VISU_MeshPL.cxx \ VISU_CutPlanesPL.cxx \ VISU_CutLinesPL.cxx \ VISU_IsoSurfacesPL.cxx \ - VISU_DeformedShapePL.cxx \ VISU_VectorsPL.cxx \ VISU_StreamLinesPL.cxx \ + VISU_Plot3DPL.cxx \ + VISU_ScalarMapOnDeformedShapePL.cxx \ VISU_LookupTable.cxx \ VISU_ScalarBarActor.cxx \ - VISU_Extractor.cxx \ VISU_FieldTransform.cxx \ VISU_UsedPointsFilter.cxx \ - VISU_GaussPointsPL.cxx \ - VISU_Plot3DPL.cxx \ SALOME_ExtractGeometry.cxx \ + SALOME_ExtractPolyDataGeometry.cxx \ VISU_OpenGLPointSpriteMapper.cxx \ VISU_ImplicitFunctionWidget.cxx \ VISU_PlanesWidget.cxx \ VISU_SphereWidget.cxx \ VISU_WidgetCtrl.cxx \ VISU_ScalarBarCtrl.cxx \ - VISU_ScalarMapOnDeformedShapePL.cxx + VISU_PipeLineUtils.cxx # Executables targets diff --git a/src/PIPELINE/SALOME_ExtractGeometry.cxx b/src/PIPELINE/SALOME_ExtractGeometry.cxx index 03cf524c..f59c35c0 100755 --- a/src/PIPELINE/SALOME_ExtractGeometry.cxx +++ b/src/PIPELINE/SALOME_ExtractGeometry.cxx @@ -32,8 +32,6 @@ #include #include -using namespace std; - #if defined __GNUC__ #if __GNUC__ == 2 #define __GNUC_2__ @@ -57,16 +55,6 @@ SALOME_ExtractGeometry {} -//---------------------------------------------------------------------------- -unsigned long int -SALOME_ExtractGeometry -::GetMTime() -{ - unsigned long int aTime = vtkExtractGeometry::GetMTime(); - return aTime; -} - - //---------------------------------------------------------------------------- vtkImplicitBoolean* SALOME_ExtractGeometry @@ -81,7 +69,7 @@ SALOME_ExtractGeometry ::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction) { myImplicitBoolean = dynamic_cast(theImplicitFunction); - vtkExtractGeometry::SetImplicitFunction(theImplicitFunction); + Superclass::SetImplicitFunction(theImplicitFunction); } @@ -90,8 +78,10 @@ void SALOME_ExtractGeometry ::SetStoreMapping(bool theStoreMapping) { - myStoreMapping = theStoreMapping; - Modified(); + if(myStoreMapping != theStoreMapping){ + myStoreMapping = theStoreMapping; + Modified(); + } } bool @@ -139,13 +129,12 @@ vtkIdType SALOME_ExtractGeometry ::GetElemObjId(int theVtkID) { - if (!myStoreMapping||myIsDoneShallowCopy){ + if(!myStoreMapping || myIsDoneShallowCopy) return theVtkID; - } - // - if (theVtkIDImplicitFunction; - if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){ - if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){ + if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()) + if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()) myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0; - } - } - - if(myIsDoneShallowCopy){ + + if(myIsDoneShallowCopy) GetOutput()->ShallowCopy(GetInput()); - Modified(); - return; - } - - Execute2(); + else + Execute2(); } + +//---------------------------------------------------------------------------- void SALOME_ExtractGeometry ::Execute2() diff --git a/src/PIPELINE/SALOME_ExtractGeometry.h b/src/PIPELINE/SALOME_ExtractGeometry.h index 6fcb07b6..5fef8082 100755 --- a/src/PIPELINE/SALOME_ExtractGeometry.h +++ b/src/PIPELINE/SALOME_ExtractGeometry.h @@ -20,8 +20,6 @@ #ifndef SALOME_ExtractGeometry_H #define SALOME_ExtractGeometry_H -#include "VTKViewer.h" - #include #include @@ -32,23 +30,22 @@ class vtkImplicitBoolean; class SALOME_ExtractGeometry : public vtkExtractGeometry { public: - vtkTypeMacro(SALOME_ExtractGeometry,vtkExtractGeometry); + vtkTypeMacro(SALOME_ExtractGeometry, vtkExtractGeometry); - static SALOME_ExtractGeometry *New(); + static + SALOME_ExtractGeometry* + New(); virtual void SetImplicitFunction(vtkImplicitFunction* theImplicitFunction); - virtual - unsigned long int - GetMTime(); - vtkImplicitBoolean* GetImplicitBoolean(); bool GetStoreMapping() const; + void SetStoreMapping(bool theStoreMapping); @@ -78,6 +75,7 @@ protected: private: bool myStoreMapping; bool myIsDoneShallowCopy; + typedef std::vector TVectorId; TVectorId myElemVTK2ObjIds; TVectorId myNodeVTK2ObjIds; diff --git a/src/PIPELINE/SALOME_ExtractPolyDataGeometry.cxx b/src/PIPELINE/SALOME_ExtractPolyDataGeometry.cxx new file mode 100644 index 00000000..987aaa62 --- /dev/null +++ b/src/PIPELINE/SALOME_ExtractPolyDataGeometry.cxx @@ -0,0 +1,363 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com + + +#include "SALOME_ExtractPolyDataGeometry.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(SALOME_ExtractPolyDataGeometry); + + +//---------------------------------------------------------------------------- +SALOME_ExtractPolyDataGeometry +::SALOME_ExtractPolyDataGeometry(): + myStoreMapping(false), + myIsDoneShallowCopy(false) +{} + +SALOME_ExtractPolyDataGeometry +::~SALOME_ExtractPolyDataGeometry() +{} + + +//---------------------------------------------------------------------------- +vtkImplicitBoolean* +SALOME_ExtractPolyDataGeometry +::GetImplicitBoolean() +{ + return myImplicitBoolean.GetPointer(); +} + + +void +SALOME_ExtractPolyDataGeometry +::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction) +{ + myImplicitBoolean = dynamic_cast(theImplicitFunction); + Superclass::SetImplicitFunction(theImplicitFunction); +} + + +//---------------------------------------------------------------------------- +void +SALOME_ExtractPolyDataGeometry +::SetStoreMapping(bool theStoreMapping) +{ + if(myStoreMapping != theStoreMapping){ + myStoreMapping = theStoreMapping; + Modified(); + } +} + +bool +SALOME_ExtractPolyDataGeometry +::GetStoreMapping() const +{ + return myStoreMapping; +} + + +//---------------------------------------------------------------------------- +vtkIdType +SALOME_ExtractPolyDataGeometry +::GetElemVTKId(vtkIdType theID) +{ + if(!myStoreMapping || myIsDoneShallowCopy){ + return theID; + } + vtkIdType iEnd = myElemVTK2ObjIds.size(); + for(vtkIdType i = 0; i < iEnd; i++) + if(myElemVTK2ObjIds[i] == theID) + return i; + + return -1; +} + +vtkIdType +SALOME_ExtractPolyDataGeometry +::GetNodeVTKId(vtkIdType theID) +{ + return theID; +} + + +//---------------------------------------------------------------------------- +vtkIdType +SALOME_ExtractPolyDataGeometry +::GetElemObjId(int theVtkID) +{ + if(!myStoreMapping || myIsDoneShallowCopy) + return theVtkID; + + if(theVtkID < myElemVTK2ObjIds.size()) + return myElemVTK2ObjIds[theVtkID]; + + return -1; +} + + +vtkIdType +SALOME_ExtractPolyDataGeometry +::GetNodeObjId(int theVtkID) +{ + return theVtkID; +} + + +//---------------------------------------------------------------------------- +void +SALOME_ExtractPolyDataGeometry +::Execute() +{ + myElemVTK2ObjIds.clear(); + myNodeVTK2ObjIds.clear(); + // + myIsDoneShallowCopy = !this->ImplicitFunction; + + if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){ + if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){ + myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0; + } + } + + if(myIsDoneShallowCopy) + GetOutput()->ShallowCopy(GetInput()); + else + Execute2(); +} + + +//---------------------------------------------------------------------------- +void +SALOME_ExtractPolyDataGeometry +::Execute2() +{ + vtkPolyData *input = this->GetInput(); + vtkPointData *pd = input->GetPointData(); + vtkCellData *cd = input->GetCellData(); + vtkPolyData *output = this->GetOutput(); + vtkPointData *outputPD = output->GetPointData(); + vtkCellData *outputCD = output->GetCellData(); + vtkPoints *inPts=input->GetPoints(); + vtkIdType numPts, i, cellId = -1, newId; + float multiplier; + vtkCellArray *inVerts=NULL, *inLines=NULL, *inPolys=NULL, *inStrips=NULL; + vtkCellArray *newVerts=NULL, *newLines=NULL, *newPolys=NULL, *newStrips=NULL; + + vtkDebugMacro(<< "Extracting poly data geometry"); + + if ( ! this->ImplicitFunction ) + { + vtkErrorMacro(<<"No implicit function specified"); + return; + } + + numPts = input->GetNumberOfPoints(); + + if ( this->ExtractInside ) + { + multiplier = 1.0; + } + else + { + multiplier = -1.0; + } + + // Use a templated function to access the points. The points are + // passed through, but scalar values are generated. + vtkFloatArray *newScalars = vtkFloatArray::New(); + newScalars->SetNumberOfValues(numPts); + + for (int ptId=0; ptId < numPts; ptId++ ) + { + newScalars->SetValue(ptId, this->ImplicitFunction-> + FunctionValue(inPts->GetPoint(ptId))*multiplier); + } + + output->SetPoints(inPts); + outputPD->PassData(pd); + + // Now loop over all cells to see whether they are inside the implicit + // function. Copy if they are. Note: there is an awful hack here, that + // can result in bugs. The cellId is assumed to be arranged starting + // with the verts, then lines, then polys, then strips. + // + int numIn; + vtkIdType npts = 0; + vtkIdType *pts = 0; + if ( input->GetNumberOfVerts() ) + { + inVerts = input->GetVerts(); + newVerts = vtkCellArray::New(); + newVerts->Allocate(inVerts->GetSize()); + } + if ( input->GetNumberOfLines() ) + { + inLines = input->GetLines(); + newLines = vtkCellArray::New(); + newLines->Allocate(inLines->GetSize()); + } + if ( input->GetNumberOfPolys() ) + { + inPolys = input->GetPolys(); + newPolys = vtkCellArray::New(); + newPolys->Allocate(inPolys->GetSize()); + } + if ( input->GetNumberOfStrips() ) + { + inStrips = input->GetStrips(); + newStrips = vtkCellArray::New(); + newStrips->Allocate(inStrips->GetSize()); + } + + // verts + if ( newVerts && !this->GetAbortExecute() ) + { + for (inVerts->InitTraversal(); inVerts->GetNextCell(npts,pts); ) + { + for (numIn=0, i=0; iGetValue(pts[i]) <= 0.0 ) + { + numIn++; + } + } + if ( (numIn == npts) || (this->ExtractBoundaryCells && numIn > 0) ) + { + newId = newVerts->InsertNextCell(npts,pts); + if(myStoreMapping) + myElemVTK2ObjIds.push_back(newId); + outputCD->CopyData(cd, cellId, newId); + } + cellId++; + } + } + this->UpdateProgress (0.6); + + // lines + if ( newLines && !this->GetAbortExecute() ) + { + for (inLines->InitTraversal(); inLines->GetNextCell(npts,pts); ) + { + for (numIn=0, i=0; iGetValue(pts[i]) <= 0.0 ) + { + numIn++; + } + } + if ( (numIn == npts) || (this->ExtractBoundaryCells && numIn > 0) ) + { + newId = newLines->InsertNextCell(npts,pts); + if(myStoreMapping) + myElemVTK2ObjIds.push_back(newId); + outputCD->CopyData(cd, cellId, newId); + } + cellId++; + } + } + this->UpdateProgress (0.75); + + // polys + if ( newPolys && !this->GetAbortExecute() ) + { + for (inPolys->InitTraversal(); inPolys->GetNextCell(npts,pts); ) + { + for (numIn=0, i=0; iGetValue(pts[i]) <= 0.0 ) + { + numIn++; + } + } + if ( (numIn == npts) || (this->ExtractBoundaryCells && numIn > 0) ) + { + newId = newPolys->InsertNextCell(npts,pts); + if(myStoreMapping) + myElemVTK2ObjIds.push_back(newId); + outputCD->CopyData(cd, cellId, newId); + } + cellId++; + } + } + this->UpdateProgress (0.90); + + // strips + if ( newStrips && !this->GetAbortExecute() ) + { + for (inStrips->InitTraversal(); inStrips->GetNextCell(npts,pts); ) + { + for (numIn=0, i=0; iGetValue(pts[i]) <= 0.0 ) + { + numIn++; + } + } + if ( (numIn == npts) || (this->ExtractBoundaryCells && numIn > 0) ) + { + newId = newStrips->InsertNextCell(npts,pts); + if(myStoreMapping) + myElemVTK2ObjIds.push_back(newId); + outputCD->CopyData(cd, cellId, newId); + } + cellId++; + } + } + this->UpdateProgress (1.0); + + // Update ourselves and release memory + // + newScalars->Delete(); + + if ( newVerts ) + { + output->SetVerts(newVerts); + newVerts->Delete(); + } + if ( newLines ) + { + output->SetLines(newLines); + newLines->Delete(); + } + if ( newPolys ) + { + output->SetPolys(newPolys); + newPolys->Delete(); + } + if ( newStrips ) + { + output->SetStrips(newStrips); + newStrips->Delete(); + } +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/SALOME_ExtractPolyDataGeometry.h b/src/PIPELINE/SALOME_ExtractPolyDataGeometry.h new file mode 100644 index 00000000..ab42be7c --- /dev/null +++ b/src/PIPELINE/SALOME_ExtractPolyDataGeometry.h @@ -0,0 +1,95 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com + +#ifndef SALOME_ExtractPolyDataGeometry_H +#define SALOME_ExtractPolyDataGeometry_H + +#include +#include + +#include + +class vtkImplicitBoolean; + +class SALOME_ExtractPolyDataGeometry : public vtkExtractPolyDataGeometry +{ +public: + vtkTypeMacro(SALOME_ExtractPolyDataGeometry, vtkExtractPolyDataGeometry); + + static + SALOME_ExtractPolyDataGeometry* + New(); + + virtual + void + SetImplicitFunction(vtkImplicitFunction* theImplicitFunction); + + vtkImplicitBoolean* + GetImplicitBoolean(); + + bool + GetStoreMapping() const; + + void + SetStoreMapping(bool theStoreMapping); + + virtual + vtkIdType + GetNodeObjId(vtkIdType theID); + + virtual + vtkIdType + GetElemObjId(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKId(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKId(vtkIdType theID); + +protected: + SALOME_ExtractPolyDataGeometry(); + ~SALOME_ExtractPolyDataGeometry(); + + virtual + void + Execute(); + + void + Execute2(); + +private: + bool myStoreMapping; + bool myIsDoneShallowCopy; + + typedef std::vector TVectorId; + TVectorId myElemVTK2ObjIds; + TVectorId myNodeVTK2ObjIds; + + vtkSmartPointer myImplicitBoolean; + + SALOME_ExtractPolyDataGeometry(const SALOME_ExtractPolyDataGeometry&); // Not implemented. + void operator=(const SALOME_ExtractPolyDataGeometry&); // Not implemented. +}; + +#endif + + diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 2af09bb9..6ad47210 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -24,7 +24,6 @@ // Author: Alexey PETROV // Module : VISU -#include "VISU_Convertor.hxx" #include "VISU_MeshPL.hxx" #include "VISU_ScalarMapPL.hxx" #include "VISU_IsoSurfacesPL.hxx" @@ -35,8 +34,11 @@ #include "VISU_StreamLinesPL.hxx" #include "VISU_GaussPointsPL.hxx" #include "VISU_Plot3DPL.hxx" +#include "VISU_ScalarBarActor.hxx" + +#include "VISU_Convertor.hxx" -typedef VISU_GaussPointsPL TPresent; +typedef VISU_DeformedShapePL TPresent; #include #include @@ -56,7 +58,76 @@ using namespace std; static int isOnlyMesh = false; -int main(int argc, char** argv){ + +//---------------------------------------------------------------------------- +template +VISU_ColoredPL* +CreateColoredPL(VISU_Convertor* theConvertor, + const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theTimeStampNumber); + + +//---------------------------------------------------------------------------- +template<> +VISU_ColoredPL* +CreateColoredPL(VISU_Convertor* theConvertor, + const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theTimeStampNumber) +{ + VISU_GaussPointsPL* aPresent = VISU_GaussPointsPL::New(); + VISU::PGaussPtsIDMapper aGaussPtsIDMapper = + theConvertor->GetTimeStampOnGaussPts(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); + aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); + + char aMainTexture[80]; + strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); + strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" ); + + char anAlphaTexture[80]; + strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); + strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" ); + + vtkSmartPointer aTextureValue = + VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); + aPresent->SetImageData( aTextureValue.GetPointer() ); + + aPresent->Update(); + + return aPresent; +} + + +//---------------------------------------------------------------------------- +template +VISU_ColoredPL* +CreateColoredPL(VISU_Convertor* theConvertor, + const std::string& theMeshName, + const VISU::TEntity& theEntity, + const std::string& theFieldName, + int theTimeStampNumber) +{ + TPipeLine* aPresent = TPipeLine::New(); + VISU::PUnstructuredGridIDMapper anUnstructuredGridIDMapper = + theConvertor->GetTimeStampOnMesh(theMeshName, + theEntity, + theFieldName, + theTimeStampNumber); + aPresent->SetUnstructuredGridIDMapper(anUnstructuredGridIDMapper); + return aPresent; +} + + +//---------------------------------------------------------------------------- +int +main(int argc, char** argv) +{ try{ if(argc > 1){ vtkRenderWindow *renWin = vtkRenderWindow::New(); @@ -80,13 +151,11 @@ int main(int argc, char** argv){ const VISU::TEntity& anEntity = VISU::CELL_ENTITY; aMeshOnEntityMapIter = aMeshOnEntityMap.find(anEntity); - VISU::PIDMapper anIDMapper = + VISU::PNamedIDMapper anIDMapper = aConvertor->GetMeshOnEntity(aMeshName,anEntity); - VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput(); VISU_MeshPL* aPresent = VISU_MeshPL::New(); - aPresent->SetInput(aDataSet); - aPresent->Build(); + aPresent->SetUnstructuredGridIDMapper(anIDMapper); vtkActor* aActor = vtkActor::New(); aActor->SetMapper(aPresent->GetMapper()); @@ -108,45 +177,32 @@ int main(int argc, char** argv){ VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin(); for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){ const VISU::PField aField = aFieldMapIter->second; - /* + ///* if(aField->myNbComp == 1) continue; - */ + //*/ const string& aFieldName = aFieldMapIter->first; const VISU::TValField& aValField = aField->myValField; VISU::TValField::const_iterator aValFieldIter = aValField.begin(); if(aValFieldIter == aValField.end()) return 0; int aTimeStamp = aValFieldIter->first; - TPresent* aPresent = TPresent::New(); - VISU::PIDMapper anIDMapper; + VISU_ColoredPL* aPresent = NULL; if(anEntity != VISU::NODE_ENTITY){ - VISU::PGaussPtsIDMapper aGaussPtsIDMapper = aConvertor->GetTimeStampOnGaussPts(aMeshName,anEntity,aFieldName,aTimeStamp); - aPresent->SetGaussPtsIDMapper(aGaussPtsIDMapper); + aPresent = CreateColoredPL(aConvertor, + aMeshName, + anEntity, + aFieldName, + aTimeStamp); }else{ - continue; - VISU::PIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp); - aPresent->SetIDMapper(anIDMapper); + //continue; + aPresent = CreateColoredPL(aConvertor, + aMeshName, + anEntity, + aFieldName, + aTimeStamp); } - aPresent->Build(); - aPresent->Init(); - - char aMainTexture[80]; - strcpy( aMainTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( aMainTexture, "/share/salome/resources/visu/sprite_texture.vti" ); - //cout << aMainTexture << endl; - - char anAlphaTexture[80]; - strcpy( anAlphaTexture, getenv( "VISU_ROOT_DIR" ) ); - strcat( anAlphaTexture, "/share/salome/resources/visu/sprite_alpha.vti" ); - //cout << anAlphaTexture << endl; - - vtkSmartPointer aTextureValue = VISU_GaussPointsPL::MakeTexture( aMainTexture, anAlphaTexture ); - aPresent->SetImageData( aTextureValue.GetPointer() ); - - aPresent->Update(); - vtkActor* anActor = vtkActor::New(); anActor->SetMapper(aPresent->GetMapper()); diff --git a/src/PIPELINE/VISU_ColoredPL.cxx b/src/PIPELINE/VISU_ColoredPL.cxx new file mode 100644 index 00000000..0e6ec807 --- /dev/null +++ b/src/PIPELINE/VISU_ColoredPL.cxx @@ -0,0 +1,308 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_ColoredPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_ColoredPL.hxx" +#include "VISU_Extractor.hxx" +#include "VISU_LookupTable.hxx" +#include "VISU_MapperHolder.hxx" + +#include "VISU_PipeLineUtils.hxx" + + +//---------------------------------------------------------------------------- +VISU_ColoredPL +::VISU_ColoredPL(): + myMapperTable(VISU_LookupTable::New()), + myBarTable(VISU_LookupTable::New()), + myExtractor(VISU_Extractor::New()), + myFieldTransform(VISU_FieldTransform::New()) +{ + myMapperTable->Delete(); + myMapperTable->SetScale(VTK_SCALE_LINEAR); + myMapperTable->SetHueRange(0.667, 0.0); + + myBarTable->Delete(); + myBarTable->SetScale(VTK_SCALE_LINEAR); + myBarTable->SetHueRange(0.667, 0.0); + + myExtractor->Delete(); + + myFieldTransform->Delete(); +} + + +VISU_ColoredPL +::~VISU_ColoredPL() +{} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + if(VISU_ColoredPL *aPipeLine = dynamic_cast(thePipeLine)){ + if(theIsCopyInput) + SetScalarRange(aPipeLine->GetScalarRange()); + SetScalarMode(aPipeLine->GetScalarMode()); + SetNbColors(aPipeLine->GetNbColors()); + SetScaling(aPipeLine->GetScaling()); + SetMapScale(aPipeLine->GetMapScale()); + } + + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); +} + + +//---------------------------------------------------------------------------- +int +VISU_ColoredPL +::GetScalarMode() +{ + return myExtractor->GetScalarMode(); +} + +void +VISU_ColoredPL +::SetScalarMode(int theScalarMode) +{ + if(vtkDataSet *anInput = GetInput()){ + if(anInput->GetPointData()->GetNumberOfArrays()){ + vtkPointData *aPointData = anInput->GetPointData(); + if(!aPointData->GetAttribute(vtkDataSetAttributes::VECTORS)) + if(theScalarMode == 0) + return; + }else{ + vtkCellData *aCellData = anInput->GetCellData(); + if(!aCellData->GetAttribute(vtkDataSetAttributes::VECTORS)) + if(theScalarMode == 0) + return; + } + } + + myExtractor->SetScalarMode(theScalarMode); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::SetScalarRange(vtkFloatingPointType theRange[2]) +{ + myFieldTransform->SetScalarRange(theRange); + myBarTable->SetRange(theRange); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_ColoredPL +::GetScalarRange() +{ + return myFieldTransform->GetScalarRange(); +} + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::SetScaling(int theScaling) +{ + myBarTable->SetScale(theScaling); + if(theScaling == VTK_SCALE_LOG10) + myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); + else + myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident)); +} + +//---------------------------------------------------------------------------- +int +VISU_ColoredPL +::GetScaling() +{ + return myBarTable->GetScale(); +} + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::SetNbColors(int theNbColors) +{ + myMapperTable->SetNumberOfColors(theNbColors); + myBarTable->SetNumberOfColors(theNbColors); +} + +int +VISU_ColoredPL +::GetNbColors() +{ + return myMapperTable->GetNumberOfColors(); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::Init() +{ + SetScalarMode(0); + SetSourceRange(); +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_ColoredPL +::InsertCustomPL() +{ + return GetFieldTransformFilter()->GetUnstructuredGridOutput(); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::Build() +{ + myExtractor->SetInput(GetClippedInput()); + myFieldTransform->SetInput(myExtractor->GetOutput()); + + GetMapperHolder()->SetLookupTable(GetMapperTable()); + GetMapper()->SetUseLookupTableScalarRange(true); + GetMapper()->SetColorModeToMapScalars(); + GetMapper()->ScalarVisibilityOn(); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::Update() +{ + vtkFloatingPointType *aRange = myFieldTransform->GetScalarRange(); + vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; + if(myBarTable->GetScale() == VTK_SCALE_LOG10) + VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); + myMapperTable->SetRange(aScalarRange); + + myMapperTable->Build(); + myBarTable->Build(); + + VISU_PipeLine::Update(); +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_ColoredPL +::GetMemorySize() +{ + unsigned long int aSize = 0; + + if(vtkDataSet* aDataSet = myExtractor->GetInput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + + if(vtkDataSet* aDataSet = myFieldTransform->GetInput()) + aSize += aDataSet->GetActualMemorySize() * 1024; + + aSize += Superclass::GetMemorySize(); + + return aSize; +} + + +//---------------------------------------------------------------------------- +VISU_LookupTable * +VISU_ColoredPL +::GetMapperTable() +{ + return myMapperTable.GetPointer(); +} + + +//---------------------------------------------------------------------------- +VISU_LookupTable* +VISU_ColoredPL +::GetBarTable() +{ + return myBarTable.GetPointer(); +} + + +//---------------------------------------------------------------------------- +VISU_Extractor* +VISU_ColoredPL +::GetExtractorFilter() +{ + return myExtractor.GetPointer(); +} + + +//---------------------------------------------------------------------------- +VISU_FieldTransform* +VISU_ColoredPL +::GetFieldTransformFilter() +{ + return myFieldTransform.GetPointer(); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::SetMapScale(vtkFloatingPointType theMapScale) +{ + if(!VISU::CheckIsSameValue(myMapperTable->GetMapScale(), theMapScale)){ + myMapperTable->SetMapScale(theMapScale); + myMapperTable->Build(); + } +} + +vtkFloatingPointType +VISU_ColoredPL +::GetMapScale() +{ + return myMapperTable->GetMapScale(); +} + + +//---------------------------------------------------------------------------- +void +VISU_ColoredPL +::GetSourceRange(vtkFloatingPointType theRange[2]) +{ + myExtractor->Update(); + myExtractor->GetOutput()->GetScalarRange(theRange); +} + +void +VISU_ColoredPL +::SetSourceRange() +{ + vtkFloatingPointType aRange[2]; + GetSourceRange(aRange); + SetScalarRange(aRange); +} diff --git a/src/PIPELINE/VISU_ColoredPL.hxx b/src/PIPELINE/VISU_ColoredPL.hxx new file mode 100644 index 00000000..e8a9f02f --- /dev/null +++ b/src/PIPELINE/VISU_ColoredPL.hxx @@ -0,0 +1,155 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_ColoredPL.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_ColoredPL_HeaderFile +#define VISU_ColoredPL_HeaderFile + +#include "VISU_PipeLine.hxx" + +#include + +class VISU_Extractor; +class VISU_FieldTransform; +class VISU_LookupTable; + + +//---------------------------------------------------------------------------- +class VISU_ColoredPL : public VISU_PipeLine +{ +public: + vtkTypeMacro(VISU_ColoredPL, VISU_PipeLine); + + //---------------------------------------------------------------------------- + virtual + int + GetScalarMode(); + + virtual + void + SetScalarMode(int theScalarMode = 0); + + virtual + vtkFloatingPointType* + GetScalarRange(); + + virtual + void + SetScalarRange(vtkFloatingPointType theRange[2]); + + virtual + void + SetScaling(int theScaling); + + virtual + int + GetScaling(); + + virtual + void + SetNbColors(int theNbColors); + + virtual + int + GetNbColors(); + + //---------------------------------------------------------------------------- +public: + virtual + void + Init(); + + virtual + void + Update(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + virtual + VISU_LookupTable* + GetMapperTable(); + + virtual + VISU_LookupTable* + GetBarTable(); + + virtual + void + SetMapScale(vtkFloatingPointType theMapScale = 1.0); + + virtual + vtkFloatingPointType + GetMapScale(); + + virtual + void + GetSourceRange(vtkFloatingPointType theRange[2]); + + virtual + void + SetSourceRange(); + +protected: + //---------------------------------------------------------------------------- + VISU_ColoredPL(); + VISU_ColoredPL(const VISU_ColoredPL&); + + virtual + ~VISU_ColoredPL(); + + //---------------------------------------------------------------------------- + virtual + void + Build(); + + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + + //---------------------------------------------------------------------------- + VISU_Extractor* + GetExtractorFilter(); + + VISU_FieldTransform* + GetFieldTransformFilter(); + + //---------------------------------------------------------------------------- + virtual + vtkDataSet* + InsertCustomPL(); + +private: + vtkSmartPointer myMapperTable; + vtkSmartPointer myBarTable; + vtkSmartPointer myExtractor; + vtkSmartPointer myFieldTransform; +}; + +#endif diff --git a/src/PIPELINE/VISU_CutLinesPL.cxx b/src/PIPELINE/VISU_CutLinesPL.cxx index 2fd62fde..d5be0a73 100644 --- a/src/PIPELINE/VISU_CutLinesPL.cxx +++ b/src/PIPELINE/VISU_CutLinesPL.cxx @@ -30,10 +30,12 @@ #include -using namespace std; +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_CutLinesPL); + +//---------------------------------------------------------------------------- VISU_CutLinesPL ::VISU_CutLinesPL() { @@ -41,6 +43,8 @@ VISU_CutLinesPL myPosition = 0; } + +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -58,6 +62,8 @@ VISU_CutLinesPL Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } + +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::Init() @@ -75,6 +81,7 @@ VISU_CutLinesPL } +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::SetPosition(vtkFloatingPointType thePosition) @@ -83,21 +90,35 @@ VISU_CutLinesPL myCondition = 0; Modified(); } + + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_CutLinesPL ::GetPosition() { vtkFloatingPointType aPosition = myPosition; if(myCondition){ - vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetInput2()->GetBounds(aBounds); - GetDir(aDir,myAng[0],myBasePlane[0]); - GetBoundProject(aBoundPrj,aBounds,aDir); - aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[0]; + vtkFloatingPointType aBounds[6]; + GetClippedInput()->GetBounds(aBounds); + + vtkFloatingPointType aDir[3]; + GetDir(aDir, + myAng[0], + myBasePlane[0]); + + vtkFloatingPointType aBoundPrj[3]; + GetBoundProject(aBoundPrj, + aBounds, + aDir); + + aPosition = aBoundPrj[0] + aBoundPrj[2] * myDisplacement[0]; } return aPosition; } + +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::SetDefault() @@ -105,6 +126,9 @@ VISU_CutLinesPL myCondition = 1; Modified(); } + + +//---------------------------------------------------------------------------- int VISU_CutLinesPL ::IsDefault() @@ -114,32 +138,58 @@ VISU_CutLinesPL } +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::Update() { ClearAppendPolyData(myAppendPolyData); + SetPartPosition(1); + vtkAppendPolyData *anAppendPolyData = vtkAppendPolyData::New(); + //Build base plane - vtkFloatingPointType aDir[2][3], aBaseBounds[6]; - GetInput2()->GetBounds(aBaseBounds); - GetDir(aDir[0],myAng[0],myBasePlane[0]); - vtkUnstructuredGrid* anUnstructuredGrid = - myFieldTransform->GetUnstructuredGridOutput(); - CutWithPlanes(anAppendPolyData,anUnstructuredGrid,1,aDir[0],aBaseBounds, - myPosition,myCondition,myDisplacement[0]); + vtkFloatingPointType aBaseBounds[6]; + GetClippedInput()->GetBounds(aBaseBounds); + + vtkFloatingPointType aDir[2][3]; + GetDir(aDir[0], + myAng[0], + myBasePlane[0]); + + vtkUnstructuredGrid* aGrid = GetFieldTransformFilter()->GetUnstructuredGridOutput(); + CutWithPlanes(anAppendPolyData, + aGrid,1, + aDir[0], + aBaseBounds, + myPosition, + myCondition, + myDisplacement[0]); //Build lines - vtkFloatingPointType aBounds[6]; vtkDataSet *aDataSet = anAppendPolyData->GetOutput(); aDataSet->Update(); + if(aDataSet->GetNumberOfCells() == 0) - aDataSet = anUnstructuredGrid; + aDataSet = aGrid; + + vtkFloatingPointType aBounds[6]; aDataSet->GetBounds(aBounds); - GetDir(aDir[1],myAng[1],myBasePlane[1]); - VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData,aDataSet,GetNbParts(),aDir[1],aBounds, - myPartPosition,myPartCondition,myDisplacement[1]); + + GetDir(aDir[1], + myAng[1], + myBasePlane[1]); + + VISU_CutPlanesPL::CutWithPlanes(myAppendPolyData, + aDataSet, + GetNbParts(), + aDir[1], + aBounds, + myPartPosition, + myPartCondition, + myDisplacement[1]); anAppendPolyData->Delete(); + //Calculate values for building of table vtkMath::Cross(aDir[0],aDir[1],myDirLn); for (int i = 0; i<3 ; i++) { @@ -147,15 +197,23 @@ VISU_CutLinesPL if(myDirLn[i] < 0.0) myDirLn[i] = -1.0*myDirLn[i];//enk:: correction of bug Bug PAL10401 } - GetBoundProject(myBoundPrjLn, aBaseBounds, myDirLn); - VISU::Mul(myDirLn,myBoundPrjLn[0],myBasePnt); + + GetBoundProject(myBoundPrjLn, + aBaseBounds, + myDirLn); + + VISU::Mul(myDirLn, + myBoundPrjLn[0], + myBasePnt); - CorrectPnt(myBasePnt,aBaseBounds); + CorrectPnt(myBasePnt, + aBaseBounds); VISU_ScalarMapPL::Update(); } +//---------------------------------------------------------------------------- void VISU_CutLinesPL ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, @@ -167,8 +225,17 @@ VISU_CutLinesPL int thePartCondition, vtkFloatingPointType theDisplacement) { - vector aPartPosition(1,thePartPosition); - vector aPartCondition(1,thePartCondition); - VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData,theDataSet,theNbPlanes,theDir,theBounds, - aPartPosition,aPartCondition,theDisplacement); + std::vector aPartPosition(1,thePartPosition); + std::vector aPartCondition(1,thePartCondition); + VISU_CutPlanesPL::CutWithPlanes(theAppendPolyData, + theDataSet, + theNbPlanes, + theDir, + theBounds, + aPartPosition, + aPartCondition, + theDisplacement); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_CutLinesPL.hxx b/src/PIPELINE/VISU_CutLinesPL.hxx index 4f2f6ea6..6332bcde 100644 --- a/src/PIPELINE/VISU_CutLinesPL.hxx +++ b/src/PIPELINE/VISU_CutLinesPL.hxx @@ -31,6 +31,8 @@ class vtkAppendPolyData; + +//---------------------------------------------------------------------------- class VISU_CutLinesPL : public VISU_CutPlanesPL { public: diff --git a/src/PIPELINE/VISU_CutPlanesPL.cxx b/src/PIPELINE/VISU_CutPlanesPL.cxx index 3eb87827..8403583d 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.cxx +++ b/src/PIPELINE/VISU_CutPlanesPL.cxx @@ -33,17 +33,20 @@ #include #include -using namespace std; - static vtkFloatingPointType EPS = 1.0E-3; + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_CutPlanesPL); + +//---------------------------------------------------------------------------- VISU_CutPlanesPL ::VISU_CutPlanesPL() { + SetIsShrinkable(false); + myAppendPolyData = vtkAppendPolyData::New(); - myIsShrinkable = false; myNbParts = 10; @@ -56,28 +59,40 @@ VISU_CutPlanesPL myAng[1][0] = myAng[1][1] = myAng[1][2] = 0.0; } + +//---------------------------------------------------------------------------- VISU_CutPlanesPL ::~VISU_CutPlanesPL() { myAppendPolyData->Delete(); + myAppendPolyData = NULL; } + +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput) { if(VISU_CutPlanesPL *aPipeLine = dynamic_cast(thePipeLine)){ + SetOrientation(aPipeLine->GetPlaneOrientation(), - aPipeLine->GetRotateX(),aPipeLine->GetRotateY()); + aPipeLine->GetRotateX(), + aPipeLine->GetRotateY()); + SetDisplacement(aPipeLine->GetDisplacement()); + SetNbParts(aPipeLine->GetNbParts()); - for (int i = 0, iend = GetNbParts(); i < iend; i++) - if(!aPipeLine->IsPartDefault(i)) SetPartPosition(i, aPipeLine->GetPartPosition(i)); + for (int i = 0, iEnd = GetNbParts(); i < iEnd; i++) + if(!aPipeLine->IsPartDefault(i)) + SetPartPosition(i, aPipeLine->GetPartPosition(i)); } Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } + +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::Init() @@ -90,30 +105,47 @@ VISU_CutPlanesPL myAng[0][0] = myAng[0][1] = myAng[0][2] = 0.0; } -VISU_ScalarMapPL::THook* + +//---------------------------------------------------------------------------- +vtkDataSet* VISU_CutPlanesPL -::DoHook() +::InsertCustomPL() { return myAppendPolyData->GetOutput(); } + +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::Update() { ClearAppendPolyData(myAppendPolyData); + SetPartPosition(); + vtkFloatingPointType aDir[3]; - GetDir(aDir,myAng[0],myBasePlane[0]); + GetDir(aDir, + myAng[0], + myBasePlane[0]); + vtkFloatingPointType aBounds[6]; - GetInput2()->GetBounds(aBounds); - vtkDataSet* aDataSet = myFieldTransform->GetUnstructuredGridOutput(); - CutWithPlanes(myAppendPolyData,aDataSet,myNbParts,aDir,aBounds, - myPartPosition,myPartCondition,myDisplacement[0]); + GetClippedInput()->GetBounds(aBounds); + + vtkDataSet* aDataSet = GetFieldTransformFilter()->GetUnstructuredGridOutput(); + CutWithPlanes(myAppendPolyData, + aDataSet, + myNbParts, + aDir, + aBounds, + myPartPosition, + myPartCondition, + myDisplacement[0]); Superclass::Update(); } + //---------------------------------------------------------------------------- unsigned long int VISU_CutPlanesPL @@ -152,6 +184,8 @@ VISU_CutPlanesPL theAppendPolyData->RemoveInput(theAppendPolyData->GetInput(i)); } + +//---------------------------------------------------------------------------- vtkFloatingPointType* VISU_CutPlanesPL:: GetRx(vtkFloatingPointType theRx[3][3], @@ -164,6 +198,8 @@ GetRx(vtkFloatingPointType theRx[3][3], } + +//---------------------------------------------------------------------------- vtkFloatingPointType* VISU_CutPlanesPL ::GetRy(vtkFloatingPointType theRy[3][3], @@ -176,6 +212,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- vtkFloatingPointType* VISU_CutPlanesPL ::GetRz(vtkFloatingPointType theRz[3][3], @@ -188,6 +225,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::CorrectPnt(vtkFloatingPointType thePnt[3], @@ -199,6 +237,8 @@ VISU_CutPlanesPL } } + +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::GetBoundProject(vtkFloatingPointType BoundPrj[3], @@ -226,6 +266,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::SetOrientation(const VISU_CutPlanesPL::PlaneOrientation& theOrient, @@ -247,6 +288,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- const VISU_CutPlanesPL::PlaneOrientation& VISU_CutPlanesPL ::GetPlaneOrientation(int theNum) @@ -266,6 +308,8 @@ VISU_CutPlanesPL return 0; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_CutPlanesPL ::GetRotateY(int theNum) @@ -279,6 +323,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_CutPlanesPL ::GetDisplacement(int theNum) @@ -287,6 +332,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::SetDisplacement(vtkFloatingPointType theDisp, @@ -297,17 +343,19 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::SetNbParts(int theNb) { myNbParts = theNb; myPartPosition.resize(myNbParts); - myPartCondition.resize(myNbParts,1); + myPartCondition.resize(myNbParts, 1); Modified(); } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::SetPartPosition(int thePartNumber, @@ -315,11 +363,14 @@ VISU_CutPlanesPL { if(thePartNumber >= myNbParts) return; + myPartPosition[thePartNumber] = thePartPosition; myPartCondition[thePartNumber] = 0; Modified(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_CutPlanesPL ::GetPartPosition(int thePartNumber, @@ -327,13 +378,21 @@ VISU_CutPlanesPL { if(thePartNumber >= myNbParts) return 0; + vtkFloatingPointType aPosition = myPartPosition[thePartNumber]; if(myPartCondition[thePartNumber]){ vtkFloatingPointType aDir[3], aBounds[6], aBoundPrj[3]; - GetInput2()->GetBounds(aBounds); - GetDir(aDir,myAng[theNum],myBasePlane[theNum]); - GetBoundProject(aBoundPrj,aBounds,aDir); - if (myNbParts > 1){ + GetClippedInput()->GetBounds(aBounds); + + GetDir(aDir, + myAng[theNum], + myBasePlane[theNum]); + + GetBoundProject(aBoundPrj, + aBounds, + aDir); + + if(myNbParts > 1){ vtkFloatingPointType aDBoundPrj = aBoundPrj[2]/(myNbParts - 1); vtkFloatingPointType aDisplacement = aDBoundPrj * myDisplacement[theNum]; vtkFloatingPointType aStartPosition = aBoundPrj[0] - 0.5*aDBoundPrj + aDisplacement; @@ -341,28 +400,38 @@ VISU_CutPlanesPL }else aPosition = aBoundPrj[0] + aBoundPrj[2]*myDisplacement[theNum]; } + return aPosition; } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::SetPartDefault(int thePartNumber) { - if(thePartNumber >= myNbParts) return; + if(thePartNumber >= myNbParts) + return; + myPartPosition[thePartNumber] = GetPartPosition(thePartNumber); myPartCondition[thePartNumber] = 1; Modified(); } + + +//---------------------------------------------------------------------------- int VISU_CutPlanesPL ::IsPartDefault(int thePartNumber) { - if(thePartNumber >= myNbParts) return 1; + if(thePartNumber >= myNbParts) + return 1; + return myPartCondition[thePartNumber]; } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::GetDir(vtkFloatingPointType theDir[3], @@ -391,11 +460,13 @@ VISU_CutPlanesPL iPlane = 1; break; } + for(int i = 0; i < 3; i++) theDir[i] = aRotation[i][iPlane]; } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::CutWithPlane(vtkAppendPolyData* theAppendPolyData, @@ -416,6 +487,7 @@ VISU_CutPlanesPL } +//---------------------------------------------------------------------------- void VISU_CutPlanesPL ::CutWithPlanes(vtkAppendPolyData* theAppendPolyData, @@ -423,8 +495,8 @@ VISU_CutPlanesPL int theNbPlanes, vtkFloatingPointType theDir[3], vtkFloatingPointType theBounds[6], - const vector& thePlanePosition, - const vector& thePlaneCondition, + const std::vector& thePlanePosition, + const std::vector& thePlaneCondition, vtkFloatingPointType theDisplacement) { vtkFloatingPointType aBoundPrj[3], aOrig[3], aPosition; @@ -454,3 +526,6 @@ VISU_CutPlanesPL aPolyData->Update(); theAppendPolyData->Update(); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_CutPlanesPL.hxx b/src/PIPELINE/VISU_CutPlanesPL.hxx index 145b30ca..86736a3c 100644 --- a/src/PIPELINE/VISU_CutPlanesPL.hxx +++ b/src/PIPELINE/VISU_CutPlanesPL.hxx @@ -33,11 +33,10 @@ class vtkAppendPolyData; + +//---------------------------------------------------------------------------- class VISU_CutPlanesPL : public VISU_ScalarMapPL { -protected: - VISU_CutPlanesPL(); - VISU_CutPlanesPL(const VISU_CutPlanesPL&); public: vtkTypeMacro(VISU_CutPlanesPL,VISU_ScalarMapPL); static VISU_CutPlanesPL* New(); @@ -180,9 +179,12 @@ public: const std::vector& thePlaneCondition, vtkFloatingPointType theDisplacement); protected: + VISU_CutPlanesPL(); + VISU_CutPlanesPL(const VISU_CutPlanesPL&); + virtual - THook* - DoHook(); + vtkDataSet* + InsertCustomPL(); virtual void diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.cxx b/src/PIPELINE/VISU_DataSetMapperHolder.cxx new file mode 100644 index 00000000..65a3caad --- /dev/null +++ b/src/PIPELINE/VISU_DataSetMapperHolder.cxx @@ -0,0 +1,348 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_DataSetMapperHolder.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_DataSetMapperHolder.hxx" +#include "SALOME_ExtractGeometry.h" +#include "VISU_LookupTable.hxx" + +#include "VISU_PipeLineUtils.hxx" + +#include +#include + +#include +#include +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_DataSetMapperHolder); + + +//---------------------------------------------------------------------------- +VISU_DataSetMapperHolder +::VISU_DataSetMapperHolder(): + myExtractGeometry(SALOME_ExtractGeometry::New()) +{ + if(MYDEBUG) MESSAGE("VISU_DataSetMapperHolder::VISU_DataSetMapperHolder - "<Delete(); + myExtractGeometry->SetStoreMapping(true); + + vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); + myExtractGeometry->SetImplicitFunction(anImplicitBoolean); + anImplicitBoolean->SetOperationTypeToIntersection(); + anImplicitBoolean->Delete(); +} + + +//---------------------------------------------------------------------------- +VISU_DataSetMapperHolder +::~VISU_DataSetMapperHolder() +{ + if(MYDEBUG) + MESSAGE("VISU_DataSetMapperHolder::~VISU_DataSetMapperHolder - "<(theMapperHolder)){ + if(theIsCopyInput) + SetUnstructuredGridIDMapper(aMapperHolder->GetUnstructuredGridIDMapper()); + + VISU::CopyDataSetMapper(GetDataSetMapper(), + aMapperHolder->GetDataSetMapper(), + theIsCopyInput); + } +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_DataSetMapperHolder +::GetMemorySize() +{ + unsigned long int aSize = 0; + + if(myExtractGeometry->GetInput()) + if(vtkDataSet* aDataSet = myExtractGeometry->GetOutput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + + aSize += Superclass::GetMemorySize(); + + return aSize; +} + + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) +{ + myExtractGeometry->SetInput(theIDMapper->GetUnstructuredGridOutput()); + myUnstructuredGridIDMapper = theIDMapper; + SetIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PUnstructuredGridIDMapper& +VISU_DataSetMapperHolder +::GetUnstructuredGridIDMapper() +{ + return myUnstructuredGridIDMapper; +} + + +//---------------------------------------------------------------------------- +vtkUnstructuredGrid* +VISU_DataSetMapperHolder +::GetUnstructuredGridInput() +{ + if(myUnstructuredGridIDMapper) + return myUnstructuredGridIDMapper->GetUnstructuredGridOutput(); + + return NULL; +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_DataSetMapperHolder +::GetClippedInput() +{ + vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput(); + aDataSet->Update(); + return aDataSet; +} + + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::OnCreateMapper() +{ + myDataSetMapper = vtkDataSetMapper::New(); + myDataSetMapper->Delete(); + SetMapper(myDataSetMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetDataSetMapper(vtkDataSetMapper* theMapper) +{ + myDataSetMapper = theMapper; + SetMapper(myDataSetMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +vtkDataSetMapper* +VISU_DataSetMapperHolder +::GetDataSetMapper() +{ + GetMapper(); + return myDataSetMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetLookupTable(VISU_LookupTable* theLookupTable) +{ + myDataSetMapper->SetLookupTable(theLookupTable); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_DataSetMapperHolder +::GetNodeObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractGeometry->GetNodeObjId(theID); + return Superclass::GetNodeObjID(anID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_DataSetMapperHolder +::GetNodeVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetNodeVTKID(theID); + return myExtractGeometry->GetNodeVTKId(anID); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_DataSetMapperHolder +::GetNodeCoord(int theObjID) +{ + return Superclass::GetNodeCoord(theObjID); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_DataSetMapperHolder +::GetElemObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractGeometry->GetElemObjId(theID); + return Superclass::GetElemObjID(anID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_DataSetMapperHolder +::GetElemVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetElemVTKID(theID); + return myExtractGeometry->GetElemVTKId(anID); +} + +//---------------------------------------------------------------------------- +vtkCell* +VISU_DataSetMapperHolder +::GetElemCell(vtkIdType theObjID) +{ + return Superclass::GetElemCell(theObjID); +} + + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetImplicitFunction(vtkImplicitFunction *theFunction) +{ + myExtractGeometry->SetImplicitFunction(theFunction); +} + +//---------------------------------------------------------------------------- +vtkImplicitFunction * +VISU_DataSetMapperHolder +::GetImplicitFunction() +{ + return myExtractGeometry->GetImplicitFunction(); +} + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::RemoveAllClippingPlanes() +{ + if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->RemoveAllItems(); + aBoolean->Modified(); // VTK bug + } +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_DataSetMapperHolder +::GetNumberOfClippingPlanes() +{ + if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + return aFunction->GetNumberOfItems(); + } + return 0; +} + +//---------------------------------------------------------------------------- +bool +VISU_DataSetMapperHolder +::AddClippingPlane(vtkPlane* thePlane) +{ + if (thePlane) { + if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) { + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->AddItem(thePlane); + // Check, that at least one cell present after clipping. + // This check was introduced because of bug IPAL8849. + vtkDataSet* aClippedDataSet = GetClippedInput(); + if(aClippedDataSet->GetNumberOfCells() < 1) + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- +vtkPlane* +VISU_DataSetMapperHolder +::GetClippingPlane(vtkIdType theID) +{ + vtkPlane* aPlane = NULL; + if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ + if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + vtkImplicitFunction* aFun = NULL; + aFunction->InitTraversal(); + for(vtkIdType anID = 0; anID <= theID; anID++) + aFun = aFunction->GetNextItem(); + aPlane = dynamic_cast(aFun); + } + } + return aPlane; +} + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetExtractInside(bool theMode) +{ + myExtractGeometry->SetExtractInside(theMode); +} + +//---------------------------------------------------------------------------- +void +VISU_DataSetMapperHolder +::SetExtractBoundaryCells(bool theMode) +{ + myExtractGeometry->SetExtractBoundaryCells(theMode); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_DataSetMapperHolder.hxx b/src/PIPELINE/VISU_DataSetMapperHolder.hxx new file mode 100644 index 00000000..a53749f6 --- /dev/null +++ b/src/PIPELINE/VISU_DataSetMapperHolder.hxx @@ -0,0 +1,165 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_DataSetMapperHolder.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_DataSetMapperHolder_HeaderFile +#define VISU_DataSetMapperHolder_HeaderFile + +#include "VISU_MapperHolder.hxx" + +class vtkDataSetMapper; +class vtkUnstructuredGrid; +class SALOME_ExtractGeometry; + + +//---------------------------------------------------------------------------- +class VISU_DataSetMapperHolder : public VISU_MapperHolder +{ +public: + vtkTypeMacro(VISU_DataSetMapperHolder, VISU_MapperHolder); + + static + VISU_DataSetMapperHolder* + New(); + + //---------------------------------------------------------------------------- + virtual + void + ShallowCopy(VISU_MapperHolder *theMapperHolder, + bool theIsCopyInput); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //---------------------------------------------------------------------------- + void + SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper); + + const VISU::PUnstructuredGridIDMapper& + GetUnstructuredGridIDMapper(); + + virtual + vtkUnstructuredGrid* + GetUnstructuredGridInput(); + + virtual + vtkDataSetMapper* + GetDataSetMapper(); + + //---------------------------------------------------------------------------- + virtual + vtkIdType + GetNodeObjID(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID); + + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetElemObjID(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID); + + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + + //---------------------------------------------------------------------------- + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + virtual + vtkImplicitFunction* + GetImplicitFunction(); + + virtual + void + SetExtractInside(bool theMode); + + virtual + void + SetExtractBoundaryCells(bool theMode); + + //---------------------------------------------------------------------------- + // Clipping planes + virtual + void + RemoveAllClippingPlanes(); + + virtual + vtkIdType + GetNumberOfClippingPlanes(); + + virtual + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID); + +protected: + //---------------------------------------------------------------------------- + VISU_DataSetMapperHolder(); + VISU_DataSetMapperHolder(const VISU_DataSetMapperHolder&); + + virtual + ~VISU_DataSetMapperHolder(); + + //---------------------------------------------------------------------------- + virtual + void + OnCreateMapper(); + + void + SetDataSetMapper(vtkDataSetMapper* theMapper); + + //---------------------------------------------------------------------------- + virtual + void + SetLookupTable(VISU_LookupTable* theLookupTable); + + virtual + vtkDataSet* + GetClippedInput(); + +private: + //---------------------------------------------------------------------------- + VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper; + vtkSmartPointer myDataSetMapper; + vtkSmartPointer myExtractGeometry; //!< Clipping +}; + +#endif diff --git a/src/PIPELINE/VISU_DeformedShapePL.cxx b/src/PIPELINE/VISU_DeformedShapePL.cxx index b1817198..5c1a629e 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.cxx +++ b/src/PIPELINE/VISU_DeformedShapePL.cxx @@ -31,25 +31,32 @@ #include + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_DeformedShapePL); + +//---------------------------------------------------------------------------- VISU_DeformedShapePL -::VISU_DeformedShapePL() +::VISU_DeformedShapePL(): + myScaleFactor(0.0) { myWarpVector = vtkWarpVector::New(); myCellDataToPointData = vtkCellDataToPointData::New(); } + +//---------------------------------------------------------------------------- VISU_DeformedShapePL ::~VISU_DeformedShapePL() { - myWarpVector->UnRegisterAllOutputs(); myWarpVector->Delete(); - myCellDataToPointData->UnRegisterAllOutputs(); myCellDataToPointData->Delete(); } + +//---------------------------------------------------------------------------- void VISU_DeformedShapePL ::DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -58,18 +65,25 @@ VISU_DeformedShapePL if(VISU_DeformedShapePL *aPipeLine = dynamic_cast(thePipeLine)){ SetScale(aPipeLine->GetScale()); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_DeformedShapePL ::GetScaleFactor(vtkDataSet* theDataSet) { - if(!theDataSet) return 0.0; + 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){ @@ -80,19 +94,24 @@ VISU_DeformedShapePL } } aVolume /= aNbElem; - return pow(aVolume,vtkFloatingPointType(1.0/idim)); + return pow(aVolume, vtkFloatingPointType(1.0/idim)); } +//---------------------------------------------------------------------------- void VISU_DeformedShapePL ::SetScale(vtkFloatingPointType theScale) { + if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale)) + return; + myWarpVector->SetScaleFactor(theScale); myScaleFactor = theScale; - Modified(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_DeformedShapePL ::GetScale() @@ -100,16 +119,18 @@ VISU_DeformedShapePL return myScaleFactor; } + //---------------------------------------------------------------------------- void VISU_DeformedShapePL ::Init() { Superclass::Init(); + vtkFloatingPointType aScalarRange[2]; GetSourceRange(aScalarRange); - vtkDataSet* aDataSet = GetInput2(); + vtkDataSet* aDataSet = GetClippedInput(); vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); static double EPS = 1.0 / VTK_LARGE_FLOAT; @@ -119,22 +140,19 @@ VISU_DeformedShapePL SetScale(0.0); } + //---------------------------------------------------------------------------- -VISU_ScalarMapPL::THook* +vtkDataSet* VISU_DeformedShapePL -::DoHook() +::InsertCustomPL() { - VISU::CellDataToPoint(myWarpVector,myCellDataToPointData,GetInput2(),myFieldTransform); + VISU::CellDataToPoint(myWarpVector, + myCellDataToPointData, + GetClippedInput(), + GetFieldTransformFilter()); return myWarpVector->GetOutput(); } -//---------------------------------------------------------------------------- -void -VISU_DeformedShapePL -::Update() -{ - Superclass::Update(); -} //---------------------------------------------------------------------------- unsigned long int @@ -164,5 +182,7 @@ VISU_DeformedShapePL Superclass::SetMapScale(theMapScale); myWarpVector->SetScaleFactor(myScaleFactor*theMapScale); - Modified(); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_DeformedShapePL.hxx b/src/PIPELINE/VISU_DeformedShapePL.hxx index 3c9e6875..456429f4 100644 --- a/src/PIPELINE/VISU_DeformedShapePL.hxx +++ b/src/PIPELINE/VISU_DeformedShapePL.hxx @@ -55,10 +55,6 @@ public: void Init(); - virtual - void - Update(); - //! Gets memory size used by the instance (bytes). virtual unsigned long int @@ -80,8 +76,8 @@ protected: ~VISU_DeformedShapePL(); virtual - THook* - DoHook(); + vtkDataSet* + InsertCustomPL(); virtual void diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index f57c5219..3dbb7bab 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -45,11 +45,13 @@ VISU_Extractor myScalarMode = 1; } + //---------------------------------------------------------------------------- VISU_Extractor ::~VISU_Extractor() {} + //---------------------------------------------------------------------------- void VISU_Extractor @@ -61,6 +63,14 @@ VISU_Extractor } } +//---------------------------------------------------------------------------- +int +VISU_Extractor +::GetScalarMode() +{ + return myScalarMode; +} + //---------------------------------------------------------------------------- template @@ -148,7 +158,9 @@ ExecuteScalars(vtkIdType theNbOfTuples, //---------------------------------------------------------------------------- -void VISU_Extractor::Execute() +void +VISU_Extractor +::Execute() { vtkDataSet *input = this->GetInput(), *output = this->GetOutput(); output->CopyStructure(input); diff --git a/src/PIPELINE/VISU_Extractor.hxx b/src/PIPELINE/VISU_Extractor.hxx index 797f9af1..22bcf9e0 100644 --- a/src/PIPELINE/VISU_Extractor.hxx +++ b/src/PIPELINE/VISU_Extractor.hxx @@ -27,22 +27,36 @@ #ifndef VISU_Extractor_HeaderFile #define VISU_Extractor_HeaderFile -#include +#include -class VTK_EXPORT VISU_Extractor : public vtkPointSetToPointSetFilter{ + +//---------------------------------------------------------------------------- +class VTK_EXPORT VISU_Extractor : public vtkDataSetToDataSetFilter +{ public: - vtkTypeMacro(VISU_Extractor,vtkPointSetToPointSetFilter); - static VISU_Extractor *New(); + vtkTypeMacro(VISU_Extractor, vtkDataSetToDataSetFilter); + + static + VISU_Extractor + *New(); - virtual int GetScalarMode(){ return myScalarMode;} - virtual void SetScalarMode(int theScalarMode = 0); + virtual + int + GetScalarMode(); + + virtual + void + SetScalarMode(int theScalarMode = 0); protected: VISU_Extractor(); VISU_Extractor(const VISU_Extractor&); + ~VISU_Extractor(); - virtual void Execute(); + virtual + void + Execute(); int myScalarMode; }; diff --git a/src/PIPELINE/VISU_FieldTransform.hxx b/src/PIPELINE/VISU_FieldTransform.hxx index f84e0b4d..d490a7ab 100644 --- a/src/PIPELINE/VISU_FieldTransform.hxx +++ b/src/PIPELINE/VISU_FieldTransform.hxx @@ -39,29 +39,69 @@ public: vtkTypeMacro(VISU_FieldTransform,vtkDataSetToDataSetFilter); static VISU_FieldTransform *New(); - virtual void Update(); - virtual unsigned long GetMTime(); + virtual + void + Update(); + + virtual + unsigned long + GetMTime(); - static double Ident(double theArg); - static double Log10(double theArg); + static + double + Ident(double theArg); + + static + double + Log10(double theArg); + typedef double (*TTransformFun)(double); - void SetScalarTransform(TTransformFun theFunction); - TTransformFun GetScalarTransform() { return myFunction;} - void SetSpaceTransform(VTKViewer_Transform* theTransform); - VTKViewer_Transform* GetSpaceTransform() { return myTransform;} + void + SetScalarTransform(TTransformFun theFunction); + + TTransformFun + GetScalarTransform() + { + return myFunction; + } + + void + SetSpaceTransform(VTKViewer_Transform* theTransform); + + VTKViewer_Transform* + GetSpaceTransform() + { + return myTransform; + } - vtkFloatingPointType* GetScalarRange(){ return myScalarRange; } - void SetScalarRange(vtkFloatingPointType theScalarRange[2]); - void SetScalarMin(vtkFloatingPointType theValue); - void SetScalarMax(vtkFloatingPointType theValue); + vtkFloatingPointType* + GetScalarRange() + { + return myScalarRange; + } + + void + SetScalarRange(vtkFloatingPointType theScalarRange[2]); + + void + SetScalarMin(vtkFloatingPointType theValue); + + void + SetScalarMax(vtkFloatingPointType theValue); protected: VISU_FieldTransform(); - virtual ~VISU_FieldTransform(); + + virtual + ~VISU_FieldTransform(); + VISU_FieldTransform(const VISU_FieldTransform&) {}; void operator=(const VISU_FieldTransform&) {}; - void Execute(); + + virtual + void + Execute(); VTKViewer_Transform *myTransform; TTransformFun myFunction; diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index f30f0553..a694e122 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -27,12 +27,13 @@ #include "VISU_GaussPointsPL.hxx" -#include "VISU_DeformedShapePL.hxx" -#include "VISU_PipeLineUtils.hxx" -#include "SALOME_ExtractGeometry.h" -#include "VISU_DeformedShapePL.hxx" +#include "VISU_PointSpriteMapperHolder.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VTKViewer_PassThroughFilter.h" +#include "VISU_DeformedShapePL.hxx" +#include "VISU_LookupTable.hxx" + +#include "VISU_PipeLineUtils.hxx" #include #include @@ -50,18 +51,9 @@ vtkStandardNewMacro(VISU_GaussPointsPL); //---------------------------------------------------------------------------- VISU_GaussPointsPL ::VISU_GaussPointsPL(): - myIsDeformed(false), myScaleFactor(0.0), myMagnificationIncrement(2) { - myExtractGeometry->SetExtractInside(0); - - myPSMapper = VISU_OpenGLPointSpriteMapper::New(); - myPSMapper->SetColorModeToMapScalars(); - myPSMapper->ScalarVisibilityOn(); - - myGeomFilter = vtkGeometryFilter::New(); - myWarpVector = vtkWarpVector::New(); myGlyph = vtkGlyph3D::New(); @@ -69,9 +61,6 @@ VISU_GaussPointsPL myGlyph->SetColorModeToColorByScalar(); myGlyph->ClampingOn(); - myExtractor->SetInput( myExtractGeometry->GetOutput() ); - myFieldTransform->SetInput( myExtractor->GetOutput() ); - mySphereSource = vtkSphereSource::New(); mySphereSource->SetThetaResolution( 8 ); mySphereSource->SetPhiResolution( 8 ); @@ -79,18 +68,6 @@ VISU_GaussPointsPL for(int i = 0; i < 3; i++) myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); - - // Deformed Shape - myPassFilter[0]->SetInput(myFieldTransform->GetUnstructuredGridOutput()); - - myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); - - myGeomFilter->SetInput( myPassFilter[1]->GetOutput() ); - - // Geometrical Sphere - myPassFilter[2]->SetInput(myGeomFilter->GetOutput()); - - myPSMapper->SetInput( myPassFilter[2]->GetPolyDataOutput() ); } @@ -98,17 +75,6 @@ VISU_GaussPointsPL VISU_GaussPointsPL ::~VISU_GaussPointsPL() { - if (this->myPSMapper) - { - this->myPSMapper->Delete(); - this->myPSMapper = NULL; - } - if (this->myGeomFilter) - { - this->myGeomFilter->Delete(); - this->myGeomFilter = NULL; - } - myWarpVector->Delete(); myGlyph->Delete(); @@ -121,12 +87,52 @@ VISU_GaussPointsPL //---------------------------------------------------------------------------- -unsigned long int +void +VISU_GaussPointsPL +::OnCreateMapperHolder() +{ + myPointSpriteMapperHolder = VISU_PointSpriteMapperHolder::New(); + myPointSpriteMapperHolder->Delete(); + + SetMapperHolder(myPointSpriteMapperHolder.GetPointer()); +} + + +//---------------------------------------------------------------------------- +void +VISU_GaussPointsPL +::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper) +{ + GetPointSpriteMapperHolder()->SetGaussPtsIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PGaussPtsIDMapper& +VISU_GaussPointsPL +::GetGaussPtsIDMapper() +{ + return GetPointSpriteMapperHolder()->GetGaussPtsIDMapper(); +} + + +//---------------------------------------------------------------------------- +VISU_PointSpriteMapperHolder* VISU_GaussPointsPL -::GetMTime() +::GetPointSpriteMapperHolder() { - unsigned long int aTime = std::max(Superclass::GetMTime(), myPSMapper->GetMTime()); - return aTime; + GetMapperHolder(); + + return myPointSpriteMapperHolder.GetPointer(); +} + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_GaussPointsPL +::GetParentMesh() +{ + VISU::TNamedIDMapper* aNamedIDMapper = GetGaussPtsIDMapper()->GetParent(); + return aNamedIDMapper->GetOutput(); } //---------------------------------------------------------------------------- @@ -173,57 +179,29 @@ VISU_GaussPointsPL CopyGlyph( aPipeLine->myGlyph, this->myGlyph ); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } //---------------------------------------------------------------------------- -void +VISU_OpenGLPointSpriteMapper* VISU_GaussPointsPL -::DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) +::GetPointSpriteMapper() { - if(VISU_GaussPointsPL* aPipeLine = dynamic_cast(thePipeLine)){ - if(theIsCopyInput) - SetGaussPtsIDMapper(aPipeLine->GetGaussPtsIDMapper()); - Update(); - VISU::CopyPointSpriteDataMapper(GetPSMapper(), - aPipeLine->GetPSMapper(), - theIsCopyInput); - } + return GetPointSpriteMapperHolder()->GetPointSpriteMapper(); } //---------------------------------------------------------------------------- -VISU_PipeLine::TMapper* -VISU_GaussPointsPL -::GetMapper() -{ - return GetPSMapper(); -} - -VISU_OpenGLPointSpriteMapper* -VISU_GaussPointsPL -::GetPSMapper() -{ - if(GetInput()){ - if(!myPSMapper->GetInput()){ - GetInput2()->Update(); - Build(); - Init(); - } - myPSMapper->Update(); - } - return myPSMapper; -} - vtkPolyData* VISU_GaussPointsPL ::GetPickableDataSet() { - return myGeomFilter->GetOutput(); + return myPassFilter[1]->GetPolyDataOutput(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -231,6 +209,8 @@ VISU_GaussPointsPL { Superclass::Init(); + SetExtractInside(false); + vtkDataSet* aDataSet = GetParentMesh(); vtkFloatingPointType aScaleFactor = VISU_DeformedShapePL::GetScaleFactor( aDataSet ); @@ -242,56 +222,58 @@ VISU_GaussPointsPL SetScale(0.0); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Build() -{} +{ + Superclass::Build(); + + // Deformed Shape + myPassFilter[0]->SetInput(GetFieldTransformFilter()->GetOutput()); + + myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); + + // Geometrical Sphere + myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput()); + + GetPointSpriteMapper()->SetInput( myPassFilter[2]->GetPolyDataOutput() ); + + // Update according the current state + SetIsDeformed(GetIsDeformed()); + + SetPrimitiveType(GetPrimitiveType()); +} + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::Update() { - //cout << "VISU_GaussPointsPL::Update()" << endl; - vtkFloatingPointType* aScalarRange = GetScalarRange(); - mySourceScalarRange[0] = aScalarRange[0]; - mySourceScalarRange[1] = aScalarRange[1]; - myDeltaScalarRange = aScalarRange[1] - aScalarRange[0]; - SetAverageCellSize( VISU_DeformedShapePL::GetScaleFactor( GetParentMesh() ) ); - vtkMapper* aMapper = GetMapper(); - vtkDataSet* aDataSet = aMapper->GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - myScalarArray = aCellData->GetScalars(); - - myPSMapper->SetLookupTable( myMapperTable ); - if(!VISU::CheckIsSameRange(myPSMapper->GetScalarRange(), aScalarRange)) - myPSMapper->SetScalarRange( aScalarRange ); - this->UpdateGlyph(); Superclass::Update(); } + //---------------------------------------------------------------------------- unsigned long int VISU_GaussPointsPL ::GetMemorySize() { - vtkDataSet* aDataSet = myGeomFilter->GetOutput(); - unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024; + unsigned long int aSize = 0; - if(GetIsDeformed()){ - aDataSet = myWarpVector->GetOutput(); - aSize += aDataSet->GetActualMemorySize() * 1024; - } + if(GetIsDeformed()) + if(vtkDataSet* aDataSet = myWarpVector->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; - if(GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere){ - aDataSet = myGlyph->GetOutput(); - aSize += aDataSet->GetActualMemorySize() * 1024; - } + if(GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere) + if(vtkDataSet* aDataSet = myGlyph->GetOutput()) + aSize += aDataSet->GetActualMemorySize() * 1024; return aSize; } @@ -304,7 +286,7 @@ VISU_GaussPointsPL { vtkFloatingPointType* aScalarRange = GetScalarRange(); - if( myPSMapper->GetPointSpriteMode() == 0 ) // Results + if( GetPointSpriteMapper()->GetPointSpriteMode() == 0 ) // Results { myGlyph->ClampingOn(); myGlyph->SetScaleModeToScaleByScalar(); @@ -326,7 +308,7 @@ VISU_GaussPointsPL myGlyph->SetScaleFactor( 1.0 ); } } - else if( myPSMapper->GetPointSpriteMode() == 1 ) // Geometry + else if( GetPointSpriteMapper()->GetPointSpriteMode() == 1 ) // Geometry { myGlyph->ClampingOff(); myGlyph->SetScaleModeToDataScalingOff(); @@ -336,7 +318,7 @@ VISU_GaussPointsPL if(!VISU::CheckIsSameValue(myGlyph->GetScaleFactor(), aScaleFactor)) myGlyph->SetScaleFactor( aScaleFactor ); } - else if( myPSMapper->GetPointSpriteMode() == 2 ) // Outside + else if( GetPointSpriteMapper()->GetPointSpriteMode() == 2 ) // Outside { myGlyph->ClampingOff(); myGlyph->SetScaleModeToDataScalingOff(); @@ -352,71 +334,37 @@ VISU_GaussPointsPL mySphereSource->SetRadius( aRadius ); } + //---------------------------------------------------------------------------- VISU::TGaussPointID VISU_GaussPointsPL -::GetObjID(vtkIdType theID) const +::GetObjID(vtkIdType theID) { - return myGaussPtsIDMapper->GetObjID(theID); + return GetGaussPtsIDMapper()->GetObjID(theID); } -vtkFloatingPointType* -VISU_GaussPointsPL -::GetNodeCoord(int theObjID) -{ - vtkIdType anID = GetNodeVTKID(theObjID); - vtkDataSet* aDataSet = myGeomFilter->GetInput(); - return aDataSet->GetPoint(anID); -} - -void -VISU_GaussPointsPL -::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper) -{ - myGaussPtsIDMapper = theGaussPtsIDMapper; - SetIDMapper(myGaussPtsIDMapper); -} - -const VISU::PGaussPtsIDMapper& -VISU_GaussPointsPL -::GetGaussPtsIDMapper() const -{ - return myGaussPtsIDMapper; -} - -VISU::TVTKOutput* -VISU_GaussPointsPL -::GetParentMesh() const -{ - VISU::TNamedIDMapper* aNamedIDMapper = myGaussPtsIDMapper->GetParent(); - return aNamedIDMapper->GetVTKOutput(); -} //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetIsDeformed( bool theIsDeformed ) { - if( GetIsDeformed() == theIsDeformed ) + if(GetIsDeformed() == theIsDeformed) return; - if( theIsDeformed ) - { + if(theIsDeformed){ myWarpVector->SetInput( myPassFilter[0]->GetUnstructuredGridOutput() ); myPassFilter[1]->SetInput(myWarpVector->GetOutput()); - } - else + }else myPassFilter[1]->SetInput(myPassFilter[0]->GetOutput()); - - myIsDeformed = theIsDeformed; } //---------------------------------------------------------------------------- bool VISU_GaussPointsPL -::GetIsDeformed() const +::GetIsDeformed() { - return myIsDeformed; + return myPassFilter[1]->GetInput() != myPassFilter[0]->GetOutput(); } //---------------------------------------------------------------------------- @@ -427,8 +375,8 @@ VISU_GaussPointsPL if(GetBicolor() == theBicolor) return; - myMapperTable->SetBicolor( theBicolor ); - myBarTable->SetBicolor( theBicolor ); + GetMapperTable()->SetBicolor( theBicolor ); + GetBarTable()->SetBicolor( theBicolor ); } //---------------------------------------------------------------------------- @@ -436,7 +384,7 @@ bool VISU_GaussPointsPL ::GetBicolor() { - return myMapperTable->GetBicolor(); + return GetMapperTable()->GetBicolor(); } //---------------------------------------------------------------------------- @@ -444,7 +392,7 @@ void VISU_GaussPointsPL ::SetIsColored(bool theIsColored) { - myPSMapper->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry + GetPointSpriteMapper()->SetPointSpriteMode( theIsColored ? 0 : 1 ); // Results / Geometry } //---------------------------------------------------------------------------- @@ -452,7 +400,7 @@ bool VISU_GaussPointsPL ::GetIsColored() { - return myPSMapper->GetPointSpriteMode() == 0; + return GetPointSpriteMapper()->GetPointSpriteMode() == 0; } //---------------------------------------------------------------------------- @@ -465,45 +413,49 @@ VISU_GaussPointsPL if( thePrimitiveType == VISU_OpenGLPointSpriteMapper::GeomSphere ) { - myGlyph->SetInput( myGeomFilter->GetOutput() ); + myGlyph->SetInput( myPassFilter[1]->GetOutput() ); myPassFilter[2]->SetInput(myGlyph->GetOutput()); } else - myPassFilter[2]->SetInput(myGeomFilter->GetOutput()); + myPassFilter[2]->SetInput(myPassFilter[1]->GetOutput()); - myPSMapper->SetPrimitiveType( thePrimitiveType ); + GetPointSpriteMapper()->SetPrimitiveType( thePrimitiveType ); } + //---------------------------------------------------------------------------- int VISU_GaussPointsPL ::GetPrimitiveType() { - return myPSMapper->GetPrimitiveType(); + return GetPointSpriteMapper()->GetPrimitiveType(); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetMaximumSupportedSize() { - return myPSMapper->GetMaximumSupportedSize(); + return GetPointSpriteMapper()->GetMaximumSupportedSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetClamp(vtkFloatingPointType theClamp) { - myPSMapper->SetPointSpriteClamp( theClamp ); + GetPointSpriteMapper()->SetPointSpriteClamp( theClamp ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetClamp() { - return myPSMapper->GetPointSpriteClamp(); + return GetPointSpriteMapper()->GetPointSpriteClamp(); } //---------------------------------------------------------------------------- @@ -511,65 +463,73 @@ void VISU_GaussPointsPL ::SetSize(vtkFloatingPointType theSize) { - myPSMapper->SetPointSpriteSize( theSize ); + GetPointSpriteMapper()->SetPointSpriteSize( theSize ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetSize() { - return myPSMapper->GetPointSpriteSize(); + return GetPointSpriteMapper()->GetPointSpriteSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetMinSize(vtkFloatingPointType theMinSize) { - myPSMapper->SetPointSpriteMinSize( theMinSize ); + GetPointSpriteMapper()->SetPointSpriteMinSize( theMinSize ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetMinSize() { - return myPSMapper->GetPointSpriteMinSize(); + return GetPointSpriteMapper()->GetPointSpriteMinSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetMaxSize(vtkFloatingPointType theMaxSize) { - myPSMapper->SetPointSpriteMaxSize( theMaxSize ); + GetPointSpriteMapper()->SetPointSpriteMaxSize( theMaxSize ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetMaxSize() { - return myPSMapper->GetPointSpriteMaxSize(); + return GetPointSpriteMapper()->GetPointSpriteMaxSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetMagnification(vtkFloatingPointType theMagnification) { - myPSMapper->SetPointSpriteMagnification( theMagnification ); + GetPointSpriteMapper()->SetPointSpriteMagnification( theMagnification ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetMagnification() { - return myPSMapper->GetPointSpriteMagnification(); + return GetPointSpriteMapper()->GetPointSpriteMagnification(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -582,22 +542,25 @@ VISU_GaussPointsPL Modified(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetAlphaThreshold(vtkFloatingPointType theAlphaThreshold) { - myPSMapper->SetPointSpriteAlphaThreshold( theAlphaThreshold ); + GetPointSpriteMapper()->SetPointSpriteAlphaThreshold( theAlphaThreshold ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetAlphaThreshold() { - return myPSMapper->GetPointSpriteAlphaThreshold(); + return GetPointSpriteMapper()->GetPointSpriteAlphaThreshold(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -607,6 +570,7 @@ VISU_GaussPointsPL mySphereSource->SetPhiResolution( theResolution ); } + //---------------------------------------------------------------------------- int VISU_GaussPointsPL @@ -615,6 +579,7 @@ VISU_GaussPointsPL return mySphereSource->GetThetaResolution(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL @@ -624,6 +589,7 @@ VISU_GaussPointsPL SetMagnification( GetMagnification() * anIncrement ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL @@ -634,9 +600,13 @@ VISU_GaussPointsPL vtkFloatingPointType aDelta = aMaxSize - aMinSize; vtkFloatingPointType aVal = theScalarArray->GetTuple1(theID); - return aMinSize + aDelta*(aVal - mySourceScalarRange[0])/myDeltaScalarRange; + vtkFloatingPointType* aScalarRange = GetScalarRange(); + vtkFloatingPointType aDeltaScalarRange = aScalarRange[1] - aScalarRange[0]; + + return aMinSize + aDelta*(aVal - aScalarRange[0]) / aDeltaScalarRange; } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL @@ -645,6 +615,7 @@ VISU_GaussPointsPL return GetAverageCellSize() * GetMaxSize(); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL @@ -652,35 +623,39 @@ VISU_GaussPointsPL { vtkMapper* aMapper = GetMapper(); vtkDataSet* aDataSet = aMapper->GetInput(); - vtkCellData* aCellData = aDataSet->GetCellData(); - vtkDataArray* aScalarArray = aCellData->GetScalars(); + vtkPointData* aPointData = aDataSet->GetPointData(); + vtkDataArray* aScalarArray = aPointData->GetScalars(); return GetPointSize(theID, aScalarArray); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetAverageCellSize(vtkFloatingPointType theAverageCellSize) { - myPSMapper->SetAverageCellSize( theAverageCellSize ); + GetPointSpriteMapper()->SetAverageCellSize( theAverageCellSize ); } + //---------------------------------------------------------------------------- vtkFloatingPointType VISU_GaussPointsPL ::GetAverageCellSize() { - return myPSMapper->GetAverageCellSize(); + return GetPointSpriteMapper()->GetAverageCellSize(); } + //---------------------------------------------------------------------------- void VISU_GaussPointsPL ::SetImageData(vtkImageData* theImageData) { - myPSMapper->SetImageData( theImageData ); + GetPointSpriteMapper()->SetImageData( theImageData ); } + //---------------------------------------------------------------------------- vtkSmartPointer VISU_GaussPointsPL @@ -743,7 +718,10 @@ VISU_GaussPointsPL return aCompositeImageData; } -void VISU_GaussPointsPL::SetScale( vtkFloatingPointType theScale ) + +void +VISU_GaussPointsPL +::SetScale( vtkFloatingPointType theScale ) { if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), theScale)) return; @@ -752,15 +730,24 @@ void VISU_GaussPointsPL::SetScale( vtkFloatingPointType theScale ) myScaleFactor = theScale; } -vtkFloatingPointType VISU_GaussPointsPL::GetScale() + +vtkFloatingPointType +VISU_GaussPointsPL +::GetScale() { return myWarpVector->GetScaleFactor(); } -void VISU_GaussPointsPL::SetMapScale( vtkFloatingPointType theMapScale ) + +void +VISU_GaussPointsPL +::SetMapScale( vtkFloatingPointType theMapScale ) { Superclass::SetMapScale( theMapScale ); - myWarpVector->SetScaleFactor( myScaleFactor * theMapScale ); - Modified(); + vtkFloatingPointType aMapScale = myScaleFactor * theMapScale; + if(VISU::CheckIsSameValue(myWarpVector->GetScaleFactor(), aMapScale)) + return; + + myWarpVector->SetScaleFactor( aMapScale ); } diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index 158342d2..a1a3913b 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -28,13 +28,13 @@ #ifndef VISU_GaussPointsPL_HeaderFile #define VISU_GaussPointsPL_HeaderFile -#include "VISU_ScalarMapPL.hxx" -#include "VISU_Convertor.hxx" +#include "VISU_ColoredPL.hxx" #include class VTKViewer_PassThroughFilter; class VISU_OpenGLPointSpriteMapper; +class VISU_PointSpriteMapperHolder; class vtkGeometryFilter; class vtkGlyph3D; @@ -46,46 +46,50 @@ class vtkPointSet; class vtkWarpVector; class SALOME_Transform; + +//---------------------------------------------------------------------------- //! Pipeline for the Gauss Points presentation. /*! * This class uses the special mapper (VISU_OpenGLPointSpriteMapper) * for rendering the Gauss Points as Point Sprites. */ -class VISU_GaussPointsPL : public VISU_ScalarMapPL +class VISU_GaussPointsPL : public VISU_ColoredPL { public: - vtkTypeMacro(VISU_GaussPointsPL,VISU_ScalarMapPL); + //---------------------------------------------------------------------------- + vtkTypeMacro(VISU_GaussPointsPL, VISU_ColoredPL); static - VISU_GaussPointsPL* New(); + VISU_GaussPointsPL* + New(); - virtual - unsigned long int - GetMTime(); + //---------------------------------------------------------------------------- + void + SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper); - //! Get the native mapper. - virtual - TMapper* - GetMapper(); + const VISU::PGaussPtsIDMapper& + GetGaussPtsIDMapper(); + + VISU_PointSpriteMapperHolder* + GetPointSpriteMapperHolder(); //! Get the internal #VISU_OpenGLPointSpriteMapper. VISU_OpenGLPointSpriteMapper* - GetPSMapper(); + GetPointSpriteMapper(); + + vtkDataSet* + GetParentMesh(); //! Get an intermediate dataset that can be picked vtkPolyData* GetPickableDataSet(); + //---------------------------------------------------------------------------- //! Redefined method for initialization of the pipeline. virtual void Init(); - //! Redefined method for building the pipeline. - virtual - void - Build(); - //! Redefined method for updating the pipeline. virtual void @@ -96,26 +100,14 @@ public: unsigned long int GetMemorySize(); + //---------------------------------------------------------------------------- //! Update glyph. void UpdateGlyph(); virtual VISU::TGaussPointID - GetObjID(vtkIdType theID) const; - - virtual - vtkFloatingPointType* - GetNodeCoord(vtkIdType theObjID); - - void - SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper); - - const VISU::PGaussPtsIDMapper& - GetGaussPtsIDMapper() const; - - VISU::TVTKOutput* - GetParentMesh() const; + GetObjID(vtkIdType theID); //! Set the Bicolor mode. /*! @@ -257,13 +249,14 @@ public: const char* theAlphaTexture ); public: + //---------------------------------------------------------------------------- virtual void SetIsDeformed( bool theIsDeformed ); virtual bool - GetIsDeformed() const; + GetIsDeformed(); virtual void @@ -278,6 +271,7 @@ public: SetMapScale( vtkFloatingPointType theMapScale = 1.0 ); protected: + //---------------------------------------------------------------------------- VISU_GaussPointsPL(); virtual @@ -285,32 +279,27 @@ protected: virtual void - DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); + OnCreateMapperHolder(); virtual void - DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); + Build(); - bool myIsDeformed; + virtual + void + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + +private: + //---------------------------------------------------------------------------- vtkFloatingPointType myScaleFactor; vtkWarpVector *myWarpVector; std::vector myPassFilter; + vtkSmartPointer myPointSpriteMapperHolder; vtkGlyph3D* myGlyph; vtkSphereSource* mySphereSource; - VISU_OpenGLPointSpriteMapper* myPSMapper; - VISU::PGaussPtsIDMapper myGaussPtsIDMapper; - - vtkGeometryFilter* myGeomFilter; - - vtkDataArray *myScalarArray; - vtkFloatingPointType mySourceScalarRange[2]; - vtkFloatingPointType myDeltaScalarRange; - - int myPrimitiveType; vtkFloatingPointType myMagnificationIncrement; }; diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.cxx b/src/PIPELINE/VISU_IsoSurfacesPL.cxx index 8c8b4cca..99cdc081 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.cxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.cxx @@ -27,30 +27,42 @@ #include "VISU_IsoSurfacesPL.hxx" +#include "VISU_LookupTable.hxx" + #include "VISU_PipeLineUtils.hxx" #include + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_IsoSurfacesPL); + +//---------------------------------------------------------------------------- VISU_IsoSurfacesPL ::VISU_IsoSurfacesPL() { + SetIsShrinkable(false); + myContourFilter = vtkContourFilter::New(); + myCellDataToPointData = vtkCellDataToPointData::New(); - myIsShrinkable = false; } + +//---------------------------------------------------------------------------- VISU_IsoSurfacesPL ::~VISU_IsoSurfacesPL() { - myContourFilter->UnRegisterAllOutputs(); myContourFilter->Delete(); + myContourFilter = NULL; - myCellDataToPointData->UnRegisterAllOutputs(); myCellDataToPointData->Delete(); + myCellDataToPointData = NULL; } + +//---------------------------------------------------------------------------- void VISU_IsoSurfacesPL ::DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -61,15 +73,21 @@ VISU_IsoSurfacesPL vtkFloatingPointType aRange[2] = {aPipeLine->GetMin(), aPipeLine->GetMax()}; SetRange(aRange); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } + +//---------------------------------------------------------------------------- int VISU_IsoSurfacesPL ::GetNbParts() { return myContourFilter->GetNumberOfContours(); } + + +//---------------------------------------------------------------------------- void VISU_IsoSurfacesPL ::SetNbParts(int theNb) @@ -79,27 +97,33 @@ VISU_IsoSurfacesPL } +//---------------------------------------------------------------------------- void VISU_IsoSurfacesPL -::SetScaling(int theScaling) +::SetScalarRange(vtkFloatingPointType theRange[2]) { - Superclass::SetScaling(theScaling); + Superclass::SetScalarRange(theRange); SetRange(myRange); } + + +//---------------------------------------------------------------------------- void VISU_IsoSurfacesPL ::SetRange(vtkFloatingPointType theRange[2]) { if(theRange[0] <= theRange[1]){ - myRange[0] = theRange[0]; myRange[1] = theRange[1]; - vtkFloatingPointType aRange[2] = {myRange[0], myRange[1]}; + myRange[0] = theRange[0]; + myRange[1] = theRange[1]; + vtkFloatingPointType aRange[2] = {theRange[0], theRange[1]}; if(GetScaling() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(theRange,aRange); - myContourFilter->GenerateValues(GetNbParts(),aRange); - Modified(); + VISU_LookupTable::ComputeLogRange(theRange, aRange); + myContourFilter->GenerateValues(GetNbParts(), aRange); } } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_IsoSurfacesPL ::GetMin() @@ -107,6 +131,8 @@ VISU_IsoSurfacesPL return myRange[0]; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_IsoSurfacesPL ::GetMax() @@ -116,26 +142,34 @@ VISU_IsoSurfacesPL void +//---------------------------------------------------------------------------- VISU_IsoSurfacesPL ::Init() { Superclass::Init(); SetNbParts(10); + vtkFloatingPointType aScalarRange[2]; GetSourceRange(aScalarRange); SetRange(aScalarRange); } -VISU_ScalarMapPL::THook* +//---------------------------------------------------------------------------- + +vtkDataSet* VISU_IsoSurfacesPL -::DoHook() +::InsertCustomPL() { - VISU::CellDataToPoint(myContourFilter,myCellDataToPointData,GetInput2(),myFieldTransform); + VISU::CellDataToPoint(myContourFilter, + myCellDataToPointData, + GetClippedInput(), + GetFieldTransformFilter()); return myContourFilter->GetOutput(); } +//---------------------------------------------------------------------------- void VISU_IsoSurfacesPL ::Update() @@ -143,6 +177,7 @@ VISU_IsoSurfacesPL Superclass::Update(); } + //---------------------------------------------------------------------------- unsigned long int VISU_IsoSurfacesPL @@ -173,6 +208,8 @@ VISU_IsoSurfacesPL vtkFloatingPointType aNewRange[2] = {aRange[0], aRange[1]}; if(GetScaling() == VTK_SCALE_LOG10) VISU_LookupTable::ComputeLogRange(aRange,aNewRange); - myContourFilter->GenerateValues(GetNbParts(),aNewRange); - Modified(); + myContourFilter->GenerateValues(GetNbParts(), aNewRange); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_IsoSurfacesPL.hxx b/src/PIPELINE/VISU_IsoSurfacesPL.hxx index 10a0be3f..207dee8b 100644 --- a/src/PIPELINE/VISU_IsoSurfacesPL.hxx +++ b/src/PIPELINE/VISU_IsoSurfacesPL.hxx @@ -32,10 +32,12 @@ class vtkContourFilter; class vtkCellDataToPointData; + +//---------------------------------------------------------------------------- class VISU_IsoSurfacesPL : public VISU_ScalarMapPL { public: - vtkTypeMacro(VISU_IsoSurfacesPL,VISU_ScalarMapPL); + vtkTypeMacro(VISU_IsoSurfacesPL, VISU_ScalarMapPL); static VISU_IsoSurfacesPL* @@ -51,7 +53,7 @@ public: virtual void - SetScaling(int theScaling = VTK_SCALE_LINEAR); + SetScalarRange(vtkFloatingPointType theRange[2]); virtual void @@ -80,8 +82,8 @@ public: GetMemorySize(); virtual - THook* - DoHook(); + vtkDataSet* + InsertCustomPL(); virtual void diff --git a/src/PIPELINE/VISU_MapperHolder.cxx b/src/PIPELINE/VISU_MapperHolder.cxx new file mode 100644 index 00000000..857daad9 --- /dev/null +++ b/src/PIPELINE/VISU_MapperHolder.cxx @@ -0,0 +1,252 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_MapperHolder.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_MapperHolder.hxx" +#include "VISU_PipeLine.hxx" + +#include "VISU_PipeLineUtils.hxx" + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +VISU_MapperHolder +::VISU_MapperHolder(): + myPipeLine(NULL) +{ + if(MYDEBUG) + MESSAGE("VISU_MapperHolder::VISU_MapperHolder - "<GetIDMapper()); + + VISU::CopyMapper(GetMapper(), + theMapperHolder->GetMapper(), + theIsCopyInput); +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_MapperHolder +::GetMemorySize() +{ + unsigned long int aSize = 0; + + if(myMapper.GetPointer()) + if(vtkDataSet* aDataSet = myMapper->GetInput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + + if(myIDMapper) + aSize += myIDMapper->GetMemorySize(); + + return aSize; +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_MapperHolder +::GetMTime() +{ + unsigned long int aTime = Superclass::GetMTime(); + + if(myIDMapper) + if(vtkDataSet* aDataSet = myIDMapper->GetOutput()) + aTime = std::max(aTime, aDataSet->GetMTime()); + + if(myMapper.GetPointer()) + aTime = std::max(aTime, myMapper->GetMTime()); + + return aTime; +} + + +//---------------------------------------------------------------------------- +void +VISU_MapperHolder +::SetPipeLine(VISU_PipeLine* thePipeLine) +{ + myPipeLine = thePipeLine; +} + + +//---------------------------------------------------------------------------- +void +VISU_MapperHolder +::SetIDMapper(const VISU::PIDMapper& theIDMapper) +{ + myIDMapper = theIDMapper; + + if(myPipeLine && GetInput()) + if(!GetMapper()->GetInput()){ + myPipeLine->Build(); + myPipeLine->Init(); + myPipeLine->Update(); + } +} + + +//---------------------------------------------------------------------------- +const VISU::PIDMapper& +VISU_MapperHolder +::GetIDMapper() +{ + return myIDMapper; +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_MapperHolder +::GetInput() +{ + if(myIDMapper) + return myIDMapper->GetOutput(); + + return NULL; +} + + +//---------------------------------------------------------------------------- +vtkMapper* +VISU_MapperHolder +::GetMapper() +{ + if(!myMapper.GetPointer()) + OnCreateMapper(); + + return myMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_MapperHolder +::GetOutput() +{ + if(myMapper.GetPointer()) + return myMapper->GetInput(); + + return NULL; +} + + +//---------------------------------------------------------------------------- +void +VISU_MapperHolder +::Update() +{ + if(myMapper.GetPointer()) + return myMapper->Update(); +} + + +//---------------------------------------------------------------------------- +void +VISU_MapperHolder +::SetMapper(vtkMapper* theMapper) +{ + myMapper = theMapper; +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_MapperHolder +::GetNodeObjID(vtkIdType theID) +{ + return myIDMapper->GetNodeObjID(theID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_MapperHolder +::GetNodeVTKID(vtkIdType theID) +{ + return myIDMapper->GetNodeVTKID(theID); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_MapperHolder +::GetNodeCoord(vtkIdType theObjID) +{ + return myIDMapper->GetNodeCoord(theObjID); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_MapperHolder +::GetElemObjID(vtkIdType theID) +{ + return myIDMapper->GetElemObjID(theID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_MapperHolder +::GetElemVTKID(vtkIdType theID) +{ + return myIDMapper->GetElemVTKID(theID); +} + +//---------------------------------------------------------------------------- +vtkCell* +VISU_MapperHolder +::GetElemCell(vtkIdType theObjID) +{ + return myIDMapper->GetElemCell(theObjID); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_MapperHolder.hxx b/src/PIPELINE/VISU_MapperHolder.hxx new file mode 100644 index 00000000..22ea018a --- /dev/null +++ b/src/PIPELINE/VISU_MapperHolder.hxx @@ -0,0 +1,186 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_MapperHolder.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_MapperHolder_HeaderFile +#define VISU_MapperHolder_HeaderFile + +#include "VISU_IDMapper.hxx" + +#include +#include + +class vtkCell; +class vtkPlane; +class vtkMapper; +class vtkDataSet; +class vtkPointSet; +class vtkImplicitFunction; + +class VISU_PipeLine; +class VISU_LookupTable; + + +//---------------------------------------------------------------------------- +class VISU_MapperHolder : public vtkObject +{ +public: + vtkTypeMacro(VISU_MapperHolder, vtkObject); + + //---------------------------------------------------------------------------- + virtual + void + ShallowCopy(VISU_MapperHolder *theMapperHolder, + bool theIsCopyInput); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- + void + SetPipeLine(VISU_PipeLine* thePipeLine); + + const VISU::PIDMapper& + GetIDMapper(); + + virtual + vtkDataSet* + GetInput(); + + virtual + vtkMapper* + GetMapper(); + + virtual + vtkDataSet* + GetOutput(); + + virtual + void + Update(); + + //---------------------------------------------------------------------------- + virtual + vtkIdType + GetNodeObjID(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID); + + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetElemObjID(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID); + + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + + //---------------------------------------------------------------------------- + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction) = 0; + + virtual + vtkImplicitFunction* + GetImplicitFunction() = 0; + + //---------------------------------------------------------------------------- + // Clipping planes + virtual + void + RemoveAllClippingPlanes() = 0; + + virtual + vtkIdType + GetNumberOfClippingPlanes() = 0; + + virtual + bool + AddClippingPlane(vtkPlane* thePlane) = 0; + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID) = 0; + + //---------------------------------------------------------------------------- + virtual + void + SetLookupTable(VISU_LookupTable* theLookupTable) = 0; + + virtual + vtkDataSet* + GetClippedInput() = 0; + + //---------------------------------------------------------------------------- + virtual + void + SetExtractInside(bool theMode) = 0; + + virtual + void + SetExtractBoundaryCells(bool theMode) = 0; + +protected: + //---------------------------------------------------------------------------- + VISU_MapperHolder(); + VISU_MapperHolder(const VISU_MapperHolder&); + + virtual + ~VISU_MapperHolder(); + + //---------------------------------------------------------------------------- + virtual + void + OnCreateMapper() = 0; + + void + SetMapper(vtkMapper* theMapper); + + void + SetIDMapper(const VISU::PIDMapper& theIDMapper); + +private: + //---------------------------------------------------------------------------- + vtkSmartPointer myMapper; + VISU::PIDMapper myIDMapper; + VISU_PipeLine* myPipeLine; +}; + +#endif diff --git a/src/PIPELINE/VISU_MeshPL.cxx b/src/PIPELINE/VISU_MeshPL.cxx index b4730bc3..dd9ea354 100644 --- a/src/PIPELINE/VISU_MeshPL.cxx +++ b/src/PIPELINE/VISU_MeshPL.cxx @@ -21,31 +21,48 @@ // // // -// File: VISU_PipeLine.cxx +// File: VISU_MeshPL.cxx // Author: Alexey PETROV // Module : VISU #include "VISU_MeshPL.hxx" -#include "VTKViewer_GeometryFilter.h" -#include -#include +#include "VISU_DataSetMapperHolder.hxx" + #include -#include +#include + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_MeshPL); -VISU_MeshPL::VISU_MeshPL() + +//---------------------------------------------------------------------------- +VISU_MeshPL +::VISU_MeshPL(): + VISU_UnstructuredGridPL(this) { - myIsShrinkable = true; + SetIsShrinkable(true); } -void VISU_MeshPL::Build() + +//---------------------------------------------------------------------------- +void +VISU_MeshPL +::OnCreateMapperHolder() { - myMapper->SetInput(GetInput2()); + VISU_UnstructuredGridPL::OnCreateMapperHolder(); } -void VISU_MeshPL::Init() + +//---------------------------------------------------------------------------- +void +VISU_MeshPL +::Build() { + GetDataSetMapperHolder()->GetDataSetMapper()->SetInput(GetInput()); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_MeshPL.hxx b/src/PIPELINE/VISU_MeshPL.hxx index 6ada3e68..8221a0f0 100644 --- a/src/PIPELINE/VISU_MeshPL.hxx +++ b/src/PIPELINE/VISU_MeshPL.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File: VISU_PipeLine.hxx +// File: VISU_MeshPL.hxx // Author: Alexey PETROV // Module : VISU @@ -28,18 +28,33 @@ #define VISU_MeshPL_HeaderFile #include "VISU_PipeLine.hxx" +#include "VISU_UnstructuredGridPL.hxx" -class VISU_MeshPL : public VISU_PipeLine{ + +//---------------------------------------------------------------------------- +class VISU_MeshPL : public VISU_PipeLine, + public VISU_UnstructuredGridPL +{ +public: + vtkTypeMacro(VISU_MeshPL, VISU_PipeLine); + + //---------------------------------------------------------------------------- + static + VISU_MeshPL* + New(); + protected: + //---------------------------------------------------------------------------- VISU_MeshPL(); VISU_MeshPL(const VISU_MeshPL&); -public: - vtkTypeMacro(VISU_MeshPL,VISU_PipeLine); - static VISU_MeshPL* New(); - -public: - virtual void Build(); - virtual void Init(); + + virtual + void + OnCreateMapperHolder(); + + virtual + void + Build(); }; #endif diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 31597270..31877305 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -27,25 +27,15 @@ #include "VISU_PipeLine.hxx" -#include "VISU_PipeLineUtils.hxx" - -#include "SALOME_ExtractGeometry.h" +#include "VISU_MapperHolder.hxx" -#include -#include +#include "VISU_PipeLineUtils.hxx" #include -#include -#include - #include -#include -#include -#include -#include -#include -static int MYVTKDEBUG = 0; +#include +#include #ifdef _DEBUG_ static int MYDEBUG = 0; @@ -53,29 +43,16 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif + //---------------------------------------------------------------------------- VISU_PipeLine ::VISU_PipeLine(): - myMapper(vtkDataSetMapper::New()), - myExtractGeometry(SALOME_ExtractGeometry::New()) + myIsShrinkable(false) { if(MYDEBUG) MESSAGE("VISU_PipeLine::VISU_PipeLine - "<Delete(); - - // Clipping planes - myExtractGeometry->Delete(); - myExtractGeometry->SetStoreMapping(true); - - vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); - myExtractGeometry->SetImplicitFunction(anImplicitBoolean); - anImplicitBoolean->SetOperationTypeToIntersection(); - anImplicitBoolean->Delete(); - - myIsShrinkable = false; } + //---------------------------------------------------------------------------- VISU_PipeLine ::~VISU_PipeLine() @@ -83,35 +60,35 @@ VISU_PipeLine if(MYDEBUG) MESSAGE("VISU_PipeLine::~VISU_PipeLine - "<GetMTime()); + unsigned long int aTime = Superclass::GetMTime(); + + if(myMapperHolder.GetPointer()) + aTime = std::max(aTime, myMapperHolder->GetMTime()); + return aTime; } -//---------------------------------------------------------------------------- -// Turn debugging output on. -void -VISU_PipeLine -::DebugOn() -{ - //myExtractGeometry->DebugOn(); - Superclass::DebugOn(); -} //---------------------------------------------------------------------------- -// Turn debugging output off. -void +unsigned long int VISU_PipeLine -::DebugOff() +::GetMemorySize() { - //myExtractGeometry->DebugOff(); - Superclass::DebugOff(); + unsigned long int aSize = 0; + + if(myMapperHolder.GetPointer()) + aSize += myMapperHolder->GetMemorySize(); + + return aSize; } + //---------------------------------------------------------------------------- void VISU_PipeLine @@ -122,29 +99,18 @@ VISU_PipeLine DoShallowCopy(thePipeLine, theIsCopyInput); } + //---------------------------------------------------------------------------- void VISU_PipeLine ::DoShallowCopy(VISU_PipeLine *thePipeLine, bool theIsCopyInput) { - DoCopyMapper(thePipeLine, theIsCopyInput); + GetMapperHolder()->ShallowCopy(thePipeLine->GetMapperHolder(), + theIsCopyInput); Build(); } -//---------------------------------------------------------------------------- -void -VISU_PipeLine -::DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) -{ - if(theIsCopyInput) - SetIDMapper(thePipeLine->GetIDMapper()); - Update(); - VISU::CopyDataSetMapper(GetDataSetMapper(), - thePipeLine->GetDataSetMapper(), - theIsCopyInput); -} //---------------------------------------------------------------------------- void @@ -154,400 +120,315 @@ VISU_PipeLine DoShallowCopy(thePipeLine, false); } + //---------------------------------------------------------------------------- -TInput* +VISU_MapperHolder* VISU_PipeLine -::GetInput() const +::GetMapperHolder() { - return myInput.GetPointer(); + if(!myMapperHolder.GetPointer()) + OnCreateMapperHolder(); + + return myMapperHolder.GetPointer(); } + //---------------------------------------------------------------------------- -vtkDataSet* +const VISU::PIDMapper& VISU_PipeLine -::GetOutput() +::GetIDMapper() { - return GetMapper()->GetInput(); + return GetMapperHolder()->GetIDMapper(); } + //---------------------------------------------------------------------------- -TInput* +vtkDataSet* VISU_PipeLine -::GetInput2() const +::GetInput() { - vtkUnstructuredGrid* aDataSet = myExtractGeometry->GetOutput(); - aDataSet->Update(); - return aDataSet; + return GetMapperHolder()->GetInput(); } + //---------------------------------------------------------------------------- -void +vtkMapper* VISU_PipeLine -::SetInput(TInput* theInput) +::GetMapper() { - if(GetInput() == theInput) - return; + return GetMapperHolder()->GetMapper(); +} - if(theInput) - theInput->Update(); - myExtractGeometry->SetInput(theInput); - myInput = theInput; +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_PipeLine +::GetOutput() +{ + return GetMapperHolder()->GetOutput(); } + //---------------------------------------------------------------------------- -VISU_PipeLine::TMapper* +bool VISU_PipeLine -::GetMapper() +::IsPlanarInput() { - if(GetInput()){ - if(!myMapper->GetInput()){ - GetInput2()->Update(); - Build(); - } - myMapper->Update(); - } - return myMapper.GetPointer(); + vtkFloatingPointType aBounds[6]; + GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax + if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN || + fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN || + fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN ) + return true; + + return false; } + //---------------------------------------------------------------------------- -vtkDataSetMapper* +void VISU_PipeLine -::GetDataSetMapper() +::SetMapperHolder(VISU_MapperHolder* theHolder) { - GetMapper(); - return myMapper.GetPointer(); + myMapperHolder = theHolder; + theHolder->SetPipeLine(this); } + +//---------------------------------------------------------------------------- +void +VISU_PipeLine +::Init() +{} + + //---------------------------------------------------------------------------- void VISU_PipeLine ::Update() { - myMapper->Update(); + GetMapperHolder()->Update(); } + //---------------------------------------------------------------------------- -size_t +vtkIdType VISU_PipeLine -::CheckAvailableMemory(size_t theSize) +::GetNodeObjID(vtkIdType theID) { - if(theSize < ULONG_MAX){ - try{ - if(char *aCheck = new char[theSize]){ - delete [] aCheck; - return theSize; - } - }catch(std::bad_alloc& exc){ - }catch(...){ - } - } - return 0; + return GetMapperHolder()->GetNodeObjID(theID); } //---------------------------------------------------------------------------- -size_t +vtkIdType VISU_PipeLine -::GetAvailableMemory(size_t theSize, - size_t theMinSize) +::GetNodeVTKID(vtkIdType theID) { - // Finds acceptable memory size by half-deflection methods - static size_t EPSILON = 2 * 1024; - size_t aMax = std::max(theSize, theMinSize); - size_t aMin = std::min(theSize, theMinSize); - //cout<<"GetAvailableMemory - "< 0 && (aMax - aMin) > EPSILON){ - size_t aRoot = (aMax + aMin) / 2; - if(CheckAvailableMemory(aRoot)) - aMin = aRoot; - else - aMax = aRoot; - } - //cout<<"; "<GetNodeVTKID(theID); } //---------------------------------------------------------------------------- -unsigned long int +vtkFloatingPointType* VISU_PipeLine -::GetMemorySize() +::GetNodeCoord(int theObjID) { - vtkDataSet* aDataSet = myExtractGeometry->GetInput(); - unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024; - - aDataSet = myExtractGeometry->GetOutput(); - aSize += aDataSet->GetActualMemorySize() * 1024; - - return aSize; + return GetMapperHolder()->GetNodeCoord(theObjID); } -//------------------------ Clipping planes ----------------------------------- -bool + +//---------------------------------------------------------------------------- +vtkIdType VISU_PipeLine -::AddClippingPlane(vtkPlane* thePlane) +::GetElemObjID(vtkIdType theID) { - if (thePlane) { - if (vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()) { - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - aFunction->AddItem(thePlane); - - // Check, that at least one cell present after clipping. - // This check was introduced because of bug IPAL8849. - vtkUnstructuredGrid* aClippedGrid = GetInput2(); - if (aClippedGrid->GetNumberOfCells() < 1) { - return false; - } - } - } - return true; + return GetMapperHolder()->GetElemObjID(theID); } //---------------------------------------------------------------------------- -vtkPlane* +vtkIdType VISU_PipeLine -::GetClippingPlane(vtkIdType theID) const -{ - vtkPlane* aPlane = NULL; - if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ - if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - vtkImplicitFunction* aFun = NULL; - aFunction->InitTraversal(); - for(vtkIdType anID = 0; anID <= theID; anID++) - aFun = aFunction->GetNextItem(); - aPlane = dynamic_cast(aFun); - } - } - return aPlane; +::GetElemVTKID(vtkIdType theID) +{ + return GetMapperHolder()->GetElemVTKID(theID); } //---------------------------------------------------------------------------- -void +vtkCell* VISU_PipeLine -::RemoveAllClippingPlanes() +::GetElemCell(vtkIdType theObjID) { - if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - aFunction->RemoveAllItems(); - aBoolean->Modified(); // VTK bug - } + return GetMapperHolder()->GetElemCell(theObjID); } + //---------------------------------------------------------------------------- -vtkIdType +bool VISU_PipeLine -::GetNumberOfClippingPlanes() const +::IsShrinkable() { - if(vtkImplicitBoolean* aBoolean = myExtractGeometry->GetImplicitBoolean()){ - vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); - return aFunction->GetNumberOfItems(); - } - return 0; + return myIsShrinkable; } -//---------------------------------------------------------------------------- -static -void -ComputeBoundsParam (vtkDataSet* theDataSet, - vtkFloatingPointType theDirection[3], - vtkFloatingPointType theMinPnt[3], - vtkFloatingPointType& theMaxBoundPrj, - vtkFloatingPointType& theMinBoundPrj) +void +VISU_PipeLine +::SetIsShrinkable(bool theIsShrinkable) { - vtkFloatingPointType aBounds[6]; - theDataSet->GetBounds(aBounds); - - //Enlarge bounds in order to avoid conflicts of precision - for(int i = 0; i < 6; i += 2){ - static double EPS = 1.0E-3; - vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS; - aBounds[i] -= aDelta; - aBounds[i+1] += aDelta; - } - - vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, - {aBounds[1],aBounds[2],aBounds[4]}, - {aBounds[0],aBounds[3],aBounds[4]}, - {aBounds[1],aBounds[3],aBounds[4]}, - {aBounds[0],aBounds[2],aBounds[5]}, - {aBounds[1],aBounds[2],aBounds[5]}, - {aBounds[0],aBounds[3],aBounds[5]}, - {aBounds[1],aBounds[3],aBounds[5]}}; - - int aMaxId = 0, aMinId = aMaxId; - theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]); - theMinBoundPrj = theMaxBoundPrj; - for(int i = 1; i < 8; i++){ - vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]); - if(theMaxBoundPrj < aTmp){ - theMaxBoundPrj = aTmp; - aMaxId = i; - } - if(theMinBoundPrj > aTmp){ - theMinBoundPrj = aTmp; - aMinId = i; - } - } - vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId]; - theMinPnt[0] = aMinPnt[0]; - theMinPnt[1] = aMinPnt[1]; - theMinPnt[2] = aMinPnt[2]; + myIsShrinkable = theIsShrinkable; } + //---------------------------------------------------------------------------- -static void -DistanceToPosition(vtkDataSet* theDataSet, - vtkFloatingPointType theDirection[3], - vtkFloatingPointType theDist, - vtkFloatingPointType thePos[3]) +VISU_PipeLine +::SetImplicitFunction(vtkImplicitFunction *theFunction) { - vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; - ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); - vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist; - thePos[0] = aMinPnt[0]-theDirection[0]*aLength; - thePos[1] = aMinPnt[1]-theDirection[1]*aLength; - thePos[2] = aMinPnt[2]-theDirection[2]*aLength; -} + GetMapperHolder()->SetImplicitFunction(theFunction); +} //---------------------------------------------------------------------------- -static -void -PositionToDistance (vtkDataSet* theDataSet, - vtkFloatingPointType theDirection[3], - vtkFloatingPointType thePos[3], - vtkFloatingPointType& theDist) +vtkImplicitFunction * +VISU_PipeLine +::GetImplicitFunction() { - vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; - ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); - vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos); - theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj); + return GetMapperHolder()->GetImplicitFunction(); } //---------------------------------------------------------------------------- void VISU_PipeLine -::SetPlaneParam(vtkFloatingPointType theDir[3], - vtkFloatingPointType theDist, - vtkPlane* thePlane) +::SetExtractInside(bool theMode) { - thePlane->SetNormal(theDir); - vtkFloatingPointType anOrigin[3]; - ::DistanceToPosition(GetInput(),theDir,theDist,anOrigin); - thePlane->SetOrigin(anOrigin); + GetMapperHolder()->SetExtractInside(theMode); } //---------------------------------------------------------------------------- void VISU_PipeLine -::GetPlaneParam(vtkFloatingPointType theDir[3], - vtkFloatingPointType& theDist, - vtkPlane* thePlane) +::SetExtractBoundaryCells(bool theMode) { - thePlane->GetNormal(theDir); - - vtkFloatingPointType anOrigin[3]; - thePlane->GetOrigin(anOrigin); - ::PositionToDistance(GetInput(),theDir,anOrigin,theDist); + GetMapperHolder()->SetExtractBoundaryCells(theMode); } + //---------------------------------------------------------------------------- -bool +void VISU_PipeLine -::IsPlanarInput() const +::RemoveAllClippingPlanes() { - vtkFloatingPointType aBounds[6]; - GetInput()->GetBounds( aBounds ); // xmin,xmax, ymin,ymax, zmin,zmax - if (fabs( aBounds[0] - aBounds[1] ) <= FLT_MIN || - fabs( aBounds[2] - aBounds[3] ) <= FLT_MIN || - fabs( aBounds[4] - aBounds[5] ) <= FLT_MIN ) - return true; - - return false; + GetMapperHolder()->RemoveAllClippingPlanes(); } -//======================================================================= -vtkIdType +//---------------------------------------------------------------------------- +vtkIdType VISU_PipeLine -::GetNodeObjID(vtkIdType theID) +::GetNumberOfClippingPlanes() { - vtkIdType anID = myExtractGeometry->GetNodeObjId(theID); - return myIDMapper->GetNodeObjID(anID); + return GetMapperHolder()->GetNumberOfClippingPlanes(); } -vtkIdType +//---------------------------------------------------------------------------- +bool VISU_PipeLine -::GetNodeVTKID(vtkIdType theID) +::AddClippingPlane(vtkPlane* thePlane) { - vtkIdType anID = myIDMapper->GetNodeVTKID(theID); - return myExtractGeometry->GetNodeVTKId(anID); + return GetMapperHolder()->AddClippingPlane(thePlane); } -vtkFloatingPointType* +//---------------------------------------------------------------------------- +vtkPlane* VISU_PipeLine -::GetNodeCoord(int theObjID) +::GetClippingPlane(vtkIdType theID) { - return myIDMapper->GetNodeCoord(theObjID); + return GetMapperHolder()->GetClippingPlane(theID); } -//======================================================================= -vtkIdType +//---------------------------------------------------------------------------- +vtkDataSet* VISU_PipeLine -::GetElemObjID(vtkIdType theID) +::GetClippedInput() { - vtkIdType anID = myExtractGeometry->GetElemObjId(theID); - return myIDMapper->GetElemObjID(anID); + return GetMapperHolder()->GetClippedInput(); } -vtkIdType -VISU_PipeLine -::GetElemVTKID(vtkIdType theID) -{ - vtkIdType anID = myIDMapper->GetElemVTKID(theID); - return myExtractGeometry->GetElemVTKId(anID); -} -vtkCell* +//---------------------------------------------------------------------------- +void VISU_PipeLine -::GetElemCell(vtkIdType theObjID) +::SetPlaneParam(vtkFloatingPointType theDir[3], + vtkFloatingPointType theDist, + vtkPlane* thePlane) { - return myIDMapper->GetElemCell(theObjID); + thePlane->SetNormal(theDir); + + vtkFloatingPointType anOrigin[3]; + VISU::DistanceToPosition(GetInput(), + theDir, + theDist, + anOrigin); + + thePlane->SetOrigin(anOrigin); } -//======================================================================= + +//---------------------------------------------------------------------------- void VISU_PipeLine -::SetIDMapper(const VISU::PIDMapper& theIDMapper) +::GetPlaneParam(vtkFloatingPointType theDir[3], + vtkFloatingPointType& theDist, + vtkPlane* thePlane) { - myIDMapper = theIDMapper; - SetInput(myIDMapper->GetVTKOutput()); + thePlane->GetNormal(theDir); + + vtkFloatingPointType anOrigin[3]; + thePlane->GetOrigin(anOrigin); + + VISU::PositionToDistance(GetInput(), + theDir, + anOrigin, + theDist); } -const VISU::PIDMapper& + +//---------------------------------------------------------------------------- +size_t VISU_PipeLine -::GetIDMapper() const +::CheckAvailableMemory(size_t theSize) { - return myIDMapper; + if(theSize < ULONG_MAX){ + try{ + if(char *aCheck = new char[theSize]){ + delete [] aCheck; + return theSize; + } + }catch(std::bad_alloc& exc){ + }catch(...){ + } + } + return 0; } -//======================================================================= -void -VISU_PipeLine -::SetImplicitFunction(vtkImplicitFunction *theFunction) -{ - myExtractGeometry->SetImplicitFunction(theFunction); -} -vtkImplicitFunction * +//---------------------------------------------------------------------------- +size_t VISU_PipeLine -::GetImplicitFunction() +::GetAvailableMemory(size_t theSize, + size_t theMinSize) { - return myExtractGeometry->GetImplicitFunction(); + // Finds acceptable memory size by half-deflection methods + static size_t EPSILON = 2 * 1024; + size_t aMax = std::max(theSize, theMinSize); + size_t aMin = std::min(theSize, theMinSize); + //cout<<"GetAvailableMemory - "< 0 && (aMax - aMin) > EPSILON){ + size_t aRoot = (aMax + aMin) / 2; + if(CheckAvailableMemory(aRoot)) + aMin = aRoot; + else + aMax = aRoot; + } + //cout<<"; "< +#include "VISU_IDMapper.hxx" + #include #include -#include - -#include "VISU_IDMapper.hxx" class vtkCell; +class vtkPlane; +class vtkMapper; class vtkDataSet; +class vtkPointSet; class vtkImplicitFunction; - //---------------------------------------------------------------------------- -template -class TVTKSmartPtr: public vtkSmartPointer -{ -public: - TVTKSmartPtr() - {} - - TVTKSmartPtr(T* r, bool theIsOwner = false): vtkSmartPointer(r) - { - if(r && theIsOwner) - r->Delete(); - } - - TVTKSmartPtr& operator()(T* r, bool theIsOwner = false) - { - vtkSmartPointer::operator=(r); - if(r && theIsOwner) - r->Delete(); - return *this; - } - - TVTKSmartPtr& operator=(T* r) - { - vtkSmartPointer::operator=(r); - return *this; - } - - operator T* () const - { - return vtkSmartPointer::GetPointer(); - } -}; - - -//---------------------------------------------------------------------------- -class vtkMapper; -class vtkDataSetMapper; -class vtkUnstructuredGrid; -class vtkExtractGeometry; -class vtkImplicitBoolean; -class vtkPlane; - -class SALOME_ExtractGeometry; - -typedef VISU::TVTKOutput TInput; - class VISU_PipeLine : public vtkObject { -public: - vtkTypeMacro(VISU_PipeLine,vtkObject); + friend class VISU_MapperHolder; - virtual - unsigned long int - GetMTime(); +public: + vtkTypeMacro(VISU_PipeLine, vtkObject); + //! Gets memory size used by the instance (bytes). virtual - void - DebugOn(); + unsigned long int + GetMemorySize(); virtual - void - DebugOff(); + unsigned long int + GetMTime(); + //---------------------------------------------------------------------------- virtual void ShallowCopy(VISU_PipeLine *thePipeLine, @@ -112,80 +66,38 @@ public: void SameAs(VISU_PipeLine *thePipeLine); -public: - virtual - void - SetInput(TInput* theInput); + //---------------------------------------------------------------------------- + void + SetMapperHolder(VISU_MapperHolder* theHolder); - virtual - TInput* - GetInput() const; + VISU_MapperHolder* + GetMapperHolder(); + + const VISU::PIDMapper& + GetIDMapper(); virtual vtkDataSet* - GetOutput(); - - bool - IsPlanarInput() const; - - typedef vtkMapper TMapper; + GetInput(); virtual - TMapper* + vtkMapper* GetMapper(); - virtual - vtkDataSetMapper* - GetDataSetMapper(); - virtual - void - Init() = 0; + vtkDataSet* + GetOutput(); + //---------------------------------------------------------------------------- virtual void - Update(); + Init(); - static - size_t - CheckAvailableMemory(size_t theSize); - - static - size_t - GetAvailableMemory(size_t theSize, - size_t theMinSize = 1024*1024); - - //! Gets memory size used by the instance (bytes). virtual - unsigned long int - GetMemorySize(); - - // Clipping planes - void - RemoveAllClippingPlanes(); - - vtkIdType - GetNumberOfClippingPlanes() const; - - bool - AddClippingPlane(vtkPlane* thePlane); - - vtkPlane* - GetClippingPlane(vtkIdType theID) const; - - void - SetPlaneParam(vtkFloatingPointType theDir[3], - vtkFloatingPointType theDist, - vtkPlane* thePlane); - void - GetPlaneParam(vtkFloatingPointType theDir[3], - vtkFloatingPointType& theDist, - vtkPlane* thePlane); - - bool - IsShrinkable() { return myIsShrinkable; } + Update(); + //---------------------------------------------------------------------------- virtual vtkIdType GetNodeObjID(vtkIdType theID); @@ -210,54 +122,95 @@ public: vtkCell* GetElemCell(vtkIdType theObjID); - void - SetIDMapper(const VISU::PIDMapper& theIDMapper); + //---------------------------------------------------------------------------- + bool + IsPlanarInput(); - const VISU::PIDMapper& - GetIDMapper()const; + bool + IsShrinkable(); + //---------------------------------------------------------------------------- void SetImplicitFunction(vtkImplicitFunction *theFunction); vtkImplicitFunction* GetImplicitFunction(); - SALOME_ExtractGeometry* - GetExtractGeometryFilter(); + void + SetExtractInside(bool theMode); + + void + SetExtractBoundaryCells(bool theMode); + + //---------------------------------------------------------------------------- + void + RemoveAllClippingPlanes(); + + vtkIdType + GetNumberOfClippingPlanes(); + + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID); + + virtual + void + SetPlaneParam(vtkFloatingPointType theDir[3], + vtkFloatingPointType theDist, + vtkPlane* thePlane); + + virtual + void + GetPlaneParam(vtkFloatingPointType theDir[3], + vtkFloatingPointType& theDist, + vtkPlane* thePlane); + + //---------------------------------------------------------------------------- + static + size_t + CheckAvailableMemory(size_t theSize); + + static + size_t + GetAvailableMemory(size_t theSize, + size_t theMinSize = 1024*1024); protected: + //---------------------------------------------------------------------------- VISU_PipeLine(); VISU_PipeLine(const VISU_PipeLine&); virtual ~VISU_PipeLine(); + //---------------------------------------------------------------------------- virtual void - DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); + Build() = 0; virtual void - DoCopyMapper(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); - - virtual - TInput* - GetInput2() const; + OnCreateMapperHolder() = 0; virtual void - Build() = 0; + DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); - bool myIsShrinkable; + //---------------------------------------------------------------------------- + vtkDataSet* + GetClippedInput(); - TVTKSmartPtr myInput; - VISU::PIDMapper myIDMapper; - TVTKSmartPtr myMapper; + void + SetIsShrinkable(bool theIsShrinkable); - // Clipping planes - TVTKSmartPtr myExtractGeometry; +private: + //---------------------------------------------------------------------------- + vtkSmartPointer myMapperHolder; + bool myIsShrinkable; }; #endif diff --git a/src/PIPELINE/VISU_PipeLineUtils.cxx b/src/PIPELINE/VISU_PipeLineUtils.cxx index 7525426d..33a97adc 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.cxx +++ b/src/PIPELINE/VISU_PipeLineUtils.cxx @@ -31,24 +31,31 @@ #include #include -void -VISU::Mul(const vtkFloatingPointType A[3], - vtkFloatingPointType b, - vtkFloatingPointType C[3]) -{ // A*b; - for(int i = 0; i < 3; i++) C[i] = A[i]*b; -} - -void -VISU::Sub(const vtkFloatingPointType A[3], - const vtkFloatingPointType B[3], - vtkFloatingPointType C[3]) -{ //A-B - for(int i = 0; i < 3; i++) C[i] = A[i] - B[i]; -} - namespace VISU { + //---------------------------------------------------------------------------- + void + Mul(const vtkFloatingPointType A[3], + vtkFloatingPointType b, + vtkFloatingPointType C[3]) + { // A*b; + for(int i = 0; i < 3; i++) + C[i] = A[i]*b; + } + + + //---------------------------------------------------------------------------- + void + Sub(const vtkFloatingPointType A[3], + const vtkFloatingPointType B[3], + vtkFloatingPointType C[3]) + { //A-B + for(int i = 0; i < 3; i++) + C[i] = A[i] - B[i]; + } + + + //---------------------------------------------------------------------------- bool CheckIsSameValue(vtkFloatingPointType theTarget, vtkFloatingPointType theSource) @@ -59,6 +66,8 @@ namespace VISU return false; } + + //---------------------------------------------------------------------------- bool CheckIsSameRange(vtkFloatingPointType* theTarget, vtkFloatingPointType* theSource) @@ -67,6 +76,8 @@ namespace VISU CheckIsSameValue(theTarget[1], theSource[1]); } + + //---------------------------------------------------------------------------- void CopyMapper(vtkMapper* theTarget, vtkMapper* theSource, @@ -92,6 +103,8 @@ namespace VISU theTarget->SetClippingPlanes(theSource->GetClippingPlanes()); } + + //---------------------------------------------------------------------------- void CopyDataSetMapper(vtkDataSetMapper* theTarget, vtkDataSetMapper* theSource, @@ -102,6 +115,8 @@ namespace VISU CopyMapper(theTarget, theSource, theIsCopyInput); } + + //---------------------------------------------------------------------------- void CopyPolyDataMapper(vtkPolyDataMapper* theTarget, vtkPolyDataMapper* theSource, @@ -116,6 +131,8 @@ namespace VISU CopyMapper(theTarget, theSource, theIsCopyInput); } + + //---------------------------------------------------------------------------- void CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget, VISU_OpenGLPointSpriteMapper* theSource, @@ -137,4 +154,94 @@ namespace VISU CopyPolyDataMapper(theTarget, theSource, theIsCopyInput); } + + + //---------------------------------------------------------------------------- + void + ComputeBoundsParam(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType theMinPnt[3], + vtkFloatingPointType& theMaxBoundPrj, + vtkFloatingPointType& theMinBoundPrj) + { + vtkFloatingPointType aBounds[6]; + theDataSet->GetBounds(aBounds); + + //Enlarge bounds in order to avoid conflicts of precision + for(int i = 0; i < 6; i += 2){ + static double EPS = 1.0E-3; + vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS; + aBounds[i] -= aDelta; + aBounds[i+1] += aDelta; + } + + vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, + {aBounds[1],aBounds[2],aBounds[4]}, + {aBounds[0],aBounds[3],aBounds[4]}, + {aBounds[1],aBounds[3],aBounds[4]}, + {aBounds[0],aBounds[2],aBounds[5]}, + {aBounds[1],aBounds[2],aBounds[5]}, + {aBounds[0],aBounds[3],aBounds[5]}, + {aBounds[1],aBounds[3],aBounds[5]}}; + + int aMaxId = 0, aMinId = aMaxId; + theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]); + theMinBoundPrj = theMaxBoundPrj; + for(int i = 1; i < 8; i++){ + vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]); + if(theMaxBoundPrj < aTmp){ + theMaxBoundPrj = aTmp; + aMaxId = i; + } + if(theMinBoundPrj > aTmp){ + theMinBoundPrj = aTmp; + aMinId = i; + } + } + vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId]; + theMinPnt[0] = aMinPnt[0]; + theMinPnt[1] = aMinPnt[1]; + theMinPnt[2] = aMinPnt[2]; + } + + + //---------------------------------------------------------------------------- + void + DistanceToPosition(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType theDist, + vtkFloatingPointType thePos[3]) + { + vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet, + theDirection, + aMinPnt, + aMaxBoundPrj, + aMinBoundPrj); + vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist; + thePos[0] = aMinPnt[0] - theDirection[0] * aLength; + thePos[1] = aMinPnt[1] - theDirection[1] * aLength; + thePos[2] = aMinPnt[2] - theDirection[2] * aLength; + } + + + //---------------------------------------------------------------------------- + void + PositionToDistance(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType thePos[3], + vtkFloatingPointType& theDist) + { + vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet, + theDirection, + aMinPnt, + aMaxBoundPrj, + aMinBoundPrj); + vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos); + theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj); + } + + + //---------------------------------------------------------------------------- } diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index b37daee0..db6570a8 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -28,8 +28,6 @@ #define VISU_PipeLineUtils_HeaderFile #include "VISU_FieldTransform.hxx" -#include "VISU_LookupTable.hxx" -#include "VISU_Extractor.hxx" #include #include @@ -59,19 +57,24 @@ class VISU_OpenGLPointSpriteMapper; namespace VISU { + //---------------------------------------------------------------------------- void Mul(const vtkFloatingPointType A[3], vtkFloatingPointType b, vtkFloatingPointType C[3]); // C = A * b + + //---------------------------------------------------------------------------- void Sub(const vtkFloatingPointType A[3], const vtkFloatingPointType B[3], vtkFloatingPointType C[3]); // C = A - B - template + + //---------------------------------------------------------------------------- + template void - CellDataToPoint(TItem* theTItem, + CellDataToPoint(TEndFilter* theEndFilter, vtkCellDataToPointData *theFilter, vtkDataSet* theDataSet, VISU_FieldTransform *theFieldTransform) @@ -79,14 +82,16 @@ namespace VISU if(theDataSet->GetCellData()->GetNumberOfArrays()){ theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); theFilter->PassCellDataOn(); - theTItem->SetInput(theFilter->GetUnstructuredGridOutput()); + theEndFilter->SetInput(theFilter->GetUnstructuredGridOutput()); }else - theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); } - template + + //---------------------------------------------------------------------------- + template void - ToCellCenters(TItem* theTItem, + ToCellCenters(TEndFilter* theEndFilter, vtkCellCenters *theFilter, vtkDataSet* theDataSet, VISU_FieldTransform *theFieldTransform) @@ -94,11 +99,13 @@ namespace VISU if(theDataSet->GetCellData()->GetNumberOfArrays()){ theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); theFilter->VertexCellsOn(); - theTItem->SetInput(theFilter->GetOutput()); + theEndFilter->SetInput(theFilter->GetOutput()); }else - theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput()); + theEndFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); } + + //---------------------------------------------------------------------------- //! Checks whether the float values are the same or not bool CheckIsSameValue(vtkFloatingPointType theTarget, @@ -109,6 +116,12 @@ namespace VISU CheckIsSameRange(vtkFloatingPointType* theTarget, vtkFloatingPointType* theSource); + //! Customizes vtkMapper::ShallowCopy + void + CopyMapper(vtkMapper* theTarget, + vtkMapper* theSource, + bool theIsCopyInput); + //! Customizes vtkDataSetMapper::ShallowCopy void CopyDataSetMapper(vtkDataSetMapper* theTarget, @@ -126,6 +139,31 @@ namespace VISU CopyPointSpriteDataMapper(VISU_OpenGLPointSpriteMapper* theTarget, VISU_OpenGLPointSpriteMapper* theSource, bool theIsCopyInput); + + + //---------------------------------------------------------------------------- + void + ComputeBoundsParam(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType theMinPnt[3], + vtkFloatingPointType& theMaxBoundPrj, + vtkFloatingPointType& theMinBoundPrj); + + + //---------------------------------------------------------------------------- + void + DistanceToPosition(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType theDist, + vtkFloatingPointType thePos[3]); + + + //---------------------------------------------------------------------------- + void + PositionToDistance(vtkDataSet* theDataSet, + vtkFloatingPointType theDirection[3], + vtkFloatingPointType thePos[3], + vtkFloatingPointType& theDist); } #endif diff --git a/src/PIPELINE/VISU_Plot3DPL.cxx b/src/PIPELINE/VISU_Plot3DPL.cxx index 898b5740..0b7758a4 100644 --- a/src/PIPELINE/VISU_Plot3DPL.cxx +++ b/src/PIPELINE/VISU_Plot3DPL.cxx @@ -39,35 +39,51 @@ #include #include -using namespace std; +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_Plot3DPL); -VISU_Plot3DPL::VISU_Plot3DPL(): - myCellDataToPointData(vtkCellDataToPointData::New(),true), - myAppendPolyData(vtkAppendPolyData::New(),true), - myGeometryFilter(vtkGeometryFilter::New(),true), - myContourFilter(vtkContourFilter::New(),true), - myWarpScalar(vtkWarpScalar::New(),true), + +//---------------------------------------------------------------------------- +VISU_Plot3DPL +::VISU_Plot3DPL(): + myCellDataToPointData(vtkCellDataToPointData::New()), + myAppendPolyData(vtkAppendPolyData::New()), + myGeometryFilter(vtkGeometryFilter::New()), + myContourFilter(vtkContourFilter::New()), + myWarpScalar(vtkWarpScalar::New()), myOrientation(VISU_CutPlanesPL::YZ), myIsRelative(true), myIsContour(false), myPosition(0.5), - myScaleFactor(1.) + myScaleFactor(1.0) { - myAngle[0] = myAngle[1] = myAngle[2] = 0.; + SetIsShrinkable(false); + + myCellDataToPointData->Delete(); + myAppendPolyData->Delete(); + myGeometryFilter->Delete(); + myContourFilter->Delete(); + myWarpScalar->Delete(); + + myAngle[0] = myAngle[1] = myAngle[2] = 0.0; + SetNumberOfContours(32); - myIsShrinkable = false; } -VISU_Plot3DPL::~VISU_Plot3DPL() + +//---------------------------------------------------------------------------- +VISU_Plot3DPL +::~VISU_Plot3DPL() { } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) +VISU_Plot3DPL +::DoShallowCopy(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) { if(VISU_Plot3DPL *aPipeLine = dynamic_cast(thePipeLine)){ SetOrientation (aPipeLine->GetPlaneOrientation(), @@ -78,12 +94,15 @@ DoShallowCopy(VISU_PipeLine *thePipeLine, SetContourPrs( aPipeLine->GetIsContourPrs() ); SetNumberOfContours( aPipeLine->GetNumberOfContours() ); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } + +//---------------------------------------------------------------------------- VISU_CutPlanesPL::PlaneOrientation -VISU_Plot3DPL:: -GetOrientation(vtkDataSet* theDataSet) +VISU_Plot3DPL +::GetOrientation(vtkDataSet* theDataSet) { theDataSet->Update(); @@ -112,9 +131,11 @@ GetOrientation(vtkDataSet* theDataSet) return VISU_CutPlanesPL::XY; } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetScaleFactor(vtkDataSet* theDataSet) +VISU_Plot3DPL +::GetScaleFactor(vtkDataSet* theDataSet) { theDataSet->Update(); vtkFloatingPointType aLength = theDataSet->GetLength(); // diagonal length @@ -130,26 +151,32 @@ GetScaleFactor(vtkDataSet* theDataSet) return 0.0; } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -Init() +VISU_Plot3DPL +::Init() { Superclass::Init(); - myOrientation = GetOrientation(GetInput2()); - SetScaleFactor(GetScaleFactor(GetInput2())); + myOrientation = GetOrientation(GetClippedInput()); + SetScaleFactor(GetScaleFactor(GetClippedInput())); } -VISU_ScalarMapPL::THook* -VISU_Plot3DPL:: -DoHook() + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_Plot3DPL +::InsertCustomPL() { return myAppendPolyData->GetOutput(); } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -Update() +VISU_Plot3DPL +::Update() { vtkFloatingPointType aPlaneNormal[3]; vtkFloatingPointType anOrigin[3]; @@ -158,7 +185,7 @@ Update() vtkPolyData* aPolyData = 0; vtkCutter *aCutPlane = 0; vtkUnstructuredGrid* anUnstructuredGrid = - myFieldTransform->GetUnstructuredGridOutput(); + GetFieldTransformFilter()->GetUnstructuredGridOutput(); if ( !IsPlanarInput() ) { @@ -206,7 +233,7 @@ Update() myWarpScalar->SetInput(myContourFilter->GetOutput()); } - VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData); + VISU_CutPlanesPL::ClearAppendPolyData(myAppendPolyData.GetPointer()); myAppendPolyData->AddInput(myWarpScalar->GetPolyDataOutput()); if ( aCutPlane ) @@ -257,28 +284,36 @@ VISU_Plot3DPL myContourFilter->SetNumberOfContours(theNumber); } + +//---------------------------------------------------------------------------- int -VISU_Plot3DPL:: -GetNumberOfContours() const +VISU_Plot3DPL +::GetNumberOfContours() { return myContourFilter->GetNumberOfContours(); } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -SetScaleFactor(vtkFloatingPointType theScaleFactor) +VISU_Plot3DPL +::SetScaleFactor(vtkFloatingPointType theScaleFactor) { myScaleFactor = theScaleFactor; myWarpScalar->SetScaleFactor(theScaleFactor); } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetScaleFactor() const +VISU_Plot3DPL +::GetScaleFactor() { return myScaleFactor; } + +//---------------------------------------------------------------------------- void VISU_Plot3DPL:: SetContourPrs(bool theIsContourPrs ) @@ -287,38 +322,47 @@ SetContourPrs(bool theIsContourPrs ) Modified(); } + +//---------------------------------------------------------------------------- bool -VISU_Plot3DPL:: -GetIsContourPrs() const +VISU_Plot3DPL +::GetIsContourPrs() { return myIsContour; } + +//---------------------------------------------------------------------------- void -VISU_Plot3DPL:: -SetPlanePosition(vtkFloatingPointType thePosition, - bool theIsRelative) +VISU_Plot3DPL +::SetPlanePosition(vtkFloatingPointType thePosition, + bool theIsRelative) { myIsRelative = theIsRelative; myPosition = thePosition; Modified(); } + +//---------------------------------------------------------------------------- bool -VISU_Plot3DPL:: -IsPositionRelative() const +VISU_Plot3DPL +::IsPositionRelative() { return myIsRelative; } + +//---------------------------------------------------------------------------- VISU_CutPlanesPL::PlaneOrientation -VISU_Plot3DPL:: -GetPlaneOrientation() const +VISU_Plot3DPL +::GetPlaneOrientation() { return myOrientation; } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_Plot3DPL:: GetRotateX() @@ -331,6 +375,8 @@ GetRotateX() return 0; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_Plot3DPL:: GetRotateY(){ @@ -342,6 +388,8 @@ GetRotateY(){ return 0; } + +//---------------------------------------------------------------------------- void VISU_Plot3DPL:: SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, @@ -362,9 +410,11 @@ SetOrientation(VISU_CutPlanesPL::PlaneOrientation theOrientation, Modified(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType -VISU_Plot3DPL:: -GetPlanePosition() const +VISU_Plot3DPL +::GetPlanePosition() { return myPosition; } @@ -377,7 +427,7 @@ void VISU_Plot3DPL ::GetBasePlane(vtkFloatingPointType theOrigin[3], vtkFloatingPointType theNormal[3], - bool theCenterOrigine ) const + bool theCenterOrigine ) { VISU_CutPlanesPL::GetDir(theNormal,myAngle,myOrientation); @@ -393,7 +443,7 @@ VISU_Plot3DPL if ( theCenterOrigine ) { // move theOrigin to the center of aBounds projections to the plane - GetInput2()->GetBounds(aBounds); + GetClippedInput()->GetBounds(aBounds); vtkFloatingPointType boundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, {aBounds[1],aBounds[2],aBounds[4]}, @@ -424,7 +474,7 @@ VISU_Plot3DPL void VISU_Plot3DPL ::GetMinMaxPosition( vtkFloatingPointType& minPos, - vtkFloatingPointType& maxPos ) const + vtkFloatingPointType& maxPos ) { vtkFloatingPointType aBounds[6], aBoundPrj[3], aNormal[3]; VISU_CutPlanesPL::GetDir(aNormal,myAngle,myOrientation); diff --git a/src/PIPELINE/VISU_Plot3DPL.hxx b/src/PIPELINE/VISU_Plot3DPL.hxx index 81f47c49..ec2c408d 100644 --- a/src/PIPELINE/VISU_Plot3DPL.hxx +++ b/src/PIPELINE/VISU_Plot3DPL.hxx @@ -35,6 +35,8 @@ class vtkContourFilter; class vtkGeometryFilter; class vtkCellDataToPointData; + +//---------------------------------------------------------------------------- class VISU_Plot3DPL : public VISU_ScalarMapPL { public: @@ -43,7 +45,7 @@ public: virtual ~VISU_Plot3DPL(); VISU_CutPlanesPL::PlaneOrientation - GetPlaneOrientation() const; + GetPlaneOrientation(); vtkFloatingPointType GetRotateX(); @@ -57,10 +59,10 @@ public: vtkFloatingPointType theYAngle = 0.0); vtkFloatingPointType - GetPlanePosition() const; + GetPlanePosition(); bool - IsPositionRelative() const; + IsPositionRelative(); void SetPlanePosition(vtkFloatingPointType thePosition, @@ -70,28 +72,28 @@ public: SetScaleFactor(vtkFloatingPointType theScaleFactor); vtkFloatingPointType - GetScaleFactor() const; + GetScaleFactor(); void SetContourPrs(bool theIsContourPrs ); bool - GetIsContourPrs() const; + GetIsContourPrs(); void SetNumberOfContours(int theNumber); int - GetNumberOfContours() const; + GetNumberOfContours(); void GetBasePlane (vtkFloatingPointType theOrigin[3], vtkFloatingPointType theNormal[3], - bool theCenterOrigine = false ) const; + bool theCenterOrigine = false ); void GetMinMaxPosition( vtkFloatingPointType& minPos, - vtkFloatingPointType& maxPos ) const; + vtkFloatingPointType& maxPos ); public: virtual @@ -121,8 +123,8 @@ protected: VISU_Plot3DPL(const VISU_Plot3DPL&); virtual - THook* - DoHook(); + vtkDataSet* + InsertCustomPL(); virtual void @@ -134,11 +136,11 @@ protected: vtkFloatingPointType myPosition, myScaleFactor; VISU_CutPlanesPL::PlaneOrientation myOrientation; - TVTKSmartPtr myCellDataToPointData; - TVTKSmartPtr myAppendPolyData; - TVTKSmartPtr myGeometryFilter; - TVTKSmartPtr myContourFilter; - TVTKSmartPtr myWarpScalar; + vtkSmartPointer myCellDataToPointData; + vtkSmartPointer myAppendPolyData; + vtkSmartPointer myGeometryFilter; + vtkSmartPointer myContourFilter; + vtkSmartPointer myWarpScalar; }; #endif diff --git a/src/PIPELINE/VISU_PointSpriteMapperHolder.cxx b/src/PIPELINE/VISU_PointSpriteMapperHolder.cxx new file mode 100644 index 00000000..69c9be26 --- /dev/null +++ b/src/PIPELINE/VISU_PointSpriteMapperHolder.cxx @@ -0,0 +1,122 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_PointSpriteMapperHolder.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_PointSpriteMapperHolder.hxx" +#include "VISU_OpenGLPointSpriteMapper.hxx" + +#include "VISU_PipeLineUtils.hxx" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_PointSpriteMapperHolder); + + +//---------------------------------------------------------------------------- +VISU_PointSpriteMapperHolder +::VISU_PointSpriteMapperHolder() +{ + if(MYDEBUG) + MESSAGE("VISU_PointSpriteMapperHolder::VISU_PointSpriteMapperHolder - "<(theMapperHolder)){ + if(theIsCopyInput) + SetGaussPtsIDMapper(aMapperHolder->GetGaussPtsIDMapper()); + + VISU::CopyPointSpriteDataMapper(GetPointSpriteMapper(), + aMapperHolder->GetPointSpriteMapper(), + theIsCopyInput); + } +} + + +//---------------------------------------------------------------------------- +void +VISU_PointSpriteMapperHolder +::SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theIDMapper) +{ + myGaussPtsIDMapper = theIDMapper; + SetPolyDataIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PGaussPtsIDMapper& +VISU_PointSpriteMapperHolder +::GetGaussPtsIDMapper() +{ + return myGaussPtsIDMapper; +} + + +//---------------------------------------------------------------------------- +void +VISU_PointSpriteMapperHolder +::OnCreateMapper() +{ + myPointSpriteMapper = VISU_OpenGLPointSpriteMapper::New(); + myPointSpriteMapper->Delete(); + myPointSpriteMapper->SetColorModeToMapScalars(); + myPointSpriteMapper->ScalarVisibilityOn(); + SetPolyDataMapper(myPointSpriteMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +VISU_OpenGLPointSpriteMapper* +VISU_PointSpriteMapperHolder +::GetPointSpriteMapper() +{ + GetMapper(); + return myPointSpriteMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PointSpriteMapperHolder.hxx b/src/PIPELINE/VISU_PointSpriteMapperHolder.hxx new file mode 100644 index 00000000..9aedbc62 --- /dev/null +++ b/src/PIPELINE/VISU_PointSpriteMapperHolder.hxx @@ -0,0 +1,81 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_PointSpriteMapperHolder.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_PointSpriteMapperHolder_HeaderFile +#define VISU_PointSpriteMapperHolder_HeaderFile + +#include "VISU_PolyDataMapperHolder.hxx" + +class VISU_OpenGLPointSpriteMapper; + + +//---------------------------------------------------------------------------- +class VISU_PointSpriteMapperHolder : public VISU_PolyDataMapperHolder +{ +public: + vtkTypeMacro(VISU_PointSpriteMapperHolder, VISU_PolyDataMapperHolder); + + static + VISU_PointSpriteMapperHolder* + New(); + + //---------------------------------------------------------------------------- + virtual + void + ShallowCopy(VISU_MapperHolder *theMapperHolder, + bool theIsCopyInput); + + //---------------------------------------------------------------------------- + void + SetGaussPtsIDMapper(const VISU::PGaussPtsIDMapper& theGaussPtsIDMapper); + + const VISU::PGaussPtsIDMapper& + GetGaussPtsIDMapper(); + + virtual + VISU_OpenGLPointSpriteMapper* + GetPointSpriteMapper(); + +protected: + //---------------------------------------------------------------------------- + VISU_PointSpriteMapperHolder(); + VISU_PointSpriteMapperHolder(const VISU_PointSpriteMapperHolder&); + + virtual + ~VISU_PointSpriteMapperHolder(); + + //---------------------------------------------------------------------------- + virtual + void + OnCreateMapper(); + +private: + //---------------------------------------------------------------------------- + VISU::PGaussPtsIDMapper myGaussPtsIDMapper; + vtkSmartPointer myPointSpriteMapper; +}; + +#endif diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.cxx b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx new file mode 100644 index 00000000..4a8c2e39 --- /dev/null +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.cxx @@ -0,0 +1,348 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_PolyDataMapperHolder.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_PolyDataMapperHolder.hxx" +#include "SALOME_ExtractPolyDataGeometry.h" +#include "VISU_LookupTable.hxx" + +#include "VISU_PipeLineUtils.hxx" + +#include +#include + +#include +#include +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_PolyDataMapperHolder); + + +//---------------------------------------------------------------------------- +VISU_PolyDataMapperHolder +::VISU_PolyDataMapperHolder(): + myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New()) +{ + if(MYDEBUG) MESSAGE("VISU_PolyDataMapperHolder::VISU_PolyDataMapperHolder - "<Delete(); + myExtractPolyDataGeometry->SetStoreMapping(true); + + vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); + myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean); + anImplicitBoolean->SetOperationTypeToIntersection(); + anImplicitBoolean->Delete(); +} + + +//---------------------------------------------------------------------------- +VISU_PolyDataMapperHolder +::~VISU_PolyDataMapperHolder() +{ + if(MYDEBUG) + MESSAGE("VISU_PolyDataMapperHolder::~VISU_PolyDataMapperHolder - "<(theMapperHolder)){ + if(theIsCopyInput) + SetPolyDataIDMapper(aMapperHolder->GetPolyDataIDMapper()); + + VISU::CopyPolyDataMapper(GetPolyDataMapper(), + aMapperHolder->GetPolyDataMapper(), + theIsCopyInput); + } +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_PolyDataMapperHolder +::GetMemorySize() +{ + unsigned long int aSize = 0; + + if(myExtractPolyDataGeometry->GetInput()) + if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + + aSize += Superclass::GetMemorySize(); + + return aSize; +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper) +{ + myExtractPolyDataGeometry->SetInput(theIDMapper->GetPolyDataOutput()); + myPolyDataIDMapper = theIDMapper; + SetIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PPolyDataIDMapper& +VISU_PolyDataMapperHolder +::GetPolyDataIDMapper() +{ + return myPolyDataIDMapper; +} + + +//---------------------------------------------------------------------------- +vtkPolyData* +VISU_PolyDataMapperHolder +::GetPolyDataInput() +{ + if(myPolyDataIDMapper) + return myPolyDataIDMapper->GetPolyDataOutput(); + + return NULL; +} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VISU_PolyDataMapperHolder +::GetClippedInput() +{ + vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput(); + aDataSet->Update(); + return aDataSet; +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::OnCreateMapper() +{ + myPolyDataMapper = vtkPolyDataMapper::New(); + myPolyDataMapper->Delete(); + SetMapper(myPolyDataMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetPolyDataMapper(vtkPolyDataMapper* theMapper) +{ + myPolyDataMapper = theMapper; + SetMapper(myPolyDataMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +vtkPolyDataMapper* +VISU_PolyDataMapperHolder +::GetPolyDataMapper() +{ + GetMapper(); + return myPolyDataMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetLookupTable(VISU_LookupTable* theLookupTable) +{ + myPolyDataMapper->SetLookupTable(theLookupTable); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataMapperHolder +::GetNodeObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID); + return Superclass::GetNodeObjID(anID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataMapperHolder +::GetNodeVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetNodeVTKID(theID); + return myExtractPolyDataGeometry->GetNodeVTKId(anID); +} + +//---------------------------------------------------------------------------- +vtkFloatingPointType* +VISU_PolyDataMapperHolder +::GetNodeCoord(vtkIdType theObjID) +{ + return Superclass::GetNodeCoord(theObjID); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataMapperHolder +::GetElemObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID); + return Superclass::GetElemObjID(anID); +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataMapperHolder +::GetElemVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetElemVTKID(theID); + return myExtractPolyDataGeometry->GetElemVTKId(anID); +} + +//---------------------------------------------------------------------------- +vtkCell* +VISU_PolyDataMapperHolder +::GetElemCell(vtkIdType theObjID) +{ + return Superclass::GetElemCell(theObjID); +} + + +//------------------------ Clipping planes ----------------------------------- +bool +VISU_PolyDataMapperHolder +::AddClippingPlane(vtkPlane* thePlane) +{ + if (thePlane) { + if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) { + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->AddItem(thePlane); + // Check, that at least one cell present after clipping. + // This check was introduced because of bug IPAL8849. + vtkDataSet* aClippedDataSet = GetClippedInput(); + if(aClippedDataSet->GetNumberOfCells() < 1) + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- +vtkPlane* +VISU_PolyDataMapperHolder +::GetClippingPlane(vtkIdType theID) +{ + vtkPlane* aPlane = NULL; + if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + vtkImplicitFunction* aFun = NULL; + aFunction->InitTraversal(); + for(vtkIdType anID = 0; anID <= theID; anID++) + aFun = aFunction->GetNextItem(); + aPlane = dynamic_cast(aFun); + } + } + return aPlane; +} + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::RemoveAllClippingPlanes() +{ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->RemoveAllItems(); + aBoolean->Modified(); // VTK bug + } +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataMapperHolder +::GetNumberOfClippingPlanes() +{ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + return aFunction->GetNumberOfItems(); + } + return 0; +} + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetImplicitFunction(vtkImplicitFunction *theFunction) +{ + myExtractPolyDataGeometry->SetImplicitFunction(theFunction); +} + +//---------------------------------------------------------------------------- +vtkImplicitFunction* +VISU_PolyDataMapperHolder +::GetImplicitFunction() +{ + return myExtractPolyDataGeometry->GetImplicitFunction(); +} + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetExtractInside(bool theMode) +{ + myExtractPolyDataGeometry->SetExtractInside(theMode); +} + +//---------------------------------------------------------------------------- +void +VISU_PolyDataMapperHolder +::SetExtractBoundaryCells(bool theMode) +{ + myExtractPolyDataGeometry->SetExtractBoundaryCells(theMode); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PolyDataMapperHolder.hxx b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx new file mode 100644 index 00000000..077dd91c --- /dev/null +++ b/src/PIPELINE/VISU_PolyDataMapperHolder.hxx @@ -0,0 +1,165 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_PolyDataMapperHolder.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_PolyDataMapperHolder_HeaderFile +#define VISU_PolyDataMapperHolder_HeaderFile + +#include "VISU_MapperHolder.hxx" + +class vtkPolyDataMapper; +class vtkPolyData; +class SALOME_ExtractPolyDataGeometry; + + +//---------------------------------------------------------------------------- +class VISU_PolyDataMapperHolder : public VISU_MapperHolder +{ +public: + vtkTypeMacro(VISU_PolyDataMapperHolder, VISU_MapperHolder); + + static + VISU_PolyDataMapperHolder* + New(); + + //---------------------------------------------------------------------------- + virtual + void + ShallowCopy(VISU_MapperHolder *theMapperHolder, + bool theIsCopyInput); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //---------------------------------------------------------------------------- + void + SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper); + + const VISU::PPolyDataIDMapper& + GetPolyDataIDMapper(); + + virtual + vtkPolyData* + GetPolyDataInput(); + + virtual + vtkPolyDataMapper* + GetPolyDataMapper(); + + //---------------------------------------------------------------------------- + virtual + vtkIdType + GetNodeObjID(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID); + + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetElemObjID(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID); + + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + + //---------------------------------------------------------------------------- + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + virtual + vtkImplicitFunction* + GetImplicitFunction(); + + virtual + void + SetExtractInside(bool theMode); + + virtual + void + SetExtractBoundaryCells(bool theMode); + + //---------------------------------------------------------------------------- + // Clipping planes + virtual + void + RemoveAllClippingPlanes(); + + virtual + vtkIdType + GetNumberOfClippingPlanes(); + + virtual + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID); + +protected: + //---------------------------------------------------------------------------- + VISU_PolyDataMapperHolder(); + VISU_PolyDataMapperHolder(const VISU_PolyDataMapperHolder&); + + virtual + ~VISU_PolyDataMapperHolder(); + + //---------------------------------------------------------------------------- + virtual + void + OnCreateMapper(); + + void + SetPolyDataMapper(vtkPolyDataMapper* theMapper); + + //---------------------------------------------------------------------------- + virtual + void + SetLookupTable(VISU_LookupTable* theLookupTable); + + virtual + vtkDataSet* + GetClippedInput(); + +private: + //---------------------------------------------------------------------------- + VISU::PPolyDataIDMapper myPolyDataIDMapper; + vtkSmartPointer myPolyDataMapper; + vtkSmartPointer myExtractPolyDataGeometry; //!< Clipping +}; + +#endif diff --git a/src/PIPELINE/VISU_PolyDataPL.cxx b/src/PIPELINE/VISU_PolyDataPL.cxx new file mode 100644 index 00000000..a10d93d3 --- /dev/null +++ b/src/PIPELINE/VISU_PolyDataPL.cxx @@ -0,0 +1,331 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_PolyDataPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_PolyDataPL.hxx" +#include "SALOME_ExtractPolyDataGeometry.h" + +#include "VISU_PipeLineUtils.hxx" + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +//---------------------------------------------------------------------------- +VISU_PolyDataPL +::VISU_PolyDataPL(): + myExtractPolyDataGeometry(SALOME_ExtractPolyDataGeometry::New()) +{ + if(MYDEBUG) MESSAGE("VISU_PolyDataPL::VISU_PolyDataPL - "<Delete(); + myExtractPolyDataGeometry->SetStoreMapping(true); + + vtkImplicitBoolean* anImplicitBoolean = vtkImplicitBoolean::New(); + myExtractPolyDataGeometry->SetImplicitFunction(anImplicitBoolean); + anImplicitBoolean->SetOperationTypeToIntersection(); + anImplicitBoolean->Delete(); +} + + +//---------------------------------------------------------------------------- +VISU_PolyDataPL +::~VISU_PolyDataPL() +{ + if(MYDEBUG) + MESSAGE("VISU_PolyDataPL::~VISU_PolyDataPL - "<SetInput(theIDMapper->GetPolyDataOutput()); + myPolyDataIDMapper = theIDMapper; + SetIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +const VISU::PPolyDataIDMapper& +VISU_PolyDataPL +::GetPolyDataIDMapper() const +{ + return myPolyDataIDMapper; +} + + +//---------------------------------------------------------------------------- +vtkPolyData* +VISU_PolyDataPL +::GetPolyDataInput() +{ + if(myPolyDataIDMapper) + return myPolyDataIDMapper->GetPolyDataOutput(); + + return NULL; +} + + +//---------------------------------------------------------------------------- +vtkPointSet* +VISU_PolyDataPL +::GetClippedInput() const +{ + vtkPolyData* aDataSet = myExtractPolyDataGeometry->GetOutput(); + aDataSet->Update(); + return aDataSet; +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::OnCreateMapper() +{ + myPolyDataMapper = vtkPolyDataMapper::New(); + myPolyDataMapper->Delete(); + SetMapper(myPolyDataMapper.GetPointer()); +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::SetPolyDataMapper(vtkPolyDataMapper* theMapper) +{ + myPolyDataMapper = theMapper; + SetMapper(theMapper); +} + + +//---------------------------------------------------------------------------- +vtkPolyDataMapper* +VISU_PolyDataPL +::GetPolyDataMapper() +{ + return myPolyDataMapper.GetPointer(); +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::DoCopyMapper(VISU_PipeLine *thePipeLine, + bool theIsCopyInput) +{ + if(VISU_PolyDataPL* aPipeLine = dynamic_cast(thePipeLine)){ + if(theIsCopyInput) + SetPolyDataIDMapper(aPipeLine->GetPolyDataIDMapper()); + Update(); + VISU::CopyPolyDataMapper(GetPolyDataMapper(), + aPipeLine->GetPolyDataMapper(), + theIsCopyInput); + } +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::SetLookupTable(VISU_LookupTable* theLookupTable) +{ + myPolyDataMapper->SetLookupTable(theLookupTable); +} + + +//---------------------------------------------------------------------------- +unsigned long int +VISU_PolyDataPL +::GetMemorySize() +{ + unsigned long int aSize = 0; + if(myExtractPolyDataGeometry->GetInput()) + if(vtkDataSet* aDataSet = myExtractPolyDataGeometry->GetOutput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + + aSize += Superclass::GetMemorySize(); + + return aSize; +} + + +//------------------------ Clipping planes ----------------------------------- +bool +VISU_PolyDataPL +::AddClippingPlane(vtkPlane* thePlane) +{ + if (thePlane) { + if (vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()) { + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->AddItem(thePlane); + // Check, that at least one cell present after clipping. + // This check was introduced because of bug IPAL8849. + vtkDataSet* aClippedDataSet = GetClippedInput(); + if(aClippedDataSet->GetNumberOfCells() < 1) + return false; + } + } + return true; +} + +//---------------------------------------------------------------------------- +vtkPlane* +VISU_PolyDataPL +::GetClippingPlane(vtkIdType theID) const +{ + vtkPlane* aPlane = NULL; + if(theID >= 0 && theID < GetNumberOfClippingPlanes()){ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + vtkImplicitFunction* aFun = NULL; + aFunction->InitTraversal(); + for(vtkIdType anID = 0; anID <= theID; anID++) + aFun = aFunction->GetNextItem(); + aPlane = dynamic_cast(aFun); + } + } + return aPlane; +} + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::RemoveAllClippingPlanes() +{ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->RemoveAllItems(); + aBoolean->Modified(); // VTK bug + } +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataPL +::GetNumberOfClippingPlanes() const +{ + if(vtkImplicitBoolean* aBoolean = myExtractPolyDataGeometry->GetImplicitBoolean()){ + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + return aFunction->GetNumberOfItems(); + } + return 0; +} + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataPL +::GetNodeObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractPolyDataGeometry->GetNodeObjId(theID); + return Superclass::GetNodeObjID(anID); +} + +vtkIdType +VISU_PolyDataPL +::GetNodeVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetNodeVTKID(theID); + return myExtractPolyDataGeometry->GetNodeVTKId(anID); +} + +vtkFloatingPointType* +VISU_PolyDataPL +::GetNodeCoord(int theObjID) +{ + return Superclass::GetNodeCoord(theObjID); +} + + +//---------------------------------------------------------------------------- +vtkIdType +VISU_PolyDataPL +::GetElemObjID(vtkIdType theID) +{ + vtkIdType anID = myExtractPolyDataGeometry->GetElemObjId(theID); + return Superclass::GetElemObjID(anID); +} + +vtkIdType +VISU_PolyDataPL +::GetElemVTKID(vtkIdType theID) +{ + vtkIdType anID = Superclass::GetElemVTKID(theID); + return myExtractPolyDataGeometry->GetElemVTKId(anID); +} + +vtkCell* +VISU_PolyDataPL +::GetElemCell(vtkIdType theObjID) +{ + return Superclass::GetElemCell(theObjID); +} + + +//---------------------------------------------------------------------------- +void +VISU_PolyDataPL +::SetImplicitFunction(vtkImplicitFunction *theFunction) +{ + myExtractPolyDataGeometry->SetImplicitFunction(theFunction); +} + +vtkImplicitFunction * +VISU_PolyDataPL +::GetImplicitFunction() +{ + return myExtractPolyDataGeometry->GetImplicitFunction(); +} + +SALOME_ExtractPolyDataGeometry* +VISU_PolyDataPL +::GetExtractPolyDataGeometryFilter() +{ + return myExtractPolyDataGeometry.GetPointer(); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_PolyDataPL.hxx b/src/PIPELINE/VISU_PolyDataPL.hxx new file mode 100644 index 00000000..1b8fa325 --- /dev/null +++ b/src/PIPELINE/VISU_PolyDataPL.hxx @@ -0,0 +1,153 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_UnstructuredGripPL.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_PolyDataPL_HeaderFile +#define VISU_PolyDataPL_HeaderFile + +#include "VISU_ColoredPL.hxx" + +class vtkPolyDataMapper; +class vtkPolyData; +class SALOME_ExtractPolyDataGeometry; + + +//---------------------------------------------------------------------------- +class VISU_PolyDataPL : public VISU_ColoredPL +{ +public: + vtkTypeMacro(VISU_PolyDataPL, VISU_ColoredPL); + + //---------------------------------------------------------------------------- + virtual + vtkPolyDataMapper* + GetPolyDataMapper(); + + virtual + vtkPolyData* + GetPolyDataInput(); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //---------------------------------------------------------------------------- + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + virtual + vtkImplicitFunction* + GetImplicitFunction(); + + virtual + SALOME_ExtractPolyDataGeometry* + GetExtractPolyDataGeometryFilter(); + + //---------------------------------------------------------------------------- + // Clipping planes + virtual + void + RemoveAllClippingPlanes(); + + virtual + vtkIdType + GetNumberOfClippingPlanes() const; + + virtual + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID) const; + + //---------------------------------------------------------------------------- + virtual + vtkIdType + GetNodeObjID(vtkIdType theID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID); + + virtual + vtkFloatingPointType* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetElemObjID(vtkIdType theID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID); + + virtual + vtkCell* + GetElemCell(vtkIdType theObjID); + + //---------------------------------------------------------------------------- + void + SetPolyDataIDMapper(const VISU::PPolyDataIDMapper& theIDMapper); + + const VISU::PPolyDataIDMapper& + GetPolyDataIDMapper() const; + +protected: + VISU_PolyDataPL(); + VISU_PolyDataPL(const VISU_PolyDataPL&); + + virtual + ~VISU_PolyDataPL(); + + virtual + void + DoCopyMapper(VISU_PipeLine *thePipeLine, + bool theIsCopyInput); + + virtual + void + OnCreateMapper(); + + void + SetPolyDataMapper(vtkPolyDataMapper* theMapper); + + virtual + void + SetLookupTable(VISU_LookupTable* theLookupTable); + + virtual + vtkPointSet* + GetClippedInput() const; + +private: + VISU::PPolyDataIDMapper myPolyDataIDMapper; + vtkSmartPointer myPolyDataMapper; + vtkSmartPointer myExtractPolyDataGeometry; //!< Clipping +}; + +#endif diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx index cfd0068f..2612324a 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.cxx @@ -25,21 +25,25 @@ // Module : VISU #include "VISU_ScalarMapOnDeformedShapePL.hxx" +#include "VISU_Extractor.hxx" +#include "VISU_LookupTable.hxx" #include "VISU_DeformedShapePL.hxx" -#include "VISU_PipeLineUtils.hxx" #include "VTKViewer_TransformFilter.h" #include "VTKViewer_Transform.h" +#include "VISU_PipeLineUtils.hxx" + #include #include #include #include #include -#include +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_ScalarMapOnDeformedShapePL) +//---------------------------------------------------------------------------- /*! * Constructor. Creating new instances of vtkWarpVector,vtkMergeFilter,vtkUnstructuredGrid * Where: @@ -57,6 +61,7 @@ VISU_ScalarMapOnDeformedShapePL myCellDataToPointData = vtkCellDataToPointData::New(); } +//---------------------------------------------------------------------------- /*! * Destructor. * Delete all fields. @@ -77,6 +82,7 @@ VISU_ScalarMapOnDeformedShapePL myCellDataToPointData->Delete(); } +//---------------------------------------------------------------------------- /*! * Initial method */ @@ -84,26 +90,25 @@ void VISU_ScalarMapOnDeformedShapePL ::Init() { - if (GetScalars() == NULL) SetScalars(GetInput2()); + if(GetScalars() == NULL) + SetScalars(GetClippedInput()); Superclass::Init(); vtkFloatingPointType aScalarRange[2]; GetSourceRange(aScalarRange); + static double EPS = 1.0 / VTK_LARGE_FLOAT; if(aScalarRange[1] > EPS) - SetScale(VISU_DeformedShapePL::GetScaleFactor(GetInput2())/aScalarRange[1]); + SetScale(VISU_DeformedShapePL::GetScaleFactor(GetClippedInput()) / aScalarRange[1]); else SetScale(0.0); - myMapper->SetColorModeToMapScalars(); - myMapper->ScalarVisibilityOn(); - - // Sets input for field transformation filter - myFieldTransform->SetInput(myExtractor->GetOutput()); - + GetMapper()->SetColorModeToMapScalars(); + GetMapper()->ScalarVisibilityOn(); } +//---------------------------------------------------------------------------- /*! * Build method * Building of deformation and puts result to merge filter. @@ -112,19 +117,20 @@ void VISU_ScalarMapOnDeformedShapePL ::Build() { - // Set input for extractor - myExtractor->SetInput(GetInput2()); - - VISU::CellDataToPoint(myDeformVectors,myCellDataToPointData, - GetInput2(),myFieldTransform); + VISU::CellDataToPoint(myDeformVectors, + myCellDataToPointData, + GetClippedInput(), + GetFieldTransformFilter()); // Sets geometry for merge filter myMergeFilter->SetGeometry(myDeformVectors->GetOutput()); myMergeFilter->SetScalars(myExtractorScalars->GetOutput()); + // Sets data to mapper - myMapper->SetInput(myMergeFilter->GetOutput()); + GetDataSetMapper()->SetInput(myMergeFilter->GetOutput()); } +//---------------------------------------------------------------------------- /*! * Update method */ @@ -138,15 +144,15 @@ VISU_ScalarMapOnDeformedShapePL GetSourceRange(aRange); vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; - if(myBarTable->GetScale() == VTK_SCALE_LOG10) + if(GetBarTable()->GetScale() == VTK_SCALE_LOG10) VISU_LookupTable::ComputeLogRange(aRange,aScalarRange); - myMapperTable->SetRange(aScalarRange); + GetMapperTable()->SetRange(aScalarRange); - myMapperTable->Build(); - myBarTable->Build(); + GetMapperTable()->Build(); + GetBarTable()->Build(); - myMapper->SetLookupTable(myMapperTable); - myMapper->SetScalarRange(aScalarRange); + GetMapper()->SetLookupTable(GetMapperTable()); + GetMapper()->SetScalarRange(aScalarRange); VISU_PipeLine::Update(); } @@ -175,7 +181,6 @@ VISU_ScalarMapOnDeformedShapePL return aSize; } - //---------------------------------------------------------------------------- /*! * Update scalars method. @@ -188,6 +193,7 @@ VISU_ScalarMapOnDeformedShapePL myExtractorScalars->Update(); } +//---------------------------------------------------------------------------- /*! * Copy information about pipline. * Copy scale and scalars. @@ -204,9 +210,11 @@ VISU_ScalarMapOnDeformedShapePL aPipeLine->GetSourceRange(aRange); SetScalarRange(aRange); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } +//---------------------------------------------------------------------------- /*! * Set scalars. * Sets vtkDataSet with scalars values to VISU_Extractor filter for scalars extraction. @@ -236,6 +244,7 @@ VISU_ScalarMapOnDeformedShapePL Modified(); } +//---------------------------------------------------------------------------- /*! * Get pointer to input scalars. */ @@ -246,6 +255,7 @@ VISU_ScalarMapOnDeformedShapePL return myScalars.GetPointer(); } +//---------------------------------------------------------------------------- /*! * Sets scale for deformed shape */ @@ -253,12 +263,14 @@ void VISU_ScalarMapOnDeformedShapePL ::SetScale(vtkFloatingPointType theScale) { - if(myScaleFactor == theScale) return; - myScaleFactor = theScale; + if(VISU::CheckIsSameValue(myScaleFactor, theScale)) + return; + myDeformVectors->SetScaleFactor(myScaleFactor); - Modified(); + myScaleFactor = theScale; } +//---------------------------------------------------------------------------- /*! * Gets scale of deformed shape. */ @@ -266,10 +278,10 @@ vtkFloatingPointType VISU_ScalarMapOnDeformedShapePL ::GetScale() { - vtkFloatingPointType aScale=myDeformVectors->GetScaleFactor(); - return aScale; + return myDeformVectors->GetScaleFactor(); } +//---------------------------------------------------------------------------- /*! * Set scale factor of deformation. */ @@ -277,10 +289,10 @@ void VISU_ScalarMapOnDeformedShapePL ::SetMapScale(vtkFloatingPointType theMapScale) { - myDeformVectors->SetScaleFactor(myScaleFactor*theMapScale); - Modified(); + myDeformVectors->SetScaleFactor(myScaleFactor * theMapScale); } +//---------------------------------------------------------------------------- /*! * Gets scalar mode. */ @@ -288,10 +300,10 @@ int VISU_ScalarMapOnDeformedShapePL ::GetScalarMode() { - int aMode=myExtractorScalars->GetScalarMode(); - return aMode; + return myExtractorScalars->GetScalarMode(); } +//---------------------------------------------------------------------------- /*! * Sets scalar mode. */ @@ -303,6 +315,7 @@ VISU_ScalarMapOnDeformedShapePL Modified(); } +//---------------------------------------------------------------------------- /*! * Gets ranges of extracted scalars * \param theRange[2] - output values diff --git a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx index b09ed168..f4284b06 100644 --- a/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx +++ b/src/PIPELINE/VISU_ScalarMapOnDeformedShapePL.hxx @@ -35,11 +35,12 @@ class vtkUnstructuredGrid; class vtkCellDataToPointData; class vtkPointDataToCellData; + +//---------------------------------------------------------------------------- class VISU_ScalarMapOnDeformedShapePL : public VISU_ScalarMapPL { -protected: public: - vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL,VISU_ScalarMapPL); + vtkTypeMacro(VISU_ScalarMapOnDeformedShapePL, VISU_ScalarMapPL); static VISU_ScalarMapOnDeformedShapePL* diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index 1ad9bbe6..1153b5d3 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -21,296 +21,53 @@ // // // -// File: VISU_PipeLine.cxx +// File: VISU_ScalarMapPL.cxx // Author: Alexey PETROV // Module : VISU #include "VISU_ScalarMapPL.hxx" -#include "VISU_PipeLineUtils.hxx" -#include "SALOME_ExtractGeometry.h" +#include "VISU_DataSetMapperHolder.hxx" - -//============================================================================ -vtkStandardNewMacro(VISU_ScalarMapPL); - - -//---------------------------------------------------------------------------- -VISU_ScalarMapPL -::VISU_ScalarMapPL() -{ - myMapperTable = VISU_LookupTable::New(); - myMapperTable->SetScale(VTK_SCALE_LINEAR); - myMapperTable->SetHueRange(0.667,0.0); - - myBarTable = VISU_LookupTable::New(); - myBarTable->SetScale(VTK_SCALE_LINEAR); - myBarTable->SetHueRange(0.667,0.0); - - myExtractor = VISU_Extractor::New(); - myExtractor->SetInput(myExtractGeometry->GetOutput()); - - myFieldTransform = VISU_FieldTransform::New(); - myFieldTransform->SetInput(myExtractor->GetOutput()); - - myIsShrinkable = true; -} - - -VISU_ScalarMapPL -::~VISU_ScalarMapPL() -{ - myFieldTransform->Delete(); - myMapperTable->Delete(); - myBarTable->Delete(); - myExtractor->Delete(); -} - - -//---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput) -{ - if(VISU_ScalarMapPL *aPipeLine = dynamic_cast(thePipeLine)){ - if(theIsCopyInput) - SetScalarRange(aPipeLine->GetScalarRange()); - SetScalarMode(aPipeLine->GetScalarMode()); - SetNbColors(aPipeLine->GetNbColors()); - SetScaling(aPipeLine->GetScaling()); - SetMapScale(aPipeLine->GetMapScale()); - } - Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); -} - - -//---------------------------------------------------------------------------- -int -VISU_ScalarMapPL -::GetScalarMode() -{ - return myExtractor->GetScalarMode(); -} - -void -VISU_ScalarMapPL -::SetScalarMode(int theScalarMode) -{ - vtkDataSet *input = GetInput(); - if (input){ - if(input->GetPointData()->GetNumberOfArrays()){ - vtkPointData *inData = input->GetPointData(); - if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)) { - if (theScalarMode==0){ - return; - } - } - } - else { - vtkCellData *inData = input->GetCellData(); - if(!inData->GetAttribute(vtkDataSetAttributes::VECTORS)){ - if (theScalarMode==0){ - return; - } - } - } - } - // - myExtractor->SetScalarMode(theScalarMode); -} +#include +#include //---------------------------------------------------------------------------- -int -VISU_ScalarMapPL -::GetScaling() -{ - return myBarTable->GetScale(); -} - -void -VISU_ScalarMapPL -::SetScaling(int theScaling) -{ - myBarTable->SetScale(theScaling); - if(theScaling == VTK_SCALE_LOG10) - myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Log10)); - else - myFieldTransform->SetScalarTransform(&(VISU_FieldTransform::Ident)); -} +vtkStandardNewMacro(VISU_ScalarMapPL); //---------------------------------------------------------------------------- -vtkFloatingPointType* -VISU_ScalarMapPL -::GetScalarRange() -{ - return myFieldTransform->GetScalarRange(); -} - -void -VISU_ScalarMapPL -::SetScalarRange(vtkFloatingPointType theRange[2]) -{ - if(!VISU::CheckIsSameRange(GetScalarRange(), theRange)){ - myFieldTransform->SetScalarRange(theRange); - myBarTable->SetRange(theRange); - } -} - -void -VISU_ScalarMapPL -::SetScalarMin(vtkFloatingPointType theValue) -{ - vtkFloatingPointType aScalarRange[2] = {theValue, GetScalarRange()[1]}; - if(!VISU::CheckIsSameRange(GetScalarRange(), aScalarRange)) - SetScalarRange(aScalarRange); -} - -void VISU_ScalarMapPL -::SetScalarMax(vtkFloatingPointType theValue) -{ - vtkFloatingPointType aScalarRange[2] = {GetScalarRange()[0], theValue}; - if(!VISU::CheckIsSameRange(GetScalarRange(), aScalarRange)) - SetScalarRange(aScalarRange); -} +::VISU_ScalarMapPL(): + VISU_UnstructuredGridPL(this) +{} //---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::SetNbColors(int theNbColors) -{ - myMapperTable->SetNumberOfColors(theNbColors); - myBarTable->SetNumberOfColors(theNbColors); -} - -int VISU_ScalarMapPL -::GetNbColors() -{ - return myMapperTable->GetNumberOfColors(); -} +::~VISU_ScalarMapPL() +{} //---------------------------------------------------------------------------- -VISU_ScalarMapPL::THook* +void VISU_ScalarMapPL -::DoHook() +::OnCreateMapperHolder() { - myMapper->SetColorModeToMapScalars(); - myMapper->ScalarVisibilityOn(); - return myFieldTransform->GetUnstructuredGridOutput(); + VISU_UnstructuredGridPL::OnCreateMapperHolder(); } -//---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::Init() -{ - SetScalarMode(0); - SetSourceRange(); -} - //---------------------------------------------------------------------------- void VISU_ScalarMapPL ::Build() { - myMapper->SetInput(DoHook()); -} - - -//---------------------------------------------------------------------------- -unsigned long int -VISU_ScalarMapPL -::GetMemorySize() -{ - vtkDataSet* aDataSet = myExtractor->GetOutput(); - unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024; - - aDataSet = myFieldTransform->GetOutput(); - aSize += aDataSet->GetActualMemorySize() * 1024; - - aSize += Superclass::GetMemorySize(); - - return aSize; -} - - -//---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::Update() -{ - vtkFloatingPointType *aRange = GetScalarRange(); - vtkFloatingPointType aScalarRange[2] = {aRange[0], aRange[1]}; - if(myBarTable->GetScale() == VTK_SCALE_LOG10) - VISU_LookupTable::ComputeLogRange(aRange, aScalarRange); - - if(!VISU::CheckIsSameRange(myMapperTable->GetTableRange(), aScalarRange)) - myMapperTable->SetRange(aScalarRange); - - myMapperTable->Build(); - myBarTable->Build(); - - myMapper->SetLookupTable(myMapperTable); - if(!VISU::CheckIsSameRange(myMapper->GetScalarRange(), aScalarRange)) - myMapper->SetScalarRange(aScalarRange); - - Superclass::Update(); -} - - -//---------------------------------------------------------------------------- -VISU_LookupTable * -VISU_ScalarMapPL -::GetMapperTable() -{ - return myMapperTable; -} - -VISU_LookupTable* -VISU_ScalarMapPL -::GetBarTable() -{ - return myBarTable; -} - - -//---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::SetMapScale(vtkFloatingPointType theMapScale) -{ - myMapperTable->SetMapScale(theMapScale); - myMapperTable->Build(); -} + Superclass::Build(); -vtkFloatingPointType -VISU_ScalarMapPL::GetMapScale() -{ - return myMapperTable->GetMapScale(); + GetDataSetMapper()->SetInput(InsertCustomPL()); } //---------------------------------------------------------------------------- -void -VISU_ScalarMapPL -::GetSourceRange(vtkFloatingPointType theRange[2]) -{ - myExtractor->Update(); - myExtractor->GetOutput()->GetScalarRange(theRange); -} - -void -VISU_ScalarMapPL -::SetSourceRange() -{ - vtkFloatingPointType aRange[2]; - GetSourceRange(aRange); - SetScalarRange(aRange); -} diff --git a/src/PIPELINE/VISU_ScalarMapPL.hxx b/src/PIPELINE/VISU_ScalarMapPL.hxx index 9d976381..55295f5f 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.hxx +++ b/src/PIPELINE/VISU_ScalarMapPL.hxx @@ -21,138 +21,45 @@ // // // -// File: VISU_PipeLine.hxx +// File: VISU_ScalarMapPL.hxx // Author: Alexey PETROV // Module : VISU -#ifndef VISU_ScalrMapPL_HeaderFile -#define VISU_ScalrMapPL_HeaderFile +#ifndef VISU_ScalarMapPL_HeaderFile +#define VISU_ScalarMapPL_HeaderFile -#include "VISU_PipeLine.hxx" -#include "VISU_ScalarBarActor.hxx" +#include "VISU_ColoredPL.hxx" +#include "VISU_UnstructuredGridPL.hxx" -class vtkCell; -class vtkDataSet; +class VISU_DataSetMapperHolder; -class VISU_Extractor; -class VISU_FieldTransform; - -//============================================================================ -class VISU_ScalarMapPL : public VISU_PipeLine +//---------------------------------------------------------------------------- +class VISU_ScalarMapPL : public VISU_ColoredPL, + public VISU_UnstructuredGridPL { -protected: - VISU_ScalarMapPL(); - VISU_ScalarMapPL(const VISU_ScalarMapPL&); - - virtual - ~VISU_ScalarMapPL(); - public: - //---------------------------------------------------------------------------- - vtkTypeMacro(VISU_ScalarMapPL,VISU_PipeLine); + vtkTypeMacro(VISU_ScalarMapPL, VISU_ColoredPL); - static + static VISU_ScalarMapPL* New(); +protected: //---------------------------------------------------------------------------- - virtual - int - GetScalarMode(); - - virtual - void - SetScalarMode(int theScalarMode = 0); - - virtual - int - GetScaling(); - virtual - void - SetScaling(int theScaling = VTK_SCALE_LINEAR); - - virtual - vtkFloatingPointType* - GetScalarRange(); - - virtual - void - SetScalarRange(vtkFloatingPointType theRange[2]); - - virtual - void - SetScalarMin(vtkFloatingPointType theValue); - - virtual - void - SetScalarMax(vtkFloatingPointType theValue); + VISU_ScalarMapPL(); + VISU_ScalarMapPL(const VISU_ScalarMapPL&); virtual - void - SetNbColors(int theNbColors = 16); + ~VISU_ScalarMapPL(); - virtual - int - GetNbColors(); - - //---------------------------------------------------------------------------- -public: virtual void - Init(); + OnCreateMapperHolder(); virtual void Build(); - - virtual - void - Update(); - - //! Gets memory size used by the instance (bytes). - virtual - unsigned long int - GetMemorySize(); - - virtual - VISU_LookupTable* - GetMapperTable(); - - virtual - VISU_LookupTable* - GetBarTable(); - - virtual - void - SetMapScale(vtkFloatingPointType theMapScale = 1.0); - - virtual - vtkFloatingPointType - GetMapScale(); - - virtual - void - GetSourceRange(vtkFloatingPointType theRange[2]); - - virtual - void - SetSourceRange(); - - //---------------------------------------------------------------------------- -protected: - typedef vtkDataSet THook; - virtual THook* DoHook(); - - virtual - void - DoShallowCopy(VISU_PipeLine *thePipeLine, - bool theIsCopyInput); - - VISU_LookupTable* myMapperTable; - VISU_LookupTable* myBarTable; - VISU_FieldTransform* myFieldTransform; - VISU_Extractor* myExtractor; }; #endif diff --git a/src/PIPELINE/VISU_StreamLinesPL.cxx b/src/PIPELINE/VISU_StreamLinesPL.cxx index aeb1c9ed..93706555 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.cxx +++ b/src/PIPELINE/VISU_StreamLinesPL.cxx @@ -20,20 +20,22 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File: VISU_PipeLine.cxx +// File: VISU_StreamLinesPL.cxx // Author: Alexey PETROV // Module : VISU #include "VISU_StreamLinesPL.hxx" -#include "VISU_PipeLineUtils.hxx" +#include "VISU_Extractor.hxx" #include "VISU_UsedPointsFilter.hxx" #include "VTKViewer_GeometryFilter.h" +#include "VISU_PipeLineUtils.hxx" + #include #include -#include +#include #include #ifdef _DEBUG_ @@ -48,8 +50,11 @@ static vtkFloatingPointType aMinNbOfSteps = 1.0E+2; static vtkFloatingPointType aCoeffOfIntStep = 1.0E+1; +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_StreamLinesPL); + +//---------------------------------------------------------------------------- VISU_StreamLinesPL ::VISU_StreamLinesPL() { @@ -61,22 +66,26 @@ VISU_StreamLinesPL mySource = NULL; } + +//---------------------------------------------------------------------------- VISU_StreamLinesPL ::~VISU_StreamLinesPL() { - myPointsFilter->UnRegisterAllOutputs(); myPointsFilter->Delete(); + myPointsFilter = NULL; myCenters->UnRegisterAllOutputs(); - myCenters->Delete(); + myCenters = NULL; myGeomFilter->UnRegisterAllOutputs(); - myGeomFilter->Delete(); + myGeomFilter = NULL; myStream->UnRegisterAllOutputs(); - myStream->Delete(); + myStream = NULL; } + +//---------------------------------------------------------------------------- void VISU_StreamLinesPL ::DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -90,10 +99,12 @@ VISU_StreamLinesPL aPipeLine->GetUsedPoints(), aPipeLine->GetDirection()); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } +//---------------------------------------------------------------------------- size_t VISU_StreamLinesPL ::GetNecasseryMemorySize(vtkIdType theNbOfPoints, @@ -122,9 +133,11 @@ VISU_StreamLinesPL return aResult; } + +//---------------------------------------------------------------------------- size_t VISU_StreamLinesPL -::FindPossibleParams(vtkPointSet* theDataSet, +::FindPossibleParams(vtkDataSet* theDataSet, vtkFloatingPointType& theStepLength, vtkFloatingPointType& thePropogationTime, vtkFloatingPointType& thePercents) @@ -162,29 +175,45 @@ VISU_StreamLinesPL } +//---------------------------------------------------------------------------- size_t VISU_StreamLinesPL ::SetParams(vtkFloatingPointType theIntStep, vtkFloatingPointType thePropogationTime, vtkFloatingPointType theStepLength, - vtkPointSet* theSource, + vtkDataSet* theSource, vtkFloatingPointType thePercents, int theDirection, int isOnlyTry) { - vtkPointSet* aDataSet = theSource? theSource: myFieldTransform->GetUnstructuredGridOutput(); + vtkDataSet* aDataSet = theSource? theSource: + GetFieldTransformFilter()->GetUnstructuredGridOutput(); aDataSet->Update(); + vtkIdType aNbOfPoints = aDataSet->GetNumberOfPoints(); - vtkPointSet* aPointSet = myExtractor->GetOutput(); - if(thePercents*aNbOfPoints < 1) thePercents = 2.0/aNbOfPoints; - theIntStep = CorrectIntegrationStep(theIntStep,aPointSet,thePercents); - thePropogationTime = CorrectPropagationTime(thePropogationTime,aPointSet); - theStepLength = CorrectStepLength(theStepLength,aPointSet); - size_t isAccepted = FindPossibleParams(aPointSet,theStepLength,thePropogationTime,thePercents); + vtkDataSet* aPointSet = GetExtractorFilter()->GetOutput(); + if(thePercents * aNbOfPoints < 1) + thePercents = 2.0 / aNbOfPoints; + + theIntStep = CorrectIntegrationStep(theIntStep, + aPointSet, + thePercents); + + thePropogationTime = CorrectPropagationTime(thePropogationTime, + aPointSet); + + theStepLength = CorrectStepLength(theStepLength, + aPointSet); + + size_t isAccepted = FindPossibleParams(aPointSet, + theStepLength, + thePropogationTime, + thePercents); + if((!isOnlyTry && isAccepted) || (isOnlyTry && isAccepted == 1)){ mySource = theSource; myPercents = thePercents; - if(GetInput2()->GetCellData()->GetNumberOfArrays()){ + if(GetClippedInput()->GetCellData()->GetNumberOfArrays()){ myCenters->SetInput(aDataSet); myCenters->VertexCellsOn(); aDataSet = myCenters->GetOutput(); @@ -205,13 +234,16 @@ VISU_StreamLinesPL } -vtkPointSet* +//---------------------------------------------------------------------------- +vtkDataSet* VISU_StreamLinesPL ::GetSource() { return mySource; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetUsedPoints() @@ -219,6 +251,8 @@ VISU_StreamLinesPL return myPercents; } + +//---------------------------------------------------------------------------- vtkDataSet* VISU_StreamLinesPL ::GetStreamerSource() @@ -226,40 +260,48 @@ VISU_StreamLinesPL return myStream->GetSource(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetVelocityCoeff() { - return GetVelocityCoeff(myExtractor->GetOutput()); + return GetVelocityCoeff(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetVelocityCoeff(vtkPointSet* theDataSet) +::GetVelocityCoeff(vtkDataSet* theDataSet) { vtkFloatingPointType* aScalarRange = theDataSet->GetScalarRange(); return (fabs(aScalarRange[1]) + fabs(aScalarRange[0]))/2.0; } +//---------------------------------------------------------------------------- size_t VISU_StreamLinesPL -::IsPossible(vtkPointSet* theDataSet, +::IsPossible(vtkDataSet* theDataSet, vtkFloatingPointType thePercents) { vtkFloatingPointType aStepLength = GetBaseStepLength(theDataSet); vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet); VISU_UsedPointsFilter *aPointsFilter = VISU_UsedPointsFilter::New(); aPointsFilter->SetInput(theDataSet); - vtkPointSet* aDataSet = aPointsFilter->GetOutput(); + vtkDataSet* aDataSet = aPointsFilter->GetOutput(); aDataSet->Update(); - size_t aRes = FindPossibleParams(aDataSet,aStepLength,aBasePropTime,thePercents); - aPointsFilter->UnRegisterAllOutputs(); + size_t aRes = FindPossibleParams(aDataSet, + aStepLength, + aBasePropTime, + thePercents); aPointsFilter->Delete(); return aRes; } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetIntegrationStep() @@ -267,6 +309,8 @@ VISU_StreamLinesPL return myStream->GetIntegrationStepLength(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetStepLength() @@ -274,6 +318,8 @@ VISU_StreamLinesPL return myStream->GetStepLength(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetPropagationTime() @@ -281,6 +327,8 @@ VISU_StreamLinesPL return myStream->GetMaximumPropagationTime(); } + +//---------------------------------------------------------------------------- int VISU_StreamLinesPL ::GetDirection() @@ -289,15 +337,19 @@ VISU_StreamLinesPL } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMinIntegrationStep(vtkPointSet* theDataSet, +::GetMinIntegrationStep(vtkDataSet* theDataSet, vtkFloatingPointType thePercents) { - if(!theDataSet) return -1.0; - vtkFloatingPointType aVolume = 1.0; - int degree = 0; + if(!theDataSet) + return -1.0; + theDataSet->Update(); + + int degree = 0; + vtkFloatingPointType aVolume = 1.0; vtkFloatingPointType* aBounds = theDataSet->GetBounds(); for(int i = 0, j = 0; i < 3; ++i, j = 2*i){ vtkFloatingPointType tmp = aBounds[j+1] - aBounds[j]; @@ -306,7 +358,10 @@ VISU_StreamLinesPL degree += 1; } } - if (degree < 1) return 0.0; // absolutely empty object + + if (degree < 1) + return 0.0; // absolutely empty object + vtkFloatingPointType anStepLength = GetMaxIntegrationStep(theDataSet)/aCoeffOfIntStep; vtkFloatingPointType aBasePropTime = GetBasePropagationTime(theDataSet)/GetVelocityCoeff(theDataSet); thePercents = 1.0; @@ -318,211 +373,286 @@ VISU_StreamLinesPL return aStep; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetMinIntegrationStep() { - return GetMinIntegrationStep(myExtractor->GetOutput(),GetUsedPoints()); + return GetMinIntegrationStep(GetExtractorFilter()->GetOutput(), GetUsedPoints()); } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMaxIntegrationStep(vtkPointSet* theDataSet) +::GetMaxIntegrationStep(vtkDataSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; + theDataSet->Update(); + vtkFloatingPointType aLength = theDataSet->GetLength(); vtkFloatingPointType* aBounds = theDataSet->GetBounds(); vtkFloatingPointType aMaxSizeY = (aBounds[3]-aBounds[2])/aLength; vtkFloatingPointType aMaxSizeZ = (aBounds[5]-aBounds[4])/aLength; vtkFloatingPointType aMinMax = (aBounds[1] - aBounds[0])/aLength; - if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) aMinMax = aMaxSizeY; - if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) aMinMax = aMaxSizeZ; + if (aMinMax < EPS || (aMaxSizeY < aMinMax && aMaxSizeY > EPS)) + aMinMax = aMaxSizeY; + if (aMinMax < EPS || (aMaxSizeZ < aMinMax && aMaxSizeZ > EPS)) + aMinMax = aMaxSizeZ; return aMinMax*aLength/2.0; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetMaxIntegrationStep() { - return GetMaxIntegrationStep(myExtractor->GetOutput()); + return GetMaxIntegrationStep(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetBaseIntegrationStep(vtkPointSet* theDataSet, +::GetBaseIntegrationStep(vtkDataSet* theDataSet, vtkFloatingPointType thePercents) { theDataSet->Update(); - vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents); + vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet); vtkFloatingPointType anIntegrationStep = aMaxIntegrationStep / aCoeffOfIntStep; - vtkFloatingPointType aMinMax = theDataSet->GetLength()/theDataSet->GetNumberOfPoints(); + vtkFloatingPointType aMinMax = theDataSet->GetLength() / theDataSet->GetNumberOfPoints(); if(aMinMax > anIntegrationStep) anIntegrationStep = (anIntegrationStep*aCoeffOfIntStep*0.9+aMinMax)/aCoeffOfIntStep; + + vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents); if(aMinIntegrationStep > anIntegrationStep) anIntegrationStep = aMinIntegrationStep; + return anIntegrationStep; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::CorrectIntegrationStep(vtkFloatingPointType theStep, - vtkPointSet* theDataSet, + vtkDataSet* theDataSet, vtkFloatingPointType thePercents) { theDataSet->Update(); - vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet,thePercents); - vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet); + + vtkFloatingPointType aMinIntegrationStep = GetMinIntegrationStep(theDataSet, thePercents); if(aMinIntegrationStep > theStep) theStep = aMinIntegrationStep; + + vtkFloatingPointType aMaxIntegrationStep = GetMaxIntegrationStep(theDataSet); if(aMaxIntegrationStep < theStep) theStep = aMaxIntegrationStep; + return theStep; } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMinPropagationTime(vtkPointSet* theDataSet) +::GetMinPropagationTime(vtkDataSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; + return GetMinStepLength(theDataSet); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetMinPropagationTime() { - return GetMinPropagationTime(myExtractor->GetOutput()); + return GetMinPropagationTime(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMaxPropagationTime(vtkPointSet* theDataSet) +::GetMaxPropagationTime(vtkDataSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; + return GetBasePropagationTime(theDataSet)*aMinNbOfSteps; } -vtkFloatingPointType VISU_StreamLinesPL::GetMaxPropagationTime(){ - return GetMaxPropagationTime(myExtractor->GetOutput()); + +//---------------------------------------------------------------------------- +vtkFloatingPointType +VISU_StreamLinesPL +::GetMaxPropagationTime() +{ + return GetMaxPropagationTime(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::CorrectPropagationTime(vtkFloatingPointType thePropagationTime, - vtkPointSet* theDataSet) + vtkDataSet* theDataSet) { vtkFloatingPointType aMinPropagationTime = GetMinPropagationTime(theDataSet); - vtkFloatingPointType aMaxPropagationTime = GetMaxPropagationTime(theDataSet); if(aMinPropagationTime > thePropagationTime) thePropagationTime = aMinPropagationTime; + + vtkFloatingPointType aMaxPropagationTime = GetMaxPropagationTime(theDataSet); if(aMaxPropagationTime < thePropagationTime) thePropagationTime = aMaxPropagationTime; + return thePropagationTime; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetBasePropagationTime(vtkPointSet* theDataSet) +::GetBasePropagationTime(vtkDataSet* theDataSet) { - if(!theDataSet) return -1.0; + if(!theDataSet) + return -1.0; + theDataSet->Update(); - vtkFloatingPointType aPropagationTime = theDataSet->GetLength()/GetVelocityCoeff(theDataSet); + vtkFloatingPointType aPropagationTime = theDataSet->GetLength() / GetVelocityCoeff(theDataSet); + return aPropagationTime; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetBasePropagationTime() { - return GetBasePropagationTime(myExtractor->GetOutput()); + return GetBasePropagationTime(GetExtractorFilter()->GetOutput()); } +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMinStepLength(vtkPointSet* theDataSet) +::GetMinStepLength(vtkDataSet* theDataSet) { static vtkFloatingPointType aNbOfStepsOfIntStep = 1.0E+1; vtkFloatingPointType anIntStep = GetMinIntegrationStep(theDataSet); - vtkFloatingPointType aStepLength = anIntStep*aNbOfStepsOfIntStep/GetVelocityCoeff(theDataSet); + vtkFloatingPointType aStepLength = anIntStep * aNbOfStepsOfIntStep / GetVelocityCoeff(theDataSet); return aStepLength; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetMinStepLength() { - return GetMinStepLength(myExtractor->GetOutput()); + return GetMinStepLength(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetMaxStepLength(vtkPointSet* theDataSet) +::GetMaxStepLength(vtkDataSet* theDataSet) { vtkFloatingPointType aStepLength = GetBasePropagationTime(theDataSet); return aStepLength; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::GetMaxStepLength() { - return GetMaxStepLength(myExtractor->GetOutput()); + return GetMaxStepLength(GetExtractorFilter()->GetOutput()); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL ::CorrectStepLength(vtkFloatingPointType theStep, - vtkPointSet* theDataSet) + vtkDataSet* theDataSet) { vtkFloatingPointType aMinStep = GetMinStepLength(theDataSet); - if(theStep < aMinStep) theStep = aMinStep; + if(theStep < aMinStep) + theStep = aMinStep; + vtkFloatingPointType aMaxStep = GetMaxStepLength(theDataSet); - if(theStep > aMaxStep) theStep = aMaxStep; + if(theStep > aMaxStep) + theStep = aMaxStep; + return theStep; } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_StreamLinesPL -::GetBaseStepLength(vtkPointSet* theDataSet) +::GetBaseStepLength(vtkDataSet* theDataSet) { static vtkFloatingPointType anAvgNbOfSteps = 1.0E+2; vtkFloatingPointType aPropagationTime = GetBasePropagationTime(theDataSet); vtkFloatingPointType aStepLength = aPropagationTime/anAvgNbOfSteps; aStepLength = CorrectStepLength(aStepLength,theDataSet); + return aStepLength; } +//---------------------------------------------------------------------------- void VISU_StreamLinesPL ::Init() { VISU_ScalarMapPL::Init(); - vtkPointSet* aDataSet = myExtractor->GetOutput(); + + vtkDataSet* aDataSet = GetExtractorFilter()->GetOutput(); vtkFloatingPointType anIntStep = GetBaseIntegrationStep(aDataSet); vtkFloatingPointType aPropagationTime = GetBasePropagationTime(aDataSet); vtkFloatingPointType aStepLength = GetBaseStepLength(aDataSet); - SetParams(anIntStep,aPropagationTime,aStepLength); + SetParams(anIntStep, + aPropagationTime, + aStepLength); } -VISU_ScalarMapPL::THook* + +//---------------------------------------------------------------------------- +vtkDataSet* VISU_StreamLinesPL -::DoHook() +::InsertCustomPL() { - GetInput2()->Update(); - VISU::CellDataToPoint(myStream,myCellDataToPointData,GetInput2(),myFieldTransform); - vtkFloatingPointType *aBounds = GetInput2()->GetBounds(); + GetClippedInput()->Update(); + + VISU::CellDataToPoint(myStream, + myCellDataToPointData, + GetClippedInput(), + GetFieldTransformFilter()); + + vtkFloatingPointType *aBounds = GetClippedInput()->GetBounds(); myGeomFilter->SetExtent(aBounds); myGeomFilter->ExtentClippingOn(); myGeomFilter->SetInput(myStream->GetOutput()); + return myGeomFilter->GetOutput(); } + +//---------------------------------------------------------------------------- void VISU_StreamLinesPL ::Update() @@ -530,6 +660,7 @@ VISU_StreamLinesPL VISU_ScalarMapPL::Update(); } + //---------------------------------------------------------------------------- unsigned long int VISU_StreamLinesPL @@ -559,3 +690,6 @@ VISU_StreamLinesPL { VISU_ScalarMapPL::SetMapScale(theMapScale); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_StreamLinesPL.hxx b/src/PIPELINE/VISU_StreamLinesPL.hxx index 747e97e0..b203df89 100644 --- a/src/PIPELINE/VISU_StreamLinesPL.hxx +++ b/src/PIPELINE/VISU_StreamLinesPL.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // -// File: VISU_PipeLine.hxx +// File: VISU_StreamLinesPL.hxx // Author: Alexey PETROV // Module : VISU @@ -30,24 +30,17 @@ #include "VISU_DeformedShapePL.hxx" #include -using namespace std; - -class vtkPointSet; +class vtkDataSet; class vtkCellCenters; class VTKViewer_GeometryFilter; class VISU_UsedPointsFilter; + +//---------------------------------------------------------------------------- class VISU_StreamLinesPL : public VISU_DeformedShapePL { -protected: - VISU_StreamLinesPL(); - VISU_StreamLinesPL(const VISU_StreamLinesPL&); - - virtual - ~VISU_StreamLinesPL(); - public: - vtkTypeMacro(VISU_StreamLinesPL,VISU_DeformedShapePL); + vtkTypeMacro(VISU_StreamLinesPL, VISU_DeformedShapePL); static VISU_StreamLinesPL* @@ -58,13 +51,13 @@ public: SetParams(vtkFloatingPointType theIntStep, vtkFloatingPointType thePropogationTime, vtkFloatingPointType theStepLength, - vtkPointSet* theSource = NULL, + vtkDataSet* theSource = NULL, vtkFloatingPointType thePercents = 0.3, int theDirection = VTK_INTEGRATE_BOTH_DIRECTIONS, int isOnlyTry = false); virtual - vtkPointSet* + vtkDataSet* GetSource(); virtual @@ -125,8 +118,8 @@ public: public: virtual - THook* - DoHook(); + vtkDataSet* + InsertCustomPL(); virtual void @@ -148,51 +141,57 @@ public: public: static vtkFloatingPointType - GetMaxIntegrationStep(vtkPointSet* theDataSet); + GetMaxIntegrationStep(vtkDataSet* theDataSet); static vtkFloatingPointType - GetMinIntegrationStep(vtkPointSet* theDataSet, + GetMinIntegrationStep(vtkDataSet* theDataSet, vtkFloatingPointType thePercents = 0.3); static vtkFloatingPointType - GetBaseIntegrationStep(vtkPointSet* theDataSet, + GetBaseIntegrationStep(vtkDataSet* theDataSet, vtkFloatingPointType thePercents = 0.3); static vtkFloatingPointType - GetMinPropagationTime(vtkPointSet* theDataSet); + GetMinPropagationTime(vtkDataSet* theDataSet); static vtkFloatingPointType - GetMaxPropagationTime(vtkPointSet* theDataSet); + GetMaxPropagationTime(vtkDataSet* theDataSet); static vtkFloatingPointType - GetBasePropagationTime(vtkPointSet* theDataSet); + GetBasePropagationTime(vtkDataSet* theDataSet); static vtkFloatingPointType - GetMinStepLength(vtkPointSet* theDataSet); + GetMinStepLength(vtkDataSet* theDataSet); static vtkFloatingPointType - GetMaxStepLength(vtkPointSet* theDataSet); + GetMaxStepLength(vtkDataSet* theDataSet); static vtkFloatingPointType - GetBaseStepLength(vtkPointSet* theDataSet); + GetBaseStepLength(vtkDataSet* theDataSet); static vtkFloatingPointType - GetVelocityCoeff(vtkPointSet* theDataSet); + GetVelocityCoeff(vtkDataSet* theDataSet); static size_t - IsPossible(vtkPointSet* theDataSet, + IsPossible(vtkDataSet* theDataSet, vtkFloatingPointType thePercents = 0.3); protected: + VISU_StreamLinesPL(); + VISU_StreamLinesPL(const VISU_StreamLinesPL&); + + virtual + ~VISU_StreamLinesPL(); + virtual void DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -207,7 +206,7 @@ protected: static size_t - FindPossibleParams(vtkPointSet* theDataSet, + FindPossibleParams(vtkDataSet* theDataSet, vtkFloatingPointType& theStepLength, vtkFloatingPointType& thePropogationTime, vtkFloatingPointType& thePercents); @@ -215,21 +214,21 @@ protected: static vtkFloatingPointType CorrectIntegrationStep(vtkFloatingPointType theStep, - vtkPointSet* theDataSet, + vtkDataSet* theDataSet, vtkFloatingPointType thePercents = 0.3); static vtkFloatingPointType CorrectPropagationTime(vtkFloatingPointType thePropagationTime, - vtkPointSet* theDataSet); + vtkDataSet* theDataSet); static vtkFloatingPointType CorrectStepLength(vtkFloatingPointType theStep, - vtkPointSet* theDataSet); + vtkDataSet* theDataSet); vtkStreamLine* myStream; - vtkPointSet* mySource; + vtkDataSet* mySource; vtkCellCenters* myCenters; VTKViewer_GeometryFilter *myGeomFilter; VISU_UsedPointsFilter *myPointsFilter; diff --git a/src/PIPELINE/VISU_UnstructuredGridPL.cxx b/src/PIPELINE/VISU_UnstructuredGridPL.cxx new file mode 100644 index 00000000..9e4f84cc --- /dev/null +++ b/src/PIPELINE/VISU_UnstructuredGridPL.cxx @@ -0,0 +1,81 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_UnstructuredGridPL.cxx +// Author: Alexey PETROV +// Module : VISU + + +#include "VISU_UnstructuredGridPL.hxx" +#include "VISU_DataSetMapperHolder.hxx" + + +//---------------------------------------------------------------------------- +VISU_UnstructuredGridPL +::VISU_UnstructuredGridPL(VISU_PipeLine* thePipeLine): + myPipeLine(thePipeLine) +{} + + +//---------------------------------------------------------------------------- +void +VISU_UnstructuredGridPL +::OnCreateMapperHolder() +{ + myDataSetMapperHolder = VISU_DataSetMapperHolder::New(); + myDataSetMapperHolder->Delete(); + + myPipeLine->SetMapperHolder(myDataSetMapperHolder.GetPointer()); +} + + +//---------------------------------------------------------------------------- +void +VISU_UnstructuredGridPL +::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) +{ + GetDataSetMapperHolder()->SetUnstructuredGridIDMapper(theIDMapper); +} + + +//---------------------------------------------------------------------------- +VISU_DataSetMapperHolder* +VISU_UnstructuredGridPL +::GetDataSetMapperHolder() +{ + myPipeLine->GetMapperHolder(); + + return myDataSetMapperHolder.GetPointer(); +} + + +//---------------------------------------------------------------------------- +vtkDataSetMapper* +VISU_UnstructuredGridPL +::GetDataSetMapper() +{ + return GetDataSetMapperHolder()->GetDataSetMapper(); +} + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_UnstructuredGridPL.hxx b/src/PIPELINE/VISU_UnstructuredGridPL.hxx new file mode 100644 index 00000000..dbad21e3 --- /dev/null +++ b/src/PIPELINE/VISU_UnstructuredGridPL.hxx @@ -0,0 +1,66 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_UnstructuredGripPL.hxx +// Author: Alexey PETROV +// Module : VISU + +#ifndef VISU_UnstructuredGridPL_HeaderFile +#define VISU_UnstructuredGridPL_HeaderFile + +#include "VISU_PipeLine.hxx" + +class VISU_DataSetMapperHolder; +class vtkDataSetMapper; + +//---------------------------------------------------------------------------- +class VISU_UnstructuredGridPL +{ +public: + //---------------------------------------------------------------------------- + void + SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper); + + VISU_DataSetMapperHolder* + GetDataSetMapperHolder(); + + vtkDataSetMapper* + GetDataSetMapper(); + +protected: + //---------------------------------------------------------------------------- + VISU_UnstructuredGridPL(VISU_PipeLine* thePipeLine); + + virtual + void + OnCreateMapperHolder(); + +private: + //---------------------------------------------------------------------------- + VISU_UnstructuredGridPL(); // Not implemented + VISU_UnstructuredGridPL(const VISU_UnstructuredGridPL&); // Not implemented + + VISU_PipeLine* myPipeLine; + vtkSmartPointer myDataSetMapperHolder; +}; + +#endif diff --git a/src/PIPELINE/VISU_UsedPointsFilter.cxx b/src/PIPELINE/VISU_UsedPointsFilter.cxx index 9c49ea25..6fb0ffda 100644 --- a/src/PIPELINE/VISU_UsedPointsFilter.cxx +++ b/src/PIPELINE/VISU_UsedPointsFilter.cxx @@ -28,22 +28,38 @@ #include "VISU_UsedPointsFilter.hxx" #include -#include +#include #include #include #include #include + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_UsedPointsFilter); -VISU_UsedPointsFilter::VISU_UsedPointsFilter(){ + +//---------------------------------------------------------------------------- +VISU_UsedPointsFilter +::VISU_UsedPointsFilter() +{ PercentsOfUsedPoints = 1.0; } -VISU_UsedPointsFilter::~VISU_UsedPointsFilter(){} -void VISU_UsedPointsFilter::Execute(){ - vtkPointSet *anInput = this->GetInput(), *anOutput = this->GetOutput(); +//---------------------------------------------------------------------------- +VISU_UsedPointsFilter +::~VISU_UsedPointsFilter() +{} + + +//---------------------------------------------------------------------------- +void +VISU_UsedPointsFilter +::Execute() +{ + vtkDataSet *anInput = this->GetInput(); + vtkPointSet *anOutput = this->GetOutput(); anOutput->GetPointData()->CopyAllOff(); anOutput->GetCellData()->CopyAllOff(); anOutput->CopyStructure(anInput); @@ -68,3 +84,6 @@ void VISU_UsedPointsFilter::Execute(){ aNewPoints->Delete(); aPoints->Delete(); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_UsedPointsFilter.hxx b/src/PIPELINE/VISU_UsedPointsFilter.hxx index dd20877a..3795da85 100644 --- a/src/PIPELINE/VISU_UsedPointsFilter.hxx +++ b/src/PIPELINE/VISU_UsedPointsFilter.hxx @@ -27,23 +27,34 @@ #ifndef VISU_UsedPointsFilter_HeaderFile #define VISU_UsedPointsFilter_HeaderFile -#include +#include + + +//---------------------------------------------------------------------------- +class VISU_UsedPointsFilter : public vtkDataSetToUnstructuredGridFilter +{ +public: + vtkTypeMacro(VISU_UsedPointsFilter, vtkDataSetToUnstructuredGridFilter); + + static + VISU_UsedPointsFilter* + New(); + + vtkSetMacro(PercentsOfUsedPoints,float); + vtkGetMacro(PercentsOfUsedPoints,float); -class VISU_UsedPointsFilter : public vtkPointSetToPointSetFilter{ protected: VISU_UsedPointsFilter(); VISU_UsedPointsFilter(const VISU_UsedPointsFilter&); - virtual void Execute(); - float PercentsOfUsedPoints; + virtual + ~VISU_UsedPointsFilter(); -public: - vtkTypeMacro(VISU_UsedPointsFilter,vtkPointSetToPointSetFilter); - static VISU_UsedPointsFilter* New(); - virtual ~VISU_UsedPointsFilter(); + virtual + void + Execute(); - vtkSetMacro(PercentsOfUsedPoints,float); - vtkGetMacro(PercentsOfUsedPoints,float); + float PercentsOfUsedPoints; }; #endif diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 2c10134b..9c685a06 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -36,11 +36,17 @@ #include #include + +//---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_VectorsPL); + +//---------------------------------------------------------------------------- VISU_VectorsPL ::VISU_VectorsPL() { + SetIsShrinkable(false); + myBaseGlyph = vtkGlyph3D::New(); myTransformedGlyph = vtkGlyph3D::New(); @@ -50,9 +56,10 @@ VISU_VectorsPL myCenters = vtkCellCenters::New(); myTransformFilter = VTKViewer_TransformFilter::New(); - myIsShrinkable = false; } + +//---------------------------------------------------------------------------- VISU_VectorsPL ::~VISU_VectorsPL() { @@ -70,6 +77,8 @@ VISU_VectorsPL myTransformFilter->Delete(); } + +//---------------------------------------------------------------------------- void VISU_VectorsPL ::DoShallowCopy(VISU_PipeLine *thePipeLine, @@ -79,27 +88,32 @@ VISU_VectorsPL SetGlyphType(aPipeLine->GetGlyphType()); SetGlyphPos(aPipeLine->GetGlyphPos()); } + Superclass::DoShallowCopy(thePipeLine, theIsCopyInput); } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::SetTransform(VTKViewer_Transform* theTransform) { - myFieldTransform->SetSpaceTransform(theTransform); + GetFieldTransformFilter()->SetSpaceTransform(theTransform); myTransformFilter->SetTransform(theTransform); myTransformFilter->Modified(); } + +//---------------------------------------------------------------------------- VTKViewer_Transform* VISU_VectorsPL ::GetTransform() { - return myFieldTransform->GetSpaceTransform(); + return GetFieldTransformFilter()->GetSpaceTransform(); } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::SetScale(vtkFloatingPointType theScale) @@ -115,6 +129,8 @@ VISU_VectorsPL Modified(); } + +//---------------------------------------------------------------------------- vtkFloatingPointType VISU_VectorsPL ::GetScale() @@ -123,6 +139,7 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::SetGlyphType(VISU_VectorsPL::GlyphType theType) @@ -131,6 +148,8 @@ VISU_VectorsPL Modified(); } + +//---------------------------------------------------------------------------- VISU_VectorsPL::GlyphType VISU_VectorsPL ::GetGlyphType() const @@ -139,6 +158,7 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::SetGlyphPos(VISU_VectorsPL::GlyphPos thePos) @@ -147,6 +167,8 @@ VISU_VectorsPL Modified(); } + +//---------------------------------------------------------------------------- VISU_VectorsPL::GlyphPos VISU_VectorsPL ::GetGlyphPos() const @@ -155,6 +177,7 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::Init() @@ -166,6 +189,7 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- vtkDataSet* VISU_VectorsPL ::GetOutput() @@ -175,16 +199,25 @@ VISU_VectorsPL } -VISU_ScalarMapPL::THook* +//---------------------------------------------------------------------------- +vtkDataSet* VISU_VectorsPL -::DoHook() +::InsertCustomPL() { - VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform); + VISU::ToCellCenters(myBaseGlyph, + myCenters, + GetClippedInput(), + GetFieldTransformFilter()); + myBaseGlyph->SetVectorModeToUseVector(); myBaseGlyph->SetScaleModeToScaleByVector(); myBaseGlyph->SetColorModeToColorByScalar(); - VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform); + VISU::ToCellCenters(myTransformFilter, + myCenters, + GetClippedInput(), + GetFieldTransformFilter()); + myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); myTransformedGlyph->SetVectorModeToUseVector(); myTransformedGlyph->SetScaleModeToScaleByVector(); @@ -194,6 +227,7 @@ VISU_VectorsPL } +//---------------------------------------------------------------------------- void VISU_VectorsPL ::Update() @@ -287,3 +321,6 @@ VISU_VectorsPL Modified(); } + + +//---------------------------------------------------------------------------- diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 5e22f6da..dd75e135 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -39,15 +39,10 @@ class vtkLineSource; class vtkGlyph3D; + +//---------------------------------------------------------------------------- class VISU_VectorsPL : public VISU_DeformedShapePL { -protected: - VISU_VectorsPL(); - VISU_VectorsPL(const VISU_VectorsPL&); - - virtual - ~VISU_VectorsPL(); - public: vtkTypeMacro(VISU_VectorsPL,VISU_DeformedShapePL); @@ -113,9 +108,15 @@ public: SetMapScale(vtkFloatingPointType theMapScale = 1.0); protected: + VISU_VectorsPL(); + VISU_VectorsPL(const VISU_VectorsPL&); + virtual - THook* - DoHook(); + ~VISU_VectorsPL(); + + virtual + vtkDataSet* + InsertCustomPL(); virtual void diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 9fd8c91e..2637de41 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -519,8 +519,8 @@ void VisuGUI_ClippingDlg::ClickOnApply() // Check contents of the resulting (clipped) presentation data if (!isFailed) { VISU_PipeLine* aPL = myPrs3d->GetPipeLine(); - VISU_PipeLine::TMapper* aM = aPL->GetMapper(); - vtkDataSet* aPrsData = aM->GetInput(); + vtkMapper* aMapper = aPL->GetMapper(); + vtkDataSet* aPrsData = aMapper->GetInput(); aPrsData->Update(); if (aPrsData->GetNumberOfCells() < 1) { isFailed = true; diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index aeec6824..cd721668 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -38,6 +38,7 @@ #include "VISUConfig.hh" #include "VISU_Convertor.hxx" #include "VISU_ScalarMapPL.hxx" +#include "VISU_ScalarBarActor.hxx" #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMap_i.hh" #include "VISU_Result_i.hh" diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index 0f98f149..4c13191b 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -26,7 +26,7 @@ #include "VISU_ColoredPrs3d_i.hh" -#include "VISU_ScalarMapPL.hxx" +#include "VISU_ColoredPL.hxx" #include "VISU_Result_i.hh" #include "VISU_Convertor.hxx" @@ -50,7 +50,7 @@ VISU::ColoredPrs3d_i:: ColoredPrs3d_i(EPublishInStudyMode thePublishInStudyMode) : myPublishInStudyMode(thePublishInStudyMode), myIsTimeStampFixed(thePublishInStudyMode == EPublishUnderTimeStamp), - myScalarMapPL(NULL), + myColoredPL(NULL), myIsFixedRange(false) {} @@ -471,7 +471,7 @@ CORBA::Long VISU::ColoredPrs3d_i ::GetScalarMode() { - return myScalarMapPL->GetScalarMode(); + return myColoredPL->GetScalarMode(); } //---------------------------------------------------------------------------- @@ -485,7 +485,7 @@ VISU::ColoredPrs3d_i else if(theScalarMode > aNbComp) theScalarMode = 0; - myScalarMapPL->SetScalarMode(theScalarMode); + myColoredPL->SetScalarMode(theScalarMode); } //---------------------------------------------------------------------------- @@ -493,7 +493,7 @@ CORBA::Double VISU::ColoredPrs3d_i ::GetMin() { - return myScalarMapPL->GetScalarRange()[0]; + return myColoredPL->GetScalarRange()[0]; } //---------------------------------------------------------------------------- @@ -501,7 +501,7 @@ CORBA::Double VISU::ColoredPrs3d_i ::GetMax() { - return myScalarMapPL->GetScalarRange()[1]; + return myColoredPL->GetScalarRange()[1]; } //---------------------------------------------------------------------------- @@ -1138,13 +1138,9 @@ VISU::ColoredPrs3d_i ::CreatePipeLine(VISU_PipeLine* thePipeLine) { if(MYDEBUG) MESSAGE("ColoredPrs3d_i::CreatePipeLine() - "<GetMapper()->SetScalarVisibility(1); - }else - myScalarMapPL = dynamic_cast(thePipeLine); + myColoredPL = dynamic_cast(thePipeLine); - SetPipeLine(myScalarMapPL); + SetPipeLine(myColoredPL); } //---------------------------------------------------------------------------- diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 848f927f..1115bbef 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -29,7 +29,7 @@ #include "VISU_Prs3d_i.hh" -class VISU_ScalarMapPL; +class VISU_ColoredPL; namespace VISU { @@ -358,10 +358,10 @@ namespace VISU vtkFloatingPointType theG, vtkFloatingPointType theB); - VISU_ScalarMapPL* + VISU_ColoredPL* GetSpecificPL() const { - return myScalarMapPL; + return myColoredPL; } //---------------------------------------------------------------------------- @@ -475,7 +475,7 @@ namespace VISU int myLblFontType; vtkFloatingPointType myLabelColor[3]; - VISU_ScalarMapPL* myScalarMapPL; + VISU_ColoredPL* myColoredPL; bool myIsFixedRange; }; diff --git a/src/VISU_I/VISU_CorbaMedConvertor.cxx b/src/VISU_I/VISU_CorbaMedConvertor.cxx index b0c15cd4..dd78ea91 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.cxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.cxx @@ -28,6 +28,7 @@ // Copyright (C) 2003 CEA/DEN, EDF R&D #include "VISU_CorbaMedConvertor.hxx" +#include "VISU_ConvertorUtils.hxx" #include @@ -1320,8 +1321,8 @@ VISU_MEDConvertor VISU::PCValForTime theValForTime) { //Check on loading already done - PIDMapperFilter anIDMapperFilter = theValForTime->myIDMapperFilter; - if(anIDMapperFilter->myIsVTKDone) + PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = theValForTime->myUnstructuredGridIDMapper; + if(anUnstructuredGridIDMapper->myIsVTKDone) return 0; PCProfile aProfile(new TCProfile()); @@ -1333,16 +1334,25 @@ VISU_MEDConvertor if(!aFieldDouble->_is_nil()){ SALOME_MED::double_array_var anArray = aFieldDouble->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDDOUBLE = "<length()); - ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); + ImportField(anArray, + theMesh, + theField, + theValForTime, + theMeshOnEntity); } + SALOME_MED::FIELDINT_ptr aFieldInt = SALOME_MED::FIELDINT::_narrow(aMEDField); if(!aFieldInt->_is_nil()){ SALOME_MED::long_array_var anArray = aFieldInt->getValue(SALOME_MED::MED_FULL_INTERLACE); if(MYDEBUG) MESSAGE("VISU_MEDConvertor::LoadField - There is FIELDINT = "<length()); - ImportField(anArray,theMesh,theField,theValForTime,theMeshOnEntity); + ImportField(anArray, + theMesh, + theField, + theValForTime, + theMeshOnEntity); } - anIDMapperFilter->myIsVTKDone = true; + anUnstructuredGridIDMapper->myIsVTKDone = true; return 1; } diff --git a/src/VISU_I/VISU_CorbaMedConvertor.hxx b/src/VISU_I/VISU_CorbaMedConvertor.hxx index 595d45d6..e51c5809 100644 --- a/src/VISU_I/VISU_CorbaMedConvertor.hxx +++ b/src/VISU_I/VISU_CorbaMedConvertor.hxx @@ -32,6 +32,9 @@ #include "VISUConfig.hh" #include "VISU_Convertor_impl.hxx" +#include "VISU_Structures_impl.hxx" +#include "VISU_PointCoords.hxx" +#include "VISU_MeshValue.hxx" #include @@ -96,19 +99,19 @@ namespace VISU { SALOME_MED::MESH_var myMesh; }; - typedef SharedPtr PCMesh; + typedef MED::SharedPtr PCMesh; //--------------------------------------------------------------- struct TCProfile: virtual TProfileImpl {}; - typedef SharedPtr PCProfile; + typedef MED::SharedPtr PCProfile; //--------------------------------------------------------------- struct TCSubMesh: virtual TSubMeshImpl {}; - typedef SharedPtr PCSubMesh; + typedef MED::SharedPtr PCSubMesh; //--------------------------------------------------------------- @@ -119,7 +122,7 @@ namespace VISU typedef std::map TCellsFirstIndex; TCellsFirstIndex myCellsFirstIndex; }; - typedef SharedPtr PCMeshOnEntity; + typedef MED::SharedPtr PCMeshOnEntity; //--------------------------------------------------------------- @@ -127,7 +130,7 @@ namespace VISU { SALOME_MED::FAMILY_var myFamily; }; - typedef SharedPtr PCFamily; + typedef MED::SharedPtr PCFamily; //--------------------------------------------------------------- @@ -135,13 +138,13 @@ namespace VISU { SALOME_MED::GROUP_var myGroup; }; - typedef SharedPtr PCGroup; + typedef MED::SharedPtr PCGroup; //--------------------------------------------------------------- struct TCField: virtual TFieldImpl {}; - typedef SharedPtr PCField; + typedef MED::SharedPtr PCField; //--------------------------------------------------------------- @@ -149,7 +152,7 @@ namespace VISU { SALOME_MED::FIELD_var myField; }; - typedef SharedPtr PCValForTime; + typedef MED::SharedPtr PCValForTime; } diff --git a/src/VISU_I/VISU_DumpPython.cc b/src/VISU_I/VISU_DumpPython.cc index c2e892a0..fe78c72a 100644 --- a/src/VISU_I/VISU_DumpPython.cc +++ b/src/VISU_I/VISU_DumpPython.cc @@ -41,8 +41,6 @@ #include "VISU_Table_i.hh" #include "VISU_GaussPoints_i.hh" #include "VISU_ScalarMapOnDeformedShape_i.hh" -#include "VISU_ColoredPrs3dCache_i.hh" -#include "VISU_ColoredPrs3dHolder_i.hh" #include "utilities.h" @@ -61,8 +59,6 @@ namespace VISU { static std::string PREFIX(" "); - static std::string aResultName; - typedef std::map TName2EntryMap; typedef std::map TEntry2NameMap; @@ -530,7 +526,6 @@ namespace VISU switch(aType){ case VISU::TRESULT: if(Result_i* aServant = dynamic_cast(GetServant(anObj).in())){ - aResultName = aName; std::string aFileName = aServant->GetFileName(); Result_i::ECreationId anId = aServant->GetCreationId(); if(anId == Result_i::eImportFile || anId == Result_i::eCopyAndImportFile){ @@ -1101,36 +1096,6 @@ namespace VISU } } return; - case VISU::TCOLOREDPRS3DCACHE: - if(ColoredPrs3dCache_i* aServant = dynamic_cast(GetServant(anObj).in())){ - theStr<GetHolderMap(); - TColoredPrs3dHolderMap::const_iterator aHolderIter = aHolderMap.begin(); - TColoredPrs3dHolderMap::const_iterator aHolderIterEnd = aHolderMap.end(); - for(; aHolderIter != aHolderIterEnd; aHolderIter++){ - const TLastVisitedPrsList& aPrsList = aHolderIter->second; - if(TPrs3dPtr aPrs3d = aPrsList.front()) - { - ColoredPrs3dHolder::BasicInput_var anInput = aPrs3d->GetBasicInput(); - - std::string anEntity; - switch(anInput->myEntity){ - case VISU::NODE : anEntity = "VISU.NODE"; break; - case VISU::EDGE : anEntity = "VISU.EDGE"; break; - case VISU::FACE : anEntity = "VISU.FACE"; break; - case VISU::CELL : anEntity = "VISU.CELL"; break; - } - - theStr<myMeshName<<"',"<myFieldName<<"',"<myTimeStampNumber<<")"<GetComment(); - theStr<SetGaussPtsIDMapper(aGaussPtsIDMapper); if(theIsInitilizePipe){ GetSpecificPL()->Init(); - GetSpecificPL()->Build(); } GetCResult()->MinMaxConnect(this); diff --git a/src/VISU_I/VISU_Gen_i.cc b/src/VISU_I/VISU_Gen_i.cc index fdfd89e6..c2c6f804 100644 --- a/src/VISU_I/VISU_Gen_i.cc +++ b/src/VISU_I/VISU_Gen_i.cc @@ -851,7 +851,7 @@ namespace VISU if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(); - if(!aPresent->Create(aResult, theMeshName, theEntity)) + if(aPresent->Create(aResult, theMeshName, theEntity)) return aPresent->_this(); else{ aPresent->_remove_ref(); @@ -874,7 +874,7 @@ namespace VISU if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(); - if(!aPresent->Create(aResult, theMeshName, theEntity, theFamilyName)) + if(aPresent->Create(aResult, theMeshName, theEntity, theFamilyName)) return aPresent->_this(); else{ aPresent->_remove_ref(); @@ -896,7 +896,7 @@ namespace VISU if(Result_i* aResult = dynamic_cast(GetServant(theResult).in())){ Mesh_i* aPresent = new Mesh_i(); - if(!aPresent->Create(aResult, theMeshName, theGroupName)) + if(aPresent->Create(aResult, theMeshName, theGroupName)) return aPresent->_this(); else{ aPresent->_remove_ref(); diff --git a/src/VISU_I/VISU_Mesh_i.cc b/src/VISU_I/VISU_Mesh_i.cc index a88515f5..b2396268 100644 --- a/src/VISU_I/VISU_Mesh_i.cc +++ b/src/VISU_I/VISU_Mesh_i.cc @@ -193,7 +193,7 @@ VISU::Mesh_i if(MYDEBUG) MESSAGE("Mesh_i::Build - myType = "<GetInput(); switch(myType){ case VISU::TENTITY : @@ -235,8 +235,7 @@ VISU::Mesh_i if(!anIDMapper) throw std::runtime_error("Mesh_i::Build - !anIDMapper !!!"); - myMeshPL->SetIDMapper(anIDMapper); - myMeshPL->Build(); + myMeshPL->SetUnstructuredGridIDMapper(anIDMapper); if(!theRestoring) { //Setting IOR on the label myMeshPL->Init(); diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 777f0ac1..93a5f995 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -427,7 +427,7 @@ VISU::Prs3d_i } //---------------------------------------------------------------------------- -vtkUnstructuredGrid* +vtkDataSet* VISU::Prs3d_i ::GetInput() { diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index f1a94b43..22cdf4f8 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -46,7 +46,7 @@ class VISU_Actor; class vtkPlane; class vtkActorCollection; -class vtkUnstructuredGrid; +class vtkDataSet; namespace VISU { @@ -178,7 +178,7 @@ namespace VISU IsPipeLineExists(); //! Get input of the VISU_PipeLine - vtkUnstructuredGrid* + vtkDataSet* GetInput(); //---------------------------------------------------------------------------- diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 818523cc..86f12f43 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -1605,9 +1605,9 @@ Result_i return components; } - VISU::PIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName, - CELL_ENTITY); - VISU::TVTKOutput* aMesh = anIDMapper->GetVTKOutput(); + VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName, + CELL_ENTITY); + vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput(); if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) { MESSAGE( "No cells in the mesh: " << theMeshName ); diff --git a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc index 9314cbc7..f4b52725 100644 --- a/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc +++ b/src/VISU_I/VISU_ScalarMapOnDeformedShape_i.cc @@ -349,11 +349,14 @@ VISU::ScalarMapOnDeformedShape_i { VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); SetField(anInput->GetField(theMeshName,theEntity,theFieldName)); - VISU::PIDMapper anIDMapper = anInput->GetTimeStampOnMesh(theMeshName, - theEntity, - theFieldName, - theIteration); - TVTKOutput* anOutput = anIDMapper->GetVTKOutput(); + + VISU::PUnstructuredGridIDMapper anIDMapper = + anInput->GetTimeStampOnMesh(theMeshName, + theEntity, + theFieldName, + theIteration); + + vtkUnstructuredGrid* anOutput = anIDMapper->GetUnstructuredGridOutput(); if(myScalarMapOnDeformedShapePL && anOutput) myScalarMapOnDeformedShapePL->SetScalars(anOutput); diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index d72072fb..983853c1 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -30,6 +30,8 @@ #include "VISU_ScalarMapAct.h" #include "VISU_ScalarMapPL.hxx" +#include "VISU_LookupTable.hxx" +#include "VISU_ScalarBarActor.hxx" #include "VISU_Convertor.hxx" #include "SUIT_ResourceMgr.h" @@ -284,16 +286,15 @@ VISU::ScalarMap_i if(!GetField()) throw std::runtime_error("There is no Field with the parameters !!!"); - VISU::PIDMapper anIDMapper = + VISU::PUnstructuredGridIDMapper anIDMapper = anInput->GetTimeStampOnMesh(GetCMeshName(),GetTEntity(),GetCFieldName(),GetTimeStampNumber()); if(!anIDMapper) throw std::runtime_error("There is no TimeStamp with the parameters !!!"); - GetSpecificPL()->SetIDMapper(anIDMapper); + GetSpecificPL()->SetUnstructuredGridIDMapper(anIDMapper); if(theIsInitilizePipe){ GetSpecificPL()->Init(); - GetSpecificPL()->Build(); } // To update scalar range according to the new input @@ -311,6 +312,21 @@ VISU::ScalarMap_i } +//---------------------------------------------------------------------------- +void +VISU::ScalarMap_i +::CreatePipeLine(VISU_PipeLine* thePipeLine) +{ + if(MYDEBUG) MESSAGE("ScalarMap_i::CreatePipeLine() - "<GetMapper()->SetScalarVisibility(1); + }else + myScalarMapPL = dynamic_cast(thePipeLine); + + TSuperClass::CreatePipeLine(myScalarMapPL); +} + //---------------------------------------------------------------------------- void VISU::ScalarMap_i diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 81836445..992e1626 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -29,6 +29,7 @@ #include "VISU_ColoredPrs3d_i.hh" +class VISU_ScalarMapPL; namespace VISU { @@ -90,12 +91,24 @@ namespace VISU VISU::ScalarMap::Orientation GetBarOrientation(); + //---------------------------------------------------------------------------- + VISU_ScalarMapPL* + GetSpecificPL() const + { + return myScalarMapPL; + } + protected: //! Redefines VISU_ColoredPrs3d_i::DoSetInput virtual void DoSetInput(bool theIsInitilizePipe, bool theReInit); + //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine + virtual + void + CreatePipeLine(VISU_PipeLine* thePipeLine); + //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible virtual bool @@ -161,6 +174,9 @@ namespace VISU virtual void UpdateActor(VISU_Actor* theActor); + + private: + VISU_ScalarMapPL* myScalarMapPL; }; } diff --git a/src/VISU_I/VISU_StreamLines_i.cc b/src/VISU_I/VISU_StreamLines_i.cc index f7ffe872..2bb2c746 100644 --- a/src/VISU_I/VISU_StreamLines_i.cc +++ b/src/VISU_I/VISU_StreamLines_i.cc @@ -55,13 +55,17 @@ VISU::StreamLines_i bool theIsMemoryCheck) { try{ - if(!VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,false)) + if(!VISU::ScalarMap_i::IsPossible(theResult, theMeshName, theEntity, theFieldName, theTimeStampNumber, false)) return 0; VISU::Result_i::TInput* anInput = theResult->GetInput(); - VISU::PIDMapper anIDMapper = - anInput->GetTimeStampOnMesh(theMeshName,VISU::TEntity(theEntity),theFieldName,theTimeStampNumber); - VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput(); + VISU::PUnstructuredGridIDMapper anIDMapper = + anInput->GetTimeStampOnMesh(theMeshName, + VISU::TEntity(theEntity), + theFieldName, + theTimeStampNumber); + + vtkUnstructuredGrid* aDataSet = anIDMapper->GetUnstructuredGridOutput(); size_t aResult = VISU_StreamLinesPL::IsPossible(aDataSet); MESSAGE("StreamLines_i::IsPossible - aResult = "< #include @@ -48,15 +49,11 @@ ScalarMap::ScalarMap(Convertor* theConvertor, const char* theMeshName, int theEn : myScalarMap(NULL) { if(VISU_Convertor* aConvertor = theConvertor->GetImpl()){ - VISU::PIDMapper anIDMapper = + VISU::PUnstructuredGridIDMapper anIDMapper = aConvertor->GetTimeStampOnMesh(theMeshName,VISU::TEntity(theEntity),theFieldName,theIteration); - VISU::TVTKOutput* aDataSet = anIDMapper->GetVTKOutput(); - if(aDataSet){ + if(anIDMapper){ myScalarMap = VISU_ScalarMapPL::New(); - myScalarMap->SetInput(aDataSet); - myScalarMap->Build(); - myScalarMap->Init(); - myScalarMap->SetSourceRange(); + myScalarMap->SetUnstructuredGridIDMapper(anIDMapper); } } } @@ -93,8 +90,6 @@ void View3D::Display(ScalarMap* theScalarMap){ VISU_ScalarBarActor * aScalarBar = VISU_ScalarBarActor::New(); aScalarBar->SetLookupTable(aScalarMap->GetBarTable()); - aScalarMap->Build(); - myRen->AddActor(anActor); myRen->AddActor2D(aScalarBar); myRen->ResetCameraClippingRange(); -- 2.39.2