Skip to content

Commit 07dbdf3

Browse files
committed
Support constrainting vertices to an IProjectionTarget in Remesher. Also handled an issue where we were not necessarily preserving topology of edge constraints (see can_collapse_constraints()).
Project-to-target-surface policy is now configrable, can be disabled, done as a post-process, or done inline. Added DoDebugChecks, disabled by default but if enabled will do verification of constraints after each operation.
1 parent 7434399 commit 07dbdf3

File tree

4 files changed

+283
-31
lines changed

4 files changed

+283
-31
lines changed

geometry3Sharp.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
<Compile Include="curve\Circle2.cs" />
5353
<Compile Include="curve\Ellipse2.cs" />
5454
<Compile Include="curve\NURBSCurve2.cs" />
55+
<Compile Include="distance\DistPoint2Circle2.cs" />
5556
<Compile Include="distance\DistPoint3Circle3.cs" />
5657
<Compile Include="implicit\ImplicitField.cs" />
5758
<Compile Include="implicit\ImplicitOperators.cs" />
@@ -88,6 +89,7 @@
8889
<Compile Include="math\Vector3d.cs" />
8990
<Compile Include="math\Vector3i.cs" />
9091
<Compile Include="math\Vector3f.cs" />
92+
<Compile Include="spatial\BasicProjectionTargets.cs" />
9193
<Compile Include="queries\Distance.cs" />
9294
<Compile Include="queries\MeshQueries.cs" />
9395
<Compile Include="queries\RayIntersection.cs" />
@@ -148,7 +150,6 @@
148150
<Compile Include="intersection\IntrRay3Box3.cs" />
149151
<Compile Include="shapes3\Circle3.cs" />
150152
<Compile Include="spatial\DMeshAABBTree.cs" />
151-
<Compile Include="spatial\MeshProjectionTarget.cs" />
152153
<Compile Include="spatial\SpatialInterfaces.cs" />
153154
</ItemGroup>
154155
<ItemGroup>

mesh/MeshConstraints.cs

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ public enum EdgeRefineFlags
1919
public struct EdgeConstraint
2020
{
2121
EdgeRefineFlags refineFlags;
22+
public IProjectionTarget Target; // edge is associated with this projection Target.
23+
// Currently only used as information, we do not explicitly
24+
// project edges onto targets (must also set VertexConstraint)
2225

2326

2427
public EdgeConstraint(EdgeRefineFlags rflags)
2528
{
2629
refineFlags = rflags;
30+
Target = null;
31+
}
32+
33+
public EdgeConstraint(EdgeRefineFlags rflags, IProjectionTarget target)
34+
{
35+
refineFlags = rflags;
36+
Target = target;
2737
}
2838

2939
public bool CanFlip {
@@ -39,6 +49,10 @@ public bool NoModifications {
3949
get { return (refineFlags & EdgeRefineFlags.FullyConstrained) == EdgeRefineFlags.FullyConstrained; }
4050
}
4151

52+
public bool IsUnconstrained {
53+
get { return refineFlags == EdgeRefineFlags.NoConstraint && Target == null; }
54+
}
55+
4256
static public readonly EdgeConstraint Unconstrained = new EdgeConstraint() { refineFlags = 0 };
4357
}
4458

@@ -49,15 +63,29 @@ public struct VertexConstraint
4963
public bool Fixed;
5064
public int FixedSetID; // in Remesher, we can allow two Fixed vertices with
5165
// same FixedSetID to be collapsed together
66+
67+
public IProjectionTarget Target; // vertex is constrained to lie on this projection Target.
68+
// Fixed and Target are mutually exclusive
5269

5370
public VertexConstraint(bool isFixed, int setID = InvalidSetID)
5471
{
5572
Fixed = isFixed;
5673
FixedSetID = setID;
74+
Target = null;
5775
}
5876

59-
public const int InvalidSetID = -1;
60-
static public readonly VertexConstraint Unconstrained = new VertexConstraint() { Fixed = false };
77+
public VertexConstraint(IProjectionTarget target)
78+
{
79+
Fixed = false;
80+
FixedSetID = InvalidSetID;
81+
Target = target;
82+
}
83+
84+
public const int InvalidSetID = -1; // clients should interpret negative values as invalid
85+
// (in case you wanted to use negative values for something else...)
86+
87+
static public readonly VertexConstraint Unconstrained = new VertexConstraint()
88+
{ Fixed = false, FixedSetID = InvalidSetID, Target = null };
6189
}
6290

6391

@@ -119,5 +147,11 @@ public void ClearVertexConstraint(int vid)
119147
}
120148

121149

150+
public System.Collections.IEnumerable VertexConstraintsItr() {
151+
foreach (KeyValuePair<int,VertexConstraint> v in Vertices)
152+
yield return v;
153+
}
154+
155+
122156
}
123157
}

0 commit comments

Comments
 (0)