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
Karsten Rink
ogs
Commits
31955814
Commit
31955814
authored
7 years ago
by
Karsten Rink
Browse files
Options
Downloads
Patches
Plain Diff
adjusted removeMeshElements-tool to also accept value ranges (and double arrays)
parent
fe5e35f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Applications/Utils/MeshEdit/removeMeshElements.cpp
+102
-25
102 additions, 25 deletions
Applications/Utils/MeshEdit/removeMeshElements.cpp
with
102 additions
and
25 deletions
Applications/Utils/MeshEdit/removeMeshElements.cpp
+
102
−
25
View file @
31955814
...
...
@@ -28,26 +28,46 @@
#include
"MeshLib/MeshEditing/RemoveMeshComponents.h"
template
<
typename
PROPERTY_TYPE
>
void
searchByProperty
(
std
::
string
const
&
property_name
,
std
::
vector
<
PROPERTY_TYPE
>
const
&
property_values
,
MeshLib
::
ElementSearch
&
searcher
)
void
searchByProperty
Value
(
std
::
string
const
&
property_name
,
std
::
vector
<
PROPERTY_TYPE
>
const
&
property_values
,
MeshLib
::
ElementSearch
&
searcher
)
{
for
(
auto
const
&
property_value
:
property_values
)
{
const
std
::
size_t
n_marked_elements
=
searcher
.
searchByPropertyValue
(
property_name
,
property_value
);
for
(
auto
const
&
property_value
:
property_values
)
{
std
::
size_t
n_marked_elements
=
searcher
.
searchByPropertyValue
<
double
>
(
property_name
,
property_value
);
if
(
n_marked_elements
==
0
)
std
::
size_t
n_marked_elements
=
searcher
.
searchByPropertyValue
<
int
>
(
property_name
,
property_value
);
INFO
(
"%d elements with property value %s found."
,
n_marked_elements
,
std
::
to_string
(
property_value
).
c_str
());
}
}
void
searchByPropertyRange
(
std
::
string
const
&
property_name
,
double
const
&
min_value
,
double
const
&
max_value
,
bool
const
&
outside
,
MeshLib
::
ElementSearch
&
searcher
)
{
std
::
size_t
n_marked_elements
=
searcher
.
searchByPropertyValueRange
<
double
>
(
property_name
,
min_value
,
max_value
,
outside
);
if
(
n_marked_elements
==
0
)
n_marked_elements
=
searcher
.
searchByPropertyValueRange
<
int
>
(
property_name
,
static_cast
<
int
>
(
min_value
),
static_cast
<
int
>
(
max_value
),
outside
);
INFO
(
"%d elements in range [%s, %s] found."
,
n_marked_elements
,
std
::
to_string
(
min_value
).
c_str
(),
std
::
to_string
(
max_value
).
c_str
());
}
int
main
(
int
argc
,
char
*
argv
[])
{
ApplicationsLib
::
LogogSetup
logog_setup
;
TCLAP
::
CmdLine
cmd
(
"Remove mesh elements. The documentation is available at "
"https://docs.opengeosys.org/docs/tools/meshing/remove-mesh-elements."
,
' '
,
"0.1"
);
TCLAP
::
CmdLine
cmd
(
"Removes mesh elements based on element type, element volume, scalar "
"arrays, or bounding box . The documentation is available at "
"https://docs.opengeosys.org/docs/tools/meshing/remove-mesh-elements."
,
' '
,
"0.1"
);
// Bounding box params
TCLAP
::
ValueArg
<
double
>
zLargeArg
(
""
,
"z-max"
,
"largest allowed extent in z-dimension"
,
...
...
@@ -76,15 +96,31 @@ int main (int argc, char* argv[])
"element type to be removed"
,
false
,
"element type"
);
cmd
.
add
(
eleTypeArg
);
TCLAP
::
MultiArg
<
int
>
int_property_arg
(
""
,
"int-property-value"
,
"new property value (data type int)"
,
false
,
"number"
);
cmd
.
add
(
int_property_arg
);
// scalar array params
TCLAP
::
ValueArg
<
std
::
string
>
property_name_arg
(
"n"
,
"property-name"
,
"name of property in the mesh"
,
false
,
"MaterialIDs"
,
"string"
);
"n"
,
"property-name"
,
"name of property in the mesh"
,
false
,
"MaterialIDs"
,
"string"
);
cmd
.
add
(
property_name_arg
);
TCLAP
::
MultiArg
<
int
>
property_arg
(
""
,
"property-value"
,
"value of selected property to be removed"
,
false
,
"number"
);
cmd
.
add
(
property_arg
);
TCLAP
::
ValueArg
<
double
>
min_property_arg
(
""
,
"min-value"
,
"minimum value of range for selected property"
,
false
,
0
,
"number"
);
cmd
.
add
(
min_property_arg
);
TCLAP
::
ValueArg
<
double
>
max_property_arg
(
""
,
"max-value"
,
"maximum value of range for selected property"
,
false
,
0
,
"number"
);
cmd
.
add
(
max_property_arg
);
TCLAP
::
SwitchArg
outside_property_arg
(
""
,
"outside"
,
"remove all elements outside the given property range"
);
cmd
.
add
(
outside_property_arg
);
TCLAP
::
SwitchArg
inside_property_arg
(
""
,
"inside"
,
"remove all elements inside the given property range"
);
cmd
.
add
(
inside_property_arg
);
// I/O params
TCLAP
::
ValueArg
<
std
::
string
>
mesh_out
(
"o"
,
"mesh-output-file"
,
"the name of the file the mesh will be written to"
,
true
,
...
...
@@ -94,11 +130,13 @@ int main (int argc, char* argv[])
"the name of the file containing the input mesh"
,
true
,
""
,
"file name of input mesh"
);
cmd
.
add
(
mesh_in
);
cmd
.
parse
(
argc
,
argv
);
std
::
unique_ptr
<
MeshLib
::
Mesh
const
>
mesh
(
MeshLib
::
IO
::
readMeshFromFile
(
mesh_in
.
getValue
()));
if
(
mesh
==
nullptr
)
return
EXIT_FAILURE
;
INFO
(
"Mesh read: %d nodes, %d elements."
,
mesh
->
getNumberOfNodes
(),
mesh
->
getNumberOfElements
());
MeshLib
::
ElementSearch
searcher
(
*
mesh
);
...
...
@@ -116,9 +154,52 @@ int main (int argc, char* argv[])
}
}
if
(
int_property_arg
.
isSet
())
{
searchByProperty
(
property_name_arg
.
getValue
(),
int_property_arg
.
getValue
(),
searcher
);
if
(
property_name_arg
.
isSet
()
||
property_arg
.
isSet
()
||
min_property_arg
.
isSet
()
||
max_property_arg
.
isSet
())
{
if
((
property_arg
.
isSet
()
||
min_property_arg
.
isSet
()
||
max_property_arg
.
isSet
())
&&
!
property_name_arg
.
isSet
())
{
ERR
(
"Specify a property name for the value/range selected."
);
return
EXIT_FAILURE
;
}
if
(
property_name_arg
.
isSet
()
&&
!
((
min_property_arg
.
isSet
()
&&
max_property_arg
.
isSet
())
||
property_arg
.
isSet
()))
{
ERR
(
"Specify a value or range (
\"
-min-value
\"
and
\"
-max_value
\"
) "
"for the property selected."
);
return
EXIT_FAILURE
;
}
// name + value
if
(
property_arg
.
isSet
()
&&
property_name_arg
.
isSet
())
{
searchByPropertyValue
(
property_name_arg
.
getValue
(),
property_arg
.
getValue
(),
searcher
);
}
// name + range
if
(
property_name_arg
.
isSet
()
&&
min_property_arg
.
isSet
()
&&
max_property_arg
.
isSet
())
{
if
((
!
outside_property_arg
.
isSet
()
&&
!
inside_property_arg
.
isSet
())
||
(
outside_property_arg
.
isSet
()
&&
inside_property_arg
.
isSet
()))
{
ERR
(
"Specify if the inside or the outside of the selected "
"range should be removed."
);
return
EXIT_FAILURE
;
}
bool
outside
=
false
;
if
(
outside_property_arg
.
isSet
())
outside
=
true
;
searchByPropertyRange
(
property_name_arg
.
getValue
(),
min_property_arg
.
getValue
(),
max_property_arg
.
getValue
(),
outside
,
searcher
);
}
}
if
(
xSmallArg
.
isSet
()
||
xLargeArg
.
isSet
()
||
...
...
@@ -150,8 +231,7 @@ int main (int argc, char* argv[])
MathLib
::
Point3d
(
std
::
array
<
double
,
3
>
{{
xLargeArg
.
getValue
(),
yLargeArg
.
getValue
(),
zLargeArg
.
getValue
()}})}});
INFO
(
"%d elements found."
,
searcher
.
searchByBoundingBox
(
GeoLib
::
AABB
(
extent
.
begin
(),
extent
.
end
())));
searcher
.
searchByBoundingBox
(
GeoLib
::
AABB
(
extent
.
begin
(),
extent
.
end
())));
}
// remove the elements and create a new mesh object.
...
...
@@ -166,6 +246,3 @@ int main (int argc, char* argv[])
return
EXIT_SUCCESS
;
}
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