Ejemplo n.º 1
0
bool CommandDeleteT::Do()
{
    wxASSERT(!m_Done);
    if (m_Done) return false;

    // Deselect any affected elements that are selected.
    m_CommandSelect->Do();

    ArrayT<MapElementT*> DeletedElems;

    for (unsigned long EntNr=0; EntNr<m_DeleteEnts.Size(); EntNr++)
    {
        m_MapDoc.Remove(m_DeleteEnts[EntNr]);
        DeletedElems.PushBack(m_DeleteEnts[EntNr]);
    }

    for (unsigned long PrimNr=0; PrimNr<m_DeletePrims.Size(); PrimNr++)
    {
        m_MapDoc.Remove(m_DeletePrims[PrimNr]);
        DeletedElems.PushBack(m_DeletePrims[PrimNr]);
    }

    // Update all observers.
    m_MapDoc.UpdateAllObservers_Deleted(DeletedElems);

    m_Done=true;
    return true;
}
Ejemplo n.º 2
0
/* echo element connectivity data */
void SCNIMFT::DefineElements(const ArrayT<StringT>& block_ID, const ArrayT<int>& mat_index) 
{
  const char caller[] = "SCNIMFT::DefineElements";

  //TEMP
  if (block_ID.Length() > 1)
    ExceptionT::GeneralFail(caller, "mutliple block ID's not supported %d",
			    block_ID.Length());
	
  /* access to the model database */
  ModelManagerT& model = ElementSupport().ModelManager();

  fElementConnectivities.Dimension(1);

  // NB THIS IS SPECIALIZED TO ONLY ONE ELEMENT BLOCK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  model.ReadConnectivity(block_ID[0]);

  /* set pointer to connectivity list */
  fElementConnectivities[0] = model.ElementGroupPointer(block_ID[0]);

  // Get nodal coordinates 
  int nsd = NumSD();
  fNodalCoordinates.Dimension(fNodes.Length(), nsd);
  fNodalCoordinates.RowCollect(fNodes, model.Coordinates());

  /* set up element cards for state variable storage */
  fElementCards.Dimension(fNodes.Length()); /* one card per node */
  for (int i = 0; i < fElementCards.Length(); i++)
    fElementCards[i].SetMaterialNumber(mat_index[0]);
	
  fCellGeometry->DefineElements(block_ID, mat_index);
}
Ejemplo n.º 3
0
 TEATREE_FLATTEN
 static void exec(moments_type& p, const moments_type& d, const ArrayT& r)
 {
     p.Oxxx += d.Oxxx + r*(-3*d.Qxx + r*(3*d.Dx - r*d.M));
     p.Oxxy += d.Oxxy - r.yx()*d.Qxx
             + r*(-2*d.Qxy + 2*r.yx()*d.Dx + r*(d.Dx.yx()-r.yx()*d.M));
 }
Ejemplo n.º 4
0
int InspectorDialogT::GetBestPage(const ArrayT<MapElementT*>& Selection) const
{
    if (Selection.Size()==0)
    {
        // Nothing is selected, so just show the scene graph.
        return 0;
    }
    else if (Selection.Size()==1)
    {
        MapElementT* MapElement=Selection[0];

        return (MapElement->GetType()==&MapEntityT::TypeInfo) ? 1 : 2;
    }
    else
    {
        // Multiple map elements are selected.
        // If we have only map primitives, open the Primitive Properties tab
        // (even though it doesn't make much sense - primitive properties can be edited for a single item only).
        // One or more entities in the selection cause us to open the Entitiy Properties tab.
        bool HaveEntities=false;

        for (unsigned long SelNr=0; SelNr<Selection.Size(); SelNr++)
        {
            MapElementT* MapElement=Selection[SelNr];

            if (MapElement->GetType()==&MapEntityT::TypeInfo)
            {
                HaveEntities=true;
                break;
            }
        }

        return HaveEntities ? 1 : 2;
    }
}
Ejemplo n.º 5
0
/*static*/ bool StateT::IsDeltaMessageEmpty(const ArrayT<uint8_t>& DeltaMessage)
{
    if (DeltaMessage[0] == 1)
    {
        // Check the RLE-compressed delta message.
        unsigned int i = 1;

        while (i < DeltaMessage.Size())
        {
            const unsigned int N = DeltaMessage[i];

            i++;

            if (N < MAX_VERBATIM)
            {
                for (unsigned int Stop = i+N+1; i < Stop; i++)
                    if (DeltaMessage[i]) return false;
            }
            else
            {
                if (DeltaMessage[i]) return false;
                i++;
            }
        }
    }
    else
    {
        // Check the uncompressed delta message.
        for (unsigned int i = 1; i < DeltaMessage.Size(); i++)
            if (DeltaMessage[i])
                return false;
    }

    return true;
}
Ejemplo n.º 6
0
template<class T> ArrayT< Polygon3T<T> > Polygon3T<T>::GetSplits(const Plane3T<T>& SplitPlane, const T HalfPlaneThickness) const
{
    const unsigned long FRONT=0;
    const unsigned long BACK =1;

    ArrayT< Polygon3T<T> > Result;

    Result.PushBackEmpty(2);

    Result[FRONT].Plane=this->Plane;
    Result[BACK ].Plane=this->Plane;

    if (!Vertices.Size()) return Result;

    Vector3T<T> LastVertex=Vertices[Vertices.Size()-1];
    double      LastDist  =SplitPlane.GetDistance(LastVertex);

    for (unsigned long VertexNr=0; VertexNr<Vertices.Size(); VertexNr++)
    {
        const Vector3T<T>& ThisVertex=Vertices[VertexNr];
        const double       ThisDist  =SplitPlane.GetDistance(ThisVertex);

        if (ThisDist>HalfPlaneThickness)
        {
            if (LastDist<-HalfPlaneThickness)
            {
                Vector3T<T> Intersection=SplitPlane.GetIntersection(LastVertex, ThisVertex, 0);

                Result[BACK ].Vertices.PushBack(Intersection);
                Result[FRONT].Vertices.PushBack(Intersection);
            }
            else if (LastDist<=HalfPlaneThickness) Result[FRONT].Vertices.PushBack(LastVertex);

            Result[FRONT].Vertices.PushBack(ThisVertex);
        }
        else if (ThisDist<-HalfPlaneThickness)
        {
            if (LastDist>HalfPlaneThickness)
            {
                Vector3T<T> Intersection=SplitPlane.GetIntersection(LastVertex, ThisVertex, 0);

                Result[FRONT].Vertices.PushBack(Intersection);
                Result[BACK ].Vertices.PushBack(Intersection);
            }
            else if (LastDist>=-HalfPlaneThickness) Result[BACK].Vertices.PushBack(LastVertex);

            Result[BACK].Vertices.PushBack(ThisVertex);
        }
        else
        {
                 if (LastDist> HalfPlaneThickness) Result[FRONT].Vertices.PushBack(ThisVertex);
            else if (LastDist<-HalfPlaneThickness) Result[BACK ].Vertices.PushBack(ThisVertex);
        }

        LastVertex=ThisVertex;
        LastDist  =ThisDist;
    }

    return Result;
}
Ejemplo n.º 7
0
/* return the index the next receive */
void CommunicatorT::WaitReceive(const ArrayT<MPI_Request>& requests, int& index, int& source) const
{
	const char caller[] = "CommunicatorT::WaitReceive";
	Log(kModerate, caller, "waiting for 1 of %d", requests.Length());

	index = source = -1;

#ifdef __TAHOE_MPI__
	/* grab completed receive */
	MPI_Status status;
	int ret = MPI_Waitany(requests.Length(), (MPI_Request*) requests.Pointer(), &index, &status);

#ifdef CHECK_MPI_RETURN
	if (ret != MPI_SUCCESS) Log(kFail, caller, "MPI_Waitany failed");
#endif

#ifdef CHECK_MPI_STATUS
	if (status.MPI_ERROR != MPI_SUCCESS) Log(kFail, caller, "bad status: %d", status.MPI_ERROR);
#endif
	
	source = status.MPI_SOURCE;
#endif

	Log(kModerate, caller, "received request at index %d from %d", index, source);
}
Ejemplo n.º 8
0
// This function determines the adjacency cell graph of the 'SuperLeaves'.
// It is filled-in and stored in the 'Neighbours' members/components of the 'SuperLeaves'.
// After this function was called, all components of all 'SuperLeaves' are completely filled-in.
void DetermineAdjacencyGraph()
{
    for (unsigned long SL1Nr=0; SL1Nr<SuperLeaves.Size(); SL1Nr++)
        for (unsigned long SL2Nr=0; SL2Nr<SuperLeaves.Size(); SL2Nr++)
        {
            if (SL1Nr==SL2Nr || !SuperLeaves[SL1Nr].BB.GetEpsilonBox(MapT::RoundEpsilon).Intersects(SuperLeaves[SL2Nr].BB)) continue;

            // Jedes Portal des ersten Leafs gegen jedes Portal des zweiten Leafs
            // prüfen und testen, ob sie sich schneiden (dann sind sie durchlässig).
            // BEACHTE: SuperLeaves haben *alle* Portale von *allen* ihrer Leaves!
            // D.h. es können sich nicht nur Portale auf ihrer konvexen Hülle befinden, sondern auch "innen drin".
            // Wegen der Konvexität der SuperLeaves dürfte das aber keine Rolle spielen und folgendes müßte trotzdem korrekt funktionieren.
            for (unsigned long Portal1Nr=0; Portal1Nr<SuperLeaves[SL1Nr].Portals.Size(); Portal1Nr++)
                for (unsigned long Portal2Nr=0; Portal2Nr<SuperLeaves[SL2Nr].Portals.Size(); Portal2Nr++)
                {
                    if (!SuperLeaves[SL1Nr].Portals[Portal1Nr].Overlaps(SuperLeaves[SL2Nr].Portals[Portal2Nr], false, MapT::RoundEpsilon)) continue;

                    // Folgender Check ist zwar redundant, aber zumindest sinnvoll.
                    // Da diese Funktion sowieso schnell genug ist, lasse ihn nicht weg!
                    if (SuperLeaves[SL1Nr].Portals[Portal1Nr].WhatSide(SuperLeaves[SL2Nr].Portals[Portal2Nr].Plane, MapT::RoundEpsilon)!=Polygon3T<double>::InMirrored) continue;

                    ArrayT< Polygon3T<double> > NewPortals;
                    SuperLeaves[SL1Nr].Portals[Portal1Nr].GetChoppedUpAlong(SuperLeaves[SL2Nr].Portals[Portal2Nr], MapT::RoundEpsilon, NewPortals);

                    SuperLeaves[SL1Nr].Neighbours.PushBackEmpty();
                    SuperLeaves[SL1Nr].Neighbours[SuperLeaves[SL1Nr].Neighbours.Size()-1].SuperLeafNr=SL2Nr;
                    SuperLeaves[SL1Nr].Neighbours[SuperLeaves[SL1Nr].Neighbours.Size()-1].SubPortal  =NewPortals[NewPortals.Size()-1];
                }
        }

    printf("SLs Adjacency Graph :       done\n");
}
Ejemplo n.º 9
0
bool CommandGroupSetPropT::Do()
{
    wxASSERT(!m_Done);
    if (m_Done) return false;

    // Set the new property
    // and notify all observers that our groups inventory changed.
    switch (m_Prop)
    {
        case PROP_NAME:          m_Group->Name=m_NewName;          break;
        case PROP_COLOR:         m_Group->Color=m_NewColor;        break;
        case PROP_CANSELECT:     m_Group->CanSelect=m_NewFlag;     break;
        case PROP_SELECTASGROUP: m_Group->SelectAsGroup=m_NewFlag; break;
    }

    m_MapDoc.UpdateAllObservers_GroupsChanged();

    // If the elements in the group have changed color, update all observers accordingly.
    if (m_Prop==PROP_COLOR)
    {
        const ArrayT<MapElementT*> GroupElems=m_Group->GetMembers(m_MapDoc);

        if (GroupElems.Size()>0)
            m_MapDoc.UpdateAllObservers_Modified(GroupElems, MEMD_GENERIC /*MEMD_VISIBILITY*/);
    }

    m_Done=true;
    return true;
}
Ejemplo n.º 10
0
inline void StringToArray(LPCTSTR text, ArrayT & array, LPCTSTR separator = _T(""), bool trimSpaces = true)
{
    CString search = text;
    int seplen = CString(separator).GetLength();
    while (true)
    {
        int idx = search.Find(separator);
        if (idx == -1)
        {
            if (trimSpaces)
            {
                search.TrimLeft();
                search.TrimRight();
            }
            if (!search.IsEmpty())
                array.Add(search);
            break;
        }
        CString part = search.Left(idx);
        search.Delete(0, idx + seplen);
        if (trimSpaces)
        {
            part.TrimLeft();
            part.TrimRight();
        }
        if (!part.IsEmpty())
            array.Add(part);
    }
}
Ejemplo n.º 11
0
/* change the number of active element groups */
void ElementListT::SetActiveElementGroupMask(const ArrayT<bool>& mask)
{
	/* first time */
	if (fAllElementGroups.Length() == 0)
	{
		/* cache all pointers */
		fAllElementGroups.Dimension(Length());
		for (int i = 0; i < fAllElementGroups.Length(); i++)
		{
			ElementBaseT* element = (*this)[i];
			fAllElementGroups[i] = element;
		}
	}

	/* check */
	if (mask.Length() != fAllElementGroups.Length())
		ExceptionT::SizeMismatch("ElementListT::SetActiveElementGroupMask",
			"expecting mask length %d not %d", fAllElementGroups.Length(), mask.Length());

	/* reset active element groups */
	int num_active = 0;
	for (int i = 0; i < mask.Length(); i++)
		if (mask[i])
			num_active++;

	/* cast this to an ArrayT */
	ArrayT<ElementBaseT*>& element_list = *this;
	element_list.Dimension(num_active);
	num_active = 0;
	for (int i = 0; i < mask.Length(); i++)
		if (mask[i])
			element_list[num_active++] = fAllElementGroups[i];
}
Ejemplo n.º 12
0
bool EditorChoiceWindowT::HandlePGChange(wxPropertyGridEvent& Event, GuiEditor::ChildFrameT* ChildFrame)
{
    if (EditorWindowT::HandlePGChange(Event, ChildFrame)) return true;

    const wxPGProperty* Prop    =Event.GetProperty();
    const wxString      PropName=Prop->GetName();

    if (PropName=="Choices")
    {
        ArrayT<std::string> NewStrings;
        wxStringTokenizer   Tokenizer(Prop->GetValueAsString(), "\r\n");

        while (Tokenizer.HasMoreTokens())
            NewStrings.PushBack(std::string(Tokenizer.GetNextToken()));

        ChildFrame->SubmitCommand(new CommandSetWinPropT< ArrayT<std::string> >(m_GuiDoc, this, PropName, m_Choice->m_Choices, NewStrings));
        return true;
    }

    if (PropName=="DefaultChoice")
    {
        wxASSERT(m_Choice->GetMemberVar("selectedChoice").Member!=NULL);

        ChildFrame->SubmitCommand(new CommandModifyWindowT(m_GuiDoc, m_Choice, PropName, m_Choice->GetMemberVar("selectedChoice"), Prop->GetValue().GetLong()));
        return true;
    }

    return false;
}
Ejemplo n.º 13
0
bool ToolEditSurfaceT::OnLMouseDown3D(ViewWindow3DT& ViewWindow, wxMouseEvent& ME)
{
    const ArrayT<ViewWindow3DT::HitInfoT> Hits=ViewWindow.GetElementsAt(ME.GetPosition());

    // Having this statement here means that the user absolutely cannot entirely clear the
    // surfaces selection (in 3D views, it works in 2D views), but that is just fine - why would he?
    if (Hits.Size()==0) return true;

    MapElementT*  Object   =Hits[0].Object;
    unsigned long FaceIndex=Hits[0].FaceNr;

    if (m_EyeDropperActive)
    {
        ViewWindow.GetChildFrame()->GetSurfacePropsDialog()->EyeDropperClick(Object, FaceIndex);
        return true;
    }

    if (!ME.ControlDown())
        ViewWindow.GetChildFrame()->GetSurfacePropsDialog()->ClearSelection();

    ViewWindow.GetChildFrame()->GetSurfacePropsDialog()->ToggleClick(Object, ME.ShiftDown() ? EditSurfacePropsDialogT::ALL_FACES : FaceIndex);

    // When something is newly selected (Control is not down), its surface properties are also picked up.
    if (!ME.ControlDown())
        ViewWindow.GetChildFrame()->GetSurfacePropsDialog()->EyeDropperClick(Object, FaceIndex);

    return true;
}
Ejemplo n.º 14
0
void CommandDeleteT::Undo()
{
    wxASSERT(m_Done);
    if (!m_Done) return;

    ArrayT<MapElementT*> InsertedElems;

    for (unsigned long PrimNr=0; PrimNr<m_DeletePrims.Size(); PrimNr++)
    {
        m_MapDoc.Insert(m_DeletePrims[PrimNr], m_DeletePrimsParents[PrimNr]);
        InsertedElems.PushBack(m_DeletePrims[PrimNr]);
    }

    for (unsigned long EntNr=0; EntNr<m_DeleteEnts.Size(); EntNr++)
    {
        m_MapDoc.Insert(m_DeleteEnts[EntNr]);
        InsertedElems.PushBack(m_DeleteEnts[EntNr]);
    }

    // Update all observers.
    m_MapDoc.UpdateAllObservers_Created(InsertedElems);

    // Select the previously selected elements again.
    m_CommandSelect->Undo();

    m_Done=false;
}
Ejemplo n.º 15
0
void SubjectT::UpdateAllObservers_Modified(IntrusivePtrT<cf::GuiSys::WindowT> Window, WindowModDetailE Detail, const wxString& PropertyName)
{
    ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> > Windows;
    Windows.PushBack(Window);

    UpdateAllObservers_Modified(Windows, Detail, PropertyName);
}
Ejemplo n.º 16
0
void MFPenaltyContact2DT::ComputeStrikerCoordinates(const ArrayT<int>& strikers)
{
	/* dimension */
	fStrikerCoords_man.SetMajorDimension(strikers.Length(), false);

	/* current striker coords */
	if (strikers.Length() > 0) {
	
		/* reconstruct displacement field */
		if (fSCNI) {
			fSCNI_tmp = strikers;
			if (!fSCNI->GlobalToLocalNumbering(fSCNI_tmp))
				ExceptionT::GeneralFail("MFPenaltyContact2DT::ComputeStrikerCoordinates", 
					"SCNI global->local failed");
			fSCNI->InterpolatedFieldAtNodes(fSCNI_tmp, fStrikerCoords);
		}
		else {
			iArrayT tmp;
			tmp.Alias(strikers);
			fElementGroup->NodalDOFs(tmp, fStrikerCoords);
		}

		/* compute current coordinates */
		const dArray2DT& init_coords = ElementSupport().InitialCoordinates();
		for (int i = 0; i < strikers.Length(); i++)
			fStrikerCoords.AddToRowScaled(i, 1.0, init_coords(strikers[i]));
	}
}
Ejemplo n.º 17
0
void SubjectT::UpdateAllObservers_Deleted(IntrusivePtrT<cf::GuiSys::WindowT> Window)
{
    ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> > Windows;
    Windows.PushBack(Window);

    UpdateAllObservers_Deleted(Windows);
}
Ejemplo n.º 18
0
CommandSelectT::CommandSelectT(GuiDocumentT* GuiDocument, const ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> >& OldSelection, const ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> >& NewSelection)
    : CommandT(abs(int(OldSelection.Size())-int(NewSelection.Size()))>3, false), // Only show selection command in the undo/redo history if selection difference is greater 3.
      m_GuiDocument(GuiDocument),
      m_OldSelection(OldSelection),
      m_NewSelection(NewSelection)
{
}
Ejemplo n.º 19
0
/* free any uncompleted requests */
void CommunicatorT::FreeRequests(ArrayT<MPI_Request>& requests) const
{
#ifdef __TAHOE_MPI__
	const char caller[] = "CommunicatorT::FreeRequests";

	/* free any uncompleted receive requests */
	for (int i = 0; i < requests.Length(); i++)
		if (requests[i] != MPI_REQUEST_NULL)
		{
			Log(kLow, "caller", "cancelling request %d/%d", i+1, requests.Length());
		
			/* cancel request */
			MPI_Cancel(&requests[i]);
			MPI_Status status;
			MPI_Wait(&requests[i], &status);
			int flag;
			MPI_Test_cancelled(&status, &flag);
			if (flag )
				Log(kLow, "caller", "cancelling request %d/%d: DONE", i+1, requests.Length());
			else	
				Log(kLow, "caller", "cancelling request %d/%d: FAIL", i+1, requests.Length());
		}
#else
#pragma unused(requests)
#endif
}
Ejemplo n.º 20
0
CommandSelectT* CommandSelectT::Add(GuiDocumentT* GuiDocument, IntrusivePtrT<cf::GuiSys::WindowT> Window)
{
    ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> > AddSelection;
    AddSelection.PushBack(Window);

    return CommandSelectT::Add(GuiDocument, AddSelection);
}
Ejemplo n.º 21
0
/* block until all sends posted with CommunicatorT::PostSend have completed */
void CommunicatorT::WaitSends(const ArrayT<MPI_Request>& requests)
{
	const char caller[] = "CommunicatorT::WaitSends";
	Log(kModerate, caller, "waiting for 1 of %d", requests.Length());

	/* complete all sends */
	for (int i = 0; i < requests.Length(); i++)
	{
		int index = -1;

#ifdef __TAHOE_MPI__
		/* grab completed receive */
		MPI_Status status;
		int ret = MPI_Waitany(requests.Length(), (MPI_Request*) requests.Pointer(), &index, &status);

#ifdef CHECK_MPI_RETURN
		if (ret != MPI_SUCCESS) Log(kFail, caller, "MPI_Waitany failed");
#endif

#ifdef CHECK_MPI_STATUS
		if (status.MPI_ERROR != MPI_SUCCESS) {
			WriteStatus(Log(), caller, status);
			Log(kFail, caller, "bad status: %d", status.MPI_ERROR);
		}
#endif

#endif

		Log(kLow, caller, "completing send at index %d", index);
	}
}
Ejemplo n.º 22
0
CommandSelectT* CommandSelectT::Remove(GuiDocumentT* GuiDocument, IntrusivePtrT<cf::GuiSys::WindowT> Window)
{
    ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> > RemoveSelection;
    RemoveSelection.PushBack(Window);

    return CommandSelectT::Remove(GuiDocument, RemoveSelection);
}
Ejemplo n.º 23
0
void CommandTransformT::Undo()
{
    wxASSERT(m_Done);
    if (!m_Done) return;

    if (m_DoClone)
    {
        m_CommandSelect->Undo();

        // Remove cloned objects from world again.
        for (unsigned long CloneNr=0; CloneNr<m_ClonedElems.Size(); CloneNr++)
            m_MapDoc.Remove(m_ClonedElems[CloneNr]);

        m_MapDoc.UpdateAllObservers_Deleted(m_ClonedElems);
    }
    else
    {
        // Record the previous bounding-boxes for the observer message.
        ArrayT<BoundingBox3fT> OldBounds;

        for (unsigned long ElemNr=0; ElemNr<m_TransElems.Size(); ElemNr++)
        {
            OldBounds.PushBack(m_TransElems[ElemNr]->GetBB());
            m_TransElems[ElemNr]->Assign(m_OldStates[ElemNr]);
        }

        m_MapDoc.UpdateAllObservers_Modified(m_TransElems, MEMD_TRANSFORM, OldBounds);
    }

    m_Done=false;
}
Ejemplo n.º 24
0
uint32_t* SingleOpenGLWindowImplT::GetFrameBuffer(unsigned int& Width_, unsigned int& Height_)
{
    static ArrayT<uint32_t> FrameBuffer;

    FrameBuffer.Overwrite();
    FrameBuffer.PushBackEmpty(Width*Height);

    // Pixel vom BackBuffer in den FrameBuffer lesen.
    // Beachte: Die ersten beiden Parameter (0, 0) spezifizieren die linke UNTERE Ecke des gewünschten Bereichs!
    glReadPixels(0, 0, Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, &FrameBuffer[0]);

    Width_ =Width;
    Height_=Height;

    // Wie oben schon erwähnt, steht der 'FrameBuffer' leider auf dem Kopf.
    // Vertausche daher alle Zeilen (vertikale Spiegelung).
    for (unsigned int y=0; y<Height_/2; y++)
    {
        uint32_t* UpperRow=&FrameBuffer[0]+         y   *Width_;
        uint32_t* LowerRow=&FrameBuffer[0]+(Height_-y-1)*Width_;

        for (unsigned int x=0; x<Width_; x++)
        {
            const uint32_t Swap=*UpperRow;

            *UpperRow=*LowerRow;
            *LowerRow=Swap;

            UpperRow++;
            LowerRow++;
        }
    }

    return &FrameBuffer[0];
}
Ejemplo n.º 25
0
/* initialize the state variable array */
void MR_RP2DT::InitStateVariables(ArrayT<double>& state)
{
    int num_state = NumStateVariables();
    if (state.Length() != num_state) {
#ifndef _SIERRA_TEST_
        cout << "\n SurfacePotentialT::InitStateVariables: expecting state variable array\n"
             <<   "     length " << num_state << ", found length " << state.Length() << endl;
#endif
        throw ExceptionT::kSizeMismatch;
    }

    /* clear */
    if (num_state > 0) state = 0.0;

    /* Initializing internal state variables */
    double enp  = state[14];
    double esp  = state[15];
    double fchi = fchi_r + (fchi_p - fchi_r)*exp(-falpha_chi*enp);
    double fc   = fc_r + (fc_p - fc_r)*exp(-falpha_c*esp);
    double ftan_phi = tan(fphi_r) + (tan(fphi_p) - tan(fphi_r))*exp(-falpha_phi*esp);
    double ftan_psi = (tan(fpsi_p))*exp(-falpha_psi*esp);
    state[6]  = fchi;
    state[7]  = fc ;
    state[8]  = ftan_phi;
    state[9]  = ftan_psi;
    state[13] = 0.;
    state[nTiedFlag] = kTiedNode;
}
Ejemplo n.º 26
0
bool EngineEntityT::Repredict(const ArrayT<PlayerCommandT>& PlayerCommands, unsigned long RemoteLastIncomingSequenceNr, unsigned long LastOutgoingSequenceNr)
{
    if (!UsePrediction.GetValueBool())
        return false;

    if (LastOutgoingSequenceNr-RemoteLastIncomingSequenceNr>PlayerCommands.Size())
    {
        EnqueueString("WARNING - Prediction impossible: Last ack'ed PlayerCommand is too old (%u, %u)!\n", RemoteLastIncomingSequenceNr, LastOutgoingSequenceNr);
        return false;
    }

    /*
     * This assumes that this method is immediately called after ParseServerDeltaUpdateMessage(),
     * where the state of this entity has been set to the state of the latest server frame,
     * and that every in-game packet from the server contains a delta update message for our local client!
     */

    // Unseren Entity über alle relevanten (d.h. noch nicht bestätigten) PlayerCommands unterrichten.
    // Wenn wir auf dem selben Host laufen wie der Server (z.B. Single-Player Spiel oder lokaler Client bei non-dedicated-Server Spiel),
    // werden die Netzwerk-Nachrichten in Nullzeit (im Idealfall über Memory-Buffer) versandt.
    // Falls dann auch noch der Server mit full-speed läuft, sollte daher immer RemoteLastIncomingSequenceNr==LastOutgoingSequenceNr sein,
    // was impliziert, daß dann keine Prediction stattfindet (da nicht notwendig!).
    for (unsigned long SequenceNr=RemoteLastIncomingSequenceNr+1; SequenceNr<=LastOutgoingSequenceNr; SequenceNr++)
        Entity->ProcessConfigString(&PlayerCommands[SequenceNr & (PlayerCommands.Size()-1)], "PlayerCommand");

    Entity->Think(-2.0, 0);
    return true;
}
Ejemplo n.º 27
0
static void
TraceArray(JSTracer* trc, void* data)
{
  ArrayT* array = static_cast<ArrayT *>(data);
  for (unsigned i = 0; i < array->Length(); ++i)
    JS_CallHeapObjectTracer(trc, &array->ElementAt(i), "array-element");
}
Ejemplo n.º 28
0
void SubjectT::UpdateAllObservers_Modified(IntrusivePtrT<cf::GuiSys::WindowT> Window, WindowModDetailE Detail)
{
    ArrayT< IntrusivePtrT<cf::GuiSys::WindowT> > Windows;
    Windows.PushBack(Window);

    UpdateAllObservers_Modified(Windows, Detail);
}
Ejemplo n.º 29
0
void InspDlgEntityPropsT::OnContextMenuItemDelete(wxCommandEvent& event)
{
    // Just in case the user pressed e.g. CTRL+Q (clear selection) in the meanwhile...
    if (LastRightClickedProperty==NULL) return;

    // Only handle deletes on properties that are not a category.
    if (LastRightClickedProperty->IsCategory()) return;

    // Key is not undefined (cannot be deleted).
    if (LastRightClickedProperty->GetParent()!=UnDefKeys)
    {
        wxMessageBox("Only undefined keys can be deleted.");
        return;
    }

    ArrayT<CommandT*> Commands;

    for (unsigned long i=0; i<SelectedEntities.Size(); i++)
        Commands.PushBack(new CommandDeletePropertyT(*MapDoc, SelectedEntities[i], LastRightClickedProperty->GetName()));

    CommandT* MacroCommand=new CommandMacroT(Commands, "Delete Property '"+LastRightClickedProperty->GetName()+"'");

    // Note that we also receive the update notification recursively (triggered by command execution in SubmitCommand()).
    // This is intentional, or else we had to manually fix the PropMan, CombinedPropInfos, etc. here, which is error-prone.
    // The complete recursive update is much less work and 100% safe, because it guarantees that no new bugs are introduced here.
    MapDoc->GetHistory().SubmitCommand(MacroCommand);
}
Ejemplo n.º 30
0
void ClipWorldT::TraceRay(const Vector3dT& Start, const Vector3dT& Ray,
    unsigned long ClipMask, const ClipModelT* Ignore, TraceResultT& Result, ClipModelT** HitClipModel) const
{
    // Violation of this requirement is usually, but not necessarily, an error.
    // If you ever get false-positives here, just remove the test entirely.
    assert(Result.Fraction==1.0 && !Result.StartSolid);

    if (HitClipModel) *HitClipModel=NULL;

    // Try the trace against the WorldCollMdl first.
    WorldCollMdl->TraceRay(Start, Ray, ClipMask, Result);

 // if (Result.Fraction<OldFrac && HitClipModel) *HitClipModel=WorldCollMdl;     // FIXME: WorldCollMdl is of type CollisionModelT...
    if (Result.Fraction==0.0) return;


    // Now try all the entity models.
    ArrayT<ClipModelT*>  ClipModels;
    const BoundingBox3dT OverallBB(Start, Start+Ray*Result.Fraction);

    GetClipModelsFromBB(ClipModels, ClipMask, OverallBB);

    for (unsigned long ModelNr=0; ModelNr<ClipModels.Size(); ModelNr++)
    {
        ClipModelT*  ClipModel  =ClipModels[ModelNr];
        const double OldFraction=Result.Fraction;

        if (ClipModel==Ignore) continue;

        ClipModel->TraceRay(Start, Ray, ClipMask, Result);

        if (Result.Fraction<OldFraction && HitClipModel) *HitClipModel=ClipModel;
        if (Result.Fraction==0.0) break;
    }
}