From 2eb7ea88acf1d6dc295cd5d60890d98d4ee6cdba Mon Sep 17 00:00:00 2001 From: forty-twoo <1013417276@qq.com> Date: Fri, 25 Nov 2022 22:06:09 +0800 Subject: [PATCH] modify some files --- README.md | 19 ++++++++++++++++++- include/bvh.hpp | 4 ++-- include/mathdef.hpp | 4 ++++ include/newton.hpp | 1 - src/main.cpp | 36 ++++++++++++++++++++++++------------ src/newton.cpp | 5 ++--- 6 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 include/mathdef.hpp delete mode 100644 include/newton.hpp diff --git a/README.md b/README.md index e1de6be..1cf267b 100644 --- a/README.md +++ b/README.md @@ -1 +1,18 @@ -Nurbs curve surface intersection calculation \ No newline at end of file +Nurbs curve surface intersection check. + +## Dependencies + +**STL**, **Libigl**, **Eigen**, **Ginac** and the dependencies of the **igl::opengl::glfw::Viewer (OpenGL, glad and GLFW)**. The CMake build system will automatically download libigl and its dependencies using CMake FetchContent, thus requiring no setup on your part. **As for Ginac, you need to download it by yourself before the cmake build.** + +## Compile +``` +mkdir build +cd build +cmake .. +make +``` + +## Run +``` +./NurbsIntersection +``` \ No newline at end of file diff --git a/include/bvh.hpp b/include/bvh.hpp index e72aa5a..df50ee9 100644 --- a/include/bvh.hpp +++ b/include/bvh.hpp @@ -43,10 +43,10 @@ public: { return bvh_aabb_node; }; - BVH_AABB_NodePtr Build_NurbsCurve(tinynurbs::RationalCurve &curve, BVH_AABB_NodePtr &curNode, int curLevel, double t, double tstep); - BVH_AABB_NodePtr Build_NurbsSurface(tinynurbs::RationalSurface &surface, BVH_AABB_NodePtr &curNode, int curLevel, double u, double v, double ustep, double vstep); AABB UnionBound(const AABB &a, const AABB &b); AABB UpdateBound(const AABB &bound, const glm::vec3 &p); + BVH_AABB_NodePtr Build_NurbsCurve(tinynurbs::RationalCurve &curve, BVH_AABB_NodePtr &curNode, int curLevel, double t, double tstep); + BVH_AABB_NodePtr Build_NurbsSurface(tinynurbs::RationalSurface &surface, BVH_AABB_NodePtr &curNode, int curLevel, double u, double v, double ustep, double vstep); }; #endif // !BVH_H_ diff --git a/include/mathdef.hpp b/include/mathdef.hpp new file mode 100644 index 0000000..a24d68e --- /dev/null +++ b/include/mathdef.hpp @@ -0,0 +1,4 @@ +#ifndef MATHDEF_H_ +#define MATHDEF_H_ + +#endif \ No newline at end of file diff --git a/include/newton.hpp b/include/newton.hpp deleted file mode 100644 index 0d12891..0000000 --- a/include/newton.hpp +++ /dev/null @@ -1 +0,0 @@ -#include \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 48c9043..7e84688 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,6 @@ int main(int argc, char *argv[]) viewer.data().point_size = 5; - /* tinynurbs::RationalCurve crv; // Planar curve using float32 crv.control_points = {glm::vec3(-3, 0, 0), // std::vector of 3D points glm::vec3(-2, 2, 3), @@ -21,26 +20,39 @@ int main(int argc, char *argv[]) crv.weights = {1, 1, 1, 1, 1}; ShowCurve_Igl(viewer, crv, 100); - BVH_AABB bvh_curve(5, 2, 100); + BVH_AABB bvh_curve(8, 2, 100); double tstep = *(crv.knots.end() - 1); bvh_curve.Build_NurbsCurve(crv, bvh_curve.bvh_aabb_node, 0, 0, tstep); ShowBVHNode(viewer, bvh_curve.bvh_aabb_node); - */ - tinynurbs::RationalCurve crv; // Planar curve using float32 - crv.control_points = {glm::vec3(-3, -3, -3), // std::vector of 3D points - glm::vec3(-2, -2, -2), - glm::vec3(-1, -1, -1), - glm::vec3(0, 0, 0), - glm::vec3(1, 1, 1)}; - crv.knots = {0, 0, 0, 1, 2, 3, 3, 3}; // std::vector of floats - crv.degree = 2; - crv.weights = {1, 1, 1, 1, 1}; + /* + tinynurbs::RationalCurve crv; // Planar curve using float32 + crv.control_points = {glm::vec3(-3, -3, -3), // std::vector of 3D points + glm::vec3(-2, -2, -2), + glm::vec3(-1, -1, -1), + glm::vec3(0, 0, 0), + glm::vec3(1, 1, 1)}; + crv.knots = {0, 0, 0, 1, 2, 3, 3, 3}; // std::vector of floats + crv.degree = 2; + crv.weights = {1, 1, 1, 1, 1}; + */ + + /* ShowCurve_Igl(viewer, crv, 100); BVH_AABB bvh_curve(5, 2, 100); double tstep = *(crv.knots.end() - 1); bvh_curve.Build_NurbsCurve(crv, bvh_curve.bvh_aabb_node, 0, 0, tstep); ShowBVHNode(viewer, bvh_curve.bvh_aabb_node); + */ + + /* + double u = 0.5; + std::vector basis = tinynurbs::bsplineBasis(crv.degree, tinynurbs::findSpan(crv.degree, crv.knots, u), crv.knots, u); + for (auto it : basis) + { + std::cout << it << std::endl; + } + */ viewer.launch(); } diff --git a/src/newton.cpp b/src/newton.cpp index 2ab8f0b..1ab9bfc 100644 --- a/src/newton.cpp +++ b/src/newton.cpp @@ -1,8 +1,7 @@ -#include "newton.hpp" +#include "mathdef.hpp" +/* // 默认id参数不用传,表示四个变量四个方程,id=1 or 2 的时候是2x2的方程组, id=3时是6x6的方程组, id=4 (x0,x1,x2... xn-1) 表示的方程组 - -/* vector newton(const MUL_F &F, const vector &init_point, const numeric &eps, bool &isConvergence, int id) { vector symbols = {get_symbol("u"), get_symbol("v"), get_symbol("s"), get_symbol("t")};