diff --git a/Geo/Curvature.cpp b/Geo/Curvature.cpp index 6266b5aed9d04d398b16ea3581674556a0a54f49..05d89fe4a24db19a394dced1d3c9b435792644af 100644 --- a/Geo/Curvature.cpp +++ b/Geo/Curvature.cpp @@ -885,6 +885,7 @@ void Curvature::computeCurvature(GModel* model, typeOfCurvature typ) double t1 = Cpu(); Msg::StatusBar(2, true, "(C) Done Computing Curvature (%g s)", t1-t0); + writeToMshFile("curvature.msh"); writeToPosFile("curvature.pos"); writeToVtkFile("curvature.vtk"); @@ -1433,6 +1434,85 @@ double Curvature::getAtVertex(const MVertex *v) const { return _VertexCurve[it->second]; } +//======================================================================================================== + +void Curvature::writeToMshFile(const std::string &filename) +{ + std::ofstream outfile; + outfile.precision(18); + outfile.open(filename.c_str()); + + /// Write the values of curvature + outfile << "$MeshFormat" << std::endl; + outfile << "2.1 0 8" << std::endl; + outfile << "$EndMeshFormat" << std::endl; + outfile << "$NodeData" << std::endl; + outfile << "1" << std::endl; // One string tag + outfile << "\"Curvature\"" << std::endl; // The name of the view + outfile << "1" << std::endl; // One real tag + outfile << "0.0" << std::endl; // The time value + outfile << "3" << std::endl; // Three integer tags + outfile << "0" << std::endl; // The time step (time steps always start at 0) + outfile << "1" << std::endl; // 1-component (scalar) field + outfile << _VertexToInt.size() << std::endl; // How many associated nodal values + + std::map<int,int>::const_iterator vertex_iterator; + for(vertex_iterator = _VertexToInt.begin(); vertex_iterator != _VertexToInt.end(); ++vertex_iterator) + { + outfile << vertex_iterator->first << " " << _VertexCurve[vertex_iterator->second] << std::endl; + } + + outfile << "$EndNodeData" << std::endl; + + + /// Write the values of curvature direction - principal direction 1 + outfile << "$NodeData" << std::endl; + outfile << "1" << std::endl; // One string tag + outfile << "\"Principal curvature direction 1\"" << std::endl; // The name of the view + outfile << "1" << std::endl; // One real tag + outfile << "0.0" << std::endl; // The time value + outfile << "3" << std::endl; // Three integer tags + outfile << "0" << std::endl; // The time step (time steps always start at 0) + outfile << "3" << std::endl; // 3-component (vector) field + outfile << _VertexToInt.size() << std::endl; // How many associated nodal values + + for(vertex_iterator = _VertexToInt.begin(); vertex_iterator != _VertexToInt.end(); ++vertex_iterator) + { + outfile << vertex_iterator->first << " " << _pdir1[vertex_iterator->second].x() << " " + << _pdir1[vertex_iterator->second].y() << " " + << _pdir1[vertex_iterator->second].z() << std::endl; + } + + outfile << "$EndNodeData" << std::endl; + + + /// Write the values of curvature direction - principal direction 1 + outfile << "$NodeData" << std::endl; + outfile << "1" << std::endl; // One string tag + outfile << "\"Principal curvature direction 2\"" << std::endl; // The name of the view + outfile << "1" << std::endl; // One real tag + outfile << "0.0" << std::endl; // The time value + outfile << "3" << std::endl; // Three integer tags + outfile << "0" << std::endl; // The time step (time steps always start at 0) + outfile << "3" << std::endl; // 3-component (vector) field + outfile << _VertexToInt.size() << std::endl; // How many associated nodal values + + for(vertex_iterator = _VertexToInt.begin(); vertex_iterator != _VertexToInt.end(); ++vertex_iterator) + { + outfile << vertex_iterator->first << " " << _pdir2[vertex_iterator->second].x() << " " + << _pdir2[vertex_iterator->second].y() << " " + << _pdir2[vertex_iterator->second].z() << std::endl; + } + + outfile << "$EndNodeData" << std::endl; + + outfile.close(); + + +} + +//======================================================================================================== + void Curvature::writeToPosFile( const std::string & filename) { std::ofstream outfile; diff --git a/Geo/Curvature.h b/Geo/Curvature.h index 095d23f6bd694123d10d4826bc3f3f79ca724f35..9baab2121e8da0cfd03f945a6c011db309c1b5df 100644 --- a/Geo/Curvature.h +++ b/Geo/Curvature.h @@ -64,7 +64,7 @@ private: //Averaged vertex normals std::vector<SVector3> _VertexNormal; - // Vector of principal dircections + // Vector of principal directions std::vector<SVector3> _pdir1; std::vector<SVector3> _pdir2; @@ -213,6 +213,8 @@ public: void edgeNodalValues(MLine* edge, double& c0, double& c1, int isAbs=0); + void writeToMshFile( const std::string & filename); + void writeToPosFile( const std::string & filename); void writeToVtkFile( const std::string & filename);