本文整理汇总了C++中mesquite::MeshImpl::vertices_get_coordinates方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshImpl::vertices_get_coordinates方法的具体用法?C++ MeshImpl::vertices_get_coordinates怎么用?C++ MeshImpl::vertices_get_coordinates使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesquite::MeshImpl
的用法示例。
在下文中一共展示了MeshImpl::vertices_get_coordinates方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_vertices
void test_vertices()
{
size_t nbVert = mVertices.size();
CPPUNIT_ASSERT_EQUAL(9,(int)nbVert);
Mesquite::MsqVertex correct_coords[9], coords[9];
correct_coords[0].set(1,0,0);
correct_coords[1].set(0,1.732,0);
correct_coords[2].set(-1,0,0);
correct_coords[3].set(-1,-2,0);
correct_coords[4].set(1,-2,0);
correct_coords[5].set(2.732,1,0);
correct_coords[6].set(1.732,2.732,0);
correct_coords[7].set(-1.732,2.732,0);
correct_coords[8].set(-2.732,1,0);
mMesh->vertices_get_coordinates(&mVertices[0], coords, nbVert, mErr);
CPPUNIT_ASSERT(!mErr);
for (size_t i=0; i<nbVert; ++i) {
for (int j=0; j<3; ++j)
CPPUNIT_ASSERT_DOUBLES_EQUAL(coords[i][j], correct_coords[i][j], .01);
}
coords[3].set(2.,3.,4.);
mMesh->vertex_set_coordinates(mVertices[3], coords[3], mErr);
CPPUNIT_ASSERT(!mErr);
Mesquite::MsqVertex coords_2;
mMesh->vertices_get_coordinates(&mVertices[3], &coords_2, 1, mErr);
CPPUNIT_ASSERT(!mErr);
for (int j=0; j<3; ++j)
CPPUNIT_ASSERT_DOUBLES_EQUAL(coords[3][j], coords_2[j], 1e-6);
}
示例2: test_element_get_attached_vertex_indices
void test_element_get_attached_vertex_indices()
{
// Find the index of the triangle
Mesquite::EntityTopology topo=Mesquite::MIXED;
int tri_index = -1;
while (topo != Mesquite::TRIANGLE) {
++tri_index;
CPPUNIT_ASSERT((unsigned)tri_index < mElements.size());
Mesquite::Mesh::ElementHandle handle = mElements[tri_index];
mMesh->elements_get_topologies(&handle, &topo, 1, mErr);
CPPUNIT_ASSERT(!mErr);
}
// creates list with correct vertices coordinates for the triangle
std::vector<Mesquite::Vector3D> correct_coords;
correct_coords.push_back(Mesquite::Vector3D(1.,0.,0.));
correct_coords.push_back(Mesquite::Vector3D(0.,1.732050807,0.));
correct_coords.push_back(Mesquite::Vector3D(-1.,0.,0.));
// Creates same list from the mesh implementation
std::vector<Mesquite::MsqVertex> tri_coords(3);
mMesh->vertices_get_coordinates(&mConnectivity[mOffsets[tri_index]],
&tri_coords[0], 3, mErr );
CPPUNIT_ASSERT(!mErr);
// Makes sure both list contain the same elements (not necessarily in the same order).
std::vector<Mesquite::Vector3D>::iterator correct_iter;
std::vector<Mesquite::MsqVertex>::iterator tri_iter;
for (tri_iter = tri_coords.begin(); tri_iter != tri_coords.end(); ++tri_iter)
{
for (correct_iter = correct_coords.begin();
correct_iter != correct_coords.end();
++correct_iter)
{
if (Mesquite::Vector3D::distance_between(*tri_iter, *correct_iter) < 10e-4)
break;
}
// check if a match was found
CPPUNIT_ASSERT( correct_iter != correct_coords.end() );
// remove match from list
correct_coords.erase( correct_iter );
}
CPPUNIT_ASSERT(correct_coords.empty());
}
示例3: main
int main( int argc, char* argv[] )
{
unsigned i;
const char* input_file = MESH_FILES_DIR "3D/VTK/mixed-hex-pyr-tet.vtk";
if (argc == 2)
input_file = argv[1];
else if (argc != 1)
{
std::cerr << "Invalid arguments.\n";
return 2;
}
Mesquite::MsqPrintError err(cout);
IdealWeightMeanRatio m1;
IdealWeightInverseMeanRatio m2(err);
ConditionNumberQualityMetric m3;
QualityMetric* metrics[] = { &m1, &m2, &m3, 0 };
// Read Mesh
Mesquite::MeshImpl mesh;
mesh.read_vtk(MESH_FILES_DIR "3D/VTK/12-pyramid-unit-sphere.vtk", err);
CPPUNIT_ASSERT(!err);
Mesquite::MeshImpl ideal_mesh;
ideal_mesh.read_vtk(MESH_FILES_DIR "3D/VTK/12-pyramid-unit-sphere.vtk", err);
CPPUNIT_ASSERT(!err);
// Check that the mesh read correctly, and contains what is
// expected later.
// Get mesh data
// Expecting file to contain 12 pyramid elements constructed
// from 15 vertices.
std::vector<Mesh::VertexHandle> vert_array;
std::vector<Mesh::ElementHandle> elem_array;
std::vector<size_t> conn_offsets;
mesh.get_all_elements( elem_array, err );
CPPUNIT_ASSERT(!err);
CPPUNIT_ASSERT( elem_array.size() == 12 );
mesh.elements_get_attached_vertices( &elem_array[0],
elem_array.size(),
vert_array,
conn_offsets,
err );
CPPUNIT_ASSERT(!err);
CPPUNIT_ASSERT(vert_array.size() == 60);
CPPUNIT_ASSERT(conn_offsets.size() == 13);
EntityTopology type_array[12];
mesh.elements_get_topologies( &elem_array[0], type_array, 12, err );
CPPUNIT_ASSERT(!err);
// Verify element types and number of vertices
for (i = 0; i < 12; ++i)
{
CPPUNIT_ASSERT( type_array[i] == PYRAMID );
CPPUNIT_ASSERT( conn_offsets[i] == 5*i );
}
// All pyramids should share a common apex, at the
// center of the sphere
Mesh::VertexHandle apex_handle = vert_array[4];
for (i = 1; i < 12; ++i)
{
CPPUNIT_ASSERT( vert_array[5*i+4] == apex_handle );
}
// Verify that apex is at origin and all other vertices are
// on unit sphere
MsqVertex vertices[60];
mesh.vertices_get_coordinates( &vert_array[0], vertices, 60, err );
CPPUNIT_ASSERT(!err);
for (i = 0; i < 60; ++i)
{
if (vert_array[i] == apex_handle)
CPPUNIT_ASSERT( vertices[i].within_tolerance_box( Vector3D(0,0,0), 1e-6 ) );
else
CPPUNIT_ASSERT( fabs(1.0 - vertices[i].length()) < 1e-6 );
}
// Try smoothing w/out moving the free vertex and verify that
// the smoother didn't move the vertex
Vector3D position(0,0,0);
for (i = 0; metrics[i] != NULL; ++i)
CPPUNIT_ASSERT( !smooth_mesh( &mesh, &ideal_mesh, apex_handle, position, metrics[i] ) );
// Now try moving the vertex and see if the smoother moves it back
// to the origin
position.set( 0.1, 0.1, 0.1 );
for (i = 0; metrics[i] != NULL; ++i)
CPPUNIT_ASSERT( !smooth_mesh( &mesh, &ideal_mesh, apex_handle, position, metrics[i] ) );
// Now try moving the vertex further and see if the smoother moves it back
// to the origin
position.set( 0.3, 0.3, 0.3 );
for (i = 0; metrics[i] != NULL; ++i)
CPPUNIT_ASSERT( !smooth_mesh( &mesh, &ideal_mesh, apex_handle, position, metrics[i] ) );
// Now try smoothing a real mixed mesh
CPPUNIT_ASSERT( !smooth_mixed_mesh( input_file ) );
//.........这里部分代码省略.........
示例4: main
int main(int argc, char* argv[])
{
std::cout << std::endl << "********* Wrappers Timing Tests **********"
<< std::endl << "Version " << version_string(true)
<< std::endl << std::endl;
Mesquite::MsqPrintError err(cout);
Mesquite::MeshImpl mesh;
// #################### Begin ShapeImprover tests ###################
ShapeImprover si_wrapper;
mesh.read_vtk(shape_improv_file_name_1, err);
Timer t;
si_wrapper.run_instructions(&mesh, err);
if (err) return 1;
double si_s_secs = t.since_birth();
std::cout << std::endl << "ShapeImprover small file optimization completed in "
<< si_s_secs << " seconds" << std::endl;
mesh.clear();
mesh.read_vtk(shape_improv_file_name_2, err);
t.reset();
si_wrapper.run_instructions(&mesh, err);
if (err) return 1;
double si_l_secs = t.since_birth();
std::cout << std::endl << "ShapeImprover large file optimization completed in "
<< si_l_secs << " seconds" << std::endl;
// #################### Begin LaplacianWrapper tests ###################
Vector3D pnt1(0,0,5);
Vector3D s_norm(0,0,1);
Mesquite::PlanarDomain msq_geom(s_norm, pnt1);
LaplaceWrapper lp_wrapper;
mesh.clear();
mesh.read_vtk(laplacian_file_name_1, err);
if (err) return 1;
MeshDomainAssoc mesh_and_domain4 = MeshDomainAssoc(&mesh, &msq_geom);
t.reset();
lp_wrapper.run_instructions(&mesh_and_domain4, err);
if (err) return 1;
double lp_s_secs = t.since_birth();
std::cout << std::endl << "LaplacianWrapper small file optimization completed in "
<< lp_s_secs << " seconds" << std::endl;
Vector3D pnt2(0,0,0);
Mesquite::PlanarDomain msq_geom2(s_norm, pnt2);
mesh.clear();
mesh.read_vtk(laplacian_file_name_2, err);
if (err) return 1;
MeshDomainAssoc mesh_and_domain5 = MeshDomainAssoc(&mesh, &msq_geom2);
t.reset();
lp_wrapper.run_instructions(&mesh_and_domain5, err);
if (err) return 1;
double lp_l1_secs = t.since_birth();
std::cout << std::endl << "LaplacianWrapper large file (term crit=0.001) completed in "
<< lp_l1_secs << " seconds" << std::endl;
mesh.clear();
mesh.read_vtk(laplacian_file_name_2, err);
if (err) return 1;
lp_wrapper.set_vertex_movement_limit_factor(0.1);
t.reset();
lp_wrapper.run_instructions(&mesh_and_domain5, err);
if (err) return 1;
double lp_l2_secs = t.since_birth();
std::cout << std::endl << "LaplacianWrapper large file (term crit=0.1) completed in "
<< lp_l2_secs << " seconds" << std::endl;
// #################### Begin UntangleWrapper::BETA tests ###################
mesh.clear();
mesh.read_vtk(untangle_file_name_1, err);
if (err) return 1;
std::vector<Mesh::VertexHandle> verts;
mesh.get_all_vertices( verts, err );
if (err || verts.empty()) return 1;
MsqVertex coords;
mesh.vertices_get_coordinates( arrptr(verts), &coords, 1, err );
if (err) return 1;
Vector3D norm(0,0,1);
PlanarDomain u_domain( norm, coords );
UntangleWrapper::UntangleMetric metric = UntangleWrapper::BETA;
UntangleWrapper un_wrapper (metric);
un_wrapper.set_vertex_movement_limit_factor( 0.005 );
MeshDomainAssoc mesh_and_domain3 = MeshDomainAssoc(&mesh, &u_domain);
//.........这里部分代码省略.........
示例5: main
int main(int argc, char* argv[])
{
Mesquite::MsqPrintError err(cout);
Mesquite::MeshImpl mesh;
//mesh->read_exodus("transformed_mesh.exo", err);
mesh.read_vtk(MESH_FILES_DIR "2D/vtk/quads/untangled/tfi_horse10x4-12.vtk", err);
if (err) return 1;
// Get all vertex coordinates from mesh
std::vector<Mesquite::Mesh::VertexHandle> handles;
mesh.get_all_vertices( handles, err );
if (err) return 1;
if (handles.empty()) {
std::cerr << "No verticies in mesh" << endl;
return 1;
}
std::vector<Mesquite::MsqVertex> coords( handles.size() );
mesh.vertices_get_coordinates( arrptr(handles), arrptr(coords), handles.size(), err );
if (err) return 1;
//create the matrix for affine transformation
double array_entries[9];
array_entries[0]=0; array_entries[1]=1; array_entries[2]=0;
array_entries[3]=1; array_entries[4]=0; array_entries[5]=0;
array_entries[6]=0; array_entries[7]=0; array_entries[8]=1;
//create the translation vector
Matrix3D my_mat(array_entries);
Vector3D my_vec(0, 0 , 10);
MeshTransform my_transform(my_mat, my_vec);
//mesh->write_exodus("original_mesh.exo", err);
MeshDomainAssoc mesh_and_domain = MeshDomainAssoc(&mesh, 0);
my_transform.loop_over_mesh(&mesh_and_domain, 0, err);
if (err) return 1;
//mesh->write_exodus("transformed_mesh.exo", err);
mesh.write_vtk("transformed_mesh.vtk", err);
if (err) return 1;
// Get transformed coordinates
std::vector<Mesquite::MsqVertex> coords2( handles.size() );
mesh.vertices_get_coordinates( arrptr(handles), arrptr(coords2), handles.size(), err );
if (err) return 1;
// Compare vertex coordinates
size_t invalid = 0;
std::vector<Mesquite::MsqVertex>::iterator iter, iter2;
iter = coords.begin();
iter2 = coords2.begin();
for ( ; iter != coords.end(); ++iter, ++iter2 )
{
Mesquite::Vector3D xform = my_mat * *iter + my_vec;
double d = (xform - *iter2).length();
if (d > EPSILON)
++invalid;
}
std::cerr << invalid << " vertices not within " << EPSILON
<< " of expected location" << std::endl;
return (invalid != 0);
}