20 #ifndef MIRTK_PointCorrespondence_H 21 #define MIRTK_PointCorrespondence_H 23 #include "mirtk/Observable.h" 25 #include "mirtk/Array.h" 26 #include "mirtk/Point.h" 27 #include "mirtk/PointLocator.h" 28 #include "mirtk/RegisteredPointSet.h" 30 #include "vtkSmartPointer.h" 31 #include "vtkPointSet.h" 91 static int GetNumberOfPoints(vtkPointSet *dataset,
const Array<int> *sample = NULL);
120 static int GetPointIndex(vtkPointSet *dataset,
const Array<int> *sample,
int index);
137 static void GetPoint(
Point &point, vtkPointSet *dataset,
const Array<int> *sample,
int index);
154 static void GetPoint(
double *point, vtkPointSet *dataset,
const Array<int> *sample,
155 int index,
const FeatureList *feature = NULL);
165 const Array<int> *sample,
int index,
const FeatureList *feature = NULL);
182 static vtkSmartPointer<vtkPoints>
GetPoints(vtkPointSet *dataset,
const Array<int> *sample);
198 static vtkSmartPointer<vtkPointSet>
GetPointSet(vtkPointSet *dataset,
const Array<int> *sample);
306 virtual bool Set(
const char *,
const char *);
339 bool AddFeature(
const char *name,
double weight = 1.0,
double slope = 1.0,
double intercept = .0);
408 virtual void WriteDataSets(
const char *,
const char *,
bool =
true)
const;
493 const Array<int> *sample,
int index,
const FeatureList *features)
509 vtkSmartPointer<vtkPoints> points;
510 if (sample && sample->size() > 0) {
511 points = vtkSmartPointer<vtkPoints>::New();
512 points->SetNumberOfPoints(sample->size());
514 for (
size_t i = 0; i < sample->size(); ++i) {
515 dataset->GetPoint(i, p);
516 points ->SetPoint(i, p);
519 points = dataset->GetPoints();
535 vtkSmartPointer<vtkPointSet> output;
536 if (sample && sample->size() > 0) {
537 output.TakeReference(dataset->NewInstance());
538 output->SetPoints(
GetPoints(dataset, sample));
566 if (_DefaultDirection == TargetToSource)
return this->
GetSourcePoint(i, p);
573 if (_DefaultDirection == TargetToSource)
return this->
GetSourceIndex(i);
581 namespace PointCorrespondenceUtils {
592 void SamplePoints(vtkPointSet *dataset, Array<int> &indices,
int maxnum,
593 double maxdist = .0,
bool stratified =
true);
604 int maxnum,
double maxdist = .0,
bool stratified =
true)
606 SamplePoints(dataset->InputPointSet(), indices, maxnum, maxdist, stratified);
615 #endif // MIRTK_PointCorrespondence_H Unknown/invalid/default correspondence.
TypeId
Enumeration of available point correspondence maps.
bool GetInputPoint(int, Point &) const
Get untransformed output point corresponding to i-th input (sample) point.
Direction
Enumeration of correspondence mapping direction.
virtual void Initialize()
Initialize correspondence map.
vtkPointSet * PointSet() const
Get (transformed) point set.
Find closest points within proximity in both directions.
static int GetPointIndex(vtkPointSet *dataset, const Array< int > *sample, int index)
static int GetPointDimension(vtkPointSet *dataset, const FeatureList *feature)
mirtkPublicAttributeMacro(FeatureList, TargetFeatures)
Indices and rescaling parameters of target point features.
virtual ParameterList Parameter() const
Get parameter key/value as string map.
mirtkPublicAggregateMacro(const RegisteredPointSet, Target)
(Transformed) target data set
bool AddFeature(const char *name, double weight=1.0, double slope=1.0, double intercept=.0)
static int GetNumberOfPoints(vtkPointSet *dataset, const Array< int > *sample=NULL)
Array< Pair< string, string > > ParameterList
Ordered list of parameter name/value pairs.
void RemoveFeature(const char *name)
virtual bool GetInputTargetPoint(int, Point &) const =0
Get untransformed target point corresponding to i-th source (sample) point.
static double Distance2BetweenPoints(const double *a, const double *b, int d=3)
virtual int GetSourceIndex(int) const
Array< FeatureInfo > FeatureList
List of point features to use for nearest neighbor search.
static int GetPointDimension(vtkPointSet *dataset, const FeatureList *feature)
virtual int GetTargetIndex(int) const
virtual bool GetTargetPoint(int, Point &) const =0
Get (transformed) target point corresponding to i-th source (sample) point.
static double Distance2BetweenPoints(const double *a, const double *b, int d=3)
virtual bool GetSourcePoint(int, Point &) const =0
Get (transformed) source point corresponding to i-th target (sample) point.
PointCorrespondence(const RegisteredPointSet *=NULL, const RegisteredPointSet *=NULL)
Constructor.
static void GetPoint(Point &point, vtkPointSet *dataset, const Array< int > *sample, int index)
static int GetPointIndex(vtkPointSet *dataset, const Array< int > *sample, int index)
virtual void WriteDataSets(const char *, const char *, bool=true) const
Write input of data fidelity term.
virtual PointCorrespondence * NewInstance() const =0
Copy construct a new instance.
mirtkAttributeMacro(int, M)
Number of point (samples) in target data set.
static PointCorrespondence * New(TypeId)
Construct new instance of specified type.
mirtkReadOnlyAttributeMacro(int, NumberOfFeatures)
Dimension of feature vectors.
Find closest point in source data set.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
bool FromString(const char *str, EnergyMeasure &value)
Convert energy measure string to enumeration value.
virtual bool Set(const char *, const char *)
Set parameter value from string.
void CompleteFeatureInfo(const RegisteredPointSet *, FeatureList &)
virtual void Reinitialize()
Reinitialize correspondence map after change of input topology.
virtual void Update()
Update correspondence map after change of input data sets.
static void GetPoint(Point &point, vtkPointSet *dataset, const Array< int > *sample, int index)
PointLocator::FeatureList FeatureList
List of point features to use for point matching.
virtual ParameterList Parameter() const
Get parameter name/value pairs.
Find closest cell in source data set.
virtual ~PointCorrespondence()
Destructor.
static vtkSmartPointer< vtkPoints > GetPoints(vtkPointSet *dataset, const Array< int > *sample)
static vtkSmartPointer< vtkPointSet > GetPointSet(vtkPointSet *dataset, const Array< int > *sample)
Match points by their respective indices.
static int GetNumberOfPoints(vtkPointSet *dataset, const Array< int > *sample=NULL)
PointLocator::FeatureInfo FeatureInfo
Info structure of point feature to use for point matching.
static int GetPointDataIndexByCaseInsensitiveName(vtkPointData *, const string &)
Get index of point data array using case insensitive name.
virtual TypeId Type() const =0
Type enumeration value.
Closest point interpolated using spectral similarity.
Find closest point in source data set with identical label.
virtual void WriteSpectralPoints(const char *, vtkPointSet *) const
Write first three spectral coordinates as polydata points.
virtual bool GetInputSourcePoint(int, Point &) const =0
Get untransformed source point corresponding to i-th target (sample) point.