Merge pull request #463 from qingfengxia/fluidmaterial

Fem: add push button to export customed fluid and solid material to FCMat file
This commit is contained in:
wwmayer 2017-01-22 15:46:10 +01:00 committed by GitHub
commit 6105ea7a69
9 changed files with 655 additions and 30 deletions

View File

@ -41,6 +41,7 @@
#include <Base/TimeInfo.h>
#include <Base/Console.h>
#include <Base/Type.h>
#include <Base/Parameter.h>
#include <App/Application.h>
#include <App/Document.h>
@ -109,7 +110,13 @@ template<class TWriter> void writeVTKFile(const char* filename, vtkSmartPointer<
writer->Write();
}
void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* mesh)
/*
double scale = 1000;
p[0] = p[0]* scale; // scale back to mm
p[1] = p[1]* scale;
p[1] = p[1]* scale;
*/
void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* mesh, float scale)
{
const vtkIdType nPoints = dataset->GetNumberOfPoints();
const vtkIdType nCells = dataset->GetNumberOfCells();
@ -126,7 +133,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
for(vtkIdType i=0; i<nPoints; i++)
{
double* p = dataset->GetPoint(i);
meshds->AddNodeWithID(p[0], p[1], p[2], i+1);
meshds->AddNodeWithID(p[0]*scale, p[1]*scale, p[2]*scale, i+1);
}
for(vtkIdType iCell=0; iCell<nCells; iCell++)
@ -487,7 +494,14 @@ App::DocumentObject* FemVTKTools::readFluidicResult(const char* filename, App::D
Base::TimeInfo Start;
Base::Console().Log("Start: read FemResult with FemMesh from VTK file ======================\n");
Base::FileInfo f(filename);
auto hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Units");
int unitSchema = hGrp->GetInt("UserSchema",0);
float scale = 1.0;
if(unitSchema == 0) // standard mm
{
scale = 1000.0; // convert from meter in length of CFD result file
}
vtkSmartPointer<vtkDataSet> ds;
if(f.hasExtension("vtu"))
{
@ -528,7 +542,7 @@ App::DocumentObject* FemVTKTools::readFluidicResult(const char* filename, App::D
App::DocumentObject* mesh = pcDoc->addObject("Fem::FemMeshObject", "ResultMesh");
FemMesh* fmesh = new FemMesh(); // PropertyFemMesh instance is responsible to relase FemMesh ??
importVTKMesh(dataset, fmesh);
importVTKMesh(dataset, fmesh, scale);
static_cast<PropertyFemMesh*>(mesh->getPropertyByName("FemMesh"))->setValue(*fmesh);
static_cast<App::PropertyLink*>(result->getPropertyByName("Mesh"))->setValue(mesh);
// PropertyLink is the property type to store DocumentObject pointer
@ -636,20 +650,37 @@ void FemVTKTools::importFluidicResult(vtkSmartPointer<vtkDataSet> dataset, App::
vtkSmartPointer<vtkDataArray> vel = pd->GetArray(vars["Velocity"]);
if(nPoints && vel && vel->GetNumberOfComponents() == 3) {
std::vector<Base::Vector3d> vec(nPoints);
double vmin=1.0e100, vmean=0.0, vmax=0.0; // only velocity magnitude is calc in c++
double vmin=1.0e100, vmean=0.0, vmax=0.0;
//stat of Vx, Vy, Vz is not necessary
double vmins[3] = {0.0, 0.0, 0.0};
double vmeans[3] = {0.0, 0.0, 0.0};
double vmaxs[3] = {0.0, 0.0, 0.0};
for(vtkIdType i=0; i<nPoints; ++i) {
double *p = vel->GetTuple(i); // both vtkFloatArray and vtkDoubleArray return double* for GetTuple(i)
double vmag = std::sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2]);
for(int ii=0; ii<3; ii++) {
vmeans[ii] += p[ii];
if(p[ii] > vmaxs[ii]) vmaxs[ii] = p[ii];
if(p[ii] < vmins[ii]) vmins[ii] = p[ii];
}
vmean += vmag;
if(vmag > vmax) vmax = vmag;
if(vmag < vmin) vmin = vmag;
vec[i] = (Base::Vector3d(p[0], p[1], p[2]));
nodeIds[i] = i;
}
for(int ii=0; ii<3; ii++) {
stats[ii*3] = vmins[ii];
stats[ii*3 + 2] = vmaxs[ii];
stats[ii*3 + 1] = vmeans[ii]/nPoints;
}
int index = varids["Umag"];
stats[index*3] = vmin;
stats[index*3 + 2] = vmax;
stats[index*3 + 1] = vmean/nPoints;
App::PropertyVectorList* velocity = static_cast<App::PropertyVectorList*>(res->getPropertyByName("Velocity"));
if(velocity) {
//PropertyVectorList will not show up in PropertyEditor

View File

@ -46,7 +46,7 @@ namespace Fem
/*!
FemMesh import from vtkUnstructuredGrid instance
*/
static void importVTKMesh(vtkSmartPointer<vtkDataSet> grid, FemMesh* mesh);
static void importVTKMesh(vtkSmartPointer<vtkDataSet> grid, FemMesh* mesh, float scale = 1.0);
/*!
FemMesh read from vtkUnstructuredGrid data file
*/

View File

@ -36,6 +36,7 @@
<file>icons/fem-frequency-analysis.svg</file>
<file>icons/fem-inp-editor.svg</file>
<file>icons/fem-material.svg</file>
<file>icons/fem-material-fluid.svg</file>
<file>icons/fem-material-nonlinear.svg</file>
<file>icons/fem-plane.svg</file>
<file>icons/fem-purge-results.svg</file>

View File

@ -0,0 +1,532 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="64px"
height="64px"
id="svg2816"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="fem-material-fluid.svg">
<defs
id="defs2818">
<linearGradient
inkscape:collect="always"
id="linearGradient4044">
<stop
style="stop-color:#000000;stop-opacity:1;"
offset="0"
id="stop4046" />
<stop
style="stop-color:#000000;stop-opacity:0;"
offset="1"
id="stop4048" />
</linearGradient>
<linearGradient
id="linearGradient3681">
<stop
id="stop3697"
offset="0"
style="stop-color:#fff110;stop-opacity:1;" />
<stop
style="stop-color:#cf7008;stop-opacity:1;"
offset="1"
id="stop3685" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2824" />
<inkscape:perspective
id="perspective3622"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3622-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3653"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3675"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3697"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3720"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3742"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3764"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3785"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3806-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3835"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3614-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3643-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3672-5"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3701-8"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective3746"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.67643728,-0.81829155,2.4578314,1.8844554,-26.450606,18.294947)"
id="pattern5231"
xlink:href="#Strips1_1-4"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5224-9"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,39.618381,8.9692804)"
id="pattern5231-4"
xlink:href="#Strips1_1-6"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5224-3"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-6"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-0"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.66513382,-1.0631299,2.4167603,2.4482973,-49.762569,2.9546807)"
id="pattern5296"
xlink:href="#pattern5231-3"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5288"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,-26.336284,10.887197)"
id="pattern5231-3"
xlink:href="#Strips1_1-4-3"
inkscape:collect="always" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-4-3"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-4-6"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<pattern
patternTransform="matrix(0.42844886,-0.62155849,1.5567667,1.431396,27.948414,13.306456)"
id="pattern5330"
xlink:href="#Strips1_1-9"
inkscape:collect="always" />
<inkscape:perspective
id="perspective5323"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<pattern
inkscape:stockid="Stripes 1:1"
id="Strips1_1-9"
patternTransform="matrix(0.66772843,-1.0037085,2.4261878,2.3114548,3.4760987,3.534923)"
height="1"
width="2"
patternUnits="userSpaceOnUse"
inkscape:collect="always">
<rect
id="rect4483-3"
height="2"
width="1"
y="-0.5"
x="0"
style="fill:black;stroke:none" />
</pattern>
<inkscape:perspective
id="perspective5361"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5383"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<inkscape:perspective
id="perspective5411"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3687"
x1="37.89756"
y1="41.087898"
x2="4.0605712"
y2="40.168594"
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient3681"
id="linearGradient3695"
x1="31.777767"
y1="40.24213"
x2="68.442062"
y2="54.041203"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.25023482,-0.66040068,0.68751357,0.24036653,-8.7488565,43.149938)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512"
id="radialGradient278"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513" />
<stop
style="stop-color:#fff520;stop-opacity:0.89108908;"
offset="0.50000000"
id="stop12517" />
<stop
style="stop-color:#fff300;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop12514" />
</linearGradient>
<radialGradient
r="14.375"
fy="125"
fx="55"
cy="125"
cx="55"
gradientUnits="userSpaceOnUse"
id="radialGradient4017"
xlink:href="#linearGradient12512"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient4060"
x1="15.78776"
y1="50.394047"
x2="27.641447"
y2="39.95837"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.3006889,0,0,0.42340995,-4.2689268,33.381825)" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient12512-2"
id="radialGradient278-5"
gradientUnits="userSpaceOnUse"
cx="55"
cy="125"
fx="55"
fy="125"
r="14.375" />
<linearGradient
id="linearGradient12512-2">
<stop
style="stop-color:#ffffff;stop-opacity:1.0000000;"
offset="0.0000000"
id="stop12513-3" />
<stop
style="stop-color:#fff520;stop-opacity:0.89108908;"
offset="0.50000000"
id="stop12517-1" />
<stop
style="stop-color:#fff300;stop-opacity:0.0000000;"
offset="1.0000000"
id="stop12514-6" />
</linearGradient>
<filter
style="color-interpolation-filters:sRGB;"
inkscape:label="Blur"
id="filter3399">
<feGaussianBlur
stdDeviation="2 2"
result="blur"
id="feGaussianBlur3401" />
</filter>
<filter
inkscape:label="Blur Double"
inkscape:menu="Blurs"
inkscape:menu-tooltip="Overlays two copies with different blur amounts and modifiable blend and composite"
style="color-interpolation-filters:sRGB;"
id="filter3435">
<feGaussianBlur
stdDeviation="5"
result="fbSourceGraphic"
id="feGaussianBlur3437" />
<feGaussianBlur
stdDeviation="0.01"
in="SourceGraphic"
result="result1"
id="feGaussianBlur3439" />
<feComposite
in2="result1"
operator="arithmetic"
in="fbSourceGraphic"
k2="0.5"
k3="0.5"
result="result2"
id="feComposite3441" />
<feBlend
in2="fbSourceGraphic"
mode="normal"
result="result3"
id="feBlend3443" />
</filter>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890872"
inkscape:cx="-18.452064"
inkscape:cy="14.197821"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:object-paths="true"
inkscape:object-nodes="true"
inkscape:window-width="1280"
inkscape:window-height="758"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="0" />
<metadata
id="metadata2821">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<ellipse
style="fill:#000080;fill-opacity:1;stroke:url(#linearGradient4060);stroke-width:1.48421645;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;filter:url(#filter3435)"
id="path4042"
cx="31.683996"
cy="50.300598"
rx="27.257332"
ry="8.8730106"
transform="matrix(0.99177198,0,0,1.1723755,0.26069664,-7.1278108)" />
<ellipse
style="color:#000000;display:block;visibility:visible;fill:#000080;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.25000024;marker:none;filter:url(#filter3399)"
id="path12511"
inkscape:export-filename="/home/jimmac/ximian_art/icons/nautilus/suse93/stock_new-16.png"
inkscape:export-xdpi="33.852203"
inkscape:export-ydpi="33.852203"
cx="32.326824"
cy="18.083538"
rx="11.117324"
ry="14.425747" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -137,24 +137,14 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Density</string>
<string>Density </string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButton_saveas">
<property name="text">
<string>save as name</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="edit_name"/>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="Gui::InputField" name="input_fd_density">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
@ -576,6 +566,13 @@
<string>External material resources</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QPushButton" name="pushButton_saveas">
<property name="text">
<string>save customed material</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_MatWeb">
<property name="text">

View File

@ -38,7 +38,7 @@ class _CommandMaterialFluid(FemCommands):
"the Fem_MaterialFluid command definition"
def __init__(self):
super(_CommandMaterialFluid, self).__init__()
self.resources = {'Pixmap': 'fem-material',
self.resources = {'Pixmap': 'fem-material-fluid',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialFluid", "FEM material for Fluid"),
'Accel': "M, M",
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Fem_MaterialFluid", "Creates a FEM material for Fluid")}

View File

@ -30,6 +30,8 @@ __url__ = "http://www.freecadweb.org"
import FreeCAD
import FreeCADGui
from PySide import QtGui
from PySide.QtGui import QFileDialog
from PySide.QtGui import QMessageBox
from PySide import QtCore
import Units
@ -51,8 +53,8 @@ class _TaskPanelFemMaterial:
self.references_shape_type = None
self.form = FreeCADGui.PySideUic.loadUi(FreeCAD.getHomePath() + "Mod/Fem/TaskPanelFemMaterial.ui")
QtCore.QObject.connect(self.form.pushButton_MatWeb, QtCore.SIGNAL("clicked()"), self.goMatWeb)
QtCore.QObject.connect(self.form.pushButton_saveas, QtCore.SIGNAL("clicked()"), self.saveas_material)
QtCore.QObject.connect(self.form.pushButton_MatWeb, QtCore.SIGNAL("clicked()"), self.goto_MatWeb)
QtCore.QObject.connect(self.form.pushButton_saveas, QtCore.SIGNAL("clicked()"), self.export_material)
QtCore.QObject.connect(self.form.cb_materials, QtCore.SIGNAL("activated(int)"), self.choose_material)
QtCore.QObject.connect(self.form.pushButton_Reference, QtCore.SIGNAL("clicked()"), self.add_references)
QtCore.QObject.connect(self.form.rb_standard, QtCore.SIGNAL("toggled(bool)"), self.choose_selection_mode_standard)
@ -154,7 +156,7 @@ class _TaskPanelFemMaterial:
return False
return True
def goMatWeb(self):
def goto_MatWeb(self):
import webbrowser
webbrowser.open("http://matweb.com")
@ -353,6 +355,7 @@ class _TaskPanelFemMaterial:
self.form.cb_materials.addItem(QtGui.QIcon(":/icons/help-browser.svg"), material_name, material_name)
self.materials[material_name] = material
######################## material import and export ###################
def import_materials(self):
self.materials = {}
self.pathList = []
@ -388,7 +391,7 @@ class _TaskPanelFemMaterial:
use_mat_from_config_dir = self.fem_prefs.GetBool("UseMaterialsFromConfigDir", True)
if use_mat_from_config_dir:
user_mat_dirname = FreeCAD.getUserAppDataDir() + "Materials"
user_mat_dirname = FreeCAD.getUserAppDataDir() + "FluidMaterial"
self.add_mat_dir(user_mat_dirname, ":/icons/preferences-general.svg")
use_mat_from_custom_dir = self.fem_prefs.GetBool("UseMaterialsFromCustomDir", True)
@ -413,10 +416,71 @@ class _TaskPanelFemMaterial:
for mat in material_name_list:
self.form.cb_materials.addItem(QtGui.QIcon(icon), mat[0], mat[1])
def saveas_material(self):
import Material
mat_file_extension = ".FCMat"
# overwritinig warning, save to customed dir, material name check
def export_FCMat(self, fileName, matDict):
"""
Write a material dictionary to a FCMat file, a version without group support, with Python3
<https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Material/Material.py>
"""
try:
import ConfigParser as configparser
except:
import configparser # Python 3
import string
Config = configparser.ConfigParser()
Config.optionxform = str # disable conversion all uppercase leter in key into lower case
# ignore creating group, just fill all into group 'FCMat'
grp = 'FCMat'
if not Config.has_section(grp):
Config.add_section(grp)
for x in matDict.keys():
Config.set(grp,x,matDict[x])
Preamble = "# This is a FreeCAD material-card file\n\n"
# Writing our configuration file to 'example.cfg'
with open(fileName, 'wb') as configfile:
configfile.write(Preamble)
Config.write(configfile)
def export_material(self):
import os
if self.obj.Category == 'Fluid':
MaterialDir = 'FluidMaterial'
else:
MaterialDir = 'Material'
_UseMaterialsFromCustomDir = self.fem_prefs.GetBool("UseMaterialsFromCustomDir", True)
_dir =self.fem_prefs.GetString("CustomMaterialsDir", "")
if _UseMaterialsFromCustomDir and _dir != "" and os.path.isdir(_dir):
TargetDir = self.fem_prefs.GetString("CustomMaterialsDir", "")
elif self.fem_prefs.GetBool("UseMaterialsFromConfigDir", True):
TargetDir = FreeCAD.getUserAppDataDir() + os.path.sep + MaterialDir # $HOME/.FreeCAD
else:
FreeCAD.Console.PrintMessage("Customed material saving directory is not setup in Fem preference")
if not os.path.exists(TargetDir):
os.mkdir(TargetDir)
saveName, Filter = QFileDialog.getSaveFileName(None, "Save a Material property file", TargetDir, "*.FCMat")
if not saveName == "":
print(saveName)
knownMaterials = [self.form.cb_materials.itemText(i) for i in range(self.form.cb_materials.count())]
material_name = os.path.basename(saveName[:-len('.FCMat')])
if material_name not in knownMaterials:
self.export_FCMat(saveName, self.obj.Material)
FreeCAD.Console.PrintMessage("Sucessfully save the Material property file: "+ saveName + "\n")
else:
self.export_FCMat(saveName, self.obj.Material)
FreeCAD.Console.PrintMessage("Sucessfully overwritren the Material property file: "+ saveName + "\n")
"""
msgBox = QMessageBox()
msgBox.setText("FcMat file name {} has existed in {} or system folder, overwriting?\n".format(saveName, TargetDir))
msgBox.addButton(QMessageBox.Yes)
msgBox.addButton(QMessageBox.No)
msgBox.setDefaultButton(QMessageBox.No)
ret = msgBox.exec_()
if ret == QMessageBox.Yes:
self.export_FCMat(saveName, self.obj.Material)
FreeCAD.Console.PrintMessage("Sucessfully overwritren the Material property file: "+ saveName + "\n")
"""
###################geometry reference selection #################
def references_list_right_clicked(self, QPos):

View File

@ -5,7 +5,7 @@ Description = None
Density = 0 kg/m^3
DynamicViscosity = 0 kg/m/s
KinematicViscosity = 0 m^2/s
VolumetricExpansionCoefficient = 0 m/m/K
VolumetricThermalExpansionCoefficient = 0 m/m/K
SpecificHeat = 0 J/kg/K
ThermalConductivity = 0 W/m/K

View File

@ -7,7 +7,7 @@ Density = 998 kg/m^3
DynamicViscosity = 1.003e-3 kg/m/s
KinematicViscosity = 1.005 m^2/s
VolumetricExpansionCoefficient = 2.07e-4 m/m/K
VolumetricThermalExpansionCoefficient = 2.07e-4 m/m/K
SpecificHeat = 4.182 J/kg/K
ThermalConductivity = 0.591 W/m/K