diff --git a/algoim/organizer/organizer.hpp b/algoim/organizer/organizer.hpp index 894d136..1000543 100644 --- a/algoim/organizer/organizer.hpp +++ b/algoim/organizer/organizer.hpp @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -326,7 +327,13 @@ void buildOcTreeV1(const Scene& scene, const OcTreeNode& node, std::vector& leaves, int depth, int& cnt) +void buildOcTreeV0(const Scene& scene, + const OcTreeNode& node, + std::vector& leaves, + int depth, + int& cnt, + int depthWithSamePolyCnt, + int fatherPolyCnt) { if (deepest < depth) { deepest = depth; @@ -346,6 +353,18 @@ void buildOcTreeV0(const Scene& scene, const OcTreeNode& node, std::vector subNodes; std::vector subNodes(CHILD_NUM); // intermediateNodes.resize(lastIdx + 8); @@ -404,7 +423,9 @@ void buildOcTreeV0(const Scene& scene, const OcTreeNode& node, std::vector>& primitiv detail::powerTransformation(range, xmin, tensor); detail::power2BernsteinTensor(tensor); } + visiblePrimitiveReps[i].aabb.normalize(range, xmin); + } else if (auto pt = std::dynamic_pointer_cast(primitives[i])) { + visiblePrimitiveReps[i].tensors = {tensor3(nullptr, 3)}; + auto& tensor = visiblePrimitiveReps[i].tensors[0]; + tensorStacks.emplace_back(algoim_spark_alloc_heap(real, tensor)); + + makeHalfPlane(*pt, visiblePrimitiveReps[i]); + + detail::powerTransformation(range, xmin, tensor); + detail::power2BernsteinTensor(tensor); + visiblePrimitiveReps[i].aabb.normalize(range, xmin); } else { std::cerr << "unrecognized primitive type." << std::endl; @@ -673,7 +705,7 @@ void quadratureScene(const std::vector>& primitiv OcTreeNode rootNode(0, 1, blobTree); for (int i = 0; i < minimalReps.size(); ++i) { rootNode.polyIntersectIndices.emplace_back(i); } int cnt = 1; - buildOcTreeV0(scene, rootNode, leaves, 1, cnt); + buildOcTreeV0(scene, rootNode, leaves, 1, cnt, 0, -1); std::cout << "octree built over" << std::endl; // basicTask(scene, leaves[14], q); @@ -682,7 +714,8 @@ void quadratureScene(const std::vector>& primitiv auto basicRes = basicTask(scene, leaf, q); if (std::isinf(basicRes.volume)) { std::cout << "inf volume when solving leaf: " << i << std::endl; } volume += basicRes.volume; - std::cout << "Solved leaves: " << ++i << "/" << leaves.size() << ", volume: " << volume << std::endl; + std::cout << "Solved leaves: " << ++i << "/" << leaves.size() << ", primitive cnt: " << leaf.polyIntersectIndices.size() + << ", volume: " << volume << std::endl; } volume *= prod(xmax - xmin); diff --git a/algoim/organizer/primitive.hpp b/algoim/organizer/primitive.hpp index a9466e1..19cd4f7 100644 --- a/algoim/organizer/primitive.hpp +++ b/algoim/organizer/primitive.hpp @@ -618,17 +618,37 @@ class ConeDesc : virtual public PrimitiveDesc { public: const static PrimitiveType type = Cone; + // uvector3 top; uvector3 bottom; - // uvector3 node2; - real radius; + real radiusTop, radiusBottom; real height; int alignAxis; - ConeDesc(const uvector3& n1, real r, real h, int ax) : PrimitiveDesc(), bottom(n1), radius(r), height(h), alignAxis(ax) + ConeDesc(const uvector3& n1, real r, real h, int ax) + : PrimitiveDesc(), bottom(n1), radiusBottom(r), radiusTop(0), height(h), alignAxis(ax) { assert(alignAxis >= 0 && alignAxis <= 2); } + ConeDesc(const uvector3& bottom, const uvector3& top, real rBottom, real rTop) + : PrimitiveDesc(), bottom(bottom), radiusBottom(rBottom), radiusTop(rTop) + { + assert(radiusTop >= 0 && radiusBottom > radiusTop); + uvector3 dir = top - bottom; + height = norm(dir); + dir /= height; + if (std::abs(std::abs(dot(dir, uvector3(0, 0, 1))) - 1) < std::numeric_limits::epsilon()) { + alignAxis = 2; + } else if (std::abs(std::abs(dot(dir, uvector3(0, 1, 0))) - 1) < std::numeric_limits::epsilon()) { + alignAxis = 1; + } else if (std::abs(std::abs(dot(dir, uvector3(1, 0, 0))) - 1) < std::numeric_limits::epsilon()) { + alignAxis = 0; + } else { + assert(false); + } + if (dir(alignAxis) < 0) { height = -height; } + } + void print() override { std::cout << "Cone Description" << std::endl; } }; @@ -673,6 +693,19 @@ public: { } + /** + @param vertices_ 顶点坐标 + @param indices_ 顶点索引 + @param faces_ 面索引 {顶点索引其实偏移(exclusive scan),顶点数} + */ + MeshDesc(const std::vector& vertices_, const std::vector& indices_, const std::vector& faces_) + : PrimitiveDesc(), vertices(vertices_), indices(indices_) + { + indexInclusiveScan.resize(faces_.size()); + for (int i = 0; i < faces_.size(); ++i) { indexInclusiveScan[i] = faces_[i](0) + faces_[i](1); } + int aaa = 1; + } + MeshDesc() = default; void print() override { std::cout << "Mesh Description" << std::endl; } @@ -875,7 +908,7 @@ void makeCone(const ConeDesc& coneDesc, VisiblePrimitiveRep& visiblePrimitive) // plane1 / plane2 分别为底面 / 顶点所在面 int dimA = (alignAxis + 1) % 3, dimB = (alignAxis + 2) % 3; real h = coneDesc.height, a = coneDesc.bottom(dimA), b = coneDesc.bottom(dimB), c = coneDesc.bottom(alignAxis) + h; - real scale = h / coneDesc.radius, scaleSquare = scale * scale; + real scale = h / (coneDesc.radiusBottom - coneDesc.radiusTop), scaleSquare = scale * scale; // f = (scale(x-a))^2 + (scale(y-b))^2 - (z-c)^2 uvector idx = 0; plane1.m(idx) = util::sign(h) * coneDesc.bottom(alignAxis); @@ -906,10 +939,10 @@ void makeCone(const ConeDesc& coneDesc, VisiblePrimitiveRep& visiblePrimitive) auto node2 = coneDesc.bottom; node2(alignAxis) += coneDesc.height; visiblePrimitive.aabb.extend(node2); - visiblePrimitive.aabb.min(dimA) -= coneDesc.radius; - visiblePrimitive.aabb.max(dimA) += coneDesc.radius; - visiblePrimitive.aabb.min(dimB) -= coneDesc.radius; - visiblePrimitive.aabb.max(dimB) += coneDesc.radius; + visiblePrimitive.aabb.min(dimA) -= coneDesc.radiusBottom; + visiblePrimitive.aabb.max(dimA) += coneDesc.radiusBottom; + visiblePrimitive.aabb.min(dimB) -= coneDesc.radiusBottom; + visiblePrimitive.aabb.max(dimB) += coneDesc.radiusBottom; // subBlobTree visiblePrimitive.subBlobTree.clear(); diff --git a/examples/examples_quad_multipoly.cpp b/examples/examples_quad_multipoly.cpp index d23a1ac..2d6190f 100644 --- a/examples/examples_quad_multipoly.cpp +++ b/examples/examples_quad_multipoly.cpp @@ -17,6 +17,7 @@ #include "myDebug.hpp" #include "primitiveDebug.hpp" +#include "PMTest.hpp" using namespace algoim; @@ -398,7 +399,9 @@ int main(int argc, char* argv[]) // module_test(); // testMain(); - testPrimitive(); + // testPrimitive(); + testPM(); return 0; } + #endif diff --git a/gjj/PMCases/PolyDifFace/entDataZJU_Des.txt b/gjj/PMCases/PolyDifFace/entDataZJU_Des.txt new file mode 100644 index 0000000..48b942c --- /dev/null +++ b/gjj/PMCases/PolyDifFace/entDataZJU_Des.txt @@ -0,0 +1,11 @@ + + vertexInfo: +4543.06080677052,-3903.14378907895,5000.00000000000; +4543.06080677052,-6019.09878238160,5000.00000000000; +1879.87607382063,-6019.09878238160,1000.00000000000; +1879.87607382063,-3903.14378907895,1000.00000000000; + + indexInfo: +0,1,2,3 + faceInfo: +0,4; diff --git a/gjj/PMCases/PolyDifFace/entDataZJU_Src.txt b/gjj/PMCases/PolyDifFace/entDataZJU_Src.txt new file mode 100644 index 0000000..a1900f2 --- /dev/null +++ b/gjj/PMCases/PolyDifFace/entDataZJU_Src.txt @@ -0,0 +1,15 @@ + + vertexInfo: +2594.16907620245,-4314.08525101657,3773.59344941283; +2594.16907620245,-4314.08525101657,3573.59344941283; +2594.16907620245,-5754.08525101657,3573.59344941283; +2594.16907620245,-5754.08525101657,3773.59344941283; +3726.28373273492,-4314.08525101657,3773.59344941283; +3593.12449608742,-4314.08525101657,3573.59344941283; +3726.28373273492,-5754.08525101657,3773.59344941283; +3593.12449608742,-5754.08525101657,3573.59344941283; + + indexInfo: +0,1,2,3,1,0,4,5,0,3,6,4,3,2,7,6,2,1,5,7,6,7,5,4 + faceInfo: +0,4;4,4;8,4;12,4;16,4;20,4; diff --git a/gjj/PMCases/PolyDifPoly/entDataZJU_Des.txt b/gjj/PMCases/PolyDifPoly/entDataZJU_Des.txt new file mode 100644 index 0000000..962a27d --- /dev/null +++ b/gjj/PMCases/PolyDifPoly/entDataZJU_Des.txt @@ -0,0 +1,296 @@ + + complexBodyInfo:0,9,24,34 + vertexInfo: +11748.40944836227,-4325.95442631630,21549.59021205360; +11748.40944836227,-4325.95442631630,21688.15427665911; +12484.47483358811,-3577.50000026381,21256.03391230463; +12484.47483358811,-3577.50000026381,21117.46984769912; +13547.89202684581,-6100.00000002560,20666.46170041069; +13395.74126433313,-5950.00000002583,20614.28430405553; +13395.74126433326,-5950.00000002584,20663.98975519961; +13547.89202684630,-6100.00000002596,20663.99725169609; +14896.90742621000,-5950.00000002583,19886.27039878878; +13547.89202684630,-5950.00000002583,20665.01632032316; +14896.90742621000,-5950.00000002583,19747.70633418327; +13547.89202684630,-5950.00000002583,20526.45225571764; +13547.89202684630,-5950.00000002583,20663.99725169609; +19320.12419289630,-10425.00000002583,17237.43714661155; +17934.90567930174,-10425.00000002583,18037.08203458280; +17934.90567930176,-10425.00000002583,18174.44161578225; +19320.12419289630,-10425.00000002583,17374.79672781102; +19322.21070997919,-10425.00000002583,17374.79672780697; +19447.22812297115,-10425.00000002583,17302.62794416358; +19447.22812297115,-10425.00000002583,17164.06387955807; +20849.99999998906,-13298.88732652532,16381.97836082562; +20849.99999998906,-11804.55202899014,16367.57914427394; +20849.99999998906,-11952.06910409846,16369.00059922656; +21124.99999998917,-13570.00000002583,16225.84155693102; +21124.99999998917,-13570.00000002583,16364.40562153653; +17808.11337720760,-10300.00000002579,18247.63498939708; +20849.99999998906,-13298.88732652532,16433.95194745345; +20998.20769789509,-13445.00000002584,16435.35986977861; +20998.20769789509,-13445.00000002584,16423.72661838442; +20999.99999998906,-13446.76696661644,16423.72670669148; +20999.99999998906,-13446.76696661645,16296.81283142860; +21124.99999998918,-13445.00000002584,16363.20113813048; +21124.99999998918,-13445.00000002584,16224.63707352497; +20999.99999998706,-11952.06910409846,16420.97418585554; +20849.99999998906,-11804.55202899014,16506.14320887944; +19320.12419289630,-10300.00000002807,17374.79672781104; +20999.99999998906,-13445.00000002584,16435.35986977861; +20849.99999998906,-11952.06910409846,16420.97418585438; +20999.99999998906,-13445.00000002584,16296.79580517310; +20999.99999998906,-13445.00000002584,16423.72670669148; +15049.43214230555,-6250.00000002583,19662.54917389031; +13700.04278935896,-6250.00000002583,20441.51096755456; +13700.04278935883,-6250.00000002583,20578.62965207288; +15049.43214230555,-6250.00000002583,19799.66785840855; +15051.93596280547,-6250.00000002583,19799.66785840341; +15201.95685839510,-6250.00000002583,19713.06531803178; +15201.95685839510,-6250.00000002583,19574.50125342627; +17374.99999998906,-9873.00899774759,18354.97979185655; +17499.99999998647,-8510.00401819123,18269.68732516803; +17374.99999998905,-8510.00401819123,18341.84605681460; +17499.99999998906,-9996.24203115686,18422.57258196454; +17374.99999998906,-9873.00899774759,18421.38512481399; +17499.99999998647,-8510.00401819123,18408.25138977354; +15049.43214230555,-6100.00000002878,19799.66785840858; +17374.99999998905,-8510.00401819123,18408.25138977205; +17681.32107511346,-10175.00000002584,18239.32978475061; +17681.32107511355,-10175.00000002583,18181.05981500027; +17808.11337720775,-10175.00000002583,18107.86644138542; +17808.11337720775,-10175.00000002583,18239.33603183102; +17499.99999998894,-9996.24203115674,18414.69559548384; +17624.99999998906,-10119.47506456613,18343.54697073095; +17624.99999998905,-10119.47506456613,18213.03724286152; +17808.11337720775,-10300.00000002602,18239.33603183102; +19193.02026281690,-10175.00000002583,17446.96551146108; +17624.99999998905,-8632.93491411901,18337.27720391787; +17624.99999998906,-9996.24203115674,18350.41385031648; +17624.99999998906,-10105.75355350319,18351.46908880798; +17513.64524135624,-9996.24203115674,18414.69559548384; +17808.11337720776,-10175.00000002583,18246.43050599092; +19193.02026281690,-10175.00000002583,17308.40144685557; +17624.99999998905,-8632.93491411901,18198.71313931236; +17624.99999998906,-9996.24203115674,18211.84978571097; +11748.40944836227,-4325.95442631630,21549.59021205360; +11748.40944836227,-4325.95442631630,21688.15427665911; +12484.47483358811,-3577.50000026381,21256.03391230463; +12484.47483358811,-3577.50000026381,21117.46984769912; +13547.89202684581,-6100.00000002560,20666.46170041069; +13395.74126433313,-5950.00000002583,20614.28430405553; +13395.74126433326,-5950.00000002584,20663.98975519961; +13547.89202684630,-6100.00000002596,20663.99725169609; +14896.90742621000,-5950.00000002583,19886.27039878878; +13547.89202684630,-5950.00000002583,20665.01632032316; +14896.90742621000,-5950.00000002583,19747.70633418327; +13547.89202684630,-5950.00000002583,20526.45225571764; +13547.89202684630,-5950.00000002583,20663.99725169609; +19320.12419289630,-10425.00000002583,17237.43714661155; +17934.90567930174,-10425.00000002583,18037.08203458280; +17934.90567930176,-10425.00000002583,18174.44161578225; +19320.12419289630,-10425.00000002583,17374.79672781102; +19322.21070997919,-10425.00000002583,17374.79672780697; +19447.22812297115,-10425.00000002583,17302.62794416358; +19447.22812297115,-10425.00000002583,17164.06387955807; +20849.99999998906,-13298.88732652532,16381.97836082562; +20849.99999998906,-11804.55202899014,16367.57914427394; +20849.99999998906,-11952.06910409846,16369.00059922656; +21124.99999998917,-13570.00000002583,16225.84155693102; +21124.99999998917,-13570.00000002583,16364.40562153653; +17808.11337720760,-10300.00000002579,18247.63498939708; +20849.99999998906,-13298.88732652532,16433.95194745345; +20998.20769789509,-13445.00000002584,16435.35986977861; +20998.20769789509,-13445.00000002584,16423.72661838442; +20999.99999998906,-13446.76696661644,16423.72670669148; +20999.99999998906,-13446.76696661645,16296.81283142860; +21124.99999998918,-13445.00000002584,16363.20113813048; +21124.99999998918,-13445.00000002584,16224.63707352497; +20999.99999998706,-11952.06910409846,16420.97418585554; +20849.99999998906,-11804.55202899014,16506.14320887944; +19320.12419289630,-10300.00000002807,17374.79672781104; +20999.99999998906,-13445.00000002584,16435.35986977861; +20849.99999998906,-11952.06910409846,16420.97418585438; +20999.99999998906,-13445.00000002584,16296.79580517310; +20999.99999998906,-13445.00000002584,16423.72670669148; +15049.43214230555,-6250.00000002583,19662.54917389031; +13700.04278935896,-6250.00000002583,20441.51096755456; +13700.04278935883,-6250.00000002583,20578.62965207288; +15049.43214230555,-6250.00000002583,19799.66785840855; +15051.93596280547,-6250.00000002583,19799.66785840341; +15201.95685839510,-6250.00000002583,19713.06531803178; +15201.95685839510,-6250.00000002583,19574.50125342627; +17374.99999998906,-9873.00899774759,18354.97979185655; +17499.99999998647,-8510.00401819123,18269.68732516803; +17374.99999998905,-8510.00401819123,18341.84605681460; +17499.99999998906,-9996.24203115686,18422.57258196454; +17374.99999998906,-9873.00899774759,18421.38512481399; +17499.99999998647,-8510.00401819123,18408.25138977354; +15049.43214230555,-6100.00000002878,19799.66785840858; +17374.99999998905,-8510.00401819123,18408.25138977205; +17681.32107511346,-10175.00000002584,18239.32978475061; +17681.32107511355,-10175.00000002583,18181.05981500027; +17808.11337720775,-10175.00000002583,18107.86644138542; +17808.11337720775,-10175.00000002583,18239.33603183102; +17499.99999998894,-9996.24203115674,18414.69559548384; +17624.99999998906,-10119.47506456613,18343.54697073095; +17624.99999998905,-10119.47506456613,18213.03724286152; +17808.11337720775,-10300.00000002602,18239.33603183102; +19193.02026281690,-10175.00000002583,17446.96551146108; +17624.99999998905,-8632.93491411901,18337.27720391787; +17624.99999998906,-9996.24203115674,18350.41385031648; +17624.99999998906,-10105.75355350319,18351.46908880798; +17513.64524135624,-9996.24203115674,18414.69559548384; +17808.11337720776,-10175.00000002583,18246.43050599092; +19193.02026281690,-10175.00000002583,17308.40144685557; +17624.99999998905,-8632.93491411901,18198.71313931236; +17624.99999998906,-9996.24203115674,18211.84978571097; +11748.40944836227,-4325.95442631630,21549.59021205360; +11748.40944836227,-4325.95442631630,21688.15427665911; +12484.47483358811,-3577.50000026381,21256.03391230463; +12484.47483358811,-3577.50000026381,21117.46984769912; +13547.89202684581,-6100.00000002560,20666.46170041069; +13395.74126433313,-5950.00000002583,20614.28430405553; +13395.74126433326,-5950.00000002584,20663.98975519961; +13547.89202684630,-6100.00000002596,20663.99725169609; +14896.90742621000,-5950.00000002583,19886.27039878878; +13547.89202684630,-5950.00000002583,20665.01632032316; +14896.90742621000,-5950.00000002583,19747.70633418327; +13547.89202684630,-5950.00000002583,20526.45225571764; +13547.89202684630,-5950.00000002583,20663.99725169609; +19320.12419289630,-10425.00000002583,17237.43714661155; +17934.90567930174,-10425.00000002583,18037.08203458280; +17934.90567930176,-10425.00000002583,18174.44161578225; +19320.12419289630,-10425.00000002583,17374.79672781102; +19322.21070997919,-10425.00000002583,17374.79672780697; +19447.22812297115,-10425.00000002583,17302.62794416358; +19447.22812297115,-10425.00000002583,17164.06387955807; +20849.99999998906,-13298.88732652532,16381.97836082562; +20849.99999998906,-11804.55202899014,16367.57914427394; +20849.99999998906,-11952.06910409846,16369.00059922656; +21124.99999998917,-13570.00000002583,16225.84155693102; +21124.99999998917,-13570.00000002583,16364.40562153653; +17808.11337720760,-10300.00000002579,18247.63498939708; +20849.99999998906,-13298.88732652532,16433.95194745345; +20998.20769789509,-13445.00000002584,16435.35986977861; +20998.20769789509,-13445.00000002584,16423.72661838442; +20999.99999998906,-13446.76696661644,16423.72670669148; +20999.99999998906,-13446.76696661645,16296.81283142860; +21124.99999998918,-13445.00000002584,16363.20113813048; +21124.99999998918,-13445.00000002584,16224.63707352497; +20999.99999998706,-11952.06910409846,16420.97418585554; +20849.99999998906,-11804.55202899014,16506.14320887944; +19320.12419289630,-10300.00000002807,17374.79672781104; +20999.99999998906,-13445.00000002584,16435.35986977861; +20849.99999998906,-11952.06910409846,16420.97418585438; +20999.99999998906,-13445.00000002584,16296.79580517310; +20999.99999998906,-13445.00000002584,16423.72670669148; +15049.43214230555,-6250.00000002583,19662.54917389031; +13700.04278935896,-6250.00000002583,20441.51096755456; +13700.04278935883,-6250.00000002583,20578.62965207288; +15049.43214230555,-6250.00000002583,19799.66785840855; +15051.93596280547,-6250.00000002583,19799.66785840341; +15201.95685839510,-6250.00000002583,19713.06531803178; +15201.95685839510,-6250.00000002583,19574.50125342627; +17374.99999998906,-9873.00899774759,18354.97979185655; +17499.99999998647,-8510.00401819123,18269.68732516803; +17374.99999998905,-8510.00401819123,18341.84605681460; +17499.99999998906,-9996.24203115686,18422.57258196454; +17374.99999998906,-9873.00899774759,18421.38512481399; +17499.99999998647,-8510.00401819123,18408.25138977354; +15049.43214230555,-6100.00000002878,19799.66785840858; +17374.99999998905,-8510.00401819123,18408.25138977205; +17681.32107511346,-10175.00000002584,18239.32978475061; +17681.32107511355,-10175.00000002583,18181.05981500027; +17808.11337720775,-10175.00000002583,18107.86644138542; +17808.11337720775,-10175.00000002583,18239.33603183102; +17499.99999998894,-9996.24203115674,18414.69559548384; +17624.99999998906,-10119.47506456613,18343.54697073095; +17624.99999998905,-10119.47506456613,18213.03724286152; +17808.11337720775,-10300.00000002602,18239.33603183102; +19193.02026281690,-10175.00000002583,17446.96551146108; +17624.99999998905,-8632.93491411901,18337.27720391787; +17624.99999998906,-9996.24203115674,18350.41385031648; +17624.99999998906,-10105.75355350319,18351.46908880798; +17513.64524135624,-9996.24203115674,18414.69559548384; +17808.11337720776,-10175.00000002583,18246.43050599092; +19193.02026281690,-10175.00000002583,17308.40144685557; +17624.99999998905,-8632.93491411901,18198.71313931236; +17624.99999998906,-9996.24203115674,18211.84978571097; +11748.40944836227,-4325.95442631630,21549.59021205360; +11748.40944836227,-4325.95442631630,21688.15427665911; +12484.47483358811,-3577.50000026381,21256.03391230463; +12484.47483358811,-3577.50000026381,21117.46984769912; +13547.89202684581,-6100.00000002560,20666.46170041069; +13395.74126433313,-5950.00000002583,20614.28430405553; +13395.74126433326,-5950.00000002584,20663.98975519961; +13547.89202684630,-6100.00000002596,20663.99725169609; +14896.90742621000,-5950.00000002583,19886.27039878878; +13547.89202684630,-5950.00000002583,20665.01632032316; +14896.90742621000,-5950.00000002583,19747.70633418327; +13547.89202684630,-5950.00000002583,20526.45225571764; +13547.89202684630,-5950.00000002583,20663.99725169609; +19320.12419289630,-10425.00000002583,17237.43714661155; +17934.90567930174,-10425.00000002583,18037.08203458280; +17934.90567930176,-10425.00000002583,18174.44161578225; +19320.12419289630,-10425.00000002583,17374.79672781102; +19322.21070997919,-10425.00000002583,17374.79672780697; +19447.22812297115,-10425.00000002583,17302.62794416358; +19447.22812297115,-10425.00000002583,17164.06387955807; +20849.99999998906,-13298.88732652532,16381.97836082562; +20849.99999998906,-11804.55202899014,16367.57914427394; +20849.99999998906,-11952.06910409846,16369.00059922656; +21124.99999998917,-13570.00000002583,16225.84155693102; +21124.99999998917,-13570.00000002583,16364.40562153653; +17808.11337720760,-10300.00000002579,18247.63498939708; +20849.99999998906,-13298.88732652532,16433.95194745345; +20998.20769789509,-13445.00000002584,16435.35986977861; +20998.20769789509,-13445.00000002584,16423.72661838442; +20999.99999998906,-13446.76696661644,16423.72670669148; +20999.99999998906,-13446.76696661645,16296.81283142860; +21124.99999998918,-13445.00000002584,16363.20113813048; +21124.99999998918,-13445.00000002584,16224.63707352497; +20999.99999998706,-11952.06910409846,16420.97418585554; +20849.99999998906,-11804.55202899014,16506.14320887944; +19320.12419289630,-10300.00000002807,17374.79672781104; +20999.99999998906,-13445.00000002584,16435.35986977861; +20849.99999998906,-11952.06910409846,16420.97418585438; +20999.99999998906,-13445.00000002584,16296.79580517310; +20999.99999998906,-13445.00000002584,16423.72670669148; +15049.43214230555,-6250.00000002583,19662.54917389031; +13700.04278935896,-6250.00000002583,20441.51096755456; +13700.04278935883,-6250.00000002583,20578.62965207288; +15049.43214230555,-6250.00000002583,19799.66785840855; +15051.93596280547,-6250.00000002583,19799.66785840341; +15201.95685839510,-6250.00000002583,19713.06531803178; +15201.95685839510,-6250.00000002583,19574.50125342627; +17374.99999998906,-9873.00899774759,18354.97979185655; +17499.99999998647,-8510.00401819123,18269.68732516803; +17374.99999998905,-8510.00401819123,18341.84605681460; +17499.99999998906,-9996.24203115686,18422.57258196454; +17374.99999998906,-9873.00899774759,18421.38512481399; +17499.99999998647,-8510.00401819123,18408.25138977354; +15049.43214230555,-6100.00000002878,19799.66785840858; +17374.99999998905,-8510.00401819123,18408.25138977205; +17681.32107511346,-10175.00000002584,18239.32978475061; +17681.32107511355,-10175.00000002583,18181.05981500027; +17808.11337720775,-10175.00000002583,18107.86644138542; +17808.11337720775,-10175.00000002583,18239.33603183102; +17499.99999998894,-9996.24203115674,18414.69559548384; +17624.99999998906,-10119.47506456613,18343.54697073095; +17624.99999998905,-10119.47506456613,18213.03724286152; +17808.11337720775,-10300.00000002602,18239.33603183102; +19193.02026281690,-10175.00000002583,17446.96551146108; +17624.99999998905,-8632.93491411901,18337.27720391787; +17624.99999998906,-9996.24203115674,18350.41385031648; +17624.99999998906,-10105.75355350319,18351.46908880798; +17513.64524135624,-9996.24203115674,18414.69559548384; +17808.11337720776,-10175.00000002583,18246.43050599092; +19193.02026281690,-10175.00000002583,17308.40144685557; +17624.99999998905,-8632.93491411901,18198.71313931236; +17624.99999998906,-9996.24203115674,18211.84978571097; + + indexInfo: +0,1,2,3,4,1,0,5,6,7,8,2,1,4,9,3,2,8,10,11,10,8,9,12,6,5,11,12,11,5,0,3,10,7,6,12,9,4,7,12,85,86,87,88,89,90,91,92,86,85,91,93,94,95,96,97,87,86,92,98,99,100,101,102,103,96,95,104,105,106,90,89,107,97,96,103,108,109,106,105,99,98,109,105,108,98,92,94,93,106,109,90,106,93,91,108,103,104,110,111,100,99,95,102,110,104,110,102,101,111,101,100,111,107,89,88,87,97,107,88,184,185,186,187,188,189,190,191,185,184,190,192,193,194,148,186,185,191,195,196,189,188,197,148,194,189,196,192,190,193,192,196,198,195,191,193,198,196,194,195,198,197,188,187,186,148,197,187,271,272,273,274,241,266,275,276,277,272,271,278,279,280,281,282,283,266,241,284,280,279,285,286,273,285,279,284,274,273,272,277,287,286,285,287,277,276,282,281,280,286,276,275,283,282,266,283,275,284,241,278,274,278,271,274 + faceInfo: +0,4;4,6;10,5;15,4;19,5;24,4;28,5;33,3;36,4;40,7;47,6;53,11;64,4;68,9;77,3;80,5;85,6;91,4;95,7;102,4;106,4;110,3;113,3;116,4;120,7;127,6;133,6;139,6;145,4;149,4;153,4;157,4;161,3;164,4;168,4;172,8;180,8;188,4;192,5;197,6;203,7;210,4;214,3;217,4;221,3; diff --git a/gjj/PMCases/PolyDifPoly/entDataZJU_Src.txt b/gjj/PMCases/PolyDifPoly/entDataZJU_Src.txt new file mode 100644 index 0000000..c2bd87c --- /dev/null +++ b/gjj/PMCases/PolyDifPoly/entDataZJU_Src.txt @@ -0,0 +1,15 @@ + + vertexInfo: +17624.99999998905,-8510.00401819123,17830.90112057791; +17374.99999998905,-8510.00401819123,17830.90112057791; +17374.99999998905,-8510.00401819123,18408.25138976753; +17624.99999998905,-8510.00401819123,18408.25138976753; +17624.99999998906,-3577.50000024273,20678.68364311939; +17374.99999998906,-3577.50000024273,20678.68364311939; +17374.99999998906,-3577.50000024273,21256.03391230901; +17624.99999998906,-3577.50000024273,21256.03391230901; + + indexInfo: +0,1,2,3,0,1,5,4,1,2,6,5,2,3,7,6,3,0,4,7,4,5,6,7 + faceInfo: +0,4;4,4;8,4;12,4;16,4;20,4; diff --git a/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Des.txt b/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Des.txt new file mode 100644 index 0000000..3153a25 --- /dev/null +++ b/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Des.txt @@ -0,0 +1,19 @@ + + vertexInfo: +2629.82969004962,6801.21455575771,49030.00000000000; +2869.82968877607,6801.18983125328,49030.00000000000; +2869.82968877607,6801.18983125328,52180.00000000000; +2629.82969004962,6801.21455575771,52180.00000000000; +2870.01294237553,8580.02684557581,49030.00000000000; +2629.98821659743,8340.02684557581,49030.00000000000; +1939.99863941572,8340.02684557581,49030.00000000000; +1939.99863941572,8580.02684557581,49030.00000000000; +2629.98821659743,8340.02684557581,52180.00000000000; +1939.99863941572,8340.02684557581,52180.00000000000; +2870.01294237553,8580.02684557581,52180.00000000000; +1939.99863941572,8580.02684557581,52180.00000000000; + + indexInfo: +0,1,2,3,4,1,0,5,6,7,6,5,8,9,5,0,3,8,8,3,2,10,11,9,1,4,10,2,4,7,11,10,7,6,9,11 + faceInfo: +0,4;4,6;10,4;14,4;18,6;24,4;28,4;32,4; diff --git a/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Src.txt b/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Src.txt new file mode 100644 index 0000000..ef6cf76 --- /dev/null +++ b/gjj/PMCases/PolyDifPolyThickFace/entDataZJU_Src.txt @@ -0,0 +1,18 @@ + + vertexInfo: +2629.99453728099,8340.01156816906,52180.00000000000; +2869.99453728099,8340.01156816906,52180.00000000000; +2869.99453728099,8401.36916293070,52180.00000000000; +2869.99453728099,8580.01156816906,52180.00000000000; +2629.99453728099,8580.01156816906,52180.00000000000; +2629.99453728099,8340.02684557581,52180.00000000000; +2629.99453728099,8340.01156816906,49030.00000000000; +2869.99453728099,8340.01156816906,49030.00000000000; +2869.99453728099,8401.36916293070,49030.00000000000; +2869.99453728099,8580.01156816906,49030.00000000000; +2629.99453728099,8580.01156816906,49030.00000000000; + + indexInfo: +0,1,2,3,4,5,6,7,1,0,7,8,9,3,2,1,9,10,4,3,10,6,0,5,4,6,10,9,8,7 + faceInfo: +0,6;6,4;10,6;16,4;20,5;25,5; diff --git a/gjj/PMTest.hpp b/gjj/PMTest.hpp index 7b9637e..15320ad 100644 --- a/gjj/PMTest.hpp +++ b/gjj/PMTest.hpp @@ -1 +1,159 @@ -#pragma once \ No newline at end of file +#pragma once +#include +#include "organizer/organizer.hpp" +#include "organizer/primitive.hpp" +#include "organizer/blobtree.hpp" + +#include "uvector.hpp" + +using namespace algoim::organizer; +using namespace algoim; + +void casePolyhedronTilted() +{ + const int PRIMITIVE_CNT = 2; + std::vector> primitiveDescriptions(PRIMITIVE_CNT); + primitiveDescriptions[0] = std::make_shared(MeshDesc( + { + uvector3{2629.82969004962, 6801.21455575771, 49030.00000000000}, + uvector3{2869.82968877607, 6801.18983125328, 49030.00000000000}, + uvector3{2869.82968877607, 6801.18983125328, 52180.00000000000}, + uvector3{2629.82969004962, 6801.21455575771, 52180.00000000000}, + uvector3{2870.01294237553, 8580.02684557581, 49030.00000000000}, + uvector3{2629.98821659743, 8340.02684557581, 49030.00000000000}, + uvector3{1939.99863941572, 8340.02684557581, 49030.00000000000}, + uvector3{1939.99863941572, 8580.02684557581, 49030.00000000000}, + uvector3{2629.98821659743, 8340.02684557581, 52180.00000000000}, + uvector3{1939.99863941572, 8340.02684557581, 52180.00000000000}, + uvector3{2870.01294237553, 8580.02684557581, 52180.00000000000}, + uvector3{1939.99863941572, 8580.02684557581, 52180.00000000000}, + }, + {0, 1, 2, 3, 4, 1, 0, 5, 6, 7, 6, 5, 8, 9, 5, 0, 3, 8, 8, 3, 2, 10, 11, 9, 1, 4, 10, 2, 4, 7, 11, 10, 7, 6, 9, 11}, + {uvector2i{0, 4}, uvector2i{4, 6}, uvector2i{10, 4}, uvector2i{14, 4}, uvector2i{18, 6}, uvector2i{24, 4}, + uvector2i{28, 4}, uvector2i{32, 4}})); + primitiveDescriptions[1] = std::make_shared(CuboidDesc(uvector3(0.6, 0.6, -0.6), 2.)); + // primitiveDescriptions[1] = std::make_shared(SphereDesc(1., uvector3(0.6, 0.6, -0.6), 1.)); + primitiveDescriptions[2] = std::make_shared(SphereDesc(0.7, uvector3(0.8, 0.8, 0.8), 1.)); + primitiveDescriptions[3] = std::make_shared(SphereDesc(0.5, uvector3(-0.3, -0.8, 0.8), 1.)); + std::vector pyramidBottomVertices = { + uvector3{-1, -1, 0}, + uvector3{1, -1, 0}, + uvector3{1, 1, 0}, + uvector3{-1, 1, 0} + }; + // primitiveDescriptions[4] = std::make_shared(pyramidBottomVertices, uvector3{0, 0, 1}); + primitiveDescriptions[4] = std::make_shared(SphereDesc(0.2, uvector3(0.2, -0.7, 0.), 1.)); + + // primitiveDescriptions[5] = std::make_shared(SphereDesc(0.2, uvector3(0., -0.5, 0.), 1)); + primitiveDescriptions[5] = std::make_shared(ConeDesc(uvector3(0., -0.2, 0.), 0.4, -0.7, 1)); + // primitiveDescriptions[6] = std::make_shared(CylinderDesc(uvector3(-0.3, 0.3, 2.3), 0.4, 3.6, 1)); + organizer::BlobTree blobTree; + blobTree.structure.resize(PRIMITIVE_CNT * 2 - 1); + blobTree.primitiveNodeIdx.resize(PRIMITIVE_CNT); + blobTree.structure[0] = {1, 0, 0, 0, 1, 2}; // cube1 + blobTree.structure[1] = {1, 0, 0, 0, 0, 0}; // cube2 + blobTree.structure[2] = {0, OP_UNION, 0, 0, 1, 6 - 2}; // Union of cubes = opNode1 + blobTree.structure[3] = {1, 0, 0, 0, 1, 5 - 3}; // sphere1 + blobTree.structure[4] = {1, 0, 0, 0, 0, 0}; // sphere2 + blobTree.structure[5] = {0, OP_UNION, 0, 0, 0, 0}; // Union of spheres = opNode2 + blobTree.structure[6] = {0, OP_DIFFERENCE, 0, 0, 1, 10 - 6}; // Difference of opNode1 and opNode2 = opNode3 + blobTree.structure[7] = {1, 0, 0, 0, 1, 9 - 7}; // Pyramid (sphere3) + blobTree.structure[8] = {1, 0, 0, 0, 0, 0}; // Cone + blobTree.structure[9] = {0, OP_UNION, 0, 0, 0, 0}; // UNION of Pyramid (sphere3) and Cone = opNode4 + blobTree.structure[10] = { + 0, OP_DIFFERENCE, 0, 0, 1, 12 - 10}; // Difference of opNode3 and opNode4 = opNode5 + // blobTree.structure[11] = {1, 0, 0, 0, 0, 0}; // Cylinder + // blobTree.structure[12] = {0, 2, 0, 0, 1, 0}; // Difference of opNode5 and Cylinder + // blobTree.primitiveNodeIdx = {0, 1, 3, 4, 7, 8, 11}; + // quadratureScene(primitiveDescriptions, uvector3(-1., -1.3, -1.6), uvector3(1.6, 1.6, 2.3), blobTree); + blobTree.primitiveNodeIdx = {0, 1, 3, 4, 7, 8}; + quadratureScene(primitiveDescriptions, uvector3(-0.8, -1.3, -1.6), uvector3(1.6, 1.6, 1.5), blobTree); +} + +void casePolyhedronDifFace() +{ + const int PRIMITIVE_CNT = 2; + std::vector> primitiveDescriptions(PRIMITIVE_CNT); + primitiveDescriptions[1] = std::make_shared(HalfPlaneDesc({ + uvector3{4543.06080677052, -3903.14378907895, 5000.00000000000}, + uvector3{4543.06080677052, -6019.09878238160, 5000.00000000000}, + uvector3{1879.87607382063, -6019.09878238160, 1000.00000000000}, + uvector3{1879.87607382063, -3903.14378907895, 1000.00000000000} + })); + primitiveDescriptions[0] = std::make_shared(MeshDesc( + { + uvector3{2594.16907620245, -4314.08525101657, 3773.59344941283}, + uvector3{2594.16907620245, -4314.08525101657, 3573.59344941283}, + uvector3{2594.16907620245, -5754.08525101657, 3573.59344941283}, + uvector3{2594.16907620245, -5754.08525101657, 3773.59344941283}, + uvector3{3726.28373273492, -4314.08525101657, 3773.59344941283}, + uvector3{3593.12449608742, -4314.08525101657, 3573.59344941283}, + uvector3{3726.28373273492, -5754.08525101657, 3773.59344941283}, + uvector3{3593.12449608742, -5754.08525101657, 3573.59344941283} + }, + {0, 1, 2, 3, 1, 0, 4, 5, 0, 3, 6, 4, 3, 2, 7, 6, 2, 1, 5, 7, 6, 7, 5, 4}, + {uvector2i{0, 4}, uvector2i{4, 4}, uvector2i{8, 4}, uvector2i{12, 4}, uvector2i{16, 4}, uvector2i{20, 4}})); + organizer::BlobTree blobTree; + blobTree.structure.resize(PRIMITIVE_CNT * 2 - 1); + blobTree.primitiveNodeIdx.resize(PRIMITIVE_CNT); + blobTree.structure[0] = {1, 0, 0, 0, 1, 2}; + blobTree.structure[1] = {1, 0, 0, 0, 0, 0}; + blobTree.structure[2] = {0, OP_DIFFERENCE, 0, 0, 1, 6 - 2}; + blobTree.primitiveNodeIdx = {0, 1}; + quadratureScene(primitiveDescriptions, uvector3(1879, -6020, 1000), uvector3(4544, -3903, 5000), blobTree); +} + +void casePolyDifPolyThickFace() +{ + const int PRIMITIVE_CNT = 2; + std::vector> primitiveDescriptions(PRIMITIVE_CNT); + primitiveDescriptions[0] = std::make_shared(MeshDesc( + { + uvector3{2629.82969004962, 6801.21455575771, 49030.00000000000}, + uvector3{2869.82968877607, 6801.18983125328, 49030.00000000000}, + uvector3{2869.82968877607, 6801.18983125328, 52180.00000000000}, + uvector3{2629.82969004962, 6801.21455575771, 52180.00000000000}, + uvector3{2870.01294237553, 8580.02684557581, 49030.00000000000}, + uvector3{2629.98821659743, 8340.02684557581, 49030.00000000000}, + uvector3{1939.99863941572, 8340.02684557581, 49030.00000000000}, + uvector3{1939.99863941572, 8580.02684557581, 49030.00000000000}, + uvector3{2629.98821659743, 8340.02684557581, 52180.00000000000}, + uvector3{1939.99863941572, 8340.02684557581, 52180.00000000000}, + uvector3{2870.01294237553, 8580.02684557581, 52180.00000000000}, + uvector3{1939.99863941572, 8580.02684557581, 52180.00000000000} + }, + {0, 1, 2, 3, 4, 1, 0, 5, 6, 7, 6, 5, 8, 9, 5, 0, 3, 8, 8, 3, 2, 10, 11, 9, 1, 4, 10, 2, 4, 7, 11, 10, 7, 6, 9, 11}, + {uvector2i{0, 4}, uvector2i{4, 6}, uvector2i{10, 4}, uvector2i{14, 4}, uvector2i{18, 6}, uvector2i{24, 4}, + uvector2i{28, 4}, uvector2i{32, 4}})); + primitiveDescriptions[1] = std::make_shared(MeshDesc( + { + uvector3{2629.99453728099, 8340.01156816906, 52180.00000000000}, + uvector3{2869.99453728099, 8340.01156816906, 52180.00000000000}, + uvector3{2869.99453728099, 8401.36916293070, 52180.00000000000}, + uvector3{2869.99453728099, 8580.01156816906, 52180.00000000000}, + uvector3{2629.99453728099, 8580.01156816906, 52180.00000000000}, + uvector3{2629.99453728099, 8340.02684557581, 52180.00000000000}, + uvector3{2629.99453728099, 8340.01156816906, 49030.00000000000}, + uvector3{2869.99453728099, 8340.01156816906, 49030.00000000000}, + uvector3{2869.99453728099, 8401.36916293070, 49030.00000000000}, + uvector3{2869.99453728099, 8580.01156816906, 49030.00000000000}, + uvector3{2629.99453728099, 8580.01156816906, 49030.00000000000} + }, + {0, 1, 2, 3, 4, 5, 6, 7, 1, 0, 7, 8, 9, 3, 2, 1, 9, 10, 4, 3, 10, 6, 0, 5, 4, 6, 10, 9, 8, 7}, + {uvector2i{0, 6}, uvector2i{6, 4}, uvector2i{10, 6}, uvector2i{16, 4}, uvector2i{20, 5}, uvector2i{25, 5}})); + organizer::BlobTree blobTree; + blobTree.structure.resize(PRIMITIVE_CNT * 2 - 1); + blobTree.primitiveNodeIdx.resize(PRIMITIVE_CNT); + blobTree.structure[0] = {1, 0, 0, 0, 1, 2}; + blobTree.structure[1] = {1, 0, 0, 0, 0, 0}; + blobTree.structure[2] = {0, OP_DIFFERENCE, 0, 0, 1, 6 - 2}; + blobTree.primitiveNodeIdx = {0, 1}; + quadratureScene(primitiveDescriptions, uvector3(1939, 6801, 49030), uvector3(2871, 8581, 52180), blobTree); +} + +void testPM() +{ + // casePolyhedronDifFace(); + // casePolyhedronTilted(); + casePolyDifPolyThickFace(); +} \ No newline at end of file diff --git a/gjj/output.cpp b/gjj/output.cpp new file mode 100644 index 0000000..e85a0f0 --- /dev/null +++ b/gjj/output.cpp @@ -0,0 +1,19 @@ +primitiveDescriptions[0] = std::make_shared(MeshDesc( + { + uvector3{2629.82969004962, 6801.21455575771, 49030.00000000000}, uvector3{ +2869.82968877607, 6801.18983125328, 49030.00000000000}, uvector3{ +2869.82968877607, 6801.18983125328, 52180.00000000000}, uvector3{ +2629.82969004962, 6801.21455575771, 52180.00000000000}, uvector3{ +2870.01294237553, 8580.02684557581, 49030.00000000000}, uvector3{ +2629.98821659743, 8340.02684557581, 49030.00000000000}, uvector3{ +1939.99863941572, 8340.02684557581, 49030.00000000000}, uvector3{ +1939.99863941572, 8580.02684557581, 49030.00000000000}, uvector3{ +2629.98821659743, 8340.02684557581, 52180.00000000000}, uvector3{ +1939.99863941572, 8340.02684557581, 52180.00000000000}, uvector3{ +2870.01294237553, 8580.02684557581, 52180.00000000000}, uvector3{ +1939.99863941572, 8580.02684557581, 52180.00000000000} + }, + {0,1,2,3,4,1,0,5,6,7,6,5,8,9,5,0,3,8,8,3,2,10,11,9,1,4,10,2,4,7,11,10,7,6,9,11 + }, + {uvector2i{0, 4}, uvector2i{4, 6}, uvector2i{10, 4}, uvector2i{14, 4}, uvector2i{18, 6}, uvector2i{24, 4}, uvector2i{28, 4}, uvector2i{32, 4}} +)); \ No newline at end of file diff --git a/gjj/polyhedronReader.py b/gjj/polyhedronReader.py new file mode 100644 index 0000000..5f8af91 --- /dev/null +++ b/gjj/polyhedronReader.py @@ -0,0 +1,55 @@ +import re + +# 读取输入文件 +with open("PMCases/PolyDifPolyThickFace/entDataZJU_Des.txt", "r") as file: + data = file.read() + +# 使用正则表达式提取vertexInfo和indexInfo +vertex_info_match = re.findall(r"vertexInfo:\s*([\d\.\-,;\s]+)", data) +index_info_match = re.findall(r"indexInfo:\s*([\d,;\s]+)", data) +face_info_match = re.findall(r"faceInfo:\s*([\d;,;\s]+)", data) + +if not vertex_info_match or not index_info_match or not face_info_match: + raise ValueError("Input data format is incorrect") + +# 合并所有匹配到的vertexInfo +vertex_info = [] +for match in vertex_info_match: + vertex_info.extend(match.split(";")) + +# 合并所有匹配到的indexInfo +index_info = [] +for match in index_info_match: + index_info.extend(match.split(",")) + +# 合并所有匹配到的faceInfo +face_info = [] +for match in face_info_match: + face_info.extend(match.split(";")) + +# 转换vertexInfo为uvector3格式 +vertex_list = [ + f"uvector3{{{', '.join(v.split(','))}}}" for v in vertex_info if v.strip() +] + +# 转换indexInfo为整数列表 +index_list = [str(i) for i in index_info if i.strip()] + +# 转换faceInfo为uvector2i格式 +face_list = [f"uvector2i{{{', '.join(f.split(','))}}}" for f in face_info if f.strip()] + +# 生成C++代码 +cpp_code = f"""primitiveDescriptions[0] = std::make_shared(MeshDesc( + {{ + {', '.join(vertex_list)} + }}, + {{{','.join(index_list)}}}, + {{{', '.join(face_list)}}} +));""" + +# 输出结果 +print(cpp_code) + +# 将结果写入文件 +with open("output.cpp", "w") as file: + file.write(cpp_code)