Gocator Development Kit
 All Classes Files Functions Variables Typedefs Friends Modules Pages
Data and Generic Outputs

A tool can also output data such as profiles, surfaces, as well as generic data that can then be selected as stream inputs for other tools.

These can be copied from the input streams, modified versions of them, or even created from scratch.

Defining Outputs

To define either a profile or surface as an tool output, use GdkToolInfo_AddOutput with the respective output type:

  • GDK_DATA_TYPE_UNIFORM_PROFILE
  • GDK_DATA_TYPE_PROFILE_POINT_CLOUD
  • GDK_DATA_TYPE_UNIFORM_SURFACE
  • GDK_DATA_TYPE_SURFACE_POINT_CLOUD
  • GDK_DATA_TYPE_MESH

In addition, they can be configured to include intensity data using GdkToolDataOutputInfo_SetHasIntensity.

Profiles are represented as GvProfileMsg classes while surfaces use the GvSurfaceMsg class. During tool processing, the respective class objects can be retrieved using:

  • GdkToolOutput_InitProfileAt
  • GdkToolOutput_InitSurfaceAt
  • GdkToolOutput_InitRawSurfaceAt

To retrieve the index of a data output, GdkTool_ToolDataOutputIndexByType method should be used. Once a class object is retrieved, its member functions can be utilized to populate profile/surface data and other related data such as intensity. Attributes of the object such as the scale and offset can also be set or updated before being sent out.

GdkFx(kStatus) GdkTestTool_VProcess(GdkTestTool tool, GdkToolInput input, GdkToolOutput output)
{
GdkTestPeakToolClass* obj = GdkTestTool_Cast_(tool);
kSize profilePointsCount = GdkProfileInput_Count(item);
GvProfileMsg profileMsg=kNULL;
kTest(GdkToolOutput_InitProfileAt(output, obj->dataoutputIndexProfile, profilePointsCount, &profileMsg));
if (!kIsNull(profileMsg))
{
kSize i;
// create array for profile data and copy data from input profile
kTest(kArray1_Construct(&dataArrayA, kTypeOf(k16s), profilePointsCount, kObject_Alloc(tool)));
// copy profile data to array
for (i = 0; i < profilePointsCount; i++)
{
dataItem = dataItems[i];
kTest(kArray1_SetItem(dataArrayA, i, &dataItem));
}
// set the updated profile array to the output profile message object
// to be sent out by the GDK framework
kTest(GvProfileMsg_SetPointsArray(profileMsg1, dataArrayA));
}
return kOK;
}

Defining Generic Outputs

Generic data output is added using GdkToolInfo_AddOutput with the output type value ranging from GDK_DATA_TYPE_GENERIC_BASE to GDK_DATA_TYPE_GENERIC_END. This allows up to 2147483648 generic data types to be uniquely identified.

There are two ways generic data can be represented: as a kObject type and as a kByte buffer. Similar to profiles and surfaces, generic data is represented as a GvGenericMsg class. During tool processing, the generic class objects can be retrieved using GdkToolOutput_InitGenericAt where the generic data type (kObject or kByte buffer) is specified as one the parameters passed to the function. Because generic outputs are handled by the framework similar to tool data outputs, GdkTool_ToolDataOutputIndexByType method is used to retrieve the appropriate index.

Once a class object is retrieved, its member functions can be utilized to populate the generic data object.

GdkFx(kStatus) GdkTestTool_VProcess(GdkTestTool tool, GdkToolInput input, GdkToolOutput output)
{
GdkTestPeakToolClass* obj = GdkTestTool_Cast_(tool);
GvGenericMsg genericMsg = kNULL;
// retrieve generic output object of type kByte buffer
kTest(GdkToolOutput_InitGenericAt(output, obj->dataoutputIndexGeneric1, kFALSE, 16, &profileMsg));
if (!kIsNull(genericMsg))
{
kByte i;
kByte* data = (kByte*) GvGenericMsg_Buffer(generalMsg);
// generic kByte buffer elements will contain values that are the index of the buffer
for (i = 0; i < 16; i++)
{
data[i] = (kByte) i;
}
}
return kOK;
}

Data Regions

By default data outputs from a tool inherit the region of the input to the tool. There are situations where a developer may want to use a different region. This can be done by overriding the function GdkTool_VCalcDataOutputRegionInstanced. Note that this is called every time the sensor configuration is changed but not on every data scan so the updated region must be able to accomodate for the possible data outputs generated during multiple scan cycles.

In the example below, a surface output has its region set such that the length is equal to the width. If the function does not explicitly set the region, the region remains the default.

GdkFx(kStatus) GdkTestTool_VCalcDataOutputRegionInstanced(GdkTestTool tool, GdkToolDataOutputCfg outputConfig, GdkRegion3d64f* region)
{
const kChar* dataOutputType = GdkToolDataOutputCfg_Type(outputConfig);
GdkSensorInfo sensorInfo;
GdkToolCfg toolConfig;
GdkDataInfo dataInfo;
sensorInfo = GdkTool_SensorInfo(tool);
toolConfig = GdkTool_Config(tool);
dataInfo = GdkSensorInfo_DataSource(sensorInfo, GdkToolCfg_Source(toolConfig));
kCheck(dataInfo != kNULL);
if (kStrEquals(dataOutputType, "SurfaceOutput"))
{
// The output has the same length as the width.
region->y = 0;
region->length = GdkDataInfo_Region(dataInfo)->width;
}
return kOK;
}