This example reads a VTFx file and prints the content of the file to the console.
It outputs meta data on the file , database, case and all blocks. It also lists data content of data blocks (such as result values, node coordinates and ids). Only the first 100 values of such arrays are printed (if the size exceeds 100 items).
The example might be useful for dumping the file content to a console as help for debugging.
{
{
{
std::vector<cee::Variant> array = v.
getArray();
for (std::vector<cee::Variant>::iterator it = array.begin(); it != array.end(); it++)
{
str = str + getAsString(*it) + " | ";
}
return str;
}
default:
return "";
}
}
int main()
{
unsigned int licenseKeyA = 0x00;
unsigned int licenseKeyB = 0x00;
if (!file->
open(
"../../DemoFiles/SimpleExample.vtfx"))
{
return EXIT_FAILURE;
}
for (size_t i = 0; i < numCases; i++)
{
std::wcout <<
"Case " << c->
id() <<
": ";
std::wcout << std::endl;
if (properties)
{
for (
size_t j = 0; j < properties->
count(); j++)
{
std::wcout <<
"Class type: " << propertySet->
classType().
c_str() << std::endl;
std::vector<cee::Str> keys = propertySet->
allKeys();
std::vector<cee::Variant> values = propertySet->
allValues();
for (size_t k = 0; k < keys.size(); k++)
{
std::wcout << " Key: " << keys.at(k).c_str() << std::endl;
std::wcout << " Value: " << getAsString(values.at(k)).c_str() << std::endl;
}
}
}
std::wcout << "Image count: " << numImages << std::endl;
for (size_t i = 0; i < numImages; i++)
{
}
}
for (size_t i = 0; i < numDatabases; i++)
{
std::wcout <<
"Database " << db->
id() <<
": ";
std::wcout << std::endl;
size_t numNodeBlocks = db->
blockCount(cee::vtfx::Block::NODES);
std::wcout << "Number of node blocks: " << numNodeBlocks << std::endl;
for (size_t j = 0; j < numNodeBlocks; j++)
{
std::wcout <<
"Node block id: " << nodeBlock->
blockId() << std::endl;
std::wcout <<
" Number of nodes: " << nodeBlock->
nodeCount() << std::endl;
std::wcout << " Nodes: ( x, y, z)" << std::endl;
for (size_t k = 0; k < nodeCount; k++)
{
std::wcout <<
" (" << nodeBlock->
nodes().at(k).x() <<
", " << nodeBlock->
nodes().at(k).y() <<
", " << nodeBlock->
nodes().at(k).z() <<
")";
std::wcout << std::endl;
}
bool usesNodeIds = (nodeBlock->
nodeIds().size() > 0);
std::wcout << " Using node ids: " << (usesNodeIds ? "yes" : "no") << std::endl;
if (usesNodeIds)
{
std::wcout << " Node ids: ";
size_t nodeIdCount = nodeBlock->
nodeIds().size() > 100 ? 100 : nodeBlock->
nodeIds().size();
for (size_t k = 0; k < nodeIdCount; k++)
{
std::wcout <<
" " << nodeBlock->
nodeIds().at(k);
}
std::wcout << std::endl;
}
}
std::wcout << "Number of element blocks: " << numElementBlocks << std::endl;
for (size_t j = 0; j < numElementBlocks; j++)
{
std::wcout <<
"Element block id: " << elementBlock->
blockId() << std::endl;
std::wcout <<
" Node block id: " << elementBlock->
nodeBlockId() << std::endl;
std::wcout <<
" Number of elements: " << elementBlock->
elementCount() << std::endl;
std::wcout <<
" Number of element nodes: " << elementBlock->
elementNodeCount() << std::endl;
std::wcout <<
" Number of element groups: " << elementBlock->
elementGroupCount() << std::endl;
for (size_t k = 0; k < elementGroupCount; k++)
{
std::wcout << " Element group " << k << ":" << std::endl;
std::vector<int> elementNodes;
std::vector<int> elementIds;
std::wcout <<
" Element type: " << elementBlock->
elementGroupType(k) << std::endl;
if (elementNodes.size() > 0)
{
std::wcout << " Element nodes: ";
size_t elementNodeCount = elementNodes.size() > 100 ? 100 : elementNodes.size();
for (size_t l = 0; l < elementNodeCount; l++)
{
std::wcout << elementNodes[l] << " ";
}
std::wcout << std::endl;
}
if (elementIds.size() > 0)
{
std::wcout << " Element ids: ";
size_t elementIdCount = elementIds.size() > 100 ? 100 : elementIds.size();
for (size_t l = 0; l < elementIdCount; l++)
{
std::wcout << elementIds[l] << " ";
}
std::wcout << std::endl;
}
}
}
std::wcout << "Number of result blocks: " << numResultBlocks << std::endl;
for (size_t j = 0; j < numResultBlocks; j++)
{
std::wcout <<
"Result block id: " << resultBlock->
blockId() << std::endl;
std::wcout <<
" Result id: " << resultBlock->
resultId() << std::endl;
std::wcout <<
" Result name: " << resultBlock->
name().
c_str() << std::endl;
std::wcout <<
" Result type: " << resultBlock->
resultType() << std::endl;
std::wcout <<
" Result mapping: " << resultBlock->
resultMapping() << std::endl;
{
}
std::wcout <<
" Number of states: " << resultBlock->
stateCount() << std::endl;
for (
size_t k = 0; k < resultBlock->
stateCount(); k++)
{
std::wcout <<
" State id: " << resultBlock->
stateId(k) << std::endl;
std::wcout << " Number of result values blocks: " << resultValuesBlocks.size() << std::endl;
std::wcout << " Result values block ids: ";
for (std::vector<int>::iterator it = resultValuesBlocks.begin(); it != resultValuesBlocks.end(); ++it)
{
std::wcout << *it << " ";
}
std::wcout << std::endl;
}
}
std::wcout << "Number of result values blocks: " << numResultValuesBlocks << std::endl;
for (size_t j = 0; j < numResultValuesBlocks; j++)
{
std::wcout <<
"Result values block id: " << resultValuesBlock->
blockId() << std::endl;
std::wcout <<
" Mapped to block id: " << resultValuesBlock->
mapToBlockId() << std::endl;
std::wcout <<
" Mapped using ids: " << (resultValuesBlock->
hasMapToItemIds() ?
"yes" :
"no") << std::endl;
{
std::vector<int> mapToItemIds = resultValuesBlock->
mapToItemIds();
std::wcout << " Mapped ids: ";
for (std::vector<int>::iterator it = mapToItemIds.begin(); it != mapToItemIds.end(); ++it)
{
std::wcout << *it << " ";
}
std::wcout << std::endl;
}
std::wcout <<
" Dimension: " << resultValuesBlock->
dimension() << std::endl;
std::vector<float> resultValues = resultValuesBlock->
resultValues();
std::wcout << " Result values: ";
size_t resultValueCount = resultValues.size() > 100 ? 100 : resultValues.size();
for (size_t l = 0; l < resultValueCount; l++)
{
std::wcout << resultValues[l] << " ";
}
std::wcout << std::endl;
}
std::wcout << "Number of geometry blocks: " << numGeometryBlocks << std::endl;
{
std::wcout <<
"Geometry block id: " << geometryBlock->
blockId() << std::endl;
for (
size_t stateIndex = 0; stateIndex < geometryBlock->
stateCount(); stateIndex++)
{
{
std::wcout <<
" Number of parts: " << geometryBlock->
partCount(geoIndex, stateIndex) << std::endl;
std::vector<int> blockIds = geometryBlock->
elementBlockIds(geoIndex, stateIndex);
std::wcout << " Number of blocks: " << blockIds.size() << std::endl;
std::wcout << " Element block ids: ";
for (std::vector<int>::iterator it = blockIds.begin(); it != blockIds.end(); ++it)
{
std::wcout << *it << " ";
}
std::wcout << std::endl;
}
}
}
std::wcout << "Number of geometry info blocks: " << numGeometryInfoBlocks << std::endl;
if (numGeometryInfoBlocks > 0)
{
std::wcout <<
"Geometry info block id: " << geometryInfoBlock->
blockId() << std::endl;
{
std::wcout <<
" Number of parts: " << geometryInfoBlock->
partCount(geoIndex) << std::endl;
for (
size_t k = 0; k < geometryInfoBlock->
partCount(geoIndex); k++)
{
std::wcout <<
" Part id: " << geometryInfoBlock->
partId(geoIndex, k) << std::endl;
std::wcout <<
" Part name: " << geometryInfoBlock->
partName(geoIndex, k).
c_str() << std::endl;
}
}
}
std::wcout << "Number of state info blocks: " << numStateInfoBlocks << std::endl;
for (size_t j = 0; j < numStateInfoBlocks; j++)
{
std::wcout <<
"State info block id: " << stateInfoBlock->
blockId() << std::endl;
std::wcout <<
" Number of states: " << stateInfoBlock->
stateCount() << std::endl;
for (
size_t k = 0; k < stateInfoBlock->
stateCount(); k++)
{
std::wcout <<
" State id: " << stateInfoBlock->
stateId(k) << std::endl;
std::wcout <<
" State name: " << stateInfoBlock->
stateName(k).
c_str() << std::endl;
std::wcout <<
" State reference value: " << stateInfoBlock->
stateReferenceValue(k) << std::endl;
std::wcout <<
" State name: " << stateInfoBlock->
stateName(k).
c_str() << std::endl;
}
}
std::wcout << "Number of transformation result blocks: " << numTransResultsBlocks << std::endl;
for (size_t j = 0; j < numTransResultsBlocks; j++)
{
std::wcout <<
"Transformation result block id: " << transResultBlock->
blockId() << std::endl;
std::wcout <<
" Result id: " << transResultBlock->
resultId() << std::endl;
std::wcout <<
" Result name: " << transResultBlock->
name().
c_str() << std::endl;
std::wcout <<
" Number of states: " << transResultBlock->
stateCount() << std::endl;
for (
size_t k = 0; k < transResultBlock->
stateCount(); k++)
{
std::wcout <<
" State id: " << transResultBlock->
stateId(k) << std::endl;
std::wcout << " Result values block ids: ";
for (std::vector<int>::iterator it = resultValuesBlocks.begin(); it != resultValuesBlocks.end(); ++it)
{
std::wcout << *it << " ";
}
std::wcout << std::endl;
}
}
std::wcout << "Number of transformation result values blocks: " << numTransResultValuesBlocks << std::endl;
for (size_t j = 0; j < numTransResultValuesBlocks; j++)
{
std::wcout <<
"Result values block id: " << resultValuesBlock->
blockId() << std::endl;
std::wcout << " Matrix values: ";
for (int row = 0; row < 4; ++row)
{
for (int col = 0; col < 4; col++)
{
std::wcout << matrix.
rowCol(row, col) <<
" ";
}
}
std::wcout << std::endl;
}
}
for (size_t i = 0; i < numFiles; i++)
{
}
std::wcout << std::endl;
{
return EXIT_FAILURE;
}
std::cout << std::endl << "Press enter to exit..." << std::endl;
std::cin.ignore();
return EXIT_SUCCESS;
}