void BasicLocator::draw( M3dView & view, const MDagPath & path, M3dView::DisplayStyle style, M3dView::DisplayStatus status ) { view.beginGL(); glPushAttrib( GL_CURRENT_BIT ); MPointArray pts; getCirclePoints( pts ); glBegin(GL_LINE_STRIP); for( unsigned int i=0; i < pts.length(); i++ ) glVertex3f( float(pts[i].x), float(pts[i].y), float(pts[i].z) ); glEnd(); glBegin(GL_LINES); glVertex3f( -0.5f, 0.0f, 0.0f ); glVertex3f( 0.5f, 0.0f, 0.0f ); glVertex3f( 0.0f, 0.0f, -0.5f ); glVertex3f( 0.0f, 0.0f, 0.5f ); glEnd(); glPopAttrib(); view.endGL(); }
double symmetryDetection::detectSymmetryAngle (const Mat& pattern, const Point& centroid) { vector<int> angles; for (int radius = CONCENTRIC_MIN_RADIUS; radius < getMinContainingRadius(pattern, centroid); radius += CONCENTRIC_SAMPLE_STEP) { vector<Point> circle_pts = getCirclePoints(centroid, radius); Mat circle_pt_mat = Mat((int)circle_pts.size(), 1, CV_64FC1); Mat convolved_mat = Mat((int)circle_pts.size(), 1, CV_64FC1); for (int i = 0; i < circle_pts.size(); i ++) { circle_pt_mat.at<double>(i, 0) = pattern.at<double>(circle_pts[i]); } for (int i = 0; i < circle_pts.size(); i ++) { convolved_mat.at<double>(i, 0) = convolveMat(circle_pt_mat); shiftMatElement(circle_pt_mat); } double max = 0.0; int idx = 0; for (int i = 0; i < convolved_mat.rows; i ++) { if ( max < convolved_mat.at<double>(i, 0) ) { max = convolved_mat.at<double>(i, 0); idx = i; } } int angle = ceil(135 - idx*(360.0 / convolved_mat.rows)); angle = angle > 0 ? angle : 360 + angle; angles.push_back(angle); } return mode(angles); }
MBoundingBox BasicLocator::boundingBox() const // // N.B. It is important to have this bounding box function otherwise zoom selected and // zoom all won't work correctly. // { MPointArray pts; getCirclePoints( pts ); MBoundingBox bbox; for( unsigned int i=0; i < pts.length(); i++ ) bbox.expand( pts[i] ); return bbox; }
int symmetryDetection::getMinContainingRadius (const Mat& pattern, const Point& centroid) { int min_radius = 0; for (int r = INNER_MOST_RADIUS; r < pattern.rows/2; r ++) { vector<Point>circle_p = getCirclePoints(centroid, r); for (int i = 0; i < circle_p.size(); i ++) { if ( pattern.at<double>(circle_p[i]) ) { min_radius = r; break; } } } return min_radius; }