PetscParallelConfiguration::PetscParallelConfiguration(Parameters & parameters):
    _parameters(parameters) {

    // Obtain the rank of the current processor
    int rank, nproc;
    MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
    MPI_Comm_size(PETSC_COMM_WORLD, &nproc);

    parameters.parallel.rank = rank;

    // Obtain the position of this subdomain, and locate its neighbors.
    createIndices();
    locateNeighbors();
    computeSizes();

    int nprocFromFile = _parameters.parallel.numProcessors[0] *
                        _parameters.parallel.numProcessors[1];

    if (parameters.geometry.dim == 3) {
        nprocFromFile *= _parameters.parallel.numProcessors[2];
    }

    if (nproc != nprocFromFile){
        handleError(1, "The number of processors specified in the configuration file doesn't match the communicator");
    }
}
GeodesicHemisphereMesh::GeodesicHemisphereMesh(unsigned level)
{
    unsigned nv = (level + 1) * (level + 1) * 2;
    
    unsigned nf = level * level * 2 * 2;
    
    createVertices(nv);
	createIndices(nf * 3);

	Vector3F * p = vertices();
	
	unsigned * idx = indices();
	
	unsigned currentidx = 0;
	unsigned currentver = 0;
	
	Vector3F a(0.f, 1.f, 0.f);
	Vector3F b(-1.f, 0.001f, 0.f);
	Vector3F c(0.f, 0.001f, 1.f);
	Vector3F d(1.f, 0.001f, 0.f);
	Vector3F e(0.f, 0.001f, -1.f);
	
	subdivide(level, currentver, currentidx, p, idx, a, b, c, d);
	subdivide(level, currentver, currentidx, p, idx, a, d, e, b);

    printf("vertices count: %d\n", currentver);
    printf("indices count: %d\n", currentidx);	
}
void createShape(int type)
{
    cleanup();
    createGeometry(type, &geometry, uTessellation, uTessellation);
    createIndices(&geometry, uTessellation, uTessellation);
    createNormals(type, &geometry, uTessellation, uTessellation);
}
Beispiel #4
0
KDbRelationship::KDbRelationship(KDbQuerySchema *query, KDbField *field1, KDbField *field2)
        : m_masterIndex(0)
        , m_detailsIndex(0)
        , m_masterIndexOwned(false)
        , m_detailsIndexOwned(false)
{
    createIndices(query, field1, field2);
}
BtIndexPage::BtIndexPage()
	: BtConfigPage()
{

	QVBoxLayout *vboxLayout;
	QHBoxLayout *hboxLayout;
    vboxLayout = new QVBoxLayout(this);
 
	m_autoDeleteOrphanedIndicesBox = new QCheckBox(this);
	m_autoDeleteOrphanedIndicesBox->setToolTip(tr("If selected, those indexes which have no corresponding work will be deleted when BibleTime starts"));
	m_autoDeleteOrphanedIndicesBox->setText(tr("Automatically delete orphaned indexes when BibleTime starts"));
	vboxLayout->addWidget(m_autoDeleteOrphanedIndicesBox);

	m_moduleList = new QTreeWidget(this);
	vboxLayout->addWidget(m_moduleList);

	hboxLayout = new QHBoxLayout();

	QSpacerItem *spacerItem = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
	hboxLayout->addItem(spacerItem);

	m_deleteButton = new QPushButton(this);
	m_deleteButton->setToolTip(tr("Delete the selected indexes"));
	m_deleteButton->setText(tr("Delete"));
	hboxLayout->addWidget(m_deleteButton);

	m_createButton = new QPushButton(this);
	m_createButton->setToolTip(tr("Create new indexes for the selected works"));
	m_createButton->setText(tr("Create..."));
	hboxLayout->addWidget(m_createButton);

	vboxLayout->addLayout(hboxLayout);

	// configure the list view
	m_moduleList->setHeaderLabels( (QStringList(tr("Work")) << tr("Index size")) );
	m_moduleList->setRootIsDecorated(true);
	m_moduleList->setColumnWidth(0, CToolClass::mWidth(m_moduleList, 20) );
	//m_moduleList->setTextAlignment(1, Qt::AlignRight); see doc...
	m_moduleList->setSortingEnabled(false);

	m_autoDeleteOrphanedIndicesBox->setChecked( CBTConfig::get( CBTConfig::autoDeleteOrphanedIndices ) );

	// icons for our buttons
	m_createButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::indexpage::create_icon));
	m_deleteButton->setIcon(util::filesystem::DirectoryUtil::getIcon(CResMgr::bookshelfmgr::indexpage::delete_icon));

	// connect our signals/slots
	connect(m_createButton, SIGNAL(clicked()), this, SLOT(createIndices()));
	connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteIndices()));
	connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged(CSwordBackend::SetupChangedReason)), SLOT(slotSwordSetupChanged()));

	populateModuleList();
}
Sphere::Sphere(float nRadius, float nStacks, float nSlices) 
:radius(nRadius)
,stacks(nStacks)
,slices(nSlices)
{
	num_vertices = (nStacks + 1) * (nSlices + 1);
	num_index_elements = (nStacks) * (nSlices) * 4;
	vertices = new VertexPTNC[num_vertices];
	index_elements = new int[num_index_elements];
	
	createVertices();
	createIndices();
};
void Toroid::init(){
    vertCount = detail * segs;
    triFaceCount = vertCount*2;
    
    indicesCount = triFaceCount*3;
    
    allocateMemory();
    createVertices();
    createIndices();
    createFaces();
    createVertexNormals();
    createCoords();
}
void ReduceSurfaceTriangulation::operate()
{
  setStretchingFactor(1.0);
  prepare();
  //writeGrid(m_Grid, "take1");
  updateNodeInfo();
  //writeGrid(m_Grid, "take2");
  pass1();
  //pass2();
  createIndices(m_Grid);
  updateNodeInfo();
  computeMeshDensity();
}
bool ThumbnailSchemaUpdater::createDatabase()
{
    if ( createTables()
         && createIndices()
         && createTriggers())
    {
        m_currentVersion = schemaVersion();
        m_currentRequiredVersion = 1;
        return true;
    }
    else
    {
        return false;
    }
}
HRESULT ManagementSprite::initIndexBuffer(ID3D11Device* p_device)
{
	HRESULT hr = S_OK;

	std::vector<DWORD> indices = createIndices();

	D3D11_BUFFER_DESC ibd;
	ibd.Usage = D3D11_USAGE_DYNAMIC;
	ibd.ByteWidth = sizeof(DWORD) * indices.size();
	ibd.BindFlags = D3D11_BIND_INDEX_BUFFER;
	ibd.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	ibd.MiscFlags = 0;

	D3D11_SUBRESOURCE_DATA iinitData;
	iinitData.pSysMem = &indices[0];
	hr = p_device->CreateBuffer(&ibd, &iinitData, &m_indexBuffer);

	if(FAILED(hr))
		MessageBox(NULL, L"ManagmenetSprite::initIndexBuffer() | CreateBuffer() | Failed", L"Sprite IndexBuffer", MB_OK | MB_ICONEXCLAMATION);

	return hr;
}
Beispiel #11
0
void Model_Sonic::createGeometry(ParserContext &ctx) {
	_geometries.resize(ctx.polygons.size());
	for (size_t i = 0; i < ctx.polygons.size(); i++) {
		Polygon  &polygon  = ctx.polygons[i];
		Geometry &geometry = _geometries[i];

		// Load texture
		try {
			if (polygon.material && !polygon.material->texture.empty())
				geometry.texture = TextureMan.get(polygon.material->texture);
		} catch (Common::Exception &e) {
			Common::printException(e, "WARNING: ");
		}

		// Create the primitives and their vertices
		createPrimitives(ctx, geometry, polygon);

		// And fill in the indices
		for (Primitives::iterator p = geometry.primitives.begin(); p != geometry.primitives.end(); ++p)
			createIndices(*p);
	}
}
Beispiel #12
0
AbcMesh::AbcMesh(const char * filename) 
{
    std::cout<<"abc file "<<filename<<std::endl;
	createVertices(4);
	createIndices(6);
	
	Vector3F * p = vertices();
	
	unsigned * idx = indices();
	
	idx[0] = 0;
	idx[1] = 1;
	idx[2] = 2;
	idx[3] = 2;
	idx[4] = 3;
	idx[5] = 0;
	
	p[0].x = 0.f; p[0].y = 0.f; p[0].z = 2.f;
	p[1].x = 1.f; p[1].y = 0.f; p[1].z = 2.f;
	p[2].x = 1.f; p[2].y = 1.f; p[2].z = 2.f;
	p[3].x = 0.f; p[3].y = 1.f; p[3].z = 2.f;
}
Beispiel #13
0
unsigned BaseMesh::processTriangleFromPolygon()
{
	m_numTriangles = 0;
	
	unsigned i, j;
    for(i = 0; i < m_numPolygons; i++)
        m_numTriangles += m_polygonCounts[i] - 2;
		
	createIndices(m_numTriangles * 3);
    
    unsigned curTri = 0;
    unsigned curFace = 0;
    for(i = 0; i < m_numPolygons; i++) {
        for(j = 1; j < m_polygonCounts[i] - 1; j++) {
            _indices[curTri] = m_polygonIndices[curFace];
            _indices[curTri + 1] = m_polygonIndices[curFace + j];
            _indices[curTri + 2] = m_polygonIndices[curFace + j + 1];
            curTri += 3;
        }
        curFace += m_polygonCounts[i];
    }
	
	return m_numTriangles;
}
Beispiel #14
0
bool TerrainPager::Init()
{
	assert(NULL != pDevice && "Direct 3D Device not set");
	geometryStream = StreamReader::Create("map");
	assert(NULL != geometryStream);	// No data to read just quit.

	if (utilizeTextures)
	{
		texturesStream = StreamReader::Create("textures");
		assert(NULL != texturesStream);	// No data to read just quit.
	}
	
	

	pPatchResolution = PatchResolution::Create(resolution);
	if (NULL == pPatchResolution)
		return false;

	pPatchVerticesMapping = PatchVerticesMapping::Create(pPatchResolution);
	if (NULL == pPatchVerticesMapping)
		return false;

	pPatchFacesIndexer = PatchFacesIndexer::Create(pPatchResolution);
	if (NULL == pPatchFacesIndexer)
		return false;

	createVertexDeclarations();

	// Now create device objects
	// determine vertex buffer size.
	int vrtsPerPatchRow = pPatchResolution->GetValue() + 1;
	int vrtsPerPatch = vrtsPerPatchRow * vrtsPerPatchRow;
	int vrtsInAllPatches = vrtsPerPatch * nbAllocatedPatches;

	HRESULT hr;


	// create texture uv vertex buffer
	V(pDevice->CreateVertexBuffer(
		vrtsPerPatch * 2 * sizeof(float),
		D3DUSAGE_WRITEONLY,
		0,
		D3DPOOL_DEFAULT,
		&vbTexUV,
		NULL));

	// fill the uv vertex buffer.
	struct UV
	{
		float u, v;
	};

	UV *texUV;
	float step = 1.0f / pPatchResolution->GetValue();
	int index;
	V(vbTexUV->Lock(0, 0, (void**)&texUV, 0));
	for(int i = 0; i <= pPatchResolution->GetValue(); ++i)
		for (int j = 0; j <= pPatchResolution->GetValue(); ++j)
		{
			index = (*pPatchVerticesMapping)(i, j);
			texUV[index].u = j * step;
			texUV[index].v = i * step;
		}
	V(vbTexUV->Unlock());

	// create geomtery vertex buffer.
	V(pDevice->CreateVertexBuffer(
		vrtsInAllPatches * sizeof(TerrainVertex),
		D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
		0,
		D3DPOOL_DEFAULT,
		&pVB,
		NULL));

	if (false == createPatches(vrtsPerPatch))
		return false;

	if (false == createIndices())
		return false;

	jobManager = new JobManager(pPatchResolution->GetLevelsCount(), utilizeTextures);

	return true;
}