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
Container Registry
Model registry
Operate
Environments
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
Antoine Belvire
otb
Commits
744250ff
Commit
744250ff
authored
17 years ago
by
Cyrille Valladeau
Browse files
Options
Downloads
Patches
Plain Diff
Ajout d'une methode de calcul de boite englobante dans la classe Polygon.
parent
8725d028
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Code/Common/otbPolygon.h
+20
-2
20 additions, 2 deletions
Code/Common/otbPolygon.h
Code/Common/otbPolygon.txx
+53
-0
53 additions, 0 deletions
Code/Common/otbPolygon.txx
Testing/Code/Common/otbPolygon.cxx
+11
-0
11 additions, 0 deletions
Testing/Code/Common/otbPolygon.cxx
with
84 additions
and
2 deletions
Code/Common/otbPolygon.h
+
20
−
2
View file @
744250ff
...
...
@@ -56,8 +56,17 @@ class ITK_EXPORT Polygon
typedef
typename
Superclass
::
ContinuousIndexType
ContinuousIndexType
;
typedef
typename
VertexListType
::
ConstIterator
VertexListIteratorType
;
itkSetMacro
(
Epsilon
,
double
);
itkGetMacro
(
Epsilon
,
double
);
typedef
itk
::
Size
<
2
>
SizeType
;
typedef
itk
::
Index
<
2
>
IndexType
;
itkSetMacro
(
Epsilon
,
double
);
itkGetMacro
(
Epsilon
,
double
);
itkGetMacro
(
BoundingBoxIndex
,
IndexType
);
itkSetMacro
(
BoundingBoxIndex
,
IndexType
);
itkGetMacro
(
BoundingBoxSize
,
SizeType
);
itkSetMacro
(
BoundingBoxSize
,
SizeType
);
/**
* Check wether point is strictly inside the polygon.
...
...
@@ -109,6 +118,11 @@ class ITK_EXPORT Polygon
*/
bool
IsTouching
(
VertexType
a1
,
VertexType
a2
,
VertexType
b1
,
VertexType
b2
);
/**
* Compute the polygon bounding box
*/
void
ComputeBoundingBox
();
protected:
/** Constructor */
Polygon
()
...
...
@@ -125,6 +139,10 @@ private:
void
operator
=
(
const
Self
&
);
//purposely not implemented
double
m_Epsilon
;
// Polygon bounding box index
IndexType
m_BoundingBoxIndex
;
// Polygon bounding box size
SizeType
m_BoundingBoxSize
;
};
}
// End namespace otb
...
...
This diff is collapsed.
Click to expand it.
Code/Common/otbPolygon.txx
+
53
−
0
View file @
744250ff
...
...
@@ -407,6 +407,57 @@ Polygon<TValue>
}
return resp;
}
/**
* Bounding Box computation
*/
template<class TValue>
void
Polygon<TValue>
::ComputeBoundingBox()
{
VertexListIteratorType it = this->GetVertexList()->Begin();
long int x = static_cast<long int>(it.Value()[0]);
long int y = static_cast<long int>(it.Value()[1]);
IndexType maxId;
maxId.Fill(0);
m_BoundingBoxIndex[0] = x;
m_BoundingBoxIndex[1] = y;
++it;
while(it != this->GetVertexList()->End())
{
x = static_cast<long int>(it.Value()[0]);
y = static_cast<long int>(it.Value()[1]);
// Index search
if ( x < m_BoundingBoxIndex[0] )
{
m_BoundingBoxIndex[0] = x;
}
if ( y < m_BoundingBoxIndex[1] )
{
m_BoundingBoxIndex[1] = y;
}
// Max Id search for size computation
if ( x > maxId[0] )
{
maxId[0] = x;
}
if ( y > maxId[1] )
{
maxId[1] = y;
}
++it;
}
m_BoundingBoxSize[0] = maxId[0] - m_BoundingBoxIndex[0];
m_BoundingBoxSize[1] = maxId[1] - m_BoundingBoxIndex[1];
}
/**
* PrintSelf Method
*/
...
...
@@ -417,6 +468,8 @@ Polygon<TValue>
{
Superclass::PrintSelf(os, indent);
}
} // End namespace otb
#endif
This diff is collapsed.
Click to expand it.
Testing/Code/Common/otbPolygon.cxx
+
11
−
0
View file @
744250ff
...
...
@@ -59,6 +59,7 @@ int otbPolygon(int argc, char * argv[])
}
}
IteratorType
begin1
=
polygon1
->
GetVertexList
()
->
Begin
();
IteratorType
end1
=
polygon1
->
GetVertexList
()
->
End
();
IteratorType
begin2
=
polygon2
->
GetVertexList
()
->
Begin
();
...
...
@@ -120,6 +121,16 @@ int otbPolygon(int argc, char * argv[])
file
<<
"polygon2->NbCrossing("
<<
current
<<
", "
<<
firstVertex
<<
") = "
<<
polygon2
->
NbCrossing
(
current
,
firstVertex
)
<<
std
::
endl
;
file
<<
"polygon2->NbTouching("
<<
current
<<
", "
<<
firstVertex
<<
") = "
<<
polygon2
->
NbTouching
(
current
,
firstVertex
)
<<
std
::
endl
;
file
<<
std
::
endl
<<
std
::
endl
;
file
<<
"Bounding Boxs computation : "
<<
std
::
endl
;
polygon1
->
ComputeBoundingBox
();
file
<<
"Bounding Box 1"
<<
std
::
endl
;
file
<<
"Index : "
<<
polygon1
->
GetBoundingBoxIndex
()
<<
" , Size : "
<<
polygon1
->
GetBoundingBoxSize
()
<<
std
::
endl
;
polygon2
->
ComputeBoundingBox
();
file
<<
"Bounding Box 2"
<<
std
::
endl
;
file
<<
"Index : "
<<
polygon2
->
GetBoundingBoxIndex
()
<<
" , Size : "
<<
polygon2
->
GetBoundingBoxSize
()
<<
std
::
endl
;
file
.
close
();
}
...
...
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