vtk: Modelling examples not working (Delaunay3D, finance etc) - c++

I'm new to vtk, and I've succesfully built vtk 8.1.1 from source, using Cmake and Visual Studio 2017, with the default options and examples.
I've already solved an issue with the Infovis folder examples.
Now, I'm trying to run the examples from the Modelling folder:
The problem is that when I try to run these examples, it opens a window that closes so fast I can't even see what it says, so I have no clue about the error.
The Delaunay3D.cxx file begins with these comments:
`// Delaunay3D
// Usage: Delaunay3D InputFile(.vtp) OutputFile(.vtu)
// where
// InputFile is an XML PolyData file with extension .vtp
// OutputFile is an XML Unstructured Grid file with extension .vtu
`
So it looks like I need external data files, and the same is true for the other examples. But, where do I get these files, and where do I place them?

Some of the examples in the source files are not complete i.e. as you found out, some of them require external input files which may be missing or mistakes in CMakeLists.txt etc. In the parent folder of the folder that you have attached screenshot of (i.e. the Modelling directory) there is also a folder for Python examples. In that folder, there is a Delaunay3D.py file which creates random points as input instead of reading them from file. So you can do the same. The names and signatures of functions in Python and C++ are the same by modifying the Delaunay3D.cxx code or adding some code in the TestDelaunay3D.cxx. But there is no such file for the finance example, unfortunately.
I find it useful to use VTK code along with Paraview. Paraview is built on top of VTK. It has most of the VTK filters available through the GUI. In Paraview you can also create some data and save it to file using File->Save Data. You can then use that as input for the examples. Once you become familiar with VTK file types and VTK sources, generating data does not require a lot of code. So you can do it yourself by modifying any of the example code (like it is done in the Delaunay3D.py).
About where to place the input files, in this particular case you can place them anywhere but when you run the executable that was built, you must enter the path of the input file correctly on the command line.
Updates based on comments:
The Python wrappers provide almost complete features available with the C++ version. The exceptions are noted here. If you decide to use VTK Python then a good resource to read is the VTK Numpy interface.
Paraview implements a majority of VTK filters and sources. So it can do a lot of creation and modification of geometries. In addition, you can use programmable filters and sources for doing things which are not available through Gui. In the programmable filters you can write any Python script which can import vtk and use all its functionality.
But if for your use case you only need a subset of the functionality Paraview provides then you may want to write your own GUI.

Related

How to use the documentation of C++ code inside an IDE on linux?

Up to now i tried Eclipse, KDevelop and Code::Blocks.
Code::Blocks (12.11) seems not to be able to display documentation at all.
Eclipse (4.3.2) is able to display the documentation of at least the standard libraries during code completion and on hover, but it looks like there is no way to generate or add custom documentation. By now I was able to use DoxygenCPPInfo to convert the xml documentation to a "Java Serialization Data" file, which is useable by libhover. But the documentation is only visible on hover, but not on code completion.
KDevelop (4.7) does only show the comment, which normally contains the documentation, on hover and a heavily shortened version on code completion.
Is there another IDE or something else I could do to benefit from in code documentation while writing new code?
DoxygenCPPInfo can be compiled using the following files from eclipse-linuxtools:
ClassInfo.java
FunctionInfo.java
LibHoverInfo.java
MemberInfo.java
TypedefInfo.java
DoxygenCPPInfo.java
The xml documentation needs to be in one file to be used with DoxygenCPPInfo. This can be done by using xsltproc with combine.xslt and index.xml as input files. The final output of DoxygenCPPInfo can be placed in workspace/.metadata/.plugins/org.eclipse.linuxtools.cdt.libhover/CPP/ and will be loaded on next start of eclipse using that workspace. The documentation is only shown on hover and not on code completion.
You want to document a function in one file and use that function in another file. While using that function you want to reference the documentation written earlier in a tooltip without having to compile the first file. This can be done easily in kdevelop ide. There are not much IDEs I have come across that provide such ease of cross-referencing. Eclipse lib-hover plugin for C but it is clunky and I have had trouble working with that earlier. Here is the link to kdevelop-handbook .
Documenting in doxygen style in kdevelop

Documentation on virtual folders

I am looking for documentation for the Windows API on how to make virtual folders. I am going to make sort of my own file system and would like to have an icon under "Computer" for that file system. I have seen other programs which has this type of solution like programs which allows me to explore a Linux file system under in the Explorer program. Much like the same solution I am going to make. I am yet to find any documentation on how to do this, or am I searching for the wrong stuff? Thanks.
You are looking for a Shell Namespace Extension. An entry Point for documentation is Creating Shell Data Source Objects and Extending the Shell Namespace.
An example of a almost complete Project can be found on codeplex: An almost complete Namespace Extension Sample
Also in the Windows SDK 7, there is an example of using the Shell ExtensionNamespace (can be found in the folder "Microsoft SDKs\Windows\v7.1\Samples\winui\shell\shellextensibility\explorerdataprovider"). In this Folder you will also find a document which describes the programming model (Using the System Folder View.doc).
If you really want to create a "real" file System Driver, you might want to look at this SO article:
Creating a File System "Driver" which mainly referes to the Ext2 file system driver project.

Q_IMPORT_PLUGIN compiling error with qgif and qjpeg plugin

I have some problem when a try to build my code upon the 4.7.4 dynamic version. I have linkage error because of the 2 following lines :
Q_IMPORT_PLUGIN(qgif)
Q_IMPORT_PLUGIN(qjpeg)
To resolve the problem i just commented the above lines. Now everything compile correctly, which is strange. Does that mean that the code is not using the plugin (look a stupid question, but the project has several hundred thousand lines, i don,t know every part of it)
Question : What is the purpose of qgif and qjped plugin. Should i expect code using explicitly functions form these plugins?
I just want to be sure that i will not broke something by committing these lines...
You'll only need those if you're linking the plugins statically. Since you're using the dynamic version, you don't need them, and can safely leave them out. You simply need to place the plugin DLL or SO files adjacent executable. If you open up the installation where you installed the Qt libraries to (in my case, G:\Libraries\Qt\4.7.1), you'll see a directory called 'plugins' which you can copy and paste into your project, adjacent to your executable.
As for the purpose of those plugins, they add support to QImage and the other Qt image related components for addition file formats so you can read and write, with varying levels of support. The level of support can be found here, under Reading and Writing Image Files.

Find out the mime type and associated applications with Qt

How can I find out a mime-type or content-type of a given file?
I cannot use the suffix because the file could be renamed.
Possible additions would be categorizing them as jpg, gif, png and so on are image files and can be opened by editing applications, which has been set in the OS.
Thank you in advance.
What platform? On *nix, you should refer to how the program file does it, which is based on a few heuristics including checks of the first few bytes of a file (many file formats start with a fixed header, including many image formats).
If you're on Windows, the *nix file command is probably still instructive, even if you can't reuse its code as directly. There may also be some better solution in the Windows APIs (I'm not a Windows programmer).
This could help, it is with C# but I think you can get the idea.
http://kseesharp.blogspot.com/2008/04/c-get-mimetype-from-file-name.html
You can use some sort of class for acccesing Windows Registry from qt or using the Windows API directly from qt.
I am not a qt programmer.
You can't, not from within Qt.
However, if all you want is to show a file with the correct application, you can use QDesktopServices::openUrl(), which wraps open (Windows/OSX) and xdg-open (Unix). The URL may also be a local file (in that case, use QUrl::fromLocalFile() to construct the URL).
For categorizing image files. For Qt and just only for image files.
QByteArray imageFormat = QImageReader::imageFormat(fileName); //Where fileName - path to your file
Further mapping imageFormat to mime-type is not complicable
It doesn't look like Qt offers that capability yet. However, you may want to look into the libmagic library which does what the file and other similar commands do. Assuming the library is maintained properly it will include new MIME types as time passes. From what I can tell it is part of the file tool suite. Under a Debian system do something like this:
sudo apt-get install libmagic-dev
to get the development library and use #include to make use of it.

File formats with included versioning

I like the idea of using compressed folders as containers for file formats. They are used for LibreOffice or Dia. So if I want to define a special purpose file format, I can define a folder and file structure and just zip the root folder and have a single file with all the data in a single file. Imported files just live as originals inside the compressed file. Defining a binary file format from zero with this features would be a lot of work.
Now to my question: Are there applications which are using compressed folders as file formats and do versioning inside the folder? The benefits would be great. You could just commit a state in your project into your file and the versioning is just decorated with functions from your own application. Also diffs could be presented your own way.
Libraries for working with compressed files and for versioning are available. The used versioning system should be a distributed system, where the repository lives inside your working folder and not seperate as for example subversion with its client-server model.
What do you think? I'm sure there are applications out there using this approach, but I couldn't find one. Or is there a major drawback in this approach?
Sounds like an interesting idea.
I know many applications claim they have "unlimited" undo and redo,
but that's only back to the most recent time I opened this file.
With your system, your application could "undo" to previous versions of the file,
even before the version I saw the most recent time I opened this file -- that might be a nifty feature.
Have you looked at TortoiseHg?
TortoiseHg uses Mercurial, which is
"a distributed system, where the repository lives inside your working folder".
Rather than defining a new compressed versioned file format and all the software to work with it from scratch,
perhaps you could use the Mercurial file format and borrow the TortoiseHg and Mercurial source code to work with it.
What happens if I'm working on a project using 2 different applications,
and each application wants to store the entire project in its own slightly different compressed versioned file format?
What I found now is that OpenOffice aka LibreOffice has kind of versioning inside. LibreOffice file is a zip file with a structured content (XMLs, direcories, ...) inside. You are able to mark the current content as a version. This results in creating a VersionList.xml which contains information about all the versions. A Versions directory is added and this contains files like Version1, Version2 and so on. These files are the actual documents at that state.