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
4c6bc519
Commit
4c6bc519
authored
16 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: (Visu Refactoring) Implemented the ReadBuffer() method
parent
822ae0f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/VisuRefac/otbImageWidget.h
+29
-5
29 additions, 5 deletions
Code/VisuRefac/otbImageWidget.h
Code/VisuRefac/otbImageWidget.txx
+39
-0
39 additions, 0 deletions
Code/VisuRefac/otbImageWidget.txx
with
68 additions
and
5 deletions
Code/VisuRefac/otbImageWidget.h
+
29
−
5
View file @
4c6bc519
...
...
@@ -57,8 +57,9 @@ public:
typedef
TInputImage
InputImageType
;
/** Image region typedef */
typedef
typename
InputImageType
::
RegionType
RegionType
;
/** Region size typedef */
/** Region size
& index
typedef */
typedef
typename
RegionType
::
SizeType
SizeType
;
typedef
typename
RegionType
::
IndexType
IndexType
;
/** Controller typedef */
//typedef otb::ImageViewerController ControllerType;
...
...
@@ -75,6 +76,11 @@ public:
/** Set/Get the Controller */
//itkSetObjectMacro(Controller,ControllerType);
//itkGetObjectMacro(Controller,ControllerType);
/** Handle resizing event. This method is used by FLTK routines and
* should not be called on its own.
*/
virtual
void
resize
(
int
x
,
int
y
,
int
w
,
int
h
);
protected:
/** Constructor */
...
...
@@ -87,15 +93,33 @@ protected:
* used by FLTK routines and should not be called on its own.
*/
virtual
void
draw
(
void
);
/** Handle resizing event. This method is used by FLTK routines and
* should not be called on its own.
*/
virtual
void
resize
(
int
x
,
int
y
,
int
w
,
int
h
);
/** Handle the event from the users. This method is used by FLTK
* routines and should not be called on its own.
*/
virtual
int
handle
(
int
event
);
/** Compute the linear buffer index according to the 2D region and
* its 2D index.This method is used when OTB_GL_USE_ACCEL is ON.
* \param index 2D index
* \param region 2D region
*/
static
inline
unsigned
int
ComputeBufferIndex
(
const
IndexType
&
index
,
const
RegionType
&
region
)
{
return
(
index
[
1
]
-
region
.
GetIndex
()[
1
])
*
3
*
region
.
GetSize
()[
0
]
+
3
*
(
index
[
0
]
-
region
.
GetIndex
()[
0
]);
}
/** Compute the linear buffer index according to the 2D region and
* its 2D index.This method is used when OTB_GL_USE_ACCEL is OFF.
* The resulting buffer will be flipped over the X axis.
* \param index 2D index
* \param region 2D region
*/
static
inline
unsigned
int
ComputeXAxisFlippedBufferIndex
(
const
IndexType
&
iteratorIndex
,
const
RegionType
&
region
)
{
return
(
region
.
GetSize
()[
1
]
-
1
+
region
.
GetIndex
()[
1
]
-
index
[
1
])
*
3
*
region
.
GetSize
()[
0
]
+
3
*
(
index
[
0
]
-
region
.
GetIndex
()[
0
]);
}
private
:
ImageWidget
(
const
Self
&
);
// purposely not implemented
void
operator
=
(
const
Self
&
);
// purposely not implemented
...
...
This diff is collapsed.
Click to expand it.
Code/VisuRefac/otbImageWidget.txx
+
39
−
0
View file @
4c6bc519
...
...
@@ -19,6 +19,7 @@ PURPOSE. See the above copyright notices for more information.
#define __otbImageWidget_txx
#include "otbImageWidget.h"
#include "itkImageRegionConstIteratorWithIndex.h"
namespace otb
{
...
...
@@ -37,9 +38,11 @@ template <class TInputImage>
ImageWidget<TInputImage>
::~ImageWidget()
{
// Delete OpenGl buffer if needed
if(m_OpenGlBuffer!=NULL)
{
delete [] m_OpenGlBuffer;
m_OpenGlBuffer = NULL;
}
}
...
...
@@ -75,7 +78,43 @@ void
ImageWidget<TInputImage>
::ReadBuffer(InputImageType * image, RegionType & region)
{
// Before doing anything, check if region is inside the buffered
// region of image
if(!image->GetBufferedRegion().IsInside(region))
{
itkExceptionMacro(<<"Region to read is oustside of the buffered region.");
}
// Delete previous buffer if needed
if(m_OpenGlBuffer != NULL)
{
delete [] m_OpenGlBuffer;
m_OpenGlBuffer = NULL;
}
// Allocate new memory
m_OpenGlBuffer = new unsigned char[3*region.GetNumberOfPixels()];
// Declare the iterator
itk::ImageRegionConstIteratorWithIndex<InputImageType> it(image,region);
// Go to begin
it.GoToBegin();
while(!it.IsAtEnd())
{
// Fill compute the linear index
#ifdef OTB_GL_USE_ACCEL
unsigned int index = ComputeBufferIndex(it.GetIndex(),region);
#else
unsigned int index = ComputeXAxisFlippedBufferIndex(it.GetIndex(),region);
#endif
// Fill the buffer
m_OpenGlBuffer[index] =it.Get()[0];
m_OpenGlBuffer[index+1]=it.Get()[1];
m_OpenGlBuffer[index+2]=it.Get()[2];
++it;
}
// Last, updating buffer size
m_OpenGlBufferSize = region.GetSize();
}
template <class TInputImage>
...
...
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