本文整理汇总了C++中PatchData::fill_global_patch方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::fill_global_patch方法的具体用法?C++ PatchData::fill_global_patch怎么用?C++ PatchData::fill_global_patch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::fill_global_patch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_gnuplot
void write_gnuplot( Mesh* mesh, const char* out_filebase, MsqError &err)
{
// loads a global patch
PatchData pd;
pd.set_mesh( mesh );
pd.fill_global_patch( err ); MSQ_ERRRTN(err);
write_gnuplot( pd, out_filebase, err );
}
示例2: check_global_patch_slaved
int check_global_patch_slaved( Mesh& mesh, MsqError& err )
{
Settings s;
s.set_slaved_ho_node_mode( Settings::SLAVE_FLAG );
MeshDomainAssoc mesh_and_domain = MeshDomainAssoc(&mesh, 0);
Instruction::initialize_vertex_byte( &mesh_and_domain, &s, err ); MSQ_ERRZERO(err);
PatchData pd;
pd.attach_settings( &s );
pd.set_mesh( &mesh );
pd.fill_global_patch( err ); MSQ_ERRZERO(err);
std::vector<bool> fixed, slaved;
mesh.vertices_get_fixed_flag( pd.get_vertex_handles_array(),
fixed, pd.num_nodes(), err );
MSQ_ERRZERO(err);
mesh.vertices_get_slaved_flag( pd.get_vertex_handles_array(),
slaved, pd.num_nodes(), err );
MSQ_ERRZERO(err);
const size_t first_free = 0;
const size_t first_slaved = pd.num_free_vertices();
const size_t first_fixed = pd.num_free_vertices() + pd.num_slave_vertices();
int error_count = 0;
for (size_t i = first_free; i < first_slaved; ++i) {
if (fixed[i]) {
std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
<< " is fixed in mesh but free in PatchData" << std::endl;
++error_count;
}
if (slaved[i]) {
std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
<< " is slaved in mesh but free in PatchData" << std::endl;
++error_count;
}
}
for (size_t i = first_slaved; i < first_fixed; ++i) {
if (fixed[i]) {
std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
<< " is fixed in mesh but slaved in PatchData" << std::endl;
++error_count;
}
else if (!slaved[i]) {
std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
<< " is free in Mesh but slaved in PatchData" << std::endl;
++error_count;
}
}
for (size_t i = first_fixed; i < pd.num_nodes(); ++i) {
if (!fixed[i]) {
std::cerr << "Vertex " << (size_t)pd.get_vertex_handles_array()[i]
<< " is not fixed in mesh but is in PatchData" << std::endl;
++error_count;
}
}
return 0 == error_count;
}
示例3: write_svg
void write_svg( Mesh* mesh,
const char* filename,
Projection proj,
MsqError& err )
{
// Get a global patch
PatchData pd;
pd.set_mesh( mesh );
pd.fill_global_patch( err ); MSQ_ERRRTN(err);
Transform2D transf( &pd, proj, 400, 400, true );
// Open the file
ofstream file(filename);
if (!file)
{
MSQ_SETERR(err)(MsqError::FILE_ACCESS);
return;
}
// Write header
file << "<?xml version=\"1.0\" standalone=\"no\"?>" << endl;
file << "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" "
<< "\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">" << endl;
file << endl;
file << "<svg width=\"" << transf.max_horizontal()
<< "\" height=\"" << transf.max_vertical()
<< "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">" << endl;
// Write mesh edges
EdgeIterator iter( &pd, err ); MSQ_ERRRTN(err);
while( !iter.is_at_end() )
{
int s_w, s_h, e_w, e_h;
transf.transform( iter.start(), s_w, s_h );
transf.transform( iter.end (), e_w, e_h );
file << "<line "
<< "x1=\"" << s_w << "\" "
<< "y1=\"" << s_h << "\" "
<< "x2=\"" << e_w << "\" "
<< "y2=\"" << e_h << "\" "
<< " style=\"stroke:rgb(99,99,99);stroke-width:2\""
<< "/>" << endl;
iter.step( err ); MSQ_ERRRTN(err);
}
// Write footer
file << "</svg>" << endl;
}
示例4: tag_patch_slaved
void tag_patch_slaved( Mesh& mesh,
Settings::HigherOrderSlaveMode mode,
MsqError& err )
{
int zero = 0;
TagHandle tag = mesh.tag_create( "pd_slaved", Mesh::INT, 1, &zero, err );
MSQ_ERRRTN(err);
Settings s;
s.set_slaved_ho_node_mode( mode );
PatchData pd;
pd.attach_settings( &s );
pd.set_mesh( &mesh );
pd.fill_global_patch( err );
MSQ_ERRRTN(err);
const Mesh::VertexHandle* verts = pd.get_vertex_handles_array() + pd.num_free_vertices();
std::vector<int> ones( pd.num_slave_vertices(), 1 );
mesh.tag_set_vertex_data( tag, pd.num_slave_vertices(), verts, arrptr(ones), err );
MSQ_ERRRTN(err);
}
示例5: test_absolute_vertex_movement_edge_length
void TerminationCriterionTest::test_absolute_vertex_movement_edge_length()
{
MsqPrintError err(std::cout);
// define two-tet mesh where tets share a face
double coords[] = { 0, -5, 0,
0, 5, 0,
1, 0, 0,
0, 0, 0,
0, 0, 1 };
const unsigned long conn[] = { 4, 3, 2, 0,
2, 3, 4, 1 };
int fixed[5] = {0};
ArrayMesh mesh( 3, 5, coords, fixed, 2, TETRAHEDRON, conn );
// calculate beta
const double LIMIT = 1e-4; // desired absolute limit
MeshUtil tool(&mesh);
SimpleStats len;
tool.edge_length_distribution( len, err );
ASSERT_NO_ERROR(err);
const double beta = LIMIT / (len.average() - len.standard_deviation());
// initialize termination criterion
TerminationCriterion tc;
tc.add_absolute_vertex_movement_edge_length( beta );
MeshDomainAssoc mesh_and_domain2 = MeshDomainAssoc(&mesh, 0);
tc.initialize_queue( &mesh_and_domain2, 0, err ); ASSERT_NO_ERROR(err);
// get a patch data
PatchData pd;
pd.set_mesh( &mesh );
pd.fill_global_patch( err ); ASSERT_NO_ERROR(err);
// test termination criteiorn
tc.reset_inner( pd, ofEval, err );
ASSERT_NO_ERROR(err);
tc.reset_patch( pd, err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT(!tc.terminate());
const double FIRST_STEP=10.0;
// move a vertex by 10 units and check that it did not meet criterion
pd.move_vertex( Vector3D(FIRST_STEP,0,0), 0, err );
ASSERT_NO_ERROR(err);
tc.accumulate_inner( pd, 0.0, 0, err );
ASSERT_NO_ERROR(err);
tc.accumulate_patch( pd, err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT(!tc.terminate());
double test_limit = LIMIT;
int idx = 0;
for (double step = FIRST_STEP; step > test_limit; step *= 0.09) {
idx = (idx + 1) % pd.num_free_vertices();
pd.move_vertex( Vector3D(step,0,0), idx, err );
ASSERT_NO_ERROR(err);
tc.accumulate_inner( pd, 0.0, 0, err );
ASSERT_NO_ERROR(err);
tc.accumulate_patch( pd, err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT(!tc.terminate());
}
idx = (idx + 1) % pd.num_free_vertices();
pd.move_vertex( Vector3D(0.5*test_limit,0,0), idx, err );
ASSERT_NO_ERROR(err);
tc.accumulate_inner( pd, 0.0, 0, err );
ASSERT_NO_ERROR(err);
tc.accumulate_patch( pd, err );
ASSERT_NO_ERROR(err);
CPPUNIT_ASSERT(tc.terminate());
}
示例6: write_eps
void write_eps( Mesh* mesh,
const char* filename,
Projection proj,
MsqError& err,
int width, int height )
{
// Get a global patch
PatchData pd;
pd.set_mesh( mesh );
pd.fill_global_patch( err ); MSQ_ERRRTN(err);
Transform2D transf( &pd, proj, width, height, false );
// Open the file
ofstream s(filename);
if (!s)
{
MSQ_SETERR(err)(MsqError::FILE_ACCESS);
return;
}
// Write header
s << "%!PS-Adobe-2.0 EPSF-2.0" << endl;
s << "%%Creator: Mesquite" << endl;
s << "%%Title: Mesquite " << endl;
s << "%%DocumentData: Clean7Bit" << endl;
s << "%%Origin: 0 0" << endl;
s << "%%BoundingBox: 0 0 "
<< transf.max_horizontal() << ' '
<< transf.max_vertical() << endl;
s << "%%Pages: 1" << endl;
s << "%%BeginProlog" << endl;
s << "save" << endl;
s << "countdictstack" << endl;
s << "mark" << endl;
s << "newpath" << endl;
s << "/showpage {} def" << endl;
s << "/setpagedevice {pop} def" << endl;
s << "%%EndProlog" << endl;
s << "%%Page: 1 1" << endl;
s << "1 setlinewidth" << endl;
s << "0.0 setgray" << endl;
// Write mesh edges
EdgeIterator iter( &pd, err ); MSQ_ERRRTN(err);
while( !iter.is_at_end() )
{
int s_w, s_h, e_w, e_h;
transf.transform( iter.start(), s_w, s_h );
transf.transform( iter.end (), e_w, e_h );
s << "newpath" << endl;
s << s_w << ' ' << s_h << " moveto" << endl;
if (!iter.mid()) {
s << e_w << ' ' << e_h << " lineto" << endl;
}
else {
write_eps_quadratic_edge( s, transf, iter.start(), *iter.mid(), iter.end() );
// draw rings at mid-edge node location
//transf.transform( *(iter.mid()), w1, h1 );
//s << w1+2 << ' ' << h1 << " moveto" << endl;
//s << w1 << ' ' << h1 << " 2 0 360 arc" << endl;
}
s << "stroke" << endl;
iter.step(err); MSQ_ERRRTN(err);
}
// Write footer
s << "%%Trailer" << endl;
s << "cleartomark" << endl;
s << "countdictstack" << endl;
s << "exch sub { end } repeat" << endl;
s << "restore" << endl;
s << "%%EOF" << endl;
}