Esempio n. 1
0
 const Data& GetStreamGroup()
 {
     return GetElement(0);
 }
Esempio n. 2
0
int ChSparseMatrix::Solve_LinSys	(ChMatrix<>* B, ChMatrix<>* X, int* pivarray, double* det) // the object is the [A] matrix.
{
	ChMelement* rowel;
	ChMelement* subrowel;
	int i,k, pivrow, eqpivoted;
	double r, bi, x, sum, pivot, pivlast, mval, subval, newval, leader;
	int err = 0;

	if (pivarray)	// initialize pivot index array
	{
		for (int ind = 0; ind < rows; ind++)
		{ pivarray[ind] = ind;}
	}

	*det = 1;

			// FORWARD reduction
	for (k=1; k < rows; k++)
	{
		pivot = GetElement((k-1),(k-1));
		if (fabs(pivot) < ACCEPT_PIVOT)
		{
			pivrow = BestPivotRow(k-1);
			SwapRows ((k-1), pivrow );
			B->SwapRows ((k-1), pivrow );
			*det = - *det;
			if (pivarray)
			{
				eqpivoted = pivarray[pivrow]; // swap eq.ids in pivot array
				pivarray[pivrow] =pivarray[k-1];
				pivarray[k-1] = eqpivoted;
			}
			pivot = GetElement((k-1),(k-1));
		}
		if (fabs(pivot) <= MIN_PIVOT)	// was unable to find better pivot: force solution to zero.and go ahead
		{
			//*det = *det;
			pivot = INFINITE_PIVOT;
			SetElement(k-1, k-1 , pivot);
			if (!err)
				err = (1+rows-k);	// report deficiency
		}
		else
			*det = *det * pivot;

		for (i=k; i < rows; i++)
		{
			leader = GetElement(i, (k-1));

			if (leader)
			{
		  	 r = leader / pivot;

			 bi= B->GetElement(i,0) - r * B->GetElement((k-1),0);
			 B->SetElement(i,0, bi);

			 subrowel = GetElarrayMel(i);
			 rowel=GetElarrayMel(k-1);

			 //while ((rowel->col<k) && (rowel->next))
			//	 rowel = rowel->next;		// advance top row element till it has (col >= k)

			 for (NULL; rowel!=NULL ; rowel=rowel->next)
			 {
				if (rowel->col >= k)		// skip
				{
					mval = rowel->val;
					subrowel= GetElement(i, rowel->col, &subval, subrowel);
					newval = subval - r * mval;
					subrowel= SetElement(i, rowel->col, newval, subrowel);
				}
			 }
			}
		}
	}

	pivlast = GetElement((rows-1),(rows-1));
	if (fabs(pivlast) <= MIN_PIVOT)
	{
		//*det = *det;
		pivlast = INFINITE_PIVOT;
		SetElement(rows-1, rows-1 , pivlast);
		if (!err)
			err = (1);	// report deficiency
	}
	else
		*det = *det * pivlast;

			// BACKWARD substitution
	double xlast = B->GetElement(rows-1,0) / pivlast;
	X->SetElement((rows-1),0,xlast);

	for (k=(rows-2); k>= 0; k--)
	{
		sum = 0;

		rowel=GetElarrayMel(k);

		for (NULL; rowel!=NULL ; rowel=rowel->next) //for (j=(k+1); j< rows; j++)
		{
			if (rowel->col >= k+1)		// skip L part,
			{
				sum += rowel->val * (X->GetElement(rowel->col,0)); //sum += (GetElement(k,j))*(X->GetElement(j,0));
			}
		}

		x = (B->GetElement(k,0) - sum) / GetElement(k,k);
		X->SetElement(k,0, x);
	}

	return err;
}
Esempio n. 3
0
Vector& Matrix::GetRow(int row) {
	double* vecArr = new double[4];
	for (int j = 1; j <= 4; j++)
		vecArr[j - 1] = GetElement(row, j);
	return *(new Vector(vecArr, 4));
}
Esempio n. 4
0
void Cylindrical2dMesh::UseTheseElementsToDecideMeshing(std::set<unsigned>& rMainSideElements)
{
    assert(rMainSideElements.size() == 2);

    // We find the four nodes surrounding the dodgy meshing, on each side.
    std::set<unsigned> main_four_nodes;
    for (std::set<unsigned>::iterator left_iter = rMainSideElements.begin();
         left_iter != rMainSideElements.end();
         ++left_iter)
    {
        unsigned elem_index = *left_iter;
        Element<2,2>* p_element = GetElement(elem_index);
        for (unsigned i=0; i<3; i++)
        {
            unsigned index = p_element->GetNodeGlobalIndex(i);
            main_four_nodes.insert(index);
        }
    }
    assert(main_four_nodes.size() == 4);

    std::set<unsigned> other_four_nodes;
    for (std::set<unsigned>::iterator iter = main_four_nodes.begin();
         iter != main_four_nodes.end();
         ++iter)
    {
        other_four_nodes.insert(GetCorrespondingNodeIndex(*iter));
    }
    assert(other_four_nodes.size() == 4);

    /*
     * Find the elements surrounded by the nodes on the right
     * and change them to match the elements on the left.
     */
    std::vector<unsigned> corresponding_elements;

    // Loop over all elements
    for (MutableMesh<2,2>::ElementIterator elem_iter = GetElementIteratorBegin();
         elem_iter != GetElementIteratorEnd();
         ++elem_iter)
    {
        // Loop over the nodes of the element
        if (!(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(0))==other_four_nodes.end()) &&
            !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(1))==other_four_nodes.end()) &&
            !(other_four_nodes.find(elem_iter->GetNodeGlobalIndex(2))==other_four_nodes.end()) )
        {
            corresponding_elements.push_back(elem_iter->GetIndex());
            elem_iter->MarkAsDeleted();
            mDeletedElementIndices.push_back(elem_iter->GetIndex());
        }
    }
    assert(corresponding_elements.size() == 2);

    // Now corresponding_elements contains the two elements which are going to be replaced by rMainSideElements
    unsigned num_elements = GetNumAllElements();
    for (std::set<unsigned>::iterator iter = rMainSideElements.begin();
         iter != rMainSideElements.end();
         ++iter)
    {
        Element<2,2>* p_main_element = GetElement(*iter);
        std::vector<Node<2>*> nodes;

        // Put corresponding nodes into a std::vector
        for (unsigned i=0; i<3; i++)
        {
            unsigned main_node = p_main_element->GetNodeGlobalIndex(i);
            nodes.push_back(this->GetNode(GetCorrespondingNodeIndex(main_node)));
        }

        // Make a new element
        Element<2,2>* p_new_element = new Element<2,2>(num_elements, nodes);
        this->mElements.push_back(p_new_element);
        this->mElementJacobians.push_back(zero_matrix<double>(2,2));
        this->mElementInverseJacobians.push_back(zero_matrix<double>(2,2));
        this->mElementJacobianDeterminants.push_back(0.0);
        num_elements++;
    }

    // Reindex to get rid of extra elements indices
    NodeMap map(GetNumAllNodes());
    this->ReIndex(map);
}
Esempio n. 5
0
Element*
Attr::GetOwnerElement(ErrorResult& aRv)
{
  return GetElement();
}
Esempio n. 6
0
bool VertexBuffer::HasElement(const PODVector<VertexElement>& elements, VertexElementType type, VertexElementSemantic semantic, unsigned char index)
{
    return GetElement(elements, type, semantic, index) != nullptr;
}
Esempio n. 7
0
void Cylindrical2dMesh::ReMesh(NodeMap& rMap)
{
    unsigned old_num_all_nodes = GetNumAllNodes();

    rMap.Resize(old_num_all_nodes);
    rMap.ResetToIdentity();

    // Flag the deleted nodes as deleted in the map
    for (unsigned i=0; i<old_num_all_nodes; i++)
    {
        if (mNodes[i]->IsDeleted())
        {
            rMap.SetDeleted(i);
        }
    }

    CreateHaloNodes();

    // Create mirrored nodes for the normal remesher to work with
    CreateMirrorNodes();

    /*
     * The mesh now has messed up boundary elements, but this
     * doesn't matter as the ReMesh() below doesn't read them in
     * and reconstructs the boundary elements.
     *
     * Call ReMesh() on the parent class. Note that the mesh now has lots
     * of extra nodes which will be deleted, hence the name 'big_map'.
     */
    NodeMap big_map(GetNumAllNodes());
    MutableMesh<2,2>::ReMesh(big_map);

    /*
     * If the big_map isn't the identity map, the little map ('map') needs to be
     * altered accordingly before being passed to the user. Not sure how this all
     * works, so deal with this bridge when we get to it.
     */
    assert(big_map.IsIdentityMap());

    // Re-index the vectors according to the big nodemap, and set up the maps.
    mImageToLeftOriginalNodeMap.clear();
    mImageToRightOriginalNodeMap.clear();

    assert(mLeftOriginals.size() == mLeftImages.size());
    assert(mRightOriginals.size() == mRightImages.size());

    for (unsigned i=0; i<mLeftOriginals.size(); i++)
    {
        mLeftOriginals[i] = big_map.GetNewIndex(mLeftOriginals[i]);
        mLeftImages[i] = big_map.GetNewIndex(mLeftImages[i]);
        mImageToLeftOriginalNodeMap[mLeftImages[i]] = mLeftOriginals[i];
    }

    for (unsigned i=0; i<mRightOriginals.size(); i++)
    {
        mRightOriginals[i] = big_map.GetNewIndex(mRightOriginals[i]);
        mRightImages[i] = big_map.GetNewIndex(mRightImages[i]);
        mImageToRightOriginalNodeMap[mRightImages[i]] = mRightOriginals[i];
    }

    for (unsigned i=0; i<mTopHaloNodes.size(); i++)
    {
        mTopHaloNodes[i] = big_map.GetNewIndex(mTopHaloNodes[i]);
        mBottomHaloNodes[i] = big_map.GetNewIndex(mBottomHaloNodes[i]);
    }

    /*
     * Check that elements crossing the periodic boundary have been meshed
     * in the same way at each side.
     */
    CorrectNonPeriodicMesh();

    /*
     * Take the double-sized mesh, with its new boundary elements, and
     * remove the relevant nodes, elements and boundary elements to leave
     * a proper periodic mesh.
     */
    ReconstructCylindricalMesh();

    DeleteHaloNodes();

    /*
     * Create a random boundary element between two nodes of the first
     * element if it is not deleted. This is a temporary measure to get
     * around re-index crashing when there are no boundary elements.
     */
    unsigned num_elements = GetNumAllElements();
    bool boundary_element_made = false;
    unsigned elem_index = 0;

    while (elem_index<num_elements && !boundary_element_made)
    {
        Element<2,2>* p_element = GetElement(elem_index);
        if (!p_element->IsDeleted())
        {
            boundary_element_made = true;
            std::vector<Node<2>*> nodes;
            nodes.push_back(p_element->GetNode(0));
            nodes.push_back(p_element->GetNode(1));
            BoundaryElement<1,2>* p_boundary_element = new BoundaryElement<1,2>(0, nodes);
            p_boundary_element->RegisterWithNodes();
            mBoundaryElements.push_back(p_boundary_element);
            this->mBoundaryElementWeightedDirections.push_back(zero_vector<double>(2));
            this->mBoundaryElementJacobianDeterminants.push_back(0.0);
        }
        elem_index++;
    }

    // Now call ReIndex() to remove the temporary nodes which are marked as deleted
    NodeMap reindex_map(GetNumAllNodes());
    ReIndex(reindex_map);
    assert(!reindex_map.IsIdentityMap());  // maybe don't need this

    /*
     * Go through the reindex map and use it to populate the original NodeMap
     * (the one that is returned to the user).
     */
    for (unsigned i=0; i<rMap.GetSize(); i++) // only going up to be size of map, not size of reindex_map
    {
        if (reindex_map.IsDeleted(i))
        {
            /*
             * i < num_original_nodes and node is deleted, this should correspond to
             * a node that was labelled as before the remeshing, so should have already
             * been set as deleted in the map above.
             */
            assert(rMap.IsDeleted(i));
        }
        else
        {
            rMap.SetNewIndex(i, reindex_map.GetNewIndex(i));
        }
    }

    // We can now clear the index vectors and maps; they are only used for remeshing
    mLeftOriginals.clear();
    mLeftImages.clear();
    mImageToLeftOriginalNodeMap.clear();
    mRightOriginals.clear();
    mRightImages.clear();
    mImageToRightOriginalNodeMap.clear();
    mLeftPeriodicBoundaryElementIndices.clear();
    mRightPeriodicBoundaryElementIndices.clear();
}
Esempio n. 8
0
 int64 GetTTL()
 {
     return GetElement(0).GetInt64();
 }
Esempio n. 9
0
/*********************************************************************************************
When the dialog is completed before being displayed, the colors of the buttons are modified 
and only the default buttons 'Save' 'Cancel' and 'Clear' are visible. 'Modify' and 'Delete' 
are hidden
**********************************************************************************************/
void CEntryInfoDlg::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{
	CDHtmlDialog::OnDocumentComplete(pDisp, szUrl);

	CComPtr<IHTMLElement> pModifyElement;
	CComPtr<IHTMLElement> pDeleteElement;
	CComPtr<IHTMLElement> pSaveElement;
	CComPtr<IHTMLElement> pClearElement;
	CComPtr<IHTMLElement> pCancelElement;
	CComPtr<IHTMLStyle> pModifyStyle;
	CComPtr<IHTMLStyle> pDeleteStyle;
	CComPtr<IHTMLStyle> pSaveStyle;
	CComPtr<IHTMLStyle> pClearStyle;
	CComPtr<IHTMLStyle> pCancelStyle;

	HRESULT result;
	CComBSTR bstr;
	CComBSTR Defaultbstr;
	CString szStr;
	CString szDefaultstr;
	COleVariant varColor;

	if (!m_fVisibleButtons)
		szStr = _T("hidden");
	else
		szStr = _T("visible");

	if (!m_fVisibleDefaultButtons)
		szDefaultstr = _T("hidden");
	else
		szDefaultstr = _T("visible");

	result = GetElement(_T("BModify"), &pModifyElement);
	result = GetElement(_T("BDelete"), &pDeleteElement); 
	result = GetElement(_T("BSave"), &pSaveElement);
	result = GetElement(_T("BClear"), &pClearElement); 
	result = GetElement(_T("BCancel"), &pCancelElement);
	
	ASSERT(pModifyElement);
	ASSERT(pDeleteElement);
	ASSERT(pSaveElement);
	ASSERT(pClearElement);
	ASSERT(pCancelElement);

	pModifyElement->get_style(&pModifyStyle);
	pDeleteElement->get_style(&pDeleteStyle);
	pSaveElement->get_style(&pSaveStyle);
	pClearElement->get_style(&pClearStyle);
	pCancelElement->get_style(&pCancelStyle);

	ASSERT(pModifyStyle);
	ASSERT(pDeleteStyle);
	ASSERT(pSaveStyle);
	ASSERT(pClearStyle);
	ASSERT(pCancelStyle);
	
	bstr = szStr.AllocSysString();
	Defaultbstr = szDefaultstr.AllocSysString();
	
	if (pModifyStyle && pDeleteStyle && pSaveStyle && pClearStyle && pCancelStyle)
	{
		pModifyStyle->put_visibility(bstr);
		pDeleteStyle->put_visibility(bstr);
		pSaveStyle->put_visibility(Defaultbstr);
		pClearStyle->put_visibility(Defaultbstr);
		varColor = YELLOW;
		pModifyStyle->put_color(varColor);
		pDeleteStyle->put_color(varColor);
		pSaveStyle->put_color(varColor);
		pClearStyle->put_color(varColor);
		pCancelStyle->put_color(varColor);
		varColor = BLACK;
		pModifyStyle->put_backgroundColor(varColor);
		pDeleteStyle->put_backgroundColor(varColor);
		pSaveStyle->put_backgroundColor(varColor);
		pClearStyle->put_backgroundColor(varColor);
		pCancelStyle->put_backgroundColor(varColor);
	}
}
Esempio n. 10
0
 double GetZSetScore() const
 {
     return GetElement(0).GetFloat64();
 }
Esempio n. 11
0
 const Data& GetTTLKey() const
 {
     return GetElement(0);
 }
Esempio n. 12
0
 double GetListIndex() const
 {
     return GetElement(0).GetFloat64();
 }
Esempio n. 13
0
 const Data& GetSetMember() const
 {
     return GetElement(0);
 }
Esempio n. 14
0
 const Data& GetHashField() const
 {
     return GetElement(0);
 }
Action* EmptyPlaceholderSelection::GetRestoreAction()
{
	return new RestoreEmptyPlaceholderSelectionAction(GetElement());
}
void PottsBasedCellPopulation<DIM>::UpdateCellLocations(double dt)
{
    /*
     * This method implements a Monte Carlo method to update the cell population.
     * We sample randomly from all nodes in the mesh. Once we have selected a target
     * node we randomly select a neighbour. The Hamiltonian is evaluated in the
     * current configuration (H_0) and with the target node added to the same
     * element as the neighbour (H_1). Based on the vale of deltaH = H_1 - H_0,
     * the switch is either made or not.
     *
     * For each time step (i.e. each time this method is called) we sample
     * mrMesh.GetNumNodes() nodes. This is known as a Monte Carlo Step (MCS).
     */

    RandomNumberGenerator* p_gen = RandomNumberGenerator::Instance();
    unsigned num_nodes = this->mrMesh.GetNumNodes();

    // Randomly permute mUpdateRuleCollection if specified
    if (this->mIterateRandomlyOverUpdateRuleCollection)
    {
        // Randomly permute mUpdateRuleCollection
        p_gen->Shuffle(mUpdateRuleCollection);
    }

    for (unsigned i=0; i<num_nodes*mNumSweepsPerTimestep; i++)
    {
        unsigned node_index;

        if (this->mUpdateNodesInRandomOrder)
        {
            node_index = p_gen->randMod(num_nodes);
        }
        else
        {
            // Loop over nodes in index order.
            node_index = i%num_nodes;
        }

        Node<DIM>* p_node = this->mrMesh.GetNode(node_index);

        // Each node in the mesh must be in at most one element
        assert(p_node->GetNumContainingElements() <= 1);

        // Find a random available neighbouring node to overwrite current site
        std::set<unsigned> neighbouring_node_indices = mpPottsMesh->GetMooreNeighbouringNodeIndices(node_index);
        unsigned neighbour_location_index;

        if (!neighbouring_node_indices.empty())
        {
            unsigned num_neighbours = neighbouring_node_indices.size();
            unsigned chosen_neighbour = p_gen->randMod(num_neighbours);

            std::set<unsigned>::iterator neighbour_iter = neighbouring_node_indices.begin();
            for (unsigned j=0; j<chosen_neighbour; j++)
            {
                neighbour_iter++;
            }

            neighbour_location_index = *neighbour_iter;

            std::set<unsigned> containing_elements = p_node->rGetContainingElementIndices();
            std::set<unsigned> neighbour_containing_elements = GetNode(neighbour_location_index)->rGetContainingElementIndices();
            // Only calculate Hamiltonian and update elements if the nodes are from different elements, or one is from the medium
            if (    ( !containing_elements.empty() && neighbour_containing_elements.empty() )
                 || ( containing_elements.empty() && !neighbour_containing_elements.empty() )
                 || ( !containing_elements.empty() && !neighbour_containing_elements.empty() && *containing_elements.begin() != *neighbour_containing_elements.begin() ) )
            {
                double delta_H = 0.0; // This is H_1-H_0.

                // Now add contributions to the Hamiltonian from each AbstractPottsUpdateRule
                for (typename std::vector<boost::shared_ptr<AbstractPottsUpdateRule<DIM> > >::iterator iter = mUpdateRuleCollection.begin();
                     iter != mUpdateRuleCollection.end();
                     ++iter)
                {
                    delta_H += (*iter)->EvaluateHamiltonianContribution(neighbour_location_index, p_node->GetIndex(), *this);
                }

                // Generate a uniform random number to do the random motion
                double random_number = p_gen->ranf();

                double p = exp(-delta_H/mTemperature);
                if (delta_H <= 0 || random_number < p)
                {
                    // Do swap

                    // Remove the current node from any elements containing it (there should be at most one such element)
                    for (std::set<unsigned>::iterator iter = containing_elements.begin();
                         iter != containing_elements.end();
                         ++iter)
                    {
                        GetElement(*iter)->DeleteNode(GetElement(*iter)->GetNodeLocalIndex(node_index));

                        ///\todo If this causes the element to have no nodes then flag the element and cell to be deleted
                    }

                    // Next add the current node to any elements containing the neighbouring node (there should be at most one such element)
                    for (std::set<unsigned>::iterator iter = neighbour_containing_elements.begin();
                         iter != neighbour_containing_elements.end();
                         ++iter)
                    {
                        GetElement(*iter)->AddNode(this->mrMesh.GetNode(node_index));
                    }
                }
            }
        }
    }
}
String EmptyPlaceholderSelection::TagName()
{
	return GetElement()->TagName();
}
Esempio n. 18
0
nsresult
CacheFileMetadata::SetElement(const char *aKey, const char *aValue)
{
  LOG(("CacheFileMetadata::SetElement() [this=%p, key=%s, value=%p]",
       this, aKey, aValue));

  MarkDirty();

  nsresult rv;

  const uint32_t keySize = strlen(aKey) + 1;
  char *pos = const_cast<char *>(GetElement(aKey));

  if (!aValue) {
    // No value means remove the key/value pair completely, if existing
    if (pos) {
      uint32_t oldValueSize = strlen(pos) + 1;
      uint32_t offset = pos - mBuf;
      uint32_t remainder = mElementsSize - (offset + oldValueSize);

      memmove(pos - keySize, pos + oldValueSize, remainder);
      mElementsSize -= keySize + oldValueSize;
    }
    return NS_OK;
  }

  const uint32_t valueSize = strlen(aValue) + 1;
  uint32_t newSize = mElementsSize + valueSize;
  if (pos) {
    const uint32_t oldValueSize = strlen(pos) + 1;
    const uint32_t offset = pos - mBuf;
    const uint32_t remainder = mElementsSize - (offset + oldValueSize);

    // Update the value in place
    newSize -= oldValueSize;
    rv = EnsureBuffer(newSize);
    if (NS_FAILED(rv)) {
      return rv;
    }

    // Move the remainder to the right place
    pos = mBuf + offset;
    memmove(pos + valueSize, pos + oldValueSize, remainder);
  } else {
    // allocate new meta data element
    newSize += keySize;
    rv = EnsureBuffer(newSize);
    if (NS_FAILED(rv)) {
      return rv;
    }

    // Add after last element
    pos = mBuf + mElementsSize;
    memcpy(pos, aKey, keySize);
    pos += keySize;
  }

  // Update value
  memcpy(pos, aValue, valueSize);
  mElementsSize = newSize;

  return NS_OK;
}
Esempio n. 19
0
unsigned VertexBuffer::GetElementOffset(const PODVector<VertexElement>& elements, VertexElementType type, VertexElementSemantic semantic, unsigned char index)
{
    const VertexElement* element = GetElement(elements, type, semantic, index);
    return element ? element->offset_ : M_MAX_UNSIGNED;
}
Esempio n. 20
0
void CFlashUIDisplayNode::ProcessEvent( EFlowEvent event,SActivationInfo *pActInfo )
{
    if ( event == eFE_Initialize )
    {
        UpdateUIElement( GetPortString( pActInfo, eI_UIElement ), pActInfo );
    }
    else if ( event == eFE_Activate )
    {
        if ( IsPortActive( pActInfo, eI_UIElement ) )
        {
            UpdateUIElement( GetPortString( pActInfo, eI_UIElement ), pActInfo );
        }

        const int instanceId = GetPortInt( pActInfo, eI_InstanceID );

        if ( IsPortActive( pActInfo, eI_Show ) )
        {
            SPerInstanceCall1< bool > caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::SetVisible), true);
            ActivateOutput( pActInfo, eO_OnShow, true );
        }

        if ( IsPortActive( pActInfo, eI_Hide ) )
        {
            SPerInstanceCall1< bool > caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::SetVisible), false);
            ActivateOutput( pActInfo, eO_OnHide, true );
        }

        if ( IsPortActive( pActInfo, eI_Unload ) )
        {
            SPerInstanceCall0 caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::Unload));
            ActivateOutput( pActInfo, eO_OnUnload, true );
        }

        if ( IsPortActive( pActInfo, eI_RequestHide ) )
        {
            SPerInstanceCall0 caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::RequestHide));
            ActivateOutput( pActInfo, eO_OnRequestHide, true );
        }

        if ( IsPortActive( pActInfo, eI_Init ) )
        {
            SPerInstanceCall0 caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::Init));
            ActivateOutput( pActInfo, eO_OnInit, true );
        }

        if ( IsPortActive( pActInfo, eI_Reload ) )
        {
            SPerInstanceCall0 caller;
            caller.Execute( GetElement(), instanceId, functor(*this, &CFlashUIDisplayNode::Reload));
            ActivateOutput( pActInfo, eO_OnReload, true );
        }

        if ( IsPortActive( pActInfo, eI_UnloadBootstrapper ) )
        {
            if (GetElement()) GetElement()->UnloadBootStrapper();
            ActivateOutput( pActInfo, eO_OnUnloadBootstrapper, true );
        }

        if ( IsPortActive( pActInfo, eI_ReloadBootstrapper ) )
        {
            if (GetElement()) GetElement()->ReloadBootStrapper();
            ActivateOutput( pActInfo, eO_OnReloadBootstrapper, true );
        }
    }
}
Esempio n. 21
0
void Cylindrical2dMesh::CorrectNonPeriodicMesh()
{
    GenerateVectorsOfElementsStraddlingPeriodicBoundaries();

    /*
     * Copy the member variables into new vectors, which we modify
     * by knocking out elements which pair up on each side.
     */
    std::set<unsigned> temp_left_hand_side_elements = mLeftPeriodicBoundaryElementIndices;
    std::set<unsigned> temp_right_hand_side_elements = mRightPeriodicBoundaryElementIndices;

//    if ( (mLeftPeriodicBoundaryElementIndices.size()!=mRightPeriodicBoundaryElementIndices.size())
//            || (temp_left_hand_side_elements.size() <= 2)
//            || (temp_right_hand_side_elements.size() <= 2) )
//    {
//        mMismatchedBoundaryElements = true;
//    }
    assert(mLeftPeriodicBoundaryElementIndices.size()==mRightPeriodicBoundaryElementIndices.size());

    // Go through all of the elements on the left periodic boundary
    for (std::set<unsigned>::iterator left_iter = mLeftPeriodicBoundaryElementIndices.begin();
         left_iter != mLeftPeriodicBoundaryElementIndices.end();
         ++left_iter)
    {
        unsigned elem_index = *left_iter;

        Element<2,2>* p_element = GetElement(elem_index);

        /*
         * Make lists of the nodes which the elements on the left contain and
         * the nodes which should be in a corresponding element on the right.
         */
        c_vector<unsigned,3> original_element_node_indices;
        c_vector<unsigned,3> corresponding_element_node_indices;
        for (unsigned i=0; i<3; i++)
        {
            original_element_node_indices[i] = p_element->GetNodeGlobalIndex(i);
            corresponding_element_node_indices[i] = GetCorrespondingNodeIndex(original_element_node_indices[i]);
        }

        // Search the right hand side elements for the corresponding element
        for (std::set<unsigned>::iterator right_iter = mRightPeriodicBoundaryElementIndices.begin();
             right_iter != mRightPeriodicBoundaryElementIndices.end();
             ++right_iter)
        {
            unsigned corresponding_elem_index = *right_iter;

            Element<2,2>* p_corresponding_element = GetElement(corresponding_elem_index);

            bool is_corresponding_node = true;

            for (unsigned i=0; i<3; i++)
            {
                if ( (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(0)) &&
                     (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(1)) &&
                     (corresponding_element_node_indices[i] != p_corresponding_element->GetNodeGlobalIndex(2)) )
                {
                    is_corresponding_node = false;
                    break;
                }
            }

            if (is_corresponding_node)
            {
                // Remove original and corresponding element from sets
                temp_left_hand_side_elements.erase(elem_index);
                temp_right_hand_side_elements.erase(corresponding_elem_index);
            }
        }
    }

    /*
     * If either of these ever throw you have more than one situation where the mesher has an option
     * of how to mesh. If it does ever throw you need to be cleverer and match up the
     * elements into as many pairs as possible on the left hand and right hand sides.
     */
//    assert(temp_left_hand_side_elements.size() <= 2);
//    assert(temp_right_hand_side_elements.size() <= 2);

    /*
     * Now we just have to use the first pair of elements and copy their info over to the other side.
     * First we need to get hold of both elements on either side.
     */
    if (temp_left_hand_side_elements.empty() || temp_right_hand_side_elements.empty())
    {
        assert(temp_right_hand_side_elements.empty());
        assert(temp_left_hand_side_elements.empty());
    }
    else
    {
        if (temp_right_hand_side_elements.size() == 2 && temp_left_hand_side_elements.size() == 2)
        {
            if (temp_right_hand_side_elements.size() == 2)
            {
                // Use the right hand side meshing and map to left
                UseTheseElementsToDecideMeshing(temp_right_hand_side_elements);
            }
            else
            {
                /*
                 * If you get here there are more than two mixed up elements on the periodic edge.
                 * We need to knock the pair out and then rerun this function. This shouldn't be
                 * too hard to do but is as yet unnecessary.
                 */
                NEVER_REACHED;
            }
        }
    }
}
Esempio n. 22
0
AXMLElement* AXMLElement::GetElement(sWORD pStrId, sWORD pElementRef) {
	AXMLElement	*elem = NULL;
	VString		elemname;
	//gResFile->GetString(elemname,pStrId,pElementRef);
	return GetElement(elemname);
}
Esempio n. 23
0
void CTryData4Dlg::OnTimer(UINT nIDEvent) 
{
	static bool bTwice = false;
	if(m_currPage == 0)	//is quiting
		return;
	if(bTwice)
		return;
	bTwice = true;
	SWISTATUS ss;
	CDHtmlDialog::OnTimer(nIDEvent);
	if (nIDEvent == 1)
	{
		CString status;
		m_CheckTicks++;
		if(m_CheckTicks == 1){
			status.Format("正在进行License检查");
			SetElementText(_T("checking"),status.AllocSysString());
			}
		if(m_CheckTicks == 2){	
			if(!CheckLicense())
			{
				MessageBox("本软件无法在本机上使用,请联系供应商");
				m_currPage = 0;
				::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0);
			}
			status.Format("正在连接控制板");
			SetElementText(_T("checking"),status.AllocSysString());
			}
		if(m_CheckTicks == 3){
			if(!m_Switch.Open(SPORT_SWITCH))
			{
				MessageBox("连接控制板失败","电阻校验",MB_OK);
				m_currPage = 0;
				::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0);
			}
		
			status.Format("正在连接纳伏计");
			SetElementText(_T("checking"),status.AllocSysString());
			}
		if(m_CheckTicks == 4){
			if(!m_Navmeter.Open(SPORT_NAVMETER))
			{
				MessageBox("连接纳伏计失败","电阻校验",MB_OK);
				m_currPage = 0;
				::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0);
			}

			status.Format("正在连接数据库");
			SetElementText(_T("checking"),status.AllocSysString());
		}
		if(m_CheckTicks == 5){
			if(!SqlInit(g_Path+_T("\\Data\\test.mdb")))
			{
				MessageBox("连接数据库失败","电阻校验",MB_OK);
				m_currPage = 0;
				::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0);
			}
			status.Format("正在装载程序");
			SetElementText(_T("checking"),status.AllocSysString());
		}
		if(m_CheckTicks == 6){
			if(!m_Program.InstallScheme(PathQuery2(CLSGROUP,IDTYPE)))
			{
				MessageBox("程序装载失败","电阻校验",MB_OK);
				m_currPage = 0;
				::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0);
			}
		}
		if(m_CheckTicks == 7){
			m_currPage = INDEX;		Handler("init",m_sRegSel,m_sRegLst,true);
//			m_currPage = CONFIG;	Handler("init",m_sConfSel,m_sConfLst,true);
//			m_currPage = DATA;		Handler("init",m_sDataSel,m_sDataLst,true);
//			m_currPage = JIAOHE;	Handler("init",m_sJhSel,m_sJhLst,true);
			KillTimer(1);
			m_currPage = INDEX;
			m_cmdStep = CMD_LOADHTML;
			//create the chart dialog
			m_pChartDlg = new CChartDlg(this);
			m_pChartDlg->Create(IDD_DIALOG2,this);
			m_pChartDlg->ShowWindow(SW_HIDE);
			//create the wait dialog
			m_pWaitDlg = new CWaitDialog(this);
			m_pWaitDlg->Create(IDD_DIALOG3,this);
			m_pWaitDlg->ShowWindow(SW_HIDE);

			SetTimer(2,30,NULL);
		}
	}	
	
	if(nIDEvent == 2)
	{
		if(m_cmdStep == CMD_INITHTML){
			IHTMLElement* newElement;
			if((m_currPage == INDEX) && (S_OK == GetElement("idvals",&newElement)))
			{
				m_sRegvals = this->GetAttribute(newElement,m_elemTypes[1]);
				Handler("init",m_sRegSel,m_sRegLst);
			}
			if((m_currPage == CONFIG) && (S_OK == GetElement("idvals",&newElement)))
			{
				m_sConfigvals = this->GetAttribute(newElement,m_elemTypes[1]);
				Handler("init",m_sConfSel,m_sConfLst);
			}
			if((m_currPage == JIAOHE) && (S_OK == GetElement("idvals",&newElement)))
			{

				m_sJhvals = this->GetAttribute(newElement,m_elemTypes[1]);
				Handler("init",m_sJhSel,m_sJhLst);
			}
			if((m_currPage == DATA) && (S_OK == GetElement("idvals",&newElement)))
			{
				if(g_TesterConf.m_Ps.iTimes == 0) //come to the data page directly from reg page 
				{
					m_currPage = CONFIG;
					m_sConfigvals = CString(",cklt9,rstdlt9,alphalt9,betalt9,cklt8,rstdlt8,alphalt8,betalt8,cklt1,rstdlt1,alphalt1,betalt1,cklt2,rstdlt2,alphalt2,betalt2,cklt3,rstdlt3,alphalt3,betalt3,cklt4,rstdlt4,alphalt4,betalt4,cklt5,rstdlt5,alphalt5,betalt5,cklt6,rstdlt6,alphalt6,betalt6,cklt7,rstdlt7,alphalt7,betalt7,confdxcl,zdpselect,lcselect,confcysj,confcycs,confwd,");
					Handler("init",m_sConfSel,m_sConfLst,true);


					m_currPage = JIAOHE;
					m_sJhvals = CString(",jhsel19,jhsel18,jhsel17,jhsel16,jhsel15,jhsel14,jhsel13,jhsel12,jhsel11,jhsel10,jhsel9,jhsel8,jhsel7,jhsel6,jhsel5,jhsel4,jhsel3,jhsel2,jhsel1,jhsel0,");
					Handler("init",m_sJhSel,m_sJhLst,true);
					m_sJhvals.Empty();

					m_currPage = DATA;
				}

				m_sDatavals = this->GetAttribute(newElement,m_elemTypes[1]);
				Handler("init",m_sDataSel,m_sDataLst);
				if(m_sDataLst.IsEmpty() || (m_sDataLst == " ,"))
				{
						InternalRoutines('9');//update value to page
				}
				Handler("update",m_sDataSel,m_sDataLst);
				
			}
			if(m_currPage == REPORT)
			{
				Handler("init",m_sReportSel,m_sReportLst);
			}
			m_cmdStep = CMD_IDLEHTML;
		}
		if((m_cmdStep == CMD_CONTHTML)||(m_cmdStep == CMD_CONTHTML2)){
			int group = -1;
			switch(m_currPage)
			{
			case JIAOHE:	group=IDJH;break;
			case DATA:		group=IDTEST;break;
			default: break;
			}
			if(group >= 0)
			{
				CStdioFile csf;
				if(csf.Open(g_Path+CString(PathQuery2(CLSJS,group)),CFile::modeRead))
				{
					CString content(""),line;
					while(csf.ReadString(line))
					{
						content += line;
					}
					csf.Close();
					SetElementHtml("cont",content.AllocSysString());
				}
			}
			if(m_cmdStep == CMD_CONTHTML2)
				m_cmdStep = CMD_INITHTML;
			else
				m_cmdStep = CMD_CONTHTML2;
		}
		if(m_cmdStep == CMD_LOADHTML && m_currPage > 0){
			LoadFromResource(m_currPage);
			m_cmdStep = CMD_CONTHTML;
		}
				CString str;
				CTime t = CTime::GetCurrentTime();
				str = t.Format("%H:%M:%S");
				SetElementText("curtime",str.AllocSysString());
		
		if(m_State == SUSPEND)			m_State = IDLE;
		if(m_State == BEERROR)			m_State = SUSPEND;

		if((m_State == IDLE)||(m_State == BEERROR))
		{
			if(m_CheckTicks++ > CHECKWAIT)
			{
				m_CheckTicks = 0;
#if 1
				SWISTATUS ss = m_Switch.GetSwitchStatus();
				while(ss.bOl1)
				{
					MessageBox("发生过载","电阻校验",MB_OK);
					ss = m_Switch.GetSwitchStatus();
				}

				CString str;
				str.Format("外标准[%s],被测[%s]",ss.bKN[0]?"接通":"未接",ss.bRn?"接通":"未接");
				SetElementText("swistatus",str.AllocSysString());
#endif;
			}
		}
		if(m_State == RUNNING)
		{
			char type;
			CString line;
//			m_State = SUSPEND;
				while((m_Program.m_iStackDepth > 0) )
				{
					if(m_Program.NextLine(type,line))//loop until some pausable command
					{
						if((type == 'z') || (type == 'd') || (type == 'w'))
						{
							HandleCommand(type,line);
							continue;
						}
						break;
					}
					
					 
				}
			    if(m_Program.m_iStackDepth <= 0)
				{
					Abort();
				}else{
					if(!HandleCommand(type,line))
					{
						m_State = BEERRO;
						Abort();
					}
				}
		}
	}
	bTwice = false;
	return;

}
DataDictionary MTConnectStreamsParser::ParseDataItems()
{
	MSXML2::IXMLDOMNodePtr root = m_pXMLDoc->GetdocumentElement();
	MSXML2::IXMLDOMNodeListPtr nodes = root->selectNodes(_bstr_t("//DeviceStream"));
	DataDictionary data;
	try
	{
		for(int i=0; i< nodes->length; i++)
		{
			MSXML2::IXMLDOMNodePtr pNode = NULL;					
			nodes->get_item(i, &pNode);

			_bstr_t items[3] = {_bstr_t(".//Samples"), _bstr_t(".//Events"), _bstr_t(".//Condition") };
			for(int ii=0; ii<3 ; ii++)
			{
				MSXML2::IXMLDOMNodeListPtr samples = pNode->selectNodes(items[ii]);
				for(int j=0; j< samples->length; j++)
				{
					MSXML2::IXMLDOMNodePtr pSampleHive = NULL;					
					samples->get_item(j, &pSampleHive);

					// Get each child
					MSXML2::IXMLDOMNodeListPtr childs = pSampleHive->childNodes;
					for(int k=0; k< childs->length; k++)
					{
						MSXML2::IXMLDOMNodePtr pSample = NULL;
						ptime datetime;
						std::string name ;
						std::string timestamp;
						std::string sequence;


						childs->get_item(k, &pSample);
						name = (LPCSTR)  GetAttribute(pSample, "name");
						if(name.empty())
							name = (LPCSTR)  GetAttribute(pSample, "dataItemId");
						if(name.empty())
							continue;
						timestamp = (LPCSTR)  GetAttribute(pSample, "timestamp");
						sequence = (LPCSTR)  GetAttribute(pSample, "sequence");

						// Lookup any name remapping to shorten
						if(TagRenames.find(name)!= TagRenames.end())
						{
							name = TagRenames[name];
						}
						if(items[ii] == _bstr_t(".//Samples"))
							data[name]=(LPCSTR) pSample->Gettext();
						else if(items[ii] == _bstr_t(".//Events"))
							data[name]=(LPCSTR) pSample->Gettext();
						else if(items[ii] == _bstr_t(".//Condition"))
						{
							std::string tagname  = (LPCSTR)  GetElement(pSample);
							if(stricmp(tagname.c_str(),"FAULT")==0)
								data[name]="fault";
							else
								data[name]="normal";
						}
					}
				}
			}
		}
	}
	catch(...)
	{
		std::cout<< "MTConnectStreamsParser::ParseDataItems() Exception\n";
	}
	return data;

}
Esempio n. 25
0
int	ChSparseMatrix::Decompose_LDL(int* pivarray, double* det, int from_eq)
{
	ChMelement* rowel;
	ChMelement* subrowel;
	int i,k, pivrow, eqpivoted;
	double r, leader, pivot, mval, subval, newval;
	int err = 0;

	if (pivarray)	// initialize pivot index array
	{
		for (int ind = 0; ind < rows; ind++)
		{ pivarray[ind] = ind;}
	}
	else return TRUE; // error: no pivot array.

	*det = 1;

	for (k=1; k < rows; k++)
	{
		pivot = GetElement((k-1),(k-1));

		if (fabs(pivot) < ACCEPT_PIVOT)
		{
			//static cntpiv=0;
			//R3Error("pivot %d   %g", cntpiv, fabs(pivot));

			// pivoting is needed, so ...
			pivrow = BestPivotDiag(k-1);
			DiagPivotSymmetric(k-1,pivrow);	// swap both column and row (only upper right!)
			*det = - *det;					// invert determ.sign

			eqpivoted = pivarray[pivrow];	// swap diagonal pivot indexes
			pivarray[pivrow] =pivarray[k-1];
			pivarray[k-1] = eqpivoted;

			pivot = GetElement((k-1),(k-1));
		}

		if (fabs(pivot) <= MIN_PIVOT)	// was unable to find better pivot: force solution to zero.and go ahead
		{
			pivot = INFINITE_PIVOT;
			SetElement(k-1, k-1 , pivot);
			if (!err)
				err = (1+rows-k);	// report deficiency
		}
		else
			*det = *det * pivot;

		for (i=k; i < rows; i++)
		{
			leader = GetElement((k-1), i);

			if (leader)
			{
			  r= (leader / pivot);	// compute multiplier (mirror look A)

			  subrowel = GetElarrayMel(i); // initialize guessed sparse elements
			  rowel=GetElarrayMel(k-1);	   // for speed optimization. They are in two rows.

			  // advance top row element till it has (col >= k)

			  for (NULL; rowel!= NULL; rowel=rowel->next)	// for (j=i; j < columns; j++)	// only upper right part
			  {
				if (rowel->col >= i)	// only upper right part is filled!
				{
					mval = rowel->val;
					subrowel= GetElement(i, rowel->col, &subval, subrowel);
					newval = subval - r * mval;
					subrowel= SetElement(i, rowel->col, newval, subrowel);
				}
			  }

			  SetElement((k-1),i, r); // now can store the multiplier in L part (mirror look! is up)
			}

		}
	}

	pivot = GetElement((rows-1),(rows-1));
	if (fabs(pivot) <= MIN_PIVOT)
	{
		pivot = INFINITE_PIVOT;
		SetElement(rows-1, rows-1 , pivot);
		if (!err)
			err = (1);	// report deficiency
	}
	else
		*det = *det * pivot;

	return err;
}
Esempio n. 26
0
void CItemObject::OnEndElement (CDataParser *pParser, const XML_Char *pszName)
{

	//
	// Get the element
	//

	Element nElement = GetElement (pszName);
	if (nElement == Unknown)
	{
		pParser ->SetError (IDS_ERR_XML_UNEXPECTED_ELEMENT);
		return;
	}

	//
	// Switch based on the element
	//

	switch (nElement)
	{
		
		//
		// If we are ending the Table
		//

		case Item:
			pParser ->SetState (CDataParser::InTable);
			pParser ->SaveItem ();
			break;

		//
		// If this is the chance
		//

		case Chance:
			m_nChance = atol (pParser ->GetText (false));
			break;

		//
		// If this is the name
		//

		case Name:
			m_strName = pParser ->GetText (false);
			break;

		//
		// If this is the count
		//

		case Count:
			m_nCount = atol (pParser ->GetText (false));
			break;

		//
		// If this is the range
		//

		case Range:
			m_nRange = atol (pParser ->GetText (false));
			break;
	}
	return;
}
Esempio n. 27
0
int	ChSparseMatrix::Decompose_LU(int* pivarray, double* det)
{
	ChMelement* rowel;
	ChMelement* subrowel;
	int i,k, pivrow, eqpivoted;
	double r, pivot, mval, subval, newval, leader;
	int err = 0;

	if (pivarray)	// initialize pivot index array
	{
		for (int ind = 0; ind < rows; ind++)
		{ pivarray[ind] = ind;}
	}
	else return TRUE; // error: no pivot array.

	*det = 1;

	for (k=1; k < rows; k++)
	{
		pivot = GetElement((k-1),(k-1));

		if (fabs(pivot) < ACCEPT_PIVOT)
		{
			// pivoting is needed, so swap equations
			pivrow = BestPivotRow(k-1);
			SwapRows ((k-1), pivrow );
			*det = - *det;

			eqpivoted = pivarray[pivrow]; // swap eq.ids in pivot array
			pivarray[pivrow] =pivarray[k-1];
			pivarray[k-1] = eqpivoted;

			pivot = GetElement((k-1),(k-1)); // fetch new pivot
		}

		if (fabs(pivot) <= MIN_PIVOT)	// was unable to find better pivot: force solution to zero.and go ahead
		{
			//*det = *det;
			pivot = INFINITE_PIVOT;
			SetElement(k-1, k-1 , pivot);
			if (!err)
				err = (1+rows-k);	// report deficiency
		}
		else
			*det = *det * pivot;

		for (i=k; i < rows; i++)
		{
			leader = GetElement(i, (k-1));

			if (leader)
			{
			 r= leader / pivot;	// compute multiplier
			 SetElement(i,(k-1),r);				// store the multiplier in L part!!!

			 subrowel = GetElarrayMel(i); // initialize guessed sparse elements
			 rowel=GetElarrayMel(k-1);	  // for speed optimization. They are in two rows.

			 //while ((rowel->col<k) && (rowel->next))
			 //	 rowel = rowel->next;		// advance top row element till it has (col >= k)

			 for (NULL; rowel!= NULL; rowel=rowel->next)	//for (j=k; j < columns; j++)  where j = rowel->col
			 {
				 if (rowel->col >= k)	// skip
				 {
					mval = rowel->val;
					subrowel= GetElement(i, rowel->col, &subval, subrowel);
					newval = subval - r * mval;
					subrowel= SetElement(i, rowel->col, newval, subrowel);	// set the U part
				 }
			 }
			}
		}
	}

	pivot = GetElement((rows-1),(rows-1));
	if (fabs(pivot) <= MIN_PIVOT)
	{
		//*det = *det;
		pivot = INFINITE_PIVOT;
		SetElement(rows-1, rows-1 , pivot);
		if (!err)
			err = (1);	// report deficiency
	}
	else
		*det = *det * pivot;

	return err;
}
Esempio n. 28
0
bool SequenceElements::LoadSequencerFile(xLightsXmlFile& xml_file)
{
    mFilename = xml_file;
    wxXmlDocument& seqDocument = xml_file.GetXmlDocument();

    wxXmlNode* root=seqDocument.GetRoot();
    std::vector<std::string> effectStrings;
    std::vector<std::string> colorPalettes;
    Clear();
    for(wxXmlNode* e=root->GetChildren(); e!=NULL; e=e->GetNext() )
    {
       if (e->GetName() == "DisplayElements")
       {
            for(wxXmlNode* element=e->GetChildren(); element!=NULL; element=element->GetNext() )
            {
                bool active=false;
                bool selected=false;
                bool collapsed=false;
                std::string name = element->GetAttribute(STR_NAME).ToStdString();
                std::string type = element->GetAttribute(STR_TYPE).ToStdString();
                bool visible = element->GetAttribute("visible")=='1'?true:false;

                if (type==STR_TIMING)
                {
                    active = element->GetAttribute("active")=='1'?true:false;
                }
                else
                {
                    collapsed = element->GetAttribute("collapsed")=='1'?true:false;
                }
                Element* elem = AddElement(name,type,visible,collapsed,active,selected);
                if (type==STR_TIMING)
                {
                    std::string views = element->GetAttribute("views", "").ToStdString();
                    elem->SetViews(views);
                }
            }
       }
       else if (e->GetName() == "EffectDB")
       {
           effectStrings.clear();
           for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() )
           {
               if(elementNode->GetName()==STR_EFFECT)
               {
                   effectStrings.push_back(elementNode->GetNodeContent().ToStdString());
               }
           }
       }
       else if (e->GetName() == "ColorPalettes")
       {
           colorPalettes.clear();
           for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() )
           {
               if(elementNode->GetName() == STR_COLORPALETTE)
               {
                   colorPalettes.push_back(elementNode->GetNodeContent().ToStdString());
               }
           }
       }
       else if (e->GetName() == "ElementEffects")
        {
            for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() )
            {
                if(elementNode->GetName()==STR_ELEMENT)
                {
                    Element* element = GetElement(elementNode->GetAttribute(STR_NAME).ToStdString());
                    if (element !=NULL)
                    {
                        // check for fixed timing interval
                        int interval = 0;
                        if( elementNode->GetAttribute(STR_TYPE) == STR_TIMING )
                        {
                            interval = wxAtoi(elementNode->GetAttribute("fixed"));
                        }
                        if( interval > 0 )
                        {
                            element->SetFixedTiming(interval);
                            EffectLayer* effectLayer = element->AddEffectLayer();
                            int time = 0;
                            int end_time = xml_file.GetSequenceDurationMS();
                            int startTime, endTime, next_time;
                            while( time <= end_time )
                            {
                                next_time = (time + interval <= end_time) ? time + interval : end_time;
                                startTime = TimeLine::RoundToMultipleOfPeriod(time,mFrequency);
                                endTime = TimeLine::RoundToMultipleOfPeriod(next_time,mFrequency);
                                effectLayer->AddEffect(0,"","","",startTime,endTime,EFFECT_NOT_SELECTED,false);
                                time += interval;
                            }
                        }
                        else
                        {
                            for(wxXmlNode* effectLayerNode=elementNode->GetChildren(); effectLayerNode!=NULL; effectLayerNode=effectLayerNode->GetNext())
                            {
                                if (effectLayerNode->GetName() == STR_EFFECTLAYER || effectLayerNode->GetName() == STR_STRAND)
                                {
                                    EffectLayer* effectLayer = NULL;
                                    if (effectLayerNode->GetName() == STR_EFFECTLAYER) {
                                        effectLayer = element->AddEffectLayer();
                                    } else {
                                        effectLayer = element->GetStrandLayer(wxAtoi(effectLayerNode->GetAttribute(STR_INDEX)), true);
                                        if (effectLayerNode->GetAttribute(STR_NAME, STR_EMPTY) != STR_EMPTY) {
                                            ((StrandLayer*)effectLayer)->SetName(effectLayerNode->GetAttribute(STR_NAME).ToStdString());
                                        }
                                    }
                                    LoadEffects(effectLayer, elementNode->GetAttribute(STR_TYPE).ToStdString(), effectLayerNode, effectStrings, colorPalettes);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    // Select view and set current view models as visible
    int last_view = xml_file.GetLastView();
    for(wxXmlNode* view=mViewsNode->GetChildren(); view!=NULL; view=view->GetNext() )
    {
        std::string viewName = view->GetAttribute(STR_NAME).ToStdString();
        std::string models = view->GetAttribute("models").ToStdString();
        std::vector <Element*> new_view;
        mAllViews.push_back(new_view);
        int view_index = mAllViews.size()-1;
        if( view_index == last_view )
        {
            AddMissingModelsToSequence(models);
            PopulateView(models, view_index);
            SetCurrentView(view_index);
        }
    }

    if (mModelsNode != nullptr) {
        PopulateRowInformation();
    }
    // Set to the first model/view
    mFirstVisibleModelRow = 0;
    return true;
}
Esempio n. 29
0
Vector& Matrix::GetColumn(int column) {
	double* vecArr = new double[4];
	for (int i = 1; i <= 4; i++)
		vecArr[i - 1] = GetElement(i, column);
	return * (new Vector(vecArr, 4));
}
void* TypedQueueGeneric::Top()
{
    return m_pos ? GetElement( m_pos - 1) : NULL;
}