Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
zippy84 committed Jan 4, 2024
1 parent fa92c71 commit 25a5ec6
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 196 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2012-2023 Ronald Römer
# Copyright 2012-2024 Ronald Römer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ from vtkbool.vtkBool import vtkPolyDataBooleanFilter

## Errors and their meaning

- *First/Second input does not contain any supported cells.*

What it says. Look at the Features.

- *Bad shaped cells detected.*

At least one cell has a bad shape. For a cell with more than three points: not all points lie on the plane defined by the calculated surface normal.
Expand Down Expand Up @@ -239,7 +235,7 @@ from vtkbool.vtkBool import vtkPolyDataBooleanFilter

## Copyright

2012-2023 Ronald Römer
2012-2024 Ronald Römer

## License

Expand Down
10 changes: 5 additions & 5 deletions Utilities.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2023 Ronald Römer
Copyright 2012-2024 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ limitations under the License.

#include <vtkPolyDataWriter.h>

void ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *poly) {
double ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *poly) {
n[0] = 0; n[1] = 0; n[2] = 0;

if (num == 3) {
Expand Down Expand Up @@ -59,7 +59,7 @@ void ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *p
}
}

vtkMath::Normalize(n);
return vtkMath::Normalize(n);
}

bool CheckNormal (vtkPoints *pts, vtkIdType num, const vtkIdType *poly, const double *n, double d) {
Expand Down Expand Up @@ -173,7 +173,7 @@ void BackTransform (const double *in, double *out, const Base &base) {
out[2] = z;
}

void ComputeNormal (const Poly &poly, double *n) {
double ComputeNormal (const Poly &poly, double *n) {
n[0] = 0; n[1] = 0; n[2] = 0;

Poly::const_iterator itrA, itrB;
Expand All @@ -193,7 +193,7 @@ void ComputeNormal (const Poly &poly, double *n) {
n[2] += (ptA.x-ptB.x)*(ptA.y+ptB.y);
}

vtkMath::Normalize(n);
return vtkMath::Normalize(n);
}

bool PointInPoly (const Poly &poly, const Point3d &p) {
Expand Down
6 changes: 3 additions & 3 deletions Utilities.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2023 Ronald Römer
Copyright 2012-2024 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@ limitations under the License.
double GetAngle (const double *vA, const double *vB, const double *n);

/* VTK */
void ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *poly);
double ComputeNormal (vtkPoints *pts, double *n, vtkIdType num, const vtkIdType *poly);
bool CheckNormal (vtkPoints *pts, vtkIdType num, const vtkIdType *poly, const double *n, double d);

void FindPoints (vtkKdTreePointLocator *pl, const double *pt, vtkIdList *pts, double tol = 1e-6);
Expand Down Expand Up @@ -127,7 +127,7 @@ std::ostream& operator<< (typename std::enable_if<std::is_enum<T>::value, std::o
typedef std::vector<Point3d> Poly;
typedef std::vector<Poly> PolysType;

void ComputeNormal (const Poly &poly, double *n);
double ComputeNormal (const Poly &poly, double *n);
bool PointInPoly (const Poly &poly, const Point3d &p);

void WritePolys (const char *name, const PolysType &polys);
Expand Down
2 changes: 1 addition & 1 deletion testing/generate_frieze.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# *-* coding: UTF-8 *-*

# Copyright 2012-2023 Ronald Römer
# Copyright 2012-2024 Ronald Römer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion testing/test_filter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# *-* coding: UTF-8 *-*

# Copyright 2012-2023 Ronald Römer
# Copyright 2012-2024 Ronald Römer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion testing/test_merger.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2023 Ronald Römer
Copyright 2012-2024 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion testing/test_python.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# *-* coding: UTF-8 *-*

# Copyright 2012-2023 Ronald Römer
# Copyright 2012-2024 Ronald Römer
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
16 changes: 8 additions & 8 deletions vtkPolyDataBooleanFilter.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2023 Ronald Römer
Copyright 2012-2024 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1831,7 +1831,7 @@ void vtkPolyDataBooleanFilter::RestoreOrigPoints (vtkPolyData *pd, PolyStripsTyp
std::cout << "RestoreOrigPoints()" << std::endl;
#endif

pd->BuildLinks();
pd->DeleteLinks(); pd->BuildLinks();

vtkKdTreePointLocator *loc = vtkKdTreePointLocator::New();
loc->SetDataSet(pd);
Expand Down Expand Up @@ -1873,7 +1873,7 @@ void vtkPolyDataBooleanFilter::DisjoinPolys (vtkPolyData *pd, PolyStripsType &po
std::cout << "DisjoinPolys()" << std::endl;
#endif

pd->BuildLinks();
pd->DeleteLinks(); pd->BuildLinks();

vtkKdTreePointLocator *loc = vtkKdTreePointLocator::New();
loc->SetDataSet(pd);
Expand Down Expand Up @@ -2093,7 +2093,7 @@ void vtkPolyDataBooleanFilter::AddAdjacentPoints (vtkPolyData *pd, vtkIdTypeArra
std::cout << "AddAdjacentPoints()" << std::endl;
#endif

pd->BuildLinks();
pd->DeleteLinks(); pd->BuildLinks();

vtkIdTypeArray *origCellIds = vtkIdTypeArray::SafeDownCast(pd->GetCellData()->GetScalars("OrigCellIds"));

Expand Down Expand Up @@ -2282,9 +2282,9 @@ void vtkPolyDataBooleanFilter::MergePoints (vtkPolyData *pd, PolyStripsType &pol
#endif

pd->BuildCells();
pd->BuildLinks();
pd->DeleteLinks(); pd->BuildLinks();

contLines->BuildLinks();
contLines->DeleteLinks(); contLines->BuildLinks();

auto loc = vtkSmartPointer<vtkKdTreePointLocator>::New();
loc->SetDataSet(pd);
Expand Down Expand Up @@ -2739,8 +2739,8 @@ bool vtkPolyDataBooleanFilter::CombineRegions () {
plB->SetDataSet(pdB);
plB->BuildLocator();

pdA->BuildLinks();
pdB->BuildLinks();
pdA->DeleteLinks(); pdA->BuildLinks();
pdB->DeleteLinks(); pdB->BuildLinks();

vtkIdTypeArray *scalarsA = vtkIdTypeArray::SafeDownCast(pdA->GetPointData()->GetScalars());
vtkIdTypeArray *scalarsB = vtkIdTypeArray::SafeDownCast(pdB->GetPointData()->GetScalars());
Expand Down
2 changes: 1 addition & 1 deletion vtkPolyDataBooleanFilter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2023 Ronald Römer
Copyright 2012-2024 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading

0 comments on commit 25a5ec6

Please sign in to comment.