mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: use smart pointers for paraview readers
- adds flexiblity and reduces risk of memory leaks as we add/change features STYLE: adjust naming for paraview internal polyDecomp
This commit is contained in:
@ -39,6 +39,7 @@ License
|
|||||||
#include "vtkSMRenderViewProxy.h"
|
#include "vtkSMRenderViewProxy.h"
|
||||||
#include "vtkStreamingDemandDrivenPipeline.h"
|
#include "vtkStreamingDemandDrivenPipeline.h"
|
||||||
#include "vtkStringArray.h"
|
#include "vtkStringArray.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// OpenFOAM includes
|
// OpenFOAM includes
|
||||||
#include "vtkPVFoam.H"
|
#include "vtkPVFoam.H"
|
||||||
@ -69,11 +70,13 @@ vtkPVFoamReader::vtkPVFoamReader()
|
|||||||
#ifdef VTKPVFOAM_DUALPORT
|
#ifdef VTKPVFOAM_DUALPORT
|
||||||
// Add second output for the Lagrangian
|
// Add second output for the Lagrangian
|
||||||
this->SetNumberOfOutputPorts(2);
|
this->SetNumberOfOutputPorts(2);
|
||||||
vtkMultiBlockDataSet *lagrangian = vtkMultiBlockDataSet::New();
|
|
||||||
|
vtkSmartPointer<vtkMultiBlockDataSet> lagrangian =
|
||||||
|
vtkSmartPointer<vtkMultiBlockDataSet>::New();
|
||||||
|
|
||||||
lagrangian->ReleaseData();
|
lagrangian->ReleaseData();
|
||||||
|
|
||||||
this->GetExecutive()->SetOutputData(1, lagrangian);
|
this->GetExecutive()->SetOutputData(1, lagrangian);
|
||||||
lagrangian->Delete();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TimeStepRange[0] = 0;
|
TimeStepRange[0] = 0;
|
||||||
@ -218,7 +221,7 @@ int vtkPVFoamReader::RequestInformation
|
|||||||
{
|
{
|
||||||
vtkErrorMacro("could not find valid OpenFOAM mesh");
|
vtkErrorMacro("could not find valid OpenFOAM mesh");
|
||||||
|
|
||||||
// delete foamData and flag it as fatal error
|
// delete backend handler and flag it as fatal error
|
||||||
delete backend_;
|
delete backend_;
|
||||||
backend_ = nullptr;
|
backend_ = nullptr;
|
||||||
return 0;
|
return 0;
|
||||||
@ -326,7 +329,8 @@ int vtkPVFoamReader::RequestData
|
|||||||
{
|
{
|
||||||
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
vtkInformation *outInfo = outputVector->GetInformationObject(infoI);
|
||||||
|
|
||||||
int nsteps = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
const int nsteps =
|
||||||
|
outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
@ -419,7 +423,7 @@ int vtkPVFoamReader::RequestData
|
|||||||
(
|
(
|
||||||
vtkMultiBlockDataSet::DATA_OBJECT()
|
vtkMultiBlockDataSet::DATA_OBJECT()
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
);
|
);
|
||||||
#else
|
#else
|
||||||
backend_->Update(output, output);
|
backend_->Update(output, output);
|
||||||
|
|||||||
@ -46,6 +46,7 @@ SourceFiles
|
|||||||
// VTK forward declarations
|
// VTK forward declarations
|
||||||
class vtkDataArraySelection;
|
class vtkDataArraySelection;
|
||||||
class vtkCallbackCommand;
|
class vtkCallbackCommand;
|
||||||
|
template<class T> class vtkSmartPointer;
|
||||||
|
|
||||||
// OpenFOAM forward declarations
|
// OpenFOAM forward declarations
|
||||||
namespace Foam
|
namespace Foam
|
||||||
|
|||||||
@ -37,6 +37,7 @@ License
|
|||||||
#include "vtkRenderer.h"
|
#include "vtkRenderer.h"
|
||||||
#include "vtkTextActor.h"
|
#include "vtkTextActor.h"
|
||||||
#include "vtkTextProperty.h"
|
#include "vtkTextProperty.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -48,13 +49,20 @@ namespace Foam
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
vtkTextActor* Foam::vtkPVFoam::createTextActor
|
namespace Foam
|
||||||
|
{
|
||||||
|
// file-scope
|
||||||
|
|
||||||
|
//- Create a text actor
|
||||||
|
vtkSmartPointer<vtkTextActor> createTextActor
|
||||||
(
|
(
|
||||||
const std::string& s,
|
const std::string& s,
|
||||||
const point& pt
|
const Foam::point& pt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vtkTextActor* txt = vtkTextActor::New();
|
vtkSmartPointer<vtkTextActor> txt =
|
||||||
|
vtkSmartPointer<vtkTextActor>::New();
|
||||||
|
|
||||||
txt->SetInput(s.c_str());
|
txt->SetInput(s.c_str());
|
||||||
|
|
||||||
// Set text properties
|
// Set text properties
|
||||||
@ -72,6 +80,7 @@ vtkTextActor* Foam::vtkPVFoam::createTextActor
|
|||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -93,19 +102,19 @@ void Foam::vtkPVFoam::resetCounters()
|
|||||||
|
|
||||||
void Foam::vtkPVFoam::reduceMemory()
|
void Foam::vtkPVFoam::reduceMemory()
|
||||||
{
|
{
|
||||||
forAll(regionPolyDecomp_, i)
|
forAll(regionVtus_, i)
|
||||||
{
|
{
|
||||||
regionPolyDecomp_[i].clear();
|
regionVtus_[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(zonePolyDecomp_, i)
|
forAll(zoneVtus_, i)
|
||||||
{
|
{
|
||||||
zonePolyDecomp_[i].clear();
|
zoneVtus_[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
forAll(csetPolyDecomp_, i)
|
forAll(csetVtus_, i)
|
||||||
{
|
{
|
||||||
csetPolyDecomp_[i].clear();
|
csetVtus_[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reader_->GetCacheMesh())
|
if (!reader_->GetCacheMesh())
|
||||||
@ -640,12 +649,11 @@ void Foam::vtkPVFoam::renderPatchNames
|
|||||||
{
|
{
|
||||||
// always remove old actors first
|
// always remove old actors first
|
||||||
|
|
||||||
forAll(patchTextActorsPtrs_, patchi)
|
forAll(patchTextActors_, patchi)
|
||||||
{
|
{
|
||||||
renderer->RemoveViewProp(patchTextActorsPtrs_[patchi]);
|
renderer->RemoveViewProp(patchTextActors_[patchi]);
|
||||||
patchTextActorsPtrs_[patchi]->Delete();
|
|
||||||
}
|
}
|
||||||
patchTextActorsPtrs_.clear();
|
patchTextActors_.clear();
|
||||||
|
|
||||||
if (show && meshPtr_)
|
if (show && meshPtr_)
|
||||||
{
|
{
|
||||||
@ -750,7 +758,7 @@ void Foam::vtkPVFoam::renderPatchNames
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the size of the patch labels to max number of zones
|
// Set the size of the patch labels to max number of zones
|
||||||
patchTextActorsPtrs_.setSize(displayZoneI);
|
patchTextActors_.setSize(displayZoneI);
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -783,7 +791,7 @@ void Foam::vtkPVFoam::renderPatchNames
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Into a list for later removal
|
// Into a list for later removal
|
||||||
patchTextActorsPtrs_[displayZoneI++] = createTextActor
|
patchTextActors_[displayZoneI++] = createTextActor
|
||||||
(
|
(
|
||||||
pp.name(),
|
pp.name(),
|
||||||
zoneCentre[patchi][globalZoneI]
|
zoneCentre[patchi][globalZoneI]
|
||||||
@ -792,13 +800,13 @@ void Foam::vtkPVFoam::renderPatchNames
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resize the patch names list to the actual number of patch names added
|
// Resize the patch names list to the actual number of patch names added
|
||||||
patchTextActorsPtrs_.setSize(displayZoneI);
|
patchTextActors_.setSize(displayZoneI);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add text to each renderer
|
// Add text to each renderer
|
||||||
forAll(patchTextActorsPtrs_, actori)
|
forAll(patchTextActors_, actori)
|
||||||
{
|
{
|
||||||
renderer->AddViewProp(patchTextActorsPtrs_[actori]);
|
renderer->AddViewProp(patchTextActors_[actori]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,8 @@ class vtkPolyData;
|
|||||||
class vtkUnstructuredGrid;
|
class vtkUnstructuredGrid;
|
||||||
class vtkIndent;
|
class vtkIndent;
|
||||||
|
|
||||||
|
template<class T> class vtkSmartPointer;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -105,9 +107,9 @@ class vtkPVFoam
|
|||||||
// hide in extra pointMap (cellSet/cellZone) for now
|
// hide in extra pointMap (cellSet/cellZone) for now
|
||||||
class polyDecomp
|
class polyDecomp
|
||||||
{
|
{
|
||||||
labelList superCells_;
|
labelList cellMap_;
|
||||||
labelList addPointCellLabels_;
|
|
||||||
labelList pointMap_;
|
labelList pointMap_;
|
||||||
|
labelList additionalIds_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -115,27 +117,15 @@ class vtkPVFoam
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
//- Label of original cell for decomposed cells
|
//- Label of original cell for decomposed cells
|
||||||
labelList& superCells()
|
labelList& cellMap()
|
||||||
{
|
{
|
||||||
return superCells_;
|
return cellMap_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Label of original cell for decomposed cells
|
//- Label of original cell for decomposed cells
|
||||||
const labelList& superCells() const
|
const labelList& cellMap() const
|
||||||
{
|
{
|
||||||
return superCells_;
|
return cellMap_;
|
||||||
}
|
|
||||||
|
|
||||||
//- Cell-centre labels for additional points of decomposed cells
|
|
||||||
labelList& addPointCellLabels()
|
|
||||||
{
|
|
||||||
return addPointCellLabels_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Cell-centre labels for additional points of decomposed cells
|
|
||||||
const labelList& addPointCellLabels() const
|
|
||||||
{
|
|
||||||
return addPointCellLabels_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Point labels for subsetted meshes
|
//- Point labels for subsetted meshes
|
||||||
@ -151,15 +141,29 @@ class vtkPVFoam
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Cell-centre labels for additional points of decomposed cells
|
||||||
|
labelList& additionalIds()
|
||||||
|
{
|
||||||
|
return additionalIds_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Cell-centre labels for additional points of decomposed cells
|
||||||
|
const labelList& additionalIds() const
|
||||||
|
{
|
||||||
|
return additionalIds_;
|
||||||
|
}
|
||||||
|
|
||||||
//- Clear
|
//- Clear
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
superCells_.clear();
|
cellMap_.clear();
|
||||||
addPointCellLabels_.clear();
|
|
||||||
pointMap_.clear();
|
pointMap_.clear();
|
||||||
|
additionalIds_.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef polyDecomp foamVtuData;
|
||||||
|
|
||||||
|
|
||||||
// Private Data
|
// Private Data
|
||||||
|
|
||||||
@ -208,27 +212,20 @@ class vtkPVFoam
|
|||||||
|
|
||||||
//- Decomposed cells information (mesh regions)
|
//- Decomposed cells information (mesh regions)
|
||||||
// TODO: regions
|
// TODO: regions
|
||||||
List<polyDecomp> regionPolyDecomp_;
|
List<foamVtuData> regionVtus_;
|
||||||
|
|
||||||
//- Decomposed cells information (cellZone meshes)
|
//- Decomposed cells information (cellZone meshes)
|
||||||
List<polyDecomp> zonePolyDecomp_;
|
List<foamVtuData> zoneVtus_;
|
||||||
|
|
||||||
//- Decomposed cells information (cellSet meshes)
|
//- Decomposed cells information (cellSet meshes)
|
||||||
List<polyDecomp> csetPolyDecomp_;
|
List<foamVtuData> csetVtus_;
|
||||||
|
|
||||||
//- List of patch names for rendering to window
|
//- List of patch names for rendering to window
|
||||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
List<vtkSmartPointer<vtkTextActor>> patchTextActors_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Create a text actor
|
|
||||||
static vtkTextActor* createTextActor
|
|
||||||
(
|
|
||||||
const std::string& s,
|
|
||||||
const point& pt
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Reset data counters
|
//- Reset data counters
|
||||||
void resetCounters();
|
void resetCounters();
|
||||||
|
|
||||||
@ -318,14 +315,14 @@ class vtkPVFoam
|
|||||||
// Add mesh functions
|
// Add mesh functions
|
||||||
|
|
||||||
//- Volume meshes as vtkUnstructuredGrid
|
//- Volume meshes as vtkUnstructuredGrid
|
||||||
vtkUnstructuredGrid* volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> volumeVTKMesh
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
polyDecomp& decompInfo
|
foamVtuData& vtuData
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Lagrangian positions as vtkPolyData
|
//- Lagrangian positions as vtkPolyData
|
||||||
vtkPolyData* lagrangianVTKMesh
|
vtkSmartPointer<vtkPolyData> lagrangianVTKMesh
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& cloudName
|
const word& cloudName
|
||||||
@ -333,7 +330,7 @@ class vtkPVFoam
|
|||||||
|
|
||||||
//- Patches (mesh or primitive) as vtkPolyData
|
//- Patches (mesh or primitive) as vtkPolyData
|
||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
vtkPolyData* patchVTKMesh
|
vtkSmartPointer<vtkPolyData> patchVTKMesh
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const PatchType& p
|
const PatchType& p
|
||||||
@ -344,7 +341,7 @@ class vtkPVFoam
|
|||||||
|
|
||||||
//- Convert Field to VTK field
|
//- Convert Field to VTK field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* convertFieldToVTK
|
vtkSmartPointer<vtkFloatArray> convertFieldToVTK
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Field<Type>& fld
|
const Field<Type>& fld
|
||||||
@ -352,7 +349,7 @@ class vtkPVFoam
|
|||||||
|
|
||||||
//- Face set/zone field
|
//- Face set/zone field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* convertFaceFieldToVTK
|
vtkSmartPointer<vtkFloatArray> convertFaceFieldToVTK
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
const labelUList& faceLabels
|
const labelUList& faceLabels
|
||||||
@ -360,10 +357,10 @@ class vtkPVFoam
|
|||||||
|
|
||||||
//- Volume field
|
//- Volume field
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* convertVolFieldToVTK
|
vtkSmartPointer<vtkFloatArray> convertVolFieldToVTK
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
const polyDecomp& decompInfo
|
const foamVtuData& vtuData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -416,7 +413,7 @@ class vtkPVFoam
|
|||||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range,
|
||||||
const List<polyDecomp>& decompLst
|
const List<foamVtuData>& vtuDataList
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Lagrangian fields - all types
|
//- Lagrangian fields - all types
|
||||||
@ -444,7 +441,7 @@ class vtkPVFoam
|
|||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range,
|
||||||
const List<polyDecomp>& decompLst
|
const List<foamVtuData>& vtuDataList
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Point field
|
//- Point field
|
||||||
@ -454,7 +451,7 @@ class vtkPVFoam
|
|||||||
vtkUnstructuredGrid* vtkmesh,
|
vtkUnstructuredGrid* vtkmesh,
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||||
const polyDecomp& decomp
|
const foamVtuData& vtuData
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,6 +42,7 @@ InClass
|
|||||||
#include "vtkFloatArray.h"
|
#include "vtkFloatArray.h"
|
||||||
#include "vtkCellData.h"
|
#include "vtkCellData.h"
|
||||||
#include "vtkPointData.h"
|
#include "vtkPointData.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
//
|
//
|
||||||
@ -84,7 +85,7 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeVolume_,
|
rangeVolume_,
|
||||||
regionPolyDecomp_
|
regionVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellZones
|
// Convert activated cellZones
|
||||||
@ -94,7 +95,7 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeCellZones_,
|
rangeCellZones_,
|
||||||
zonePolyDecomp_
|
zoneVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellSets
|
// Convert activated cellSets
|
||||||
@ -104,7 +105,7 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
ptfPtr,
|
ptfPtr,
|
||||||
output,
|
output,
|
||||||
rangeCellSets_,
|
rangeCellSets_,
|
||||||
csetPolyDecomp_
|
csetVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -151,38 +152,44 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
fvPatchField<Type>(p, fld).patchInternalField()
|
fvPatchField<Type>(p, fld).patchInternalField()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), tpptf());
|
vtkSmartPointer<vtkFloatArray> cdata =
|
||||||
|
convertFieldToVTK
|
||||||
|
(
|
||||||
|
fld.name(),
|
||||||
|
tpptf()
|
||||||
|
);
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
cdata->Delete();
|
|
||||||
|
|
||||||
if (patchId < patchInterpList.size())
|
if (patchId < patchInterpList.size())
|
||||||
{
|
{
|
||||||
vtkFloatArray* pdata = convertFieldToVTK
|
vtkSmartPointer<vtkFloatArray> pdata = convertFieldToVTK
|
||||||
(
|
(
|
||||||
fld.name(),
|
fld.name(),
|
||||||
patchInterpList[patchId].faceToPointInterpolate(tpptf)()
|
patchInterpList[patchId].faceToPointInterpolate(tpptf)()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetPointData()->AddArray(pdata);
|
vtkmesh->GetPointData()->AddArray(pdata);
|
||||||
pdata->Delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vtkFloatArray* cdata = convertFieldToVTK(fld.name(), ptf);
|
vtkSmartPointer<vtkFloatArray> cdata =
|
||||||
|
convertFieldToVTK
|
||||||
|
(
|
||||||
|
fld.name(),
|
||||||
|
ptf
|
||||||
|
);
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
cdata->Delete();
|
|
||||||
|
|
||||||
if (patchId < patchInterpList.size())
|
if (patchId < patchInterpList.size())
|
||||||
{
|
{
|
||||||
vtkFloatArray* pdata = convertFieldToVTK
|
vtkSmartPointer<vtkFloatArray> pdata = convertFieldToVTK
|
||||||
(
|
(
|
||||||
fld.name(),
|
fld.name(),
|
||||||
patchInterpList[patchId].faceToPointInterpolate(ptf)()
|
patchInterpList[patchId].faceToPointInterpolate(ptf)()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetPointData()->AddArray(pdata);
|
vtkmesh->GetPointData()->AddArray(pdata);
|
||||||
pdata->Delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,14 +222,13 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
vtkFloatArray* cdata = convertFaceFieldToVTK
|
vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK
|
||||||
(
|
(
|
||||||
fld,
|
fld,
|
||||||
zMesh[zoneId]
|
zMesh[zoneId]
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
cdata->Delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: points
|
// TODO: points
|
||||||
@ -253,14 +259,13 @@ void Foam::vtkPVFoam::convertVolField
|
|||||||
|
|
||||||
const faceSet fSet(mesh, selectName);
|
const faceSet fSet(mesh, selectName);
|
||||||
|
|
||||||
vtkFloatArray* cdata = convertFaceFieldToVTK
|
vtkSmartPointer<vtkFloatArray> cdata = convertFaceFieldToVTK
|
||||||
(
|
(
|
||||||
fld,
|
fld,
|
||||||
fSet.sortedToc()
|
fSet.sortedToc()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
cdata->Delete();
|
|
||||||
|
|
||||||
// TODO: points
|
// TODO: points
|
||||||
}
|
}
|
||||||
@ -369,7 +374,7 @@ void Foam::vtkPVFoam::convertVolFieldBlock
|
|||||||
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
autoPtr<GeometricField<Type, pointPatchField, pointMesh>>& ptfPtr,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range,
|
||||||
const List<polyDecomp>& decompLst
|
const List<foamVtuData>& vtuDataList
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
@ -389,18 +394,16 @@ void Foam::vtkPVFoam::convertVolFieldBlock
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkFloatArray* cdata = convertVolFieldToVTK
|
vtkSmartPointer<vtkFloatArray> cdata = convertVolFieldToVTK
|
||||||
(
|
(
|
||||||
fld,
|
fld,
|
||||||
decompLst[datasetNo]
|
vtuDataList[datasetNo]
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetCellData()->AddArray(cdata);
|
vtkmesh->GetCellData()->AddArray(cdata);
|
||||||
cdata->Delete();
|
|
||||||
|
|
||||||
if (ptfPtr.valid())
|
if (ptfPtr.valid())
|
||||||
{
|
{
|
||||||
convertPointField(vtkmesh, ptfPtr(), fld, decompLst[datasetNo]);
|
convertPointField(vtkmesh, ptfPtr(), fld, vtuDataList[datasetNo]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -449,7 +452,7 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeVolume_,
|
rangeVolume_,
|
||||||
regionPolyDecomp_
|
regionVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellZones
|
// Convert activated cellZones
|
||||||
@ -458,7 +461,7 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeCellZones_,
|
rangeCellZones_,
|
||||||
zonePolyDecomp_
|
zoneVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Convert activated cellSets
|
// Convert activated cellSets
|
||||||
@ -467,7 +470,7 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
pfld,
|
pfld,
|
||||||
output,
|
output,
|
||||||
rangeCellSets_,
|
rangeCellSets_,
|
||||||
csetPolyDecomp_
|
csetVtus_
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -492,14 +495,13 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
vtkFloatArray* pdata = convertFieldToVTK
|
vtkSmartPointer<vtkFloatArray> pdata = convertFieldToVTK
|
||||||
(
|
(
|
||||||
fieldName,
|
fieldName,
|
||||||
pfld.boundaryField()[patchId].patchInternalField()()
|
pfld.boundaryField()[patchId].patchInternalField()()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->GetPointData()->AddArray(pdata);
|
vtkmesh->GetPointData()->AddArray(pdata);
|
||||||
pdata->Delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,10 +533,14 @@ void Foam::vtkPVFoam::convertPointFields
|
|||||||
mesh.faceZones()[zoneId]().meshPoints()
|
mesh.faceZones()[zoneId]().meshPoints()
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkFloatArray* pdata = convertFieldToVTK(fieldName, znfld);
|
vtkSmartPointer<vtkFloatArray> pdata =
|
||||||
|
convertFieldToVTK
|
||||||
|
(
|
||||||
|
fieldName,
|
||||||
|
znfld
|
||||||
|
);
|
||||||
|
|
||||||
vtkmesh->GetPointData()->AddArray(pdata);
|
vtkmesh->GetPointData()->AddArray(pdata);
|
||||||
pdata->Delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -547,7 +553,7 @@ void Foam::vtkPVFoam::convertPointFieldBlock
|
|||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
vtkMultiBlockDataSet* output,
|
vtkMultiBlockDataSet* output,
|
||||||
const arrayRange& range,
|
const arrayRange& range,
|
||||||
const List<polyDecomp>& decompLst
|
const List<foamVtuData>& vtuDataList
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (auto partId : range)
|
for (auto partId : range)
|
||||||
@ -571,7 +577,7 @@ void Foam::vtkPVFoam::convertPointFieldBlock
|
|||||||
vtkmesh,
|
vtkmesh,
|
||||||
pfld,
|
pfld,
|
||||||
GeometricField<Type, fvPatchField, volMesh>::null(),
|
GeometricField<Type, fvPatchField, volMesh>::null(),
|
||||||
decompLst[datasetNo]
|
vtuDataList[datasetNo]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -584,7 +590,7 @@ void Foam::vtkPVFoam::convertPointField
|
|||||||
vtkUnstructuredGrid* vtkmesh,
|
vtkUnstructuredGrid* vtkmesh,
|
||||||
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
const GeometricField<Type, pointPatchField, pointMesh>& pfld,
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
const GeometricField<Type, fvPatchField, volMesh>& vfld,
|
||||||
const polyDecomp& decomp
|
const foamVtuData& vtuData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!vtkmesh)
|
if (!vtkmesh)
|
||||||
@ -593,13 +599,15 @@ void Foam::vtkPVFoam::convertPointField
|
|||||||
}
|
}
|
||||||
|
|
||||||
const label nComp = pTraits<Type>::nComponents;
|
const label nComp = pTraits<Type>::nComponents;
|
||||||
const labelUList& addPointCellLabels = decomp.addPointCellLabels();
|
const labelUList& addPointCellLabels = vtuData.additionalIds();
|
||||||
const labelUList& pointMap = decomp.pointMap();
|
const labelUList& pointMap = vtuData.pointMap();
|
||||||
|
|
||||||
// use a pointMap or address directly into mesh
|
// use a pointMap or address directly into mesh
|
||||||
const label nPoints = (pointMap.size() ? pointMap.size() : pfld.size());
|
const label nPoints = (pointMap.size() ? pointMap.size() : pfld.size());
|
||||||
|
|
||||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
vtkSmartPointer<vtkFloatArray> fldData =
|
||||||
|
vtkSmartPointer<vtkFloatArray>::New();
|
||||||
|
|
||||||
fldData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
fldData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
|
||||||
fldData->SetNumberOfComponents(nComp);
|
fldData->SetNumberOfComponents(nComp);
|
||||||
fldData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
fldData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
|
||||||
@ -689,7 +697,6 @@ void Foam::vtkPVFoam::convertPointField
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->GetPointData()->AddArray(fldData);
|
vtkmesh->GetPointData()->AddArray(fldData);
|
||||||
fldData->Delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -720,9 +727,13 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
|||||||
{
|
{
|
||||||
IOField<Type> fld(*iter());
|
IOField<Type> fld(*iter());
|
||||||
|
|
||||||
vtkFloatArray* fldData = convertFieldToVTK(fld.name(), fld);
|
vtkSmartPointer<vtkFloatArray> fldData =
|
||||||
|
convertFieldToVTK
|
||||||
|
(
|
||||||
|
fld.name(),
|
||||||
|
fld
|
||||||
|
);
|
||||||
vtkmesh->GetPointData()->AddArray(fldData);
|
vtkmesh->GetPointData()->AddArray(fldData);
|
||||||
fldData->Delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -735,7 +746,8 @@ void Foam::vtkPVFoam::convertLagrangianFields
|
|||||||
//
|
//
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* Foam::vtkPVFoam::convertFieldToVTK
|
vtkSmartPointer<vtkFloatArray>
|
||||||
|
Foam::vtkPVFoam::convertFieldToVTK
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Field<Type>& fld
|
const Field<Type>& fld
|
||||||
@ -751,7 +763,9 @@ vtkFloatArray* Foam::vtkPVFoam::convertFieldToVTK
|
|||||||
|
|
||||||
const label nComp = pTraits<Type>::nComponents;
|
const label nComp = pTraits<Type>::nComponents;
|
||||||
|
|
||||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
vtkSmartPointer<vtkFloatArray> fldData =
|
||||||
|
vtkSmartPointer<vtkFloatArray>::New();
|
||||||
|
|
||||||
fldData->SetNumberOfTuples(fld.size());
|
fldData->SetNumberOfTuples(fld.size());
|
||||||
fldData->SetNumberOfComponents(nComp);
|
fldData->SetNumberOfComponents(nComp);
|
||||||
fldData->Allocate(nComp*fld.size());
|
fldData->Allocate(nComp*fld.size());
|
||||||
@ -775,7 +789,8 @@ vtkFloatArray* Foam::vtkPVFoam::convertFieldToVTK
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* Foam::vtkPVFoam::convertFaceFieldToVTK
|
vtkSmartPointer<vtkFloatArray>
|
||||||
|
Foam::vtkPVFoam::convertFaceFieldToVTK
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
const labelUList& faceLabels
|
const labelUList& faceLabels
|
||||||
@ -796,7 +811,9 @@ vtkFloatArray* Foam::vtkPVFoam::convertFaceFieldToVTK
|
|||||||
const labelList& faceOwner = mesh.faceOwner();
|
const labelList& faceOwner = mesh.faceOwner();
|
||||||
const labelList& faceNeigh = mesh.faceNeighbour();
|
const labelList& faceNeigh = mesh.faceNeighbour();
|
||||||
|
|
||||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
vtkSmartPointer<vtkFloatArray> fldData =
|
||||||
|
vtkSmartPointer<vtkFloatArray>::New();
|
||||||
|
|
||||||
fldData->SetNumberOfTuples(faceLabels.size());
|
fldData->SetNumberOfTuples(faceLabels.size());
|
||||||
fldData->SetNumberOfComponents(nComp);
|
fldData->SetNumberOfComponents(nComp);
|
||||||
fldData->Allocate(nComp*faceLabels.size());
|
fldData->Allocate(nComp*faceLabels.size());
|
||||||
@ -836,35 +853,38 @@ vtkFloatArray* Foam::vtkPVFoam::convertFaceFieldToVTK
|
|||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
vtkFloatArray* Foam::vtkPVFoam::convertVolFieldToVTK
|
vtkSmartPointer<vtkFloatArray>
|
||||||
|
Foam::vtkPVFoam::convertVolFieldToVTK
|
||||||
(
|
(
|
||||||
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
const GeometricField<Type, fvPatchField, volMesh>& fld,
|
||||||
const polyDecomp& decompInfo
|
const foamVtuData& vtuData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const label nComp = pTraits<Type>::nComponents;
|
const label nComp = pTraits<Type>::nComponents;
|
||||||
const labelList& superCells = decompInfo.superCells();
|
const labelList& cellMap = vtuData.cellMap();
|
||||||
|
|
||||||
vtkFloatArray* fldData = vtkFloatArray::New();
|
vtkSmartPointer<vtkFloatArray> fldData =
|
||||||
fldData->SetNumberOfTuples(superCells.size());
|
vtkSmartPointer<vtkFloatArray>::New();
|
||||||
|
|
||||||
|
fldData->SetNumberOfTuples(cellMap.size());
|
||||||
fldData->SetNumberOfComponents(nComp);
|
fldData->SetNumberOfComponents(nComp);
|
||||||
fldData->Allocate(nComp*superCells.size());
|
fldData->Allocate(nComp*cellMap.size());
|
||||||
fldData->SetName(fld.name().c_str());
|
fldData->SetName(fld.name().c_str());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "convert volField: "
|
Info<< "convert volField: "
|
||||||
<< fld.name()
|
<< fld.name()
|
||||||
<< " size=" << superCells.size()
|
<< " size=" << cellMap.size()
|
||||||
<< " (" << fld.size() << " + "
|
<< " (" << fld.size() << " + "
|
||||||
<< (superCells.size() - fld.size())
|
<< (cellMap.size() - fld.size())
|
||||||
<< ") nComp=" << nComp << endl;
|
<< ") nComp=" << nComp << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
float vec[nComp];
|
float vec[nComp];
|
||||||
forAll(superCells, i)
|
forAll(cellMap, i)
|
||||||
{
|
{
|
||||||
const Type& t = fld[superCells[i]];
|
const Type& t = fld[cellMap[i]];
|
||||||
for (direction d=0; d<nComp; ++d)
|
for (direction d=0; d<nComp; ++d)
|
||||||
{
|
{
|
||||||
vec[d] = component(t, d);
|
vec[d] = component(t, d);
|
||||||
|
|||||||
@ -38,6 +38,7 @@ License
|
|||||||
#include "vtkMultiBlockDataSet.h"
|
#include "vtkMultiBlockDataSet.h"
|
||||||
#include "vtkPolyData.h"
|
#include "vtkPolyData.h"
|
||||||
#include "vtkUnstructuredGrid.h"
|
#include "vtkUnstructuredGrid.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ void Foam::vtkPVFoam::convertMeshVolume
|
|||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
// resize for decomposed polyhedra
|
||||||
regionPolyDecomp_.setSize(range.size());
|
regionVtus_.setSize(range.size());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -72,17 +73,15 @@ void Foam::vtkPVFoam::convertMeshVolume
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
regionPolyDecomp_[datasetNo]
|
regionVtus_[datasetNo]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,13 +126,12 @@ void Foam::vtkPVFoam::convertMeshLagrangian
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = lagrangianVTKMesh(mesh, cloudName);
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
lagrangianVTKMesh(mesh, cloudName);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
addToBlock(output, vtkmesh, range, datasetNo, cloudName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,7 +186,7 @@ void Foam::vtkPVFoam::convertMeshPatches
|
|||||||
<< patchName << endl;
|
<< patchName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = nullptr;
|
vtkSmartPointer<vtkPolyData> vtkmesh;
|
||||||
if (patchIds.size() == 1)
|
if (patchIds.size() == 1)
|
||||||
{
|
{
|
||||||
vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]);
|
vtkmesh = patchVTKMesh(patchName, patches[patchIds.begin().key()]);
|
||||||
@ -228,8 +226,6 @@ void Foam::vtkPVFoam::convertMeshPatches
|
|||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, patchName);
|
addToBlock(output, vtkmesh, range, datasetNo, patchName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,7 +256,7 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
|||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
// resize for decomposed polyhedra
|
||||||
zonePolyDecomp_.setSize(range.size());
|
zoneVtus_.setSize(range.size());
|
||||||
|
|
||||||
if (range.empty())
|
if (range.empty())
|
||||||
{
|
{
|
||||||
@ -293,32 +289,30 @@ void Foam::vtkPVFoam::convertMeshCellZones
|
|||||||
fvMeshSubset subsetter(mesh);
|
fvMeshSubset subsetter(mesh);
|
||||||
subsetter.setLargeCellSubset(zMesh[zoneId]);
|
subsetter.setLargeCellSubset(zMesh[zoneId]);
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
subsetter.subMesh(),
|
subsetter.subMesh(),
|
||||||
zonePolyDecomp_[datasetNo]
|
zoneVtus_[datasetNo]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
// superCells + addPointCellLabels must contain global cell ids
|
// cellMap + addPointCellLabels must contain global cell ids
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
zonePolyDecomp_[datasetNo].superCells()
|
zoneVtus_[datasetNo].cellMap()
|
||||||
);
|
);
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
zonePolyDecomp_[datasetNo].addPointCellLabels()
|
zoneVtus_[datasetNo].additionalIds()
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy pointMap as well, otherwise pointFields fail
|
// copy pointMap as well, otherwise pointFields fail
|
||||||
zonePolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
zoneVtus_[datasetNo].pointMap() = subsetter.pointMap();
|
||||||
|
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +343,7 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
|||||||
const fvMesh& mesh = *meshPtr_;
|
const fvMesh& mesh = *meshPtr_;
|
||||||
|
|
||||||
// resize for decomposed polyhedra
|
// resize for decomposed polyhedra
|
||||||
csetPolyDecomp_.setSize(range.size());
|
csetVtus_.setSize(range.size());
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -375,32 +369,30 @@ void Foam::vtkPVFoam::convertMeshCellSets
|
|||||||
fvMeshSubset subsetter(mesh);
|
fvMeshSubset subsetter(mesh);
|
||||||
subsetter.setLargeCellSubset(cSet);
|
subsetter.setLargeCellSubset(cSet);
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh = volumeVTKMesh
|
||||||
(
|
(
|
||||||
subsetter.subMesh(),
|
subsetter.subMesh(),
|
||||||
csetPolyDecomp_[datasetNo]
|
csetVtus_[datasetNo]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
// superCells + addPointCellLabels must contain global cell ids
|
// cellMap + addPointCellLabels must contain global cell ids
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
csetPolyDecomp_[datasetNo].superCells()
|
csetVtus_[datasetNo].cellMap()
|
||||||
);
|
);
|
||||||
inplaceRenumber
|
inplaceRenumber
|
||||||
(
|
(
|
||||||
subsetter.cellMap(),
|
subsetter.cellMap(),
|
||||||
csetPolyDecomp_[datasetNo].addPointCellLabels()
|
csetVtus_[datasetNo].additionalIds()
|
||||||
);
|
);
|
||||||
|
|
||||||
// copy pointMap as well, otherwise pointFields fail
|
// copy pointMap as well, otherwise pointFields fail
|
||||||
csetPolyDecomp_[datasetNo].pointMap() = subsetter.pointMap();
|
csetVtus_[datasetNo].pointMap() = subsetter.pointMap();
|
||||||
|
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -458,13 +450,12 @@ void Foam::vtkPVFoam::convertMeshFaceZones
|
|||||||
<< zoneName << endl;
|
<< zoneName << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = patchVTKMesh(zoneName, zMesh[zoneId]());
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
patchVTKMesh(zoneName, zMesh[zoneId]());
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -530,12 +521,12 @@ void Foam::vtkPVFoam::convertMeshFaceSets
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = patchVTKMesh("faceSet:" + partName, p);
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
patchVTKMesh("faceSet:" + partName, p);
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -586,7 +577,9 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
|||||||
|
|
||||||
const labelUList& pointLabels = zMesh[zoneId];
|
const labelUList& pointLabels = zMesh[zoneId];
|
||||||
|
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(pointLabels.size());
|
vtkpoints->Allocate(pointLabels.size());
|
||||||
|
|
||||||
const pointField& meshPoints = mesh.points();
|
const pointField& meshPoints = mesh.points();
|
||||||
@ -595,15 +588,14 @@ void Foam::vtkPVFoam::convertMeshPointZones
|
|||||||
vtkpoints->InsertNextPoint(meshPoints[pointLabels[pointi]].v_);
|
vtkpoints->InsertNextPoint(meshPoints[pointLabels[pointi]].v_);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
addToBlock(output, vtkmesh, range, datasetNo, zoneName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -657,7 +649,9 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
|||||||
|
|
||||||
const pointSet pSet(mesh, partName);
|
const pointSet pSet(mesh, partName);
|
||||||
|
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(pSet.size());
|
vtkpoints->Allocate(pSet.size());
|
||||||
|
|
||||||
const pointField& meshPoints = mesh.points();
|
const pointField& meshPoints = mesh.points();
|
||||||
@ -666,15 +660,14 @@ void Foam::vtkPVFoam::convertMeshPointSets
|
|||||||
vtkpoints->InsertNextPoint(meshPoints[iter.key()].v_);
|
vtkpoints->InsertNextPoint(meshPoints[iter.key()].v_);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
if (vtkmesh)
|
if (vtkmesh)
|
||||||
{
|
{
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
addToBlock(output, vtkmesh, range, datasetNo, partName);
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
partDataset_[partId] = datasetNo++;
|
partDataset_[partId] = datasetNo++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,16 +35,17 @@ License
|
|||||||
#include "vtkCellArray.h"
|
#include "vtkCellArray.h"
|
||||||
#include "vtkPoints.h"
|
#include "vtkPoints.h"
|
||||||
#include "vtkPolyData.h"
|
#include "vtkPolyData.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::lagrangianVTKMesh
|
||||||
(
|
(
|
||||||
const polyMesh& mesh,
|
const polyMesh& mesh,
|
||||||
const word& cloudName
|
const word& cloudName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vtkPolyData* vtkmesh = nullptr;
|
vtkSmartPointer<vtkPolyData> vtkmesh;
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -72,9 +73,13 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
|||||||
Info<< "cloud with " << parcels.size() << " parcels" << endl;
|
Info<< "cloud with " << parcels.size() << " parcels" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh = vtkPolyData::New();
|
vtkmesh = vtkSmartPointer<vtkPolyData>::New();
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkCellArray> vtkcells =
|
||||||
|
vtkSmartPointer<vtkCellArray>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(parcels.size());
|
vtkpoints->Allocate(parcels.size());
|
||||||
vtkcells->Allocate(parcels.size());
|
vtkcells->Allocate(parcels.size());
|
||||||
@ -89,10 +94,7 @@ vtkPolyData* Foam::vtkPVFoam::lagrangianVTKMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
vtkmesh->SetVerts(vtkcells);
|
vtkmesh->SetVerts(vtkcells);
|
||||||
vtkcells->Delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
@ -34,13 +34,14 @@ License
|
|||||||
#include "vtkCellArray.h"
|
#include "vtkCellArray.h"
|
||||||
#include "vtkIdTypeArray.h"
|
#include "vtkIdTypeArray.h"
|
||||||
#include "vtkUnstructuredGrid.h"
|
#include "vtkUnstructuredGrid.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
vtkSmartPointer<vtkUnstructuredGrid> Foam::vtkPVFoam::volumeVTKMesh
|
||||||
(
|
(
|
||||||
const fvMesh& mesh,
|
const fvMesh& mesh,
|
||||||
polyDecomp& decompInfo
|
foamVtuData& vtuData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||||
@ -50,7 +51,8 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
const cellModel& tetWedge = *(cellModeller::lookup("tetWedge"));
|
||||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh =
|
||||||
|
vtkSmartPointer<vtkUnstructuredGrid>::New();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -69,8 +71,8 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
// face owner is needed to determine the face orientation
|
// face owner is needed to determine the face orientation
|
||||||
const labelList& owner = mesh.faceOwner();
|
const labelList& owner = mesh.faceOwner();
|
||||||
|
|
||||||
labelList& superCells = decompInfo.superCells();
|
labelList& cellMap = vtuData.cellMap();
|
||||||
labelList& addPointCellLabels = decompInfo.addPointCellLabels();
|
labelList& addPointCellLabels = vtuData.additionalIds();
|
||||||
|
|
||||||
// Scan for cells which need to be decomposed and count additional points
|
// Scan for cells which need to be decomposed and count additional points
|
||||||
// and cells
|
// and cells
|
||||||
@ -116,10 +118,11 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
// Set size of additional cells mapping array
|
// Set size of additional cells mapping array
|
||||||
// (from added cell to original cell)
|
// (from added cell to original cell)
|
||||||
|
|
||||||
superCells.setSize(mesh.nCells() + nAddCells);
|
cellMap.setSize(mesh.nCells() + nAddCells);
|
||||||
|
|
||||||
// Convert OpenFOAM mesh vertices to VTK
|
// Convert OpenFOAM mesh vertices to VTK
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPoints> vtkpoints = vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
vtkpoints->Allocate(mesh.nPoints() + nAddPoints);
|
||||||
|
|
||||||
const Foam::pointField& points = mesh.points();
|
const Foam::pointField& points = mesh.points();
|
||||||
@ -147,7 +150,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
const cellShape& cellShape = cellShapes[celli];
|
const cellShape& cellShape = cellShapes[celli];
|
||||||
const cellModel& cellModel = cellShape.model();
|
const cellModel& cellModel = cellShape.model();
|
||||||
|
|
||||||
superCells[addCelli++] = celli;
|
cellMap[addCelli++] = celli;
|
||||||
|
|
||||||
if (cellModel == tet)
|
if (cellModel == tet)
|
||||||
{
|
{
|
||||||
@ -334,7 +337,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
superCells[addCelli++] = celli;
|
cellMap[addCelli++] = celli;
|
||||||
}
|
}
|
||||||
|
|
||||||
const face& quad = quadFcs[quadI];
|
const face& quad = quadFcs[quadI];
|
||||||
@ -377,7 +380,7 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
superCells[addCelli++] = celli;
|
cellMap[addCelli++] = celli;
|
||||||
}
|
}
|
||||||
|
|
||||||
const face& tri = triFcs[triI];
|
const face& tri = triFcs[triI];
|
||||||
@ -411,7 +414,6 @@ vtkUnstructuredGrid* Foam::vtkPVFoam::volumeVTKMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,17 +33,19 @@ License
|
|||||||
#include "vtkCellArray.h"
|
#include "vtkCellArray.h"
|
||||||
#include "vtkPoints.h"
|
#include "vtkPoints.h"
|
||||||
#include "vtkPolyData.h"
|
#include "vtkPolyData.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class PatchType>
|
template<class PatchType>
|
||||||
vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
vtkSmartPointer<vtkPolyData> Foam::vtkPVFoam::patchVTKMesh
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const PatchType& p
|
const PatchType& p
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
|
vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
@ -54,20 +56,22 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
|||||||
// Convert OpenFOAM mesh vertices to VTK
|
// Convert OpenFOAM mesh vertices to VTK
|
||||||
const Foam::pointField& points = p.localPoints();
|
const Foam::pointField& points = p.localPoints();
|
||||||
|
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(points.size());
|
vtkpoints->Allocate(points.size());
|
||||||
forAll(points, i)
|
forAll(points, i)
|
||||||
{
|
{
|
||||||
vtkpoints->InsertNextPoint(points[i].v_);
|
vtkpoints->InsertNextPoint(points[i].v_);
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
// Add faces as polygons
|
// Add faces as polygons
|
||||||
const faceList& faces = p.localFaces();
|
const faceList& faces = p.localFaces();
|
||||||
|
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
vtkSmartPointer<vtkCellArray> vtkcells =
|
||||||
|
vtkSmartPointer<vtkCellArray>::New();
|
||||||
|
|
||||||
vtkcells->Allocate(faces.size());
|
vtkcells->Allocate(faces.size());
|
||||||
forAll(faces, facei)
|
forAll(faces, facei)
|
||||||
{
|
{
|
||||||
@ -82,7 +86,6 @@ vtkPolyData* Foam::vtkPVFoam::patchVTKMesh
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->SetPolys(vtkcells);
|
vtkmesh->SetPolys(vtkcells);
|
||||||
vtkcells->Delete();
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -39,6 +39,7 @@ License
|
|||||||
#include "vtkRenderer.h"
|
#include "vtkRenderer.h"
|
||||||
#include "vtkTextActor.h"
|
#include "vtkTextActor.h"
|
||||||
#include "vtkTextProperty.h"
|
#include "vtkTextProperty.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -47,16 +48,21 @@ namespace Foam
|
|||||||
defineTypeNameAndDebug(vtkPVblockMesh, 0);
|
defineTypeNameAndDebug(vtkPVblockMesh, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
vtkTextActor* Foam::vtkPVblockMesh::createTextActor
|
namespace Foam
|
||||||
|
{
|
||||||
|
// file-scope
|
||||||
|
//- Create a text actor
|
||||||
|
static vtkSmartPointer<vtkTextActor> createTextActor
|
||||||
(
|
(
|
||||||
const std::string& s,
|
const std::string& s,
|
||||||
const point& pt
|
const Foam::point& pt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
vtkTextActor* txt = vtkTextActor::New();
|
vtkSmartPointer<vtkTextActor> txt =
|
||||||
|
vtkSmartPointer<vtkTextActor>::New();
|
||||||
|
|
||||||
txt->SetInput(s.c_str());
|
txt->SetInput(s.c_str());
|
||||||
|
|
||||||
// Set text properties
|
// Set text properties
|
||||||
@ -74,6 +80,7 @@ vtkTextActor* Foam::vtkPVblockMesh::createTextActor
|
|||||||
|
|
||||||
return txt;
|
return txt;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -436,12 +443,11 @@ void Foam::vtkPVblockMesh::renderPatchNames
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// always remove old actors first
|
// always remove old actors first
|
||||||
forAll(patchTextActorsPtrs_, actori)
|
forAll(patchTextActors_, actori)
|
||||||
{
|
{
|
||||||
renderer->RemoveViewProp(patchTextActorsPtrs_[actori]);
|
renderer->RemoveViewProp(patchTextActors_[actori]);
|
||||||
patchTextActorsPtrs_[actori]->Delete();
|
|
||||||
}
|
}
|
||||||
patchTextActorsPtrs_.clear();
|
patchTextActors_.clear();
|
||||||
|
|
||||||
// the number of text actors
|
// the number of text actors
|
||||||
label nActors = 0;
|
label nActors = 0;
|
||||||
@ -459,7 +465,7 @@ void Foam::vtkPVblockMesh::renderPatchNames
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 8 sides per block is plenty
|
// 8 sides per block is plenty
|
||||||
patchTextActorsPtrs_.setSize(8*blkMesh.size());
|
patchTextActors_.setSize(8*blkMesh.size());
|
||||||
|
|
||||||
// Collect all variables
|
// Collect all variables
|
||||||
dictionary varDict(meshDescription.subOrEmptyDict("namedVertices"));
|
dictionary varDict(meshDescription.subOrEmptyDict("namedVertices"));
|
||||||
@ -495,33 +501,33 @@ void Foam::vtkPVblockMesh::renderPatchNames
|
|||||||
const face& f = patchFaces[facei];
|
const face& f = patchFaces[facei];
|
||||||
|
|
||||||
// Into a list for later removal
|
// Into a list for later removal
|
||||||
patchTextActorsPtrs_[nActors++] = createTextActor
|
patchTextActors_[nActors++] = createTextActor
|
||||||
(
|
(
|
||||||
patchName,
|
patchName,
|
||||||
f.centre(cornerPts) * scaleFactor
|
f.centre(cornerPts) * scaleFactor
|
||||||
);
|
);
|
||||||
|
|
||||||
if (nActors == patchTextActorsPtrs_.size())
|
if (nActors == patchTextActors_.size())
|
||||||
{
|
{
|
||||||
// hit max allocated space - bail out
|
// hit max allocated space - bail out
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nActors == patchTextActorsPtrs_.size())
|
if (nActors == patchTextActors_.size())
|
||||||
{
|
{
|
||||||
// hit max allocated space - bail out
|
// hit max allocated space - bail out
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
patchTextActorsPtrs_.setSize(nActors);
|
patchTextActors_.setSize(nActors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add text to each renderer
|
// Add text to each renderer
|
||||||
forAll(patchTextActorsPtrs_, actori)
|
forAll(patchTextActors_, actori)
|
||||||
{
|
{
|
||||||
renderer->AddViewProp(patchTextActorsPtrs_[actori]);
|
renderer->AddViewProp(patchTextActors_[actori]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -534,12 +540,11 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
|||||||
{
|
{
|
||||||
// always remove old actors first
|
// always remove old actors first
|
||||||
|
|
||||||
forAll(pointTextActorsPtrs_, actori)
|
forAll(pointTextActors_, actori)
|
||||||
{
|
{
|
||||||
renderer->RemoveViewProp(pointTextActorsPtrs_[actori]);
|
renderer->RemoveViewProp(pointTextActors_[actori]);
|
||||||
pointTextActorsPtrs_[actori]->Delete();
|
|
||||||
}
|
}
|
||||||
pointTextActorsPtrs_.clear();
|
pointTextActors_.clear();
|
||||||
|
|
||||||
if (show && meshPtr_)
|
if (show && meshPtr_)
|
||||||
{
|
{
|
||||||
@ -547,7 +552,7 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
|||||||
const pointField& cornerPts = blkMesh.vertices();
|
const pointField& cornerPts = blkMesh.vertices();
|
||||||
const scalar scaleFactor = blkMesh.scaleFactor();
|
const scalar scaleFactor = blkMesh.scaleFactor();
|
||||||
|
|
||||||
pointTextActorsPtrs_.setSize(cornerPts.size());
|
pointTextActors_.setSize(cornerPts.size());
|
||||||
forAll(cornerPts, pointi)
|
forAll(cornerPts, pointi)
|
||||||
{
|
{
|
||||||
// Display either pointi as a number or with its name
|
// Display either pointi as a number or with its name
|
||||||
@ -556,7 +561,7 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
|||||||
blockVertex::write(os, pointi, blkMesh.meshDict());
|
blockVertex::write(os, pointi, blkMesh.meshDict());
|
||||||
|
|
||||||
// Into a list for later removal
|
// Into a list for later removal
|
||||||
pointTextActorsPtrs_[pointi] = createTextActor
|
pointTextActors_[pointi] = createTextActor
|
||||||
(
|
(
|
||||||
os.str(),
|
os.str(),
|
||||||
cornerPts[pointi]*scaleFactor
|
cornerPts[pointi]*scaleFactor
|
||||||
@ -565,9 +570,9 @@ void Foam::vtkPVblockMesh::renderPointNumbers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add text to each renderer
|
// Add text to each renderer
|
||||||
forAll(pointTextActorsPtrs_, actori)
|
forAll(pointTextActors_, actori)
|
||||||
{
|
{
|
||||||
renderer->AddViewProp(pointTextActorsPtrs_[actori]);
|
renderer->AddViewProp(pointTextActors_[actori]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,6 +56,8 @@ class vtkPolyData;
|
|||||||
class vtkUnstructuredGrid;
|
class vtkUnstructuredGrid;
|
||||||
class vtkIndent;
|
class vtkIndent;
|
||||||
|
|
||||||
|
template<class T> class vtkSmartPointer;
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
@ -110,21 +112,14 @@ class vtkPVblockMesh
|
|||||||
arrayRange rangeCorners_;
|
arrayRange rangeCorners_;
|
||||||
|
|
||||||
//- List of patch names for rendering to window
|
//- List of patch names for rendering to window
|
||||||
List<vtkTextActor*> patchTextActorsPtrs_;
|
List<vtkSmartPointer<vtkTextActor>> patchTextActors_;
|
||||||
|
|
||||||
//- List of point numbers for rendering to window
|
//- List of point numbers for rendering to window
|
||||||
List<vtkTextActor*> pointTextActorsPtrs_;
|
List<vtkSmartPointer<vtkTextActor>> pointTextActors_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Create a text actor
|
|
||||||
static vtkTextActor* createTextActor
|
|
||||||
(
|
|
||||||
const std::string& s,
|
|
||||||
const point& pt
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Reset data counters
|
//- Reset data counters
|
||||||
void resetCounters();
|
void resetCounters();
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ License
|
|||||||
#include "vtkPoints.h"
|
#include "vtkPoints.h"
|
||||||
#include "vtkPolyData.h"
|
#include "vtkPolyData.h"
|
||||||
#include "vtkUnstructuredGrid.h"
|
#include "vtkUnstructuredGrid.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
@ -99,7 +100,9 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
|||||||
const blockDescriptor& blockDef = blkMesh[blockI];
|
const blockDescriptor& blockDef = blkMesh[blockI];
|
||||||
|
|
||||||
// Convert OpenFOAM mesh vertices to VTK
|
// Convert OpenFOAM mesh vertices to VTK
|
||||||
vtkPoints *vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate(blockDef.nPoints());
|
vtkpoints->Allocate(blockDef.nPoints());
|
||||||
const labelList& blockLabels = blockDef.blockShape();
|
const labelList& blockLabels = blockDef.blockShape();
|
||||||
|
|
||||||
@ -117,7 +120,9 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
|||||||
nodeIds[ptI] = ptI;
|
nodeIds[ptI] = ptI;
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkUnstructuredGrid* vtkmesh = vtkUnstructuredGrid::New();
|
vtkSmartPointer<vtkUnstructuredGrid> vtkmesh =
|
||||||
|
vtkSmartPointer<vtkUnstructuredGrid>::New();
|
||||||
|
|
||||||
vtkmesh->Allocate(1);
|
vtkmesh->Allocate(1);
|
||||||
vtkmesh->InsertNextCell
|
vtkmesh->InsertNextCell
|
||||||
(
|
(
|
||||||
@ -127,7 +132,6 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
|||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
addToBlock
|
addToBlock
|
||||||
(
|
(
|
||||||
@ -135,7 +139,6 @@ void Foam::vtkPVblockMesh::convertMeshBlocks
|
|||||||
selection->GetArrayName(partId)
|
selection->GetArrayName(partId)
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->Delete();
|
|
||||||
++datasetNo;
|
++datasetNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,8 +214,11 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
|||||||
{
|
{
|
||||||
const List<point>& edgePoints = edgesPoints[foundEdgeI];
|
const List<point>& edgePoints = edgesPoints[foundEdgeI];
|
||||||
|
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPolyData>::New();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate( edgePoints.size() );
|
vtkpoints->Allocate( edgePoints.size() );
|
||||||
vtkmesh->Allocate(1);
|
vtkmesh->Allocate(1);
|
||||||
@ -237,7 +243,6 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
|||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
addToBlock
|
addToBlock
|
||||||
(
|
(
|
||||||
@ -245,7 +250,6 @@ void Foam::vtkPVblockMesh::convertMeshEdges
|
|||||||
selection->GetArrayName(partId)
|
selection->GetArrayName(partId)
|
||||||
);
|
);
|
||||||
|
|
||||||
vtkmesh->Delete();
|
|
||||||
datasetNo++;
|
datasetNo++;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -287,9 +291,14 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
|||||||
|
|
||||||
if (true) // or some flag or other condition
|
if (true) // or some flag or other condition
|
||||||
{
|
{
|
||||||
vtkPolyData* vtkmesh = vtkPolyData::New();
|
vtkSmartPointer<vtkPolyData> vtkmesh =
|
||||||
vtkPoints* vtkpoints = vtkPoints::New();
|
vtkSmartPointer<vtkPolyData>::New();
|
||||||
vtkCellArray* vtkcells = vtkCellArray::New();
|
|
||||||
|
vtkSmartPointer<vtkPoints> vtkpoints =
|
||||||
|
vtkSmartPointer<vtkPoints>::New();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkCellArray> vtkcells =
|
||||||
|
vtkSmartPointer<vtkCellArray>::New();
|
||||||
|
|
||||||
vtkpoints->Allocate( blockPoints.size() );
|
vtkpoints->Allocate( blockPoints.size() );
|
||||||
vtkcells->Allocate( blockPoints.size() );
|
vtkcells->Allocate( blockPoints.size() );
|
||||||
@ -309,15 +318,15 @@ void Foam::vtkPVblockMesh::convertMeshCorners
|
|||||||
}
|
}
|
||||||
|
|
||||||
vtkmesh->SetPoints(vtkpoints);
|
vtkmesh->SetPoints(vtkpoints);
|
||||||
vtkpoints->Delete();
|
|
||||||
|
|
||||||
vtkmesh->SetVerts(vtkcells);
|
vtkmesh->SetVerts(vtkcells);
|
||||||
vtkcells->Delete();
|
|
||||||
|
|
||||||
addToBlock(output, vtkmesh, range, datasetNo, range.name());
|
addToBlock(output, vtkmesh, range, datasetNo, range.name());
|
||||||
vtkmesh->Delete();
|
|
||||||
|
|
||||||
++datasetNo;
|
++datasetNo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// anything added?
|
||||||
|
if (datasetNo)
|
||||||
|
{
|
||||||
++blockNo;
|
++blockNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,7 @@ License
|
|||||||
#include "vtkDataSet.h"
|
#include "vtkDataSet.h"
|
||||||
#include "vtkMultiBlockDataSet.h"
|
#include "vtkMultiBlockDataSet.h"
|
||||||
#include "vtkInformation.h"
|
#include "vtkInformation.h"
|
||||||
|
#include "vtkSmartPointer.h"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -54,7 +55,8 @@ void Foam::foamPvCore::addToBlock
|
|||||||
const int blockNo = selector.block();
|
const int blockNo = selector.block();
|
||||||
|
|
||||||
vtkDataObject* dataObj = output->GetBlock(blockNo);
|
vtkDataObject* dataObj = output->GetBlock(blockNo);
|
||||||
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(dataObj);
|
vtkSmartPointer<vtkMultiBlockDataSet> block =
|
||||||
|
vtkMultiBlockDataSet::SafeDownCast(dataObj);
|
||||||
|
|
||||||
if (!block)
|
if (!block)
|
||||||
{
|
{
|
||||||
@ -66,9 +68,8 @@ void Foam::foamPvCore::addToBlock
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
block = vtkMultiBlockDataSet::New();
|
block = vtkSmartPointer<vtkMultiBlockDataSet>::New();
|
||||||
output->SetBlock(blockNo, block);
|
output->SetBlock(blockNo, block);
|
||||||
block->Delete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
|||||||
Reference in New Issue
Block a user