void CDX9Renderer::Box(const rect& r, cr_float angle, point hotspot, const color& c)
	{
		// No support for textured lines
		SetTexture(NULL);

		quad q((r - hotspot).rotate_to_quad(angle, r.topleft()));

		BeginBatch(batch_linestrip);
		CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());

		D3DCOLOR color = c.getD3DCOLOR();

		// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
		AddVertex(color, q.tl, 0.0f, 0.0f);
		AddVertex(color, q.tr, 0.0f, 0.0f);
		AddVertex(color, q.br, 0.0f, 0.0f);
		AddVertex(color, q.bl, 0.0f, 0.0f);

		unsigned short index = draw_op->vertex_count;
		AddIndex(index);
		AddIndex(index + 1);
		AddIndex(index + 2);
		AddIndex(index + 3);
		AddIndex(index);

		draw_op->vertex_count += 4;
		draw_op->index_count += 5;
	}
Example #2
0
IndexCatalog::IndexCatalog(storage::Database *pg_catalog,
                           type::AbstractPool *pool,
                           concurrency::Transaction *txn)
    : AbstractCatalog(INDEX_CATALOG_OID, INDEX_CATALOG_NAME,
                      InitializeSchema().release(), pg_catalog) {
  // Add indexes for pg_index
  AddIndex({0}, INDEX_CATALOG_PKEY_OID, INDEX_CATALOG_NAME "_pkey",
           IndexConstraintType::PRIMARY_KEY);
  AddIndex({1}, INDEX_CATALOG_SKEY0_OID, INDEX_CATALOG_NAME "_skey0",
           IndexConstraintType::UNIQUE);
  AddIndex({2}, INDEX_CATALOG_SKEY1_OID, INDEX_CATALOG_NAME "_skey1",
           IndexConstraintType::DEFAULT);

  // Insert columns into pg_attribute
  ColumnCatalog *pg_attribute = ColumnCatalog::GetInstance(pg_catalog, pool, txn);

  oid_t column_id = 0;
  for (auto column : catalog_table_->GetSchema()->GetColumns()) {
    pg_attribute->InsertColumn(INDEX_CATALOG_OID, column.GetName(), column_id,
                               column.GetOffset(), column.GetType(),
                               column.IsInlined(), column.GetConstraints(),
                               pool, txn);
    column_id++;
  }
}
	void CDX9Renderer::Box(const rect& r, const color& c)
	{
		// No support for textured lines
		SetTexture(NULL);

		BeginBatch(batch_linestrip);
		CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());

		D3DCOLOR color = c.getD3DCOLOR();

		// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
		AddVertex(color, r.topleft(), 0.0f, 0.0f);
		AddVertex(color, r.topright(), 0.0f, 0.0f);
		AddVertex(color, r.bottomright(), 0.0f, 0.0f);
		AddVertex(color, r.bottomleft(), 0.0f, 0.0f);

		unsigned short index = draw_op->vertex_count;
		AddIndex(index);
		AddIndex(index + 1);
		AddIndex(index + 2);
		AddIndex(index + 3);
		AddIndex(index);

		draw_op->vertex_count += 4;
		draw_op->index_count += 5;
	}
storage::DataTable *TransactionTestsUtil::CreatePrimaryKeyUniqueKeyTable() {
  auto id_column = catalog::Column(VALUE_TYPE_INTEGER,
                                   GetTypeSize(VALUE_TYPE_INTEGER), "id", true);
  id_column.AddConstraint(catalog::Constraint(CONSTRAINT_TYPE_NOTNULL,
                                              "not_null"));
  auto value_column = catalog::Column(
      VALUE_TYPE_INTEGER, GetTypeSize(VALUE_TYPE_INTEGER), "value", true);

  // Create the table
  catalog::Schema *table_schema =
      new catalog::Schema({id_column, value_column});
  auto table_name = "TEST_TABLE";
  size_t tuples_per_tilegroup = 100;
  auto table = storage::TableFactory::GetDataTable(
      INVALID_OID, INVALID_OID, table_schema, table_name, tuples_per_tilegroup,
      true, false);

  // Create primary index on the id column
  std::vector<oid_t> key_attrs = {0};
  auto tuple_schema = table->GetSchema();
  bool unique = false;
  auto key_schema = catalog::Schema::CopySchema(tuple_schema, key_attrs);
  key_schema->SetIndexedColumns(key_attrs);

  auto index_metadata = new index::IndexMetadata(
      "primary_btree_index", 1234, INDEX_TYPE_BTREE,
      INDEX_CONSTRAINT_TYPE_PRIMARY_KEY, tuple_schema, key_schema, unique);

  index::Index *pkey_index = index::IndexFactory::GetInstance(index_metadata);

  table->AddIndex(pkey_index);

  // Create unique index on the value column
  std::vector<oid_t> key_attrs2 = {1};
  auto tuple_schema2 = table->GetSchema();
  bool unique2 = false;
  auto key_schema2 = catalog::Schema::CopySchema(tuple_schema2, key_attrs2);
  key_schema2->SetIndexedColumns(key_attrs2);
  auto index_metadata2 = new index::IndexMetadata(
      "unique_btree_index", 1235, INDEX_TYPE_BTREE,
      INDEX_CONSTRAINT_TYPE_UNIQUE, tuple_schema2, key_schema2, unique2);

  index::Index *ukey_index = index::IndexFactory::GetInstance(index_metadata2);

  table->AddIndex(ukey_index);

  // Insert tuple
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto txn = txn_manager.BeginTransaction();
  for (int i = 0; i < 10; i++) {
    ExecuteInsert(txn, table, i, i);
  }
  txn_manager.CommitTransaction();

  return table;
}
Example #5
0
/// <summary>
/// Helper function to create a face for the base octahedron.
/// </summary>
/// <param name="mesh">Mesh</param>
/// <param name="p1">Vertex 1.</param>
/// <param name="p2">Vertex 2.</param>
/// <param name="p3">Vertex 3.</param>
void AddBaseTriangle(D3DVECTOR& p1, D3DVECTOR& p2, D3DVECTOR& p3)
{
    AddVertex(p1.x, p1.y, p1.z, p1.x, p1.y, p1.z, 0, 0);
    AddVertex(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z, 0, 0);
    AddVertex(p3.x, p3.y, p3.z, p3.x, p3.y, p3.z, 0, 0);
    
    AddIndex(nextIndex++);
    AddIndex(nextIndex++);
    AddIndex(nextIndex++);
}
Example #6
0
DatabaseCatalog::DatabaseCatalog(
    storage::Database *pg_catalog, UNUSED_ATTRIBUTE type::AbstractPool *pool,
    UNUSED_ATTRIBUTE concurrency::TransactionContext *txn)
    : AbstractCatalog(DATABASE_CATALOG_OID, DATABASE_CATALOG_NAME,
                      InitializeSchema().release(), pg_catalog) {
  // Add indexes for pg_database
  AddIndex({ColumnId::DATABASE_OID}, DATABASE_CATALOG_PKEY_OID,
           DATABASE_CATALOG_NAME "_pkey", IndexConstraintType::PRIMARY_KEY);
  AddIndex({ColumnId::DATABASE_NAME}, DATABASE_CATALOG_SKEY0_OID,
           DATABASE_CATALOG_NAME "_skey0", IndexConstraintType::UNIQUE);
}
Example #7
0
/*================================================================ 
* 函数名:    Write
* 参数:      [in] (char *index_name)当前索引名称
*             [in] (char *key_name)KEY名称
*             [in] (char *value_name)VALUE名称
* 功能描述:   以普通方式写一字符串数据
* 返回值:    成功则返回true, 否则返false
================================================================*/
bool CIni::Write(char *index_name, char *key_name, char *value_name)
{
	int data_pos = FindIndex(index_name);
	if (data_pos == ERROR_DATA_POS)	//新建索引
	{
		AddIndex(index_name);
		data_pos = FindIndex(index_name);
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, value_name);	//在当前位置n加一个数据
		return true;
	}

	//存在索引
	int data_pos2 = FindData(data_pos, key_name);
	if (data_pos2 == ERROR_DATA_POS)		//新建数据
	{
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, value_name);	//在当前位置n加一个数据
		return true;
	}

	//存在数据
	ModityData(data_pos, key_name, value_name);	//修改一个数据

	return true;
}
Example #8
0
/*================================================================ 
* 函数名:    Write
* 参数:      [in] (char *index_name)当前索引名称
*             [in] (char *key_name)KEY名称
*             [in] (int int_num)整型值
* 功能描述:   以普通方式写一整数
* 返回值:    成功则返回true, 否则返false
================================================================*/
bool CIni::Write(char *index_name, char *key_name, int int_num)
{
	char string[32];
	sprintf(string, "%d", int_num);

	int data_pos = FindIndex(index_name);
	if (data_pos == ERROR_DATA_POS)	//新建索引
	{
		AddIndex(index_name);
		data_pos = FindIndex(index_name);
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, string);	//在当前位置n加一个数据
		return true;
	}

	//存在索引
	int data_pos2 = FindData(data_pos, key_name);
	if (data_pos2 == ERROR_DATA_POS)		//新建数据
	{
		data_pos = GotoLastLine(index_name);
		AddData(data_pos, key_name, string);	//在当前位置n加一个数据
		return true;
	}

	//存在数据
	ModityData(data_pos, key_name, string);	//修改一个数据

	return true;
}
Example #9
0
RCODE CSPDB::registerIndexArray(HFDB hFlaim, CS_FIELD_DEF *indexTable, FLMINT count)
{
	RCODE				rc = FERR_OK;
	int					i;

	rc = FlmDbTransBegin(hFlaim, FLM_UPDATE_TRANS, 255);
	if (RC_OK(rc))
	{
		for (i = 0; i < count; ++i)
		{
			rc = AddIndex(hFlaim, indexTable[i].name, indexTable[i].id);
			if (RC_BAD(rc))
			{
				break;
			}
		}
		if (RC_OK(rc))
		{
	 		rc = FlmDbTransCommit(hFlaim);
		}
		else
		{
			rc = FlmDbTransAbort(hFlaim);
		}
	}

	return (rc);
} // CSPDB::registerIndexArray()
Example #10
0
File: Ini.cpp Project: CrazyPro/ape
//以普通方式写一整数
bool Ini::Write(char *index, char *name, int num)
{
	//__ENTER_FUNCTION

	char string[32];
	sprintf(string, "%d", num);

	int n=FindIndex(index);
	if( n == -1 )	//新建索引
	{
		AddIndex(index);
		n=FindIndex(index);
		n=GotoLastLine(index);
		AddData(n, name, string);	//在当前位置n加一个数据
		return true;
	}

	//存在索引
	int m=FindData(n, name);
	if( m==-1 )		//新建数据
	{
		n=GotoLastLine(index);
		AddData(n, name, string);	//在当前位置n加一个数据
		return true;
	}

	//存在数据
	ModityData(n, name, string);	//修改一个数据

	return true;

	//__LEAVE_FUNCTION

//	return 0 ;
}
Example #11
0
OP_STATUS IndexGroupRange::IndexAdded(Indexer *indexer, UINT32 index_id)
{
	if (m_or_range_start <= index_id && index_id < m_or_range_end)
	{
		return AddIndex(index_id);
	}
	
	return OpStatus::OK;
}
storage::DataTable *TransactionTestsUtil::CreateTable(int num_key,
                                                      std::string table_name,
                                                      oid_t database_id,
                                                      oid_t relation_id,
                                                      oid_t index_oid,
                                                      bool need_primary_index) {
  auto id_column = catalog::Column(VALUE_TYPE_INTEGER,
                                   GetTypeSize(VALUE_TYPE_INTEGER), "id", true);
  auto value_column = catalog::Column(
      VALUE_TYPE_INTEGER, GetTypeSize(VALUE_TYPE_INTEGER), "value", true);

  // Create the table
  catalog::Schema *table_schema =
      new catalog::Schema({id_column, value_column});

  size_t tuples_per_tilegroup = 100;
  auto table = storage::TableFactory::GetDataTable(
      database_id, relation_id, table_schema, table_name, tuples_per_tilegroup,
      true, false);

  // Create index on the id column
  std::vector<oid_t> key_attrs = {0};
  auto tuple_schema = table->GetSchema();
  bool unique = false;
  auto key_schema = catalog::Schema::CopySchema(tuple_schema, key_attrs);
  key_schema->SetIndexedColumns(key_attrs);

  auto index_metadata = new index::IndexMetadata(
      "primary_btree_index", index_oid, INDEX_TYPE_BTREE,
      need_primary_index ? INDEX_CONSTRAINT_TYPE_PRIMARY_KEY : INDEX_CONSTRAINT_TYPE_DEFAULT,
      tuple_schema, key_schema, unique);

  index::Index *pkey_index = index::IndexFactory::GetInstance(index_metadata);

  table->AddIndex(pkey_index);

  // add this table to current database
  auto &manager = catalog::Manager::GetInstance();
  storage::Database *db = manager.GetDatabaseWithOid(database_id);
  if (db != nullptr) {
    db->AddTable(table);
  }

  // Insert tuple
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto txn = txn_manager.BeginTransaction();
  for (int i = 0; i < num_key; i++) {
    ExecuteInsert(txn, table, i, 0);
  }
  txn_manager.CommitTransaction();

  return table;
}
Example #13
0
OP_STATUS FolderIndexGroup::IndexParentIdChanged(Indexer *indexer, UINT32 index_id, UINT32 old_parent_id, UINT32 new_parent_id)
{
	if (new_parent_id == m_index_id)
	{
		return AddIndex(index_id);
	}
	else if (old_parent_id == m_index_id)
	{
		return IndexRemoved(indexer, index_id);
	}
	return OpStatus::OK;
}
Example #14
0
FolderIndexGroup::FolderIndexGroup(index_gid_t index_id) 
: UnionIndexGroup(index_id)
{
	m_index->SetType(IndexTypes::UNIONGROUP_INDEX);

	OpINT32Vector children;
	m_indexer->GetChildren(index_id, children);
	for (UINT32 i = 0; i < children.GetCount(); i++)
	{
		AddIndex(children.Get(i));
	}
}
Example #15
0
IndexCatalog::IndexCatalog(concurrency::TransactionContext *,
                           storage::Database *pg_catalog,
                           type::AbstractPool *)
    : AbstractCatalog(pg_catalog,
                      InitializeSchema().release(),
                      INDEX_CATALOG_OID,
                      INDEX_CATALOG_NAME) {
  // Add indexes for pg_index
  AddIndex(INDEX_CATALOG_NAME "_pkey",
           INDEX_CATALOG_PKEY_OID,
           {ColumnId::INDEX_OID},
           IndexConstraintType::PRIMARY_KEY);
  AddIndex(INDEX_CATALOG_NAME "_skey0",
           INDEX_CATALOG_SKEY0_OID,
           {ColumnId::INDEX_NAME, ColumnId::SCHEMA_NAME},
           IndexConstraintType::UNIQUE);
  AddIndex(INDEX_CATALOG_NAME "_skey1",
           INDEX_CATALOG_SKEY1_OID,
           {ColumnId::TABLE_OID},
           IndexConstraintType::DEFAULT);
}
Example #16
0
IndexGroupRange::IndexGroupRange(index_gid_t index_id, index_gid_t range_start, index_gid_t range_end)
	: UnionIndexGroup(index_id)
	, m_or_range_start(range_start)
	, m_or_range_end(range_end)
{
	// Or all indexes currently in the range
	INT32 it = -1;
	Index* index;
	while ((index = m_indexer->GetRange(range_start, range_end, it)) != NULL)
	{
		AddIndex(index->GetId());
	}
}
Example #17
0
BOOL CPubThread::GetFileName(LPPUBINFO ppi, BOOL bPreview, LPSTR fname, LPSTR tfname, DWORD index )
{
	if ( ppi == NULL ) return FALSE;

	// Ensure buffer
	if ( fname == NULL ) fname = ppi->pub_fname;
	if ( tfname == NULL ) tfname = ppi->pub_tfname;
	if ( index == MAXDWORD ) index = ppi->curindex;

	// Add index to file name
	if ( ( ppi->f1 & PUBF1_ROTATEFNAME ) != 0 )
		AddIndex( fname, ppi->fname, index );
	else strcpy( fname, ppi->fname );

	if ( ( ppi->f1 & PUBF1_TIMESTAMP ) != 0 )
		AddTimestamp( fname, ppi->tmpl );
	
	CWinFile::CleanChars( fname );

	// Add index to thumbnail
	if ( ( ppi->f1 & PUBF1_ROTATEFNAME ) != 0 && ( ppi->f1 & PUBF1_TNROTATE ) != 0 )
		AddIndex( tfname, ppi->tfname, index );
	else strcpy( tfname, ppi->tfname );

	if ( ( ppi->f1 & PUBF1_TIMESTAMP ) != 0 && ( ppi->f1 & PUBF1_TNTIMESTAMP ) != 0 )
		AddTimestamp( tfname, ppi->tmpl );

	CWinFile::CleanChars( tfname );

	// Roll over index
	if ( !bPreview && ( ppi->f1 & PUBF1_ROTATEFNAME ) != 0 )
	{
		ppi->curindex++;
		if ( ppi->curindex > ppi->stopindex ) ppi->curindex = ppi->startindex;
		if ( ppi->curindex < ppi->startindex ) ppi->curindex = ppi->startindex;
	} // end if

	return TRUE;
}
Example #18
0
static int AVIEnd( hb_mux_object_t * m )
{
    hb_job_t * job = m->job;

    hb_log( "muxavi: writing index" );
    AddIndex( m );

    hb_log( "muxavi: closing %s", job->file );
    fclose( m->file );

    hb_buffer_close( &m->index );

    return 0;
}
Example #19
0
OP_STATUS IndexGroupWatched::IndexAdded(Indexer *indexer, UINT32 index_id)
{
	if (m_or_range_start <= index_id && index_id < m_or_range_end)
	{
		Index* index = indexer->GetIndexById(index_id);

		if (index && index->IsWatched())
		{
			return AddIndex(index_id);
		}
	}

	return OpStatus::OK;
}
Example #20
0
void IPCIndexEvent(int argc, char** argv, PLSOBJECT Object)
{
	char* Name = argv[0];
	LSTypeDefinition* Type = pLSInterface->FindLSType(argv[1]);
	char* SubType = argv[2];
	char* Method = argv[3];

	LSOBJECT indexobject;
	if((indexobject.Ptr = FindIndex(Name)) == 0)
	{
		indexobject.Ptr = new LSIndex(Type, SubType);
		AddIndex(Name, (LSIndex*)indexobject.Ptr);
	}
	pIndexType->GetMethodEx(indexobject.GetObjectData(), Method, argc-4, &argv[4]);
}
Example #21
0
void AddIndexes(storage::DataTable* table,
                const std::vector<std::vector<double>>& suggested_indices,
                size_t max_allowed_indexes) {

  oid_t index_count = table->GetIndexCount();
  size_t constructed_index_itr = 0;

  for (auto suggested_index : suggested_indices) {

    // Check if we have storage space
    if ((max_allowed_indexes <= 0) ||
        (constructed_index_itr >= max_allowed_indexes)) {
      LOG_INFO("No more index space");
      break;
    }

    std::set<oid_t> suggested_index_set(suggested_index.begin(),
                                        suggested_index.end());

    // Go over all indices
    bool suggested_index_found = false;
    oid_t index_itr;
    for (index_itr = 0; index_itr < index_count; index_itr++) {

      // Check attributes
      auto index_attrs = table->GetIndexAttrs(index_itr);
      if (index_attrs != suggested_index_set) {
        continue;
      }

      // Exact match
      suggested_index_found = true;
      break;
    }

    // Did we find suggested index ?
    if (suggested_index_found == false) {

      LOG_TRACE("Did not find suggested index.");

      // Add adhoc index with given utility
      AddIndex(table, suggested_index_set);
      constructed_index_itr++;
    } else {
      LOG_TRACE("Found suggested index.");
    }
  }
}
//-----------------------------------------------------------------------------
// Name : CMesh () (Alternate Constructor)
// Desc : CMesh Class Constructor, adds specified number of vertices / indices
//-----------------------------------------------------------------------------
CMesh::CMesh( ULONG VertexCount, ULONG IndexCount )
{
	// Reset / Clear all required values
    m_pVertex       = NULL;
    m_pIndex        = NULL;
    m_nVertexCount  = 0;
    m_nIndexCount   = 0;
	m_nRefCount		= 1;

    m_pVertexBuffer = NULL;
    m_pIndexBuffer  = NULL;

    // Add Vertices & indices if required
    if ( VertexCount > 0 ) AddVertex( VertexCount );
    if ( IndexCount  > 0 ) AddIndex( IndexCount );
}
Example #23
0
/// <summary>
/// Replaces a triangle at a given index buffer offset and replaces it with four triangles
/// that compose an equilateral subdivision.
/// </summary>
/// <param name="mesh">Mesh</param>
/// <param name="indexOffset">An offset into the index buffer.</param>
void DivideTriangle(USHORT indexOffset)
{	
    USHORT i1 = indices[indexOffset];
    USHORT i2 = indices[indexOffset + 1];
    USHORT i3 = indices[indexOffset + 2];

    D3DVECTOR p1; p1.x = vertices[i1].x; p1.y = vertices[i1].y, p1.z = vertices[i1].z;
    D3DVECTOR p2; p2.x = vertices[i2].x; p2.y = vertices[i2].y, p2.z = vertices[i2].z;
    D3DVECTOR p3; p3.x = vertices[i3].x; p3.y = vertices[i3].y, p3.z = vertices[i3].z;	
    D3DVECTOR p4 = GetNormalizedMidpoint(p1, p2);
    D3DVECTOR p5 = GetNormalizedMidpoint(p2, p3);
    D3DVECTOR p6 = GetNormalizedMidpoint(p3, p1);

    AddVertex(p4.x, p4.y, p4.z, p4.x, p4.y, p4.z, 0, 0);
    AddVertex(p5.x, p5.y, p5.z, p5.x, p5.y, p5.z, 0, 0);
    AddVertex(p6.x, p6.y, p6.z, p6.x, p6.y, p6.z, 0, 0);

    USHORT i4 = nextIndex++;
    USHORT i5 = nextIndex++;
    USHORT i6 = nextIndex++;

    indices[indexOffset] = i4;
    indices[indexOffset + 1] = i5;
    indices[indexOffset + 2] = i6;

    AddIndex(i1);
    AddIndex(i4);
    AddIndex(i6);

    AddIndex(i4);
    AddIndex(i2);
    AddIndex(i5);

    AddIndex(i6);
    AddIndex(i5);
    AddIndex(i3);
}
Example #24
0
IndexGroupWatched::IndexGroupWatched(index_gid_t index_id, index_gid_t range_start, index_gid_t range_end)
	: UnionIndexGroup(index_id)
	, m_or_range_start(range_start)
	, m_or_range_end(range_end)
{
	// Or all indexes currently in the range that are being watched
	INT32 it = -1;
	Index* index = m_indexer->GetRange(range_start, range_end, it);

	while (index)
	{
		if (index->IsWatched())
		{
			AddIndex(index->GetId());
		}
		index = m_indexer->GetRange(range_start, range_end, it);
	}
}
Example #25
0
OP_STATUS IndexGroupWatched::IndexVisibleChanged(Indexer *indexer, UINT32 index_id)
{
	if (m_or_range_start <= index_id && index_id < m_or_range_end)
	{
		Index* index = indexer->GetIndexById(index_id);
		if (index)
		{
			if (index->IsWatched())
			{
				return AddIndex(index_id);
			}
			else if (m_indexes.Contains(index_id))
				return IndexRemoved(indexer, index_id);
		}
	}
	
	return OpStatus::OK;
}
Example #26
0
IndexGroupMailingLists::IndexGroupMailingLists(index_gid_t index_id)
	: UnionIndexGroup(index_id)
{
	// Check all indexes that might be mailing lists
	INT32 it = -1;
	Index* index = m_indexer->GetRange(IndexTypes::FIRST_CONTACT, IndexTypes::LAST_CONTACT, it);

	while (index)
	{
		IndexSearch *search = index->GetSearch();
		if (search && search->GetSearchText().FindFirstOf('@') == KNotFound &&
			search->GetSearchText().FindFirstOf('.') != KNotFound)
		{
			AddIndex(index->GetId());
		}
		index = m_indexer->GetRange(IndexTypes::FIRST_CONTACT, IndexTypes::LAST_CONTACT, it);
	}
}
Example #27
0
OP_STATUS IndexGroupMailingLists::IndexAdded(Indexer *indexer, UINT32 index_id)
{
	if (IndexTypes::FIRST_CONTACT <= index_id && index_id < IndexTypes::LAST_CONTACT)
	{
		Index* index = indexer->GetIndexById(index_id);
		if (index)
		{
			IndexSearch *search = index->GetSearch();
			if (search &&
				search->GetSearchText().FindFirstOf('@') == KNotFound &&
				search->GetSearchText().FindFirstOf('.') != KNotFound)
			{
				return AddIndex(index_id);
			}
		}
	}
	
	return OpStatus::OK;
}
	// Draw quad
	void CDX9Renderer::Quad(const quad& q, const color& filter, const rect* _uv)
	{
		if (current_texture != NULL && current_texture == current_rendertarget)
			throw error(_T("Illegal rendering operation attempted"), E_FAIL);	// Not allowed to draw with texture being the render target

		BeginBatch(batch_quads);

		CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());

		rect uv;

		// No texture: UV coords don't matter
		if (current_texture == NULL)
			uv = zero_rect;
		else {
			
			// Texture supplied but no UV given: draw entire texture
			if (_uv == NULL)
				uv = point(current_texture->xf, current_texture->yf).make_rect();
			else
				uv = (*_uv) * point(current_texture->xf, current_texture->yf);
	
		}

		D3DCOLOR c = filter.getD3DCOLOR();

		AddVertex(c, q.tl + point(state.x_skew, 0.0),			uv.topleft());
		AddVertex(c, q.tr + point(state.x_skew, state.y_skew),	uv.topright());
		AddVertex(c, q.bl,										uv.bottomleft());
		AddVertex(c, q.br + point(0.0, state.y_skew),			uv.bottomright());

		unsigned short index = draw_op->vertex_count;
		AddIndex(index);
		AddIndex(index + 1);
		AddIndex(index + 2);
		AddIndex(index + 2);
		AddIndex(index + 1);
		AddIndex(index + 3);

		draw_op->vertex_count += 4;
		draw_op->index_count += 6;
	}
Example #29
0
status_t
FallbackIndex::Init()
{
	// Attempt to build an index by parsing the movi chunk
	TRACE("Constructing a Fallback Index\n");

	bool end_of_movi = false;
	chunk aChunk;

	int stream_index;
	off_t position;
	uint32 size;
	uint64 frame[fStreamCount];
	uint64 frame_no;
	bigtime_t pts = 0;
	bool keyframe = false;
	uint32 sample_size;
	uint64 entries = 0;
	
	const OpenDMLStream *stream;

	for (uint32 i=0;i < fStreamCount; i++) {
		frame[i] = 0;
	}

	position = fParser->MovieListStart();

	while (end_of_movi == false) {

		if ((int32)8 != fSource->ReadAt(position, &aChunk, 8)) {
			ERROR("libOpenDML: FallbackIndex::Init file reading failed\n");
			return B_IO_ERROR;
		}

		position += 8;

		stream_index = ((aChunk.chunk_id & 0xff) - '0') * 10;
        stream_index += ((aChunk.chunk_id >> 8) & 0xff) - '0';

		if ((stream_index < 0) || (stream_index >= fStreamCount)) {
			if (entries == 0) {
				ERROR("libOpenDML: FallbackIndex::Init - Failed to build an index, file is too corrupt\n");
				return B_IO_ERROR;
			} else {
				ERROR("libOpenDML: FallbackIndex::Init - Error while trying to build index, file is corrupt but will continue after creating %Ld entries in index\n",entries);
				return B_OK;
			}
		}

		entries++;

		stream = fParser->StreamInfo(stream_index);

		size = aChunk.size;
		frame_no = frame[stream_index];

		if (stream->is_video) {
			// Video is easy enough, it is always 1 frame = 1 index
			pts = frame[stream_index] * 1000000LL * stream->frames_per_sec_scale / stream->frames_per_sec_rate;
			frame[stream_index]++;
		} else if (stream->is_audio) {
			pts = frame[stream_index] * 1000000LL / stream->audio_format->frames_per_sec;

			// Audio varies based on many different hacks over the years
			// The simplest is chunk size / sample size = no of samples in the chunk for uncompressed audio
			// ABR Compressed audio is more difficult and VBR Compressed audio is even harder
			// What follows is what I have worked out from various sources across the internet.
			if (stream->audio_format->format_tag != 0x0001) {
				// VBR audio is detected as having a block_align >= 960
				if (stream->audio_format->block_align >= 960) {
					// VBR Audio so block_align is the largest no of samples in a chunk
					// scale is the no of samples in a frame
					// rate is the sample rate
					// but we must round up when calculating no of frames in a chunk
					frame[stream_index] += (uint64)(ceil((double)size / (double)stream->audio_format->block_align)) * stream->frames_per_sec_scale;
				} else {
					// ABR Audio so use Chunk Size and avergae bytes per second to determine how many samples there are in the chunk
					frame[stream_index] += (uint64)(ceil((double)size / (double)stream->audio_format->block_align)) * stream->audio_format->frames_per_sec / stream->audio_format->avg_bytes_per_sec;
				}
			} else {
				// sample size can be corrupt
				if (stream->stream_header.sample_size > 0) {
					sample_size = stream->stream_header.sample_size;
				} else {
					// compute sample size
					sample_size = stream->audio_format->bits_per_sample * stream->audio_format->channels / 8;
				}
				frame[stream_index] += size / stream->stream_header.sample_size;
			}
		}

		AddIndex(stream_index, position, size, frame_no, pts, keyframe);
		
		position += aChunk.size;
		
		end_of_movi = position >= fParser->MovieListSize();
	}
	
	return B_OK;
}
Example #30
0
struct Cluster* Calculate(struct Points* Field, int Height, int Width, int* Num, int NumOfPoints)
{
	struct Cluster *Clusters;
	int i,j,k,NumOfClusters;
	int n;
	double Min;
	/*int Min_x;
	int Min_y;
	int Max_x;
	int Max_y;*/
	double New_Cluster_X;
	double New_Cluster_Y;
	int Min_cluster;
	double Distance;
	double Point_X, Point_Y;
	int Flag = 1;
	int New_Flag;
	
	
	printf("Enter number of clusters: ");
	scanf("%d",&NumOfClusters);
	
	Clusters = (struct Cluster*)malloc(NumOfClusters * sizeof(struct Cluster));
	Init_Clusters(Clusters, NumOfClusters);
	
	srand(time(NULL));
	
	for(i = 0; i< NumOfClusters; i++)
	{
		Clusters[i].x = (double)(rand()%Width);
		Clusters[i].y = (double)(rand()%Height);
	}

	#pragma omp parallel for private(i, Min)
	for(i = 0;i<NumOfPoints;i++)
	{
		Min = (double)(Height + Width);
		for(k = 0; k<NumOfClusters; k++)
		{
			Distance = Dist(Field[i].x,Field[i].y,Clusters[k].x,Clusters[k].y);
			if(Distance < Min)
			{
				Min = Distance;
				Min_cluster = k;
			}
		}
		Field[i].cluster = Min_cluster;
		Clusters[Min_cluster] = AddIndex(Clusters[Min_cluster], i);
	}
	
	while(Flag == 1)
	{
		Flag = 0;
		#pragma omp parallel for private(k)
		for(k=0; k<NumOfClusters; k++)
		{
			n = GetClusterNumOfPoints(Clusters[k]);
			New_Cluster_X = 0;
			New_Cluster_Y = 0;
			
			/*for(i = 0; i < n; i++)
			{
				Point_X = GetX(Field, Clusters[k],i);
				Point_Y = GetY(Field, Clusters[k],i);
				New_Cluster_X = (i*New_Cluster_X + Point_X)/(i+1);//vot on obhod perepolneniya
				New_Cluster_Y = (i*New_Cluster_Y + Point_Y)/(i+1);
			}*/
			#pragma omp parallel for private(i) reduction(+:New_Cluster_X, New_Cluster_Y)
			for(i = 0; i < n; i++)
			{
				New_Cluster_X += GetX(Field, Clusters[k],i)/n;
				New_Cluster_Y += GetY(Field, Clusters[k],i)/n;
			}
			Clusters[k].x = New_Cluster_X;
			Clusters[k].y = New_Cluster_Y;
		}
		Clear_Points(Clusters, NumOfClusters);
		#pragma omp parallel for private(i, Min)
		for(i = 0;i<NumOfPoints;i++)
		{
			Min = (double)(Height + Width);
			for(k = 0; k<NumOfClusters; k++)
			{
				Distance = Dist(Field[i].x,Field[i].y,Clusters[k].x,Clusters[k].y);
				if(Distance < Min)
				{
					Min = Distance;
					Min_cluster = k;
				}
			}
			if(Field[i].cluster != Min_cluster)
				Flag = 1;
			Field[i].cluster = Min_cluster;
			Clusters[Min_cluster] = AddIndex(Clusters[Min_cluster], i);
		}
	}
	*Num = NumOfClusters;
	return Clusters;
}