示例#1
0
void execComm () {
    char comm[5];
    int i;
    char ch;
    for (i = 0; i < 5; i++) {
        ch = bufferReader();
        comm[i] = ch;
    }
    if (bufferReader() == ']') {
        if (!strcmp(comm, "NEWLN")) {
            printf("\n");
            linepos=0;
        }
        else if (!strcmp(comm, "DELAY")) {
            sleep(1);
        }
        else if (!strcmp(comm, "DBNLN")) {
            printf("\n\n");
            linepos = 0;
        }
        else if (!strcmp(comm, "INDNT")) {
            printf("\n     ");
            linepos = 5;
        }
        else {
            printf("\nError: unrecognized command\n");
        }
    }
}
示例#2
0
int PCLKernel::execute()
{
    PointTable table;

    Stage& readerStage(makeReader(m_inputFile, ""));

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr input_view = *viewSetIn.begin();
    std::shared_ptr<BufferReader> bufferReader(new BufferReader);
    bufferReader->addView(input_view);

    Options filterOptions({"filename", m_pclFile});
    Stage& pclStage = makeFilter("filters.pclblock", *bufferReader,
        filterOptions);

    // the PCLBlock stage consumes the BufferReader rather than the
    // readerStage

    Options writerOptions;
    if (m_bCompress)
        writerOptions.add<bool>("compression", true);
    if (m_bForwardMetadata)
        writerOptions.add("forward_metadata", true);

    Stage& writer(makeWriter(m_outputFile, pclStage, "", writerOptions));

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
示例#3
0
void * controller(void * arg)
{
    char ch;
    int j;

    char command[7];

    while(1) {
        if (linepos == 30) {
            printf("\n");
            linepos = 0;
        }
        ch = bufferReader();
        if (ch!=EOF)
            displayText(ch);
        else
            break;
    }
    return 0;
}
示例#4
0
int SmoothKernel::execute()
{
    PointTable table;

    Options readerOptions;
    readerOptions.add("filename", m_inputFile);
    setCommonOptions(readerOptions);

    Stage& readerStage(Kernel::makeReader(m_inputFile));
    readerStage.setOptions(readerOptions);

    // go ahead and prepare/execute on reader stage only to grab input
    // PointViewSet, this makes the input PointView available to both the
    // processing pipeline and the visualizer
    readerStage.prepare(table);
    PointViewSet viewSetIn = readerStage.execute(table);

    // the input PointViewSet will be used to populate a BufferReader that is
    // consumed by the processing pipeline
    PointViewPtr input_view = *viewSetIn.begin();
    std::shared_ptr<BufferReader> bufferReader(new BufferReader);
    bufferReader->setOptions(readerOptions);
    bufferReader->addView(input_view);

    Options smoothOptions;
    std::ostringstream ss;
    ss << "{";
    ss << "  \"pipeline\": {";
    ss << "    \"filters\": [{";
    ss << "      \"name\": \"MovingLeastSquares\"";
    ss << "      }]";
    ss << "    }";
    ss << "}";
    std::string json = ss.str();
    smoothOptions.add("json", json);
    smoothOptions.add("debug", isDebug());
    smoothOptions.add("verbose", getVerboseLevel());

    auto& smoothStage = createStage("filters.pclblock");
    smoothStage.setOptions(smoothOptions);
    smoothStage.setInput(*bufferReader);

    Options writerOptions;
    writerOptions.add("filename", m_outputFile);
    setCommonOptions(writerOptions);

    Stage& writer(Kernel::makeWriter(m_outputFile, smoothStage));
    writer.setOptions(writerOptions);

    writer.prepare(table);

    // process the data, grabbing the PointViewSet for visualization of the
    // resulting PointView
    PointViewSet viewSetOut = writer.execute(table);

    if (isVisualize())
        visualize(*viewSetOut.begin());
    //visualize(*viewSetIn.begin(), *viewSetOut.begin());

    return 0;
}
示例#5
0
//------------------------------------------------------------------------------------------------
// Name:  obtainSourceGeometry
// Desc:  Loads the geometry held by this class into the destination set
//------------------------------------------------------------------------------------------------
bool PackMesh::obtainSourceGeometry(LPDIRECT3DDEVICE9 pd3dDevice, SubsetGeometry* subsetGeometry) const
{
    // Fail without a device or if something is wrong with the output pointer
    if (APP_ERROR(!pd3dDevice || !subsetGeometry)("Invalid parameter to obtainSourceGeometry"))
        return false;

    // Get the pack from which to load this mesh
    dc::dcTable<ResourcePack>::Element* packElement = ((PackMesh*)this)->myResourcePack.getReferencedResource();
    if (!packElement) return false;
    ResourcePack* pack = packElement->getImplementation();
    if (!pack) return false;

    // Obtain the mesh in the pack
    dcBuffer buffer;
    if (APP_ERROR(!pack->openResource(myResourceIndex.getValue(), &buffer))
        ("Failed to open image %i in pack file", myResourceIndex))
        return false;

    // Set up a buffer reader to scan data from the returned information
    dcBuffer::Reader bufferReader(&buffer);

    // Get the number of subsets in this mesh
    size_t subsets;
    if (!bufferReader.read(&subsets, sizeof(subsets))) return false;

    // Whether or not loading failed
    bool failed = false;

    // Load each of the subsets
    for (size_t s = 0; s < subsets; ++s)
    {
        // Stores subset information while it is being loaded
        Geometry* geometry = NULL;
        SubsetIndex subset;
        DWORD vertices, indices;

        // Read the subset index information and the geometry data from the file
        if (APP_ERROR(!bufferReader.read(&subset, sizeof(subset)) ||
                       !bufferReader.read(&vertices, sizeof(vertices)) ||
                       !bufferReader.read(&indices, sizeof(indices)))
           ("Error while reading mesh data"))
        {
            // We were unable to load this mesh
            failed = true;

            // Exit the subset loop
            break;
        }

        // Create geometry for this mesh subset's data
       if (APP_FATAL(FAILED(AllocateGeometry(vertices, indices, &geometry)))
            ("Out of memory while allocating subset %i of %s (%i vertices/%i indices)",
              subset, getPathString().c_str(), vertices, indices))
       {
           // Couldn't load the mesh
           failed = true;
           
           // Exit this loop
           break;
       }

        // Load the geometry buffers
       if (APP_ERROR(!bufferReader.read(geometry->pVertices, sizeof(GeometryVertex) * vertices) ||
                      !bufferReader.read(geometry->pIndices, sizeof(GeometryIndex) * indices))
          ("Couldn't load geometry vertex/index data for subset %i of %s",
            subset, getPathString().c_str()))
       {
           // Unable to load
           failed = true;

           // Quit the loading process
           break;
       }

       // Add the data we just loaded as a mesh subset
       subsetGeometry->insert(SubsetGeometry::value_type(subset, geometry));
    }

    // If we failed, get rid of anything that managed to be loaded
    if (failed)
        DeallocateGeometry(subsetGeometry);

    // Return whether or not this operation succeeded
    return !failed;
}