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
1514int 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