Skip to content

Commit

Permalink
fallback of merger extended 2
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy84 committed Aug 20, 2023
1 parent ad078e6 commit c5870fb
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 12,059 deletions.
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ else()

set_property(TEST "import_vtkbool" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")

add_test(NAME "generate_frieze"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/generate_frieze.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)

set_property(TEST "generate_frieze" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")

add_test(NAME "test_filter"
COMMAND ${Python3_EXECUTABLE} -m pytest
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)
Expand All @@ -131,6 +125,12 @@ else()
COMMAND test_merger
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)

add_test(NAME "generate_frieze"
COMMAND ${Python3_EXECUTABLE} ${CMAKE_SOURCE_DIR}/testing/generate_frieze.py
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testing)

set_property(TEST "generate_frieze" APPEND PROPERTY ENVIRONMENT "PYTHONPATH=${CMAKE_BINARY_DIR}/${python_default_destination}/vtkbool")

endif()

endif()
Expand Down
11,708 changes: 0 additions & 11,708 deletions testing/data/milling/sphere1.vtk

This file was deleted.

115 changes: 0 additions & 115 deletions testing/data/milling/tube1.vtk

This file was deleted.

93 changes: 0 additions & 93 deletions testing/milling/milling.py

This file was deleted.

17 changes: 0 additions & 17 deletions testing/test_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,23 +695,6 @@ def test_non_manifolds():

check_result(bf)

def test_adjacent_pts(tmp_path):
readerA = vtkPolyDataReader()
readerA.SetFileName('data/milling/sphere1.vtk')

readerB = vtkPolyDataReader()
readerB.SetFileName('data/milling/tube1.vtk')

bf = vtkPolyDataBooleanFilter()
bf.SetInputConnection(0, readerA.GetOutputPort())
bf.SetInputConnection(1, readerB.GetOutputPort())
bf.SetOperModeToNone()

bf.Update()

write_result(bf, tmp_path)
check_result(bf, [3, 3])

def test_branched(tmp_path):
reader = vtkPolyDataReader()
reader.SetFileName('data/branched.vtk')
Expand Down
33 changes: 26 additions & 7 deletions testing/test_merger.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

#include <string>
#include <cmath>

#include <vtkCellData.h>
#include <vtkCellArrayIterator.h>
#include <vtkIdTypeArray.h>
Expand Down Expand Up @@ -46,7 +49,12 @@ Poly Draw (double r, vtkIdType step, double x, double y, double rotate = 0) {
return poly;
}

bool Test (PolysType &polys, vtkIdType numCells) {
bool Test (PolysType &polys, vtkIdType numCells, const char *name) {
std::string fileName(name);
fileName.append(".vtk");

WritePolys(fileName.c_str(), polys);

auto pts = vtkSmartPointer<vtkPoints>::New();

auto pd = vtkSmartPointer<vtkPolyData>::New();
Expand Down Expand Up @@ -146,7 +154,10 @@ bool Test (PolysType &polys, vtkIdType numCells) {
}
}

// WriteVTK("merged.vtk", pd);
std::string mergedFileName(name);
mergedFileName.append("_merged.vtk");

WriteVTK(mergedFileName.c_str(), pd);

if (pd->GetNumberOfCells() != numCells) {
return false;
Expand All @@ -167,8 +178,6 @@ int main() {
Draw(.5, 6, 0, -1, 30)
};

WritePolys("polysA.vtk", polysA);

Poly a = Draw(4, 18, 0, 0, 10),
b = Draw(3, 18, 0, 0, 10);

Expand All @@ -180,13 +189,23 @@ int main() {
a
};

WritePolys("polysB.vtk", polysB);
const double y = 7.5-1.5/std::cos (M_PI/6)-std::tan (M_PI/6)*4.5;

PolysType polysC {
Poly({{0, 0, 0}, {25, 0, 0}, {25, 25, 0}, {0, 25, 0}}),
Poly({{2, 5, 0}, {17, 5, 0}, {17, 20, 0}, {2, 20, 0}, {7.5/std::tan (M_PI/6)+2, 12.5, 0}}),
Poly({{6.5, 12.5-y, 0}, {y/std::tan (M_PI/6)+6.5, 12.5, 0}, {6.5, 12.5+y, 0}})
};

if (!Test(polysA, 10, "polysA")) {
return EXIT_FAILURE;
}

if (!Test(polysA, 10)) {
if (!Test(polysB, 5, "polysB")) {
return EXIT_FAILURE;
}

if (!Test(polysB, 5)) {
if (!Test(polysC, 5, "polysC")) {
return EXIT_FAILURE;
}

Expand Down
Loading

0 comments on commit c5870fb

Please sign in to comment.