FEM: code formating: remove trailing white spaces
This commit is contained in:
@@ -65,9 +65,9 @@ FemPostPipeline::FemPostPipeline()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Filter, (0), "Pipeline", App::Prop_None, "The filter used in in this pipeline");
|
||||
ADD_PROPERTY_TYPE(Functions, (0), "Pipeline", App::Prop_Hidden, "The function provider which groups all pipeline functions");
|
||||
ADD_PROPERTY_TYPE(Mode,(long(0)), "Pipeline", App::Prop_None, "Selects the pipeline data transition mode. In serial every filter"
|
||||
ADD_PROPERTY_TYPE(Mode,(long(0)), "Pipeline", App::Prop_None, "Selects the pipeline data transition mode. In serial every filter"
|
||||
"gets the output of the previous one as input, in parrallel every"
|
||||
"filter gets the pipelien source as input.");
|
||||
"filter gets the pipelien source as input.");
|
||||
Mode.setEnums(ModeEnums);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ short FemPostPipeline::mustExecute(void) const
|
||||
{
|
||||
if(Mode.isTouched())
|
||||
return 1;
|
||||
|
||||
|
||||
return FemPostFilter::mustExecute();
|
||||
}
|
||||
|
||||
@@ -88,33 +88,33 @@ 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
|
||||
|
||||
//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();
|
||||
}
|
||||
|
||||
@@ -128,17 +128,17 @@ bool FemPostPipeline::canRead(Base::FileInfo File) {
|
||||
File.hasExtension("vtu") ||
|
||||
File.hasExtension("vti"))
|
||||
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("vtu"))
|
||||
|
||||
if (File.hasExtension("vtu"))
|
||||
readXMLFile<vtkXMLUnstructuredGridReader>(File.filePath());
|
||||
else if (File.hasExtension("vtp"))
|
||||
readXMLFile<vtkXMLPolyDataReader>(File.filePath());
|
||||
@@ -149,7 +149,7 @@ void FemPostPipeline::read(Base::FileInfo File) {
|
||||
else if (File.hasExtension("vti"))
|
||||
readXMLFile<vtkXMLImageDataReader>(File.filePath());
|
||||
else if (File.hasExtension("vtk"))
|
||||
readXMLFile<vtkDataSetReader>(File.filePath());
|
||||
readXMLFile<vtkDataSetReader>(File.filePath());
|
||||
else
|
||||
throw Base::Exception("Unknown extension");
|
||||
}
|
||||
@@ -161,34 +161,34 @@ void FemPostPipeline::read(Base::FileInfo File) {
|
||||
// // ref counter is set to 1
|
||||
// PythonObject = Py::Object(new DocumentObjectPy(this),true);
|
||||
// }
|
||||
// return Py::new_reference_to(PythonObject);
|
||||
// return Py::new_reference_to(PythonObject);
|
||||
// }
|
||||
|
||||
void FemPostPipeline::onChanged(const Property* prop)
|
||||
{
|
||||
if(prop == &Filter || prop == &Mode) {
|
||||
|
||||
|
||||
//we check if all connections are right and add new ones if needed
|
||||
std::vector<App::DocumentObject*> objs = Filter.getValues();
|
||||
|
||||
|
||||
if(objs.empty())
|
||||
return;
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*>::iterator it = objs.begin();
|
||||
FemPostFilter* filter = static_cast<FemPostFilter*>(*it);
|
||||
|
||||
|
||||
//If we have a Input we need to ensure our filters are connected correctly
|
||||
if(Input.getValue()) {
|
||||
|
||||
|
||||
//the first filter is always connected to the input
|
||||
if(filter->Input.getValue() != Input.getValue())
|
||||
filter->Input.setValue(Input.getValue());
|
||||
|
||||
|
||||
//all the others need to be connected to the previous filter or the source, dependend on the mode
|
||||
++it;
|
||||
for(; it != objs.end(); ++it) {
|
||||
FemPostFilter* nextFilter = static_cast<FemPostFilter*>(*it);
|
||||
|
||||
|
||||
if(Mode.getValue() == 0) { //serial mode
|
||||
if( nextFilter->Input.getValue() != filter)
|
||||
nextFilter->Input.setValue(filter);
|
||||
@@ -197,7 +197,7 @@ void FemPostPipeline::onChanged(const Property* prop)
|
||||
if( nextFilter->Input.getValue() != Input.getValue())
|
||||
nextFilter->Input.setValue(Input.getValue());
|
||||
}
|
||||
|
||||
|
||||
filter = nextFilter;
|
||||
};
|
||||
}
|
||||
@@ -206,12 +206,12 @@ void FemPostPipeline::onChanged(const Property* prop)
|
||||
//the first filter must always grab the data
|
||||
if(filter->Input.getValue() != NULL)
|
||||
filter->Input.setValue(NULL);
|
||||
|
||||
|
||||
//all the others need to be connected to the previous filter or grab the data, dependend on mode
|
||||
++it;
|
||||
for(; it != objs.end(); ++it) {
|
||||
FemPostFilter* nextFilter = static_cast<FemPostFilter*>(*it);
|
||||
|
||||
|
||||
if(Mode.getValue() == 0) { //serial mode
|
||||
if( nextFilter->Input.getValue() != filter)
|
||||
nextFilter->Input.setValue(filter);
|
||||
@@ -220,12 +220,12 @@ void FemPostPipeline::onChanged(const Property* prop)
|
||||
if( nextFilter->Input.getValue() != NULL)
|
||||
nextFilter->Input.setValue(NULL);
|
||||
}
|
||||
|
||||
|
||||
filter = nextFilter;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
App::GeoFeature::onChanged(prop);
|
||||
|
||||
}
|
||||
@@ -234,7 +234,7 @@ FemPostObject* FemPostPipeline::getLastPostObject() {
|
||||
|
||||
if(Filter.getValues().empty())
|
||||
return this;
|
||||
|
||||
|
||||
return static_cast<FemPostObject*>(Filter.getValues().back());
|
||||
}
|
||||
|
||||
@@ -242,53 +242,53 @@ bool FemPostPipeline::holdsPostObject(FemPostObject* obj) {
|
||||
|
||||
std::vector<App::DocumentObject*>::const_iterator it = Filter.getValues().begin();
|
||||
for(; it != Filter.getValues().end(); ++it) {
|
||||
|
||||
|
||||
if(*it == obj)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void FemPostPipeline::load(FemResultObject* res) {
|
||||
|
||||
vtkSmartPointer<vtkUnstructuredGrid> grid = vtkSmartPointer<vtkUnstructuredGrid>::New();
|
||||
|
||||
|
||||
//first copy the mesh over
|
||||
//########################
|
||||
|
||||
|
||||
if(!res->Mesh.getValue() || !res->Mesh.getValue()->isDerivedFrom(Fem::FemMeshObject::getClassTypeId()))
|
||||
return;
|
||||
|
||||
const FemMesh& mesh = static_cast<FemMeshObject*>(res->Mesh.getValue())->FemMesh.getValue();
|
||||
|
||||
const FemMesh& mesh = static_cast<FemMeshObject*>(res->Mesh.getValue())->FemMesh.getValue();
|
||||
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(mesh.getSMesh());
|
||||
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
|
||||
const SMDS_MeshInfo& info = meshDS->GetMeshInfo();
|
||||
|
||||
|
||||
//start with the nodes
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
SMDS_NodeIteratorPtr aNodeIter = meshDS->nodesIterator();
|
||||
|
||||
|
||||
points->SetNumberOfPoints(info.NbNodes());
|
||||
for(; aNodeIter->more(); ) {
|
||||
const SMDS_MeshNode* node = aNodeIter->next();
|
||||
float coords[3] = {float(node->X()), float(node->Y()), float(node->Z())};
|
||||
points->SetPoint(node->GetID()-1, coords);
|
||||
points->SetPoint(node->GetID()-1, coords);
|
||||
}
|
||||
grid->SetPoints(points);
|
||||
|
||||
|
||||
//start with 2d elements
|
||||
vtkSmartPointer<vtkCellArray> triangleArray = vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkSmartPointer<vtkCellArray> quadTriangleArray = vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkSmartPointer<vtkCellArray> quadArray = vtkSmartPointer<vtkCellArray>::New();
|
||||
|
||||
|
||||
SMDS_FaceIteratorPtr aFaceIter = meshDS->facesIterator();
|
||||
for (;aFaceIter->more();) {
|
||||
const SMDS_MeshFace* aFace = aFaceIter->next();
|
||||
|
||||
//triangle
|
||||
if(aFace->NbNodes() == 3) {
|
||||
vtkSmartPointer<vtkTriangle> tria = vtkSmartPointer<vtkTriangle>::New();
|
||||
vtkSmartPointer<vtkTriangle> tria = vtkSmartPointer<vtkTriangle>::New();
|
||||
tria->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID()-1);
|
||||
tria->GetPointIds()->SetId(1, aFace->GetNode(1)->GetID()-1);
|
||||
tria->GetPointIds()->SetId(2, aFace->GetNode(2)->GetID()-1);
|
||||
@@ -297,7 +297,7 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
}
|
||||
//quad
|
||||
else if(aFace->NbNodes() == 4) {
|
||||
vtkSmartPointer<vtkQuad> quad = vtkSmartPointer<vtkQuad>::New();
|
||||
vtkSmartPointer<vtkQuad> quad = vtkSmartPointer<vtkQuad>::New();
|
||||
quad->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID()-1);
|
||||
quad->GetPointIds()->SetId(1, aFace->GetNode(1)->GetID()-1);
|
||||
quad->GetPointIds()->SetId(2, aFace->GetNode(2)->GetID()-1);
|
||||
@@ -305,7 +305,7 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
quadArray->InsertNextCell(quad);
|
||||
}
|
||||
else if (aFace->NbNodes() == 6) {
|
||||
vtkSmartPointer<vtkQuadraticTriangle> tria = vtkSmartPointer<vtkQuadraticTriangle>::New();
|
||||
vtkSmartPointer<vtkQuadraticTriangle> tria = vtkSmartPointer<vtkQuadraticTriangle>::New();
|
||||
tria->GetPointIds()->SetId(0, aFace->GetNode(0)->GetID()-1);
|
||||
tria->GetPointIds()->SetId(1, aFace->GetNode(1)->GetID()-1);
|
||||
tria->GetPointIds()->SetId(2, aFace->GetNode(2)->GetID()-1);
|
||||
@@ -317,25 +317,25 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
}
|
||||
if(triangleArray->GetNumberOfCells()>0)
|
||||
grid->SetCells(VTK_TRIANGLE, triangleArray);
|
||||
|
||||
|
||||
if(quadArray->GetNumberOfCells()>0)
|
||||
grid->SetCells(VTK_QUAD, quadArray);
|
||||
|
||||
|
||||
if(quadTriangleArray->GetNumberOfCells()>0)
|
||||
grid->SetCells(VTK_QUADRATIC_TRIANGLE, quadTriangleArray);
|
||||
|
||||
|
||||
//now all volumes
|
||||
|
||||
|
||||
//now all volumes
|
||||
vtkSmartPointer<vtkCellArray> tetraArray = vtkSmartPointer<vtkCellArray>::New();
|
||||
vtkSmartPointer<vtkCellArray> quadTetraArray = vtkSmartPointer<vtkCellArray>::New();
|
||||
|
||||
|
||||
SMDS_VolumeIteratorPtr aVolIter = meshDS->volumesIterator();
|
||||
for (;aVolIter->more();) {
|
||||
const SMDS_MeshVolume* aVol = aVolIter->next();
|
||||
|
||||
//tetrahedra
|
||||
if(aVol->NbNodes() == 4) {
|
||||
vtkSmartPointer<vtkTetra> tetra = vtkSmartPointer<vtkTetra>::New();
|
||||
vtkSmartPointer<vtkTetra> tetra = vtkSmartPointer<vtkTetra>::New();
|
||||
tetra->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(2, aVol->GetNode(2)->GetID()-1);
|
||||
@@ -345,8 +345,8 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
}
|
||||
//quadratic tetrahedra
|
||||
else if( aVol->NbNodes() == 10) {
|
||||
|
||||
vtkSmartPointer<vtkQuadraticTetra> tetra = vtkSmartPointer<vtkQuadraticTetra>::New();
|
||||
|
||||
vtkSmartPointer<vtkQuadraticTetra> tetra = vtkSmartPointer<vtkQuadraticTetra>::New();
|
||||
tetra->GetPointIds()->SetId(0, aVol->GetNode(0)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(1, aVol->GetNode(1)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(2, aVol->GetNode(2)->GetID()-1);
|
||||
@@ -357,29 +357,29 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
tetra->GetPointIds()->SetId(7, aVol->GetNode(7)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(8, aVol->GetNode(8)->GetID()-1);
|
||||
tetra->GetPointIds()->SetId(9, aVol->GetNode(9)->GetID()-1);
|
||||
|
||||
|
||||
quadTetraArray->InsertNextCell(tetra);
|
||||
}
|
||||
}
|
||||
if(tetraArray->GetNumberOfCells()>0)
|
||||
grid->SetCells(VTK_TETRA, tetraArray);
|
||||
|
||||
|
||||
if(quadTetraArray->GetNumberOfCells()>0)
|
||||
grid->SetCells(VTK_QUADRATIC_TETRA, quadTetraArray);
|
||||
|
||||
|
||||
|
||||
|
||||
//Now copy the point data over
|
||||
//############################
|
||||
|
||||
|
||||
if(!res->StressValues.getValues().empty()) {
|
||||
const std::vector<double>& vec = res->StressValues.getValues();
|
||||
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
|
||||
data->SetNumberOfValues(vec.size());
|
||||
data->SetName("Von Mises stress");
|
||||
|
||||
|
||||
for(size_t i=0; i<vec.size(); ++i)
|
||||
data->SetValue(i, vec[i]);
|
||||
|
||||
|
||||
grid->GetPointData()->AddArray(data);
|
||||
}
|
||||
|
||||
@@ -424,26 +424,26 @@ void FemPostPipeline::load(FemResultObject* res) {
|
||||
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
|
||||
data->SetNumberOfValues(vec.size());
|
||||
data->SetName("Temperature");
|
||||
|
||||
|
||||
for(size_t i=0; i<vec.size(); ++i)
|
||||
data->SetValue(i, vec[i]);
|
||||
|
||||
|
||||
grid->GetPointData()->AddArray(data);
|
||||
}
|
||||
|
||||
|
||||
if(!res->StressValues.getValues().empty()) {
|
||||
const std::vector<Base::Vector3d>& vec = res->DisplacementVectors.getValues();
|
||||
vtkSmartPointer<vtkDoubleArray> data = vtkSmartPointer<vtkDoubleArray>::New();
|
||||
data->SetNumberOfComponents(3);
|
||||
data->SetName("Displacement");
|
||||
|
||||
|
||||
for(std::vector<Base::Vector3d>::const_iterator it=vec.begin(); it!=vec.end(); ++it) {
|
||||
double tuple[] = {it->x, it->y, it->z};
|
||||
data->InsertNextTuple(tuple);
|
||||
}
|
||||
|
||||
|
||||
grid->GetPointData()->AddArray(data);
|
||||
}
|
||||
|
||||
|
||||
Data.setValue(grid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user