Skip to content

Commit 7e54d7f

Browse files
authored
Merge branch 'develop' into pcu-object-breaking
2 parents 0d3aaf9 + 0191626 commit 7e54d7f

File tree

5 files changed

+160
-1
lines changed

5 files changed

+160
-1
lines changed

doc/mylibrary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <apfBox.h>
33
#include <apfMesh2.h>
44
#include <apf.h>
5+
56
void makeMesh(pcu::PCU *PCUObj) {
67
gmi_register_mesh();
78
apf::Mesh2* m = apf::makeMdsBox(1,1,1,1,1,1,0,PCUObj);

test/cap2vtk.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ int main(int argc, char** argv)
132132
gmi_register_cap();
133133

134134
// convert the mesh to apf/mds mesh
135+
135136
apf::Mesh2* mesh = apf::createMesh(m,g,&PCUObj);
136137

137138
apf::writeVtkFiles(folderName, mesh);

test/capCheckParam.cc

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
#include <PCU.h>
2+
#include <queue>
3+
#include <apf.h>
4+
#include <pcu_util.h>
5+
#include <cstdlib>
6+
#include <cstring>
7+
#include <iostream>
8+
#include <iomanip>
9+
#include <vector>
10+
11+
12+
#include "CapstoneModule.h"
13+
#include "CreateMG_Framework_Core.h"
14+
#include "CreateMG_Framework_Analysis.h"
15+
#include "CreateMG_Framework_Application.h"
16+
#include "CreateMG_Framework_Attributes.h"
17+
#include "CreateMG_Framework_Core.h"
18+
#include "CreateMG_Framework_Geometry.h"
19+
#include "CreateMG_Framework_Mesh.h"
20+
21+
using namespace CreateMG;
22+
using namespace CreateMG::Attribution;
23+
using namespace CreateMG::Mesh;
24+
using namespace CreateMG::Geometry;
25+
26+
void checkParametrization(MeshDatabaseInterface* mdb, GeometryDatabaseInterface* gdb);
27+
28+
int main(int argc, char** argv)
29+
{
30+
MPI_Init(&argc, &argv);
31+
PCU_Comm_Init();
32+
33+
if (argc != 2) {
34+
if(0==PCU_Comm_Self())
35+
std::cerr << "usage: " << argv[0]
36+
<< " <cre file .cre>\n";
37+
return EXIT_FAILURE;
38+
}
39+
40+
const char* creFileName = argv[1];
41+
42+
// load capstone mesh
43+
// create an instance of the Capstone Module activating CREATE/CREATE/CREATE
44+
// for the Geometry/Mesh/Attribution databases
45+
/* const std::string gdbName("Geometry Database : Create");// Switch Create with SMLIB for CAD */
46+
const std::string gdbName("Geometry Database : SMLIB");// Switch Create with SMLIB for CAD
47+
const std::string mdbName("Mesh Database : Create");
48+
const std::string adbName("Attribution Database : Create");
49+
50+
CapstoneModule cs("the_module", gdbName.c_str(), mdbName.c_str(), adbName.c_str());
51+
52+
GeometryDatabaseInterface *g = cs.get_geometry();
53+
MeshDatabaseInterface *m = cs.get_mesh();
54+
AppContext *c = cs.get_context();
55+
56+
57+
PCU_ALWAYS_ASSERT(g);
58+
PCU_ALWAYS_ASSERT(m);
59+
PCU_ALWAYS_ASSERT(c);
60+
61+
v_string filenames;
62+
filenames.push_back(creFileName);
63+
64+
M_GModel gmodel = cs.load_files(filenames);
65+
66+
int numbreps = 0;
67+
MG_CALL(g->get_num_breps(numbreps));
68+
std::cout << "number of b reps is " << numbreps << std::endl;
69+
if(numbreps == 0)
70+
error(HERE, ERR_INVALID_INPUT, "Model is empty");
71+
72+
M_MModel mmodel;
73+
// Pick the volume mesh model from associated mesh models to this geom model
74+
std::vector<M_MModel> mmodels;
75+
MG_API_CALL(m, get_associated_mesh_models(gmodel, mmodels));
76+
for(std::size_t i = 0; i < mmodels.size(); ++i)
77+
{
78+
M_MModel ammodel = mmodels[i];
79+
std::size_t numregs = 0;
80+
std::size_t numfaces = 0;
81+
std::size_t numedges = 0;
82+
std::size_t numverts = 0;
83+
MG_API_CALL(m, set_current_model(ammodel));
84+
MG_API_CALL(m, get_num_topos(TOPO_REGION, numregs));
85+
MG_API_CALL(m, get_num_topos(TOPO_FACE, numfaces));
86+
MG_API_CALL(m, get_num_topos(TOPO_EDGE, numedges));
87+
MG_API_CALL(m, get_num_topos(TOPO_VERTEX, numverts));
88+
std::cout << "num regions is " << numregs << std::endl;
89+
std::cout << "num faces is " << numfaces << std::endl;
90+
std::cout << "num edges is " << numedges << std::endl;
91+
std::cout << "num verts is " << numverts << std::endl;
92+
std::cout << "-----------" << std::endl;
93+
if(numregs > 0)
94+
{
95+
mmodel = ammodel;
96+
break;
97+
}
98+
}
99+
100+
/* SET THE ADJACENCIES */
101+
MG_API_CALL(m, set_adjacency_state(REGION2FACE|
102+
REGION2EDGE|
103+
REGION2VERTEX|
104+
FACE2EDGE|
105+
FACE2VERTEX));
106+
MG_API_CALL(m, set_reverse_states());
107+
MG_API_CALL(m, set_adjacency_scope(TOPO_EDGE, SCOPE_FULL));
108+
MG_API_CALL(m, set_adjacency_scope(TOPO_FACE, SCOPE_FULL));
109+
MG_API_CALL(m, compute_adjacency());
110+
111+
112+
// check parametrization using capstone apis
113+
checkParametrization(m, g);
114+
115+
PCU_Comm_Free();
116+
MPI_Finalize();
117+
}
118+
119+
void checkParametrization(MeshDatabaseInterface* mdb, GeometryDatabaseInterface* gdb)
120+
{
121+
MeshSmartIterator miter(mdb);
122+
mdb->get_topo_iterator(TOPO_VERTEX, miter);
123+
int count = 0;
124+
double sum = 0.0;
125+
for(mdb->iterator_begin(miter); !mdb->iterator_end(miter); mdb->iterator_next(miter)) {
126+
M_MTopo vert = mdb->iterator_value(miter);
127+
M_GTopo geom;
128+
GeometryTopoType gtype;
129+
mdb->get_geom_entity(vert, gtype, geom);
130+
if (!gdb->is_face(geom)) continue;
131+
double range_u[2];
132+
double range_v[2];
133+
gdb->get_parametrization_range(geom, 0, range_u[0], range_u[1]);
134+
gdb->get_parametrization_range(geom, 1, range_v[0], range_v[1]);
135+
GeometryTopoType gtype1;
136+
double u,v;
137+
mdb->get_vertex_uv_parameters(vert, u, v, gtype1);
138+
PCU_ALWAYS_ASSERT(gtype1 == gtype);
139+
140+
// coordinate from mesh
141+
apf::Vector3 coord;
142+
mdb->get_vertex_coord(vert, &(coord[0]));
143+
144+
// coordinate from surface
145+
vec3d x;
146+
gdb->get_point(geom, vec3d(u, v, 0.0), x);
147+
apf::Vector3 pcoord(x[0], x[1], x[2]);
148+
149+
if (count < 50)
150+
printf("%d, %e, %e, %e, %e, %e, %e, %e\n", count, u, v, range_u[0], range_u[1], range_v[0], range_v[1], (coord-pcoord).getLength());
151+
sum += (coord-pcoord) * (coord-pcoord);
152+
count++;
153+
}
154+
printf("norm of the difference vector is %e\n", std::sqrt(sum));
155+
}

test/capGeomTest.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@ char const* const typeName[4] =
3939
"region"};
4040

4141
void printInfo(gmi_model* model, int dim);
42+
4243
void visualizeFace(gmi_model* model, gmi_ent* entity, int n, int m, const char* fileName, pcu::PCU *PCUObj);
4344
void visualizeEdge(gmi_model* model, gmi_ent* entity, int n, const char* fileName, pcu::PCU *PCUObj);
4445
void visualizeEdges(gmi_model* model, int n, const char* fileName, pcu::PCU *PCUObj);
4546

4647

48+
4749
int main(int argc, char** argv)
4850
{
4951
MPI_Init(&argc, &argv);

test/convert.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <getopt.h>
2323
#include <string.h>
2424
#include <stdio.h>
25-
#include <array>
25+
#include <array> //std::array
2626

2727
using namespace std;
2828

0 commit comments

Comments
 (0)