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;
Vector boundingBoxSize(int _id)
get the size of the bounding box
int vertexCount(int _id)
get total number of vertices for a given object
int vertexValence(int _id, int _vertexHandle)
get vertex valence
Kernel::Point Point
Coordinate type.
Vector boundingBoxMax(int _id)
get maximum bounding box point
Vec::value_type triangleArea(const Vec &_v0, const Vec &_v1, const Vec &_v2)
return area of triangle (_v0, _v1, _v2)
Kernel::FaceVertexIter FaceVertexIter
Circulator.
bool dataType(DataType _type) const
int genus(int _id)
get the genus of the given object
Vector boundingBoxMin(int _id)
get minumum bounding box point
int edgeCount(int _id)
get total number of edges for a given object
void getEdgeLengths(MeshT *_mesh, double &min, double &max, double &mean)
Get edge lengths.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
Scalar aspectRatio(const VectorT< Scalar, N > &_v0, const VectorT< Scalar, N > &_v1, const VectorT< Scalar, N > &_v2)
return aspect ratio (length/height) of triangle
int componentCount(int _id)
get the number of components for a given object
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
double faceArea(int _id, int _faceHandle)
get the area of a face
Vector cog(int _id)
get the center of gravity
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
int boundaryCount(int _id)
get the number of boundaries for a given object
double meanEdgeLength(int _id)
get the mean edge length
double maxEdgeLength(int _id)
get the maximal edge length
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
double minEdgeLength(int _id)
get the minimal edge length
#define DATA_TRIANGLE_MESH
void setDescriptions()
set scripting slot descriptions
int faceCount(int _id)
get total number of faces for a given object