VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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
#include "csvScenarioDescriptionImporterExporter.h"
{
public:
virtual bool loadScenarioDescription(const DtFilename& file, const std::map<std::string, std::string>& importData,
virtual bool importIntoSimulation(DtSimulationServices*) override;
virtual bool importFromSimulation(DtSimulationServices*, const std::map<std::string, std::string>& exportData,
protected:
virtual bool isExportable(DtSimulationServices* mgr, const DtLocalObject* ref) const;
virtual bool isExportableEnvironmental(DtSimulationServices* mgr, const DtLocalObject* ref) const;
virtual bool exportOrganization(DtSimulationServices*, const std::map<std::string, std::string>& exportData,
virtual bool exportTacticalGraphics(DtSimulationServices*, const std::map<std::string, std::string>& exportData,
virtual bool complete() const override;
static void createObjectsCallback(void*);
virtual void processCreateObjects();
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>
: mySimulationServices(s)
, myObjectManager(mgr)
{
}
: mySimulationServices(orig.mySimulationServices)
, myObjectManager(orig.myObjectManager)
{
}
{
}
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;
}
{
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.setOrganized(true);
crt.setObjectType(element->type);
if (element->children.size())
{
std::vector<ObjectInformation*>::iterator iter = element->children.begin();
std::vector<DtUUID> uuids;
while (iter != element->children.end())
{
uuids.push_back((*iter)->object->uuid());
++iter;
}
crt.addSubordinates(uuids);
}
element->object = myObjectManager->createAndInitVrfObject(crt);
}
{
DtString objectName = element->name.c_str();
DtEntityType object(element->type);
crt.setObjectName(deconflictName(mySimulationServices, objectName, object.kind()));
crt.setForceType((DtForceType)element->force);
crt.setLabel(crt.objectName());
crt.setCreateSubObjects(false);
crt.setOrganized(true);
crt.setObjectType(object);
crt.setClosedFigure((object.kind() == 20) || (object.kind() == 18) || (object.kind() == 19));
if (crt.objectType().kind() >= 17)
{
crt.setFillStyle(0);
}
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->type.kind() == 20)
{
// Set the closedFigure flag to true for area objects.
crt.setClosedFigure(true);
}
}
crt.setOverlay(element->parent.c_str());
element->object = myObjectManager->createAndInitVrfObject(crt);
}
{
int numCreated = 0;
while (numCreated < myOrganizationCreationOrder.size())
{
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;
}
//[The importIntoSimulation function]
{
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;
}
{
if (ref->isTopLevel() ||
ref->entityType().matchPattern(DtGlobalWeatherObjectTypes) ||
ref->entityType().matchPattern(DtGlobalPlanEntityType) ||
ref->entityType().matchPattern(DtSyncMatrixEntityType)
)
{
return false;
}
return (ref->isEntity() || ref->isUnit());
}
{
if (ref->isTopLevel() ||
ref->entityType().matchPattern(DtGlobalWeatherObjectTypes) ||
ref->entityType().matchPattern(DtGlobalPlanEntityType) ||
ref->entityType().matchPattern(DtSyncMatrixEntityType)
)
{
return false;
}
return (!ref->isEntity() && !ref->isUnit());
}
//[The importIntoSimulation function]
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings&)
{
DtSimObjectMap::const_iterator iter = localObjects.begin();
DtSimObjectMap::const_iterator end = localObjects.end();
while (iter != end)
{
const DtLocalObject* object = iter->second;
if (isExportable(mgr, object))
{
information->name = object->objectName();
information->type = object->objectType();
information->uuid = object->uuid();
information->force = object->forceType();
if (object->superior().isValid() && !object->superior()->isTopLevel())
{
information->parent = object->superior()->uuid().uuidString();
}
information->points.push_back(object->worldPosition());
myObjectMap[information->uuid] = information;
}
++iter;
}
return true;
}
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings&)
{
DtSimObjectMap::const_iterator iter = localObjects.begin();
DtSimObjectMap::const_iterator end = localObjects.end();
while (iter != end)
{
const DtLocalObject* object = iter->second;
if (isExportableEnvironmental(mgr, object))
{
information->name = object->objectName();
information->type = object->objectType();
information->uuid = object->uuid();
information->force = object->forceType();
information->parent = object->nextFrameOverlay();
DtRwVectorIterator iterator(object->worldVertices());
DtRwVector* vecPtr = NULL;
for(vecPtr = iterator.first(); vecPtr; vecPtr = iterator.next())
{
DtVector* vec = dynamic_cast<DtVector*>(vecPtr);
information->points.push_back(*vec);
}
myObjectMap[information->uuid] = information;
}
++iter;
}
return true;
}
//[The importFromSimulation function]
const std::map<std::string, std::string>& exportData, const DtMsdlHierarchyPropertyMappings& m)
{
exportOrganization(mgr, exportData, m);
exportTacticalGraphics(mgr, exportData, m);
return true;
}
//[The importFromSimulation function]
{
return (myOrganizationCreationOrder.size() == 0);
}

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)