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
7bac4c50
Commit
7bac4c50
authored
15 years ago
by
Emmanuel Christophe
Browse files
Options
Downloads
Patches
Plain Diff
ENH: definition of GenerateOutputInformation
parent
d45cab79
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mapnikOTBClasses.cxx
+3
-0
3 additions, 0 deletions
mapnikOTBClasses.cxx
otbVectorDataToImageFilter.h
+41
-0
41 additions, 0 deletions
otbVectorDataToImageFilter.h
otbVectorDataToImageFilter.txx
+106
-0
106 additions, 0 deletions
otbVectorDataToImageFilter.txx
with
150 additions
and
0 deletions
mapnikOTBClasses.cxx
+
3
−
0
View file @
7bac4c50
...
...
@@ -9,6 +9,8 @@
#include
"otbImage.h"
#include
"otbVectorDataToImageFilter.h"
// ./mapnikOTBClasses /home/christop/OTB/trunk/OTB-Data/Input/waterways.shp output.png
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -32,6 +34,7 @@ int main(int argc, char * argv[])
VectorDataToImageFilterType
::
Pointer
vectorDataRendering
=
VectorDataToImageFilterType
::
New
();
vectorDataRendering
->
SetInput
(
projection
->
GetOutput
());
//Save the image in a file
typedef
otb
::
ImageFileWriter
<
ImageType
>
WriterType
;
WriterType
::
Pointer
writer
=
WriterType
::
New
();
...
...
This diff is collapsed.
Click to expand it.
otbVectorDataToImageFilter.h
+
41
−
0
View file @
7bac4c50
...
...
@@ -48,11 +48,43 @@ template <class TVectorData, class TImage>
/** Some typedefs. */
typedef
TVectorData
VectorDataType
;
typedef
TImage
ImageType
;
typedef
typename
ImageType
::
Pointer
ImagePointer
;
/** Number of dimensions. */
itkStaticConstMacro
(
ImageDimension
,
unsigned
int
,
TImage
::
ImageDimension
);
/** Image size typedef. */
typedef
itk
::
Size
<
itkGetStaticConstMacro
(
ImageDimension
)
>
SizeType
;
/** Image index typedef. */
typedef
typename
TImage
::
IndexType
IndexType
;
/** Image spacing,origin and direction typedef */
typedef
typename
TImage
::
SpacingType
SpacingType
;
typedef
typename
TImage
::
PointType
OriginType
;
typedef
typename
TImage
::
DirectionType
DirectionType
;
virtual
void
SetInput
(
const
VectorDataType
*
input
);
const
VectorDataType
*
GetInput
(
void
);
/** Set the origin of the vector data.
* \sa GetOrigin() */
itkSetMacro
(
Origin
,
OriginType
);
virtual
void
SetOrigin
(
const
double
origin
[
2
]
);
virtual
void
SetOrigin
(
const
float
origin
[
2
]
);
itkGetConstReferenceMacro
(
Origin
,
OriginType
);
/** Set the spacing (size of a pixel) of the vector data.
* \sa GetSpacing() */
virtual
void
SetSpacing
(
const
SpacingType
&
spacing
);
virtual
void
SetSpacing
(
const
double
spacing
[
2
]);
virtual
void
SetSpacing
(
const
float
spacing
[
2
]);
itkGetConstReferenceMacro
(
Spacing
,
SpacingType
);
protected:
/** Constructor */
...
...
@@ -62,13 +94,22 @@ template <class TVectorData, class TImage>
/**PrintSelf method */
virtual
void
PrintSelf
(
std
::
ostream
&
os
,
itk
::
Indent
indent
)
const
;
virtual
void
GenerateOutputInformation
();
virtual
void
GenerateData
(
void
);
virtual
void
BeforeThreadedGenerateData
();
private
:
VectorDataToImageFilter
(
const
Self
&
);
//purposely not implemented
void
operator
=
(
const
Self
&
);
//purposely not implemented
SpacingType
m_Spacing
;
OriginType
m_Origin
;
SizeType
m_Size
;
IndexType
m_StartIndex
;
DirectionType
m_Direction
;
};
// end class
}
// end namespace otb
...
...
This diff is collapsed.
Click to expand it.
otbVectorDataToImageFilter.txx
+
106
−
0
View file @
7bac4c50
...
...
@@ -61,6 +61,99 @@ namespace otb
//----------------------------------------------------------------------------
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::SetSpacing(const SpacingType & spacing )
{
itkDebugMacro("setting Spacing to " << spacing);
if ( this->m_Spacing != spacing )
{
this->m_Spacing = spacing;
this->Modified();
}
}
//----------------------------------------------------------------------------
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::SetSpacing(const double spacing[2] )
{
SpacingType s(spacing);
this->SetSpacing(s);
}
//----------------------------------------------------------------------------
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::SetSpacing(const float spacing[2] )
{
itk::Vector<float, 2> sf(spacing);
SpacingType s;
s.CastFrom( sf );
this->SetSpacing(s);
}
//----------------------------------------------------------------------------
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::SetOrigin(const double origin[2] )
{
OriginType p(origin);
this->SetOrigin( p );
}
//----------------------------------------------------------------------------
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::SetOrigin(const float origin[2] )
{
itk::Point<float, 2> of(origin);
OriginType p;
p.CastFrom( of );
this->SetOrigin( p );
}
/**
* Inform pipeline of required output region
*/
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::GenerateOutputInformation()
{
// call the superclass' implementation of this method
Superclass::GenerateOutputInformation();
// get pointers to the input and output
ImagePointer outputPtr = this->GetOutput();
if ( !outputPtr )
{
return;
}
// Set the size of the output region
typename TImage::RegionType outputLargestPossibleRegion;
outputLargestPossibleRegion.SetSize( m_Size );
outputLargestPossibleRegion.SetIndex( m_StartIndex );
outputPtr->SetLargestPossibleRegion( outputLargestPossibleRegion );
// Set spacing and origin
outputPtr->SetSpacing( m_Spacing );
outputPtr->SetOrigin( m_Origin );
outputPtr->SetDirection( m_Direction );
return;
}
/**
* Generate Data
*/
...
...
@@ -69,10 +162,23 @@ namespace otb
VectorDataToImageFilter<TVectorData, TImage>
::GenerateData(void)
{
this->AllocateOutputs();
this->BeforeThreadedGenerateData();
this->AfterThreadedGenerateData();
}
template <class TVectorData, class TImage>
void
VectorDataToImageFilter<TVectorData, TImage>
::BeforeThreadedGenerateData(void)
{
Superclass::BeforeThreadedGenerateData();
}
/**
...
...
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