Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
LidarView
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Terraform modules
Monitor
Service Desk
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
LidarView
LidarView
Merge requests
!110
Settings fix
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Settings fix
settings-fix
into
master
Overview
0
Commits
7
Pipelines
6
Changes
6
Merged
Arnaud Billon
requested to merge
settings-fix
into
master
3 years ago
Overview
0
Commits
7
Pipelines
6
Changes
6
Expand
0
0
Merge request reports
Compare
master
version 4
7497172e
3 years ago
version 3
313f98a1
3 years ago
version 2
aa752278
3 years ago
version 1
b7a316b2
3 years ago
master (base)
and
version 3
latest version
b007d9ec
7 commits,
3 years ago
version 4
7497172e
4 commits,
3 years ago
version 3
313f98a1
6 commits,
3 years ago
version 2
aa752278
4 commits,
3 years ago
version 1
b7a316b2
4 commits,
3 years ago
6 files
+
137
−
112
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
Application/Ui/python/lidarview/planefit.py
+
103
−
103
Options
@@ -4,119 +4,119 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
http://www.apache.org/licenses/LICENSE-2.0
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from
__future__
import
print_function
#import VelodynePlugin.VelodyneLidar as vpmod #do we need this ?
import
paraview.simple
as
smp
from
paraview
import
vtk
# Clean last planefitting source and the spreadsheet view
def
cleanStats
():
planeFitter1
=
smp
.
FindSource
(
'
PlaneFitter1
'
)
if
planeFitter1
is
not
None
:
smp
.
Delete
(
planeFitter1
)
del
planeFitter1
PVTrivialProducer1
=
smp
.
FindSource
(
'
PVTrivialProducer1
'
)
if
PVTrivialProducer1
is
not
None
:
smp
.
Delete
(
PVTrivialProducer1
)
del
PVTrivialProducer1
# Imports
import
paraview.simple
as
smp
from
paraview
import
vtk
,
servermanager
# Use Named filters
planefitter_name
=
'
PlaneFitter
'
# PlaneFitter Instance
selection_copy_name
=
'
SelectedPointsCopy
'
# Trivial copy of the selected points
# Clean planefitter's state
def
cleanState
():
# Remove PlaneFitter
planefitter
=
smp
.
FindSource
(
planefitter_name
)
if
planefitter
is
not
None
:
smp
.
Delete
(
planefitter
)
del
planefitter
# Remove Selection copy TrivialProducer
trivialproducer
=
smp
.
FindSource
(
selection_copy_name
)
if
trivialproducer
is
not
None
:
smp
.
Delete
(
trivialproducer
)
del
trivialproducer
# Find or create a 'SpreadSheet View' to display plane fitting statistics
def
showStats
(
actionSpreadsheet
=
None
):
if
actionSpreadsheet
is
None
:
print
(
"
Unable to display stats : SpreadSheet action is not defined
"
)
return
planeFitter1
=
smp
.
FindSource
(
'
PlaneFitter1
'
)
if
planeFitter1
is
None
:
print
(
"
Unable to create spreadsheet view : PlaneFitter1 source missing
"
)
return
renderView1
=
smp
.
FindView
(
'
RenderView1
'
)
if
renderView1
is
None
:
print
(
"
Unable to find main renderView
"
)
return
# Check if main spreadsheet view exist or can be created
def
showStats
(
planefitter
,
actionSpreadsheet
=
None
):
# Check for SpreadSheetReaction
if
actionSpreadsheet
is
None
:
print
(
"
Unable to display stats : SpreadSheet action is not defined
"
)
return
# Check if main spreadsheet view exist or can be created
spreadSheetView1
=
smp
.
FindView
(
'
main spreadsheet view
'
)
if
spreadSheetView1
is
None
:
# try to trigger actionSpreadsheet to display main spreadsheet view
actionSpreadsheet
.
trigger
()
spreadSheetView1
=
smp
.
FindView
(
'
main spreadsheet view
'
)
if
spreadSheetView1
is
None
:
# try to trigger actionSpreadsheet to display main spreadsheet view
actionSpreadsheet
.
trigger
()
spreadSheetView1
=
smp
.
FindView
(
'
main spreadsheet view
'
)
if
spreadSheetView1
is
None
:
print
(
"
Unable to get main spreadsheet view
"
)
return
# display stats in main spreadsheet view
spreadSheetView1
.
ColumnToSort
=
''
spreadSheetView1
.
BlockSize
=
1024
spreadSheetView1
.
FieldAssociation
=
'
Row Data
'
smp
.
Show
(
planeFitter1
,
spreadSheetView1
)
print
(
"
Unable to get main spreadsheet view
"
)
return
# Display stats in main spreadsheet view
spreadSheetView1
.
ColumnToSort
=
''
spreadSheetView1
.
BlockSize
=
1024
spreadSheetView1
.
FieldAssociation
=
'
Row Data
'
smp
.
Show
(
planefitter
,
spreadSheetView1
)
# Main Method
def
fitPlane
(
actionSpreadsheet
=
None
):
src
=
smp
.
GetActiveSource
()
if
src
is
None
:
print
(
"
A source need to be selected before running plane fitting
"
)
return
selection
=
src
.
GetSelectionInput
(
src
.
Port
)
if
selection
is
None
:
print
(
"
A selection has to be defined to run plane fitting
"
)
return
extracter
=
smp
.
ExtractSelection
()
extracter
.
Selection
=
selection
extracter
.
Input
=
src
smp
.
Show
(
extracter
)
# Clean last plane fitting stats before processing a new one
cleanStats
()
try
:
pd
=
extracter
.
GetClientSideObject
().
GetOutput
()
if
not
pd
.
GetNumberOfPoints
():
print
(
"
An empty selection is defined
"
)
return
# Append data from each block
if
pd
.
IsTypeOf
(
"
vtkMultiBlockDataSet
"
):
if
not
pd
.
GetNumberOfBlocks
():
print
(
"
An empty selection is defined
"
)
return
appendFilter
=
vtk
.
vtkAppendFilter
()
for
i
in
range
(
pd
.
GetNumberOfBlocks
()):
appendFilter
.
AddInputData
(
pd
.
GetBlock
(
i
))
appendFilter
.
Update
()
pd
=
appendFilter
.
GetOutput
()
# Create a data source from selected points
PVTrivialProducer1
=
smp
.
PVTrivialProducer
()
PVTrivialProducer1Client
=
PVTrivialProducer1
.
GetClientSideObject
()
PVTrivialProducer1Client
.
SetOutput
(
pd
)
# Create and apply plane fitter filter
planeFitter1
=
smp
.
PlaneFitter
(
Input
=
PVTrivialProducer1
)
# if laser_id is the name of the array in Legacy and Special Velarray mode
# LCN is the name of the array in APF mode
if
pd
.
GetPointData
().
GetArray
(
"
laser_id
"
)
:
planeFitter1
.
laserIDArray
=
"
laser_id
"
elif
pd
.
GetPointData
().
GetArray
(
"
LCN
"
):
planeFitter1
.
laserIDArray
=
"
LCN
"
planeFitter1
.
UpdatePipeline
()
# Display results on the main spreadsheet view
showStats
(
actionSpreadsheet
)
finally
:
smp
.
Delete
(
extracter
)
smp
.
SetActiveSource
(
src
)
# Get Selected Source
src
=
smp
.
GetActiveSource
()
if
src
is
None
:
print
(
"
A source need to be selected before running plane fitting
"
)
return
# Clean plane fitting state before processing a new one
cleanState
()
# Check Selection
selection
=
src
.
GetSelectionInput
(
src
.
Port
)
if
selection
is
None
:
print
(
"
A selection has to be defined to run plane fitting
"
)
return
# Extract Selection - vtkMultiBlockDataSet(vtkUnstructuredGrid)
extractor
=
smp
.
ExtractSelection
()
extractor
.
Selection
=
selection
extractor
.
Input
=
src
# Extract first Block - vtkUnstructuredGrid
merger
=
smp
.
MergeBlocks
(
Input
=
extractor
)
# Convert to polydata - vtkPolyData
extractsurf
=
smp
.
ExtractSurface
(
Input
=
merger
)
extractsurf
.
UpdatePipeline
()
# Create a Trivial Producer HardCopy of selected points
trivialproducer
=
smp
.
PVTrivialProducer
()
smp
.
RenameSource
(
selection_copy_name
,
trivialproducer
)
trivialproducer
.
GetClientSideObject
().
SetOutput
(
extractsurf
.
GetClientSideObject
().
GetOutput
())
# PlaneFitter - Using a fixed input
planefitter
=
smp
.
PlaneFitter
(
Input
=
trivialproducer
)
smp
.
RenameSource
(
planefitter_name
,
planefitter
)
# Determine Laser ID Array Name
try
:
# if laser_id is the name of the array in Legacy and Special Velarray mode
# LCN is the name of the array in APF mode
for
arr
in
extractor
.
PointData
:
if
arr
.
Name
==
"
laser_id
"
:
planefitter
.
laserIDArray
=
"
laser_id
"
elif
arr
.
Name
==
"
LCN
"
:
planefitter
.
laserIDArray
=
"
LCN
"
planefitter
.
UpdatePipeline
()
# Display results on the main spreadsheet view
showStats
(
planefitter
,
actionSpreadsheet
)
# Show Model
smp
.
Show
(
servermanager
.
OutputPort
(
planefitter
,
outputPort
=
1
))
except
:
print
(
"
PlaneFit error: Unable to select appropriate laserIDArray
"
)
finally
:
smp
.
Delete
(
extractsurf
)
smp
.
Delete
(
merger
)
smp
.
Delete
(
extractor
)
smp
.
SetActiveSource
(
src
)
# Restore Active Source
Loading