22 #include <vtkSmartPointer.h> 23 #include <vtkCellArray.h> 24 #include <vtkPolyData.h> 25 #include <vtkImageData.h> 26 #include <vtkPointData.h> 27 #include <vtkMatrix4x4.h> 28 #include <vtkPolyDataCollection.h> 29 #include <vtkPolyDataAlgorithm.h> 30 #include <vtkTransform.h> 31 #include <vtkTransformCollection.h> 32 #include <vtkFloatArray.h> 33 #include <vtkMutableUndirectedGraph.h> 35 #include <milxGlobal.h> 38 enum GlyphType {Circle = 0, Triangle, Cross, Square, Diamond};
125 Model(vtkSmartPointer<vtkPolyData> model);
141 void AddInput(vtkSmartPointer<vtkPolyData> model);
146 inline void AddArray(vtkSmartPointer<vtkDataArray> array)
147 { CurrentModel->GetPointData()->AddArray(array); }
152 void SetInput(vtkSmartPointer<vtkPolyData> model);
163 void SetTransform(vtkSmartPointer<vtkAbstractTransform> newTransform);
168 void SetGraph(vtkSmartPointer<vtkMutableUndirectedGraph> graph);
173 void SetPoints(vtkSmartPointer<vtkPoints> modelPoints);
178 void SetPolys(vtkSmartPointer<vtkCellArray> modelPolys);
183 void SetVectors(vtkSmartPointer<vtkDataArray> modelVectors);
188 void SetScalars(vtkSmartPointer<vtkDataArray> modelScalars);
194 { CurrentModel->GetPointData()->SetActiveScalars(nameOfArray.c_str()); }
202 inline vtkSmartPointer<vtkPolyData>&
Result()
203 {
return CurrentModel; }
211 {
return PreviousModel; }
219 {
return InputModel; }
226 #if VTK_MAJOR_VERSION <=5 232 {
return Result()->GetProducerPort(); }
239 {
return Result()->GetNumberOfPoints(); }
245 {
return Result()->GetPointData()->GetNumberOfArrays(); }
251 {
return CurrentTransform; }
257 {
return Result()->GetPoints(); }
263 {
return Result()->GetPointData()->GetScalars(); }
269 {
if(GetScalars()) Result()->GetScalarRange(range); }
275 {
return Result()->GetPointData()->GetVectors(); }
281 {
return Result()->GetPointData()->GetNormals(); }
287 {
return Result()->GetPointData()->GetTensors(); }
294 #if VTK_MAJOR_VERSION > 5 295 CurrentModel->Modified();
297 CurrentModel->Update();
298 #endif // VTK_MAJOR_VERSION 321 void MatchInformation(vtkSmartPointer<vtkPolyData> matchMesh,
const bool rescale);
326 void IterativeClosestPointsRegistration(vtkSmartPointer<vtkPolyData> fixedMesh,
const bool similarity =
false,
const int maxPoints = 1024);
331 void LandmarkBasedRegistration(vtkSmartPointer<vtkPolyData> fixedMesh,
const bool similarity =
false);
336 void Decimate(
const float reduceFactor);
341 void QuadricDecimate(
const float reduceFactor);
348 void ClusterDecimate();
353 void LaplacianSmoothing(
const int iterations);
358 void WindowedSincSmoothing(
const int iterations,
const float passBand = 0.1);
363 void Curvature(
const bool meanCurvature =
true);
373 void DistanceMap(vtkSmartPointer<vtkPoints> loopPoints);
380 void GaussianWeightScalars(
float stddev,
float clampValue);
385 void Rotate(
const bool xAxis,
const bool yAxis,
const bool zAxis,
const float angle,
const coordinate centre);
390 void Flip(
const bool xAxis,
const bool yAxis,
const bool zAxis);
395 void Clip(
const coordinateType belowValue,
const coordinateType aboveValue);
400 void Threshold(
const coordinateType belowVal,
const coordinateType aboveVal,
const coordinateType outsideVal);
405 void Threshold(
const coordinateType belowVal,
const coordinateType aboveVal,
const coordinateType insideVal,
const coordinateType outsideVal);
410 void Mask(vtkSmartPointer<vtkPolyData> maskMesh);
412 void IsoSurface(vtkSmartPointer<vtkImageData> img,
double minValue);
414 vtkSmartPointer<vtkImageData> Voxelise(
const unsigned char insideValue,
double *spacing,
double *bounds = NULL,
const size_t padVoxels = 1);
419 void DelaunayGraph3D();
424 void Delaunay2DTriangulation();
429 void DelaunayTriangulation();
434 void Append(vtkSmartPointer<vtkPolyData> model);
443 static void Scale(vtkSmartPointer<vtkPolyData> model,
const coordinateType scale,
const bool useCentroid =
true);
451 inline void Scale(
const coordinateType scale,
const bool useCentroid =
true)
452 { Scale(CurrentModel, scale, useCentroid); }
464 void GenerateVertices();
469 void GenerateVertexScalars();
474 void GenerateVerticesAs2DGlyphs(
const GlyphType glyphType);
479 void GenerateTubes();
484 void GeneratePointModel(
const double newScale);
490 { GeneratePointModel(newScale); }
495 void GenerateSampledPoints(
const double distance);
502 void GenerateVectorField(
const double newScale = 0.0,
const bool useNormals =
false);
509 void GenerateTensorField(
const double newScale = 0.0);
516 void GenerateHedgehog(
const double newScale = 0.0);
521 void GenerateNormals(
const int pointNormals = 0);
526 void GenerateKMeansClustering(
int numberOfClusters);
531 void GenerateQuantisedPoints(
float quantiseFactor);
536 void GenerateCappedBoundaries();
541 void GenerateRegions();
546 void GenerateElevation(
double x,
double y,
double z);
551 void GenerateElevation();
577 void FillScalars(
const coordinateType value);
584 static void ClearScalars(vtkSmartPointer<vtkPolyData> &mesh);
591 static inline void ClearArrays(vtkSmartPointer<vtkPolyData> &mesh)
593 #if (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION < 8) 594 mesh->GetPointData()->SetActiveScalars(NULL);
596 for(
int j = 0; j < mesh->GetPointData()->GetNumberOfArrays(); j ++)
598 mesh->GetPointData()->RemoveArray(0);
605 void RemoveScalars();
617 static void ScalarDifference(vtkSmartPointer<vtkPolyData> model1, vtkSmartPointer<vtkPolyData> model2, vtkSmartPointer<vtkPolyData> result);
624 static void ThresholdScalars(vtkSmartPointer<vtkPolyData> model,
const coordinateType aboveVal,
const coordinateType belowVal,
const coordinateType outsideVal);
631 static void BinaryThresholdScalars(vtkSmartPointer<vtkPolyData> model,
const coordinateType aboveVal,
const coordinateType belowVal,
const coordinateType insideVal = 1.0,
const coordinateType outsideVal = 0.0);
636 static void MaskScalars(vtkSmartPointer<vtkPolyData> model1, vtkSmartPointer<vtkPolyData> model2);
652 static vtkSmartPointer<vtkMatrix4x4> ProcrustesAlign(vtkSmartPointer<vtkPolyData> source, vtkSmartPointer<vtkPolyData> target,
bool rigid =
false);
663 void ConcatenateCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
670 void ScaleCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const coordinateType scale);
677 void SmoothCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const size_t iterations);
684 void LaplacianCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const size_t iterations);
691 void FlipCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const bool xAxis,
const bool yAxis,
const bool zAxis);
698 void DecimateCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const coordinateType factor);
705 void SplitCollection(vtkSmartPointer<vtkPolyDataCollection> collection, vtkSmartPointer<vtkPolyDataCollection> components, std::vector< vtkSmartPointer<vtkPolyDataCollection> > &splitCollections);
712 void ScalarDifferenceCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
713 void ScalarDifferenceCollection(vtkSmartPointer<vtkPolyDataCollection> collection1, vtkSmartPointer<vtkPolyDataCollection> collection2, vtkSmartPointer<vtkPolyDataCollection> &results);
720 void ScalarThresholdCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const coordinateType aboveVal,
const coordinateType belowVal);
727 void ClipCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
const coordinateType aboveVal,
const coordinateType belowVal);
734 void ScalarStatisticsCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
741 void ScalarRemoveCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
748 void ScalarCopyCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
753 double MeanSquaredErrorCollection(vtkSmartPointer<vtkPolyDataCollection> collection);
763 vtkSmartPointer<vtkPolyDataCollection> ProcrustesAlignCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
bool rigid =
false);
772 vtkSmartPointer<vtkPolyDataCollection> IterativeClosestPointsAlignCollection(vtkSmartPointer<vtkPolyDataCollection> collection,
bool rigid =
false, vtkSmartPointer<vtkTransformCollection> tCollection=0);
783 inline bool IsCurrentModel()
787 PrintError(
"Input Model not set. Ignoring Operation.");
793 inline void UpdateModelState(vtkSmartPointer<vtkPolyDataAlgorithm> filter)
795 CurrentModel = filter->GetOutput();
796 PreviousModel = filter->GetPolyDataInput(0);
798 InputModel = PreviousModel;
800 inline void UpdateModelStateFromModel(vtkSmartPointer<vtkPolyData> mesh)
802 PreviousModel = CurrentModel;
805 InputModel = PreviousModel;
814 #endif //__MILXMODEL_H vtkSmartPointer< vtkPolyData > CurrentModel
Holds the current model in the pipeline.
vtkAlgorithmOutput * GetProducerPort()
Returns the current model, i.e. the result of the latest operation ITK/VTK style. ...
void Update()
Updates the model to be the most current.
void AddArray(vtkSmartPointer< vtkDataArray > array)
Appends an array to the model.
bool InternalInPlaceOperation
Used by the collection members to assign via pointers rather than deep copys.
vtkSmartPointer< vtkDataArray > GetScalars()
Returns the active scalars of the model.
void PrintError(const std::string msg)
Displays a generic msg to standard error with carriage return.
#define SMILI_EXPORT
DLL Function Symbol for Windows. It is empty for other OSes.
vtkSmartPointer< vtkPolyData > & Result()
Returns the current model, i.e. the result of the latest operation.
vtkSmartPointer< vtkTransform > & GetTransform()
Returns the current net transform applied to the model, i.e. concatenations of all (rigid/linear) tra...
vtkIdType GetNumberOfArrays()
Returns the total number of point-based arrays in the model.
virtual ~Model()
Standard Destructor.
vtkSmartPointer< vtkPolyData > PreviousModel
Holds the previous model in the pipeline.
void SetActiveScalars(std::string nameOfArray)
Sets the array of name as the scalar field of the mesh (values per vertex of the surface) ...
vtkSmartPointer< vtkDataArray > GetNormals()
Returns the normal vectors of the model.
vtkSmartPointer< vtkDataArray > GetVectors()
Returns the active vectors of the model.
vtkSmartPointer< vtkTransform > CurrentTransform
transform applied to model
void GenerateSpheres(const double newScale)
Generate spheres of scaling for each point of the mesh. Same as GeneratePointModel().
void SetInputData(vtkSmartPointer< vtkPolyData > model)
Assigns the input model to class. Same as SetInput and meant for VTK version > 5. ...
static void ClearArrays(vtkSmartPointer< vtkPolyData > &mesh)
Removes all the arrays from the current model.
void GetScalarRange(double *range)
Returns the scalar range of the model.
vtkSmartPointer< vtkPolyData > & PreviousResult()
Returns the previous model, i.e. the result of the penultimate operation.
vtkIdType GetNumberOfPoints()
Returns the total number of points of the model currently held.
Represents a model (i.e. a model with cells and scalar values) and their common operations. Also allows batch operations on collection of models.
vtkSmartPointer< vtkPolyData > & GetInput()
Returns the input model, i.e. the very most initial model.
vtkSmartPointer< vtkDataArray > GetTensors()
Returns the active tensors (3x3 matrix per vertex) of the model.
vtkSmartPointer< vtkPolyData > & GetOutput()
Returns the current model, i.e. the result of the latest operation ITK/VTK style. ...
vtkSmartPointer< vtkPoints > GetPoints()
Returns the points of the model.
vtkSmartPointer< vtkPolyData > InputModel
Holds the initial model in the pipeline.