44 #include "MeshObjectInfoPlugin.hh" 46 #include <MeshTools/MeshInfoT.hh> 56 emit setSlotDescription(
"vertexCount(int)",tr(
"get total number of vertices for a given object"),
57 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
59 emit setSlotDescription(
"edgeCount(int)",tr(
"get total number of edges for a given object"),
60 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
62 emit setSlotDescription(
"faceCount(int)",tr(
"get total number of faces for a given object"),
63 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
65 emit setSlotDescription(
"boundaryCount(int)",tr(
"get number of boundaries for a given object"),
66 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
68 emit setSlotDescription(
"componentCount(int)",tr(
"get number of components for a given object"),
69 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
71 emit setSlotDescription(
"genus(int)",tr(
"get the genus of a given object"),
72 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
74 emit setSlotDescription(
"cog(int)",tr(
"get the center of gravity for a given object"),
75 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
77 emit setSlotDescription(
"boundingBoxMin(int)",tr(
"get minimum point of the axis-aligned bounding box"),
78 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
80 emit setSlotDescription(
"boundingBoxMax(int)",tr(
"get maximum point of the axis-aligned bounding box"),
81 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
83 emit setSlotDescription(
"boundingBoxSize(int)",tr(
"get the size of the axis-aligned bounding box"),
84 QStringList(tr(
"objectID")), QStringList(tr(
"id of an object")));
87 emit setSlotDescription(
"edgeLength(int,int)",tr(
"Get the length of an edge"),
88 QString(tr(
"ObjectId,EdgeHandle")).split(
","),
89 QString(tr(
"id of the object, handle of an edge")).split(
","));
91 emit setSlotDescription(
"faceArea(int,int)",tr(
"Get the area of a face"),
92 QString(tr(
"ObjectId,FaceHandle")).split(
","),
93 QString(tr(
"id of the object, handle of a face")).split(
","));
95 emit setSlotDescription(
"aspectRatio(int,int)",tr(
"Get the aspect ratio of a face"),
96 QString(tr(
"ObjectId,FaceHandle")).split(
","),
97 QString(tr(
"id of the object, handle of a face")).split(
","));
99 emit setSlotDescription(
"vertexValence(int,int)",tr(
"Get the valence of a vertex"),
100 QString(tr(
"ObjectId,VertexHandle")).split(
","),
101 QString(tr(
"id of the object, handle of a vertex")).split(
","));
103 emit setSlotDescription(
"minEdgeLength(int)",tr(
"Get the minimal edge length of an object"),
104 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
106 emit setSlotDescription(
"maxEdgeLength(int)",tr(
"Get the maximal edge length of an object"),
107 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
109 emit setSlotDescription(
"meanEdgeLength(int)",tr(
"Get the mean edge length of an object"),
110 QStringList(tr(
"ObjectId")), QStringList(tr(
"id of the object")));
130 emit log(
LOGERR, tr(
"Unable to get object"));
138 emit log(
LOGERR, tr(
"Unable to get mesh"));
142 return mesh->n_vertices();
148 emit log(
LOGERR, tr(
"Unable to get mesh"));
152 return mesh->n_vertices();
172 emit log(
LOGERR, tr(
"Unable to get object"));
180 emit log(
LOGERR, tr(
"Unable to get mesh"));
184 return mesh->n_edges();
190 emit log(
LOGERR, tr(
"Unable to get mesh"));
194 return mesh->n_edges();
214 emit log(
LOGERR, tr(
"Unable to get object"));
222 emit log(
LOGERR, tr(
"Unable to get mesh"));
226 return mesh->n_faces();
232 emit log(
LOGERR, tr(
"Unable to get mesh"));
236 return mesh->n_faces();
256 emit log(
LOGERR, tr(
"Unable to get object"));
264 emit log(
LOGERR, tr(
"Unable to get mesh"));
268 return MeshInfo::boundaryCount(mesh);
274 emit log(
LOGERR, tr(
"Unable to get mesh"));
278 return MeshInfo::boundaryCount(mesh);
298 emit log(
LOGERR, tr(
"Unable to get object"));
306 emit log(
LOGERR, tr(
"Unable to get mesh"));
310 return MeshInfo::componentCount(mesh);
316 emit log(
LOGERR, tr(
"Unable to get mesh"));
320 return MeshInfo::componentCount(mesh);
340 emit log(
LOGERR, tr(
"Unable to get object"));
348 emit log(
LOGERR, tr(
"Unable to get mesh"));
352 return (1 - (mesh->n_vertices() - mesh->n_edges() + mesh->n_faces() ) / 2);
358 emit log(
LOGERR, tr(
"Unable to get mesh"));
362 return (1 - (mesh->n_vertices() - mesh->n_edges() + mesh->n_faces() ) / 2);
382 emit log(
LOGERR, tr(
"Unable to get object"));
390 emit log(
LOGERR, tr(
"Unable to get mesh"));
394 return MeshInfo::cog(mesh);
400 emit log(
LOGERR, tr(
"Unable to get mesh"));
404 return MeshInfo::cog(mesh);
424 emit log(
LOGERR, tr(
"Unable to get object"));
432 emit log(
LOGERR, tr(
"Unable to get mesh"));
438 MeshInfo::getBoundingBox(mesh, min, max);
446 emit log(
LOGERR, tr(
"Unable to get mesh"));
452 MeshInfo::getBoundingBox(mesh, min, max);
474 emit log(
LOGERR, tr(
"Unable to get object"));
482 emit log(
LOGERR, tr(
"Unable to get mesh"));
488 MeshInfo::getBoundingBox(mesh, min, max);
496 emit log(
LOGERR, tr(
"Unable to get mesh"));
502 MeshInfo::getBoundingBox(mesh, min, max);
524 emit log(
LOGERR, tr(
"Unable to get object"));
532 emit log(
LOGERR, tr(
"Unable to get mesh"));
538 MeshInfo::getBoundingBox(mesh, min, max);
546 emit log(
LOGERR, tr(
"Unable to get mesh"));
552 MeshInfo::getBoundingBox(mesh, min, max);
575 emit log(
LOGERR, tr(
"Unable to get object"));
583 emit log(
LOGERR, tr(
"Unable to get mesh"));
587 TriMesh::EdgeHandle eh( _edgeHandle );
589 if ( !eh.is_valid() ) {
590 emit log(
LOGERR,tr(
"Unable to get edge handle"));
594 TriMesh::HalfedgeHandle hh = mesh->halfedge_handle( eh, 0 );
598 return (p0 - p1).norm();
604 emit log(
LOGERR, tr(
"Unable to get mesh"));
608 PolyMesh::EdgeHandle eh( _edgeHandle );
610 if ( !eh.is_valid() ) {
611 emit log(
LOGERR,tr(
"Unable to get edge handle"));
615 PolyMesh::HalfedgeHandle hh = mesh->halfedge_handle( eh, 0 );
619 return (p0 - p1).norm();
640 emit log(
LOGERR, tr(
"Unable to get object"));
648 emit log(
LOGERR, tr(
"Unable to get mesh"));
652 TriMesh::FaceHandle fh( _faceHandle );
654 if ( !fh.is_valid() ) {
655 emit log(
LOGERR,tr(
"Unable to get face handle"));
673 emit log(
LOGERR, tr(
"Unable to get mesh"));
677 PolyMesh::FaceHandle fh( _faceHandle );
679 if ( !fh.is_valid() ) {
680 emit log(
LOGERR,tr(
"Unable to get face handle"));
686 std::vector< PolyMesh::Point > vertices;
688 for (fv_it = mesh->fv_iter(fh); fv_it.is_valid(); ++fv_it)
689 vertices.push_back( mesh->point( *fv_it ) );
692 emit log(
LOGERR,tr(
"Not implemented yet"));
715 emit log(
LOGERR, tr(
"Unable to get object"));
723 emit log(
LOGERR, tr(
"Unable to get mesh"));
727 TriMesh::FaceHandle fh( _faceHandle );
729 if ( !fh.is_valid() ) {
730 emit log(
LOGERR,tr(
"Unable to get face handle"));
746 emit log(
LOGERR,tr(
"Aspect ratio can only be calculated for triangle meshes"));
768 emit log(
LOGERR, tr(
"Unable to get object"));
776 emit log(
LOGERR, tr(
"Unable to get mesh"));
782 if ( !vh.is_valid() ) {
783 emit log(
LOGERR,tr(
"Unable to get vertex handle"));
791 for (vv_it=mesh->vv_iter( vh ); vv_it.is_valid(); ++vv_it)
800 emit log(
LOGERR, tr(
"Unable to get mesh"));
806 if ( !vh.is_valid() ) {
807 emit log(
LOGERR,tr(
"Unable to get vertex handle"));
815 for (vv_it=mesh->vv_iter( vh ); vv_it.is_valid(); ++vv_it)
831 double min, max, mean;
848 double min, max, mean;
865 double min, max, mean;
Kernel::VertexVertexIter VertexVertexIter
Circulator.
double meanEdgeLength(int _id)
get the mean edge length
#define DATA_TRIANGLE_MESH
int vertexCount(int _id)
get total number of vertices for a given object
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
Kernel::FaceVertexIter FaceVertexIter
Circulator.
void getEdgeLengths(MeshT *_mesh, double &min, double &max, double &mean)
Get edge lengths.
Kernel::Point Point
Coordinate type.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Vector cog(int _id)
get the center of gravity
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
Scalar aspectRatio(const VectorT< Scalar, N > &_v0, const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
return aspect ratio (length/height) of triangle
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
bool dataType(DataType _type) const
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
double maxEdgeLength(int _id)
get the maximal edge length
int vertexValence(int _id, int _vertexHandle)
get vertex valence
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
int boundaryCount(int _id)
get the number of boundaries for a given object
double faceArea(int _id, int _faceHandle)
get the area of a face
int edgeCount(int _id)
get total number of edges for a given object
Vector boundingBoxMax(int _id)
get maximum bounding box point
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 componentCount(int _id)
get the number of components for a given object
Vec::value_type triangleArea(const Vec &_v0, const Vec &_v1, const Vec &_v2)
return area of triangle (_v0, _v1, _v2)
double minEdgeLength(int _id)
get the minimal edge length
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
int genus(int _id)
get the genus of the given object