MCPcopy Create free account
hub / github.com/Kitware/VTK / ClipBox

Method ClipBox

Filters/General/vtkBoxClipDataSet.cxx:1892–2376  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Clip each cell of an unstructured grid. ------------------------------------------------------------------------------ (1) How decide when the cell is NOT outside Explaining with an example in 2D. Look at 9 region in the picture and the triangle represented there. v0,v1,v2 are vertices of triangle T. | | 1

Source from the content-addressed store, hash-verified

1890//------------------------------------------------------------------------------
1891//
1892void vtkBoxClipDataSet::ClipBox(vtkPoints* newPoints, vtkGenericCell* cell,
1893 vtkIncrementalPointLocator* locator, vtkCellArray* tets, vtkPointData* inPD, vtkPointData* outPD,
1894 vtkCellData* inCD, vtkIdType cellId, vtkCellData* outCD)
1895{
1896 vtkIdType cellType = cell->GetCellType();
1897 vtkIdList* cellIds = cell->GetPointIds();
1898 vtkCellArray* arraytetra = vtkCellArray::New();
1899 vtkPoints* cellPts = cell->GetPoints();
1900 vtkIdType npts = cellPts->GetNumberOfPoints();
1901 std::vector<vtkIdType> cellptId(npts);
1902 vtkIdType iid[4];
1903 const vtkIdType* v_id = nullptr;
1904 vtkIdType *verts, v1, v2;
1905 vtkIdType ptId;
1906 vtkIdType tab_id[6];
1907 vtkIdType ptstetra = 4;
1908
1909 vtkIdType i, j;
1910 unsigned int allInside;
1911 unsigned int idcellnew;
1912 unsigned int cutInd;
1913
1914 /* Edges Tetrahedron */
1915 vtkIdType edges[6][2] = {
1916 { 0, 1 },
1917 { 1, 2 },
1918 { 2, 0 },
1919 { 0, 3 },
1920 { 1, 3 },
1921 { 2, 3 },
1922 };
1923 double value, deltaScalar;
1924 double t;
1925 double *p1, *p2;
1926 double x[3], v[3];
1927 double v_tetra[4][3];
1928
1929 for (i = 0; i < npts; i++)
1930 {
1931 cellptId[i] = cellIds->GetId(i);
1932 }
1933
1934 // Convert all volume cells to tetrahedra
1935 this->CellGrid(cellType, npts, cellptId.data(), arraytetra);
1936 unsigned int totalnewtetra = arraytetra->GetNumberOfCells();
1937 unsigned int idtetranew;
1938
1939 for (idtetranew = 0; idtetranew < totalnewtetra; idtetranew++)
1940 {
1941 arraytetra->GetNextCell(ptstetra, v_id);
1942
1943 for (allInside = 1, i = 0; i < 4; i++)
1944 {
1945 cellPts->GetPoint(v_id[i], v);
1946
1947 if (!(((v[0] >= this->BoundBoxClip[0][0]) && (v[0] <= this->BoundBoxClip[0][1]) &&
1948 (v[1] >= this->BoundBoxClip[1][0]) && (v[1] <= this->BoundBoxClip[1][1]) &&
1949 (v[2] >= this->BoundBoxClip[2][0]) && (v[2] <= this->BoundBoxClip[2][1]))))

Callers 1

RequestDataMethod · 0.95

Calls 15

CellGridMethod · 0.95
InterpolateEdgeMethod · 0.95
CreateTetraMethod · 0.95
DeleteMethod · 0.65
NewFunction · 0.50
GetCellTypeMethod · 0.45
GetPointIdsMethod · 0.45
GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetIdMethod · 0.45
dataMethod · 0.45
GetNumberOfCellsMethod · 0.45

Tested by

no test coverage detected