#include <DriverUNV_W_SMDS_Mesh.h>

Public Types | |
| enum | Status { DRS_OK, DRS_EMPTY, DRS_WARN_RENUMBER, DRS_WARN_SKIP_ELEM, DRS_FAIL } |
Public Member Functions | |
| virtual Status | Perform () |
| void | AddGroup (SMESHDS_GroupBase *theGroup) |
| void | SetMesh (SMDS_Mesh *theMesh) |
| void | SetMeshId (int theMeshId) |
| void | SetFile (const std::string &theFileName) |
Protected Attributes | |
| SMDS_Mesh * | myMesh |
| std::string | myFile |
| int | myMeshId |
Private Attributes | |
| TGroupList | myGroups |
Definition at line 35 of file DriverUNV_W_SMDS_Mesh.h.
enum Driver_Mesh::Status [inherited] |
Definition at line 48 of file Driver_Mesh.h.
{
DRS_OK,
DRS_EMPTY, // a file contains no mesh with the given name
DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers,
// so the numbers from the file are ignored
DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data
DRS_FAIL // general failure (exception etc.)
};
| void DriverUNV_W_SMDS_Mesh.AddGroup | ( | SMESHDS_GroupBase * | theGroup | ) |
Definition at line 40 of file DriverUNV_W_SMDS_Mesh.h.
Referenced by SMESH_Mesh.ExportUNV().
{ myGroups.push_back(theGroup); }
| Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform | ( | ) | [virtual] |
Implements Driver_Mesh.
Definition at line 61 of file DriverUNV_W_SMDS_Mesh.cxx.
References UNV.check_file(), UNV2411.TRecord.coord, SMESH.DRS_OK, EXCEPTION, SMESHDS_GroupBase.Extent(), SMESHDS_GroupBase.GetElements(), SMESHDS_GroupBase.GetID(), SMDS_MeshElement.GetID(), SMESHDS_GroupBase.GetStoreName(), SMESHDS_GroupBase.GetType(), SMDS_MeshElement.IsPoly(), SMDS_MeshElement.IsQuadratic(), MESSAGE, SMDS_MeshElement.NbNodes(), SMDS_MeshElement.nodesIteratorToUNV(), SMDSAbs_Node, UNV2411.Write(), SMDS_MeshNode.X(), SMDS_MeshNode.Y(), and SMDS_MeshNode.Z().
Referenced by SMESH_Mesh.ExportUNV().
{
Kernel_Utils::Localizer loc;
Status aResult = DRS_OK;
std::ofstream out_stream(myFile.c_str());
try{
{
using namespace UNV2411;
TDataSet aDataSet2411;
// Storing SMDS nodes to the UNV file
//-----------------------------------
MESSAGE("Perform - myMesh->NbNodes() = "<<myMesh->NbNodes());
SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator();
for(; aNodesIter->more();){
const SMDS_MeshNode* aNode = aNodesIter->next();
TRecord aRec;
aRec.coord[0] = aNode->X();
aRec.coord[1] = aNode->Y();
aRec.coord[2] = aNode->Z();
const TNodeLab& aLabel = aNode->GetID();
aDataSet2411.insert(TDataSet::value_type(aLabel,aRec));
}
MESSAGE("Perform - aDataSet2411.size() = "<<aDataSet2411.size());
UNV2411::Write(out_stream,aDataSet2411);
}
{
using namespace UNV2412;
TDataSet aDataSet2412;
TConnect aConnect;
// Storing SMDS Edges
MESSAGE("Perform - myMesh->NbEdges() = "<<myMesh->NbEdges());
if(myMesh->NbEdges()){
SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
for(; anIter->more();){
const SMDS_MeshEdge* anElem = anIter->next();
TElementLab aLabel = anElem->GetID();
int aNbNodes = anElem->NbNodes();
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
aNodesIter = anElem->nodesIteratorToUNV();
if( anElem->IsQuadratic() ) {
aRec.fe_descriptor_id = 22;
} else {
aRec.fe_descriptor_id = 11;
}
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
}
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
}
MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
}
MESSAGE("Perform - myMesh->NbFaces() = "<<myMesh->NbFaces());
if(myMesh->NbFaces()){
SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
for(; anIter->more();){
const SMDS_MeshFace* anElem = anIter->next();
TElementLab aLabel = anElem->GetID();
int aNbNodes = anElem->NbNodes();
TRecord aRec;
aRec.node_labels.reserve(aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
aNodesIter = anElem->nodesIteratorToUNV();
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
}
switch(aNbNodes){
case 3:
aRec.fe_descriptor_id = 41;
break;
case 4:
aRec.fe_descriptor_id = 44;
break;
case 6:
aRec.fe_descriptor_id = 42;
break;
case 8:
aRec.fe_descriptor_id = 45;
break;
default:
continue;
}
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
}
MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
}
MESSAGE("Perform - myMesh->NbVolumes() = "<<myMesh->NbVolumes());
if(myMesh->NbVolumes()){
SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator();
for(; anIter->more();){
const SMDS_MeshVolume* anElem = anIter->next();
TElementLab aLabel = anElem->GetID();
int aNbNodes = anElem->NbNodes();
//MESSAGE("aNbNodes="<<aNbNodes);
SMDS_ElemIteratorPtr aNodesIter;
aNodesIter = anElem->nodesIteratorToUNV();
if ( anElem->IsPoly() ) {
MESSAGE("anElem->IsPoly");
if ( const SMDS_VtkVolume* ph =
dynamic_cast<const SMDS_VtkVolume*> (anElem))
{
aNbNodes = ph->NbUniqueNodes();
aNodesIter = ph->uniqueNodesIterator();
}
}
int anId = -1;
switch(aNbNodes){
case 4: {
anId = 111;
break;
}
case 6: {
anId = 112;
break;
}
case 8: {
anId = 115;
break;
}
case 10: {
anId = 118;
break;
}
case 13: {
anId = 114;
break;
}
case 15: {
anId = 113;
break;
}
case 20: {
anId = 116;
break;
}
default:
continue;
}
if(anId>0){
TRecord aRec;
aRec.fe_descriptor_id = anId;
aRec.node_labels.reserve(aNbNodes);
for(; aNodesIter->more();){
const SMDS_MeshElement* aNode = aNodesIter->next();
aRec.node_labels.push_back(aNode->GetID());
}
aDataSet2412.insert(TDataSet::value_type(aLabel,aRec));
}
}
MESSAGE("Perform - aDataSet2412.size() = "<<aDataSet2412.size());
}
UNV2412::Write(out_stream,aDataSet2412);
}
{
using namespace UNV2417;
if (myGroups.size() > 0) {
TDataSet aDataSet2417;
TGroupList::const_iterator aIter = myGroups.begin();
for (; aIter != myGroups.end(); aIter++) {
SMESHDS_GroupBase* aGroupDS = *aIter;
TRecord aRec;
aRec.GroupName = aGroupDS->GetStoreName();
int i;
SMDS_ElemIteratorPtr aIter = aGroupDS->GetElements();
if (aGroupDS->GetType() == SMDSAbs_Node) {
aRec.NodeList.resize(aGroupDS->Extent());
i = 0;
while (aIter->more()) {
const SMDS_MeshElement* aElem = aIter->next();
aRec.NodeList[i] = aElem->GetID();
i++;
}
} else {
aRec.ElementList.resize(aGroupDS->Extent());
i = 0;
while (aIter->more()) {
const SMDS_MeshElement* aElem = aIter->next();
aRec.ElementList[i] = aElem->GetID();
i++;
}
}
// 0019936: EDF 794 SMESH : Export UNV : Node color and group id
//aDataSet2417.insert(TDataSet::value_type(aGroupDS->GetID(), aRec));
aDataSet2417.insert(TDataSet::value_type(aGroupDS->GetID()+1, aRec));
}
UNV2417::Write(out_stream,aDataSet2417);
myGroups.clear();
}
}
/* {
using namespace UNV2417;
TDataSet aDataSet2417;
for ( TGroupsMap::iterator it = myGroupsMap.begin(); it != myGroupsMap.end(); it++ ) {
SMESH_Group* aGroup = it->second;
SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS();
if ( aGroupDS ) {
TRecord aRec;
aRec.GroupName = aGroup->GetName();
int i;
SMDS_ElemIteratorPtr aIter = aGroupDS->GetElements();
if (aGroupDS->GetType() == SMDSAbs_Node) {
aRec.NodeList.resize(aGroupDS->Extent());
i = 0;
while (aIter->more()) {
const SMDS_MeshElement* aElem = aIter->next();
aRec.NodeList[i] = aElem->GetID();
i++;
}
} else {
aRec.ElementList.resize(aGroupDS->Extent());
i = 0;
while (aIter->more()) {
const SMDS_MeshElement* aElem = aIter->next();
aRec.ElementList[i] = aElem->GetID();
i++;
}
}
aDataSet2417.insert(TDataSet::value_type(aGroupDS->GetID(), aRec));
}
}
UNV2417::Write(out_stream,aDataSet2417);
}*/
out_stream.flush();
out_stream.close();
if (!check_file(myFile))
EXCEPTION(runtime_error,"ERROR: Output file not good.");
}
catch(const std::exception& exc){
INFOS("Follow exception was cought:\n\t"<<exc.what());
throw;
}
catch(...){
INFOS("Unknown exception was cought !!!");
throw;
}
return aResult;
}
| void Driver_Mesh::SetFile | ( | const std::string & | theFileName | ) | [inherited] |
Reimplemented in DriverMED_W_SMESHDS_Mesh.
Definition at line 43 of file Driver_Mesh.cxx.
References Driver_Mesh.myFile, and SMESH_Nut.theFileName.
Referenced by SMESH_Gen_i.CreateMeshesFromMED(), SMESH_Mesh.ExportDAT(), SMESH_Mesh.ExportSTL(), SMESH_Mesh.ExportUNV(), SMESH_Gen_i.Load(), SMESH_Mesh.MEDToMesh(), SMESH_Mesh.STLToMesh(), and SMESH_Mesh.UNVToMesh().
{
myFile = theFileName;
}
| void Driver_SMDS_Mesh::SetMesh | ( | SMDS_Mesh * | theMesh | ) | [inherited] |
Definition at line 31 of file Driver_SMDS_Mesh.cxx.
References Driver_SMDS_Mesh.myMesh.
Referenced by SMESH_Mesh.ExportDAT(), SMESH_Mesh.ExportSTL(), SMESH_Mesh.ExportUNV(), SMESH_Mesh.STLToMesh(), and SMESH_Mesh.UNVToMesh().
{
myMesh = theMesh;
}
| void Driver_Mesh::SetMeshId | ( | int | theMeshId | ) | [inherited] |
Definition at line 37 of file Driver_Mesh.cxx.
References Driver_Mesh.myMeshId.
Referenced by SMESH_Gen_i.CreateMeshesFromMED(), SMESH_Mesh.ExportDAT(), SMESH_Mesh.ExportSTL(), SMESH_Mesh.ExportUNV(), SMESH_Gen_i.Load(), SMESH_Mesh.MEDToMesh(), SMESH_Mesh.STLToMesh(), and SMESH_Mesh.UNVToMesh().
{
myMeshId = theMeshId;
}
std::string Driver_Mesh.myFile [protected, inherited] |
Definition at line 62 of file Driver_Mesh.h.
Referenced by DriverSTL_R_SMDS_Mesh.Perform(), DriverMED_W_SMESHDS_Mesh.Perform(), DriverSTL_R_SMDS_Mesh.readAscii(), DriverSTL_R_SMDS_Mesh.readBinary(), Driver_Mesh.SetFile(), DriverSTL_W_SMDS_Mesh.writeAscii(), and DriverSTL_W_SMDS_Mesh.writeBinary().
TGroupList DriverUNV_W_SMDS_Mesh.myGroups [private] |
Definition at line 43 of file DriverUNV_W_SMDS_Mesh.h.
SMDS_Mesh* Driver_SMDS_Mesh.myMesh [protected, inherited] |
Definition at line 37 of file Driver_SMDS_Mesh.h.
Referenced by DriverSTL_W_SMDS_Mesh.findVolumeTriangles(), DriverSTL_W_SMDS_Mesh.getFaces(), DriverSTL_W_SMDS_Mesh.Perform(), DriverSTL_R_SMDS_Mesh.Perform(), DriverSTL_R_SMDS_Mesh.readAscii(), DriverSTL_R_SMDS_Mesh.readBinary(), Driver_SMDS_Mesh.SetMesh(), and DriverSTL_W_SMDS_Mesh.writeBinary().
int Driver_Mesh.myMeshId [protected, inherited] |
Definition at line 63 of file Driver_Mesh.h.
Referenced by DriverMED_W_SMESHDS_Mesh.Perform(), and Driver_Mesh.SetMeshId().