Exemplo n.º 1
0
PeriodicDistanceAux::PeriodicDistanceAux(const InputParameters & parameters)
  : AuxKernel(parameters), _point(getParam<Point>("point"))
{
  // Make sure the point is in the domain
  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
    if (_point(i) < _mesh.getMinInDimension(i) || _point(i) > _mesh.getMaxInDimension(i))
    {
      _console << _mesh.getMinInDimension(i) << "\t" << _mesh.getMaxInDimension(i) << "\n";
      mooseError("\"point\" is outside of the domain.");
    }
}
Exemplo n.º 2
0
static _hit_t 
hit_node(designer_node_t *n, _point_t m)
{
    // designer_node_type_t *nt = n->type;
    // node_type_data_t *ntd = node_type_data(nt);
    node_data_t *nd = node_data(n);

    _point_t pos = nd->origin;
    _point_t mr = _point(m.x - pos.x, m.y - pos.y);

    if (!_inrect(mr, nd->nr))
	return HIT_NOTHING;

    /* check for head rect */
    if (_inrect(mr, nd->tr)) {
	if (_inrect(mr, nd->xr))
	    return HIT_CLOSE;
	if (_inrect(mr, nd->lr))
	    return HIT_LABEL;
	return HIT_TITLE;
    } else {
	if (_inrect(mr, nd->ir))
	    return HIT_INPUT;
	if (_inrect(mr, nd->or))
	    return HIT_OUTPUT;
	return HIT_BODY;
    }
}
Exemplo n.º 3
0
static _point_t
get_scroll_origin (widget_data_t *data)
{
    return _point(
	gtk_adjustment_get_value(data->hadjustment),
	gtk_adjustment_get_value(data->vadjustment));
}
Exemplo n.º 4
0
static void
reset_widget_data (widget_data_t *data)
{
    data->place_next = _point(50,50);
    
    data->visible_area.o = _zerop;
    data->visible_area.s = get_visible_size(data);
    data->combined_area = data->visible_area;
}
Exemplo n.º 5
0
RH_C_FUNCTION void ON_Annotation2_SetPoint(ON_Annotation2* pAnnotation, int which, ON_2DPOINT_STRUCT point)
{
  if( pAnnotation )
  {
    ON_2dPoint _point(point.val[0], point.val[1]);
    pAnnotation->SetPoint(which, _point);
    if( ON_LinearDimension2::userpositionedtext_pt_index == which )
      pAnnotation->m_userpositionedtext = true;
  }
}
Exemplo n.º 6
0
RH_C_FUNCTION int ON_Brep_NewVertex2( ON_Brep* pBrep, ON_3DPOINT_STRUCT point, double tolerance )
{
  int rc = -1;
  if( pBrep )
  {
    ON_3dPoint _point(point.val);
    ON_BrepVertex& vertex = pBrep->NewVertex(_point, tolerance);
    rc = vertex.m_vertex_index;
  }
  return rc;
}
Exemplo n.º 7
0
QBaseDlg::QBaseDlg(QWidget * parent_)
 :QDialog(parent_)
{
    setModal(true);
    setFixedSize(450, 250);				//set size
    QPoint _point(250, 230);
    move(GetMainFrame()->mapToGlobal(_point));
    setAutoFillBackground(true);
    setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint);

    setStyleSheet("QDialog{border: 2px solid transparent;\
                           background: rgba(150, 172, 213);border-color: rgba(80, 40, 1);}");
Exemplo n.º 8
0
    Parser::Parser(const vector<Production>& productions, const string& parserTablePath) : BasicParser(productions), parserTablePath(parserTablePath)
    {
#ifdef _DEBUG
        stream.open("ParserResult.txt", fstream::out | fstream::binary);
#endif
        // String Begin
        Rule quotationMarks = Rule('\"', &context);
        Rule ruleString = quotationMarks + *!quotationMarks + quotationMarks;
        ruleString.buildDFA();
        ruleString.setShowName("\"{String}\"");
        Production::Item itemString(ruleString);
        // String End

        // Digit Start
        Rule _0('0', &context);
        Rule _9('9', &context);
        Rule _0_9  = _0 - _9;
        Rule ruleDigit = +_0_9;
        ruleDigit.buildDFA();
        ruleDigit.setShowName("\"{Digit}\"");
        Production::Item itemDigit(ruleDigit);
        // Digit End

        // Real Start
        Rule _point('.', &context);
        Rule ruleReal = *_0_9 + _point + +_0_9;
        ruleReal.buildDFA();
        ruleReal.setShowName("\"{Real}\"");
        Production::Item itemReal(ruleReal);
        // Real End

        // Letter Start
        Rule _('_', &context);
        Rule _a('a', &context);
        Rule _z('z', &context);
        Rule _A('A', &context);
        Rule _Z('Z', &context);
        Rule _a_z = _a - _z;
        Rule _A_Z = _A - _Z;
        Rule ruleLetter = ((+_ + ruleDigit) |
            (+(_ | _a_z | _A_Z))) +
            *(_ | ruleDigit | _a_z | _A_Z);
        ruleLetter.buildDFA();
        ruleLetter.setShowName("\"{Letter}\"");
        Production::Item itemLetter(ruleLetter);
        // Letter End

        vts.push_back(pair<string, Production::Item>("{String}", itemString));
        vts.push_back(pair<string, Production::Item>("{Digit}",  itemDigit));
        vts.push_back(pair<string, Production::Item>("{Real}",   itemReal));
        vts.push_back(pair<string, Production::Item>("{Letter}", itemLetter));
    }
Exemplo n.º 9
0
/* need to reseed because of the coarse quantization we tend to use on
   residuals (which causes lots & lots of dupes) */
void vqext_preprocess(vqgen *v){
  long i,j,k,l;
  float *test=alloca(sizeof(float)*v->elements);
  scalequant=q.quant;

  vqext_quantize(v,&q);
  vqgen_unquantize(v,&q);

  /* if there are any dupes, reseed */
  for(k=0;k<v->entries;k++){
    for(l=0;l<k;l++){
      if(memcmp(_now(v,k),_now(v,l),sizeof(float)*v->elements)==0)
        break;
    }
    if(l<k)break;
  }

  if(k<v->entries){
    fprintf(stderr,"reseeding with quantization....\n");

    /* seed the inputs to input points, but points on unit boundaries,
     ignoring quantbits for now, making sure each seed is unique */
    
    for(i=0,j=0;i<v->points && j<v->entries;i++){
      for(k=0;k<v->elements;k++){
        float val=_point(v,i)[k];
        test[k]=rint(val/scalequant)*scalequant;
      }
      
      for(l=0;l<j;l++){
        for(k=0;k<v->elements;k++)
          if(test[k]!=_now(v,l)[k])
            break;
        if(k==v->elements)break;
      }
      if(l==j){
        memcpy(_now(v,j),test,v->elements*sizeof(float));
        j++;
      }
    }
    
    if(j<v->elements){
      fprintf(stderr,"Not enough unique entries after prequantization\n");
      exit(1);
    }
  }  
  vqext_quantize(v,&q);
  quant_save=_ogg_malloc(sizeof(float)*v->elements*v->entries);
  memcpy(quant_save,_now(v,0),sizeof(float)*v->elements*v->entries);
  vqgen_unquantize(v,&q);

}
Exemplo n.º 10
0
static int
calc_connect_sp(_point_t p1, _point_t p2, 
	_point_t *ep, _point_t *hp, _point_t *sp, int mode, double m)
{
    _size_t d = _delta(p1, p2);
    double l = sqrt(d.w*d.w + d.h*d.h);
    double ms = MIN(m, l/2);
    double ds = sign(d.h);

    sp[0] = _point(ep[1].x, hp[0].y);
    sp[1] = _mixp(p1, sp[0], 0.333);
    sp[2] = _mixp(ep[1], sp[0], 0.333);

    sp[9] = _point(ep[2].x, hp[4].y);
    sp[8] = _mixp(p2, sp[9], 0.333);
    sp[7] = _mixp(ep[2], sp[9], 0.333);

    double dx = MIN(-d.w, 2*ms);
    double dy = ep[1].y - sp[2].y + ds*dx/2;

    dy = MIMAX(ds, d.h/2, dy/2);

    sp[3] = _move(ep[1], _size(0, dy));
    sp[4] = _move(hp[1], _size(dx/2, ds*dx));
    
    sp[4].x = MIN(sp[4].x, sp[3].x);
    sp[4].y = MIMAX(ds, sp[4].y, hp[2].y);

    sp[6] = _move(ep[2], _size(0, -dy));
    sp[5] = _move(hp[3], _size(-dx/2, -ds*dx));
    
    sp[5].x = MAX(sp[5].x, sp[6].x);
    sp[5].y = MAMIN(ds, sp[5].y, hp[2].y);

    ep[1].y += dy/3;
    ep[2].y -= dy/3;

    return mode;
}
Exemplo n.º 11
0
void
designer_widget_move_node (GtkWidget *widget, designer_node_t *node, double x, double y)
{
    widget_data_t *data = get_widget_data(widget);

#ifdef DEBUG_OUTPUT
    g_print("widget %p moves node %s to %gx%g\n", data, node->name, x, y);
#endif

    node_data_t *nd = node_data(node);

    nd->origin = _point(x,y);
    update_area_conditional(data, FALSE);
}
Exemplo n.º 12
0
RH_C_FUNCTION bool ON_BrepRegion_IsPointInside(const ON_Brep* pConstBrep, int index, ON_3DPOINT_STRUCT point, double tolerance, bool strictly_inside)
{
  bool rc = false;
  if( pConstBrep )
  {
    const ON_BrepRegionTopology& top = pConstBrep->RegionTopology();
    if( index>=0 && index<top.m_R.Count() )
    {
      ON_3dPoint _point(point.val);
      rc = top.m_R[index].IsPointInside(_point, tolerance, strictly_inside);
    }
  }
  return rc;
}
Exemplo n.º 13
0
/* we just need to calc the global_maxdel from the training set */
void vqext_preprocess(vqgen *v){
  long j,k;

  global_maxdel=0.f;
  global_mindel=M_PI;
  for(j=0;j<v->points;j++){
    float last=0.;
    for(k=0;k<v->elements+v->aux;k++){
      float p=_point(v,j)[k];
      if(p-last>global_maxdel)global_maxdel=p-last;
      if(p-last<global_mindel)global_mindel=p-last;
      last=p;
    }
  }

  weight=_ogg_malloc(sizeof(float)*v->elements);
}
Exemplo n.º 14
0
static gboolean
motion_notify_event (GtkWidget *widget, GdkEventMotion *event)
{
    widget_data_t *data = get_widget_data(widget);
    int x, y;
    GdkModifierType state;

    if (event->is_hint)
	gdk_window_get_pointer (event->window, &x, &y, &state);
    else
    {
	x = event->x;
	y = event->y;
	state = event->state;
    }

    data->mouse = map_location(data, _point(x, y));

    switch(data->state) {
    case STATE_MOVING:
	if (data->active_node) {
	    node_data(data->active_node)->origin =
		_move(data->origin,
		_delta(data->mouse_down, data->mouse));
	}
	break;
    case STATE_CONIN:
    
    
	break;
    case STATE_CONOUT:
	break;

    default:
	break;
    }

    gtk_widget_queue_draw(widget);
    return TRUE;
}
Exemplo n.º 15
0
static gboolean
button_release_event (GtkWidget *widget, GdkEventButton *event)
{
    widget_data_t *data = get_widget_data(widget);

    data->mouse_up = map_location(data, _point(event->x, event->y));

    switch(data->state) {
    case STATE_MOVING:
	update_area_conditional(data, FALSE);
	data->state = STATE_IDLE;
	break;
    case STATE_CONIN:
	if (data->target_check != DESIGNER_CONNECTION_UNCONNECTABLE)
	    connect(data,
		data->target_node, data->target_slot_id,
		data->active_node, data->active_slot_id);
	data->state = STATE_IDLE;
	break;
    case STATE_CONOUT:
	if (data->target_check != DESIGNER_CONNECTION_UNCONNECTABLE)
	    connect(data,
		data->active_node, data->active_slot_id,
		data->target_node, data->target_slot_id);
	data->state = STATE_IDLE;
	break;
    default:
	break;
    }

    /* clean up active/target */
    if (data->state == STATE_IDLE)
	clean_up_active_target (data);
    data->dragging = FALSE;

    gtk_widget_queue_draw(widget);
    return TRUE;
}
Exemplo n.º 16
0
static gboolean
button_press_event (GtkWidget *widget, GdkEventButton *event)
{
    widget_data_t *data = get_widget_data(widget);

    data->mouse_down = map_location(data, _point(event->x, event->y));

    designer_node_t *hn = NULL;
    _hit_t ht = HIT_NOTHING;
    int hs = -1;

    /* check for best node hit */
    for (GSList *list = data->design->nodes;
	list != NULL; list = list->next) {
	designer_node_t *node = list->data;

	_hit_t nht = hit_node(node, data->mouse_down);
	if (nht) {
	    hn = node;
	    ht = nht;
	}
    }

    if (event->type == GDK_2BUTTON_PRESS)
	return double_click_event(widget, event, hn, ht);

    switch(ht) {
    case HIT_LABEL:
    case HIT_TITLE:
    case HIT_BODY:
	data->active_node = hn;
	data->state = STATE_MOVING;
	data->origin = node_data(hn)->origin;
	designer_node_push_back(hn);
	break;
    case HIT_CLOSE:
	designer_disconnect_and_delete_node(hn);
	promote_focus(data);
	signal_design_change(data);
	update_area_conditional(data, FALSE);
	break;
    case HIT_INPUT:
	hs = hit_input_slot(hn, data->mouse_down);

	/* loosen connection if connected */
	if (data->target_check == DESIGNER_CONNECTION_CONNECTABLE) {
	    loosen_connection(data, hn, hs);
	    data->state = STATE_CONOUT;
	    break;
	}
	data->active_node = hn;
	data->active_slot_id = hs;
	data->origin = input_slot_origin(hn, hs);
	// g_print("hit %lf,%lf -> %d\n", event->x, event->y, data->active_slot_id);
	data->state = STATE_CONIN;
	break;
    case HIT_OUTPUT:
	hs = hit_output_slot(hn, data->mouse_down);
	data->active_node = hn;
	data->active_slot_id = hs;
	data->origin = output_slot_origin(hn, data->active_slot_id);
	// g_print("hit %lf,%lf -> %d\n", event->x, event->y, data->active_slot_Id);
	data->state = STATE_CONOUT;
	break;
    default:
	data->state = STATE_IDLE;
	break;
    }

    data->dragging = TRUE;

    gtk_widget_queue_draw(widget);
    return TRUE;
}
Exemplo n.º 17
0
/* *must* be beefed up. */
void _vqgen_seed(vqgen *v){
  long i;
  for(i=0;i<v->entries;i++)
    memcpy(_now(v,i),_point(v,i),sizeof(float)*v->elements);
  v->seeded=1;
}
Exemplo n.º 18
0
/*
 * _parse_gcode_block() - parses one line of NULL terminated G-Code. 
 *
 *	All the parser does is load the state values in gn (next model state) and set flags
 *	in gf (model state flags). The execute routine applies them. The buffer is assumed to 
 *	contain only uppercase characters and signed floats (no whitespace).
 *
 *	A number of implicit things happen when the gn struct is zeroed:
 *	  - inverse feed rate mode is cancelled - set back to units_per_minute mode
 */
static stat_t _parse_gcode_block(char_t *buf) 
{
	char *pstr = (char *)buf;		// persistent pointer into gcode block for parsing words
  	char letter;					// parsed letter, eg.g. G or X or Y
	float value = 0;				// value parsed from letter (e.g. 2 for G2)
	stat_t status = STAT_OK;

	// set initial state for new move 
	memset(&gp, 0, sizeof(gp));		// clear all parser values
	memset(&gf, 0, sizeof(gf));		// clear all next-state flags
	memset(&gn, 0, sizeof(gn));		// clear all next-state values
	gn.motion_mode = cm_get_model_motion_mode();// get motion mode from previous block

  	// extract commands and parameters
	while((status = _get_next_gcode_word(&pstr, &letter, &value)) == STAT_OK) {
		switch(letter) {
			case 'G':
				switch((uint8_t)value) {
					case 0:  SET_MODAL (MODAL_GROUP_G1, motion_mode, MOTION_MODE_STRAIGHT_TRAVERSE);
					case 1:  SET_MODAL (MODAL_GROUP_G1, motion_mode, MOTION_MODE_STRAIGHT_FEED);
					case 2:  SET_MODAL (MODAL_GROUP_G1, motion_mode, MOTION_MODE_CW_ARC);
					case 3:  SET_MODAL (MODAL_GROUP_G1, motion_mode, MOTION_MODE_CCW_ARC);
					case 4:  SET_NON_MODAL (next_action, NEXT_ACTION_DWELL);
					case 10: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_SET_COORD_DATA);
					case 17: SET_MODAL (MODAL_GROUP_G2, select_plane, CANON_PLANE_XY);
					case 18: SET_MODAL (MODAL_GROUP_G2, select_plane, CANON_PLANE_XZ);
					case 19: SET_MODAL (MODAL_GROUP_G2, select_plane, CANON_PLANE_YZ);
					case 20: SET_MODAL (MODAL_GROUP_G6, units_mode, INCHES);
					case 21: SET_MODAL (MODAL_GROUP_G6, units_mode, MILLIMETERS);
					case 28: {
						switch (_point(value)) {
							case 0: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_GOTO_G28_POSITION);
							case 1: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_SET_G28_POSITION); 
							case 2: SET_NON_MODAL (next_action, NEXT_ACTION_SEARCH_HOME); 
							case 3: SET_NON_MODAL (next_action, NEXT_ACTION_SET_ABSOLUTE_ORIGIN);
							default: status = STAT_UNRECOGNIZED_COMMAND;
						}
						break;
					}
					case 30: {
						switch (_point(value)) {
							case 0: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_GOTO_G30_POSITION);
							case 1: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_SET_G30_POSITION); 
							default: status = STAT_UNRECOGNIZED_COMMAND;
						}
						break;
					}
/*					case 38: 
						switch (_point(value)) {
							case 2: SET_NON_MODAL (next_action, NEXT_ACTION_STRAIGHT_PROBE); 
							default: status = STAT_UNRECOGNIZED_COMMAND;
						}
						break;
					}
*/					case 40: break;	// ignore cancel cutter radius compensation
					case 49: break;	// ignore cancel tool length offset comp.
					case 53: SET_NON_MODAL (absolute_override, true);
					case 54: SET_MODAL (MODAL_GROUP_G12, coord_system, G54);
					case 55: SET_MODAL (MODAL_GROUP_G12, coord_system, G55);
					case 56: SET_MODAL (MODAL_GROUP_G12, coord_system, G56);
					case 57: SET_MODAL (MODAL_GROUP_G12, coord_system, G57);
					case 58: SET_MODAL (MODAL_GROUP_G12, coord_system, G58);
					case 59: SET_MODAL (MODAL_GROUP_G12, coord_system, G59);
					case 61: {
						switch (_point(value)) {
							case 0: SET_MODAL (MODAL_GROUP_G13, path_control, PATH_EXACT_PATH);
							case 1: SET_MODAL (MODAL_GROUP_G13, path_control, PATH_EXACT_STOP); 
							default: status = STAT_UNRECOGNIZED_COMMAND;
						}
						break;
					}
					case 64: SET_MODAL (MODAL_GROUP_G13,path_control, PATH_CONTINUOUS);
					case 80: SET_MODAL (MODAL_GROUP_G1, motion_mode,  MOTION_MODE_CANCEL_MOTION_MODE);
					case 90: SET_MODAL (MODAL_GROUP_G3, distance_mode, ABSOLUTE_MODE);
					case 91: SET_MODAL (MODAL_GROUP_G3, distance_mode, INCREMENTAL_MODE);
					case 92: {
						switch (_point(value)) {
							case 0: SET_MODAL (MODAL_GROUP_G0, next_action, NEXT_ACTION_SET_ORIGIN_OFFSETS);
							case 1: SET_NON_MODAL (next_action, NEXT_ACTION_RESET_ORIGIN_OFFSETS);
							case 2: SET_NON_MODAL (next_action, NEXT_ACTION_SUSPEND_ORIGIN_OFFSETS);
							case 3: SET_NON_MODAL (next_action, NEXT_ACTION_RESUME_ORIGIN_OFFSETS); 
							default: status = STAT_UNRECOGNIZED_COMMAND;
						}
						break;
					}
					case 93: SET_MODAL (MODAL_GROUP_G5, inverse_feed_rate_mode, true);
					case 94: SET_MODAL (MODAL_GROUP_G5, inverse_feed_rate_mode, false);
					default: status = STAT_UNRECOGNIZED_COMMAND;
				}
				break;

			case 'M':
				switch((uint8_t)value) {
					case 0: case 1: case 60:
							SET_MODAL (MODAL_GROUP_M4, program_flow, PROGRAM_STOP);
					case 2: case 30:
							SET_MODAL (MODAL_GROUP_M4, program_flow, PROGRAM_END);
					case 3: SET_MODAL (MODAL_GROUP_M7, spindle_mode, SPINDLE_CW);
					case 4: SET_MODAL (MODAL_GROUP_M7, spindle_mode, SPINDLE_CCW);
					case 5: SET_MODAL (MODAL_GROUP_M7, spindle_mode, SPINDLE_OFF);
					case 6: SET_NON_MODAL (change_tool, true);
					case 7: SET_MODAL (MODAL_GROUP_M8, mist_coolant, true);
					case 8: SET_MODAL (MODAL_GROUP_M8, flood_coolant, true);
					case 9: SET_MODAL (MODAL_GROUP_M8, flood_coolant, false);
					case 48: SET_MODAL (MODAL_GROUP_M9, override_enables, true);
					case 49: SET_MODAL (MODAL_GROUP_M9, override_enables, false);
					case 50: SET_MODAL (MODAL_GROUP_M9, feed_rate_override_enable, true); // conditionally true
					case 51: SET_MODAL (MODAL_GROUP_M9, spindle_override_enable, true);	  // conditionally true
					default: status = STAT_UNRECOGNIZED_COMMAND;
				}
				break;

			case 'T': SET_NON_MODAL (tool, (uint8_t)trunc(value));
			case 'F': SET_NON_MODAL (feed_rate, value);
			case 'P': SET_NON_MODAL (parameter, value);				// used for dwell time, G10 coord select
			case 'S': SET_NON_MODAL (spindle_speed, value); 
			case 'X': SET_NON_MODAL (target[AXIS_X], value);
			case 'Y': SET_NON_MODAL (target[AXIS_Y], value);
			case 'Z': SET_NON_MODAL (target[AXIS_Z], value);
			case 'A': SET_NON_MODAL (target[AXIS_A], value);
			case 'B': SET_NON_MODAL (target[AXIS_B], value);
			case 'C': SET_NON_MODAL (target[AXIS_C], value);
		//	case 'U': SET_NON_MODAL (target[AXIS_U], value);		// reserved
		//	case 'V': SET_NON_MODAL (target[AXIS_V], value);		// reserved
		//	case 'W': SET_NON_MODAL (target[AXIS_W], value);		// reserved
			case 'I': SET_NON_MODAL (arc_offset[0], value);
			case 'J': SET_NON_MODAL (arc_offset[1], value);
			case 'K': SET_NON_MODAL (arc_offset[2], value);
			case 'R': SET_NON_MODAL (arc_radius, value);
			case 'N': SET_NON_MODAL (linenum,(uint32_t)value);		// line number
			case 'L': break;										// not used for anything
			default: status = STAT_UNRECOGNIZED_COMMAND;
		}
		if(status != STAT_OK) break;
	}
	if ((status != STAT_OK) && (status != STAT_COMPLETE)) return (status);
	ritorno(_validate_gcode_block());
	return (_execute_gcode_block());		// if successful execute the block
}