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
07a2d8a4
Commit
07a2d8a4
authored
16 years ago
by
Jordi Inglada
Browse files
Options
Downloads
Patches
Plain Diff
Example VectorDataIO
parent
8ff15ae2
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
Examples/IO/CMakeLists.txt
+3
-0
3 additions, 0 deletions
Examples/IO/CMakeLists.txt
Examples/IO/DXFReaderExample.cxx
+1
-1
1 addition, 1 deletion
Examples/IO/DXFReaderExample.cxx
Examples/IO/VectorDataIOExample.cxx
+147
-0
147 additions, 0 deletions
Examples/IO/VectorDataIOExample.cxx
with
151 additions
and
1 deletion
Examples/IO/CMakeLists.txt
+
3
−
0
View file @
07a2d8a4
...
...
@@ -52,6 +52,9 @@ TARGET_LINK_LIBRARIES(MetadataExample OTBCommon OTBIO ITKCommon ITKIO)
ADD_EXECUTABLE
(
DXFReaderExample DXFReaderExample.cxx
)
TARGET_LINK_LIBRARIES
(
DXFReaderExample OTBCommon OTBIO ITKCommon ITKIO dxf
)
ADD_EXECUTABLE
(
VectorDataIOExample VectorDataIOExample.cxx
)
TARGET_LINK_LIBRARIES
(
VectorDataIOExample OTBCommon OTBIO ITKCommon ITKIO
)
ADD_EXECUTABLE
(
DEMToImageGenerator DEMToImageGenerator.cxx
)
TARGET_LINK_LIBRARIES
(
DEMToImageGenerator OTBProjections OTBIO OTBCommon ITKCommon ITKIO otbossim otbossimElevation
)
...
...
This diff is collapsed.
Click to expand it.
Examples/IO/DXFReaderExample.cxx
+
1
−
1
View file @
07a2d8a4
...
...
@@ -27,7 +27,7 @@
// Software Guide : BeginLatex
//
// This example illustrates how to read a DXF file and how to draw objects
//
\label{DXFExample}
This example illustrates how to read a DXF file and how to draw objects
// on a $2D$ binary image. The graphical DXF objects which can be read are the following : Point, Line
// Polyline, Circle and 3DFace.
// The example begins by including the appropriate headers.
...
...
This diff is collapsed.
Click to expand it.
Examples/IO/VectorDataIOExample.cxx
0 → 100644
+
147
−
0
View file @
07a2d8a4
/*=========================================================================
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.
=========================================================================*/
// Software Guide : BeginLatex
//
// Although \ref{DXFExample}
//
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
#include
"otbVectorData.h"
#include
"otbVectorDataFileReader.h"
#include
"otbVectorDataFileWriter.h"
#include
"itkPreOrderTreeIterator.h"
#include
"otbObjectList.h"
#include
"otbPolygon.h"
// Software Guide : EndCodeSnippet
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
!=
3
)
{
std
::
cerr
<<
"Usage: "
<<
argv
[
0
]
;
std
::
cerr
<<
"inputFile outputFile"
<<
std
::
endl
;
return
EXIT_FAILURE
;
}
typedef
short
unsigned
int
PixelType
;
typedef
otb
::
VectorData
<
PixelType
,
2
>
VectorDataType
;
typedef
VectorDataType
::
Pointer
VectorDataPointerType
;
typedef
otb
::
VectorDataFileReader
<
VectorDataType
>
VectorDataFileReaderType
;
typedef
VectorDataFileReaderType
::
Pointer
VectorDataFileReaderPointerType
;
typedef
VectorDataType
::
DataTreeType
DataTreeType
;
typedef
DataTreeType
::
Pointer
DataTreePointerType
;
typedef
itk
::
PreOrderTreeIterator
<
DataTreeType
>
TreeIteratorType
;
VectorDataFileReaderPointerType
reader
=
VectorDataFileReaderType
::
New
();
reader
->
SetFileName
(
argv
[
1
]);
reader
->
Update
();
typedef
otb
::
Polygon
<
PixelType
>
PolygonType
;
typedef
PolygonType
::
VertexListIteratorType
PolygonIteratorType
;
typedef
otb
::
ObjectList
<
PolygonType
>
PolygonListType
;
typedef
PolygonListType
::
Iterator
PolygonListIteratorType
;
PolygonListType
::
Pointer
polygonList
=
PolygonListType
::
New
();
TreeIteratorType
it
(
reader
->
GetOutput
()
->
GetDataTree
());
it
.
GoToBegin
();
while
(
!
it
.
IsAtEnd
())
{
if
(
it
.
Get
()
->
IsPolygonFeature
())
{
polygonList
->
PushBack
(
it
.
Get
()
->
GetPolygonExteriorRing
());
}
++
it
;
}
polygonList
->
PushBack
(
PolygonType
::
New
());
//polygonList->Back()->SetValue(m_LeftViewer->GetNextROILabel());
typedef
VectorDataType
::
DataNodeType
DataNodeType
;
typedef
DataNodeType
::
PointType
PointType
;
typedef
DataNodeType
::
LineType
LineType
;
typedef
LineType
::
VertexType
VertexType
;
VectorDataType
::
Pointer
data
=
VectorDataType
::
New
();
DataNodeType
::
Pointer
document
=
DataNodeType
::
New
();
DataNodeType
::
Pointer
folder1
=
DataNodeType
::
New
();
DataNodeType
::
Pointer
folder2
=
DataNodeType
::
New
();
DataNodeType
::
Pointer
folder3
=
DataNodeType
::
New
();
DataNodeType
::
Pointer
line
=
DataNodeType
::
New
();
document
->
SetNodeType
(
otb
::
DOCUMENT
);
folder1
->
SetNodeType
(
otb
::
FOLDER
);
folder2
->
SetNodeType
(
otb
::
FOLDER
);
folder3
->
SetNodeType
(
otb
::
FOLDER
);
line
->
SetNodeType
(
otb
::
FEATURE_LINE
);
document
->
SetNodeId
(
"DOCUMENT"
);
folder1
->
SetNodeId
(
"FOLDER1"
);
folder2
->
SetNodeId
(
"FOLDER2"
);
folder3
->
SetNodeId
(
"FOLDER3"
);
line
->
SetNodeId
(
"FEATURE_LINE"
);
VertexType
p1
;
p1
.
Fill
(
5
);
VertexType
p3
;
p3
.
Fill
(
0
);
VertexType
p2
;
p2
[
0
]
=
0
;
p2
[
1
]
=
10
;
LineType
::
Pointer
l
=
LineType
::
New
();
l
->
AddVertex
(
p1
);
l
->
AddVertex
(
p2
);
l
->
AddVertex
(
p3
);
line
->
SetLine
(
l
);
DataNodeType
::
Pointer
root
=
data
->
GetDataTree
()
->
GetRoot
()
->
Get
();
data
->
GetDataTree
()
->
Add
(
document
,
root
);
data
->
GetDataTree
()
->
Add
(
folder1
,
document
);
data
->
GetDataTree
()
->
Add
(
folder2
,
document
);
data
->
GetDataTree
()
->
Add
(
folder3
,
document
);
data
->
GetDataTree
()
->
Add
(
line
,
folder2
);
typedef
otb
::
VectorDataFileWriter
<
VectorDataType
>
WriterType
;
WriterType
::
Pointer
writer
=
WriterType
::
New
();
writer
->
SetFileName
(
argv
[
2
]);
writer
->
SetInput
(
data
);
writer
->
Update
();
return
EXIT_SUCCESS
;
}
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