Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Youssefi
otb
Commits
d92b12e9
Commit
d92b12e9
authored
16 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add caching for path length computation
parent
8e3d70e3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Common/otbPolyLineParametricPathWithValue.h
+6
-0
6 additions, 0 deletions
Code/Common/otbPolyLineParametricPathWithValue.h
Code/Common/otbPolyLineParametricPathWithValue.txx
+24
-1
24 additions, 1 deletion
Code/Common/otbPolyLineParametricPathWithValue.txx
with
30 additions
and
1 deletion
Code/Common/otbPolyLineParametricPathWithValue.h
+
6
−
0
View file @
d92b12e9
...
...
@@ -86,6 +86,8 @@ public:
*/
virtual
double
GetLength
()
const
;
void
AddVertex
(
const
ContinuousIndexType
&
vertex
);
protected
:
/** Constructor */
PolyLineParametricPathWithValue
();
...
...
@@ -95,10 +97,14 @@ protected:
/**PrintSelf method */
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
virtual
void
ComputeLength
()
const
;
private
:
PolyLineParametricPathWithValue
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
std
::
string
m_Key
;
mutable
double
m_Length
;
mutable
bool
m_LengthIsValid
;
};
}
// End namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbPolyLineParametricPathWithValue.txx
+
24
−
1
View file @
d92b12e9
...
...
@@ -32,11 +32,33 @@ PolyLineParametricPathWithValue<TValue,VDimension>
itk::MetaDataDictionary & dict = this->GetMetaDataDictionary();
m_Key = "Value";
itk::EncapsulateMetaData<ValueType>(dict,m_Key,0);
m_LengthIsValid = false;
m_Length = -1.0;
}
template < class TValue,unsigned int VDimension>
void PolyLineParametricPathWithValue<TValue,VDimension>
::AddVertex(const ContinuousIndexType &vertex)
{
Superclass::AddVertex(vertex);
m_LengthIsValid=false;
}
template < class TValue,unsigned int VDimension>
double PolyLineParametricPathWithValue<TValue,VDimension>
::GetLength() const
{
if (!m_LengthIsValid)
{
ComputeLength();
}
return m_Length;
}
template < class TValue,unsigned int VDimension>
void
PolyLineParametricPathWithValue<TValue,VDimension>
::ComputeLength() const
{
double length = 0.0;
VertexListConstIteratorType it = this->GetVertexList()->Begin();
...
...
@@ -68,7 +90,8 @@ double PolyLineParametricPathWithValue<TValue,VDimension>
length = 0.0;
}
return length;
m_Length = length;
m_LengthIsValid = true;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment