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
e0ef022e
Commit
e0ef022e
authored
16 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add caching for polygon surface computation
parent
c0da41c6
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/otbPolygon.h
+8
-0
8 additions, 0 deletions
Code/Common/otbPolygon.h
Code/Common/otbPolygon.txx
+28
-2
28 additions, 2 deletions
Code/Common/otbPolygon.txx
with
36 additions
and
2 deletions
Code/Common/otbPolygon.h
+
8
−
0
View file @
e0ef022e
...
@@ -134,11 +134,16 @@ public:
...
@@ -134,11 +134,16 @@ public:
*/
*/
virtual
double
GetLength
()
const
;
virtual
double
GetLength
()
const
;
void
AddVertex
(
const
ContinuousIndexType
&
vertex
);
protected:
protected:
/** Constructor */
/** Constructor */
Polygon
()
Polygon
()
{
{
m_Epsilon
=
0.000001
;
m_Epsilon
=
0.000001
;
m_Surface
=
-
1.0
;
surfaceValid
=
false
;
};
};
/** Destructor */
/** Destructor */
...
@@ -147,12 +152,15 @@ protected:
...
@@ -147,12 +152,15 @@ protected:
/**PrintSelf method */
/**PrintSelf method */
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
virtual
void
ComputeSurface
()
const
;
private
:
private
:
Polygon
(
const
Self
&
);
//purposely not implemented
Polygon
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
double
m_Epsilon
;
double
m_Epsilon
;
mutable
double
m_Surface
;
mutable
bool
surfaceValid
;
};
};
}
// End namespace otb
}
// End namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbPolygon.txx
+
28
−
2
View file @
e0ef022e
...
@@ -22,6 +22,16 @@ PURPOSE. See the above copyright notices for more information.
...
@@ -22,6 +22,16 @@ PURPOSE. See the above copyright notices for more information.
namespace otb
namespace otb
{
{
template<class TValue>
void
Polygon<TValue>
::AddVertex(const ContinuousIndexType &vertex)
{
Superclass::AddVertex(vertex);
surfaceValid=false;
}
/**
/**
* Check wether point is strictly inside the polygon.
* Check wether point is strictly inside the polygon.
* \param point The point to check.
* \param point The point to check.
...
@@ -478,9 +488,9 @@ Polygon<TValue>
...
@@ -478,9 +488,9 @@ Polygon<TValue>
* Surface computation (for non convex polygons as well)
* Surface computation (for non convex polygons as well)
*/
*/
template<class TValue>
template<class TValue>
double
void
Polygon<TValue>
Polygon<TValue>
::
Get
Surface() const
::
Compute
Surface() const
{
{
double m_Surface;
double m_Surface;
m_Surface = 0.0;
m_Surface = 0.0;
...
@@ -515,9 +525,25 @@ Polygon<TValue>
...
@@ -515,9 +525,25 @@ Polygon<TValue>
m_Surface = 0.0;
m_Surface = 0.0;
}
}
surfaceValid = true;
}
/**
* Get surface
*/
template<class TValue>
double
Polygon<TValue>
::GetSurface() const
{
if (!surfaceValid)
{
ComputeSurface();
}
return m_Surface;
return m_Surface;
}
}
/**
/**
* Lenght computation (difference with path is in the last addition)
* Lenght computation (difference with path is in the last addition)
*/
*/
...
...
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