diff --git a/src/Mod/Fem/App/FemMeshShapeObject.cpp b/src/Mod/Fem/App/FemMeshShapeObject.cpp index 2501ec6fa1..9fec365a5a 100644 --- a/src/Mod/Fem/App/FemMeshShapeObject.cpp +++ b/src/Mod/Fem/App/FemMeshShapeObject.cpp @@ -36,17 +36,45 @@ #include #include #include +#include +#include #include #include #include -#include -#include -#include -#include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include using namespace Fem; using namespace App; @@ -69,13 +97,60 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute(void) Part::Feature *feat = Shape.getValue(); - +#if 0 + TopoDS_Shape oshape = feat->Shape.getValue(); + BRepBuilderAPI_Copy copy(oshape); + const TopoDS_Shape& shape = copy.Shape(); + BRepTools::Clean(shape); // remove triangulation +#else TopoDS_Shape shape = feat->Shape.getValue(); +#endif newMesh.getSMesh()->ShapeToMesh(shape); SMESH_Gen *myGen = newMesh.getGenerator(); int hyp=0; +#if 0 + SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, myGen)); + static_cast(len.get())->SetLength(1.0); + newMesh.addHypothesis(shape, len); + + SMESH_HypothesisPtr loc(new StdMeshers_LocalLength(hyp++, 1, myGen)); + static_cast(loc.get())->SetLength(1.0); + newMesh.addHypothesis(shape, loc); + + SMESH_HypothesisPtr area(new StdMeshers_MaxElementArea(hyp++, 1, myGen)); + static_cast(area.get())->SetMaxArea(1.0); + newMesh.addHypothesis(shape, area); + + SMESH_HypothesisPtr segm(new StdMeshers_NumberOfSegments(hyp++, 1, myGen)); + static_cast(segm.get())->SetNumberOfSegments(1); + newMesh.addHypothesis(shape, segm); + + SMESH_HypothesisPtr defl(new StdMeshers_Deflection1D(hyp++, 1, myGen)); + static_cast(defl.get())->SetDeflection(0.01); + newMesh.addHypothesis(shape, defl); + + SMESH_HypothesisPtr reg(new StdMeshers_Regular_1D(hyp++, 1, myGen)); + newMesh.addHypothesis(shape, reg); + + //SMESH_HypothesisPtr sel(new StdMeshers_StartEndLength(hyp++, 1, myGen)); + //static_cast(sel.get())->SetLength(1.0, true); + //newMesh.addHypothesis(shape, sel; + + SMESH_HypothesisPtr qdp(new StdMeshers_QuadranglePreference(hyp++,1,myGen)); + newMesh.addHypothesis(shape, qdp); + + //SMESH_HypothesisPtr q2d(new StdMeshers_Quadrangle_2D(hyp++,1,myGen)); + //newMesh.addHypothesis(shape, q2d); + + SMESH_HypothesisPtr h3d(new StdMeshers_Hexa_3D(hyp++,1,myGen)); + newMesh.addHypothesis(shape, h3d); + + // create mesh + newMesh.compute(); +#endif +#if 0 // Surface quad mesh SMESH_HypothesisPtr len(new StdMeshers_MaxLength(hyp++, 1, myGen)); static_cast(len.get())->SetLength(1.0); newMesh.addHypothesis(shape, len); @@ -111,6 +186,24 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute(void) // create mesh newMesh.compute(); +#endif +#if 1 // NETGEN test + NETGENPlugin_Mesher myNetGenMesher(newMesh.getSMesh(),shape,true); + + //NETGENPlugin_SimpleHypothesis_2D * tet2 = new NETGENPlugin_SimpleHypothesis_2D(hyp++,1,myGen); + //static_cast(tet2.get())->SetNumberOfSegments(5); + //static_cast(tet2.get())->SetLocalLength(0.1); + //static_cast(tet2.get())->LengthFromEdges(); + //myNetGenMesher.SetParameters(tet2); + + //NETGENPlugin_SimpleHypothesis_3D* tet= new NETGENPlugin_SimpleHypothesis_3D(hyp++,1,myGen); + //static_cast(tet.get())->LengthFromFaces(); + //static_cast(tet.get())->SetMaxElementVolume(0.1); + //myNetGenMesher.SetParameters( tet); + + myNetGenMesher.Compute(); +#endif + SMESHDS_Mesh* data = const_cast(newMesh.getSMesh())->GetMeshDS(); diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index 7454a87958..84d894ed2f 100755 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -140,7 +140,8 @@ bool FemFace::isSameFace (FemFace &face) // the same element can not have the same face if(face.ElementNumber == ElementNumber) return false; - assert(face.Size == Size); + if(face.Size != Size) + return false; // if the same face size just compare if the sorted nodes are the same if( Nodes[0] == face.Nodes[0] && Nodes[1] == face.Nodes[1] && @@ -544,27 +545,36 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop, SoCoordin int numHedr = info.NbPolyhedrons(); - + bool ShowFaces = false; + + int numTries; + if(ShowFaces) + numTries = numTria+numQuad+numPoly+numTetr*4+numHexa*6+numPyrd*5+numPris*6; + else + numTries = numTetr*4+numHexa*6+numPyrd*5+numPris*6; + + std::vector facesHelper(numTries); - std::vector facesHelper(numTria+numQuad+numPoly+numTetr*4+numHexa*6+numPyrd*5+numPris*6); Base::Console().Log(" %f: Start build up %i face helper\n",Base::TimeInfo::diffTimeF(Start,Base::TimeInfo()),facesHelper.size()); Base::BoundBox3d BndBox; int i=0; - SMDS_FaceIteratorPtr aFaceIter = data->facesIterator(); - for (;aFaceIter->more();) { - const SMDS_MeshFace* aFace = aFaceIter->next(); + if(false){ + SMDS_FaceIteratorPtr aFaceIter = data->facesIterator(); + for (;aFaceIter->more();) { + const SMDS_MeshFace* aFace = aFaceIter->next(); - int num = aFace->NbNodes(); - switch(num){ - - case 4:// quad face - BndBox.Add(facesHelper[i++].set(4,aFace,aFace->GetID(),0,aFace->GetNode(0),aFace->GetNode(1),aFace->GetNode(2),aFace->GetNode(3))); - break; + int num = aFace->NbNodes(); + switch(num){ - //unknown case - default: assert(0); + case 4:// quad face + BndBox.Add(facesHelper[i++].set(4,aFace,aFace->GetID(),0,aFace->GetNode(0),aFace->GetNode(1),aFace->GetNode(2),aFace->GetNode(3))); + break; + + //unknown case + default: assert(0); + } } }