Esempio n. 1
0
/* static */ std::vector<TopoDS_Edge> SimplifySketchTool::SortEdges( const TopoDS_Wire & wire )
{
    std::vector<TopoDS_Edge> edges;

	for(BRepTools_WireExplorer expEdge(TopoDS::Wire(wire)); expEdge.More(); expEdge.Next())
	{
	    edges.push_back( TopoDS_Edge(expEdge.Current()) );
	} // End for

	for (std::vector<TopoDS_Edge>::iterator l_itEdge = edges.begin(); l_itEdge != edges.end(); l_itEdge++)
    {
        if (l_itEdge == edges.begin())
        {
            // It's the first edge.  Find the edge whose endpoint is closest to gp_Pnt(0,0,0) so that
            // the resutls of this sorting are consistent.  When we just use the first edge in the
            // wire, we end up with different results every time.  We want consistency so that, if we
            // use this Contour operation as a location for drilling a relief hole (one day), we want
            // to be sure the machining will begin from a consistently known location.

            std::vector<TopoDS_Edge>::iterator l_itStartingEdge = edges.begin();
            gp_Pnt closest_point = GetStart(*l_itStartingEdge);
            if (GetEnd(*l_itStartingEdge).Distance(gp_Pnt(0,0,0)) < closest_point.Distance(gp_Pnt(0,0,0)))
            {
                closest_point = GetEnd(*l_itStartingEdge);
            }
            for (std::vector<TopoDS_Edge>::iterator l_itCheck = edges.begin(); l_itCheck != edges.end(); l_itCheck++)
            {
                if (GetStart(*l_itCheck).Distance(gp_Pnt(0,0,0)) < closest_point.Distance(gp_Pnt(0,0,0)))
                {
                    closest_point = GetStart(*l_itCheck);
                    l_itStartingEdge = l_itCheck;
                }

                if (GetEnd(*l_itCheck).Distance(gp_Pnt(0,0,0)) < closest_point.Distance(gp_Pnt(0,0,0)))
                {
                    closest_point = GetEnd(*l_itCheck);
                    l_itStartingEdge = l_itCheck;
                }
            }

            EdgeComparison compare( *l_itStartingEdge );
            std::sort( edges.begin(), edges.end(), compare );
        } // End if - then
        else
        {
            // We've already begun.  Just sort based on the previous point's location.
            std::vector<TopoDS_Edge>::iterator l_itNextEdge = l_itEdge;
            l_itNextEdge++;

            if (l_itNextEdge != edges.end())
            {
                EdgeComparison compare( *l_itEdge );
                std::sort( l_itNextEdge, edges.end(), compare );
            } // End if - then
        } // End if - else
    } // End for

    return(edges);

} // End SortEdges() method
Esempio n. 2
0
string FDatation::GetFormated() const
{
	string sDatation;

	if (IsNull())
	{
		sDatation = "NULL";
	}
	else
	{
		assert(GetStart().IsNull() == false || GetEnd().IsNull() == false);

		const char* sStart = GetStart().GetFormated();
		const char* sEnd = GetEnd().GetFormated();

		if (GetEnd().IsNull())
			sEnd = sStart;

		if (GetStart().IsNull())
			sStart = sEnd;

		sDatation = "('" + string(sStart) + "','" + string(sEnd) + "')";
	}

	return sDatation;
}
Esempio n. 3
0
TRI_fulltext_list_t* TRI_ExcludeListFulltextIndex(
    TRI_fulltext_list_t* list, TRI_fulltext_list_t* exclude) {
  TRI_fulltext_list_entry_t* listEntries;
  TRI_fulltext_list_entry_t* excludeEntries;
  uint32_t numEntries;
  uint32_t numExclude;
  uint32_t i, j, listPos;

  if (list == nullptr) {
    TRI_FreeListFulltextIndex(exclude);
    return list;
  }

  if (exclude == nullptr) {
    return list;
  }

  numEntries = GetNumEntries(list);
  numExclude = GetNumEntries(exclude);

  if (numEntries == 0 || numExclude == 0) {
    // original list or exclusion list are empty
    TRI_FreeListFulltextIndex(exclude);
    return list;
  }

  SortList(list);

  listEntries = GetStart(list);
  excludeEntries = GetStart(exclude);

  j = 0;
  listPos = 0;
  for (i = 0; i < numEntries; ++i) {
    TRI_fulltext_list_entry_t entry;

    entry = listEntries[i];
    while (j < numExclude && excludeEntries[j] < entry) {
      ++j;
    }

    if (j < numExclude && excludeEntries[j] == entry) {
      // entry is contained in exclusion list
      continue;
    }

    if (listPos != i) {
      listEntries[listPos] = listEntries[i];
    }
    ++listPos;
  }

  // we may have less results in the list of exclusion
  SetNumEntries(list, listPos);
  TRI_FreeListFulltextIndex(exclude);

  return list;
}
Esempio n. 4
0
time_t AutoRecording::GetStop() const
{
  if ((m_minDuration == 0) && (m_maxDuration == 0)) // no durations set => "any stop time"
    return 0;
  else if (m_minDuration == 0)
    return GetStart() + m_maxDuration;
  else if (m_maxDuration == 0)
    return GetStart() + m_minDuration;
  else
    return GetStart() + m_minDuration + ((m_maxDuration - m_minDuration) / 2);
}
bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
    EDA_RECT arect = aRect;
    arect.Inflate( aAccuracy );

    if( aContained )
        /* Tracks are a special case:
         * they are considered inside the rect if one end is inside the rect */
        return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
    else
        return arect.Intersects( GetStart(), GetEnd() );
}
Esempio n. 6
0
// WeekdayRange ------------------------------------------------------------------------------------
bool WeekdayRange::HasWday(Weekday const wday) const
{
  if (IsEmpty() || wday == Weekday::None)
    return false;

  if (!HasEnd())
    return GetStart() == wday;

  return (GetStart() <= GetEnd())
      ? GetStart() <= wday && wday <= GetEnd()
      : wday <= GetEnd() || GetStart() <= wday;
}
Esempio n. 7
0
/**
    When we're starting a new sequence of edges, we want to run along the first edge
    so that we end up nearby to the next edge in the sorted sequence.  If we go in the
    wrong direction then we're just going to have to rapid up to clearance height and
    move to the beginning of the next edge anyway.  This routine returns 'true' if
    the next edge is closer to the 'end' of this edge and 'false' if it's closer to
    the 'beginning' of this edge.  This tell us whether we want to run forwards
    or backwards along this edge so that we're setup ready to machine the next edge.
 */
/* static */ bool SimplifySketchTool::DirectionTowarardsNextEdge( const TopoDS_Edge &from, const TopoDS_Edge &to )
{
    const bool forwards = true;
    const bool backwards = false;

    bool direction = forwards;

    double min_distance = 9999999;  // Some big number.
    if (GetStart(from).Distance( GetEnd( to )) < min_distance)
    {
        min_distance = GetStart( from ).Distance( GetEnd( to ));
        direction = backwards;
    }

    if (GetEnd(from).Distance( GetEnd( to )) < min_distance)
    {
        min_distance = GetEnd(from).Distance( GetEnd( to ));
        direction = forwards;
    }

    if (GetStart(from).Distance( GetStart( to )) < min_distance)
    {
        min_distance = GetStart(from).Distance( GetStart( to ));
        direction = backwards;
    }

    if (GetEnd(from).Distance( GetStart( to )) < min_distance)
    {
        min_distance = GetEnd(from).Distance( GetStart( to ));
        direction = forwards;
    }

    return(direction);
}
bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
    wxPoint p1, p2;
    int radius;
    float theta;
    EDA_RECT arect = aRect;
    arect.Inflate( aAccuracy );

    switch( m_Shape )
    {
    case S_CIRCLE:
        // Test if area intersects or contains the circle:
        if( aContained )
            return arect.Contains( GetBoundingBox() );
        else
            return arect.Intersects( GetBoundingBox() );
        break;

    case S_ARC:
        radius = hypot( (double)( GetEnd().x - GetStart().x ),
                        (double)( GetEnd().y - GetStart().y ) );
        theta  = std::atan2( GetEnd().y - GetStart().y , GetEnd().x - GetStart().x );

        //Approximate the arc with two lines. This should be accurate enough for selection.
        p1.x   = radius * std::cos( theta + M_PI/4 ) + GetStart().x;
        p1.y   = radius * std::sin( theta + M_PI/4 ) + GetStart().y;
        p2.x   = radius * std::cos( theta + M_PI/2 ) + GetStart().x;
        p2.y   = radius * std::sin( theta + M_PI/2 ) + GetStart().y;

        if( aContained )
            return arect.Contains( GetEnd() ) && aRect.Contains( p1 ) && aRect.Contains( p2 );
        else
            return arect.Intersects( GetEnd(), p1 ) || aRect.Intersects( p1, p2 );

        break;

    case S_SEGMENT:
        if( aContained )
            return arect.Contains( GetStart() ) && aRect.Contains( GetEnd() );
        else
            return arect.Intersects( GetStart(), GetEnd() );

        break;

    default:
        ;
    }
    return false;
}
Esempio n. 9
0
void MyFrame::UpdateUI()
{
    GetStart()->Enable(m_server == NULL);
    GetServername()->Enable(m_server == NULL);
    GetAdvise()->Enable(m_server && m_server->CanAdvise());
    GetDisconnect()->Enable(m_server && m_server->IsConnected());
}
Esempio n. 10
0
void pgaSchedule::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
    if (!expandedKids)
    {
        expandedKids = true;
    }

    if (properties)
    {
        CreateListColumns(properties);

        properties->AppendItem(_("Name"), GetName());
        properties->AppendItem(_("ID"), GetRecId());
        properties->AppendYesNoItem(_("Enabled"), GetEnabled());

        properties->AppendItem(_("Start date"), GetStart());
        properties->AppendItem(_("End date"), GetEnd());
        properties->AppendItem(_("Minutes"), GetMinutesString());
        properties->AppendItem(_("Hours"), GetHoursString());
        properties->AppendItem(_("Weekdays"), GetWeekdaysString());
        properties->AppendItem(_("Monthdays"), GetMonthdaysString());
        properties->AppendItem(_("Months"), GetMonthsString());
        properties->AppendItem(_("Exceptions"), GetExceptionsString());

        properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
    }
}
Esempio n. 11
0
const int MemBlockDevice::LoadFromFile(const std::string & path)
{
	FILE* filePtr;
	if (!file_exist(path))
		return -1;

	Format();

	fopen_s(&filePtr, path.c_str(), "rb");

	
	char arr[blocksize];
	for (int i = 0; i < nrOfBlocks; i++)
	{
		fread(arr, blocksize, 1, filePtr);
		memBlocks[i].writeBlock(arr, blocksize, 0);
	}

	int size = nrOfBlocks*sizeof(int);
	int point = 0;
	for (int i = 0; i < mFillSize; i++)
	{
		int s = (size < blocksize) ? size : blocksize;
		memcpy(mFreeBlocks + point, memBlocks[1 + i * 2].toString().c_str(), s);
		memcpy(mFilledBlocks + point, memBlocks[2 + i * 2].toString().c_str(), s);
		point += s/sizeof(int);
		size -= blocksize;
	}

	return GetStart();
}
bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
{
    EDA_RECT box;
    EDA_RECT arect = aRect;
    arect.Inflate( aAccuracy );

    box.SetOrigin( GetStart() );
    box.Inflate( GetWidth() / 2 );

    if( aContained )
    {
        return arect.Contains( box );
    }
    else
    {
        return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
    }
}
Esempio n. 13
0
// Timespan ----------------------------------------------------------------------------------------
bool Timespan::HasExtendedHours() const
{
  bool const canHaveExtendedHours = HasStart() && HasEnd() &&
                                    GetStart().IsHoursMinutes() &&
                                    GetEnd().IsHoursMinutes();
  if (!canHaveExtendedHours)
  {
    return false;
  }

  auto const & startHM = GetStart().GetHourMinutes();
  auto const & endHM = GetEnd().GetHourMinutes();

  if (endHM.IsExtended())
    return true;

  return endHM.GetDuration() <= startHM.GetDuration();
}
Esempio n. 14
0
/**********************************************************************
* CTextRun::Split *
*-----------------*
*	Description:  
*		Splits up a TextRun so that this text run now ends at lFirstEnd
*       and the second text run begins at lSecondBegin.
*       "This" will now be a shorter range (it will end sooner),
*       and *ppTextRun will point to the new text run 
*       (space will be allocated here for *ppTextRun) 
*       to be inserted in the list.
*
* 	Return:
*		S_OK 
*       E_INVALIDARG 
*       E_OUTOFMEMORY 
*       Return value of ITextDocument::Range()
**********************************************************************/
HRESULT CTextRun::Split( long *plFirstEnd, long *plSecondBegin, 
                        ITextDocument *cpTextDoc,
                        CTextRun **ppTextRun )
{
    if ( !plFirstEnd || !plSecondBegin || !cpTextDoc || !ppTextRun )
    {
        return E_INVALIDARG;
    }
    _ASSERTE( m_cpTextRange );
    if ( !m_cpTextRange )
    {
        return E_UNEXPECTED;
    }

    // These values won't be changing, since this run has no associated
    // RecoResult. 
    // We can chop this block right at these positions.
    long lFirstEnd = *plFirstEnd;
    long lSecondBegin = *plSecondBegin;

    if ( !WithinRange( lFirstEnd ) || (lFirstEnd > lSecondBegin) )
    {
        return E_INVALIDARG;
    }

    if ( (GetStart() == lSecondBegin) || (GetEnd() == lFirstEnd) || (lSecondBegin > GetEnd()) )
    {
        // Don't need to do anything, since we are asking for both of the 
        // cuts to be made on already-existing TextRun boundaries
        *ppTextRun = NULL;
        return S_OK;
    }

    *ppTextRun = new CTextRun();
    if ( !(*ppTextRun) )
    {
        return E_OUTOFMEMORY;
    }

    // The latter range will start at lSecondBegin and end where "this" ended
    long lEnd = GetEnd();
    CComPtr<ITextRange> pLatterRange;
    HRESULT hr = cpTextDoc->Range( lSecondBegin, lEnd, &pLatterRange );
    if ( FAILED( hr ) )
    {
        return hr;
    }
    (*ppTextRun)->SetTextRange( pLatterRange );

    // Adjust the end of "this"'s range; it will end at lFirstEnd
    m_cpTextRange->SetEnd( lFirstEnd );

    return S_OK;

} /* CTextRun::Split */
Esempio n. 15
0
TRI_fulltext_list_t* TRI_CloneListFulltextIndex(
    TRI_fulltext_list_t const* source) {
  uint32_t numEntries;

  if (source == nullptr) {
    numEntries = 0;
  } else {
    numEntries = GetNumEntries(source);
  }

  TRI_fulltext_list_t* list = TRI_CreateListFulltextIndex(numEntries);

  if (list != nullptr) {
    if (numEntries > 0) {
      memcpy(GetStart(list), GetStart(source),
             numEntries * sizeof(TRI_fulltext_list_entry_t));
      SetNumEntries(list, numEntries);
    }
  }

  return list;
}
Esempio n. 16
0
TRI_fulltext_list_t* TRI_CloneListFulltextIndex (const TRI_fulltext_list_t* const source) {
  TRI_fulltext_list_t* list;
  uint32_t numEntries;

  if (source == NULL) {
    numEntries = 0;
  }
  else {
    numEntries = GetNumEntries(source);
  }

  list = TRI_CreateListFulltextIndex(numEntries);
  if (list == NULL) {
    return NULL;
  }

  if (numEntries > 0) {
    memcpy(GetStart(list), GetStart(source), numEntries * sizeof(TRI_fulltext_list_entry_t));
    SetNumEntries(list, numEntries);
  }

  return list;
}
long ButcherProjectMaskContainerJoined::GetStartMinMaxPos(ButcherProjectLine::orientation_t orientation)
{
    long ret=GetStart(orientation)->GetPosition(), newr;

    // returns the rightmost/bottommost start line of all areas
	for (ButcherProjectAreas::iterator i=areas_.begin(); i!=areas_.end(); i++)
	{
        newr=i->GetStartMinMaxPos(orientation);
        if (newr>ret)
            ret=newr;
	}

    return ret;
}
Esempio n. 18
0
void MyFrame::EnableControls()
{
    GetStart()->Enable(m_client == NULL);
    GetServername()->Enable(m_client == NULL);
    GetHostname()->Enable(m_client == NULL);
    GetTopic()->Enable(m_client == NULL);

    const bool isConnected = (m_client != NULL && m_client->IsConnected());
    GetDisconnect()->Enable(m_client != NULL && isConnected);
    GetStartAdvise()->Enable(m_client != NULL && isConnected);
    GetStopAdvise()->Enable(m_client != NULL && isConnected);
    GetExecute()->Enable(m_client != NULL && isConnected);
    GetPoke()->Enable(m_client != NULL && isConnected);
    GetRequest()->Enable(m_client != NULL && isConnected);
}
Esempio n. 19
0
void pgTextSearchParser::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Start"), GetStart());
		properties->AppendItem(_("Gettoken"), GetGettoken());
		properties->AppendItem(_("End"), GetEnd());
		properties->AppendItem(_("Lextypes"), GetLextypes());
		properties->AppendItem(_("Headline"), GetHeadline());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
	}
}
Esempio n. 20
0
static void SortList(TRI_fulltext_list_t* list) {
  if (IsSorted(list)) {
    // nothing to do
    return;
  }

  uint32_t numEntries = GetNumEntries(list);

  if (numEntries > 1) {
    // only sort if more than one elements
    qsort(GetStart(list), numEntries, sizeof(TRI_fulltext_list_entry_t),
          &CompareEntries);
  }

  SetIsSorted(list, true);
}
// see pcbstruct.h
void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
{
    wxString msg;
    wxString coords;

    wxASSERT( m_Parent );

    msg = wxT( "DRAWING" );

    aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );

    wxString    shape = _( "Shape" );

    switch( m_Shape )
    {
    case S_CIRCLE:
        aList.push_back( MSG_PANEL_ITEM( shape, _( "Circle" ), RED ) );
        break;

    case S_ARC:
        aList.push_back( MSG_PANEL_ITEM( shape, _( "Arc" ), RED ) );
        msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 );
        aList.push_back( MSG_PANEL_ITEM( _("Angle"), msg, RED ) );
        break;

    case S_CURVE:
        aList.push_back( MSG_PANEL_ITEM( shape, _( "Curve" ), RED ) );
        break;

    default:
        aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) );
    }

    wxString start;
    start << GetStart();

    wxString end;
    end << GetEnd();

    aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) );
    aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) );
    msg = ::CoordinateToString( m_Width );
    aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
}
Esempio n. 22
0
MRESULT WINAPI _RegMatchA(CRegexpA* lpReg, CHAR* lpszStr, int nStart, LPREGEXP_RESULT lprRslt)
{
	auto mr=lpReg->Match(lpszStr,nStart);
	lprRslt->bIsMatched=mr.IsMatched();
	if(!lprRslt->bIsMatched)
		return E_SUCCESS;

	lprRslt->rBase.nLeft=mr.GetStart();
	lprRslt->rBase.nRight=mr.GetEnd();

	auto mx=REG_MAX_GROUPS>mr.MaxGroupNumber()?mr.MaxGroupNumber():REG_MAX_GROUPS;
	lprRslt->nGroups=mx;

	for(int i=0;i<=mx;i++)
	{
		lprRslt->rGroups[i].nLeft=mr.GetGroupStart(i+1);
		lprRslt->rGroups[i].nRight=mr.GetGroupEnd(i+1);
	}
	return E_SUCCESS;
}
Esempio n. 23
0
uint32_t TRI_RewriteListFulltextIndex(TRI_fulltext_list_t* list,
                                      void const* data) {
  TRI_fulltext_list_entry_t* listEntries;
  TRI_fulltext_list_entry_t* map;
  uint32_t numEntries;
  uint32_t i, j;

  numEntries = GetNumEntries(list);
  if (numEntries == 0) {
    return 0;
  }

  map = (TRI_fulltext_list_entry_t*)data;
  listEntries = GetStart(list);
  j = 0;

  for (i = 0; i < numEntries; ++i) {
    TRI_fulltext_list_entry_t entry;
    TRI_fulltext_list_entry_t mapped;

    entry = listEntries[i];
    if (entry == 0) {
      continue;
    }

    mapped = map[entry];
    if (mapped == 0) {
      // original value has been deleted
      continue;
    }

    listEntries[j++] = mapped;
  }

  if (j != numEntries) {
    SetNumEntries(list, j);
  }

  return j;
}
Esempio n. 24
0
void EDGE_MODULE::Flip( const wxPoint& aCentre )
{
    wxPoint pt;

    switch( GetShape() )
    {
    case S_ARC:
        SetAngle( -GetAngle() );
        //Fall through
    default:
    case S_SEGMENT:
        pt = GetStart();
        MIRROR( pt.y, aCentre.y );
        SetStart( pt );

        pt = GetEnd();
        MIRROR( pt.y, aCentre.y );
        SetEnd( pt );

        MIRROR( m_Start0.y, 0 );
        MIRROR( m_End0.y, 0 );
        break;

    case S_POLYGON:
        // polygon corners coordinates are always relative to the
        // footprint position, orientation 0
        for( auto iter = m_Poly.Iterate(); iter; iter++ )
        {
            MIRROR( iter->y, 0 );
        }
	break;
    }

    // DRAWSEGMENT items are not usually on copper layers, but
    // it can happen in microwave apps.
    // However, currently, only on Front or Back layers.
    // So the copper layers count is not taken in account
    SetLayer( FlipLayer( GetLayer() ) );
}
Esempio n. 25
0
main() 
{
    while (!feof(stdin)) { //пока файл не закончится
        char *s = GetString(); //находим строку
        if (!s) continue;
        
        if (TestWhile(s)) { //проверяем, на то, что это цикл
            int num = 0;
            char **strs = GetStrings(&num); //находим строчки учавствующие в цикле
            if (strs) {
                LoopStrings(strs, num, GetStart(s), GetLimit(s), GetStep(s));
                while (num--) free(strs[num]);
                free(strs);
            }
        }
        else PrintString(s);
        
        free(s);
    }
    
    return 0;
}
Esempio n. 26
0
void TRI_DumpListFulltextIndex(TRI_fulltext_list_t const* list) {
  TRI_fulltext_list_entry_t* listEntries;
  uint32_t numEntries;
  uint32_t i;

  numEntries = GetNumEntries(list);
  listEntries = GetStart(list);

  printf("(");

  for (i = 0; i < numEntries; ++i) {
    TRI_fulltext_list_entry_t entry;

    if (i > 0) {
      printf(", ");
    }

    entry = listEntries[i];
    printf("%lu", (unsigned long)entry);
  }

  printf(")");
}
Esempio n. 27
0
wxString pgTextSearchParser::GetSql(ctlTree *browser)
{
	if (sql.IsNull())
	{
		sql = wxT("-- Text Search Parser: ") + GetFullIdentifier() + wxT("\n\n")
		      + wxT("-- DROP TEXT SEARCH PARSER ") + GetFullIdentifier() + wxT("\n\n")
		      + wxT("CREATE TEXT SEARCH PARSER ") + GetFullIdentifier() + wxT(" (")
		      + wxT("\n  START = ") + qtTypeIdent(GetStart())
		      + wxT(",\n  GETTOKEN = ") + qtTypeIdent(GetGettoken())
		      + wxT(",\n  END = ") + qtTypeIdent(GetEnd())
		      + wxT(",\n  LEXTYPES = ") + qtTypeIdent(GetLextypes());

		AppendIfFilled(sql, wxT(",\n  HEADLINE = "), GetHeadline());

		sql += wxT("\n);\n");

		if (!GetComment().IsNull())
			sql += wxT("COMMENT ON TEXT SEARCH PARSER ") + GetFullIdentifier()
			       + wxT(" IS ") + qtDbString(GetComment()) + wxT(";\n");
	}

	return sql;
}
Esempio n. 28
0
/**********************************************************************
* CTextRun::Serialize *
*---------------------*
*	Description:  
*		Serializes the text for this run.
*       Simply writes a small header that contains the start
*       and end indices of this run and indicates that
*       no phrase blob follows.
*   Return:
*       S_OK
*       E_INVALIDARG
*       E_UNEXPECTED
*       Return value of ISequentialStream::Write()
**********************************************************************/
HRESULT CTextRun::Serialize( IStream *pStream, ISpRecoContext *pRecoCtxt )
{   
    if ( !pStream )
    {
        return E_INVALIDARG;
    }
    _ASSERTE( m_cpTextRange );
    if ( !m_cpTextRange )
    {
        return E_UNEXPECTED;
    }

    RUNHEADER runHdr;
    runHdr.lStart = GetStart();
    runHdr.lEnd = GetEnd();
    runHdr.bResultFollows = false;

    // Write the header to the stream
    ULONG cbWritten;
    HRESULT hr = pStream->Write( &runHdr, sizeof( RUNHEADER ), &cbWritten );

    return hr;
} /* CTextRun::Serialize */
void EDGE_MODULE::Flip(const wxPoint& aCentre )
{
    wxPoint pt;

    switch( GetShape() )
    {
    case S_ARC:
        SetAngle( -GetAngle() );
        //Fall through
    default:
    case S_SEGMENT:
        pt = GetStart();
        pt.y -= aCentre.y;
        pt.y  = -pt.y;
        pt.y += aCentre.y;
        SetStart( pt );

        pt = GetEnd();
        pt.y -= aCentre.y;
        pt.y  = -pt.y;
        pt.y += aCentre.y;
        SetEnd( pt );

        NEGATE( m_Start0.y );
        NEGATE( m_End0.y );
        break;

    case S_POLYGON:
        // polygon corners coordinates are always relative to the
        // footprint position, orientation 0
        for( unsigned ii = 0; ii < m_PolyPoints.size(); ii++ )
            NEGATE( m_PolyPoints[ii].y );
    }

    SetLayer( FlipLayer( GetLayer() ) );
}
Esempio n. 30
0
int _tmain(int argc, _TCHAR* argv[])
{
    std::wcout << L"version : 2015.09.14" << std::endl;
    std::wcout << L"Usage : FbxExporter <path to fbx file> <outdir> [/fps:60|30|24] [/skipemptynodes] [/animstack:\"animstack name\"]" << std::endl;
    if (argc < 3) {
        std::wcerr << L"Invalid argument count" << std::endl;
        return -1;
    }
    std::wstring wInputPath(argv[1]);
    std::wstring wInputDir(argv[1]);
    std::wstring wInputFileName(argv[1]);
    auto lastDirSeparator = wInputDir.find_last_of(L'\\');
    if (lastDirSeparator == wInputDir.npos) {
        wInputDir = L".";
    }
    else {
        wInputDir.erase(lastDirSeparator);
        wInputFileName.erase(0, lastDirSeparator + 1);
    }
    std::wstring wOutputPath(argv[2]);
    CreateDirectory(wOutputPath.c_str(), nullptr);
    bool skipEmptyNodes = false;
    std::wstring animStackName;
    for (int i = 3; i < argc; ++i) {
        std::wstring warg = argv[i];
        if (warg == L"/skipemptynodes") {
            skipEmptyNodes = true;
        }
        else if (warg.find(L"/fps:") == 0) {
            if (warg == L"/fps:60") {
                GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames60;
            }
            else if (warg == L"/fps:30") {
                GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames30;
            }
            else if (warg == L"/fps:24") {
                GlobalSettings::Current().AnimationsTimeMode = FbxTime::EMode::eFrames24;
            }
            else {
                std::wcerr << L"Unrecognized fps parameter" << std::endl;
                return -2;
            }
        }
        else if (warg.find(L"/animstack:") == 0) {
            animStackName = warg.substr(11);

            if (animStackName.size()>0 && animStackName[0] == L'\"') {
                animStackName.erase(0, 1);
            }
            if (animStackName.size() > 0 && animStackName[animStackName.size() - 1] == L'\"') {
                animStackName.erase(animStackName.size() - 1, 1);
            }
        }

    }


    FbxSceneLoader sceneLoader(wstringToUtf8(wInputPath));
    auto animStackCount = sceneLoader.getScene()->GetSrcObjectCount<FbxAnimStack>();
    if (animStackName.size() == 0) {
        GlobalSettings::Current().AnimStackIndex = 0;
    }
    else {
        for (auto ix = 0; ix < animStackCount; ++ix) {
            auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix);
            if (utf8ToWstring(animStack->GetName()) == animStackName) {
                GlobalSettings::Current().AnimStackIndex = ix;
            }
        }
    }
    std::wcout << L"Animation stacks : " << std::endl;
    for (auto ix = 0; ix < animStackCount; ++ix) {
        auto animStack = sceneLoader.getScene()->GetSrcObject<FbxAnimStack>(ix);
        if (ix == GlobalSettings::Current().AnimStackIndex) {
            std::wcout << L"[X] ";
            sceneLoader.getScene()->SetCurrentAnimationStack(animStack);
        }
        else {
            std::wcout << L"[ ] ";
        }

        std::wcout << utf8ToWstring(animStack->GetName());
        auto ts=animStack->GetLocalTimeSpan();
        auto start = ts.GetStart();
        auto stop = ts.GetStop();
        std::wcout << L"(" << start.GetMilliSeconds() << L" - " << stop.GetMilliSeconds() << L")" << std::endl;
    }

    auto root = sceneLoader.rootNode();

    BabylonScene babScene(*root, skipEmptyNodes);

    for (auto& mat : babScene.materials()) {
        exportTexture(mat.ambientTexture, wOutputPath);
        exportTexture(mat.diffuseTexture, wOutputPath);
        exportTexture(mat.specularTexture, wOutputPath);
        exportTexture(mat.emissiveTexture, wOutputPath);
        exportTexture(mat.reflectionTexture, wOutputPath);
        exportTexture(mat.bumpTexture, wOutputPath);

    }



    auto json = babScene.toJson();
    if (L'\\' != *wOutputPath.crbegin()) {
        wOutputPath.append(L"\\");
    }
    wOutputPath.append(wInputFileName);

    auto lastDot = wOutputPath.find_last_of(L'.');
    wOutputPath.erase(lastDot);
    wOutputPath.append(L".babylon");
    DeleteFile(wOutputPath.c_str());
    std::ofstream stream(wOutputPath);
    json.serialize(stream);
    stream.flush();
    return 0;
}