Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTK postprocessing in FEM workbench #166

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
64e59bf
FEM Post: Proof of concept
ickby Apr 19, 2015
deea84e
FEM Post: Move post processing to fem objects
ickby Oct 25, 2015
de8d098
FEM Post: Basic implementation of filter framework
ickby Oct 31, 2015
38a7769
FEM Post: Detail filter infrastructure
ickby Nov 6, 2015
932d691
FEM Post: Command for creation of post pipeline from result
ickby Nov 14, 2015
7b6de3f
FEM Post: Add warp vector filter
ickby Nov 14, 2015
4365a37
FEM Post: Add cut filter
ickby Nov 15, 2015
0ea3c16
FEM Post: Add icons for fem post processing
ickby Nov 15, 2015
6307d9d
FEM Post: Fix crash on gui dialog only
ickby Nov 15, 2015
30f762a
FEM Post: Update function manipulators
ickby Nov 19, 2015
e89d96c
FEM Post: Fix crash due to wrong initalisation
ickby Nov 20, 2015
207319f
FEM Post: Add icons
ickby Nov 20, 2015
5176b1a
FEM Post: FreeCADify the vtk post processing
ickby Jan 1, 2016
31b73b7
FEM Post: Fix and extend file handling
ickby Jan 1, 2016
87e41f3
FEM Post: Clean up work
ickby Jan 1, 2016
264c289
FEM Post: Fix cutter error and "remove crashs"
ickby Jan 1, 2016
719de9d
FEM Post: Give access to cmake BUILD variables from python
ickby Feb 27, 2016
51554bb
FEM Post: Add missing property files
ickby Feb 27, 2016
5cd7f29
FEM Post: import VTK types only when possible
ickby Feb 27, 2016
2350728
FEM Post: Remove unused files
ickby Mar 19, 2016
4b8d2a9
FEM Post: integrate FreeCAD color system
ickby Mar 20, 2016
83760e0
FEM Post: Handle wireframe with internal wires
ickby Mar 20, 2016
593c6bd
FEM Post: fix vtk include wthout guard
ickby Apr 13, 2016
39f9323
FEM Post: Fix rebase errors
ickby May 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ if(APPLE)
endif(APPLE)

OPTION(BUILD_FEM "Build the FreeCAD FEM module, be aware, unfinished code!" ON)
OPTION(BUILD_FEM_VTK "Build the FreeCAD VTK Postprocessing support (need VTK 6 or higher)" OFF)
OPTION(BUILD_SANDBOX "Build the FreeCAD Sandbox module which is only for testing purposes" OFF)
OPTION(BUILD_TEMPLATE "Build the FreeCAD template module which is only for testing purposes" OFF)
OPTION(BUILD_ARCH "Build the FreeCAD Architecture module" ON)
Expand Down Expand Up @@ -752,6 +753,11 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

#---------------------------------------------------

# -------------------------------- VTK --------------------------------
if(BUILD_FEM_VTK)
find_package(VTK REQUIRED)
endif(BUILD_FEM_VTK)

if(BUILD_GUI)
# -------------------------------- OpenGL --------------------------------

Expand Down
3 changes: 3 additions & 0 deletions src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ using namespace boost::program_options;
// scriptings (scripts are build in but can be overridden by command line option)
#include "InitScript.h"
#include "TestScript.h"
#include "CMakeScript.h"

#ifdef _MSC_VER // New handler for Microsoft Visual C++ compiler
# include <new.h>
Expand Down Expand Up @@ -1292,6 +1293,7 @@ void Application::initApplication(void)
{
// interpreter and Init script ==========================================================
// register scripts
new ScriptProducer( "CMakeVariables", CMakeVariables );
new ScriptProducer( "FreeCADInit", FreeCADInit );
new ScriptProducer( "FreeCADTest", FreeCADTest );

Expand All @@ -1310,6 +1312,7 @@ void Application::initApplication(void)

// starting the init script
Console().Log("Run App init script\n");
Interpreter().runString(Base::ScriptFactory().ProduceScript("CMakeVariables"));
Interpreter().runString(Base::ScriptFactory().ProduceScript("FreeCADInit"));
}

Expand Down
19 changes: 19 additions & 0 deletions src/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,25 @@ ENDIF(DOCDIR)

add_definitions(-DBOOST_${Boost_VERSION})

#write relevant cmake variables to a file for later access with python. Exportet are all variables
#starting with BUILD. As the variable only exists if the user set it to ON a dict is useless, we
#use a python list for export.
set(_vars "const char CMakeVariables[] =\"cmake = [")
set(_delim "")
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
if (${_variableName})
STRING(REGEX MATCH "^[_]?[^_]*" _prefix "${_variableName}_")
if(${_prefix} STREQUAL "BUILD")
STRING(REPLACE "\\" "\\\\" _name ${_variableName})
set(_vars "${_vars}${_delim}\\n\"\n\"\\\"${_name}\\\"")
set(_delim ",")
endif()
endif ()
endforeach()
set(_vars "${_vars}]\\n\" \n;")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CMakeScript.h "${_vars}" )

include_directories(
${CMAKE_BINARY_DIR}/src
${CMAKE_SOURCE_DIR}/src
Expand Down
3 changes: 3 additions & 0 deletions src/App/FreeCADInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def InitApplications():
Wrn = FreeCAD.Console.PrintWarning
test_ascii = lambda s: all(ord(c) < 128 for c in s)

#store the cmake variales
App.__cmake__ = cmake;

Log ('Init: starting App::FreeCADInit.py\n')

# init every application by importing Init.py
Expand Down
23 changes: 22 additions & 1 deletion src/Mod/Fem/App/AppFem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@
#include "FemResultObject.h"
#include "FemSolverObject.h"

#ifdef FC_USE_VTK
#include "FemPostPipeline.h"
#include "FemPostFilter.h"
#include "FemPostFunction.h"
#include "PropertyPostDataObject.h"
#endif

namespace Fem {
extern PyObject* initModule();
}
Expand Down Expand Up @@ -142,7 +149,21 @@ PyMODINIT_FUNC initFem()
Fem::ConstraintDisplacement ::init();

Fem::FemResultObject ::init();
Fem::FemResultObjectPython ::init();
Fem::FemSolverObject ::init();
Fem::FemSolverObjectPython ::init();

#ifdef FC_USE_VTK
Fem::FemPostObject ::init();
Fem::FemPostPipeline ::init();
Fem::FemPostFilter ::init();
Fem::FemPostClipFilter ::init();
Fem::FemPostScalarClipFilter ::init();
Fem::FemPostWarpVectorFilter ::init();
Fem::FemPostCutFilter ::init();
Fem::FemPostFunction ::init();
Fem::FemPostFunctionProvider ::init();
Fem::FemPostPlaneFunction ::init();
Fem::FemPostSphereFunction ::init();
Fem::PropertyPostDataObject ::init();
#endif
}
42 changes: 33 additions & 9 deletions src/Mod/Fem/App/AppFemPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#include "FemMesh.h"
#include "FemMeshObject.h"
#include "FemMeshPy.h"
#ifdef FC_USE_VTK
#include "FemPostPipeline.h"
#endif

#include <cstdlib>

Expand Down Expand Up @@ -163,16 +166,37 @@ class Module : public Py::ExtensionModule<Module>
pcDoc = App::GetApplication().newDocument(DocName);
}

std::auto_ptr<FemMesh> mesh(new FemMesh);
mesh->read(EncodedName.c_str());
Base::FileInfo file(EncodedName.c_str());

FemMeshObject *pcFeature = static_cast<FemMeshObject *>
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->FemMesh.setValuePtr(mesh.get());
(void)mesh.release();
pcFeature->purgeTouched();

try {
std::auto_ptr<FemMesh> mesh(new FemMesh);
mesh->read(EncodedName.c_str());

FemMeshObject *pcFeature = static_cast<FemMeshObject *>
(pcDoc->addObject("Fem::FemMeshObject", file.fileNamePure().c_str()));
pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->FemMesh.setValuePtr(mesh.get());
(void)mesh.release();
pcFeature->purgeTouched();
}
catch(Base::Exception& e) {
#ifdef FC_USE_VTK
if( FemPostPipeline::canRead(file) ) {

FemPostPipeline *pcFeature = static_cast<FemPostPipeline *>
(pcDoc->addObject("Fem::FemPostPipeline", file.fileNamePure().c_str()));

pcFeature->Label.setValue(file.fileNamePure().c_str());
pcFeature->read(file);
pcFeature->touch();
pcDoc->recomputeFeature(pcFeature);
}
else
throw e;
#else
throw e;
#endif
}

return Py::None();
}
Expand Down
42 changes: 28 additions & 14 deletions src/Mod/Fem/App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,29 @@ include_directories(

link_directories(${OCC_LIBRARY_DIR})


if(BUILD_FEM_NETGEN)
set(Fem_LIBS
set(Fem_LIBS
Part
FreeCADApp
StdMeshers
NETGENPlugin
SMESH
SMDS
SMESHDS
)
else(BUILD_FEM_NETGEN)

if(BUILD_FEM_NETGEN)
set(Fem_LIBS
Part
FreeCADApp
StdMeshers
SMESH
SMDS
SMESHDS
${Fem_LIBS}
NETGENPlugin
)
endif(BUILD_FEM_NETGEN)

if(BUILD_FEM_VTK)
set(Fem_LIBS
${Fem_LIBS}
${VTK_LIBRARIES}
)
endif(BUILD_FEM_VTK)

generate_from_xml(FemMeshPy)


Expand Down Expand Up @@ -121,7 +122,6 @@ SET(FemScripts_SRCS
FemSelectionObserver.py
TestFem.py
z88DispReader.py

TaskPanelFemBeamSection.ui
TaskPanelFemShellThickness.ui
TaskPanelFemSolverCalculix.ui
Expand Down Expand Up @@ -199,15 +199,29 @@ SET(FemConstraints_SRCS
)
SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS})

SET(FemResult_SRCS
if(BUILD_FEM_VTK)
SET(FemPost_SRCS
PropertyPostDataObject.h
PropertyPostDataObject.cpp
FemPostObject.h
FemPostObject.cpp
FemPostPipeline.h
FemPostPipeline.cpp
FemPostFilter.h
FemPostFilter.cpp
FemPostFunction.h
FemPostFunction.cpp
)
SOURCE_GROUP("ResultObjects" FILES ${FemResult_SRCS})
SOURCE_GROUP("PostObjects" FILES ${FemPost_SRCS})
endif(BUILD_FEM_VTK)


SET(Fem_SRCS
${FemBase_SRCS}
${FemSet_SRCS}
${FemConstraints_SRCS}
${FemResult_SRCS}
${FemPost_SRCS}
${Mod_SRCS}
${Python_SRCS}
)
Expand Down
Loading