예제 #1
0
bool CGraph::AddLine(double x1, float y1, double x2, float y2, unsigned int row, unsigned int labelIndex, int lineColorRGB, float relative_X, unsigned int lineEnds)
{
  GraphicalObject_Line_Ex_t* newLine_p = (GraphicalObject_Line_Ex_t*)m_byteStreamManager_p->AddBytes(sizeof(GraphicalObject_Line_Ex_t));

  if (newLine_p == NULL)
  {
    ErrorHook("CGraph::AddLine_Ex failed, out of memory\n");
    return false;
  }

  ++m_numOfObjects;

  memset(newLine_p, 0, sizeof(GraphicalObject_Line_Ex_t));

  GraphicalObject_t* go_p = &newLine_p->go;

  go_p->properties  = GRAPHICAL_OBJECT_KIND_LINE_EX_LABEL_INDEX | lineEnds;

  go_p->x1          = x1;
  go_p->y1          = y1;
  go_p->x2          = x2;
  go_p->y2          = y2;
  go_p->row         = row;

  newLine_p->lineColorRGB                     = lineColorRGB;
  newLine_p->relative_X                       = relative_X;
  newLine_p->label.labelKind.labelIndex       = labelIndex;

  UpdateExtents(go_p);

  return true;
}
예제 #2
0
bool CGraph::AddBox(double x1, float y1, double x2, float y2, unsigned int row, char* label_p, unsigned char labelLength, int fillColorRGB)
{
  unsigned int totalObjectSize = sizeof(GraphicalObject_Box_Ex_t) + labelLength + 1; // +1 for EOL

  GraphicalObject_Box_Ex_t* newBox_p = (GraphicalObject_Box_Ex_t*)m_byteStreamManager_p->AddBytes(totalObjectSize);

  if (newBox_p == NULL)
  {
    ErrorHook("CGraph::AddBox failed, out of memory\n");
    return false;
  }

  ++m_numOfObjects;

  if (x1 > x2)
  {
    double temp_x = x2;
    x2  = x1;
    x1  = temp_x;

    ErrorHook("CGraph::AddBox failed, input parameter error\n");
  }

  if (y1 > y2)
  {
    float temp_y = y2;
    y2  = y1;
    y1  = y2;

    ErrorHook("CGraph::AddBox failed, input parameter error\n");
  }

  memset(newBox_p, 0, totalObjectSize);

  GraphicalObject_t* go_p = &newBox_p->go;

  go_p->x1          = x1;
  go_p->y1          = y1;
  go_p->x2          = x2;
  go_p->y2          = y2;
  go_p->row         = row;

  go_p->properties  = GRAPHICAL_OBJECT_KIND_BOX_EX_LABEL_STR;

  newBox_p->fillColorRGB                      = fillColorRGB;
  newBox_p->label.labelKind.textLabel.length  = labelLength;

  memcpy(&newBox_p->label.labelKind.textLabel.label_a, label_p, labelLength);

  (&newBox_p->label.labelKind.textLabel.label_a)[labelLength] = 0;  // Add EOL

  UpdateExtents(go_p);

  return true;
}
예제 #3
0
bool CGraph::AddLine(double x1, float y1, double x2, float y2, unsigned int row, char* label_p, unsigned char labelLength, int lineColorRGB, float relative_X, unsigned int lineEnds)
{
  unsigned int totalObjectSize = sizeof(GraphicalObject_Line_Ex_t) + labelLength + 1;  // +1 for EOL

  GraphicalObject_Line_Ex_t* newLine_p = (GraphicalObject_Line_Ex_t*)m_byteStreamManager_p->AddBytes(totalObjectSize);

  if (newLine_p == NULL)
  {
    ErrorHook("CGraph::AddLine_Ex failed, out of memory\n");
    return false;
  }

  ++m_numOfObjects;

  if (x1 > x2)
  {
    ErrorHook("CGraph::AddLine failed, input parameter error\n");

    double temp = x2;
    x2  = x1;
    x1  = temp;
  }

  memset(newLine_p, 0, totalObjectSize);

  GraphicalObject_t* go_p = &newLine_p->go;

  go_p->properties  = GRAPHICAL_OBJECT_KIND_LINE_EX_LABEL_STR | lineEnds;

  go_p->x1          = x1;
  go_p->y1          = y1;
  go_p->x2          = x2;
  go_p->y2          = y2;
  go_p->row         = row;

  newLine_p->lineColorRGB                     = lineColorRGB;
  newLine_p->relative_X                       = relative_X;
  newLine_p->label.labelKind.textLabel.length = labelLength;

  if (label_p != NULL && labelLength > 0)
  {
    memcpy(&newLine_p->label.labelKind.textLabel.label_a, label_p, labelLength);
  }

  (&newLine_p->label.labelKind.textLabel.label_a)[labelLength] = 0;  // Add EOL

  UpdateExtents(go_p);

  return true;
}
예제 #4
0
bool CGraph::AddBox(double x1, float y1, double x2, float y2, unsigned int row, unsigned int labelIndex, int fillColorRGB)
{
  GraphicalObject_Box_Ex_t* newBox_p = (GraphicalObject_Box_Ex_t*)m_byteStreamManager_p->AddBytes(sizeof(GraphicalObject_Box_Ex_t));

  if (newBox_p == NULL)
  {
    ErrorHook("CGraph::AddBox failed, out of memory\n");
    return false;
  }

  ++m_numOfObjects;

  if (x1 > x2)
  {
    double temp_x = x2;
    x2  = x1;
    x1  = temp_x;

    ErrorHook("CGraph::AddBox failed, input parameter error\n");
  }

  if (y1 > y2)
  {
    float temp_y = y2;
    y2  = y1;
    y1  = y2;

    ErrorHook("CGraph::AddBox failed, input parameter error\n");
  }

  memset(newBox_p, 0, sizeof(GraphicalObject_Box_Ex_t));

  GraphicalObject_t* go_p = &newBox_p->go;

  go_p->x1          = x1;
  go_p->y1          = y1;
  go_p->x2          = x2;
  go_p->y2          = y2;
  go_p->row         = row;

  go_p->properties  = GRAPHICAL_OBJECT_KIND_BOX_EX_LABEL_INDEX;

  newBox_p->fillColorRGB                = fillColorRGB;
  newBox_p->label.labelKind.labelIndex  = labelIndex;

  UpdateExtents(go_p);

  return true;
}
예제 #5
0
bool CGraph::AddLine(double x1, float y1, double x2, float y2, unsigned int row)
{
  GraphicalObject_Line_t* newLine_p = (GraphicalObject_Line_t*)m_byteStreamManager_p->AddBytes(sizeof(GraphicalObject_Line_t));

  if (newLine_p == NULL)
  {
    ErrorHook("CGraph::AddLine failed, out of memory\n");
    return false;
  }

  ++m_numOfObjects;

  if (x1 > x2)
  {
    ErrorHook("CGraph::AddLine failed, input parameter error\n");

    double temp = x2;
    x2  = x1;
    x1  = temp;
  }

  memset(newLine_p, 0, sizeof(GraphicalObject_Line_t));

  GraphicalObject_t* go_p = &newLine_p->go;

  go_p->x1          = x1;
  go_p->y1          = y1;
  go_p->x2          = x2;
  go_p->y2          = y2;
  go_p->row         = row;

  go_p->properties  = GRAPHICAL_OBJECT_KIND_LINE;

  UpdateExtents(go_p);

  return true;
}
void ModelLoader::CreateVertexBuffer( Vertex::VERTEX_TYPE type ) {
	aiMesh* mesh = scene->mMeshes[0];
	UINT count = mesh->mNumVertices;
	aiVector3D* vertices = mesh->mVertices;
	/*  The switch case looks like duplicated code.  It is not.	 vertData is a different type in each and SetVertices() is a template. */
	switch( type ) {
	case Vertex::BASIC_32:
	{
		std::vector<Vertex::Basic32> vertData( count );
		aiVector3D* normals = mesh->mNormals;
		aiVector3D* texCoords = mesh->mTextureCoords[0];
		for( UINT i = 0; i<count; ++i ) {
			UpdateExtents( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Pos = XMFLOAT3( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Normal = XMFLOAT3( normals[i].x, normals[i].y, normals[i].z );
			vertData[i].Tex = XMFLOAT2( texCoords[i].x, texCoords[i].y );
		}
		SetVertices( device, count, vertData.data() );
		break;
	}
	case Vertex::POS_NORMAL_TEX_TAN:
	{
		aiVector3D* normals = mesh->mNormals;
		aiVector3D* texCoords = mesh->mTextureCoords[0];
		aiVector3D* tangents = mesh->mTangents;
		std::vector<Vertex::PosNormalTexTan> vertData( count );
		for( UINT i = 0; i<count; ++i ) {
			UpdateExtents( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Pos = XMFLOAT3( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Normal = XMFLOAT3( normals[i].x, normals[i].y, normals[i].z );
			vertData[i].Tex = XMFLOAT2( texCoords[i].x, texCoords[i].y );
			vertData[i].TangentU = XMFLOAT4( tangents[i].x, tangents[i].y, tangents[i].z, 0.f );
		}
		SetVertices( device, count, vertData.data() );
		break;
	}
	case Vertex::POS_NORMAL_TEX_TAN_SKINNED:
	{
		aiVector3D* normals = mesh->mNormals;
		aiVector3D* texCoords = mesh->mTextureCoords[0];
		aiVector3D* tangents = mesh->mTangents;
		std::vector<Vertex::PosNormalTexTanSkinned> vertData( count );
		for( UINT i = 0; i<count; ++i ) {
			UpdateExtents( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Pos = XMFLOAT3( vertices[i].x, vertices[i].y, vertices[i].z );
			vertData[i].Normal = XMFLOAT3( normals[i].x, normals[i].y, normals[i].z );
			vertData[i].Tex = XMFLOAT2( texCoords[i].x, texCoords[i].y );
			vertData[i].TangentU = XMFLOAT4( tangents[i].x, tangents[i].y, tangents[i].z, 0.f );
		}

		// Bone Data
		std::multimap<int, BoneWeight> vertexBoneWeight;
		for( unsigned int boneIndex = 0; boneIndex<mesh->mNumBones; ++boneIndex ) {
			auto bone = mesh->mBones[boneIndex];
			for( int i = 0; i<bone->mNumWeights; ++i ) {
				auto boneWeight = BoneWeight( boneIndex, bone->mWeights[i].mWeight );
				vertexBoneWeight.insert( std::pair<int, BoneWeight>( bone->mWeights[i].mVertexId, boneWeight ) );
			}
		}
		for( UINT i = 0; i<count; ++i ) {
			BYTE boneIndices[4] = { 0, 0, 0, 0 };
			float weights[4] = { 0, 0, 0, 0 };
			int j = 0;
			auto itlow = vertexBoneWeight.lower_bound( i );
			auto itup = vertexBoneWeight.upper_bound( i );
			assert( itlow!=itup ); // every vertex should have some influence
			for( auto it = itlow; it!=itup; ++it ) {
				if( j>3 ) {
					assert( false ); // only 4 boes should influence one vertex
					break;
				}
				boneIndices[j] = it->second.boneIndex;
				weights[j] = it->second.weight;
				++j;
			}
			vertData[i].BoneIndicies[0] = boneIndices[0];
			vertData[i].BoneIndicies[1] = boneIndices[1];
			vertData[i].BoneIndicies[2] = boneIndices[2];
			vertData[i].BoneIndicies[3] = boneIndices[3];
			vertData[i].Weights = XMFLOAT4( weights );
		}

		SetVertices( device, count, vertData.data() );
		break;
	}
	}
}
예제 #7
0
//applies word wrapping to the string so that all characters should be in the range of 0..nWidth in 
//the X axis and in the range [0...+inf] in the Y axis. This undoes any previous word wrapping or
//formatting
bool CTextureString::WordWrap(uint32 nWidth)
{
	//fail if we have no associated glyphs
	if(GetTextureImage() == NULL)
	{
		return (m_nNumCharacters == 0);
	}

	//keep track of our current position
	uint32 nCurrX = 0;
	uint32 nCurrY = 0;

	//determine the height of a single row of text
	uint32 nRowHeight = GetTextureImage()->GetRowHeight();

	//the index into the character where this current row started
	uint32 nRowStart = 0;

	//this flag indicates that the character needs to be reset. This is set when a line break
	//is encountered so that the next character can begin on a new line
	bool bResetRow = false;

	//all characters should default to being visible. Then as they break rows or 
	//other rules are applied, they can be made invisible
	uint32 nCurrChar;
	for(nCurrChar = 0; nCurrChar < m_nNumCharacters; nCurrChar++)
	{
		m_pCharacters[nCurrChar].m_bVisible = true;
	}

	//we now need to lay out each character
	for(nCurrChar = 0; nCurrChar < m_nNumCharacters; nCurrChar++)
	{
		//see if we are following a line break and need to reset the row
		if(bResetRow)
		{
			nCurrX = 0;
			nCurrY += nRowHeight;

			//our next row will start on the 
			nRowStart = nCurrChar;

			//clear the flag so it won't do it again
			bResetRow = false;
		}

		//see if this character will fit onto this row
		CTextureStringChar* pChar = &m_pCharacters[nCurrChar];
		uint32 nCurrCharWidth = pChar->m_pGlyph->m_nTotalWidth;

		//see if this is a hard line break and we have to move onto the next line
		if(IsHardLineBreak(m_pszString, nCurrChar))
		{
			//we need to reset the row
			bResetRow = true;

			//we also want to make this line break character invisible
			m_pCharacters[nCurrChar].m_bVisible = false;
		}
		//see if we are too wide (note the >= is because 0 is counted, so the limit is not included)
		//but we must also ensure that at least one character is placed per line
        else if((nCurrChar != nRowStart) && (nCurrX + nCurrCharWidth >= nWidth))
		{
			//we are too wide, lets move down. We need to determine where we can do a break by scanning
			//backwards on this row and determining where to split, but only if it isn't a hard line break
			uint32 nSplitChar = FindLineBreak(m_pszString, nRowStart + 1, nCurrChar);
			
			//update our cursor position to begin on the next row
			nCurrX = 0;
			nCurrY += nRowHeight;

			//and update our row beginning character
			nRowStart = nSplitChar + 1;

			//and we now need to move all the characters at the break onto the next line
			for(uint32 nMoveChar = nSplitChar + 1; nMoveChar < nCurrChar; nMoveChar++)
			{
				CTextureStringChar* pMoveChar = &m_pCharacters[nMoveChar];
				pMoveChar->m_nXPos = nCurrX;
				pMoveChar->m_nYPos = nCurrY;

				//move the cursor past this character
				nCurrX += pMoveChar->m_pGlyph->m_nTotalWidth;
			}
			
			//also make the split character invisible
			m_pCharacters[nSplitChar].m_bVisible = false;

		}

		//now that we know there is room, place the character
		pChar->m_nXPos = nCurrX;
		pChar->m_nYPos = nCurrY;

		//update the cursor position
		nCurrX += nCurrCharWidth;
	}

	//update our new extents
	UpdateExtents();

	//success
	return true;
}
avtDataTree_p
avtSIMODataTreeIterator::Execute(avtDataTree_p inDT)
{
    CheckAbort();

    if (*inDT == NULL)
    {
        return NULL;
    }

    int nc = inDT->GetNChildren();

    if (nc <= 0 && !inDT->HasData())
    {
        return NULL;
    }

    if ( nc == 0 )
    {
        //
        // there is only one dataset to process
        //
        vtkDataSet *in_ds = inDT->GetDataRepresentation().GetDataVTK();
        int dom = inDT->GetDataRepresentation().GetDomain();
        std::string label = inDT->GetDataRepresentation().GetLabel();
  
        //
        // Setting the source to NULL for the input will break the 
        // pipeline.
        //
        // NO LONGER A GOOD IDEA
        //in_ds->SetSource(NULL);

        //
        // We own the returned dataset because you cannot delete it if
        // it only has one reference and you want to return it.
        //
        avtDataTree_p rv = ExecuteDataTree(in_ds, dom, label);
        UpdateExtents(rv);
        currentNode++;
        UpdateProgress(currentNode, totalNodes);
        return rv;
    }
    else
    {
        //
        // there is more than one input dataset to process
        // and we need an output datatree for each
        //
        avtDataTree_p *outDT = new avtDataTree_p[nc];
        for (int j = 0; j < nc; j++)
        {
            if (inDT->ChildIsPresent(j))
            {
                outDT[j] = Execute(inDT->GetChild(j));
            }
            else
            {
                outDT[j] = NULL;
            }
        }
        avtDataTree_p rv = new avtDataTree(nc, outDT);
        delete [] outDT;
        return (rv);
    }
}
void
avtActualExtentsFilter::Execute(void)
{
    UpdateExtents();
    SetOutputDataTree(GetInputDataTree());
}