#include "utilities.h"
#include <vtkCellArray.h>
+#include <vtkCellData.h>
#include <vtkCellLinks.h>
+#include <vtkDoubleArray.h>
#include <vtkIdTypeArray.h>
#include <vtkUnsignedCharArray.h>
++i;
int endBloc = i;
if ( endBloc > startBloc )
- copyBloc(newTypes, idCellsOldToNew, idNodesOldToNew, newConnectivity, newLocations, pointsCell,
- alreadyCopied, startBloc, endBloc);
+ copyBloc(newTypes,
+ idCellsOldToNew, idNodesOldToNew,
+ newConnectivity, newLocations,
+ pointsCell, alreadyCopied,
+ startBloc, endBloc);
}
-
newConnectivity->Squeeze();
if (1/*newNodeSize*/)
MESSAGE("NumberOfPoints: " << this->GetNumberOfPoints());
}
+ if (vtkDoubleArray* diameters =
+ vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )) // Balls
+ {
+ for (int oldCellID = 0; oldCellID < oldCellSize; oldCellID++)
+ {
+ if (this->Types->GetValue(oldCellID) == VTK_EMPTY_CELL)
+ continue;
+ int newCellId = idCellsOldToNew[ oldCellID ];
+ if (newTypes->GetValue(newCellId) == VTK_POLY_VERTEX)
+ diameters->SetValue( newCellId, diameters->GetValue( oldCellID ));
+ }
+ }
+
if (this->FaceLocations)
{
vtkIdTypeArray *newFaceLocations = vtkIdTypeArray::New();
newFaces->Delete();
}
else
+ {
this->SetCells(newTypes, newLocations, newConnectivity, FaceLocations, Faces);
+ }
newPoints->Delete();
newTypes->Delete();
}
}
-void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew,
- std::vector<int>& idNodesOldToNew, vtkCellArray* newConnectivity,
- vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
- int start, int end)
+void SMDS_UnstructuredGrid::copyBloc(vtkUnsignedCharArray *newTypes,
+ std::vector<int>& idCellsOldToNew,
+ std::vector<int>& idNodesOldToNew,
+ vtkCellArray* newConnectivity,
+ vtkIdTypeArray* newLocations,
+ vtkIdType* pointsCell,
+ int& alreadyCopied,
+ int start,
+ int end)
{
MESSAGE("copyBloc " << alreadyCopied << " " << start << " " << end << " size: " << end - start << " total: " << alreadyCopied + end - start);
for (int j = start; j < end; j++)
// TODO update sub-shape list of elements and nodes
return 0;
}
+
+//================================================================================
+/*!
+ * \brief Allocates data array for ball diameters
+ * \param MaxVtkID - max ID of a ball element
+ */
+//================================================================================
+
+void SMDS_UnstructuredGrid::AllocateDiameters( vtkIdType MaxVtkID )
+{
+ SetBallDiameter( MaxVtkID, 0 );
+}
+
+//================================================================================
+/*!
+ * \brief Sets diameter of a ball element
+ * \param vtkID - vtk id of the ball element
+ * \param diameter - diameter of the ball element
+ */
+//================================================================================
+
+void SMDS_UnstructuredGrid::SetBallDiameter( vtkIdType vtkID, double diameter )
+{
+ vtkDoubleArray* array = vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() );
+ if ( !array )
+ {
+ array = vtkDoubleArray::New();
+ array->SetNumberOfComponents(1);
+ vtkDataSet::CellData->SetScalars( array );
+ }
+ array->InsertValue( vtkID, diameter );
+}
+
+//================================================================================
+/*!
+ * \brief Returns diameter of a ball element
+ * \param vtkID - vtk id of the ball element
+ */
+//================================================================================
+
+double SMDS_UnstructuredGrid::GetBallDiameter( vtkIdType vtkID ) const
+{
+ if ( vtkDataSet::CellData )
+ return vtkDoubleArray::SafeDownCast( vtkDataSet::CellData->GetScalars() )->GetValue( vtkID );
+ return 0;
+}
+
{
public:
void setSMDS_mesh(SMDS_Mesh *mesh);
- void compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, std::vector<int>& idCellsOldToNew,
- int newCellSize);
-
+ void compactGrid(std::vector<int>& idNodesOldToNew,
+ int newNodeSize,
+ std::vector<int>& idCellsOldToNew,
+ int newCellSize);
virtual unsigned long GetMTime();
virtual void Update();
virtual void UpdateInformation();
void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
int getOrderedNodesOfFace(int vtkVolId, int& dim, std::vector<vtkIdType>& orderedNodes);
void BuildLinks();
- SMDS_MeshCell* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2, std::set<int>& originalNodes,
+ SMDS_MeshCell* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2,
+ std::set<int>& originalNodes,
std::map<int, std::map<int, int> >& nodeDomains,
std::map<int, std::map<long,int> >& nodeQuadDomains);
vtkCellLinks* GetLinks()
{
return _downArray[vtkType];
}
+ void AllocateDiameters( vtkIdType maxVtkID );
+ void SetBallDiameter( vtkIdType vtkID, double diameter );
+ double GetBallDiameter( vtkIdType vtkID ) const;
+
static SMDS_UnstructuredGrid* New();
SMDS_Mesh *_mesh;
protected: