MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <SphericalDomain.hpp>
Public Member Functions | |
SphericalDomain (const Vector3D &p_center, double p_radius) | |
SphericalDomain () | |
virtual | ~SphericalDomain () |
void | set_sphere (const Vector3D &p_center, double p_radius) |
void | fit_vertices (Mesh *mesh, MsqError &err, double epsilon=0.0) |
void | fit_vertices (Mesh *mesh, const Mesh::VertexHandle *vertex_array, size_t vertex_array_length, MsqError &err, double epsilon=0.0) |
virtual void | snap_to (Mesh::VertexHandle entity_handle, Vector3D &coordinate) const |
virtual void | vertex_normal_at (Mesh::VertexHandle entity_handle, Vector3D &coordinate) const |
virtual void | element_normal_at (Mesh::ElementHandle entity_handle, Vector3D &coordinate) const |
virtual void | vertex_normal_at (const Mesh::VertexHandle *handle, Vector3D coords[], unsigned count, MsqError &err) const |
evaluate surface normals | |
virtual void | closest_point (Mesh::VertexHandle handle, const Vector3D &position, Vector3D &closest, Vector3D &normal, MsqError &err) const |
evaluate closest point and normal | |
virtual void | domain_DoF (const Mesh::VertexHandle *handle_array, unsigned short *dof_array, size_t num_vertices, MsqError &err) const |
Vector3D | center () const |
double | radius () const |
Private Attributes | |
Vector3D | mCenter |
double | mRadius |
This is a template for a spherical domain. It will provide the normal information necessary for surface mesh optimization.
Definition at line 48 of file SphericalDomain.hpp.
MBMesquite::SphericalDomain::SphericalDomain | ( | const Vector3D & | p_center, |
double | p_radius | ||
) | [inline] |
Definition at line 51 of file SphericalDomain.hpp.
MBMesquite::SphericalDomain::SphericalDomain | ( | ) | [inline] |
Definition at line 53 of file SphericalDomain.hpp.
{}
MBMesquite::SphericalDomain::~SphericalDomain | ( | ) | [virtual] |
Definition at line 43 of file SphericalDomain.cpp.
{}
Vector3D MBMesquite::SphericalDomain::center | ( | ) | const [inline] |
Definition at line 93 of file SphericalDomain.hpp.
Referenced by SphericalDomainTest::check_closest_pt(), SphericalDomainTest::check_normal(), SphericalDomainTest::test_construct(), and SphericalDomainTest::test_fit_vertices().
{ return mCenter; }
void MBMesquite::SphericalDomain::closest_point | ( | Mesh::VertexHandle | handle, |
const Vector3D & | position, | ||
Vector3D & | closest, | ||
Vector3D & | normal, | ||
MsqError & | err | ||
) | const [virtual] |
evaluate closest point and normal
Given a position in space, return the closest position in the domain and the domain normal at that point.
entity_handle | Evaluate the subset of the domain contianing this entity |
position | Input position for which to evaluate |
closest | Closest position in the domain. |
normal | Domain normal at the location of 'closest' |
Implements MBMesquite::MeshDomain.
Definition at line 85 of file SphericalDomain.cpp.
References moab::Util::is_finite(), MBMesquite::Vector3D::normalize(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().
Referenced by SphericalDomainTest::test_closest_point().
void MBMesquite::SphericalDomain::domain_DoF | ( | const Mesh::VertexHandle * | handle_array, |
unsigned short * | dof_array, | ||
size_t | num_vertices, | ||
MsqError & | err | ||
) | const [virtual] |
Definition at line 97 of file SphericalDomain.cpp.
{ std::fill( dof_array, dof_array + num_vertices, 2 ); }
void MBMesquite::SphericalDomain::element_normal_at | ( | Mesh::ElementHandle | entity_handle, |
Vector3D & | coordinate | ||
) | const [virtual] |
Implements MBMesquite::MeshDomain.
Definition at line 71 of file SphericalDomain.cpp.
References vertex_normal_at().
Referenced by SphericalDomainTest::test_normal_at().
{ SphericalDomain::vertex_normal_at( h, coordinate ); }
void MBMesquite::SphericalDomain::fit_vertices | ( | Mesh * | mesh, |
MsqError & | err, | ||
double | epsilon = 0.0 |
||
) |
Definition at line 105 of file SphericalDomain.cpp.
References MBMesquite::arrptr(), epsilon, MBMesquite::Mesh::get_all_vertices(), and MSQ_CHKERR.
Referenced by SphericalDomainTest::test_fit_vertices().
{ std::vector< Mesh::VertexHandle > verts; mesh->get_all_vertices( verts, err ); if( !MSQ_CHKERR( err ) ) fit_vertices( mesh, arrptr( verts ), verts.size(), err, epsilon ); }
void MBMesquite::SphericalDomain::fit_vertices | ( | Mesh * | mesh, |
const Mesh::VertexHandle * | vertex_array, | ||
size_t | vertex_array_length, | ||
MsqError & | err, | ||
double | epsilon = 0.0 |
||
) |
Definition at line 112 of file SphericalDomain.cpp.
References MBMesquite::arrptr(), MBMesquite::DomainUtil::default_tolerance(), MBMesquite::det(), MBMesquite::MsqError::INVALID_MESH, MSQ_ERRRTN, MSQ_SETERR, MBMesquite::DomainUtil::non_coplanar_vertices(), and MBMesquite::Mesh::vertices_get_coordinates().
{ std::vector< MsqVertex > coords( num_verts ); mesh->vertices_get_coordinates( verts, arrptr( coords ), num_verts, err );MSQ_ERRRTN( err ); if( epsilon <= 0.0 ) epsilon = DomainUtil::default_tolerance( arrptr( coords ), num_verts ); Vector3D pts[4]; if( !DomainUtil::non_coplanar_vertices( arrptr( coords ), num_verts, pts, epsilon ) ) { MSQ_SETERR( err )( "All vertices are co-planar", MsqError::INVALID_MESH ); return; } // solve deterinant form of four-point sphere // Define the bottom 4 rows of a 5x5 matrix. The top // row contains the variables we are solving for, so just // fill it with ones. const double M_vals[25] = { 1, 1, 1, 1, 1, pts[0] % pts[0], pts[0][0], pts[0][1], pts[0][2], 1, pts[1] % pts[1], pts[1][0], pts[1][1], pts[1][2], 1, pts[2] % pts[2], pts[2][0], pts[2][1], pts[2][2], 1, pts[3] % pts[3], pts[3][0], pts[3][1], pts[3][2], 1 }; MsqMatrix< 5, 5 > M( M_vals ); double M11 = det( MsqMatrix< 4, 4 >( M, 0, 0 ) ); double M12 = det( MsqMatrix< 4, 4 >( M, 0, 1 ) ); double M13 = det( MsqMatrix< 4, 4 >( M, 0, 2 ) ); double M14 = det( MsqMatrix< 4, 4 >( M, 0, 3 ) ); double M15 = det( MsqMatrix< 4, 4 >( M, 0, 4 ) ); // define the sphere Vector3D cent( 0.5 * M12 / M11, -0.5 * M13 / M11, 0.5 * M14 / M11 ); this->set_sphere( cent, sqrt( cent % cent - M15 / M11 ) ); }
double MBMesquite::SphericalDomain::radius | ( | ) | const [inline] |
Definition at line 97 of file SphericalDomain.hpp.
Referenced by SphericalDomainTest::check_closest_pt(), SphericalDomainTest::test_construct(), and SphericalDomainTest::test_fit_vertices().
{ return mRadius; }
void MBMesquite::SphericalDomain::set_sphere | ( | const Vector3D & | p_center, |
double | p_radius | ||
) | [inline] |
Definition at line 57 of file SphericalDomain.hpp.
Referenced by SphericalDomainTest::test_construct().
void MBMesquite::SphericalDomain::snap_to | ( | Mesh::VertexHandle | entity_handle, |
Vector3D & | coordinate | ||
) | const [virtual] |
Modifies "coordinate" so that it lies on the domain to which "entity_handle" is constrained. The handle determines the domain. The coordinate is the proposed new position on that domain.
Implements MBMesquite::MeshDomain.
Definition at line 45 of file SphericalDomain.cpp.
References moab::Util::is_finite(), MBMesquite::Vector3D::length(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().
Referenced by SphericalDomainTest::test_snap_to().
{ // Get vector center to coordinate, store in coordinate. coordinate -= mCenter; // Get distance from center of sphere double len = coordinate.length(); // Scale vector to have length of radius coordinate *= mRadius / len; // If was at center, return arbitrary position on sphere // (all possitions are equally close) if( !moab::Util::is_finite( coordinate.x() ) ) coordinate.set( mRadius, 0.0, 0.0 ); // Get position from vector coordinate += mCenter; }
void MBMesquite::SphericalDomain::vertex_normal_at | ( | Mesh::VertexHandle | entity_handle, |
Vector3D & | coordinate | ||
) | const [virtual] |
Returns the normal of the domain to which "entity_handle" is constrained. For non-planar surfaces, the normal is calculated at the point on the domain that is closest to the passed in value of "coordinate". If the domain does not have a normal, or the normal cannot be determined, "coordinate" is set to (0,0,0). Otherwise, "coordinate" is set to the domain's normal at the appropriate point. In summary, the handle determines the domain. The coordinate determines the point of interest on that domain.
User should see also PatchData::get_domain_normal_at_vertex and PatchData::get_domain_normal_at_element .
Implements MBMesquite::MeshDomain.
Definition at line 60 of file SphericalDomain.cpp.
References moab::Util::is_finite(), MBMesquite::Vector3D::length(), MBMesquite::length(), MBMesquite::Vector3D::set(), and MBMesquite::Vector3D::x().
Referenced by element_normal_at(), and SphericalDomainTest::test_normal_at().
{ // normal is vector from center to input position coordinate -= mCenter; // make it a unit vector double length = coordinate.length(); coordinate /= length; // if input position was at center, choose same position // on sphere as snap_to. if( !moab::Util::is_finite( coordinate.x() ) ) coordinate.set( 1.0, 0.0, 0.0 ); }
void MBMesquite::SphericalDomain::vertex_normal_at | ( | const Mesh::VertexHandle * | handles, |
Vector3D | coordinates[], | ||
unsigned | count, | ||
MsqError & | err | ||
) | const [virtual] |
evaluate surface normals
Returns normals for a domain.
handles | The domain evaluated is the one in which this mesh entity is constrained. |
coordinates | As input, a list of positions at which to evaluate the domain. As output, the resulting domain normals. |
count | The length of the coordinates array. |
Implements MBMesquite::MeshDomain.
Definition at line 76 of file SphericalDomain.cpp.
{ for( unsigned i = 0; i < count; ++i ) vertex_normal_at( handle[i], coords[i] ); }
Vector3D MBMesquite::SphericalDomain::mCenter [private] |
Definition at line 103 of file SphericalDomain.hpp.
double MBMesquite::SphericalDomain::mRadius [private] |
Definition at line 104 of file SphericalDomain.hpp.