50 #include "MeshObjectInfoPlugin.hh"
52 #include <MeshTools/MeshInfoT.hh>
62 emit setSlotDescription(
"vertexCount(int)",tr(
"get total number of vertices for a given object"),
63 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
65 emit setSlotDescription(
"edgeCount(int)",tr(
"get total number of edges for a given object"),
66 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
68 emit setSlotDescription(
"faceCount(int)",tr(
"get total number of faces for a given object"),
69 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
71 emit setSlotDescription(
"boundaryCount(int)",tr(
"get number of boundaries for a given object"),
72 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
74 emit setSlotDescription(
"componentCount(int)",tr(
"get number of components for a given object"),
75 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
77 emit setSlotDescription(
"genus(int)",tr(
"get the genus of a given object"),
78 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
80 emit setSlotDescription(
"cog(int)",tr(
"get the center of gravity for a given object"),
81 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
83 emit setSlotDescription(
"boundingBoxMin(int)",tr(
"get minimum point of the axis-aligned bounding box"),
84 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
86 emit setSlotDescription(
"boundingBoxMax(int)",tr(
"get maximum point of the axis-aligned bounding box"),
87 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
89 emit setSlotDescription(
"boundingBoxSize(int)",tr(
"get the size of the axis-aligned bounding box"),
90 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
93 emit setSlotDescription(
"edgeLength(int,int)",tr(
"Get the length of an edge"),
94 QString(tr(
"ObjectId,EdgeHandle")).split(
","),
95 QString(tr(
"id of the object, handle of an edge")).split(
","));
97 emit setSlotDescription(
"faceArea(int,int)",tr(
"Get the area of a face"),
98 QString(tr(
"ObjectId,FaceHandle")).split(
","),
99 QString(tr(
"id of the object, handle of a face")).split(
","));
101 emit setSlotDescription(
"aspectRatio(int,int)",tr(
"Get the aspect ratio of a face"),
102 QString(tr(
"ObjectId,FaceHandle")).split(
","),
103 QString(tr(
"id of the object, handle of a face")).split(
","));
105 emit setSlotDescription(
"vertexValence(int,int)",tr(
"Get the valence of a vertex"),
106 QString(tr(
"ObjectId,VertexHandle")).split(
","),
107 QString(tr(
"id of the object, handle of a vertex")).split(
","));
109 emit setSlotDescription(
"minEdgeLength(int)",tr(
"Get the minimal edge length of an object"),
110 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
112 emit setSlotDescription(
"maxEdgeLength(int)",tr(
"Get the maximal edge length of an object"),
113 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
115 emit setSlotDescription(
"meanEdgeLength(int)",tr(
"Get the mean edge length of an object"),
116 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
136 emit log(
LOGERR, tr(
"Unable to get object"));
144 emit log(
LOGERR, tr(
"Unable to get mesh"));
148 return mesh->n_vertices();
154 emit log(
LOGERR, tr(
"Unable to get mesh"));
158 return mesh->n_vertices();
178 emit log(
LOGERR, tr(
"Unable to get object"));
186 emit log(
LOGERR, tr(
"Unable to get mesh"));
190 return mesh->n_edges();
196 emit log(
LOGERR, tr(
"Unable to get mesh"));
200 return mesh->n_edges();
220 emit log(
LOGERR, tr(
"Unable to get object"));
228 emit log(
LOGERR, tr(
"Unable to get mesh"));
232 return mesh->n_faces();
238 emit log(
LOGERR, tr(
"Unable to get mesh"));
242 return mesh->n_faces();
262 emit log(
LOGERR, tr(
"Unable to get object"));
270 emit log(
LOGERR, tr(
"Unable to get mesh"));
274 return MeshInfo::boundaryCount(mesh);
280 emit log(
LOGERR, tr(
"Unable to get mesh"));
284 return MeshInfo::boundaryCount(mesh);
304 emit log(
LOGERR, tr(
"Unable to get object"));
312 emit log(
LOGERR, tr(
"Unable to get mesh"));
316 return MeshInfo::componentCount(mesh);
322 emit log(
LOGERR, tr(
"Unable to get mesh"));
326 return MeshInfo::componentCount(mesh);
346 emit log(
LOGERR, tr(
"Unable to get object"));
354 emit log(
LOGERR, tr(
"Unable to get mesh"));
358 return (1 - (mesh->n_vertices() - mesh->n_edges() + mesh->n_faces() ) / 2);
364 emit log(
LOGERR, tr(
"Unable to get mesh"));
368 return (1 - (mesh->n_vertices() - mesh->n_edges() + mesh->n_faces() ) / 2);
388 emit log(
LOGERR, tr(
"Unable to get object"));
396 emit log(
LOGERR, tr(
"Unable to get mesh"));
400 return MeshInfo::cog(mesh);
406 emit log(
LOGERR, tr(
"Unable to get mesh"));
410 return MeshInfo::cog(mesh);
430 emit log(
LOGERR, tr(
"Unable to get object"));
438 emit log(
LOGERR, tr(
"Unable to get mesh"));
444 MeshInfo::getBoundingBox(mesh, min, max);
452 emit log(
LOGERR, tr(
"Unable to get mesh"));
458 MeshInfo::getBoundingBox(mesh, min, max);
480 emit log(
LOGERR, tr(
"Unable to get object"));
488 emit log(
LOGERR, tr(
"Unable to get mesh"));
494 MeshInfo::getBoundingBox(mesh, min, max);
502 emit log(
LOGERR, tr(
"Unable to get mesh"));
508 MeshInfo::getBoundingBox(mesh, min, max);
530 emit log(
LOGERR, tr(
"Unable to get object"));
538 emit log(
LOGERR, tr(
"Unable to get mesh"));
544 MeshInfo::getBoundingBox(mesh, min, max);
552 emit log(
LOGERR, tr(
"Unable to get mesh"));
558 MeshInfo::getBoundingBox(mesh, min, max);
581 emit log(
LOGERR, tr(
"Unable to get object"));
589 emit log(
LOGERR, tr(
"Unable to get mesh"));
593 TriMesh::EdgeHandle eh( _edgeHandle );
595 if ( !eh.is_valid() ) {
596 emit log(
LOGERR,tr(
"Unable to get edge handle"));
600 TriMesh::HalfedgeHandle hh = mesh->halfedge_handle( eh, 0 );
601 TriMesh::Point p0 = mesh->point( mesh->from_vertex_handle(hh) );
602 TriMesh::Point p1 = mesh->point( mesh->to_vertex_handle(hh) );
604 return (p0 - p1).norm();
610 emit log(
LOGERR, tr(
"Unable to get mesh"));
614 PolyMesh::EdgeHandle eh( _edgeHandle );
616 if ( !eh.is_valid() ) {
617 emit log(
LOGERR,tr(
"Unable to get edge handle"));
621 PolyMesh::HalfedgeHandle hh = mesh->halfedge_handle( eh, 0 );
625 return (p0 - p1).norm();
646 emit log(
LOGERR, tr(
"Unable to get object"));
654 emit log(
LOGERR, tr(
"Unable to get mesh"));
658 TriMesh::FaceHandle fh( _faceHandle );
660 if ( !fh.is_valid() ) {
661 emit log(
LOGERR,tr(
"Unable to get face handle"));
665 TriMesh::FaceVertexIter fv_it = mesh->fv_iter(fh);
667 TriMesh::Point v0 = mesh->point( *fv_it );
669 TriMesh::Point v1 = mesh->point( *fv_it );
671 TriMesh::Point v2 = mesh->point( *fv_it );
679 emit log(
LOGERR, tr(
"Unable to get mesh"));
683 PolyMesh::FaceHandle fh( _faceHandle );
685 if ( !fh.is_valid() ) {
686 emit log(
LOGERR,tr(
"Unable to get face handle"));
692 std::vector< PolyMesh::Point > vertices;
694 for (fv_it = mesh->fv_iter(fh); fv_it.is_valid(); ++fv_it)
695 vertices.push_back( mesh->point( *fv_it ) );
698 emit log(
LOGERR,tr(
"Not implemented yet"));
721 emit log(
LOGERR, tr(
"Unable to get object"));
729 emit log(
LOGERR, tr(
"Unable to get mesh"));
733 TriMesh::FaceHandle fh( _faceHandle );
735 if ( !fh.is_valid() ) {
736 emit log(
LOGERR,tr(
"Unable to get face handle"));
740 TriMesh::FaceVertexIter fv_it = mesh->fv_iter(fh);
742 TriMesh::Point v0 = mesh->point( *fv_it );
744 TriMesh::Point v1 = mesh->point( *fv_it );
746 TriMesh::Point v2 = mesh->point( *fv_it );
752 emit log(
LOGERR,tr(
"Aspect ratio can only be calculated for triangle meshes"));
774 emit log(
LOGERR, tr(
"Unable to get object"));
782 emit log(
LOGERR, tr(
"Unable to get mesh"));
786 TriMesh::VertexHandle vh( _vertexHandle );
788 if ( !vh.is_valid() ) {
789 emit log(
LOGERR,tr(
"Unable to get vertex handle"));
795 TriMesh::VertexVertexIter vv_it;
797 for (vv_it=mesh->vv_iter( vh ); vv_it.is_valid(); ++vv_it)
806 emit log(
LOGERR, tr(
"Unable to get mesh"));
812 if ( !vh.is_valid() ) {
813 emit log(
LOGERR,tr(
"Unable to get vertex handle"));
821 for (vv_it=mesh->vv_iter( vh ); vv_it.is_valid(); ++vv_it)
837 double min, max, mean;
854 double min, max, mean;
871 double min, max, mean;
int componentCount(int _id)
get the number of components for a given object
int faceCount(int _id)
get total number of faces for a given object
void setDescriptions()
set scripting slot descriptions
Vector boundingBoxSize(int _id)
get the size of the bounding box
Vector boundingBoxMin(int _id)
get minumum bounding box point
int genus(int _id)
get the genus of the given object
double faceArea(int _id, int _faceHandle)
get the area of a face
Kernel::VertexVertexIter VertexVertexIter
Circulator.
bool getObject(int _identifier, BSplineCurveObject *&_object)
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
int edgeCount(int _id)
get total number of edges for a given object
Kernel::Point Point
Coordinate type.
int boundaryCount(int _id)
get the number of boundaries for a given object
bool dataType(DataType _type) const
Scalar aspectRatio(const VectorT< Scalar, N > &_v0, const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
return aspect ratio (length/height) of triangle
Vector boundingBoxMax(int _id)
get maximum bounding box point
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
void getEdgeLengths(MeshT *_mesh, double &min, double &max, double &mean)
Get edge lengths.
double meanEdgeLength(int _id)
get the mean edge length
int vertexCount(int _id)
get total number of vertices for a given object
double minEdgeLength(int _id)
get the minimal edge length
Vec::value_type triangleArea(const Vec &_v0, const Vec &_v1, const Vec &_v2)
return area of triangle (_v0, _v1, _v2)
Vector cog(int _id)
get the center of gravity
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
Kernel::FaceVertexIter FaceVertexIter
Circulator.
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
double maxEdgeLength(int _id)
get the maximal edge length
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
#define DATA_TRIANGLE_MESH
int vertexValence(int _id, int _vertexHandle)
get vertex valence