【VTK】最近点计算

很高兴在雪易的CSDN遇见你 

VTK技术爱好者 QQ:870202403


前言

在VTK中,经常会用到最近点计算,比如到平面的最近点,到PolyData数据上的最点,本文分享VTK中的最近点计算方法,希望对各位小伙伴有所帮助!

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的点赞就是我的动力(^U^)ノ~YO


目录

前言

1. Vertex最近点

2. PolyVertex最近点

3. Line最近点

4. PolyLine最近点

4. Triangle最近点

5. TriangleStrip最近点

6. Quad最近点

7. Pixee最近点

8. polygon最近点

9. Tetra最近点

10. voxel最近点

11. wedge最近点

12. Hexahedron最近点

13. pentagonal prism最近点

14. Hexagonal prism最近点

15. 注意

结论:


1. Vertex最近点

  vtkIdList* ids = vtkIdList::New();int j;int n;double dist2;int subId;strm << "Test vtkCell::EvaluatePosition Start" << endl;// VertexvtkVertex* vertex = vtkVertex::New();double vertexCoords[3], vertexWeights[2];double vertexPoint[2][3] = { { 10.0, 20.0, 30.0 }, { 0, 0, 0 } };double vertexClosest[3];vertex->GetPointIds()->SetId(0, 0);vertex->GetPoints()->SetPoint(0, 10.0, 20.0, 30.0);n = sizeof(vertexPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){vertex->EvaluatePosition(&vertexPoint[j][0], &vertexClosest[0], subId, &vertexCoords[0], dist2, &vertexWeights[0]);strm << "vtkVertex (" << vertexPoint[j][0] << ", " << vertexPoint[j][1] << ", "<< vertexPoint[j][2] << ")" << endl;strm << "\tclosest: " << vertexClosest[0] << ", " << vertexClosest[1] << ", "<< vertexClosest[2] << endl;strm << "\tcoords: " << vertexCoords[0] << endl;strm << "\tweights: " << vertexWeights[0] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;strm << endl;}

2. PolyVertex最近点

// Poly VertexvtkPolyVertex* polyVertex = vtkPolyVertex::New();double polyVertexCoords[3], polyVertexWeights[2];double polyVertexPoint[3][3] = { { 10.0, 20.0, 30.0 }, { 30.0, 20.0, 10.0 }, { 0, 0, 0 } };double polyVertexClosest[3];polyVertex->GetPointIds()->SetNumberOfIds(2);polyVertex->GetPointIds()->SetId(0, 0);polyVertex->GetPointIds()->SetId(1, 1);polyVertex->GetPoints()->SetNumberOfPoints(2);polyVertex->GetPoints()->SetPoint(0, 10.0, 20.0, 30.0);polyVertex->GetPoints()->SetPoint(1, 30.0, 20.0, 10.0);n = sizeof(polyVertexPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){polyVertex->EvaluatePosition(&polyVertexPoint[j][0], &polyVertexClosest[0], subId,&polyVertexCoords[0], dist2, &polyVertexWeights[0]);strm << "vtkPolyVertex (" << polyVertexPoint[j][0] << ", " << polyVertexPoint[j][1] << ", "<< polyVertexPoint[j][2] << ")" << endl;strm << "\tclosest: " << polyVertexClosest[0] << ", " << polyVertexClosest[1] << ", "<< polyVertexClosest[2] << endl;strm << "\tcoords: " << polyVertexCoords[0] << endl;strm << "\tweights: " << polyVertexWeights[0] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;strm << endl;}

3. Line最近点

  // LinevtkLine* line = vtkLine::New();double lineCoords[3], lineWeights[2];double linePoint[3][3] = { { 10.0, 20.0, 30.0 }, { 30.0, 20.0, 10.0 }, { 0, 0, 0 } };double lineClosest[3];line->GetPointIds()->SetId(0, 0);line->GetPointIds()->SetId(1, 1);line->GetPoints()->SetPoint(0, 10.0, 20.0, 30.0);line->GetPoints()->SetPoint(1, 30.0, 20.0, 10.0);n = sizeof(linePoint) / (3 * sizeof(double));for (j = 0; j < n; j++){line->EvaluatePosition(&linePoint[j][0], &lineClosest[0], subId, &lineCoords[0], dist2, &lineWeights[0]);strm << "vtkLine (" << linePoint[j][0] << ", " << linePoint[j][1] << ", " << linePoint[j][2]<< ")" << endl;strm << "\tclosest: " << lineClosest[0] << ", " << lineClosest[1] << ", " << lineClosest[2]<< endl;strm << "\tcoords: " << lineCoords[0] << endl;strm << "\tweights: " << lineWeights[0] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;strm << endl;}

4. PolyLine最近点

  // Poly LinevtkPolyLine* polyLine = vtkPolyLine::New();double polyLineCoords[3], polyLineWeights[3];double polyLinePoint[4][3] = { { 10.0, 20.0, 30.0 }, { 10.0, 30.0, 30.0 }, { 10.0, 30.0, 40.0 },{ 0, 0, 0 } };double polyLineClosest[3];polyLine->GetPointIds()->SetNumberOfIds(3);polyLine->GetPointIds()->SetId(0, 0);polyLine->GetPointIds()->SetId(1, 1);polyLine->GetPointIds()->SetId(2, 2);polyLine->GetPoints()->SetNumberOfPoints(3);polyLine->GetPoints()->SetPoint(0, 10.0, 20.0, 30.0);polyLine->GetPoints()->SetPoint(1, 10.0, 30.0, 30.0);polyLine->GetPoints()->SetPoint(2, 10.0, 30.0, 40.0);n = sizeof(polyLinePoint) / (3 * sizeof(double));for (j = 0; j < n; j++){polyLine->EvaluatePosition(&polyLinePoint[j][0], &polyLineClosest[0], subId, &polyLineCoords[0],dist2, &polyLineWeights[0]);strm << "vtkPolyLine (" << polyLinePoint[j][0] << ", " << polyLinePoint[j][1] << ", "<< polyLinePoint[j][2] << ")" << endl;strm << "\tclosest: " << polyLineClosest[0] << ", " << polyLineClosest[1] << ", "<< polyLineClosest[2] << endl;strm << "\tcoords: " << polyLineCoords[0] << endl;strm << "\tweights: " << polyLineWeights[0] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;strm << endl;}

4. Triangle最近点

  // TrianglevtkTriangle* triangle = vtkTriangle::New();double triangleCoords[3], triangleWeights[3], trianglePosition[3];double trianglePoint[4][3] = { { 10.0, 10.0, 10.0 }, { 12.0, 10.0, 10.0 }, { 11.0, 12.0, 12.0 },{ 11, 11, 11 } };double triangleClosest[3];triangle->GetPointIds()->SetId(0, 0);triangle->GetPointIds()->SetId(1, 1);triangle->GetPointIds()->SetId(2, 2);triangle->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);triangle->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);triangle->GetPoints()->SetPoint(2, 11.0, 12.0, 12.0);n = sizeof(trianglePoint) / (3 * sizeof(double));for (j = 0; j < n; j++){triangle->EvaluatePosition(&trianglePoint[j][0], &triangleClosest[0], subId, &triangleCoords[0],dist2, &triangleWeights[0]);strm << "vtkTriangle (" << trianglePoint[j][0] << ", " << trianglePoint[j][1] << ", "<< trianglePoint[j][2] << ")" << endl;strm << "\tclosest: " << triangleClosest[0] << ", " << triangleClosest[1] << ", "<< triangleClosest[2] << endl;strm << "\tcoords: " << triangleCoords[0] << ", " << triangleCoords[1] << ", "<< triangleCoords[2] << endl;strm << "\tweights: " << triangleWeights[0] << ", " << triangleWeights[1] << ", "<< triangleWeights[2] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;triangle->EvaluateLocation(subId, triangleCoords, trianglePosition, triangleWeights);strm << "\tposition: " << trianglePosition[0] << ", " << trianglePosition[1] << ", "<< trianglePosition[2] << endl;strm << endl;}

5. TriangleStrip最近点

 // Triangle StripvtkTriangleStrip* triangleStrip = vtkTriangleStrip::New();double triangleStripCoords[3], triangleStripWeights[4], triangleStripPosition[3];double triangleStripPoint[5][3] = { { 10.0, 10.0, 10.0 }, { 12.0, 10.0, 10.0 },{ 11.0, 12.0, 10.0 }, { 13, 10, 10 }, { 11, 11, 10 } };double triangleStripClosest[3];triangleStrip->GetPointIds()->SetNumberOfIds(4);triangleStrip->GetPointIds()->SetId(0, 0);triangleStrip->GetPointIds()->SetId(1, 1);triangleStrip->GetPointIds()->SetId(2, 2);triangleStrip->GetPointIds()->SetId(3, 3);triangleStrip->GetPoints()->SetNumberOfPoints(4);triangleStrip->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);triangleStrip->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);triangleStrip->GetPoints()->SetPoint(2, 11.0, 12.0, 10.0);triangleStrip->GetPoints()->SetPoint(3, 13.0, 10.0, 10.0);n = sizeof(triangleStripPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){triangleStrip->EvaluatePosition(&triangleStripPoint[j][0], &triangleStripClosest[0], subId,&triangleStripCoords[0], dist2, &triangleStripWeights[0]);strm << "vtkTriangleStrip (" << triangleStripPoint[j][0] << ", " << triangleStripPoint[j][1]<< ", " << triangleStripPoint[j][2] << ")" << endl;strm << "\tclosest: " << triangleStripClosest[0] << ", " << triangleStripClosest[1] << ", "<< triangleStripClosest[2] << endl;strm << "\tcoords: " << triangleStripCoords[0] << ", " << triangleStripCoords[1] << ", "<< triangleStripCoords[2] << endl;strm << "\tweights: " << triangleStripWeights[0] << ", " << triangleStripWeights[1] << ", "<< triangleStripWeights[2] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;triangleStrip->EvaluateLocation(subId, triangleStripCoords, triangleStripPosition, triangleStripWeights);strm << "\tposition: " << triangleStripPosition[0] << ", " << triangleStripPosition[1] << ", "<< triangleStripPosition[2] << endl;strm << endl;}

6. Quad最近点

  // QuadvtkQuad* quad = vtkQuad::New();double quadCoords[3], quadWeights[4], quadPosition[3];double quadPoint[5][3] = { { 10.0, 10.0, 10.0 }, { 12.0, 10.0, 10.0 }, { 12.0, 12.0, 10.0 },{ 10, 12, 10 }, { 11, 11, 10.1 } };double quadClosest[3];quad->GetPointIds()->SetId(0, 0);quad->GetPointIds()->SetId(1, 1);quad->GetPointIds()->SetId(2, 2);quad->GetPointIds()->SetId(3, 3);quad->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);quad->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);quad->GetPoints()->SetPoint(2, 12.0, 12.0, 10.0);quad->GetPoints()->SetPoint(3, 10.0, 12.0, 10.0);n = sizeof(quadPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){quad->EvaluatePosition(&quadPoint[j][0], &quadClosest[0], subId, &quadCoords[0], dist2, &quadWeights[0]);strm << "vtkQuad (" << quadPoint[j][0] << ", " << quadPoint[j][1] << ", " << quadPoint[j][2]<< ")" << endl;strm << "\tclosest: " << quadClosest[0] << ", " << quadClosest[1] << ", " << quadClosest[2]<< endl;strm << "\tcoords: " << quadCoords[0] << ", " << quadCoords[1] << endl;strm << "\tweights: " << quadWeights[0] << ", " << quadWeights[1] << ", " << quadWeights[2]<< ", " << quadWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;quad->EvaluateLocation(subId, quadCoords, quadPosition, quadWeights);strm << "\tposition: " << quadPosition[0] << ", " << quadPosition[1] << ", " << quadPosition[2]<< endl;strm << endl;}

7. Pixee最近点

  // PixelvtkPixel* pixel = vtkPixel::New();double pixelCoords[3], pixelWeights[4], pixelPosition[3];double pixelPoint[5][3] = { { 10.0, 10.0, 10.0 }, { 12.0, 10.0, 10.0 }, { 12.0, 12.0, 10.0 },{ 10, 12, 10 }, { 11, 11, 10.1 } };double pixelClosest[3];pixel->GetPointIds()->SetId(0, 0);pixel->GetPointIds()->SetId(1, 1);pixel->GetPointIds()->SetId(2, 3);pixel->GetPointIds()->SetId(3, 2);pixel->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);pixel->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);pixel->GetPoints()->SetPoint(3, 12.0, 12.0, 10.0);pixel->GetPoints()->SetPoint(2, 10.0, 12.0, 10.0);n = sizeof(pixelPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){pixel->EvaluatePosition(&pixelPoint[j][0], &pixelClosest[0], subId, &pixelCoords[0], dist2, &pixelWeights[0]);strm << "vtkPixel (" << pixelPoint[j][0] << ", " << pixelPoint[j][1] << ", " << pixelPoint[j][2]<< ")" << endl;strm << "\tclosest: " << pixelClosest[0] << ", " << pixelClosest[1] << ", " << pixelClosest[2]<< endl;strm << "\tcoords: " << pixelCoords[0] << ", " << pixelCoords[1] << endl;strm << "\tweights: " << pixelWeights[0] << ", " << pixelWeights[1] << ", " << pixelWeights[2]<< ", " << pixelWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;pixel->EvaluateLocation(subId, pixelCoords, pixelPosition, pixelWeights);strm << "\tposition: " << pixelPosition[0] << ", " << pixelPosition[1] << ", "<< pixelPosition[2] << endl;strm << endl;}

8. polygon最近点

  // PolygonvtkPolygon* polygon = vtkPolygon::New();double polygonCoords[3], polygonWeights[4], polygonPosition[3];double polygonPoint[5][3] = { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 1.0, 1.0, 0.0 },{ 0, 1, 0 }, { .5, .5, 0 } };double polygonClosest[3];polygon->GetPointIds()->SetNumberOfIds(4);polygon->GetPointIds()->SetId(0, 0);polygon->GetPointIds()->SetId(1, 1);polygon->GetPointIds()->SetId(2, 2);polygon->GetPointIds()->SetId(3, 3);polygon->GetPoints()->SetNumberOfPoints(4);polygon->GetPoints()->SetPoint(0, 0.0, 0.0, 0.0);polygon->GetPoints()->SetPoint(1, 1.0, 0.0, 0.0);polygon->GetPoints()->SetPoint(2, 1.0, 1.0, 0.0);polygon->GetPoints()->SetPoint(3, 0.0, 1.0, 0.0);n = sizeof(polygonPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){polygon->EvaluatePosition(&polygonPoint[j][0], &polygonClosest[0], subId, &polygonCoords[0], dist2, &polygonWeights[0]);strm << "vtkPolygon (" << polygonPoint[j][0] << ", " << polygonPoint[j][1] << ", "<< polygonPoint[j][2] << ")" << endl;strm << "\tclosest: " << polygonClosest[0] << ", " << polygonClosest[1] << ", "<< polygonClosest[2] << endl;strm << "\tcoords: " << polygonCoords[0] << ", " << polygonCoords[1] << endl;strm << "\tweights: " << polygonWeights[0] << ", " << polygonWeights[1] << ", "<< polygonWeights[2] << ", " << polygonWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;polygon->EvaluateLocation(subId, polygonCoords, polygonPosition, polygonWeights);strm << "\tposition: " << polygonPosition[0] << ", " << polygonPosition[1] << ", "<< polygonPosition[2] << endl;strm << endl;}

9. Tetra最近点

  // TetravtkTetra* tetra = vtkTetra::New();double tetraCoords[3], tetraWeights[4], tetraPosition[3];double tetraPoint[5][3] = { { 10, 10, 10 }, { 12, 10, 10 }, { 11, 12, 10 }, { 11, 11, 12 },{ 11, 11, 11 } };double tetraClosest[3];tetra->GetPointIds()->SetNumberOfIds(4);tetra->GetPointIds()->SetId(0, 0);tetra->GetPointIds()->SetId(1, 1);tetra->GetPointIds()->SetId(2, 2);tetra->GetPointIds()->SetId(3, 3);tetra->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);tetra->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);tetra->GetPoints()->SetPoint(2, 11.0, 12.0, 10.0);tetra->GetPoints()->SetPoint(3, 11.0, 11.0, 12.0);n = sizeof(tetraPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){tetra->EvaluatePosition(&tetraPoint[j][0], &tetraClosest[0], subId, &tetraCoords[0], dist2, &tetraWeights[0]);strm << "vtkTetra (" << tetraPoint[j][0] << ", " << tetraPoint[j][1] << ", " << tetraPoint[j][2]<< ")" << endl;strm << "\tclosest: " << tetraClosest[0] << ", " << tetraClosest[1] << ", " << tetraClosest[2]<< endl;strm << "\tcoords: " << tetraCoords[0] << ", " << tetraCoords[1] << ", " << tetraCoords[2]<< endl;strm << "\tweights: " << tetraWeights[0] << ", " << tetraWeights[1] << ", " << tetraWeights[2]<< ", " << tetraWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;tetra->EvaluateLocation(subId, tetraCoords, tetraPosition, tetraWeights);strm << "\tposition: " << tetraPosition[0] << ", " << tetraPosition[1] << ", "<< tetraPosition[2] << endl;strm << endl;}

10. voxel最近点

// VoxelvtkVoxel* voxel = vtkVoxel::New();double voxelCoords[3], voxelWeights[8], voxelPosition[3];double voxelPoint[9][3] = { { 10, 10, 10 }, { 12, 10, 10 }, { 12, 12, 10 }, { 10, 12, 10 },{ 10, 10, 12 }, { 12, 10, 12 }, { 12, 12, 12 }, { 10, 12, 12 }, { 11, 11, 11 } };double voxelClosest[3];voxel->GetPointIds()->SetNumberOfIds(8);voxel->GetPointIds()->SetId(0, 0);voxel->GetPointIds()->SetId(1, 1);voxel->GetPointIds()->SetId(2, 3);voxel->GetPointIds()->SetId(3, 2);voxel->GetPointIds()->SetId(4, 4);voxel->GetPointIds()->SetId(5, 5);voxel->GetPointIds()->SetId(6, 7);voxel->GetPointIds()->SetId(7, 6);voxel->GetPoints()->SetPoint(0, 10, 10, 10);voxel->GetPoints()->SetPoint(1, 12, 10, 10);voxel->GetPoints()->SetPoint(3, 12, 12, 10);voxel->GetPoints()->SetPoint(2, 10, 12, 10);voxel->GetPoints()->SetPoint(4, 10, 10, 12);voxel->GetPoints()->SetPoint(5, 12, 10, 12);voxel->GetPoints()->SetPoint(7, 12, 12, 12);voxel->GetPoints()->SetPoint(6, 10, 12, 12);n = sizeof(voxelPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){voxel->EvaluatePosition(&voxelPoint[j][0], &voxelClosest[0], subId, &voxelCoords[0], dist2, &voxelWeights[0]);strm << "vtkVoxel (" << voxelPoint[j][0] << ", " << voxelPoint[j][1] << ", " << voxelPoint[j][2]<< ")" << endl;strm << "\tclosest: " << voxelClosest[0] << ", " << voxelClosest[1] << ", " << voxelClosest[2]<< endl;strm << "\tcoords: " << voxelCoords[0] << ", " << voxelCoords[1] << ", " << voxelCoords[2]<< endl;strm << "\tweights: " << voxelWeights[0] << ", " << voxelWeights[1] << ", " << voxelWeights[2]<< ", " << voxelWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;voxel->EvaluateLocation(subId, voxelCoords, voxelPosition, voxelWeights);strm << "\tposition: " << voxelPosition[0] << ", " << voxelPosition[1] << ", "<< voxelPosition[2] << endl;strm << endl;}

11. wedge最近点

  // WedgevtkWedge* wedge = vtkWedge::New();double wedgeCoords[3], wedgeWeights[8], wedgePosition[3];double wedgePoint[9][3] = { { 10, 10, 10 }, { 12, 10, 10 }, { 11, 12, 10 }, { 10, 10, 12 },{ 12, 10, 12 }, { 11, 12, 12 }, { 11, 11, 11 } };double wedgeClosest[3];wedge->GetPointIds()->SetNumberOfIds(6);wedge->GetPointIds()->SetId(0, 0);wedge->GetPointIds()->SetId(1, 1);wedge->GetPointIds()->SetId(2, 2);wedge->GetPointIds()->SetId(3, 3);wedge->GetPointIds()->SetId(4, 4);wedge->GetPointIds()->SetId(5, 5);wedge->GetPoints()->SetPoint(0, 10, 10, 10);wedge->GetPoints()->SetPoint(1, 12, 10, 10);wedge->GetPoints()->SetPoint(2, 11, 12, 10);wedge->GetPoints()->SetPoint(3, 10, 10, 12);wedge->GetPoints()->SetPoint(4, 12, 10, 12);wedge->GetPoints()->SetPoint(5, 11, 12, 12);n = sizeof(wedgePoint) / (3 * sizeof(double));for (j = 0; j < n; j++){wedge->EvaluatePosition(&wedgePoint[j][0], &wedgeClosest[0], subId, &wedgeCoords[0], dist2, &wedgeWeights[0]);strm << "vtkWedge (" << wedgePoint[j][0] << ", " << wedgePoint[j][1] << ", " << wedgePoint[j][2]<< ")" << endl;strm << "\tclosest: " << wedgeClosest[0] << ", " << wedgeClosest[1] << ", " << wedgeClosest[2]<< endl;strm << "\tcoords: " << wedgeCoords[0] << ", " << wedgeCoords[1] << ", " << wedgeCoords[2]<< endl;strm << "\tweights: " << wedgeWeights[0] << ", " << wedgeWeights[1] << ", " << wedgeWeights[2]<< ", " << wedgeWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;wedge->EvaluateLocation(subId, wedgeCoords, wedgePosition, wedgeWeights);strm << "\tposition: " << wedgePosition[0] << ", " << wedgePosition[1] << ", "<< wedgePosition[2] << endl;strm << endl;}

12. Hexahedron最近点

 // HexahedronvtkHexahedron* hexahedron = vtkHexahedron::New();double hexahedronCoords[3], hexahedronWeights[8], hexahedronPosition[3];double hexahedronPoint[9][3] = { { 10, 10, 10 }, { 12, 10, 10 }, { 12, 12, 10 }, { 10, 12, 10 },{ 10, 10, 12 }, { 12, 10, 12 }, { 12, 12, 12 }, { 10, 12, 12 }, { 11, 11, 11 } };double hexahedronClosest[3];hexahedron->GetPointIds()->SetNumberOfIds(8);hexahedron->GetPointIds()->SetId(0, 0);hexahedron->GetPointIds()->SetId(1, 1);hexahedron->GetPointIds()->SetId(2, 2);hexahedron->GetPointIds()->SetId(3, 3);hexahedron->GetPointIds()->SetId(4, 4);hexahedron->GetPointIds()->SetId(5, 5);hexahedron->GetPointIds()->SetId(6, 6);hexahedron->GetPointIds()->SetId(7, 7);hexahedron->GetPoints()->SetPoint(0, 10, 10, 10);hexahedron->GetPoints()->SetPoint(1, 12, 10, 10);hexahedron->GetPoints()->SetPoint(2, 12, 12, 10);hexahedron->GetPoints()->SetPoint(3, 10, 12, 10);hexahedron->GetPoints()->SetPoint(4, 10, 10, 12);hexahedron->GetPoints()->SetPoint(5, 12, 10, 12);hexahedron->GetPoints()->SetPoint(6, 12, 12, 12);hexahedron->GetPoints()->SetPoint(7, 10, 12, 12);n = sizeof(hexahedronPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){hexahedron->EvaluatePosition(&hexahedronPoint[j][0], &hexahedronClosest[0], subId,&hexahedronCoords[0], dist2, &hexahedronWeights[0]);strm << "vtkHexahedron (" << hexahedronPoint[j][0] << ", " << hexahedronPoint[j][1] << ", "<< hexahedronPoint[j][2] << ")" << endl;strm << "\tclosest: " << hexahedronClosest[0] << ", " << hexahedronClosest[1] << ", "<< hexahedronClosest[2] << endl;strm << "\tcoords: " << hexahedronCoords[0] << ", " << hexahedronCoords[1] << ", "<< hexahedronCoords[2] << endl;strm << "\tweights: " << hexahedronWeights[0] << ", " << hexahedronWeights[1] << ", "<< hexahedronWeights[2] << ", " << hexahedronWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;hexahedron->EvaluateLocation(subId, hexahedronCoords, hexahedronPosition, hexahedronWeights);strm << "\tposition: " << hexahedronPosition[0] << ", " << hexahedronPosition[1] << ", "<< hexahedronPosition[2] << endl;strm << endl;}

13. pentagonal prism最近点

// Pentagonal PrismvtkPentagonalPrism* penta = vtkPentagonalPrism::New();double pentaCoords[3], pentaWeights[10], pentaPosition[3];double pentaPoint[11][3] = { { 11, 10, 10 }, { 13, 10, 10 }, { 14, 12, 10 }, { 12, 14, 10 },{ 10, 12, 10 }, { 11, 10, 14 }, { 13, 10, 14 }, { 14, 12, 14 }, { 12, 14, 14 }, { 10, 12, 14 },{ 12, 12, 12 } };double pentaClosest[3];penta->GetPointIds()->SetNumberOfIds(10);penta->GetPointIds()->SetId(0, 0);penta->GetPointIds()->SetId(1, 1);penta->GetPointIds()->SetId(2, 2);penta->GetPointIds()->SetId(3, 3);penta->GetPointIds()->SetId(4, 4);penta->GetPointIds()->SetId(5, 5);penta->GetPointIds()->SetId(6, 6);penta->GetPointIds()->SetId(7, 7);penta->GetPointIds()->SetId(8, 8);penta->GetPointIds()->SetId(9, 9);penta->GetPoints()->SetPoint(0, 11, 10, 10);penta->GetPoints()->SetPoint(1, 13, 10, 10);penta->GetPoints()->SetPoint(2, 14, 12, 10);penta->GetPoints()->SetPoint(3, 12, 14, 10);penta->GetPoints()->SetPoint(4, 10, 12, 10);penta->GetPoints()->SetPoint(5, 11, 10, 14);penta->GetPoints()->SetPoint(6, 13, 10, 14);penta->GetPoints()->SetPoint(7, 14, 12, 14);penta->GetPoints()->SetPoint(8, 12, 14, 14);penta->GetPoints()->SetPoint(9, 10, 12, 14);n = sizeof(pentaPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){penta->EvaluatePosition(&pentaPoint[j][0], &pentaClosest[0], subId, &pentaCoords[0], dist2, &pentaWeights[0]);strm << "vtkPentagonalPrism (" << pentaPoint[j][0] << ", " << pentaPoint[j][1] << ", "<< pentaPoint[j][2] << ")" << endl;strm << "\tclosest: " << pentaClosest[0] << ", " << pentaClosest[1] << ", " << pentaClosest[2]<< endl;strm << "\tcoords: " << pentaCoords[0] << ", " << pentaCoords[1] << ", " << pentaCoords[2]<< endl;strm << "\tweights: " << pentaWeights[0] << ", " << pentaWeights[1] << ", " << pentaWeights[2]<< ", " << pentaWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;penta->EvaluateLocation(subId, pentaCoords, pentaPosition, pentaWeights);strm << "\tposition: " << pentaPosition[0] << ", " << pentaPosition[1] << ", "<< pentaPosition[2] << endl;strm << endl;}

14. Hexagonal prism最近点

 // Hexagonal PrismvtkHexagonalPrism* hexa = vtkHexagonalPrism::New();double hexaCoords[3], hexaWeights[12], hexaPosition[3];double hexaPoint[13][3] = { { 11, 10, 10 }, { 13, 10, 10 }, { 14, 12, 10 }, { 13, 14, 10 },{ 11, 14, 10 }, { 10, 12, 10 }, { 11, 10, 14 }, { 13, 10, 14 }, { 14, 12, 14 }, { 13, 14, 14 },{ 11, 14, 14 }, { 10, 12, 14 }, { 12, 12, 12 } };double hexaClosest[3];hexa->GetPointIds()->SetNumberOfIds(12);hexa->GetPointIds()->SetId(0, 0);hexa->GetPointIds()->SetId(1, 1);hexa->GetPointIds()->SetId(2, 2);hexa->GetPointIds()->SetId(3, 3);hexa->GetPointIds()->SetId(4, 4);hexa->GetPointIds()->SetId(5, 5);hexa->GetPointIds()->SetId(6, 6);hexa->GetPointIds()->SetId(7, 7);hexa->GetPointIds()->SetId(8, 8);hexa->GetPointIds()->SetId(9, 9);hexa->GetPointIds()->SetId(10, 10);hexa->GetPointIds()->SetId(11, 11);hexa->GetPoints()->SetPoint(0, 11, 10, 10);hexa->GetPoints()->SetPoint(1, 13, 10, 10);hexa->GetPoints()->SetPoint(2, 14, 12, 10);hexa->GetPoints()->SetPoint(3, 13, 14, 10);hexa->GetPoints()->SetPoint(4, 11, 14, 10);hexa->GetPoints()->SetPoint(5, 10, 12, 10);hexa->GetPoints()->SetPoint(6, 11, 10, 14);hexa->GetPoints()->SetPoint(7, 13, 10, 14);hexa->GetPoints()->SetPoint(8, 14, 12, 14);hexa->GetPoints()->SetPoint(9, 13, 14, 14);hexa->GetPoints()->SetPoint(10, 11, 14, 14);hexa->GetPoints()->SetPoint(11, 10, 12, 14);n = sizeof(hexaPoint) / (3 * sizeof(double));for (j = 0; j < n; j++){hexa->EvaluatePosition(&hexaPoint[j][0], &hexaClosest[0], subId, &hexaCoords[0], dist2, &hexaWeights[0]);strm << "vtkHexagonalPrism (" << hexaPoint[j][0] << ", " << hexaPoint[j][1] << ", "<< hexaPoint[j][2] << ")" << endl;strm << "\tclosest: " << hexaClosest[0] << ", " << hexaClosest[1] << ", " << hexaClosest[2]<< endl;strm << "\tcoords: " << hexaCoords[0] << ", " << hexaCoords[1] << ", " << hexaCoords[2] << endl;strm << "\tweights: " << hexaWeights[0] << ", " << hexaWeights[1] << ", " << hexaWeights[2]<< ", " << hexaWeights[3] << endl;strm << "\tsubid: " << subId << endl;strm << "\tdist2: " << dist2 << endl;hexa->EvaluateLocation(subId, hexaCoords, hexaPosition, hexaWeights);strm << "\tposition: " << hexaPosition[0] << ", " << hexaPosition[1] << ", " << hexaPosition[2]<< endl;strm << endl;}ids->Delete();vertex->Delete();polyVertex->Delete();line->Delete();polyLine->Delete();triangle->Delete();triangleStrip->Delete();quad->Delete();pixel->Delete();polygon->Delete();tetra->Delete();voxel->Delete();wedge->Delete();hexahedron->Delete();penta->Delete();hexa->Delete();

15. 注意

        Weights[]数组的大小与输入的vtkPoints的个数相关。

 

结论:

感谢各位小伙伴的点赞+关注,小易会继续努力分享,一起进步!

你的赞赏是我的最最最最大的动力(^U^)ノ~YO

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/277081.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在windows系统搭建LVGL模拟器(codeblock工程)

1.codeblock准备 下载codeblock(mingw)&#xff0c;安装。可参考网上教程。 2.pc_simulator_win_codeblocks 工程获取 仓库地址&#xff1a;lvgl/lv_port_win_codeblocks: Windows PC simulator project for LVGL embedded GUI Library (github.com) 拉取代码到本地硬盘&…

攻防世界题目练习——Web引导模式(五)(持续更新)

题目目录 1. FlatScience2. bug3. Confusion1 1. FlatScience 参考博客&#xff1a; 攻防世界web进阶区FlatScience详解 题目点进去如图&#xff0c;点击链接只能看到一些论文pdf 用dirsearch和御剑扫描出一些隐藏文件&#xff1a; robots.txt: admin.php: login.php: f…

影视视频+知识付费行业万能通用响应式网站系统源码 三网合一 带完整的安装部署教程

互联网的快速发展&#xff0c;网络视频和知识付费行业也迎来了前所未有的发展机遇。为了满足这一市场的需求&#xff0c;基于响应式网站技术的万能通用影视视频知识付费行业网站系统便由此应运而生。本系统集成了三网合一的解决方案&#xff0c;旨在帮助用户快速搭建高品质、高…

flutter的SingleChildScrollView控件详解

文章目录 SingleChildScrollView的介绍和使用场景详细介绍 SingleChildScrollView的介绍和使用场景 SingleChildScrollView 是 Flutter 中的一个小部件&#xff0c;用于创建一个可滚动的单个子部件。它通常用于处理内容超出屏幕可见区域的情况&#xff0c;允许用户通过滚动来查…

2024年视频监控行业发展趋势预测及EasyCVR视频分析技术应用

随着技术的改进&#xff0c;视频监控领域在过去十年迅速发展。与此同时&#xff0c;该行业正在通过先进创新技术&#xff08;如人工智能和云计算等技术&#xff09;的积极商业化&#xff0c;获得了新的增长机会。视频监控系统不再仅仅用于记录图像&#xff0c;而是已经成为全球…

3. cgal 示例 GIS (Geographic Information System)

GIS (Geographic Information System) 地理信息系统 原文地址: https://doc.cgal.org/latest/Manual/tuto_gis.html GIS 应用中使用的许多传感器&#xff08;例如激光雷达&#xff09;都会生成密集的点云。此类应用程序通常利用更先进的数据结构&#xff1a;例如&#xff0c;不…

学习使用echarts漏斗图的参数配置和应用场景

学习使用echarts漏斗图的参数配置和应用场景 前言什么是漏斗图漏斗图的特点及应用场景漏斗图的特点漏斗图常见的的应用场景&#xff1a; echarts中漏斗的常用属性echart漏斗代码美化漏斗图样式1、设置标题字体大小2、设置标签样式3、设置漏斗图为渐变颜色4、设置高亮效果5、设置…

速学数据结构 | 树 森林 二叉树 的概念详讲篇

&#x1f3ac; 鸽芷咕&#xff1a;个人主页 &#x1f525; 个人专栏:《速学数据结构》 《C语言进阶篇》 ⛺️生活的理想&#xff0c;就是为了理想的生活! &#x1f4cb; 前言 &#x1f308;hello&#xff01; 各位宝子们大家好啊&#xff0c;关于线性表我们已经在前面更新完了…

MES安灯管理:优化生产监控的重要工具

一、MES安灯管理的概念 MES安灯管理是一种基于物理安灯和数字化管理的生产异常管理工具。它通过物理安灯和数字化系统的结合&#xff0c;实现对生产异常的实时监控和及时反馈&#xff0c;从而帮助企业快速响应和解决生产异常&#xff0c;提高生产效率和产品质量。 二、MES系统…

mysql:通过INFORMATION_SCHEMA数据库查询表的元信息

使用SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA database_name AND TABLE_NAME table_name;查询某个表的元信息。其中database_name替换为数据库名称&#xff0c;table_name替换为表的名称。 例如&#xff0c;下面语句&#xff0c;查询development数据库中…

【C++初阶】类与对象(上)

类与对象&#xff08;上&#xff09; 1.面向过程和面向对象初步认识2.类的引入3.类的定义4.类的访问限定符及封装4.1 访问限定符4.2 封装 5.类的作用域6.类的实例化7.类对象模型7.1 如何计算类对象的大小7.2 结构体内存对齐规则 8.this指针8.1 this指针的引出8.2 this指针的特性…

前端必备-http知识

在掘金查看该文章 计算机网络五层模型 1.物理层 (Physical Layer) 关键词 光纤,电缆,双绞线,连接 物理层要解决的主要问题&#xff1a; &#xff08;1&#xff09;物理层要尽可能地屏蔽掉物理设备和传输媒体&#xff0c;通信手段的不同&#xff0c;使数据链路层感觉不到这些…