Skip to content

geometry3Sharp #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 231 commits into
base: UnityPackage_Net4p5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
5d02972
PerVertexTransform variant for a submesh that has been appended to a …
rms80 Feb 8, 2018
6733b70
add quaternionf opreator==
rms80 Feb 8, 2018
3cb31d5
useful fns
rms80 Feb 9, 2018
3a98c9d
added box3d.Contains functions
rms80 Feb 11, 2018
618f512
delete-tris utilities
rms80 Feb 11, 2018
9d6d680
added DSubmesh3Set, for computing set of submeshes
rms80 Feb 12, 2018
b45313f
add support for other rootfinding modes
rms80 Feb 12, 2018
dc51a77
merge in changes from siggraph project
rms80 Feb 12, 2018
5ad4608
implement functionality so that surface curves extracted from MeshIso…
rms80 Feb 13, 2018
73a1b41
improve comment, remove unnecessary variable
rms80 Feb 13, 2018
71c6f77
added a bunch of functional implicit objects and operators - halfspac…
rms80 Feb 19, 2018
adfebec
implicits improvements
rms80 Feb 20, 2018
d27d10a
add per-object weighting to blends
rms80 Feb 20, 2018
e29be6a
add some gs colors
rms80 Feb 22, 2018
baf82c1
documentation updates, deprecated weird-api ToPlaneUV function
rms80 Feb 23, 2018
38b44ce
util functions
rms80 Feb 23, 2018
77815a9
add indexing operator to MeshNormals
rms80 Feb 26, 2018
64d7d61
handle null argument
rms80 Feb 27, 2018
f5f877f
add frame xforms to TransformSequence (can be replaced w/ rotate and …
rms80 Feb 27, 2018
475a351
comments and a few minor optimizations
rms80 Feb 28, 2018
f3ba841
this is better?
rms80 Feb 28, 2018
73bab15
added byte array conversions and byte array compress/decompress
rms80 Mar 2, 2018
fc56ebd
additional byte array conversions
rms80 Mar 2, 2018
11b16c1
avoid infinite loop in PolySimplification2. Polygon2d.SetVertices()
rms80 Mar 5, 2018
b00be7e
try to handle degenerate-geometry cases
rms80 Mar 5, 2018
f74e5a9
early-out if size is the same
rms80 Mar 6, 2018
fb14d57
StandardMeshWriter now allows client to override streams that are wri…
rms80 Mar 6, 2018
7a0d95f
util functions
rms80 Mar 8, 2018
d951d47
bounds utils
rms80 Mar 8, 2018
44af5ac
initial implementation
rms80 Mar 8, 2018
fd1865d
DMesh3.InsertVertex/InsertTriangle work now, and have "fast insert" m…
rms80 Mar 9, 2018
dd5ea3b
Merge branch 'mesh_insert'
rms80 Mar 9, 2018
8c90d17
added quaternion inverse-multiply functions
rms80 Mar 11, 2018
9042ec2
added ref variants of existing functions to Frame3f, AABB. Frame3f no…
rms80 Mar 11, 2018
50bb18a
added ref matrix-vector multiplies
rms80 Mar 11, 2018
7e39a20
minor performance things
rms80 Mar 11, 2018
bb16273
util function
rms80 Mar 13, 2018
dbb52fd
fix for https://github.com/gradientspace/geometry3Sharp/issues/42
rms80 Mar 22, 2018
d1437a8
comments
rms80 Mar 23, 2018
5f19b6f
added DMesh3.CompactMetric
rms80 Mar 24, 2018
3a75c31
in unity stream is not always flushed when closed !?!?
rms80 Mar 24, 2018
3efb5d9
handle degenerate case in polygon area
rms80 Mar 24, 2018
78a8636
yikes this function was totally wrong...
rms80 Mar 25, 2018
47500e5
added MeshTransforms.Scale that takes origin
rms80 Mar 25, 2018
ca363f3
comparison fix, minor additions
rms80 Mar 26, 2018
c9f69ac
transform sequence, per-vertex transforms
rms80 Mar 26, 2018
8370d23
added Vector4f. small memory optimizations.
rms80 Mar 29, 2018
fd44fe9
small utils
rms80 Mar 29, 2018
b4a808e
2D hash table for triangles, supports containment and range queries (…
rms80 Mar 29, 2018
b12e01a
use spatial data structure. ~100x speedup?
rms80 Mar 29, 2018
4e4d5d3
debug check for refcount limit, and test for it in dmesh splitedge
rms80 Mar 30, 2018
2be7780
make edge flip tolerance configurable in MeshRefinerBase
rms80 Mar 31, 2018
e5d4590
add constraint setup mode
rms80 Mar 31, 2018
2a53d67
bugfix
rms80 Mar 31, 2018
4270ff8
utility functions
rms80 Mar 31, 2018
afcc47e
Merge branch 'master' of https://github.com/gradientspace/geometry3Sharp
rms80 Mar 31, 2018
ba416bd
utilities, bugfix to dcurve3 returned by EdgeSpan.ToCurve
rms80 Apr 1, 2018
0793cc4
ExtractCurves can now optionally return eid lists for each span/loop,…
rms80 Apr 1, 2018
888bbfa
improve edge constraint transfer in Remesher
rms80 Apr 1, 2018
45b64a2
constraint util
rms80 Apr 1, 2018
1753e1c
bugfix for degenerate edges, fixes https://github.com/gradientspace/g…
rms80 Apr 1, 2018
dba186b
added FindNearestVertex
rms80 Apr 2, 2018
39b02e0
added dijkstra variant that computes until a specific node is frozen,…
rms80 Apr 2, 2018
457c898
rebuild loop and span from vertices
rms80 Apr 2, 2018
5eec147
utility fn, AddTrianglesMeshChange, and initialize variant for Remove…
rms80 Apr 2, 2018
c5cf0ad
make dvector enumerable
rms80 Apr 2, 2018
e77194a
add optional apply/revert actions
rms80 Apr 2, 2018
026281c
support for cancelling sdf and marching cubes calculations
rms80 Apr 2, 2018
ad20354
bugfix for binsgrid, try to use more sensible grid resolution for pro…
rms80 Apr 3, 2018
0dd0c0a
moved over from gsCore
rms80 Apr 3, 2018
9ac8f7b
handle a failure case in MeshBoundaryLoops for nested-bowtie-loops, s…
rms80 Apr 4, 2018
fab03e4
function to repair bowtie by duplicating vtx for each disjoint triang…
rms80 Apr 4, 2018
d3d6628
cutpastefix
rms80 Apr 4, 2018
a9cbd92
utility fns
rms80 Apr 4, 2018
5467244
detect an invalid case in DMesh3.MergeEdges
rms80 Apr 4, 2018
73d16cc
construct 3d curve from 2d polygon
rms80 Apr 5, 2018
4a23002
use tasks framework in unity when using dotnet 4.6
rms80 Apr 9, 2018
50ad627
triangle strip fn
rms80 Apr 9, 2018
f396244
TubeGenerator weighed UV mapping
sandord Mar 5, 2018
a0c5cee
utility fn, added some files to csproj
rms80 Apr 11, 2018
accb164
improvements
rms80 Apr 11, 2018
cdaea23
dcurve3 resampling that produces better 3D tube meshes, and tubegen c…
rms80 Apr 11, 2018
575181b
bugfixes
rms80 Apr 11, 2018
8c7ca53
utility bits
rms80 Apr 12, 2018
3181ae0
added spherical fibonacci point set implementation. Using in NormalHi…
rms80 Apr 12, 2018
17c6a7a
added option to enable/disable merging along the fill boundary. usefu…
rms80 Apr 12, 2018
46502e4
extended LaplacianMeshSmoother.RegionSmooth to optionally include add…
rms80 Apr 12, 2018
ac7003b
refactored this class so that it is possible to get access to the Mes…
rms80 Apr 12, 2018
cf1a33b
Improved handling of poke-face degeneracy cases. using small barycent…
rms80 Apr 12, 2018
7fa7a1d
explicitly track original mesh vertices that had a polycurve vertex s…
rms80 Apr 13, 2018
a26c012
utility functions
rms80 Apr 14, 2018
0c84997
added optional action to RegionOperator that allows caller to customi…
rms80 Apr 14, 2018
5392fb6
utility fns
rms80 Apr 14, 2018
3da5f6b
changed default behavior of remove tri/vtx to not preserve manifoldne…
rms80 Apr 14, 2018
e3ccdad
bugfix
rms80 Apr 14, 2018
717c98f
utility functions, etc
rms80 Apr 15, 2018
4e62f08
added static function that can be called w/o having to construct obj…
rms80 Apr 15, 2018
5f38b39
use new static function instead of per-iteration object
rms80 Apr 15, 2018
d9644d5
refactored ray/aabb and ray/obb so that intersection test is a static…
rms80 Apr 15, 2018
d197b3f
added OBB-tree for DCurve3. this is functional but has not been teste…
rms80 Apr 15, 2018
a06128b
custom static variant of ray/tri intersection specifically for DMeshA…
rms80 Apr 15, 2018
2115de7
tri/tri intersection optimizations. note that this may change behavio…
rms80 Apr 16, 2018
5fa10dc
yikes quite the typo...
rms80 Apr 16, 2018
b7d373a
quaterniond conversions
rms80 Apr 16, 2018
259ef01
yikes was updating spatial DS before points were moved!
rms80 Apr 16, 2018
c3cd9d5
extended DMesh3.SplitEdge to take t parameter. Usin in MeshInsertUVPo…
rms80 Apr 16, 2018
b58f8ad
bugfix for DCurve3, supported open curves in DCurveBoxTree, added to …
rms80 Apr 18, 2018
8fbed7f
utility bitses
rms80 Apr 18, 2018
874e061
dijkstra mode that terminates when an indicator function returns true…
rms80 Apr 18, 2018
0065c61
replace float.MaxValue usage w/ a constant. Don't update neighbour if…
rms80 Apr 18, 2018
7ae54a5
add vector3i accessor, expose some of the internal compute functions …
rms80 Apr 18, 2018
1da4284
integer tag utility struct
rms80 Apr 20, 2018
bd31d7d
polygon utilities
rms80 Apr 20, 2018
f597e82
added 2D dense float/int grids, extended 2D and 3D grids
rms80 Apr 22, 2018
ee9fa99
discretize implicit functions into dense grid
rms80 Apr 22, 2018
583dfe6
polygon utils
rms80 Apr 22, 2018
01f5ed4
very useful aabb function
rms80 Apr 23, 2018
89dcd9f
utility bits
rms80 Apr 24, 2018
307dfe4
optional flag to force return face normal
rms80 Apr 24, 2018
b6544b4
curve smoothing fn
rms80 Apr 24, 2018
2c69ccb
util functions
rms80 Apr 25, 2018
8c74495
Merge branch 'master' of https://github.com/gradientspace/geometry3Sharp
rms80 Apr 25, 2018
f7622ca
svg writer util
rms80 Apr 25, 2018
36ae0fb
added ModifyVerticesMeshChange
rms80 Apr 25, 2018
ecfcc2e
add triangles constructor to DijkstraGraphDistance, option to use hig…
rms80 Apr 26, 2018
5d97cc4
iterator
rms80 Apr 26, 2018
bff0f42
IsBoundaryLoop can now take a different mesh to check
rms80 May 9, 2018
f23639c
utility fn
rms80 May 10, 2018
c963d7b
added Matrix3d vector-product constructor. exposed members of DMeshAA…
rms80 May 11, 2018
9f03660
valid check
rms80 May 11, 2018
c3cbf65
buffer util functions
rms80 May 11, 2018
a7dfecd
xform normals in meshtransforms.rotate
rms80 May 16, 2018
4a59fcb
returns wrong value for very small inputs unless we clamp
rms80 May 19, 2018
2244af3
utility fn
rms80 May 20, 2018
0822bf9
don't add obviously degenerate edge
rms80 May 20, 2018
e569636
added ProgressCancel, use to allow cancellation of computation in Red…
rms80 May 22, 2018
d2a0063
sequence composition
rms80 May 22, 2018
a33e7bf
refactor point/tri distance calc so we can call statically. add IOrie…
rms80 May 23, 2018
d7912e9
add TransformedMeshProjectionTarget
rms80 May 23, 2018
64fd259
fix dotnet 3.5 compilation
rms80 May 25, 2018
16ae958
warning fixes
rms80 May 25, 2018
652ebcf
allocate
rms80 May 25, 2018
053728b
add DVector.copy, SetVerticesMeshChange
rms80 May 28, 2018
9da0198
catch a case in DMesh3.MergeEdges that would otherwise result in the …
rms80 May 30, 2018
d63ebb6
DMesh3.IsBowtieVertex did not properly handle some cases (eg two tetr…
rms80 May 30, 2018
929fb18
rest of loop is busted if we actually have no edges
rms80 May 30, 2018
4ae0035
Mesh.AppendTriangle can return multiple failure codes, InvalidID chec…
rms80 May 30, 2018
44e96b7
always use 64-bit
rms80 May 30, 2018
2fc389a
add comment
rms80 May 31, 2018
d386af2
modulo iteration util
rms80 May 31, 2018
b40112f
MeshEditor colors for box-append
rms80 Jun 1, 2018
c5817d4
util fn to erode open spurs from 3D graph
rms80 Jun 1, 2018
f40deca
color util fn
rms80 Jun 7, 2018
84a73cf
util fn
rms80 Jun 11, 2018
4a0c338
detect cases where fill boundary loop will be incompatible with input…
rms80 Jun 11, 2018
336f88d
add ImplicitShell3D impicit unary op op
rms80 Jun 11, 2018
7aa8d30
indexing util. maybe should be at a higher level because we need this…
rms80 Jun 11, 2018
aafff98
2D arc length parameterization/sampling of discretized open curve
rms80 Jun 12, 2018
78f9ac6
ray normalization
rms80 Jun 13, 2018
5bda8e1
bugfixes
rms80 Jun 15, 2018
a86dcc2
util fn
rms80 Jun 15, 2018
7310b01
improvements to DGraph2 processing utils
rms80 Jun 15, 2018
f654bd1
Merge branch 'master' of https://github.com/gradientspace/geometry3Sharp
rms80 Jun 15, 2018
c171e65
resolve duplicate fn
rms80 Jun 15, 2018
b714edf
improve FastCollapsePass
rms80 Jun 20, 2018
d8c5ebe
vertices at the ends of constrained spans should be pinned, right? ma…
rms80 Jun 21, 2018
cc01874
catch a case in mesh refinement constraints where we were allowing a …
rms80 Jun 21, 2018
7e6377b
asmdef file for unity
rms80 Jun 24, 2018
bd90bbe
minor changes to obj writing
rms80 Jun 25, 2018
5960868
mesh measurement util
rms80 Jun 26, 2018
627b255
added nary-intersect implicit op
rms80 Jun 27, 2018
a74c6b9
improve cancel support in SDF when we are calculating full grid
rms80 Jun 27, 2018
a635f8b
new implicit ops
rms80 Jun 27, 2018
f43c259
fix bounds for skeletal binary blends
rms80 Jun 28, 2018
3863b6e
nary ricci blend
rms80 Jun 28, 2018
18baf8f
unity update, early-out in MeshBoundaryLoops
rms80 Jun 30, 2018
a42c9b9
tiny ref optimizations
rms80 Jul 3, 2018
ccfa794
add support for using Spatial DS to compute mesh SDF. This is not *al…
rms80 Jul 3, 2018
1442651
profiling flag
rms80 Jul 3, 2018
c356b12
bound was too conservative
rms80 Jul 3, 2018
eedae10
aaahhh format strings were ignoring seconds, so timing was wrong if a…
rms80 Jul 4, 2018
5b5fb92
be able to query current priority. add inclusive-bounds util fn.
rms80 Jul 4, 2018
38ca32a
minor refactor bits, no functionality change
rms80 Jul 4, 2018
9967c56
add new floodfill compute mode that uses spatial data structure more …
rms80 Jul 4, 2018
6ab75f0
Merge branch 'master' of https://github.com/gradientspace/geometry3Sharp
rms80 Jul 4, 2018
54d0fa5
add MeshEditor.RemoveSmallComponents, MeshMeasurements.VolumeArea calc
rms80 Jul 5, 2018
996ca11
added MeshEditor.RemoveFinTriangles
rms80 Jul 6, 2018
2a587ca
catch cases where weights are invalid
rms80 Jul 6, 2018
c0bd535
add MeshEditor.RemoveUnusedVertices
rms80 Jul 6, 2018
a03ebf4
remove this function. was contributed by user but is not called in an…
rms80 Jul 6, 2018
d556dd2
minor bit
rms80 Jul 6, 2018
3324d8d
add optional filter function to RemoveFinTriangles
rms80 Jul 6, 2018
8dac710
modified filter func so it passes mesh as argument (hence no capture …
rms80 Jul 6, 2018
528552b
float variant
rms80 Jul 8, 2018
b0c6857
variant of bvtree.FindNearestTriangle that also returns the squared-d…
rms80 Jul 8, 2018
da164ab
use static function to get point/tri distance, instead of calling Tri…
rms80 Jul 8, 2018
d6debfb
bit of a hack, but useful
rms80 Jul 8, 2018
b3d79ac
util fin
rms80 Jul 20, 2018
ef53ec1
Merge branch 'master' of https://github.com/gradientspace/geometry3Sharp
rms80 Jul 20, 2018
79fb6b2
FaceGroupUtil.SeparateMeshByGroups now returns group IDs, also static…
rms80 Jul 20, 2018
d1e70fa
rewrite vertex-correspondence parts, handles partial-loop-merging bet…
rms80 Jul 25, 2018
0c9801f
added support for returning STL binary face attributes, and added doc…
rms80 Jul 26, 2018
ad50025
added SimpleStore utility class that makes it easy to read/write test…
rms80 Jul 26, 2018
3507332
allow MeshEditor.StitchUnorderedEdges to optionally return partial-su…
rms80 Jul 26, 2018
80fd3e0
provide feedback about partial extrude failures (in join stitching)
rms80 Jul 26, 2018
c589fdf
add MeshFaceSelection.RemoveBowties, removes bowtie vertices in selec…
rms80 Jul 26, 2018
7bff03d
add 2D bezier curve, laplacian curve deformer
rms80 Jul 29, 2018
4288537
update readme with new tutorials, new Core classes
rms80 Jul 30, 2018
c090125
minor improvement to insert uv-curve
rms80 Aug 4, 2018
932fde9
initial mesh fast winding number implementation
rms80 Sep 11, 2018
647a46d
add IPointSet.Timestamp, implement in other mesh/pointset classes
rms80 Sep 14, 2018
d07de12
aabb util fn, mesh one-ring area fn
rms80 Sep 14, 2018
73aa879
implementation of fast point winding number
rms80 Sep 14, 2018
19abdd7
circle util functions
rms80 Sep 17, 2018
39d3e8e
readme update
rms80 Sep 17, 2018
05c2776
util fns
rms80 Sep 17, 2018
aa4f55d
some minor optimizations to ray/aabb intersection, does make a differ…
rms80 Sep 25, 2018
b375ce5
utli fn
rms80 Oct 3, 2018
21665bb
utility function to try to improve vtx loop stitching
rms80 Nov 5, 2018
25649aa
util fn
rms80 Nov 7, 2018
838b040
improve failure for stitchloops, in case where one triangle works and…
rms80 Nov 13, 2018
fea8731
Add Polygon2d.Contains(Segment2d) method
gregmeess Nov 19, 2018
a6dd51d
Add additional methods for checking Segment2d
gregmeess Nov 20, 2018
d358f3e
Add comment summary strings.
gregmeess Nov 27, 2018
4b65c4b
Add Snapping methods for snapping high or low
gregmeess Jan 14, 2019
190c59f
Add .vs pattern to .gitignore
gregmeess Jan 14, 2019
539daf1
Add optional offset parameter to Snapping methodsw
gregmeess Jan 14, 2019
359238f
copied over files from gsGeometry and released under Boost License
rms80 Mar 7, 2019
2309a50
update readme
rms80 Mar 7, 2019
7982934
update nuget key
rms80 Mar 7, 2019
8f185f1
Update README.md
rms80 Dec 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Folders
.vs/

# Compiled Object files
*.slo
*.lo
Expand Down Expand Up @@ -32,4 +35,5 @@ geometry3Sharp/obj
geometry3Sharp.csproj.user
bin
obj
.vs
*.meta
75 changes: 65 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
# A Short Note about the future of geometry3Sharp

I have not been able to work on or maintain geometry3Sharp for the past few years, due to some restrictive employment-contract terms. Various forks now exist that have active maintainers, and I would recommend you consider switching to one of those. In particular I would recommend the geometry4Sharp fork being developed by New Wheel Technology (_who also does C# development consulting, if you are looking for that_):

https://github.com/NewWheelTech/geometry4Sharp

# geometry3Sharp

Open-Source (Boost-license) C# library for geometric computing.

geometry3Sharp only uses C# language features available in .NET 3.5, so it works with the Mono C# runtime used in Unity 5.x (*NOTE: you must configure Unity for this to work, see note at bottom of this file*).
geometry3Sharp is compatible with Unity. Set the G3_USING_UNITY Scripting Define and you will have transparent interop between g3 and Unity vector types (*see details at the very bottom of this README*). Although the library is written for C# 4.5, if you are using the .NET 3.5 Unity runtime, it will still work, just with a few missing features.

Currently there is a small amount of unsafe code, however this code is only used in a few fast-buffer-copy routines, which can be deleted if you need a safe version (eg for Unity web player).

[A Nuget Package is available](https://www.nuget.org/packages/geometry3Sharp). This package is updated roughly monthly from the github master branch. So, it's "more" stable. Currently this package includes .NET 4.5 and .NET Standard 2.0 dlls. If you would like others, please email and they can be added.

Questions? Contact Ryan Schmidt [@rms80](http://www.twitter.com/rms80) / [gradientspace](http://www.gradientspace.com)

# Projects using g3Sharp

* [Gradientspace Cotangent](https://www.cotangent.io/) - 3D printing and Mesh Repair/Modeling Tool
* [Nia Technologies NiaFit](https://niatech.org/technology/niafit/) - 3D-printed prosthetic and orthotic design
* [OrthoVR Project](https://orthovrproject.org/) - 3D-printed lower-leg prosthetic design in VR
* [Archform](https://www.archform.co/) - Clear Dental Aligner design/planning app
* [Your Project Here?]([email protected]) - *we are very excited to hear about your project!*


# Credits

Expand All @@ -23,10 +37,14 @@ The **MeshSignedDistanceGrid** class was implemented based on the C++ [SDFGen](h

Several tutorials for using g3Sharp have been posted on the Gradientspace blog:

- [Creating meshes, Mesh File I/O, Ray/Mesh Intersection and Nearest-Point](http://www.gradientspace.com/tutorials/2017/7/20/basic-mesh-creation-with-g3sharp)
- [Mesh Simplification with Reducer class](http://www.gradientspace.com/tutorials/2017/8/30/mesh-simplification)
- [Voxelization/Signed Distance Fields and Marching Cubes Remeshing](http://www.gradientspace.com/tutorials/2017/11/21/signed-distance-fields-tutorial)

- [Creating meshes, Mesh File I/O, Ray/Mesh Intersection and Nearest-Point](http://www.gradientspace.com/tutorials/2017/7/20/basic-mesh-creation-with-g3sharp) - Explains DMesh3 basics, StandardMeshReader, DMeshAABBTree3 ray and point queries and custom traversals
- [Mesh Simplification with Reducer class](http://www.gradientspace.com/tutorials/2017/8/30/mesh-simplification) - Reducer class, DMesh3.CheckValidity, MeshConstraints
- [Remeshing and Mesh Constraints](http://www.gradientspace.com/tutorials/2018/7/5/remeshing-and-constraints) - Remesher class, projection targets, MeshConstraints, Unity remeshing animations
- [Voxelization/Signed Distance Fields and Marching Cubes Remeshing](http://www.gradientspace.com/tutorials/2017/11/21/signed-distance-fields-tutorial) - MeshSignedDistanceGrid, MarchingCubes, DenseGridTrilinearImplicit, generating 3D lattices
- [3D Bitmaps, Minecraft Cubes, and Mesh Winding Numbers](http://www.gradientspace.com/tutorials/2017/12/14/3d-bitmaps-and-minecraft-meshes) - Bitmap3, VoxelSurfaceGenerator, DMeshAABBTree3 Mesh Winding Number,
- [Implicit Surface Modeling](http://www.gradientspace.com/tutorials/2018/2/20/implicit-surface-modeling) - Implicit primitives, voxel/levelset/functional booleans, offsets, and blending, lattice/lightweighting demo
- [DMesh3: A Dynamic Indexed Triangle Mesh](http://www.gradientspace.com/tutorials/dmesh3) - deep dive into the DMesh3 class's internal data structures and operations
- [Surfacing Point Sets with Fast Winding Numbers](http://www.gradientspace.com/tutorials/2018/9/14/point-set-fast-winding) - tutorial on the Fast Mesh/PointSet Winding Number, and how to use the g3Sharp implementation


# Main Classes
Expand All @@ -47,6 +65,13 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
- **IndexPriorityQueue**: min-heap priority queue for dense situations (ie small or large number of items in queue)
- **DijkstraGraphDistance**: compute shortest-path distances between nodes in graph, from seed points. Graph is defined externally by iterators and Func's, so this class can easily be applied to many situations.
- **SmallListSet**: efficient allocation of a large number of small lists, with initial fixed-size buffer and "spilling" into linked list.
- **BufferUtil**: utilities for working with arrays. Math on float/double arrays, automatic conversions, byte[] conversions, compression
- **FileSystemUtils**: utilities for filesystem stuff
- *g3Iterators*: IEnumerable utils **ConstantItr**, **RemapItr**, IList hacks **MappedList**, **IntSequence**
- **HashUtil**: **HashBuilder** util for constructing FNV hashes of g3 types
- **MemoryPool**: basic object pool
- *ProfileUtil*: code profiling utility **LocalProfiler** supports multiple timers, accumulating, etc
- *SafeCollections*: **SafeListBuilder** multi-threaded List construction and operator-apply

## Math

Expand Down Expand Up @@ -164,6 +189,10 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
- vertices can be pinned to fixed positions
- vertices can be constrained to an IProjectionTarget - eg 3D polylines, smooth curves, surfaces, etc
- **MeshConstraintUtil** constructs common constraint situations
- **RemesherPro**: extension of Remesher that can remesh much more quickly
- FastestRemesh() uses active-set queue to converge, instead of fixed full-mesh passes
- SharpEdgeReprojectionRemesh() tries to remesh while aligning triangle face normals to the projection target, in an attempt to preserve sharp edges
- FastSplitIteration() quickly splits edges to increase available vertex resolution
- **RegionRemesher**: applies *Remesher* to sub-region of a *DMesh3*, via *DSubmesh3*
- boundary of sub-region automatically preserved
- *BackPropropagate()* function integrates submesh back into input mesh
Expand Down Expand Up @@ -202,8 +231,10 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
- **TubeGenerator**: polygon swept along polyline
- **Curve3Axis3RevolveGenerator**: 3D polyline revolved around 3D axis
- **Curve3Curve3RevolveGenerator**: 3D polyline revolved around 3D polyline (!)
- **TriangulatedPolygonGenerator**: triangulate 2D polygon-with-holes
- **VoxelSurfaceGenerator**: generates minecraft-y voxel mesh surface
- **MarchingCubes**: multi-threaded triangulation of implicit functions / scalar fields
- **MarchingCubesPro**: continuation-method approach to marching cubes that explores isosurface from seed points (more efficient but may miss things if seed points are insufficient)


## Mesh Selections
Expand All @@ -230,24 +261,44 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
- **MeshExtrudeMesh**: extrude all faces of mesh and stitch boundaries w/ triangle strips
- **MeshICP**: basic iterative-closest-point alignment to target surface
- **MeshInsertUVPolyCurve**: insert a 2D polyline (optionally closed) into a 2D mesh
- **MeshInsertPolygon**: insert a 2D polygon-with-holes into a 2D mesh and return set of triangles "inside" polygon
- **MeshInsertProjectedPolygon**: variant of MeshInsertPolygon that inserts 2D polygon onto 3D mesh surface via projection plane
- **MeshIterativeSmooth**: standard iterative vertex-laplacian smoothing with uniform, cotan, mean-value weights
- **MeshLocalParam**: calculate Discrete Exponential Map uv-coords around a point on mesh
- **MeshLoopClosure**: cap open region of mesh with a plane
- **MeshLoopSmooth**: smooth an embedded *EdgeLoop* of a mesh
- **MeshPlaneCut**: cut a mesh with a plane, return new **EdgeLoop**s and **EdgeSpans**, and optionally fill holes
- **RegionOperator**: support class that makes it easy to extract a submesh and safely re-integrate it back into base mesh. IE like RegionRemesher, but you can do arbitrary changes to the submesh (as long as you preserve boundary).
- **SimpleHoleFiller**: topological filling of an open boundary edge loop. No attempt to preserve shape whatsoever!
- **MeshStitchLoops**: Stitch together two edge loops without any constraint that they have the same vertex count
- **MeshTrimLoop**: trim mesh with 3D polyline curve lying on mesh faces (approximately)
- **MeshIsoCurve**: compute piecewise-linear iso-curves of a function on a mesh, as a **DGraph3**
- **MeshTopology**: Extract mesh sharp-edge-path topology based on crease angle
- **MeshAssembly**: Decompose mesh into submeshes based on connected solids and open patches
- **MeshSpatialSort**: sorts set of mesh components into "solids" (each solid is outer mesh and contained cavity meshes)
- **MeshMeshCut**: Cut one mesh with another, and optionally remove contained regions
- **MeshBoolean**: Apply **MeshMeshCut** to each of a pair of meshes, and then try to resample cut boundaries so they have same vertices. **This is not a robust mesh boolean!**
- **SimpleHoleFiller**: topological filling of an open boundary edge loop. No attempt to preserve shape whatsoever!
- **SmoothedHoleFill**: fill hole in mesh smoothly, ie with (approximate) boundary tangent continuity
- **MinimalHoleFill**: construct "minimal" fill that is often developable (recovers sharp edges well)
- **PlanarHoleFiller**: fill planar holes in mesh by mapping to 2D, handles nested holes (eg from plane cut through torus)
- **PlanarSpansFiller**: try to fill disconnected set of planar spans, by chaining them (WIP)
- **MeshRepairOrientation**: make triangle winding order consistent across mesh connected components (if possible), and then assign global orientation via spatial sorting/nesting
- **MergeCoincidentEdges**: weld coincident open boundary edges of mesh (more robust than weld vertices!)
- **RemoveDuplicateTriangles**: remove duplicate triangles of mesh
- **RemoteOccludedTriangles**: remove triangles that are "occluded" under various definitions
- **MeshAutoRepair**: apply many of the above algorithms in an attempt to automatically "repair" an input mesh, where "repaired" means the mesh is closed and manifold.


## Spatial Data Structures

- **DMeshAABBTree**: triangle mesh axis-aligned bounding box tree
- **DMeshAABBTree3**: triangle mesh axis-aligned bounding box tree
- bottom-up construction using mesh topology to accelerate leaf node layer
- generic traversal interface DoTraversal(TreeTraversal)
- Queries for NearestTriangle(point), FindNearestHitTriangle(ray) and FindAllHitTriangles(ray)
- TestIntersection(triangle), TestIntersection(other_tree), FindIntersections(other_tree)
- IsInside(point)
- FindNearestTriangle(point), FindNearestHitTriangle(ray) and FindAllHitTriangles(ray), FindNearestVertex(point)
- FindNearestTriangles(other_tree)
- TestIntersection(triangle), TestIntersection(other_tree), FindAllIntersections(other_tree)
- IsInside(point), WindingNumber(point), FastWindingNumber(point)
- **PointAABBTree3**: point variant of DMeshAABBTree3, with PointSet Fast Winding Number
- **Polygon2dBoxTree**: 2D segment bbox-tree, distance query
- **PointHashGrid2d**, **SegmentHashGrid2d**: hash tables for 2D geometry elements
- **PointHashGrid3d**: hash tables for 3D geometry elements
Expand All @@ -256,6 +307,9 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:
- **Bitmap3**: 3D dense bitmap
- **BiGrid3**: two-level DSparseGrid3
- **MeshSignedDistanceGrid**: 3D fast-marching construction of narrow-band level set / voxel-distance-field for mesh
- **MeshScalarSamplingGrid**: Samples scalar function on 3D grid. Can sample full grid or narrow band around specific iso-contour
- **MeshWindingNumberGrid**: MeshScalarSamplingGrid variant specifically for computing narrow-band Mesh Winding Number field on meshes with holes (finds narrow-band in hole regions via flood-fill)
- **CachingMeshSDF**: variant of MeshSignedDistanceGrid that does lazy evaluation of distances (eg for use with continuation-method MarchingCubesPro)
- **IProjectionTarget** implementations for DCurve3, DMesh3, Plane3, Circle3d, Cylinder3d, etc, for use w/ reprojection in Remesher and other algorithms
- **IIntersectionTarget** implementations for DMesh3, transformed DMesh3, Plane3

Expand Down Expand Up @@ -302,6 +356,7 @@ Several tutorials for using g3Sharp have been posted on the Gradientspace blog:

- **Cylinder3d**
- **DenseGridTrilinearImplicit**: trilinear interpolant of 3D grid
- **CachingDenseGridTrilinearImplicit**: variant of DenseGridTrilinearImplicit that does lazy evaluation of grid values based on an implicit function


## I/O
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ deploy:
provider: NuGet
# server: # remove to push to NuGet.org
api_key:
secure: NwCvdkjy/Jpu+Cev4PeXnCdyEtf5F5O4bDtBoXisEKkez6R+U5Wk12hdHNa1NTFT
secure: DIcqDc7g8mWxhl3/G0MxoGVSnRJzdMvPZdJM7NbYjuy1tFhcF8hWA+nNoGntESX7
on:
appveyor_repo_tag: true
skip_symbols: false
Expand Down
11 changes: 10 additions & 1 deletion color/Colorf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public void Subtract(Colorf o)
{
r -= o.r; g -= o.g; b -= o.b; a -= o.a;
}

public Colorf WithAlpha(float newAlpha)
{
return new Colorf(r, g, b, newAlpha);
}


public static Colorf operator -(Colorf v)
Expand Down Expand Up @@ -222,6 +225,12 @@ public string ToString(string fmt)



// default colors
static readonly public Colorf StandardBeige = new Colorf(0.75f, 0.75f, 0.5f);
static readonly public Colorf SelectionGold = new Colorf(1.0f, 0.6f, 0.05f);
static readonly public Colorf PivotYellow = new Colorf(1.0f, 1.0f, 0.05f);



// allow conversion to/from Vector3f
public static implicit operator Vector3f(Colorf c)
Expand Down
2 changes: 1 addition & 1 deletion comp_geom/GraphCells2d.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void FindCells()

int start_vid = idx.a;
int wid = idx.b;
int e0 = wedges[start_vid][wid].a;
int e0 = wedges[start_vid][wid].a; e0 = e0+1-1; // get rid of unused variable warning, want to keep this for debugging
int e1 = wedges[start_vid][wid].b;

loopv.Clear();
Expand Down
129 changes: 129 additions & 0 deletions comp_geom/SphericalFibonacciPointSet.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace g3
{
/// <summary>
/// A Spherical Fibonacci Point Set is a set of points that are roughly evenly distributed on
/// a sphere. Basically the points lie on a spiral, see pdf below.
/// The i-th SF point of an N-point set can be calculated directly.
/// For a given (normalized) point P, finding the nearest SF point (ie mapping back to i)
/// can be done in constant time.
///
/// math from http://lgdv.cs.fau.de/uploads/publications/spherical_fibonacci_mapping_opt.pdf
/// </summary>
public class SphericalFibonacciPointSet
{
public int N = 64;

public SphericalFibonacciPointSet(int n = 64) {
N = n;
}


public int Count { get { return N; } }


/// <summary>
/// Compute i'th spherical point
/// </summary>
public Vector3d Point(int i)
{
Util.gDevAssert(i < N);
double div = (double)i / PHI;
double phi = MathUtil.TwoPI * (div - Math.Floor(div));
double cos_phi = Math.Cos(phi), sin_phi = Math.Sin(phi);

double z = 1.0 - (2.0 * (double)i + 1.0) / (double)N;
double theta = Math.Acos(z);
double sin_theta = Math.Sin(theta);

return new Vector3d(cos_phi * sin_theta, sin_phi * sin_theta, z);
}
public Vector3d this[int i] {
get { return Point(i); }
}


/// <summary>
/// Find index of nearest point-set point for input arbitrary point
/// </summary>
public int NearestPoint(Vector3d p, bool bIsNormalized = false)
{
if (bIsNormalized)
return inverseSF(ref p);
p.Normalize();
return inverseSF(ref p);
}




static readonly double PHI = (Math.Sqrt(5.0) + 1.0) / 2.0;

double madfrac(double a, double b)
{
//#define madfrac(A,B) mad((A),(B),-floor((A)*(B)))
return a * b + -Math.Floor(a * b);
}

/// <summary>
/// This computes mapping from p to i. Note that the code in the original PDF is HLSL shader code.
/// I have ported here to comparable C# functions. *However* the PDF also explains some assumptions
/// made about what certain operators return in different cases (particularly NaN handling).
/// I have not yet tested these cases to make sure C# behavior is the same (not sure when they happen).
/// </summary>
int inverseSF(ref Vector3d p)
{
double phi = Math.Min(Math.Atan2(p.y, p.x), Math.PI);
double cosTheta = p.z;
double k = Math.Max(2.0, Math.Floor(
Math.Log(N * Math.PI * Math.Sqrt(5.0) * (1.0 - cosTheta*cosTheta)) / Math.Log(PHI*PHI)));
double Fk = Math.Pow(PHI, k) / Math.Sqrt(5.0);

//double F0 = round(Fk), F1 = round(Fk * PHI);
double F0 = Math.Round(Fk), F1 = Math.Round(Fk * PHI);

Matrix2d B = new Matrix2d(
2 * Math.PI * madfrac(F0 + 1, PHI - 1) - 2 * Math.PI * (PHI - 1),
2 * Math.PI * madfrac(F1 + 1, PHI - 1) - 2 * Math.PI * (PHI - 1),
-2 * F0 / N, -2 * F1 / N);
Matrix2d invB = B.Inverse();

//Vector2d c = floor(mul(invB, double2(phi, cosTheta - (1 - 1.0/N))));
Vector2d c = new Vector2d(phi, cosTheta - (1 - 1.0 / N));
c = invB * c;
c.x = Math.Floor(c.x); c.y = Math.Floor(c.y);

double d = double.PositiveInfinity, j = 0;
for (uint s = 0; s < 4; ++s) {
Vector2d cosTheta_second = new Vector2d(s%2, s/2) + c;
cosTheta = B.Row(1).Dot(cosTheta_second) + (1-1.0/N);
cosTheta = MathUtil.Clamp(cosTheta, -1.0, +1.0)*2.0 - cosTheta;
double i = Math.Floor(N*0.5 - cosTheta*N*0.5);
phi = 2.0 * Math.PI * madfrac(i, PHI - 1);
cosTheta = 1.0 - (2.0 * i + 1.0) * (1.0 / N); // rcp(n);
double sinTheta = Math.Sqrt(1.0 - cosTheta * cosTheta);
Vector3d q = new Vector3d(
Math.Cos(phi) * sinTheta,
Math.Sin(phi) * sinTheta,
cosTheta);
double squaredDistance = Vector3d.Dot(q - p, q - p);
if (squaredDistance < d) {
d = squaredDistance;
j = i;
}
}

// [TODO] should we be clamping this??
return (int)j;
}




}
}
Expand Down
Loading