Skip to content
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

Adding SDF LevelSet #187

Merged
merged 46 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
11716ba
polymorphic device functions working
elalish Mar 11, 2022
e34b939
starting to flesh out algorithm
elalish Mar 12, 2022
c869c50
getting closer
elalish Mar 12, 2022
677f7b8
fleshed out vert computation
elalish Mar 15, 2022
4ef8f42
merging master
elalish Apr 30, 2022
055035f
more progress
elalish Apr 30, 2022
5efb432
BuildTris
elalish May 3, 2022
0dd1f57
fixed some syntax
elalish May 4, 2022
c17e9cb
merging master
elalish May 11, 2022
0859717
updating to cpp
elalish May 11, 2022
06d1a38
Merge branch 'master' of github.com:elalish/manifold into sdf
elalish Jun 14, 2022
0280a40
added VecDc
elalish Jun 14, 2022
6936c56
Merge branch 'master' of github.com:elalish/manifold into sdf
elalish Jun 25, 2022
09cb0cf
SDF compiles
elalish Jun 25, 2022
3888973
SDF runs
elalish Jun 26, 2022
245338a
fixed some bugs
elalish Jun 26, 2022
997fb73
manifold output
elalish Jun 26, 2022
f4eeca7
fixed out of memory bug
elalish Jun 27, 2022
941fd62
flattened sides
elalish Jun 30, 2022
f0f997a
merging master
elalish Jul 18, 2022
25f376c
merging master
elalish Aug 14, 2022
d5e4635
Merge branch 'master' of github.com:elalish/manifold into sdf
elalish Aug 14, 2022
6dd429a
back to egg-crate
elalish Aug 16, 2022
2c95950
works with CUDA too
elalish Aug 16, 2022
ba2348f
moved SDF
elalish Aug 16, 2022
059f86d
Revert "moved SDF"
elalish Aug 16, 2022
8b1a17e
added gyroid sample
elalish Aug 16, 2022
73e395d
added sdf_test
elalish Aug 16, 2022
0fc8c8f
added SDF tests
elalish Aug 18, 2022
01bdb70
tests pass
elalish Aug 18, 2022
fbcb707
updated gyroid_module
elalish Aug 18, 2022
ea0c7d0
fixed gyroid module
elalish Aug 18, 2022
7a57b0f
added docs
elalish Aug 18, 2022
cd57ffe
addressing feedback
elalish Aug 23, 2022
c1f825f
fix cuda detection
elalish Aug 23, 2022
4d89088
clean up detect cuda
elalish Aug 23, 2022
a2b282f
fixed CUDA failure
elalish Aug 23, 2022
b91db71
consistent execution policy in Boolean
elalish Aug 27, 2022
94a3c69
remove SDF wrapper class
elalish Aug 27, 2022
c626f4e
simplified tet logic
elalish Aug 27, 2022
55de478
use NeighborInside()
elalish Aug 27, 2022
1ba085e
optimized SDF
elalish Aug 30, 2022
0aefceb
moved RemoveUnreferencedVerts
elalish Aug 30, 2022
3ccbba9
put printf statements behind MANIFOLD_DEBUG
elalish Aug 30, 2022
c56f1bc
enable hashtable resize
elalish Aug 30, 2022
7bdaa27
added test for hashtable resizing
elalish Aug 30, 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
2 changes: 1 addition & 1 deletion extras/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
38 changes: 30 additions & 8 deletions samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,48 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

project (samples)
project(samples)

file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp)
add_library(${PROJECT_NAME} ${SOURCE_FILES})
add_library(samples src/bracelet.cpp src/knot.cpp src/menger_sponge.cpp src/rounded_frame.cpp src/scallop.cpp src/tet_puzzle.cpp)

target_include_directories( ${PROJECT_NAME}
target_include_directories(samples
PUBLIC ${PROJECT_SOURCE_DIR}/include
)

target_link_libraries( ${PROJECT_NAME}
target_link_libraries(samples
PUBLIC manifold
)

target_compile_options(${PROJECT_NAME} PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
target_compile_options(samples PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(samples PUBLIC cxx_std_14)

project(samplesGPU)

add_library(samplesGPU src/gyroid_module.cpp)

if(MANIFOLD_USE_CUDA)
set_source_files_properties(src/gyroid_module.cpp PROPERTIES LANGUAGE CUDA)
set_property(TARGET samplesGPU PROPERTY CUDA_ARCHITECTURES 61)
endif()

target_include_directories(samplesGPU
PUBLIC ${PROJECT_SOURCE_DIR}/include
)

target_link_libraries(samplesGPU
PUBLIC manifold sdf
)

target_compile_options(samplesGPU PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(samplesGPU
PUBLIC cxx_std_14
PRIVATE cxx_std_17
)
2 changes: 2 additions & 0 deletions samples/include/samples.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,7 @@ Manifold RoundedFrame(float edgeLength, float radius, int circularSegments = 0);
Manifold TetPuzzle(float edgeLength, float gap, int nDivisions);

Manifold Scallop();

Manifold GyroidModule(float size = 20, int n = 20);
/** @} */ // end of Samples
} // namespace manifold
57 changes: 57 additions & 0 deletions samples/src/gyroid_module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2022 The Manifold Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "samples.h"
#include "sdf.h"

namespace {

struct Gyroid {
__host__ __device__ float operator()(glm::vec3 p) const {
p -= glm::pi<float>() / 4;
return cos(p.x) * sin(p.y) + cos(p.y) * sin(p.z) + cos(p.z) * sin(p.x);
}
};

Manifold RhombicDodecahedron(float size) {
Manifold box =
Manifold::Cube(size * glm::sqrt(2.0f) * glm::vec3(1, 1, 2), true);
Manifold result = box.Rotate(90, 45) ^ box.Rotate(90, 45, 90);
return result ^ box.Rotate(0, 0, 45);
}

} // namespace

namespace manifold {

/**
* Creates a rhombic dodecahedral module of a gyroid manifold, which can be
* assembled together to tile space continuously. This one is designed to be
* 3D-printable, as it is oriented with minimal overhangs. This sample
* demonstrates the use of a Signed Distance Function (SDF) to create smooth,
* complex manifolds.
*/
Manifold GyroidModule(float size, int n) {
auto gyroid = [&](float level) {
const float period = glm::two_pi<float>();
return Manifold(LevelSet(Gyroid(), {glm::vec3(-period), glm::vec3(period)},
period / n, level))
.Scale(glm::vec3(size / period));
};

Manifold result = (RhombicDodecahedron(size) ^ gyroid(-0.4)) - gyroid(0.4);

return result.Rotate(-45, 0, 90).Translate({0, 0, size / glm::sqrt(2.0f)});
}
} // namespace manifold
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -17,3 +17,4 @@ add_subdirectory(utilities)
add_subdirectory(collider)
add_subdirectory(polygon)
add_subdirectory(manifold)
add_subdirectory(sdf)
2 changes: 1 addition & 1 deletion src/collider/src/collider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ __host__ __device__ int Leaf2Node(int leaf) { return leaf * 2; }
struct CreateRadixTree {
int* nodeParent_;
thrust::pair<int, int>* internalChildren_;
const VecD<uint32_t> leafMorton_;
const VecDc<uint32_t> leafMorton_;

__host__ __device__ int PrefixLength(uint32_t a, uint32_t b) const {
// count-leading-zeros is used to find the number of identical highest-order
Expand Down
Loading