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
a1a5198e
Commit
a1a5198e
authored
13 years ago
by
Otmane Lahlou
Browse files
Options
Downloads
Plain Diff
MRG
parents
9c288a62
57ce9676
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/Utils/otbVectorDataTransform.cxx
+154
-0
154 additions, 0 deletions
Applications/Utils/otbVectorDataTransform.cxx
with
154 additions
and
0 deletions
Applications/Utils/otbVectorDataTransform.cxx
0 → 100644
+
154
−
0
View file @
a1a5198e
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include
"otbWrapperApplication.h"
#include
"otbWrapperApplicationFactory.h"
#include
"otbVectorDataTransformFilter.h"
#include
"otbVectorDataProjectionFilter.h"
#include
"itkCenteredSimilarity2DTransform.h"
#include
"otbMath.h"
namespace
otb
{
namespace
Wrapper
{
class
VectorDataTransform
:
public
Application
{
public:
/** Standard class typedefs. */
typedef
VectorDataTransform
Self
;
typedef
Application
Superclass
;
typedef
itk
::
SmartPointer
<
Self
>
Pointer
;
typedef
itk
::
SmartPointer
<
const
Self
>
ConstPointer
;
/** Standard macro */
itkNewMacro
(
Self
);
itkTypeMacro
(
VectorDataTransform
,
otb
::
Application
);
/** Convenient typedefs */
typedef
otb
::
VectorDataTransformFilter
<
VectorDataType
,
VectorDataType
>
VectorDataTransformFilterType
;
typedef
otb
::
VectorDataProjectionFilter
<
VectorDataType
,
VectorDataType
>
VectorDataProjectionFilterType
;
typedef
itk
::
CenteredSimilarity2DTransform
<
double
>
TransformType
;
private:
VectorDataTransform
()
{
SetName
(
"VectorDataTransform"
);
SetDescription
(
"Apply a transform to each vertex of the input VectorData"
);
}
void
DoCreateParameters
()
{
AddParameter
(
ParameterType_InputVectorData
,
"vd"
,
"Input Vector data"
);
AddParameter
(
ParameterType_OutputVectorData
,
"out"
,
"Output Vector data"
);
AddParameter
(
ParameterType_InputImage
,
"in"
,
"Support image"
);
SetParameterDescription
(
"in"
,
"Image needed as a support of the VectorData"
);
// Transform Group
AddParameter
(
ParameterType_Group
,
"transform"
,
"Transform parameters"
);
MandatoryOff
(
"transform"
);
AddParameter
(
ParameterType_Float
,
"transform.tx"
,
"Translation X"
);
SetParameterDescription
(
"transform.tx"
,
"Translation in the X direction"
);
AddParameter
(
ParameterType_Float
,
"transform.ty"
,
"Translation Y"
);
SetParameterDescription
(
"transform.ty"
,
"Translation in the Y direction"
);
SetDefaultParameterFloat
(
"transform.tx"
,
0.
);
SetDefaultParameterFloat
(
"transform.ty"
,
0.
);
AddParameter
(
ParameterType_Float
,
"transform.ro"
,
"Rotation Angle"
);
SetParameterDescription
(
"transform.ro"
,
"Angle of the rotation to apply in degrees"
);
SetDefaultParameterFloat
(
"transform.ro"
,
0.
);
AddParameter
(
ParameterType_Float
,
"transform.centerx"
,
"Center X"
);
SetParameterDescription
(
"transform.centerx"
,
"The first coordinate of the rotation center"
);
AddParameter
(
ParameterType_Float
,
"transform.centery"
,
"Center Y"
);
SetParameterDescription
(
"transform.centery"
,
"The second coordinate of the rotation center"
);
SetDefaultParameterFloat
(
"transform.centerx"
,
0.
);
SetDefaultParameterFloat
(
"transform.centery"
,
0.
);
AddParameter
(
ParameterType_Float
,
"transform.scale"
,
"Scale"
);
SetParameterDescription
(
"transform.scale"
,
"The scale to apply"
);
SetDefaultParameterFloat
(
"transform.scale"
,
1.
);
}
void
DoUpdateParameters
()
{
// nothing to update
}
void
DoExecute
()
{
// Get the support image
FloatVectorImageType
*
inImage
=
GetParameterImage
(
"in"
);
// Get the VectorData to apply the transform on
VectorDataType
*
vd
=
GetParameterVectorData
(
"vd"
);
// Reproject the VectorData in the image coordinate system
m_VectorDataProj
=
VectorDataProjectionFilterType
::
New
();
m_VectorDataProj
->
SetInput
(
vd
);
m_VectorDataProj
->
SetInputProjectionRef
(
inImage
->
GetProjectionRef
());
m_VectorDataProj
->
SetOutputKeywordList
(
inImage
->
GetImageKeywordlist
());
m_VectorDataProj
->
SetOutputProjectionRef
(
inImage
->
GetProjectionRef
());
// Set up the transform
m_Transform
=
TransformType
::
New
();
TransformType
::
ParametersType
parameters
(
6
);
// Get parameters if any
parameters
[
0
]
=
GetParameterFloat
(
"transform.scale"
);
parameters
[
1
]
=
CONST_PI
*
GetParameterFloat
(
"transform.ro"
)
/
180.
;
parameters
[
2
]
=
GetParameterFloat
(
"transform.centerx"
);
parameters
[
3
]
=
GetParameterFloat
(
"transform.centery"
);
parameters
[
4
]
=
inImage
->
GetSpacing
()[
0
]
*
GetParameterFloat
(
"transform.tx"
);
parameters
[
5
]
=
vcl_abs
(
inImage
->
GetSpacing
()[
1
])
*
GetParameterFloat
(
"transform.ty"
);
// Set the parameters to the transform
m_Transform
->
SetParameters
(
parameters
);
m_TransformFilter
=
VectorDataTransformFilterType
::
New
();
m_TransformFilter
->
SetInput
(
vd
);
m_TransformFilter
->
SetTransform
(
m_Transform
);
// retransform int the input vector projection
m_ReverseVectorDataProj
=
VectorDataProjectionFilterType
::
New
();
m_ReverseVectorDataProj
->
SetInput
(
m_TransformFilter
->
GetOutput
());
m_ReverseVectorDataProj
->
SetOutputProjectionRef
(
inImage
->
GetProjectionRef
());
m_ReverseVectorDataProj
->
SetInputKeywordList
(
inImage
->
GetImageKeywordlist
());
m_ReverseVectorDataProj
->
SetInputProjectionRef
(
inImage
->
GetProjectionRef
());
// Set the output image
SetParameterOutputVectorData
(
"out"
,
m_ReverseVectorDataProj
->
GetOutput
());
}
VectorDataTransformFilterType
::
Pointer
m_TransformFilter
;
VectorDataProjectionFilterType
::
Pointer
m_VectorDataProj
;
VectorDataProjectionFilterType
::
Pointer
m_ReverseVectorDataProj
;
TransformType
::
Pointer
m_Transform
;
};
}
}
OTB_APPLICATION_EXPORT
(
otb
::
Wrapper
::
VectorDataTransform
)
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