FEM Post: Clean up work

This commit is contained in:
Stefan Tröger 2016-01-01 20:19:55 +01:00 committed by wmayer
parent defecae339
commit dd72ea6ab0
6 changed files with 51 additions and 63 deletions

View File

@ -67,7 +67,6 @@ void FemPostFilter::setActiveFilterPipeline(std::string name) {
DocumentObjectExecReturn* FemPostFilter::execute(void) {
Base::Console().Message("Recalculate filter\n");
if(!m_pipelines.empty() && !m_activePipeline.empty()) {
FemPostFilter::FilterPipeline& pipe = m_pipelines[m_activePipeline];
@ -76,7 +75,6 @@ DocumentObjectExecReturn* FemPostFilter::execute(void) {
Data.setValue(pipe.target->GetOutputDataObject(0));
}
Base::Console().Message("Done Recalculate filter\n");
return StdReturn;
}
@ -165,6 +163,13 @@ short int FemPostClipFilter::mustExecute(void) const {
else return App::DocumentObject::mustExecute();
}
DocumentObjectExecReturn* FemPostClipFilter::execute(void) {
if(!m_extractor->GetImplicitFunction())
return StdReturn;
return Fem::FemPostFilter::execute();
}

View File

@ -86,6 +86,7 @@ public:
return "FemGui::ViewProviderFemPostClip";
}
virtual short int mustExecute(void) const;
virtual App::DocumentObjectExecReturn* execute(void);
protected:
virtual void onChanged(const App::Property* prop);

View File

@ -48,6 +48,7 @@
#include <vtkQuad.h>
#include <vtkImageData.h>
#include <vtkRectilinearGrid.h>
#include <vtkAppendFilter.h>
#include <vtkXMLUnstructuredGridReader.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkXMLStructuredGridReader.h>
@ -76,15 +77,42 @@ FemPostPipeline::~FemPostPipeline()
short FemPostPipeline::mustExecute(void) const
{
return 1;
if(Mode.isTouched())
return 1;
return FemPostFilter::mustExecute();
}
DocumentObjectExecReturn* FemPostPipeline::execute(void) {
//if we are the toplevel pipeline our data object is not created by filters, we are the main source!
if(!Input.getValue())
return StdReturn;
//now if we are a filter than our data object is created by the filter we hold
//if we are in serial mode we just copy over the data of the last filter,
//but if we are in parallel we need to combine all filter results
if(Mode.getValue() == 0) {
//serial
Data.setValue(getLastPostObject()->Data.getValue());
}
else {
//parallel. go through all filters and append the result
const std::vector<App::DocumentObject*>& filters = Filter.getValues();
std::vector<App::DocumentObject*>::const_iterator it = filters.begin();
vtkSmartPointer<vtkAppendFilter> append = vtkSmartPointer<vtkAppendFilter>::New();
for(;it != filters.end(); ++it) {
append->AddInputDataObject(static_cast<FemPostObject*>(*it)->Data.getValue());
}
append->Update();
Data.setValue(append->GetOutputDataObject(0));
}
return Fem::FemPostObject::execute();

View File

@ -249,7 +249,6 @@ void ViewProviderFemPostFunction::dragFinishCallback(void *data, SoDragger *)
void ViewProviderFemPostFunction::dragMotionCallback(void *data, SoDragger *drag)
{
Base::Console().Message("dragger callback\n");
ViewProviderFemPostFunction* that = reinterpret_cast<ViewProviderFemPostFunction*>(data);
that->draggerUpdate(drag);
@ -346,8 +345,6 @@ ViewProviderFemPostPlaneFunction::~ViewProviderFemPostPlaneFunction() {
void ViewProviderFemPostPlaneFunction::draggerUpdate(SoDragger* m) {
Base::Console().Message("dragger udate\n");
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
SoCenterballDragger* dragger = static_cast<SoCenterballDragger*>(m);
@ -360,18 +357,10 @@ void ViewProviderFemPostPlaneFunction::draggerUpdate(SoDragger* m) {
func->Origin.setValue(center[0], center[1], center[2]);
func->Normal.setValue(norm[0],norm[1],norm[2]);
SbVec3f c = static_cast<SoCenterballManip*>(getManipulator())->center.getValue();
SbVec3f t = static_cast<SoCenterballManip*>(getManipulator())->translation.getValue();
SbVec3f s = static_cast<SoCenterballManip*>(getManipulator())->scaleFactor.getValue();
SbVec3f rt, irt;
dragger->rotation.getValue().multVec(t,rt);
dragger->rotation.getValue().inverse().multVec(t,irt);
Base::Console().Message("Center: %f, %f, %f\n", c[0], c[1], c[2]);
Base::Console().Message("Translation: %f, %f, %f\n", t[0], t[1], t[2]);
Base::Console().Message("Rot Translation: %f, %f, %f\n", rt[0], rt[1], rt[2]);
Base::Console().Message("I Rot Translation: %f, %f, %f\n", irt[0], irt[1], irt[2]);
Base::Console().Message("Normal %f, %f, %f\n", norm[0], norm[1], norm[2]);
Base::Console().Message("Scale %f, %f, %f\n", s[0], s[1], s[2]);
}
void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) {
@ -382,8 +371,6 @@ void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) {
Base::Vector3d trans = func->Origin.getValue();
Base::Vector3d norm = func->Normal.getValue();
Base::Console().Message("Translation: %f, %f, %f\n", trans.x, trans.y, trans.z);
Base::Console().Message("Normal %f, %f, %f\n", norm.x, norm.y, norm.z);
norm = norm / norm.Length();
SbRotation rot(SbVec3f(0.,0.,1.), SbVec3f(norm.x, norm.y, norm.z));
@ -393,9 +380,6 @@ void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) {
translate.setTranslate(SbVec3f(trans.x, trans.y, trans.z));
t.multRight(translate);
getManipulator()->setMatrix(t);
Base::Console().Message("Matrix:\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n\n", t[0][0], t[0][1], t[0][2], t[0][3],
t[1][0], t[1][1], t[1][2], t[1][3], t[2][0], t[2][1], t[2][2], t[2][3], t[3][0], t[3][1], t[3][2], t[3][3]);
}
Gui::ViewProviderDocumentObject::updateData(p);
}
@ -533,8 +517,6 @@ SoTransformManip* ViewProviderFemPostSphereFunction::setupManipulator() {
void ViewProviderFemPostSphereFunction::draggerUpdate(SoDragger* m) {
Base::Console().Message("dragger udate\n");
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
SoHandleBoxDragger* dragger = static_cast<SoHandleBoxDragger*>(m);

View File

@ -91,6 +91,8 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(
m_lines->ref();
m_drawStyle = new SoDrawStyle();
m_drawStyle->ref();
m_drawStyle->lineWidth.setValue(2);
m_drawStyle->pointSize.setValue(3);
m_seperator = new SoSeparator();
m_seperator->ref();
@ -129,30 +131,17 @@ 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);
m_seperator->addChild(m_shapeHints);
m_seperator->addChild(m_drawStyle);
m_seperator->addChild(m_materialBinding);
m_seperator->addChild(m_material);
m_seperator->addChild(m_coordinates);
m_seperator->addChild(m_markers);
m_seperator->addChild(m_lines);
m_seperator->addChild(m_faces);
//all
m_seperator->addChild(pcFlatRoot);
m_seperator->addChild(pcWireRoot);
m_seperator->addChild(pcPointsRoot);
addDisplayMaskMode(m_seperator, "Default");
setDisplayMaskMode("Default");
@ -291,7 +280,6 @@ void ViewProviderFemPostObject::update3D() {
// 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();
@ -314,7 +302,6 @@ void ViewProviderFemPostObject::update3D() {
// 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();
@ -336,7 +323,6 @@ void ViewProviderFemPostObject::update3D() {
// 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();
@ -357,7 +343,6 @@ void ViewProviderFemPostObject::update3D() {
// write out verts if any
if (pd->GetNumberOfVerts() > 0){
Base::Console().Message("render verts: %i\n", pd->GetNumberOfVerts());
int soidx = 0;
cells = pd->GetVerts();
m_markers->coordIndex.startEditing();
@ -381,9 +366,6 @@ void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray*
if(!points)
return;
Base::Console().Message("render points: %i", points->GetNumberOfPoints());
Base::Console().Message("\n");
m_coordinates->point.startEditing();
m_coordinates->point.setNum(points->GetNumberOfPoints());
for (i = 0; i < points->GetNumberOfPoints(); i++) {
@ -395,7 +377,6 @@ void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray*
// write out the point normal data
if (normals) {
Base::Console().Message("Write normals: %i\n", normals->GetNumberOfTuples());
m_normals->vector.startEditing();
m_normals->vector.setNum(normals->GetNumberOfTuples());
for (i = 0; i < normals->GetNumberOfTuples(); i++) {
@ -464,12 +445,7 @@ void ViewProviderFemPostObject::WriteColorData() {
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();
m_material->transparency.setValue(trans);
}

View File

@ -51,7 +51,6 @@ std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren(v
children.push_back(pipeline->Functions.getValue());
children.insert(children.end(), pipeline->Filter.getValues().begin(), pipeline->Filter.getValues().end());
Base::Console().Message("claim children pipeline: %i\n", children.size());
return children;
}
@ -63,10 +62,7 @@ std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren3D
void ViewProviderFemPostPipeline::updateData(const App::Property* prop) {
FemGui::ViewProviderFemPostObject::onChanged(prop);
if(strcmp(prop->getName(), "ModificationTime") == 0) {
updateFunctionSize();
}
else if(strcmp(prop->getName(), "Function") == 0) {
if(strcmp(prop->getName(), "Function") == 0) {
updateFunctionSize();
}