------------------------------------------------------------------------------ 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
| 1890 | //------------------------------------------------------------------------------ |
| 1891 | // |
| 1892 | void 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])))) |
no test coverage detected