Fem: scale imported vtk data set
This commit is contained in:
@@ -63,8 +63,6 @@ typedef const vtkIdType* vtkIdTypePtr;
|
||||
typedef vtkIdType* vtkIdTypePtr;
|
||||
#endif
|
||||
|
||||
const char* ViewProviderFemPostObject::ScaleEnums[] = { "1", "1000", nullptr };
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostObject, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(false)
|
||||
@@ -73,9 +71,6 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(
|
||||
ADD_PROPERTY_TYPE(Field, ((long)0), "Coloring", App::Prop_None, "Select the field used for calculating the color");
|
||||
ADD_PROPERTY_TYPE(VectorMode, ((long)0), "Coloring", App::Prop_None, "Select what to show for a vector field");
|
||||
ADD_PROPERTY(Transparency, (0));
|
||||
ADD_PROPERTY_TYPE(Scale, (0L), "Base", (App::PropertyType)(App::Prop_None), "Scale factor of the mesh");
|
||||
Scale.setEnums(ScaleEnums);
|
||||
Scale.setReadOnly(true);
|
||||
|
||||
sPixmap = "fem-femmesh-from-shape";
|
||||
|
||||
@@ -426,33 +421,11 @@ void ViewProviderFemPostObject::WritePointData(vtkPoints* points, vtkDataArray*
|
||||
if (!points)
|
||||
return;
|
||||
|
||||
// we must inherit the Scale of parent meshes (for example for clip filters)
|
||||
auto parents = pcObject->getInList();
|
||||
if (!parents.empty()) {
|
||||
for (auto itParents = parents.begin(); itParents != parents.end(); ++itParents) {
|
||||
if ((*itParents)->getTypeId() == Base::Type::fromName("Fem::FemPostPipeline")) {
|
||||
auto vpObject = dynamic_cast<FemGui::ViewProviderFemPostObject*>(
|
||||
Gui::Application::Instance->getViewProvider(*itParents));
|
||||
if (vpObject) {
|
||||
auto propScale = Base::freecad_dynamic_cast<App::PropertyEnumeration>(
|
||||
vpObject->getPropertyByName("Scale"));
|
||||
if (propScale) {
|
||||
if (propScale->getValue() != Scale.getValue()) {
|
||||
Scale.setValue(propScale->getValue());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_coordinates->point.setNum(points->GetNumberOfPoints());
|
||||
SbVec3f* pnts = m_coordinates->point.startEditing();
|
||||
double scale = (strcmp(Scale.getValueAsString(), "1") == 0) ? 1.0 : 1000.0;
|
||||
for (int i = 0; i < points->GetNumberOfPoints(); i++) {
|
||||
double* p = points->GetPoint(i);
|
||||
pnts[i].setValue(p[0] * scale, p[1] * scale, p[2] * scale);
|
||||
pnts[i].setValue(p[0], p[1], p[2]);
|
||||
}
|
||||
m_coordinates->point.finishEditing();
|
||||
|
||||
@@ -594,9 +567,6 @@ void ViewProviderFemPostObject::onChanged(const App::Property* prop) {
|
||||
else if (prop == &Transparency) {
|
||||
WriteTransparency();
|
||||
}
|
||||
else if (prop == &Scale) {
|
||||
update3D();
|
||||
}
|
||||
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ public:
|
||||
App::PropertyEnumeration Field;
|
||||
App::PropertyEnumeration VectorMode;
|
||||
App::PropertyPercent Transparency;
|
||||
App::PropertyEnumeration Scale;
|
||||
|
||||
void attach(App::DocumentObject *pcObject);
|
||||
void setDisplayMode(const char* ModeName);
|
||||
@@ -146,8 +145,6 @@ protected:
|
||||
vtkSmartPointer<vtkExtractEdges> m_wireframe, m_wireframeSurface;
|
||||
vtkSmartPointer<vtkVertexGlyphFilter> m_points, m_pointsSurface;
|
||||
|
||||
static const char* ScaleEnums[];
|
||||
|
||||
private:
|
||||
void updateProperties();
|
||||
void update3D();
|
||||
|
||||
@@ -161,6 +161,7 @@ class Results(run.Results):
|
||||
self._createResults()
|
||||
postPath = self._getResultFile()
|
||||
self.solver.ElmerResult.read(postPath)
|
||||
self.solver.ElmerResult.scale(1000)
|
||||
self.solver.ElmerResult.getLastPostObject().touch()
|
||||
self.solver.Document.recompute()
|
||||
|
||||
@@ -169,8 +170,6 @@ class Results(run.Results):
|
||||
"Fem::FemPostPipeline", self.solver.Name + "Result")
|
||||
self.solver.ElmerResult.Label = self.solver.Label + "Result"
|
||||
self.analysis.addObject(self.solver.ElmerResult)
|
||||
# set the scale to 1 (meaning factor 1000) to scale the mesh back for display
|
||||
self.solver.ElmerResult.ViewObject.Scale = 1
|
||||
# to assure the user sees something, set the default to Surface
|
||||
self.solver.ElmerResult.ViewObject.DisplayMode = "Surface"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user