本文整理汇总了C++中BoundBox::update方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundBox::update方法的具体用法?C++ BoundBox::update怎么用?C++ BoundBox::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundBox
的用法示例。
在下文中一共展示了BoundBox::update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetGlobalBox
//Determine the global assembly box
ErrorCode ParallelMergeMesh::GetGlobalBox(double *gbox)
{
ErrorCode rval;
/*Get Bounding Box*/
BoundBox box;
if(mySkinEnts[0].size() != 0){
rval = box.update(*myMB, mySkinEnts[0]);MB_CHK_ERR(rval);
}
//Invert the max
box.bMax *= -1;
/*Communicate to all processors*/
MPI_Allreduce(&box, gbox, 6, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
/*Assemble Global Bounding Box*/
//Flip the max back
for(int i=3; i<6; i++){
gbox[i] *= -1;
}
return MB_SUCCESS;
}
示例2: update
ErrorCode BoundBox::update(Interface &iface, const Range& elems)
{
ErrorCode rval;
bMin = CartVect(HUGE_VAL);
bMax = CartVect(-HUGE_VAL);
CartVect coords;
EntityHandle const *conn, *conn2;
int len, len2;
Range::const_iterator i;
// vertices
const Range::const_iterator elem_begin = elems.lower_bound( MBEDGE );
for (i = elems.begin(); i != elem_begin; ++i) {
rval = iface.get_coords( &*i, 1, coords.array() );
if (MB_SUCCESS != rval)
return rval;
update_min(coords.array());
update_max(coords.array());
}
// elements with vertex-handle connectivity list
const Range::const_iterator poly_begin = elems.lower_bound( MBPOLYHEDRON, elem_begin );
std::vector<EntityHandle> dum_vector;
for (i = elem_begin; i != poly_begin; ++i) {
rval = iface.get_connectivity( *i, conn, len, true, &dum_vector);
if (MB_SUCCESS != rval)
return rval;
for (int j = 0; j < len; ++j) {
rval = iface.get_coords( conn+j, 1, coords.array() );
if (MB_SUCCESS != rval)
return rval;
update_min(coords.array());
update_max(coords.array());
}
}
// polyhedra
const Range::const_iterator set_begin = elems.lower_bound( MBENTITYSET, poly_begin );
for (i = poly_begin; i != set_begin; ++i) {
rval = iface.get_connectivity( *i, conn, len, true );
if (MB_SUCCESS != rval)
return rval;
for (int j = 0; j < len; ++j) {
rval = iface.get_connectivity( conn[j], conn2, len2 );
for (int k = 0; k < len2; ++k) {
rval = iface.get_coords( conn2+k, 1, coords.array() );
if (MB_SUCCESS != rval)
return rval;
update_min(coords.array());
update_max(coords.array());
}
}
}
// sets
BoundBox box;
for (i = set_begin; i != elems.end(); ++i) {
Range tmp_elems;
rval = iface.get_entities_by_handle(*i, tmp_elems);
if (MB_SUCCESS != rval) return rval;
rval = box.update(iface, tmp_elems);
if (MB_SUCCESS != rval) return rval;
update(box);
}
return MB_SUCCESS;
}
示例3: deform_master
ErrorCode DeformMeshRemap::deform_master(Range &fluid_elems, Range &solid_elems, const char *tag_name)
{
// Deform elements with an analytic function
ErrorCode rval;
// Get all the vertices and coords in the solid
Range solid_verts, fluid_verts;
rval = mbImpl->get_adjacencies(solid_elems, 0, false, solid_verts, Interface::UNION);MB_CHK_SET_ERR(rval, "Failed to get vertices");
vector<double> coords(3*solid_verts.size()), new_coords(3*solid_verts.size());
rval = mbImpl->get_coords(solid_verts, &coords[0]);MB_CHK_SET_ERR(rval, "Failed to get vertex coords");
unsigned int num_verts = solid_verts.size();
// Get or create the tag
if (!xDispNames[0].empty() && !xDispNames[1].empty() && !xDispNames[2].empty()) {
// 3 tags, specifying xyz individual data, integrate into one tag
rval = mbImpl->tag_get_handle((tag_name ? tag_name : ""), 3, MB_TYPE_DOUBLE,
xNew, MB_TAG_CREAT | MB_TAG_DENSE);MB_CHK_SET_ERR(rval, "Failed to create xnew tag");
vector<double> disps(num_verts);
for (int i = 0; i < 3; i++) {
rval = mbImpl->tag_get_handle(xDispNames[0].c_str(), 1, MB_TYPE_DOUBLE, xDisp[i]);MB_CHK_SET_ERR(rval, "Failed to get xDisp tag");
rval = mbImpl->tag_get_data(xDisp[i], solid_verts, &disps[0]);MB_CHK_SET_ERR(rval, "Failed to get xDisp tag values");
for (unsigned int j = 0; j < num_verts; j++)
new_coords[3*j+i] = coords[3*j+i] + disps[j];
}
}
else if (!xDispNames[0].empty()) {
rval = mbImpl->tag_get_handle(xDispNames[0].c_str(), 3, MB_TYPE_DOUBLE, xDisp[0]);MB_CHK_SET_ERR(rval, "Failed to get first xDisp tag");
xNew = xDisp[0];
vector<double> disps(3*num_verts);
rval = mbImpl->tag_get_data(xDisp[0], solid_verts, &disps[0]);
for (unsigned int j = 0; j < 3*num_verts; j++)
new_coords[j] = coords[j] + disps[j];
}
else {
// Get the bounding box of the solid mesh
BoundBox bbox;
bbox.update(*mbImpl, solid_elems);
for (unsigned int j = 0; j < num_verts; j++)
deform_func(bbox, &coords[3*j], &new_coords[3*j]);
}
if (debug) {
double len = 0.0;
for (unsigned int i = 0; i < num_verts; i++) {
CartVect dx = CartVect(&new_coords[3*i]) - CartVect(&coords[3*i]);
double tmp_len = dx.length_squared();
if (tmp_len > len) len = tmp_len;
}
Range tmp_elems(fluid_elems);
tmp_elems.merge(solid_elems);
BoundBox box;
box.update(*mbImpl, tmp_elems);
double max_len = std::max(box.bMax[2] - box.bMin[2], std::max(box.bMax[1] - box.bMin[1], box.bMax[0] - box.bMin[0]));
cout << "Max displacement = " << len << " (" << 100.0 * len / max_len << "% of max box length)" << endl;
}
if (!xNew) {
rval = mbImpl->tag_get_handle((tag_name ? tag_name : ""), 3, MB_TYPE_DOUBLE,
xDisp[0], MB_TAG_CREAT|MB_TAG_DENSE);MB_CHK_SET_ERR(rval, "Failed to get xNew tag");
xNew = xDisp[0];
}
// Set the new tag to those coords
rval = mbImpl->tag_set_data(xNew, solid_verts, &new_coords[0]);MB_CHK_SET_ERR(rval, "Failed to set tag data");
// Get all the vertices and coords in the fluid, set xnew to them
rval = mbImpl->get_adjacencies(fluid_elems, 0, false, fluid_verts, Interface::UNION);MB_CHK_SET_ERR(rval, "Failed to get vertices");
fluid_verts = subtract(fluid_verts, solid_verts);
if (coords.size() < 3*fluid_verts.size()) coords.resize(3*fluid_verts.size());
rval = mbImpl->get_coords(fluid_verts, &coords[0]);MB_CHK_SET_ERR(rval, "Failed to get vertex coords");
rval = mbImpl->tag_set_data(xNew, fluid_verts, &coords[0]);MB_CHK_SET_ERR(rval, "Failed to set xnew tag on fluid verts");
if (debug) {
// Save deformed mesh coords to new file for visualizing
Range tmp_range(fluidElems[MASTER]);
tmp_range.merge(solidElems[MASTER]);
rval = write_and_save(tmp_range, masterSet, xNew, "deformed_master.h5m", true);MB_CHK_ERR(rval);
}
return MB_SUCCESS;
}