Beispiel #1
0
t_list		*map_wires(t_env *e)
{
	t_dot	*c;
	t_list	*wires;

	wires = NULL;
	c = dot(0, 0, 0);
	while (c->y < e->max->y)
	{
		c->x = 0;
		while (c->x < e->max->x)
		{
			if (c->y + 1 < e->max->y)
				ft_lstadd(&wires,
				ft_lstnew(wire(e->map[c->y][c->x], e->map[c->y + 1][c->x]),
				sizeof(t_wire)));
			if (c->x + 1 < e->max->x)
				ft_lstadd(&wires,
				ft_lstnew(wire(e->map[c->y][c->x], e->map[c->y][c->x + 1]),
				sizeof(t_wire)));
			c->x++;
		}
		c->y++;
	}
	return (wires);
}
 explicit CharacterJumpState(Actor *actor) :
     actor_(actor),
     propertyComponent_(wire(actor->getPropertyComponent())),
     physicsComponent_(wire(actor->getPhysicsComponent())),
     jumpInput_(wire(propertyComponent_->findBool("jump-input"))),
     bodyBody_(wire(physicsComponent_->findBody("body")))
 { }
Beispiel #3
0
int readline() {
  SIGNAL in1, in2, out;
  OPTYPE op;
  int ch;

  ch = getchar();
  if(ch == EOF) {
    return 0;
  } else if(ch <= 'z' && ch >= 'a') {
    ungetchar(ch);
    in1 = wire();
  } else if(ch <= '9' && ch >= '0') {
    ungetchar(ch);
    in1 = number();
  } else if(ch == 'N') {
    ungetchar(ch);
    in1.type = NONE;
  }

  ch = getchar();
  switch(ch) {
    case '-': op = ASSIGN; break;
    case 'A': op = AND;    break;
    case 'O': op = OR;     break;
    case 'N': op = NOT;    break;
    case 'L': op = LSHIFT; break;
    case 'R': op = RSHIFT;
  }
  while((ch = getchar()) != ' ');

  if(op == ASSIGN)
    out = wire();
  else {
    ch = getchar();
    if(ch <= 'z' && ch >= 'a') {
      ungetchar(ch);
      in2 = wire();
    } else if(ch <= '9' && ch >= '0') {
      ungetchar(ch);
      in2 = number();
    }

    while((ch = getchar()) != ' ');

    out = wire();
  }

  printfunction(op, in1, in2, out);
  return 1;
}
/**
    Accumulate a list of TopoDS_Edge objects along with their lengths.  We will use
    this repeatedly while we're rendering this text string.  We don't want to re-aquire
    this information for every point of every character.  Cache it here.  This method
    should be called once before each rendering session for the text string.
 */
void COrientationModifier::InitializeFromSketch()
{
    m_edges.clear();
    m_total_edge_length = 0.0;

    if (GetNumChildren() > 0)
    {
        std::list<TopoDS_Shape> wires;
        if (::ConvertSketchToFaceOrWire( GetFirstChild(), wires, false))
        {
            // Aggregate a list of TopoDS_Edge objects and each of their lengths.  We can
            // use this list to skip through edges that we're not interested in.  i.e. the
            // text won't sit on top of them.

            for (std::list<TopoDS_Shape>::iterator itWire = wires.begin(); itWire != wires.end(); itWire++)
            {
                TopoDS_Wire wire(TopoDS::Wire(*itWire));

                for(BRepTools_WireExplorer expEdge(TopoDS::Wire(wire)); expEdge.More(); expEdge.Next())
                {
                    TopoDS_Edge edge(TopoDS_Edge(expEdge.Current()));

                    BRepAdaptor_Curve curve(edge);
                    double edge_length = GCPnts_AbscissaPoint::Length(curve);
                    m_edges.push_back( std::make_pair(edge,edge_length) );
                    m_total_edge_length += edge_length;
                } // End for
            } // End for
        } // End if - then
    } // End if - then
}
Beispiel #5
0
void MediaJack::MouseDown(
	BPoint point,
	uint32 buttons,
	uint32 clicks)
{
	D_MOUSE(("MediaJack::MouseOver()\n"));

	// if connected, redirect to the wire
	if (isConnected())
	{
		dynamic_cast<MediaWire *>(wire())->MouseDown(point, buttons, clicks);
		return;
	}

	// else we handle the mouse event ourselves
	switch (buttons)
	{
		case B_SECONDARY_MOUSE_BUTTON:
		{
			showContextMenu(point);
			break;
		}
		default:
		{
			DiagramEndPoint::MouseDown(point, buttons, clicks);
		}
	}
}
bool WireSet::tryAddElement(const float elementHeight, const float elementRadius) {
    if (wires.size() == 0)
        return false;

    //choose last wire
    Wire& wire(*wiresIterator);
    /**OPTION**/
    //we could instead choose a random wire each time

    //choose random position on that wire
    Element element = wire.makeRandomElement(elementHeight, elementRadius);
    if (element.defined == false)
        return false;
    //check if this element obfuscates existing elements
    //in this instance we must also:
    //	1. each element must be aware of the viewpoints from which it is visible
    //	2. each element must have a minimum number of viewpoints. If viewpoints are to be from opposing sides, then we instead need a different measure of valid coverage of an element. e.g
    //		2.a. Minimum total angle of coverage (presumes cylindrical)
    //		2.b. 2 viewpoints must exist which are > 90degrees apart (or higher threshold) when you measure their polar position with respect to the element
    //
    // this might be a major distraction for the time being
    // let's focus on 1 viewpoint


    /**HACK**/
    //enable here for no occlusion checking
    elements.push_back(element);
    elementsMesh.addVertex(element.position);
    wire.insert(*elements.rbegin());
    return true;


    //check if this element obscures any existing element from a single viewpoint
    //
    // cycle through every other element and get the corner rays
    // check whether those corner rays intersect this element's plane section
    //
    /**OPTIMISE**/
    //we could check only elements on wires which could possibly contain elements which could be in the way (e.g. select a set of possible wires)
    vector<Element>::const_iterator it;
    ofPlane thisFace = element.getFace(viewpoint);
    ofPlane otherFace;
    ofRay otherCornerRays[4];
    for (it = elements.begin(); it != elements.end(); it++) {
        otherFace = it->getFace(viewpoint);
        otherFace.getCornerRaysFrom(viewpoint, otherCornerRays);
        for (int i=0; i<4; i++)
            if (thisFace.intersect(otherCornerRays[i]))
                return false;
    }

    // if we reach here, we're not obstructing any other faces
    // yipee!
    // let's add it
    elements.push_back(element);
    elementsMesh.addVertex(element.position);
    wire.insert(*elements.rbegin());
    return true;
}
Beispiel #7
0
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
    case '\033':	exit(0); break;
    case 'h':		help(); break;
    case 't':		tfunc(); break;
    case 'w':		wire(); break;
    }
}
Beispiel #8
0
int main ()
{	void * ic = new(Ic());
	void * mux = new(Mux());
	int i;
	void * lineOut = new(LineOut());

	for (i = 0; i < 2; ++ i)
		wire(new(Ic()), mux);
	wire(lineOut, mux);
	wire(lineOut, mux);
	wire(mux, ic);
	puto(ic, stdout);
	gate(ic, "hello, world");
	delete(ic);
	delete(mux);
	delete(lineOut);
	return 0;
}
Beispiel #9
0
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
#if NATE
    case 'w': wire(); break;
#endif
    case 'h': help(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
    glutPostRedisplay();
}
void GDSin::Gds2Ted::convert(GDSin::GdsStructure* src, laydata::tdtcell* dst)
{
   //@FIXME!!! ged rid of this silly loop! GDS database is layer oriented now!
   for(int2b laynum = 1 ; laynum < GDS_MAX_LAYER ; laynum++)
   {
      if (src->allLay(laynum))
      {// layers
         GDSin::GdsData *wd = src->fDataAt(laynum);
         while( wd )
         {
            word tdtlaynum;
            if (_theLayMap.getTdtLay(tdtlaynum, laynum, wd->singleType()) )
            {
               // convert only if layer/data type pair is defined
               laydata::tdtlayer* dwl = static_cast<laydata::tdtlayer*>(dst->securelayer(tdtlaynum));
               switch( wd->gdsDataType() )
               {
                  case      gds_BOX: box (static_cast<GDSin::GdsBox*>(wd)     , dwl, laynum);  break;
                  case gds_BOUNDARY: poly(static_cast<GDSin::GdsPolygon*>(wd) , dwl, laynum);  break;
                  case     gds_PATH: wire(static_cast<GDSin::GDSpath*>(wd)    , dwl, laynum);  break;
                  case     gds_TEXT: text(static_cast<GDSin::GdsText*>(wd)    , dwl);  break;
                  default: assert(false); /*Error - unexpected type*/
               }
            }
            //else
            //{
            //   // The message below could be noughty - so put it in place ONLY if the data type
            //   // is different from default
            //   std::ostringstream ost;
            //   ost << "Layer: " << laynum << "; data type: " << wd->singleType() <<
            //         "; found in GDS database, but not in the conversion map.";
            //   tell_log(console::MT_INFO,ost.str());
            //}
            wd = wd->last();
         }
      }
   }
   if (src->allLay(0))
   {// references
      GDSin::GdsData *wd = src->fDataAt(0);
      while( wd )
      {
         switch( wd->gdsDataType() )
         {
            case gds_SREF: ref (static_cast<GDSin::GdsRef*>(wd)   , dst);  break;
            case gds_AREF: aref(static_cast<GDSin::GdsARef*>(wd)  , dst);  break;
                  default: assert(false); /*Error - unexpected type*/
         }
         wd = wd->last();
      }
   }
   dst->resort();
}
Beispiel #11
0
/*ARGSUSED1*/
void
key(unsigned char key, int x, int y) {
    switch(key) {
    case 'l': light(); break;
    case 't': toggle_t(); break;
    case 'w': wire(); break;
    case 'h': help(); break;
    case '\033': exit(EXIT_SUCCESS); break;
    default: break;
    }
    glutPostRedisplay();
}
UBPreferencesController::UBPreferencesController(QWidget *parent)
    : QObject(parent)
    , mPreferencesWindow(0)
    , mPreferencesUI(0)
    , mPenProperties(0)
    , mMarkerProperties(0)
{
    mPreferencesWindow = new QDialog(parent, Qt::Dialog);
    mPreferencesUI = new Ui::preferencesDialog();  // deleted in UBPreferencesController::destructor
    mPreferencesUI->setupUi(mPreferencesWindow);

    wire();
}
Beispiel #13
0
Datei: xrun.c Projekt: AAAJet/ooc
int main (int argc, char * argv [])
{	void * shell = new(XtApplicationShell(), & argc, argv);
	void * form = new(XawForm(), shell, "form");
	void * lineOut = new(XLineOut(), form, "lineOut",
												"........");
	void * calc = new(Calc());
	static const char * const cmd [] = {  "C", "C",
		"1", "1", "2", "2", "3", "3", "a", "+",
		"4", "4", "5", "5", "6", "6", "s", "-",
		"7", "7", "8", "8", "9", "9", "m", "*",
		"Q", "Q", "0", "0", "t", "=", "d", "/", 0 };
	const char * const * cpp;

	wire(lineOut, calc);
	for (cpp = cmd; * cpp; cpp += 2)
	{	void * button = new(XButton(), form, cpp[0], cpp[1]);

		wire(calc, button);
	}
	addAllAccelerators(form);
	mainLoop(shell);
        return 0; /* dummy */
}
Beispiel #14
0
// Received an event, a full packetSignalEvent
void ParticlePMS7003::onEvent(const PollEvent& evt)
{
  // Get the message
  const UartPacket& pkt = UartLinux::uartRead(wire()->handle());

  // Get the message
  const std::string& message = pkt.message;

  // Get the length of the message
  const int msg_len = message.length();

  // Get the pointer to the first character of the message
  const byte* msg_bytes = (byte*) message.c_str();

  // Go through the message byte by byte
  for (int i = 0; i < msg_len; i++)
  {
    // Check if we have a partial message being populated
    if (_partial)
    {
      // Check if it is the correct second start character or any other character
      if (_index != 1 || (_index == 1 && msg_bytes[i] == PMS7003_START_CHAR_2))
      {
        // Put character in buffer
        _buffer[_index] = msg_bytes[i];

        // Increment message and Callback on the end of message if needed
        if (++_index == PMS7003_MESSAGE_LEN) { onMessage(); }
      }
      // There is a mistake we reset the buffer
      else { resetBuffer(); }
    }
    // We do not have a partial message yet, looking for the begining
    else
    {
      // Check if it could be begining of message
      if (msg_bytes[i] == PMS7003_START_CHAR_1)
      {
        // Initialize new message
        _buffer[0] = msg_bytes[i];
        _partial = true;
        _index = 1;
      }
    }
  }
}
bool WireSet::tryAddWire() {
    // try and add a wire at this radius
    // check whether would exceed density
    // check whether within bounds of size
    for (int i=0; i<WIRESET_MAX_TRIES_PER_RADIUS; i++) {
        Wire wire(radius, height, center);
        if (!inside(wire))
            continue;
        if (!isDensityHigh(wire)) {
            wires.push_back(wire);
            return true;
        }
    }

    // if we reach here then we didn't find a suitable wire
    // return an undefined wire
    return false;
}
UBPreferencesController::UBPreferencesController(QWidget *parent)
    : QObject(parent)
    , mPreferencesWindow(0)
    , mPreferencesUI(0)
    , mPenProperties(0)
    , mMarkerProperties(0)
{
    mDesktop = qApp->desktop();
    mPreferencesWindow = new UBPreferencesDialog(this,parent, Qt::Dialog);
    mPreferencesUI = new Ui::preferencesDialog();  // deleted in
    mPreferencesUI->setupUi(mPreferencesWindow);
    adjustScreens(1);
    connect(mDesktop, SIGNAL(screenCountChanged(int)), this, SLOT(adjustScreens(int)));

    connect(mPreferencesUI->languageComboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(onLanguageChanged(QString)));

    wire();
}
void CIFin::Cif2Ted::convert(CIFin::CifStructure* src, laydata::tdtcell* dst)
{
   _crosscoeff = _dbucoeff * src->a() / src->b();
   CIFin::CifLayer* swl = src->firstLayer();
   while( swl ) // loop trough the layers
   {
      if (_cif_layers->end() != _cif_layers->find(swl->name()))
      {
         laydata::tdtlayer* dwl =
               static_cast<laydata::tdtlayer*>(dst->securelayer((*_cif_layers)[swl->name()]));
         CIFin::CifData* wd = swl->firstData();
         while ( wd ) // loop trough data
         {
            switch (wd->dataType())
            {
               case cif_BOX     : box ( static_cast<CIFin::CifBox*     >(wd), dwl, swl->name() );break;
               case cif_POLY    : poly( static_cast<CIFin::CifPoly*    >(wd), dwl, swl->name() );break;
               case cif_WIRE    : wire( static_cast<CIFin::CifWire*    >(wd), dwl, swl->name() );break;
               case cif_LBL_LOC : lbll( static_cast<CIFin::CifLabelLoc*>(wd), dwl, swl->name() );break;
               case cif_LBL_SIG : lbls( static_cast<CIFin::CifLabelSig*>(wd), dwl, swl->name() );break;
               default    : assert(false);
            }
            wd = wd->last();
         }
      }
      //else
      //{
      //   std::ostringstream ost;
      //   ost << "CIF Layer name \"" << swl->name() << "\" is not defined in the function input parameter. Will be omitted";
      //   tell_log(console::MT_INFO,ost.str());
      //}
      swl = swl->last();
   }

   CIFin::CifRef* swr = src->refirst();
   while ( swr )
   {
      ref(swr,dst);
      swr = swr->last();
   }
   dst->resort();
}
MultiplexerGraph::MultiplexerGraph(int inputs,
    sf::Vector2f pos,
    sf::Font& consolas,
    bool seltop) :
    Graph(pos, consolas, "MUX", sf::Vector2f(40, 15*inputs)),
    inputs(inputs)
{
    last = 0;

    for(int i = 0; i < inputs; i++)
    {
        sf::VertexArray wire(sf::LinesStrip, 4);
        wire[0] = sf::Vertex(sf::Vector2f(0, 23 + i*15), sf::Color(220, 220, 220));
        wire[1] = sf::Vertex(sf::Vector2f(20, 23 + i*15), sf::Color(220, 220, 220));
        wire[2] = sf::Vertex(sf::Vector2f(20, 16 + (15*inputs)/2), sf::Color(220, 220, 220));
        wire[3] = sf::Vertex(sf::Vector2f(40, 16 + (15*inputs)/2), sf::Color(220, 220, 220));

        addPort(sf::Vector2f(0, 23 + i*15), "I", consolas, true);

        if(last == i)
        {
            active = wire;
            active[0].color = sf::Color::Red;
            active[1].color = sf::Color::Red;
            active[2].color = sf::Color::Red;
            active[3].color = sf::Color::Red;

        }

        wires.push_back(wire);

    }

    addPort(sf::Vector2f(40, 16 + (15*inputs)/2), "O", consolas, false);
    addPort(sf::Vector2f(20, seltop ? 0 : 16 + 15*inputs), "Sel", consolas, !seltop);

}
Beispiel #19
0
int
Component::compare(const Component& other) const
{
  if (this->hasWire() && other.hasWire()) {
    // In the common case where both components have wire encoding,
    // it's more efficient to simply compare the wire encoding.
    // This works because lexical order of TLV encoding happens to be
    // the same as canonical order of the value.
    return std::memcmp(wire(), other.wire(), std::min(size(), other.size()));
  }

  int cmpType = type() - other.type();
  if (cmpType != 0)
    return cmpType;

  int cmpSize = value_size() - other.value_size();
  if (cmpSize != 0)
    return cmpSize;

  if (empty())
    return 0;

  return std::memcmp(value(), other.value(), value_size());
}
Beispiel #20
0
/* datagn is the main routine for input of geometry data. */
  gboolean
datagn( void )
{
  char gm[3];

  /* input card mnemonic list */
  char *atst[] =
  {
    "GW", "GX", "GR", "GS", "GE","GM", "SP",\
    "SM", "GA", "SC", "GH", "GF", "CT"
  };

  int nwire, isct, itg, iy=0, iz;
  size_t mreq;
  int ix, i, ns, gm_num; /* geometry card id as a number */
  double rad, xs1, xs2, ys1, ys2, zs1, zs2;
  double x3=0, y3=0, z3=0, x4=0, y4=0, z4=0;
  double xw1, xw2, yw1, yw2, zw1, zw2;
  double dummy;

  data.ipsym=0;
  nwire=0;
  data.n=0;
  data.np=0;
  data.m=0;
  data.mp=0;
  isct=0;
  structure_proj_params.r_max = 0.0;

  /* read geometry data card and branch to */
  /* section for operation requested */
  do
  {
    if( !readgm(gm, &itg, &ns, &xw1, &yw1, &zw1, &xw2, &yw2, &zw2, &rad) )
      return( FALSE );

    /* identify card id mnemonic */
    for( gm_num = 0; gm_num < NUM_GEOMN; gm_num++ )
      if( strncmp( gm, atst[gm_num], 2) == 0 )
        break;

    if( gm_num != 9 ) isct=0;

    switch( gm_num )
    {
      case GW: /* "gw" card, generate segment data for straight wire. */
        if( Tag_Seg_Error(itg, ns) ) return( FALSE );
        nwire++;

        if( rad != 0.0)
        {
          xs1=1.0;
          ys1=1.0;
        }
        else
        {
          if( !readgm(gm, &ix, &iy, &xs1, &ys1, &zs1,
              &dummy, &dummy, &dummy, &dummy) )
              return( FALSE );

          if( strcmp(gm, "GC" ) != 0 )
          {
            fprintf( stderr,
                "xnec2c: datagn(): geometry data card error "
                "no GC card for tapered wire\n" );
            stop( _("datagn(): Geometry data error\n"\
                  "No GC card for tapered wire"), ERR_OK );
            return( FALSE );
          }

          if( (ys1 == 0.0) || (zs1 == 0.0) )
          {
            fprintf( stderr, "xnec2c: datagn(): geometry GC data card error\n" );
            stop( _("datagn(): Geometry GC data card error"), ERR_OK );
            return( FALSE );
          }

          rad= ys1;
          ys1= pow( (zs1/ys1), (1.0/(ns-1.0)) );
        }

        wire( xw1, yw1, zw1, xw2, yw2, zw2, rad, xs1, ys1, ns, itg);
        continue;

        /* reflect structure along x,y, or z */
        /* axes or rotate to form cylinder.  */
      case GX: /* "gx" card */
        if( (ns < 0) || (itg < 0) )
        {
          fprintf( stderr, "xnec2c: datagn(): geometry GX data card error\n" );
          stop( _("datagn(): Geometry GX data card error"), ERR_OK );
          return( FALSE );
        }

        iy= ns/10;
        iz= ns- iy*10;
        ix= iy/10;
        iy= iy- ix*10;

        if( ix != 0)
          ix=1;
        if( iy != 0)
          iy=1;
        if( iz != 0)
          iz=1;

        if( !reflc(ix, iy, iz, itg, ns) )
          return( FALSE );
        continue;

      case GR: /* "gr" card */
        if( (ns < 0) || (itg < 0) )
        {
          fprintf( stderr, "xnec2c: datagn(): geometry GR data card error\n" );
          stop( _("datagn(): Geometry GR data card error"), ERR_OK );
          return( FALSE );
        }

        ix=-1;
        iz = 0;
        if( !reflc(ix, iy, iz, itg, ns) )
          return( FALSE );
        continue;

      case GS: /* "gs" card, scale structure dimensions by factor xw1 */
        if( (itg > 0) && (ns > 0) && (ns >= itg) )
        {
          for( i = 0; i < data.n; i++ )
          {
            if( (data.itag[i] >= itg) && (data.itag[i] <= ns) )
            {
              data.x1[i]= data.x1[i]* xw1;
              data.y1[i]= data.y1[i]* xw1;
              data.z1[i]= data.z1[i]* xw1;
              data.x2[i]= data.x2[i]* xw1;
              data.y2[i]= data.y2[i]* xw1;
              data.z2[i]= data.z2[i]* xw1;
              data.bi[i]= data.bi[i]* xw1;
            }
          }
          /* FIXME corrects errors when GS follows GX but this is just a work-around */
          data.np = data.n;
          data.ipsym = 0;
        }
        else for( i = 0; i < data.n; i++ )
        {
          data.x1[i]= data.x1[i]* xw1;
          data.y1[i]= data.y1[i]* xw1;
          data.z1[i]= data.z1[i]* xw1;
          data.x2[i]= data.x2[i]* xw1;
          data.y2[i]= data.y2[i]* xw1;
          data.z2[i]= data.z2[i]* xw1;
          data.bi[i]= data.bi[i]* xw1;
        }

        yw1= xw1* xw1;
        for( i = 0; i < data.m; i++ )
        {
          data.px[i] = data.px[i]* xw1;
          data.py[i] = data.py[i]* xw1;
          data.pz[i] = data.pz[i]* xw1;
          data.pbi[i]= data.pbi[i]* yw1;
        }
        continue;

      case GE: /* "ge" card, terminate structure geometry input. */
        /* My addition, for drawing */
        if( ((data.n > 0) || (data.m > 0)) && !CHILD )
          Init_Struct_Drawing();
        else if( (data.n == 0) && (data.m == 0) )
        {
          stop( _("No geometry data cards"), ERR_OK );
          return( FALSE );
        }

        if( !conect(itg) ) return( FALSE );

        if( data.n != 0)
        {
          /* Allocate wire buffers */
          mreq = (size_t)data.n * sizeof(double);
          mem_realloc( (void **)&data.si,   mreq, "in input.c" );
          mem_realloc( (void **)&data.sab,  mreq, "in input.c" );
          mem_realloc( (void **)&data.cab,  mreq, "in input.c" );
          mem_realloc( (void **)&data.salp, mreq, "in input.c" );
          mem_realloc( (void **)&data.x, mreq, "in input.c" );
          mem_realloc( (void **)&data.y, mreq, "in input.c" );
          mem_realloc( (void **)&data.z, mreq, "in input.c" );

          for( i = 0; i < data.n; i++ )
          {
            xw1= data.x2[i]- data.x1[i];
            yw1= data.y2[i]- data.y1[i];
            zw1= data.z2[i]- data.z1[i];
            data.x[i]=( data.x1[i]+ data.x2[i])/2.0;
            data.y[i]=( data.y1[i]+ data.y2[i])/2.0;
            data.z[i]=( data.z1[i]+ data.z2[i])/2.0;
            xw2= xw1* xw1+ yw1* yw1+ zw1* zw1;
            yw2= sqrt( xw2);
            //yw2=( xw2/yw2 + yw2)/2.0;
            data.si[i]= yw2;
            data.cab[i]= xw1/ yw2;
            data.sab[i]= yw1/ yw2;
    
            xw2= zw1/ yw2;
            if( xw2 > 1.0)
              xw2=1.0;
            if( xw2 < -1.0)
              xw2=-1.0;
            data.salp[i]= xw2;

            //xw2= asin( xw2)* TD;
            //yw2= atan2( yw1, xw1)* TD;

            if( (data.si[i] <= 1.0e-20) || (data.bi[i] <= 0.0) )
            {
              fprintf( stderr, "xnec2c: datagn(): segment data error\n" );
              stop( _("datagn(): Segment data error"), ERR_OK );
              return( FALSE );
            }

          } /* for( i = 0; i < data.n; i++ ) */

        } /* if( data.n != 0) */

        if( data.m != 0)
        {
          for( i = 0; i < data.m; i++ )
          {
            xw1=( data.t1y[i]* data.t2z[i] -
                data.t1z[i]* data.t2y[i])* data.psalp[i];
            yw1=( data.t1z[i]* data.t2x[i] -
                data.t1x[i]* data.t2z[i])* data.psalp[i];
            zw1=( data.t1x[i]* data.t2y[i] -
                data.t1y[i]* data.t2x[i])* data.psalp[i];
          } /* for( i = 0; i < data.m; i++ ) */

        } /* if( data.m != 0) */

        data.npm  = data.n+data.m;
        data.np2m = data.n+2*data.m;
        data.np3m = data.n+3*data.m;

        return( TRUE );

        /* "gm" card, move structure or reproduce */
        /* original structure in new positions.   */
      case GM:
        {
          int tgf = (int)(rad + 0.5);
          if( (tgf < 0) || (ns < 0) || (rad < 0.0) )
          {
            fprintf( stderr, "xnec2c: datagn(): move GM data card error\n" );
            stop( _("datagn(): Move GM data card error"), ERR_OK );
            return( FALSE );
          }
          xw1= xw1* TA;
          yw1= yw1* TA;
          zw1= zw1* TA;
          if( !move(xw1, yw1, zw1, xw2, yw2, zw2, (int)(rad+.5), ns, itg) )
            return( FALSE );
        }
        continue;

      case SP: /* "sp" card, generate single new patch */
        ns++;

        if( itg != 0)
        {
          fprintf( stderr, "xnec2c: datagn(): patch data card error\n" );
          stop( _("datagn(): Patch data card error"), ERR_OK );
          return( FALSE );
        }

        if( (ns == 2) || (ns == 4) )
          isct=1;

        if( ns > 1)
        {
          if( !readgm(gm, &ix, &iy, &x3, &y3,
                &z3, &x4, &y4, &z4, &dummy) )
            return( FALSE );

          if( (ns == 2) || (itg > 0) )
          {
            x4= xw1+ x3- xw2;
            y4= yw1+ y3- yw2;
            z4= zw1+ z3- zw2;
          }

          if( strcmp(gm, "SC") != 0 )
          {
            fprintf( stderr, "xnec2c: datagn(): patch data error\n" );
            stop( _("datagn(): Patch data error"), ERR_OK );
            return( FALSE );
          }

        } /* if( ns > 1) */
        else
        {
          xw2= xw2* TA;
          yw2= yw2* TA;
        }

        if( !patch( itg, ns, xw1, yw1, zw1, xw2,
            yw2, zw2, x3, y3, z3, x4, y4, z4) )
            return( FALSE );
        continue;

      case SM: /* "sm" card, generate multiple-patch surface */
        if( (itg < 1) || (ns < 1) )
        {
          fprintf( stderr, "datagn(): xnec2c: patch card data error\n" );
          stop( _("datagn(): Patch data card error"), ERR_OK );
          return( FALSE );
        }

        if( !readgm(gm, &ix, &iy, &x3, &y3,
              &z3, &x4, &y4, &z4, &dummy) )
          return( FALSE );

        if( (ns == 2) || (itg > 0) )
        {
          x4= xw1+ x3- xw2;
          y4= yw1+ y3- yw2;
          z4= zw1+ z3- zw2;
        }

        if( strcmp(gm, "SC" ) != 0 )
        {
          fprintf( stderr, "xnec2c: datagn(): patch card data error\n" );
          stop( _("datagn(): Patch data card error"), ERR_OK );
          return( FALSE );
        }

        if( !patch(itg, ns, xw1, yw1, zw1, xw2,
            yw2, zw2, x3, y3, z3, x4, y4, z4) )
          return( FALSE );
        continue;

      case GA: /* "ga" card, generate segment data for wire arc */
        if( Tag_Seg_Error(itg, ns) ) return( FALSE );
        nwire++;
        if( !arc(itg, ns, xw1, yw1, zw1, xw2) ) return( FALSE );
        continue;

      case SC: /* "sc" card */
        if( isct == 0)
        {
          fprintf( stderr, "xnec2c: datagn(): patch data card error\n" );
          stop( _("datagn(): Patch data card error"), ERR_OK );
          return( FALSE );
        }

        ns++;

        if( (itg != 0) || ((ns != 2) && (ns != 4)) )
        {
          fprintf( stderr, "xnec2c: datagn(): patch data card error\n" );
          stop( _("datagn(): Patch data card error"), ERR_OK );
          return( FALSE );
        }

        xs1= x4;
        ys1= y4;
        zs1= z4;
        xs2= x3;
        ys2= y3;
        zs2= z3;
        x3= xw1;
        y3= yw1;
        z3= zw1;

        if( ns == 4)
        {
          x4= xw2;
          y4= yw2;
          z4= zw2;
        }

        xw1= xs1;
        yw1= ys1;
        zw1= zs1;
        xw2= xs2;
        yw2= ys2;
        zw2= zs2;

        if( ns != 4)
        {
          x4= xw1+ x3- xw2;
          y4= yw1+ y3- yw2;
          z4= zw1+ z3- zw2;
        }

        if( !patch(itg, ns, xw1, yw1, zw1, xw2,
            yw2, zw2, x3, y3, z3, x4, y4, z4) )
          return( FALSE );
        continue;

      case GH: /* "gh" card, generate helix */
        if( Tag_Seg_Error(itg, ns) ) return( FALSE );
        nwire++;
        helix( xw1, yw1, zw1, xw2, yw2, zw2, rad, ns, itg);
        continue;

      case GF: /* "gf" card, not supported */
        fprintf( stderr, "xnec2c: datagn(): \"GF\" card (NGF solution) "
                "is not supported\n" );
        stop( _("datagn(): \"GF\" card (NGF solution)\n"\
              "is not supported"), ERR_OK );
        return( FALSE );

      case CT: /* Ignore in-data comments (NEC4 compatibility) */
        fprintf( stderr, "xnec2c: datagn(): ignoring CM card in geometry\n" );
        stop( _("datagn(): Ignoring CM card in geometry"), ERR_OK );
        continue;

      default: /* error message */
        fprintf( stderr, "xnec2c: datagn(): geometry data card error\n" );
        fprintf( stderr,
            "%2s %3d %5d %10.5f %10.5f %10.5f"
            " %10.5f %10.5f %10.5f %10.5f\n",
            gm, itg, ns, xw1, yw1, zw1, xw2, yw2, zw2, rad );

        stop( _("datagn(): Geometry data card error"), ERR_OK );
        return( FALSE );

    } /* switch( gm_num ) */

  } /* do */
  while( TRUE );

} /* datagn() */
Beispiel #21
0
static void SimplifySketch(const double deviation, bool make_bspline )
{

    wxGetApp().CreateUndoPoint();

    double original_tolerance = wxGetApp().m_geom_tol;
    wxGetApp().m_geom_tol = sketch_tool_options.m_cleanup_tolerance;

    std::list<HeeksObj *> selected_sketches;
    std::copy( wxGetApp().m_marked_list->list().begin(), wxGetApp().m_marked_list->list().end(),
                std::inserter( selected_sketches, selected_sketches.begin() ));

	std::list<HeeksObj*>::const_iterator It;
	for(It = selected_sketches.begin(); It != selected_sketches.end(); It++){
		HeeksObj* object = *It;
		std::list<HeeksObj *> new_objects;

		if (object->GetType() == SketchType)
		{
			std::list<TopoDS_Shape> wires;
			try {
				heekscad_interface.ConvertSketchToFaceOrWire(object, wires, false);
			} // End try
			catch(...)
			{
				continue;
			}
			for (std::list<TopoDS_Shape>::iterator itWire = wires.begin(); itWire != wires.end(); itWire++)
			{
				std::list<SimplifySketchTool::SortPoint> points = SimplifySketchTool::GetPoints( TopoDS::Wire(*itWire), deviation );

				if (sketch_tool_options.m_sort_points)
				{
					// The sort points option is turned on.  The idea of this is to detect shapes that include
					// sections that 'double back' on themselves.  The first example being a shape made up of
					// a box as well as a single line that layed along one edge of the box.  In this case the extra
					// line was superfluous.  If we sort the points so that each point is closest to the previous
					// point then, hopefully, we will reorder these shapes that double back on themselves.  If this
					// doesn't work then the user can always turn the 'sort points' option off and try again.

					std::vector<SimplifySketchTool::SortPoint> sorted_points;
					std::copy( points.begin(), points.end(), std::inserter( sorted_points, sorted_points.begin() ));

					for (std::vector<SimplifySketchTool::SortPoint>::iterator l_itPoint = sorted_points.begin(); l_itPoint != sorted_points.end(); l_itPoint++)
					{
						// We've already begun.  Just sort based on the previous point's location.
						std::vector<SimplifySketchTool::SortPoint>::iterator l_itNextPoint = l_itPoint;
						l_itNextPoint++;

						if (l_itNextPoint != sorted_points.end())
						{
							SimplifySketchTool::sort_points_by_distance compare( *l_itPoint );
							std::sort( l_itNextPoint, sorted_points.end(), compare );
						} // End if - then
					} // End for

					points.clear();
					std::copy( sorted_points.begin(), sorted_points.end(), std::inserter( points, points.begin() ));

					// This sorting process will have resulted in the start and end points being located next to each other
					// and hence removed.  If the original wire was periodic (closed shape) then make sure the last point
					// is the same as the first point.

					TopoDS_Wire wire(TopoDS::Wire(*itWire));
					if (wire.Closed())
					{
						if (*(points.begin()) != *(points.rbegin()))
						{
							points.push_back(*points.begin());	// Close the shape manually.
						}
					}
				}

				// Whether we sorted or not, we may want to close the shape.
				if (sketch_tool_options.m_force_closed_shape)
				{
					if (*(points.begin()) != *(points.rbegin()))
					{
						points.push_back(*points.begin());	// Close the shape manually.
					}
				}

				// Now keep removing points from this list as long as the midpoints are within deviation of
				// the line between the two neighbour points.
				bool points_removed = false;
				do {
					points_removed = false;

					for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++ )
					{
						std::list<SimplifySketchTool::SortPoint>::iterator itP1 = itPoint;
						std::list<SimplifySketchTool::SortPoint>::iterator itP2 = itPoint;
						std::list<SimplifySketchTool::SortPoint>::iterator itP3 = itPoint;

						itP2++;
						if (itP2 != points.end())
						{
							itP3 = itP2;
							itP3++;

							if (itP3 != points.end())
							{
								// First see if p1 and p2 are too close to each other.
								if (itP1->Distance(*itP2) < deviation)
								{
									// Discard p2.
									points.erase(itP2);
									points_removed = true;
									continue;
								}

								if (itP2->Distance(*itP3) < deviation)
								{
									// Discard p2
									points.erase(itP2);
									points_removed = true;
									continue;
								}

                                if (itP1->Distance(*itP3) > deviation)
                                {
                                    // Now draw a line between p1 and p3.  Measure the distance between p2 and the nearest point
                                    // along that line.  If this distance is less than the max deviation then discard p2.
                                    gp_Lin line(*itP1, gp_Dir(itP3->X() - itP1->X(), itP3->Y() - itP1->Y(), itP3->Z() - itP1->Z()));
                                    if (line.SquareDistance(*itP2) < deviation)
                                    {
                                        // Discard p2
                                        points.erase(itP2);
                                        points_removed = true;
                                        continue;
                                    }
                                }
							}
						}
					} // End for
				} while (points_removed == true);

				if (points.size() >= 2)
				{
					


				    if (make_bspline)
				    {
				        try {
                            TColgp_Array1OfPnt Points(0, points.size()-1);
                            Standard_Integer i=0;
                            for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++, i++)
                            {
                                Points.SetValue(i, *itPoint);
                            }

                            // GeomAPI_PointsToBSpline bspline(Points);

                            GeomAPI_PointsToBSpline bspline(Points,
                                                            sketch_tool_options.m_degree_min,
                                                            sketch_tool_options.m_degree_max,
                                                            GeomAbs_Shape(sketch_tool_options.m_continuity),
                                                            sketch_tool_options.m_cleanup_tolerance);

                            // Standard_EXPORT GeomAPI_PointsToBSpline(const TColgp_Array1OfPnt& Points,const Standard_Integer DegMin = 3,const Standard_Integer DegMax = 8,const GeomAbs_Shape Continuity = GeomAbs_C2,const Standard_Real Tol3D = 1.0e-3);

                            HSpline *hspline = new HSpline(bspline.Curve(), &(wxGetApp().current_color));
                            heekscad_interface.Add( hspline, NULL );
				        }
				        catch (Standard_Failure) {
                            Handle_Standard_Failure e = Standard_Failure::Caught();
                            wxMessageBox(_("Failed to create BSpline curve"));
                        }
				    } // End if - then
				    else
				    {
				        // We're making straight lines

                        HeeksObj *sketch = heekscad_interface.NewSketch();
                        for (std::list<SimplifySketchTool::SortPoint>::iterator itPoint = points.begin(); itPoint != points.end(); itPoint++)
                        {
                            std::list<SimplifySketchTool::SortPoint>::iterator itNext = itPoint;
                            itNext++;
                            if (itNext == points.end()) continue;

                            double start[3], end[3];
                            itPoint->ToDoubleArray(start);
                            itNext->ToDoubleArray(end);

                            sketch->Add(heekscad_interface.NewLine(start, end), NULL);
                        } // End for

                        // heekscad_interface.Add(sketch, NULL);
                        new_objects.push_back(sketch);
				    } // End if - else
				} // End if - then
			} // End for

            if (new_objects.size() > 0)
            {
#ifdef MULTIPLE_OWNERS
                std::list<HeeksObj *> parents = object->Owners();
                for (std::list<HeeksObj *>::iterator itOwner = parents.begin(); itOwner != parents.end(); itOwner++)
                {
#else
				if(object->m_owner)
				{
#endif
                    if ((object->CanEditString()) && (object->GetShortString()))
                    {
                        // (*itOwner)->Remove(object);

                        // Mark the old sketches with a name that can be easily recognised so that we can delete the
                        // old objects if we're satisfied with the replacements.
                        wxString title;
                        title << _("Replaced ") << object->GetShortString();
                        object->OnEditString(title);
                    } // End if - then

                    for (std::list<HeeksObj *>::iterator itNewChild = new_objects.begin(); itNewChild != new_objects.end(); itNewChild++)
                    {
#ifdef MULTIPLE_OWNERS
                        (*itOwner)->Add( *itNewChild, NULL );
#else
                        object->m_owner->Add( *itNewChild, NULL );
#endif
                    } // End for
                } // End for
            } // End if - then
		} // End if - then
	} // End for

    wxGetApp().m_geom_tol = original_tolerance;
    wxGetApp().Changed();
}

void SimplifySketchTool::Run()
{
    SimplifySketch(m_deviation, false);
} // End Run() method
Beispiel #22
0
Block::operator boost::asio::const_buffer() const
{
  return boost::asio::const_buffer(wire(), size());
}
Beispiel #23
0
void WireExport::Export(string folder, string fileName)
{
	MStatus stat;

	mFolder = folder;
	mFileName = fileName;

	mSaver.SetFolder(mFolder);

	MItDependencyNodes itRenderLayers(MFn::kRenderLayer,&stat);
	err_code(stat);

	MFnRenderLayer wireLayer;
	while (!itRenderLayers.isDone())
	{		
		MFnRenderLayer renderLayer( itRenderLayers.item() );

		if (renderLayer.name() == "wire")
		{
			stat = wireLayer.setObject( renderLayer.object() );
			err_code(stat);
			break;
		}

		stat = itRenderLayers.next();
		err_code(stat);
	}

	MItDependencyNodes itDepCurve(MFn::kNurbsCurve,&stat);
	err_code(stat);

	vector<Wire> wires;

	while (!itDepCurve.isDone())
	{
		MObject obj = itDepCurve.item();
		MFnNurbsCurve wire(obj, &stat);
		err_code(stat);

		bool objInLayer = wireLayer.inLayer(obj, &stat);
		//err_code(stat);	

		if (!objInLayer)
		{
			stat = itDepCurve.next();
			err_code(stat);	
			continue;
		}

		MString cmd = MString("reference -q -f ") + wire.name();
		MString file_id;
		stat = MGlobal::executeCommand( cmd, file_id );
		if( stat == MS::kSuccess ) 
		{ 
			itDepCurve.next();
			continue;
		}

		MObject parentObj = wire.parent(0, &stat);
		err_code(stat);

		Wire newWire;
		newWire.name = wire.name().asChar();

		
		MPointArray points;

		stat = wire.getCVs(points);			
		err_code(stat);


		int numOfPoints = points.length();
		for (int n = 0; n < numOfPoints ; n++)
		{
			MPoint point = points[n];
			WirePoint wirePoint;
			wirePoint.x = (float)point.x;
			wirePoint.z = (float)point.z;

			double param;
			stat = wire.getParamAtPoint( point, param );
			err_code(stat);

			MVector	tangent = wire.tangent( param , MSpace::kObject, &stat);
			err_code(stat);

			tangent.normalize();

			wirePoint.tx = (float)tangent.x;
			wirePoint.tz = (float)tangent.z;

			newWire.wirePoints.push_back(wirePoint);
		}

		wires.push_back(newWire);

		stat = itDepCurve.next();
		err_code(stat);
	}

	WriteWires(wires);


}
Beispiel #24
0
bool maze_router::lee_algorithm(int x1, int y1, int x2, int y2, int m){
  //std::cout << x1 << "," << y1 << " -> " << x2 << "," << y2 << std::endl;
  
  std::vector<coord> cset; //current set
  std::vector<coord> nset; //neighbor set
  int wave = 1;
  bool targetFound = 0;

  //this->print_grid(ccols, crows);

  // init the current set
  cset.push_back(coord(x1, y1));
  grid[x1][y1].val = wave;
  
  
  while(!targetFound){
  //for(int pass = 0; pass < 70; pass++){
    //set wave
    wave++;
    if (wave == 10){wave = 1;}

    // find neighbors
    //std::cout << "Checking Neighbors." << std::endl;
    //std::cout << "Cset = " << cset.size() <<  "; Nset = " << nset.size() << std::endl;
    for ( int i = 0; i < cset.size(); i++){
      if (this->check_neighbor(cset[i].x+1, cset[i].y, m)) {nset.push_back(coord(cset[i].x+1, cset[i].y));}
      if (this->check_neighbor(cset[i].x-1, cset[i].y, m)) {nset.push_back(coord(cset[i].x-1, cset[i].y));}
      if (this->check_neighbor(cset[i].x, cset[i].y+1, m)) {nset.push_back(coord(cset[i].x, cset[i].y+1));}
      if (this->check_neighbor(cset[i].x, cset[i].y-1, m)) {nset.push_back(coord(cset[i].x, cset[i].y-1));}
    }
    if (nset.size() == 0) {
      // no neighbors, no route
      this->reset_grid(ccols, crows);
      return 0;
    }
    
    // wave propagation
    //std::cout << "Propagating Wave." << std::endl;
    //std::cout << "Cset = " << cset.size() <<  "; Nset = " << nset.size() << std::endl;
    for ( int i = 0; i < nset.size(); i++){
      grid[nset[i].x][nset[i].y].val = wave;
      // check if target was found
      if((nset[i].x == x2) && (nset[i].y == y2)) {targetFound = 1;}
    }
    
    
    // reset sets
    //std::cout << "Re-setting." << std::endl;
    //cset.erase(cset.begin(), cset.end());
    cset.clear();
    for( int i = 0; i < nset.size(); i++){
      cset.push_back(nset[i]);
    }
    //nset.erase(nset.begin(), nset.end());
    nset.clear();
  }

  //this->print_grid(ccols, crows);

  // trace route back to source
  bool routeFound = 0;
  coord cur = coord(x2, y2);
  coord wstart = cur;
  bool vert = 1;
  while (!routeFound){
    coord next = this->check_nvals(cur.x, cur.y, grid[cur.x][cur.y].val, vert);
    //check if wire ends (change in direction)
    if (((cur.x == next.x) && (vert == 0)) || ((cur.y == next.y) && (vert == 1))){
      if (m == 1){
	metal1.push_back(wire(wstart.x, wstart.y, cur.x, cur.y));
      } else {
	metal2.push_back(wire(wstart.x, wstart.y, cur.x, cur.y));
      }
      wstart = cur;
    }

    //track direction
    if (cur.x == next.x) {vert = 1;}
    if (cur.y == next.y) {vert = 0;}

    if (m == 1) {
      grid[cur.x][cur.y].m1 = 1;
      if (vert){
	grid[cur.x+1][cur.y].m1buf = 1;
	grid[cur.x-1][cur.y].m1buf = 1;
      } else {
	grid[cur.x][cur.y+1].m1buf = 1;
	grid[cur.x][cur.y-1].m1buf = 1;
      }
    }
    if (m == 2) {
      grid[cur.x][cur.y].m2 = 1;
      if (vert){
	grid[cur.x+1][cur.y].m2buf = 1;
	grid[cur.x-1][cur.y].m2buf = 1;
      } else {
	grid[cur.x][cur.y+1].m2buf = 1;
	grid[cur.x][cur.y-1].m2buf = 1;
      }
    }
    
    cur = next;
    
    if ((cur.x == x1) && (cur.y == y1)) {
      //add final wire
      if (m == 1){
	metal1.push_back(wire(wstart.x, wstart.y, cur.x, cur.y));
      } else {
	metal2.push_back(wire(wstart.x, wstart.y, cur.x, cur.y));
      }
      routeFound = 1;
    }
  }
    
  //this->print_grid(ccols, crows);
  this->reset_grid(ccols, crows);
  //this->print_grid(ccols, crows);
  return 1;
}
 explicit CharacterFallState(Actor *actor) :
     actor_(actor),
     propertyComponent_(wire(actor->getPropertyComponent())),
     physicsComponent_(wire(actor->getPhysicsComponent()))
 { }
Beispiel #26
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QWidget container;
	container.resize(640, 680);
	container.setFocusPolicy ( Qt::NoFocus );
	Engine engine(NULL);

	QMenuBar open_menu_bar(&container);
	QMenu open_menu("&File", &container);

	QAction open("&Open", &container);
	open.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O));
	open_menu.addAction(&open);

	QAction reset("&Reset", &container);
	reset.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
	open_menu.addAction(&reset);

	QAction save("&Save", &container);
	save.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
	open_menu.addAction(&save);

	QAction close("&Close", &container);
	close.setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4));
	open_menu.addAction(&close);

	QMenu draw_menu("&Drawmodes", &container);

	QAction points("&Points", &container);
	points.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
	draw_menu.addAction(&points);

	QAction wire("&Wireframe", &container);
	wire.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W));
	draw_menu.addAction(&wire);

	QAction flat("&Flat shaded", &container);
	flat.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F));
	draw_menu.addAction(&flat);

	QAction smooth("&Smooth shaded", &container);
	smooth.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
	draw_menu.addAction(&smooth);

	/**** MENU CONVEX HULL ****/
	QMenu convex_hull("Convex Hull", &container);

	QAction calc("&Calculate CH", &container);
	calc.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_C));
	convex_hull.addAction(&calc);

	/**** MENU HELP ****/
	QMenu help_menu("&?", &container);

	QAction help("&Help", &container);
	help.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_H));
	help_menu.addAction(&help);

	QAction about("&About", &container);
	about.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
	help_menu.addAction(&about);
	
	open_menu_bar.addMenu(&open_menu);
	open_menu_bar.addMenu(&draw_menu);
	open_menu_bar.addMenu(&convex_hull);
	open_menu_bar.addMenu(&help_menu);
	
	Window_gl window(&container);
	window.setGeometry(0,22,640, 680);

	container.show();
	
	QDialog instructions( NULL );
	instructions.setFixedSize(300,180);
	instructions.setWindowTitle("Help");
	QLabel instr_text("\nUp - Sposta l'osservatore verso l'alto\nDown - Sposta l'osservatore verso il basso\nLeft - Ruota verso sinistra\nRight - Ruota verso destra\nShift+Up - Zoom In\nShift+Down - Zoom out\n\nSi ricorda che il programma e' in grado di gestire\nsolo files di tipo .OFF.\nAltri formati non sono attualmente supportati.", &instructions);
	instr_text.setTextFormat(Qt::AutoText);
	instr_text.setWordWrap(true);
	instructions.hide();

	QDialog credits( NULL );
	credits.setFixedSize(300,100);
	credits.setWindowTitle("Credits");
	QLabel cred_text("\tCGVew v.1.7\n\nA cura di Fabio Guggeri ([email protected])\ne Stefano Marras ([email protected]).\n", &credits);
	cred_text.setTextFormat(Qt::AutoText);
	cred_text.setWordWrap(true);
	credits.hide();

	QObject::connect( &open, SIGNAL(triggered()), &engine, SLOT(open_file()) );
	QObject::connect( &reset, SIGNAL(triggered()), &window, SLOT(reset()) );
	QObject::connect( &reset, SIGNAL(triggered()), &engine, SLOT(reset()) );
	QObject::connect( &save, SIGNAL(triggered()), &engine, SLOT(save_file()) );
	QObject::connect( &points, SIGNAL(triggered()), &window, SLOT(set_p_drawmode()) );
	QObject::connect( &wire, SIGNAL(triggered()), &window, SLOT(set_w_drawmode()) );
	QObject::connect( &flat, SIGNAL(triggered()), &window, SLOT(set_f_drawmode()) );
	QObject::connect( &smooth, SIGNAL(triggered()), &window, SLOT(set_s_drawmode()) );
	QObject::connect( &help, SIGNAL(triggered()), &instructions, SLOT(show()) );
	QObject::connect( &about, SIGNAL(triggered()), &credits, SLOT(show()) );
	QObject::connect( &close, SIGNAL(triggered()), &app, SLOT(quit()) );
	QObject::connect( &engine, SIGNAL(send_dcel(QVector<DCEL>&)), &window, SLOT(add_dcel(QVector<DCEL>&)) );
	QObject::connect( &calc, SIGNAL(triggered()), &engine, SLOT(calculate_ch()) );

	window.setFocus();

	return app.exec();
}