All Projects β†’ zippy84 β†’ vtkbool

zippy84 / vtkbool

Licence: Apache-2.0 License
A new boolean operations filter for VTK

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
python
139335 projects - #7 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vtkbool

Matplotplusplus
Matplot++: A C++ Graphics Library for Data Visualization πŸ“ŠπŸ—Ύ
Stars: ✭ 2,433 (+3059.74%)
Mutual labels:  scientific-computing, graphics-library
Cgal
The public CGAL repository, see the README below
Stars: ✭ 2,825 (+3568.83%)
Mutual labels:  meshes, boolean-operations
trame
Trame let you weave various components and technologies into a Web Application solely written in Python.
Stars: ✭ 50 (-35.06%)
Mutual labels:  vtk, paraview
bitpit
Open source library for scientific HPC
Stars: ✭ 80 (+3.9%)
Mutual labels:  scientific-computing, meshes
getfem
Mirror of GetFEM repository
Stars: ✭ 23 (-70.13%)
Mutual labels:  scientific-computing, vtk
gis-snippets
Some code snippets for GIS tasks
Stars: ✭ 45 (-41.56%)
Mutual labels:  vtk, paraview
PVGeo
🌍 Python package of VTK-based algorithms to analyze geoscientific data and models
Stars: ✭ 156 (+102.6%)
Mutual labels:  vtk, paraview
NPY-for-Fortran
A FORTRAN module to write Numpy's *.npy and *.npz files
Stars: ✭ 30 (-61.04%)
Mutual labels:  scientific-computing
CoppeliaSim-VR-Toolbox
This repository contains the code to experience CoppeliaSim in VR
Stars: ✭ 24 (-68.83%)
Mutual labels:  vtk
source
The main source repository for the Raysect project.
Stars: ✭ 62 (-19.48%)
Mutual labels:  scientific-computing
siconos
Simulation framework for nonsmooth dynamical systems
Stars: ✭ 120 (+55.84%)
Mutual labels:  scientific-computing
stripy
2D spherical and Cartesian triangulation toolkit using tripack, stripack, srfpack and ssrfpack
Stars: ✭ 33 (-57.14%)
Mutual labels:  meshes
ampscan
ampscan is an open-source Python package for analysis and visualisation of digitised surface scan data, specifically for applications within Prosthetics and Orthotics (P&O), with an aim to improve evidence-based clinical practice towards improved patient outcomes.
Stars: ✭ 14 (-81.82%)
Mutual labels:  vtk
rocket viewer
This simple and generic viewer allows you to visualize different kinds of data such as medical and biological images, 3D surfaces, electric signals (ECGs) and documents.
Stars: ✭ 22 (-71.43%)
Mutual labels:  vtk
fw4spl
Main repository for fw4spl
Stars: ✭ 30 (-61.04%)
Mutual labels:  vtk
ameshref
Efficient Matlab Implementation of Adaptive Mesh Refinement in 2D
Stars: ✭ 28 (-63.64%)
Mutual labels:  meshes
DataSciPy
Data Science with Python
Stars: ✭ 15 (-80.52%)
Mutual labels:  scientific-computing
monolish
monolish: MONOlithic LInear equation Solvers for Highly-parallel architecture
Stars: ✭ 166 (+115.58%)
Mutual labels:  scientific-computing
ls1-mardyn
ls1-MarDyn is a massively parallel Molecular Dynamics (MD) code for large systems. Its main target is the simulation of thermodynamics and nanofluidics. ls1-MarDyn is designed with a focus on performance and easy extensibility.
Stars: ✭ 17 (-77.92%)
Mutual labels:  scientific-computing
python-data-science-project
Template repository for a Python 3-based (data) science project
Stars: ✭ 54 (-29.87%)
Mutual labels:  scientific-computing

vtkbool Travis CI Build Status Appveyor Build Status Coverage Status

About

This is an extension of the graphics library VTK. The goal of the extension is to equip the library with boolean operations on polygonal meshes. I started the project at the end of my studies in mechanical engineering at the University of Applied Sciences (HTWK) in Leipzig. I used VTK to develop a program, which I had to create for a paper. At this time I would have wished, that this feature already exists. There was several implementations from third parties, but after some tests, I came to the conclusion, that none of them worked correct. I decided to start with my own implementation. This library is the result of my efforts.

Donation

You can support my project with PayPal.

Features

  • no extra libraries required
  • triangulation is not needed
  • non-convex polygons are allowed
  • only the involved polygons are modified
  • meshes can be stacked (coplanar polygons are right handled)
  • 4 operation types (union, intersection, difference and difference2 - difference with interchanged operands)
  • all types of polygonal cells are supported (triangles, quads, polygons, triangle-strips)
  • the meshes don’t need to be closed
  • CellData is passed (attached by the rules of vtkAppendPolyData)
  • original cell ids are added to CellData (OrigCellIdsA and OrigCellIdsB as vtkIntArray)
  • contact lines are available
  • non-convex polygons are decomposed
  • the filter is able to embed holes
  • it is also a plugin for ParaView
  • Python wrapped

Limitations

  • correctness depends on the polygon-defining normals (use vtkPolyDataNormals if you have problems with incorrect orientations)
  • PointData is not preserved - you have to do your own mapping

Todo

  • the filter needs a mesh optimizer for sharp-angled triangles and non-planar polygons

Requirements

  • CMake >= 3.1
  • VTK >= 6.1
  • C++11 compiler

Optional

  • ParaView >= 5.0
  • Python 2.7 or 3.x

Library

To include vtkbool into your program, you have to compile it as a library. All you need is an installation of VTK with header files. If you have installed VTK over your package manager, CMake is able to find the required files. Otherwise you have to set VTK_DIR manually. It must be a path like /home/zippy/VTK6/lib/cmake/vtk-6.3 or C:/Users/zippy/VTK6/lib/cmake/vtk-6.3.

The usage of the library is very simple. Look at testing.cxx and you can see how. Upon creating the instance of the boolean-filter and connecting the two inputs with the pipeline, you can choose between different operation types, in different manners. You can set the operation mode by calling one of the named methods:

  • SetOperModeToUnion
  • SetOperModeToIntersection
  • SetOperModeToDifference
  • SetOperModeToDifference2

The alternative is the more generic SetOperMode. The method must be called with the number of the desired operation, an integer between 0 and 3, with the same meaning as mentioned before. After updating the pipeline, the result is stored in the first output, typically accessable with GetOutputPort(). The second output, GetOutputPort(1), contains the lines of contact between the inputs. The inputs must be outputs of filters or sources returning vtkPolyData. The outputs from this filter are of the same type.

Other options are MergeRegs and DecPolys.

The first option is used in testing and is deactivated by default. It ignors the OperMode and mergs all divided regions into the output. If you don't want to combine the regions yourself, don't use it.

The second option controls whether non-convex polygons will be decomposed into convex polygons. Only the created polygons will be decomposed. The option is activated by default and it has to stay activated, if you want to triangulate the mesh with vtkTriangleFilter.

Example

Create a directory somewhere in your file system, download vtkbool and unpack it into that. Then create the following two files:

exp.cxx

#include <vtkCubeSource.h>
#include <vtkCylinderSource.h>

#include "vtkPolyDataBooleanFilter.h"

int Point::_tag = 0; // important

int main (int argc, char *argv[]) {
    vtkCubeSource *cu = vtkCubeSource::New();
    cu->SetYLength(.5);

    vtkCylinderSource *cyl = vtkCylinderSource::New();
    cyl->SetResolution(32);
    cyl->SetHeight(.5);
    cyl->SetCenter(0, .5, 0);

    vtkPolyDataBooleanFilter *bf = vtkPolyDataBooleanFilter::New();
    bf->SetInputConnection(0, cu->GetOutputPort());
    bf->SetInputConnection(1, cyl->GetOutputPort());
    bf->SetOperModeToDifference();
    bf->Update();

    bf->Delete();
    cyl->Delete();
    cu->Delete();

    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.1)
project(exp)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(vtkbool-master)

add_subdirectory(vtkbool-master)

find_package(VTK REQUIRED COMPONENTS vtkFiltersSources NO_MODULE)
include(${VTK_USE_FILE})

include_directories(vtkbool-master/libs/vp)

add_executable(exp exp.cxx)
target_link_libraries(exp ${VTK_LIBRARIES} vtkbool)

Also create a directory named build. If you are on Linux, open a terminal and enter this directory. Run ccmake .., follow the instructions, and finally type make.

ParaView Plugin

To build the plugin you have to compile ParaView from source. Download the current version from http://www.paraview.org and follow the compilation instructions. As soon as ParaView is compiled, it may take a while, you can build the plugin by activating the VTKBOOL_PARAVIEW option within CMake. In CMake you also have to point to ParaView_DIR if CMake can't found it and it is not installed in a common location like /usr/lib or /usr/local/lib. Make sure PARAVIEW_INSTALL_DEVELOPMENT_FILES is set.

When everything has been compiled successfully, you can install the plugin. For that purpose I made screenshots from the necessary steps. You can find them under paraview_plugin/install/. There is also a screenshot of how to use it.

Python

The Python module will be generated automatically, if three conditions are met:

  • vtkbool is configured as a library
  • Python 2 or 3 is installed with header files
  • VTK itself is wrapped to Python

After a successful compilation, the module can be used as follows:

import sys
sys.path.append('/path/to/your/build/directory')

import vtk
import vtkboolPython

cube = vtk.vtkCubeSource()

sphere = vtk.vtkSphereSource()
sphere.SetCenter(.5, .5, .5)
sphere.SetThetaResolution(20)
sphere.SetPhiResolution(20)

boolean = vtkboolPython.vtkPolyDataBooleanFilter()
boolean.SetInputConnection(0, cube.GetOutputPort())
boolean.SetInputConnection(1, sphere.GetOutputPort())
boolean.SetOperModeToDifference()

# write the result, if you want ...

writer = vtk.vtkPolyDataWriter()
writer.SetInputConnection(boolean.GetOutputPort())
writer.SetFileName('result.vtk')

writer.Update()

Copyright

2012-2020 Ronald RΓΆmer

License

Apache License, Version 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].