FEM Post: Move post processing to fem objects
This commit is contained in:
@@ -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)" ON)
|
||||
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)
|
||||
@@ -196,7 +197,6 @@ OPTION(BUILD_START "Build the FreeCAD start module" ON)
|
||||
OPTION(BUILD_TEST "Build the FreeCAD test module" ON)
|
||||
OPTION(BUILD_WEB "Build the FreeCAD web module" ON)
|
||||
OPTION(BUILD_VR "Build the FreeCAD Oculus Rift support (need Oculus SDK 4.x or higher)" OFF)
|
||||
OPTION(BUILD_VTK "Build the FreeCAD VTK support (need VTK 6 or higher)" OFF)
|
||||
|
||||
if(MSVC)
|
||||
OPTION(BUILD_FEM_NETGEN "Build the FreeCAD FEM module with the NETGEN mesher" ON)
|
||||
@@ -754,12 +754,9 @@ endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
#---------------------------------------------------
|
||||
|
||||
# -------------------------------- VTK --------------------------------
|
||||
if(BUILD_VTK)
|
||||
find_package(VTK REQUIRED)
|
||||
add_definitions(-DFC_USE_VTK)
|
||||
|
||||
include(${VTK_USE_FILE})
|
||||
endif(BUILD_VTK)
|
||||
if(BUILD_FEM_VTK)
|
||||
find_package(VTK REQUIRED)
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
if(BUILD_GUI)
|
||||
# -------------------------------- OpenGL --------------------------------
|
||||
|
||||
@@ -115,13 +115,6 @@ if(PYSIDE_INCLUDE_DIR)
|
||||
)
|
||||
endif(PYSIDE_INCLUDE_DIR)
|
||||
|
||||
if(BUILD_VTK)
|
||||
set(FreeCADGui_LIBS
|
||||
${FreeCADGui_LIBS}
|
||||
${VTK_LIBRARIES}
|
||||
)
|
||||
endif(BUILD_VTK)
|
||||
|
||||
generate_from_xml(DocumentPy)
|
||||
generate_from_xml(PythonWorkbenchPy)
|
||||
generate_from_xml(ViewProviderPy)
|
||||
|
||||
@@ -115,13 +115,6 @@ if(PYSIDE_INCLUDE_DIR)
|
||||
)
|
||||
endif(PYSIDE_INCLUDE_DIR)
|
||||
|
||||
if(BUILD_VTK)
|
||||
set(FreeCADGui_LIBS
|
||||
${FreeCADGui_LIBS}
|
||||
${VTK_LIBRARIES}
|
||||
)
|
||||
endif(BUILD_VTK)
|
||||
|
||||
generate_from_xml(DocumentPy)
|
||||
generate_from_xml(PythonWorkbenchPy)
|
||||
generate_from_xml(ViewProviderPy)
|
||||
@@ -900,11 +893,10 @@ SET(Inventor_CPP_SRCS
|
||||
SoAxisCrossKit.cpp
|
||||
SoTextLabel.cpp
|
||||
SoTouchEvents.cpp
|
||||
<<<<<<< d7d347b2d62ec685840e7db1c35863e659148981
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
SoFCCSysDragger.cpp
|
||||
=======
|
||||
SoVTKActor.cpp
|
||||
>>>>>>> proof of concept
|
||||
>>>>>>> Move post processing to fem objects
|
||||
)
|
||||
SET(Inventor_SRCS
|
||||
${Inventor_CPP_SRCS}
|
||||
@@ -928,11 +920,10 @@ SET(Inventor_SRCS
|
||||
SoAxisCrossKit.h
|
||||
SoTextLabel.h
|
||||
SoTouchEvents.h
|
||||
<<<<<<< d7d347b2d62ec685840e7db1c35863e659148981
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
SoFCCSysDragger.h
|
||||
=======
|
||||
SoVTKActor.h
|
||||
>>>>>>> proof of concept
|
||||
>>>>>>> Move post processing to fem objects
|
||||
)
|
||||
SOURCE_GROUP("View3D\\Inventor" FILES ${Inventor_SRCS})
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <zipios++/gzipoutputstream.h>
|
||||
|
||||
#include "SoFCDB.h"
|
||||
#include "SoVTKActor.h"
|
||||
#include "SoFCColorBar.h"
|
||||
#include "SoFCColorLegend.h"
|
||||
#include "SoFCColorGradient.h"
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <zipios++/gzipoutputstream.h>
|
||||
|
||||
#include "SoFCDB.h"
|
||||
#include "SoVTKActor.h"
|
||||
#include "SoFCColorBar.h"
|
||||
#include "SoFCColorLegend.h"
|
||||
#include "SoFCColorGradient.h"
|
||||
|
||||
310
src/Gui/SoFCDB.cpp.orig.orig
Normal file
310
src/Gui/SoFCDB.cpp.orig.orig
Normal file
@@ -0,0 +1,310 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2005 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/actions/SoToVRML2Action.h>
|
||||
# include <Inventor/VRMLnodes/SoVRMLGroup.h>
|
||||
# include <Inventor/VRMLnodes/SoVRMLParent.h>
|
||||
# include <Inventor/SbString.h>
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
#endif
|
||||
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <zipios++/gzipoutputstream.h>
|
||||
|
||||
#include "SoFCDB.h"
|
||||
#include "SoFCColorBar.h"
|
||||
#include "SoFCColorLegend.h"
|
||||
#include "SoFCColorGradient.h"
|
||||
#include "SoFCSelection.h"
|
||||
#include "SoFCBackgroundGradient.h"
|
||||
#include "SoFCBoundingBox.h"
|
||||
#include "SoFCSelection.h"
|
||||
#include "SoFCUnifiedSelection.h"
|
||||
#include "SoFCSelectionAction.h"
|
||||
#include "SoFCInteractiveElement.h"
|
||||
#include "SoFCUnifiedSelection.h"
|
||||
#include "SoFCVectorizeSVGAction.h"
|
||||
#include "SoFCVectorizeU3DAction.h"
|
||||
#include "SoAxisCrossKit.h"
|
||||
#include "SoTextLabel.h"
|
||||
#include "SoNavigationDragger.h"
|
||||
#include "Inventor/SoDrawingGrid.h"
|
||||
#include "Inventor/SoAutoZoomTranslation.h"
|
||||
#include "Inventor/MarkerBitmaps.h"
|
||||
#include "SoFCCSysDragger.h"
|
||||
|
||||
#include "propertyeditor/PropertyItem.h"
|
||||
#include "NavigationStyle.h"
|
||||
#include "Flag.h"
|
||||
#include "SelectionObject.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::Inventor;
|
||||
using namespace Gui::PropertyEditor;
|
||||
|
||||
static SbBool init_done = false;
|
||||
static SoGroup *storage = nullptr;
|
||||
|
||||
SbBool Gui::SoFCDB::isInitialized(void)
|
||||
{
|
||||
return init_done;
|
||||
}
|
||||
|
||||
void Gui::SoFCDB::init()
|
||||
{
|
||||
SoInteraction ::init();
|
||||
RotTransDragger ::initClass();
|
||||
SoGLRenderActionElement ::initClass();
|
||||
SoFCInteractiveElement ::initClass();
|
||||
SoGLWidgetElement ::initClass();
|
||||
SoFCColorBarBase ::initClass();
|
||||
SoFCColorBar ::initClass();
|
||||
SoFCColorLegend ::initClass();
|
||||
SoFCColorGradient ::initClass();
|
||||
SoFCBackgroundGradient ::initClass();
|
||||
SoFCBoundingBox ::initClass();
|
||||
SoFCSelection ::initClass();
|
||||
SoFCUnifiedSelection ::initClass();
|
||||
SoFCSelectionAction ::initClass();
|
||||
SoFCDocumentAction ::initClass();
|
||||
SoGLWidgetNode ::initClass();
|
||||
SoFCEnableSelectionAction ::initClass();
|
||||
SoFCEnableHighlightAction ::initClass();
|
||||
SoFCSelectionColorAction ::initClass();
|
||||
SoFCHighlightColorAction ::initClass();
|
||||
SoFCDocumentObjectAction ::initClass();
|
||||
SoGLSelectAction ::initClass();
|
||||
SoVisibleFaceAction ::initClass();
|
||||
SoBoxSelectionRenderAction ::initClass();
|
||||
SoFCVectorizeSVGAction ::initClass();
|
||||
SoFCVectorizeU3DAction ::initClass();
|
||||
SoHighlightElementAction ::initClass();
|
||||
SoSelectionElementAction ::initClass();
|
||||
SoVRMLAction ::initClass();
|
||||
SoSkipBoundingGroup ::initClass();
|
||||
SoTextLabel ::initClass();
|
||||
SoStringLabel ::initClass();
|
||||
SoFrameLabel ::initClass();
|
||||
TranslateManip ::initClass();
|
||||
SoShapeScale ::initClass();
|
||||
SoAxisCrossKit ::initClass();
|
||||
SoRegPoint ::initClass();
|
||||
SoDrawingGrid ::initClass();
|
||||
SoAutoZoomTranslation ::initClass();
|
||||
MarkerBitmaps ::initClass();
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
SoFCCSysDragger ::initClass();
|
||||
=======
|
||||
>>>>>>> Move post processing to fem objects
|
||||
|
||||
PropertyItem ::init();
|
||||
PropertySeparatorItem ::init();
|
||||
PropertyStringItem ::init();
|
||||
PropertyFontItem ::init();
|
||||
PropertyIntegerItem ::init();
|
||||
PropertyIntegerConstraintItem ::init();
|
||||
PropertyFloatItem ::init();
|
||||
PropertyUnitItem ::init();
|
||||
PropertyFloatConstraintItem ::init();
|
||||
PropertyUnitConstraintItem ::init();
|
||||
PropertyAngleItem ::init();
|
||||
PropertyBoolItem ::init();
|
||||
PropertyVectorItem ::init();
|
||||
PropertyVectorDistanceItem ::init();
|
||||
PropertyMatrixItem ::init();
|
||||
PropertyPlacementItem ::init();
|
||||
PropertyEnumItem ::init();
|
||||
PropertyStringListItem ::init();
|
||||
PropertyFloatListItem ::init();
|
||||
PropertyIntegerListItem ::init();
|
||||
PropertyColorItem ::init();
|
||||
PropertyMaterialItem ::init();
|
||||
PropertyMaterialListItem ::init();
|
||||
PropertyFileItem ::init();
|
||||
PropertyPathItem ::init();
|
||||
PropertyTransientFileItem ::init();
|
||||
PropertyLinkItem ::init();
|
||||
|
||||
NavigationStyle ::init();
|
||||
UserNavigationStyle ::init();
|
||||
InventorNavigationStyle ::init();
|
||||
CADNavigationStyle ::init();
|
||||
BlenderNavigationStyle ::init();
|
||||
MayaGestureNavigationStyle ::init();
|
||||
TouchpadNavigationStyle ::init();
|
||||
GestureNavigationStyle ::init();
|
||||
OpenCascadeNavigationStyle ::init();
|
||||
|
||||
GLGraphicsItem ::init();
|
||||
GLFlagWindow ::init();
|
||||
|
||||
SelectionObject ::init();
|
||||
|
||||
qRegisterMetaType<Base::Vector3f>("Base::Vector3f");
|
||||
qRegisterMetaType<Base::Vector3d>("Base::Vector3d");
|
||||
qRegisterMetaType<Base::Quantity>("Base::Quantity");
|
||||
qRegisterMetaType<QList<Base::Quantity> >("Base::QuantityList");
|
||||
init_done = true;
|
||||
|
||||
assert(!storage);
|
||||
storage = new SoGroup();
|
||||
storage->ref();
|
||||
}
|
||||
|
||||
void Gui::SoFCDB::finish()
|
||||
{
|
||||
// Coin doesn't provide a mechanism to free static members of own data types.
|
||||
// Hence, we need to define a static method e.g. 'finish()' for all new types
|
||||
// to invoke the private member function 'atexit_cleanup()'.
|
||||
SoFCColorBarBase ::finish();
|
||||
SoFCColorBar ::finish();
|
||||
SoFCColorLegend ::finish();
|
||||
SoFCColorGradient ::finish();
|
||||
SoFCBackgroundGradient ::finish();
|
||||
SoFCBoundingBox ::finish();
|
||||
SoFCSelection ::finish();
|
||||
SoFCSelectionAction ::finish();
|
||||
SoFCDocumentAction ::finish();
|
||||
SoFCDocumentObjectAction ::finish();
|
||||
SoFCEnableSelectionAction ::finish();
|
||||
SoFCEnableHighlightAction ::finish();
|
||||
SoFCSelectionColorAction ::finish();
|
||||
SoFCHighlightColorAction ::finish();
|
||||
|
||||
storage->unref();
|
||||
storage = nullptr;
|
||||
}
|
||||
|
||||
// buffer acrobatics for inventor ****************************************************
|
||||
static char * buffer;
|
||||
static size_t buffer_size = 0;
|
||||
static std::string cReturnString;
|
||||
|
||||
static void *
|
||||
buffer_realloc(void * bufptr, size_t size)
|
||||
{
|
||||
buffer = (char *)realloc(bufptr, size);
|
||||
buffer_size = size;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const std::string& Gui::SoFCDB::writeNodesToString(SoNode * root)
|
||||
{
|
||||
SoOutput out;
|
||||
buffer = (char *)malloc(1024);
|
||||
buffer_size = 1024;
|
||||
out.setBuffer(buffer, buffer_size, buffer_realloc);
|
||||
if (root && root->getTypeId().isDerivedFrom(SoVRMLParent::getClassTypeId()))
|
||||
out.setHeaderString("#VRML V2.0 utf8");
|
||||
|
||||
SoWriteAction wa(&out);
|
||||
wa.apply(root);
|
||||
|
||||
cReturnString = buffer;
|
||||
free(buffer);
|
||||
return cReturnString;
|
||||
}
|
||||
|
||||
bool Gui::SoFCDB::writeToVRML(SoNode* node, const char* filename, bool binary)
|
||||
{
|
||||
SoVRMLAction vrml2;
|
||||
vrml2.setOverrideMode(true);
|
||||
vrml2.apply(node);
|
||||
SoToVRML2Action tovrml2;
|
||||
tovrml2.apply(node);
|
||||
SoVRMLGroup* vrmlRoot = tovrml2.getVRML2SceneGraph();
|
||||
vrmlRoot->setInstancePrefix(SbString("o"));
|
||||
vrmlRoot->ref();
|
||||
std::string buffer = SoFCDB::writeNodesToString(vrmlRoot);
|
||||
vrmlRoot->unref(); // release the memory as soon as possible
|
||||
|
||||
// restore old settings
|
||||
vrml2.setOverrideMode(false);
|
||||
vrml2.apply(node);
|
||||
|
||||
Base::FileInfo fi(filename);
|
||||
if (binary) {
|
||||
// We want to write compressed VRML but Coin 2.4.3 doesn't do it even though
|
||||
// SoOutput::getAvailableCompressionMethods() delivers a string list that
|
||||
// contains 'GZIP'. setCompression() was called directly after opening the file,
|
||||
// returned true and no error message appeared but anyway it didn't work.
|
||||
// Strange is that reading GZIPped VRML files works.
|
||||
// So, we do the compression on our own.
|
||||
Base::ofstream str(fi, std::ios::out | std::ios::binary);
|
||||
zipios::GZIPOutputStream gzip(str);
|
||||
|
||||
if (gzip) {
|
||||
gzip << buffer;
|
||||
gzip.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Base::ofstream str(fi, std::ios::out);
|
||||
|
||||
if (str) {
|
||||
str << buffer;
|
||||
str.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Gui::SoFCDB::writeToFile(SoNode* node, const char* filename, bool binary)
|
||||
{
|
||||
bool ret = false;
|
||||
Base::FileInfo fi(filename);
|
||||
|
||||
// Write VRML V2.0
|
||||
if (fi.hasExtension("wrl") || fi.hasExtension("vrml") || fi.hasExtension("wrz")) {
|
||||
// If 'wrz' is set then force compression
|
||||
if (fi.hasExtension("wrz"))
|
||||
binary = true;
|
||||
|
||||
ret = SoFCDB::writeToVRML(node, filename, binary);
|
||||
}
|
||||
else if (fi.hasExtension("iv")) {
|
||||
// Write Inventor in ASCII
|
||||
std::string buffer = SoFCDB::writeNodesToString(node);
|
||||
Base::ofstream str(Base::FileInfo(filename), std::ios::out);
|
||||
|
||||
if (str) {
|
||||
str << buffer;
|
||||
str.close();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SoGroup* Gui::SoFCDB::getStorage()
|
||||
{
|
||||
assert(storage); //call init first.
|
||||
return storage;
|
||||
}
|
||||
@@ -129,6 +129,7 @@
|
||||
#include "WinNativeGestureRecognizers.h"
|
||||
#include "Document.h"
|
||||
|
||||
/*
|
||||
#include "SoVTKActor.h"
|
||||
#include "vtkDataSetSurfaceFilter.h"
|
||||
#include "vtkGeometryFilter.h"
|
||||
@@ -146,7 +147,7 @@
|
||||
#include "vtkRungeKutta4.h"
|
||||
#include "vtkStreamTracer.h"
|
||||
#include "vtkPointLocator.h"
|
||||
|
||||
*/
|
||||
//#define FC_LOGGING_CB
|
||||
|
||||
using namespace Gui;
|
||||
@@ -545,241 +546,7 @@ void View3DInventorViewer::init()
|
||||
cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap);
|
||||
mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap);
|
||||
panCursor = QCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y);
|
||||
|
||||
|
||||
//test vtk integration
|
||||
vtkCubeSource* cube = vtkCubeSource::New();
|
||||
source = vtkSmartPointer<vtkDataSetReader>::New();
|
||||
source->SetFileName("/home/stefan/Downloads/pressure.vtk");
|
||||
vtkGeometryFilter* f1 = vtkGeometryFilter::New();
|
||||
f1->SetInputConnection(source->GetOutputPort());
|
||||
f1->Update();
|
||||
|
||||
vtkPolyDataMapper* mapper_ = vtkPolyDataMapper::New();
|
||||
mapper_->SetInputConnection(f1->GetOutputPort());
|
||||
|
||||
mapper_->Update();
|
||||
vtkPolyData* data = mapper_->GetInput();
|
||||
|
||||
//try to color the data
|
||||
vtkLookupTable* table = vtkLookupTable::New();
|
||||
|
||||
double range[2];
|
||||
data->GetPointData()->GetArray(0)->GetRange(range, 0);
|
||||
table->SetTableRange(range[0], range[1]);
|
||||
table->Build();
|
||||
|
||||
vtkUnsignedCharArray* colors = vtkUnsignedCharArray::New();
|
||||
colors->SetNumberOfComponents(3);
|
||||
colors->SetName("Colors");
|
||||
|
||||
for(int i=0; i<data->GetNumberOfPoints(); ++i) {
|
||||
|
||||
//get the pressure at the point
|
||||
double pressure = data->GetPointData()->GetArray(0)->GetComponent(i, 0);
|
||||
double dcolor[3];
|
||||
table->GetColor(pressure, dcolor);
|
||||
unsigned char color[3];
|
||||
for(unsigned int j=0; j<3; ++j)
|
||||
color[j] = static_cast<unsigned char>(255*dcolor[j]);
|
||||
|
||||
colors->InsertNextTupleValue(color);
|
||||
}
|
||||
data->GetPointData()->SetScalars(colors);
|
||||
|
||||
|
||||
SoVTKActor* actor = new SoVTKActor;
|
||||
actor->ref();
|
||||
actor->setMapper(mapper_);
|
||||
pcViewProviderRoot->addChild(actor);
|
||||
|
||||
|
||||
//contour plot (isosurface)
|
||||
SoTranslation* trans = new SoTranslation();
|
||||
trans->ref();
|
||||
trans->translation.setValue(SbVec3f(15,15,5));
|
||||
pcViewProviderRoot->addChild(trans);
|
||||
|
||||
SoVTKActor* actor2 = new SoVTKActor;
|
||||
actor2->ref();
|
||||
pcViewProviderRoot->addChild(actor2);
|
||||
|
||||
vtkContourFilter* contour = vtkContourFilter::New();
|
||||
contour->SetValue(0, (range[0]+range[1])/2);
|
||||
contour->SetInputConnection(source->GetOutputPort());
|
||||
vtkGeometryFilter* gf = vtkGeometryFilter::New();
|
||||
gf->SetInputConnection(contour->GetOutputPort());
|
||||
vtkPolyDataMapper* mapper2 = vtkPolyDataMapper::New();
|
||||
mapper2->SetInputConnection(gf->GetOutputPort());
|
||||
mapper2->Update();
|
||||
actor2->setMapper(mapper2);
|
||||
|
||||
//slice
|
||||
trans = new SoTranslation();
|
||||
trans->ref();
|
||||
trans->translation.setValue(SbVec3f(15,15,5));
|
||||
pcViewProviderRoot->addChild(trans);
|
||||
|
||||
SoVTKActor* actor3 = new SoVTKActor;
|
||||
actor3->ref();
|
||||
pcViewProviderRoot->addChild(actor3);
|
||||
|
||||
vtkPlane* plane = vtkPlane::New();
|
||||
plane->SetOrigin(5,-4, 30);
|
||||
plane->SetNormal(0.28, 0, 0.95);
|
||||
vtkCutter* cutter = vtkCutter::New();
|
||||
cutter->SetInputConnection(source->GetOutputPort());
|
||||
cutter->SetCutFunction(plane);
|
||||
cutter->Update();
|
||||
vtkPolyDataMapper* mapper3 = vtkPolyDataMapper::New();
|
||||
mapper3->SetInputConnection(cutter->GetOutputPort());
|
||||
mapper3->Update();
|
||||
|
||||
data = mapper3->GetInput();
|
||||
table = vtkLookupTable::New();
|
||||
data->GetPointData()->GetArray(0)->GetRange(range, 0);
|
||||
table->SetTableRange(range[0], range[1]);
|
||||
table->Build();
|
||||
colors = vtkUnsignedCharArray::New();
|
||||
colors->SetNumberOfComponents(3);
|
||||
colors->SetName("Colors");
|
||||
for(int i=0; i<data->GetNumberOfPoints(); ++i) {
|
||||
//get the pressure at the point
|
||||
double pressure = data->GetPointData()->GetArray(0)->GetComponent(i, 0);
|
||||
double dcolor[3];
|
||||
table->GetColor(pressure, dcolor);
|
||||
unsigned char color[3];
|
||||
for(unsigned int j=0; j<3; ++j)
|
||||
color[j] = static_cast<unsigned char>(255*dcolor[j]);
|
||||
|
||||
colors->InsertNextTupleValue(color);
|
||||
}
|
||||
data->GetPointData()->SetScalars(colors);
|
||||
actor3->setMapper(mapper3);
|
||||
|
||||
|
||||
|
||||
//hedgehog
|
||||
trans = new SoTranslation();
|
||||
trans->ref();
|
||||
trans->translation.setValue(SbVec3f(-30, -30, -30));
|
||||
pcViewProviderRoot->addChild(trans);
|
||||
|
||||
SoVTKActor* actor4 = new SoVTKActor;
|
||||
actor4->ref();
|
||||
pcViewProviderRoot->addChild(actor4);
|
||||
|
||||
//vtkLookupTable* lut = vtkLookupTable::New();
|
||||
vtkHedgeHog* hedge = vtkHedgeHog::New();
|
||||
hedge->SetScaleFactor(0.001);
|
||||
hedge->SetInputConnection(source->GetOutputPort());
|
||||
vtkPolyDataMapper* mapper4 = vtkPolyDataMapper::New();
|
||||
mapper4->SetInputConnection(hedge->GetOutputPort());
|
||||
mapper4->Update();
|
||||
data = mapper4->GetInput();
|
||||
colors = vtkUnsignedCharArray::New();
|
||||
colors->SetNumberOfComponents(3);
|
||||
colors->SetName("Colors");
|
||||
for(int i=0; i<data->GetNumberOfPoints(); ++i) {
|
||||
unsigned char color[3];
|
||||
color[0] = 255;
|
||||
color[1] = 50;
|
||||
color[2] = 50;
|
||||
|
||||
colors->InsertNextTupleValue(color);
|
||||
}
|
||||
data->GetPointData()->SetScalars(colors);
|
||||
actor4->setMapper(mapper4);
|
||||
|
||||
|
||||
//streamline
|
||||
trans = new SoTranslation();
|
||||
trans->ref();
|
||||
trans->translation.setValue(SbVec3f(15, 15, 5));
|
||||
pcViewProviderRoot->addChild(trans);
|
||||
|
||||
SoVTKActor* actor6 = new SoVTKActor;
|
||||
actor6->ref();
|
||||
pcViewProviderRoot->addChild(actor6);
|
||||
|
||||
vtkPointSource* point = vtkPointSource::New();
|
||||
point->SetRadius(3);
|
||||
point->SetCenter(source->GetOutput()->GetCenter());
|
||||
point->SetNumberOfPoints(100);
|
||||
vtkRungeKutta4* runge = vtkRungeKutta4::New();
|
||||
vtkStreamTracer* stream = vtkStreamTracer::New();
|
||||
stream->SetInputConnection(source->GetOutputPort());
|
||||
stream->SetSourceConnection(point->GetOutputPort());
|
||||
stream->SetMaximumPropagation(100);
|
||||
stream->SetMaximumIntegrationStep(0.01);
|
||||
stream->SetIntegrationDirection(vtkStreamTracer::BOTH);
|
||||
stream->SetIntegrator(runge);
|
||||
|
||||
vtkPolyDataMapper* mapper6 = vtkPolyDataMapper::New();
|
||||
mapper6->SetInputConnection(stream->GetOutputPort());
|
||||
mapper6->Update();
|
||||
|
||||
data = mapper6->GetInput();
|
||||
//see which cell data we got
|
||||
for(int i=0; i<data->GetPointData()->GetNumberOfArrays(); ++i) {
|
||||
Base::Console().Message("Point data:\nArray %s (Type: %i)\n", data->GetPointData()->GetArrayName(i),
|
||||
data->GetPointData()->GetArrayName(i));
|
||||
}
|
||||
for(int i=0; i<data->GetCellData()->GetNumberOfArrays(); ++i) {
|
||||
Base::Console().Message("\nCell data:\nArray %s (Type: %i)", data->GetCellData()->GetArrayName(i),
|
||||
data->GetCellData()->GetArrayName(i));
|
||||
|
||||
}
|
||||
|
||||
table = vtkLookupTable::New();
|
||||
data->GetPointData()->GetArray(7)->GetRange(range, 0);
|
||||
table->SetTableRange(range[0], range[1]);
|
||||
Base::Console().Message("range: %d - %d\n", range[0], range[1]);
|
||||
table->Build();
|
||||
colors = vtkUnsignedCharArray::New();
|
||||
colors->SetNumberOfComponents(3);
|
||||
colors->SetName("Colors");
|
||||
for(int i=0; i<data->GetNumberOfPoints(); ++i) {
|
||||
//get the pressure at the point
|
||||
double pressure = data->GetPointData()->GetArray(7)->GetComponent(i, 0);
|
||||
//Base::Console().Message("angular velocity: %d\n", pressure);
|
||||
double dcolor[3];
|
||||
table->GetColor(pressure, dcolor);
|
||||
unsigned char color[3];
|
||||
for(unsigned int j=0; j<3; ++j)
|
||||
color[j] = static_cast<unsigned char>(255*dcolor[j]);
|
||||
|
||||
colors->InsertNextTupleValue(color);
|
||||
}
|
||||
data->GetPointData()->SetScalars(colors);
|
||||
actor6->setMapper(mapper6);
|
||||
|
||||
|
||||
|
||||
//glyph
|
||||
trans = new SoTranslation();
|
||||
trans->ref();
|
||||
trans->translation.setValue(SbVec3f(15, 15, 5));
|
||||
pcViewProviderRoot->addChild(trans);
|
||||
|
||||
SoVTKActor* actor5 = new SoVTKActor;
|
||||
actor5->ref();
|
||||
pcViewProviderRoot->addChild(actor5);
|
||||
|
||||
// vtkArrowSource* arrow = vtkArrowSource::New();
|
||||
// arrow->SetTipRadius(0.1);
|
||||
// arrow->SetTipLength(0.35);
|
||||
// arrow->SetShaftRadius(0.03);
|
||||
// arrow->SetTipResolution(4);
|
||||
// arrow->SetShaftResolution(4);
|
||||
// vtkGlyph3D* glyph = vtkGlyph3D::New();
|
||||
// glyph->SetInputConnection(source->GetOutputPort());
|
||||
// //glyph->SetSourceConnection(arrow->GetOutputPort());
|
||||
// vtkPolyDataMapper* mapper5 = vtkPolyDataMapper::New();
|
||||
// mapper5->SetInputConnection(glyph->GetOutputPort());
|
||||
// mapper5->Update();
|
||||
// actor5->setMapper(mapper5);
|
||||
|
||||
}
|
||||
|
||||
View3DInventorViewer::~View3DInventorViewer()
|
||||
|
||||
@@ -39,10 +39,6 @@
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <vtkDataSetReader.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
|
||||
class SoTranslation;
|
||||
class SoTransform;
|
||||
class SoText2;
|
||||
@@ -435,11 +431,6 @@ private:
|
||||
friend class NavigationStyle;
|
||||
friend class GLPainter;
|
||||
friend class ViewerEventFilter;
|
||||
|
||||
|
||||
//vtk test
|
||||
vtkSmartPointer<vtkDataSetReader> source;
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
#include "FemResultObject.h"
|
||||
#include "FemSolverObject.h"
|
||||
#include "FemPostPipeline.h"
|
||||
#include "FemPostFilter.h"
|
||||
|
||||
namespace Fem {
|
||||
extern PyObject* initModule();
|
||||
@@ -142,7 +144,12 @@ 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();
|
||||
#endif
|
||||
}
|
||||
|
||||
306
src/Mod/Fem/App/AppFem.cpp.orig
Normal file
306
src/Mod/Fem/App/AppFem.cpp.orig
Normal file
@@ -0,0 +1,306 @@
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <CXX/Extensions.hxx>
|
||||
|
||||
#include "FemMeshPy.h"
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshProperty.h"
|
||||
#include "FemAnalysis.h"
|
||||
#include "FemMeshObject.h"
|
||||
#include "FemMeshShapeObject.h"
|
||||
#include "FemMeshShapeNetgenObject.h"
|
||||
|
||||
#include "FemSetElementsObject.h"
|
||||
#include "FemSetFacesObject.h"
|
||||
#include "FemSetGeometryObject.h"
|
||||
#include "FemSetNodesObject.h"
|
||||
|
||||
#include "HypothesisPy.h"
|
||||
#include "FemConstraintBearing.h"
|
||||
#include "FemConstraintFixed.h"
|
||||
#include "FemConstraintForce.h"
|
||||
#include "FemConstraintPressure.h"
|
||||
#include "FemConstraintGear.h"
|
||||
#include "FemConstraintPulley.h"
|
||||
#include "FemConstraintDisplacement.h"
|
||||
|
||||
#include "FemResultObject.h"
|
||||
#include "FemSolverObject.h"
|
||||
|
||||
namespace Fem {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFem()
|
||||
{
|
||||
// load dependend module
|
||||
try {
|
||||
Base::Interpreter().loadModule("Part");
|
||||
//Base::Interpreter().loadModule("Mesh");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
PyObject* femModule = Fem::initModule();
|
||||
Base::Console().Log("Loading Fem module... done\n");
|
||||
|
||||
Fem::StdMeshers_Arithmetic1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_AutomaticLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NotConformAllowedPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LocalLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_QuadranglePreferencePy ::init_type(femModule);
|
||||
Fem::StdMeshers_Quadrangle_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxElementAreaPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Regular_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_UseExisting_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_UseExisting_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_CompositeSegment_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Deflection1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LayerDistributionPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LengthFromEdgesPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxElementVolumePy ::init_type(femModule);
|
||||
Fem::StdMeshers_MEFISTO_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NumberOfLayersPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NumberOfSegmentsPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Prism_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_QuadraticMeshPy ::init_type(femModule);
|
||||
Fem::StdMeshers_RadialPrism_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_SegmentAroundVertex_0DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_SegmentLengthAroundVertexPy ::init_type(femModule);
|
||||
Fem::StdMeshers_StartEndLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_TrianglePreferencePy ::init_type(femModule);
|
||||
Fem::StdMeshers_Hexa_3DPy ::init_type(femModule);
|
||||
|
||||
// Add Types to module
|
||||
Base::Interpreter().addType(&Fem::FemMeshPy::Type,femModule,"FemMesh");
|
||||
|
||||
|
||||
// NOTE: To finish the initialization of our own type objects we must
|
||||
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
|
||||
// This function is responsible for adding inherited slots from a type's base class.
|
||||
|
||||
Fem::FemAnalysis ::init();
|
||||
Fem::FemAnalysisPython ::init();
|
||||
Fem::DocumentObject ::init();
|
||||
Fem::FeaturePython ::init();
|
||||
Fem::FemMesh ::init();
|
||||
Fem::FemMeshObject ::init();
|
||||
Fem::FemMeshShapeObject ::init();
|
||||
Fem::FemMeshShapeNetgenObject ::init();
|
||||
Fem::PropertyFemMesh ::init();
|
||||
|
||||
Fem::FemSetObject ::init();
|
||||
Fem::FemSetElementsObject ::init();
|
||||
Fem::FemSetFacesObject ::init();
|
||||
Fem::FemSetGeometryObject ::init();
|
||||
Fem::FemSetNodesObject ::init();
|
||||
|
||||
Fem::Constraint ::init();
|
||||
Fem::ConstraintBearing ::init();
|
||||
Fem::ConstraintFixed ::init();
|
||||
Fem::ConstraintForce ::init();
|
||||
Fem::ConstraintPressure ::init();
|
||||
Fem::ConstraintGear ::init();
|
||||
Fem::ConstraintPulley ::init();
|
||||
Fem::ConstraintDisplacement ::init();
|
||||
|
||||
Fem::FemResultObject ::init();
|
||||
Fem::FemResultObjectPython ::init();
|
||||
Fem::FemSolverObject ::init();
|
||||
Fem::FemSolverObjectPython ::init();
|
||||
}
|
||||
=======
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <CXX/Extensions.hxx>
|
||||
|
||||
#include "FemMeshPy.h"
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshProperty.h"
|
||||
#include "FemAnalysis.h"
|
||||
#include "FemMeshObject.h"
|
||||
#include "FemMeshShapeObject.h"
|
||||
#include "FemMeshShapeNetgenObject.h"
|
||||
|
||||
#include "FemSetElementsObject.h"
|
||||
#include "FemSetFacesObject.h"
|
||||
#include "FemSetGeometryObject.h"
|
||||
#include "FemSetNodesObject.h"
|
||||
|
||||
#include "HypothesisPy.h"
|
||||
#include "FemConstraintBearing.h"
|
||||
#include "FemConstraintFixed.h"
|
||||
#include "FemConstraintForce.h"
|
||||
#include "FemConstraintPressure.h"
|
||||
#include "FemConstraintGear.h"
|
||||
#include "FemConstraintPulley.h"
|
||||
#include "FemConstraintDisplacement.h"
|
||||
|
||||
#include "FemResultObject.h"
|
||||
#include "FemSolverObject.h"
|
||||
#include "FemPostPipeline.h"
|
||||
#include "FemPostFilter.h"
|
||||
|
||||
namespace Fem {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFem()
|
||||
{
|
||||
// load dependend module
|
||||
try {
|
||||
Base::Interpreter().loadModule("Part");
|
||||
//Base::Interpreter().loadModule("Mesh");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
}
|
||||
PyObject* femModule = Fem::initModule();
|
||||
Base::Console().Log("Loading Fem module... done\n");
|
||||
|
||||
Fem::StdMeshers_Arithmetic1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_AutomaticLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NotConformAllowedPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LocalLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_QuadranglePreferencePy ::init_type(femModule);
|
||||
Fem::StdMeshers_Quadrangle_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxElementAreaPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Regular_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_UseExisting_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_UseExisting_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_CompositeSegment_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Deflection1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LayerDistributionPy ::init_type(femModule);
|
||||
Fem::StdMeshers_LengthFromEdgesPy ::init_type(femModule);
|
||||
Fem::StdMeshers_MaxElementVolumePy ::init_type(femModule);
|
||||
Fem::StdMeshers_MEFISTO_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NumberOfLayersPy ::init_type(femModule);
|
||||
Fem::StdMeshers_NumberOfSegmentsPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Prism_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_Projection_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource1DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource2DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_ProjectionSource3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_QuadraticMeshPy ::init_type(femModule);
|
||||
Fem::StdMeshers_RadialPrism_3DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_SegmentAroundVertex_0DPy ::init_type(femModule);
|
||||
Fem::StdMeshers_SegmentLengthAroundVertexPy ::init_type(femModule);
|
||||
Fem::StdMeshers_StartEndLengthPy ::init_type(femModule);
|
||||
Fem::StdMeshers_TrianglePreferencePy ::init_type(femModule);
|
||||
Fem::StdMeshers_Hexa_3DPy ::init_type(femModule);
|
||||
|
||||
// Add Types to module
|
||||
Base::Interpreter().addType(&Fem::FemMeshPy::Type,femModule,"FemMesh");
|
||||
|
||||
|
||||
// NOTE: To finish the initialization of our own type objects we must
|
||||
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
|
||||
// This function is responsible for adding inherited slots from a type's base class.
|
||||
|
||||
Fem::FemAnalysis ::init();
|
||||
Fem::FemAnalysisPython ::init();
|
||||
Fem::DocumentObject ::init();
|
||||
Fem::FeaturePython ::init();
|
||||
Fem::FemMesh ::init();
|
||||
Fem::FemMeshObject ::init();
|
||||
Fem::FemMeshShapeObject ::init();
|
||||
Fem::FemMeshShapeNetgenObject ::init();
|
||||
Fem::PropertyFemMesh ::init();
|
||||
|
||||
Fem::FemSetObject ::init();
|
||||
Fem::FemSetElementsObject ::init();
|
||||
Fem::FemSetFacesObject ::init();
|
||||
Fem::FemSetGeometryObject ::init();
|
||||
Fem::FemSetNodesObject ::init();
|
||||
|
||||
Fem::Constraint ::init();
|
||||
Fem::ConstraintBearing ::init();
|
||||
Fem::ConstraintFixed ::init();
|
||||
Fem::ConstraintForce ::init();
|
||||
Fem::ConstraintPressure ::init();
|
||||
Fem::ConstraintGear ::init();
|
||||
Fem::ConstraintPulley ::init();
|
||||
Fem::ConstraintDisplacement ::init();
|
||||
|
||||
Fem::FemResultObject ::init();
|
||||
Fem::FemSolverObject ::init();
|
||||
Fem::FemSolverObjectPython ::init();
|
||||
|
||||
#ifdef FC_USE_VTK
|
||||
Fem::FemPostObject ::init();
|
||||
Fem::FemPostPipeline ::init();
|
||||
Fem::FemPostFilter ::init();
|
||||
#endif
|
||||
}
|
||||
>>>>>>> Move post processing to fem objects
|
||||
@@ -64,6 +64,7 @@
|
||||
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshObject.h"
|
||||
#include "FemPostPipeline.h"
|
||||
#include "FemMeshPy.h"
|
||||
|
||||
#include <cstdlib>
|
||||
@@ -163,16 +164,36 @@ private:
|
||||
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();
|
||||
}
|
||||
else
|
||||
throw e;
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
510
src/Mod/Fem/App/AppFemPy.cpp.orig
Normal file
510
src/Mod/Fem/App/AppFemPy.cpp.orig
Normal file
@@ -0,0 +1,510 @@
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
//#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
//#include <Mod/Mesh/App/Core/Evaluation.h>
|
||||
//#include <Mod/Mesh/App/Core/Iterator.h>
|
||||
|
||||
#include <SMESH_Gen.hxx>
|
||||
#include <SMESH_Group.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
#include <SMDS_MeshNode.hxx>
|
||||
#include <StdMeshers_MaxLength.hxx>
|
||||
#include <StdMeshers_LocalLength.hxx>
|
||||
#include <StdMeshers_NumberOfSegments.hxx>
|
||||
#include <StdMeshers_AutomaticLength.hxx>
|
||||
#include <StdMeshers_TrianglePreference.hxx>
|
||||
#include <StdMeshers_MEFISTO_2D.hxx>
|
||||
#include <StdMeshers_Deflection1D.hxx>
|
||||
#include <StdMeshers_MaxElementArea.hxx>
|
||||
#include <StdMeshers_Regular_1D.hxx>
|
||||
#include <StdMeshers_QuadranglePreference.hxx>
|
||||
#include <StdMeshers_Quadrangle_2D.hxx>
|
||||
|
||||
#include <StdMeshers_LengthFromEdges.hxx>
|
||||
#include <StdMeshers_NotConformAllowed.hxx>
|
||||
#include <StdMeshers_Arithmetic1D.hxx>
|
||||
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshObject.h"
|
||||
#include "FemMeshPy.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
|
||||
namespace Fem {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Fem")
|
||||
{
|
||||
add_varargs_method("open",&Module::open,
|
||||
"open(string) -- Create a new document and a Mesh::Import feature to load the file into the document."
|
||||
);
|
||||
add_varargs_method("insert",&Module::insert,
|
||||
"insert(string|mesh,[string]) -- Load or insert a mesh into the given or active document."
|
||||
);
|
||||
add_varargs_method("export",&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file."
|
||||
);
|
||||
add_varargs_method("read",&Module::read,
|
||||
"Read a mesh from a file and returns a Mesh object."
|
||||
);
|
||||
add_varargs_method("show",&Module::show,
|
||||
"show(shape) -- Add the shape to the active document or create one if no document exists."
|
||||
);
|
||||
initialize("This module is the Fem module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
virtual Py::Object invoke_method_varargs(void *method_def, const Py::Tuple &args)
|
||||
{
|
||||
try {
|
||||
return Py::ExtensionModule<Module>::invoke_method_varargs(method_def, args);
|
||||
}
|
||||
catch (const Standard_Failure &e) {
|
||||
std::string str;
|
||||
Standard_CString msg = e.GetMessageString();
|
||||
str += typeid(e).name();
|
||||
str += " ";
|
||||
if (msg) {str += msg;}
|
||||
else {str += "No OCCT Exception Message";}
|
||||
throw Py::Exception(Part::PartExceptionOCCError, str);
|
||||
}
|
||||
catch (const Base::Exception &e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
}
|
||||
Py::Object open(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
std::auto_ptr<FemMesh> mesh(new FemMesh);
|
||||
mesh->read(EncodedName.c_str());
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
// create new document and add Import feature
|
||||
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
|
||||
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();
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object insert(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
const char* DocName = 0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
App::Document *pcDoc = 0;
|
||||
if (DocName)
|
||||
pcDoc = App::GetApplication().getDocument(DocName);
|
||||
else
|
||||
pcDoc = App::GetApplication().getActiveDocument();
|
||||
|
||||
if (!pcDoc) {
|
||||
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();
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object exporter(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* object;
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "Oet",&object,"utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
Py::Sequence list(object);
|
||||
Base::Type meshId = Base::Type::fromName("Fem::FemMeshObject");
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->getTypeId().isDerivedFrom(meshId)) {
|
||||
static_cast<FemMeshObject*>(obj)->FemMesh.getValue().write(EncodedName.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object read(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
std::auto_ptr<FemMesh> mesh(new FemMesh);
|
||||
mesh->read(EncodedName.c_str());
|
||||
return Py::asObject(new FemMeshPy(mesh.release()));
|
||||
}
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(FemMeshPy::Type), &pcObj))
|
||||
throw Py::Exception();
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
|
||||
FemMeshPy* pShape = static_cast<FemMeshPy*>(pcObj);
|
||||
Fem::FemMeshObject *pcFeature = (Fem::FemMeshObject *)pcDoc->addObject("Fem::FemMeshObject", "Mesh");
|
||||
// copy the data
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->FemMesh.setValue(*(pShape->getFemMeshPtr()));
|
||||
pcDoc->recompute();
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return (new Module)->module().ptr();
|
||||
}
|
||||
|
||||
} // namespace Fem
|
||||
=======
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
#include <CXX/Extensions.hxx>
|
||||
#include <CXX/Objects.hxx>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
//#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
//#include <Mod/Mesh/App/Core/Evaluation.h>
|
||||
//#include <Mod/Mesh/App/Core/Iterator.h>
|
||||
|
||||
#include <SMESH_Gen.hxx>
|
||||
#include <SMESH_Group.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
#include <SMDS_MeshNode.hxx>
|
||||
#include <StdMeshers_MaxLength.hxx>
|
||||
#include <StdMeshers_LocalLength.hxx>
|
||||
#include <StdMeshers_NumberOfSegments.hxx>
|
||||
#include <StdMeshers_AutomaticLength.hxx>
|
||||
#include <StdMeshers_TrianglePreference.hxx>
|
||||
#include <StdMeshers_MEFISTO_2D.hxx>
|
||||
#include <StdMeshers_Deflection1D.hxx>
|
||||
#include <StdMeshers_MaxElementArea.hxx>
|
||||
#include <StdMeshers_Regular_1D.hxx>
|
||||
#include <StdMeshers_QuadranglePreference.hxx>
|
||||
#include <StdMeshers_Quadrangle_2D.hxx>
|
||||
|
||||
#include <StdMeshers_LengthFromEdges.hxx>
|
||||
#include <StdMeshers_NotConformAllowed.hxx>
|
||||
#include <StdMeshers_Arithmetic1D.hxx>
|
||||
|
||||
#include "FemMesh.h"
|
||||
#include "FemMeshObject.h"
|
||||
#include "FemPostPipeline.h"
|
||||
#include "FemMeshPy.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <Standard_Real.hxx>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Mod/Part/App/OCCError.h>
|
||||
|
||||
namespace Fem {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Fem")
|
||||
{
|
||||
add_varargs_method("open",&Module::open,
|
||||
"open(string) -- Create a new document and a Mesh::Import feature to load the file into the document."
|
||||
);
|
||||
add_varargs_method("insert",&Module::insert,
|
||||
"insert(string|mesh,[string]) -- Load or insert a mesh into the given or active document."
|
||||
);
|
||||
add_varargs_method("export",&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file."
|
||||
);
|
||||
add_varargs_method("read",&Module::read,
|
||||
"Read a mesh from a file and returns a Mesh object."
|
||||
);
|
||||
add_varargs_method("show",&Module::show,
|
||||
"show(shape) -- Add the shape to the active document or create one if no document exists."
|
||||
);
|
||||
initialize("This module is the Fem module."); // register with Python
|
||||
}
|
||||
|
||||
virtual ~Module() {}
|
||||
|
||||
private:
|
||||
virtual Py::Object invoke_method_varargs(void *method_def, const Py::Tuple &args)
|
||||
{
|
||||
try {
|
||||
return Py::ExtensionModule<Module>::invoke_method_varargs(method_def, args);
|
||||
}
|
||||
catch (const Standard_Failure &e) {
|
||||
std::string str;
|
||||
Standard_CString msg = e.GetMessageString();
|
||||
str += typeid(e).name();
|
||||
str += " ";
|
||||
if (msg) {str += msg;}
|
||||
else {str += "No OCCT Exception Message";}
|
||||
throw Py::Exception(Part::PartExceptionOCCError, str);
|
||||
}
|
||||
catch (const Base::Exception &e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
}
|
||||
Py::Object open(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
std::auto_ptr<FemMesh> mesh(new FemMesh);
|
||||
mesh->read(EncodedName.c_str());
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
// create new document and add Import feature
|
||||
App::Document *pcDoc = App::GetApplication().newDocument("Unnamed");
|
||||
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();
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object insert(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
const char* DocName = 0;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
App::Document *pcDoc = 0;
|
||||
if (DocName)
|
||||
pcDoc = App::GetApplication().getDocument(DocName);
|
||||
else
|
||||
pcDoc = App::GetApplication().getActiveDocument();
|
||||
|
||||
if (!pcDoc) {
|
||||
pcDoc = App::GetApplication().newDocument(DocName);
|
||||
}
|
||||
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
|
||||
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();
|
||||
}
|
||||
else
|
||||
throw e;
|
||||
#else
|
||||
throw e;
|
||||
#endif
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object exporter(const Py::Tuple& args)
|
||||
{
|
||||
PyObject* object;
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "Oet",&object,"utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
Py::Sequence list(object);
|
||||
Base::Type meshId = Base::Type::fromName("Fem::FemMeshObject");
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
if (obj->getTypeId().isDerivedFrom(meshId)) {
|
||||
static_cast<FemMeshObject*>(obj)->FemMesh.getValue().write(EncodedName.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object read(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et","utf-8",&Name))
|
||||
throw Py::Exception();
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
std::auto_ptr<FemMesh> mesh(new FemMesh);
|
||||
mesh->read(EncodedName.c_str());
|
||||
return Py::asObject(new FemMeshPy(mesh.release()));
|
||||
}
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(FemMeshPy::Type), &pcObj))
|
||||
throw Py::Exception();
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
|
||||
FemMeshPy* pShape = static_cast<FemMeshPy*>(pcObj);
|
||||
Fem::FemMeshObject *pcFeature = (Fem::FemMeshObject *)pcDoc->addObject("Fem::FemMeshObject", "Mesh");
|
||||
// copy the data
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->FemMesh.setValue(*(pShape->getFemMeshPtr()));
|
||||
pcDoc->recompute();
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return (new Module)->module().ptr();
|
||||
}
|
||||
|
||||
} // namespace Fem
|
||||
>>>>>>> Move post processing to fem objects
|
||||
@@ -26,28 +26,29 @@ include_directories(
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
|
||||
set(Fem_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
StdMeshers
|
||||
SMESH
|
||||
SMDS
|
||||
SMESHDS
|
||||
)
|
||||
|
||||
if(BUILD_FEM_NETGEN)
|
||||
set(Fem_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
StdMeshers
|
||||
${Fem_LIBS}
|
||||
NETGENPlugin
|
||||
SMESH
|
||||
SMDS
|
||||
SMESHDS
|
||||
)
|
||||
else(BUILD_FEM_NETGEN)
|
||||
set(Fem_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
StdMeshers
|
||||
SMESH
|
||||
SMDS
|
||||
SMESHDS
|
||||
)
|
||||
endif(BUILD_FEM_NETGEN)
|
||||
|
||||
if(BUILD_FEM_VTK)
|
||||
set(Fem_LIBS
|
||||
${Fem_LIBS}
|
||||
${VTK_LIBRARIES}
|
||||
)
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
generate_from_xml(FemMeshPy)
|
||||
|
||||
|
||||
@@ -199,15 +200,25 @@ SET(FemConstraints_SRCS
|
||||
)
|
||||
SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS})
|
||||
|
||||
SET(FemResult_SRCS
|
||||
if(BUILD_FEM_VTK)
|
||||
SET(FemPost_SRCS
|
||||
FemPostObject.h
|
||||
FemPostObject.cpp
|
||||
FemPostPipeline.h
|
||||
FemPostPipeline.cpp
|
||||
FemPostFilter.h
|
||||
FemPostFilter.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}
|
||||
)
|
||||
|
||||
241
src/Mod/Fem/App/CMakeLists.txt.orig
Executable file
241
src/Mod/Fem/App/CMakeLists.txt.orig
Executable file
@@ -0,0 +1,241 @@
|
||||
if(MSVC)
|
||||
add_definitions(-DFCAppFem -DHAVE_ACOSH -DHAVE_ASINH -DHAVE_ATANH)
|
||||
else(MSVC)
|
||||
add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H)
|
||||
endif(MSVC)
|
||||
|
||||
if(BUILD_FEM_NETGEN)
|
||||
add_definitions(-DFCWithNetgen ${NETGEN_DEFINITIONS})
|
||||
endif(BUILD_FEM_NETGEN)
|
||||
|
||||
|
||||
include_directories(
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_BINARY_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/src/3rdParty/ANN/include
|
||||
${Boost_INCLUDE_DIRS}
|
||||
${QT_INCLUDE_DIR}
|
||||
${OCC_INCLUDE_DIR}
|
||||
${PYTHON_INCLUDE_DIRS}
|
||||
${ZLIB_INCLUDE_DIR}
|
||||
${XercesC_INCLUDE_DIRS}
|
||||
${SMESH_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
link_directories(${OCC_LIBRARY_DIR})
|
||||
|
||||
set(Fem_LIBS
|
||||
Part
|
||||
FreeCADApp
|
||||
StdMeshers
|
||||
SMESH
|
||||
SMDS
|
||||
SMESHDS
|
||||
)
|
||||
|
||||
if(BUILD_FEM_NETGEN)
|
||||
set(Fem_LIBS
|
||||
${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)
|
||||
|
||||
|
||||
SET(Python_SRCS
|
||||
FemMeshPy.xml
|
||||
FemMeshPyImp.cpp
|
||||
HypothesisPy.cpp
|
||||
HypothesisPy.h
|
||||
)
|
||||
SOURCE_GROUP("Python" FILES ${Python_SRCS})
|
||||
|
||||
SET(Mod_SRCS
|
||||
AppFem.cpp
|
||||
AppFemPy.cpp
|
||||
FemTools.cpp
|
||||
FemTools.h
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
)
|
||||
SOURCE_GROUP("Module" FILES ${Mod_SRCS})
|
||||
|
||||
SET(FemScripts_SRCS
|
||||
_CommandFemBeamSection.py
|
||||
_CommandFemFromShape.py
|
||||
_CommandFemShellThickness.py
|
||||
_CommandFemSolverCalculix.py
|
||||
_CommandMechanicalMaterial.py
|
||||
_CommandMechanicalShowResult.py
|
||||
_CommandNewMechanicalAnalysis.py
|
||||
_CommandPurgeFemResults.py
|
||||
_CommandQuickAnalysis.py
|
||||
_CommandSolverJobControl.py
|
||||
_FemAnalysis.py
|
||||
_FemBeamSection.py
|
||||
_FemShellThickness.py
|
||||
_FemSolverCalculix.py
|
||||
_MechanicalMaterial.py
|
||||
_TaskPanelFemBeamSection.py
|
||||
_TaskPanelFemShellThickness.py
|
||||
_TaskPanelFemSolverCalculix.py
|
||||
_TaskPanelMechanicalMaterial.py
|
||||
_TaskPanelResultControl.py
|
||||
_ViewProviderFemAnalysis.py
|
||||
_ViewProviderFemBeamSection.py
|
||||
_ViewProviderFemShellThickness.py
|
||||
_ViewProviderFemSolverCalculix.py
|
||||
_ViewProviderMechanicalMaterial.py
|
||||
ccxDatReader.py
|
||||
ccxFrdReader.py
|
||||
ccxInpWriter.py
|
||||
convert2TetGen.py
|
||||
Init.py
|
||||
InitGui.py
|
||||
FemAnalysis.py
|
||||
FemCommands.py
|
||||
FemBeamSection.py
|
||||
FemShellThickness.py
|
||||
FemSolverCalculix.py
|
||||
FemTools.py
|
||||
MechanicalMaterial.py
|
||||
SelectionObserverFem.py
|
||||
TestFem.py
|
||||
|
||||
TaskPanelFemBeamSection.ui
|
||||
TaskPanelFemShellThickness.ui
|
||||
TaskPanelFemSolverCalculix.ui
|
||||
TaskPanelMechanicalMaterial.ui
|
||||
TaskPanelShowDisplacement.ui
|
||||
)
|
||||
#SOURCE_GROUP("Scripts" FILES ${FemScripts_SRCS})
|
||||
|
||||
SET(FemTests_SRCS
|
||||
test_files/ccx/mesh_points.csv
|
||||
test_files/ccx/mesh_volumes.csv
|
||||
test_files/ccx/cube_frequency.inp
|
||||
test_files/ccx/cube_frequency.dat
|
||||
test_files/ccx/cube_frequency.frd
|
||||
test_files/ccx/cube_frequency_expected_values
|
||||
test_files/ccx/cube_static.inp
|
||||
test_files/ccx/cube_static.dat
|
||||
test_files/ccx/cube_static.frd
|
||||
test_files/ccx/cube_static_expected_values
|
||||
test_files/ccx/cube.fcstd
|
||||
)
|
||||
|
||||
SET(FemBase_SRCS
|
||||
FemMeshObject.cpp
|
||||
FemMeshObject.h
|
||||
FemMeshShapeObject.cpp
|
||||
FemMeshShapeObject.h
|
||||
FemMeshShapeNetgenObject.cpp
|
||||
FemMeshShapeNetgenObject.h
|
||||
FemAnalysis.cpp
|
||||
FemAnalysis.h
|
||||
FemMesh.cpp
|
||||
FemMesh.h
|
||||
FemResultObject.cpp
|
||||
FemResultObject.h
|
||||
FemSolverObject.cpp
|
||||
FemSolverObject.h
|
||||
FemConstraint.cpp
|
||||
FemConstraint.h
|
||||
FemMeshProperty.cpp
|
||||
FemMeshProperty.h
|
||||
)
|
||||
SOURCE_GROUP("Base types" FILES ${FemBase_SRCS})
|
||||
|
||||
|
||||
SET(FemSet_SRCS
|
||||
FemSetObject.cpp
|
||||
FemSetObject.h
|
||||
FemSetNodesObject.cpp
|
||||
FemSetNodesObject.h
|
||||
FemSetElementsObject.cpp
|
||||
FemSetElementsObject.h
|
||||
FemSetFacesObject.cpp
|
||||
FemSetFacesObject.h
|
||||
FemSetGeometryObject.cpp
|
||||
FemSetGeometryObject.h
|
||||
)
|
||||
SOURCE_GROUP("Set objects" FILES ${FemSet_SRCS})
|
||||
|
||||
SET(FemConstraints_SRCS
|
||||
FemConstraintBearing.h
|
||||
FemConstraintBearing.cpp
|
||||
FemConstraintFixed.cpp
|
||||
FemConstraintFixed.h
|
||||
FemConstraintForce.cpp
|
||||
FemConstraintForce.h
|
||||
FemConstraintPressure.cpp
|
||||
FemConstraintPressure.h
|
||||
FemConstraintGear.cpp
|
||||
FemConstraintGear.h
|
||||
FemConstraintPulley.cpp
|
||||
FemConstraintPulley.h
|
||||
FemConstraintDisplacement.h
|
||||
FemConstraintDisplacement.cpp
|
||||
)
|
||||
SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS})
|
||||
|
||||
<<<<<<< 09326bbbdaf756fe381d51d340e0db27fd8c452a
|
||||
SET(FemResult_SRCS
|
||||
)
|
||||
SOURCE_GROUP("ResultObjects" FILES ${FemResult_SRCS})
|
||||
|
||||
SET(Fem_SRCS
|
||||
${FemBase_SRCS}
|
||||
${FemSet_SRCS}
|
||||
${FemConstraints_SRCS}
|
||||
${FemResult_SRCS}
|
||||
=======
|
||||
if(BUILD_FEM_VTK)
|
||||
SET(FemPost_SRCS
|
||||
FemPostObject.h
|
||||
FemPostObject.cpp
|
||||
FemPostPipeline.h
|
||||
FemPostPipeline.cpp
|
||||
FemPostFilter.h
|
||||
FemPostFilter.cpp
|
||||
)
|
||||
SOURCE_GROUP("PostObjects" FILES ${FemPost_SRCS})
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
|
||||
SET(Fem_SRCS
|
||||
${FemBase_SRCS}
|
||||
${FemSet_SRCS}
|
||||
${FemConstraints_SRCS}
|
||||
${FemPost_SRCS}
|
||||
>>>>>>> Move post processing to fem objects
|
||||
${Mod_SRCS}
|
||||
${Python_SRCS}
|
||||
)
|
||||
|
||||
add_library(Fem SHARED ${Fem_SRCS})
|
||||
target_link_libraries(Fem ${Fem_LIBS})
|
||||
|
||||
|
||||
fc_target_copy_resource(Fem
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/Fem
|
||||
${CMAKE_BINARY_DIR}/Mod/Fem
|
||||
Init.py
|
||||
${FemScripts_SRCS}
|
||||
${FemTests_SRCS}
|
||||
)
|
||||
|
||||
SET_BIN_DIR(Fem Fem /Mod/Fem)
|
||||
SET_PYTHON_PREFIX_SUFFIX(Fem)
|
||||
|
||||
INSTALL(TARGETS Fem DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
66
src/Mod/Fem/App/FemPostFilter.cpp
Normal file
66
src/Mod/Fem/App/FemPostFilter.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "FemPostFilter.h"
|
||||
#include <App/DocumentObjectPy.h>
|
||||
|
||||
using namespace Fem;
|
||||
using namespace App;
|
||||
|
||||
PROPERTY_SOURCE(Fem::FemPostFilter, Fem::FemPostObject)
|
||||
|
||||
|
||||
FemPostFilter::FemPostFilter()
|
||||
{
|
||||
}
|
||||
|
||||
FemPostFilter::~FemPostFilter()
|
||||
{
|
||||
}
|
||||
|
||||
short FemPostFilter::mustExecute(void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject *FemPostFilter::getPyObject()
|
||||
{
|
||||
if (PythonObject.is(Py::_None())){
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DocumentObjectPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
void FemPostFilter::onChanged(const Property* prop)
|
||||
{
|
||||
App::GeoFeature::onChanged(prop);
|
||||
|
||||
// if the placement has changed apply the change to the grid data as well
|
||||
|
||||
}
|
||||
61
src/Mod/Fem/App/FemPostFilter.h
Normal file
61
src/Mod/Fem/App/FemPostFilter.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef Fem_FemPostFilter_H
|
||||
#define Fem_FemPostFilter_H
|
||||
|
||||
#include "FemPostObject.h"
|
||||
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
|
||||
namespace Fem
|
||||
{
|
||||
|
||||
class AppFemExport FemPostFilter : public Fem::FemPostObject
|
||||
{
|
||||
PROPERTY_HEADER(Fem::FemPostFilter);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FemPostFilter(void);
|
||||
virtual ~FemPostFilter();
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "FemGui::ViewProviderPostPipeline";
|
||||
}
|
||||
short mustExecute(void) const;
|
||||
PyObject* getPyObject();
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
//members
|
||||
vtkSmartPointer<vtkUnstructuredGrid> source;
|
||||
};
|
||||
|
||||
} //namespace Fem
|
||||
|
||||
|
||||
#endif // Fem_FemPostFilter_H
|
||||
94
src/Mod/Fem/App/FemPostObject.cpp
Normal file
94
src/Mod/Fem/App/FemPostObject.cpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "FemPostObject.h"
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include <vtkPointData.h>
|
||||
#include <vtkCellData.h>
|
||||
|
||||
using namespace Fem;
|
||||
using namespace App;
|
||||
|
||||
PROPERTY_SOURCE(Fem::FemPostObject, App::GeoFeature)
|
||||
|
||||
|
||||
FemPostObject::FemPostObject()
|
||||
{
|
||||
ADD_PROPERTY(ModificationTime,(0));
|
||||
}
|
||||
|
||||
FemPostObject::~FemPostObject()
|
||||
{
|
||||
}
|
||||
|
||||
short FemPostObject::mustExecute(void) const
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn* FemPostObject::execute(void) {
|
||||
|
||||
//analyse the data and print
|
||||
Base::Console().Message("\nPoly Data Analysis:\n");
|
||||
|
||||
vtkPolyData* poly = polyDataSource->GetOutput();
|
||||
vtkPointData* point = poly->GetPointData();
|
||||
Base::Console().Message("Point components: %i\n", point->GetNumberOfComponents());
|
||||
Base::Console().Message("Point arrays: %i\n", point->GetNumberOfArrays());
|
||||
Base::Console().Message("Point tuples: %i\n", point->GetNumberOfTuples());
|
||||
|
||||
vtkCellData* cell = poly->GetCellData();
|
||||
Base::Console().Message("Cell components: %i\n", cell->GetNumberOfComponents());
|
||||
Base::Console().Message("Cell arrays: %i\n", cell->GetNumberOfArrays());
|
||||
Base::Console().Message("Point tuples: %i\n", cell->GetNumberOfTuples());
|
||||
|
||||
|
||||
if(polyDataSource && static_cast<unsigned long>(ModificationTime.getValue()) < polyDataSource->GetMTime())
|
||||
ModificationTime.setValue(static_cast<unsigned long>(polyDataSource->GetMTime()));
|
||||
|
||||
return DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
||||
PyObject *FemPostObject::getPyObject()
|
||||
{
|
||||
if (PythonObject.is(Py::_None())){
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DocumentObjectPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
void FemPostObject::onChanged(const Property* prop)
|
||||
{
|
||||
App::GeoFeature::onChanged(prop);
|
||||
|
||||
// if the placement has changed apply the change to the grid data as well
|
||||
|
||||
}
|
||||
72
src/Mod/Fem/App/FemPostObject.h
Normal file
72
src/Mod/Fem/App/FemPostObject.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef Fem_FemPostObject_H
|
||||
#define Fem_FemPostObject_H
|
||||
|
||||
#include <App/GeoFeature.h>
|
||||
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkPolyDataAlgorithm.h>
|
||||
|
||||
namespace Fem
|
||||
{
|
||||
|
||||
//poly data is the only data we can visualize, hence every post processing object needs to expose it
|
||||
class AppFemExport FemPostObject : public App::GeoFeature
|
||||
{
|
||||
PROPERTY_HEADER(Fem::FemPostObject);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FemPostObject(void);
|
||||
virtual ~FemPostObject();
|
||||
|
||||
App::PropertyInteger ModificationTime;
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "FemGui::ViewProviderFemPostObject";
|
||||
}
|
||||
|
||||
short mustExecute(void) const;
|
||||
virtual App::DocumentObjectExecReturn* execute(void);
|
||||
|
||||
PyObject* getPyObject();
|
||||
|
||||
//get the algorithm or the data
|
||||
vtkPolyData* getPolyData() {return polyDataSource->GetOutput();};
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> getPolyAlgorithm() {return polyDataSource;};
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
//members
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> polyDataSource;
|
||||
};
|
||||
|
||||
} //namespace Fem
|
||||
|
||||
|
||||
#endif // Fem_FemPostObject_H
|
||||
128
src/Mod/Fem/App/FemPostPipeline.cpp
Normal file
128
src/Mod/Fem/App/FemPostPipeline.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#endif
|
||||
|
||||
#include "FemPostPipeline.h"
|
||||
#include <Base/Console.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include <vtkDataSetReader.h>
|
||||
#include <vtkGeometryFilter.h>
|
||||
#include <vtkPointData.h>
|
||||
#include <vtkStructuredGrid.h>
|
||||
#include <vtkCellData.h>
|
||||
|
||||
using namespace Fem;
|
||||
using namespace App;
|
||||
|
||||
PROPERTY_SOURCE(Fem::FemPostPipeline, Fem::FemPostObject)
|
||||
|
||||
|
||||
FemPostPipeline::FemPostPipeline()
|
||||
{
|
||||
}
|
||||
|
||||
FemPostPipeline::~FemPostPipeline()
|
||||
{
|
||||
}
|
||||
|
||||
short FemPostPipeline::mustExecute(void) const
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
DocumentObjectExecReturn* FemPostPipeline::execute(void) {
|
||||
|
||||
Base::Console().Message("Pipeline analysis: \n");
|
||||
Base::Console().Message("Data Type: %i\n", source->GetDataObjectType());
|
||||
|
||||
if(source->GetDataObjectType() == VTK_STRUCTURED_GRID ) {
|
||||
vtkStructuredGrid* poly = static_cast<vtkStructuredGrid*>(source.GetPointer());
|
||||
vtkPointData* point = poly->GetPointData();
|
||||
Base::Console().Message("Point components: %i\n", point->GetNumberOfComponents());
|
||||
Base::Console().Message("Point arrays: %i\n", point->GetNumberOfArrays());
|
||||
Base::Console().Message("Point tuples: %i\n", point->GetNumberOfTuples());
|
||||
|
||||
vtkCellData* cell = poly->GetCellData();
|
||||
Base::Console().Message("Cell components: %i\n", cell->GetNumberOfComponents());
|
||||
Base::Console().Message("Cell arrays: %i\n", cell->GetNumberOfArrays());
|
||||
Base::Console().Message("Point tuples: %i\n", cell->GetNumberOfTuples());
|
||||
}
|
||||
|
||||
return Fem::FemPostObject::execute();
|
||||
}
|
||||
|
||||
|
||||
bool FemPostPipeline::canRead(Base::FileInfo File) {
|
||||
|
||||
if (File.hasExtension("vtk") )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void FemPostPipeline::read(Base::FileInfo File) {
|
||||
|
||||
// checking on the file
|
||||
if (!File.isReadable())
|
||||
throw Base::Exception("File to load not existing or not readable");
|
||||
|
||||
if (File.hasExtension("vtk") ) {
|
||||
|
||||
vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New();
|
||||
reader->SetFileName(File.filePath().c_str());
|
||||
reader->Update();
|
||||
source = reader->GetOutput();
|
||||
|
||||
}
|
||||
else{
|
||||
throw Base::Exception("Unknown extension");
|
||||
}
|
||||
|
||||
polyDataSource = vtkGeometryFilter::New();
|
||||
polyDataSource->SetInputData(source);
|
||||
polyDataSource->Update();
|
||||
}
|
||||
|
||||
|
||||
PyObject *FemPostPipeline::getPyObject()
|
||||
{
|
||||
if (PythonObject.is(Py::_None())){
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DocumentObjectPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
void FemPostPipeline::onChanged(const Property* prop)
|
||||
{
|
||||
App::GeoFeature::onChanged(prop);
|
||||
|
||||
// if the placement has changed apply the change to the grid data as well
|
||||
|
||||
}
|
||||
67
src/Mod/Fem/App/FemPostPipeline.h
Normal file
67
src/Mod/Fem/App/FemPostPipeline.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef Fem_FemPostPipeline_H
|
||||
#define Fem_FemPostPipeline_H
|
||||
|
||||
#include "FemPostObject.h"
|
||||
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkDataSet.h>
|
||||
|
||||
namespace Fem
|
||||
{
|
||||
|
||||
class AppFemExport FemPostPipeline : public Fem::FemPostObject
|
||||
{
|
||||
PROPERTY_HEADER(Fem::FemPostPipeline);
|
||||
|
||||
public:
|
||||
/// Constructor
|
||||
FemPostPipeline(void);
|
||||
virtual ~FemPostPipeline();
|
||||
|
||||
/// returns the type name of the ViewProvider
|
||||
// virtual const char* getViewProviderName(void) const {
|
||||
// return "FemGui::ViewProviderPostPipeline";
|
||||
// }
|
||||
|
||||
short mustExecute(void) const;
|
||||
virtual App::DocumentObjectExecReturn* execute(void);
|
||||
PyObject* getPyObject();
|
||||
|
||||
//load data from files
|
||||
static bool canRead(Base::FileInfo file);
|
||||
void read(Base::FileInfo file);
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
//members
|
||||
vtkSmartPointer<vtkDataSet> source;
|
||||
};
|
||||
|
||||
} //namespace Fem
|
||||
|
||||
|
||||
#endif // Fem_FemPostPipeline_H
|
||||
@@ -1,10 +1,15 @@
|
||||
|
||||
if(BUILD_FEM_VTK)
|
||||
include(${VTK_USE_FILE})
|
||||
add_definitions(-DFC_USE_VTK)
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
add_subdirectory(App)
|
||||
|
||||
if(BUILD_GUI)
|
||||
add_subdirectory(Gui)
|
||||
endif(BUILD_GUI)
|
||||
|
||||
|
||||
INSTALL(
|
||||
FILES
|
||||
# changes on the file list here needs to be made in App/CMakeLists.txt as well
|
||||
|
||||
@@ -1,116 +1,127 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
# include <Standard_math.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/WidgetFactory.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include "PropertyFemMeshItem.h"
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include "ViewProviderFemMesh.h"
|
||||
#include "ViewProviderFemMeshShape.h"
|
||||
#include "ViewProviderFemMeshShapeNetgen.h"
|
||||
#include "ViewProviderAnalysis.h"
|
||||
#include "ViewProviderSolver.h"
|
||||
#include "ViewProviderSetNodes.h"
|
||||
#include "ViewProviderSetElements.h"
|
||||
#include "ViewProviderSetFaces.h"
|
||||
#include "ViewProviderSetGeometry.h"
|
||||
#include "ViewProviderFemConstraint.h"
|
||||
#include "ViewProviderFemConstraintBearing.h"
|
||||
#include "ViewProviderFemConstraintFixed.h"
|
||||
#include "ViewProviderFemConstraintForce.h"
|
||||
#include "ViewProviderFemConstraintPressure.h"
|
||||
#include "ViewProviderFemConstraintGear.h"
|
||||
#include "ViewProviderFemConstraintPulley.h"
|
||||
#include "ViewProviderFemConstraintDisplacement.h"
|
||||
#include "ViewProviderResult.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateFemCommands(void);
|
||||
|
||||
void loadFemResource()
|
||||
{
|
||||
// add resources and reloads the translators
|
||||
Q_INIT_RESOURCE(Fem);
|
||||
Gui::Translator::instance()->refresh();
|
||||
}
|
||||
|
||||
namespace FemGui {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFemGui()
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
return;
|
||||
}
|
||||
|
||||
(void) FemGui::initModule();
|
||||
Base::Console().Log("Loading GUI of Fem module... done\n");
|
||||
|
||||
// instantiating the commands
|
||||
CreateFemCommands();
|
||||
|
||||
// addition objects
|
||||
FemGui::Workbench ::init();
|
||||
FemGui::ViewProviderFemAnalysis ::init();
|
||||
FemGui::ViewProviderFemAnalysisPython ::init();
|
||||
FemGui::ViewProviderFemMesh ::init();
|
||||
FemGui::ViewProviderFemMeshShape ::init();
|
||||
FemGui::ViewProviderFemMeshShapeNetgen ::init();
|
||||
FemGui::ViewProviderSolver ::init();
|
||||
FemGui::ViewProviderSolverPython ::init();
|
||||
FemGui::ViewProviderSetNodes ::init();
|
||||
FemGui::ViewProviderSetElements ::init();
|
||||
FemGui::ViewProviderSetFaces ::init();
|
||||
FemGui::ViewProviderSetGeometry ::init();
|
||||
FemGui::ViewProviderFemConstraint ::init();
|
||||
FemGui::ViewProviderFemConstraintBearing ::init();
|
||||
FemGui::ViewProviderFemConstraintFixed ::init();
|
||||
FemGui::ViewProviderFemConstraintForce ::init();
|
||||
FemGui::ViewProviderFemConstraintPressure ::init();
|
||||
FemGui::ViewProviderFemConstraintGear ::init();
|
||||
FemGui::ViewProviderFemConstraintPulley ::init();
|
||||
FemGui::ViewProviderFemConstraintDisplacement ::init();
|
||||
FemGui::ViewProviderResult ::init();
|
||||
FemGui::ViewProviderResultPython ::init();
|
||||
FemGui::PropertyFemMeshItem ::init();
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<FemGui::DlgSettingsFemImp> ("FEM");
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadFemResource();
|
||||
}
|
||||
<<<<<<< 5ad8d55fe07f22805dab9d61746caf74d0deda72
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Python.h>
|
||||
# include <Standard_math.hxx>
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/WidgetFactory.h>
|
||||
#include <Gui/Language/Translator.h>
|
||||
#include "PropertyFemMeshItem.h"
|
||||
#include "DlgSettingsFemImp.h"
|
||||
#include "ViewProviderFemMesh.h"
|
||||
#include "ViewProviderFemMeshShape.h"
|
||||
#include "ViewProviderFemMeshShapeNetgen.h"
|
||||
#include "ViewProviderAnalysis.h"
|
||||
#include "ViewProviderSolver.h"
|
||||
#include "ViewProviderSetNodes.h"
|
||||
#include "ViewProviderSetElements.h"
|
||||
#include "ViewProviderSetFaces.h"
|
||||
#include "ViewProviderSetGeometry.h"
|
||||
#include "ViewProviderFemConstraint.h"
|
||||
#include "ViewProviderFemConstraintBearing.h"
|
||||
#include "ViewProviderFemConstraintFixed.h"
|
||||
#include "ViewProviderFemConstraintForce.h"
|
||||
#include "ViewProviderFemConstraintPressure.h"
|
||||
#include "ViewProviderFemConstraintGear.h"
|
||||
#include "ViewProviderFemConstraintPulley.h"
|
||||
#include "ViewProviderFemConstraintDisplacement.h"
|
||||
#include "ViewProviderResult.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
#ifdef FC_USE_VTK
|
||||
#include "ViewProviderFemPostObject.h"
|
||||
#endif
|
||||
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
void CreateFemCommands(void);
|
||||
|
||||
void loadFemResource()
|
||||
{
|
||||
// add resources and reloads the translators
|
||||
Q_INIT_RESOURCE(Fem);
|
||||
Gui::Translator::instance()->refresh();
|
||||
}
|
||||
|
||||
namespace FemGui {
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initFemGui()
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
return;
|
||||
}
|
||||
|
||||
(void) FemGui::initModule();
|
||||
Base::Console().Log("Loading GUI of Fem module... done\n");
|
||||
|
||||
// instantiating the commands
|
||||
CreateFemCommands();
|
||||
|
||||
// addition objects
|
||||
FemGui::Workbench ::init();
|
||||
FemGui::ViewProviderFemAnalysis ::init();
|
||||
FemGui::ViewProviderFemAnalysisPython ::init();
|
||||
FemGui::ViewProviderFemMesh ::init();
|
||||
FemGui::ViewProviderFemMeshShape ::init();
|
||||
FemGui::ViewProviderFemMeshShapeNetgen ::init();
|
||||
FemGui::ViewProviderSolver ::init();
|
||||
FemGui::ViewProviderSolverPython ::init();
|
||||
FemGui::ViewProviderSetNodes ::init();
|
||||
FemGui::ViewProviderSetElements ::init();
|
||||
FemGui::ViewProviderSetFaces ::init();
|
||||
FemGui::ViewProviderSetGeometry ::init();
|
||||
FemGui::ViewProviderFemConstraint ::init();
|
||||
FemGui::ViewProviderFemConstraintBearing ::init();
|
||||
FemGui::ViewProviderFemConstraintFixed ::init();
|
||||
FemGui::ViewProviderFemConstraintForce ::init();
|
||||
FemGui::ViewProviderFemConstraintPressure ::init();
|
||||
FemGui::ViewProviderFemConstraintGear ::init();
|
||||
FemGui::ViewProviderFemConstraintPulley ::init();
|
||||
FemGui::ViewProviderFemConstraintDisplacement ::init();
|
||||
FemGui::ViewProviderResult ::init();
|
||||
FemGui::ViewProviderResultPython ::init();
|
||||
FemGui::PropertyFemMeshItem ::init();
|
||||
|
||||
#ifdef FC_USE_VTK
|
||||
FemGui::ViewProviderFemPostObject ::init();
|
||||
#endif
|
||||
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<FemGui::DlgSettingsFemImp> ("FEM");
|
||||
|
||||
// add resources and reloads the translators
|
||||
loadFemResource();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,13 @@ set(FemGui_LIBS
|
||||
FreeCADGui
|
||||
)
|
||||
|
||||
if(BUILD_FEM_VTK)
|
||||
set(FemGui_LIBS
|
||||
${FemGui_LIBS}
|
||||
${VTK_LIBRARIES}
|
||||
)
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
generate_from_xml(ViewProviderFemMeshPy)
|
||||
|
||||
SET(Python_SRCS
|
||||
@@ -202,6 +209,14 @@ SET(FemGui_SRCS_Module
|
||||
)
|
||||
SOURCE_GROUP("Module" FILES ${FemGui_SRCS_Module})
|
||||
|
||||
if(BUILD_FEM_VTK)
|
||||
SET(FemGui_SRCS_Post
|
||||
ViewProviderFemPostObject.h
|
||||
ViewProviderFemPostObject.cpp
|
||||
)
|
||||
SOURCE_GROUP("PostObjects" FILES ${FemGui_SRCS_Post})
|
||||
endif(BUILD_FEM_VTK)
|
||||
|
||||
SET(FemGui_SRCS
|
||||
${Python_SRCS}
|
||||
${FemGui_DLG_SRCS}
|
||||
@@ -210,6 +225,7 @@ SET(FemGui_SRCS
|
||||
${FemGui_SRCS_TaskDlg}
|
||||
${FemGui_SRCS_TaskBoxes}
|
||||
${FemGui_SRCS_Module}
|
||||
${FemGui_SRCS_Post}
|
||||
)
|
||||
|
||||
|
||||
|
||||
476
src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp
Normal file
476
src/Mod/Fem/Gui/ViewProviderFemPostObject.cpp
Normal file
@@ -0,0 +1,476 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoIndexedMarkerSet.h>
|
||||
#include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
#include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
#include <Inventor/nodes/SoIndexedTriangleStripSet.h>
|
||||
#include <Inventor/nodes/SoShapeHints.h>
|
||||
#include <Inventor/nodes/SoMaterial.h>
|
||||
#include <Inventor/nodes/SoNormal.h>
|
||||
#include <Inventor/nodes/SoSeparator.h>
|
||||
#include <Inventor/nodes/SoPointSet.h>
|
||||
#include <Inventor/nodes/SoPolygonOffset.h>
|
||||
#include <Inventor/nodes/SoDrawStyle.h>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderFemPostObject.h"
|
||||
#include <Mod/Fem/App/FemPostObject.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <vtkPointData.h>
|
||||
#include <vtkCellArray.h>
|
||||
#include <vtkCellData.h>
|
||||
#include <vtkLookupTable.h>
|
||||
|
||||
using namespace FemGui;
|
||||
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostObject, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(false)
|
||||
{
|
||||
//initialize the properties
|
||||
ADD_PROPERTY(Coloring,((long)0));
|
||||
ADD_PROPERTY(Transperency, (0));
|
||||
|
||||
m_transperencyConstraint.StepSize = 1;
|
||||
m_transperencyConstraint.LowerBound = 0;
|
||||
m_transperencyConstraint.UpperBound = 100;
|
||||
Transperency.setConstraints(&m_transperencyConstraint);
|
||||
|
||||
sPixmap = "fem-fem-mesh-from-shape";
|
||||
|
||||
//create the subnodes which do the visualization work
|
||||
m_shapeHints = new SoShapeHints();
|
||||
m_shapeHints->ref();
|
||||
m_shapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
|
||||
m_coordinates = new SoCoordinate3();
|
||||
m_coordinates->ref();
|
||||
m_materialBinding = new SoMaterialBinding();
|
||||
m_materialBinding->ref();
|
||||
m_material = new SoMaterial();
|
||||
m_material->ref();
|
||||
m_normalBinding = new SoNormalBinding();
|
||||
m_normalBinding->ref();
|
||||
m_normals = new SoNormal();
|
||||
m_normals->ref();
|
||||
m_faces = new SoIndexedFaceSet();
|
||||
m_faces->ref();
|
||||
m_triangleStrips = new SoIndexedTriangleStripSet();
|
||||
m_triangleStrips->ref();
|
||||
m_markers = new SoIndexedMarkerSet();
|
||||
m_markers->ref();
|
||||
m_lines = new SoIndexedLineSet();
|
||||
m_lines->ref();
|
||||
m_drawStyle = new SoDrawStyle();
|
||||
m_drawStyle->ref();
|
||||
m_seperator = new SoSeparator();
|
||||
m_seperator->ref();
|
||||
}
|
||||
|
||||
ViewProviderFemPostObject::~ViewProviderFemPostObject()
|
||||
{
|
||||
m_shapeHints->unref();
|
||||
m_coordinates->unref();
|
||||
m_materialBinding->unref();
|
||||
m_drawStyle->unref();
|
||||
m_normalBinding->unref();
|
||||
m_normals->unref();
|
||||
m_faces->unref();
|
||||
m_triangleStrips->unref();
|
||||
m_markers->unref();
|
||||
m_lines->unref();
|
||||
m_seperator->unref();
|
||||
m_material->unref();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::attach(App::DocumentObject *pcObj)
|
||||
{
|
||||
ViewProviderDocumentObject::attach(pcObj);
|
||||
|
||||
// flat
|
||||
SoGroup* pcFlatRoot = new SoGroup();
|
||||
// face nodes
|
||||
pcFlatRoot->addChild(m_coordinates);
|
||||
pcFlatRoot->addChild(m_shapeHints);
|
||||
pcFlatRoot->addChild(m_material);
|
||||
pcFlatRoot->addChild(m_materialBinding);
|
||||
pcFlatRoot->addChild(m_faces);
|
||||
|
||||
// line
|
||||
SoGroup* pcWireRoot = new SoGroup();
|
||||
pcWireRoot->addChild(m_coordinates);
|
||||
pcWireRoot->addChild(m_drawStyle);
|
||||
pcWireRoot->addChild(m_lines);
|
||||
|
||||
// Points
|
||||
SoGroup* pcPointsRoot = new SoSeparator();
|
||||
pcPointsRoot->addChild(m_coordinates);
|
||||
pcPointsRoot->addChild(m_markers);
|
||||
|
||||
//all
|
||||
m_seperator->addChild(pcFlatRoot);
|
||||
m_seperator->addChild(pcWireRoot);
|
||||
m_seperator->addChild(pcPointsRoot);
|
||||
addDisplayMaskMode(m_seperator, "Default");
|
||||
setDisplayMaskMode("Default");
|
||||
|
||||
setupPipeline();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::setDisplayMode(const char* ModeName)
|
||||
{
|
||||
if (strcmp("Outline",ModeName)==0)
|
||||
m_currentAlgorithm = m_outline;
|
||||
else if (strcmp("Surface with Edges",ModeName)==0)
|
||||
m_currentAlgorithm = m_surfaceEdges;
|
||||
else if (strcmp("Surface",ModeName)==0)
|
||||
m_currentAlgorithm = static_cast<Fem::FemPostObject*>(getObject())->getPolyAlgorithm();
|
||||
else if (strcmp("Wireframe",ModeName)==0)
|
||||
m_currentAlgorithm = m_wireframe;
|
||||
/*else if (strcmp("Nodes",ModeName)==0)
|
||||
setDisplayMaskMode("Nodes");*/
|
||||
|
||||
update();
|
||||
|
||||
ViewProviderDocumentObject::setDisplayMode( ModeName );
|
||||
}
|
||||
|
||||
std::vector<std::string> ViewProviderFemPostObject::getDisplayModes(void) const
|
||||
{
|
||||
std::vector<std::string> StrList;
|
||||
StrList.push_back("Outline");
|
||||
// StrList.push_back("Points");
|
||||
StrList.push_back("Surface");
|
||||
StrList.push_back("Surface with Edges");
|
||||
StrList.push_back("Wireframe");
|
||||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::update() {
|
||||
|
||||
if(!setupPipeline())
|
||||
return;
|
||||
|
||||
m_currentAlgorithm->Update();
|
||||
vtkPolyData* poly = m_currentAlgorithm->GetOutput();
|
||||
|
||||
//update the coloring property
|
||||
m_blockPropertyChanges = true;
|
||||
|
||||
std::string val;
|
||||
if(Coloring.getEnums() && Coloring.getValue() >= 0)
|
||||
val = Coloring.getValueAsString();
|
||||
|
||||
std::vector<std::string> colorArrays;
|
||||
colorArrays.push_back("None");
|
||||
|
||||
vtkPointData* point = poly->GetPointData();
|
||||
for(int i=0; i<point->GetNumberOfArrays(); ++i)
|
||||
colorArrays.push_back(point->GetArrayName(i));
|
||||
|
||||
vtkCellData* cell = poly->GetCellData();
|
||||
for(int i=0; i<cell->GetNumberOfArrays(); ++i)
|
||||
colorArrays.push_back(cell->GetArrayName(i));
|
||||
|
||||
App::Enumeration empty;
|
||||
Coloring.setValue(empty);
|
||||
m_coloringEnum.setEnums(colorArrays);
|
||||
Coloring.setValue(m_coloringEnum);
|
||||
|
||||
std::vector<std::string>::iterator it = std::find(colorArrays.begin(), colorArrays.end(), val);
|
||||
if(!val.empty() && it != colorArrays.end())
|
||||
Coloring.setValue(val.c_str());
|
||||
|
||||
Coloring.purgeTouched();
|
||||
|
||||
m_blockPropertyChanges = false;
|
||||
|
||||
//update the visualization
|
||||
update3D();
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderFemPostObject::update3D() {
|
||||
|
||||
if(!setupPipeline())
|
||||
return;
|
||||
|
||||
vtkPolyData* pd = m_currentAlgorithm->GetOutput();
|
||||
|
||||
vtkPointData *pntData;
|
||||
vtkPoints *points;
|
||||
vtkDataArray *normals = NULL;
|
||||
vtkDataArray *tcoords = NULL;
|
||||
vtkCellArray *cells;
|
||||
vtkIdType npts = 0;
|
||||
vtkIdType *indx = 0;
|
||||
|
||||
points = pd->GetPoints();
|
||||
pntData = pd->GetPointData();
|
||||
normals = pntData->GetNormals();
|
||||
tcoords = pntData->GetTCoords();
|
||||
|
||||
// write out point data if any
|
||||
WritePointData(points, normals, tcoords);
|
||||
WriteColorData();
|
||||
WriteTransperency();
|
||||
|
||||
// write out polys if any
|
||||
if (pd->GetNumberOfPolys() > 0) {
|
||||
|
||||
Base::Console().Message("render polys: %i\n", pd->GetNumberOfPolys());
|
||||
m_faces->coordIndex.startEditing();
|
||||
int soidx = 0;
|
||||
cells = pd->GetPolys();
|
||||
for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) {
|
||||
|
||||
for (int i = 0; i < npts; i++) {
|
||||
m_faces->coordIndex.set1Value(soidx, static_cast<int>(indx[i]));
|
||||
++soidx;
|
||||
}
|
||||
m_faces->coordIndex.set1Value(soidx, -1);
|
||||
++soidx;
|
||||
}
|
||||
m_faces->coordIndex.setNum(soidx);
|
||||
m_faces->coordIndex.finishEditing();
|
||||
}
|
||||
else
|
||||
m_faces->coordIndex.setNum(0);
|
||||
|
||||
|
||||
// write out tstrips if any
|
||||
if (pd->GetNumberOfStrips() > 0) {
|
||||
|
||||
Base::Console().Message("render strips\n");
|
||||
int soidx = 0;
|
||||
cells = pd->GetStrips();
|
||||
m_triangleStrips->coordIndex.startEditing();
|
||||
for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) {
|
||||
|
||||
for (int i = 0; i < npts; i++) {
|
||||
m_triangleStrips->coordIndex.set1Value(soidx, static_cast<int>(indx[i]));
|
||||
++soidx;
|
||||
}
|
||||
m_triangleStrips->coordIndex.set1Value(soidx, -1);
|
||||
++soidx;
|
||||
}
|
||||
m_triangleStrips->coordIndex.setNum(soidx);
|
||||
m_triangleStrips->coordIndex.finishEditing();
|
||||
}
|
||||
else
|
||||
m_triangleStrips->coordIndex.setNum(0);
|
||||
|
||||
// write out lines if any
|
||||
if (pd->GetNumberOfLines() > 0) {
|
||||
|
||||
Base::Console().Message("render lines: %i\n", pd->GetNumberOfLines());
|
||||
int soidx = 0;
|
||||
cells = pd->GetLines();
|
||||
m_lines->coordIndex.startEditing();
|
||||
for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) {
|
||||
for (int i = 0; i < npts; i++) {
|
||||
m_lines->coordIndex.set1Value(soidx, static_cast<int>(indx[i]));
|
||||
++soidx;
|
||||
}
|
||||
m_lines->coordIndex.set1Value(soidx, -1);
|
||||
++soidx;
|
||||
}
|
||||
m_lines->coordIndex.setNum(soidx);
|
||||
m_lines->coordIndex.finishEditing();
|
||||
}
|
||||
else
|
||||
m_lines->coordIndex.setNum(0);
|
||||
|
||||
// write out verts if any
|
||||
// (more complex because there is no IndexedPointSet)
|
||||
if (pd->GetNumberOfVerts() > 0){
|
||||
|
||||
Base::Console().Message("render verts\n");
|
||||
int soidx = 0;
|
||||
cells = pd->GetVerts();
|
||||
m_markers->coordIndex.startEditing();
|
||||
for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) {
|
||||
for (int i = 0; i < npts; i++) {
|
||||
m_markers->coordIndex.set1Value(soidx, static_cast<int>(indx[i]));
|
||||
++soidx;
|
||||
}
|
||||
m_markers->coordIndex.set1Value(soidx, -1);
|
||||
++soidx;
|
||||
}
|
||||
m_markers->coordIndex.setNum(soidx);
|
||||
m_markers->coordIndex.finishEditing();
|
||||
}
|
||||
else
|
||||
m_markers->coordIndex.setNum(0);
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray* normals, vtkDataArray* tcoords) {
|
||||
|
||||
|
||||
double *p;
|
||||
int i;
|
||||
|
||||
if(!points)
|
||||
return;
|
||||
|
||||
Base::Console().Message("render points: %i", points->GetNumberOfPoints());
|
||||
Base::Console().Message("\n");
|
||||
|
||||
m_coordinates->point.startEditing();
|
||||
for (i = 0; i < points->GetNumberOfPoints(); i++) {
|
||||
p = points->GetPoint(i);
|
||||
m_coordinates->point.set1Value(i, p[0], p[1], p[2]);
|
||||
}
|
||||
m_coordinates->point.setNum(points->GetNumberOfPoints());
|
||||
m_coordinates->point.finishEditing();
|
||||
|
||||
// write out the point normal data
|
||||
if (normals) {
|
||||
|
||||
Base::Console().Message("Write normals: %i\n", normals->GetNumberOfTuples());
|
||||
m_normals->vector.startEditing();
|
||||
for (i = 0; i < normals->GetNumberOfTuples(); i++) {
|
||||
p = normals->GetTuple(i);
|
||||
m_normals->vector.set1Value(i, SbVec3f(p[0], p[1], p[2]));
|
||||
}
|
||||
m_normals->vector.setNum(normals->GetNumberOfTuples());
|
||||
m_normals->vector.finishEditing();
|
||||
|
||||
m_normalBinding->value = SoNormalBinding::PER_VERTEX_INDEXED;
|
||||
m_normalBinding->value.touch();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::WriteColorData() {
|
||||
|
||||
if(!m_currentAlgorithm)
|
||||
return;
|
||||
|
||||
if(Coloring.getEnumVector().empty() || Coloring.getValue() == 0) {
|
||||
|
||||
m_material->diffuseColor.setValue(SbColor(0.8,0.8,0.8));
|
||||
m_material->transparency.setValue(0.);
|
||||
m_materialBinding->value = SoMaterialBinding::OVERALL;
|
||||
m_materialBinding->touch();
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
int array = Coloring.getValue() - 1; //0 is none
|
||||
vtkPolyData* pd = m_currentAlgorithm->GetOutput();
|
||||
vtkDataArray* data = pd->GetPointData()->GetArray(array);
|
||||
|
||||
//build the lookuptable
|
||||
double range[2];
|
||||
data->GetRange(range, 0);
|
||||
m_lookup->SetTableRange(range[0], range[1]);
|
||||
m_lookup->SetScaleToLinear();
|
||||
m_lookup->Build();
|
||||
|
||||
m_material->diffuseColor.startEditing();
|
||||
|
||||
for (int i = 0; i < pd->GetNumberOfPoints(); i++) {
|
||||
|
||||
double value = data->GetComponent(i, 0);
|
||||
double c[3];
|
||||
m_lookup->GetColor(value, c);
|
||||
m_material->diffuseColor.set1Value(i, c[0], c[1], c[2]);
|
||||
}
|
||||
m_material->diffuseColor.finishEditing();
|
||||
m_materialBinding->value = SoMaterialBinding::PER_VERTEX_INDEXED;
|
||||
m_materialBinding->touch();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostObject::WriteTransperency() {
|
||||
|
||||
float trans = float(Transperency.getValue()) / 100.;
|
||||
|
||||
m_material->transparency.startEditing();
|
||||
for(int i=0; i<m_material->diffuseColor.getNum(); ++i)
|
||||
m_material->transparency.set1Value(i, trans);
|
||||
|
||||
m_material->transparency.finishEditing();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ViewProviderFemPostObject::updateData(const App::Property* p) {
|
||||
|
||||
if( strcmp(p->getName(), "ModificationTime") == 0 && setupPipeline() ) {
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderFemPostObject::setupPipeline() {
|
||||
|
||||
if(!static_cast<Fem::FemPostObject*>(getObject())->getPolyAlgorithm())
|
||||
return false;
|
||||
|
||||
if(!m_currentAlgorithm) {
|
||||
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> algorithm = static_cast<Fem::FemPostObject*>(getObject())->getPolyAlgorithm();
|
||||
|
||||
m_outline = vtkOutlineCornerFilter::New();
|
||||
m_outline->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
m_surface = vtkGeometryFilter::New();
|
||||
m_surface->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
m_wireframe = vtkExtractEdges::New();
|
||||
m_wireframe->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
m_surfaceEdges = vtkAppendPolyData::New();
|
||||
m_surfaceEdges->AddInputConnection(m_surface->GetOutputPort());
|
||||
m_surfaceEdges->AddInputConnection(m_wireframe->GetOutputPort());
|
||||
|
||||
m_lookup = vtkLookupTable::New();
|
||||
m_lookup->SetRampToLinear();
|
||||
|
||||
m_currentAlgorithm = m_outline;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderFemPostObject::onChanged(const App::Property* prop) {
|
||||
|
||||
if(m_blockPropertyChanges)
|
||||
return;
|
||||
|
||||
Base::Console().Message("On Changed: %s\n", prop->getName());
|
||||
if(prop == &Coloring && setupPipeline()) {
|
||||
WriteColorData();
|
||||
}
|
||||
else if(prop == &Transperency) {
|
||||
WriteTransperency();
|
||||
}
|
||||
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
135
src/Mod/Fem/Gui/ViewProviderFemPostObject.h
Normal file
135
src/Mod/Fem/Gui/ViewProviderFemPostObject.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2015 Stefan Tröger <stefantroeger@gmx.net> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef FEM_VIEWPROVIDERFEMPOSTOBJECT_H
|
||||
#define FEM_VIEWPROVIDERFEMPOSTOBJECT_H
|
||||
|
||||
#include <Gui/ViewProviderGeometryObject.h>
|
||||
|
||||
#include <CXX/Objects.hxx>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkOutlineFilter.h>
|
||||
#include <vtkOutlineCornerFilter.h>
|
||||
#include <vtkLookupTable.h>
|
||||
#include <vtkExtractEdges.h>
|
||||
#include <vtkAppendPolyData.h>
|
||||
#include <vtkGeometryFilter.h>
|
||||
|
||||
class vtkUnsignedCharArray;
|
||||
class vtkDataArray;
|
||||
class vtkPoints;
|
||||
class SoSeparator;
|
||||
class SoNormal;
|
||||
class SoNormalBinding;
|
||||
class SoMaterial;
|
||||
class SoShapeHints;
|
||||
class SoMaterialBinding;
|
||||
class SoIndexedFaceSet;
|
||||
class SoIndexedLineSet;
|
||||
class SoIndexedMarkerSet;
|
||||
class SoCoordinate3;
|
||||
class SoDrawStyle;
|
||||
class SoIndexedFaceSet;
|
||||
class SoIndexedLineSet;
|
||||
class SoIndexedTriangleStripSet;
|
||||
|
||||
|
||||
namespace FemGui
|
||||
{
|
||||
|
||||
class FemGuiExport ViewProviderFemPostObject : public Gui::ViewProviderDocumentObject
|
||||
{
|
||||
PROPERTY_HEADER(FemGui::ViewProviderFemPostObject);
|
||||
|
||||
public:
|
||||
/// constructor.
|
||||
ViewProviderFemPostObject();
|
||||
|
||||
/// destructor.
|
||||
~ViewProviderFemPostObject();
|
||||
|
||||
App::PropertyEnumeration Coloring;
|
||||
App::PropertyIntegerConstraint Transperency;
|
||||
|
||||
void attach(App::DocumentObject *pcObject);
|
||||
void setDisplayMode(const char* ModeName);
|
||||
std::vector<std::string> getDisplayModes() const;
|
||||
void updateData(const App::Property*);
|
||||
void onChanged(const App::Property* prop);
|
||||
|
||||
/** @name Selection handling
|
||||
* This group of methodes do the selection handling.
|
||||
* Here you can define how the selection for your ViewProvider
|
||||
* works.
|
||||
*/
|
||||
//@{
|
||||
// /// indicates if the ViewProvider use the new Selection model
|
||||
// virtual bool useNewSelectionModel(void) const {return true;}
|
||||
// /// return a hit element to the selection path or 0
|
||||
// virtual std::string getElement(const SoDetail*) const;
|
||||
// virtual SoDetail* getDetail(const char*) const;
|
||||
// /// return the higlight lines for a given element or the whole shape
|
||||
// virtual std::vector<Base::Vector3d> getSelectionShape(const char* Element) const;
|
||||
// //@}
|
||||
|
||||
protected:
|
||||
bool setupPipeline();
|
||||
void update();
|
||||
|
||||
SoCoordinate3* m_coordinates;
|
||||
SoIndexedMarkerSet* m_markers;
|
||||
SoIndexedLineSet* m_lines;
|
||||
SoIndexedFaceSet* m_faces;
|
||||
SoIndexedTriangleStripSet* m_triangleStrips;
|
||||
SoMaterial* m_material;
|
||||
SoMaterialBinding* m_materialBinding;
|
||||
SoShapeHints* m_shapeHints;
|
||||
SoNormalBinding* m_normalBinding;
|
||||
SoNormal* m_normals;
|
||||
SoDrawStyle* m_drawStyle;
|
||||
SoSeparator* m_seperator;
|
||||
|
||||
vtkSmartPointer<vtkPolyDataAlgorithm> m_currentAlgorithm;
|
||||
vtkSmartPointer<vtkGeometryFilter> m_surface;
|
||||
vtkSmartPointer<vtkAppendPolyData> m_surfaceEdges;
|
||||
vtkSmartPointer<vtkOutlineCornerFilter> m_outline;
|
||||
vtkSmartPointer<vtkExtractEdges> m_wireframe;
|
||||
vtkSmartPointer<vtkLookupTable> m_lookup;
|
||||
|
||||
private:
|
||||
void update3D();
|
||||
void WritePointData(vtkPoints *points, vtkDataArray *normals,
|
||||
vtkDataArray *tcoords);
|
||||
void WriteColorData();
|
||||
void WriteTransperency();
|
||||
|
||||
App::Enumeration m_coloringEnum;
|
||||
App::PropertyIntegerConstraint::Constraints m_transperencyConstraint;
|
||||
bool m_blockPropertyChanges;
|
||||
};
|
||||
|
||||
} //namespace FemGui
|
||||
|
||||
|
||||
#endif // FEM_VIEWPROVIDERFEMPOSTOBJECT_H
|
||||
@@ -1,39 +1,40 @@
|
||||
# FreeCAD init script of the Fem module
|
||||
# (c) 2001 Juergen Riegel
|
||||
|
||||
#***************************************************************************
|
||||
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
|
||||
#* *
|
||||
#* This file is part of the FreeCAD CAx development system. *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* FreeCAD is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Lesser General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with FreeCAD; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#* Juergen Riegel 2002 *
|
||||
#***************************************************************************/
|
||||
|
||||
|
||||
import FreeCAD
|
||||
|
||||
|
||||
FreeCAD.addExportType("TetGen file (*.poly)", "convert2TetGen")
|
||||
FreeCAD.addImportType("FEM formats (*.unv *.med *.dat *.bdf)", "Fem")
|
||||
FreeCAD.addExportType("FEM formats (*.unv *.med *.dat *.inp)", "Fem")
|
||||
FreeCAD.addImportType("CalculiX result (*.frd)", "ccxFrdReader")
|
||||
FreeCAD.addImportType("Abaqus file (*.inp)", "FemGui")
|
||||
FreeCAD.addImportType("Z88 mesh file (*.txt)", "importZ88Mesh")
|
||||
FreeCAD.addExportType("Z88 mesh file (*.txt)", "importZ88Mesh")
|
||||
FreeCAD.addImportType("Z88 displacement result file (*.txt)", "z88DispReader")
|
||||
# FreeCAD init script of the Fem module
|
||||
# (c) 2001 Juergen Riegel
|
||||
|
||||
#***************************************************************************
|
||||
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
|
||||
#* *
|
||||
#* This file is part of the FreeCAD CAx development system. *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* FreeCAD is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Lesser General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with FreeCAD; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#* Juergen Riegel 2002 *
|
||||
#***************************************************************************/
|
||||
|
||||
|
||||
import FreeCAD
|
||||
|
||||
|
||||
FreeCAD.addExportType("TetGen file (*.poly)", "convert2TetGen")
|
||||
FreeCAD.addImportType("FEM formats (*.unv *.med *.dat *.bdf)", "Fem")
|
||||
FreeCAD.addImportType("FEM results (*.vtk)","Fem")
|
||||
FreeCAD.addExportType("FEM formats (*.unv *.med *.dat *.inp)", "Fem")
|
||||
FreeCAD.addImportType("CalculiX result (*.frd)", "ccxFrdReader")
|
||||
FreeCAD.addImportType("Abaqus file (*.inp)", "FemGui")
|
||||
FreeCAD.addImportType("Z88 mesh file (*.txt)", "importZ88Mesh")
|
||||
FreeCAD.addExportType("Z88 mesh file (*.txt)", "importZ88Mesh")
|
||||
FreeCAD.addImportType("Z88 displacement result file (*.txt)", "z88DispReader")
|
||||
|
||||
Reference in New Issue
Block a user