本文整理汇总了C++中PatchData::get_vertex_handles_array方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::get_vertex_handles_array方法的具体用法?C++ PatchData::get_vertex_handles_array怎么用?C++ PatchData::get_vertex_handles_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::get_vertex_handles_array方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: optimize_vertex_positions
void TCTFauxOptimizer::optimize_vertex_positions( PatchData& pd, MsqError& err )
{
Mesh::VertexHandle free_vtx = pd.get_vertex_handles_array()[0];
if (visited.insert(free_vtx).second == false) { // already visited this one
// The inner termination criterion should include an iteration limit of 1.
// So if we are seeing the same vertex again, this means that we *should*
// be stating a new pass over the mesh.
// We are presumably starting a new pass over the mesh.
// Verify that we visisted all of the free, non-culled vertices
for (size_t i = 0; i < all.size(); ++i) {
if (culled.find(all[i]) == culled.end()) {
if (visited.find(all[i]) == visited.end()) {
std::ostringstream str;
str << "Did not visit vertex " << i << " (handle " << all[i] << ") in pass " << numPasses << std::endl;
CPPUNIT_FAIL( str.str() );
}
}
}
visited.clear();
visited.insert(free_vtx);
++numPasses;
// Check that we terminate when expected
CPPUNIT_ASSERT(!should_have_terminated());
perturbFrac *= 2; // for each pass, perturb half as many vertices
}
// check that we are not visiting a culled vertex
CPPUNIT_ASSERT( culled.find(free_vtx) == culled.end() );
// for each pass, perturb half as many vertices
size_t idx = std::find( all.begin(), all.end(), free_vtx ) - all.begin();
CPPUNIT_ASSERT( idx < all.size() ); // not a free vertex????
if (0 == ((idx+1) % perturbFrac)) {
// perturb vertex
double sign = numPasses % 2 == 0 ? 1 : -1;
Vector3D delta( sign * mDelta, 0, 0 );
pd.move_vertex( delta, 0, err );
ASSERT_NO_ERROR(err);
// any adjacent vertices should not be culled
for (size_t i = 0; i < pd.num_nodes(); ++i)
culled.erase( pd.get_vertex_handles_array()[i] );
}
else {
// If we're not moving this vertex, then it should get culled
culled.insert( free_vtx );
}
}
示例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: 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);
}
示例4: setUp
void PatchDataTestNormals::setUp()
{
MsqPrintError err(cout);
// Define a mesh on the unit sphere
// Make six quads corresponding to the six faces
// of a cube inscribed in the sphere
const double T = 1.0 / sqrt(3.0);
double ucoords[] = { T, -T, -T,
T, T, -T,
-T, T, -T,
-T, -T, -T,
T, -T, T,
T, T, T,
-T, T, T,
-T, -T, T };
size_t uconn[] = { 3, 2, 1, 0, // -Z face
4, 5, 6, 7, // +Z face
0, 1, 5, 4, // +X face
1, 2, 6, 5, // +Y face
2, 3, 7, 6, // -X face
3, 0, 4, 7 // -Y face
};
unboundedMesh.fill( 8, ucoords, 6, QUADRILATERAL, uconn, 0, err );
CPPUNIT_ASSERT( !err );
unboundedMesh.set_domain( &unboundedDomain );
// Define a mesh on a cylinder with a radius of
// one that is capped at z = +/- 2. Define the
// mesh as the 8 quads defining the sides of a pair of cubes
// stacked axially in the cylinder
const double V = 1.0 / sqrt(2.0);
double bcoords[] = { V, -V, -2,
V, V, -2,
-V, V, -2,
-V, -V, -2,
V, -V, 0,
V, V, 0,
-V, V, 0,
-V, -V, 0,
V, -V, 2,
V, V, 2,
-V, V, 2,
-V, -V, 2};
size_t bconn[] = { // lower cube side faces
0, 1, 5, 4, // +X face
1, 2, 6, 5, // +Y face
2, 3, 7, 6, // -X face
3, 0, 4, 7, // -Y face
// upper cube side faces
4, 5, 9, 8, // +X face
5, 6, 10, 9, // +Y face
6, 7, 11, 10, // -X face
7, 4, 8, 11, // -Y face
};
boundedMesh.fill( 12, bcoords, 8, QUADRILATERAL, bconn, 0, err );
CPPUNIT_ASSERT( !err );
boundedMesh.set_domain( &boundedDomain );
// set element and vertex handles arrays
size_t i = 0;
for (i = 0; i < 12; ++i)
boundedMesh.get_vertex_handles_array()[i] = (Mesh::VertexHandle)i;
for (i = 0; i < 8; ++i)
boundedMesh.get_element_handles_array()[i] = (Mesh::ElementHandle)i;
// Bound the unit cylinder at +/- 1 on the z axis
std::vector<Mesh::VertexHandle> upper_curve(4), lower_curve(4);
for (i = 0; i < 4; ++i)
{
lower_curve[i] = (Mesh::VertexHandle)i;
upper_curve[i] = (Mesh::VertexHandle)(i+8);
}
boundedDomain.create_curve( -2, lower_curve );
boundedDomain.create_curve( 2, upper_curve );
}
示例5: get_weight
double TetDihedralWeight::get_weight( PatchData& pd,
size_t element,
Sample ,
MsqError& err )
{
const double eps = 1e-10;
MsqMeshEntity &elem = pd.element_by_index( element );
if (elem.get_element_type() != TETRAHEDRON) {
MSQ_SETERR(err)(MsqError::UNSUPPORTED_ELEMENT);
return 0.0;
}
const size_t *indices = elem.get_vertex_index_array();
Vector3D v01, v02, v31, v32;
if (refMesh) {
const Mesh::VertexHandle* vtx_hdl = pd.get_vertex_handles_array();
Mesh::VertexHandle handles[] = { vtx_hdl[indices[0]],
vtx_hdl[indices[1]],
vtx_hdl[indices[2]],
vtx_hdl[indices[3]] };
Vector3D coords[4];
refMesh->get_reference_vertex_coordinates( handles, 4, coords, err );
MSQ_ERRZERO(err);
v01 = coords[1] - coords[0];
v02 = coords[2] - coords[0];
v31 = coords[1] - coords[3];
v32 = coords[2] - coords[3];
}
else {
const MsqVertex* coords = pd.get_vertex_array();
v01 = coords[indices[1]] - coords[indices[0]];
v02 = coords[indices[2]] - coords[indices[0]];
v31 = coords[indices[1]] - coords[indices[3]];
v32 = coords[indices[2]] - coords[indices[3]];
}
Vector3D n012 = v02 * v01;
Vector3D n013 = v31 * v01;
Vector3D n023 = v02 * v32;
Vector3D n123 = v31 * v32;
// normalize face vectors.
double l012 = n012.length();
double l013 = n013.length();
double l023 = n023.length();
double l123 = n123.length();
n012 *= (l012 < eps) ? 0.0 : 1.0/l012;
n013 *= (l013 < eps) ? 0.0 : 1.0/l013;
n023 *= (l023 < eps) ? 0.0 : 1.0/l023;
n123 *= (l123 < eps) ? 0.0 : 1.0/l123;
// calculate dihedral handles for each edge
double ds[] = { da(n012 % n013),
da(n012 % n123),
da(n012 % n023),
da(n013 % n023),
da(n013 % n123),
da(n023 % n123) };
// calculate weight from max dihedral handle
double d = *std::max_element( ds, ds+6 );
return 1/(1 + exp(-mA*(d - mCutoff)));
}
示例6: cull_vertices_global
/*!This function is activated when cullingGlobalPatch is true. It supplies
cull_vertices with a single vertex-based patch at a time. If the patch
satisfies the culling criterion, it's free vertices are then soft-fixed.
*/
bool TerminationCriterion::cull_vertices_global(PatchData &global_patch,
Mesh *mesh, MeshDomain *domain, const Settings *settings,
OFEvaluator& of_eval,
MsqError &err)
{
if (!cullingGlobalPatch) return false;
//PRINT_INFO("CULLING_METHOD FLAG = %i",cullingMethodFlag);
//cull_bool will be changed to true if the criterion is satisfied
bool cull_bool=false;
std::vector<Mesh::VertexHandle> mesh_vertices;
//std::vector<Mesh::VertexHandle> patch_vertices;
//std::vector<Mesh::ElementHandle> patch_elements;
//std::vector<Mesh::VertexHandle> fixed_vertices;
//std::vector<Mesh::VertexHandle> free_vertices;
// FIXME, verify global_patch is a global patch... how, is this right?
mesh->get_all_vertices(mesh_vertices, err);
size_t mesh_num_nodes = mesh_vertices.size();
size_t global_patch_num_nodes = global_patch.num_nodes() ;
if (0) std::cout << "tmp srk mesh_num_nodes= " << mesh_num_nodes << " global_patch_num_nodes= "
<< global_patch_num_nodes << std::endl;
if (mesh_num_nodes != global_patch_num_nodes)
{
std::cout << "tmp srk cull_vertices_global found non global patch" << std::endl;
exit(123);
return false;
}
PatchData patch;
patch.set_mesh( (Mesh*) mesh );
patch.set_domain( domain );
patch.attach_settings( settings );
const MsqVertex* global_patch_vertex_array = global_patch.get_vertex_array( err );
Mesh::VertexHandle* global_patch_vertex_handles = global_patch.get_vertex_handles_array();
int num_culled = 0;
for (unsigned iv=0; iv < global_patch_num_nodes; iv++)
{
// form a patch for this vertex; if it is culled, set it to be soft fixed
Mesh::VertexHandle vert = global_patch_vertex_handles[iv];
std::vector<Mesh::ElementHandle> elements;
std::vector<size_t> offsets;
mesh->vertices_get_attached_elements(&vert, 1, elements, offsets, err);
std::set<Mesh::VertexHandle> patch_free_vertices_set;
for (unsigned ie=0; ie < elements.size(); ie++)
{
std::vector<Mesh::VertexHandle> vert_handles;
std::vector<size_t> v_offsets;
mesh->elements_get_attached_vertices(&elements[ie], 1, vert_handles, v_offsets, err);
for (unsigned jv=0; jv < vert_handles.size(); jv++)
{
unsigned char bt;
mesh->vertex_get_byte(vert_handles[jv], &bt, err);
MsqVertex v;
v.set_flags(bt);
if (v.is_free_vertex())
patch_free_vertices_set.insert(vert_handles[jv]);
}
}
std::vector<Mesh::VertexHandle> patch_free_vertices_vector(patch_free_vertices_set.begin(), patch_free_vertices_set.end());
//std::vector<unsigned char> byte_vector(patch_vertices_vector.size());
//mesh->vertices_get_byte(&vert_handles[0], &byte_vector[0], vert_handles.size(), err);
patch.set_mesh_entities( elements, patch_free_vertices_vector, err );
if (cull_vertices(patch, of_eval, err))
{
//std::cout << "tmp srk cull_vertices_global found culled patch" << std::endl;
Mesh::VertexHandle* patch_vertex_handles = patch.get_vertex_handles_array();
const MsqVertex* patch_vertex_array = patch.get_vertex_array( err );
for (unsigned jv=0; jv < patch.num_nodes(); jv++)
{
if (patch_vertex_handles[jv] == global_patch_vertex_handles[iv])
{
if (patch_vertex_array[jv].is_flag_set(MsqVertex::MSQ_CULLED))
{
global_patch.set_vertex_culled(iv);
++num_culled;
cull_bool = true;
//std::cout << "tmp srk cull_vertices_global found culled vertex" << std::endl;
}
}
}
}
}
if (0) std::cout << "tmp srk cull_vertices_global found " << num_culled << " culled vertices out of " << global_patch_num_nodes << std::endl;
return cull_bool;
}