diff --git a/Geo/GModelIO_Mesh.cpp b/Geo/GModelIO_Mesh.cpp index f9311300187c91897995771f64e7a1a2d460bd43..3fa99f568fc8f59e3df74f200b24a31ee7b9683b 100644 --- a/Geo/GModelIO_Mesh.cpp +++ b/Geo/GModelIO_Mesh.cpp @@ -2986,12 +2986,8 @@ static void writeElementsINP(FILE *fp, GEntity *ge, std::vector<T*> &elements, for(int p = 0; p < np; p++){ int part = (saveAll ? ge->tag() : ge->physicals[p]); fprintf(fp, "*Element, type=%s, ELSET=PART%d\n", typ, part); - for(unsigned int i = 0; i < elements.size(); i++){ - fprintf(fp, "%d", ne++); - for(int j = 0; j < elements[i]->getNumVertices(); j++) - fprintf(fp, ", %d", elements[i]->getVertexINP(j)->getIndex()); - fprintf(fp, "\n"); - } + for(unsigned int i = 0; i < elements.size(); i++) + elements[i]->writeINP(fp, ne); } } } diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp index 424d24a0ed2bac36e4c6b569518a82c7588e0a11..1b45a659d19c58bfcee2c93570218a009835b201 100644 --- a/Geo/MElement.cpp +++ b/Geo/MElement.cpp @@ -789,6 +789,15 @@ void MElement::writeDIFF(FILE *fp, int num, bool binary, int physical_property) } } +void MElement::writeINP(FILE *fp, int num) +{ + setVolumePositive(); + fprintf(fp, "%d", num); + for(int i = 0; i < getNumVertices(); i++) + fprintf(fp, ", %d", getVertexINP(i)->getIndex()); + fprintf(fp, "\n"); +} + int MElement::getInfoMSH(const int typeMSH, const char **const name) { switch(typeMSH){ diff --git a/Geo/MElement.h b/Geo/MElement.h index 55e7011c037335ff79542446d1198daf9817cbec..69f675ff8d3132ff822f6b8a19f621207fc40d5f 100644 --- a/Geo/MElement.h +++ b/Geo/MElement.h @@ -283,6 +283,7 @@ class MElement int elementary=1, int physical=0); virtual void writeDIFF(FILE *fp, int num, bool binary=false, int physical_property=1); + virtual void writeINP(FILE *fp, int num); // info for specific IO formats (returning 0 means that the element // is not implemented in that format)