Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Dmitri Naumov
ogs
Commits
18393bae
Commit
18393bae
authored
8 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[DHL] Tabs to whitespaces.
parent
4c762fc2
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
DataHolderLib/CMakeLists.txt
+3
-3
3 additions, 3 deletions
DataHolderLib/CMakeLists.txt
DataHolderLib/Project.cpp
+48
-48
48 additions, 48 deletions
DataHolderLib/Project.cpp
DataHolderLib/Project.h
+35
-35
35 additions, 35 deletions
DataHolderLib/Project.h
with
86 additions
and
86 deletions
DataHolderLib/CMakeLists.txt
+
3
−
3
View file @
18393bae
...
...
@@ -5,7 +5,7 @@ GET_SOURCE_FILES(SOURCES_DataHolderLib)
add_library
(
DataHolderLib
${
SOURCES_DataHolderLib
}
)
target_link_libraries
(
DataHolderLib
GeoLib
MeshLib
logog
GeoLib
MeshLib
logog
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
DataHolderLib/Project.cpp
+
48
−
48
View file @
18393bae
...
...
@@ -24,80 +24,80 @@ namespace DataHolderLib
void
Project
::
addMesh
(
std
::
unique_ptr
<
MeshLib
::
Mesh
>
mesh
)
{
std
::
string
name
=
mesh
->
getName
();
getUniqueName
(
name
);
mesh
->
setName
(
name
);
_mesh_vec
.
push_back
(
std
::
move
(
mesh
));
std
::
string
name
=
mesh
->
getName
();
getUniqueName
(
name
);
mesh
->
setName
(
name
);
_mesh_vec
.
push_back
(
std
::
move
(
mesh
));
}
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
const_iterator
Project
::
findMeshByName
(
std
::
string
const
&
name
)
const
{
return
const_cast
<
Project
&>
(
*
this
).
findMeshByName
(
name
);
return
const_cast
<
Project
&>
(
*
this
).
findMeshByName
(
name
);
}
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
iterator
Project
::
findMeshByName
(
std
::
string
const
&
name
)
{
return
std
::
find_if
(
_mesh_vec
.
begin
(),
_mesh_vec
.
end
(),
[
&
name
](
std
::
unique_ptr
<
MeshLib
::
Mesh
>
&
mesh
)
{
return
mesh
&&
(
name
==
mesh
->
getName
());
});
return
std
::
find_if
(
_mesh_vec
.
begin
(),
_mesh_vec
.
end
(),
[
&
name
](
std
::
unique_ptr
<
MeshLib
::
Mesh
>
&
mesh
)
{
return
mesh
&&
(
name
==
mesh
->
getName
());
});
}
const
MeshLib
::
Mesh
*
Project
::
getMesh
(
const
std
::
string
&
name
)
const
{
auto
it
=
findMeshByName
(
name
);
return
(
it
==
_mesh_vec
.
end
()
?
nullptr
:
it
->
get
());
auto
it
=
findMeshByName
(
name
);
return
(
it
==
_mesh_vec
.
end
()
?
nullptr
:
it
->
get
());
}
bool
Project
::
removeMesh
(
const
std
::
string
&
name
)
{
auto
it
=
findMeshByName
(
name
);
if
(
it
!=
_mesh_vec
.
end
())
{
delete
it
->
release
();
_mesh_vec
.
erase
(
it
);
return
true
;
}
return
false
;
auto
it
=
findMeshByName
(
name
);
if
(
it
!=
_mesh_vec
.
end
())
{
delete
it
->
release
();
_mesh_vec
.
erase
(
it
);
return
true
;
}
return
false
;
}
bool
Project
::
meshExists
(
const
std
::
string
&
name
)
const
{
return
findMeshByName
(
name
)
!=
_mesh_vec
.
end
();
return
findMeshByName
(
name
)
!=
_mesh_vec
.
end
();
}
bool
Project
::
getUniqueName
(
std
::
string
&
name
)
const
{
int
count
(
0
);
bool
isUnique
(
false
);
std
::
string
cpName
;
while
(
!
isUnique
)
{
isUnique
=
true
;
cpName
=
name
;
count
++
;
// If the original name already exists we start to add numbers to name for
// as long as it takes to make the name unique.
if
(
count
>
1
)
cpName
=
cpName
+
"-"
+
std
::
to_string
(
count
);
for
(
auto
&
mesh
:
_mesh_vec
)
if
(
cpName
==
mesh
->
getName
())
isUnique
=
false
;
}
// At this point cpName is a unique name and isUnique is true.
// If cpName is not the original name, "name" is changed and isUnique is set to false,
// indicating that a vector with the original name already exists.
if
(
count
>
1
)
{
isUnique
=
false
;
name
=
cpName
;
}
return
isUnique
;
int
count
(
0
);
bool
isUnique
(
false
);
std
::
string
cpName
;
while
(
!
isUnique
)
{
isUnique
=
true
;
cpName
=
name
;
count
++
;
// If the original name already exists we start to add numbers to name for
// as long as it takes to make the name unique.
if
(
count
>
1
)
cpName
=
cpName
+
"-"
+
std
::
to_string
(
count
);
for
(
auto
&
mesh
:
_mesh_vec
)
if
(
cpName
==
mesh
->
getName
())
isUnique
=
false
;
}
// At this point cpName is a unique name and isUnique is true.
// If cpName is not the original name, "name" is changed and isUnique is set to false,
// indicating that a vector with the original name already exists.
if
(
count
>
1
)
{
isUnique
=
false
;
name
=
cpName
;
}
return
isUnique
;
}
}
//namespace
This diff is collapsed.
Click to expand it.
DataHolderLib/Project.h
+
35
−
35
View file @
18393bae
...
...
@@ -17,7 +17,7 @@
#include
"MeshLib/Mesh.h"
//namespace MeshLib {
//
class Mesh;
//
class Mesh;
//}
namespace
DataHolderLib
...
...
@@ -31,53 +31,53 @@ namespace DataHolderLib
class
Project
final
{
public:
/// Constructor
Project
()
=
default
;
/// Constructor
Project
()
=
default
;
Project
(
Project
&
)
=
delete
;
Project
(
Project
&
)
=
delete
;
~
Project
()
=
default
;
~
Project
()
=
default
;
/// Returns the GEOObjects containing all points, polylines and surfaces.
GeoLib
::
GEOObjects
&
getGEOObjects
()
{
return
_geoObjects
;
}
/// Returns the GEOObjects containing all points, polylines and surfaces.
GeoLib
::
GEOObjects
&
getGEOObjects
()
{
return
_geoObjects
;
}
/// Adds a new mesh under a (possibly new) unique name.
/// \attention This might change the given mesh's name.
void
addMesh
(
std
::
unique_ptr
<
MeshLib
::
Mesh
>
mesh
);
/// Adds a new mesh under a (possibly new) unique name.
/// \attention This might change the given mesh's name.
void
addMesh
(
std
::
unique_ptr
<
MeshLib
::
Mesh
>
mesh
);
/// Returns the mesh with the given name or a \c nullptr if the mesh was not
/// found.
const
MeshLib
::
Mesh
*
getMesh
(
const
std
::
string
&
name
)
const
;
/// Returns the mesh with the given name or a \c nullptr if the mesh was not
/// found.
const
MeshLib
::
Mesh
*
getMesh
(
const
std
::
string
&
name
)
const
;
/// Returns all the meshes with their respective names
const
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>&
getMeshObjects
()
const
{
return
_mesh_vec
;
}
/// Returns all the meshes with their respective names
const
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>&
getMeshObjects
()
const
{
return
_mesh_vec
;
}
/// Deletes all meshes with the given name and removes them from the list of
/// saved meshes. If any mesh was found for removal, true is returned and
/// false otherwise.
bool
removeMesh
(
const
std
::
string
&
name
);
/// Deletes all meshes with the given name and removes them from the list of
/// saved meshes. If any mesh was found for removal, true is returned and
/// false otherwise.
bool
removeMesh
(
const
std
::
string
&
name
);
private
:
/// Checks if a mesh with the same name exists and provides a unique name in
/// case of already existing mesh. Returns true if the mesh name is unique.
/// Returns false and changes the provided name to a unique name otherwise.
bool
getUniqueName
(
std
::
string
&
name
)
const
;
/// Checks if a mesh with the same name exists and provides a unique name in
/// case of already existing mesh. Returns true if the mesh name is unique.
/// Returns false and changes the provided name to a unique name otherwise.
bool
getUniqueName
(
std
::
string
&
name
)
const
;
/// Returns true if a mesh with the same name exists and false otherwise.
bool
meshExists
(
const
std
::
string
&
name
)
const
;
/// Returns true if a mesh with the same name exists and false otherwise.
bool
meshExists
(
const
std
::
string
&
name
)
const
;
/// Returns an iterator to the first found mesh with the given name.
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
const_iterator
findMeshByName
(
std
::
string
const
&
name
)
const
;
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
iterator
findMeshByName
(
std
::
string
const
&
name
);
/// Returns an iterator to the first found mesh with the given name.
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
const_iterator
findMeshByName
(
std
::
string
const
&
name
)
const
;
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>::
iterator
findMeshByName
(
std
::
string
const
&
name
);
GeoLib
::
GEOObjects
_geoObjects
;
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>
_mesh_vec
;
GeoLib
::
GEOObjects
_geoObjects
;
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>
_mesh_vec
;
};
}
// namespace
...
...
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