Browse Source

Add loader

master
wangxiaolong 8 months ago
parent
commit
e2b9f22474
  1. 267
      algoim/organizer/loader.hpp
  2. 14
      algoim/organizer/organizer.hpp
  3. 1
      algoim/organizer/primitive.hpp
  4. 266
      examples/example_loader.cpp
  5. 1
      wxl/parser.py

267
algoim/organizer/loader.hpp

@ -234,10 +234,12 @@ public:
* @brief Union two visible primitive node
* @param[in] rep1 The first visible primitive node
* @param[in] rep2 The second visible primitive node
* @param[in] modify Whether the aabb of primitive node is need to modify
* @return The unioned visible primitive
*/
algoim::organizer::VisiblePrimitiveRep unionNode(const algoim::organizer::VisiblePrimitiveRep& rep1,
const algoim::organizer::VisiblePrimitiveRep& rep2)
const algoim::organizer::VisiblePrimitiveRep& rep2,
const bool modify = true)
{
auto tree = createEmptyBlobTree();
tree.structure[2].nodeOp = 0;
@ -251,9 +253,26 @@ public:
result.aabb = rep1.aabb;
result.aabb.extend(rep2.aabb);
for (auto& iter : minimalReps)
if (modify)
{
result.tensors.push_back(iter.tensor);
for (auto& iter : minimalReps)
{
result.tensors.push_back(iter.tensor);
result.aabbs.push_back(iter.aabb);
}
}
else
{
for (auto& iter : rep1.tensors)
{
result.tensors.push_back(iter);
}
for (auto& iter : rep2.tensors)
{
result.tensors.push_back(iter);
}
result.aabbs = rep1.aabbs;
result.aabbs.insert(result.aabbs.end(), rep2.aabbs.begin(), rep2.aabbs.end());
}
return result;
@ -263,10 +282,12 @@ public:
* @brief Intersect two visible primitive node
* @param[in] rep1 The first visible primitive node
* @param[in] rep2 The second visible primitive node
* @param[in] modify Whether the aabb of primitive node is need to modify
* @return The intersected visible primitive
*/
algoim::organizer::VisiblePrimitiveRep intersectNode(const algoim::organizer::VisiblePrimitiveRep& rep1,
const algoim::organizer::VisiblePrimitiveRep& rep2)
const algoim::organizer::VisiblePrimitiveRep& rep2,
const bool modify = true)
{
auto tree = createEmptyBlobTree();
tree.structure[2].nodeOp = 1;
@ -280,9 +301,26 @@ public:
result.aabb = rep1.aabb;
result.aabb.intersect(rep2.aabb);
for (auto& iter : minimalReps)
if (modify)
{
result.tensors.push_back(iter.tensor);
for (auto& iter : minimalReps)
{
result.tensors.push_back(iter.tensor);
result.aabbs.push_back(iter.aabb);
}
}
else
{
for (auto& iter : rep1.tensors)
{
result.tensors.push_back(iter);
}
for (auto& iter : rep2.tensors)
{
result.tensors.push_back(iter);
}
result.aabbs = rep1.aabbs;
result.aabbs.insert(result.aabbs.end(), rep2.aabbs.begin(), rep2.aabbs.end());
}
return result;
@ -292,10 +330,12 @@ public:
* @brief Difference two visible primitive node
* @param[in] rep1 The first visible primitive node
* @param[in] rep2 The second visible primitive node
* @param[in] modify Whether the aabb of primitive node is need to modify
* @return The differenced visible primitive
*/
algoim::organizer::VisiblePrimitiveRep differentNode(const algoim::organizer::VisiblePrimitiveRep& rep1,
const algoim::organizer::VisiblePrimitiveRep& rep2)
const algoim::organizer::VisiblePrimitiveRep& rep2,
const bool modify = true)
{
auto tree = createEmptyBlobTree();
tree.structure[2].nodeOp = 2;
@ -308,9 +348,26 @@ public:
result.subBlobTree = tree;
result.aabb = rep1.aabb;
for (auto& iter : minimalReps)
if (modify)
{
for (auto& iter : minimalReps)
{
result.tensors.push_back(iter.tensor);
result.aabbs.push_back(iter.aabb);
}
}
else
{
result.tensors.push_back(iter.tensor);
for (auto& iter : rep1.tensors)
{
result.tensors.push_back(iter);
}
for (auto& iter : rep2.tensors)
{
result.tensors.push_back(iter);
}
result.aabbs = rep1.aabbs;
result.aabbs.insert(result.aabbs.end(), rep2.aabbs.begin(), rep2.aabbs.end());
}
return result;
@ -320,8 +377,20 @@ public:
{
auto& rep1 = this->m_allVisible[body1];
auto& rep2 = this->m_allVisible[body2];
algoim::organizer::VisiblePrimitiveRep result;
auto result = this->unionNode(rep1, rep2);
if (rep1.isEmpty())
{
result = rep2;
}
else if (rep2.isEmpty())
{
result = rep1;
}
else
{
result = this->differentNode(rep1, rep2, false);
}
this->m_allVisible[body1] = result;
}
@ -330,8 +399,16 @@ public:
{
auto& rep1 = this->m_allVisible[body1];
auto& rep2 = this->m_allVisible[body2];
algoim::organizer::VisiblePrimitiveRep result;
auto result = this->intersectNode(rep1, rep2);
if (rep1.isEmpty() || rep2.isEmpty())
{
result = algoim::organizer::VisiblePrimitiveRep{};
}
else
{
result = this->differentNode(rep1, rep2, false);
}
this->m_allVisible[body1] = result;
}
@ -340,8 +417,16 @@ public:
{
auto& rep1 = this->m_allVisible[body1];
auto& rep2 = this->m_allVisible[body2];
algoim::organizer::VisiblePrimitiveRep result;
auto result = this->differentNode(rep1, rep2);
if (rep1.isEmpty() || rep2.isEmpty())
{
result = rep1;
}
else
{
result = this->differentNode(rep1, rep2, false);
}
this->m_allVisible[body1] = result;
}
@ -365,7 +450,7 @@ public:
{
auto& rep = this->m_allVisible[body];
auto halfPlane = this->createHalfPlane(basePoint, -normal);
auto result = this->intersectNode(rep, halfPlane);
auto result = this->intersectNode(rep, halfPlane, false);
this->m_allVisible[body] = result;
}
@ -475,7 +560,7 @@ public:
algoim::algoimSparkAllocHeapVector(temp, halfPlane.tensors);
algoim::organizer::makeHalfPlane(halfPlaneDesc, halfPlane);
this->m_allPointer.push_back(temp[0]);
halfPlane.aabbs.push_back(halfPlane.aabb);
return halfPlane;
}
@ -489,8 +574,6 @@ public:
const std::vector<double>& bulges,
const Vector3D& extusion)
{
assert(bulges[0] >= 0.0 && bulges[1] >= 0.0);
auto normal = Direction3D(extusion);
auto& point1 = points[0];
auto& point2 = points[1];
@ -555,11 +638,16 @@ public:
rep1 = getPrimitive(point1, point2, bulge1);
rep2 = getPrimitive(point2, point1, bulge2);
/* if the bulge == 1 and bulge == 2, it is a cylinder */
/* if the bulge == 1 and bulge == 1, it is a cylinder */
if (std::abs(bulge1 - 1.0) < 1e-8 && std::abs(bulge2 - 1.0) < 1e-8)
{
result = getPrimitive(point1, point2, bulge1);
}
/* if the bulge == -1 and bulge == -1, it is a cylinder */
else if (std::abs(bulge1 + 1.0) < 1e-8 && std::abs(bulge2 + 1.0) < 1e-8)
{
result = getPrimitive(point1, point2, bulge1);
}
/* if the bulge1 and bulge2 has the same symbol, it is merge */
else if (bulge1 * bulge2 > 0.0)
{
@ -707,6 +795,11 @@ public:
base = this->unionNode(base, halfPlane1);
base = this->unionNode(base, halfPlane2);
for (size_t i = 0; i < base.aabbs.size(); i++)
{
base.aabbs[i] = base.aabb;
}
this->m_allVisible.push_back(base);
return this->m_allVisible.size() - 1;
@ -743,19 +836,155 @@ public:
algoim::algoimSparkAllocHeapVector(temp, cone.tensors);
algoim::organizer::makeCone(coneDesc, cone);
for (auto& pointer : temp)
{
this->m_allPointer.push_back(pointer);
}
for (int i = 0; i < 3; i++)
{
cone.aabbs.push_back(cone.aabb);
}
this->m_allVisible.push_back(cone);
return this->m_allVisible.size() - 1;
}
BodyTag addBox(const Point3D& leftBottomPoint, const double length, const double width, const double height)
{
auto size = Vector3D{length, width, height};
auto boxDesc =
algoim::organizer::CuboidDesc{(leftBottomPoint + (size / 2.0)).getUVector3Data(), size.getUVector3Data()};
algoim::organizer::VisiblePrimitiveRep box;
box.tensors.resize(6, algoim::tensor3(nullptr, 3));
std::vector<algoim::SparkStack<algoim::real>*> temp;
algoim::algoimSparkAllocHeapVector(temp, box.tensors);
algoim::organizer::makeMesh(boxDesc, box);
for (auto& pointer : temp)
{
this->m_allPointer.push_back(pointer);
}
for (int i = 0; i < 6; i++)
{
box.aabbs.push_back(box.aabb);
}
this->m_allVisible.push_back(box);
return this->m_allVisible.size() - 1;
}
BodyTag addCylinder(const Point3D& bottomOrigion, const double radius, const Vector3D& offset)
{
auto normal = Direction3D{offset};
/* Determine which axis is aligned */
int alignAxis;
if (normal.isParallel(Direction3D(1, 0, 0)))
{
alignAxis = 0;
}
else if (normal.isParallel(Direction3D(0, 1, 0)))
{
alignAxis = 1;
}
else if (normal.isParallel(Direction3D(0, 0, 1)))
{
alignAxis = 2;
}
else
{
throw std::runtime_error("Non align axis cylinder.");
}
algoim::uvector3 ext = 3;
ext(alignAxis) = 1;
algoim::organizer::VisiblePrimitiveRep cylinder;
cylinder.tensors.resize(3, algoim::tensor3(nullptr, 3));
cylinder.tensors[0].ext_ = ext;
std::vector<algoim::SparkStack<algoim::real>*> temp;
algoim::algoimSparkAllocHeapVector(temp, cylinder.tensors);
algoim::organizer::CylinderDesc cylinderDesc(
bottomOrigion.getUVector3Data(), radius, offset.length(), alignAxis);
for (auto& pointer : temp)
{
this->m_allPointer.push_back(pointer);
}
for (int i = 0; i < 3; i++)
{
cylinder.aabbs.push_back(cylinder.aabb);
}
this->m_allVisible.push_back(cylinder);
return this->m_allVisible.size() - 1;
}
BodyTag addEmpty()
{
algoim::organizer::VisiblePrimitiveRep empty;
this->m_allVisible.push_back(empty);
return this->m_allVisible.size() - 1;
}
std::pair<double, double> getAreaAndVolume(const BodyTag& tag)
{
auto& rep = this->m_allVisible[tag];
assert(rep.tensors.size() == rep.aabbs.size());
std::vector<algoim::organizer::MinimalPrimitiveRep> minimalReps;
algoim::uvector3 range = rep.aabb.max - rep.aabb.min;
for (size_t i = 0; i < rep.tensors.size(); i++)
{
auto& tenser = rep.tensors[i];
algoim::organizer::detail::powerTransformation(range, rep.aabb.min, tenser);
algoim::organizer::detail::power2BernsteinTensor(tenser);
algoim::organizer::MinimalPrimitiveRep minimalRep{tenser, rep.aabbs[i]};
minimalReps.push_back(minimalRep);
}
auto size = rep.aabb.size();
algoim::organizer::Scene scene{minimalReps,
algoim::organizer::AABB(rep.aabb.min - size * 1e-5, rep.aabb.max + size * 1e-5)};
algoim::organizer::OcTreeNode rootNode(0, 1, rep.subBlobTree);
for (int i = 0; i < minimalReps.size(); ++i)
{
rootNode.polyIntersectIndices.emplace_back(i);
}
int cnt = 1;
std::vector<algoim::organizer::OcTreeNode> leaves;
algoim::organizer::buildOcTreeV0(scene, rootNode, leaves, 1, cnt, 0, -1);
std::cout << "octree built over" << std::endl;
// basicTask(scene, leaves[14], q);
int i = 0;
int q = 10;
double volume = 0;
double area = 0;
for (const auto& leaf : leaves)
{
auto basicRes = algoim::organizer::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()
<< ", primitive cnt: " << leaf.polyIntersectIndices.size() << ", volume: " << volume << std::endl;
}
volume *= algoim::prod(rep.aabb.max - rep.aabb.min);
std::cout << "Volume xxx: " << volume << std::endl;
return std::make_pair(area, volume);
}
void output(const BodyTag& tag)
{
auto rep = this->m_allVisible[tag];
auto result = rep.tensors[0].m(algoim::uvector3(0));
}
private:

14
algoim/organizer/organizer.hpp

@ -438,7 +438,8 @@ void basicTask(const std::shared_ptr<PrimitiveDesc>& p, int q = 20, real xmin =
if (auto pt = std::dynamic_pointer_cast<SphereDesc>(p)) {
tensor3 tensor(nullptr, 3);
algoim_spark_alloc(real, tensor);
VisiblePrimitiveRep visiblePrimitiveRep{{tensor}, AABB(), BlobTree()};
std::vector<AABB> aabbs;
VisiblePrimitiveRep visiblePrimitiveRep{{tensor}, aabbs, AABB(), BlobTree()};
makeSphere(*pt, visiblePrimitiveRep);
detail::powerTransformation(range, xmin, tensor);
detail::power2BernsteinTensor(tensor);
@ -452,7 +453,8 @@ void basicTask(const std::shared_ptr<PrimitiveDesc>& p, int q = 20, real xmin =
assert(faceCount > 1);
std::vector<tensor3> planeTensors(faceCount, tensor3(nullptr, 2));
algoim_spark_alloc(real, planeTensors);
VisiblePrimitiveRep visiblePrimitiveRep{planeTensors, AABB(), BlobTree()};
std::vector<AABB> aabbs;
VisiblePrimitiveRep visiblePrimitiveRep{planeTensors, aabbs, AABB(), BlobTree()};
AABB aabb;
makeMesh(*pt, visiblePrimitiveRep);
for (auto& tensor : planeTensors) {
@ -481,8 +483,8 @@ void basicTask(const std::vector<std::shared_ptr<PrimitiveDesc>>& primitives, in
if (auto pt = std::dynamic_pointer_cast<SphereDesc>(primitives[i])) {
tensor3 tensor(nullptr, 3);
phiStacks.emplace_back(algoim_spark_alloc_heap(real, tensor));
VisiblePrimitiveRep visiblePrimitiveRep{{tensor}, AABB(), BlobTree()};
std::vector<AABB> aabbs;
VisiblePrimitiveRep visiblePrimitiveRep{{tensor}, aabbs, AABB(), BlobTree()};
makeSphere(*pt, visiblePrimitiveRep);
detail::powerTransformation(range, xmin, tensor);
@ -493,8 +495,8 @@ void basicTask(const std::vector<std::shared_ptr<PrimitiveDesc>>& primitives, in
assert(faceCount > 1);
std::vector<tensor3> planeTensors(faceCount, tensor3(nullptr, 3));
algoimSparkAllocHeapVector(phiStacks, planeTensors);
VisiblePrimitiveRep visiblePrimitiveRep{planeTensors, AABB(), BlobTree()};
std::vector<AABB> aabbs;
VisiblePrimitiveRep visiblePrimitiveRep{planeTensors, aabbs, AABB(), BlobTree()};
makeMesh(*pt, visiblePrimitiveRep);
for (auto& tensor : planeTensors) {

1
algoim/organizer/primitive.hpp

@ -760,6 +760,7 @@ public:
struct VisiblePrimitiveRep {
std::vector<tensor3> tensors;
std::vector<AABB> aabbs;
AABB aabb;
organizer::BlobTree subBlobTree;

266
examples/example_loader.cpp

@ -7,10 +7,12 @@ void loaderTest1()
std::vector<Point3D> points;
std::vector<double> bulges;
Vector3D extusion;
Point3D topPoint, bottomPoint, basePoint;
Point3D topPoint, bottomPoint, basePoint, leftBottomPoint;
Direction3D direction;
double offset, radius1, radius2;
double offset, radius1, radius2, length, width, height, areaDifference, volumeDifference;
std::pair<double, double> before, after;
/* 体1 */
points.clear();
@ -22,8 +24,6 @@ void loaderTest1()
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 3300.0000000000000};
auto tag1 = loader.addExtrude(points, bulges, extusion);
loader.output(tag1);
/* 体2 */
points.clear();
bulges.clear();
@ -84,7 +84,7 @@ void loaderTest1()
/* 体5被切割 */
basePoint = Point3D{-1.1224183253943920e-06, -3.8391322798592142e-07, 3300.0000000000000000};
direction = Direction3D{0, 0, 1};
loader.split(tag3, basePoint, direction);
loader.split(tag5, basePoint, direction);
/* 体3和体5布尔并 */
loader.unionNode(tag3, tag5);
@ -198,22 +198,268 @@ void loaderTest1()
direction = Direction3D{0, 0, 1};
loader.split(tag11, basePoint, direction);
/* 体8和体11布尔并 */
/* 体8和体11布尔并 */
loader.unionNode(tag8, tag11);
/* 体7和体8布尔差 */
/* 体7和体8布尔差 */
loader.differentNode(tag7, tag8);
/* 体2和体7布尔并 */
/* 体2和体7布尔并 */
loader.unionNode(tag2, tag7);
/* 体1和体2布尔并 */
/* 体1和体2布尔并 */
loader.unionNode(tag1, tag2);
/* 体1 Z轴偏移 -3600 */
/* 体1 Z轴偏移 -3600 */
direction = Direction3D{0, 0, 1};
offset = -3600;
loader.offset(tag1, direction, offset);
/* 新的体11 */
points.clear();
bulges.clear();
points.push_back(Point3D{-32050.000001122418, -3.8396319723688066e-07, 0.0000000000000000});
points.push_back(Point3D{32049.999998877582, -3.8387224776670337e-07, 0.0000000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto newTag11 = loader.addExtrude(points, bulges, extusion);
/* 体0 */
points.clear();
bulges.clear();
points.push_back(Point3D{-11798.670446418590, 5999.2409883221799, 0.0000000000000000});
points.push_back(Point3D{11801.337366082498, 5999.2409883221590, 0.0000000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto tag0 = loader.addExtrude(points, bulges, extusion);
/* 新的体11和体0布尔差 */
loader.differentNode(newTag11, tag0);
/* 新的体11 Z轴偏移 -3500 */
direction = Direction3D{0, 0, 1};
offset = -3500;
loader.offset(newTag11, direction, offset);
/* 体1和新的体11判交 */
/* TODO */
/* 体12 */
points.clear();
bulges.clear();
points.push_back(Point3D{676.33403607269543, 5999.2409883221790, 0.0000000000000000});
points.push_back(Point3D{-673.66711640879771, 5999.2409883221790, 0.0000000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto tag12 = loader.addExtrude(points, bulges, extusion);
/* 体12 Z轴偏移 -3500 */
direction = Direction3D{0, 0, 1};
offset = -3500;
loader.offset(tag12, direction, offset);
/* 体1和体12判交 */
/* TODO */
/* 新的体11和体12布尔并 保留体12 */
loader.unionNode(newTag11, tag12);
/* 体13 */
points.clear();
bulges.clear();
points.push_back(Point3D{-2398.6665401680511, 5999.2409883221771, 0.0000000000000000});
points.push_back(Point3D{2401.3334598319489, 5999.2409883221790, 0.0000000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto tag13 = loader.addExtrude(points, bulges, extusion);
/* 体13 */
points.clear();
bulges.clear();
points.push_back(Point3D{-673.66711640879771, 5999.2409883221790, 0.0000000000000000});
points.push_back(Point3D{676.33403607269543, 5999.2409883221790, 0.0000000000000000});
bulges.push_back(-0.99999999999999989);
bulges.push_back(-0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto tag14 = loader.addExtrude(points, bulges, extusion);
/* 体13和体14布尔差 */
loader.differentNode(tag13, tag14);
/* 体13 Z轴偏移-3500 */
direction = Direction3D{0, 0, 1};
offset = -3500;
loader.offset(tag13, direction, offset);
/* 体1和体13判交 */
/* TODO */
/* 新的体11和体13布尔并保留体13 */
loader.unionNode(newTag11, tag13);
before = loader.getAreaAndVolume(tag1);
/* 体1和新的体11布尔差 */
loader.differentNode(tag1, newTag11);
after = loader.getAreaAndVolume(tag1);
/* 获取 体1 布尔前后的 体积差 和 面积差 */
areaDifference = after.first - before.first;
volumeDifference = after.second - before.second;
/* 定义空体 扣减体1 */
auto subTag1 = loader.addEmpty();
auto cycle = [&loader, subTag1](const Point3D& point) {
std::vector<Point3D> points;
std::vector<double> bulges;
Vector3D extusion;
Direction3D direction;
double offset;
/* 循环体1 */
points.clear();
bulges.clear();
points.push_back(Point3D{-1000.0000000000000, 1000.0000000000001, 0.0000000000000000});
points.push_back(Point3D{-1000.0000000000000, -1000.0000000000000, 0.0000000000000000});
points.push_back(Point3D{1000.0000000000000, -1000.0000000000000, 0.0000000000000000});
points.push_back(Point3D{1000.0000000000000, 1000.0000000000000, 0.0000000000000000});
bulges.push_back(0.0000000000000000);
bulges.push_back(0.0000000000000000);
bulges.push_back(0.0000000000000000);
bulges.push_back(0.0000000000000000);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto cycleTag1 = loader.addExtrude(points, bulges, extusion);
/* 循环体1 偏移+ 传入的X,Y,Z坐标值 */
loader.offset(cycleTag1, Direction3D{point}, point.length());
/* 循环体2 */
auto leftBottomPoint = Point3D{point.m_x - 1000, point.m_y - 1000, point.m_z + 0.0000000000005};
double length = 2000.0000000000036;
double width = 2000.0000000000036;
double height = 600;
auto cycleTag2 = loader.addBox(leftBottomPoint, length, width, height);
/* 循环体3 */
points.clear();
bulges.clear();
points.push_back(Point3D{-32050.000001122418, -3.8396319723688066e-07, 0.0000000000000000});
points.push_back(Point3D{32049.999998877582, -3.8387224776670337e-07, 0.0000000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{0.0000000000000000, 0.0000000000000000, 600.0000000000000};
auto cycleTag3 = loader.addExtrude(points, bulges, extusion);
/* 循环体3 Z轴偏移 -2900 */
direction = Direction3D{0, 0, 1};
offset = -2900;
loader.offset(cycleTag3, direction, offset);
/* 循环体3和体2布尔交 */
loader.intersectNode(cycleTag3, cycleTag2);
/* 循环体1和体3布尔交 */
loader.intersectNode(cycleTag1, cycleTag3);
/* 循环体1和体1判交 */
/* TODO */
/* 扣减体1和循环体1布尔并 */
loader.unionNode(subTag1, cycleTag1);
};
points.clear();
points.push_back(Point3D{-21595.036456438422, -21609.173181957169, -2900.0000000000000});
points.push_back(Point3D{-13505.711180076411, -13505.717935507526, -2900.0000000000000});
points.push_back(Point3D{-2987.8729842756293, -18864.829751913778, -2900.0000000000000});
points.push_back(Point3D{2987.9196792985895, -18864.830728476278, -2900.0000000000000});
points.push_back(Point3D{13505.770265236089, -13505.722818320026, -2900.0000000000000});
points.push_back(Point3D{17018.254640236089, -8671.2047519137759, -2900.0000000000000});
points.push_back(Point3D{27220.281983986089, -13869.397623007526, -2900.0000000000000});
points.push_back(Point3D{21602.139405861089, -21602.103677695028, -2900.0000000000000});
points.push_back(Point3D{30173.926515236089, -4778.9669589450259, -2900.0000000000000});
points.push_back(Point3D{18864.887452736089, -2987.8275546481514, -2900.0000000000000});
points.push_back(Point3D{-18864.815672263911, -2987.8811435153389, -2900.0000000000000});
points.push_back(Point3D{-30173.856687888911, -4779.0570468356509, -2900.0000000000000});
points.push_back(Point3D{-13869.422117576411, -27220.218912070028, -2900.0000000000000});
points.push_back(Point3D{-11781.052000388911, -23121.591958945028, -2900.0000000000000});
points.push_back(Point3D{-8671.2131332014105, -17018.193521445028, -2900.0000000000000});
points.push_back(Point3D{-27220.229734763911, -13869.391763632526, -2900.0000000000000});
points.push_back(Point3D{-17018.194578513911, -8671.1974276950259, -2900.0000000000000});
points.push_back(Point3D{-30173.856687888911, 4779.0965176174741, -2900.0000000000000});
points.push_back(Point3D{-25630.485594138911, 4059.4959316799741, -2900.0000000000000});
points.push_back(Point3D{-18864.815672263911, 2987.9134121487236, -2900.0000000000000});
points.push_back(Point3D{-15863.798094138911, 8083.0535488674741, -2900.0000000000000});
points.push_back(Point3D{-27220.216062888911, 13869.449056679974, -2900.0000000000000});
points.push_back(Point3D{-21602.091062888911, 21602.130697304972, -2900.0000000000000});
points.push_back(Point3D{-18349.393797263911, 18349.437337929972, -2900.0000000000000});
points.push_back(Point3D{-13908.684812888911, 13908.728353554974, -2900.0000000000000});
points.push_back(Point3D{-9584.8552230451605, 18811.339681679972, -2900.0000000000000});
points.push_back(Point3D{-13869.425047263911, 27220.249837929972, -2900.0000000000000});
points.push_back(Point3D{-4779.0493148420355, 30173.900228554972, -2900.0000000000000});
points.push_back(Point3D{4779.0900894548395, 30173.904134804972, -2900.0000000000000});
points.push_back(Point3D{13869.430421486089, 27220.275228554972, -2900.0000000000000});
points.push_back(Point3D{9584.8806167985895, 18811.363119179972, -2900.0000000000000});
points.push_back(Point3D{13908.739015236089, 13908.728353554974, -2900.0000000000000});
points.push_back(Point3D{18349.453858986089, 18349.433431679972, -2900.0000000000000});
points.push_back(Point3D{21602.147218361089, 21602.130697304972, -2900.0000000000000});
points.push_back(Point3D{27220.268312111089, 13869.454916054974, -2900.0000000000000});
points.push_back(Point3D{15863.852296486089, 8083.0574551174741, -2900.0000000000000});
points.push_back(Point3D{18864.879640236089, 2987.9153652737236, -2900.0000000000000});
points.push_back(Point3D{25630.543702736089, 4059.4900723049741, -2900.0000000000000});
points.push_back(Point3D{30173.912843361089, 4779.0896816799741, -2900.0000000000000});
points.push_back(Point3D{13869.432374611089, -27220.242349570028, -2900.0000000000000});
points.push_back(Point3D{-4776.1108367703273, -30098.869302695028, -2900.0000000000000});
points.push_back(Point3D{4779.0915542985895, -30098.869302695028, -2900.0000000000000});
points.push_back(Point3D{-23121.594969138911, -11781.033365195026, -2900.0000000000000});
points.push_back(Point3D{23121.637452736089, 11781.092611367474, -2900.0000000000000});
points.push_back(Point3D{11781.053468361089, -23121.619302695028, -2900.0000000000000});
points.push_back(Point3D{-23121.583250388911, 11781.089681679974, -2900.0000000000000});
for (auto& point : points)
{
cycle(point);
}
before = loader.getAreaAndVolume(tag1);
/* 体1和扣减体1布尔差 */
loader.differentNode(tag1, subTag1);
after = loader.getAreaAndVolume(tag1);
/* 获取 体1 布尔前后的 体积差 和 面积差 */
areaDifference = after.first - before.first;
volumeDifference = after.second - before.second;
/* 体15:Ent1.bool */
/* 体1和体15布尔差 */
/* 体16 */
points.clear();
bulges.clear();
points.push_back(Point3D{-2503.6291053659488, 5999.2409883221790, -3500.0000000000000});
points.push_back(Point3D{2501.2960250298465, 5999.2409883221790, -3500.0000000000000});
bulges.push_back(0.99999999999999989);
bulges.push_back(0.99999999999999989);
extusion = Vector3D{-0.0000000000000000, -0.0000000000000000, -100.00000000000000};
auto tag16 = loader.addExtrude(points, bulges, extusion);
before = loader.getAreaAndVolume(tag1);
/* 体1和体16布尔差 */
loader.differentNode(tag1, tag16);
after = loader.getAreaAndVolume(tag1);
/* 获取 体1 布尔前后的 体积差 和 面积差 */
areaDifference = after.first - before.first;
volumeDifference = after.second - before.second;
}
int main(int argc, char** argv)

1
wxl/parser.py

@ -10,6 +10,7 @@ class Parser:
pattern1 = re.compile(r"m_pData\[\d+\]\t\{x=(.*?) y=(.*?) z=(.*?) \}\tOdGePoint3d\n", re.VERBOSE)
pattern2 = re.compile(r"m_pData\[\d+\]\t(.*?)\tdouble\n", re.VERBOSE)
pattern3 = re.compile(r"\{x=(.*?) y=(.*?) z=(.*?) \}")
end_pattern = re.compile(r"体(\d+)")
with open("/home/xiaolong/HeteQuadrature/wxl/data.txt") as f:

Loading…
Cancel
Save