Allow compilation in windows.
return err;
}
-void NETGENPlugin_Mesher::MakeSecondOrder( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo,
+void NETGENPlugin_Mesher::MakeSecondOrder( netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo,
list< SMESH_subMesh* >* meshedSM, NETGENPlugin_ngMeshInfo& initState, SMESH_Comment& comment )
{
if ( mparams.secondorder > 0 )
SMESH_MesherHelper &quadHelper, NETGENPlugin_ngMeshInfo& initState,
netgen::MeshingParameters &mparams )
{
- int err = 0;
// Init occ geometry maps for non meshed object and fill meshedSM with premeshed objects
PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, internals );
_occgeom = &occgeo;
int err = CallNetgenMeshFaces( ngLib, occgeo, comment );
if ( !err && dim == DIM::D2 /* if mesh is 3D then second order is defined after volumens are computed*/ )
- MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment );
+ MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment );
return err;
}
}
if ( !err )
- MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment );
+ MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment );
return err;
}
}
if (!err )
- MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment );
+ MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment );
}
_ticTime = 0.98 / _progressTic;
int CallNetgenMeshEdges( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo );
int CallNetgenMeshFaces( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment );
int CallNetgenMeshVolumens( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment );
- void MakeSecondOrder( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo,
+ void MakeSecondOrder( netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo,
list< SMESH_subMesh* >* meshedSM, NETGENPlugin_ngMeshInfo& initState, SMESH_Comment& comment );
int FillInternalElements( NETGENPlugin_NetgenLibWrapper& ngLib, NETGENPlugin_Internals& internals, netgen::OCCGeometry& occgeo,
NETGENPlugin_ngMeshInfo& initState, SMESH_MesherHelper &quadHelper, list< SMESH_subMesh* >* meshedSM );
{
}
+/**
+ * @brief Check presence and content of orientation file. Implemented for completness and future reference.
+ *
+ * @param element_orientation_file Binary file containing the orientation of surface elemnts
+ * @return true, false
+ */
+bool NETGENPlugin_NETGEN_1D2D3D_SA::checkOrientationFile( const std::string element_orientation_file )
+{
+ if(element_orientation_file.empty()){
+ MESSAGE("No element orientation file");
+ return true;
+ } else {
+ MESSAGE("Reading from elements from file: " << element_orientation_file);
+ // By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing
+ int nbElement;
+ std::ifstream df(element_orientation_file, ios::binary|ios::in);
+ df.read((char*)&nbElement, sizeof(int));
+ df.close();
+ return (nbElement == 0);
+ }
+}
+
/**
* @brief fill plugin hypothesis from the netgen_params structure
*
netgen_params myParams;
importNetgenParams(hypo_file, myParams);
fillHyp(myParams);
+ int ret = 1;
- int ret = Compute( *myMesh, myShape, new_element_file, !output_mesh_file.empty(), dim );
- if(ret){
- std::cerr << "Meshing failed" << std::endl;
- return ret;
- }
+ if ( checkOrientationFile(element_orientation_file) )
+ {
+ ret = Compute( *myMesh, myShape, new_element_file, !output_mesh_file.empty(), dim );
+ if(ret){
+ std::cerr << "Meshing failed" << std::endl;
+ return ret;
+ }
- if(!output_mesh_file.empty()){
- std::string meshName = "MESH";
- SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
+ if(!output_mesh_file.empty()){
+ std::string meshName = "MESH";
+ SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
+ }
}
+ else
+ std::cerr << "For NETGENPlugin_NETGEN_1D2D3D_SA, orientation file should be market with 0 or be empty!" << std::endl;
+
return ret;
}
const std::string output_mesh_file,
const NETGENPlugin_Mesher::DIM dim );
-protected:
+private:
+ bool checkOrientationFile( const std::string element_orientation_file );
void fillHyp(netgen_params aParams);
bool FillNewElementFile( std::vector< const SMDS_MeshNode* > &nodeVec, NETGENPlugin_NetgenLibWrapper &ngLib,
std::string new_element_file, const NETGENPlugin_Mesher::DIM dim );
div.Parameter( i ), div.Parameter( i+1 ),
enlarge, curve );
}
- catch ( Standard_Failure ) {
+ catch ( Standard_Failure& ) {
_segments.resize( _segments.size() - 1 );
--i;
}
const int numberOfPremeshedNodes = aMesh.NbNodes();
TopTools_IndexedMapOfShape faces;
TopExp::MapShapes( aShape, TopAbs_FACE, faces );
-
+ int err = 0;
for ( int i = 1; i <= faces.Size(); ++i )
{
int numOfEdges = 0;
ngMesh->CalcSurfacesOfNode();
const int startWith = MESHCONST_MESHSURFACE;
const int endWith = MESHCONST_OPTSURFACE;
- int err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
+ err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh);
// Ng_Mesh * ngMeshptr = (Ng_Mesh*) ngLib._ngMesh;
// int NetgenNodes = Ng_GetNP(ngMeshptr);
FillNodesAndElements( aMesh, helper, ngMesh, nodeVec, ng2smesh, newNetgenCoordinates, newNetgenElements, numberOfPremeshedNodes );
} // Face iteration
- return false;
+ return (bool) err;
}
std::tuple<bool,bool> NETGENPlugin_NETGEN_2D_ONLY::SetParameteres( SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
aMesher.SetParameters( _hypParameters ); // _hypParameters -> netgen::mparam
- const bool toOptimize = _hypParameters ? _hypParameters->GetOptimize() : true;
if ( _hypMaxElementArea )
{
netgen::mparam.maxh = sqrt( 2. * _hypMaxElementArea->GetMaxArea() / sqrt(3.0) );
* @param aShape the shape associated to the mesh
* @param output_file name of the binary file
*/
-void NETGENPlugin_NETGEN_2D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- const std::string output_file)
+void NETGENPlugin_NETGEN_2D_Remote::exportElementOrientation(const std::string output_file)
{
std::ofstream df(output_file, ios::out|ios::binary);
int size=0;
// exportNetgenParams(param_file.string(), aParams);
{
// Simply write the file with the proper name
- std::ofstream myfile(param_file);
+ std::ofstream myfile(param_file.string());
myfile << 1 << std::endl;
myfile.close();
}
// Exporting element orientation
- exportElementOrientation(aMesh, aShape, element_orientation_file.string());
+ exportElementOrientation(element_orientation_file.string());
}
// Calling run_mesher
void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override;
- protected:
- void exportElementOrientation(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- const std::string output_file);
+ private:
+ void exportElementOrientation(const std::string output_file);
void fillParameters(const NETGENPlugin_Hypothesis* hyp,
netgen_params &aParams);
{
}
+/**
+ * @brief Check presence and content of orientation file. Implemented for completness and future reference.
+ *
+ * @param element_orientation_file Binary file containing the orientation of surface elemnts
+ * @return true, false
+ */
+bool NETGENPlugin_NETGEN_2D_SA::checkOrientationFile( const std::string element_orientation_file )
+{
+ if(element_orientation_file.empty()){
+ MESSAGE("No element orientation file");
+ return true;
+ } else {
+ MESSAGE("Reading from elements from file: " << element_orientation_file);
+ // By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing
+ int nbElement;
+ std::ifstream df(element_orientation_file, ios::binary|ios::in);
+ df.read((char*)&nbElement, sizeof(int));
+ df.close();
+ return (nbElement == 0);
+ }
+}
+
/**
* @brief fill plugin hypothesis from the netgen_params structure
*
{
std::unique_ptr<SMESH_Mesh> myMesh(_gen->CreateMesh(false));
-
+
SMESH_DriverMesh::importMesh(input_mesh_file, *myMesh);
// Importing shape
TopoDS_Shape myShape;
importNetgenParams(hypo_file, myParams);
fillHyp(hypo_file,myParams);
MESSAGE("Meshing with netgen2d");
- int ret = (int) Compute( *myMesh, myShape, new_element_file );
+ int ret = 1;
+ if ( checkOrientationFile(element_orientation_file) )
+ {
+ ret = (int) Compute( *myMesh, myShape, new_element_file );
- if(ret){
- std::cerr << "Meshing failed" << std::endl;
- return ret;
- }
+ if(ret){
+ std::cerr << "Meshing failed" << std::endl;
+ return ret;
+ }
- if(!output_mesh_file.empty()){
- std::string meshName = "MESH";
- SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
+ if(!output_mesh_file.empty()){
+ std::string meshName = "MESH";
+ SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName);
+ }
}
+ else
+ std::cerr << "For NETGENPlugin_NETGEN_2D_SA orientation file should be market with 0 or be empty!" << std::endl;
return ret;
}
std::map<int,const SMDS_MeshNode*>& premeshedNodes,
std::map<int,std::vector<double>>& newNetgenCoordinates,
std::map<int,std::vector<smIdType>>& newNetgenElements );
-protected:
+private:
+ bool checkOrientationFile( const std::string element_orientation_file );
void fillHyp(const std::string param_file, netgen_params aParams);
};