diff --git a/Documentation~/manual/advanced/input-validation.md b/Documentation~/manual/advanced/input-validation.md index 7b5dc0b..388e410 100644 --- a/Documentation~/manual/advanced/input-validation.md +++ b/Documentation~/manual/advanced/input-validation.md @@ -1,18 +1,24 @@ # Input validation -If [`ValidateInput`][validate] is set to true, the provided data will be validated before running the triangulation procedure. Input positions, as well as input constraints, have several restrictions: - -- Points count must be greater/equal 3. -- Points positions cannot be duplicated. -- Points cannot contain NaNs or infinities. -- Constraint edges cannot intersect with each other. -- Constraint edges cannot be duplicated or swapped duplicated. -- Zero-length constraint edges are forbidden. -- Constraint edges cannot intersect with points other than the points for which they are defined. -- [`IgnoreConstraintForPlantingSeeds`][ignore-constraint] must have a length equal to half the length of [ConstraintEdges][constraints]. -- If [`IgnoreConstraintForPlantingSeeds`][ignore-constraint] is provided, [`ConstraintEdges`][constraints] must also be provided. - -If any of these conditions fail, triangulation will not be calculated. You can catch this as an error by using [`Status`][status] (native, can be used in jobs). +If [`ValidateInput`][validate] set to true, the provided [`InputData`][input-data] and [`TriangulationSettings`][settings] will be validated before executing the triangulation procedure. +The input + [`InputData.Positions`][positions], + [`InputData.ConstraintEdges`][constraints], + [`InputData.HoleSeeds`][holes], + and [`InputData.IgnoreConstraintForPlantingSeeds`][ignore-constraint] have certain restrictions: + +- [Positions][positions] count must be greater or equal 3. +- [Positions][positions] and [HoleSeeds][holes] cannot contain NaNs or infinities. +- [Positions][positions] cannot be duplicated. +- [ConstraintEdges][constraints] should have length multiple of 2. +- [ConstraintEdges][constraints] should have constraints defined in [Positions][positions] range. +- [ConstraintEdges][constraints] cannot be duplicated, swapped duplicated, or create self-loop. +- [ConstraintEdges][constraints] cannot intersect with each other. +- [ConstraintEdges][constraints] cannot be collinear with positions which is not included in the constraint. +- [IgnoreConstraintForPlantingSeeds][ignore-constraint] must have a length equal to half the length of [ConstraintEdges][constraints]. + +If any of these conditions fail, triangulation will not be calculated. You can catch this as an error by using [`Status`][status-ref] (native reference, can be used in jobs). +For more details about error codes, refer to the [Status][status] API documentation. ```csharp using var triangulator = new Triangulator(Allocator.Persistent) @@ -32,6 +38,11 @@ var status = triangulator.Output.Status.Value; > Input validation can be expensive. If you are certain of your input, consider disabling this option for additional performance. [validate]: xref:andywiecko.BurstTriangulator.TriangulationSettings.ValidateInput -[status]: xref:andywiecko.BurstTriangulator.Status +[input-data]: xref:andywiecko.BurstTriangulator.InputData`1 +[settings]: xref:andywiecko.BurstTriangulator.TriangulationSettings +[positions]: xref:andywiecko.BurstTriangulator.InputData`1.Positions [constraints]: xref:andywiecko.BurstTriangulator.InputData`1.ConstraintEdges +[holes]: xref:andywiecko.BurstTriangulator.InputData`1.HoleSeeds [ignore-constraint]: xref:andywiecko.BurstTriangulator.InputData`1.IgnoreConstraintForPlantingSeeds +[status-ref]: xref:andywiecko.BurstTriangulator.OutputData`1.Status +[status]: xref:andywiecko.BurstTriangulator.Status diff --git a/Documentation~/manual/examples/index.md b/Documentation~/manual/examples/index.md index 284e33f..77c6d8a 100644 --- a/Documentation~/manual/examples/index.md +++ b/Documentation~/manual/examples/index.md @@ -22,7 +22,7 @@ var triangles = triangulator.Output.Triangles; > If you want to call this within a jobs pipeline, schedule a job using [`triangulator.Schedule(dependencies)`][schedule]. > Click [**here**](xref:example-unity-jobs) to learn how to use triangulation within a jobs pipeline. -If triangulation fails for some reason, you can catch the information using [`Status`][status] +If triangulation fails for some reason, you can catch the information using [`Status`][status-ref] ```csharp status = triangulator.Output.Status.Value; @@ -32,6 +32,10 @@ if (status != Status.OK) // ERROR! } ``` +> [!WARNING] +> The [Status][status-ref] can be used to handle various error codes. +> For more information about other enum values, refer to the [API documentation][status]. + The result of the triangulation procedure will depend on the selected settings. There are a few settings for triangulation, which are briefly described in the [API documentation][settings]. Follow the articles in the manual to learn more about settings. @@ -43,4 +47,5 @@ In other examples, the following *cool* guitar was used as an input test case: [settings]: xref:andywiecko.BurstTriangulator.TriangulationSettings [run]: xref:andywiecko.BurstTriangulator.Triangulator.Run [schedule]: xref:andywiecko.BurstTriangulator.Triangulator.Schedule(Unity.Jobs.JobHandle) -[status]: xref:andywiecko.BurstTriangulator.OutputData`1.Status +[status-ref]: xref:andywiecko.BurstTriangulator.OutputData`1.Status +[status]: xref:andywiecko.BurstTriangulator.Status