Importing XYZ file and creating RCP file

Importing XYZ file and creating RCP file

mertyWFD7H
Participant Participant
1,767 Views
4 Replies
Message 1 of 5

Importing XYZ file and creating RCP file

mertyWFD7H
Participant
Participant

Hi. I am a total beginner in both C++ and ReCap SDK.

 

I want to create the most basic program that imports an XYZ file and creates an RCP file.

 

I thought that I could use the "Creating from Raw Scans" example in the documentation.

void importCallback(const RCIOStatus& status)
{
    wprintf(L"Total Progress: %d%%\n", status.getTotalProgress());
}

void completionCallback(RCCode errCode, const RCBuffer<RCScanImportStatus>&)
{
    // do something
}

int main()
{
    std::cout << "Starting...:\n";

    RCImportFilesSettings importSettings;

    const RCString outputRcpFilePath = L"C:\\Test\\";
    RCProjectImporter importer(outputRcpFilePath);

    RCBuffer<RCString> inputFiles;
    inputFiles.append(L"C:\\Test\\cloud.xyz");

    importer.importFiles(inputFiles, importSettings, importCallback, completionCallback);
    importer.waitTillFinished();

    string str;
    cin >> str;
}

With this code, I wasn't able to generate anything other than the empty support folder.

 

Any help would be appreciated. 🙂

Accepted solutions (2)
1,768 Views
4 Replies
Replies (4)
Message 2 of 5

yan.fu
Alumni
Alumni
Accepted solution

Hello @mertyWFD7H ,

 

Thank you for your interest in using ReCap SDK. 

* ReCap SDK doesn't provide xyz file format CCK by default. So you need to implement a .xyz file CCK to support .xyz file import. 

 

class  ASCIIParser : public IRCImportPluginFileParser
{
public:
ASCIIParser() = default;
virtual ~ASCIIParser() = default;

size_t getScanCount() const override;

//\brief: Get the descriptive metadata for the specified scan index.
DescriptiveScanMetadata getDescriptiveScanMetadata(const size_t index) const override;

//\brief: Get the statistical metadata for the specified scan index.
StatisticalScanMetadata getStatisticalScanMetadata(const size_t index) const override;

//\brief: Begin reading the scan at the specified index.
bool beginScan(const size_t index) override;

// Read the next point, returns true if succeed, returns false if it reaches the end of file
bool readNextPoint(PointNode& pointNode) override;

// Returns true if file opening is succeeded
bool openFile(const RCString& fileName) override;

// Returns whether the current subfile file is closed successfully
bool closeFile() override;

// Return the estimated points number. Returns 0 if don't need progress support.
long long getNumberOfPointsEstimate() override;
};

 

Alternatively, you can use RCProjectImportSession. With this class, you need to parse .xyz file and then add the points with RCProjectImportSession::addPointsToScan(). Sample code can be found from the document in ReCap SDK. 

 

Best Regards,

Yan

Message 3 of 5

mertyWFD7H
Participant
Participant

Hi @yan.fu 

 

Thank you very much for your explanation and code example. These will help me a lot. 🙂

Message 4 of 5

martin.graner
Contributor
Contributor
Accepted solution

@mertyWFD7H 

I'd like to point out an alternative:

 

Use the RCP Generater sample, and import the data into the memory yourself:

Import the data:

https://www.cplusplus.com/doc/tutorial/files/

 

And then split the strings by finding the whitespace or tab and depending on the amount of columns you can set the data (3 columns -> XYZ; 4 columns XYZ + intensity; 6 columns XYZ + color; 7 columns XYZ + intensity + color).

 

Then you can hand it over to the written functions.

Message 5 of 5

mertyWFD7H
Participant
Participant

Hi @martin.graner 

 

Thank you very much for your help. I will try your method as well.