Skip to content

Commit 4a80e38

Browse files
committed
STYLE: Remove AdvancedCombinationTransform member function pointers
Removed those nine member function pointers as well as the 28 member functions that they could point to, and added nine `switch (m_SelectedMethod)` statements instead.
1 parent 38b6152 commit 4a80e38

2 files changed

Lines changed: 353 additions & 1151 deletions

File tree

Common/Transforms/itkAdvancedCombinationTransform.h

Lines changed: 8 additions & 289 deletions
Original file line numberDiff line numberDiff line change
@@ -316,236 +316,6 @@ class ITK_TEMPLATE_EXPORT AdvancedCombinationTransform : public AdvancedTransfor
316316
void
317317
UpdateCombinationMethod();
318318

319-
/** ************************************************
320-
* Methods to transform a point.
321-
*/
322-
323-
/** ADDITION: \f$T(x) = T_0(x) + T_1(x) - x\f$ */
324-
OutputPointType
325-
TransformPointUseAddition(const InputPointType & point) const;
326-
327-
/** COMPOSITION: \f$T(x) = T_1( T_0(x) )\f$
328-
* \warning: assumes that input and output point type are the same.
329-
*/
330-
OutputPointType
331-
TransformPointUseComposition(const InputPointType & point) const;
332-
333-
/** CURRENT ONLY: \f$T(x) = T_1(x)\f$ */
334-
OutputPointType
335-
TransformPointNoInitialTransform(const InputPointType & point) const;
336-
337-
/** NO CURRENT TRANSFORM SET: throw an exception. */
338-
OutputPointType
339-
TransformPointNoCurrentTransform(const InputPointType & point) const;
340-
341-
/** ************************************************
342-
* Methods to compute the sparse Jacobian.
343-
*/
344-
345-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
346-
void
347-
GetJacobianUseAddition(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const;
348-
349-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
350-
* \warning: assumes that input and output point type are the same.
351-
*/
352-
void
353-
GetJacobianUseComposition(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const;
354-
355-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
356-
void
357-
GetJacobianNoInitialTransform(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const;
358-
359-
/** NO CURRENT TRANSFORM SET: throw an exception. */
360-
void
361-
GetJacobianNoCurrentTransform(const InputPointType &, JacobianType &, NonZeroJacobianIndicesType &) const;
362-
363-
/** ************************************************
364-
* Methods to compute the inner product of the Jacobian with the moving image gradient.
365-
*/
366-
367-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
368-
void
369-
EvaluateJacobianWithImageGradientProductUseAddition(const InputPointType &,
370-
const MovingImageGradientType &,
371-
DerivativeType &,
372-
NonZeroJacobianIndicesType &) const;
373-
374-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
375-
* \warning: assumes that input and output point type are the same.
376-
*/
377-
void
378-
EvaluateJacobianWithImageGradientProductUseComposition(const InputPointType &,
379-
const MovingImageGradientType &,
380-
DerivativeType &,
381-
NonZeroJacobianIndicesType &) const;
382-
383-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
384-
void
385-
EvaluateJacobianWithImageGradientProductNoInitialTransform(const InputPointType &,
386-
const MovingImageGradientType &,
387-
DerivativeType &,
388-
NonZeroJacobianIndicesType &) const;
389-
390-
/** NO CURRENT TRANSFORM SET: throw an exception. */
391-
void
392-
EvaluateJacobianWithImageGradientProductNoCurrentTransform(const InputPointType &,
393-
const MovingImageGradientType &,
394-
DerivativeType &,
395-
NonZeroJacobianIndicesType &) const;
396-
397-
/** ************************************************
398-
* Methods to compute the spatial Jacobian.
399-
*/
400-
401-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
402-
void
403-
GetSpatialJacobianUseAddition(const InputPointType & inputPoint, SpatialJacobianType & sj) const;
404-
405-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
406-
* \warning: assumes that input and output point type are the same.
407-
*/
408-
void
409-
GetSpatialJacobianUseComposition(const InputPointType & inputPoint, SpatialJacobianType & sj) const;
410-
411-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
412-
void
413-
GetSpatialJacobianNoInitialTransform(const InputPointType & inputPoint, SpatialJacobianType & sj) const;
414-
415-
/** NO CURRENT TRANSFORM SET: throw an exception. */
416-
void
417-
GetSpatialJacobianNoCurrentTransform(const InputPointType & inputPoint, SpatialJacobianType & sj) const;
418-
419-
/** ************************************************
420-
* Methods to compute the spatial Hessian.
421-
*/
422-
423-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
424-
void
425-
GetSpatialHessianUseAddition(const InputPointType & inputPoint, SpatialHessianType & sh) const;
426-
427-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
428-
* \warning: assumes that input and output point type are the same.
429-
*/
430-
void
431-
GetSpatialHessianUseComposition(const InputPointType & inputPoint, SpatialHessianType & sh) const;
432-
433-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
434-
void
435-
GetSpatialHessianNoInitialTransform(const InputPointType & inputPoint, SpatialHessianType & sh) const;
436-
437-
/** NO CURRENT TRANSFORM SET: throw an exception. */
438-
void
439-
GetSpatialHessianNoCurrentTransform(const InputPointType & inputPoint, SpatialHessianType & sh) const;
440-
441-
/** ************************************************
442-
* Methods to compute the Jacobian of the spatial Jacobian.
443-
*/
444-
445-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
446-
void
447-
GetJacobianOfSpatialJacobianUseAddition(const InputPointType & inputPoint,
448-
JacobianOfSpatialJacobianType & jsj,
449-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
450-
451-
void
452-
GetJacobianOfSpatialJacobianUseAddition(const InputPointType & inputPoint,
453-
SpatialJacobianType & sj,
454-
JacobianOfSpatialJacobianType & jsj,
455-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
456-
457-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
458-
* \warning: assumes that input and output point type are the same.
459-
*/
460-
void
461-
GetJacobianOfSpatialJacobianUseComposition(const InputPointType & inputPoint,
462-
JacobianOfSpatialJacobianType & jsj,
463-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
464-
465-
void
466-
GetJacobianOfSpatialJacobianUseComposition(const InputPointType & inputPoint,
467-
SpatialJacobianType & sj,
468-
JacobianOfSpatialJacobianType & jsj,
469-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
470-
471-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
472-
void
473-
GetJacobianOfSpatialJacobianNoInitialTransform(const InputPointType & inputPoint,
474-
JacobianOfSpatialJacobianType & jsj,
475-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
476-
477-
void
478-
GetJacobianOfSpatialJacobianNoInitialTransform(const InputPointType & inputPoint,
479-
SpatialJacobianType & sj,
480-
JacobianOfSpatialJacobianType & jsj,
481-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
482-
483-
/** NO CURRENT TRANSFORM SET: throw an exception. */
484-
void
485-
GetJacobianOfSpatialJacobianNoCurrentTransform(const InputPointType & inputPoint,
486-
JacobianOfSpatialJacobianType & jsj,
487-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
488-
489-
void
490-
GetJacobianOfSpatialJacobianNoCurrentTransform(const InputPointType & inputPoint,
491-
SpatialJacobianType & sj,
492-
JacobianOfSpatialJacobianType & jsj,
493-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
494-
495-
/** ************************************************
496-
* Methods to compute the Jacobian of the spatial Hessian.
497-
*/
498-
499-
/** ADDITION: \f$J(x) = J_1(x)\f$ */
500-
void
501-
GetJacobianOfSpatialHessianUseAddition(const InputPointType & inputPoint,
502-
JacobianOfSpatialHessianType & jsh,
503-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
504-
505-
void
506-
GetJacobianOfSpatialHessianUseAddition(const InputPointType & inputPoint,
507-
SpatialHessianType & sh,
508-
JacobianOfSpatialHessianType & jsh,
509-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
510-
511-
/** COMPOSITION: \f$J(x) = J_1( T_0(x) )\f$
512-
* \warning: assumes that input and output point type are the same.
513-
*/
514-
void
515-
GetJacobianOfSpatialHessianUseComposition(const InputPointType & inputPoint,
516-
JacobianOfSpatialHessianType & jsh,
517-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
518-
519-
void
520-
GetJacobianOfSpatialHessianUseComposition(const InputPointType & inputPoint,
521-
SpatialHessianType & sh,
522-
JacobianOfSpatialHessianType & jsh,
523-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
524-
525-
/** CURRENT ONLY: \f$J(x) = J_1(x)\f$ */
526-
void
527-
GetJacobianOfSpatialHessianNoInitialTransform(const InputPointType & inputPoint,
528-
JacobianOfSpatialHessianType & jsh,
529-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
530-
531-
void
532-
GetJacobianOfSpatialHessianNoInitialTransform(const InputPointType & inputPoint,
533-
SpatialHessianType & sh,
534-
JacobianOfSpatialHessianType & jsh,
535-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
536-
537-
/** NO CURRENT TRANSFORM SET: throw an exception. */
538-
void
539-
GetJacobianOfSpatialHessianNoCurrentTransform(const InputPointType & inputPoint,
540-
JacobianOfSpatialHessianType & jsh,
541-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
542-
543-
void
544-
GetJacobianOfSpatialHessianNoCurrentTransform(const InputPointType & inputPoint,
545-
SpatialHessianType & sh,
546-
JacobianOfSpatialHessianType & jsh,
547-
NonZeroJacobianIndicesType & nonZeroJacobianIndices) const;
548-
549319
private:
550320
/** Exception text. */
551321
constexpr static const char * NoCurrentTransformSet = "No current transform set in the AdvancedCombinationTransform";
@@ -554,68 +324,17 @@ class ITK_TEMPLATE_EXPORT AdvancedCombinationTransform : public AdvancedTransfor
554324
InitialTransformPointer m_InitialTransform{ nullptr };
555325
CurrentTransformPointer m_CurrentTransform{ nullptr };
556326

557-
/** Typedefs for function pointers. */
558-
using TransformPointFunctionPointer = OutputPointType (Self::*)(const InputPointType &) const;
559-
using GetSparseJacobianFunctionPointer = void (Self::*)(const InputPointType &,
560-
JacobianType &,
561-
NonZeroJacobianIndicesType &) const;
562-
using EvaluateJacobianWithImageGradientProductFunctionPointer = void (Self::*)(const InputPointType &,
563-
const MovingImageGradientType &,
564-
DerivativeType &,
565-
NonZeroJacobianIndicesType &) const;
566-
using GetSpatialJacobianFunctionPointer = void (Self::*)(const InputPointType &, SpatialJacobianType &) const;
567-
using GetSpatialHessianFunctionPointer = void (Self::*)(const InputPointType &, SpatialHessianType &) const;
568-
using GetJacobianOfSpatialJacobianFunctionPointer = void (Self::*)(const InputPointType &,
569-
JacobianOfSpatialJacobianType &,
570-
NonZeroJacobianIndicesType &) const;
571-
using GetJacobianOfSpatialJacobianFunctionPointer2 = void (Self::*)(const InputPointType &,
572-
SpatialJacobianType &,
573-
JacobianOfSpatialJacobianType &,
574-
NonZeroJacobianIndicesType &) const;
575-
using GetJacobianOfSpatialHessianFunctionPointer = void (Self::*)(const InputPointType &,
576-
JacobianOfSpatialHessianType &,
577-
NonZeroJacobianIndicesType &) const;
578-
using GetJacobianOfSpatialHessianFunctionPointer2 = void (Self::*)(const InputPointType &,
579-
SpatialHessianType &,
580-
JacobianOfSpatialHessianType &,
581-
NonZeroJacobianIndicesType &) const;
582-
583-
/** A pointer to one of the following functions:
584-
* - TransformPointUseAddition,
585-
* - TransformPointUseComposition,
586-
* - TransformPointNoCurrentTransform
587-
* - TransformPointNoInitialTransform.
588-
*/
589-
TransformPointFunctionPointer m_SelectedTransformPointFunction{ &Self::TransformPointNoCurrentTransform };
590-
591-
/** A pointer to one of the following functions:
592-
* - GetJacobianUseAddition,
593-
* - GetJacobianUseComposition,
594-
* - GetJacobianNoCurrentTransform
595-
* - GetJacobianNoInitialTransform.
596-
*/
597-
// GetJacobianFunctionPointer m_SelectedGetJacobianFunction;
598327

599-
/** More of these. Set everything to have no current transform. */
600-
GetSparseJacobianFunctionPointer m_SelectedGetSparseJacobianFunction{ &Self::GetJacobianNoCurrentTransform };
601-
EvaluateJacobianWithImageGradientProductFunctionPointer m_SelectedEvaluateJacobianWithImageGradientProductFunction{
602-
&Self::EvaluateJacobianWithImageGradientProductNoInitialTransform
603-
};
604-
GetSpatialJacobianFunctionPointer m_SelectedGetSpatialJacobianFunction{ &Self::GetSpatialJacobianNoCurrentTransform };
605-
GetSpatialHessianFunctionPointer m_SelectedGetSpatialHessianFunction{ &Self::GetSpatialHessianNoCurrentTransform };
606-
GetJacobianOfSpatialJacobianFunctionPointer m_SelectedGetJacobianOfSpatialJacobianFunction{
607-
&Self::GetJacobianOfSpatialJacobianNoCurrentTransform
608-
};
609-
GetJacobianOfSpatialJacobianFunctionPointer2 m_SelectedGetJacobianOfSpatialJacobianFunction2{
610-
&Self::GetJacobianOfSpatialJacobianNoCurrentTransform
611-
};
612-
GetJacobianOfSpatialHessianFunctionPointer m_SelectedGetJacobianOfSpatialHessianFunction{
613-
&Self::GetJacobianOfSpatialHessianNoCurrentTransform
614-
};
615-
GetJacobianOfSpatialHessianFunctionPointer2 m_SelectedGetJacobianOfSpatialHessianFunction2{
616-
&Self::GetJacobianOfSpatialHessianNoCurrentTransform
328+
enum class SelectedMethod
329+
{
330+
NoInitialTransform,
331+
UseComposition,
332+
UseAddition,
333+
NoCurrentTransform
617334
};
618335

336+
SelectedMethod m_SelectedMethod{};
337+
619338
/** How to combine the transformations. Composition by default. */
620339
bool m_UseAddition{ false };
621340
bool m_UseComposition{ true };

0 commit comments

Comments
 (0)