本文整理汇总了C++中PatchData::get_element_handles_array方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchData::get_element_handles_array方法的具体用法?C++ PatchData::get_element_handles_array怎么用?C++ PatchData::get_element_handles_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchData
的用法示例。
在下文中一共展示了PatchData::get_element_handles_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_weight
double WeightReader::get_weight( PatchData &pd,
size_t element,
Sample sample,
MsqError& err )
{
WeightReaderData& data = get_data( pd );
// calculate index of sample in array
NodeSet all_samples = pd.get_samples( element );
unsigned offset = all_samples.num_before( sample );
if (!data.weights.empty() && data.elementIndex == element) {
assert(offset < data.weights.size());
return data.weights[offset];
}
const unsigned num_samples = all_samples.num_nodes();
const unsigned handle_idx = num_samples - 1;
// get the tag handle
const TagHandle INVALID_HANDLE = (TagHandle)-1;
if (data.handles.size() <= handle_idx)
data.handles.resize( handle_idx + 1, INVALID_HANDLE );
TagHandle& tag_handle = data.handles[handle_idx];
if (tag_handle == INVALID_HANDLE) {
tag_handle = get_tag( pd.get_mesh(),
num_samples,
tagBaseName.c_str(),
err );
MSQ_ERRZERO(err);
assert(tag_handle != INVALID_HANDLE);
}
// get the tag data
data.weights.resize( num_samples );
pd.get_mesh()->tag_get_element_data( tag_handle, 1,
pd.get_element_handles_array() + element,
&data.weights[0],
err );
if (MSQ_CHKERR(err)) {
data.weights.clear();
return false;
}
data.elementIndex = element;
assert(offset < num_samples);
return data.weights[offset];
}
示例2: 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 );
}
示例3: loop_over_mesh
double TargetWriter::loop_over_mesh( MeshDomainAssoc* mesh_and_domain,
const Settings* settings,
MsqError& err )
{
Mesh* mesh = mesh_and_domain->get_mesh();
MeshDomain* domain = mesh_and_domain->get_domain();
PatchData patch;
patch.set_mesh( mesh );
patch.set_domain( domain );
if (settings)
patch.attach_settings( settings );
ElementPatches patch_set;
patch_set.set_mesh( mesh );
std::vector<PatchSet::PatchHandle> patches;
std::vector<PatchSet::PatchHandle>::iterator p;
std::vector<Mesh::VertexHandle> patch_verts;
std::vector<Mesh::ElementHandle> patch_elems;
patch_set.get_patch_handles( patches, err ); MSQ_ERRZERO(err);
std::vector< MsqMatrix<3,3> > targets3d;
std::vector< MsqMatrix<3,2> > targets2dorient;
std::vector< MsqMatrix<2,2> > targets2d;
std::vector< double > weights;
std::vector< Sample > samples;
for (p = patches.begin(); p != patches.end(); ++p)
{
patch_verts.clear();
patch_elems.clear();
patch_set.get_patch( *p, patch_elems, patch_verts, err ); MSQ_ERRZERO(err);
patch.set_mesh_entities( patch_elems, patch_verts, err ); MSQ_ERRZERO(err);
assert(patch.num_elements() == 1);
MsqMeshEntity& elem = patch.element_by_index(0);
EntityTopology type = elem.get_element_type();
patch.get_samples( 0, samples, err ); MSQ_ERRZERO(err);
if (samples.empty())
continue;
if (targetCalc) {
const unsigned dim = TopologyInfo::dimension(type);
if (dim == 3) {
targets3d.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_3D_target( patch, 0, samples[i], targets3d[i], err ); MSQ_ERRZERO(err);
if (DBL_EPSILON > det(targets3d[i])) {
MSQ_SETERR(err)("Inverted 3D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 3, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets3d), err ); MSQ_ERRZERO(err);
}
else if(targetCalc->have_surface_orient()) {
targets2dorient.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_surface_target( patch, 0, samples[i], targets2dorient[i], err ); MSQ_ERRZERO(err);
MsqMatrix<3,1> cross = targets2dorient[i].column(0) * targets2dorient[i].column(1);
if (DBL_EPSILON > (cross%cross)) {
MSQ_SETERR(err)("Degenerate 2D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 2, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets2dorient), err ); MSQ_ERRZERO(err);
}
else {
targets2d.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
targetCalc->get_2D_target( patch, 0, samples[i], targets2d[i], err ); MSQ_ERRZERO(err);
if (DBL_EPSILON > det(targets2d[i])) {
MSQ_SETERR(err)("Degenerate/Inverted 2D target", MsqError::INVALID_ARG);
return 0.0;
}
}
TagHandle tag = get_target_tag( 2, samples.size(), mesh, err ); MSQ_ERRZERO(err);
mesh->tag_set_element_data( tag, 1,
patch.get_element_handles_array(),
arrptr(targets2d), err ); MSQ_ERRZERO(err);
}
}
if (weightCalc) {
weights.resize( samples.size() );
for (unsigned i = 0; i < samples.size(); ++i) {
weights[i] = weightCalc->get_weight( patch, 0, samples[i], err ); MSQ_ERRZERO(err);
}
TagHandle tag = get_weight_tag( samples.size(), mesh, err ); MSQ_ERRZERO(err);
//.........这里部分代码省略.........