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 );
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"));
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"));
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"));
788 if ( !vh.is_valid() ) {
789 emit log(
LOGERR,tr(
"Unable to get vertex handle"));
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;
double edgeLength(int _id, int _edgeHandle)
get the length of an edge
double minEdgeLength(int _id)
get the minimal edge length
int faceCount(int _id)
get total number of faces for a given 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
bool getObject(int _identifier, BSplineCurveObject *&_object)
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
bool dataType(DataType _type) const
double maxEdgeLength(int _id)
get the maximal edge length
int boundaryCount(int _id)
get the number of boundaries for a given object
Vector boundingBoxMax(int _id)
get maximum bounding box point
int componentCount(int _id)
get the number of components for a given object
void setDescriptions()
set scripting slot descriptions
Vector boundingBoxMin(int _id)
get minumum bounding box point
int vertexValence(int _id, int _vertexHandle)
get vertex valence
double faceArea(int _id, int _faceHandle)
get the area of a face
Kernel::FaceVertexIter FaceVertexIter
Circulator.
double meanEdgeLength(int _id)
get the mean edge length
int vertexCount(int _id)
get total number of vertices for a given object
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.
double aspectRatio(int _id, int _faceHandle)
get the aspect ratio of a face
ACG::Vec3d Vector
Standard Type for 3d Vector used for scripting.
Kernel::VertexVertexIter VertexVertexIter
Circulator.
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::Point Point
Coordinate type.
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
int genus(int _id)
get the genus of the given object
#define DATA_TRIANGLE_MESH
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
Vector boundingBoxSize(int _id)
get the size of the bounding box