VR-Forces 4.3 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Class that will import from or export to a comma delimited file and put information into the scenario

Classes

Header

/*******************************************************************************
** Copyright (c) 2012 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma once
{
public:
virtual bool loadScenarioDescription(const DtFilename& file, const std::map<std::string, std::string>& importData,
virtual bool importFromSimulation(DtSimManager*, const std::map<std::string, std::string>& exportData,
protected:
virtual bool exportOrganization(DtSimManager*, const std::map<std::string, std::string>& exportData,
virtual bool exportTacticalGraphics(DtSimManager*, const std::map<std::string, std::string>& exportData,
virtual bool complete() const;
virtual bool prepareOrganizationCreationOrder(DtSimManager* mgr, ObjectInformation* element);
static void createObjectsCallback(void*);
virtual void processCreateObjects();
virtual void createEntity(ObjectInformation*);
virtual void createTacticalGraphic(ObjectInformation*);
virtual DtString deconflictName(DtSimManager*, const DtString&, int kind);
protected:
std::vector<ObjectInformation*> myOrganizedHierarchy;
std::vector<ObjectInformation*> myOrganizationCreationOrder;
};

Class

/*******************************************************************************
** Copyright (c) 2012 MaK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#include <matrix/vlMath.h>
#include <matrix/geodeticCoord.h>
{
}
{
}
const std::map<std::string, std::string>& importData,const DtMsdlHierarchyPropertyMappings& mappings)
{
{
ObjectMap::iterator iter = myObjectMap.begin();
while (iter != myObjectMap.end())
{
if (!iter->second->parent.length() || (iter->second->type.kind() >= 16))
{
myOrganizedHierarchy.push_back(iter->second);
}
++iter;
}
return true;
}
return false;
}
{
}
{
if (element->children.size())
{
std::vector<ObjectInformation*>::iterator iter = element->children.begin();
while (iter != element->children.end())
{
{
return false;
}
++iter;
}
myOrganizationCreationOrder.push_back(element);
return true;
}
myOrganizationCreationOrder.push_back(element);
return true;
}
{
std::vector<ObjectInformation*>::iterator iter = myOrganizedHierarchy.begin();
int consecutiveCreate = 0;
while (iter != myOrganizedHierarchy.end())
{
if (!(*iter)->children.size())
{
if ((*iter)->type.kind() < 16)
{
myOrganizationCreationOrder.push_back(*iter);
if (++consecutiveCreate == 20)
{
consecutiveCreate = 0;
}
}
}
else
{
consecutiveCreate = 0;
{
return false;
}
}
++iter;
}
return true;
}
{
}
{
int count = 1;
DtString baseName = name;
DtString newName = name;
if ((kind < 11) && (name.length() > 11))
{
baseName = DtString(name.c_str(), 11);
newName = baseName;
}
while (mgr->vrfObjectManager()->lookupObjectByName(newName))
{
int maxLength = 31;
if ((kind < 11) && (name.length() > 9))
{
maxLength = 12;
baseName = DtString(name.c_str(), 9);
}
newName = DtString(count++) + "_" + baseName;
if (newName.length() >= maxLength)
{
newName = DtString(newName, maxLength - 1);
}
}
return newName;
}
{
DtString objectName = element->name;
crt.setForceType((DtForceType)element->force);
crt.setPosition(element->points[0]);
crt.setCreateSubObjects(false);
crt.setObjectType(DtObjectType((element->type.kind() == 11 ? 3 : 1), element->type));
crt.setObjectName(deconflictName(mySimManager, objectName, crt.objectType().kind()));
element->object->tick();
if (element->children.size())
{
std::vector<ObjectInformation*>::iterator iter = element->children.begin();
DtList names;
while (iter != element->children.end())
{
names.add((void*)&(*iter)->object->objectName());
++iter;
}
mySimManager->vrfObjectManager()->addSubordinatesToAggregate(element->object, &names, DtDisaggregated);
}
}
{
DtString objectName = element->name.c_str();
DtObjectType object(1, element->type);
crt.setObjectName(deconflictName(mySimManager, objectName, object.kind()));
crt.setForceType((DtForceType)element->force);
crt.setCreateSubObjects(false);
crt.setObjectType(object);
if (element->points.size() == 1)
{
crt.setPosition(element->points[0]);
}
else
{
std::vector<DtVector>::const_iterator iter = element->points.begin();
while (iter != element->points.end())
{
crt.addVertex(*iter);
++iter;
}
}
if (element->object)
{
element->object->setOverlayParent(element->parent.c_str());
}
}
{
int numCreated = 0;
while (numCreated < myOrganizationCreationOrder.size())
{
ObjectInformation* element = myOrganizationCreationOrder[numCreated++];
if (element->type.kind() >= 16)
{
}
else
{
createEntity(element);
}
if (numCreated == myOrganizationCreationOrder.size())
{
break;
}
else if (myOrganizationCreationOrder[numCreated] == 0)
{
numCreated++;
break;
}
}
if (numCreated == (myOrganizationCreationOrder.size() - 1))
{
}
else
{
}
if (myOrganizationCreationOrder.size() == 0)
{
}
}
{
std::vector<ObjectInformation*>::iterator iter = myOrganizedHierarchy.begin();
int createdCount = 0;
while (iter != myOrganizedHierarchy.end())
{
if ((*iter)->type.kind() >= 16)
{
myOrganizationCreationOrder.push_back(*iter);
if (++createdCount == 10)
{
createdCount = 0;
}
}
++iter;
}
return true;
}
{
mySimManager = mgr;
{
}
return true;
}
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings&)
{
DtListItem* item = orgMgr->nodes().list()->first();
while (item)
{
DtOrganizationManagerNode* node = static_cast<DtOrganizationManagerNode*>(item->data());
{
DtEntityIdentifier id = orgMgr->superior(object->objectIdentifier());
ObjectInformation* information = new ObjectInformation;
information->name = object->objectName();
information->type = object->objectType();
information->force = object->vrfState()->forceType();
if (id != DtEntityIdentifier())
{
{
information->parent = parent->objectName();
}
}
information->points.push_back(object->vrfState()->worldPosition());
myObjectMap[information->name] = information;
}
item = item->next();
}
return true;
}
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings&)
{
const DtVrfObject* object = iter.first();
while (object)
{
if ((object->objectType().kind() >= 16) && (object->objectType().kind() <= 20))
{
ObjectInformation* information = new ObjectInformation;
information->name = object->objectName();
information->type = object->objectType();
information->force = object->vrfState()->forceType();
information->parent = object->overlayParent();
DtRwVectorIterator iterator = object->vrfState()->worldVertexIterator();
DtRwVector* vecPtr = NULL;
for(vecPtr = iterator.first(); vecPtr; vecPtr = iterator.next())
{
DtVector* vec = dynamic_cast<DtVector*>(vecPtr);
information->points.push_back(*vec);
}
myObjectMap[information->name] = information;
}
object = iter.next();
}
return true;
}
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings& m)
{
exportOrganization(mgr, exportData, m);
exportTacticalGraphics(mgr, exportData, m);
return true;
}
{
return (myOrganizationCreationOrder.size() == 0);
}

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)