Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMB
SMTK
Commits
5796503f
Commit
5796503f
authored
Oct 31, 2018
by
David Thompson
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Assign default names to meshes upon import.
parent
21eea530
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
2 deletions
+48
-2
smtk/mesh/core/Collection.cxx
smtk/mesh/core/Collection.cxx
+28
-0
smtk/mesh/core/Collection.h
smtk/mesh/core/Collection.h
+5
-0
smtk/mesh/operators/Import.cxx
smtk/mesh/operators/Import.cxx
+7
-0
smtk/mesh/operators/Import.sbt
smtk/mesh/operators/Import.sbt
+8
-2
No files found.
smtk/mesh/core/Collection.cxx
View file @
5796503f
...
...
@@ -54,6 +54,7 @@ Collection::Collection()
,
m_floatData
(
new
MeshFloatData
)
,
m_stringData
(
new
MeshStringData
)
,
m_integerData
(
new
MeshIntegerData
)
,
m_nameCounter
(
-
1
)
,
m_internals
(
new
InternalImpl
())
{
}
...
...
@@ -66,6 +67,7 @@ Collection::Collection(const smtk::common::UUID& collectionID)
,
m_floatData
(
new
MeshFloatData
)
,
m_stringData
(
new
MeshStringData
)
,
m_integerData
(
new
MeshIntegerData
)
,
m_nameCounter
(
-
1
)
,
m_internals
(
new
InternalImpl
())
{
}
...
...
@@ -79,6 +81,7 @@ Collection::Collection(smtk::mesh::InterfacePtr interface)
,
m_floatData
(
new
MeshFloatData
)
,
m_stringData
(
new
MeshStringData
)
,
m_integerData
(
new
MeshIntegerData
)
,
m_nameCounter
(
-
1
)
,
m_internals
(
new
InternalImpl
(
interface
))
{
}
...
...
@@ -91,6 +94,7 @@ Collection::Collection(const smtk::common::UUID& collectionID, smtk::mesh::Inter
,
m_floatData
(
new
MeshFloatData
)
,
m_stringData
(
new
MeshStringData
)
,
m_integerData
(
new
MeshIntegerData
)
,
m_nameCounter
(
-
1
)
,
m_internals
(
new
InternalImpl
(
interface
))
{
}
...
...
@@ -249,6 +253,30 @@ smtk::mesh::PointConnectivity Collection::pointConnectivity() const
return
ms
.
pointConnectivity
();
}
void
Collection
::
assignDefaultNames
()
{
smtk
::
resource
::
Component
::
Visitor
nameAssigner
=
[
this
](
const
smtk
::
resource
::
Component
::
Ptr
&
comp
)
{
auto
mset
=
comp
?
comp
->
as
<
smtk
::
mesh
::
Component
>
()
:
nullptr
;
if
(
!
mset
||
!
mset
->
name
().
empty
())
{
return
;
}
// Keep generating names until we find an unused one.
std
::
string
nameToTry
;
do
{
m_nameCounter
++
;
std
::
ostringstream
namer
;
namer
<<
"mesh "
<<
m_nameCounter
;
nameToTry
=
namer
.
str
();
}
while
(
this
->
meshes
(
nameToTry
).
isValid
());
mset
->
mesh
().
setName
(
nameToTry
);
};
this
->
visit
(
nameAssigner
);
}
smtk
::
mesh
::
MeshSet
Collection
::
meshes
()
const
{
return
smtk
::
mesh
::
MeshSet
(
this
->
shared_from_this
(),
m_internals
->
mesh_root_handle
());
...
...
smtk/mesh/core/Collection.h
View file @
5796503f
...
...
@@ -163,6 +163,9 @@ public:
smtk
::
mesh
::
PointConnectivity
pointConnectivity
()
const
;
//all point connectivity info for all cells
/// Assign a machine-generated name to any mesh component that does not have a user-assigned name.
void
assignDefaultNames
();
//For any mesh set that has a name we return that name. It is possible
//that the we have un-named mesh sets.
std
::
vector
<
std
::
string
>
meshNames
()
const
;
...
...
@@ -363,6 +366,8 @@ private:
smtk
::
shared_ptr
<
MeshStringData
>
m_stringData
;
smtk
::
shared_ptr
<
MeshIntegerData
>
m_integerData
;
int
m_nameCounter
;
//holds a reference to the specific backend interface
class
InternalImpl
;
smtk
::
mesh
::
Collection
::
InternalImpl
*
m_internals
;
...
...
smtk/mesh/operators/Import.cxx
View file @
5796503f
...
...
@@ -19,6 +19,7 @@
#include "smtk/attribute/Resource.h"
#include "smtk/attribute/ResourceItem.h"
#include "smtk/attribute/StringItem.h"
#include "smtk/attribute/VoidItem.h"
#include "smtk/io/ImportMesh.h"
...
...
@@ -77,6 +78,12 @@ Import::Result Import::operateInternal()
smtk
::
mesh
::
for_each
(
collection
->
meshes
(),
addMeshToResult
);
auto
assignNames
=
this
->
parameters
()
->
findVoid
(
"assign default names"
);
if
(
assignNames
&&
assignNames
->
isEnabled
())
{
collection
->
assignDefaultNames
();
}
result
->
findResource
(
"resource"
)
->
appendValue
(
collection
);
return
result
;
...
...
smtk/mesh/operators/Import.sbt
View file @
5796503f
...
...
@@ -11,8 +11,14 @@
</
File
>
<
String
Name
=
"label"
Label
=
"Domain Property"
NumberOfRequiredValues
=
"1"
AdvanceLevel
=
"1"
>
<
DefaultValue
></
DefaultValue
>
</
String
>
<
DefaultValue
></
DefaultValue
>
</
String
>
<
Void
Name
=
"assign default names"
Optional
=
"true"
IsEnabledByDefault
=
"true"
AdvanceLevel
=
"1"
>
<
BriefDescription
>
Upon
importing
,
assign
names
to
meshes
that
have
no
name
already
.
</
BriefDescription
>
</
Void
>
</
ItemDefinitions
>
</
AttDef
>
...
...
David Thompson
@dcthomp
mentioned in commit
26f5e674
·
Nov 01, 2018
mentioned in commit
26f5e674
mentioned in commit 26f5e67479d22deb1e247b1ca46f1d1db24e17b4
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment