Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
iMSTK
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
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
Ben Boeckel
iMSTK
Commits
387dcf7e
Commit
387dcf7e
authored
7 years ago
by
Sreekanth Arikatla
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Add Cylinder analytical geometry
parent
88152daf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Base/Geometry/Analytic/imstkCylinder.cpp
+117
-0
117 additions, 0 deletions
Base/Geometry/Analytic/imstkCylinder.cpp
Base/Geometry/Analytic/imstkCylinder.h
+91
-0
91 additions, 0 deletions
Base/Geometry/Analytic/imstkCylinder.h
Base/Geometry/imstkGeometry.h
+1
-0
1 addition, 0 deletions
Base/Geometry/imstkGeometry.h
with
209 additions
and
0 deletions
Base/Geometry/Analytic/imstkCylinder.cpp
0 → 100644
+
117
−
0
View file @
387dcf7e
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
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.txt
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.
=========================================================================*/
#include
"imstkCylinder.h"
#include
"g3log/g3log.hpp"
namespace
imstk
{
void
Cylinder
::
print
()
const
{
AnalyticalGeometry
::
print
();
LOG
(
INFO
)
<<
"Radius: "
<<
m_radius
;
LOG
(
INFO
)
<<
"Length: "
<<
m_length
;
}
double
Cylinder
::
getVolume
()
const
{
return
PI
*
m_radius
*
m_radius
*
m_length
;
}
double
Cylinder
::
getRadius
(
DataType
type
/* = DataType::PostTransform */
)
{
if
(
type
==
DataType
::
PostTransform
)
{
this
->
updatePostTransformData
();
return
m_radiusPostTransform
;
}
return
m_radius
;
}
double
Cylinder
::
getLength
(
DataType
type
/* = DataType::PostTransform */
)
{
if
(
type
==
DataType
::
PostTransform
)
{
this
->
updatePostTransformData
();
return
m_lengthPostTransform
;
}
return
m_length
;
}
void
Cylinder
::
setRadius
(
const
double
r
)
{
if
(
r
<=
0
)
{
LOG
(
WARNING
)
<<
"Cylinder::setRadius error: radius should be positive."
;
return
;
}
if
(
m_radius
==
r
)
{
return
;
}
m_radius
=
r
;
m_dataModified
=
true
;
m_transformApplied
=
false
;
}
void
Cylinder
::
setLength
(
const
double
l
)
{
if
(
l
<=
0
)
{
LOG
(
WARNING
)
<<
"Cylinder::setLength error: length should be positive."
;
return
;
}
if
(
m_length
==
l
)
{
return
;
}
m_length
=
l
;
m_dataModified
=
true
;
m_transformApplied
=
false
;
}
void
Cylinder
::
applyScaling
(
const
double
s
)
{
this
->
setRadius
(
m_radius
*
s
);
this
->
setLength
(
m_length
*
s
);
}
void
Cylinder
::
updatePostTransformData
()
{
if
(
m_transformApplied
)
{
return
;
}
AnalyticalGeometry
::
updatePostTransformData
();
m_radiusPostTransform
=
m_scaling
*
m_radius
;
m_lengthPostTransform
=
m_scaling
*
m_length
;
m_transformApplied
=
true
;
}
}
// imstk
This diff is collapsed.
Click to expand it.
Base/Geometry/Analytic/imstkCylinder.h
0 → 100644
+
91
−
0
View file @
387dcf7e
/*=========================================================================
Library: iMSTK
Copyright (c) Kitware, Inc. & Center for Modeling, Simulation,
& Imaging in Medicine, Rensselaer Polytechnic Institute.
Licensed under the Apache License, Version 2.0 (the "License");
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.txt
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.
=========================================================================*/
#ifndef imstkCylinder_h
#define imstkCylinder_h
// imstk
#include
"imstkAnalyticalGeometry.h"
namespace
imstk
{
///
/// \class Cylinder
///
/// \brief Cylinder geometry
///
class
Cylinder
:
public
AnalyticalGeometry
{
public:
///
/// \brief Constructor
///
Cylinder
()
:
AnalyticalGeometry
(
Type
::
Cylinder
)
{}
///
/// \brief Default destructor
///
~
Cylinder
()
=
default
;
///
/// \brief Print the cylinder info
///
void
print
()
const
override
;
///
/// \brief Returns the volume of the cylinder
///
double
getVolume
()
const
override
;
///
/// \brief Returns the radius of the cylinder
///
double
getRadius
(
DataType
type
=
DataType
::
PostTransform
);
///
/// \brief Sets the radius of the cylinder
///
void
setRadius
(
const
double
r
);
///
/// \brief Returns the length of the cylinder
///
double
getLength
(
DataType
type
=
DataType
::
PostTransform
);
///
/// \brief Sets the length of the cylinder
///
void
setLength
(
const
double
r
);
protected
:
friend
class
VTKCylinderRenderDelegate
;
void
applyScaling
(
const
double
s
)
override
;
void
updatePostTransformData
()
override
;
double
m_radius
=
1.0
;
///> Radius of the cylinder
double
m_length
=
1.0
;
///> Length of the cylinder
double
m_radiusPostTransform
=
1.0
;
///> Radius of the cylinder once transform applied
double
m_lengthPostTransform
=
1.0
;
///> Length of the cylinder once transform applied
};
}
// imstk
#endif // ifndef imstkCylinder_h
This diff is collapsed.
Click to expand it.
Base/Geometry/imstkGeometry.h
+
1
−
0
View file @
387dcf7e
...
...
@@ -44,6 +44,7 @@ public:
{
Plane
,
Sphere
,
Cylinder
,
Cube
,
SurfaceMesh
,
TetrahedralMesh
,
...
...
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