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
Ben Boeckel
SMTK
Commits
fe4dff71
Commit
fe4dff71
authored
Oct 23, 2017
by
T.J. Corona
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InterpolateMesh: rename and update doc
parent
1d221578
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
127 additions
and
433 deletions
+127
-433
smtk/mesh/CMakeLists.txt
smtk/mesh/CMakeLists.txt
+3
-3
smtk/mesh/operators/GenerateHotStartData.h
smtk/mesh/operators/GenerateHotStartData.h
+2
-2
smtk/mesh/operators/InterpolateOntoMesh.cxx
smtk/mesh/operators/InterpolateOntoMesh.cxx
+6
-6
smtk/mesh/operators/InterpolateOntoMesh.h
smtk/mesh/operators/InterpolateOntoMesh.h
+6
-6
smtk/mesh/operators/InterpolateOntoMesh.sbt
smtk/mesh/operators/InterpolateOntoMesh.sbt
+15
-14
smtk/mesh/pybind11/PybindInterpolateOntoMesh.h
smtk/mesh/pybind11/PybindInterpolateOntoMesh.h
+42
-0
smtk/mesh/pybind11/PybindMesh.cxx
smtk/mesh/pybind11/PybindMesh.cxx
+2
-2
smtk/mesh/testing/cxx/CMakeLists.txt
smtk/mesh/testing/cxx/CMakeLists.txt
+31
-31
smtk/mesh/testing/cxx/TestGenerateHotStartData.cxx
smtk/mesh/testing/cxx/TestGenerateHotStartData.cxx
+2
-2
smtk/mesh/testing/cxx/TestInterpolateOntoMesh.cxx
smtk/mesh/testing/cxx/TestInterpolateOntoMesh.cxx
+18
-14
smtk/mesh/testing/cxx/TestWarpMesh.cxx
smtk/mesh/testing/cxx/TestWarpMesh.cxx
+0
-0
smtk/model/testing/cxx/unitInterpolateMesh.cxx
smtk/model/testing/cxx/unitInterpolateMesh.cxx
+0
-353
No files found.
smtk/mesh/CMakeLists.txt
View file @
fe4dff71
...
...
@@ -41,7 +41,7 @@ set(meshSrcs
operators/DeleteMesh.cxx
operators/ExportMesh.cxx
operators/GenerateHotStartData.cxx
operators/InterpolateMesh.cxx
operators/Interpolate
Onto
Mesh.cxx
operators/UndoWarpMesh.cxx
operators/WarpMesh.cxx
operators/WriteMesh.cxx
...
...
@@ -86,7 +86,7 @@ set(meshHeaders
operators/DeleteMesh.h
operators/ExportMesh.h
operators/GenerateHotStartData.h
operators/InterpolateMesh.h
operators/Interpolate
Onto
Mesh.h
operators/UndoWarpMesh.h
operators/WarpMesh.h
operators/WriteMesh.h
...
...
@@ -95,7 +95,7 @@ set(meshHeaders
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/DeleteMesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/ExportMesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/GenerateHotStartData.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/InterpolateMesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/Interpolate
Onto
Mesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/UndoWarpMesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/WarpMesh.sbt"
defOpXML
)
smtk_operator_xml
(
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/operators/WriteMesh.sbt"
defOpXML
)
...
...
smtk/mesh/operators/GenerateHotStartData.h
View file @
fe4dff71
...
...
@@ -19,8 +19,8 @@ namespace mesh
/**\brief A class for generating hot start data for AdH.
This class performs the same actions as InterpolateMesh, with the
following
differences:
This class performs the same actions as Interpolate
Onto
Mesh, with the
following
differences:
1) the API is tweaked to apply directly to AdH's use case
2) only point data can be generated
3) when computing initial water surface elevation, the z-coordinate of each
...
...
smtk/mesh/operators/InterpolateMesh.cxx
→
smtk/mesh/operators/Interpolate
Onto
Mesh.cxx
View file @
fe4dff71
...
...
@@ -8,7 +8,7 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/mesh/operators/InterpolateMesh.h"
#include "smtk/mesh/operators/Interpolate
Onto
Mesh.h"
#include "smtk/attribute/Attribute.h"
#include "smtk/attribute/DoubleItem.h"
...
...
@@ -104,7 +104,7 @@ namespace smtk
namespace
mesh
{
bool
InterpolateMesh
::
ableToOperate
()
bool
Interpolate
Onto
Mesh
::
ableToOperate
()
{
if
(
!
this
->
ensureSpecification
())
{
...
...
@@ -120,7 +120,7 @@ bool InterpolateMesh::ableToOperate()
return
true
;
}
smtk
::
model
::
OperatorResult
InterpolateMesh
::
operateInternal
()
smtk
::
model
::
OperatorResult
Interpolate
Onto
Mesh
::
operateInternal
()
{
// Access the mesh to elevate
smtk
::
attribute
::
MeshItem
::
Ptr
meshItem
=
this
->
specification
()
->
findMesh
(
"mesh"
);
...
...
@@ -211,7 +211,7 @@ smtk::model::OperatorResult InterpolateMesh::operateInternal()
}
}
#include "smtk/mesh/InterpolateMesh_xml.h"
#include "smtk/mesh/Interpolate
Onto
Mesh_xml.h"
smtkImplementsModelOperator
(
SMTKCORE_EXPORT
,
smtk
::
mesh
::
InterpolateMesh
,
interpolate_mesh
,
"interpolate mesh"
,
InterpolateMesh_xml
,
smtk
::
model
::
Session
);
smtkImplementsModelOperator
(
SMTKCORE_EXPORT
,
smtk
::
mesh
::
Interpolate
Onto
Mesh
,
interpolate_
onto_
mesh
,
"interpolate
onto
mesh"
,
Interpolate
Onto
Mesh_xml
,
smtk
::
model
::
Session
);
smtk/mesh/operators/InterpolateMesh.h
→
smtk/mesh/operators/Interpolate
Onto
Mesh.h
View file @
fe4dff71
...
...
@@ -7,8 +7,8 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_mesh_operators_InterpolateMesh_h
#define __smtk_mesh_operators_InterpolateMesh_h
#ifndef __smtk_mesh_operators_Interpolate
Onto
Mesh_h
#define __smtk_mesh_operators_Interpolate
Onto
Mesh_h
#include "smtk/model/Operator.h"
...
...
@@ -19,11 +19,11 @@ namespace mesh
/**\brief A class for generating a mesh data set from interpolation points.
*/
class
SMTKCORE_EXPORT
InterpolateMesh
:
public
smtk
::
model
::
Operator
class
SMTKCORE_EXPORT
Interpolate
Onto
Mesh
:
public
smtk
::
model
::
Operator
{
public:
smtkTypeMacro
(
InterpolateMesh
);
smtkCreateMacro
(
InterpolateMesh
);
smtkTypeMacro
(
Interpolate
Onto
Mesh
);
smtkCreateMacro
(
Interpolate
Onto
Mesh
);
smtkSharedFromThisMacro
(
Operator
);
smtkDeclareModelOperator
();
...
...
@@ -35,4 +35,4 @@ protected:
}
}
#endif // __smtk_mesh_operators_InterpolateMesh_h
#endif // __smtk_mesh_operators_Interpolate
Onto
Mesh_h
smtk/mesh/operators/InterpolateMesh.sbt
→
smtk/mesh/operators/Interpolate
Onto
Mesh.sbt
View file @
fe4dff71
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<!--
Description
of
the
"interpolate mesh"
Operator
-->
<!--
Description
of
the
"interpolate
onto
mesh"
Operator
-->
<
SMTK_AttributeSystem
Version
=
"2"
>
<
Definitions
>
<!--
Operator
-->
<
AttDef
Type
=
"interpolate mesh"
Label
=
"Mesh - Interpolate"
BaseType
=
"operator"
>
<
AttDef
Type
=
"interpolate
onto
mesh"
Label
=
"Mesh - Interpolate
data onto mesh
"
BaseType
=
"operator"
>
<
BriefDescription
>
Create
a
field
on
mesh
nodes
/
elements
from
interpolated
2
-
dimensional
data
.
Create
a
field
on
mesh
nodes
/
elements
from
interpolated
3
-
dimensional
data
.
</
BriefDescription
>
<
DetailedDescription
>
&
lt
;
p
&
gt
;
Create
a
field
on
mesh
nodes
/
elements
from
interpolated
2
-
dimensional
data
.
&
lt
;
p
&
gt
;
This
operator
accepts
as
input
two
-
dimensional
point
s
with
associated
scalar
values
,
and
interpolates
these
values
onto
either
the
points
or
the
cells
of
the
mesh
.
The
input
points
can
be
inserted
manually
or
read
from
a
CSV
file
.
&
lt
;
p
&
gt
;
Create
a
field
on
mesh
nodes
/
elements
from
interpolated
3
-
dimensional
data
.
&
lt
;
p
&
gt
;
This
operator
accepts
as
input
three
-
dimensional
points
with
associated
scalar
values
;
it
interpolates
these
value
s
onto
either
the
points
or
the
cells
of
the
mesh
using
Shepard
's
method
for
interpolation
.
The
input
points
can
be
inserted
manually
or
read
from
a
CSV
file
.
</
DetailedDescription
>
<
ItemDefinitions
>
<
MeshEntity
Name
=
"mesh"
Label
=
"Mesh"
NumberOfRequiredValues
=
"1"
Extensible
=
"true"
>
<
BriefDescription
>
The
mesh
to
elev
ate
.</
BriefDescription
>
<
BriefDescription
>
The
mesh
on
to
which
the
data
is
interpol
ate
d
.</
BriefDescription
>
</
MeshEntity
>
<
String
Name
=
"dsname"
Label
=
"Field Name"
NumberOfRequiredValues
=
"1"
>
<
BriefDescription
>
The
name
of
the
data
set
.</
BriefDescription
>
<
BriefDescription
>
The
name
of
the
generated
data
set
.</
BriefDescription
>
</
String
>
<
Int
Name
=
"interpmode"
Label
=
"Output Field Type"
NumberOfRequiredValues
=
"1"
Extensible
=
"false"
>
<
BriefDescription
>
Interpolate
the
data
as
cell
-
centered
or
point
-
centered
on
the
mesh
.</
BriefDescription
>
<
DiscreteInfo
DefaultIndex
=
"0"
>
<
Value
Enum
=
"Cell Fields"
>
0
</
Value
>
<
Value
Enum
=
"Point Fields"
>
1
</
Value
>
...
...
@@ -35,6 +35,7 @@
<
File
Name
=
"ptsfile"
Label
=
"Input CSV File"
NumberOfValues
=
"1"
ShouldExist
=
"true"
Optional
=
"true"
FileFilters
=
"CSV file (*.csv)"
>
<
BriefDescription
>
Input
file
containing
rows
of
4
comma
separated
values
:
x
,
y
,
z
,
value
.</
BriefDescription
>
</
File
>
<
Group
Name
=
"points"
Label
=
"Interpolation Points"
...
...
@@ -71,7 +72,7 @@
</
ItemDefinitions
>
</
AttDef
>
<!--
Result
-->
<
AttDef
Type
=
"result(interpolate mesh)"
BaseType
=
"result"
>
<
AttDef
Type
=
"result(interpolate
onto
mesh)"
BaseType
=
"result"
>
<
ItemDefinitions
>
<
MeshEntity
Name
=
"mesh_modified"
NumberOfRequiredValues
=
"0"
Extensible
=
"true"
AdvanceLevel
=
"11"
/>
<
ModelEntity
Name
=
"tess_changed"
NumberOfRequiredValues
=
"0"
...
...
smtk/mesh/pybind11/PybindInterpolateMesh.h
→
smtk/mesh/pybind11/PybindInterpolate
Onto
Mesh.h
View file @
fe4dff71
...
...
@@ -8,34 +8,33 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef pybind_smtk_mesh_operators_InterpolateMesh_h
#define pybind_smtk_mesh_operators_InterpolateMesh_h
#ifndef pybind_smtk_mesh_operators_Interpolate
Onto
Mesh_h
#define pybind_smtk_mesh_operators_Interpolate
Onto
Mesh_h
#include <pybind11/pybind11.h>
#include "smtk/mesh/operators/InterpolateMesh.h"
#include "smtk/mesh/operators/Interpolate
Onto
Mesh.h"
#include "smtk/model/Operator.h"
namespace
py
=
pybind11
;
PySharedPtrClass
<
smtk
::
mesh
::
InterpolateMesh
,
smtk
::
model
::
Operator
>
pybind11_init_smtk_mesh_InterpolateMesh
(
py
::
module
&
m
)
PySharedPtrClass
<
smtk
::
mesh
::
Interpolate
Onto
Mesh
,
smtk
::
model
::
Operator
>
pybind11_init_smtk_mesh_Interpolate
Onto
Mesh
(
py
::
module
&
m
)
{
PySharedPtrClass
<
smtk
::
mesh
::
InterpolateMesh
,
smtk
::
model
::
Operator
>
instance
(
m
,
"InterpolateMesh"
);
PySharedPtrClass
<
smtk
::
mesh
::
Interpolate
Onto
Mesh
,
smtk
::
model
::
Operator
>
instance
(
m
,
"Interpolate
Onto
Mesh"
);
instance
.
def
(
py
::
init
<>
())
.
def
(
py
::
init
<::
smtk
::
mesh
::
InterpolateMesh
const
&>
())
.
def
(
"deepcopy"
,
(
smtk
::
mesh
::
InterpolateMesh
&
(
smtk
::
mesh
::
InterpolateMesh
::*
)(
::
smtk
::
mesh
::
InterpolateMesh
const
&
))
&
smtk
::
mesh
::
InterpolateMesh
::
operator
=
)
.
def
(
"ableToOperate"
,
&
smtk
::
mesh
::
InterpolateMesh
::
ableToOperate
)
.
def_static
(
"baseCreate"
,
&
smtk
::
mesh
::
InterpolateMesh
::
baseCreate
)
.
def
(
"className"
,
&
smtk
::
mesh
::
InterpolateMesh
::
className
)
.
def
(
"classname"
,
&
smtk
::
mesh
::
InterpolateMesh
::
classname
)
.
def_static
(
"create"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateMesh
>
(
*
)())
&
smtk
::
mesh
::
InterpolateMesh
::
create
)
.
def_static
(
"create"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateMesh
>
(
*
)(
::
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateMesh
>
&
))
&
smtk
::
mesh
::
InterpolateMesh
::
create
,
py
::
arg
(
"ref"
))
.
def
(
"name"
,
&
smtk
::
mesh
::
InterpolateMesh
::
name
)
.
def
(
"shared_from_this"
,
(
std
::
shared_ptr
<
const
smtk
::
mesh
::
InterpolateMesh
>
(
smtk
::
mesh
::
InterpolateMesh
::*
)()
const
)
&
smtk
::
mesh
::
InterpolateMesh
::
shared_from_this
)
.
def
(
"shared_from_this"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateMesh
>
(
smtk
::
mesh
::
InterpolateMesh
::*
)())
&
smtk
::
mesh
::
InterpolateMesh
::
shared_from_this
)
.
def_readwrite_static
(
"operatorName"
,
&
smtk
::
mesh
::
InterpolateMesh
::
operatorName
)
.
def
(
py
::
init
<::
smtk
::
mesh
::
InterpolateOntoMesh
const
&>
())
.
def
(
"deepcopy"
,
(
smtk
::
mesh
::
InterpolateOntoMesh
&
(
smtk
::
mesh
::
InterpolateOntoMesh
::*
)(
::
smtk
::
mesh
::
InterpolateOntoMesh
const
&
))
&
smtk
::
mesh
::
InterpolateOntoMesh
::
operator
=
)
.
def
(
"ableToOperate"
,
&
smtk
::
mesh
::
InterpolateOntoMesh
::
ableToOperate
)
.
def
(
"className"
,
&
smtk
::
mesh
::
InterpolateOntoMesh
::
className
)
.
def
(
"classname"
,
&
smtk
::
mesh
::
InterpolateOntoMesh
::
classname
)
.
def_static
(
"create"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateOntoMesh
>
(
*
)())
&
smtk
::
mesh
::
InterpolateOntoMesh
::
create
)
.
def_static
(
"create"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateOntoMesh
>
(
*
)(
::
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateOntoMesh
>
&
))
&
smtk
::
mesh
::
InterpolateOntoMesh
::
create
,
py
::
arg
(
"ref"
))
.
def
(
"name"
,
&
smtk
::
mesh
::
InterpolateOntoMesh
::
name
)
.
def
(
"shared_from_this"
,
(
std
::
shared_ptr
<
const
smtk
::
mesh
::
InterpolateOntoMesh
>
(
smtk
::
mesh
::
InterpolateOntoMesh
::*
)()
const
)
&
smtk
::
mesh
::
InterpolateOntoMesh
::
shared_from_this
)
.
def
(
"shared_from_this"
,
(
std
::
shared_ptr
<
smtk
::
mesh
::
InterpolateOntoMesh
>
(
smtk
::
mesh
::
InterpolateOntoMesh
::*
)())
&
smtk
::
mesh
::
InterpolateOntoMesh
::
shared_from_this
)
.
def_readwrite_static
(
"operatorName"
,
&
smtk
::
mesh
::
InterpolateOntoMesh
::
operatorName
)
;
return
instance
;
}
...
...
smtk/mesh/pybind11/PybindMesh.cxx
View file @
fe4dff71
...
...
@@ -46,7 +46,7 @@ using PySharedPtrClass = py::class_<T, std::shared_ptr<T>, Args...>;
#include "PybindDeleteMesh.h"
#include "PybindExportMesh.h"
#include "PybindInterpolateMesh.h"
#include "PybindInterpolate
Onto
Mesh.h"
#include "PybindWriteMesh.h"
#include "smtk/model/Operator.h"
...
...
@@ -142,6 +142,6 @@ PYBIND11_MODULE(_smtkPybindMesh, mesh)
PySharedPtrClass
<
smtk
::
mesh
::
DeleteMesh
,
smtk
::
model
::
Operator
>
smtk_mesh_DeleteMesh
=
pybind11_init_smtk_mesh_DeleteMesh
(
mesh
);
PySharedPtrClass
<
smtk
::
mesh
::
ExportMesh
,
smtk
::
model
::
Operator
>
smtk_mesh_ExportMesh
=
pybind11_init_smtk_mesh_ExportMesh
(
mesh
);
PySharedPtrClass
<
smtk
::
mesh
::
InterpolateMesh
,
smtk
::
model
::
Operator
>
smtk_mesh_InterpolateMesh
=
pybind11_init_smtk_mesh_InterpolateMesh
(
mesh
);
PySharedPtrClass
<
smtk
::
mesh
::
Interpolate
Onto
Mesh
,
smtk
::
model
::
Operator
>
smtk_mesh_Interpolate
Onto
Mesh
=
pybind11_init_smtk_mesh_Interpolate
Onto
Mesh
(
mesh
);
PySharedPtrClass
<
smtk
::
mesh
::
WriteMesh
,
smtk
::
model
::
Operator
>
smtk_mesh_WriteMesh
=
pybind11_init_smtk_mesh_WriteMesh
(
mesh
);
}
smtk/mesh/testing/cxx/CMakeLists.txt
View file @
fe4dff71
...
...
@@ -67,47 +67,47 @@ smtk_unit_tests(
LIBRARIES smtkCore smtkCoreModelTesting
${
extra_libs
}
${
Boost_LIBRARIES
}
)
add_executable
(
Unit
TestGenerateHotStartData
Unit
TestGenerateHotStartData.cxx
)
target_compile_definitions
(
Unit
TestGenerateHotStartData PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
Unit
TestGenerateHotStartData smtkCore
${
Boost_LIBRARIES
}
)
add_executable
(
TestGenerateHotStartData TestGenerateHotStartData.cxx
)
target_compile_definitions
(
TestGenerateHotStartData PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
TestGenerateHotStartData smtkCore
${
Boost_LIBRARIES
}
)
add_executable
(
Unit
TestInterpolateMesh
Unit
TestInterpolateMesh.cxx
)
target_compile_definitions
(
Unit
TestInterpolateMesh PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
Unit
TestInterpolateMesh smtkCore
${
Boost_LIBRARIES
}
)
add_executable
(
TestInterpolate
Onto
Mesh TestInterpolate
Onto
Mesh.cxx
)
target_compile_definitions
(
TestInterpolate
Onto
Mesh PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
TestInterpolate
Onto
Mesh smtkCore
${
Boost_LIBRARIES
}
)
add_executable
(
Unit
TestWarpMesh
Unit
TestWarpMesh.cxx
)
target_compile_definitions
(
Unit
TestWarpMesh PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
Unit
TestWarpMesh smtkCore
${
Boost_LIBRARIES
}
)
add_executable
(
TestWarpMesh TestWarpMesh.cxx
)
target_compile_definitions
(
TestWarpMesh PRIVATE
"SMTK_SCRATCH_DIR=
\"
${
CMAKE_BINARY_DIR
}
/Testing/Temporary
\"
"
)
target_link_libraries
(
TestWarpMesh smtkCore
${
Boost_LIBRARIES
}
)
if
(
SMTK_DATA_DIR AND EXISTS
${
SMTK_DATA_DIR
}
/cmb-testing-data.marker
)
add_test
(
NAME
Unit
TestGenerateHotStartData
COMMAND $<TARGET_FILE:
Unit
TestGenerateHotStartData>
add_test
(
NAME TestGenerateHotStartData
COMMAND $<TARGET_FILE:TestGenerateHotStartData>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
)
set_tests_properties
(
Unit
TestGenerateHotStartData PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestGenerateHotStartDataCSV
COMMAND $<TARGET_FILE:
Unit
TestGenerateHotStartData>
set_tests_properties
(
TestGenerateHotStartData PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestGenerateHotStartDataCSV
COMMAND $<TARGET_FILE:TestGenerateHotStartData>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
1
)
set_tests_properties
(
Unit
TestGenerateHotStartDataCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestInterpolateMesh
To
Cells
COMMAND $<TARGET_FILE:
Unit
TestInterpolateMesh>
set_tests_properties
(
TestGenerateHotStartDataCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestInterpolate
Onto
MeshCells
COMMAND $<TARGET_FILE:TestInterpolate
Onto
Mesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
)
set_tests_properties
(
Unit
TestInterpolateMesh
To
Cells PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestInterpolateMesh
To
Points
COMMAND $<TARGET_FILE:
Unit
TestInterpolateMesh>
set_tests_properties
(
TestInterpolate
Onto
MeshCells PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestInterpolate
Onto
MeshPoints
COMMAND $<TARGET_FILE:TestInterpolate
Onto
Mesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
0
)
set_tests_properties
(
Unit
TestInterpolateMesh
To
Points PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestInterpolateMesh
To
CellsCSV
COMMAND $<TARGET_FILE:
Unit
TestInterpolateMesh>
set_tests_properties
(
TestInterpolate
Onto
MeshPoints PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestInterpolate
Onto
MeshCellsCSV
COMMAND $<TARGET_FILE:TestInterpolate
Onto
Mesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
0 1
)
set_tests_properties
(
Unit
TestInterpolateMesh
To
CellsCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestInterpolateMesh
To
PointsCSV
COMMAND $<TARGET_FILE:
Unit
TestInterpolateMesh>
set_tests_properties
(
TestInterpolate
Onto
MeshCellsCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestInterpolate
Onto
MeshPointsCSV
COMMAND $<TARGET_FILE:TestInterpolate
Onto
Mesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
1 1
)
set_tests_properties
(
Unit
TestInterpolateMesh
To
PointsCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME
Unit
TestWarpMesh
COMMAND $<TARGET_FILE:
Unit
TestWarpMesh>
set_tests_properties
(
TestInterpolate
Onto
MeshPointsCSV PROPERTIES LABELS
"Mesh"
)
add_test
(
NAME TestWarpMesh
COMMAND $<TARGET_FILE:TestWarpMesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
0
)
add_test
(
NAME
Unit
TestWarpMeshCSV
COMMAND $<TARGET_FILE:
Unit
TestWarpMesh>
add_test
(
NAME TestWarpMeshCSV
COMMAND $<TARGET_FILE:TestWarpMesh>
"
${
SMTK_DATA_DIR
}
/model/2d/smtk/test2D.json"
1
)
endif
()
smtk/mesh/testing/cxx/
Unit
TestGenerateHotStartData.cxx
→
smtk/mesh/testing/cxx/TestGenerateHotStartData.cxx
View file @
fe4dff71
...
...
@@ -261,7 +261,7 @@ int main(int argc, char* argv[])
}
}
// Execute "
Interpolate Mesh
" operator...
// Execute "
generate hot start data
" operator...
smtk
::
model
::
OperatorResult
generateHotStartDataOpResult
=
generateHotStartDataOp
->
operate
();
// ...delete the generated points file...
...
...
@@ -273,7 +273,7 @@ int main(int argc, char* argv[])
// ...and test the results for success.
if
(
generateHotStartDataOpResult
->
findInt
(
"outcome"
)
->
value
()
!=
smtk
::
model
::
OPERATION_SUCCEEDED
)
{
std
::
cerr
<<
"
\"
interpolate mesh
\"
operator failed
\n
"
;
std
::
cerr
<<
"
\"
generate hot start data
\"
operator failed
\n
"
;
return
1
;
}
...
...
smtk/mesh/testing/cxx/
Unit
TestInterpolateMesh.cxx
→
smtk/mesh/testing/cxx/TestInterpolate
Onto
Mesh.cxx
View file @
fe4dff71
...
...
@@ -188,16 +188,17 @@ int main(int argc, char* argv[])
smtk
::
io
::
ModelToMesh
convert
;
smtk
::
mesh
::
CollectionPtr
c
=
convert
(
meshManager
,
manager
);
// Create an "Interpolate Mesh" operator
smtk
::
model
::
OperatorPtr
interpolateMeshOp
=
sessRef
.
session
()
->
op
(
"interpolate mesh"
);
if
(
!
interpolateMeshOp
)
// Create an "Interpolate
Onto
Mesh" operator
smtk
::
model
::
OperatorPtr
interpolate
Onto
MeshOp
=
sessRef
.
session
()
->
op
(
"interpolate
onto
mesh"
);
if
(
!
interpolate
Onto
MeshOp
)
{
std
::
cerr
<<
"No
\"
interpolate mesh
\"
operator
\n
"
;
std
::
cerr
<<
"No
\"
interpolate
onto
mesh
\"
operator
\n
"
;
return
1
;
}
// Set the operator's data set name
bool
valueSet
=
interpolateMeshOp
->
specification
()
->
findString
(
"dsname"
)
->
setValue
(
"my field"
);
bool
valueSet
=
interpolateOntoMeshOp
->
specification
()
->
findString
(
"dsname"
)
->
setValue
(
"my field"
);
if
(
!
valueSet
)
{
...
...
@@ -207,7 +208,7 @@ int main(int argc, char* argv[])
// Set the operator's input mesh
smtk
::
mesh
::
MeshSet
mesh
=
meshManager
->
collectionBegin
()
->
second
->
meshes
();
valueSet
=
interpolateMeshOp
->
specification
()
->
findMesh
(
"mesh"
)
->
setValue
(
mesh
);
valueSet
=
interpolate
Onto
MeshOp
->
specification
()
->
findMesh
(
"mesh"
)
->
setValue
(
mesh
);
if
(
!
valueSet
)
{
...
...
@@ -216,7 +217,8 @@ int main(int argc, char* argv[])
}
// Set the operator's input power
smtk
::
attribute
::
DoubleItemPtr
power
=
interpolateMeshOp
->
specification
()
->
findDouble
(
"power"
);
smtk
::
attribute
::
DoubleItemPtr
power
=
interpolateOntoMeshOp
->
specification
()
->
findDouble
(
"power"
);
if
(
!
power
)
{
...
...
@@ -233,7 +235,7 @@ int main(int argc, char* argv[])
}
smtk
::
attribute
::
IntItemPtr
interpMode
=
interpolateMeshOp
->
specification
()
->
findInt
(
"interpmode"
);
interpolate
Onto
MeshOp
->
specification
()
->
findInt
(
"interpmode"
);
if
(
!
interpMode
)
{
...
...
@@ -266,7 +268,8 @@ int main(int argc, char* argv[])
}
outfile
.
close
();
smtk
::
attribute
::
FileItemPtr
ptsFile
=
interpolateMeshOp
->
specification
()
->
findFile
(
"ptsfile"
);
smtk
::
attribute
::
FileItemPtr
ptsFile
=
interpolateOntoMeshOp
->
specification
()
->
findFile
(
"ptsfile"
);
if
(
!
ptsFile
)
{
std
::
cerr
<<
"No
\"
ptsfile
\"
item in specification
\n
"
;
...
...
@@ -280,7 +283,8 @@ int main(int argc, char* argv[])
else
{
// Set the operator's input points
smtk
::
attribute
::
GroupItemPtr
points
=
interpolateMeshOp
->
specification
()
->
findGroup
(
"points"
);
smtk
::
attribute
::
GroupItemPtr
points
=
interpolateOntoMeshOp
->
specification
()
->
findGroup
(
"points"
);
if
(
!
points
)
{
...
...
@@ -299,8 +303,8 @@ int main(int argc, char* argv[])
}
}
// Execute "Interpolate Mesh" operator...
smtk
::
model
::
OperatorResult
interpolateMeshOpResult
=
interpolateMeshOp
->
operate
();
// Execute "Interpolate
Onto
Mesh" operator...
smtk
::
model
::
OperatorResult
interpolate
Onto
MeshOpResult
=
interpolate
Onto
MeshOp
->
operate
();
// ...delete the generated points file...
if
(
fromCSV
)
...
...
@@ -311,7 +315,7 @@ int main(int argc, char* argv[])
// ...and test the results for success.
if
(
interpolateMeshOpResult
->
findInt
(
"outcome"
)
->
value
()
!=
smtk
::
model
::
OPERATION_SUCCEEDED
)
{
std
::
cerr
<<
"
\"
interpolate mesh
\"
operator failed
\n
"
;
std
::
cerr
<<
"
\"
interpolate
onto
mesh
\"
operator failed
\n
"
;
return
1
;
}
...
...
@@ -344,7 +348,7 @@ int main(int argc, char* argv[])
{
if
(
bin
!=
expected
[
counter
++
])
{
std
::
cerr
<<
"
\"
interpolate mesh
\"
operator produced unexpected results
\n
"
;
std
::
cerr
<<
"
\"
interpolate
onto
mesh
\"
operator produced unexpected results
\n
"
;
return
1
;
}
}
...
...
smtk/mesh/testing/cxx/
Unit
TestWarpMesh.cxx
→
smtk/mesh/testing/cxx/TestWarpMesh.cxx
View file @
fe4dff71
File moved
smtk/model/testing/cxx/unitInterpolateMesh.cxx
deleted
100644 → 0
View file @
1d221578
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/UUID.h"
#include "smtk/attribute/DoubleItem.h"
#include "smtk/attribute/FileItem.h"
#include "smtk/attribute/GroupItem.h"
#include "smtk/attribute/IntItem.h"
#include "smtk/attribute/MeshItem.h"
#include "smtk/attribute/StringItem.h"
#include "smtk/io/LoadJSON.h"
#include "smtk/io/ModelToMesh.h"
#include "smtk/io/ReadMesh.h"
#include "smtk/model/DefaultSession.h"
#include "smtk/mesh/CellField.h"
#include "smtk/mesh/Collection.h"
#include "smtk/mesh/ForEachTypes.h"
#include "smtk/mesh/Manager.h"
#include "smtk/mesh/PointField.h"
#include "smtk/model/Manager.h"
#include "smtk/model/Operator.h"
#include <algorithm>
#include <array>
#include <fstream>
//force to use filesystem version 3
#define BOOST_FILESYSTEM_VERSION 3
#include <boost/filesystem.hpp>
using
namespace
boost
::
filesystem
;
namespace
{
std
::
string
write_root
=
SMTK_SCRATCH_DIR
;
void
create_simple_mesh_model
(
smtk
::
model
::
ManagerPtr
mgr
,
std
::
string
file_path
)
{
std
::
ifstream
file
(
file_path
.
c_str
());
std
::
string
json
((
std
::
istreambuf_iterator
<
char
>
(
file
)),
(
std
::
istreambuf_iterator
<
char
>
()));
smtk
::
io
::
LoadJSON
::
intoModelManager
(
json
.
c_str
(),
mgr
);
mgr
->
assignDefaultNames
();
file
.
close
();
}
void
cleanup
(
const
std
::
string
&
file_path
)
{
//first verify the file exists
::
boost
::
filesystem
::
path
path
(
file_path
);
if
(
::
boost
::
filesystem
::
is_regular_file
(
path
))
{
//remove the file_path if it exists.
::
boost
::
filesystem
::
remove
(
path
);
}
}
class
HistogramFieldData
{
public:
HistogramFieldData
(
std
::
size_t
nBins
,
double
min
,
double
max
)
:
m_min
(
min
)
,
m_max
(
max
)
{
m_hist
.
resize
(
nBins
,
0
);
}
const
std
::
vector
<
std
::
size_t
>&
histogram
()
const
{
return
m_hist
;
}
protected:
std
::
vector
<
std
::
size_t
>
m_hist
;
double
m_min
;
double
m_max
;
};
class
HistogramCellFieldData
:
public
smtk
::
mesh
::
CellForEach
,
public
HistogramFieldData
{
public:
HistogramCellFieldData
(
std
::
size_t
nBins
,
double
min
,
double
max
,
smtk
::
mesh
::
CellField
&
cf
)
:
smtk
::
mesh
::
CellForEach
(
false
)
,
HistogramFieldData
(
nBins
,
min
,
max
)
,
m_cellField
(
cf
)
{
}
void
forCell
(
const
smtk
::
mesh
::
Handle
&
cellId
,
smtk
::
mesh
::
CellType
,
int
)
{
smtk
::
mesh
::
HandleRange
range
;
range
.
insert
(
cellId
);
double
value
=
0.
;
this
->
m_cellField
.
get
(
range
,
&
value
);
std
::
size_t
bin
=
static_cast
<
std
::
size_t
>
((
value
-
m_min
)
/
(
m_max
-
m_min
)
*
m_hist
.
size
());
++
m_hist
[
bin
];
}
protected:
smtk
::
mesh
::
CellField
&
m_cellField
;
};
class
HistogramPointFieldData
:
public
smtk
::
mesh
::
PointForEach
,
public
HistogramFieldData
{
public:
HistogramPointFieldData
(
std
::
size_t
nBins
,
double
min
,
double
max
,
smtk
::
mesh
::
PointField
&
pf
)
:
smtk
::
mesh
::
PointForEach
()
,
HistogramFieldData
(
nBins
,
min
,
max
)
,
m_pointField
(
pf
)
{
}
void
forPoints
(
const
smtk
::
mesh
::
HandleRange
&
pointIds
,
std
::
vector
<
double
>&
,
bool
&
)
{
std
::
vector
<
double
>
values
(
pointIds
.
size
());
this
->
m_pointField
.
get
(
pointIds
,
&
values
[
0
]);
for
(
auto
&
value
:
values
)
{
std
::
size_t
bin
=
static_cast
<
std
::
size_t
>
((
value
-
m_min
)
/
(
m_max
-
m_min
)
*
m_hist
.
size
());
++
m_hist
[
bin
];
}
}
protected:
smtk
::
mesh
::
PointField
&
m_pointField
;
};
}
// Load in a model, convert it to a mesh, and construct a dataset for that mesh
// using interpolation points. Then, histogram the values of the mesh cells
// and compare the histogram to expected values.
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
==
1
)
{
std
::
cout
<<
"Must provide input file as argument"
<<
std
::
endl
;
return
1
;
}
std
::
ifstream
file
;
file
.
open
(
argv
[
1
]);
if
(
!
file
.
good
())
{
std
::
cout
<<
"Could not open file
\"
"
<<
argv
[
1
]
<<
"
\"
.
\n\n
"
;