Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VTK Examples
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
VTK
VTK Examples
Commits
0b09a55c
Commit
0b09a55c
authored
5 years ago
by
Bharatesh Chakravarthi S B
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create CenterOfMass.java
Former-commit-id:
da7f1d92
parent
4c639c06
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
src/Java/PolyData/CenterOfMass.java
+47
-0
47 additions, 0 deletions
src/Java/PolyData/CenterOfMass.java
with
47 additions
and
0 deletions
src/Java/PolyData/CenterOfMass.java
0 → 100644
+
47
−
0
View file @
0b09a55c
import
vtk.vtkNativeLibrary
;
import
vtk.vtkCenterOfMass
;
import
vtk.vtkPolyData
;
import
vtk.vtkPoints
;
public
class
CenterOfMass
{
// -----------------------------------------------------------------
// Load VTK library and print which library was not properly loaded
static
{
if
(!
vtkNativeLibrary
.
LoadAllNativeLibraries
())
{
for
(
vtkNativeLibrary
lib
:
vtkNativeLibrary
.
values
())
{
if
(!
lib
.
IsLoaded
())
{
System
.
out
.
println
(
lib
.
GetLibraryName
()
+
" not loaded"
);
}
}
}
vtkNativeLibrary
.
DisableOutputWindow
(
null
);
}
// -----------------------------------------------------------------
public
static
void
main
(
String
args
[])
{
vtkPoints
points
=
new
vtkPoints
();
points
.
InsertNextPoint
(
0
,
0
,
0
);
points
.
InsertNextPoint
(
1
,
0
,
0
);
points
.
InsertNextPoint
(
0
,
1
,
0
);
points
.
InsertNextPoint
(
1
,
1
,
0
);
vtkPolyData
polydata
=
new
vtkPolyData
();
polydata
.
SetPoints
(
points
);
// Compute the center of mass
vtkCenterOfMass
centerOfMassFilter
=
new
vtkCenterOfMass
();
centerOfMassFilter
.
SetInputData
(
polydata
);
centerOfMassFilter
.
SetUseScalarsAsWeights
(
false
);
centerOfMassFilter
.
Update
();
double
center
[]
=
new
double
[
3
];
center
=
centerOfMassFilter
.
GetCenter
();
System
.
out
.
print
(
"Center of mass is "
+
" "
+
center
[
0
]
+
" "
+
center
[
1
]
+
" "
+
center
[
2
]);
}
}
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