Skip to content

Commit 32c246e

Browse files
committed
test: update capCheckParam
- test/capCheckParam.cc: use apf APIs to call the same underlying Capstone ones. - reformat table. - check edges as well as faces. - enable lion error messages - test/CMakeLists.txt: remove obsolete capVol include dir. - remove obsolete capCheckParam link libraries. Signed-off-by: Aiden Woodruff <[email protected]>
1 parent 1b30ee3 commit 32c246e

File tree

2 files changed

+44
-41
lines changed

2 files changed

+44
-41
lines changed

test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ endif()
218218

219219
if(PUMI_ENABLE_CAPSTONE)
220220
util_exe_func(capVol capVol.cc)
221-
target_include_directories(capVol PRIVATE "${PROJECT_SOURCE_DIR}/capstone_clis")
222221
test_exe_func(cap_inClosureOf cap_inClosureOf.cc)
223222
test_exe_func(cap_closestPoint cap_closestPoint.cc)
224223
if(PUMI_HAS_CAPSTONE_SIZINGMETRICTOOL)
@@ -227,7 +226,6 @@ if(PUMI_ENABLE_CAPSTONE)
227226
util_exe_func(cap2vtk cap2vtk.cc)
228227
util_exe_func(capGeomTest capGeomTest.cc)
229228
util_exe_func(capCheckParam capCheckParam.cc)
230-
target_link_libraries(capCheckParam framework_geometry framework_mesh)
231229
util_exe_func(capAdapt capAdapt.cc)
232230
util_exe_func(capProbe capProbe.cc)
233231
util_exe_func(capLoadSome capLoadSome.cc)

test/capCheckParam.cc

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#include <iostream>
2+
#include <iomanip>
23

34
#include <PCU.h>
45
#include <apf.h>
56
#include <apfCAP.h>
67
#include <apfMesh2.h>
78
#include <gmi_cap.h>
9+
#include <lionPrint.h>
810
#include <pcu_util.h>
911

10-
#include <CreateMG_Framework_Geometry.h>
11-
#include <CreateMG_Framework_Mesh.h>
12-
13-
void checkParametrization(CreateMG::MDBI* mdb, CreateMG::GDBI* gdb);
12+
void checkParametrization(apf::Mesh* mesh);
1413

1514
int main(int argc, char** argv)
1615
{
@@ -26,60 +25,66 @@ int main(int argc, char** argv)
2625

2726
const char* creFileName = argv[1];
2827

28+
lion_set_verbosity(1);
2929
gmi_cap_start();
3030
gmi_register_cap();
3131

3232
gmi_model* model = gmi_cap_load(creFileName);
3333
apf::Mesh2* mesh = apf::createCapMesh(model, &PCUobj);
3434

3535
// check parametrization using capstone apis
36-
checkParametrization(apf::exportCapNative(mesh), gmi_export_cap(model));
36+
checkParametrization(mesh);
3737
apf::destroyMesh(mesh);
3838
gmi_cap_stop();
3939
} // pcu object scope
4040
pcu::Finalize();
4141
}
4242

43-
void checkParametrization(CreateMG::MDBI* mdb, CreateMG::GDBI* gdb) {
44-
using namespace CreateMG;
45-
using namespace CreateMG::Mesh;
46-
MeshSmartIterator miter(mdb);
47-
mdb->get_topo_iterator(TOPO_VERTEX, miter);
48-
int count = 0;
43+
void checkParametrization(apf::Mesh* mesh) {
44+
int count[2] = {0, 0};
4945
double sum = 0.0;
50-
for(mdb->iterator_begin(miter); !mdb->iterator_end(miter); mdb->iterator_next(miter)) {
51-
M_MTopo vert = mdb->iterator_value(miter);
52-
M_GTopo geom;
53-
GeometryTopoType gtype;
54-
mdb->get_geom_entity(vert, gtype, geom);
55-
if (!gdb->is_face(geom)) continue;
56-
double range_u[2];
57-
double range_v[2];
58-
gdb->get_parametrization_range(geom, 0, range_u[0], range_u[1]);
59-
gdb->get_parametrization_range(geom, 1, range_v[0], range_v[1]);
60-
GeometryTopoType gtype1;
61-
double u,v;
62-
mdb->get_vertex_uv_parameters(vert, u, v, gtype1);
63-
PCU_ALWAYS_ASSERT(gtype1 == gtype);
64-
46+
std::cout <<
47+
"ct, ( u, v), ( umin, umax), "
48+
"( vmin, vmax), diff\n";
49+
apf::MeshIterator* it = mesh->begin(0);
50+
for (apf::MeshEntity* vtx; (vtx = mesh->iterate(it));) {
51+
apf::ModelEntity* me = mesh->toModel(vtx);
52+
int dim = mesh->getModelType(me);
53+
if (dim != 1 && dim != 2) continue;
54+
double range_u[2], range_v[2];
55+
mesh->getPeriodicRange(me, 0, range_u);
56+
mesh->getPeriodicRange(me, 1, range_v);
57+
apf::Vector3 xi;
58+
mesh->getParam(vtx, xi);
6559
// coordinate from mesh
6660
apf::Vector3 coord;
67-
mdb->get_vertex_coord(vert, &(coord[0]));
68-
61+
mesh->getPoint(vtx, 0, coord);
6962
// coordinate from surface
70-
vec3d x;
71-
gdb->get_point(geom, vec3d(u, v, 0.0), x);
72-
apf::Vector3 pcoord(x[0], x[1], x[2]);
63+
apf::Vector3 pcoord;
64+
mesh->snapToModel(me, xi, pcoord);
65+
apf::Vector3 diff = coord - pcoord;
7366

74-
if (count < 50) {
75-
std::cout << count << ", "
76-
<< u << ", " << v << ", "
77-
<< range_u[0] << ", " << range_u[1]
78-
<< ", " << range_v[0] << ", " << range_v[1]
79-
<< ", " << (coord - pcoord).getLength() << std::endl;
67+
constexpr int dim_printmax = 25;
68+
if (count[dim - 1] < dim_printmax) {
69+
std::cout << std::setw(2) << count[dim - 1] << ", "
70+
<< std::setprecision(3) << std::scientific
71+
<< '(' << std::setw(8) << xi.x() << ", "
72+
<< std::setw(8) << xi.y() << "), "
73+
<< '(' << std::setw(4) << range_u[0] << ", "
74+
<< std::setw(4) << range_u[1] << "), ";
75+
if (dim == 2)
76+
std::cout << '(' << std::setw(4) << range_v[0] << ", "
77+
<< std::setw(4) << range_v[1] << "), ";
78+
else
79+
std::cout << "----------------------, ";
80+
std::cout << std::setw(4) << std::defaultfloat << diff.getLength()
81+
<< std::endl;
82+
} else if (count[dim - 1] == dim_printmax) {
83+
std::cout << "Skipping printing remaining "
84+
<< (dim == 1 ? "edges" : "faces") << std::endl;
8085
}
81-
sum += (coord-pcoord) * (coord-pcoord);
82-
count++;
86+
sum += diff * diff;
87+
count[dim - 1]++;
8388
}
8489
std::cout << "norm of the difference vector is " << std::sqrt(sum)
8590
<< std::endl;

0 commit comments

Comments
 (0)