48 #ifdef MSQ_USE_OLD_STD_HEADERS
55 #ifdef MSQ_USE_OLD_IO_HEADERS
72 vertices.resize( vertex_count() );
73 memcpy( &vertices[0], vertexIndices, vertex_count() *
sizeof(
size_t) );
85 vertex_list.insert(vertex_list.end(),
87 vertexIndices + vertex_count());
110 for (
size_t i=0;
i<nve; ++
i)
121 short &num_jacobian_vectors,
125 const size_t* v_v = &vertexIndices[0];
134 jacobian_vectors[0].
set(vertices[v_v[1]]-vertices[v_v[0]]);
135 jacobian_vectors[1].
set((2.0*vertices[v_v[2]]-vertices[v_v[0]]-
137 num_jacobian_vectors=2;
141 jacobian_vectors[0]=(vertices[v_v[1]]-vertices[v_v[0]]+sample_point[1]*
142 (vertices[v_v[2]]+vertices[v_v[0]]-vertices[v_v[3]]-
144 jacobian_vectors[1]=(vertices[v_v[3]]-vertices[v_v[0]]+sample_point[0]*
145 (vertices[v_v[2]]+vertices[v_v[0]]-vertices[v_v[3]]-
147 num_jacobian_vectors=2;
151 jacobian_vectors[0]=vertices[v_v[1]]-vertices[v_v[0]];
152 jacobian_vectors[1]=(2.0*vertices[v_v[2]]-vertices[v_v[0]]-
153 vertices[v_v[1]])*MSQ_SQRT_THREE_INV;
154 jacobian_vectors[2]=(3.0*vertices[v_v[3]]-vertices[v_v[2]]-
155 vertices[v_v[1]]-vertices[v_v[0]])*
157 num_jacobian_vectors=3;
162 jacobian_vectors[0]=vertices[v_v[1]]-vertices[v_v[0]]+
163 (sample_point[1]*(vertices[v_v[2]]+vertices[v_v[0]]-
164 vertices[v_v[3]]-vertices[v_v[1]]))+
165 (sample_point[2]*(vertices[v_v[5]]+vertices[v_v[0]]-
166 vertices[v_v[4]]-vertices[v_v[1]]))+
167 (sample_point[1]*sample_point[2]*(vertices[v_v[6]]+
175 jacobian_vectors[1]=vertices[v_v[3]]-vertices[v_v[0]]+
176 (sample_point[0]*(vertices[v_v[2]]+vertices[v_v[0]]-
177 vertices[v_v[3]]-vertices[v_v[1]]))+
178 (sample_point[2]*(vertices[v_v[7]]+vertices[v_v[0]]-
179 vertices[v_v[4]]-vertices[v_v[3]]))+
180 (sample_point[0]*sample_point[2]*(vertices[v_v[6]]+
189 jacobian_vectors[2]=vertices[v_v[4]]-vertices[v_v[0]]+
190 (sample_point[0]*(vertices[v_v[5]]+vertices[v_v[0]]-
191 vertices[v_v[4]]-vertices[v_v[1]]))+
192 (sample_point[1]*(vertices[v_v[7]]+vertices[v_v[0]]-
193 vertices[v_v[4]]-vertices[v_v[3]]))+
194 (sample_point[0]*sample_point[1]*(vertices[v_v[6]]+
203 num_jacobian_vectors=3;
208 "Compute_weighted_jacobian not yet defined for this entity.",
223 vector<Vector3D> &coords,
232 coords.push_back(
Vector3D(0.0, 0.0, 0.0));
233 coords.push_back(
Vector3D(1.0, 0.0, 0.0));
245 coords.push_back(
Vector3D(0.5, 0.0, 0.0));
262 MSQ_SETERR(err)(
"Requested Sample Point Mode not implemented",
273 coords.push_back(
Vector3D(0.0, 0.0, 0.0));
274 coords.push_back(
Vector3D(1.0, 0.0, 0.0));
275 coords.push_back(
Vector3D(1.0, 1.0, 0.0));
276 coords.push_back(
Vector3D(0.0, 1.0, 0.0));
280 coords.push_back(
Vector3D(0.5, 0.5, 0.0));
286 MSQ_SETERR(err)(
"Requested Sample Point Mode not implemented",
297 coords.push_back(
Vector3D(0.0, 0.0, 0.0));
298 coords.push_back(
Vector3D(1.0, 0.0, 0.0));
311 MSQ_SETERR(err)(
"Requested Sample Point Mode not implemented",
322 coords.push_back(
Vector3D(0.0, 0.0, 0.0));
323 coords.push_back(
Vector3D(1.0, 0.0, 0.0));
324 coords.push_back(
Vector3D(1.0, 1.0, 0.0));
325 coords.push_back(
Vector3D(0.0, 1.0, 0.0));
326 coords.push_back(
Vector3D(0.0, 0.0, 1.0));
327 coords.push_back(
Vector3D(1.0, 0.0, 1.0));
328 coords.push_back(
Vector3D(1.0, 1.0, 1.0));
329 coords.push_back(
Vector3D(0.0, 1.0, 1.0));
339 MSQ_SETERR(err)(
"Requested Sample Point Mode not implemented",
347 MSQ_SETERR(err)(
"Requested Sample Point Mode not implemented",
369 tem = ((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
370 (verts[vertexIndices[3]]-verts[vertexIndices[0]])).
length();
371 tem += ((verts[vertexIndices[3]]-verts[vertexIndices[2]])*
372 (verts[vertexIndices[1]]-verts[vertexIndices[2]])).
length();
376 MSQ_SETERR(err)(
"Invalid type of element passed to compute unsigned area.",
390 short num_jacobian_vectors=-1;
398 (verts[vertexIndices[1]]-verts[vertexIndices[0]]))/6.0;
404 return fabs(jac_vecs[2]%(jac_vecs[0]*jac_vecs[1]));
407 MSQ_SETERR(err)(
"Invalid type of element passed to compute unsigned volume.",
435 tem = (cross_vec.
length()/2.0);
437 if(cross_vec%surface_normal<0){
444 cross_vec=((verts[vertexIndices[1]]-verts[vertexIndices[0]])*
445 (verts[vertexIndices[3]]-verts[vertexIndices[0]]));
448 tem = (cross_vec.
length()/2.0);
450 if(cross_vec%surface_normal<0){
453 cross_vec=((verts[vertexIndices[3]]-verts[vertexIndices[2]])*
454 (verts[vertexIndices[1]]-verts[vertexIndices[2]]));
455 tem2 = (cross_vec.
length()/2.0);
457 if(cross_vec%surface_normal<0){
467 MSQ_SETERR(err)(
"Invalid type of element passed to compute unsigned area.",
481 short num_jacobian_vectors=-1;
489 (verts[vertexIndices[2]]-verts[vertexIndices[0]]))/6.0;
494 num_jacobian_vectors, err );
496 return (jac_vecs[2]%(jac_vecs[0]*jac_vecs[1]));
499 MSQ_SETERR(err)(
"Invalid type of element passed to compute signed volume.",
514 vector<size_t> &vert_indices,
528 if(vertexIndices[i]==vertex_index)
537 vert_indices.push_back(vertexIndices[(index+1)%3]);
538 vert_indices.push_back(vertexIndices[(index+2)%3]);
546 if(vertexIndices[i]==vertex_index)
555 vert_indices.push_back(vertexIndices[(index+1)%4]);
556 vert_indices.push_back(vertexIndices[(index+3)%4]);
564 if(vertexIndices[i]==vertex_index)
573 vert_indices.push_back(vertexIndices[(index+1)%4]);
574 vert_indices.push_back(vertexIndices[(index+2)%4]);
575 vert_indices.push_back(vertexIndices[(index+3)%4]);
583 if(vertexIndices[i]==vertex_index)
595 vert_indices.push_back(vertexIndices[(index+1)%4]);
596 vert_indices.push_back(vertexIndices[(index+3)%4]);
597 vert_indices.push_back(vertexIndices[(index)+4]);
601 vert_indices.push_back(vertexIndices[(index+3)%4+4]);
602 vert_indices.push_back(vertexIndices[(index+1)%4+4]);
603 vert_indices.push_back(vertexIndices[(index)-4]);
677 MSQ_SETERR(err)(
"Should only be used for faces (tri, quads, ...).",
699 for (
unsigned i = 0; i < count; ++
i)
706 if (length > DBL_EPSILON)
713 const size_t prev_idx =
vertexIndices[(i + count - 1) % count];
737 Vector3D normals[4], vec1, vec2, vec3, vec4;
750 vec1 = vertices[v_i[1]]-vertices[v_i[0]];
751 vec2 = vertices[v_i[2]]-vertices[v_i[0]];
752 vec3 = vertices[v_i[2]]-vertices[v_i[1]];
760 A[1].
set_column(2, normals[1]*MSQ_3RT_2_OVER_6RT_3);
764 A[2].
set_column(2, normals[2]*MSQ_3RT_2_OVER_6RT_3);
773 vec1 = vertices[v_i[1]]-vertices[v_i[0]];
774 vec2 = vertices[v_i[3]]-vertices[v_i[0]];
775 vec3 = vertices[v_i[2]]-vertices[v_i[1]];
776 vec4 = vertices[v_i[3]]-vertices[v_i[2]];
803 A[0].
set_column(0, vertices[v_i[1]]-vertices[v_i[0]]);
804 A[0].
set_column(1, vertices[v_i[2]]-vertices[v_i[0]]);
805 A[0].
set_column(2, vertices[v_i[3]]-vertices[v_i[0]]);
807 A[1].
set_column(0, vertices[v_i[0]]-vertices[v_i[1]]);
808 A[1].
set_column(1, vertices[v_i[3]]-vertices[v_i[1]]);
809 A[1].
set_column(2, vertices[v_i[2]]-vertices[v_i[1]]);
811 A[2].
set_column(0, vertices[v_i[3]]-vertices[v_i[2]]);
812 A[2].
set_column(1, vertices[v_i[0]]-vertices[v_i[2]]);
813 A[2].
set_column(2, vertices[v_i[1]]-vertices[v_i[2]]);
815 A[3].
set_column(0, vertices[v_i[2]]-vertices[v_i[3]]);
816 A[3].
set_column(1, vertices[v_i[1]]-vertices[v_i[3]]);
817 A[3].
set_column(2, vertices[v_i[0]]-vertices[v_i[3]]);
879 A[0].
set_column(0, vertices[v_i[1]]-vertices[v_i[0]]);
880 A[0].
set_column(1, vertices[v_i[3]]-vertices[v_i[0]]);
881 A[0].
set_column(2, vertices[v_i[4]]-vertices[v_i[0]]);
883 A[1].
set_column(0, vertices[v_i[2]]-vertices[v_i[1]]);
884 A[1].
set_column(1, vertices[v_i[0]]-vertices[v_i[1]]);
885 A[1].
set_column(2, vertices[v_i[5]]-vertices[v_i[1]]);
887 A[2].
set_column(0, vertices[v_i[3]]-vertices[v_i[2]]);
888 A[2].
set_column(1, vertices[v_i[1]]-vertices[v_i[2]]);
889 A[2].
set_column(2, vertices[v_i[6]]-vertices[v_i[2]]);
891 A[3].
set_column(0, vertices[v_i[0]]-vertices[v_i[3]]);
892 A[3].
set_column(1, vertices[v_i[2]]-vertices[v_i[3]]);
893 A[3].
set_column(2, vertices[v_i[7]]-vertices[v_i[3]]);
895 A[4].
set_column(0, vertices[v_i[7]]-vertices[v_i[4]]);
896 A[4].
set_column(1, vertices[v_i[5]]-vertices[v_i[4]]);
897 A[4].
set_column(2, vertices[v_i[0]]-vertices[v_i[4]]);
899 A[5].
set_column(0, vertices[v_i[4]]-vertices[v_i[5]]);
900 A[5].
set_column(1, vertices[v_i[6]]-vertices[v_i[5]]);
901 A[5].
set_column(2, vertices[v_i[1]]-vertices[v_i[5]]);
903 A[6].
set_column(0, vertices[v_i[5]]-vertices[v_i[6]]);
904 A[6].
set_column(1, vertices[v_i[7]]-vertices[v_i[6]]);
905 A[6].
set_column(2, vertices[v_i[2]]-vertices[v_i[6]]);
907 A[7].
set_column(0, vertices[v_i[6]]-vertices[v_i[7]]);
908 A[7].
set_column(1, vertices[v_i[4]]-vertices[v_i[7]]);
909 A[7].
set_column(2, vertices[v_i[3]]-vertices[v_i[7]]);
922 stream <<
"MsqMeshEntity " << &entity <<
" with vertices ";
923 for (
size_t i = 0; i < num_vert; ++
i)
#define MSQ_ERRZERO(err)
Return zero/NULL on error.
void get_node_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
gets the vertices of the mesh entity
MsqVertex & vertex_by_index(size_t index)
Returns the start of the vertex->element array.
Used to hold the error state and return it to the application.
void get_domain_normals_at_corners(size_t element_index, Vector3D normals_out[], MsqError &err)
Get surface normal at a point where the surface is the domain of an element and the point is the loca...
double compute_signed_area(PatchData &pd, MsqError &err)
Computes the signed area of the element.
requested functionality is not (yet) implemented
MsqMeshEntity is the Mesquite object that stores information about the elements in the mesh...
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
void get_vertex_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
gets the vertices of the mesh entity
static const double MSQ_SQRT_TWO_DIV_SQRT_THREE
double compute_unsigned_volume(PatchData &pd, MsqError &err)
Computes the volume of the element.
static const double MSQ_SQRT_THREE_DIV_TWO
size_t * vertexIndices
Pointer to connectivity array.
double length(Vector3D *const v, int n)
void get_domain_normal_at_element(size_t elem_index, Vector3D &surf_norm, MsqError &err) const
invalid function argument passed
NVec< 3, double > Vector3D
msq_stdc::size_t vertex_count() const
Returns the number of vertices in this element, based on its element type.
size_t get_element_index(MsqMeshEntity *element)
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
void append_vertex_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
void compute_weighted_jacobian(PatchData &pd, Vector3D &sample_point, Vector3D jacobian_vectors[], short &num_jacobian_vectors, MsqError &err)
void get_centroid(Vector3D ¢roid, const PatchData &pd, MsqError &err) const
Returns the centroid of the element.
double compute_unsigned_area(PatchData &pd, MsqError &err)
Computes the area of the element.
void append_node_indices(msq_std::vector< msq_stdc::size_t > &vertex_list) const
static const double MSQ_SQRT_TWO_INV
void get_connected_vertices(msq_stdc::size_t vertex_index, msq_std::vector< msq_stdc::size_t > &vert_indices, MsqError &err)
Fills a vector<size_t> with vertices connected to the given vertex through the edges of this MsqMeshE...
const MsqVertex * get_vertex_array(MsqError &err) const
Returns a pointer to the start of the vertex array.
void set_column(int j, const Vector3D &c)
Sets column j (0, 1 or 2) to Vector3D c.
EntityTopology get_element_type() const
Returns element type.
double compute_signed_volume(PatchData &pd, MsqError &err)
Computes the signed volume of the element.
static const double MSQ_SQRT_THREE_INV
msq_stdio::ostream & operator<<(msq_stdio::ostream &s, const Matrix3D &A)
void set(const double x, const double y, const double z)
void get_sample_points(QualityMetric::ElementEvaluationMode mode, msq_std::vector< Vector3D > &coords, MsqError &err)
Returns a list of sample points given an evaluationmode.
void compute_corner_matrices(PatchData &pd, Matrix3D A[], int num_m3d, MsqError &err)
Compute matrices which column are the vectors issued from a corner.
MsqVertex is the Mesquite object that stores information about the vertices in the mesh...
#define MSQ_ERRRTN(err)
If passed error is true, return from a void function.
void compute_corner_normals(Vector3D normals[], PatchData &pd, MsqError &err)
Uses a MeshDomain call-back function to compute the normal at the corner.
static const double MSQ_3RT_2_OVER_6RT_3
msq_stdc::size_t node_count() const
Return number of nodes in element (number of corner vertices + number of higher-order nodes)...