17 #ifndef __itkBloxBoundaryPointToCoreAtomImageFilter_txx
18 #define __itkBloxBoundaryPointToCoreAtomImageFilter_txx
28 template<
unsigned int dim >
32 itkDebugMacro(<<
"BloxBoundaryPointToCoreAtomImageFilter::BloxBoundaryPointToCoreAtomImageFilter() called");
38 m_InverseNumberOfBoundaryPoints = 0;
39 m_BoundaryPointsPerUpdate = 0;
40 m_BoundaryPointsBeforeUpdate = 0;
41 m_CurrentBoundaryPoint = 0;
44 template<
unsigned int dim >
49 itkDebugMacro(<<
"BloxBoundaryPointToCoreAtomImageFilter::GenerateInputRequestedRegion() called");
51 Superclass::GenerateInputRequestedRegion();
55 template<
unsigned int dim >
60 itkDebugMacro(<<
"BloxBoundaryPointToCoreAtomImageFilter::GenerateData() called");
63 m_InputPtr = this->GetInput(0);
64 m_OutputPtr = this->GetOutput(0);
67 m_OutputPtr->SetBufferedRegion( m_OutputPtr->GetRequestedRegion() );
68 m_OutputPtr->Allocate();
71 m_OutputPtr->EmptyImage();
75 float numBoundaryPoints = m_InputPtr->GetNumBoundaryPoints();
76 float numUpdates = 100.0;
79 if(numBoundaryPoints < 1)
81 numBoundaryPoints = 1;
85 if(numUpdates > numBoundaryPoints)
87 numUpdates = numBoundaryPoints;
91 m_BoundaryPointsPerUpdate =
static_cast<unsigned long>(numBoundaryPoints/numUpdates);
92 m_InverseNumberOfBoundaryPoints = 1.0 / numBoundaryPoints;
95 this->UpdateProgress(0);
97 m_BoundaryPointsBeforeUpdate = m_BoundaryPointsPerUpdate;
99 m_CurrentBoundaryPoint = 0;
101 this->FindCoreAtoms();
104 template<
unsigned int dim >
112 ImageIteratorType imageIt ( m_InputPtr,
113 m_InputPtr->GetRequestedRegion() );
116 for ( imageIt.GoToBegin(); !imageIt.IsAtEnd(); ++imageIt)
122 for (bpiterator = imageIt.Value().begin(); bpiterator != imageIt.Value().end(); ++bpiterator)
124 this->FindCoreAtomsAtBoundaryPoint( *bpiterator );
126 if(--m_BoundaryPointsBeforeUpdate == 0)
128 m_BoundaryPointsBeforeUpdate = m_BoundaryPointsPerUpdate;
129 m_CurrentBoundaryPoint += m_BoundaryPointsPerUpdate;
130 this->UpdateProgress(m_CurrentBoundaryPoint * m_InverseNumberOfBoundaryPoints);
141 ( &bloxIt.
Value() )->CalcMeanCoreAtomDiameter();
145 template<
unsigned int dim >
160 typedef typename FunctionType::GradientType FunctionGradientType;
162 typename FunctionType::Pointer spatialFunc = FunctionType::New();
165 spatialFunc->SetDistanceMin(m_DistanceMin);
166 spatialFunc->SetDistanceMax(m_DistanceMax);
167 spatialFunc->SetEpsilon(m_Epsilon);
168 spatialFunc->SetPolarity(m_Polarity);
172 spatialFunc->SetOrigin(spatialFunctionOrigin);
181 FunctionGradientType spatialFunctionGradient = pBPOne->
GetGradient();
182 spatialFunc->SetOriginGradient(spatialFunctionGradient);
189 seedVector.
SetVnlVector(spatialFunctionGradient.GetVnlVector());
190 seedVector = seedVector / seedVector.
GetNorm();
195 seedVector = seedVector * -1;
199 PositionType seedPos = spatialFunctionOrigin + (seedVector * m_DistanceMin);
202 if( m_InputPtr->TransformPhysicalPointToIndex(seedPos, seedIndex) )
206 ConicItType sfi = ConicItType(m_InputPtr, spatialFunc, seedIndex);
207 sfi.SetIntersectInclusionStrategy();
210 for( sfi.GoToBegin(); !( sfi.IsAtEnd() ); ++sfi)
216 for (bpiterator = sfi.Get().begin(); bpiterator != sfi.Get().end(); ++bpiterator)
219 BPItemType* pBPTwo = *bpiterator;
229 if(!( (C12.
GetNorm() > m_DistanceMin) && (C12.
GetNorm() < m_DistanceMax) ) )
249 if( faceToFaceness > (1.0 - m_Epsilon) )
255 double coreAtomDiameter = (P2-P1).GetNorm();
269 m_OutputPtr->TransformPhysicalPointToIndex(coreAtomCenter, coreAtomPos);
272 m_OutputPtr->GetPixel(coreAtomPos).push_back(pCoreAtom);
280 template<
unsigned int dim >
285 Superclass::PrintSelf(os,indent);
287 os << indent <<
"Minimum core atom search distance: " << m_DistanceMin << std::endl;
288 os << indent <<
"Maximum core atom search distance: " << m_DistanceMax << std::endl;
289 os << indent <<
"Core atom search epsilon: " << m_Epsilon << std::endl;
290 os << indent <<
"Core atom search polarity: " << m_Polarity << std::endl;
292 os << indent <<
"Inverse number of boundary points: " << m_InverseNumberOfBoundaryPoints << std::endl;
293 os << indent <<
"Current boundary point: " << m_CurrentBoundaryPoint << std::endl;
294 os << indent <<
"Boundary points per update: " << m_BoundaryPointsPerUpdate << std::endl;
295 os << indent <<
"Boundary points before update: " << m_BoundaryPointsBeforeUpdate << std::endl;