App::DocumentObjectExecReturn *FemMeshShapeNetgenObject::execute(void) { #ifdef FCWithNetgen Fem::FemMesh newMesh; Part::Feature *feat = Shape.getValue<Part::Feature*>(); TopoDS_Shape shape = feat->Shape.getValue(); NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true); NETGENPlugin_Hypothesis* tet= new NETGENPlugin_Hypothesis(0,1,newMesh.getGenerator()); tet->SetMaxSize(MaxSize.getValue()); tet->SetSecondOrder(SecondOrder.getValue()); tet->SetOptimize(Optimize.getValue()); int iFineness = Fineness.getValue(); tet->SetFineness((NETGENPlugin_Hypothesis::Fineness)iFineness); if(iFineness == 5){ tet->SetGrowthRate(GrowthRate.getValue()); tet->SetNbSegPerEdge(NbSegsPerEdge.getValue()); tet->SetNbSegPerRadius(NbSegsPerRadius.getValue()); } myNetGenMesher.SetParameters( tet); newMesh.getSMesh()->ShapeToMesh(shape); myNetGenMesher.Compute(); // throw Base::RuntimeError("Compute Done\n"); SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS(); const SMDS_MeshInfo& info = data->GetMeshInfo(); int numFaces = data->NbFaces(); int numNode = info.NbNodes(); //int numTria = info.NbTriangles(); //int numQuad = info.NbQuadrangles(); //int numPoly = info.NbPolygons(); int numVolu = info.NbVolumes(); //int numTetr = info.NbTetras(); //int numHexa = info.NbHexas(); //int numPyrd = info.NbPyramids(); //int numPris = info.NbPrisms(); //int numHedr = info.NbPolyhedrons(); Base::Console().Log("NetgenMesh: %i Nodes, %i Volumes, %i Faces\n",numNode,numVolu,numFaces); FemMesh.setValue(newMesh); return App::DocumentObject::StdReturn; #else return new App::DocumentObjectExecReturn("The FEM module is built without NETGEN support. Meshing will not work!!!", this); #endif }
Py::Object StdMeshers_AutomaticLengthPy::getLength(const Py::Tuple& args) { Py::FemMesh mesh(args[0]); Py::Object shape_or_double(args[1]); Fem::FemMesh* m = mesh.extensionObject()->getFemMeshPtr(); if (shape_or_double.type() == Py::Float().type()) { double len = (double)Py::Float(shape_or_double); return Py::Float(hypothesis<StdMeshers_AutomaticLength>()->GetLength(m->getSMesh(),len)); } else { Py::TopoShape shape(shape_or_double); const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->_Shape; return Py::Float(hypothesis<StdMeshers_AutomaticLength>()->GetLength(m->getSMesh(),s)); } throw Py::Exception(); }
Py::Object SMESH_HypothesisPy<T>::setParametersByMesh(const Py::Tuple& args) { PyObject *mesh, *shape; if (!PyArg_ParseTuple(args.ptr(), "O!O!", &(Fem::FemMeshPy::Type), &mesh, &(Part::TopoShapePy::Type), &shape)) throw Py::Exception(); Fem::FemMesh* m = static_cast<Fem::FemMeshPy*>(mesh)->getFemMeshPtr(); const TopoDS_Shape& s = static_cast<Part::TopoShapePy*>(shape)->getTopoShapePtr()->_Shape; return Py::Boolean(hypothesis<SMESH_Hypothesis>()->SetParametersByMesh(m->getSMesh(), s)); }