IAP GITLAB
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
corsika
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue 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
Air Shower Physics
corsika
Commits
949fabf4
Commit
949fabf4
authored
4 years ago
by
Nikos Karastathis
Browse files
Options
Downloads
Patches
Plain Diff
Path class header and inline file in correct format
parent
04d9d4c5
No related branches found
No related tags found
1 merge request
!313
Resolve "Geometry and environment feature updates - merge to refactored version"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
corsika/detail/framework/geometry/Path.inl
+78
-59
78 additions, 59 deletions
corsika/detail/framework/geometry/Path.inl
corsika/framework/geometry/Path.hpp
+14
-53
14 additions, 53 deletions
corsika/framework/geometry/Path.hpp
with
92 additions
and
112 deletions
corsika/detail/framework/geometry/Path.inl
+
78
−
59
View file @
949fabf4
///*
// * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
// *
// * This software is distributed under the terms of the GNU General Public
// * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
// * the license.
// */
//
//#pragma once
//
//#include <deque>
//#include <corsika/framework/geometry/Point.hpp>
//
//namespace corsika {
//
// inline void AddToEnd(Point const& point) {
// length_ += (point - points_.back()).getNorm();
// points_.push_back(point);
// }
//
//
// inline void RemoveFromEnd() {
// auto lastpoint_ = points_.back();
// points_.pop_back();
// int dequesize_ = points_.size();
// if (dequesize_ == 0 || dequesize_ == 1) {
// length_ = LengthType::zero();
// }
// else if (dequesize_ == 2) {
// length_ = (points_.back() - points_.front()).getNorm();
// }
// else { length_ -= (lastpoint_ - points_.back()).getNorm(); }
// }
//
//
// inline LengthType GetLength() const {
// return length_;
// }
//
//
// inline Point GetStart() const {
// return points_.front();
// }
//
//
// inline Point GetEnd() const {
// return points_.back();
// }
//
//
// inline Point GetPoint(std::size_t const index) const {
// return points_.at(index);
// }
//
//
//
// inline int GetNSegments() const { return points_.size() - 1; }
//
//} // namespace corsika
\ No newline at end of file
/*
* (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
*
* This software is distributed under the terms of the GNU General Public
* Licence version 3 (GPL Version 3). See file LICENSE for a full version of
* the license.
*/
#pragma once
#include
<deque>
#include
<corsika/framework/geometry/Point.hpp>
namespace
corsika
{
Path
::
Path
(
Point
const
&
point
)
{
points_
.
push_front
(
point
);
}
Path
::
Path
(
std
::
deque
<
Point
>
const
&
points
)
:
points_
(
points
)
{
int
dequesize_
=
points
.
size
();
if
(
dequesize_
==
0
||
dequesize_
==
1
)
{
length_
=
LengthType
::
zero
();
}
else
if
(
dequesize_
==
2
)
{
length_
=
(
points
.
back
()
-
points
.
front
()).
getNorm
();
}
else
{
for
(
auto
point
=
points
.
begin
();
point
!=
points
.
end
()
-
1
;
++
point
)
{
auto
point_next
=
*
(
point
+
1
);
auto
point_now
=
*
(
point
);
length_
+=
(
point_next
-
point_now
).
getNorm
();
}
}
}
inline
void
Path
::
AddToEnd
(
Point
const
&
point
)
{
length_
+=
(
point
-
points_
.
back
()).
getNorm
();
points_
.
push_back
(
point
);
}
inline
void
Path
::
RemoveFromEnd
()
{
auto
lastpoint_
=
points_
.
back
();
points_
.
pop_back
();
int
dequesize_
=
points_
.
size
();
if
(
dequesize_
==
0
||
dequesize_
==
1
)
{
length_
=
LengthType
::
zero
();
}
else
if
(
dequesize_
==
2
)
{
length_
=
(
points_
.
back
()
-
points_
.
front
()).
getNorm
();
}
else
{
length_
-=
(
lastpoint_
-
points_
.
back
()).
getNorm
();
}
}
inline
LengthType
Path
::
GetLength
()
const
{
return
length_
;
}
inline
Point
Path
::
GetStart
()
const
{
return
points_
.
front
();
}
inline
Point
Path
::
GetEnd
()
const
{
return
points_
.
back
();
}
inline
Point
Path
::
GetPoint
(
std
::
size_t
const
index
)
const
{
return
points_
.
at
(
index
);
}
inline
auto
Path
::
begin
()
{
return
points_
.
begin
();
}
inline
auto
Path
::
end
()
{
return
points_
.
end
();
}
inline
int
Path
::
GetNSegments
()
const
{
return
points_
.
size
()
-
1
;
}
}
// namespace corsika
\ No newline at end of file
This diff is collapsed.
Click to expand it.
corsika/framework/geometry/Path.hpp
+
14
−
53
View file @
949fabf4
...
...
@@ -24,101 +24,62 @@ namespace corsika {
/**
* Create a Path with a given starting Point.
*/
Path
(
Point
const
&
point
)
{
points_
.
push_front
(
point
);
}
Path
(
Point
const
&
point
);
/**
* Initialize a Path from an existing collection of Points.
*/
Path
(
std
::
deque
<
Point
>
const
&
points
)
:
points_
(
points
)
{
int
dequesize_
=
points
.
size
();
if
(
dequesize_
==
0
||
dequesize_
==
1
)
{
length_
=
LengthType
::
zero
();
}
else
if
(
dequesize_
==
2
)
{
length_
=
(
points
.
back
()
-
points
.
front
()).
getNorm
();
}
else
{
for
(
auto
point
=
points
.
begin
();
point
!=
points
.
end
()
-
1
;
++
point
)
{
auto
point_next
=
*
(
point
+
1
);
auto
point_now
=
*
(
point
);
length_
+=
(
point_next
-
point_now
).
getNorm
();
}
}
}
Path
(
std
::
deque
<
Point
>
const
&
points
);
/**
* Add a new Point to the end of the path.
*/
void
AddToEnd
(
Point
const
&
point
)
{
length_
+=
(
point
-
points_
.
back
()).
getNorm
();
points_
.
push_back
(
point
);
}
inline
void
AddToEnd
(
Point
const
&
point
);
/**
* Remove a point from the end of the path.
*/
void
RemoveFromEnd
()
{
auto
lastpoint_
=
points_
.
back
();
points_
.
pop_back
();
int
dequesize_
=
points_
.
size
();
if
(
dequesize_
==
0
||
dequesize_
==
1
)
{
length_
=
LengthType
::
zero
();
}
else
if
(
dequesize_
==
2
)
{
length_
=
(
points_
.
back
()
-
points_
.
front
()).
getNorm
();
}
else
{
length_
-=
(
lastpoint_
-
points_
.
back
()).
getNorm
();
}
}
inline
void
RemoveFromEnd
();
/**
* Get the total length of the path.
*/
LengthType
GetLength
()
const
{
return
length_
;
}
inline
LengthType
GetLength
()
const
;
/**
* Get the starting point of the path.
*/
Point
GetStart
()
const
{
return
points_
.
front
();
}
inline
Point
GetStart
()
const
;
/**
* Get the end point of the path.
*/
Point
GetEnd
()
const
{
return
points_
.
back
();
}
inline
Point
GetEnd
()
const
;
/**
* Get a specific point of the path.
*/
Point
GetPoint
(
std
::
size_t
const
index
)
const
{
return
points_
.
at
(
index
);
}
inline
Point
GetPoint
(
std
::
size_t
const
index
)
const
;
/**
* Return an iterator to the start of the Path.
*/
auto
begin
()
{
return
points_
.
begin
();
}
inline
auto
begin
();
/**
* Return an iterator to the end of the Path.
*/
auto
end
()
{
return
points_
.
end
();
}
inline
auto
end
()
;
/**
* Get the number of steps in the path.
*
* This is one less than the number of points that
* defines the path.
*/
int
GetNSegments
()
const
{
return
points_
.
size
()
-
1
;
}
inline
int
GetNSegments
()
const
;
};
// class Path
}
// namespace corsika
\ No newline at end of file
}
// namespace corsika
#include
<corsika/detail/framework/geometry/Path.inl>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Nikos Karastathis
@Nikos
mentioned in commit
c6880dfa
·
3 years ago
mentioned in commit
c6880dfa
mentioned in commit c6880dfa89be05f8a2d273d75e4e2541f867c36b
Toggle commit list
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