Skip to content

Commit

Permalink
Merge pull request #37 from Matter-and-Form/feature/Import
Browse files Browse the repository at this point in the history
Feature/import
  • Loading branch information
drewsipher authored Jan 16, 2025
2 parents 42bf932 + 0c94390 commit 85330b5
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 0 deletions.
54 changes: 54 additions & 0 deletions MF/V3/Descriptors/Import.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
syntax = "proto3";

import "MF/V3/Descriptors/Project.proto";

package MF.V3.Descriptors;

// Import scan descriptor.
message Import
{
// Import error codes.
enum Error
{
// The error is unspecified.
Unspecified = 0;

// The file format is not supported.
FileNotSupported = 1;

// The file format is supported but cannot be read.
CannotReadFile = 2;

// The imported mesh has no faces.
MeshIsEmpty = 3;

// There is not enough filesystem memory to store the mesh.
NotEnoughStorage = 4;
}

// A file that was successfully imported to the project.
message Imported
{
// The file name.
string file = 1;
}

// A file that failed to be imported to the project.
message Ignored
{
// The file name.
string file = 1;

// The import error code.
Error error = 2;
}

// The list of successfully imported files.
repeated Imported imported = 1;

// The list of ignored files.
repeated Ignored ignored = 2;

// The updated project group tree.
Project.Group groups = 3;
}
38 changes: 38 additions & 0 deletions MF/V3/Settings/Import.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
syntax = "proto3";

package MF.V3.Settings;

// Import mesh settings.
message Import
{
// Unit of imported mesh positions.
enum Unit
{
// Mesh positions in millimeters.
Millimeter = 0;
// Mesh positions in centimeters.
Centimeter = 1;
// Mesh positions in meters.
Meter = 2;
// Mesh positions in inches.
Inch = 3;
// Mesh positions in feet.
Foot = 4;
}

// Optional name of the impored mesh. Ignored if the imported file is a zip archive, in which case the archive filenames are used.
optional string name = 1;

// Optional scale factor for mesh positions. Default is 1.0.
optional double scale = 2;

// Unit of imported mesh positions. Default is millimeters. Ignored if the scale is specified.
optional Unit unit = 3;

// If true the mesh is centered at the world origin. Default is true.
optional bool center = 4;

// Project group index in which to add the imported meshes. Default is 0 (root group).
optional int32 groupIndex = 5;
}

106 changes: 106 additions & 0 deletions MF/V3/Tasks/Import.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
syntax = "proto3";

import "MF/V3/Task.proto";
import "MF/V3/Settings/Import.proto";

package MF.V3.Tasks;

/**
* Import a set of 3D meshes to the current open project. The meshes must be archived in a ZIP file. Supported formats are DAE, FBX, GLB, OBJ, PLY and STL.
*
* > Request example:
*
* ```json
* {
* "Task":{
* "Index":1,
* "Type":"Import",
* "Input":{"unit":"Inch"}
* }
* }
* ```
*
* > Buffer message from client.
*
* ```json
* {
* "Buffer":{
* "Index":0,
* "Size":1052,
* "Task":{
* "Index":1,
* "Type":"Import",
* "Input":{"unit":"Inch"}
* }
* }
* }
* ```
*
* > Binary data transfer from client: The mesh zip file [1052 bytes].
* > Response example:
*
* ```json
* {
* "Task":{
* "Index":1,
* "Type":"Import",
* "Input":{"unit":"Inch"},
* "Output":{
* "groups":[{"index":1,"name":"box","scan":1}],
* "imported":[{"file":"mesh.ply"}],
* "ignored":[],
* },
* "State":"Completed"
* }
* }
* ```
*/
message Import
{

// Client request for the `Import` task.
message Request
{
// A unique identifier generated by the client.
int32 Index = 1;

// "Import"
string Type = 2;

// Import settings.
optional Settings.Import Input = 3;
}

// Server response for the `Import` task.
message Response
{
// The unique identifier generated by the client.
int32 Index = 1;

// "Import"
string Type = 2;

// Requested export settings.
optional Settings.Import Input = 3;

// The current state of the task.
optional TaskState State = 4;

// A string describing the error if the task has failed.
optional string Error = 5;
}

// Client buffer message for the `Import` task.
message Buffer
{
// The zero-based index identifying the data buffer.
int32 Index = 1;

// The size of the incoming data buffer in bytes.
uint64 Size = 2;

// The requested Import task.
Task Task = 3;
}

}
4 changes: 4 additions & 0 deletions MF/V3/Three.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import "MF/V3/Tasks/HasCameras.proto";
import "MF/V3/Tasks/HasProjector.proto";
import "MF/V3/Tasks/HasTurntable.proto";
import "MF/V3/Tasks/HeatMap.proto";
import "MF/V3/Tasks/Import.proto";
import "MF/V3/Tasks/ListExportFormats.proto";
import "MF/V3/Tasks/ListGroups.proto";
import "MF/V3/Tasks/ListNetworkInterfaces.proto";
Expand Down Expand Up @@ -166,6 +167,9 @@ rpc MergeData(Tasks.MergeData.Request) returns (Tasks.MergeData.Response);
// Add a merged scan to the current project.
rpc AddMergeToProject(Tasks.AddMergeToProject.Request) returns (Tasks.AddMergeToProject.Response);

// Import a set of 3D meshes to the current open project. The meshes must be archived in a ZIP file.
rpc Import(Tasks.Import.Request) returns (Tasks.Import.Response);

// List all export formats.
rpc ListExportFormats(Tasks.ListExportFormats.Request) returns (Tasks.ListExportFormats.Response);

Expand Down

0 comments on commit 85330b5

Please sign in to comment.