From: nri Date: Mon, 19 May 2003 14:07:00 +0000 (+0000) Subject: NRI : First integration. X-Git-Tag: Start-v1_1a~15 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=3973ceea250d2a077cdb5a798eb7c6151fa9c568 NRI : First integration. --- diff --git a/src/Driver/Document_Reader.cxx b/src/Driver/Document_Reader.cxx new file mode 100644 index 000000000..3a0ec88f1 --- /dev/null +++ b/src/Driver/Document_Reader.cxx @@ -0,0 +1,13 @@ +using namespace std; +#include "Document_Reader.h" + +#include "utilities.h" + +void Document_Reader::SetFile(string aFile) { + myFile = aFile; +} + +void Document_Reader::SetDocument(Handle(SMESHDS_Document)& aDoc) { + myDocument = aDoc; +} + diff --git a/src/Driver/Document_Reader.h b/src/Driver/Document_Reader.h new file mode 100644 index 000000000..46472e521 --- /dev/null +++ b/src/Driver/Document_Reader.h @@ -0,0 +1,18 @@ +#ifndef _INCLUDE_DOCUMENT_READER +#define _INCLUDE_DOCUMENT_READER + +#include "SMESHDS_Document.hxx" +#include + +class Document_Reader { + + public : + virtual void Read() =0; + void SetFile(string); + void SetDocument(Handle(SMESHDS_Document)&); + + protected : + Handle_SMESHDS_Document myDocument; + string myFile; +}; +#endif diff --git a/src/Driver/Document_Writer.cxx b/src/Driver/Document_Writer.cxx new file mode 100644 index 000000000..73ad7f78a --- /dev/null +++ b/src/Driver/Document_Writer.cxx @@ -0,0 +1,11 @@ +using namespace std; +#include "Document_Writer.h" + +void Document_Writer::SetFile(string aFile) { + myFile = aFile; +} + +void Document_Writer::SetDocument(Handle(SMESHDS_Document)& aDoc) { + myDocument = aDoc; +} + diff --git a/src/Driver/Document_Writer.h b/src/Driver/Document_Writer.h new file mode 100644 index 000000000..4d3a67fc8 --- /dev/null +++ b/src/Driver/Document_Writer.h @@ -0,0 +1,19 @@ +#ifndef _INCLUDE_DOCUMENT_WRITER +#define _INCLUDE_DOCUMENT_WRITER + +#include "SMESHDS_Document.hxx" +#include + +class Document_Writer { + + public : + virtual void Write() =0; + void SetFile(string); + void SetDocument(Handle(SMESHDS_Document)&); + + protected : + Handle_SMESHDS_Document myDocument; + string myFile; + +}; +#endif diff --git a/src/Driver/Driver_dl.cxx b/src/Driver/Driver_dl.cxx new file mode 100644 index 000000000..81dd4230b --- /dev/null +++ b/src/Driver/Driver_dl.cxx @@ -0,0 +1,183 @@ +using namespace std; +#include "Driver.h" + +#include +#include +#include + +#include "DriverDAT_R_SMESHDS_Document.h" +#include "Test.h" + +/*! extern "C" +{ + void test() { + + void *handle; + double (*cosine)(double); + char *error; + + handle = dlopen ("/usr/lib/libm.so", RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + cosine = dlsym(handle, "cos"); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + + printf ("%f\n", (*cosine)(2.0)); + dlclose(handle); + + char* error; + string Extension=string("DAT"); + string Class=string("SMESHDS_Document"); + string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so"); + SCRUTE(myLibrary); + //Document_Reader* myDriver;//a caster ??? + DriverDAT_R_SMESHDS_Document* myDriver; + + string myClass = string("Driver")+Extension+string("_R_")+Class; + SCRUTE(myClass); + + void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + MESSAGE("Open ok"); + + //int* res = (int*)dlsym(handle, "getOne"); + //SCRUTE(res); + SCRUTE(dlsym(handle, "getOne")); + //int res2= (*res)(); + myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str()); + MESSAGE("Reading 1"); + SCRUTE(myDriver); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + MESSAGE("Reading 2"); + + dlclose(handle); + MESSAGE("after close"); + + } + }*/ + +Document_Reader* Driver::GetDocumentReader(string Extension, string Class) { + test(); + //p-e extern C ? + /*! + char* error; + string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so"); + SCRUTE(myLibrary); + //Document_Reader* myDriver;//a caster ??? + DriverDAT_R_SMESHDS_Document* myDriver; + + string myClass = string("Driver")+Extension+string("_R_")+Class; + SCRUTE(myClass); + + void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + MESSAGE("Open ok"); + //myDriver = (Document_Reader*) dlsym(handle, myClass.c_str()); + int* res = (int*) dlsym(handle, "getOne"); + SCRUTE(res); + myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str()); + MESSAGE("Reading 1"); + SCRUTE(myDriver); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + MESSAGE("Reading 2"); + + dlclose(handle); + MESSAGE("after close"); + return (myDriver); + */ + +} + +Document_Writer* Driver::GetDocumentWriter(string Extension, string Class) { + + char* error; + string myLibrary = string("libMeshDriver")+Extension+string(".so"); + Document_Writer* myDriver;//a caster ??? + string myClass = string("Driver")+Extension+string("_W_")+Class; + + void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + myDriver = (Document_Writer*) dlsym(handle, myClass.c_str()); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + + dlclose(handle); + + return (myDriver); + +} + +Mesh_Reader* Driver::GetMeshReader(string Extension, string Class) { + + char* error; + string myLibrary = string("libMeshDriver")+Extension+string(".so"); + Mesh_Reader* myDriver;//a caster ??? + string myClass = string("Driver")+Extension+string("_R_")+Class; + + void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + myDriver = (Mesh_Reader*) dlsym(handle, myClass.c_str()); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + + dlclose(handle); + + return (myDriver); + +} + +Mesh_Writer* Driver::GetMeshWriter(string Extension, string Class) { + + char* error; + string myLibrary = string("libMeshDriver")+Extension+string(".so"); + Mesh_Writer* myDriver;//a caster ??? + string myClass = string("Driver")+Extension+string("_W_")+Class; + + void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); + if (!handle) { + fputs (dlerror(), stderr); + exit(1); + } + + myDriver = (Mesh_Writer*) dlsym(handle, myClass.c_str()); + if ((error = dlerror()) != NULL) { + fprintf (stderr, "%s\n", error); + exit(1); + } + + dlclose(handle); + + return (myDriver); + +} + diff --git a/src/Driver/Makefile.in b/src/Driver/Makefile.in new file mode 100644 index 000000000..c8bb27367 --- /dev/null +++ b/src/Driver/Makefile.in @@ -0,0 +1,39 @@ +# -* Makefile *- +# +# Author : Marc Tajchman (CEA) +# Date : 5/07/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= Document_Reader.h Document_Writer.h Mesh_Reader.h Mesh_Writer.h + +# Libraries targets +LIB = libMeshDriver.la +LIB_SRC = Document_Reader.cxx Document_Writer.cxx Mesh_Reader.cxx Mesh_Writer.cxx + +LIB_CLIENT_IDL = + +LIB_SERVER_IDL = + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -rdynamic -ldl -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) -lSMESHDS -lSMDS + +%_moc.cxx: %.h + $(MOC) $< -o $@ + +@CONCLUDE@ + + + diff --git a/src/Driver/Mesh_Reader.cxx b/src/Driver/Mesh_Reader.cxx new file mode 100644 index 000000000..3001d36cd --- /dev/null +++ b/src/Driver/Mesh_Reader.cxx @@ -0,0 +1,3 @@ +using namespace std; +#include "Mesh_Reader.h" + diff --git a/src/Driver/Mesh_Reader.h b/src/Driver/Mesh_Reader.h new file mode 100644 index 000000000..8671f5d3e --- /dev/null +++ b/src/Driver/Mesh_Reader.h @@ -0,0 +1,17 @@ +#ifndef _INCLUDE_MESH_READER +#define _INCLUDE_MESH_READER + +#include +#include "Handle_SMDS_Mesh.hxx" + +class Mesh_Reader { + + public : + virtual void Add() =0; + virtual void Read() =0; + virtual void SetMesh(Handle(SMDS_Mesh)&) =0; + virtual void SetMeshId(int) =0; + virtual void SetFile(string) =0; + +}; +#endif diff --git a/src/Driver/Mesh_Writer.cxx b/src/Driver/Mesh_Writer.cxx new file mode 100644 index 000000000..034e68f9e --- /dev/null +++ b/src/Driver/Mesh_Writer.cxx @@ -0,0 +1,2 @@ +using namespace std; +#include "Mesh_Writer.h" diff --git a/src/Driver/Mesh_Writer.h b/src/Driver/Mesh_Writer.h new file mode 100644 index 000000000..e9d84df54 --- /dev/null +++ b/src/Driver/Mesh_Writer.h @@ -0,0 +1,17 @@ +#ifndef _INCLUDE_MESH_WRITER +#define _INCLUDE_MESH_WRITER + +#include +#include "Handle_SMDS_Mesh.hxx" + +class Mesh_Writer { + + public : + virtual void Add() =0; + virtual void Write() =0; + virtual void SetMesh(Handle(SMDS_Mesh)&) =0; + virtual void SetFile(string) =0; + virtual void SetMeshId(int) =0; + +}; +#endif diff --git a/src/Driver/SMESHDriver.cxx b/src/Driver/SMESHDriver.cxx new file mode 100644 index 000000000..2bd13fadd --- /dev/null +++ b/src/Driver/SMESHDriver.cxx @@ -0,0 +1,113 @@ +using namespace std; +#include "SMESHDriver.h" + +#include +#include + +//A enlever +#include "DriverMED_R_SMESHDS_Document.h" +#include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverMED_R_SMDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Document.h" +#include "DriverMED_W_SMESHDS_Mesh.h" +#include "DriverMED_W_SMDS_Mesh.h" + +#include "DriverDAT_R_SMESHDS_Document.h" +#include "DriverDAT_R_SMESHDS_Mesh.h" +#include "DriverDAT_R_SMDS_Mesh.h" +#include "DriverDAT_W_SMESHDS_Document.h" +#include "DriverDAT_W_SMESHDS_Mesh.h" +#include "DriverDAT_W_SMDS_Mesh.h" +// + +Document_Reader* SMESHDriver::GetDocumentReader(string Extension, string Class) { + if (Extension==string("MED")) { + DriverMED_R_SMESHDS_Document* myDriver = new DriverMED_R_SMESHDS_Document(); + return (myDriver); + } + else if (Extension==string("DAT")) { + DriverDAT_R_SMESHDS_Document* myDriver = new DriverDAT_R_SMESHDS_Document(); + return (myDriver); + } + else { + MESSAGE("No driver known for this extension"); + return (Document_Reader*)NULL; + } + + +} + +Document_Writer* SMESHDriver::GetDocumentWriter(string Extension, string Class) { + if (Extension==string("MED")) { + DriverMED_W_SMESHDS_Document* myDriver = new DriverMED_W_SMESHDS_Document(); + return (myDriver); + } + else if (Extension==string("DAT")) { + DriverDAT_W_SMESHDS_Document* myDriver = new DriverDAT_W_SMESHDS_Document(); + return (myDriver); + } + else { + MESSAGE("No driver known for this extension"); + return (Document_Writer*)NULL; + } + + +} + +Mesh_Reader* SMESHDriver::GetMeshReader(string Extension, string Class) { + if (Extension==string("MED")) { + + if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { + DriverMED_R_SMESHDS_Mesh* myDriver = new DriverMED_R_SMESHDS_Mesh(); + return (myDriver); + } + else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { + DriverMED_R_SMDS_Mesh* myDriver = new DriverMED_R_SMDS_Mesh(); + return (myDriver); + } + + } + else if (Extension==string("DAT")) { + + if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { + DriverDAT_R_SMESHDS_Mesh* myDriver = new DriverDAT_R_SMESHDS_Mesh(); + return (myDriver); + } + else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { + DriverDAT_R_SMDS_Mesh* myDriver = new DriverDAT_R_SMDS_Mesh(); + return (myDriver); + } + + } + + +} + +Mesh_Writer* SMESHDriver::GetMeshWriter(string Extension, string Class) { + if (Extension==string("MED")) { + + if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { + DriverMED_W_SMESHDS_Mesh* myDriver = new DriverMED_W_SMESHDS_Mesh(); + return (myDriver); + } + else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { + DriverMED_W_SMDS_Mesh* myDriver = new DriverMED_W_SMDS_Mesh(); + return (myDriver); + } + + } + else if (Extension==string("DAT")) { + + if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { + DriverDAT_W_SMESHDS_Mesh* myDriver = new DriverDAT_W_SMESHDS_Mesh(); + return (myDriver); + } + else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { + DriverDAT_W_SMDS_Mesh* myDriver = new DriverDAT_W_SMDS_Mesh(); + return (myDriver); + } + + } + +} + diff --git a/src/Driver/SMESHDriver.h b/src/Driver/SMESHDriver.h new file mode 100644 index 000000000..ba0e7ad19 --- /dev/null +++ b/src/Driver/SMESHDriver.h @@ -0,0 +1,19 @@ +#ifndef _INCLUDE_SMESHDRIVER +#define _INCLUDE_SMESHDRIVER + +#include "Document_Reader.h" +#include "Document_Writer.h" +#include "Mesh_Reader.h" +#include "Mesh_Writer.h" + +class SMESHDriver { + + public : + static Document_Reader* GetDocumentReader(string Extension, string Class); + static Document_Writer* GetDocumentWriter(string Extension, string Class); + + static Mesh_Reader* GetMeshReader(string Extension, string Class); + static Mesh_Writer* GetMeshWriter(string Extension, string Class); + +}; +#endif diff --git a/src/MEFISTO2/Makefile.in b/src/MEFISTO2/Makefile.in new file mode 100644 index 000000000..63798ef3f --- /dev/null +++ b/src/MEFISTO2/Makefile.in @@ -0,0 +1,36 @@ +# -* Makefile *- +# +# Author : +# Date : 29/01/2001 +# +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# header files +EXPORT_HEADERS = aptrte.h Rn.h + +# Libraries targets +LIB = libMEFISTO2D.la +LIB_SRC = aptrte.cxx trte.f +# areteideale.f + +LIB_CLIENT_IDL = + +LIB_SERVER_IDL = + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += $(OCC_LIBS) -lg2c + +@CONCLUDE@ + diff --git a/src/MEFISTO2/Rn.h b/src/MEFISTO2/Rn.h new file mode 100755 index 000000000..a2856eeec --- /dev/null +++ b/src/MEFISTO2/Rn.h @@ -0,0 +1,204 @@ +#ifndef Rn__h +#define Rn__h + +#include //Dans OpenCascade +#include //Dans OpenCascade +#include //Dans OpenCascade + +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// BUT: Definir les espaces affines R R2 R3 R4 soit Rn pour n=1,2,3,4 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// AUTEUR : Frederic HECHT ANALYSE NUMERIQUE UPMC PARIS OCTOBRE 2000 +// MODIFS : Alain PERRONNET ANALYSE NUMERIQUE UPMC PARIS NOVEMBRE 2000 +//............................................................................... +#include +#include + +using namespace std; + +template inline T Abs (const T &a){return a <0 ? -a : a;} +template inline void Echange (T& a,T& b) {T c=a;a=b;b=c;} + +template inline T Min (const T &a,const T &b) {return a < b ? a : b;} +template inline T Max (const T &a,const T & b) {return a > b ? a : b;} + +template inline T Max (const T &a,const T & b,const T & c){return Max(Max(a,b),c);} +template inline T Min (const T &a,const T & b,const T & c){return Min(Min(a,b),c);} + +template inline T Max (const T &a,const T & b,const T & c,const T & d) + {return Max(Max(a,b),Max(c,d));} +template inline T Min (const T &a,const T & b,const T & c,const T & d) + {return Min(Min(a,b),Min(c,d));} + +//le type Nom des entites geometriques P L S V O +//=========== +typedef char Nom[1+24]; + +//le type N des nombres entiers positifs +//========= +typedef unsigned long int N; + +//le type Z des nombres entiers relatifs +//========= +typedef long int Z; + +//le type R des nombres "reels" +//========= +typedef double R; + +//le type XPoint des coordonnees d'un pixel dans une fenetre +//============== +//typedef struct { short int x,y } XPoint; //en fait ce type est defini dans X11-Window + // #include +//la classe R2 +//============ +class R2 +{ + friend ostream& operator << (ostream& f, const R2 & P) + { f << P.x << ' ' << P.y ; return f; } + friend istream& operator >> (istream& f, R2 & P) + { f >> P.x >> P.y ; return f; } + + friend ostream& operator << (ostream& f, const R2 * P) + { f << P->x << ' ' << P->y ; return f; } + friend istream& operator >> (istream& f, R2 * P) + { f >> P->x >> P->y ; return f; } + +public: + R x,y; //les donnees + + R2 () :x(0),y(0) {} //les constructeurs + R2 (R a,R b) :x(a),y(b) {} + R2 (R2 A,R2 B) :x(B.x-A.x),y(B.y-A.y) {} //vecteur defini par 2 points + + R2 operator+(R2 P) const {return R2(x+P.x,y+P.y);} // Q+P possible + R2 operator+=(R2 P) {x += P.x;y += P.y; return *this;}// Q+=P; + R2 operator-(R2 P) const {return R2(x-P.x,y-P.y);} // Q-P + R2 operator-=(R2 P) {x -= P.x;y -= P.y; return *this;} // Q-=P; + R2 operator-()const {return R2(-x,-y);} // -Q + R2 operator+()const {return *this;} // +Q + R operator,(R2 P)const {return x*P.x+y*P.y;} // produit scalaire (Q,P) + R operator^(R2 P)const {return x*P.y-y*P.x;} // produit vectoriel Q^P + R2 operator*(R c)const {return R2(x*c,y*c);} // produit a droite P*c + R2 operator*=(R c) {x *= c; y *= c; return *this;} + R2 operator/(R c)const {return R2(x/c,y/c);} // division par un reel + R2 operator/=(R c) {x /= c; y /= c; return *this;} + R & operator[](int i) {return (&x)[i];} // la coordonnee i + R2 orthogonal() {return R2(-y,x);} //le vecteur orthogonal dans R2 + friend R2 operator*(R c,R2 P) {return P*c;} // produit a gauche c*P +}; + + +//la classe R3 +//============ +class R3 +{ + friend ostream& operator << (ostream& f, const R3 & P) + { f << P.x << ' ' << P.y << ' ' << P.z ; return f; } + friend istream& operator >> (istream& f, R3 & P) + { f >> P.x >> P.y >> P.z ; return f; } + + friend ostream& operator << (ostream& f, const R3 * P) + { f << P->x << ' ' << P->y << ' ' << P->z ; return f; } + friend istream& operator >> (istream& f, R3 * P) + { f >> P->x >> P->y >> P->z ; return f; } + +public: + R x,y,z; //les 3 coordonnees + + R3 () :x(0),y(0),z(0) {} //les constructeurs + R3 (R a,R b,R c):x(a),y(b),z(c) {} //Point ou Vecteur (a,b,c) + R3 (R3 A,R3 B):x(B.x-A.x),y(B.y-A.y),z(B.z-A.z) {} //Vecteur AB + + R3 (gp_Pnt P) : x(P.X()), y(P.Y()), z(P.Z()) {} //Point d'OpenCascade + R3 (gp_Vec V) : x(V.X()), y(V.Y()), z(V.Z()) {} //Vecteur d'OpenCascade + R3 (gp_Dir P) : x(P.X()), y(P.Y()), z(P.Z()) {} //Direction d'OpenCascade + + R3 operator+(R3 P)const {return R3(x+P.x,y+P.y,z+P.z);} + R3 operator+=(R3 P) {x += P.x; y += P.y; z += P.z; return *this;} + R3 operator-(R3 P)const {return R3(x-P.x,y-P.y,z-P.z);} + R3 operator-=(R3 P) {x -= P.x; y -= P.y; z -= P.z; return *this;} + R3 operator-()const {return R3(-x,-y,-z);} + R3 operator+()const {return *this;} + R operator,(R3 P)const {return x*P.x+y*P.y+z*P.z;} // produit scalaire + R3 operator^(R3 P)const {return R3(y*P.z-z*P.y ,P.x*z-x*P.z, x*P.y-y*P.x);} // produit vectoriel + R3 operator*(R c)const {return R3(x*c,y*c,z*c);} + R3 operator*=(R c) {x *= c; y *= c; z *= c; return *this;} + R3 operator/(R c)const {return R3(x/c,y/c,z/c);} + R3 operator/=(R c) {x /= c; y /= c; z /= c; return *this;} + R & operator[](int i) {return (&x)[i];} + friend R3 operator*(R c,R3 P) {return P*c;} + + R3 operator=(gp_Pnt P) {return R3(P.X(),P.Y(),P.Z());} + R3 operator=(gp_Dir P) {return R3(P.X(),P.Y(),P.Z());} + + friend gp_Pnt gp_pnt(R3 xyz) { return gp_Pnt(xyz.x,xyz.y,xyz.z); } + //friend gp_Pnt operator=() { return gp_Pnt(x,y,z); } + friend gp_Dir gp_dir(R3 xyz) { return gp_Dir(xyz.x,xyz.y,xyz.z); } + + bool DansPave( R3 & xyzMin, R3 & xyzMax ) + { return xyzMin.x<=x && x<=xyzMax.x && + xyzMin.y<=y && y<=xyzMax.y && + xyzMin.z<=z && z<=xyzMax.z; } +}; + +//la classe R4 +//============ +class R4: public R3 +{ + friend ostream& operator <<(ostream& f, const R4 & P ) + { f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; } + friend istream& operator >>(istream& f, R4 & P) + { f >> P.x >> P.y >> P.z >> P.omega ; return f; } + + friend ostream& operator <<(ostream& f, const R4 * P ) + { f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; } + friend istream& operator >>(istream& f, R4 * P) + { f >> P->x >> P->y >> P->z >> P->omega ; return f; } + +public: + R omega; //la donnee du poids supplementaire + + R4 () :omega(1.0) {} //les constructeurs + R4 (R a,R b,R c,R d):R3(a,b,c),omega(d) {} + R4 (R4 A,R4 B) :R3(B.x-A.x,B.y-A.y,B.z-A.z),omega(B.omega-A.omega) {} + + R4 operator+(R4 P)const {return R4(x+P.x,y+P.y,z+P.z,omega+P.omega);} + R4 operator+=(R4 P) {x += P.x;y += P.y;z += P.z;omega += P.omega;return *this;} + R4 operator-(R4 P)const {return R4(x-P.x,y-P.y,z-P.z,omega-P.omega);} + R4 operator-=(R4 P) {x -= P.x;y -= P.y;z -= P.z;omega -= P.omega;return *this;} + R4 operator-()const {return R4(-x,-y,-z,-omega);} + R4 operator+()const {return *this;} + R operator,(R4 P)const {return x*P.x+y*P.y+z*P.z+omega*P.omega;} // produit scalaire + R4 operator*(R c)const {return R4(x*c,y*c,z*c,omega*c);} + R4 operator*=(R c) {x *= c; y *= c; z *= c; omega *= c; return *this;} + R4 operator/(R c)const {return R4(x/c,y/c,z/c,omega/c);} + R4 operator/=(R c) {x /= c; y /= c; z /= c; omega /= c; return *this;} + R & operator[](int i) {return (&x)[i];} + friend R4 operator*(R c,R4 P) {return P*c;} +}; + +//quelques fonctions supplementaires sur ces classes +//================================================== +inline R Aire2d(const R2 A,const R2 B,const R2 C){return (B-A)^(C-A);} +inline R Angle2d(R2 P){ return atan2(P.y,P.x);} + +inline R Norme2_2(const R2 & A){ return (A,A);} +inline R Norme2(const R2 & A){ return sqrt((A,A));} +inline R NormeInfinie(const R2 & A){return Max(Abs(A.x),Abs(A.y));} + +inline R Norme2_2(const R3 & A){ return (A,A);} +inline R Norme2(const R3 & A){ return sqrt((A,A));} +inline R NormeInfinie(const R3 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z));} + +inline R Norme2_2(const R4 & A){ return (A,A);} +inline R Norme2(const R4 & A){ return sqrt((A,A));} +inline R NormeInfinie(const R4 & A){return Max(Abs(A.x),Abs(A.y),Abs(A.z),Abs(A.omega));} + +inline R2 XY(R3 P) {return R2(P.x, P.y);} //restriction a R2 d'un R3 par perte de z +inline R3 Min(R3 P, R3 Q) +{return R3(P.xQ.x ? P.x : Q.x, P.y>Q.y ? P.y : Q.y, P.z>Q.z ? P.z : Q.z);} //Pt de xyz Max + +#endif diff --git a/src/MEFISTO2/aptrte.cxx b/src/MEFISTO2/aptrte.cxx new file mode 100755 index 000000000..58da98168 --- /dev/null +++ b/src/MEFISTO2/aptrte.cxx @@ -0,0 +1,760 @@ +using namespace std; +#include "Rn.h" +#include "aptrte.h" +#include "utilities.h" + +extern "C" +{ + R aretemaxface_; + R areteideale_( R3 xyz, R3 direction ) + { + return aretemaxface_; + } +} +//calcul de la longueur ideale de l'arete au sommet xyz (z ici inactif) +//dans la direction donnee +//a ajuster pour chaque surface plane et selon l'entier notysu (voir plus bas) + + +static double cpunew, cpuold=0; + +void tempscpu_( double & tempsec ) +//Retourne le temps CPU utilise en secondes +{ + tempsec = ( (double) clock() ) / CLOCKS_PER_SEC; + //MESSAGE( "temps cpu=" << tempsec ); +} + + +void deltacpu_( R & dtcpu ) +//Retourne le temps CPU utilise en secondes depuis le precedent appel +{ + tempscpu_( cpunew ); + dtcpu = R( cpunew - cpuold ); + cpuold = cpunew; + //MESSAGE( "delta temps cpu=" << dtcpu ); + return; +} + + +void aptrte( Z nutysu, R aretmx, + Z nblf, Z * nudslf, R2 * uvslf, + Z nbpti, R2 *uvpti, + Z & nbst, R2 * & uvst, Z & nbt, Z * & nust, + Z & ierr ) +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// but : appel de la triangulation par un arbre-4 recouvrant +// ----- de triangles equilateraux +// le contour du domaine plan est defini par des lignes fermees +// la premiere ligne etant l'enveloppe de toutes les autres +// la fonction areteideale(s,d) donne la taille d'arete +// au point s dans la direction (actuellement inactive) d +// des lors toute arete issue d'un sommet s devrait avoir une longueur +// comprise entre 0.65 areteideale_(s,d) et 1.3 areteideale_(s,d) +// +//Attention: +// Les tableaux uvslf et uvpti sont supposes ne pas avoir de sommets identiques! +// De meme, un sommet d'une ligne fermee ne peut appartenir a une autre ligne fermee +// +// entrees: +// -------- +// nutysu : numero de traitement de areteideale_(s,d) selon le type de surface +// 0 pas d'emploi de la fonction areteideale_() et aretmx est active +// 1 il existe une fonction areteideale_(s,d) +// dont seules les 2 premieres composantes de uv sont actives +// ... autres options a definir ... +// aretmx : longueur maximale des aretes de la future triangulation +// nblf : nombre de lignes fermees de la surface +// nudslf : numero du dernier sommet de chacune des nblf lignes fermees +// nudslf(0)=0 pour permettre la difference sans test +// Attention le dernier sommet de chaque ligne est raccorde au premier +// tous les sommets et les points internes ont des coordonnees +// UV differentes <=> Pas de point double! +// uvslf : uv des nudslf(nblf) sommets des lignes fermees +// nbpti : nombre de points internes futurs sommets de la triangulation +// uvpti : uv des points internes futurs sommets de la triangulation +// +// sorties: +// -------- +// nbst : nombre de sommets de la triangulation finale +// uvst : coordonnees uv des nbst sommets de la triangulation +// nbt : nombre de triangles de la triangulation finale +// nust : 4 numeros dans uvst des sommets des nbt triangles +// s1, s2, s3, 0: no dans uvst des 3 sommets et 0 car quadrangle! +// ierr : 0 si pas d'erreur +// > 0 sinon +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// auteur : Alain Perronnet Analyse Numerique Paris UPMC decembre 2001 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +{ + R d, tcpu=0; + R3 direction=R3(0,0,0); //direction pour areteideale() inactive ici! + Z nbarfr=nudslf[nblf]; //nombre total d'aretes des lignes fermees + Z mxtrou = Max( 1024, nblf ); //nombre maximal de trous dans la surface + + R3 *mnpxyd=NULL; + Z *mnsoar=NULL, mosoar=7, mxsoar, n1soar; //le hachage des aretes + Z *mnartr=NULL, moartr=3, mxartr, n1artr; //le no des 3 aretes des triangles + Z *mntree=NULL, motree=9, mxtree; //L'arbre 4 de TE et nombre d'entiers par TE + Z *mnqueu=NULL, mxqueu; + Z *mn1arcf=NULL; + Z *mnarcf=NULL, mxarcf; + Z *mnarcf1=NULL; + Z *mnarcf2=NULL; + Z *mnarcf3=NULL; + Z *mntrsu=NULL; + Z *mndalf=NULL; + Z *mnslig=NULL; + Z *mnarst=NULL; + Z *mnlftr=NULL; + + R3 comxmi[2]; //coordonnees UV Min et Maximales + R aremin, aremax; //longueur minimale et maximale des aretes + R quamoy, quamin; + + Z noar0, noar, na; + Z i, l, n, ns, ns0, ns1, ns2, nosotr[3], nt; + Z mxsomm, nbsomm, nbarpi, nbarli, ndtri0, mn; + Z moins1=-1; + + aretemaxface_ = aretmx; + + // initialisation du temps cpu + deltacpu_( d ); + ierr = 0; + + // quelques reservations de tableaux pour faire les calculs + // ======================================================== + // le tableau pointeur sur la premiere arete de chaque ligne fermee + if( mndalf!=NULL ) delete [] mndalf; + mndalf = new Z[1+nblf]; + if( mndalf==NULL ) goto ERREUR; + mndalf[0]=0; + + // declaration du tableau des coordonnees des sommets de la frontiere + // puis des sommets internes ajoutes + // majoration empirique du nombre de sommets de la triangulation + i = 4*nbarfr/10; + mxsomm = Max( 20000, 64*nbpti+i*i ); + MESSAGE( "APTRTE: Depart de la triangulation avec " ); + MESSAGE( "nutysu=" << nutysu << " aretmx=" << aretmx << " mxsomm=" << mxsomm ); + + NEWDEPART: + //mnpxyd( 3, mxsomm ) les coordonnees UV des sommets et la taille d'arete aux sommets + if( mnpxyd!=NULL ) delete [] mnpxyd; + mnpxyd = new R3[mxsomm]; + if( mnpxyd==NULL ) goto ERREUR; + + // le tableau mnsoar des aretes des triangles + // 1: sommet 1 dans pxyd, + // 2: sommet 2 dans pxyd, + // 3: numero de 1 a nblf de la ligne qui supporte l'arete + // 4: numero dans mnartr du triangle 1 partageant cette arete, + // 5: numero dans mnartr du triangle 2 partageant cette arete, + // 6: chainage des aretes frontalieres ou internes ou + // des aretes simples des etoiles de triangles, + // 7: chainage du hachage des aretes + // nombre d'aretes = 3 ( nombre de sommets - 1 + nombre de trous ) + // pour le hachage des aretes mxsoar doit etre > 3*mxsomm! + // h(ns1,ns2) = min( ns1, ns2 ) + if( mnsoar!=NULL ) delete [] mnsoar; + mxsoar = 3 * ( mxsomm + mxtrou ); + mnsoar = new Z[mosoar*mxsoar]; + if( mnsoar==NULL ) goto ERREUR; + //initialiser le tableau mnsoar pour le hachage des aretes + insoar_( mxsomm, mosoar, mxsoar, n1soar, mnsoar ); + + // mnarst( mxsomm ) numero mnsoar d'une arete pour chacun des sommets + if( mnarst!=NULL ) delete [] mnarst; + mnarst = new Z[1+mxsomm]; + if( mnarst==NULL ) goto ERREUR; + n = 1+mxsomm; + azeroi_( n, mnarst ); + + // mnslig( mxsomm ) no de sommet dans sa ligne pour chaque sommet frontalier + // ou no du point si interne forc'e par l'utilisateur + // ou 0 si interne cree par le module + if( mnslig!=NULL ) delete [] mnslig; + mnslig = new Z[mxsomm]; + if( mnslig==NULL ) goto ERREUR; + azeroi_( mxsomm, mnslig ); + + // initialisation des aretes frontalieres de la triangulation future + // renumerotation des sommets des aretes des lignes pour la triangulation + // mise a l'echelle des coordonnees des sommets pour obtenir une + // meilleure precision lors des calculs + quelques verifications + // boucle sur les lignes fermees qui forment la frontiere + // ====================================================================== + noar = 0; + aremin = 1e100; + aremax = 0; + + for (n=1; n<=nblf; n++) + { + //l'initialisation de la premiere arete de la ligne n dans la triangulation + //------------------------------------------------------------------------- + //le sommet ns0 est le numero de l'origine de la ligne + ns0 = nudslf[n-1]; + mnpxyd[ns0].x = uvslf[ns0].x; + mnpxyd[ns0].y = uvslf[ns0].y; + mnpxyd[ns0].z = areteideale_( mnpxyd[ns0], direction ); +// cout << "Sommet " << ns0 << ": " << mnpxyd[ns0].x +// << " " << mnpxyd[ns0].y << " longueur arete=" << mnpxyd[ns0].z << endl; + + //carre de la longueur de l'arete 1 de la ligne fermee n + d = pow( uvslf[ns0+1].x - uvslf[ns0].x, 2 ) + + pow( uvslf[ns0+1].y - uvslf[ns0].y, 2 ) ; + aremin = Min( aremin, d ); + aremax = Max( aremax, d ); + + //le numero des 2 sommets (ns1,ns2) de la premiere arete de la ligne + //initialisation de la 1-ere arete ns1-ns1+1 de cette ligne fermee n + //le numero des 2 sommets ns1 ns2 de la 1-ere arete + //Attention: les numeros ns debutent a 1 (ils ont >0) + // les tableaux c++ demarrent a zero! + // les tableaux fortran demarrent ou l'on veut! + ns0++; + ns1 = ns0; + ns2 = ns1+1; + + //le numero n de la ligne du sommet et son numero ns1 dans la ligne + mnslig[ns0-1] = 1000000 * n + ns1-nudslf[n-1]; + fasoar_( ns1, ns2, moins1, moins1, n, + mosoar, mxsoar, n1soar, mnsoar, mnarst, + noar0, ierr ); + //pas de test sur ierr car pas de saturation possible a ce niveau + + //le pointeur dans le hachage sur la premiere arete de la ligne fermee n + mndalf[n] = noar0; + + //la nouvelle arete est la suivante de l'arete definie juste avant + if( noar > 0 ) + mnsoar[mosoar * noar - mosoar + 5] = noar0; + + //l'initialisation des aretes suivantes de la ligne dans la triangulation + //----------------------------------------------------------------------- + nbarli = nudslf[n] - nudslf[n-1]; //nombre d'aretes=sommets de la ligne n + for (i=2; i<=nbarli; i++) + { + ns1 = ns2; //le numero de l'arete et le numero du premier sommet de l'arete + if( i < nbarli ) + //nbs+1 est le 2-eme sommet de l'arete i de la ligne fermee n + ns2 = ns1+1; + else + //le 2-eme sommet de la derniere arete est le premier sommet de la ligne + ns2 = ns0; + + //l'arete precedente est dotee de sa suivante:celle cree ensuite + //les 2 coordonnees du sommet ns2 de la ligne + ns = ns1 - 1; + mnpxyd[ns].x = uvslf[ns].x; + mnpxyd[ns].y = uvslf[ns].y; + mnpxyd[ns].z = areteideale_( mnpxyd[ns], direction ); +// cout << "Sommet " << ns << ": " << mnpxyd[ns].x +// << " " << mnpxyd[ns].y << " longueur arete=" << mnpxyd[ns].z << endl; + + //carre de la longueur de l'arete + d = pow( uvslf[ns2-1].x - uvslf[ns1-1].x, 2) + + pow( uvslf[ns2-1].y - uvslf[ns1-1].y, 2); + aremin = Min( aremin, d ); + aremax = Max( aremax, d ); + + //le numero n de la ligne du sommet et son numero ns1 dans la ligne + mnslig[ns] = 1000000 * n + ns1-nudslf[n-1]; + + //ajout de l'arete dans la liste + fasoar_( ns1, ns2, moins1, moins1, n, + mosoar, mxsoar, n1soar, mnsoar, + mnarst, noar, ierr ); + //pas de test sur ierr car pas de saturation possible a ce niveau + + //chainage des aretes frontalieres en position 6 du tableau mnsoar + //la nouvelle arete est la suivante de l'arete definie juste avant + mnsoar[ mosoar * noar0 - mosoar + 5 ] = noar; + noar0 = noar; + } + //attention: la derniere arete de la ligne fermee enveloppe + // devient en fait la premiere arete de cette ligne + // dans le chainage des aretes de la frontiere! + } + if( ierr != 0 ) goto ERREUR; + + aremin = sqrt( aremin ); //longueur minimale d'une arete des lignes fermees + aremax = sqrt( aremax ); //longueur maximale d'une arete + + aretmx = Min( aretmx, aremax ); //pour homogeneiser + cout << "nutysu=" << nutysu << " aretmx=" << aretmx + << " arete min=" << aremin << " arete max=" << aremax << endl; + + //chainage des aretes frontalieres : la derniere arete frontaliere + mnsoar[ mosoar * noar - mosoar + 5 ] = 0; + + //tous les sommets et aretes frontaliers sont numerotes de 1 a nbarfr + //reservation du tableau des numeros des 3 aretes de chaque triangle + //mnartr( moartr, mxartr ) + //En nombre: Triangles = Aretes Internes + Aretes Frontalieres - Sommets + 1-Trous + // 3Triangles = 2 Aretes internes + Aretes frontalieres + // d'ou 3T/2 < AI + AF => T < 3T/2 - Sommets + 1-Trous + //nombre de triangles < 2 ( nombre de sommets - 1 + nombre de trous ) + if( mnartr!=NULL ) delete [] mnartr; + mxartr = 2 * ( mxsomm + mxtrou ); + mnartr = new Z[moartr*mxartr]; + if( mnartr==NULL ) goto ERREUR; + + //Ajout des points internes + ns1 = nudslf[ nblf ]; + for (i=0; i redepart avec 2 fois plus de sommets + mxsomm = 2 * mxsomm; + ierr = 0; + goto NEWDEPART; + } + else + { + MESSAGE( "Triangulation non realisee " << ierr ); + if( ierr == 0 ) ierr=1; + goto NETTOYAGE; + } +} + + +void qualitetrte( R3 *mnpxyd, + Z & mosoar, Z & mxsoar, Z *mnsoar, + Z & moartr, Z & mxartr, Z *mnartr, + Z & nbtria, R & quamoy, R & quamin ) +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// but : calculer la qualite moyenne et minimale de la triangulation +// ----- actuelle definie par les tableaux mnsoar et mnartr +// entrees: +// -------- +// mnpxyd : tableau des coordonnees 2d des points +// par point : x y distance_souhaitee +// mosoar : nombre maximal d'entiers par arete et +// indice dans mnsoar de l'arete suivante dans le hachage +// mxsoar : nombre maximal d'aretes stockables dans le tableau mnsoar +// attention: mxsoar>3*mxsomm obligatoire! +// mnsoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +// chainage des aretes frontalieres, chainage du hachage des aretes +// hachage des aretes = mnsoar(1)+mnsoar(2)*2 +// avec mxsoar>=3*mxsomm +// une arete i de mnsoar est vide <=> mnsoar(1,i)=0 et +// mnsoar(2,arete vide)=l'arete vide qui precede +// mnsoar(3,arete vide)=l'arete vide qui suit +// moartr : nombre maximal d'entiers par arete du tableau mnartr +// mxartr : nombre maximal de triangles declarables +// mnartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +// arete1 = 0 si triangle vide => arete2 = triangle vide suivant +// sorties: +// -------- +// nbtria : nombre de triangles internes au domaine +// quamoy : qualite moyenne des triangles actuels +// quamin : qualite minimale des triangles actuels +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +{ + R d, aire, qualite; + Z nosotr[3], mn, nbtrianeg, nt; + + aire = 0; + quamoy = 0; + quamin = 2.0; + nbtria = 0; + nbtrianeg = 0; + + mn = -moartr; + for ( nt=1; nt<=mxartr; nt++ ) + { + mn += moartr; + if( mnartr[mn]!=0 ) + { + //un triangle occupe de plus + nbtria++; + + //le numero des 3 sommets du triangle nt + nusotr_( nt, mosoar, mnsoar, moartr, mnartr, nosotr ); + + //la qualite du triangle ns1 ns2 ns3 + qutr2d_( mnpxyd[nosotr[0]-1], mnpxyd[nosotr[1]-1], mnpxyd[nosotr[2]-1], + qualite ); + + //la qualite moyenne + quamoy += qualite; + + //la qualite minimale + quamin = Min( quamin, qualite ); + + //aire signee du triangle nt + d = surtd2_( mnpxyd[nosotr[0]-1], mnpxyd[nosotr[1]-1], mnpxyd[nosotr[2]-1] ); + if( d<0 ) + { + //un triangle d'aire negative de plus + nbtrianeg++; + cout << "ATTENTION: le triangle " << nt << " de sommets:" + << nosotr[0] << " " << nosotr[1] << " " << nosotr[2] + << " a une aire " << d <<"<=0" << endl; + } + + //aire des triangles actuels + aire += Abs(d); + } + } + + //les affichages + quamoy /= nbtria; + cout << "Qualite moyenne=" << quamoy + << " Qualite minimale=" << quamin + << " des " << nbtria << " triangles de surface totale=" + << aire << endl; + + if( nbtrianeg>0 ) + MESSAGE( "ATTENTION: nombre de triangles d'aire negative=" << nbtrianeg ); + return; +} diff --git a/src/MEFISTO2/aptrte.h b/src/MEFISTO2/aptrte.h new file mode 100755 index 000000000..9e57131dd --- /dev/null +++ b/src/MEFISTO2/aptrte.h @@ -0,0 +1,229 @@ +#ifndef aptrte__h +#define aptrte__h + +#include // limites min max int long real ... +#include // gethostname, ... +#include +#include // pour cout cin ... +#include // pour le format des io setw, stx, setfill, ... +#include // pour les fonctions sur les chaines de caracteres +#include +#include +#include // pour les fonctions mathematiques +#include + +#include +#include + +void qualitetrte( R3 *mnpxyd, + Z & mosoar, Z & mxsoar, Z *mnsoar, + Z & moartr, Z & mxartr, Z *mnartr, + Z & nbtria, R & quamoy, R & quamin ); +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// but : calculer la qualite moyenne et minimale de la triangulation +// ----- actuelle definie par les tableaux nosoar et noartr +// entrees: +// -------- +// mnpxyd : tableau des coordonnees 2d des points +// par point : x y distance_souhaitee +// mosoar : nombre maximal d'entiers par arete et +// indice dans nosoar de l'arete suivante dans le hachage +// mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +// attention: mxsoar>3*mxsomm obligatoire! +// nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +// chainage des aretes frontalieres, chainage du hachage des aretes +// hachage des aretes = nosoar(1)+nosoar(2)*2 +// avec mxsoar>=3*mxsomm +// une arete i de nosoar est vide <=> nosoar(1,i)=0 et +// nosoar(2,arete vide)=l'arete vide qui precede +// nosoar(3,arete vide)=l'arete vide qui suit +// moartr : nombre maximal d'entiers par arete du tableau noartr +// mxartr : nombre maximal de triangles declarables +// noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +// arete1 = 0 si triangle vide => arete2 = triangle vide suivant +// sorties: +// -------- +// nbtria : nombre de triangles internes au domaine +// quamoy : qualite moyenne des triangles actuels +// quamin : qualite minimale des triangles actuels +// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + +void aptrte( Z nutysu, R aretmx, + Z nblf, Z *nudslf, R2 *uvslf, + Z nbpti, R2 *uvpti, + Z & nbst, R2 * & uvst, Z & nbt, Z * & nust, + Z & ierr ); +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// but : appel de la triangulation par un arbre-4 recouvrant +// ----- de triangles equilateraux +// le contour du domaine plan est defini par des lignes fermees +// la premiere ligne etant l'enveloppe de toutes les autres +// la fonction areteideale_(s,d) donne la taille d'arete +// au point s dans la direction d (direction inactive pour l'instant) +// des lors toute arete issue d'un sommet s devrait avoir une longueur +// comprise entre 0.65 areteideale_(s,d) et 1.3 areteideale_(s,d) +// +//Attention: +// Les tableaux uvslf et uvpti sont supposes ne pas avoir de sommets identiques! +// De meme, un sommet d'une ligne fermee ne peut appartenir a une autre ligne fermee +// +// entrees: +// -------- +// nutysu : numero de traitement de areteideale_() selon le type de surface +// 0 pas d'emploi de la fonction areteideale_() et aretmx est active +// 1 il existe une fonction areteideale_(s,d) +// dont seules les 2 premieres composantes de uv sont actives +// ... autres options a definir ... +// aretmx : longueur maximale des aretes de la future triangulation +// nblf : nombre de lignes fermees de la surface +// nudslf : numero du dernier sommet de chacune des nblf lignes fermees +// nudslf(0)=0 pour permettre la difference sans test +// Attention le dernier sommet de chaque ligne est raccorde au premier +// tous les sommets et les points internes ont des coordonnees +// UV differentes <=> Pas de point double! +// uvslf : uv des nudslf(nblf) sommets des lignes fermees +// nbpti : nombre de points internes futurs sommets de la triangulation +// uvpti : uv des points internes futurs sommets de la triangulation +// +// sorties: +// -------- +// nbst : nombre de sommets de la triangulation finale +// uvst : coordonnees uv des nbst sommets de la triangulation +// nbt : nombre de triangles de la triangulation finale +// nust : 3 numeros dans uvst des sommets des nbt triangles +// ierr : 0 si pas d'erreur +// > 0 sinon +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// auteur : Alain Perronnet Analyse Numerique Paris UPMC decembre 2001 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +extern "C" { void tempscpu_( double & tempsec ); } +//Retourne le temps CPU utilise en secondes + +extern "C" { void deltacpu_( R & dtcpu ); } +//Retourne le temps CPU utilise en secondes depuis le precedent appel + +//initialiser le tableau mnsoar pour le hachage des aretes +extern "C" {void insoar_( Z & mxsomm, Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar );} + +//mettre a zero les nb entiers de tab +extern "C" {void azeroi_( Z & nb, Z * tab );} + +extern "C" {void fasoar_( Z & ns1, Z & ns2, Z & nt1, Z & nt2, Z & nolign, + Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, Z * mnarst, + Z & noar, Z & ierr );} +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +// but : former l'arete de sommet ns1-ns2 dans le hachage du tableau +// ----- nosoar des aretes de la triangulation +// entrees: +// -------- +// ns1 ns2: numero pxyd des 2 sommets de l'arete +// nt1 : numero du triangle auquel appartient l'arete +// nt1=-1 si numero inconnu +// nt2 : numero de l'eventuel second triangle de l'arete si connu +// nt2=-1 si numero inconnu +// nolign : numero de la ligne fermee de l'arete +// =0 si l'arete n'est une arete de ligne +// ce numero est ajoute seulement si l'arete est creee +// mosoar : nombre maximal d'entiers par arete du tableau nosoar +// mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +// modifies: +// --------- +// n1soar : numero de la premiere arete vide dans le tableau nosoar +// une arete i de nosoar est vide <=> nosoar(1,i)=0 +// chainage des aretes vides amont et aval +// l'arete vide qui precede=nosoar(4,i) +// l'arete vide qui suit =nosoar(5,i) +// nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, +// chainage momentan'e d'aretes, chainage du hachage des aretes +// hachage des aretes = min( nosoar(1), nosoar(2) ) +// noarst : noarst(np) numero d'une arete du sommet np + +// ierr : si < 0 en entree pas d'affichage en cas d'erreur du type +// "arete appartenant a plus de 2 triangles et a creer!" +// si >=0 en entree affichage de ce type d'erreur +// sorties: +// -------- +// noar : >0 numero de l'arete retrouvee ou ajoutee +// ierr : =0 si pas d'erreur +// =1 si le tableau nosoar est sature +// =2 si arete a creer et appartenant a 2 triangles distincts +// des triangles nt1 et nt2 +// =3 si arete appartenant a 2 triangles distincts +// differents des triangles nt1 et nt2 +// =4 si arete appartenant a 2 triangles distincts +// dont le second n'est pas le triangle nt2 +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +//initialisation du tableau letree et ajout dans letree des sommets 1 a nbsomm +extern "C" {void teajte_( Z & mxsomm, Z & nbsomm, R3 * mnpxyd, R3 * comxmi, + R & aretmx, Z & mxtree, Z * letree, + Z & ierr );} + + +extern "C" {void tehote_( Z & nutysu, Z & nbarpi, Z & mxsomm, Z & nbsomm, R3 * mnpxyd, + R3 * comxmi, R & aretmx, + Z * letree, Z & mxqueu, Z * mnqueu, + Z & ierr );} +// homogeneisation de l'arbre des te a un saut de taille au plus +// prise en compte des tailles d'aretes souhaitees autour des sommets initiaux + +extern "C" {void tetrte_( R3 * comxmi, R & aretmx, Z & nbarpi, Z & mxsomm, R3 * mnpxyd, + Z & mxqueu, Z * mnqueu, Z * mntree, + Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, + Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z * mnarst, + Z & ierr );} +// trianguler les triangles equilateraux feuilles a partir de leurs 3 sommets +// et des points de la frontiere, des points internes imposes interieurs + +extern "C" {void aisoar_( Z & mosoar, Z & mxsoar, Z * mnsoar, Z & na );} + // formation du chainage 6 des aretes internes a echanger eventuellement + +extern "C" {void tedela_( R3 * mnpxyd, Z * mnarst, + Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, Z & na, + Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z & n );} + // boucle sur les aretes internes (non sur une ligne de la frontiere) + // avec echange des 2 diagonales afin de rendre la triangulation delaunay + +extern "C" {void terefr_( Z & nbarpi, R3 * mnpxyd, + Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, + Z & moartr, Z & n1artr, Z * mnartr, Z * mnarst, + Z & mxarcf, Z * mnarc1, Z * mnarc2, + Z * mnarc3, Z * mnarc4, + Z & n, Z & ierr );} +// detection des aretes frontalieres initiales perdues +// triangulation frontale pour les restaurer + +extern "C" {void tesuex_( Z & nblf, Z * nulftr, + Z & ndtri0, Z & nbsomm, R3 * mnpxyd, Z * mnslig, + Z & mosoar, Z & mxsoar, Z * mnsoar, + Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, Z * mnarst, + Z & nbtria, Z * mntrsu, Z & ierr );} +// suppression des triangles externes a la surface + +extern "C" {void teamqt_( Z & nutysu, + Z * mnarst, Z & mosoar, Z & mxsoar, Z & n1soar, Z * mnsoar, + Z & moartr, Z & mxartr, Z & n1artr, Z * mnartr, + Z & mxarcf, Z * mntrcf, Z * mnstbo, + Z * n1arcf, Z * mnarcf, Z * mnarc1, + R3 * comxmi, Z & nbarpi, Z & nbsomm, Z & mxsomm, + R3 * mnpxyd, Z * mnslig, + Z & ierr );} +// amelioration de la qualite de la triangulation par +// barycentrage des sommets internes a la triangulation +// suppression des aretes trop longues ou trop courtes +// modification de la topologie des groupes de triangles +// mise en delaunay de la triangulation + +extern "C" {void nusotr_( Z & nt, Z & mosoar, Z * mnsoar, Z & moartr, Z * mnartr, + Z * nosotr );} +//retrouver les numero des 3 sommets du triangle nt + +extern "C" {void qutr2d_( R3 & p1, R3 & p2, R3 & p3, R & qualite );} +//calculer la qualite d'un triangle de R2 de sommets p1, p2, p3 + +extern "C" { R surtd2_( R3 & p1, R3 & p2, R3 & p3 ); } +//calcul de la surface d'un triangle defini par 3 points de r**2 + +#endif diff --git a/src/MEFISTO2/areteideale.f b/src/MEFISTO2/areteideale.f new file mode 100755 index 000000000..cabc8d442 --- /dev/null +++ b/src/MEFISTO2/areteideale.f @@ -0,0 +1,5 @@ + double precision function areteideale( xyz, direction ) + double precision xyz(3), direction(3) + areteideale = 10 + return + end diff --git a/src/MEFISTO2/trte.f b/src/MEFISTO2/trte.f new file mode 100755 index 000000000..f66104e34 --- /dev/null +++ b/src/MEFISTO2/trte.f @@ -0,0 +1,8319 @@ + subroutine qutr2d( p1, p2, p3, qualite ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer la qualite d'un triangle de r**2 +c ----- 2 coordonnees des 3 sommets en double precision +c +c entrees : +c --------- +c p1,p2,p3 : les 3 coordonnees des 3 sommets du triangle +c sens direct pour une surface et qualite >0 +c sorties : +c --------- +c qualite: valeur de la qualite du triangle entre 0 et 1 (equilateral) +c 1 etant la qualite optimale +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique upmc paris janvier 1995 +c2345x7..............................................................012 + parameter ( d2uxr3 = 3.4641016151377544d0 ) +c d2uxr3 = 2 * sqrt(3) + double precision p1(2), p2(2), p3(2), qualite, a, b, c, p +c +c la longueur des 3 cotes + a = sqrt( (p2(1)-p1(1))**2 + (p2(2)-p1(2))**2 ) + b = sqrt( (p3(1)-p2(1))**2 + (p3(2)-p2(2))**2 ) + c = sqrt( (p1(1)-p3(1))**2 + (p1(2)-p3(2))**2 ) +c +c demi perimetre + p = (a+b+c) * 0.5d0 +c + if ( (a*b*c) .ne. 0d0 ) then +c critere : 2 racine(3) * rayon_inscrit / plus longue arete + qualite = d2uxr3 * sqrt( abs( (p-a) / p * (p-b) * (p-c) ) ) + % / max(a,b,c) + else + qualite = 0d0 + endif +c +c +c autres criteres possibles: +c critere : 2 * rayon_inscrit / rayon_circonscrit +c qualite = 8d0 * (p-a) * (p-b) * (p-c) / (a * b * c) +c +c critere : 3*sqrt(3.) * ray_inscrit / demi perimetre +c qualite = 3*sqrt(3.) * sqrt ((p-a)*(p-b)*(p-c) / p**3) +c +c critere : 2*sqrt(3.) * ray_inscrit / max( des aretes ) +c qualite = 2*sqrt(3.) * sqrt( (p-a)*(p-b)*(p-c) / p ) / max(a,b,c) + end + + + double precision function surtd2( p1 , p2 , p3 ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul de la surface d'un triangle defini par 3 points de R**2 +c ----- +c parametres d entree : +c --------------------- +c p1 p2 p3 : les 3 fois 2 coordonnees des sommets du triangle +c +c parametre resultat : +c -------------------- +c surtd2 : surface du triangle +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique upmc paris fevrier 1992 +c2345x7..............................................................012 + double precision p1(2), p2(2), p3(2) +c +c la surface du triangle + surtd2 = ( ( p2(1)-p1(1) ) * ( p3(2)-p1(2) ) + % - ( p2(2)-p1(2) ) * ( p3(1)-p1(1) ) ) * 0.5d0 + end + + integer function nopre3( i ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : numero precedent i dans le sens circulaire 1 2 3 1 ... +c ----- +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + if( i .eq. 1 ) then + nopre3 = 3 + else + nopre3 = i - 1 + endif + end + + integer function nosui3( i ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : numero suivant i dans le sens circulaire 1 2 3 1 ... +c ----- +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + if( i .eq. 3 ) then + nosui3 = 1 + else + nosui3 = i + 1 + endif + end + + subroutine provec( v1 , v2 , v3 ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : v3 vecteur = produit vectoriel de 2 vecteurs de r ** 3 +c ----- +c entrees: +c -------- +c v1, v2 : les 2 vecteurs de 3 composantes +c +c sortie : +c -------- +c v3 : vecteur = v1 produit vectoriel v2 +cc++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : perronnet alain upmc analyse numerique paris mars 1987 +c2345x7..............................................................012 + double precision v1(3), v2(3), v3(3) +c + v3( 1 ) = v1( 2 ) * v2( 3 ) - v1( 3 ) * v2( 2 ) + v3( 2 ) = v1( 3 ) * v2( 1 ) - v1( 1 ) * v2( 3 ) + v3( 3 ) = v1( 1 ) * v2( 2 ) - v1( 2 ) * v2( 1 ) +c + return + end + + subroutine norme1( n, v, ierr ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : normalisation euclidienne a 1 d un vecteur v de n composantes +c ----- +c entrees : +c --------- +c n : nombre de composantes du vecteur +c +c modifie : +c --------- +c v : le vecteur a normaliser a 1 +c +c sortie : +c --------- +c ierr : 1 si la norme de v est egale a 0 +c 0 si pas d'erreur +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris mars 1987 +c ...................................................................... + double precision v( n ), s, sqrt +c + s = 0.0d0 + do 10 i=1,n + s = s + v( i ) * v( i ) + 10 continue +c +c test de nullite de la norme du vecteur +c -------------------------------------- + if( s .le. 0.0d0 ) then +c norme nulle du vecteur non normalisable a 1 + ierr = 1 + return + endif +c + s = 1.0d0 / sqrt( s ) + do 20 i=1,n + v( i ) = v ( i ) * s + 20 continue +c + ierr = 0 + end + + + subroutine insoar( mxsomm, mosoar, mxsoar, n1soar, nosoar ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : initialiser le tableau nosoar pour le hachage des aretes +c ----- +c +c entrees: +c -------- +c mxsomm : plus grand numero de sommet d'une arete au cours du calcul +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c avec mxsoar>=3*mxsomm +c +c sorties: +c -------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c chainage des aretes vides amont et aval +c l'arete vide qui precede=nosoar(4,i) +c l'arete vide qui suit =nosoar(5,i) +c nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, +c chainage momentan'e d'aretes, chainage du hachage des aretes +c hachage des aretes = min( nosoar(1), nosoar(2) ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + integer nosoar(mosoar,mxsoar) +c +c initialisation des aretes 1 a mxsomm + do 10 i=1,mxsomm +c +c sommet 1 = 0 <=> temoin d'arete vide pour le hachage + nosoar( 1, i ) = 0 +c +c arete sur aucune ligne + nosoar( 3, i ) = 0 +c +c la position de l'arete interne ou frontaliere est inconnue + nosoar( 6, i ) = -2 +c +c fin de chainage du hachage pas d'arete suivante + nosoar( mosoar, i ) = 0 +c + 10 continue +c +c la premiere arete vide chainee est la mxsomm+1 du tableau +c car ces aretes ne sont pas atteignables par le hachage direct + n1soar = mxsomm + 1 +c +c initialisation des aretes vides et des chainages + do 20 i = n1soar, mxsoar +c +c sommet 1 = 0 <=> temoin d'arete vide pour le hachage + nosoar( 1, i ) = 0 +c +c arete sur aucune ligne + nosoar( 3, i ) = 0 +c +c chainage sur l'arete vide qui precede +c (si arete occupee cela deviendra le no du triangle 1 de l'arete) + nosoar( 4, i ) = i-1 +c +c chainage sur l'arete vide qui suit +c (si arete occupee cela deviendra le no du triangle 2 de l'arete) + nosoar( 5, i ) = i+1 +c +c chainages des aretes frontalieres ou internes ou ... + nosoar( 6, i ) = -2 +c +c fin de chainage du hachage + nosoar( mosoar, i ) = 0 +c + 20 continue +c +c la premiere arete vide n'a pas de precedent + nosoar( 4, n1soar ) = 0 +c +c la derniere arete vide est mxsoar sans arete vide suivante + nosoar( 5, mxsoar ) = 0 + end + + + subroutine azeroi ( l , ntab ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : initialisation a zero d un tableau ntab de l variables entieres +c ----- +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique upmc paris septembre 1988 +c23456---------------------------------------------------------------012 + integer ntab(l) + do 1 i = 1 , l + ntab( i ) = 0 + 1 continue + end + + + subroutine fasoar( ns1, ns2, nt1, nt2, nolign, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former l'arete de sommet ns1-ns2 dans le hachage du tableau +c ----- nosoar des aretes de la triangulation +c +c entrees: +c -------- +c ns1 ns2: numero pxyd des 2 sommets de l'arete +c nt1 : numero du triangle auquel appartient l'arete +c nt1=-1 si numero inconnu +c nt2 : numero de l'eventuel second triangle de l'arete si connu +c nt2=-1 si numero inconnu +c nolign : numero de la ligne de l'arete dans ladefi(wulftr-1+nolign) +c =0 si l'arete n'est une arete de ligne +c ce numero est ajoute seulement si l'arete est creee +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c chainage des aretes vides amont et aval +c l'arete vide qui precede=nosoar(4,i) +c l'arete vide qui suit =nosoar(5,i) +c nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, +c chainage momentan'e d'aretes, chainage du hachage des aretes +c hachage des aretes = min( nosoar(1), nosoar(2) ) +c noarst : noarst(np) numero d'une arete du sommet np +c +c ierr : si < 0 en entree pas d'affichage en cas d'erreur du type +c "arete appartenant a plus de 2 triangles et a creer!" +c si >=0 en entree affichage de ce type d'erreur +c +c sorties: +c -------- +c noar : >0 numero de l'arete retrouvee ou ajoutee +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si arete a creer et appartenant a 2 triangles distincts +c des triangles nt1 et nt2 +c =3 si arete appartenant a 2 triangles distincts +c differents des triangles nt1 et nt2 +c =4 si arete appartenant a 2 triangles distincts +c dont le second n'est pas le triangle nt2 +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) + integer nosoar(mosoar,mxsoar), noarst(*) + integer nu2sar(2) +c +c ajout eventuel de l'arete s1 s2 dans nosoar + nu2sar(1) = ns1 + nu2sar(2) = ns2 +c +c hachage de l'arete de sommets nu2sar + call hasoar( mosoar, mxsoar, n1soar, nosoar, nu2sar, noar ) +c en sortie: noar>0 => no arete retrouvee +c <0 => no arete ajoutee +c =0 => saturation du tableau nosoar +c + if( noar .eq. 0 ) then +c +c saturation du tableau nosoar + write(imprim,*) 'fasoar: tableau nosoar sature' + ierr = 1 + return +c + else if( noar .lt. 0 ) then +c +c l'arete a ete ajoutee. initialisation des autres informations + noar = -noar +c le numero de la ligne de l'arete + nosoar(3,noar) = nolign +c le triangle 1 de l'arete => le triangle nt1 + nosoar(4,noar) = nt1 +c le triangle 2 de l'arete => le triangle nt2 + nosoar(5,noar) = nt2 +c +c le sommet appartient a l'arete noar + noarst( nu2sar(1) ) = noar + noarst( nu2sar(2) ) = noar +c + else +c +c l'arete a ete retrouvee. +c si elle appartient a 2 triangles differents de nt1 et nt2 +c alors il y a une erreur + if( nosoar(4,noar) .gt. 0 .and. + % nosoar(5,noar) .gt. 0 ) then + if( nosoar(4,noar) .ne. nt1 .and. + % nosoar(4,noar) .ne. nt2 .or. + % nosoar(5,noar) .ne. nt1 .and. + % nosoar(5,noar) .ne. nt2 ) then +c arete appartenant a plus de 2 triangles => erreur + if( ierr .ge. 0 ) then + write(imprim,*) 'erreur fasoar: arete ',noar, + % ' dans 2 triangles et a creer!' + endif + ierr = 2 + return + endif + endif +c +c mise a jour du numero des triangles de l'arete noar +c le triangle 2 de l'arete => le triangle nt1 + if( nosoar(4,noar) .lt. 0 ) then +c pas de triangle connu pour cette arete + n = 4 + else +c deja un triangle connu. ce nouveau est le second + if( nosoar(5,noar) .gt. 0 .and. nt1 .gt. 0 .and. + % nosoar(5,noar) .ne. nt1 ) then +c arete appartenant a plus de 2 triangles => erreur + write(imprim,*) 'erreur fasoar: arete ',noar, + % ' dans plus de 2 triangles' + ierr = 3 + return + endif + n = 5 + endif + nosoar(n,noar) = nt1 +c +c cas de l'arete frontaliere retrouvee comme diagonale d'un quadrangle + if( nt2 .gt. 0 ) then +c l'arete appartient a 2 triangles + if( nosoar(5,noar) .gt. 0 .and. + % nosoar(5,noar) .ne. nt2 ) then +c arete appartenant a plus de 2 triangles => erreur + write(imprim,*) 'erreur fasoar: arete ',noar, + % ' dans plus de 2 triangles' + ierr = 4 + return + endif + nosoar(5,noar) = nt2 + endif +c + endif +c +c pas d'erreur + ierr = 0 + end + + subroutine fq1inv( x, y, s, xc, yc, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul des 2 coordonnees (xc,yc) dans le carre (0,1) +c ----- image par f:carre unite-->quadrangle appartenant a q1**2 +c par une resolution directe due a nicolas thenault +c +c entrees: +c -------- +c x,y : coordonnees du point image dans le quadrangle de sommets s +c s : les 2 coordonnees des 4 sommets du quadrangle +c +c sorties: +c -------- +c xc,yc : coordonnees dans le carre dont l'image par f vaut (x,y) +c ierr : 0 si calcul sans erreur, 1 si quadrangle degenere +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteurs: thenault tulenew analyse numerique paris janvier 1998 +c modifs : perronnet alain analyse numerique paris janvier 1998 +c234567..............................................................012 + real s(1:2,1:4), dist(2) + double precision a,b,c,d,alpha,beta,gamma,delta,x0,y0,t(2),u,v,w +c + a = s(1,1) + b = s(1,2) - s(1,1) + c = s(1,4) - s(1,1) + d = s(1,1) - s(1,2) + s(1,3) - s(1,4) +c + alpha = s(2,1) + beta = s(2,2) - s(2,1) + gamma = s(2,4) - s(2,1) + delta = s(2,1) - s(2,2) + s(2,3) - s(2,4) +c + u = beta * c - b * gamma + if( u .eq. 0 ) then +c quadrangle degenere + ierr = 1 + return + endif + v = delta * c - d * gamma + w = b * delta - beta * d +c + x0 = c * (y-alpha) - gamma * (x-a) + y0 = b * (y-alpha) - beta * (x-a) +c + a = v * w + b = u * u - w * x0 - v * y0 + c = x0 * y0 +c + if( a .ne. 0 ) then +c + delta = sqrt( b*b-4*a*c ) + if( b .ge. 0.0 ) then + t(2) = -b - delta + else + t(2) = -b + delta + endif +c la racine de plus grande valeur absolue +c (elle donne le plus souvent le point exterieur au carre unite +c donc a tester en second pour reduire les calculs) + t(2) = t(2) / ( 2 * a ) +c calcul de la seconde racine a partir de la somme => plus stable + t(1) = - b/a - t(2) +c + do 10 i=1,2 +c +c la solution i donne t elle un point interne au carre unite? + xc = ( x0 - v * t(i) ) / u + yc = ( w * t(i) - y0 ) / u + if( 0.0 .le. xc .and. xc .le. 1.0 ) then + if( 0.0 .le. yc .and. yc .le. 1.0 ) goto 9000 + endif +c +c le point (xc,yc) n'est pas dans le carre unite +c cela peut etre du aux erreurs d'arrondi +c => choix par le minimum de la distance aux bords du carre + dist(i) = max( 0.0, -xc, xc-1.0, -yc, yc-1.0 ) +c + 10 continue +c + if( dist(1) .gt. dist(2) ) then +c f(xc,yc) pour la racine 2 est plus proche de x,y +c xc yc sont deja calcules + goto 9000 + endif +c + else if ( b .ne. 0 ) then + t(1) = - c / b + else + t(1) = 0 + endif +c +c les 2 coordonnees du point dans le carre unite + xc = ( x0 - v * t(1) ) / u + yc = ( w * t(1) - y0 ) / u +c + 9000 ierr = 0 + return + end + + + subroutine ptdatr( point, pxyd, nosotr, nsigne ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : le point est il dans le triangle de sommets nosotr +c ----- +c +c entrees: +c -------- +c point : les 2 coordonnees du point +c pxyd : les 2 coordonnees et distance souhaitee des points du maillage +c nosotr : le numero des 3 sommets du triangle +c +c sorties: +c -------- +c nsigne : >0 si le point est dans le triangle ou sur une des 3 aretes +c =0 si le triangle est degenere ou indirect ou ne contient pas le poin +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + integer nosotr(3) + double precision point(2), pxyd(3,*) + double precision xp,yp, x1,x2,x3, y1,y2,y3, d,dd, cb1,cb2,cb3 +c + xp = point( 1 ) + yp = point( 2 ) +c + n1 = nosotr( 1 ) + x1 = pxyd( 1 , n1 ) + y1 = pxyd( 2 , n1 ) +c + n2 = nosotr( 2 ) + x2 = pxyd( 1 , n2 ) + y2 = pxyd( 2 , n2 ) +c + n3 = nosotr( 3 ) + x3 = pxyd( 1 , n3 ) + y3 = pxyd( 2 , n3 ) +c +c 2 fois la surface du triangle = determinant de la matrice +c de calcul des coordonnees barycentriques du point p + d = ( x2 - x1 ) * ( y3 - y1 ) - ( x3 - x1 ) * ( y2 - y1 ) +c + if( d .gt. 0 ) then +c +c triangle non degenere +c ===================== +c calcul des 3 coordonnees barycentriques du +c point xp yp dans le triangle + cb1 = ( ( x2-xp ) * ( y3-yp ) - ( x3-xp ) * ( y2-yp ) ) / d + cb2 = ( ( x3-xp ) * ( y1-yp ) - ( x1-xp ) * ( y3-yp ) ) / d + cb3 = 1d0 - cb1 -cb2 +ccc cb3 = ( ( x1-xp ) * ( y2-yp ) - ( x2-xp ) * ( y1-yp ) ) / d +c +ccc if( cb1 .ge. -0.00005d0 .and. cb1 .le. 1.00005d0 .and. + if( cb1 .ge. 0d0 .and. cb1 .le. 1d0 .and. + % cb2 .ge. 0d0 .and. cb2 .le. 1d0 .and. + % cb3 .ge. 0d0 .and. cb3 .le. 1d0 ) then +c +c le triangle nosotr contient le point + nsigne = 1 + else + nsigne = 0 + endif +c + else +c +c triangle degenere +c ================= +c le point est il du meme cote que le sommet oppose de chaque arete? + nsigne = 0 + do 10 i=1,3 +c le sinus de l'angle p1 p2-p1 point + x1 = pxyd(1,n1) + y1 = pxyd(2,n1) + d = ( pxyd(1,n2) - x1 ) * ( point(2) - y1 ) + % - ( pxyd(2,n2) - y1 ) * ( point(1) - x1 ) + dd = ( pxyd(1,n2) - x1 ) * ( pxyd(2,n3) - y1 ) + % - ( pxyd(2,n2) - y1 ) * ( pxyd(1,n3) - x1 ) + cb1 = ( pxyd(1,n2) - x1 ) ** 2 + % + ( pxyd(2,n2) - y1 ) ** 2 + cb2 = ( point(1) - x1 ) ** 2 + % + ( point(2) - y1 ) ** 2 + cb3 = ( pxyd(1,n3) - x1 ) ** 2 + % + ( pxyd(2,n3) - y1 ) ** 2 + if( abs( dd ) .le. 1e-4 * sqrt( cb1 * cb3 ) ) then +c le point 3 est sur l'arete 1-2 +c le point doit y etre aussi + if( abs( d ) .le. 1e-4 * sqrt( cb1 * cb2 ) ) then +c point sur l'arete + nsigne = nsigne + 1 + endif + else +c le point 3 n'est pas sur l'arete . test des signes + if( d * dd .ge. 0 ) then + nsigne = nsigne + 1 + endif + endif +c permutation circulaire des 3 sommets et aretes + n = n1 + n1 = n2 + n2 = n3 + n3 = n + 10 continue + if( nsigne .ne. 3 ) nsigne = 0 + endif + end + + integer function nosstr( p, pxyd, nt, letree ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer le numero 0 a 3 du sous-triangle te contenant +c ----- le point p +c +c entrees: +c -------- +c p : point de r**2 contenu dans le te nt de letree +c pxyd : x y distance des points +c nt : numero letree du te de te voisin a calculer +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 …a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c sorties : +c --------- +c nosstr : 0 si le sous-triangle central contient p +c i =1,2,3 numero du sous-triangle contenant p +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + integer letree(0:8,0:*) + double precision pxyd(3,*), p(2), + % x1, y1, x21, y21, x31, y31, d, xe, ye +c +c le numero des 3 sommets du triangle + ns1 = letree( 6, nt ) + ns2 = letree( 7, nt ) + ns3 = letree( 8, nt ) +c +c les coordonnees entre 0 et 1 du point p + x1 = pxyd(1,ns1) + y1 = pxyd(2,ns1) +c + x21 = pxyd(1,ns2) - x1 + y21 = pxyd(2,ns2) - y1 +c + x31 = pxyd(1,ns3) - x1 + y31 = pxyd(2,ns3) - y1 +c + d = 1.0 / ( x21 * y31 - x31 * y21 ) +c + xe = ( ( p(1) - x1 ) * y31 - ( p(2) - y1 ) * x31 ) * d + ye = ( ( p(2) - y1 ) * x21 - ( p(1) - x1 ) * y21 ) * d +c + if( xe .gt. 0.5d0 ) then +c sous-triangle droit + nosstr = 2 + else if( ye .gt. 0.5d0 ) then +c sous-triangle haut + nosstr = 3 + else if( xe+ye .lt. 0.5d0 ) then +c sous-triangle gauche + nosstr = 1 + else +c sous-triangle central + nosstr = 0 + endif + end + + + integer function notrpt( p, pxyd, notrde, letree ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer le numero letree du sous-triangle feuille contenant +c ----- le point p a partir du te notrde de letree +c +c entrees: +c -------- +c p : point de r**2 contenu dans le te nt de letree +c pxyd : x y distance des points +c notrde : numero letree du triangle depart de recherche (1=>racine) +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 … 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c sorties : +c --------- +c notrpt : numero letree du triangle contenant le point p +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + integer letree(0:8,0:*) + double precision pxyd(1:3,*), p(2) +c +c la racine depart de la recherche + notrpt = notrde +c +c tant que la feuille n'est pas atteinte descendre l'arbre + 10 if( letree(0,notrpt) .gt. 0 ) then +c +c recherche du sous-triangle contenant p + nsot = nosstr( p, pxyd, notrpt, letree ) +c +c le numero letree du sous-triangle + notrpt = letree( nsot, notrpt ) + goto 10 +c + endif + end + + + subroutine teajpt( ns, nbsomm, mxsomm, pxyd, letree, + & ntrp, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : ajout du point ns de pxyd dans letree +c ----- +c +c entrees: +c -------- +c ns : numero du point a ajouter dans letree +c mxsomm : nombre maximal de points declarables dans pxyd +c pxyd : tableau des coordonnees des points +c par point : x y distance_souhaitee +c +c modifies : +c ---------- +c nbsomm : nombre actuel de points dans pxyd +c +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) : no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 …a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c sorties : +c --------- +c ntrp : numero letree du triangle te ou a ete ajoute le point +c ierr : 0 si pas d'erreur, 51 saturation letree, 52 saturation pxyd +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + integer letree(0:8,0:*) + double precision pxyd(3,mxsomm) +c +c depart de la racine + ntrp = 1 +c +c recherche du triangle contenant le point pxyd(ns) + 1 ntrp = notrpt( pxyd(1,ns), pxyd, ntrp, letree ) +c +c existe t il un point libre + do 10 i=0,3 + if( letree(i,ntrp) .eq. 0 ) then +c la place i est libre + letree(i,ntrp) = -ns + return + endif + 10 continue +c +c pas de place libre => 4 sous-triangles sont crees +c a partir des 3 milieux des aretes + call te4ste( nbsomm, mxsomm, pxyd, ntrp, letree, ierr ) + if( ierr .ne. 0 ) return +c +c ajout du point ns + goto 1 + end + + subroutine n1trva( nt, lar, letree, notrva, lhpile ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer le numero letree du triangle voisin du te nt +c ----- par l'arete lar (1 a 3 ) de nt +c attention : notrva n'est pas forcement minimal +c +c entrees: +c -------- +c nt : numero letree du te de te voisin a calculer +c lar : numero 1 a 3 de l'arete du triangle nt +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur-triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c sorties : +c --------- +c notrva : >0 numero letree du te voisin par l'arete lar +c =0 si pas de te voisin (racine , ... ) +c lhpile : =0 si nt et notrva ont meme taille +c >0 nt est 4**lhpile fois plus petit que notrva +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + integer letree(0:8,0:*) + integer lapile(1:64) +c +c initialisation de la pile +c le triangle est empile + lapile(1) = nt + lhpile = 1 +c +c tant qu'il existe un sur-triangle + 10 ntr = lapile( lhpile ) + if( ntr .eq. 1 ) then +c racine atteinte => pas de triangle voisin + notrva = 0 + lhpile = lhpile - 1 + return + endif +c +c le type du triangle ntr + nty = letree( 5, ntr ) +c l'eventuel sur-triangle + nsut = letree( 4, ntr ) +c + if( nty .eq. 0 ) then +c +c triangle de type 0 => triangle voisin de type precedent(lar) +c dans le sur-triangle de ntr +c ce triangle remplace ntr dans lapile + lapile( lhpile ) = letree( nopre3(lar), nsut ) + goto 20 + endif +c +c triangle ntr de type nty>0 + if( nosui3(nty) .eq. lar ) then +c +c le triangle voisin par lar est le triangle 0 + lapile( lhpile ) = letree( 0, nsut ) + goto 20 + endif +c +c triangle sans voisin direct => passage par le sur-triangle + if( nsut .eq. 0 ) then +c +c ntr est la racine => pas de triangle voisin par cette arete + notrva = 0 + return + else +c +c le sur-triangle est empile + lhpile = lhpile + 1 + lapile(lhpile) = nsut + goto 10 + endif +c +c descente aux sous-triangles selon la meme arete + 20 notrva = lapile( lhpile ) +c + 30 lhpile = lhpile - 1 + if( letree(0,notrva) .le. 0 ) then +c le triangle est une feuille de l'arbre 0 sous-triangle +c lhpile = nombre de differences de niveaux dans l'arbre + return + else +c le triangle a 4 sous-triangles + if( lhpile .gt. 0 ) then +c +c bas de pile non atteint + nty = letree( 5, lapile(lhpile) ) + if( nty .eq. lar ) then +c l'oppose est suivant(nty) de notrva + notrva = letree( nosui3(nty) , notrva ) + else +c l'oppose est precedent(nty) de notrva + notrva = letree( nopre3(nty) , notrva ) + endif + goto 30 + endif + endif +c +c meme niveau dans l'arbre lhpile = 0 + end + + + subroutine cenced( xy1, xy2, xy3, cetria, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul des coordonnees du centre du cercle circonscrit +c ----- du triangle defini par ses 3 sommets de coordonnees +c xy1 xy2 xy3 ainsi que le carre du rayon de ce cercle +c +c entrees : +c --------- +c xy1 xy2 xy3 : les 2 coordonnees des 3 sommets du triangle +c ierr : <0 => pas d'affichage si triangle degenere +c >=0 => affichage si triangle degenere +c +c sortie : +c -------- +c cetria : cetria(1)=abcisse du centre +c cetria(2)=ordonnee du centre +c cetria(3)=carre du rayon 1d28 si triangle degenere +c ierr : 0 si triangle non degenere +c 1 si triangle degenere +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : perronnet alain upmc analyse numerique paris juin 1995 +c2345x7..............................................................012 + parameter (epsurf=1d-7) + common / unites / lecteu,imprim,nunite(30) + double precision x1,y1,x21,y21,x31,y31, + % aire2,xc,yc,rot, + % xy1(2),xy2(2),xy3(2),cetria(3) +c +c le calcul de 2 fois l'aire du triangle +c attention l'ordre des 3 sommets est direct ou non + x1 = xy1(1) + x21 = xy2(1) - x1 + x31 = xy3(1) - x1 +c + y1 = xy1(2) + y21 = xy2(2) - y1 + y31 = xy3(2) - y1 +c + aire2 = x21 * y31 - x31 * y21 +c +c recherche d'un test relatif peu couteux +c pour reperer la degenerescence du triangle + if( abs(aire2) .le. + % epsurf*(abs(x21)+abs(x31))*(abs(y21)+abs(y31)) ) then +c triangle de qualite trop faible + if( ierr .ge. 0 ) then +c nblgrc(nrerr) = 1 +c kerr(1) = 'erreur cenced: triangle degenere' +c call lereur + write(imprim,*) 'erreur cenced: triangle degenere' + write(imprim,10000) xy1,xy2,xy3,aire2 + endif +10000 format( 3(' x=',g24.16,' y=',g24.16/),' aire*2=',g24.16) + cetria(1) = 0d0 + cetria(2) = 0d0 + cetria(3) = 1d28 + ierr = 1 + return + endif +c +c les 2 coordonnees du centre intersection des 2 mediatrices +c x = (x1+x2)/2 + lambda * (y2-y1) +c y = (y1+y2)/2 - lambda * (x2-x1) +c x = (x1+x3)/2 + rot * (y3-y1) +c y = (y1+y3)/2 - rot * (x3-x1) +c ========================================================== + rot = ((xy2(1)-xy3(1))*x21 + (xy2(2)-xy3(2))*y21) / (2 * aire2) +c + xc = ( x1 + xy3(1) ) * 0.5d0 + rot * y31 + yc = ( y1 + xy3(2) ) * 0.5d0 - rot * x31 +c + cetria(1) = xc + cetria(2) = yc +c +c le carre du rayon + cetria(3) = (x1-xc) ** 2 + (y1-yc) ** 2 +c +c pas d'erreur rencontree + ierr = 0 + end + + + double precision function angled( p1, p2, p3 ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer l'angle (p1p2,p1p3) en radians +c ----- +c +c entrees : +c --------- +c p1,p2,p3 : les 2 coordonnees des 3 sommets de l'angle +c sens direct pour une surface >0 +c sorties : +c --------- +c angled : angle (p1p2,p1p3) en radians entre [0 et 2pi] +c 0 si p1=p2 ou p1=p3 +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique upmc paris fevrier 1992 +c2345x7..............................................................012 + double precision p1(2),p2(2),p3(2),x21,y21,x31,y31,a1,a2,d,c +c +c les cotes + x21 = p2(1) - p1(1) + y21 = p2(2) - p1(2) + x31 = p3(1) - p1(1) + y31 = p3(2) - p1(2) +c +c longueur des cotes + a1 = x21 * x21 + y21 * y21 + a2 = x31 * x31 + y31 * y31 + d = sqrt( a1 * a2 ) + if( d .eq. 0 ) then + angled = 0 + return + endif +c +c cosinus de l'angle + c = ( x21 * x31 + y21 * y31 ) / d + if( c .le. -1.d0 ) then +c tilt sur apollo si acos( -1 -eps ) + angled = atan( 1.d0 ) * 4.d0 + return + else if( c .ge. 1.d0 ) then +c tilt sur apollo si acos( 1 + eps ) + angled = 0 + return + endif +c + angled = acos( c ) + if( x21 * y31 - x31 * y21 .lt. 0 ) then +c demi plan inferieur + angled = 8.d0 * atan( 1.d0 ) - angled + endif + end + + + subroutine teajte( mxsomm, nbsomm, pxyd, comxmi, + % aretmx, mxtree, letree, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : initialisation des tableaux letree +c ----- ajout des sommets 1 a nbsomm (valeur en entree) dans letree +c +c entrees: +c -------- +c mxsomm : nombre maximal de sommets permis pour la triangulation +c mxtree : nombre maximal de triangles equilateraux (te) declarables +c aretmx : longueur maximale des aretes des triangles equilateraux +c +c entrees et sorties : +c -------------------- +c nbsomm : nombre de sommets apres identification +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c tableau reel(3,mxsomm) +c +c sorties: +c -------- +c comxmi : coordonnees minimales et maximales des points frontaliers +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) : no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c ierr : 0 si pas d'erreur +c 51 saturation letree +c 52 saturation pxyd +c 7 tous les points sont alignes +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juillet 1994 +c....................................................................012 + integer letree(0:8,0:mxtree) + double precision pxyd(3,mxsomm) + double precision comxmi(3,2) + double precision a(2),s,aretmx,rac3 +c +c protection du nombre de sommets avant d'ajouter ceux de tetree + nbsofr = nbsomm + do 1 i = 1, nbsomm + comxmi(1,1) = min( comxmi(1,1), pxyd(1,i) ) + comxmi(1,2) = max( comxmi(1,2), pxyd(1,i) ) + comxmi(2,1) = min( comxmi(2,1), pxyd(2,i) ) + comxmi(2,2) = max( comxmi(2,2), pxyd(2,i) ) + 1 continue +c +c creation de l'arbre tee +c ======================= +c la premiere colonne vide de letree + letree(0,0) = 2 +c chainage des te vides + do 4 i = 2 , mxtree + letree(0,i) = i+1 + 4 continue + letree(0,mxtree) = 0 +c les maxima des 2 indices de letree + letree(1,0) = 8 + letree(2,0) = mxtree +c +c la racine +c aucun point interne au triangle equilateral (te) 1 + letree(0,1) = 0 + letree(1,1) = 0 + letree(2,1) = 0 + letree(3,1) = 0 +c pas de sur-triangle + letree(4,1) = 0 + letree(5,1) = 0 +c le numero pxyd des 3 sommets du te 1 + letree(6,1) = nbsomm + 1 + letree(7,1) = nbsomm + 2 + letree(8,1) = nbsomm + 3 +c +c calcul de la largeur et hauteur du rectangle englobant +c ====================================================== + a(1) = comxmi(1,2) - comxmi(1,1) + a(2) = comxmi(2,2) - comxmi(2,1) +c la longueur de la diagonale + s = sqrt( a(1)**2 + a(2)**2 ) + do 60 k=1,2 + if( a(k) .lt. 1e-4 * s ) then +c nblgrc(nrerr) = 1 + write(imprim,*) 'tous les points sont alignes' +c call lereur + ierr = 7 + return + endif + 60 continue +c +c le maximum des ecarts + s = s + s +c +c le triangle equilateral englobant +c ================================= +c ecart du rectangle au triangle equilateral + rac3 = sqrt( 3.0d0 ) + arete = a(1) + 2 * aretmx + 2 * ( a(2) + aretmx ) / rac3 +c +c le point nbsomm + 1 en bas a gauche + nbsomm = nbsomm + 1 + pxyd(1,nbsomm) = (comxmi(1,1)+comxmi(1,2))*0.5d0 - arete*0.5d0 + pxyd(2,nbsomm) = comxmi(2,1) - aretmx + pxyd(3,nbsomm) = s +c +c le point nbsomm + 2 en bas a droite + nbsomm = nbsomm + 1 + pxyd(1,nbsomm) = pxyd(1,nbsomm-1) + arete + pxyd(2,nbsomm) = pxyd(2,nbsomm-1) + pxyd(3,nbsomm) = s +c +c le point nbsomm + 3 sommet au dessus + nbsomm = nbsomm + 1 + pxyd(1,nbsomm) = pxyd(1,nbsomm-2) + arete * 0.5d0 + pxyd(2,nbsomm) = pxyd(2,nbsomm-2) + arete * 0.5d0 * rac3 + pxyd(3,nbsomm) = s +c +c ajout des sommets des lignes pour former letree +c =============================================== + do 150 i=1,nbsofr +c ajout du point i de pxyd a letree + call teajpt( i, nbsomm, mxsomm, pxyd, letree, + & nt, ierr ) + if( ierr .ne. 0 ) return + 150 continue +c + return + end + + + subroutine tetaid( nutysu, dx, dy, longai, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer la longueur de l'arete ideale en dx,dy +c ----- +c +c entrees: +c -------- +c nutysu : numero de traitement de areteideale() selon le type de surface +c 0 pas d'emploi de la fonction areteideale() => aretmx active +c 1 il existe une fonction areteideale(xyz,xyzdir) +c ... autres options a definir ... +c dx, dy : abscisse et ordonnee dans le plan du point (reel2!) +c +c sorties: +c -------- +c longai : longueur de l'areteideale(xyz,xyzdir) autour du point xyz +c ierr : 0 si pas d'erreur, <>0 sinon +c 1 calcul incorrect de areteideale(xyz,xyzdir) +c 2 longueur calculee nulle +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) +c + double precision areteideale + double precision dx, dy, longai + double precision xyz(3), xyzd(3), d0 +c + ierr = 0 + if( nutysu .gt. 0 ) then + d0 = longai +c le point ou se calcule la longueur + xyz(1) = dx + xyz(2) = dy +c z pour le calcul de la longueur (inactif ici!) + xyz(3) = 0d0 +c la direction pour le calcul de la longueur (inactif ici!) + xyzd(1) = 0d0 + xyzd(2) = 0d0 + xyzd(3) = 0d0 + + longai = areteideale(xyz,xyzd) + if( longai .lt. 0d0 ) then + write(imprim,10000) xyz +10000 format('attention: longueur de areteideale(', + % g14.6,',',g14.6,',',g14.6,')<=0! => rendue >0' ) + longai = -longai + endif + if( longai .eq. 0d0 ) then + write(imprim,10001) xyz +10001 format('erreur: longueur de areteideale(', + % g14.6,',',g14.6,',',g14.6,')=0!' ) + ierr = 2 + longai = d0 + endif + endif + end + + + subroutine tehote( nutysu, + % nbarpi, mxsomm, nbsomm, pxyd, + % comxmi, aretmx, + % letree, mxqueu, laqueu, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : homogeneisation de l'arbre des te a un saut de taille au plus +c ----- prise en compte des distances souhaitees autour des sommets initiaux +c +c entrees: +c -------- +c nutysu : numero de traitement de areteideale() selon le type de surface +c 0 pas d'emploi de la fonction areteideale() => aretmx active +c 1 il existe une fonction areteideale() +c dont seules les 2 premieres composantes de uv sont actives +c autres options a definir... +c nbarpi : nombre de sommets de la frontiere + nombre de points internes +c imposes par l'utilisateur +c mxsomm : nombre maximal de sommets permis pour la triangulation et te +c mxqueu : nombre d'entiers utilisables dans laqueu +c comxmi : minimum et maximum des coordonnees de l'objet +c aretmx : longueur maximale des aretes des triangles equilateraux +c permtr : perimetre de la ligne enveloppe dans le plan +c avant mise a l'echelle a 2**20 +c +c modifies : +c ---------- +c nbsomm : nombre de sommets apres identification +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) : no du 1-er te vide dans letree +c letree(1,0) : maximum du 1-er indice de letree (ici 8) +c letree(2,0) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c auxiliaire : +c ------------ +c laqueu : mxqueu entiers servant de queue pour le parcours de letree +c +c sorties: +c -------- +c ierr : 0 si pas d'erreur +c 51 si saturation letree dans te4ste +c 52 si saturation pxyd dans te4ste +c >0 si autre erreur +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc avril 1997 +c2345x7..............................................................012 + double precision ampli + parameter (ampli=1.34d0) + common / unites / lecteu, imprim, intera, nunite(29) +c + double precision pxyd(3,mxsomm), d2, aretm2 + double precision comxmi(3,2),aretmx,a,s,xrmin,xrmax,yrmin,yrmax + double precision dmin, dmax + integer letree(0:8,0:*) +c + integer laqueu(1:mxqueu),lequeu +c lequeu : entree dans la queue +c lhqueu : longueur de la queue +c gestion circulaire +c + integer nuste(3) + equivalence (nuste(1),ns1),(nuste(2),ns2),(nuste(3),ns3) +c +c existence ou non de la fonction 'taille_ideale' des aretes +c autour du point. ici la carte est supposee isotrope +c ========================================================== +c attention: si la fonction taille_ideale existe +c alors pxyd(3,*) est la taille_ideale dans l'espace initial +c sinon pxyd(3,*) est la distance calculee dans le plan par +c propagation a partir des tailles des aretes de la frontiere +c + if( nutysu .gt. 0 ) then +c +c la fonction taille_ideale(x,y,z) existe +c --------------------------------------- +c initialisation de la distance souhaitee autour des points 1 a nbsomm + do 1 i=1,nbsomm +c calcul de pxyzd(3,i) + call tetaid( nutysu, pxyd(1,i), pxyd(2,i), + % pxyd(3,i), ierr ) + if( ierr .ne. 0 ) goto 9999 + 1 continue +c + else +c +c la fonction taille_ideale(x,y,z) n'existe pas +c --------------------------------------------- +c prise en compte des distances souhaitees dans le plan +c autour des points frontaliers et des points internes imposes +c toutes les autres distances souhaitees ont ete mis a aretmx +c lors de l'execution du sp teqini + do 3 i=1,nbarpi +c le sommet i n'est pas un sommet de letree => sommet frontalier +c recherche du sous-triangle minimal feuille contenant le point i + nte = 1 + 2 nte = notrpt( pxyd(1,i), pxyd, nte, letree ) +c la distance au sommet le plus eloigne est elle inferieure +c a la distance souhaitee? + ns1 = letree(6,nte) + ns2 = letree(7,nte) + ns3 = letree(8,nte) + d2 = max( ( pxyd(1,i)-pxyd(1,ns1) )**2 + + % ( pxyd(2,i)-pxyd(2,ns1) )**2 + % , ( pxyd(1,i)-pxyd(1,ns2) )**2 + + % ( pxyd(2,i)-pxyd(2,ns2) )**2 + % , ( pxyd(1,i)-pxyd(1,ns3) )**2 + + % ( pxyd(2,i)-pxyd(2,ns3) )**2 ) + if( d2 .gt. pxyd(3,i)**2 ) then +c le triangle nte trop grand doit etre subdivise en 4 sous-triangle + call te4ste( nbsomm, mxsomm, pxyd, nte, letree, + & ierr ) + if( ierr .ne. 0 ) return + goto 2 + endif + 3 continue + endif +c +c le sous-triangle central de la racine est decoupe systematiquement +c ================================================================== + nte = 2 + if( letree(0,2) .le. 0 ) then +c le sous-triangle central de la racine n'est pas subdivise +c il est donc decoupe en 4 soustriangles + nbsom0 = nbsomm + call te4ste( nbsomm, mxsomm, pxyd, nte, letree, + % ierr ) + if( ierr .ne. 0 ) return + do 4 i=nbsom0+1,nbsomm +c mise a jour de taille_ideale des nouveaux sommets de te + call tetaid( nutysu, pxyd(1,i), pxyd(2,i), pxyd(3,i), ierr ) + if( ierr .ne. 0 ) goto 9999 + 4 continue + endif +c +c le carre de la longueur de l'arete de triangles equilateraux +c souhaitee pour le fond de la triangulation + aretm2 = (aretmx*ampli) ** 2 +c +c tout te contenu dans le rectangle englobant doit avoir un +c cote < aretmx et etre de meme taille que les te voisins +c s'il contient un point; sinon un seul saut de taille est permis +c =============================================================== +c le rectangle englobant pour selectionner les te "internes" +c le numero des 3 sommets du te englobant racine de l'arbre des te + ns1 = letree(6,1) + ns2 = letree(7,1) + ns3 = letree(8,1) + a = aretmx * 0.01d0 +c abscisse du milieu de l'arete gauche du te 1 + s = ( pxyd(1,ns1) + pxyd(1,ns3) ) / 2 + xrmin = min( s, comxmi(1,1) - aretmx ) - a +c abscisse du milieu de l'arete droite du te 1 + s = ( pxyd(1,ns2) + pxyd(1,ns3) ) / 2 + xrmax = max( s, comxmi(1,2) + aretmx ) + a + yrmin = comxmi(2,1) - aretmx +c ordonnee de la droite passant par les milieus des 2 aretes +c droite gauche du te 1 + s = ( pxyd(2,ns1) + pxyd(2,ns3) ) / 2 + yrmax = max( s, comxmi(2,2) + aretmx ) + a +c +c cas particulier de 3 ou 4 ou peu d'aretes frontalieres + if( nbarpi .le. 8 ) then +c tout le triangle englobant (racine) est a prendre en compte + xrmin = pxyd(1,ns1) - a + xrmax = pxyd(1,ns2) + a + yrmin = pxyd(2,ns1) - a + yrmax = pxyd(2,ns3) + a + endif +c + nbs0 = nbsomm + nbiter = -1 +c +c initialisation de la queue + 5 nbiter = nbiter + 1 + lequeu = 1 + lhqueu = 0 +c la racine de letree initialise la queue + laqueu(1) = 1 +c +c tant que la longueur de la queue est >=0 traiter le debut de queue + 10 if( lhqueu .ge. 0 ) then +c +c le triangle te a traiter + i = lequeu - lhqueu + if( i .le. 0 ) i = mxqueu + i + nte = laqueu( i ) +c la longueur de la queue est reduite + lhqueu = lhqueu - 1 +c +c nte est il un sous-triangle feuille minimal ? + 15 if( letree(0,nte) .gt. 0 ) then +c +c non les 4 sous-triangles sont mis dans la queue + if( lhqueu + 4 .ge. mxqueu ) then + write(imprim,*) 'tehote: saturation de la queue' + ierr = 7 + return + endif + do 20 i=3,0,-1 +c ajout du sous-triangle i + lhqueu = lhqueu + 1 + lequeu = lequeu + 1 + if( lequeu .gt. mxqueu ) lequeu = lequeu - mxqueu + laqueu( lequeu ) = letree( i, nte ) + 20 continue + goto 10 +c + endif +c +c ici nte est un triangle minimal non subdivise +c --------------------------------------------- +c le te est il dans le cadre englobant de l'objet ? + ns1 = letree(6,nte) + ns2 = letree(7,nte) + ns3 = letree(8,nte) + if( pxyd(1,ns1) .gt. pxyd(1,ns2) ) then + dmin = pxyd(1,ns2) + dmax = pxyd(1,ns1) + else + dmin = pxyd(1,ns1) + dmax = pxyd(1,ns2) + endif + if( (xrmin .le. dmin .and. dmin .le. xrmax) .or. + % (xrmin .le. dmax .and. dmax .le. xrmax) ) then + if( pxyd(2,ns1) .gt. pxyd(2,ns3) ) then + dmin = pxyd(2,ns3) + dmax = pxyd(2,ns1) + else + dmin = pxyd(2,ns1) + dmax = pxyd(2,ns3) + endif + if( (yrmin .le. dmin .and. dmin .le. yrmax) .or. + % (yrmin .le. dmax .and. dmax .le. yrmax) ) then +c +c nte est un te feuille et interne au rectangle englobant +c ======================================================= +c le carre de la longueur de l'arete du te de numero nte + d2 = (pxyd(1,ns1)-pxyd(1,ns2)) ** 2 + + % (pxyd(2,ns1)-pxyd(2,ns2)) ** 2 +c + if( nutysu .eq. 0 ) then +c +c il n'existe pas de fonction 'taille_ideale' +c ------------------------------------------- +c si la taille effective de l'arete du te est superieure a aretmx +c alors le te est decoupe + if( d2 .gt. aretm2 ) then +c le triangle nte trop grand doit etre subdivise +c en 4 sous-triangles + call te4ste( nbsomm,mxsomm, pxyd, + % nte, letree, ierr ) + if( ierr .ne. 0 ) return + goto 15 + endif +c + else +c +c il existe ici une fonction 'taille_ideale' +c ------------------------------------------ +c si la taille effective de l'arete du te est superieure au mini +c des 3 tailles_ideales aux sommets alors le te est decoupe + do 28 i=1,3 + if( d2 .gt. (pxyd(3,nuste(i))*ampli)**2 ) then +c le triangle nte trop grand doit etre subdivise +c en 4 sous-triangles + nbsom0 = nbsomm + call te4ste( nbsomm, mxsomm, pxyd, + & nte, letree, ierr ) + if( ierr .ne. 0 ) return + do 27 j=nbsom0+1,nbsomm +c mise a jour de taille_ideale des nouveaux sommets de + call tetaid( nutysu, pxyd(1,j), pxyd(2,j), + % pxyd(3,j), ierr ) + if( ierr .ne. 0 ) goto 9999 + 27 continue + goto 15 + endif + 28 continue + endif +c +c recherche du nombre de niveaux entre nte et les te voisins par se +c si la difference de subdivisions excede 1 alors le plus grand des +c ================================================================= + 29 do 30 i=1,3 +c +c noteva triangle voisin de nte par l'arete i + call n1trva( nte, i, letree, noteva, niveau ) + if( noteva .le. 0 ) goto 30 +c il existe un te voisin + if( niveau .gt. 0 ) goto 30 +c nte a un te voisin plus petit ou egal + if( letree(0,noteva) .le. 0 ) goto 30 +c nte a un te voisin noteva subdivise au moins une fois +c + if( nbiter .gt. 0 ) then +c les 2 sous triangles voisins sont-ils subdivises? + ns2 = letree(i,noteva) + if( letree(0,ns2) .le. 0 ) then +c ns2 n'est pas subdivise + ns2 = letree(nosui3(i),noteva) + if( letree(0,ns2) .le. 0 ) then +c les 2 sous-triangles ne sont pas subdivises + goto 30 + endif + endif + endif +c +c saut>1 => le triangle nte doit etre subdivise en 4 sous-triang +c -------------------------------------------------------------- + nbsom0 = nbsomm + call te4ste( nbsomm,mxsomm, pxyd, nte, letree, + & ierr ) + if( ierr .ne. 0 ) return + if( nutysu .gt. 0 ) then + do 32 j=nbsom0+1,nbsomm +c mise a jour de taille_ideale des nouveaux sommets de te + call tetaid( nutysu, pxyd(1,j), pxyd(2,j), + % pxyd(3,j), ierr ) + if( ierr .ne. 0 ) goto 9999 + 32 continue + endif + goto 15 +c + 30 continue + endif + endif + goto 10 + endif + if( nbs0 .lt. nbsomm ) then + nbs0 = nbsomm + goto 5 + endif + return +c +c pb dans le calcul de la fonction taille_ideale + + 9999 write(imprim,*) 'pb dans le calcul de taille_ideale' +c nblgrc(nrerr) = 1 +c kerr(1) = 'pb dans le calcul de taille_ideale' +c call lereur + return + end + + + subroutine tetrte( comxmi, aretmx, nbarpi, mxsomm, pxyd, + % mxqueu, laqueu, letree, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : trianguler les triangles equilateraux feuilles et +c ----- les points de la frontiere et les points internes imposes +c +c attention: la triangulation finale n'est pas de type delaunay! +c +c entrees: +c -------- +c comxmi : minimum et maximum des coordonnees de l'objet +c aretmx : longueur maximale des aretes des triangles equilateraux +c nbarpi : nombre de sommets de la frontiere + nombre de points internes +c imposes par l'utilisateur +c mxsomm : nombre maximal de sommets declarables dans pxyd +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c +c mxqueu : nombre d'entiers utilisables dans laqueu +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) : no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c noarst : noarst(i) numero d'une arete de sommet i +c +c auxiliaire : +c ------------ +c laqueu : mxqueu entiers servant de queue pour le parcours de letree +c +c sorties: +c -------- +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes d'un t +c =5 si saturation de la queue de parcours de l'arbre des te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, intera, nunite(29) +c + double precision pxyd(3,mxsomm) + double precision comxmi(3,2),aretmx,a,s,xrmin,xrmax,yrmin,yrmax + double precision dmin, dmax +c + integer nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(mxsomm) +c + integer letree(0:8,0:*) + integer laqueu(1:mxqueu) +c lequeu:entree dans la queue en gestion circulaire +c lhqueu:longueur de la queue en gestion circulaire +c + integer milieu(3), nutr(1:13) +c +c le rectangle englobant pour selectionner les te "internes" +c le numero des 3 sommets du te englobant racine de l'arbre des te + ns1 = letree(6,1) + ns2 = letree(7,1) + ns3 = letree(8,1) + a = aretmx * 0.01d0 +c abscisse du milieu de l'arete gauche du te 1 + s = ( pxyd(1,ns1) + pxyd(1,ns3) ) / 2 + xrmin = min( s, comxmi(1,1) - aretmx ) - a +c abscisse du milieu de l'arete droite du te 1 + s = ( pxyd(1,ns2) + pxyd(1,ns3) ) / 2 + xrmax = max( s, comxmi(1,2) + aretmx ) + a + yrmin = comxmi(2,1) - aretmx +c ordonnee de la droite passant par les milieus des 2 aretes +c droite gauche du te 1 + s = ( pxyd(2,ns1) + pxyd(2,ns3) ) / 2 + yrmax = max( s, comxmi(2,2) + aretmx ) + a +c +c cas particulier de 3 ou 4 ou peu d'aretes frontalieres + if( nbarpi .le. 8 ) then +c tout le triangle englobant (racine) est a prendre en compte + xrmin = pxyd(1,ns1) - a + xrmax = pxyd(1,ns2) + a + yrmin = pxyd(2,ns1) - a + yrmax = pxyd(2,ns3) + a + endif +c +c initialisation du tableau noartr + do 5 i=1,mxartr +c le numero de l'arete est inconnu + noartr(1,i) = 0 +c le chainage sur le triangle vide suivant + noartr(2,i) = i+1 + 5 continue + noartr(2,mxartr) = 0 + n1artr = 1 +c +c parcours des te jusqu'a trianguler toutes les feuilles (triangles eq) +c ===================================================================== +c initialisation de la queue sur les te + ierr = 0 + lequeu = 1 + lhqueu = 0 +c la racine de letree initialise la queue + laqueu(1) = 1 +c +c tant que la longueur de la queue est >=0 traiter le debut de queue + 10 if( lhqueu .ge. 0 ) then +c +c le triangle te a traiter + i = lequeu - lhqueu + if( i .le. 0 ) i = mxqueu + i + nte = laqueu( i ) +c la longueur est reduite + lhqueu = lhqueu - 1 +c +c nte est il un sous-triangle feuille (minimal) ? + 15 if( letree(0,nte) .gt. 0 ) then +c non les 4 sous-triangles sont mis dans la queue + if( lhqueu + 4 .ge. mxqueu ) then + write(imprim,*) 'tetrte: saturation de la queue' + ierr = 5 + return + endif + do 20 i=3,0,-1 +c ajout du sous-triangle i + lhqueu = lhqueu + 1 + lequeu = lequeu + 1 + if( lequeu .gt. mxqueu ) lequeu = lequeu - mxqueu + laqueu( lequeu ) = letree( i, nte ) + 20 continue + goto 10 + endif +c +c ici nte est un triangle minimal non subdivise +c --------------------------------------------- +c le te est il dans le cadre englobant de l'objet ? + ns1 = letree(6,nte) + ns2 = letree(7,nte) + ns3 = letree(8,nte) + if( pxyd(1,ns1) .gt. pxyd(1,ns2) ) then + dmin = pxyd(1,ns2) + dmax = pxyd(1,ns1) + else + dmin = pxyd(1,ns1) + dmax = pxyd(1,ns2) + endif + if( (xrmin .le. dmin .and. dmin .le. xrmax) .or. + % (xrmin .le. dmax .and. dmax .le. xrmax) ) then + if( pxyd(2,ns1) .gt. pxyd(2,ns3) ) then + dmin = pxyd(2,ns3) + dmax = pxyd(2,ns1) + else + dmin = pxyd(2,ns1) + dmax = pxyd(2,ns3) + endif + if( (yrmin .le. dmin .and. dmin .le. yrmax) .or. + % (yrmin .le. dmax .and. dmax .le. yrmax) ) then +c +c te minimal et interne au rectangle englobant +c -------------------------------------------- +c recherche du nombre de niveaux entre nte et les te voisins +c par ses aretes + nbmili = 0 + do 30 i=1,3 +c +c a priori pas de milieu de l'arete i du te nte + milieu(i) = 0 +c +c recherche de noteva te voisin de nte par l'arete i + call n1trva( nte, i, letree, noteva, niveau ) +c noteva : >0 numero letree du te voisin par l'arete i +c =0 si pas de te voisin (racine , ... ) +c niveau : =0 si nte et noteva ont meme taille +c >0 nte est 4**niveau fois plus petit que noteva + if( noteva .gt. 0 ) then +c il existe un te voisin + if( letree(0,noteva) .gt. 0 ) then +c noteva est plus petit que nte +c => recherche du numero du milieu du cote=sommet du te no +c le sous-te 0 du te noteva + nsot = letree(0,noteva) +c le numero dans pxyd du milieu de l'arete i de nte + milieu( i ) = letree( 5+nopre3(i), nsot ) + nbmili = nbmili + 1 + endif + endif +c + 30 continue +c +c triangulation du te nte en fonction du nombre de ses milieux + goto( 50, 100, 200, 300 ) , nbmili + 1 +c +c 0 milieu => 1 triangle = le te nte +c ---------------------------------- + 50 call f0trte( letree(0,nte), pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) + if( ierr .ne. 0 ) return + goto 10 +c +c 1 milieu => 2 triangles = 2 demi te +c ----------------------------------- + 100 call f1trte( letree(0,nte), pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) + if( ierr .ne. 0 ) return + goto 10 +c +c 2 milieux => 3 triangles +c ----------------------------------- + 200 call f2trte( letree(0,nte), pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) + if( ierr .ne. 0 ) return + goto 10 +c +c 3 milieux => 4 triangles = 4 quart te +c ------------------------------------- + 300 call f3trte( letree(0,nte), pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) + if( ierr .ne. 0 ) return + goto 10 + endif + endif + goto 10 + endif + end + + + subroutine aisoar( mosoar, mxsoar, nosoar, na1 ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : chainer en colonne lchain les aretes non vides et +c ----- non frontalieres du tableau nosoar +c +c entrees: +c -------- +c mosoar : nombre maximal d'entiers par arete dans le tableau nosoar +c mxsoar : nombre maximal d'aretes frontalieres declarables +c +c modifies : +c ---------- +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c nosoar(lchain,i)=arete interne suivante +c +c sortie : +c -------- +c na1 : numero dans nosoar de la premiere arete interne +c les suivantes sont nosoar(lchain,na1), ... +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter (lchain=6) + integer nosoar(mosoar,mxsoar) +c +c formation du chainage des aretes internes a echanger eventuellement +c recherche de la premiere arete non vide et non frontaliere + do 10 na1=1,mxsoar + if( nosoar(1,na1) .gt. 0 .and. nosoar(3,na1) .le. 0 ) goto 15 + 10 continue +c +c protection de la premiere arete non vide et non frontaliere + 15 na0 = na1 + do 20 na=na1+1,mxsoar + if( nosoar(1,na) .gt. 0 .and. nosoar(3,na) .le. 0 ) then +c arete interne => elle est chainee a partir de la precedente + nosoar(lchain,na0) = na + na0 = na + endif + 20 continue +c +c la derniere arete interne n'a pas de suivante + nosoar(lchain,na0) = 0 + end + + + subroutine tedela( pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, n1ardv, + % moartr, mxartr, n1artr, noartr, modifs ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : pour toutes les aretes chainees dans nosoar(lchain,*) +c ----- du tableau nosoar +c echanger la diagonale des 2 triangles si le sommet oppose +c a un triangle ayant en commun une arete appartient au cercle +c circonscrit de l'autre (violation boule vide delaunay) +c +c entrees: +c -------- +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c +c modifies : +c ---------- +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete dans le tableau nosoar +c mxsoar : nombre maximal d'aretes frontalieres declarables +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c n1ardv : numero dans nosoar de la premiere arete du chainage +c des aretes a rendre delaunay +c +c moartr : nombre d'entiers par triangle dans le tableau noartr +c mxartr : nombre maximal de triangles declarables dans noartr +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c modifs : nombre d'echanges de diagonales pour maximiser la qualite +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter (lchain=6) + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*), surtd2, s123, s142, s143, s234, + % s12, s34, a12, cetria(3), r0 + integer nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*) +c +c le nombre d'echanges de diagonales pour minimiser l'aire + modifs = 0 + r0 = 0 +c +c la premiere arete du chainage des aretes a rendre delaunay + na0 = n1ardv +c +c tant que la pile des aretes a echanger eventuellement est non vide +c ================================================================== + 20 if( na0 .gt. 0 ) then +c +c l'arete a traiter + na = na0 +c la prochaine arete a traiter + na0 = nosoar(lchain,na0) +c +c l'arete est marquee traitee avec le numero -1 + nosoar(lchain,na) = -1 +c +c l'arete est elle active? + if( nosoar(1,na) .eq. 0 ) goto 20 +c +c si arete frontaliere pas d'echange possible + if( nosoar(3,na) .gt. 0 ) goto 20 +c +c existe-t-il 2 triangles ayant cette arete commune? + if( nosoar(4,na) .le. 0 .or. nosoar(5,na) .le. 0 ) goto 20 +c +c aucun des 2 triangles est-il desactive? + if( noartr(1,nosoar(4,na)) .eq. 0 .or. + % noartr(1,nosoar(5,na)) .eq. 0 ) goto 20 +c +c l'arete appartient a deux triangles actifs +c le numero des 4 sommets du quadrangle des 2 triangles + call mt4sqa( na, moartr, noartr, mosoar, nosoar, + % ns1, ns2, ns3, ns4 ) + if( ns4 .eq. 0 ) goto 20 +c +c carre de la longueur de l'arete ns1 ns2 + a12 = (pxyd(1,ns2)-pxyd(1,ns1))**2+(pxyd(2,ns2)-pxyd(2,ns1))**2 +c +c comparaison de la somme des aires des 2 triangles +c ------------------------------------------------- +c calcul des surfaces des triangles 123 et 142 de cette arete + s123=surtd2( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3) ) + s142=surtd2( pxyd(1,ns1), pxyd(1,ns4), pxyd(1,ns2) ) + s12 = abs( s123 ) + abs( s142 ) + if( s12 .le. 0.001*a12 ) goto 20 +c +c calcul des surfaces des triangles 143 et 234 de cette arete + s143=surtd2( pxyd(1,ns1), pxyd(1,ns4), pxyd(1,ns3) ) + s234=surtd2( pxyd(1,ns2), pxyd(1,ns3), pxyd(1,ns4) ) + s34 = abs( s234 ) + abs( s143 ) +c + if( abs(s34-s12) .gt. 1d-15*s34 ) goto 20 +c +c quadrangle convexe : le critere de delaunay intervient +c ------------------ --------------------------------- +c calcul du centre et rayon de la boule circonscrite a 123 +c pas d'affichage si le triangle est degenere + ierr = -1 + call cenced( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3), cetria, + % ierr ) + if( ierr .gt. 0 ) then +c ierr=1 si triangle degenere => abandon + goto 20 + endif +c + if( (cetria(1)-pxyd(1,ns4))**2+(cetria(2)-pxyd(2,ns4))**2 + % .lt. cetria(3) ) then +c +c protection contre une boucle infinie sur le meme cercle + if( r0 .eq. cetria(3) ) goto 20 +c +c oui: ns4 est dans le cercle circonscrit a ns1 ns2 ns3 +c => ns3 est aussi dans le cercle circonscrit de ns1 ns2 ns4 +c +cccc les 2 triangles d'arete na sont effaces +ccc do 25 j=4,5 +ccc nt = nosoar(j,na) +cccc trace du triangle nt +ccc call mttrtr( pxyd, nt, moartr, noartr, mosoar, nosoar, +ccc % ncnoir, ncjaun ) +ccc 25 continue +c +c echange de la diagonale 12 par 34 des 2 triangles + call te2t2t( na, mosoar, n1soar, nosoar, noarst, + % moartr, noartr, na34 ) + if( na34 .eq. 0 ) goto 20 + r0 = cetria(3) +c +c l'arete na34 est marquee traitee + nosoar(lchain,na34) = -1 + modifs = modifs + 1 +c +c les aretes internes peripheriques des 2 triangles sont enchainees + do 60 j=4,5 + nt = nosoar(j,na34) +cccc trace du triangle nt +ccc call mttrtr( pxyd, nt, moartr, noartr, mosoar, nosoar, +ccc % ncoran, ncgric ) + do 50 i=1,3 + n = abs( noartr(i,nt) ) + if( n .ne. na34 ) then + if( nosoar(3,n) .eq. 0 .and. + % nosoar(lchain,n) .eq. -1 ) then +c cette arete marquee est chainee pour etre traitee + nosoar(lchain,n) = na0 + na0 = n + endif + endif + 50 continue + 60 continue + goto 20 + endif +c +c retour en haut de la pile des aretes a traiter + goto 20 + endif + end + + + subroutine terefr( nbarpi, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, larmin, notrcf, + % nbarpe, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : recherche des aretes de la frontiere non dans la triangulation +c ----- triangulation frontale pour les reobtenir +c +c attention: le chainage lchain de nosoar devient celui des cf +c +c entrees: +c -------- +c le tableau nosoar +c nbarpi : numero du dernier point interne impose par l'utilisateur +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxarcf : nombre de variables des tableaux n1arcf, noarcf, larmin, notrcf +c +c modifies: +c --------- +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c +c auxiliaires : +c ------------- +c n1arcf : tableau (0:mxarcf) auxiliaire d'entiers +c noarcf : tableau (3,mxarcf) auxiliaire d'entiers +c larmin : tableau (mxarcf) auxiliaire d'entiers +c notrcf : tableau (mxarcf) auxiliaire d'entiers +c +c sortie : +c -------- +c nbarpe : nombre d'aretes perdues puis retrouvees +c ierr : =0 si pas d'erreur +c >0 si une erreur est survenue +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter (lchain=6) + common / unites / lecteu,imprim,intera,nunite(29) + double precision pxyd(3,*) + integer nosoar(mosoar,mxsoar), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf), + % notrcf(mxarcf) +c +c le nombre d'aretes de la frontiere non arete de la triangulation + nbarpe = 0 +c +c initialisation du chainage des aretes des cf => 0 arete de cf + do 10 narete=1,mxsoar + nosoar( lchain, narete) = -1 + 10 continue +c +c boucle sur l'ensemble des aretes actuelles +c ========================================== + do 30 narete=1,mxsoar +c + if( nosoar(3,narete) .gt. 0 ) then +c arete appartenant a une ligne => frontaliere +c + if(nosoar(4,narete) .le. 0 .or. nosoar(5,narete) .le. 0)then +c l'arete narete frontaliere n'appartient pas a 2 triangles +c => elle est perdue + nbarpe = nbarpe + 1 +c +c le numero des 2 sommets de l'arete frontaliere perdue + ns1 = nosoar( 1, narete ) + ns2 = nosoar( 2, narete ) +c write(imprim,10000) ns1,(pxyd(j,ns1),j=1,2), +c % ns2,(pxyd(j,ns2),j=1,2) +10000 format(' arete perdue a forcer', + % (t24,'sommet=',i6,' x=',g13.5,' y=',g13.5)) +c +c traitement de cette arete perdue ns1-ns2 + call tefoar( narete, nbarpi, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, larmin, notrcf, + % ierr ) + if( ierr .ne. 0 ) return +c +c fin du traitement de cette arete perdue et retrouvee + endif + endif +c + 30 continue + end + + + subroutine tesuex( nblftr, nulftr, + % ndtri0, nbsomm, pxyd, nslign, + % mosoar, mxsoar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % nbtria, letrsu, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : supprimer du tableau noartr les triangles externes au domaine +c ----- en annulant le numero de leur 1-ere arete dans noartr +c et en les chainant comme triangles vides +c +c entrees: +c -------- +c nblftr : nombre de lignes fermees definissant la surface +c nulftr : numero des lignes fermees definissant la surface +c ndtri0 : plus grand numero dans noartr d'un triangle +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c nslign : tableau du numero de sommet dans sa ligne pour chaque +c sommet frontalier +c numero du point dans le lexique point si interne impose +c 0 si le point est interne non impose par l'utilisateur +c -1 si le sommet est externe au domaine +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles declarables +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero nosoar d'une arete de sommet i +c +c sorties: +c -------- +c nbtria : nombre de triangles internes au domaine +c letrsu : letrsu(nt)=numero du triangle interne, 0 sinon +c noarst : noarst(i) numero nosoar d'une arete du sommet i (modifi'e) +c ierr : 0 si pas d'erreur, >0 sinon +cc++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mai 1999 +c2345x7..............................................................012 + double precision pxyd(3,*) + integer nulftr(nblftr),nslign(nbsomm), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*) + integer letrsu(1:ndtri0) + double precision dmin +c +c les triangles sont a priori non marques + do 5 nt=1,ndtri0 + letrsu(nt) = 0 + 5 continue +c +c les aretes sont marquees non chainees + do 10 noar1=1,mxsoar + nosoar(6,noar1) = -2 + 10 continue +c +c recherche du sommet de la triangulation de plus petite abscisse +c =============================================================== + ntmin = 0 + dmin = 1d38 + do 20 i=1,nbsomm + if( pxyd(1,i) .lt. dmin ) then +c le nouveau minimum + noar1 = noarst(i) + if( noar1 .gt. 0 ) then +c le sommet appartient a une arete de triangle + if( nosoar(4,noar1) .gt. 0 ) then +c le nouveau minimum + dmin = pxyd(1,i) + ntmin = i + endif + endif + endif + 20 continue +c +c une arete de sommet ntmin + noar1 = noarst( ntmin ) +c un triangle d'arete noar1 + ntmin = nosoar( 4, noar1 ) + if( ntmin .le. 0 ) then +c nblgrc(nrerr) = 1 +c kerr(1) = 'pas de triangle d''abscisse minimale' +c call lereur + write(imprim,*) 'pas de triangle d''abscisse minimale' + ierr = 2 + goto 9990 + endif +c +c chainage des 3 aretes du triangle ntmin +c ======================================= +c la premiere arete du chainage des aretes traitees + noar1 = abs( noartr(1,ntmin) ) + na0 = abs( noartr(2,ntmin) ) +c elle est chainee sur la seconde arete du triangle ntmin + nosoar(6,noar1) = na0 +c les 2 autres aretes du triangle ntmin sont chainees + na1 = abs( noartr(3,ntmin) ) +c la seconde est chainee sur la troisieme arete + nosoar(6,na0) = na1 +c la troisieme n'a pas de suivante + nosoar(6,na1) = 0 +c +c le triangle ntmin est a l'exterieur du domaine +c tous les triangles externes sont marques -123 456 789 +c les triangles de l'autre cote d'une arete sur une ligne +c sont marques: no de la ligne de l'arete * signe oppose +c ======================================================= + ligne0 = 0 + ligne = -123 456 789 +c + 40 if( noar1 .ne. 0 ) then +c +c l'arete noar1 du tableau nosoar est a traiter +c --------------------------------------------- + noar = noar1 +c l'arete suivante devient la premiere a traiter ensuite + noar1 = nosoar(6,noar1) +c l'arete noar est traitee + nosoar(6,noar) = -3 +c + do 60 i=4,5 +c +c l'un des 2 triangles de l'arete + nt = nosoar(i,noar) + if( nt .gt. 0 ) then +c +c triangle deja traite pour une ligne anterieure? + if( letrsu(nt) .ne. 0 .and. + % abs(letrsu(nt)) .ne. ligne ) goto 60 +c +cccc trace du triangle nt en couleur ligne0 +ccc call mttrtr( pxyd, nt, moartr, noartr, mosoar, nosoar, +ccc % ligne0, ncnoir ) +c +c le triangle est marque avec la valeur de ligne + letrsu(nt) = ligne +c +c chainage eventuel des autres aretes de ce triangle +c si ce n'est pas encore fait + do 50 j=1,3 +c +c le numero na de l'arete j du triangle nt dans nosoar + na = abs( noartr(j,nt) ) + if( nosoar(6,na) .ne. -2 ) goto 50 +c +c le numero de 1 a nblftr dans nulftr de la ligne de l'arete + nl = nosoar(3,na) +c +c si l'arete est sur une ligne fermee differente de celle envelo +c et non marquee alors examen du triangle oppose + if( nl .gt. 0 ) then +c + if( nl .eq. ligne0 ) goto 50 +c +c arete frontaliere de ligne non traitee +c => passage de l'autre cote de la ligne +c le triangle de l'autre cote de la ligne est recherche + if( nt .eq. abs( nosoar(4,na) ) ) then + nt2 = 5 + else + nt2 = 4 + endif + nt2 = abs( nosoar(nt2,na) ) + if( nt2 .gt. 0 ) then +c +c le triangle nt2 de l'autre cote est marque avec le +c avec le signe oppose de celui de ligne + if( ligne .ge. 0 ) then + lsigne = -1 + else + lsigne = 1 + endif + letrsu(nt2) = lsigne * nl +c +c temoin de ligne a traiter ensuite dans nulftr + nulftr(nl) = -abs( nulftr(nl) ) +c +cccc trace du triangle nt2 en jaune borde de magenta +ccc call mttrtr( pxyd,nt2, +ccc % moartr,noartr,mosoar,nosoar, +ccc % ncjaun, ncmage ) +c +c l'arete est traitee + nosoar(6,na) = -3 +c + endif +c +c l'arete est traitee + goto 50 +c + endif +c +c arete non traitee => elle est chainee + nosoar(6,na) = noar1 + noar1 = na +c + 50 continue +c + endif + 60 continue +c + goto 40 + endif +c les triangles de la ligne fermee ont tous ete marques +c plus d'arete chainee +c +c recherche d'une nouvelle ligne fermee a traiter +c =============================================== + 65 do 70 nl=1,nblftr + if( nulftr(nl) .lt. 0 ) goto 80 + 70 continue +c plus de ligne fermee a traiter + goto 110 +c +c tous les triangles de cette composante connexe +c entre ligne et ligne0 vont etre marques +c ============================================== +c remise en etat du numero de ligne +c nl est le numero de la ligne dans nulftr a traiter + 80 nulftr(nl) = -nulftr(nl) + do 90 nt2=1,ndtri0 + if( abs(letrsu(nt2)) .eq. nl ) goto 92 + 90 continue +c +c recherche de l'arete j du triangle nt2 avec ce numero de ligne nl + 92 do 95 j=1,3 +c +c le numero de l'arete j du triangle dans nosoar + noar1 = 0 + na0 = abs( noartr(j,nt2) ) + if( nl .eq. nosoar(3,na0) ) then +c +c na0 est l'arete de ligne nl +c l'arete suivante du triangle nt2 + i = mod(j,3) + 1 +c le numero dans nosoar de l'arete i de nt2 + na1 = abs( noartr(i,nt2) ) + if( nosoar(6,na1) .eq. -2 ) then +c arete non traitee => elle est la premiere du chainage + noar1 = na1 +c pas de suivante dans ce chainage + nosoar(6,na1) = 0 + else + na1 = 0 + endif +c +c l'eventuelle seconde arete suivante + i = mod(i,3) + 1 + na = abs( noartr(i,nt2) ) + if( nosoar(6,na) .eq. -2 ) then + if( na1 .eq. 0 ) then +c 1 arete non traitee et seule a chainer + noar1 = na + nosoar(6,na) = 0 + else +c 2 aretes a chainer + noar1 = na + nosoar(6,na) = na1 + endif + endif +c + if( noar1 .gt. 0 ) then +c +c il existe au moins une arete a visiter pour ligne +c marquage des triangles internes a la ligne nl + ligne = letrsu(nt2) + ligne0 = nl + goto 40 +c + else +c +c nt2 est le seul triangle de la ligne fermee + goto 65 +c + endif + endif + 95 continue +c +c reperage des sommets internes ou externes dans nslign +c nslign(sommet externe au domaine)=-1 +c nslign(sommet interne au domaine)= 0 +c ===================================================== + 110 do 170 ns1=1,nbsomm +c tout sommet non sur la frontiere ou interne impose +c est suppose externe + if( nslign(ns1) .eq. 0 ) nslign(ns1) = -1 + 170 continue +c +c les triangles externes sont marques vides dans le tableau noartr +c ================================================================ + nbtria = 0 + do 200 nt=1,ndtri0 +c + if( letrsu(nt) .le. 0 ) then +c +c triangle nt externe + if( noartr(1,nt) .ne. 0 ) then +c la premiere arete est annulee + noartr(1,nt) = 0 +c le triangle nt est considere comme etant vide + noartr(2,nt) = n1artr + n1artr = nt + endif +c + else +c +c triangle nt interne + nbtria = nbtria + 1 + letrsu(nt) = nbtria +c +c marquage des 3 sommets du triangle nt + do 190 i=1,3 +c le numero nosoar de l'arete i du triangle nt + noar = abs( noartr(i,nt) ) +c le numero des 2 sommets + ns1 = nosoar(1,noar) + ns2 = nosoar(2,noar) +c mise a jour du numero d'une arete des 2 sommets de l'arete + noarst( ns1 ) = noar + noarst( ns2 ) = noar +c ns1 et ns2 sont des sommets de la triangulation du domaine + if( nslign(ns1) .lt. 0 ) nslign(ns1)=0 + if( nslign(ns2) .lt. 0 ) nslign(ns2)=0 + 190 continue +c + endif +c + 200 continue +c ici tout sommet externe ns verifie nslign(ns)=-1 +c +c les triangles externes sont mis a zero dans nosoar +c ================================================== + do 300 noar=1,mxsoar +c + if( nosoar(1,noar) .gt. 0 ) then +c +c le second triangle de l'arete noar + nt = nosoar(5,noar) + if( nt .gt. 0 ) then +c si le triangle nt est externe +c alors il est supprime pour l'arete noar + if( letrsu(nt) .le. 0 ) nosoar(5,noar)=0 + endif +c +c le premier triangle de l'arete noar + nt = nosoar(4,noar) + if( nt .gt. 0 ) then + if( letrsu(nt) .le. 0 ) then +c si le triangle nt est externe +c alors il est supprime pour l'arete noar +c et l'eventuel triangle oppose prend sa place +c en position 4 de nosoar + if( nosoar(5,noar) .gt. 0 ) then + nosoar(4,noar)=nosoar(5,noar) + nosoar(5,noar)=0 + else + nosoar(4,noar)=0 + endif + endif + endif + endif +c + 300 continue +c +c remise en etat pour eviter les modifications de ladefi + 9990 do 9991 nl=1,nblftr + if( nulftr(nl) .lt. 0 ) nulftr(nl)=-nulftr(nl) + 9991 continue + return + end + + + + subroutine trp1st( ns, noarst, mosoar, nosoar, moartr, noartr, + % mxpile, lhpile, lapile ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : recherche des triangles de noartr partageant le sommet ns +c ----- +c limite: un camembert de centre ns entame 2 fois +c ne donne que l'une des parties +c +c entrees: +c -------- +c ns : numero du sommet +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c mxpile : nombre maximal de triangles empilables +c +c sorties : +c -------- +c lhpile : >0 nombre de triangles empiles +c =0 si impossible de tourner autour du point +c =-lhpile si apres butee sur la frontiere il y a a nouveau +c butee sur la frontiere . a ce stade on ne peut dire si tous +c les triangles ayant ce sommet ont ete recenses +c ce cas arrive seulement si le sommet est sur la frontiere +c lapile : numero dans noartr des triangles de sommet ns +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + integer noartr(moartr,*), + % nosoar(mosoar,*), + % noarst(*) + integer lapile(1:mxpile) + integer nosotr(3) +c +c la premiere arete de sommet ns + nar = noarst( ns ) + if( nar .le. 0 ) then + write(imprim,*) 'trp1st: sommet',ns,' sans arete' + goto 9999 + endif +c +c l'arete nar est elle active? + if( nosoar(1,nar) .le. 0 ) then +ccc write(imprim,*) 'trp1st: arete vide',nar, +ccc % ' st1:', nosoar(1,nar),' st2:',nosoar(2,nar) + goto 9999 + endif +c +c le premier triangle de sommet ns + nt0 = abs( nosoar(4,nar) ) + if( nt0 .le. 0 ) then + write(imprim,*) 'trp1st: sommet',ns,' dans aucun triangle' + goto 9999 + endif +c +c le triangle est il interne? + if( noartr(1,nt0) .eq. 0 ) goto 9999 +c +c le numero des 3 sommets du triangle nt0 dans le sens direct + call nusotr( nt0, mosoar, nosoar, moartr, noartr, nosotr ) +c +c reperage du sommet ns dans le triangle nt0 + do 5 nar=1,3 + if( nosotr(nar) .eq. ns ) goto 10 + 5 continue + nta = nt0 + goto 9995 +c +c ns retrouve : le triangle nt0 est empile + 10 lhpile = 1 + lapile(1) = nt0 + nta = nt0 +c +c recherche dans le sens des aiguilles d'une montre +c (sens indirect) du triangle nt1 de l'autre cote de l'arete +c nar du triangle et en tournant autour du sommet ns +c ========================================================== + noar = abs( noartr(nar,nt0) ) +c le triangle nt1 oppose du triangle nt0 par l'arete noar + if( nosoar(4,noar) .eq. nt0 ) then + nt1 = nosoar(5,noar) + else + nt1 = nosoar(4,noar) + endif +c +c la boucle sur les triangles nt1 de sommet ns dans le sens indirect +c ================================================================== + if( nt1 .gt. 0 ) then +c + if( noartr(1,nt1) .eq. 0 ) goto 30 +c +c le triangle nt1 n'a pas ete detruit. il est actif +c le triangle oppose par l'arete noar existe +c le numero des 3 sommets du triangle nt1 dans le sens direct + 15 call nusotr( nt1, mosoar, nosoar, moartr, noartr, nosotr ) +c +c reperage du sommet ns dans nt1 + do 20 nar=1,3 + if( nosotr(nar) .eq. ns ) goto 25 + 20 continue + nta = nt1 + goto 9995 +c +c nt1 est empile + 25 if( lhpile .ge. mxpile ) goto 9990 + lhpile = lhpile + 1 + lapile(lhpile) = nt1 +c +c le triangle nt1 de l'autre cote de l'arete de sommet ns +c sauvegarde du precedent triangle dans nta + nta = nt1 + noar = abs( noartr(nar,nt1) ) + if( nosoar(4,noar) .eq. nt1 ) then + nt1 = nosoar(5,noar) + else + nt1 = nosoar(4,noar) + endif + if( nt1 .le. 0 ) goto 30 +c le triangle suivant est a l'exterieur + if( nt1 .ne. nt0 ) goto 15 +c +c recherche terminee par arrivee sur nt0 +c les triangles forment un "cercle" de "centre" ns + return +c + endif +c +c pas de triangle voisin a nt1 +c ============================ +c le parcours passe par 1 des triangles exterieurs +c le parcours est inverse par l'arete de gauche +c le triangle nta est le premier triangle empile + 30 lhpile = 1 + lapile(lhpile) = nta +c +c le numero des 3 sommets du triangle nta dans le sens direct + call nusotr( nta, mosoar, nosoar, moartr, noartr, nosotr ) + do 32 nar=1,3 + if( nosotr(nar) .eq. ns ) goto 33 + 32 continue + goto 9995 +c +c l'arete qui precede (rotation / ns dans le sens direct) + 33 if( nar .eq. 1 ) then + nar = 3 + else + nar = nar - 1 + endif +c +c le triangle voisin de nta dans le sens direct + noar = abs( noartr(nar,nta) ) + if( nosoar(4,noar) .eq. nta ) then + nt1 = nosoar(5,noar) + else + nt1 = nosoar(4,noar) + endif + if( nt1 .le. 0 ) then +c un seul triangle contient ns + goto 70 + endif +c +c boucle sur les triangles de sommet ns dans le sens direct +c ========================================================== + 40 if( noartr(1,nt1) .eq. 0 ) goto 70 +c +c le triangle nt1 n'a pas ete detruit. il est actif +c le numero des 3 sommets du triangle nt1 dans le sens direct + call nusotr( nt1, mosoar, nosoar, moartr, noartr, nosotr ) +c +c reperage du sommet ns dans nt1 + do 50 nar=1,3 + if( nosotr(nar) .eq. ns ) goto 60 + 50 continue + nta = nt1 + goto 9995 +c +c nt1 est empile + 60 if( lhpile .ge. mxpile ) goto 9990 + lhpile = lhpile + 1 + lapile(lhpile) = nt1 +c +c l'arete qui precede dans le sens direct + if( nar .eq. 1 ) then + nar = 3 + else + nar = nar - 1 + endif +c +c l'arete de sommet ns dans nosoar + noar = abs( noartr(nar,nt1) ) +c +c le triangle voisin de nta dans le sens direct + nta = nt1 + if( nosoar(4,noar) .eq. nt1 ) then + nt1 = nosoar(5,noar) + else + nt1 = nosoar(4,noar) + endif + nta = nt1 + if( nt1 .gt. 0 ) goto 40 +c +c butee sur le trou => fin des triangles de sommet ns +c ---------------------------------------------------- + 70 lhpile = -lhpile +c impossible ici de trouver les autres triangles de sommet ns +c les triangles de sommet ns ne forment pas une boule de centre ns + return +c +c saturation de la pile des triangles +c ----------------------------------- + 9990 write(imprim,*) 'trp1st:saturation pile des triangles autour ', + %'sommet',ns + goto 9999 +c +c erreur triangle ne contenant pas le sommet ns +c ---------------------------------------------- + 9995 write(imprim,*) 'trp1st:triangle ',nta,' st=', + % (nosotr(nar),nar=1,3),' sans le sommet' ,ns +c + 9999 lhpile = 0 + return + end + + + + subroutine nusotr( nt, mosoar, nosoar, moartr, noartr, nosotr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul du numero des 3 sommets du triangle nt de noartr +c ----- dans le sens direct (aire>0 si non degenere) +c +c entrees: +c -------- +c nt : numero du triangle dans le tableau noartr +c mosoar : nombre maximal d'entiers par arete +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c moartr : nombre maximal d'entiers par arete du tableau noartr +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1=0 si triangle vide => arete2=triangle vide suivant +c +c sorties: +c -------- +c nosotr : numero (dans le tableau pxyd) des 3 sommets du triangle +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + integer nosoar(mosoar,*), noartr(moartr,*), nosotr(3) +c +c les 2 sommets de l'arete 1 du triangle nt dans le sens direct + na = noartr( 1, nt ) + if( na .gt. 0 ) then + nosotr(1) = 1 + nosotr(2) = 2 + else + nosotr(1) = 2 + nosotr(2) = 1 + na = -na + endif + nosotr(1) = nosoar( nosotr(1), na ) + nosotr(2) = nosoar( nosotr(2), na ) +c +c l'arete suivante + na = abs( noartr(2,nt) ) +c +c le sommet nosotr(3 du triangle 123 + nosotr(3) = nosoar( 1, na ) + if( nosotr(3) .eq. nosotr(1) .or. nosotr(3) .eq. nosotr(2) ) then + nosotr(3) = nosoar(2,na) + endif + end + + + subroutine tesusp( nbarpi, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, notrcf, liarcf, + % nbstsu, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : supprimer de la triangulation les sommets de te trop proches +c ----- soit d'un sommet frontalier ou point interne impose +c soit d'une arete frontaliere +c +c attention: le chainage lchain de nosoar devient celui des cf +c +c entrees: +c -------- +c nbarpi : numero du dernier point interne impose par l'utilisateur +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxarcf : nombre de variables des tableaux n1arcf, noarcf, larmin, notrcf +c +c modifies: +c --------- +c noarst : noarst(i) numero d'une arete de sommet i +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c +c auxiliaires : +c ------------- +c n1arcf : tableau (0:mxarcf) auxiliaire d'entiers +c noarcf : tableau (3,mxarcf) auxiliaire d'entiers +c larmin : tableau ( mxarcf ) auxiliaire d'entiers +c notrcf : tableau ( mxarcf ) auxiliaire d'entiers +c liarcf : tableau ( mxarcf ) auxiliaire d'entiers +c +c sortie : +c -------- +c nbstsu : nombre de sommets de te supprimes +c ierr : =0 si pas d'erreur +c >0 si une erreur est survenue +c 11 algorithme defaillant +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 +c parameter ( quamal=0.3 ) => ok +c parameter ( quamal=0.4 ) => pb pour le test ocean +c parameter ( quamal=0.5 ) => pb pour le test ocean +c + parameter ( quamal=0.333, lchain=6 ) + common / unites / lecteu,imprim,intera,nunite(29) + double precision pxyd(3,*), qualit + integer nosoar(mosoar,mxsoar), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf), + % notrcf(mxarcf), + % liarcf(mxarcf) +c + integer nosotr(3) + equivalence (nosotr(1),ns1), (nosotr(2),ns2), + % (nosotr(3),ns3) +c +c le nombre de sommets de te supprimes + nbstsu = 0 +c +c initialisation du chainage des aretes des cf => 0 arete de cf + do 10 narete=1,mxsoar + nosoar( lchain, narete ) = -1 + 10 continue +c +c boucle sur l'ensemble des sommets frontaliers ou points internes +c ================================================================ + do 100 ns = 1, nbarpi +c +cccc le nombre de sommets supprimes pour ce sommet ns +ccc nbsuns = 0 +c +c la qualite minimale au dessous de laquelle le point proche +c interne est supprime + quaopt = quamal +c +c une arete de sommet ns + 15 narete = noarst( ns ) + if( narete .le. 0 ) then +c erreur: le point appartient a aucune arete + write(imprim,*) 'sommet ',ns,' dans aucune arete' + pause + ierr = 11 + return + endif +c +c recherche des triangles de sommet ns +c ils doivent former un contour ferme de type etoile + call trp1st( ns, noarst, mosoar, nosoar, moartr, noartr, + % mxarcf, nbtrcf, notrcf ) + if( nbtrcf .le. 0 ) then +c erreur: impossible de trouver tous les triangles de sommet ns +c seule une partie est a priori retrouvee + nbtrcf = -nbtrcf + endif +c +c boucle sur les triangles de l'etoile du sommet ns + quamin = 2.0 + do 20 i=1,nbtrcf +c +c le numero des 3 sommets du triangle nt + nt = notrcf(i) + call nusotr( nt, mosoar, nosoar, moartr, noartr, + % nosotr ) +c nosotr(1:3) est en equivalence avec ns1, ns2, ns3 +c +c la qualite du triangle ns1 ns2 ns3 + call qutr2d( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3), qualit ) + if( qualit .lt. quamin ) then + quamin = qualit + ntqmin = nt + endif + 20 continue +c +c bilan sur la qualite des triangles de sommet ns + if( quamin .lt. quaopt ) then +c +c recherche du sommet de ntqmin le plus proche et non frontalier +c ============================================================== +c le numero des 3 sommets du triangle nt + call nusotr( ntqmin, mosoar, nosoar, moartr, noartr, + % nosotr ) + nste = 0 + quamin = 1e28 + do 30 j=1,3 + if( nosotr(j) .ne. ns .and. nosotr(j) .gt. nbarpi ) then + d = (pxyd(1,nosotr(j))-pxyd(1,ns))**2 + % + (pxyd(2,nosotr(j))-pxyd(2,ns))**2 + if( d .lt. quamin ) then + quamin = d + nste = j + endif + endif + 30 continue +c + if( nste .gt. 0 ) then +c +c nste est le sommet le plus proche de ns de ce +c triangle de mauvaise qualite et sommet non encore traite + nste = nosotr( nste ) +c +c nste est un sommet de triangle equilateral +c => le sommet nste va etre supprime +c ========================================== + call te1stm( nste, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, + % larmin, notrcf, liarcf, ierr ) + if( ierr .eq. 0 ) then +c un sommet de te supprime de plus + nbstsu = nbstsu + 1 + else if( ierr .lt. 0 ) then +c le sommet nste est externe donc non supprime +c ou bien le sommet nste est le centre d'un cf dont toutes +c les aretes simples sont frontalieres +c dans les 2 cas le sommet n'est pas supprime + ierr = 0 + goto 100 + else +c erreur motivant un arret de la triangulation + return + endif +c +c boucle jusqu'a obtenir une qualite suffisante +c si triangulation tres irreguliere => +c destruction de beaucoup de points internes +c les 2 variables suivantes brident ces destructions massives +ccc nbsuns = nbsuns + 1 + quaopt = quaopt * 0.8 +ccc if( nbsuns .le. 5 ) goto 15 + goto 15 + endif + endif +c + 100 continue + end + + + subroutine teamqa( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxtrcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but: si la taille de l'arete moyenne est >ampli*taille souhaitee +c ---- alors ajout d'un sommet barycentre du plus grand triangle +c de sommet ns +c si la taille de l'arete moyenne est aretmx active +c 1 il existe une fonction areteideale() +c dont seules les 2 premieres composantes de uv sont actives +c autres options a definir... +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes frontalieres declarables +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles declarables dans noartr +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c mxtrcf : nombre maximal de triangles empilables +c nbarpi : numero du dernier sommet frontalier ou interne impose +c nslign : tableau du numero de sommet dans sa ligne pour chaque +c sommet frontalier +c numero du point dans le lexique point si interne impose +c 0 si le point est interne non impose par l'utilisateur +c -1 si le sommet est externe au domaine +c comxmi : min et max des coordonneees des sommets du maillage +c +c modifies : +c ---------- +c nbsomm : nombre actuel de sommets de la triangulation +c (certains sommets internes ont ete desactives ou ajoutes) +c pxyd : tableau des coordonnees 2d des points +c +c auxiliaires: +c ------------ +c notrcf : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans noartr des triangles de sommet ns +c nostbo : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans pxyd des sommets des aretes simples de la boule +c n1arcf : tableau (0:mxtrcf) auxiliaire d'entiers +c noarcf : tableau (3,mxtrcf) auxiliaire d'entiers +c larmin : tableau ( mxtrcf ) auxiliaire d'entiers +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juin 1997 +c....................................................................012 + double precision ampli,ampli2 + parameter (ampli=1.34d0,ampli2=ampli/2d0) + parameter (lchain=6) + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + double precision ponder, ponde1, xbar, ybar, x, y, surtd2 + double precision d, dmoy + double precision d2d3(3,3) + real origin(3), xyz(3) + integer noartr(moartr,*), + % nosoar(mosoar,*), + % noarst(*), + % notrcf(mxtrcf), + % nslign(*), + % nostbo(*), + % n1arcf(0:mxtrcf), + % noarcf(3,mxtrcf), + % larmin(mxtrcf) + double precision comxmi(3,2) + integer nosotr(3) +c +c le nombre d'iterations pour ameliorer la qualite + nbitaq = 4 + ier = 0 +c +c initialisation du parcours + nbs1 = nbsomm + nbs2 = nbarpi + 1 + nbs3 = -1 +c + do 5000 iter=1,nbitaq +c +c le nombre de sommets supprimes + nbstsu = 0 + nbbaaj = 0 +c +c coefficient de ponderation croissant avec les iterations + ponder = min( 1d0, ( 50 + (50*iter)/nbitaq ) * 0.01d0 ) + ponde1 = 1d0 - ponder +c +c l'ordre du parcours dans le sens croissant ou decroissant + nt = nbs1 + nbs1 = nbs2 + nbs2 = nt +c alternance du parcours + nbs3 = -nbs3 +c + do 1000 ns = nbs1, nbs2, nbs3 +c +c le sommet est il interne au domaine? + if( nslign(ns) .ne. 0 ) goto 1000 +c +c existe-t-il une arete de sommet ns ? + 10 noar = noarst( ns ) + if( noar .le. 0 ) goto 1000 +c +c le 1-er triangle de l'arete noar + nt = nosoar( 4, noar ) + if( nt .le. 0 ) goto 1000 +c +c recherche des triangles de sommet ns +c ils doivent former un contour ferme de type etoile + call trp1st( ns, noarst, mosoar, nosoar, moartr, noartr, + % mxtrcf, nbtrcf, notrcf ) + if( nbtrcf .le. 0 ) goto 1000 +c +c mise a jour de la distance souhaitee + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,ns) dans le repere initial => xyz(1:3) + call tetaid( nutysu, pxyd(1,ns), pxyd(2,ns), + % pxyd(3,ns), ier ) + endif +c +c boucle sur les triangles qui forment une boule autour du sommet ns + nbstbo = 0 +c chainage des aretes simples de la boule a rendre delaunay + noar0 = 0 + do 40 i=1,nbtrcf +c +c le numero de l'arete du triangle nt ne contenant pas le sommet ns + nt = notrcf(i) + do 20 na=1,3 +c le numero de l'arete na dans le tableau nosoar + noar = abs( noartr(na,nt) ) + if( nosoar(1,noar) .ne. ns .and. + % nosoar(2,noar) .ne. ns ) goto 25 + 20 continue +c +c construction de la liste des sommets des aretes simples +c de la boule des triangles de sommet ns +c ------------------------------------------------------- + 25 do 35 na=1,2 + ns1 = nosoar(na,noar) + do 30 j=nbstbo,1,-1 + if( ns1 .eq. nostbo(j) ) goto 35 + 30 continue +c ns1 est un nouveau sommet a ajouter + nbstbo = nbstbo + 1 + nostbo(nbstbo) = ns1 + 35 continue +c +c noar est une arete potentielle a rendre delaunay + if( nosoar(3,noar) .eq. 0 ) then +c arete non frontaliere + nosoar(lchain,noar) = noar0 + noar0 = noar + endif +c + 40 continue +c +c calcul des 2 coordonnees du barycentre de la boule du sommet ns +c calcul de la longueur moyenne des aretes issues du sommet ns +c --------------------------------------------------------------- + xbar = 0d0 + ybar = 0d0 + dmoy = 0d0 + do 50 i=1,nbstbo + x = pxyd(1,nostbo(i)) + y = pxyd(2,nostbo(i)) + xbar = xbar + x + ybar = ybar + y + dmoy = dmoy + sqrt( (x-pxyd(1,ns))**2+(y-pxyd(2,ns))**2 ) + 50 continue + dmoy = dmoy / nbstbo +c +c pas de modification de la topologie lors de la derniere iteration +c ================================================================= + if( iter .eq. nbitaq ) goto 200 +c +c si la taille de l'arete moyenne est >ampli*taille souhaitee +c alors ajout d'un sommet barycentre du plus grand triangle +c de sommet ns +c =========================================================== + if( dmoy .gt. ampli*pxyd(3,ns) ) then +c + dmoy = 0d0 + do 150 i=1,nbtrcf +c recherche du plus grand triangle en surface + call nusotr( notrcf(i), mosoar, nosoar, + % moartr, noartr, nosotr ) + d = surtd2( pxyd(1,nosotr(1)), + % pxyd(1,nosotr(2)), + % pxyd(1,nosotr(3)) ) + if( d .gt. dmoy ) then + dmoy = d + imax = i + endif + 150 continue +c +c ajout du barycentre du triangle notrcf(imax) + nt = notrcf( imax ) + call nusotr( nt, mosoar, nosoar, + % moartr, noartr, nosotr ) + if( nbsomm .ge. mxsomm ) then + write(imprim,*) 'saturation du tableau pxyd' +c abandon de l'amelioration du sommet ns + goto 9999 + endif + nbsomm = nbsomm + 1 + do 160 i=1,3 + pxyd(i,nbsomm) = ( pxyd(i,nosotr(1)) + % + pxyd(i,nosotr(2)) + % + pxyd(i,nosotr(3)) ) / 3d0 + 160 continue +c + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,nbsomm) dans le repere initial => xyz(1:3) + call tetaid( nutysu, pxyd(1,nbsomm), pxyd(2,nbsomm), + % pxyd(3,nbsomm), ier ) + endif +c +c sommet interne a la triangulation + nslign(nbsomm) = 0 +c +c les 3 aretes du triangle nt sont a rendre delaunay + do 170 i=1,3 + noar = abs( noartr(i,nt) ) + if( nosoar(3,noar) .eq. 0 ) then +c arete non frontaliere + if( nosoar(lchain,noar) .lt. 0 ) then +c arete non encore chainee + nosoar(lchain,noar) = noar0 + noar0 = noar + endif + endif + 170 continue +c +c triangulation du triangle de barycentre nbsomm +c protection a ne pas modifier sinon erreur! + call tr3str( nbsomm, nt, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nosotr, ierr ) + if( ierr .ne. 0 ) goto 9999 +c +c un barycentre ajoute de plus + nbbaaj = nbbaaj + 1 +c +c les aretes chainees de la boule sont rendues delaunay + goto 900 +c + endif +c +c si la taille de l'arete moyenne est xyz(1:3) + call tetaid( nutysu, pxyd(1,ns), pxyd(2,ns), + % pxyd(3,ns), ier ) + endif +c +c les aretes chainees de la boule sont rendues delaunay + 900 call tedela( pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, noar0, + % moartr, mxartr, n1artr, noartr, modifs ) +c + 1000 continue +c +ccc write(imprim,11000) nbstsu, nbbaaj +ccc11000 format( i6,' sommets supprimes ' , +ccc % i6,' barycentres ajoutes' ) +c +c mise a jour pour ne pas oublier les nouveaux sommets + if( nbs1 .gt. nbs2 ) then + nbs1 = nbsomm + else + nbs2 = nbsomm + endif +c + 5000 continue +c + 9999 return + end + + + subroutine teamsf( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxtrcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : modification de la topologie des triangles autour des +c ----- sommets frontaliers et mise en triangulation delaunay locale +c +c entrees: +c -------- +c nutysu : numero de traitement de areteideale() selon le type de surface +c 0 pas d'emploi de la fonction areteideale() => aretmx active +c 1 il existe une fonction areteideale() +c dont seules les 2 premieres composantes de uv sont actives +c autres options a definir... +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes frontalieres declarables +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles declarables dans noartr +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c mxtrcf : nombre maximal de triangles empilables +c nbarpi : numero du dernier sommet frontalier ou interne impose +c nslign : >0 => ns numero du point dans le lexique point si interne impose +c ou => 1 000 000 * n + ns1 +c ou n est le numero (1 a nblftr) de la ligne de ce point +c ns1 est le numero du point dans sa ligne +c = 0 si le point est interne non impose par l'utilisateur +c =-1 si le sommet est externe au domaine +c comxmi : min et max des coordonneees des sommets du maillage +c +c modifies : +c ---------- +c nbsomm : nombre actuel de sommets de la triangulation +c (certains sommets internes ont ete desactives ou ajoutes) +c pxyd : tableau des coordonnees 2d des points +c +c auxiliaires: +c ------------ +c notrcf : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans noartr des triangles de sommet ns +c nostbo : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans pxyd des sommets des aretes simples de la boule +c n1arcf : tableau (0:mxtrcf) auxiliaire d'entiers +c noarcf : tableau (3,mxtrcf) auxiliaire d'entiers +c larmin : tableau ( mxtrcf ) auxiliaire d'entiers +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc janvier 1998 +c....................................................................012 + parameter (lchain=6) + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + double precision a, angle, angled, pi, deuxpi, pis3 + double precision d2d3(3,3) + real origin(3), xyz(3) + integer noartr(moartr,*), + % nosoar(mosoar,*), + % noarst(*), + % notrcf(mxtrcf), + % nslign(*), + % nostbo(*), + % n1arcf(0:mxtrcf), + % noarcf(3,mxtrcf), + % larmin(mxtrcf), + % nosotr(3) + double precision comxmi(3,2) +c +c le nombre d'iterations pour ameliorer la qualite + nbitaq = 2 + ier = 0 +c +c pi / 3 + pi = atan(1d0) * 4d0 + pis3 = pi / 3d0 + deuxpi = 2d0 * pi +c +c initialisation du parcours + modifs = 0 + nbs1 = nbarpi + nbs2 = 1 +c => pas de traitement sur les points des lignes de la frontiere + nbs3 = -1 +c + do 5000 iter=1,nbitaq +c +c le nombre de sommets supprimes + nbstsu = 0 +c +c l'ordre du parcours dans le sens croissant ou decroissant + nt = nbs1 + nbs1 = nbs2 + nbs2 = nt +c alternance du parcours + nbs3 = -nbs3 +c + do 1000 ns = nbs1, nbs2, nbs3 +c +c le sommet est il sur une ligne de la frontiere? +c if( nslign(ns) .lt. 1 000 000 ) goto 1000 +c +c traitement d'un sommet d'une ligne de la frontiere +c ================================================== +c existe-t-il une arete de sommet ns ? + noar = noarst( ns ) + if( noar .le. 0 ) goto 1000 +c +c le 1-er triangle de l'arete noar + nt = nosoar( 4, noar ) + if( nt .le. 0 ) goto 1000 +c +c recherche des triangles de sommet ns +c ils doivent former un contour ferme de type camembert + call trp1st( ns, noarst, mosoar, nosoar, moartr, noartr, + % mxtrcf, nbtrcf, notrcf ) + if( nbtrcf .ge. -1 ) goto 1000 +c +c boucle sur les triangles qui forment un camembert autour du sommet n + nbtrcf = -nbtrcf +c +c angle interne au camembert autour du sommet ns + angle = 0d0 + do 540 i=1,nbtrcf +c +c le numero de l'arete du triangle nt ne contenant pas le sommet ns + nt = notrcf(i) + do 520 na=1,3 +c le numero de l'arete na dans le tableau nosoar + noar = abs( noartr(na,nt) ) + if( nosoar(1,noar) .ne. ns .and. + % nosoar(2,noar) .ne. ns ) goto 525 + 520 continue +c +c calcul de l'angle (ns-st1 arete, ns-st2 arete) + 525 ns1 = nosoar(1,noar) + ns2 = nosoar(2,noar) + a = angled( pxyd(1,ns), pxyd(1,ns1), pxyd(1,ns2) ) + if( a .gt. pi ) a = deuxpi - a + angle = angle + a +c + 540 continue +c +c nombre ideal de triangles autour du sommet ns + n = nint( angle / pis3 ) + if( n .le. 1 ) goto 1000 + i = 1 + if( nbtrcf .gt. n ) then +c +c ajout du barycentre du triangle "milieu" + nt = notrcf( (n+1)/2 ) + call nusotr( nt, mosoar, nosoar, + % moartr, noartr, nosotr ) + if( nbsomm .ge. mxsomm ) then + write(imprim,*) 'saturation du tableau pxyd' +c abandon de l'amelioration du sommet ns + goto 1000 + endif + nbsomm = nbsomm + 1 + do 560 i=1,3 + pxyd(i,nbsomm) = ( pxyd(i,nosotr(1)) + % + pxyd(i,nosotr(2)) + % + pxyd(i,nosotr(3)) ) / 3d0 + 560 continue +c + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,nbsomm) dans le repere initial => xyz(1:3) + call tetaid( nutysu, pxyd(1,nbsomm), pxyd(2,nbsomm), + % pxyd(3,nbsomm), ier ) + endif +c +c sommet interne a la triangulation + nslign(nbsomm) = 0 +c +c les 3 aretes du triangle nt sont a rendre delaunay + noar0 = 0 + do 570 i=1,3 + noar = abs( noartr(i,nt) ) + if( nosoar(3,noar) .eq. 0 ) then +c arete non frontaliere + if( nosoar(lchain,noar) .lt. 0 ) then +c arete non encore chainee + nosoar(lchain,noar) = noar0 + noar0 = noar + endif + endif + 570 continue +c +c triangulation du triangle de barycentre nbsomm +c protection a ne pas modifier sinon erreur! + call tr3str( nbsomm, nt, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nosotr, ierr ) + if( ierr .ne. 0 ) goto 9999 +c +c les aretes chainees de la boule sont rendues delaunay + call tedela( pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, noar0, + % moartr, mxartr, n1artr, noartr, modifs ) + endif +c + 1000 continue +c + 5000 continue +c + 9999 return + end + + + subroutine teamqs( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxtrcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : une iteration de barycentrage des points internes +c ----- modification de la topologie pour avoir 4 ou 5 ou 6 triangles +c pour chaque sommet de la triangulation +c mise en triangulation delaunay +c +c entrees: +c -------- +c nutysu : numero de traitement de areteideale() selon le type de surface +c 0 pas d'emploi de la fonction areteideale() => aretmx active +c 1 il existe une fonction areteideale() +c dont seules les 2 premieres composantes de uv sont actives +c autres options a definir... +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes frontalieres declarables +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles declarables dans noartr +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c mxtrcf : nombre maximal de triangles empilables +c nbarpi : numero du dernier sommet frontalier ou interne impose +c nslign : >0 => ns numero du point dans le lexique point si interne impose +c ou => 1 000 000 * n + ns1 +c ou n est le numero (1 a nblftr) de la ligne de ce point +c ns1 est le numero du point dans sa ligne +c = 0 si le point est interne non impose par l'utilisateur +c =-1 si le sommet est externe au domaine +c comxmi : min et max des coordonneees des sommets du maillage +c +c modifies : +c ---------- +c nbsomm : nombre actuel de sommets de la triangulation +c (certains sommets internes ont ete desactives ou ajoutes) +c pxyd : tableau des coordonnees 2d des points +c +c auxiliaires: +c ------------ +c notrcf : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans noartr des triangles de sommet ns +c nostbo : tableau ( mxtrcf ) auxiliaire d'entiers +c numero dans pxyd des sommets des aretes simples de la boule +c n1arcf : tableau (0:mxtrcf) auxiliaire d'entiers +c noarcf : tableau (3,mxtrcf) auxiliaire d'entiers +c larmin : tableau ( mxtrcf ) auxiliaire d'entiers +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mai 1997 +c....................................................................012 + parameter (lchain=6) + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + double precision ponder, ponde1, xbar, ybar, x, y, d, dmin, dmax + double precision d2d3(3,3) + real origin(3), xyz(3) + integer noartr(moartr,*), + % nosoar(mosoar,*), + % noarst(*), + % notrcf(mxtrcf), + % nslign(*), + % nostbo(*), + % n1arcf(0:mxtrcf), + % noarcf(3,mxtrcf), + % larmin(mxtrcf) + integer nosotr(3,2) + double precision comxmi(3,2) +c +c le nombre d'iterations pour ameliorer la qualite + nbitaq = 6 + ier = 0 +c +c initialisation du parcours + nbs1 = nbsomm + nbs2 = nbarpi + 1 +c => pas de traitement sur les points des lignes de la frontiere + nbs3 = -1 +c + do 5000 iter=1,nbitaq +c +c le nombre de sommets supprimes + nbstsu = 0 +c +c les compteurs de passage sur les differents cas + nbst4 = 0 + nbst5 = 0 + nbst8 = 0 +c +c coefficient de ponderation croissant avec les iterations + ponder = min( 1d0, ( 50 + (50*iter)/nbitaq ) * 0.01d0 ) + ponde1 = 1d0 - ponder +c +c l'ordre du parcours dans le sens croissant ou decroissant + nt = nbs1 + nbs1 = nbs2 + nbs2 = nt +c alternance du parcours + nbs3 = -nbs3 +c + do 1000 ns = nbs1, nbs2, nbs3 +c +c le sommet est il interne au domaine? + if( nslign(ns) .ne. 0 ) goto 1000 +c +c traitement d'un sommet interne non impose par l'utilisateur +c =========================================================== +c existe-t-il une arete de sommet ns ? + 10 noar = noarst( ns ) + if( noar .le. 0 ) goto 1000 +c +c le 1-er triangle de l'arete noar + nt = nosoar( 4, noar ) + if( nt .le. 0 ) goto 1000 +c +c recherche des triangles de sommet ns +c ils doivent former un contour ferme de type etoile + call trp1st( ns, noarst, mosoar, nosoar, moartr, noartr, + % mxtrcf, nbtrcf, notrcf ) + if( nbtrcf .le. 0 ) goto 1000 +c +c boucle sur les triangles qui forment une boule autour du sommet ns + nbstbo = 0 +c chainage des aretes simples de la boule a rendre delaunay + noar0 = 0 + do 40 i=1,nbtrcf +c +c le numero de l'arete du triangle nt ne contenant pas le sommet ns + nt = notrcf(i) + do 20 na=1,3 +c le numero de l'arete na dans le tableau nosoar + noar = abs( noartr(na,nt) ) + if( nosoar(1,noar) .ne. ns .and. + % nosoar(2,noar) .ne. ns ) goto 25 + 20 continue +c +c construction de la liste des sommets des aretes simples +c de la boule des triangles de sommet ns +c ------------------------------------------------------- + 25 do 35 na=1,2 + ns1 = nosoar(na,noar) + do 30 j=nbstbo,1,-1 + if( ns1 .eq. nostbo(j) ) goto 35 + 30 continue +c ns1 est un nouveau sommet a ajouter + nbstbo = nbstbo + 1 + nostbo(nbstbo) = ns1 + 35 continue +c +c noar est une arete potentielle a rendre delaunay + if( nosoar(3,noar) .eq. 0 ) then +c arete non frontaliere + nosoar(lchain,noar) = noar0 + noar0 = noar + endif +c + 40 continue +c +c calcul des 2 coordonnees du barycentre de la boule du sommet ns +c calcul de l'arete de taille maximale et minimale issue de ns +c --------------------------------------------------------------- + xbar = 0d0 + ybar = 0d0 + dmin = 1d28 + dmax = 0d0 + do 50 i=1,nbstbo + x = pxyd(1,nostbo(i)) + y = pxyd(2,nostbo(i)) + xbar = xbar + x + ybar = ybar + y + d = (x-pxyd(1,ns)) ** 2 + (y-pxyd(2,ns)) ** 2 + if( d .gt. dmax ) then + dmax = d + imax = i + endif + if( d .lt. dmin ) then + dmin = d + imin = i + endif + 50 continue +c +c pas de modification de la topologie lors de la derniere iteration +c ================================================================= + if( iter .ge. nbitaq ) goto 200 +c +c si la boule de ns contient 3 ou 4 triangles le sommet ns est detruit +c ==================================================================== + if( nbtrcf .le. 4 ) then +c +c remise a -1 du chainage des aretes peripheriques de la boule ns + noar = noar0 + 60 if( noar .gt. 0 ) then +c protection du no de l'arete suivante + na = nosoar(lchain,noar) +c l'arete interne est remise a -1 + nosoar(lchain,noar) = -1 +c l'arete suivante + noar = na + goto 60 + endif + call te1stm( ns, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxtrcf, n1arcf, noarcf, + % larmin, notrcf, nostbo, + % ierr ) + if( ierr .lt. 0 ) then +c le sommet ns est externe donc non supprime +c ou bien le sommet ns est le centre d'un cf dont toutes +c les aretes simples sont frontalieres +c dans les 2 cas le sommet ns n'est pas supprime + ierr = 0 + goto 200 + else if( ierr .eq. 0 ) then + nbst4 = nbst4 + 1 + nbstsu = nbstsu + 1 + else +c erreur irrecuperable + goto 9999 + endif + goto 1000 +c + endif +c +c si la boule de ns contient 5 triangles et a un sommet voisin +c sommet de 5 triangles alors l'arete joignant ces 2 sommets +c est transformee en un seul sommet de 6 triangles +c ============================================================ + if( nbtrcf .eq. 5 ) then +c + do 80 i=1,5 +c le numero du sommet de l'arete i et different de ns + ns1 = nostbo(i) +c la liste des triangles de sommet ns1 + call trp1st( ns1, noarst, + % mosoar, nosoar, moartr, noartr, + % mxtrcf-5, nbtrc1, notrcf(6) ) + if( nbtrc1 .eq. 5 ) then +c +c l'arete de sommets ns-ns1 devient un point +c par suppression du sommet ns +c +c remise a -1 du chainage des aretes peripheriques de la boul + noar = noar0 + 70 if( noar .gt. 0 ) then +c protection du no de l'arete suivante + na = nosoar(lchain,noar) +c l'arete interne est remise a -1 + nosoar(lchain,noar) = -1 +c l'arete suivante + noar = na + goto 70 + endif +c +c le point ns1 devient le milieu de l'arete ns-ns1 + do 75 j=1,3 + pxyd(j,ns1) = (pxyd(j,ns) + pxyd(j,ns1)) * 0.5d0 + 75 continue +c + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,ns1) dans le repere initial => xyz(1:3 + call tetaid( nutysu,pxyd(1,ns1),pxyd(2,ns1), + % pxyd(3,ns1), ier ) + endif +c +c suppression du point ns et mise en delaunay + call te1stm( ns, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxtrcf, n1arcf, noarcf, + % larmin, notrcf, nostbo, + % ierr ) + if( ierr .lt. 0 ) then +c le sommet ns est externe donc non supprime +c ou bien le sommet ns est le centre d'un cf dont toutes +c les aretes simples sont frontalieres +c dans les 2 cas le sommet ns n'est pas supprime + ierr = 0 + goto 200 + else if( ierr .eq. 0 ) then + nbstsu = nbstsu + 1 + nbst5 = nbst5 + 1 + goto 1000 + else +c erreur irrecuperable + goto 9999 + endif + endif + 80 continue + endif +c +c si la boule de ns contient au moins 8 triangles +c alors un triangle interne est ajoute + 3 triangles (1 par arete) +c ================================================================ + if( nbtrcf .ge. 8 ) then +c +c modification des coordonnees du sommet ns +c il devient le barycentre du triangle notrcf(1) + call nusotr( notrcf(1), mosoar, nosoar, + % moartr, noartr, nosotr ) + do 110 i=1,3 + pxyd(i,ns) = ( pxyd(i,nosotr(1,1)) + % + pxyd(i,nosotr(2,1)) + % + pxyd(i,nosotr(3,1)) ) / 3d0 + 110 continue +c + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,nbsomm) dans le repere initial => xyz(1:3) + call tetaid( nutysu, pxyd(1,ns), pxyd(2,ns), + % pxyd(3,ns), ier ) + endif +c +c ajout des 2 autres sommets comme barycentres des triangles +c notrcf(1+nbtrcf/3) et notrcf(1+2*nbtrcf/3) + nbt1 = ( nbtrcf + 1 ) / 3 + do 140 n=1,2 +c +c le triangle traite + nt = notrcf(1 + n * nbt1 ) +c +c le numero pxyd de ses 3 sommets + call nusotr( nt, mosoar, nosoar, + % moartr, noartr, nosotr ) +c +c ajout du nouveau barycentre + if( nbsomm .ge. mxsomm ) then + write(imprim,*) 'saturation du tableau pxyd' +c abandon de l'amelioration + goto 1100 + endif + nbsomm = nbsomm + 1 + do 120 i=1,3 + pxyd(i,nbsomm) = ( pxyd(i,nosotr(1,1)) + % + pxyd(i,nosotr(2,1)) + % + pxyd(i,nosotr(3,1)) ) / 3d0 + 120 continue +c + if( nutysu .gt. 0 ) then +c la fonction taille_ideale(x,y,z) existe +c calcul de pxyzd(3,nbsomm) dans le repere initial => xyz(1:3 + call tetaid( nutysu, pxyd(1,nbsomm),pxyd(2,nbsomm), + % pxyd(3,nbsomm), ier ) + endif +c +c sommet interne a la triangulation + nslign(nbsomm) = 0 +c +c les 3 aretes du triangle nt sont a rendre delaunay + do 130 i=1,3 + noar = abs( noartr(i,nt) ) + if( nosoar(3,noar) .eq. 0 ) then +c arete non frontaliere + if( nosoar(lchain,noar) .lt. 0 ) then +c arete non encore chainee + nosoar(lchain,noar) = noar0 + noar0 = noar + endif + endif + 130 continue +c +c triangulation du triangle de barycentre nbsomm +c protection a ne pas modifier sinon erreur! + call tr3str( nbsomm, nt, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nosotr, ierr ) + if( ierr .ne. 0 ) goto 9999 + 140 continue +c + nbst8 = nbst8 + 1 +c +c les aretes chainees de la boule sont rendues delaunay + goto 300 +c + endif +c +c nbtrcf est compris entre 5 et 7 => barycentrage simple +c ====================================================== +c les 2 coordonnees du barycentre des sommets des aretes +c simples de la boule du sommet ns + 200 xbar = xbar / nbstbo + ybar = ybar / nbstbo +c +c ponderation pour eviter les degenerescenses + pxyd(1,ns) = ponde1 * pxyd(1,ns) + ponder * xbar + pxyd(2,ns) = ponde1 * pxyd(2,ns) + ponder * ybar +c +c les aretes chainees de la boule sont rendues delaunay + 300 call tedela( pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, noar0, + % moartr, mxartr, n1artr, noartr, modifs ) +c + 1000 continue +c +c trace de la triangulation actuelle et calcul de la qualite + 1100 continue +c +ccc write(imprim,11000) nbst4, nbst5, nbst8 +ccc11000 format( i7,' sommets de 4t', +ccc % i7,' sommets 5t+5t', +ccc % i7,' sommets >7t' ) +c +c mise a jour pour ne pas oublier les nouveaux sommets + if( nbs1 .gt. nbs2 ) then + nbs1 = nbsomm + nbs2 = nbarpi + 1 + else + nbs1 = nbarpi + 1 + nbs2 = nbsomm + endif +c + 5000 continue +c + 9999 return + end + + + subroutine teamqt( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : amelioration de la qualite de la triangulation issue de teabr4 +c ----- +c +c entrees: +c -------- +c nutysu : numero de traitement de areteideale() selon le type de surface +c 0 pas d'emploi de la fonction areteideale() => aretmx active +c 1 il existe une fonction areteideale() +c dont seules les 2 premieres composantes de uv sont actives +c autres options a definir... +c noarst : noarst(i) numero d'une arete de sommet i +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes frontalieres declarables +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles declarables dans noartr +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c mxarcf : nombre maximal de triangles empilables +c nbarpi : numero du dernier sommet frontalier ou interne impose +c nslign : tableau du numero de sommet dans sa ligne pour chaque +c sommet frontalier +c numero du point dans le lexique point si interne impose +c 0 si le point est interne non impose par l'utilisateur +c -1 si le sommet est externe au domaine +c comxmi : min et max des coordonneees des sommets du maillage +c +c modifies : +c ---------- +c nbsomm : nombre actuel de sommets de la triangulation +c (certains sommets internes ont ete desactives ou ajoutes) +c pxyd : tableau des coordonnees 2d des points +c +c auxiliaires: +c ------------ +c notrcf : tableau ( mxarcf ) auxiliaire d'entiers +c numero dans noartr des triangles de sommet ns +c nostbo : tableau ( mxarcf ) auxiliaire d'entiers +c numero dans pxyd des sommets des aretes simples de la boule +c n1arcf : tableau (0:mxarcf) auxiliaire d'entiers +c noarcf : tableau (3,mxarcf) auxiliaire d'entiers +c larmin : tableau ( mxarcf ) auxiliaire d'entiers +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juin 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*), d2d3(3,3) + integer noartr(moartr,*), + % nosoar(mosoar,*), + % noarst(*), + % notrcf(mxarcf), + % nslign(*), + % nostbo(mxarcf), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf) + double precision comxmi(3,2) +c +c suppression des sommets de triangles equilateraux trop proches +c d'un sommet frontalier ou d'un point interne impose par +c triangulation frontale de l'etoile et mise en delaunay +c ============================================================== + call tesusp( nbarpi, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, notrcf, nostbo, + % nbstsu, ierr ) + if( ierr .ne. 0 ) goto 9999 +c write(imprim,*) 'retrait de',nbstsu, +c % ' sommets de te trop proches de la frontiere' +c +c ajustage des tailles moyennes des aretes avec ampli=1.34d0 entre +c ampli/2 x taille_souhaitee et ampli x taille_souhaitee +c + barycentrage des sommets et mise en triangulation delaunay +c ================================================================ + call teamqa( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) + if( ierr .ne. 0 ) goto 9999 +c +c modification de la topologie autour des sommets frontaliers +c pour avoir un nombre de triangles egal a l'angle/60 degres +c et mise en triangulation delaunay locale +c =========================================================== + call teamsf( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) + if( ierr .ne. 0 ) goto 9999 +c +c quelques iterations de barycentrage des points internes +c modification de la topologie pour avoir 4 ou 5 ou 6 triangles +c pour chaque sommet de la triangulation +c et mise en triangulation delaunay +c ============================================================= + call teamqs( nutysu, + % noarst, mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, notrcf, nostbo, + % n1arcf, noarcf, larmin, + % comxmi, nbarpi, nbsomm, mxsomm, pxyd, nslign, + % ierr ) +c + 9999 return + end + + subroutine trfrcf( nscent, mosoar, nosoar, moartr, noartr, + % nbtrcf, notrcf, nbarfr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calculer le nombre d'aretes simples du contour ferme des +c ----- nbtrcf triangles de numeros stockes dans le tableau notrcf +c ayant tous le sommet nscent +c +c entrees: +c -------- +c nscent : numero du sommet appartenant a tous les triangles notrcf +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c moartr : nombre maximal d'entiers par arete du tableau noartr +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c nbtrcf : >0 nombre de triangles empiles +c =0 si impossible de tourner autour du point +c =-nbtrcf si apres butee sur la frontiere il y a a nouveau +c butee sur la frontiere . a ce stade on ne peut dire si tous +c les triangles ayant ce sommet ont ete recenses +c ce cas arrive seulement si le sommet est sur la frontiere +c notrcf : numero dans noartr des triangles de sommet ns +c +c sortie : +c -------- +c nbarfr : nombre d'aretes simples frontalieres +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juin 1997 +c....................................................................012 + integer noartr(moartr,*), + % nosoar(mosoar,*), + % notrcf(1:nbtrcf) +c + nbarfr = 0 + do 50 n=1,nbtrcf +c le numero du triangle n dans le tableau noartr + nt = notrcf( n ) +c parcours des 3 aretes du triangle nt + do 40 i=1,3 +c le numero de l'arete i dans le tableau nosoar + noar = abs( noartr( i, nt ) ) + do 30 j=1,2 +c le numero du sommet j de l'arete noar + ns = nosoar( j, noar ) + if( ns .eq. nscent ) goto 40 + 30 continue +c l'arete noar (sans sommet nscent) est elle frontaliere? + if( nosoar( 5, noar ) .le. 0 ) then +c l'arete appartient au plus a un triangle +c une arete simple frontaliere de plus + nbarfr = nbarfr + 1 + endif +c le triangle a au plus une arete sans sommet nscent + goto 50 + 40 continue + 50 continue + end + + subroutine int2ar( p1, p2, p3, p4, oui ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : les 2 aretes de r**2 p1-p2 p3-p4 s'intersectent elles +c ----- entre leurs sommets? +c +c entrees: +c -------- +c p1,p2,p3,p4 : les 2 coordonnees reelles des sommets des 2 aretes +c +c sortie : +c -------- +c oui : .true. si intersection, .false. sinon +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc octobre 1991 +c2345x7..............................................................012 + double precision p1(2),p2(2),p3(2),p4(2) + double precision x21,y21,d21,x43,y43,d43,d,x,y,xx + logical oui +c +c longueur des aretes + x21 = p2(1)-p1(1) + y21 = p2(2)-p1(2) + d21 = x21**2 + y21**2 +c + x43 = p4(1)-p3(1) + y43 = p4(2)-p3(2) + d43 = x43**2 + y43**2 +c +c les 2 aretes sont-elles jugees paralleles ? + d = x43 * y21 - y43 * x21 + if( abs(d) .le. 0.001 * sqrt(d21 * d43) ) then +c aretes paralleles . pas d'intersection + oui = .false. + return + endif +c +c les 2 coordonnees du point d'intersection + x = ( p1(1)*x43*y21 - p3(1)*x21*y43 - (p1(2)-p3(2))*x21*x43 ) / d + y =-( p1(2)*y43*x21 - p3(2)*y21*x43 - (p1(1)-p3(1))*y21*y43 ) / d +c +c coordonnees de x,y dans le repere ns1-ns2 + xx = ( x - p1(1) ) * x21 + ( y - p1(2) ) * y21 +c le point est il entre p1 et p2 ? + oui = -0.00001d0*d21 .le. xx .and. xx .le. 1.00001d0*d21 +c +c coordonnees de x,y dans le repere ns3-ns4 + xx = ( x - p3(1) ) * x43 + ( y - p3(2) ) * y43 +c le point est il entre p3 et p4 ? + oui = oui .and. -0.00001d0*d43 .le. xx .and. xx .le. 1.00001d0*d43 + end + + + subroutine trchtd( pxyd, nar00, nar0, noarcf, + % namin0, namin, larmin ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : recherche dans le contour ferme du sommet qui joint a la plus +c ----- courte arete nar00 donne le triangle sans intersection +c avec le contour ferme de meilleure qualite +c +c entrees: +c -------- +c pxyd : tableau des coordonnees des sommets et distance_souhaitee +c +c entrees et sorties: +c ------------------- +c nar00 : numero dans noarcf de l'arete avant nar0 +c nar0 : numero dans noarcf de la plus petite arete du contour ferme +c a joindre a noarcf(1,namin) pour former le triangle ideal +c noarcf : numero du sommet , numero de l'arete suivante +c numero du triangle exterieur a l'etoile +c +c sortie : +c -------- +c namin0 : numero dans noarcf de l'arete avant namin +c namin : numero dans noarcf du sommet choisi +c 0 si contour ferme reduit a moins de 3 aretes +c larmin : tableau auxiliaire pour stocker la liste des numeros des +c aretes de meilleure qualite pour faire le choix final +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + double precision dmaxim, precision + parameter (dmaxim=1.7d+308, precision=1d-16) +c ATTENTION:variables a ajuster selon la machine! +c ATTENTION:dmaxim : le plus grand reel machine +c ATTENTION:sur dec-alpha la precision est de 10**-14 seulement + + common / unites / lecteu,imprim,nunite(30) + double precision pxyd(1:3,1:*) + integer noarcf(1:3,1:*), + % larmin(1:*) + double precision q, dd, dmima, + % unpeps, rayon, surtd2 + logical oui + double precision centre(3) +c +c initialisations +c dmaxim : le plus grand reel machine + unpeps = 1d0 + 100d0 * precision +c +c recherche de la plus courte arete du contour ferme + nbmin = 0 + na00 = nar00 + dmima = dmaxim + nbar = 0 +c + 2 na0 = noarcf( 2, na00 ) + na1 = noarcf( 2, na0 ) + nbar = nbar + 1 +c les 2 sommets de l'arete na0 du cf + ns1 = noarcf( 1, na0 ) + ns2 = noarcf( 1, na1 ) + dd = (pxyd(1,ns2)-pxyd(1,ns1))**2 + (pxyd(2,ns2)-pxyd(2,ns1))**2 + if( dd .lt. dmima ) then + dmima = dd + larmin(1) = na00 + endif + na00 = na0 + if( na00 .ne. nar00 ) then +c derniere arete non atteinte + goto 2 + endif +c + if( nbar .eq. 3 ) then +c +c contour ferme reduit a un triangle +c ---------------------------------- + namin = nar00 + nar0 = noarcf( 2, nar00 ) + namin0 = noarcf( 2, nar0 ) + return +c + else if( nbar .le. 2 ) then + write(imprim,*) 'erreur trchtd: cf<3 aretes' + pause + namin = 0 + namin0 = 0 + return + endif +c +c cf non reduit a un triangle +c la plus petite arete est nar0 dans noarcf + nar00 = larmin( 1 ) + nar0 = noarcf( 2, nar00 ) + nar = noarcf( 2, nar0 ) +c + ns1 = noarcf( 1, nar0 ) + ns2 = noarcf( 1, nar ) +c +c recherche dans cette etoile du sommet offrant la meilleure qualite +c du triangle ns1-ns2 ns3 sans intersection avec le contour ferme +c ================================================================== + nar3 = nar + qmima = -1 +c +c parcours des sommets possibles ns3 + 10 nar3 = noarcf( 2, nar3 ) + if( nar3 .ne. nar0 ) then +c +c il existe un sommet ns3 different de ns1 et ns2 + ns3 = noarcf( 1, nar3 ) +c +c les aretes ns1-ns3 et ns2-ns3 intersectent-elles une arete +c du contour ferme ? +c ---------------------------------------------------------- +c intersection de l'arete ns2-ns3 et des aretes du cf +c jusqu'au sommet ns3 + nar1 = noarcf( 2, nar ) +c + 15 if( nar1 .ne. nar3 .and. noarcf( 2, nar1 ) .ne. nar3 ) then +c l'arete suivante + nar2 = noarcf( 2, nar1 ) +c le numero des 2 sommets de l'arete + np1 = noarcf( 1, nar1 ) + np2 = noarcf( 1, nar2 ) + call int2ar( pxyd(1,ns2), pxyd(1,ns3), + % pxyd(1,np1), pxyd(1,np2), oui ) + if( oui ) goto 10 +c les 2 aretes ne s'intersectent pas entre leurs sommets + nar1 = nar2 + goto 15 + endif +c +c intersection de l'arete ns3-ns1 et des aretes du cf +c jusqu'au sommet de l'arete nar0 + nar1 = noarcf( 2, nar3 ) +c + 18 if( nar1 .ne. nar0 .and. noarcf( 2, nar1 ) .ne. nar0 ) then +c l'arete suivante + nar2 = noarcf( 2, nar1 ) +c le numero des 2 sommets de l'arete + np1 = noarcf( 1, nar1 ) + np2 = noarcf( 1, nar2 ) + call int2ar( pxyd(1,ns1), pxyd(1,ns3), + % pxyd(1,np1), pxyd(1,np2), oui ) + if( oui ) goto 10 +c les 2 aretes ne s'intersectent pas entre leurs sommets + nar1 = nar2 + goto 18 + endif +c +c le triangle ns1-ns2-ns3 n'intersecte pas une arete du contour ferme +c le calcul de la surface du triangle + dd = surtd2( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3) ) + if( dd .le. 0d0 ) then +c surface negative => triangle a rejeter + q = 0 + else +c calcul de la qualite du triangle ns1-ns2-ns3 + call qutr2d( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3), q ) + endif +c + if( q .ge. qmima*1.00001 ) then +c q est un vrai maximum de la qualite + qmima = q + nbmin = 1 + larmin(1) = nar3 + else if( q .ge. qmima*0.999998 ) then +c q est voisin de qmima +c il est empile + nbmin = nbmin + 1 + larmin( nbmin ) = nar3 + endif + goto 10 + endif +c +c bilan : existe t il plusieurs sommets de meme qualite? +c ====================================================== + if( nbmin .gt. 1 ) then +c +c oui:recherche de ceux de cercle ne contenant pas d'autres sommets + do 80 i=1,nbmin +c le sommet + nar = larmin( i ) + if( nar .le. 0 ) goto 80 + ns3 = noarcf(1,nar) +c les coordonnees du centre du cercle circonscrit +c et son rayon + ier = -1 + call cenced( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3), + % centre, ier ) + if( ier .ne. 0 ) then +c le sommet ns3 ne convient pas + larmin( i ) = 0 + goto 80 + endif + rayon = centre(3) * unpeps + do 70 j=1,nbmin + if( j .ne. i ) then +c l'autre sommet + nar1 = larmin(j) + if( nar1 .le. 0 ) goto 70 + ns4 = noarcf(1,nar1) +c appartient t il au cercle ns1 ns2 ns3 ? + dd = (centre(1)-pxyd(1,ns4))**2 + + % (centre(2)-pxyd(2,ns4))**2 + if( dd .le. rayon ) then +c ns4 est dans le cercle circonscrit ns1 ns2 ns3 +c le sommet ns3 ne convient pas + larmin( i ) = 0 + goto 80 + endif + endif + 70 continue + 80 continue +c +c existe t il plusieurs sommets ? + j = 0 + do 90 i=1,nbmin + if( larmin( i ) .gt. 0 ) then +c compactage des min + j = j + 1 + larmin(j) = larmin(i) + endif + 90 continue +c + if( j .gt. 1 ) then +c oui : choix du plus petit rayon de cercle circonscrit + dmima = dmaxim + do 120 i=1,nbmin + ns3 = noarcf(1,larmin(i)) +c +c les coordonnees du centre de cercle circonscrit +c au triangle nt et son rayon + ier = -1 + call cenced( pxyd(1,ns1), pxyd(1,ns2), pxyd(1,ns3), + % centre, ier ) + if( ier .ne. 0 ) then +c le sommet ns3 ne convient pas + goto 120 + endif + rayon = sqrt( centre(3) ) + if( rayon .lt. dmima ) then + dmima = rayon + larmin(1) = larmin(i) + endif + 120 continue + endif + endif +c +c le choix final +c ============== + namin = larmin(1) +c +c recherche de l'arete avant namin ( nar0 <> namin ) +c ================================================== + nar1 = nar0 + 200 if( nar1 .ne. namin ) then + namin0 = nar1 + nar1 = noarcf( 2, nar1 ) + goto 200 + endif + end + + subroutine trcf0a( nbcf, na01, na1, na2, na3, + % noar1, noar2, noar3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : modification de la triangulation du contour ferme nbcf +c ----- par ajout d'un triangle ayant 0 arete sur le contour +c creation des 3 aretes dans le tableau nosoar +c modification du contour par ajout de la 3-eme arete +c creation d'un contour ferme a partir de la seconde arete +c +c entrees: +c -------- +c nbcf : numero dans n1arcf du cf traite ici +c na01 : numero noarcf de l'arete precedent l'arete na1 de noarcf +c na1 : numero noarcf du 1-er sommet du triangle +c implicitement l'arete na1 n'est pas une arete du triangle +c na2 : numero noarcf du 2-eme sommet du triangle +c implicitement l'arete na1 n'est pas une arete du triangle +c na3 : numero noarcf du 3-eme sommet du triangle +c implicitement l'arete na1 n'est pas une arete du triangle +c +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c +c entrees et sorties : +c -------------------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c noarst : noarst(i) numero d'une arete de sommet i +c n1arcf : numero d'une arete de chaque contour +c noarcf : numero des aretes de la ligne du contour ferme +c attention : chainage circulaire des aretes +c +c sortie : +c -------- +c noar1 : numero dans le tableau nosoar de l'arete 1 du triangle +c noar2 : numero dans le tableau nosoar de l'arete 2 du triangle +c noar3 : numero dans le tableau nosoar de l'arete 3 du triangle +c nt : numero du triangle ajoute dans noartr +c 0 si saturation du tableau noartr ou noarcf ou n1arcf +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) + integer nosoar(mosoar,*), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:*), + % noarcf(3,*) +c + ierr = 0 +c +c 2 contours fermes peuvent ils etre ajoutes ? + if( nbcf+2 .gt. mxarcf ) goto 9100 +c +c creation des 3 aretes du triangle dans le tableau nosoar +c ======================================================== +c la formation de l'arete sommet1-sommet2 dans le tableau nosoar + call fasoar( noarcf(1,na1), noarcf(1,na2), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar1, ierr ) + if( ierr .ne. 0 ) goto 9900 +c +c la formation de l'arete sommet2-sommet3 dans le tableau nosoar + call fasoar( noarcf(1,na2), noarcf(1,na3), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar2, ierr ) + if( ierr .ne. 0 ) goto 9900 +c +c la formation de l'arete sommet3-sommet1 dans le tableau nosoar + call fasoar( noarcf(1,na3), noarcf(1,na1), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar3, ierr ) + if( ierr .ne. 0 ) goto 9900 +c +c ajout dans noartr de ce triangle nt +c =================================== + call trcf3a( noarcf(1,na1), noarcf(1,na2), noarcf(1,na3), + % noar1, noar2, noar3, + % mosoar, nosoar, + % moartr, n1artr, noartr, + % nt ) + if( nt .le. 0 ) return +c +c modification du contour nbcf existant +c chainage de l'arete na2 vers l'arete na1 +c ======================================== +c modification du cf en pointant na2 sur na1 + na2s = noarcf( 2, na2 ) + noarcf( 2, na2 ) = na1 +c le numero de l'arete dans le tableau nosoar + noar2s = noarcf( 3, na2 ) +c le numero de l'arete dans le tableau nosoar + noarcf( 3, na2 ) = noar1 +c debut du cf + n1arcf( nbcf ) = na2 +c +c creation d'un nouveau contour ferme na2 - na3 +c ============================================= + nbcf = nbcf + 1 +c recherche d'une arete de cf vide + nav = n1arcf(0) + if( nav .le. 0 ) goto 9100 +c la 1-ere arete vide est mise a jour + n1arcf(0) = noarcf( 2, nav ) +c +c ajout de l'arete nav pointant sur na2s +c le numero du sommet + noarcf( 1, nav ) = noarcf( 1, na2 ) +c l'arete suivante + noarcf( 2, nav ) = na2s +c le numero nosoar de cette arete + noarcf( 3, nav ) = noar2s +c +c l'arete na3 se referme sur nav + na3s = noarcf( 2, na3 ) + noarcf( 2, na3 ) = nav +c le numero de l'arete dans le tableau nosoar + noar3s = noarcf( 3, na3 ) + noarcf( 3, na3 ) = noar2 +c debut du cf+1 + n1arcf( nbcf ) = na3 +c +c creation d'un nouveau contour ferme na3 - na1 +c ============================================= + nbcf = nbcf + 1 +c recherche d'une arete de cf vide + nav = n1arcf(0) + if( nav .le. 0 ) goto 9100 +c la 1-ere arete vide est mise a jour + n1arcf(0) = noarcf( 2, nav ) +c +c ajout de l'arete nav pointant sur na3s +c le numero du sommet + noarcf( 1, nav ) = noarcf( 1, na3 ) +c l'arete suivante + noarcf( 2, nav ) = na3s +c le numero de l'arete dans le tableau nosoar + noarcf( 3, nav ) = noar3s +c +c recherche d'une arete de cf vide + nav1 = n1arcf(0) + if( nav1 .le. 0 ) goto 9100 +c la 1-ere arete vide est mise a jour + n1arcf(0) = noarcf( 2, nav1 ) +c +c l'arete precedente na01 de na1 pointe sur la nouvelle nav1 + noarcf( 2, na01 ) = nav1 +c +c ajout de l'arete nav1 pointant sur nav +c le numero du sommet + noarcf( 1, nav1 ) = noarcf( 1, na1 ) +c l'arete suivante + noarcf( 2, nav1 ) = nav +c le numero de l'arete dans le tableau nosoar + noarcf( 3, nav1 ) = noar3 +c +c debut du cf+2 + n1arcf( nbcf ) = nav1 + return +c +c erreur + 9100 write(imprim,*) 'saturation du tableau mxarcf' + nt = 0 + return +c +c erreur tableau nosoar sature + 9900 write(imprim,*) 'saturation du tableau nosoar' + nt = 0 + return + end + + + subroutine trcf1a( nbcf, na01, na1, na2, noar1, noar3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : modification de la triangulation du contour ferme nbcf +c ----- par ajout d'un triangle ayant 1 arete sur le contour +c modification du contour par ajout de la 3-eme arete +c creation d'un contour ferme a partir de la seconde arete +c +c entrees: +c -------- +c nbcf : numero dans n1arcf du cf traite ici +c na01 : numero noarcf de l'arete precedant l'arete na1 de noarcf +c na1 : numero noarcf du 1-er sommet du triangle +c implicitement l'arete na1 n'est pas une arete du triangle +c na2 : numero noarcf du 2-eme sommet du triangle +c cette arete est l'arete 2 du triangle a ajouter +c son arete suivante dans noarcf n'est pas sur le contour +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c +c entrees et sorties : +c -------------------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c noarst : noarst(i) numero d'une arete de sommet i +c n1arcf : numero d'une arete de chaque contour +c noarcf : numero des aretes de la ligne du contour ferme +c attention : chainage circulaire des aretes +c +c sortie : +c -------- +c noar1 : numero nosoar de l'arete 1 du triangle cree +c noar3 : numero nosoar de l'arete 3 du triangle cree +c nt : numero du triangle ajoute dans notria +c 0 si saturation du tableau notria ou noarcf ou n1arcf +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) + integer nosoar(mosoar,mxsoar), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:*), + % noarcf(3,*) +c +c un cf supplementaire peut il etre ajoute ? + if( nbcf .ge. mxarcf ) then + write(imprim,*) 'saturation du tableau noarcf' + nt = 0 + return + endif +c + ierr = 0 +c +c l' arete suivante du triangle non sur le cf + na3 = noarcf( 2, na2 ) +c +c creation des 2 nouvelles aretes du triangle dans le tableau nosoar +c ================================================================== +c la formation de l'arete sommet1-sommet2 dans le tableau nosoar + call fasoar( noarcf(1,na1), noarcf(1,na2), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar1, ierr ) + if( ierr .ne. 0 ) goto 9900 +c +c la formation de l'arete sommet1-sommet3 dans le tableau nosoar + call fasoar( noarcf(1,na3), noarcf(1,na1), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar3, ierr ) + if( ierr .ne. 0 ) goto 9900 +c +c le triangle nt de noartr a l'arete 2 comme arete du contour na2 +c =============================================================== + call trcf3a( noarcf(1,na1), noarcf(1,na2), noarcf(1,na3), + % noar1, noarcf(3,na2), noar3, + % mosoar, nosoar, + % moartr, n1artr, noartr, + % nt ) + if( nt .le. 0 ) return +c +c modification du contour ferme existant +c suppression de l'arete na2 du cf +c ====================================== +c modification du cf en pointant na2 sur na1 + noarcf( 2, na2 ) = na1 + noarcf( 3, na2 ) = noar1 +c debut du cf + n1arcf( nbcf ) = na2 +c +c creation d'un nouveau contour ferme na3 - na1 +c ============================================= + nbcf = nbcf + 1 +c +c recherche d'une arete de cf vide + nav = n1arcf(0) + if( nav .le. 0 ) then + write(imprim,*) 'saturation du tableau noarcf' + nt = 0 + return + endif +c +c la 1-ere arete vide est mise a jour + n1arcf(0) = noarcf( 2, nav ) +c +c ajout de l'arete nav pointant sur na3 +c le numero du sommet + noarcf( 1, nav ) = noarcf( 1, na1 ) +c l'arete suivante + noarcf( 2, nav ) = na3 +c le numero de l'arete dans le tableau nosoar + noarcf( 3, nav ) = noar3 +c +c l'arete precedente na01 de na1 pointe sur la nouvelle nav + noarcf( 2, na01 ) = nav +c +c debut du cf + n1arcf( nbcf ) = nav + return +c +c erreur tableau nosoar sature + 9900 write(imprim,*) 'saturation du tableau nosoar' + nt = 0 + return + end + + + subroutine trcf2a( nbcf, na1, noar3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % n1arcf, noarcf, nt ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : modification de la triangulation du contour ferme nbcf +c ----- par ajout d'un triangle ayant 2 aretes sur le contour +c creation d'une arete dans nosoar (sommet3-sommet1) +c et modification du contour par ajout de la 3-eme arete +c +c entrees: +c -------- +c nbcf : numero dans n1arcf du cf traite ici +c na1 : numero noarcf de la premiere arete sur le contour +c implicitement sa suivante est sur le contour +c la suivante de la suivante n'est pas sur le contour +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c +c entrees et sorties : +c -------------------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c noarst : noarst(i) numero d'une arete de sommet i +c n1arcf : numero d'une arete de chaque contour +c noarcf : numero des aretes de la ligne du contour ferme +c attention : chainage circulaire des aretes +c +c sortie : +c -------- +c noar3 : numero de l'arete 3 dans le tableau nosoar +c nt : numero du triangle ajoute dans noartr +c 0 si saturation du tableau noartr ou nosoar +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) + integer nosoar(mosoar,*), + % noartr(moartr,*), + % noarst(*) + integer n1arcf(0:*), + % noarcf(3,*) +c + ierr = 0 +c +c l'arete suivante de l'arete na1 dans noarcf + na2 = noarcf( 2, na1 ) +c l'arete suivante de l'arete na2 dans noarcf + na3 = noarcf( 2, na2 ) +c +c la formation de l'arete sommet3-sommet1 dans le tableau nosoar + call fasoar( noarcf(1,na3), noarcf(1,na1), -1, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar3, ierr ) + if( ierr .ne. 0 ) then + if( ierr .eq. 1 ) then + write(imprim,*) 'saturation des aretes (tableau nosoar)' + endif + nt = 0 + return + endif +c +c le triangle a ses 2 aretes na1 na2 sur le contour ferme +c ajout dans noartr de ce triangle nt + call trcf3a( noarcf(1,na1), noarcf(1,na2), noarcf(1,na3), + % noarcf(3,na1), noarcf(3,na2), noar3, + % mosoar, nosoar, + % moartr, n1artr, noartr, + % nt ) + if( nt .le. 0 ) return +c +c suppression des 2 aretes (na1 na2) du cf +c ces 2 aretes se suivent dans le chainage du cf +c ajout de la 3-eme arete (noar3) dans le cf +c l'arete suivante de na1 devient la suivante de na2 + noarcf(2,na1) = na3 + noarcf(3,na1) = noar3 +c +c l'arete na2 devient vide dans noarcf + noarcf(2,na2) = n1arcf( 0 ) + n1arcf( 0 ) = na2 +c +c la premiere pointee dans noarcf est na1 +c chainage circulaire => ce peut etre n'importe laquelle + n1arcf(nbcf) = na1 + end + + + subroutine trcf3a( ns1, ns2, ns3, + % noar1, noar2, noar3, + % mosoar, nosoar, + % moartr, n1artr, noartr, + % nt ) +c++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : ajouter dans le tableau noartr le triangle +c ----- de sommets ns1 ns2 ns3 +c d'aretes noar1 noar2 noar3 deja existantes +c dans le tableau nosoar des aretes +c +c entrees: +c -------- +c ns1, ns2, ns3 : le numero dans pxyd des 3 sommets du triangle +c noar1,noar2,noar3 : le numero dans nosoar des 3 aretes du triangle +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies : +c ---------- +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c sorties: +c -------- +c nt : numero dans noartr du triangle ajoute +c =0 si le tableau noartr est sature +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu,imprim,nunite(30) + integer nosoar(mosoar,*), + % noartr(moartr,*) +c +c recherche d'un triangle libre dans le tableau noartr + if( n1artr .le. 0 ) then + write(imprim,*) 'saturation du tableau noartr des aretes' + nt = 0 + return + endif +c +c le numero dans noartr du nouveau triangle + nt = n1artr +c +c le nouveau premier triangle vide dans le tableau noartr + n1artr = noartr(2,n1artr) +c +c arete 1 du triangle nt +c ====================== +c orientation des 3 aretes du triangle pour qu'il soit direct + if( ns1 .eq. nosoar(1,noar1) ) then + n = 1 + else + n = -1 + endif +c le numero de l'arete 1 du triangle nt + noartr(1,nt) = n * noar1 +c +c le numero du triangle nt pour l'arete + if( nosoar(4,noar1) .le. 0 ) then + n = 4 + else + n = 5 + endif + nosoar(n,noar1) = nt +c +c arete 2 du triangle nt +c ====================== +c orientation des 3 aretes du triangle pour qu'il soit direct + if( ns2 .eq. nosoar(1,noar2) ) then + n = 1 + else + n = -1 + endif +c le numero de l'arete 2 du triangle nt + noartr(2,nt) = n * noar2 +c +c le numero du triangle nt pour l'arete + if( nosoar(4,noar2) .le. 0 ) then + n = 4 + else + n = 5 + endif + nosoar(n,noar2) = nt +c +c arete 3 du triangle nt +c ====================== +c orientation des 3 aretes du triangle pour qu'il soit direct + if( ns3 .eq. nosoar(1,noar3) ) then + n = 1 + else + n = -1 + endif +c le numero de l'arete 3 du triangle nt + noartr(3,nt) = n * noar3 +c +c le numero du triangle nt pour l'arete + if( nosoar(4,noar3) .le. 0 ) then + n = 4 + else + n = 5 + endif + nosoar(n,noar3) = nt + end + + + + subroutine trcf3s( nbcf, na01, na1, na02, na2, na03, na3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : ajout d'un triangle d'aretes na1 2 3 du tableau noarcf +c ----- a la triangulation d'un contour ferme (cf) +c +c entrees: +c -------- +c nbcf : numero dans n1arcf du cf traite ici +c mais aussi nombre actuel de cf avant ajout du triangle +c na01 : numero noarcf de l'arete precedent l'arete na1 de noarcf +c na1 : numero noarcf du 1-er sommet du triangle +c na02 : numero noarcf de l'arete precedent l'arete na2 de noarcf +c na2 : numero noarcf du 2-eme sommet du triangle +c na03 : numero noarcf de l'arete precedent l'arete na3 de noarcf +c na3 : numero noarcf du 3-eme sommet du triangle +c +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxarcf : nombre maximal d'aretes declarables dans noarcf, n1arcf +c +c modifies: +c --------- +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c n1arcf : numero d'une arete de chaque contour ferme +c noarcf : numero du sommet , numero de l'arete suivante +c numero de l'arete dans le tableau nosoar +c attention : chainage circulaire des aretes +c +c sortie : +c -------- +c nbcf : nombre actuel de cf apres ajout du triangle +c nt : numero du triangle ajoute dans noartr +c 0 si saturation du tableau nosoar ou noartr ou noarcf ou n1arcf +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + integer nosoar(mosoar,*), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf) +c +c combien y a t il d'aretes nbascf sur le cf ? +c ============================================ +c la premiere arete est elle sur le cf? + if( noarcf(2,na1) .eq. na2 ) then +c la 1-ere arete est sur le cf + na1cf = 1 + else +c la 1-ere arete n'est pas sur le cf + na1cf = 0 + endif +c +c la seconde arete est elle sur le cf? + if( noarcf(2,na2) .eq. na3 ) then +c la 2-eme arete est sur le cf + na2cf = 1 + else + na2cf = 0 + endif +c +c la troisieme arete est elle sur le cf? + if( noarcf(2,na3) .eq. na1 ) then +c la 3-eme arete est sur le cf + na3cf = 1 + else + na3cf = 0 + endif +c +c le nombre d'aretes sur le cf + nbascf = na1cf + na2cf + na3cf +c +c traitement selon le nombre d'aretes sur le cf +c ============================================= + if( nbascf .eq. 3 ) then +c +c le contour ferme se reduit a un triangle avec 3 aretes sur le cf +c ---------------------------------------------------------------- +c ajout dans noartr de ce nouveau triangle + call trcf3a( noarcf(1,na1), noarcf(1,na2), noarcf(1,na3), + % noarcf(3,na1), noarcf(3,na2), noarcf(3,na3), + % mosoar, nosoar, + % moartr, n1artr, noartr, + % nt ) + if( nt .le. 0 ) return +c +c le cf est supprime et chaine vide + noarcf(2,na3) = n1arcf(0) + n1arcf( 0 ) = na1 +c +c ce cf a ete traite => un cf de moins a traiter + nbcf = nbcf - 1 +c + else if( nbascf .eq. 2 ) then +c +c le triangle a 2 aretes sur le contour +c ------------------------------------- +c les 2 aretes sont la 1-ere et 2-eme du triangle + if( na1cf .eq. 0 ) then +c l'arete 1 n'est pas sur le cf + naa1 = na2 + else if( na2cf .eq. 0 ) then +c l'arete 2 n'est pas sur le cf + naa1 = na3 + else +c l'arete 3 n'est pas sur le cf + naa1 = na1 + endif +c le triangle oppose a l'arete 3 est inconnu +c modification du contour apres integration du +c triangle ayant ses 2-eres aretes sur le cf + call trcf2a( nbcf, naa1, naor3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % n1arcf, noarcf, nt ) +c + else if( nbascf .eq. 1 ) then +c +c le triangle a 1 arete sur le contour +c ------------------------------------ +c cette arete est la seconde du triangle + if( na3cf .ne. 0 ) then +c l'arete 3 est sur le cf + naa01 = na02 + naa1 = na2 + naa2 = na3 + else if( na1cf .ne. 0 ) then +c l'arete 1 est sur le cf + naa01 = na03 + naa1 = na3 + naa2 = na1 + else +c l'arete 2 est sur le cf + naa01 = na01 + naa1 = na1 + naa2 = na2 + endif +c le triangle oppose a l'arete 1 et 3 est inconnu +c modification du contour apres integration du +c triangle ayant 1 arete sur le cf avec creation +c d'un nouveau contour ferme + call trcf1a( nbcf, naa01, naa1, naa2, naor1, naor3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) +c + else +c +c le triangle a 0 arete sur le contour +c ------------------------------------ +c modification du contour apres integration du +c triangle ayant 0 arete sur le cf avec creation +c de 2 nouveaux contours fermes + call trcf0a( nbcf, na01, na1, na2, na3, + % naa1, naa2, naa01, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) + endif + end + + + subroutine tridcf( nbcf0, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, + % nbtrcf, notrcf, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : triangulation directe de nbcf0 contours fermes (cf) +c ----- definis par la liste circulaire de leurs aretes peripheriques +c +c entrees: +c -------- +c nbcf0 : nombre initial de cf a trianguler +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxarcf : nombre maximal d'aretes declarables dans noarcf, n1arcf, larmin, not +c +c modifies: +c --------- +c noarst : noarst(i) numero d'une arete de sommet i +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c n1arcf : numero de la premiere arete de chacun des nbcf0 cf +c n1arcf(0) no de la premiere arete vide du tableau noarcf +c noarcf(2,i) no de l'arete suivante +c noarcf : numero du sommet , numero de l'arete suivante du cf +c numero de l'arete dans le tableau nosoar +c +c auxiliaires : +c ------------- +c larmin : tableau (mxarcf) auxiliaire +c stocker la liste des numeros des meilleures aretes +c lors de la selection du meilleur sommet du cf a trianguler +c cf le sp trchtd +c +c sortie : +c -------- +c nbtrcf : nombre de triangles des nbcf0 cf +c notrcf : numero des triangles des nbcf0 cf dans le tableau noartr +c ierr : 0 si pas d'erreur +c 2 saturation de l'un des des tableaux nosoar, noartr, ... +c 3 si contour ferme reduit a moins de 3 aretes +c 4 saturation du tableau notrcf +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer noartr(moartr,*), + % nosoar(mosoar,mxsoar), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf), + % notrcf(mxarcf) +c +ccc integer nosotr(3) +ccc double precision d, surtd2 +c +c depart avec nbcf0 cf a trianguler + nbcf = nbcf0 +c +c le nombre de triangles formes dans l'ensemble des cf + nbtrcf = 0 +c +c tant qu'il existe un cf a trianguler faire +c la triangulation directe du cf +c ========================================== + 10 if( nbcf .gt. 0 ) then +c +c le cf en haut de pile a pour premiere arete + na01 = n1arcf( nbcf ) + na1 = noarcf( 2, na01 ) +c +c choix du sommet du cf a relier a l'arete na1 +c -------------------------------------------- + call trchtd( pxyd, na01, na1, noarcf, + % na03, na3, larmin ) + if( na3 .eq. 0 ) then + ierr = 3 + return + endif +c +c l'arete suivante de na1 + na02 = na1 + na2 = noarcf( 2, na1 ) +c +c formation du triangle arete na1 - sommet noarcf(1,na3) +c ------------------------------------------------------ + call trcf3s( nbcf, na01, na1, na02, na2, na03, na3, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, nt ) + if( nt .le. 0 ) then +c saturation du tableau noartr ou noarcf ou n1arcf + ierr = 2 + return + endif +c +c ajout du triangle cree a sa pile + if( nbtrcf .ge. mxarcf ) then + write(imprim,*) 'saturation du tableau notrcf' + ierr = 4 + return + endif + nbtrcf = nbtrcf + 1 + notrcf( nbtrcf ) = nt + goto 10 + endif +c +c mise a jour du chainage des triangles des aretes +c ================================================ + do 30 ntp0 = 1, nbtrcf +c +c le numero du triangle ajoute dans le tableau noartr + nt0 = notrcf( ntp0 ) +c +cccc aire signee du triangle nt0 +cccc le numero des 3 sommets du triangle nt +ccc call nusotr( nt0, mosoar, nosoar, moartr, noartr, +ccc % nosotr ) +ccc d = surtd2( pxyd(1,nosotr(1)), pxyd(1,nosotr(2)), +ccc % pxyd(1,nosotr(3)) ) +ccc if( d .le. 0 ) then +cccc +cccc un triangle d'aire negative de plus +ccc write(imprim,*) 'triangle ',nt0,' st:',nosotr, +ccc % ' d aire ',d,'<=0' +ccc pause +ccc endif +c +cccc trace du triangle nt0 +ccc call mttrtr( pxyd, nt0, moartr, noartr, mosoar, nosoar, +ccc % ncturq, ncblan ) +c +c boucle sur les 3 aretes du triangle + do 20 i=1,3 +c +c le numero de l'arete i du triangle dans le tableau nosoar + noar = abs( noartr(i,nt0) ) +c +c ce triangle est il deja chaine dans cette arete? + nt1 = nosoar(4,noar) + nt2 = nosoar(5,noar) + if( nt1 .eq. nt0 .or. nt2 .eq. nt0 ) goto 20 +c +c ajout de ce triangle nt0 a l'arete noar + if( nt1 .le. 0 ) then +c le triangle est ajoute a l'arete + nosoar( 4, noar ) = nt0 + else if( nt2 .le. 0 ) then +c le triangle est ajoute a l'arete + nosoar( 5, noar ) = nt0 + else +c l'arete appartient a 2 triangles differents de nt0 +c anomalie. chainage des triangles des aretes defectueux +c a corriger + write(imprim,*) 'pause dans tridcf' + pause + ierr = 5 + return + endif +c + 20 continue +c + 30 continue + end + + + subroutine te1stm( nsasup, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, notrcf, liarcf, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : supprimer de la triangulation le sommet nsasup qui doit +c ----- etre un sommet interne ("centre" d'une boule de triangles) +c +c attention: le chainage lchain de nosoar devient celui des cf +c +c entrees: +c -------- +c nsasup : numero dans le tableau pxyd du sommet a supprimer +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxarcf : nombre de variables des tableaux n1arcf, noarcf, larmin, notrcf +c +c modifies: +c --------- +c noarst : noarst(i) numero d'une arete de sommet i +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c +c auxiliaires : +c ------------- +c n1arcf : tableau (0:mxarcf) auxiliaire d'entiers +c noarcf : tableau (3,mxarcf) auxiliaire d'entiers +c larmin : tableau ( mxarcf ) auxiliaire d'entiers +c notrcf : tableau ( mxarcf ) auxiliaire d'entiers +c liarcf : tableau ( mxarcf ) auxiliaire d'entiers +c +c sortie : +c -------- +c ierr : =0 si pas d'erreur +c -1 le sommet a supprimer n'est pas le centre d'une boule +c de triangles. il est suppose externe +c ou bien le sommet est centre d'un cf dont toutes les +c aretes sont frontalieres +c dans les 2 cas => retour sans modifs +c >0 si une erreur est survenue +c =11 algorithme defaillant +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter ( lchain=6, quamal=0.3) + common / unites / lecteu,imprim,intera,nunite(29) + double precision pxyd(3,*) + integer nosoar(mosoar,mxsoar), + % noartr(moartr,*), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf), + % notrcf(mxarcf), + % liarcf(mxarcf) +c +c nsasup est il un sommet interne, "centre" d'une boule de triangles? +c => le sommet nsasup peut etre supprime +c =================================================================== +c formation du cf de ''centre'' le sommet nsasup + call trp1st( nsasup, noarst, mosoar, nosoar, + % moartr, noartr, + % mxarcf, nbtrcf, notrcf ) + if( nbtrcf .le. 0 ) then +c erreur: impossible de trouver tous les triangles de sommet nsasup +c le sommet nsasup n'est pas supprime de la triangulation + ierr = -1 + return + else if( nbtrcf .le. 2 ) then +c le sommet nsasup n'est pas supprime + ierr = -1 + return + endif + if( nbtrcf*3 .gt. mxarcf ) then + write(imprim,*) 'saturation du tableau noarcf' + ierr = 10 + return + endif +c +ccc trace des triangles de l'etoile du sommet nsasup +ccc call trpltr( nbtrcf, notrcf, pxyd, +ccc % moartr, noartr, mosoar, nosoar, +ccc % ncroug, ncblan ) +c +c si toutes les aretes du cf sont frontalieres, alors il est +c interdit de detruire le sommet "centre" du cf +c calcul du nombre nbarfr des aretes simples des nbtrcf triangles + call trfrcf( nsasup, mosoar, nosoar, moartr, noartr, + % nbtrcf, notrcf, nbarfr ) + if( nbarfr .ge. nbtrcf ) then +c toutes les aretes simples sont frontalieres +c le sommet nsasup ("centre" de la cavite) n'est pas supprime + ierr = -1 + return + endif +c +c formation du contour ferme (liste chainee des aretes simples) +c forme a partir des aretes des triangles de l'etoile du sommet nsasup + call focftr( nbtrcf, notrcf, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % nbarcf, n1arcf, noarcf, + % ierr ) + if( ierr .ne. 0 ) return +c +c ici le sommet nsasup appartient a aucune arete + noarst( nsasup ) = 0 +c +c chainage des aretes vides dans le tableau noarcf + n1arcf(0) = nbarcf+1 + mmarcf = min(8*nbarcf,mxarcf) + do 40 i=nbarcf+1,mmarcf + noarcf(2,i) = i+1 + 40 continue + noarcf(2,mmarcf) = 0 +c +c sauvegarde du chainage des aretes peripheriques +c pour la mise en delaunay du maillage + nbcf = n1arcf(1) + do 50 i=1,nbarcf +c le numero de l'arete dans le tableau nosoar + liarcf( i ) = noarcf( 3, nbcf ) +c l'arete suivante dans le cf + nbcf = noarcf( 2, nbcf ) + 50 continue +c +c triangulation directe du contour ferme sans le sommet nsasup +c ============================================================ + nbcf = 1 + call tridcf( nbcf, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, + % nbtrcf, notrcf, ierr ) + if( ierr .ne. 0 ) return +c +c transformation des triangles du cf en triangles delaunay +c ======================================================== +c construction du chainage lchain dans nosoar +c des aretes peripheriques du cf a partir de la sauvegarde liarcf + noar0 = liarcf(1) + do 60 i=2,nbarcf +c le numero de l'arete peripherique du cf dans nosoar + noar = liarcf( i ) + if( nosoar(3,noar) .le. 0 ) then +c arete interne => elle est chainee a partir de la precedente + nosoar( lchain, noar0 ) = noar + noar0 = noar + endif + 60 continue +c la derniere arete peripherique n'a pas de suivante + nosoar(lchain,noar0) = 0 +c +c mise en delaunay des aretes chainees + call tedela( pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, liarcf(1), + % moartr, mxartr, n1artr, noartr, modifs ) +ccc write(imprim,*) 'nombre echanges diagonales =',modifs + return + end + + + subroutine tr3str( np, nt, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former les 3 sous-triangles du triangle nt a partir +c ----- du point interne np +c +c entrees: +c -------- +c np : numero dans le tableau pxyd du point +c nt : numero dans le tableau noartr du triangle a trianguler +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c sorties: +c -------- +c nutr : le numero des 3 sous-triangles du triangle nt +c nt : en sortie le triangle initial n'est plus actif dans noartr +c c'est en fait le premier triangle vide de noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + integer nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(3) +c + integer nosotr(3), nu2sar(2), nuarco(3) +c +c reservation des 3 nouveaux triangles dans le tableau noartr +c =========================================================== + do 10 i=1,3 +c le numero du sous-triangle i dans le tableau noartr + if( n1artr .le. 0 ) then +c tableau noartr sature + ierr = 2 + return + endif + nutr(i) = n1artr +c le nouveau premier triangle libre dans noartr + n1artr = noartr(2,n1artr) + 10 continue +c +c les numeros des 3 sommets du triangle nt + call nusotr( nt, mosoar, nosoar, moartr, noartr, nosotr ) +c +c formation des 3 aretes nosotr(i)-np dans le tableau nosoar +c ========================================================== + nt0 = nutr(3) + do 20 i=1,3 +c +c le triangle a creer + nti = nutr(i) +c +c les 2 sommets du cote i du triangle nosotr + nu2sar(1) = nosotr(i) + nu2sar(2) = np + call hasoar( mosoar, mxsoar, n1soar, nosoar, nu2sar, noar ) +c en sortie: noar>0 => no arete retrouvee +c <0 => no arete ajoutee +c =0 => saturation du tableau nosoar +c + if( noar .eq. 0 ) then +c saturation du tableau nosoar + ierr = 1 + return + else if( noar .lt. 0 ) then +c l'arete a ete ajoutee. initialisation des autres informations + noar = -noar +c le numero des 2 sommets a ete initialise par hasoar +c et (nosoar(1,noar) le triangle nt0 + nosoar(4,noar) = nt0 +c le triangle 2 de l'arete noar => le triangle nti + nosoar(5,noar) = nti +c +c le sommet nosotr(i) appartient a l'arete noar + noarst( nosotr(i) ) = noar +c +c le numero d'arete nosotr(i)-np + nuarco(i) = noar +c +c le triangle qui precede le suivant + nt0 = nti + 20 continue +c +c le numero d'une arete du point np + noarst( np ) = noar +c +c les 3 sous-triangles du triangle nt sont formes dans le tableau noartr +c ====================================================================== + do 30 i=1,3 +c +c le numero suivant i => i mod 3 + 1 + if( i .ne. 3 ) then + i1 = i + 1 + else + i1 = 1 + endif +c +c le numero dans noartr du sous-triangle a ajouter + nti = nutr( i ) +c +c le numero de l'arete i du triangle initial nt +c est l'arete 1 du sous-triangle i + noar = noartr(i,nt) + noartr( 1, nti ) = noar +c +c mise a jour du numero de triangle de cette arete + noar = abs( noar ) + if( nosoar(4,noar) .eq. nt ) then +c le sous-triangle nti remplace le triangle nt + nosoar(4,noar) = nti + else +c le sous-triangle nti remplace le triangle nt + nosoar(5,noar) = nti + endif +c +c l'arete 2 du sous-triangle i est l'arete i1 ajoutee + if( nosotr(i1) .eq. nosoar(1,nuarco(i1)) ) then +c l'arete ns i1-np dans nosoar est dans le sens direct + noartr( 2, nti ) = nuarco(i1) + else +c l'arete ns i1-np dans nosoar est dans le sens indirect + noartr( 2, nti ) = -nuarco(i1) + endif +c +c l'arete 3 du sous-triangle i est l'arete i ajoutee + if( nosotr(i) .eq. nosoar(1,nuarco(i)) ) then +c l'arete ns i1-np dans nosoar est dans le sens indirect + noartr( 3, nti ) = -nuarco(i) + else +c l'arete ns i1-np dans nosoar est dans le sens direct + noartr( 3, nti ) = nuarco(i) + endif + 30 continue +c +c le triangle nt est rendu libre +c ============================== +c il devient n1artr le premier triangle libre + noartr( 1, nt ) = 0 + noartr( 2, nt ) = n1artr + n1artr = nt + end + + + subroutine mt4sqa( na, moartr, noartr, mosoar, nosoar, + % ns1, ns2, ns3, ns4) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul du numero des 4 sommets de l'arete na de nosoar +c ----- formant un quadrangle +c +c entrees: +c -------- +c na : numero de l'arete dans nosoar a traiter +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1=0 si triangle vide => arete2=triangle vide suivant +c mosoar : nombre maximal d'entiers par arete +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c +c sorties: +c -------- +c ns1,ns2,ns3 : les 3 numeros des sommets du triangle t1 en sens direct +c ns1,ns4,ns2 : les 3 numeros des sommets du triangle t2 en sens direct +c +c si erreur rencontree => ns4 = 0 +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + common / unites / lecteu, imprim, nunite(30) + integer noartr(moartr,*), nosoar(mosoar,*) +c +c le numero de triangle est il correct ? +c a supprimer apres mise au point + if( na .le. 0 ) then +c nblgrc(nrerr) = 1 +c write(kerr(mxlger)(1:6),'(i6)') na +c kerr(1) = kerr(mxlger)(1:6) // +c % ' no incorrect arete dans nosoar' +c call lereur + write(imprim,*) na, ' no incorrect arete dans nosoar' + ns4 = 0 + return + endif +c + if( nosoar(1,na) .le. 0 ) then +c nblgrc(nrerr) = 1 +c write(kerr(mxlger)(1:6),'(i6)') na +c kerr(1) = kerr(mxlger)(1:6) // +c % ' arete non active dans nosoar' +c call lereur + write(imprim,*) na, ' arete non active dans nosoar' + ns4 = 0 + return + endif +c +c recherche de l'arete na dans le premier triangle + nt = nosoar(4,na) + if( nt .le. 0 ) then +c nblgrc(nrerr) = 1 +c write(kerr(mxlger)(1:6),'(i6)') na +c kerr(1) = 'triangle 1 incorrect pour l''arete ' // +c % kerr(mxlger)(1:6) +c call lereur + write(imprim,*) 'triangle 1 incorrect pour l''arete ', na + ns4 = 0 + return + endif +c + do 5 i=1,3 + if( abs( noartr(i,nt) ) .eq. na ) goto 8 + 5 continue +c si arrivee ici => bogue avant + write(imprim,*) 'mt4sqa: arete',na,' non dans le triangle',nt + ns4 = 0 + return +c +c les 2 sommets de l'arete na + 8 if( noartr(i,nt) .gt. 0 ) then + ns1 = 1 + ns2 = 2 + else + ns1 = 2 + ns2 = 1 + endif + ns1 = nosoar(ns1,na) + ns2 = nosoar(ns2,na) +c +c l'arete suivante + if( i .lt. 3 ) then + i = i + 1 + else + i = 1 + endif + naa = abs( noartr(i,nt) ) +c +c le sommet ns3 du triangle 123 + ns3 = nosoar(1,naa) + if( ns3 .eq. ns1 .or. ns3 .eq. ns2 ) then + ns3 = nosoar(2,naa) + endif +c +c le triangle de l'autre cote de l'arete na +c ========================================= + nt = nosoar(5,na) + if( nt .le. 0 ) then +c nblgrc(nrerr) = 1 +c write(kerr(mxlger)(1:6),'(i6)') na +c kerr(1) = 'triangle 2 incorrect pour l''arete ' // +c % kerr(mxlger)(1:6) +c call lereur + write(imprim,*) 'triangle 2 incorrect pour l''arete ',na + ns4 = 0 + return + endif +c +c le numero de l'arete naa du triangle nt + naa = abs( noartr(1,nt) ) + if( naa .eq. na ) naa = abs( noartr(2,nt) ) + ns4 = nosoar(1,naa) + if( ns4 .eq. ns1 .or. ns4 .eq. ns2 ) then + ns4 = nosoar(2,naa) + endif + end + + + subroutine te2t2t( noaret, mosoar, n1soar, nosoar, noarst, + % moartr, noartr, noar34 ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : echanger la diagonale des 2 triangles ayant en commun +c ----- l'arete noaret du tableau nosoar si c'est possible +c +c entrees: +c -------- +c noaret : numero de l'arete a echanger entre les 2 triangles +c mosoar : nombre maximal d'entiers par arete +c moartr : nombre maximal d'entiers par triangle +c +c modifies : +c ---------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c noarst : noarst(i) numero d'une arete de sommet i +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c sortie : +c -------- +c noar34 : numero nosoar de la nouvelle arete diagonale +c 0 si pas d'echange des aretes diagonales +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc avril 1997 +c....................................................................012 + integer nosoar(mosoar,*), + % noartr(moartr,*), + % noarst(*) +c +c une arete frontaliere ne peut etre echangee + noar34 = 0 + if( nosoar(3,noaret) .gt. 0 ) return +c +c les 4 sommets des 2 triangles ayant l'arete noaret en commun + call mt4sqa( noaret, moartr, noartr, mosoar, nosoar, + % ns1, ns2, ns3, ns4) +c ns1,ns2,ns3 : les 3 numeros des sommets du triangle nt1 en sens direct +c ns1,ns4,ns2 : les 3 numeros des sommets du triangle nt2 en sens direct +c +c recherche du numero de l'arete noaret dans le triangle nt1 + nt1 = nosoar(4,noaret) + do 10 n1 = 1, 3 + if( abs(noartr(n1,nt1)) .eq. noaret ) goto 15 + 10 continue +c impossible d'arriver ici sans bogue! + write(imprim,*) 'pause dans te2t2t 1' + pause +c +c l'arete de sommets 2 et 3 + 15 if( n1 .lt. 3 ) then + n2 = n1 + 1 + else + n2 = 1 + endif + na23 = noartr(n2,nt1) +c +c l'arete de sommets 3 et 1 + if( n2 .lt. 3 ) then + n3 = n2 + 1 + else + n3 = 1 + endif + na31 = noartr(n3,nt1) +c +c recherche du numero de l'arete noaret dans le triangle nt2 + nt2 = nosoar(5,noaret) + do 20 n1 = 1, 3 + if( abs(noartr(n1,nt2)) .eq. noaret ) goto 25 + 20 continue +c impossible d'arriver ici sans bogue! + write(imprim,*) 'pause dans te2t2t 2' + pause +c +c l'arete de sommets 1 et 4 + 25 if( n1 .lt. 3 ) then + n2 = n1 + 1 + else + n2 = 1 + endif + na14 = noartr(n2,nt2) +c +c l'arete de sommets 4 et 2 + if( n2 .lt. 3 ) then + n3 = n2 + 1 + else + n3 = 1 + endif + na42 = noartr(n3,nt2) +c +c les triangles 123 142 deviennent 143 234 +c ======================================== +c ajout de l'arete ns3-ns4 +c on evite l'affichage de l'erreur + ierr = -1 + call fasoar( ns3, ns4, nt1, nt2, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % noar34, ierr ) + if( ierr .gt. 0 ) then +c ierr=1 si le tableau nosoar est sature +c =2 si arete a creer et appartenant a 2 triangles distincts +c des triangles nt1 et nt2 +c =3 si arete appartenant a 2 triangles distincts +c differents des triangles nt1 et nt2 +c =4 si arete appartenant a 2 triangles distincts +c dont le second n'est pas le triangle nt2 +c => pas d'echange + noar34 = 0 + return + endif +c +c suppression de l'arete noaret + call sasoar( noaret, mosoar, mxsoar, n1soar, nosoar ) +c +c nt1 = triangle 143 + noartr(1,nt1) = na14 +c sens de stockage de l'arete ns3-ns4 dans nosoar? + if( nosoar(1,noar34) .eq. ns3 ) then + n1 = -1 + else + n1 = 1 + endif + noartr(2,nt1) = noar34 * n1 + noartr(3,nt1) = na31 +c +c nt2 = triangle 234 + noartr(1,nt2) = na23 + noartr(2,nt2) = -noar34 * n1 + noartr(3,nt2) = na42 +c +c echange nt1 -> nt2 pour l'arete na23 + na23 = abs( na23 ) + if( nosoar(4,na23) .eq. nt1 ) then + n1 = 4 + else + n1 = 5 + endif + nosoar(n1,na23) = nt2 +c +c echange nt2 -> nt1 pour l'arete na14 + na14 = abs( na14 ) + if( nosoar(4,na14) .eq. nt2 ) then + n1 = 4 + else + n1 = 5 + endif + nosoar(n1,na14) = nt1 +c +c numero d'une arete de chacun des 4 sommets + noarst(ns1) = na14 + noarst(ns2) = na23 + noarst(ns3) = noar34 + noarst(ns4) = noar34 + end + + + + subroutine f0trte( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former le ou les triangles du triangle equilateral letree +c ----- les points internes au te deviennent des sommets des +c sous-triangles du te +c +c entrees: +c -------- +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c si letree(0)>0 alors +c letree(0:3) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( le te est une feuille de l'arbre ) +c letree(4) : no letree du sur-triangle du triangle j +c letree(5) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8) : no pxyd des 3 sommets du triangle j +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c sorties: +c -------- +c nbtr : nombre de sous-triangles du te, triangulation du te +c nutr : numero des nbtr sous-triangles du te dans le tableau noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes au te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer letree(0:8), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(1:nbtr) + integer nuarco(3) +c +c le numero nt du triangle dans le tableau noartr + if( n1artr .le. 0 ) then +c tableau noartr sature + write(imprim,*) 'f0trte: tableau noartr sature' + ierr = 2 + return + endif + nt = n1artr +c le numero du nouveau premier triangle libre dans noartr + n1artr = noartr( 2, n1artr ) +c +c formation du triangle = le triangle equilateral letree + do 10 i=1,3 + if( i .ne. 3 ) then + i1 = i + 1 + else + i1 = 1 + endif +c ajout eventuel de l'arete si si+1 dans le tableau nosoar + call fasoar( letree(5+i), letree(5+i1), nt, -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(i), ierr ) + if( ierr .ne. 0 ) return + 10 continue +c +c le triangle nt est forme dans le tableau noartr + do 20 i=1,3 +c letree(5+i) est le numero du sommet 1 de l'arete i du te + if( letree(5+i) .eq. nosoar(1,nuarco(i)) ) then + lesign = 1 + else + lesign = -1 + endif +c l'arete ns1-ns2 dans nosoar est celle du cote du te + noartr( i, nt ) = lesign * nuarco(i) + 20 continue +c +c triangulation du te=triangle nt par ajout des points internes du te + nbtr = 1 + nutr(1) = nt + call trpite( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % nbtr, nutr, ierr ) + end + + + subroutine f1trte( letree, pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former les triangles du triangle equilateral letree +c ----- a partir de l'un des 3 milieux des cotes du te +c et des points internes au te +c ils deviennent tous des sommets des sous-triangles du te +c +c entrees: +c -------- +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c si letree(0)>0 alors +c letree(0:3) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( le te est une feuille de l'arbre ) +c letree(4) : no letree du sur-triangle du triangle j +c letree(5) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8) : no pxyd des 3 sommets du triangle j +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c milieu : milieu(i) numero dans pxyd du milieu de l'arete i du te +c 0 si pas de milieu du cote i a ajouter +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(np) numero d'une arete du sommet np +c +c sorties: +c -------- +c nbtr : nombre de sous-triangles du te, triangulation du te +c nutr : numero des nbtr sous-triangles du te dans le tableau noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes au te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + double precision pxyd(3,*) + integer letree(0:8), + % milieu(3), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(1:nbtr) +c + integer nosotr(3), nuarco(5) +c +c le numero des 2 triangles (=2 demi te) a creer dans le tableau noartr + do 5 nbtr=1,2 + if( n1artr .le. 0 ) then +c tableau noartr sature + ierr = 2 + return + endif + nutr(nbtr) = n1artr +c le nouveau premier triangle libre dans noartr + n1artr = noartr(2,n1artr) + 5 continue + nbtr = 2 +c +c recherche du milieu a creer + do 7 i=1,3 + if( milieu(i) .ne. 0 ) goto 9 + 7 continue +c le numero pxyd du point milieu du cote i + 9 nm = milieu( i ) +c +c on se ramene au seul cas i=3 c-a-d le milieu est sur le cote 3 + if( i .eq. 1 ) then +c milieu sur le cote 1 + nosotr(1) = letree(7) + nosotr(2) = letree(8) + nosotr(3) = letree(6) + else if( i .eq. 2 ) then +c milieu sur le cote 2 + nosotr(1) = letree(8) + nosotr(2) = letree(6) + nosotr(3) = letree(7) + else +c milieu sur le cote 3 + nosotr(1) = letree(6) + nosotr(2) = letree(7) + nosotr(3) = letree(8) + endif +c +c formation des 2 aretes s1 s2 et s2 s3 + do 10 i=1,2 + if( i .ne. 3 ) then + i1 = i + 1 + else + i1 = 1 + endif +c ajout eventuel de l'arete dans nosoar + call fasoar( nosotr(i), nosotr(i1), nutr(i), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(i), ierr ) + if( ierr .ne. 0 ) return + 10 continue +c +c ajout eventuel de l'arete s3 milieu dans nosoar + call fasoar( nosotr(3), nm, nutr(2), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(3), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete milieu s1 dans nosoar + call fasoar( nosotr(1), nm, nutr(1), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(4), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete milieu s2 dans nosoar + call fasoar( nosotr(2), nm, nutr(1), nutr(2), 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(5), ierr ) + if( ierr .ne. 0 ) return +c +c les aretes s1 s2 et s2 s3 dans le tableau noartr + do 20 i=1,2 +c nosotr(i) est le numero du sommet 1 de l'arete i du te + if( nosotr(i) .eq. nosoar(1,nuarco(i)) ) then + lesign = 1 + else + lesign = -1 + endif +c l'arete ns1-ns2 dans nosoar est celle du cote du te + noartr( 1, nutr(i) ) = lesign * nuarco(i) + 20 continue +c +c l'arete mediane s2 milieu + if( nm .eq. nosoar(1,nuarco(5)) ) then + lesign = -1 + else + lesign = 1 + endif + noartr( 2, nutr(1) ) = lesign * nuarco(5) + noartr( 3, nutr(2) ) = -lesign * nuarco(5) +c +c l'arete s1 milieu + if( nm .eq. nosoar(1,nuarco(4)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 3, nutr(1) ) = lesign * nuarco(4) +c +c l'arete s3 milieu + if( nm .eq. nosoar(1,nuarco(3)) ) then + lesign = -1 + else + lesign = 1 + endif + noartr( 2, nutr(2) ) = lesign * nuarco(3) +c +c triangulation des 2 demi te par ajout des points internes du te + call trpite( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % nbtr, nutr, ierr ) + end + + + subroutine f2trte( letree, pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former les triangles du triangle equilateral letree +c ----- a partir de 2 milieux des cotes du te +c et des points internes au te +c ils deviennent tous des sommets des sous-triangles du te +c +c entrees: +c -------- +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c si letree(0)>0 alors +c letree(0:3) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( le te est une feuille de l'arbre ) +c letree(4) : no letree du sur-triangle du triangle j +c letree(5) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8) : no pxyd des 3 sommets du triangle j +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c milieu : milieu(i) numero dans pxyd du milieu de l'arete i du te +c 0 si pas de milieu du cote i a ajouter +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(np) numero d'une arete du sommet np +c +c sorties: +c -------- +c nbtr : nombre de sous-triangles du te, triangulation du te +c nutr : numero des nbtr sous-triangles du te dans le tableau noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes au te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer letree(0:8), + % milieu(3), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(1:nbtr) +c + integer nosotr(3), nuarco(7) +c +c le numero des 3 triangles a creer dans le tableau noartr + do 5 nbtr=1,3 + if( n1artr .le. 0 ) then +c tableau noartr sature + ierr = 2 + return + endif + nutr(nbtr) = n1artr +c le nouveau premier triangle libre dans noartr + n1artr = noartr(2,n1artr) + 5 continue + nbtr = 3 +c +c recherche du premier milieu a creer + do 7 i=1,3 + if( milieu(i) .ne. 0 ) goto 9 + 7 continue +c +c on se ramene au seul cas i=2 c-a-d le cote 1 n'a pas de milieu + 9 if( i .eq. 2 ) then +c pas de milieu sur le cote 1 + nosotr(1) = letree(6) + nosotr(2) = letree(7) + nosotr(3) = letree(8) +c le numero pxyd du milieu du cote 2 + nm2 = milieu( 2 ) +c le numero pxyd du milieu du cote 3 + nm3 = milieu( 3 ) + else if( milieu(2) .ne. 0 ) then +c pas de milieu sur le cote 3 + nosotr(1) = letree(8) + nosotr(2) = letree(6) + nosotr(3) = letree(7) +c le numero pxyd du milieu du cote 2 + nm2 = milieu( 1 ) +c le numero pxyd du milieu du cote 3 + nm3 = milieu( 2 ) + else +c pas de milieu sur le cote 2 + nosotr(1) = letree(7) + nosotr(2) = letree(8) + nosotr(3) = letree(6) +c le numero pxyd du milieu du cote 2 + nm2 = milieu( 3 ) +c le numero pxyd du milieu du cote 3 + nm3 = milieu( 1 ) + endif +c +c ici seul le cote 1 n'a pas de milieu +c nm2 est le milieu du cote 2 +c nm3 est le milieu du cote 3 +c +c ajout eventuel de l'arete s1 s2 dans nosoar + call fasoar( nosotr(1), nosotr(2), nutr(1), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(1), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete s1 s2 dans nosoar + call fasoar( nosotr(2), nm2, nutr(1), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(2), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete s1 nm2 dans nosoar + call fasoar( nosotr(1), nm2, nutr(1), nutr(2), 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(3), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete nm2 nm3 dans nosoar + call fasoar( nm3, nm2, nutr(2), nutr(3), 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(4), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete s1 nm3 dans nosoar + call fasoar( nosotr(1), nm3, nutr(2), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(5), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete nm2 s3 dans nosoar + call fasoar( nm2, nosotr(3), nutr(3), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(6), ierr ) +c +c ajout eventuel de l'arete nm3 s3 dans nosoar + call fasoar( nosotr(3), nm3, nutr(3), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(7), ierr ) + if( ierr .ne. 0 ) return +c +c le triangle s1 s2 nm2 ou arete1 arete2 arete3 + do 20 i=1,2 +c nosotr(i) est le numero du sommet 1 de l'arete i du te + if( nosotr(i) .eq. nosoar(1,nuarco(i)) ) then + lesign = 1 + else + lesign = -1 + endif +c l'arete ns1-ns2 dans nosoar est celle du cote du te + noartr( i, nutr(1) ) = lesign * nuarco(i) + 20 continue + if( nm2 .eq. nosoar(1,nuarco(3)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 3, nutr(1) ) = lesign * nuarco(3) +c +c le triangle s1 nm2 nm3 + noartr( 1, nutr(2) ) = -lesign * nuarco(3) + if( nm2 .eq. nosoar(1,nuarco(4)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 2, nutr(2) ) = lesign * nuarco(4) + noartr( 1, nutr(3) ) = -lesign * nuarco(4) + if( nm3 .eq. nosoar(1,nuarco(5)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 3, nutr(2) ) = lesign * nuarco(5) +c +c le triangle nm2 nm3 s3 + if( nm2 .eq. nosoar(1,nuarco(6)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 2, nutr(3) ) = lesign * nuarco(6) + if( nm3 .eq. nosoar(1,nuarco(7)) ) then + lesign = -1 + else + lesign = 1 + endif + noartr( 3, nutr(3) ) = lesign * nuarco(7) +c +c triangulation des 3 sous-te par ajout des points internes du te + call trpite( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % nbtr, nutr, ierr ) + end + + + subroutine f3trte( letree, pxyd, milieu, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former les triangles du triangle equilateral letree +c ----- a partir de 3 milieux des cotes du te +c et des points internes au te +c ils deviennent tous des sommets des sous-triangles du te +c +c entrees: +c -------- +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c si letree(0)>0 alors +c letree(0:3) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( le te est une feuille de l'arbre ) +c letree(4) : no letree du sur-triangle du triangle j +c letree(5) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8) : no pxyd des 3 sommets du triangle j +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c milieu : milieu(i) numero dans pxyd du milieu de l'arete i du te +c 0 si pas de milieu du cote i a ajouter +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(np) numero d'une arete du sommet np +c +c sorties: +c -------- +c nbtr : nombre de sous-triangles du te, triangulation du te +c nutr : numero des nbtr sous-triangles du te dans le tableau noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes au te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer letree(0:8), + % milieu(3), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(1:nbtr) +c + integer nuarco(9) +c +c le numero des 4 triangles a creer dans le tableau noartr + do 5 nbtr=1,4 + if( n1artr .le. 0 ) then +c tableau noartr sature + ierr = 2 + return + endif + nutr(nbtr) = n1artr +c le nouveau premier triangle libre dans noartr + n1artr = noartr(2,n1artr) + 5 continue + nbtr = 4 +c + do 10 i=1,3 +c le sommet suivant + if( i .ne. 3 ) then + i1 = i + 1 + else + i1 = 1 + endif +c le sommet precedant + if( i .ne. 1 ) then + i0 = i - 1 + else + i0 = 3 + endif + i3 = 3 * i +c +c ajout eventuel de l'arete si mi dans nosoar + call fasoar( letree(5+i), milieu(i), nutr(i), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(i3-2), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete mi mi-1 dans nosoar + call fasoar( milieu(i), milieu(i0), nutr(i), nutr(4), 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(i3-1), ierr ) + if( ierr .ne. 0 ) return +c +c ajout eventuel de l'arete m i-1 si dans nosoar + call fasoar( milieu(i0), letree(5+i), nutr(i), -1, 0, + % mosoar, mxsoar, n1soar, nosoar, noarst, + % nuarco(i3), ierr ) + if( ierr .ne. 0 ) return +c + 10 continue +c +c les 3 sous-triangles pres des sommets + do 20 i=1,3 +c le sommet suivant + if( i .ne. 3 ) then + i1 = i + 1 + else + i1 = 1 + endif +c le sommet precedant + if( i .ne. 1 ) then + i0 = i - 1 + else + i0 = 3 + endif + i3 = 3 * i +c +c ajout du triangle arete3i-2 arete3i-1 arete3i + if( letree(5+i) .eq. nosoar(1,nuarco(i3-2)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 1, nutr(i) ) = lesign * nuarco(i3-2) +c + if( milieu(i) .eq. nosoar(1,nuarco(i3-1)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 2, nutr(i) ) = lesign * nuarco(i3-1) +c + if( milieu(i0) .eq. nosoar(1,nuarco(i3)) ) then + lesign = 1 + else + lesign = -1 + endif + noartr( 3, nutr(i) ) = lesign * nuarco(i3) +c + 20 continue +c +c le sous triangle central + i3 = -1 + do 30 i=1,3 + i3 = i3 + 3 + if( milieu(i) .eq. nosoar(1,nuarco(i3)) ) then + lesign = -1 + else + lesign = 1 + endif + noartr( i, nutr(4) ) = lesign * nuarco(i3) + 30 continue +c +c triangulation des 3 sous-te par ajout des points internes du te + call trpite( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, noarst, + % nbtr, nutr, ierr ) + end + + + + subroutine hasoar( mosoar, mxsoar, n1soar, nosoar, nu2sar, + % noar ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : rechercher le numero des 2 sommets d'une arete parmi +c ----- les numeros des 2 sommets des aretes du tableau nosoar +c s ils n y sont pas stockes les y ajouter +c dans tous les cas retourner le numero de l'arete dans nosoar +c +c la methode employee ici est celle du hachage +c avec pour fonction d'adressage h(ns1,ns2)=min(ns1,ns2) +c +c remarque: h(ns1,ns2)=ns1 + 2*ns2 +c ne marche pas si des aretes sont detruites +c et ajoutees aux aretes vides +c le chainage est commun a plusieurs hachages! +c d'ou ce choix du minimum pour le hachage +c +c entrees: +c -------- +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c chainage des aretes vides amont et aval +c l'arete vide qui precede=nosoar(4,i) +c l'arete vide qui suit =nosoar(5,i) +c nosoar : numero des 2 sommets, no ligne, 2 triangles de l'arete, +c chainage momentan'e d'aretes, chainage du hachage des aretes +c hachage des aretes = min( nosoar(1), nosoar(2) ) +c nu2sar : en entree les 2 numeros des sommets de l'arete +c en sortie nu2sar(1)0 si le tableau nu2sar est l'arete noar retrouvee +c dans le tableau nosoar +c <0 si le tableau nu2sar a ete ajoute et forme l'arete +c -noar du tableau nosoar avec nosoar(1,noar) elle devient la nouvelle arete +c retouche des chainages de cette arete noar qui ne sera plus vide + noar = nu2sar(1) +c l'eventuel chainage du hachage n'est pas modifie +c + else +c +c la premiere arete dans l'adressage du hachage n'est pas libre +c => choix quelconque d'une arete vide pour ajouter cette arete + if( n1soar .le. 0 ) then +c +c le tableau nosoar est sature avec pour temoin d'erreur + noar = 0 + return +c + else +c +c l'arete n1soar est vide => c'est la nouvelle arete +c mise a jour du chainage de la derniere arete noar du chainage +c sa suivante est la nouvelle arete n1soar + nosoar( mosoar, noar ) = n1soar +c +c l'arete ajoutee est n1soar + noar = n1soar +c +c la nouvelle premiere arete vide + n1soar = nosoar( 5, n1soar ) +c +c la premiere arete vide n1soar n'a pas d'arete vide precedente + nosoar( 4, n1soar ) = 0 +c +c noar la nouvelle arete est la derniere du chainage du hachage + nosoar( mosoar, noar ) = 0 +c + endif +c + endif +c +c les 2 sommets de la nouvelle arete noar + nosoar( 1, noar ) = nu2sar(1) + nosoar( 2, noar ) = nu2sar(2) +c +c le tableau nu2sar a ete ajoute avec l'indice -noar + noar = - noar + end + + + subroutine mt3str( nt, moartr, noartr, mosoar, nosoar, + % ns1, ns2, ns3 ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : calcul du numero des 3 sommets du triangle nt du tableau noartr +c ----- +c +c entrees: +c -------- +c nt : numero du triangle de noartr a traiter +c moartr : nombre maximal d'entiers par triangle +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1=0 si triangle vide => arete2=triangle vide suivant +c mosoar : nombre maximal d'entiers par arete +c nosoar : numero des 2 sommets , no ligne, 2 triangles, chainages en + +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c +c sorties: +c -------- +c ns1,ns2,ns3 : les 3 numeros des sommets du triangle en sens direct +c +c si erreur rencontree => ns1 = 0 +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juillet 1995 +c2345x7..............................................................012 + integer noartr(moartr,*), nosoar(mosoar,*) +c +c le numero de triangle est il correct ? +c a supprimer apres mise au point + if( nt .le. 0 ) then +c nblgrc(nrerr) = 1 +c write(kerr(mxlger)(1:6),'(i6)') nt +c kerr(1) = kerr(mxlger)(1:6) // +c % ' no triangle dans noartr incorrect' +c call lereur + write(imprim,*) nt,' no triangle dans noartr incorrect' + ns1 = 0 + return + endif +c + na = noartr(1,nt) + if( na .gt. 0 ) then +c arete dans le sens direct + ns1 = nosoar(1,na) + ns2 = nosoar(2,na) + else +c arete dans le sens indirect + ns1 = nosoar(2,-na) + ns2 = nosoar(1,-na) + endif +c + na = noartr(2,nt) + if( na .gt. 0 ) then +c arete dans le sens direct => ns3 est le second sommet de l'arete + ns3 = nosoar(2,na) + else +c arete dans le sens indirect => ns3 est le premier sommet de l'arete + ns3 = nosoar(1,-na) + endif + end + subroutine trpite( letree, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nbtr, nutr, ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former le ou les sous-triangles des nbtr triangles nutr +c ----- qui forment le triangle equilateral letree par ajout +c des points internes au te qui deviennent des sommets des +c sous-triangles des nbtr triangles +c +c entrees: +c -------- +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0:3):-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( le te est ici une feuille de l'arbre ) +c letree(4) : no letree du sur-triangle du triangle j +c letree(5) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8) : no pxyd des 3 sommets du triangle j +c pxyd : tableau des x y distance_souhaitee de chaque sommet +c mosoar : nombre maximal d'entiers par arete du tableau nosoar +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c moartr : nombre maximal d'entiers par arete du tableau noartr +c mxartr : nombre maximal de triangles stockables dans le tableau noartr +c +c modifies: +c --------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = (nosoar(1)+nosoar(2)) modulo mxsoar +c sommet 1 = 0 si arete vide => sommet 2 = arete vide suivante +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c sorties: +c -------- +c nbtr : nombre de sous-triangles du te +c nutr : numero des nbtr sous-triangles du te dans le tableau noartr +c ierr : =0 si pas d'erreur +c =1 si le tableau nosoar est sature +c =2 si le tableau noartr est sature +c =3 si aucun des triangles ne contient l'un des points internes au te +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + logical tratri + common / dv2dco / tratri +c trace ou non des triangles generes dans la triangulation + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer letree(0:8), + % nosoar(mosoar,mxsoar), + % noartr(moartr,mxartr), + % noarst(*), + % nutr(1:nbtr) +c + integer nosotr(3) +c +c si pas de point interne alors trace eventuel puis retour + if( letree(0) .eq. 0 ) goto 150 +c +c il existe au moins un point interne a trianguler +c dans les nbtr triangles + do 100 k=0,3 +c +c le numero du point + np = -letree(k) + if( np .eq. 0 ) goto 150 +c +c le point np dans pxyd est a traiter + do 10 n = 1, nbtr +c +c les numeros des 3 sommets du triangle nt=nutr(n) + nt = nutr(n) + call nusotr( nt, mosoar, nosoar, moartr, noartr, nosotr ) +c +c le triangle nt contient il le point np? + call ptdatr( pxyd(1,np), pxyd, nosotr, nsigne ) +c nsigne>0 si le point est dans le triangle ou sur une des 3 aretes +c =0 si triangle degenere ou indirect ou ne contient pas le poin +c + if( nsigne .gt. 0 ) then +c +c le triangle nt est triangule en 3 sous-triangles + call tr3str( np, nt, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, mxartr, n1artr, noartr, + % noarst, + % nutr(nbtr+1), ierr ) + if( ierr .ne. 0 ) return +c +c reamenagement des 3 triangles crees dans nutr +c en supprimant le triangle nt + nutr( n ) = nutr( nbtr + 3 ) + nbtr = nbtr + 2 +c le point np est triangule + goto 100 +c + endif + 10 continue +c +c erreur: le point np n'est pas dans l'un des nbtr triangles + write(imprim,10010) np + pause + ierr = 3 + return +c + 100 continue +10010 format(' erreur trpite: pas de triangle contenant le point',i7) +c + 150 continue + +ccc 150 if( tratri ) then +cccc les traces sont demandes +ccc call efface +cccc le cadre objet global en unites utilisateur +ccc xx1 = min(pxyd(1,nosotr(1)),pxyd(1,nosotr(2)),pxyd(1,nosotr(3))) +ccc xx2 = max(pxyd(1,nosotr(1)),pxyd(1,nosotr(2)),pxyd(1,nosotr(3))) +ccc yy1 = min(pxyd(2,nosotr(1)),pxyd(2,nosotr(2)),pxyd(2,nosotr(3))) +ccc yy2 = max(pxyd(2,nosotr(1)),pxyd(2,nosotr(2)),pxyd(2,nosotr(3))) +ccc if( xx1 .ge. xx2 ) xx2 = xx1 + (yy2-yy1) +ccc if( yy1 .ge. yy2 ) yy2 = yy1 + (xx2-xx1)*0.5 +ccc call isofenetre( xx1-(xx2-xx1), xx2+(xx2-xx1), +ccc % yy1-(yy2-yy1), yy2+(yy2-yy1) ) +ccc do 200 i=1,nbtr +cccc trace du triangle nutr(i) +ccc call mttrtr( pxyd, nutr(i), moartr, noartr, mosoar, nosoar, +ccc % i, ncblan ) +ccc 200 continue +ccc endif + + end + + + subroutine sasoar( noar, mosoar, mxsoar, n1soar, nosoar ) +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : supprimer l'arete noar du tableau nosoar +c ----- si celle ci n'est pas une arete des lignes de la frontiere +c +c la methode employee ici est celle du hachage +c avec pour fonction d'adressage h = min( nu2sar(1), nu2sar(2) ) +c +c attention: il faut mettre a jour le no d'arete des 2 sommets +c de l'arete supprimee dans le tableau noarst! +c +c entrees: +c -------- +c noar : numero de l'arete de nosoar a supprimer +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage h +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c +c modifies: +c --------- +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(4,arete vide)=l'arete vide qui precede +c nosoar(5,arete vide)=l'arete vide qui suit +c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique upmc paris mars 1997 +c ...................................................................012 + common / unites / lecteu, imprim, nunite(30) + integer nosoar(mosoar,mxsoar) +c + if( nosoar(3,noar) .le. 0 ) then +c +c l'arete n'est pas frontaliere => elle devient une arete vide +c +c recherche de l'arete qui precede dans le chainage du hachage + noar1 = nosoar(1,noar) +c +c parcours du chainage du hachage jusqu'a retrouver l'arete noar + 10 if( noar1 .ne. noar ) then +c +c l'arete suivante parmi celles ayant meme fonction d'adressage + noar0 = noar1 + noar1 = nosoar( mosoar, noar1 ) + if( noar1 .gt. 0 ) goto 10 +c +c l'arete noar n'a pas ete retrouvee dans le chainage => erreur + write(imprim,*) 'erreur sasoar:arete non dans le chainage ' + % ,noar + write(imprim,*) 'arete de st1=',nosoar(1,noar), + % ' st2=',nosoar(2,noar),' ligne=',nosoar(3,noar), + % ' tr1=',nosoar(4,noar),' tr2=',nosoar(5,noar) + write(imprim,*) 'chainages=',(nosoar(i,noar),i=6,mosoar) + pause +c l'arete n'est pas detruite + return +c + endif +c + if( noar .ne. nosoar(1,noar) ) then +c +c saut de l'arete noar dans le chainage du hachage +c noar0 initialisee est ici l'arete qui precede noar dans ce chainage + nosoar( mosoar, noar0 ) = nosoar( mosoar, noar ) +c +c le chainage du hachage n'existe plus pour noar +c pas utile car mise a zero faite dans le sp hasoar +ccc nosoar( mosoar, noar ) = 0 +c +c noar devient la nouvelle premiere arete du chainage des vides + nosoar( 4, noar ) = 0 + nosoar( 5, noar ) = n1soar +c la nouvelle precede l'ancienne premiere + nosoar( 4, n1soar ) = noar + n1soar = noar +c +ccc else +c +c noar est la premiere arete du chainage du hachage h +c cette arete ne peut etre consideree dans le chainage des vides +c car le chainage du hachage doit etre conserve (sinon perte...) +c + endif +c +c le temoin d'arete vide + nosoar( 1, noar ) = 0 + endif + end + + + subroutine caetoi( noar, mosoar, mxsoar, n1soar, nosoar, + % n1aeoc, nbtrar ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : ajouter (ou retirer) l'arete noar de nosoar de l'etoile +c ----- des aretes simples chainees en position lchain de nosoar +c detruire du tableau nosoar les aretes doubles +c +c attention: le chainage lchain de nosoar devient celui des cf +c +c entree : +c -------- +c noar : numero dans le tableau nosoar de l'arete a traiter +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c +c entrees et sorties: +c ------------------- +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c n1aeoc : numero dans nosoar de la premiere arete simple de l'etoile +c +c sortie : +c -------- +c nbtrar : 1 si arete ajoutee, 2 si arete double supprimee +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c2345x7..............................................................012 + parameter (lchain=6) + integer nosoar(mosoar,mxsoar) +c +c si l'arete n'appartient pas aux aretes de l'etoile naetoi +c alors elle est ajoutee a l'etoile dans naetoi +c sinon elle est empilee dans npile pour etre detruite ensuite +c elle est supprimee de l'etoile naetoi +c + if( nosoar( lchain, noar ) .lt. 0 ) then +c +c arete de l'etoile vue pour la premiere fois +c elle est ajoutee au chainage + nosoar( lchain, noar ) = n1aeoc +c elle devient la premiere du chainage + n1aeoc = noar +c arete simple + nbtrar = 1 +c + else +c +c arete double de l'etoile. elle est supprimee du chainage + na0 = 0 + na = n1aeoc +c parcours des aretes chainees jusqu'a trouver l'arete noar + 10 if( na .ne. noar ) then +c passage a la suivante + na0 = na + na = nosoar( lchain, na ) + goto 10 + endif +c +c suppression de noar du chainage des aretes simples de l'etoile + if( na0 .gt. 0 ) then +c il existe une arete qui precede + nosoar( lchain, na0 ) = nosoar( lchain, noar ) + else +c noar est en fait n1aeoc la premiere du chainage + n1aeoc = nosoar( lchain, noar ) + endif +c noar n'est plus une arete simple de l'etoile + nosoar( lchain, noar ) = -1 +c +c destruction du tableau nosoar de l'arete double noar + call sasoar( noar, mosoar, mxsoar, n1soar, nosoar ) +c +c arete double + nbtrar = 2 + endif + end + + + subroutine focftr( nbtrcf, notrcf, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % nbarcf, n1arcf, noarcf, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : former un contour ferme (cf) avec les aretes simples des +c ----- nbtrcf triangles du tableau notrcf +c destruction des nbtrcf triangles du tableau noartr +c destruction des aretes doubles du tableau nosoar +c +c attention: le chainage lchain de nosoar devient celui des cf +c +c entrees: +c -------- +c nbtrcf : nombre de triangles du cf a former +c notrcf : numero des triangles dans le tableau noartr +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c +c entrees et sorties : +c -------------------- +c noarst : noarst(i) numero d'une arete de sommet i +c n1soar : numero de la premiere arete vide dans le tableau nosoar +c une arete i de nosoar est vide <=> nosoar(1,i)=0 +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c +c sorties: +c -------- +c nbarcf : nombre d'aretes du cf +c n1arcf : numero d'une arete de chaque contour +c noarcf : numero des aretes de la ligne du contour ferme +c attention: chainage circulaire des aretes +c les aretes vides pointes par n1arcf(0) ne sont pas chainees +c ierr : 0 si pas d'erreur +c 14 si les lignes fermees se coupent => donnees a revoir +c 15 si une seule arete simple frontaliere +c 16 si boucle infinie car toutes les aretes simples +c de la boule sont frontalieres! +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter (lchain=6) + common / unites / lecteu, imprim, nunite(30) + double precision pxyd(3,*) + integer notrcf(1:nbtrcf) + integer nosoar(mosoar,mxsoar), + % noartr(moartr,*), + % n1arcf(0:*), + % noarcf(3,*), + % noarst(*) +c +c formation des aretes simples du cf autour de l'arete ns1-ns2 +c attention: le chainage lchain du tableau nosoar devient actif +c ============================================================ +c ici toutes les aretes du tableau nosoar verifient nosoar(lchain,i) = -1 +c ce qui equivaut a dire que l'etoile des aretes simples est vide +c (initialisation dans le sp insoar puis remise a -1 dans la suite!) + n1aeoc = 0 +c +c ajout a l'etoile des aretes simples des 3 aretes des triangles a supprimer +c suppression des triangles de l'etoile pour les aretes simples de l'etoile + do 10 i=1,nbtrcf +c ajout ou retrait des 3 aretes du triangle notrcf(i) de l'etoile + nt = notrcf( i ) + do 5 j=1,3 +c l'arete de nosoar a traiter + noar = abs( noartr(j,nt) ) + call caetoi( noar, mosoar, mxsoar, n1soar, nosoar, + % n1aeoc, nbtrar ) +c si arete simple alors suppression du numero de triangle pour cette a + if( nbtrar .eq. 1 ) then + if( nosoar(4,noar) .eq. nt ) then + nosoar(4,noar) = nosoar(5,noar) + endif + nosoar(5,noar) = -1 +c else +c l'arete appartient a aucun triangle => elle est vide +c les positions 4 et 5 servent maintenant aux chainages des vides + endif + 5 continue + 10 continue +c +c les aretes simples de l'etoile sont reordonnees pour former une +c ligne fermee = un contour ferme peripherique de l'etoile encore dit 1 cf +c ======================================================================== + n1ae00 = n1aeoc + 12 na1 = n1aeoc +c la premiere arete du contour ferme + ns0 = nosoar(1,na1) + ns1 = nosoar(2,na1) +c +c l'arete est-elle dans le sens direct? +c recherche de l'arete du triangle exterieur nt d'arete na1 + nt = nosoar(4,na1) + if( nt .le. 0 ) nt = nosoar(5,na1) +c +c attention au cas de l'arete initiale frontaliere de no de triangles 0 et - + if( nt .le. 0 ) then +c permutation circulaire des aretes simples chainees +c la premiere arete doit devenir la derniere du chainage, +c la 2=>1, la 3=>2, ... , la derniere=>l'avant derniere, 1=>derniere + n1aeoc = nosoar( lchain, n1aeoc ) + if( n1aeoc .eq. n1ae00 ) then +c attention: boucle infinie si toutes les aretes simples +c de la boule sont frontalieres!... arretee par ce test + ierr = 16 + return + endif + noar = n1aeoc + na0 = 0 + 14 if( noar .gt. 0 ) then +c la sauvegarde de l'arete et l'arete suivante + na0 = noar + noar = nosoar(lchain,noar) + goto 14 + endif + if( na0 .le. 0 ) then +c une seule arete simple frontaliere + ierr = 15 + return + endif +c le suivant de l'ancien dernier est l'ancien premier + nosoar(lchain,na0) = na1 +c le nouveau dernier est l'ancien premier + nosoar(lchain,na1) = 0 + goto 12 + endif +c +c ici l'arete na1 est l'une des aretes du triangle nt + do 15 i=1,3 + if( abs(noartr(i,nt)) .eq. na1 ) then +c c'est l'arete + if( noartr(i,nt) .gt. 0 ) then +c elle est parcourue dans le sens indirect de l'etoile +c (car c'est en fait le triangle exterieur a la boule) + ns0 = nosoar(2,na1) + ns1 = nosoar(1,na1) + endif + goto 17 + endif + 15 continue +c +c le 1-er sommet ou arete du contour ferme + 17 n1arcf( 1 ) = 1 +c le nombre de sommets du contour ferme de l'etoile + nbarcf = 1 +c le premier sommet de l'etoile + noarcf( 1, nbarcf ) = ns0 +c l'arete suivante du cf + noarcf( 2, nbarcf ) = nbarcf + 1 +c le numero de cette arete dans le tableau nosoar + noarcf( 3, nbarcf ) = na1 +c mise a jour du numero d'arete du sommet ns0 + noarst(ns0) = na1 +c +cccc trace de l'arete +ccc call dvtrar( pxyd, ns0, ns1, ncvert, ncblan ) +c +c l'arete suivante a chainer + n1aeoc = nosoar( lchain, na1 ) +c l'arete na1 n'est plus dans l'etoile + nosoar( lchain, na1 ) = -1 +c +c boucle sur les aretes simples de l'etoile + 20 if( n1aeoc .gt. 0 ) then +c +c recherche de l'arete de 1-er sommet ns1 + na0 = -1 + na1 = n1aeoc + 25 if( na1 .gt. 0 ) then +c +c le numero du dernier sommet de l'arete precedente +c est il l'un des 2 sommets de l'arete na1? + if ( ns1 .eq. nosoar(1,na1) ) then +c l'autre sommet de l'arete na1 + ns2 = nosoar(2,na1) + else if( ns1 .eq. nosoar(2,na1) ) then +c l'autre sommet de l'arete na1 + ns2 = nosoar(1,na1) + else +c non: passage a l'arete suivante + na0 = na1 + na1 = nosoar( lchain, na1 ) + goto 25 + endif +c +c oui: na1 est l'arete peripherique suivante +c na0 est sa precedente dans le chainage +c une arete de plus dans le contour ferme (cf) + nbarcf = nbarcf + 1 +c le premier sommet de l'arete nbarcf peripherique + noarcf( 1, nbarcf ) = ns1 +c l'arete suivante du cf + noarcf( 2, nbarcf ) = nbarcf + 1 +c le numero de cette arete dans le tableau nosoar + noarcf( 3, nbarcf ) = na1 +c mise a jour du numero d'arete du sommet ns1 + noarst(ns1) = na1 +c +cccc trace de l'arete +ccc call dvtrar( pxyd, ns1, ns2, ncvert, ncblan ) +c +c suppression de l'arete des aretes simples de l'etoile + if( n1aeoc .eq. na1 ) then + n1aeoc = nosoar( lchain, na1 ) + else + nosoar( lchain, na0 ) = nosoar( lchain, na1 ) + endif +c l'arete n'est plus une arete simple de l'etoile + nosoar( lchain, na1 ) = -1 +c +c le sommet final de l'arete a rechercher ensuite + ns1 = ns2 + goto 20 + endif + endif +c +c verification + if( ns1 .ne. ns0 ) then +c arete non retrouvee : l'etoile ne se referme pas +c nblgrc(nrerr) = 3 +c kerr(1) = 'focftr: revoyez vos donnees' +c kerr(2) = 'les lignes fermees doivent etre disjointes' +c kerr(3) = 'verifiez si elles ne se coupent pas' +c call lereur + write(imprim,*) 'focftr: revoyez vos donnees' + write(imprim,*)'les lignes fermees doivent etre disjointes' + write(imprim,*)'verifiez si elles ne se coupent pas' + ierr = 14 + return + endif +c +c l'arete suivant la derniere arete du cf est la premiere du cf +c => realisation d'un chainage circulaire des aretes du cf + noarcf( 2, nbarcf ) = 1 +c +c destruction des triangles de l'etoile du tableau noartr +c ------------------------------------------------------- + do 50 i=1,nbtrcf +c le numero du triangle dans noartr + nt0 = notrcf( i ) +c l'arete 1 de nt0 devient nulle + noartr( 1, nt0 ) = 0 +c chainage de nt0 en tete du chainage des triangles vides de noartr + noartr( 2, nt0 ) = n1artr + n1artr = nt0 + 50 continue + end + + + subroutine int1sd( ns1, ns2, ns3, ns4, pxyd, linter, x0, y0 ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : existence ou non d'une intersection a l'interieur +c ----- des 2 aretes ns1-ns2 et ns3-ns4 +c attention les intersections au sommet sont comptees +c +c entrees: +c -------- +c ns1,...ns4 : numero pxyd des 4 sommets +c pxyd : les coordonnees des sommets +c +c sortie : +c -------- +c linter : -1 si ns3-ns4 parallele a ns1 ns2 +c 0 si ns3-ns4 n'intersecte pas ns1-ns2 entre les aretes +c 1 si ns3-ns4 intersecte ns1-ns2 entre les aretes +c 2 si le point d'intersection est ns1 entre ns3-ns4 +c 3 si le point d'intersection est ns3 entre ns1-ns2 +c 4 si le point d'intersection est ns4 entre ns1-ns2 +c x0,y0 : 2 coordonnees du point d'intersection s'il existe(linter>=1) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc fevrier 1992 +c2345x7..............................................................012 + parameter ( epsmoi=-0.000001d0, eps=0.001d0, + % unmeps= 0.999d0, unpeps=1.000001d0 ) + double precision pxyd(3,*), x0, y0 + double precision x1,y1,x21,y21,d21,x43,y43,d43,d,x,y,p21,p43 +c + x1 = pxyd(1,ns1) + y1 = pxyd(2,ns1) + x21 = pxyd(1,ns2) - x1 + y21 = pxyd(2,ns2) - y1 + d21 = x21**2 + y21**2 +c + x43 = pxyd(1,ns4) - pxyd(1,ns3) + y43 = pxyd(2,ns4) - pxyd(2,ns3) + d43 = x43**2 + y43**2 +c +c les 2 aretes sont-elles jugees paralleles ? + d = x43 * y21 - y43 * x21 + if( d*d .le. 0.000001d0 * d21 * d43 ) then +c cote i parallele a ns1-ns2 + linter = -1 + return + endif +c +c les 2 coordonnees du point d'intersection + x =( x1*x43*y21-pxyd(1,ns3)*x21*y43-(y1-pxyd(2,ns3))*x21*x43)/d + y =(-y1*y43*x21+pxyd(2,ns3)*y21*x43+(x1-pxyd(1,ns3))*y21*y43)/d +c +c coordonnee barycentrique de x,y dans le repere ns1-ns2 + p21 = ( ( x - x1 ) * x21 + ( y - y1 ) * y21 ) / d21 +c coordonnee barycentrique de x,y dans le repere ns3-ns4 + p43 = ( (x - pxyd(1,ns3))* x43 + (y - pxyd(2,ns3)) * y43 ) / d43 +c +c + if( epsmoi .le. p21 .and. p21 .le. unpeps ) then +c x,y est entre ns1-ns2 + if( (p21 .le. eps) .and. + % (epsmoi .le. p43 .and. p43 .le. unpeps) ) then +c le point x,y est proche de ns1 et interne a ns3-ns4 + linter = 2 + x0 = pxyd(1,ns1) + y0 = pxyd(2,ns1) + return + else if( epsmoi .le. p43 .and. p43 .le. eps ) then +c le point x,y est proche de ns3 et entre ns1-ns2 + linter = 3 + x0 = pxyd(1,ns3) + y0 = pxyd(2,ns3) + return + else if( unmeps .le. p43 .and. p43 .le. unpeps ) then +c le point x,y est proche de ns4 et entre ns1-ns2 + linter = 4 + x0 = pxyd(1,ns4) + y0 = pxyd(2,ns4) + return + else if( eps .le. p43 .and. p43 .le. unmeps ) then +c le point x,y est entre ns3-ns4 + linter = 1 + x0 = x + y0 = y + return + endif + endif +c +c pas d'intersection a l'interieur des aretes + linter = 0 + end + + + subroutine tefoar( narete, nbarpi, pxyd, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, noarst, + % mxarcf, n1arcf, noarcf, larmin, notrcf, + % ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : forcer l'arete narete de nosoar dans la triangulation actuelle +c ----- triangulation frontale pour la reobtenir +c +c attention: le chainage lchain(=6) de nosoar devient actif +c durant la formation des contours fermes (cf) +c +c entrees: +c -------- +c narete : numero nosoar de l'arete frontaliere a forcer +c nbarpi : numero du dernier point interne impose par l'utilisateur +c pxyd : tableau des coordonnees 2d des points +c par point : x y distance_souhaitee +c +c mosoar : nombre maximal d'entiers par arete et +c indice dans nosoar de l'arete suivante dans le hachage +c mxsoar : nombre maximal d'aretes stockables dans le tableau nosoar +c attention: mxsoar>3*mxsomm obligatoire! +c moartr : nombre maximal d'entiers par arete du tableau noartr +c +c modifies: +c --------- +c n1soar : no de l'eventuelle premiere arete libre dans le tableau nosoar +c chainage des vides suivant en 3 et precedant en 2 de nosoar +c nosoar : numero des 2 sommets , no ligne, 2 triangles de l'arete, +c chainage des aretes frontalieres, chainage du hachage des aretes +c hachage des aretes = nosoar(1)+nosoar(2)*2 +c avec mxsoar>=3*mxsomm +c une arete i de nosoar est vide <=> nosoar(1,i)=0 et +c nosoar(2,arete vide)=l'arete vide qui precede +c nosoar(3,arete vide)=l'arete vide qui suit +c n1artr : numero du premier triangle vide dans le tableau noartr +c le chainage des triangles vides se fait sur noartr(2,.) +c noartr : les 3 aretes des triangles +-arete1, +-arete2, +-arete3 +c arete1 = 0 si triangle vide => arete2 = triangle vide suivant +c noarst : noarst(i) numero d'une arete de sommet i +c +c mxarcf : nombre de variables des tableaux n1arcf, noarcf, larmin, notrcf +c +c tableaux auxiliaires : +c ---------------------- +c n1arcf : tableau (0:mxarcf) auxiliaire +c noarcf : tableau (3,mxarcf) auxiliaire +c larmin : tableau (mxarcf) auxiliaire +c notrcf : tableau (1:mxarcf) auxiliaire +c +c sortie : +c -------- +c ierr : 0 si pas d'erreur +c 1 saturation des sommets +c 2 ns1 dans aucun triangle +c 9 tableau nosoar de taille insuffisante car trop d'aretes +c a probleme +c 10 un des tableaux n1arcf, noarcf notrcf est sature +c augmenter a l'appel mxarcf +c 11 algorithme defaillant +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc mars 1997 +c....................................................................012 + parameter (mxpitr=32) + common / unites / lecteu,imprim,intera,nunite(29) + logical tratri + common / dv2dco / tratri + double precision pxyd(3,*) + integer noartr(moartr,*), + % nosoar(mosoar,mxsoar), + % noarst(*), + % n1arcf(0:mxarcf), + % noarcf(3,mxarcf), + % larmin(mxarcf), + % notrcf(mxarcf) +c + integer lapitr(mxpitr) + double precision x1,y1,x2,y2,d12,d3,d4,x,y,d,dmin + integer nosotr(3), ns(2) + integer nacf(1:2), nacf1, nacf2 + equivalence (nacf(1),nacf1), (nacf(2),nacf2) +c +c traitement de cette arete perdue + ns1 = nosoar( 1, narete ) + ns2 = nosoar( 2, narete ) +c + if( tratri ) then +c les traces sont demandes +c call efface +c le cadre objet global en unites utilisateur + xx1 = min( pxyd(1,ns1), pxyd(1,ns2) ) + xx2 = max( pxyd(1,ns1), pxyd(1,ns2) ) + yy1 = min( pxyd(2,ns1), pxyd(2,ns2) ) + yy2 = max( pxyd(2,ns1), pxyd(2,ns2) ) + if( xx1 .ge. xx2 ) xx2 = xx1 + (yy2-yy1) + if( yy1 .ge. yy2 ) yy2 = yy1 + (xx2-xx1)*0.5 +c call isofenetre( xx1-(xx2-xx1), xx2+(xx2-xx1), +c % yy1-(yy2-yy1), yy2+(yy2-yy1) ) + endif +c +cccc trace de l'arete perdue +ccc call dvtrar( pxyd, ns1, ns2, ncroug, ncblan ) +c +c le sommet ns2 est il correct? + na = noarst( ns2 ) + if( na .le. 0 ) then + write(imprim,*) 'tefoar: erreur sommet ',ns2,' sans arete' + ierr = 8 + return + endif + if( nosoar(4,na) .le. 0 ) then + write(imprim,*) 'tefoar: erreur sommet ',ns2, + % ' dans aucun triangle' + ierr = 8 + return + endif +c +c recherche du triangle voisin dans le sens indirect de rotation + nsens = -1 +c le premier passage: recherche dans le sens ns1->ns2 + ipas = 0 +c +c recherche des triangles intersectes par le segment ns1-ns2 +c ========================================================== + 3 x1 = pxyd(1,ns1) + y1 = pxyd(2,ns1) + x2 = pxyd(1,ns2) + y2 = pxyd(2,ns2) + d12 = (x2-x1)**2 + (y2-y1)**2 +c +c recherche du no local du sommet ns1 dans l'un de ses triangles + na01 = noarst( ns1 ) + if( na01 .le. 0 ) then + write(imprim,*) 'tefoar: sommet ',ns1,' sans arete' + ierr = 8 + return + endif + nt0 = nosoar(4,na01) + if( nt0 .le. 0 ) then + write(imprim,*) 'tefoar: sommet ',ns1,' dans aucun triangle' + ierr = 8 + return + endif +c +c le numero des 3 sommets du triangle nt0 dans le sens direct + 20 call nusotr( nt0, mosoar, nosoar, moartr, noartr, nosotr ) + do 22 na00=1,3 + if( nosotr(na00) .eq. ns1 ) goto 26 + 22 continue +c + 25 if( ipas .eq. 0 ) then +c le second passage: recherche dans le sens ns2->ns1 +c tentative d'inversion des 2 sommets extremites de l'arete a forcer + na00 = ns1 + ns1 = ns2 + ns2 = na00 + ipas = 1 + goto 3 + else +c les sens ns1->ns2 et ns2->ns1 ne donne pas de solution! + write(imprim,*)'tefoar:arete ',ns1,' - ',ns2,' a imposer' + write(imprim,*)'tefoar:anomalie sommet ',ns1, + % 'non dans le triangle de sommets ',(nosotr(i),i=1,3) + pause + ierr = 11 + return + endif +c +c le numero des aretes suivante et precedente + 26 na0 = nosui3( na00 ) + na1 = nopre3( na00 ) + ns3 = nosotr( na0 ) + ns4 = nosotr( na1 ) +c +cccc trace du triangle nt0 et de l'arete perdue +ccc call mttrtr( pxyd, nt0, moartr, noartr, mosoar, nosoar, +ccc % ncblan, ncjaun ) +ccc call dvtrar( pxyd, ns1, ns2, ncroug, ncblan ) +ccc call dvtrar( pxyd, ns3, ns4, ncbleu, nccyan ) +c +c point d'intersection du segment ns1-ns2 avec l'arete ns3-ns4 +c ------------------------------------------------------------ + call int1sd( ns1, ns2, ns3, ns4, pxyd, linter, x1, y1 ) + if( linter .le. 0 ) then +c +c pas d'intersection: rotation autour du point ns1 +c pour trouver le triangle de l'autre cote de l'arete na01 + if( nsens .lt. 0 ) then +c sens indirect de rotation: l'arete de sommet ns1 + na01 = abs( noartr(na00,nt0) ) + else +c sens direct de rotation: l'arete de sommet ns1 qui precede + na01 = abs( noartr(na1,nt0) ) + endif +c le triangle de l'autre cote de l'arete na01 + if( nosoar(4,na01) .eq. nt0 ) then + nt0 = nosoar(5,na01) + else + nt0 = nosoar(4,na01) + endif + if( nt0 .gt. 0 ) goto 20 +c +c le parcours sort du domaine +c il faut tourner dans l'autre sens autour de ns1 + if( nsens .lt. 0 ) then + nsens = 1 + nt0 = noarst( ns1 ) + goto 20 + endif +c +c dans les 2 sens, pas d'intersection => impossible +c essai avec l'arete inversee ns1 <-> ns2 + if( ipas .eq. 0 ) goto 25 + write(imprim,*) 'tefoar: arete ',ns1,' ',ns2, + % ' sans intersection avec les triangles actuels' + write(imprim,*) 'revoyez les lignes du contour' + ierr = 11 + return + endif +c +c il existe une intersection avec l'arete opposee au sommet ns1 +c ============================================================= +c nbtrcf : nombre de triangles du cf + nbtrcf = 1 + notrcf( 1 ) = nt0 +c +c le triangle oppose a l'arete na0 de nt0 + 30 noar = abs( noartr(na0,nt0) ) + if( nosoar(4,noar) .eq. nt0 ) then + nt1 = nosoar(5,noar) + else + nt1 = nosoar(4,noar) + endif +c +cccc trace du triangle nt1 et de l'arete perdue +ccc call mttrtr( pxyd, nt1, moartr, noartr, mosoar, nosoar, +ccc % ncjaun, ncmage ) +ccc call dvtrar( pxyd, ns1, ns2, ncroug, ncblan ) +c +c le numero des 3 sommets du triangle nt1 dans le sens direct + call nusotr( nt1, mosoar, nosoar, moartr, noartr, nosotr ) +c +c le triangle nt1 contient il ns2 ? + do 32 j=1,3 + if( nosotr(j) .eq. ns2 ) goto 70 + 32 continue +c +c recherche de l'arete noar, na1 dans nt1 qui est l'arete na0 de nt0 + do 34 na1=1,3 + if( abs( noartr(na1,nt1) ) .eq. noar ) goto 35 + 34 continue +c +c trace du triangle nt1 et de l'arete perdue + 35 continue +ccc 35 call mttrtr( pxyd, nt1, moartr, noartr, mosoar, nosoar, +ccc % ncjaun, ncmage ) +ccc call dvtrar( pxyd, ns1, ns2, ncroug, ncblan ) +c +c recherche de l'intersection de ns1-ns2 avec les 2 autres aretes de nt1 +c ====================================================================== + na2 = na1 + do 50 i1 = 1,2 +c l'arete suivante + na2 = nosui3(na2) +c +c les 2 sommets de l'arete na2 de nt1 + noar = abs( noartr(na2,nt1) ) + ns3 = nosoar( 1, noar ) + ns4 = nosoar( 2, noar ) +ccc call dvtrar( pxyd, ns3, ns4, ncbleu, nccyan ) +c +c point d'intersection du segment ns1-ns2 avec l'arete ns3-ns4 +c ------------------------------------------------------------ + call int1sd( ns1, ns2, ns3, ns4, pxyd, linter, x , y ) + if( linter .gt. 0 ) then +c +c les 2 aretes s'intersectent en (x,y) +c distance de (x,y) a ns3 et ns4 + d3 = (pxyd(1,ns3)-x)**2 + (pxyd(2,ns3)-y)**2 + d4 = (pxyd(1,ns4)-x)**2 + (pxyd(2,ns4)-y)**2 +c nsp est le point le plus proche de (x,y) + if( d3 .lt. d4 ) then + nsp = ns3 + d = d3 + else + nsp = ns4 + d = d4 + endif + if( d .gt. 1d-5*d12 ) goto 60 +c +c ici le sommet nsp est trop proche de l'arete perdue ns1-ns2 + if( nsp .le. nbarpi ) then +c point utilisateur ou frontalier non supprimable + ierr = 11 + write(imprim,*) 'pause dans tefoar 1', d, d3, d4, d12 + pause + return + endif +c +c le sommet interne nsp est supprime en mettant tous les triangles +c l'ayant comme sommet dans la pile notrcf des triangles a supprimer +c ------------------------------------------------------------------ +ccc write(imprim,*) 'tefoar: le sommet ',nsp,' est supprime' +c construction de la liste des triangles de sommet nsp + call trp1st( nsp, noarst, mosoar, nosoar, moartr, noartr, + % mxpitr, nbt, lapitr ) + if( nbt .le. 0 ) then +c les triangles de sommet nsp ne forme pas une "boule" +c avec ce sommet nsp pour "centre" + write(imprim,*) + % 'tefoar: pas d''etoile de triangles autour du sommet',nsp +cccc trace des triangles de l'etoile du sommet nsp +ccc tratri = .true. +ccc call trpltr( nbt, lapitr, pxyd, +ccc % moartr, noartr, mosoar, nosoar, +ccc % ncroug, ncblan ) +ccc tratri = .false. + ierr = 11 + write(imprim,*) 'pause dans tefoar 2' + pause + return + endif +c +c ajout des triangles de sommet ns1 a notrcf + nbtrc0 = nbtrcf + do 38 j=1,nbt + nt = lapitr(j) + do 37 k=nbtrcf,1,-1 + if( nt .eq. notrcf(k) ) goto 38 + 37 continue +c triangle ajoute + nbtrcf = nbtrcf + 1 + notrcf( nbtrcf ) = nt +ccc call mttrtr( pxyd, nt, moartr, noartr, mosoar, nosoar, +ccc % ncjaun, ncmage ) +ccc call dvtrar( pxyd, ns1, ns2, ncroug, ncblan ) + 38 continue +c +c ce sommet supprime n'appartient plus a aucun triangle + noarst( nsp ) = 0 +c +c ns2 est-il un sommet des triangles empiles? +c ------------------------------------------- + do 40 nt=nbtrc0+1,nbtrcf +c le triangle a supprimer nt + nt1 = notrcf( nt ) +c le numero des 3 sommets du triangle nt1 dans le sens direct + call nusotr( nt1, mosoar, nosoar, moartr, noartr, nosotr) + do 39 k=1,3 +c le sommet k de nt1 + if( nosotr( k ) .eq. ns2 ) then +c but atteint + goto 80 + endif + 39 continue + 40 continue +c +c recherche du plus proche point d'intersection de ns1-ns2 +c par rapport a ns2 avec les aretes des triangles ajoutes + nt0 = 0 + dmin = d12 * 10000 + do 48 nt=nbtrc0+1,nbtrcf + nt1 = notrcf( nt ) +c le numero des 3 sommets du triangle nt1 dans le sens direct + call nusotr( nt1, mosoar, nosoar, moartr, noartr, nosotr) + do 45 k=1,3 +c les 2 sommets de l'arete k de nt + ns3 = nosotr( k ) + ns4 = nosotr( nosui3(k) ) +c +c point d'intersection du segment ns1-ns2 avec l'arete ns3-ns4 +c ------------------------------------------------------------ + call int1sd( ns1, ns2, ns3, ns4, pxyd, + % linter, x , y ) + if( linter .gt. 0 ) then +c les 2 aretes s'intersectent en (x,y) + d = (x-x2)**2+(y-y2)**2 + if( d .lt. dmin ) then + nt0 = nt1 + na0 = k + dmin = d + endif + endif + 45 continue + 48 continue +c +c redemarrage avec le triangle nt0 et l'arete na0 + if( nt0 .gt. 0 ) goto 30 +c + write(imprim,*) 'tefoar: algorithme defaillant' + ierr = 11 + pause + return + endif + 50 continue +c +c pas d'intersection differente de l'initiale => sommet sur ns1-ns2 +c rotation autour du sommet par l'arete suivant na1 + write(imprim,*) + write(imprim,*) 'tefoar 50: revoyez vos donnees' + write(imprim,*) 'les lignes fermees doivent etre disjointes' + write(imprim,*) 'verifiez si elles ne se coupent pas' + ierr = 13 + pause + return +c +c cas sans probleme : intersection differente de celle initiale +c ================= ========================================= + 60 nbtrcf = nbtrcf + 1 + notrcf( nbtrcf ) = nt1 +c passage au triangle suivant + na0 = na2 + nt0 = nt1 + goto 30 +c +c ---------------------------------------------------------- +c ici toutes les intersections de ns1-ns2 ont ete parcourues +c tous les triangles intersectes ou etendus forment les +c nbtrcf triangles du tableau notrcf +c ---------------------------------------------------------- + 70 nbtrcf = nbtrcf + 1 + notrcf( nbtrcf ) = nt1 +c +c formation du cf des aretes simples des triangles de notrcf +c et destruction des nbtrcf triangles du tableau noartr +c attention: le chainage lchain du tableau nosoar devient actif +c ============================================================= + 80 if( nbtrcf*3 .gt. mxarcf ) then + write(imprim,*) 'saturation du tableau noarcf' + ierr = 10 + return + endif +c + call focftr( nbtrcf, notrcf, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % nbarcf, n1arcf, noarcf, + % ierr ) + if( ierr .ne. 0 ) return +c +c chainage des aretes vides dans le tableau noarcf +c ------------------------------------------------ +c decalage de 2 aretes car 2 aretes sont necessaires ensuite pour +c integrer 2 fois l'arete perdue et former ainsi 2 cf +c comme nbtrcf*3 minore mxarcf il existe au moins 2 places vides +c derriere => pas de test de debordement + n1arcf(0) = nbarcf+3 + mmarcf = min(8*nbarcf,mxarcf) + do 90 i=nbarcf+3,mmarcf + noarcf(2,i) = i+1 + 90 continue + noarcf(2,mmarcf) = 0 +c +c reperage des sommets ns1 ns2 de l'arete perdue dans le cf +c --------------------------------------------------------- + ns1 = nosoar( 1, narete ) + ns2 = nosoar( 2, narete ) + ns(1) = ns1 + ns(2) = ns2 + do 120 i=1,2 +c la premiere arete dans noarcf du cf + na0 = n1arcf(1) + 110 if( noarcf(1,na0) .ne. ns(i) ) then +c passage a l'arete suivante + na0 = noarcf( 2, na0 ) + goto 110 + endif +c position dans noarcf du sommet i de l'arete perdue + nacf(i) = na0 + 120 continue +c +c formation des 2 cf chacun contenant l'arete ns1-ns2 +c --------------------------------------------------- +c sauvegarde de l'arete suivante de celle de sommet ns1 + na0 = noarcf( 2, nacf1 ) + nt1 = noarcf( 3, nacf1 ) +c +c le premier cf + n1arcf( 1 ) = nacf1 +c l'arete suivante dans le premier cf + noarcf( 2, nacf1 ) = nacf2 +c cette arete est celle perdue + noarcf( 3, nacf1 ) = narete +c +c le second cf +c l'arete doublee + n1 = nbarcf + 1 + n2 = nbarcf + 2 +c le premier sommet de la premiere arete du second cf + noarcf( 1, n1 ) = ns2 +c l'arete suivante dans le second cf + noarcf( 2, n1 ) = n2 +c cette arete est celle perdue + noarcf( 3, n1 ) = narete +c la seconde arete du second cf + noarcf( 1, n2 ) = ns1 + noarcf( 2, n2 ) = na0 + noarcf( 3, n2 ) = nt1 + n1arcf( 2 ) = n1 +c +c recherche du precedent de nacf2 + 130 na1 = noarcf( 2, na0 ) + if( na1 .ne. nacf2 ) then +c passage a l'arete suivante + na0 = na1 + goto 130 + endif +c na0 precede nacf2 => il precede n1 + noarcf( 2, na0 ) = n1 +c +c depart avec 2 cf + nbcf = 2 +c +c triangulation directe des 2 contours fermes +c l'arete ns1-ns2 devient une arete de la triangulation des 2 cf +c ============================================================== + call tridcf( nbcf, pxyd, noarst, + % mosoar, mxsoar, n1soar, nosoar, + % moartr, n1artr, noartr, + % mxarcf, n1arcf, noarcf, larmin, + % nbtrcf, notrcf, ierr ) + end + + + subroutine te4ste( nbsomm, mxsomm, pxyd, ntrp, letree, + & ierr ) +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c but : decouper un te ntrp de letree en 4 sous-triangles +c ----- eliminer les sommets de te trop proches des points +c +c entrees: +c -------- +c mxsomm : nombre maximal de points declarables dans pxyd +c ntrp : numero letree du triangle a decouper en 4 sous-triangles +c +c modifies : +c ---------- +c nbsomm : nombre actuel de points dans pxyd +c pxyd : tableau des coordonnees des points +c par point : x y distance_souhaitee +c letree : arbre-4 des triangles equilateraux (te) fond de la triangulation +c letree(0,0) : no du 1-er te vide dans letree +c letree(0,1) : maximum du 1-er indice de letree (ici 8) +c letree(0,2) : maximum declare du 2-eme indice de letree (ici mxtree) +c letree(0:8,1) : racine de l'arbre (triangle sans sur triangle) +c si letree(0,.)>0 alors +c letree(0:3,j) : no (>0) letree des 4 sous-triangles du triangle j +c sinon +c letree(0:3,j) :-no pxyd des 1 a 4 points internes au triangle j +c 0 si pas de point +c ( j est alors une feuille de l'arbre ) +c letree(4,j) : no letree du sur-triangle du triangle j +c letree(5,j) : 0 1 2 3 no du sous-triangle j pour son sur-triangle +c letree(6:8,j) : no pxyd des 3 sommets du triangle j +c +c sorties : +c --------- +c ierr : 0 si pas d'erreur, 51 saturation letree, 52 saturation pxyd +c+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +c auteur : alain perronnet analyse numerique paris upmc juillet 1994 +c2345x7..............................................................012 + common / unites / lecteu,imprim,nunite(30) + integer letree(0:8,0:*) + double precision pxyd(3,mxsomm) + integer np(0:3),milieu(3) +c +c debut par l'arete 2 du triangle ntrp + i1 = 2 + i2 = 3 + do 30 i=1,3 +c +c le milieu de l'arete i1 existe t il deja ? + call n1trva( ntrp, i1, letree, noteva, niveau ) + if( noteva .gt. 0 ) then +c il existe un te voisin +c s'il existe 4 sous-triangles le milieu existe deja + if( letree(0,noteva) .gt. 0 ) then +c le milieu existe + nsot = letree(0,noteva) + milieu(i) = letree( 5+nopre3(i1), nsot ) + goto 25 + endif + endif +c +c le milieu n'existe pas. il est cree + nbsomm = nbsomm + 1 + if( nbsomm .gt. mxsomm ) then +c plus assez de place dans pxyd + write(imprim,*) 'te4ste: saturation pxyd' + write(imprim,*) + ierr = 52 + return + endif +c le milieu de l'arete i + milieu(i) = nbsomm +c +c ntrp est le triangle de milieux d'arete ces 3 sommets + ns1 = letree( 5+i1, ntrp ) + ns2 = letree( 5+i2, ntrp ) + pxyd(1,nbsomm) = ( pxyd(1,ns1) + pxyd(1,ns2) ) * 0.5 + pxyd(2,nbsomm) = ( pxyd(2,ns1) + pxyd(2,ns2) ) * 0.5 +c +c l'arete et milieu suivant + 25 i1 = i2 + i2 = nosui3( i2 ) + 30 continue +c + do 50 i=0,3 +c +c le premier triangle vide + nsot = letree(0,0) + if( nsot .le. 0 ) then +c manque de place. saturation letree + ierr = 51 + write(imprim,*) 'te4ste: saturation letree' + write(imprim,*) + return + endif +c +c mise a jour du premier te libre + letree(0,0) = letree(0,nsot) +c +c nsot est le i-eme sous triangle + letree(0,nsot) = 0 + letree(1,nsot) = 0 + letree(2,nsot) = 0 + letree(3,nsot) = 0 +c +c le numero des points et sous triangles dans ntrp + np(i) = -letree(i,ntrp) + letree(i,ntrp) = nsot +c +c le sommet commun avec le triangle ntrp + letree(5+i,nsot) = letree(5+i,ntrp) +c +c le sur-triangle et numero de sous-triangle de nsot +c a laisser ici car incorrect sinon pour i=0 + letree(4,nsot) = ntrp + letree(5,nsot) = i +c +c le sous-triangle du triangle + letree(i,ntrp) = nsot + 50 continue +c +c le numero des nouveaux sommets milieux + nsot = letree(0,ntrp) + letree(6,nsot) = milieu(1) + letree(7,nsot) = milieu(2) + letree(8,nsot) = milieu(3) +c + nsot = letree(1,ntrp) + letree(7,nsot) = milieu(3) + letree(8,nsot) = milieu(2) +c + nsot = letree(2,ntrp) + letree(6,nsot) = milieu(3) + letree(8,nsot) = milieu(1) +c + nsot = letree(3,ntrp) + letree(6,nsot) = milieu(2) + letree(7,nsot) = milieu(1) +c +c repartition des eventuels 4 points np dans ces 4 sous-triangles +c il y a obligatoirement suffisamment de place + do 110 i=0,3 + if( np(i) .gt. 0 ) then + nsot = notrpt( pxyd(1,np(i)), pxyd, ntrp, letree ) +c ajout du point + do 100 i1=0,3 + if( letree(i1,nsot) .eq. 0 ) then +c place libre a occuper + letree(i1,nsot) = -np(i) + goto 110 + endif + 100 continue + endif + 110 continue + end diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 000000000..72cfcf925 --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,22 @@ +#============================================================================== +# File : Makefile.in +# Created : ven déc 7 13:32:20 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + +@COMMENCE@ + +SUBDIRS = OBJECT SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV MEFISTO2 \ + SMESH SMESH_I SMESHFiltersSelection SMESHGUI \ + SMESH_SWIG + +@MODULE@ diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in new file mode 100644 index 000000000..b6a2db810 --- /dev/null +++ b/src/OBJECT/Makefile.in @@ -0,0 +1,33 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome + + +@COMMENCE@ + +EXPORT_HEADERS = SMESH_Actor.h \ + SMESH_Grid.h + + +# Libraries targets + +LIB = libSMESHObject.la +LIB_SRC = SMESH_Actor.cxx \ + SMESH_Grid.cxx + +LIB_CLIENT_IDL = + +# Executables targets +BIN = +BIN_SRC = + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) -lSalomeObject -L${KERNEL_ROOT_DIR}/lib/salome + +%_moc.cxx: %.h + $(MOC) $< -o $@ + + +@CONCLUDE@ diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx new file mode 100644 index 000000000..0a4390185 --- /dev/null +++ b/src/OBJECT/SMESH_Actor.cxx @@ -0,0 +1,598 @@ +using namespace std; +// File : SMESH_Actor.cxx +// Created : Mon May 13 22:31:18 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class SMESH_Actor SMESH_Actor.h + \brief ... +*/ + +#include "SMESH_Actor.h" +#include "SMESH_Grid.h" +#include "utilities.h" + +// VTK Includes +#include +#include +#include +#include +#include + +//------------------------------------------------------------- +// Main methods +//------------------------------------------------------------- + +SMESH_Actor* SMESH_Actor::New() +{ + // First try to create the object from the vtkObjectFactory + vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Actor"); + if(ret) + { + return (SMESH_Actor*)ret; + } + // If the factory was unable to create the object, then create it here. + return new SMESH_Actor; +} + + +SMESH_Actor::SMESH_Actor() +{ + this->Device = vtkActor::New(); + + this->EdgeDevice = vtkActor::New(); + EdgeDevice->VisibilityOff(); + EdgeDevice->PickableOff(); + + this->EdgeShrinkDevice = vtkActor::New(); + EdgeShrinkDevice->VisibilityOff(); + EdgeShrinkDevice->PickableOff(); + + myIO = NULL; + myName = ""; + myDisplayMode = 0; + + ishighlighted = false; + ispreselected = false; + + edgeColor.r = 0.; + edgeColor.g = 0.; + edgeColor.b = 0.; + + edgeHighlightColor.r = 1.; + edgeHighlightColor.g = 1.; + edgeHighlightColor.b = 1.; + + edgePreselectedColor.r = 0.; + edgePreselectedColor.g = 1.; + edgePreselectedColor.b = 1.; + + actorColor.r = 1.; + actorColor.g = 1.; + actorColor.b = 0.; + + actorHighlightColor.r = 1.; + actorHighlightColor.g = 1.; + actorHighlightColor.b = 1.; + + actorPreselectedColor.r = 0.; + actorPreselectedColor.g = 1.; + actorPreselectedColor.b = 1.; + + actorNodeColor.r = 1.; + actorNodeColor.g = 1.; + actorNodeColor.b = 0.; + + actorNodeSize = 2 ; + +} + +SMESH_Actor::~SMESH_Actor() +{ + this->EdgeDevice->Delete(); + this->EdgeShrinkDevice->Delete(); +} + +void SMESH_Actor::setReader(vtkUnstructuredGridReader* r) { + myReader=r; +} + +vtkUnstructuredGridReader* SMESH_Actor::getReader() { + return (myReader); +} + +vtkMapper* SMESH_Actor::getMapper() { + return (this->Mapper); +} + +void SMESH_Actor::ShallowCopy(vtkProp *prop) +{ + SMESH_Actor *f = SMESH_Actor::SafeDownCast(prop); + if ( f != NULL ) + { + this->setName( f->getName() ); + if ( f->hasIO() ) + this->setIO( f->getIO() ); + this->setDisplayMode( f->getDisplayMode() ); + + // Copy devices + vtkActor* tempDev = vtkActor::New(); + tempDev->ShallowCopy(f->Device); + vtkProperty* prp = vtkProperty::New(); + prp->DeepCopy(f->Device->GetProperty()); + tempDev->SetProperty(prp); + prp = vtkProperty::New(); + prp->DeepCopy(f->Device->GetBackfaceProperty()); + tempDev->SetBackfaceProperty(prp); + this->Device = tempDev; + + tempDev = vtkActor::New(); + tempDev->ShallowCopy(f->EdgeDevice); + prp = vtkProperty::New(); + prp->DeepCopy(f->EdgeDevice->GetProperty()); + tempDev->SetProperty(prp); + prp = vtkProperty::New(); + prp->DeepCopy(f->EdgeDevice->GetBackfaceProperty()); + tempDev->SetBackfaceProperty(prp); + this->EdgeDevice = tempDev; + + tempDev = vtkActor::New(); + tempDev->ShallowCopy(f->EdgeShrinkDevice); + prp = vtkProperty::New(); + prp->DeepCopy(f->EdgeShrinkDevice->GetProperty()); + tempDev->SetProperty(prp); + prp = vtkProperty::New(); + prp->DeepCopy(f->EdgeShrinkDevice->GetBackfaceProperty()); + tempDev->SetBackfaceProperty(prp); + this->EdgeShrinkDevice = tempDev; + + // Copy data source + this->DataSource = f->DataSource; + + this->myReader = f->myReader; + } + + // Now do superclass + this->SALOME_Actor::ShallowCopy(prop); + + // Here we need to modify default ShallowCopy() results + // Create copies of properties + if ( f != NULL ) { + vtkProperty* prp = vtkProperty::New(); + prp->DeepCopy(f->GetProperty()); + this->SetProperty(prp); + + prp = vtkProperty::New(); + prp->DeepCopy(f->GetBackfaceProperty()); + this->SetBackfaceProperty(prp); + + // Copy the mapper + vtkDataSetMapper* mpr = vtkDataSetMapper::New(); + mpr->ShallowCopy(f->GetMapper()); + mpr->SetInput(f->DataSource); + this->SetMapper(mpr); + } +} + +void SMESH_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper ) +{ + if (this->Mapper == NULL) { + MESSAGE ("No mapper for actor.") + return; + } + + if ( myDisplayMode == 1 ) { + EdgeDevice->VisibilityOn(); + EdgeShrinkDevice->VisibilityOff(); + } else if ( myDisplayMode == 2 ) { + EdgeShrinkDevice->VisibilityOn(); + EdgeDevice->VisibilityOff(); + } else { + EdgeShrinkDevice->VisibilityOff(); + EdgeDevice->VisibilityOff(); + } + + + vtkMapper *bestMapper; + bestMapper = this->Mapper; + + /* render the property */ + if (!this->Property) { + // force creation of a property + this->GetProperty(); + } + + if ( ishighlighted ) { + if ( myDisplayMode == 1 ) { + EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b); + this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b); + } else if ( myDisplayMode == 2 ) { + EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b); + } else { + this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b); + } + } else if (! ispreselected ) { + if ( myDisplayMode == 1 ) { + EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b); + this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b); + } + else if ( myDisplayMode == 2 ) + EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b); + else + this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b); + } + else { + if ( myDisplayMode == 1 ) + EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b); + else if ( myDisplayMode == 2 ) + EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b); + else + this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b); + } + + this->Property->Render(this, ren); + if (this->BackfaceProperty) { + this->BackfaceProperty->BackfaceRender(this, ren); + this->Device->SetBackfaceProperty(this->BackfaceProperty); + } + this->Device->SetProperty(this->Property); + + /* render the texture */ + if (this->Texture) { + this->Texture->Render(ren); + } + + + // Store information on time it takes to render. + // We might want to estimate time from the number of polygons in mapper. + this->Device->Render(ren,bestMapper); + this->EstimatedRenderTime = bestMapper->GetTimeToDraw(); +} + +int SMESH_Actor::RenderOpaqueGeometry(vtkViewport *vp) +{ + int renderedSomething = 0; + vtkRenderer *ren = (vtkRenderer *)vp; + + if ( ! this->Mapper ) { + return 0; + } + + // make sure we have a property + if (!this->Property) { + // force creation of a property + this->GetProperty(); + } + + if ( ishighlighted ) { + if ( myDisplayMode == 1 ) { + EdgeDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b); + } else if ( myDisplayMode == 2 ) { + EdgeShrinkDevice->GetProperty()->SetColor(edgeHighlightColor.r,edgeHighlightColor.g,edgeHighlightColor.b); + } else { + this->GetProperty()->SetColor(actorHighlightColor.r,actorHighlightColor.g,actorHighlightColor.b); + } + } else if (! ispreselected ) { + if ( myDisplayMode == 1 ) + EdgeDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b); + else if ( myDisplayMode == 2 ) + EdgeShrinkDevice->GetProperty()->SetColor(edgeColor.r,edgeColor.g,edgeColor.b); + else + this->GetProperty()->SetColor(actorColor.r,actorColor.g,actorColor.b); + } + else { + if ( myDisplayMode == 1 ) + EdgeDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b); + else if ( myDisplayMode == 2 ) + EdgeShrinkDevice->GetProperty()->SetColor(edgePreselectedColor.r,edgePreselectedColor.g,edgePreselectedColor.b); + else + this->GetProperty()->SetColor(actorPreselectedColor.r,actorPreselectedColor.g,actorPreselectedColor.b); + } + + // is this actor opaque ? + if (this->GetIsOpaque()) { + this->Property->Render(this, ren); + + // render the backface property + if (this->BackfaceProperty) { + this->BackfaceProperty->BackfaceRender(this, ren); + } + + // render the texture + if (this->Texture) { + this->Texture->Render(ren); + } + this->Render(ren,this->Mapper); + + renderedSomething = 1; + } + + return renderedSomething; +} + + +void SMESH_Actor::SetColor(float r,float g,float b) +{ + actorColor.r = r; + actorColor.g = g; + actorColor.b = b; +} + +void SMESH_Actor::GetColor(float& r,float& g,float& b) +{ + r = actorColor.r; + g = actorColor.g; + b = actorColor.b; +} + +void SMESH_Actor::SetPreselectedColor(float r,float g,float b) +{ + actorPreselectedColor.r = r; + actorPreselectedColor.g = g; + actorPreselectedColor.b = b; +} + +void SMESH_Actor::GetPreselectedColor(float& r,float& g,float& b) +{ + r = actorPreselectedColor.r; + g = actorPreselectedColor.g; + b = actorPreselectedColor.b; +} + +void SMESH_Actor::SetHighlightColor(float r,float g,float b) +{ + actorHighlightColor.r = r; + actorHighlightColor.g = g; + actorHighlightColor.b = b; +} + +void SMESH_Actor::GetHighlightColor(float& r,float& g,float& b) +{ + r = actorHighlightColor.r; + g = actorHighlightColor.g; + b = actorHighlightColor.b; +} + +void SMESH_Actor::SetEdgeColor(float r,float g,float b) +{ + edgeColor.r = r; + edgeColor.g = g; + edgeColor.b = b; +} + +void SMESH_Actor::GetEdgeColor(float& r,float& g,float& b) +{ + r = edgeColor.r; + g = edgeColor.g; + b = edgeColor.b; +} + +void SMESH_Actor::SetEdgeHighlightColor(float r,float g,float b) +{ + edgeHighlightColor.r = r; + edgeHighlightColor.g = g; + edgeHighlightColor.b = b; +} + +void SMESH_Actor::GetEdgeHighlightColor(float& r,float& g,float& b) +{ + r = edgeHighlightColor.r; + g = edgeHighlightColor.g; + b = edgeHighlightColor.b; +} + +void SMESH_Actor::SetEdgePreselectedColor(float r,float g,float b) +{ + edgePreselectedColor.r = r; + edgePreselectedColor.g = g; + edgePreselectedColor.b = b; +} + +void SMESH_Actor::GetEdgePreselectedColor(float& r,float& g,float& b) +{ + r = edgePreselectedColor.r; + g = edgePreselectedColor.g; + b = edgePreselectedColor.b; +} + + +void SMESH_Actor::SetNodeColor(float r,float g,float b) +{ + actorNodeColor.r = r ; + actorNodeColor.g = g ; + actorNodeColor.b = b ; +} + +void SMESH_Actor::GetNodeColor(float& r,float& g,float& b) +{ + r = actorNodeColor.r ; + g = actorNodeColor.g ; + b = actorNodeColor.b ; +} + +void SMESH_Actor::SetNodeSize(int size) +{ + actorNodeSize = size ; +} + +int SMESH_Actor::GetNodeSize() +{ + return actorNodeSize ; +} + + +void SMESH_Actor::AddNode(int idSMESHDSnode,int idVTKnode) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->AddNode(idSMESHDSnode, idVTKnode); + } else + MESSAGE("AddNode() method has been moved to SMESH_Grid class"); +} +void SMESH_Actor::AddElement(int idSMESHDSelement, int idVTKelement) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->AddElement(idSMESHDSelement, idVTKelement); + } else + MESSAGE("AddElement() method has been moved to SMESH_Grid class"); +} + +void SMESH_Actor::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->SetIdsVTKNode(mapVTK); + } else + MESSAGE("SetIdsVTKNode() method has been moved to SMESH_Grid class"); +} +void SMESH_Actor::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->SetIdsSMESHDSNode(mapSMESHDS); + } else + MESSAGE("SetIdsSMESHDSNode() method has been moved to SMESH_Grid class"); +} + +void SMESH_Actor::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->SetIdsVTKElement(mapVTK); + } else + MESSAGE("SetIdsVTKElement() method has been moved to SMESH_Grid class"); +} +void SMESH_Actor::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->SetIdsSMESHDSElement(mapSMESHDS); + } else + MESSAGE("SetIdsSMESHDSElement() method has been moved to SMESH_Grid class"); +} + +int SMESH_Actor::GetIdVTKNode(int idSMESHDSnode) +{ + if (DataSource->IsA("SMESH_Grid")) { + return ((SMESH_Grid*)DataSource)->GetIdVTKNode(idSMESHDSnode); + } else { + MESSAGE("GetIdVTKNode() method has been moved to SMESH_Grid class"); + return -1; + } +} +int SMESH_Actor::GetIdVTKElement(int idSMESHDSelement) +{ + if (DataSource->IsA("SMESH_Grid")) { + return ((SMESH_Grid*)DataSource)->GetIdVTKElement(idSMESHDSelement); + } else { + MESSAGE("GetIdVTKElement() method has been moved to SMESH_Grid class"); + return -1; + } + +} + +int SMESH_Actor::GetIdSMESHDSNode(int idVTKnode) +{ + if (DataSource->IsA("SMESH_Grid")) { + return ((SMESH_Grid*)DataSource)->GetIdSMESHDSNode(idVTKnode); + } else { + MESSAGE("GetIdSMESHDSNode() method has been moved to SMESH_Grid class"); + return -1; + } +} + +int SMESH_Actor::GetIdSMESHDSElement(int idVTKelement) +{ + if (DataSource->IsA("SMESH_Grid")) { + return ((SMESH_Grid*)DataSource)->GetIdSMESHDSElement(idVTKelement); + } else { + MESSAGE("AddNode() method has been moved to SMESH_Grid class"); + return -1; + } +} + +void SMESH_Actor::ClearNode() +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->ClearNode(); + } else + MESSAGE("ClearNode() method has been moved to SMESH_Grid class"); +} + +void SMESH_Actor::ClearElement() +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->ClearElement(); + } else + MESSAGE("ClearElement() method has been moved to SMESH_Grid class"); +} + +void SMESH_Actor::RemoveNode(int id) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->RemoveNode(id); + } else + MESSAGE("RemoveNode() method has been moved to SMESH_Grid class"); +} +void SMESH_Actor::RemoveElement(int id) +{ + if (DataSource->IsA("SMESH_Grid")) { + ((SMESH_Grid*)DataSource)->RemoveElement(id); + } else + MESSAGE("RemoveElement() method has been moved to SMESH_Grid class"); +} + +void SMESH_Actor::setDisplayMode(int thenewmode) { + myDisplayMode = thenewmode; + if ( myDisplayMode == 1 ) { + EdgeDevice->VisibilityOn(); + EdgeShrinkDevice->VisibilityOff(); + } else if ( myDisplayMode == 2 ) { + EdgeDevice->VisibilityOff(); + EdgeShrinkDevice->VisibilityOn(); + } else { + EdgeDevice->VisibilityOff(); + EdgeShrinkDevice->VisibilityOff(); + } +} + +float SMESH_Actor::GetShrinkFactor() +{ + return myShrinkFactor; +} + +void SMESH_Actor::SetShrinkFactor(float value ) +{ + if ( value <= 0.1 ) + value = 0.8; + + myShrinkFactor = value; +} + +void SMESH_Actor::GetChildActors(vtkActorCollection* actors) +{ + actors->AddItem(EdgeDevice); + actors->AddItem(EdgeShrinkDevice); +} + +void SMESH_Actor::SetVisibility(bool visibility) +{ + if ( visibility ) { + this->VisibilityOn(); + if ( myDisplayMode == 1 ) { + EdgeDevice->VisibilityOn(); + EdgeShrinkDevice->VisibilityOff(); + } else if ( myDisplayMode == 2 ) { + EdgeDevice->VisibilityOff(); + EdgeShrinkDevice->VisibilityOn(); + } else { + EdgeDevice->VisibilityOff(); + EdgeShrinkDevice->VisibilityOff(); + } + } else { + this->VisibilityOff(); + EdgeDevice->VisibilityOff(); + EdgeShrinkDevice->VisibilityOff(); + } +} + diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h new file mode 100644 index 000000000..c58c309c5 --- /dev/null +++ b/src/OBJECT/SMESH_Actor.h @@ -0,0 +1,137 @@ +// File : SMESH_Actor.h +// Created : Mon May 13 22:30:51 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SMESH_ACTOR_H +#define SMESH_ACTOR_H + +#include "SALOME_Actor.h" + +// VTK Includes +#include +#include +#include + +// Open CASCADE Includes +#include +#include + +typedef struct rgbStruct +{ + float r; + float g; + float b; +} RGBStruct; + +class SMESH_Actor : public SALOME_Actor { + + public: + vtkTypeMacro(SMESH_Actor,SALOME_Actor); + + static SMESH_Actor* New(); + + // Description: + // This causes the actor to be rendered. It, in turn, will render the actor`s + // property and then mapper. + virtual void Render(vtkRenderer *, vtkMapper *); + + // Description: + // This method is used internally by the rendering process. + // We overide the superclass method to properly set the estimated render time. + int RenderOpaqueGeometry(vtkViewport *viewport); + + void ShallowCopy(vtkProp *prop); + + void setReader(vtkUnstructuredGridReader* r) ; + vtkUnstructuredGridReader* getReader(); + + // Highlight + virtual bool hasHighlight() { return true; } + + vtkMapper* getMapper(); + + void setDisplayMode(int); + + void SetColor(float r,float g,float b); + void GetColor(float& r,float& g,float& b); + void SetHighlightColor(float r,float g,float b); + void GetHighlightColor(float& r,float& g,float& b); + void SetPreselectedColor(float r,float g,float b); + void GetPreselectedColor(float& r,float& g,float& b); + + void SetEdgeColor(float r,float g,float b); + void GetEdgeColor(float& r,float& g,float& b); + void SetEdgeHighlightColor(float r,float g,float b); + void GetEdgeHighlightColor(float& r,float& g,float& b); + void SetEdgePreselectedColor(float r,float g,float b); + void GetEdgePreselectedColor(float& r,float& g,float& b); + + void SetNodeColor(float r,float g,float b); + void GetNodeColor(float& r,float& g,float& b); + + void SetNodeSize(int size) ; + int GetNodeSize() ; + + + void ClearNode(); + void ClearElement(); + + void RemoveNode(int idSMESHDSnode); + void RemoveElement(int idSMESHDSelement); + + void AddNode(int idSMESHDSnode, int idVTKnode); + void AddElement(int idSMESHDSelement, int idVTKelement); + + int GetIdVTKNode(int idSMESHDSnode); + int GetIdVTKElement(int idSMESHDSelement); + + int GetIdSMESHDSNode(int idVTKnode); + int GetIdSMESHDSElement(int idVTKelement); + + void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK); + void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS); + + void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK); + void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS); + + vtkDataSet* DataSource; + vtkActor* EdgeDevice; + vtkActor* EdgeShrinkDevice; + + float GetShrinkFactor(); + void SetShrinkFactor(float value ); + + void GetChildActors(vtkActorCollection*); + + void SetVisibility(bool visibility); + + protected: + + SMESH_Actor(); + ~SMESH_Actor(); + SMESH_Actor(const SMESH_Actor&) {}; + void operator=(const SMESH_Actor&) {}; + + vtkUnstructuredGridReader* myReader; + + float myShrinkFactor; + + RGBStruct edgeColor; + RGBStruct edgeHighlightColor; + RGBStruct edgePreselectedColor; + + RGBStruct actorColor; + RGBStruct actorHighlightColor; + RGBStruct actorPreselectedColor; + + RGBStruct actorNodeColor; // LPN + int actorNodeSize; // LPN + +}; +#endif //SMESH_ACTOR_H diff --git a/src/OBJECT/SMESH_Grid.cxx b/src/OBJECT/SMESH_Grid.cxx new file mode 100644 index 000000000..de8c49e34 --- /dev/null +++ b/src/OBJECT/SMESH_Grid.cxx @@ -0,0 +1,141 @@ +using namespace std; +// File: SMESH_Grid.cxx +// Created: Fri Sep 27 15:47:42 2002 +// Author: Nicolas REJNERI + +#include "SMESH_Grid.h" + +#include "utilities.h" + +// VTK Includes +#include + +SMESH_Grid* SMESH_Grid::New() +{ + // First try to create the object from the vtkObjectFactory + vtkObject* ret = vtkObjectFactory::CreateInstance("SMESH_Grid"); + if(ret) + { + return (SMESH_Grid*)ret; + } + // If the factory was unable to create the object, then create it here. + return new SMESH_Grid; +} + +void SMESH_Grid::AddNode(int idSMESHDSnode,int idVTKnode) +{ + myMapNodeSMDStoVTK.Bind(idSMESHDSnode, idVTKnode); + myMapNodeVTKtoSMDS.Bind(idVTKnode, idSMESHDSnode); +} +void SMESH_Grid::AddElement(int idSMESHDSelement, int idVTKelement) +{ + myMapElementSMDStoVTK.Bind(idSMESHDSelement, idVTKelement); + myMapElementVTKtoSMDS.Bind(idVTKelement, idSMESHDSelement); +} + +void SMESH_Grid::SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK) +{ + myMapNodeVTKtoSMDS = mapVTK; +} +void SMESH_Grid::SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS) +{ + myMapNodeSMDStoVTK = mapSMESHDS; +} + +void SMESH_Grid::SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK) +{ + myMapElementVTKtoSMDS = mapVTK; +} +void SMESH_Grid::SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS) +{ + myMapElementSMDStoVTK = mapSMESHDS; +} + +int SMESH_Grid::GetIdVTKNode(int idSMESHDSnode) +{ + if ( myMapNodeSMDStoVTK.IsBound( idSMESHDSnode ) ) + return myMapNodeSMDStoVTK.Find(idSMESHDSnode); + else { + MESSAGE("GetIdVTKNode(): SMDS node not found: " << idSMESHDSnode); + return -1; + } +} +int SMESH_Grid::GetIdVTKElement(int idSMESHDSelement) +{ + if ( myMapElementSMDStoVTK.IsBound( idSMESHDSelement ) ) + return myMapElementSMDStoVTK.Find(idSMESHDSelement); + else { + MESSAGE("GetIdVTKElement(): SMDS element not found: " << idSMESHDSelement); + return -1; + } +} + +int SMESH_Grid::GetIdSMESHDSNode(int idVTKnode) +{ + if ( myMapNodeVTKtoSMDS.IsBound( idVTKnode ) ) + return myMapNodeVTKtoSMDS.Find(idVTKnode); + else { + MESSAGE("GetIdSMESHDSNode(): VTK node not found: " << idVTKnode); + return -1; + } +} +int SMESH_Grid::GetIdSMESHDSElement(int idVTKelement) +{ + if ( myMapElementVTKtoSMDS.IsBound( idVTKelement ) ) + return myMapElementVTKtoSMDS.Find(idVTKelement); + else { + MESSAGE("GetIdSMESHDSElement(): VTK element not found: " << idVTKelement); + return -1; + } +} + +void SMESH_Grid::ClearNode() +{ + myMapNodeVTKtoSMDS.Clear(); + myMapNodeSMDStoVTK.Clear(); +} +void SMESH_Grid::ClearElement() +{ + myMapElementVTKtoSMDS.Clear(); + myMapElementSMDStoVTK.Clear(); +} + +void SMESH_Grid::RemoveNode(int id) +{ + if ( myMapNodeSMDStoVTK.IsBound( id ) ) { + int idVTK = myMapNodeSMDStoVTK.Find(id); + myMapNodeSMDStoVTK.UnBind(id); + if ( myMapNodeVTKtoSMDS.IsBound( idVTK ) ) { + myMapNodeVTKtoSMDS.UnBind(idVTK); + } + } +} +void SMESH_Grid::RemoveElement(int id) +{ + if ( myMapElementSMDStoVTK.IsBound( id ) ) { + int idVTK = myMapElementSMDStoVTK.Find(id); + myMapElementSMDStoVTK.UnBind(id); + if ( myMapElementVTKtoSMDS.IsBound( idVTK ) ) { + myMapElementVTKtoSMDS.UnBind(idVTK); + } + } +} + +void SMESH_Grid::DeepCopy(vtkDataObject *src) +{ + SMESH_Grid* srcGrid = SMESH_Grid::SafeDownCast(src); + + if (srcGrid != NULL) { + CopyMaps(srcGrid); + } + + vtkUnstructuredGrid::DeepCopy(src); +} + +void SMESH_Grid::CopyMaps(SMESH_Grid *srcGrid) +{ + this->myMapNodeVTKtoSMDS = srcGrid->myMapNodeVTKtoSMDS; + this->myMapNodeSMDStoVTK = srcGrid->myMapNodeSMDStoVTK; + this->myMapElementVTKtoSMDS = srcGrid->myMapElementVTKtoSMDS; + this->myMapElementSMDStoVTK = srcGrid->myMapElementSMDStoVTK; +} diff --git a/src/OBJECT/SMESH_Grid.h b/src/OBJECT/SMESH_Grid.h new file mode 100644 index 000000000..2d5a6338d --- /dev/null +++ b/src/OBJECT/SMESH_Grid.h @@ -0,0 +1,61 @@ +// File : SMESH_Grid.h +// Created : Fri Sep 27 15:30:51 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SMESH_GRID_H +#define SMESH_GRID_H + +// VTK Includes +#include + +// Open CASCADE Includes +#include + +class SMESH_Grid : public vtkUnstructuredGrid { + + public: + vtkTypeMacro(SMESH_Grid, vtkUnstructuredGrid); + + static SMESH_Grid* New(); + + void ClearNode(); + void ClearElement(); + + void RemoveNode(int idSMESHDSnode); + void RemoveElement(int idSMESHDSelement); + + void AddNode(int idSMESHDSnode, int idVTKnode); + void AddElement(int idSMESHDSelement, int idVTKelement); + + int GetIdVTKNode(int idSMESHDSnode); + int GetIdVTKElement(int idSMESHDSelement); + + int GetIdSMESHDSNode(int idVTKnode); + int GetIdSMESHDSElement(int idVTKelement); + + void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK); + void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS); + + void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK); + void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS); + + virtual void DeepCopy (vtkDataObject *src); + void CopyMaps(SMESH_Grid *src); + + protected: + SMESH_Grid() : vtkUnstructuredGrid() {}; + + TColStd_DataMapOfIntegerInteger myMapNodeVTKtoSMDS; + TColStd_DataMapOfIntegerInteger myMapNodeSMDStoVTK; + + TColStd_DataMapOfIntegerInteger myMapElementVTKtoSMDS; + TColStd_DataMapOfIntegerInteger myMapElementSMDStoVTK; +}; + +#endif diff --git a/src/SMESHFiltersSelection/Handle_SMESH_TypeFilter.hxx b/src/SMESHFiltersSelection/Handle_SMESH_TypeFilter.hxx new file mode 100644 index 000000000..79db47025 --- /dev/null +++ b/src/SMESHFiltersSelection/Handle_SMESH_TypeFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SMESH_TypeFilter_HeaderFile +#define _Handle_SMESH_TypeFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include "Handle_SALOME_Filter.hxx" +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class SMESH_TypeFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SMESH_TypeFilter); + +class Handle(SMESH_TypeFilter) : public Handle(SALOME_Filter) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SMESH_TypeFilter)():Handle(SALOME_Filter)() {} + Handle(SMESH_TypeFilter)(const Handle(SMESH_TypeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(SMESH_TypeFilter)(const SMESH_TypeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(SMESH_TypeFilter)& operator=(const Handle(SMESH_TypeFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SMESH_TypeFilter)& operator=(const SMESH_TypeFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SMESH_TypeFilter* operator->() + { + return (SMESH_TypeFilter *)ControlAccess(); + } + + SMESH_TypeFilter* operator->() const + { + return (SMESH_TypeFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SMESH_TypeFilter)(); + + Standard_EXPORT static const Handle(SMESH_TypeFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SMESHFiltersSelection/Makefile.in b/src/SMESHFiltersSelection/Makefile.in new file mode 100644 index 000000000..6878fa16c --- /dev/null +++ b/src/SMESHFiltersSelection/Makefile.in @@ -0,0 +1,40 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSMESHFiltersSelection.la +LIB_SRC = SMESH_TypeFilter.cxx + +LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl + +# header files +EXPORT_HEADERS= SMESH_Type.h \ + SMESH_TypeFilter.hxx \ + Handle_SMESH_TypeFilter.hxx + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) +CXXFLAGS += $(OCC_CXXFLAGS) +LDFLAGS += $(OCC_LIBS) + +# additional file to be cleaned +MOSTLYCLEAN = +CLEAN = +DISTCLEAN = + +@CONCLUDE@ + diff --git a/src/SMESHFiltersSelection/SMESH_Type.h b/src/SMESHFiltersSelection/SMESH_Type.h new file mode 100644 index 000000000..7bf427270 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_Type.h @@ -0,0 +1,21 @@ +// File : SMESH_Type.h +// Created : Mon Jun 03 15:14:15 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +enum MeshObjectType { + HYPOTHESIS, + ALGORITHM, + MESH, + SUBMESH, + MESHorSUBMESH, + SUBMESH_VERTEX, + SUBMESH_EDGE, + SUBMESH_FACE, + SUBMESH_SOLID, + SUBMESH_COMPOUND +}; diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx new file mode 100644 index 000000000..3a14178e5 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -0,0 +1,139 @@ +using namespace std; +// File : SMESH_TypeFilter.cxx +// Created : Fri Dec 07 09:57:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE +// $Header$ + +#include "SMESH_TypeFilter.ixx" + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_TypeFilter.hxx" + +#include "utilities.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + + +SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType) +{ + myKind = aType; +} + +Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "MESH" ); + if ( !meshFilter->IsOk(anObj) ) + return false; + + if ( anObj->hasEntry() ) { + QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() ); + + bool Ok = false; + + switch ( myKind ) + { + case HYPOTHESIS: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + Ok = true; + break; + } + case ALGORITHM: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + Ok = true; + break; + } + case MESH: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) + Ok = true; + break; + } + case SUBMESH: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + Ok = true; + break; + } + case MESHorSUBMESH: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) + Ok = true; + + if (( objFather->Tag() >= 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + Ok = true; + + break; + } + case SUBMESH_VERTEX: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + Ok = true; + break; + } + case SUBMESH_EDGE: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + Ok = true; + break; + } + case SUBMESH_FACE: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + Ok = true; + break; + } + case SUBMESH_SOLID: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + Ok = true; + break; + } + case SUBMESH_COMPOUND: + { + SALOMEDS::SObject_var objFather = obj->GetFather(); + SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); + + if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + Ok = true; + break; + } + } + + if ( Ok ) + return true; + } + return false; +} diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx new file mode 100644 index 000000000..9e98ab8b8 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.hxx @@ -0,0 +1,95 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SMESH_TypeFilter_HeaderFile +#define _SMESH_TypeFilter_HeaderFile + +#ifndef _Handle_SMESH_TypeFilter_HeaderFile +#include "Handle_SMESH_TypeFilter.hxx" +#endif + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Filter.hxx" +#include "SMESH_Type.h" + +// Open CASCADE Includes +#include + +class SMESH_TypeFilter : public SALOME_Filter { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SMESH_TypeFilter(MeshObjectType aType); +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~SMESH_TypeFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SMESH_TypeFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +MeshObjectType myKind; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.ixx b/src/SMESHFiltersSelection/SMESH_TypeFilter.ixx new file mode 100644 index 000000000..a01d02ee0 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SMESH_TypeFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SMESH_TypeFilter::~SMESH_TypeFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& SMESH_TypeFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SMESH_TypeFilter", + sizeof(SMESH_TypeFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SMESH_TypeFilter) Handle(SMESH_TypeFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SMESH_TypeFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SMESH_TypeFilter))) { + _anOtherObject = Handle(SMESH_TypeFilter)((Handle(SMESH_TypeFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SMESH_TypeFilter::DynamicType() const +{ + return STANDARD_TYPE(SMESH_TypeFilter) ; +} +Standard_Boolean SMESH_TypeFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SMESH_TypeFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_SMESH_TypeFilter::~Handle_SMESH_TypeFilter() {} + diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.jxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.jxx new file mode 100644 index 000000000..2aed9c397 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _SMESH_TypeFilter_HeaderFile +#include "SMESH_TypeFilter.hxx" +#endif diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in new file mode 100644 index 000000000..4fed8d203 --- /dev/null +++ b/src/SMESHGUI/Makefile.in @@ -0,0 +1,111 @@ +# -* Makefile *- +# +# Author : Nicolas REJNERI +# Date : Sun May 05 11:45:40 2002 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= SMESHGUI_Swig.hxx \ + SMESHGUI_Swig.i + +# .po files to transform in .qm +PO_FILES = \ + SMESH_icons.po \ + SMESH_msg_en.po + +# Libraries targets +LIB = libSMESHGUI.la +LIB_SRC = SMESHGUI.cxx \ + SMESHGUI_StudyAPI.cxx \ + SMESHGUI_SpinBox.cxx \ + SMESHGUI_NodesDlg.cxx \ + SMESHGUI_AddHypothesisDlg.cxx \ + SMESHGUI_AddAlgorithmDlg.cxx \ + SMESHGUI_InitMeshDlg.cxx \ + SMESHGUI_AddSubMeshDlg.cxx \ + SMESHGUI_LocalLengthDlg.cxx \ + SMESHGUI_NbSegmentsDlg.cxx \ + SMESHGUI_TransparencyDlg.cxx \ + SMESHGUI_RemoveNodesDlg.cxx \ + SMESHGUI_RemoveElementsDlg.cxx \ + SMESHGUI_MeshInfosDlg.cxx \ + SMESHGUI_Preferences_ColorDlg.cxx \ + SMESHGUI_MaxElementAreaDlg.cxx \ + SMESHGUI_Preferences_ScalarBarDlg.cxx \ + SMESHGUI_EditScalarBarDlg.cxx \ + SMESHGUI_aParameterDlg.cxx \ + SMESHGUI_MaxElementVolumeDlg.cxx \ + SMESHGUI_Swig.cxx \ + SMESHGUI_ComputeScalarValue.cxx \ + SMESHGUI_MoveNodesDlg.cxx \ + SMESHGUI_OrientationElementsDlg.cxx \ + SMESHGUI_DiagonalInversionDlg.cxx \ + SMESHGUI_EdgesConnectivityDlg.cxx \ + SMESHGUI_AddFaceDlg.cxx \ + SMESHGUI_AddVolumeDlg.cxx \ + SMESHGUI_AddEdgeDlg.cxx \ + SMESHGUI_EditHypothesesDlg.cxx + +LIB_MOC = \ + SMESHGUI.h \ + SMESHGUI_NodesDlg.h \ + SMESHGUI_SpinBox.h \ + SMESHGUI_AddHypothesisDlg.h \ + SMESHGUI_AddAlgorithmDlg.h \ + SMESHGUI_InitMeshDlg.h \ + SMESHGUI_AddSubMeshDlg.h \ + SMESHGUI_LocalLengthDlg.h \ + SMESHGUI_NbSegmentsDlg.h \ + SMESHGUI_TransparencyDlg.h \ + SMESHGUI_RemoveNodesDlg.h \ + SMESHGUI_RemoveElementsDlg.h \ + SMESHGUI_MeshInfosDlg.h \ + SMESHGUI_Preferences_ColorDlg.h \ + SMESHGUI_MaxElementAreaDlg.h \ + SMESHGUI_Preferences_ScalarBarDlg.h \ + SMESHGUI_EditScalarBarDlg.h \ + SMESHGUI_aParameterDlg.h \ + SMESHGUI_MaxElementVolumeDlg.h \ + SMESHGUI_MoveNodesDlg.h \ + SMESHGUI_OrientationElementsDlg.h \ + SMESHGUI_DiagonalInversionDlg.h \ + SMESHGUI_EdgesConnectivityDlg.h \ + SMESHGUI_AddEdgeDlg.h \ + SMESHGUI_AddVolumeDlg.h \ + SMESHGUI_AddFaceDlg.h \ + SMESHGUI_EditHypothesesDlg.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SMESH_Gen.idl \ + SMESH_Mesh.idl \ + SMESH_Hypothesis.idl \ + SMESH_BasicHypothesis.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + MED.idl + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome +#$(OCC_CXXFLAGS) + +LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lSMESHObject -lSMDS -lSMESHDS -lSMESHFiltersSelection -lGeometryClient -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV $(OCC_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx new file mode 100644 index 000000000..72e66bf00 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -0,0 +1,6013 @@ +using namespace std; +// File : SMESHGUI.cxx +// Created : Sun May 05 11:49:46 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI.h" +#include "SMESHGUI_AddHypothesisDlg.h" +#include "SMESHGUI_AddAlgorithmDlg.h" +#include "SMESHGUI_InitMeshDlg.h" +#include "SMESHGUI_LocalLengthDlg.h" +#include "SMESHGUI_NbSegmentsDlg.h" +#include "SMESHGUI_AddSubMeshDlg.h" +#include "SMESHGUI_NodesDlg.h" +#include "SMESHGUI_TransparencyDlg.h" +#include "SMESHGUI_RemoveNodesDlg.h" +#include "SMESHGUI_RemoveElementsDlg.h" +#include "SMESHGUI_MeshInfosDlg.h" +#include "SMESHGUI_Preferences_ColorDlg.h" +#include "SMESHGUI_MaxElementAreaDlg.h" +#include "SMESHGUI_MaxElementVolumeDlg.h" +#include "SMESHGUI_Preferences_ScalarBarDlg.h" +#include "SMESHGUI_EditScalarBarDlg.h" +#include "SMESHGUI_aParameterDlg.h" +#include "SMESHGUI_ComputeScalarValue.h" +#include "SMESHGUI_MoveNodesDlg.h" +#include "SMESHGUI_OrientationElementsDlg.h" +#include "SMESHGUI_DiagonalInversionDlg.h" +#include "SMESHGUI_EdgesConnectivityDlg.h" +#include "SMESHGUI_AddFaceDlg.h" +#include "SMESHGUI_AddEdgeDlg.h" +#include "SMESHGUI_AddVolumeDlg.h" +#include "SMESHGUI_EditHypothesesDlg.h" + +#include "SMESH_Grid.h" + +// SALOME Includes +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Config.h" +#include "QAD_Settings.h" +#include "QAD_RightFrame.h" +#include "QAD_MessageBox.h" +#include "QAD_Resource.h" +#include "QAD_FileDlg.h" +#include "SALOMEGUI_Desktop.h" +#include "SALOMEGUI_NameDlg.h" + +#include "OCCViewer_ViewPort.h" +#include "OCCViewer_ViewPort3d.h" +#include "OCCViewer_Viewer3d.h" + +#include "VTKViewer_RenderWindowInteractor.h" +#include "VTKViewer_ViewFrame.h" +//#include "QAD_ViewPort.h" +//#include "QAD_ViewPort3d.h" + +#include "GEOM_Client.hxx" +#include "GEOM_InteractiveObject.hxx" + +#include "SALOME_NamingService.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_InteractiveObject.hxx" + +#include "SALOMEGUI_ImportOperation.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "utilities.h" + +#include "SMDS_Mesh.hxx" +#include "SMESHDS_Document.hxx" +#include "Document_Reader.h" +#include "Document_Writer.h" +#include "Mesh_Reader.h" +#include "Mesh_Writer.h" + +#include "DriverDAT_R_SMESHDS_Document.h" +#include "DriverMED_R_SMESHDS_Document.h" +#include "DriverUNV_R_SMESHDS_Document.h" +#include "DriverDAT_W_SMESHDS_Document.h" +#include "DriverMED_W_SMESHDS_Document.h" +#include "DriverUNV_W_SMESHDS_Document.h" +#include "DriverDAT_R_SMESHDS_Mesh.h" +#include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverUNV_R_SMESHDS_Mesh.h" +#include "DriverDAT_W_SMESHDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Mesh.h" +#include "DriverUNV_W_SMESHDS_Mesh.h" + +// QT Includes +#define INCLUDE_MENUITEM_DEF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// VTK Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Open CASCADE Includes +#include +#include + +static GEOM_Client ShapeReader; +static SMESHGUI* smeshGUI = 0; +static CORBA::ORB_var _orb; + + +//============================================================================= +/*! + * + */ +//============================================================================= +class CustomItem : public QCustomMenuItem +{ +public: + CustomItem( const QString& s, const QFont& f ) + : string( s ), font( f ){}; + ~CustomItem(){} + + void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h ) + { + p->setFont ( font ); + p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); + } + + QSize sizeHint() + { + return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); + } +private: + QString string; + QFont font; +}; + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESHGUI::SMESHGUI() : + QObject() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESHGUI::~SMESHGUI() +{ +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESHGUI* SMESHGUI::GetSMESHGUI( ) +{ + return smeshGUI; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESHGUI* SMESHGUI::GetOrCreateSMESHGUI( QAD_Desktop* desktop ) +{ + if( smeshGUI == 0 ) { + setOrb(); + smeshGUI = new SMESHGUI; + smeshGUI->myActiveDialogBox = 0 ; + smeshGUI->myState = -1 ; + smeshGUI->myDesktop = desktop ; + smeshGUI->myActiveStudy = desktop->getActiveStudy(); + + Engines::Component_var comp = desktop->getEngine("FactoryServer", "SMESH"); + smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp); + + Engines::Component_var comp1 = desktop->getEngine("FactoryServer", "Geometry"); + smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1); + + /* GetCurrentStudy */ + smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId(); + + smeshGUI->myComponentGeom->GetCurrentStudy( smeshGUI->myStudyId ); + // smeshGUI->myComponentGeom->NbLabels(); + + smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument(); + + smeshGUI->myStudyAPI = SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh); + + smeshGUI->myDocument = new SMESHDS_Document(1);//NBU + + smeshGUI->mySimulationActors = vtkActorCollection::New(); + smeshGUI->mySimulationActors2D = vtkActor2DCollection::New(); + } else { + /* study may have changed */ + smeshGUI->myActiveStudy = desktop->getActiveStudy(); + smeshGUI->myStudyAPI.Update(smeshGUI->myComponentMesh); + } + + /* Automatic Update */ + if ( desktop->menuBar()->isItemChecked(1001) ) + smeshGUI->myAutomaticUpdate = true; + else + smeshGUI->myAutomaticUpdate = false; + + return smeshGUI; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::SetState(int aState ) +{ this->myState = aState ; return ; } + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::ResetState() +{ this->myState = -1 ; return ; } + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::EmitSignalDeactivateDialog() +{ + emit this->SignalDeactivateActiveDialog() ; + return ; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::EmitSignalCloseAllDialogs() +{ + emit this->SignalCloseAllDialogs() ; + return ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +QDialog* SMESHGUI::GetActiveDialogBox() +{ + return this->myActiveDialogBox ; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::SetActiveDialogBox(QDialog* aDlg) +{ + this->myActiveDialogBox = (QDialog*)aDlg ; + return ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +QAD_Study* SMESHGUI::GetActiveStudy() +{ + return this->myActiveStudy ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SALOMEDS::Study_ptr SMESHGUI::GetStudy() +{ + return SALOMEDS::Study::_narrow( myStudy ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI() +{ + return myStudyAPI; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +QAD_Desktop* SMESHGUI::GetDesktop() +{ + return this->myDesktop ; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +vtkScalarBarActor* SMESHGUI::GetScalarBar() +{ + vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActor2DCollection* actor2DList = aRenderer->GetActors2D(); + actor2DList->InitTraversal(); + vtkActor2D* aActor2d = actor2DList->GetNextActor2D(); + while (aActor2d != NULL) { + if (aActor2d->IsA("vtkScalarBarActor")) + return vtkScalarBarActor::SafeDownCast(aActor2d); + actor2DList->GetNextActor2D(); + } + return NULL; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::activeStudyChanged( QAD_Desktop* parent ) +{ + MESSAGE ("SMESHGUI::activeStudyChanged init.") + /* Create or retrieve an object SMESHGUI */ + SMESHGUI::GetOrCreateSMESHGUI(parent); + if(smeshGUI != 0) { + smeshGUI->EmitSignalCloseAllDialogs() ; + MESSAGE( "Active study changed : SMESHGUI nullified" << endl ) ; + smeshGUI = 0 ; + } + + //smeshGUI->SetSettings( parent ); //DCQ : Pb. Multi-Etudes + MESSAGE ("SMESHGUI::activeStudyChanged done.") + return ; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::DefineDlgPosition(QWidget* aDlg, int& x, int& y) +{ + /* Here the position is on the bottom right corner - 10 */ + QAD_Desktop* PP = QAD_Application::getDesktop() ; + x = abs ( PP->x() + PP->size().width() - aDlg->size().width() - 10 ) ; + y = abs ( PP->y() + PP->size().height() - aDlg->size().height() - 10 ) ; + return true ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::EraseSimulationActors() +{ + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + + if ( mySimulationActors != NULL ) { + + mySimulationActors->InitTraversal(); + vtkActor *ac = mySimulationActors->GetNextActor(); + while(!(ac==NULL)) { + theRenderer->RemoveActor(ac); + ac = mySimulationActors->GetNextActor(); + } + mySimulationActors->RemoveAllItems(); + } + if ( mySimulationActors2D != NULL ) { + mySimulationActors2D->InitTraversal(); + vtkActor2D *ac = mySimulationActors2D->GetNextActor2D(); + while(!(ac==NULL)) { + theRenderer->RemoveActor2D(ac); + ac = mySimulationActors2D->GetNextActor2D(); + } + mySimulationActors2D->RemoveAllItems(); + } + renWin->Render(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh ) +{ + try { + if ( !myComponentMesh->_is_nil() && !aShape->_is_nil() ) { + SMESH::SMESH_Mesh_var aMesh = myComponentMesh->Init( myComponentGeom, myStudyId, aShape); + + if ( !aMesh->_is_nil() ) { + SALOMEDS::SObject_var SM = myStudyAPI.AddNewMesh ( aMesh ); + myStudyAPI.SetName( SM, NameMesh ); + + // GEOM::GEOM_Shape has non-empty StudyShapeId only after AddInStudy operation, + // not after loading from file, so let's use more reliable way to retrieve SObject + Standard_CString ShapeIOR = _orb->object_to_string(aShape); + SALOMEDS::SObject_var SObject = myStudy->FindObjectIOR(ShapeIOR); + if ( !SObject->_is_nil() && !SM->_is_nil() ) { + myStudyAPI.SetShape( SM, SObject ); + } + return SMESH::SMESH_Mesh::_narrow(aMesh); + } + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); + return SMESH::SMESH_Mesh::_nil(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh ) +{ + try { + SMESH::SMESH_subMesh_var aSubMesh = aMesh->GetElementsOnShape(aShape); + SALOMEDS::SObject_var SO_Mesh = myStudyAPI.FindMesh(aMesh); + Standard_CString ShapeIOR = _orb->object_to_string(aShape); + SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectIOR(ShapeIOR); + + if ( !SO_GeomShape->_is_nil() && !SO_Mesh->_is_nil() && !aSubMesh->_is_nil() && !aMesh->_is_nil() ) { + SALOMEDS::SObject_var SO = myStudyAPI.AddSubMeshOnShape(SO_Mesh, SO_GeomShape, aSubMesh, aShape->ShapeType() ); + myStudyAPI.SetName(SO, NameMesh); + + SMESH_Actor* amesh = SMESH_Actor::New(); + Handle(SALOME_InteractiveObject) IO = new SALOME_InteractiveObject(SO->GetID(), + "MESH", + strdup(NameMesh)); + amesh->setIO( IO ); + amesh->setName( strdup(NameMesh) ); + DisplayActor(amesh, false); + return SMESH::SMESH_subMesh::_narrow( aSubMesh ); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); + return SMESH::SMESH_subMesh::_nil(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis( QString TypeHypothesis, + QString NameHypothesis ) +{ + SMESH::SMESH_Hypothesis_var Hyp; + try { + Hyp = myComponentMesh->CreateHypothesis( TypeHypothesis, myStudyId ); + if ( !Hyp->_is_nil() ) { + SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewHypothesis( Hyp ); + myStudyAPI.SetName( SHyp, NameHypothesis); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + return SMESH::SMESH_Hypothesis::_narrow( Hyp ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) +{ + if ( !aMesh->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOMEDS::SObject_var SM = myStudyAPI.FindMesh( aMesh ); + GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SM ); + try { + bool res = aMesh->AddHypothesis( aShape, aHyp ); + if (res) { + SALOMEDS::SObject_var SH = myStudyAPI.FindHypothesisOrAlgorithms( aHyp ); + if ( !SM->_is_nil() && !SH->_is_nil() ) { + myStudyAPI.SetHypothesis( SM, SH ); + myStudyAPI.ModifiedMesh( SM, false ); + } + QApplication::restoreOverrideCursor(); + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"), tr ("SMESH_BUT_YES") ); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) +{ + if ( IObject->hasReference() ) { + SMESH::SMESH_Hypothesis_var anHyp; + SALOMEDS::SObject_var SO_Hypothesis = smeshGUI->myStudy->FindObjectID(IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + + if ( !SO_Hypothesis->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anHyp = SMESH::SMESH_Hypothesis::_narrow( _orb->string_to_object(anIOR->Value()) ); + } + + SALOMEDS::SObject_var SO_Applied_Hypothesis = smeshGUI->myStudy->FindObjectID(IObject->getReference()); + if ( !SO_Applied_Hypothesis->_is_nil() ) { + SALOMEDS::SObject_var MorSM = smeshGUI->myStudyAPI.GetMeshOrSubmesh( SO_Applied_Hypothesis ); + if ( !MorSM->_is_nil() ) { + smeshGUI->myStudyAPI.ModifiedMesh( MorSM, false ); + + GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh( MorSM ); + if ( !aShape->_is_nil() ) { + if (MorSM->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->RemoveHypothesis( aShape, anHyp ); + if ( !res ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_NOTEXIST"), tr ("SMESH_BUT_YES") ); + } + } else if ( !aSubMesh->_is_nil() ) { + aMesh = aSubMesh->GetFather(); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->RemoveHypothesis( aShape, anHyp ); + if ( !res ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_NOTEXIST"), tr ("SMESH_BUT_YES") ); + } + } + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { +#ifdef TRACE + Dump( Mesh ); +#endif + DisplayActor( Mesh ); + DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + } + } + } + } + } + smeshGUI->myStudyAPI.UnSetHypothesis( SO_Applied_Hypothesis ); + } + } + } else if ( IObject->hasEntry() ) { + MESSAGE ( "IObject entry " << IObject->getEntry() ) + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) +{ + SALOMEDS::SObject_var AHR, aRef; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + + if ( !MorSM->_is_nil() ) { + GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh( MorSM ); + if ( !aShape->_is_nil() ) { + if (MorSM->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->RemoveHypothesis( aShape, anHyp ); + if ( !res ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_NOTEXIST"), tr ("SMESH_BUT_YES") ); + } + } else if ( !aSubMesh->_is_nil() ) { + aMesh = aSubMesh->GetFather(); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->RemoveHypothesis( aShape, anHyp ); + if ( !res ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_NOTEXIST"), tr ("SMESH_BUT_YES") ); + } + } + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { +#ifdef TRACE + Dump( Mesh ); +#endif + DisplayActor( Mesh ); + DisplayEdges( Mesh ); + // smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + } + } + } + } + + if ( MorSM->FindSubObject (2, AHR)) { + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if ( strcmp( anIOR->Value(), _orb->object_to_string(anHyp) ) == 0 ) { + smeshGUI->myStudyAPI.UnSetHypothesis( Obj ); + break; + } + } + } + } + } + if ( MorSM->FindSubObject (3, AHR)) { + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if ( strcmp( anIOR->Value(), _orb->object_to_string(anHyp) ) == 0 ) { + smeshGUI->myStudyAPI.UnSetAlgorithm( Obj ); + break; + } + } + } + } + } + smeshGUI->myStudyAPI.ModifiedMesh( MorSM, false ); + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) +{ + if ( !aMesh->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOMEDS::SObject_var SM = myStudyAPI.FindMesh( aMesh ); + GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SM ); + try { + bool res = aMesh->AddHypothesis( aShape, aHyp ); + if (res) { + SALOMEDS::SObject_var SH = myStudyAPI.FindHypothesisOrAlgorithms( aHyp ); + if ( !SM->_is_nil() && !SH->_is_nil() ) { + myStudyAPI.SetAlgorithms( SM, SH ); + myStudyAPI.ModifiedMesh( SM, false ); + } + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_ALGORITHM_ALREADYEXIST"), tr ("SMESH_BUT_YES") ); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) +{ + if ( !aSubMesh->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh( aSubMesh ); + GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SsubM ); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->AddHypothesis( aShape, aHyp ); + if (res) { + SALOMEDS::SObject_var SH = myStudyAPI.FindHypothesisOrAlgorithms( aHyp ); + if ( !SsubM->_is_nil() && !SH->_is_nil() ) { + myStudyAPI.SetHypothesis( SsubM, SH ); + myStudyAPI.ModifiedMesh( SsubM, false ); + } + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_HYPOTHESIS_ALREADYEXIST"), tr ("SMESH_BUT_YES") ); + } + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) +{ + if ( !aSubMesh->_is_nil() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + SALOMEDS::SObject_var SsubM = myStudyAPI.FindSubMesh( aSubMesh ); + GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SsubM ); + if ( !aMesh->_is_nil() ) { + bool res = aMesh->AddHypothesis( aShape, aHyp ); + if (res) { + SALOMEDS::SObject_var SH = myStudyAPI.FindHypothesisOrAlgorithms( aHyp ); + if ( !SsubM->_is_nil() && !SH->_is_nil() ) { + myStudyAPI.SetAlgorithms( SsubM, SH ); + myStudyAPI.ModifiedMesh( SsubM, false ); + } + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_ALGORITHM_ALREADYEXIST"), tr ("SMESH_BUT_YES") ); + } + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::CreateAlgorithm( QString TypeAlgo, QString NameAlgo ) +{ + SMESH::SMESH_Hypothesis_var Hyp; + try { + if ( TypeAlgo.compare("Regular_1D") == 0 ) + Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); + else if ( TypeAlgo.compare("MEFISTO_2D") == 0 ) + Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); + else if ( TypeAlgo.compare("Quadrangle_2D") == 0 ) + Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); + else if ( TypeAlgo.compare("Hexa_3D") == 0 ) + Hyp = myComponentMesh->CreateHypothesis( TypeAlgo, myStudyId ); + + if ( !Hyp->_is_nil() ) { + SALOMEDS::SObject_var SHyp = myStudyAPI.AddNewAlgorithms( Hyp ); + myStudyAPI.SetName( SHyp, NameAlgo); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow( CreateHypothesis( TypeHypothesis, NameHypothesis ) ); + SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( Hyp ); + if ( !LL->_is_nil() ) + LL->SetLength( Length ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow( CreateHypothesis( TypeHypothesis, NameHypothesis ) ); + SMESH::SMESH_MaxElementArea_var MaxElArea = SMESH::SMESH_MaxElementArea::_narrow( Hyp ); + if ( !MaxElArea->_is_nil() ) + MaxElArea->SetMaxElementArea( MaxArea ); + } + catch (SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow( CreateHypothesis( TypeHypothesis, NameHypothesis ) ); + SMESH::SMESH_MaxElementVolume_var MaxElVolume = SMESH::SMESH_MaxElementVolume::_narrow( Hyp ); + if ( !MaxElVolume->_is_nil() ) + MaxElVolume->SetMaxElementVolume( MaxVolume ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, double nbSegments ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow( CreateHypothesis( TypeHypothesis, NameHypothesis ) ); + SMESH::SMESH_NumberOfSegments_var NbS = SMESH::SMESH_NumberOfSegments::_narrow( Hyp ); + if ( !NbS->_is_nil() ) + NbS->SetNumberOfSegments( nbSegments ); + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + myActiveStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +int SMESHGUI::GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) +{ + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + aName = IObject->getName(); + } else { + aName = tr( "SMESH_OBJECTS_SELECTED" ).arg( nbSel ); + } + return nbSel; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +int SMESHGUI::GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) +{ + int nbNodes = 0; + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if ( !IObject->hasEntry() ) + return -1; + + Standard_Boolean res; + SMESH_Actor* ac = FindActorByEntry( IObject->getEntry(), res, true ); + if ( !res ) + return -1; + + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + aName = " "; + nbNodes = MapIndex.Extent(); + for ( ; ite.More(); ite.Next() ) { + aName = aName + QString("%1").arg(ac->GetIdSMESHDSNode(ite.Key())) + " "; + } + } else { + aName = ""; + } + return nbNodes; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +int SMESHGUI::GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) +{ + int nbElements = 0; + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if ( !IObject->hasEntry() ) + return -1; + + Standard_Boolean res; + SMESH_Actor* ac = FindActorByEntry( IObject->getEntry(), res, true ); + if ( !res ) + return -1; + + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + aName = " "; + nbElements = MapIndex.Extent(); + MESSAGE("GetNameOfSelectedElements(): number = " << nbElements); + for ( ; ite.More(); ite.Next() ) { + int idVTK = ite.Key(); + MESSAGE("GetNameOfSelectedElements(): VTK Id = " << idVTK); + aName = aName + QString("%1").arg(ac->GetIdSMESHDSElement(idVTK)) + " "; + } + } else { + aName = ""; + } + return nbElements; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +int SMESHGUI::GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) +{ + int nbElements = 0; + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if ( !IObject->hasEntry() ) + return -1; + + Standard_Boolean res; + SMESH_Actor* ac = FindActorByEntry( IObject->getEntry(), res, true ); + if ( !res ) + return -1; + + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + aName = " "; + nbElements = MapIndex.Extent(); + for ( ; ite.More(); ite.Next() ) { + aName = aName + QString("%1").arg(ite.Key()) + " "; + } + } else { + aName = ""; + } + return nbElements; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH_Actor* SMESHGUI::FindActorByEntry(QString entry, + Standard_Boolean& testResult, + bool onlyInActiveView) +{ + int nbSf = myActiveStudy->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SMESH_Actor") ) { + SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = anActor->getIO(); + if ( strcmp( IO->getEntry(), entry ) == 0 ) { + if ( onlyInActiveView ) { + if ( sf == myActiveStudy->getActiveStudyFrame() ) { + testResult = true; + return anActor; + } + } else { + testResult = true; + return anActor; + } + } + } + } + ac = theActors->GetNextActor(); + } + } + } + + MESSAGE ( " Actor Not Found " ) + testResult = false; + return SMESH_Actor::New(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH_Actor* SMESHGUI::FindActor(SMESH::SMESH_Mesh_ptr aMesh, + Standard_Boolean& testResult, + bool onlyInActiveView) +{ + SALOMEDS::SObject_var SM = myStudyAPI.FindMesh( aMesh ); + if ( SM->_is_nil() ) { + MESSAGE ( " Actor Not Found " ) + + testResult = false; + return SMESH_Actor::New(); + } + + return FindActorByEntry( SM->GetID(), testResult, onlyInActiveView); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_Mesh_ptr SMESHGUI::ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult) +{ + SMESH::SMESH_Mesh_var aMesh; + testResult = false ; + + /* case SObject */ + if ( IO->hasEntry() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aMesh = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + if ( !aMesh->_is_nil() ) { + testResult = true ; + return SMESH::SMESH_Mesh::_duplicate( aMesh ); + } + } + } + } + return SMESH::SMESH_Mesh::_nil(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_subMesh_ptr SMESHGUI::ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult) +{ + SMESH::SMESH_subMesh_var aSubMesh; + testResult = false ; + + /* case SObject */ + if ( IO->hasEntry() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aSubMesh = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + if ( !aSubMesh->_is_nil() ) { + testResult = true ; + return SMESH::SMESH_subMesh::_duplicate( aSubMesh ); + } + } + } + } + return SMESH::SMESH_subMesh::_nil(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_Hypothesis_ptr SMESHGUI::ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult ) +{ + SMESH::SMESH_Hypothesis_var aHyp ; + testResult = false ; + + /* case SObject */ + if ( IO->hasEntry() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aHyp = SMESH::SMESH_Hypothesis::_narrow( _orb->string_to_object(anIOR->Value())); + if ( !aHyp->_is_nil() ) { + testResult = true ; + return SMESH::SMESH_Hypothesis::_duplicate( aHyp ); + } + } + } + } + return SMESH::SMESH_Hypothesis::_nil(); +} + + + +//============================================================================= +/*! + * + */ +//============================================================================= +GEOM::GEOM_Shape_ptr SMESHGUI::ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult ) +{ + GEOM::GEOM_Shape_var aShape ; + testResult = false ; + + /* case SObject */ + if ( IO->hasEntry() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IO->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aShape = myComponentGeom->GetIORFromString(anIOR->Value()) ; + if ( !aShape->_is_nil() ) { + testResult = true ; + return GEOM::GEOM_Shape::_duplicate( aShape ); + } + } + } + } + return GEOM::GEOM_Shape::_nil(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::SetViewMode(int commandId) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + if ( nbSel >= 1 ) { + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if ( IObject->hasEntry() ) { + Standard_Boolean res; + SMESH_Actor* ac = FindActorByEntry( IObject->getEntry(), res, true ); + if ( res ) { + switch (commandId) { + case 211: { + ChangeRepresentation( ac, 0 ); + break; + } + case 212: { + ChangeRepresentation( ac, 1 ); + break; + } + case 213: { + ChangeRepresentation( ac, 2 ); + break; + } + case 1132: { + ChangeRepresentation( ac, 3 ); + break; + } + } + } + } + } + if ( commandId == 1133 ) { + ChangeRepresentation( SMESH_Actor::New(), 4 ); + } + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::ChangeRepresentation( SMESH_Actor* ac, int type ) +{ + if (ac->DataSource == NULL && type != 4 ) + return; + + if ( type != 4 ) { + if ( ac->getMapper() == NULL ) { + return; + } + } + switch (type) { + case 0 : { + QApplication::setOverrideCursor( Qt::waitCursor ); + if (ac->getDisplayMode()==2) { + vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper()); + meshMapper->SetInput(ac->DataSource); + } + ac->setDisplayMode(0); + ac->GetProperty()->SetRepresentationToWireframe(); + // ac->SetActorProperty( ac->GetProperty() ); + QApplication::restoreOverrideCursor(); + break; + } + case 1 : { + QApplication::setOverrideCursor( Qt::waitCursor ); + if (ac->getDisplayMode()==2) { + vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper()); + meshMapper->SetInput(ac->DataSource); + } + ac->setDisplayMode(1); + ac->GetProperty()->SetRepresentationToSurface(); + QApplication::restoreOverrideCursor(); + // ac->SetActorProperty( ac->GetProperty() ); + break; + } + case 2 : { + // if (!(ac->getDisplayMode()==2)) { + // ChangeRepresentation(ac, 1); + QApplication::setOverrideCursor( Qt::waitCursor ); + ac->setDisplayMode(2); + vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper()); + meshMapper->SetInput(ac->DataSource); + vtkShrinkFilter *shrink = vtkShrinkFilter::New(); + shrink->SetInput(meshMapper->GetInput()); + shrink->SetShrinkFactor(ac->GetShrinkFactor()); + + meshMapper->SetInput( shrink->GetOutput() ); + ac->SetMapper( meshMapper ); + QApplication::restoreOverrideCursor(); + // } + break; + } + case 3: + { + float color[3]; + float edgecolor[3]; + float backfacecolor[3]; + float nodecolor[3]; + ac->GetColor(color[0],color[1],color[2]); + QColor c(color[0]*255,color[1]*255,color[2]*255); + ac->GetEdgeColor(edgecolor[0],edgecolor[1],edgecolor[2]); + QColor e(edgecolor[0]*255,edgecolor[1]*255,edgecolor[2]*255); + ac->GetBackfaceProperty()->GetColor(backfacecolor); + QColor b(backfacecolor[0]*255,backfacecolor[1]*255,backfacecolor[2]*255); + ac->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2] ) ; + QColor n(nodecolor[0]*255, nodecolor[1]*255, nodecolor[2]*255 ) ; + + int Edgewidth = (int)ac->EdgeDevice->GetProperty()->GetLineWidth(); + if ( Edgewidth == 0 ) + Edgewidth = 1; + int intValue = ac->GetNodeSize() ; + float Shrink = ac->GetShrinkFactor(); + + SMESHGUI_Preferences_ColorDlg *aDlg = new SMESHGUI_Preferences_ColorDlg( QAD_Application::getDesktop(), "" ) ; + aDlg->SetColor(1,c); + aDlg->SetColor(2,e); + aDlg->SetColor(3,n); + aDlg->SetColor(4,b); + aDlg->SetIntValue(1,Edgewidth); + aDlg->SetIntValue(2,intValue); + aDlg->SetIntValue(3,int(Shrink*100.)); + + if ( aDlg->exec() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + QColor color = aDlg->GetColor(1); + QColor edgecolor = aDlg->GetColor(2); + QColor nodecolor = aDlg->GetColor(3); + QColor backfacecolor = aDlg->GetColor(4); + /* actor color and backface color */ + ac->GetProperty()->SetColor(float(color.red())/255.,float(color.green())/255.,float(color.blue())/255.); + ac->SetColor(float(color.red())/255.,float(color.green())/255.,float(color.blue())/255.); + ac->GetBackfaceProperty()->SetColor(float(backfacecolor.red())/255.,float(backfacecolor.green())/255.,float(backfacecolor.blue())/255.); + + /* edge color */ + ac->EdgeDevice->GetProperty()->SetColor(float(edgecolor.red())/255., + float(edgecolor.green())/255., + float(edgecolor.blue())/255.); + ac->EdgeShrinkDevice->GetProperty()->SetColor(float(edgecolor.red())/255., + float(edgecolor.green())/255., + float(edgecolor.blue())/255.); + ac->SetEdgeColor(float(edgecolor.red())/255., + float(edgecolor.green())/255., + float(edgecolor.blue())/255.); + + /* Shrink factor and size edges */ + ac->SetShrinkFactor( aDlg->GetIntValue(3)/100. ); + ac->EdgeDevice->GetProperty()->SetLineWidth( aDlg->GetIntValue(1) ); + ac->EdgeShrinkDevice->GetProperty()->SetLineWidth( aDlg->GetIntValue(1) ); + + /* Nodes color and size */ + ac->SetNodeColor(float(nodecolor.red())/255., + float(nodecolor.green())/255., + float(nodecolor.blue())/255.); + ac->SetNodeSize(aDlg->GetIntValue(2)) ; + + if (ac->getDisplayMode()==2) { + vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (ac->getMapper()); + meshMapper->SetInput(ac->DataSource); + vtkShrinkFilter *shrink = vtkShrinkFilter::New(); + shrink->SetInput(meshMapper->GetInput()); + shrink->SetShrinkFactor(ac->GetShrinkFactor()); + + meshMapper->SetInput( shrink->GetOutput() ); + ac->SetMapper( meshMapper ); + } + } + delete aDlg; + QApplication::restoreOverrideCursor(); + break; + } + case 4: + { + EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SMESHGUI_TransparencyDlg *aDlg = new SMESHGUI_TransparencyDlg( QAD_Application::getDesktop(), "", Sel) ; + break; + } + case 5: { + QApplication::setOverrideCursor( Qt::waitCursor ); + ac->GetProperty()->SetRepresentationToPoints(); + QApplication::restoreOverrideCursor(); + break; + } + } + + QApplication::setOverrideCursor( Qt::waitCursor ); + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + theRenderer->Render(); + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::UpdateView() +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + theRenderer->Render(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplayActor(SMESH_Actor* ac, bool visibility) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + MESSAGE("DisplayActor(): DataSource = " << ac->DataSource); + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theActors = theRenderer->GetActors(); + theActors->InitTraversal(); + if ( theActors->IsItemPresent(ac) == 0 ) { + vtkProperty* prop = vtkProperty::New(); + prop->SetColor( QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat()/255. ) ; + + prop->SetPointSize( QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt()); + prop->SetLineWidth( QAD_CONFIG->getSetting("SMESH:SettingsWidth").toInt() ); + ac->SetProperty( prop ); + ac->SetColor( QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue").toFloat()/255. ); + + // prop->BackfaceCullingOn(); + vtkProperty* backprop = vtkProperty::New(); + backprop->SetColor( QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue").toFloat()/255. ) ; + ac->SetBackfaceProperty(backprop); + + int intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff").toInt(); + if (intValue == 0 ) + intValue = 80; + ac->SetShrinkFactor( intValue/100. ); + + ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer(); + ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02); + + QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + if ( DisplayMode.compare("Wireframe") == 0 ){ + ac->setDisplayMode(0); + ChangeRepresentation( ac, 0 ); + } else if ( DisplayMode.compare("Shading") == 0 ){ + ac->setDisplayMode(1); + ChangeRepresentation( ac, 1 ); + } else if ( DisplayMode.compare("Shrink") == 0 ) { + ac->setDisplayMode(2); + ChangeRepresentation( ac, 2 ); + } + theRenderer->AddActor(ac); + } else { + if (ac->GetMapper()) + ac->GetMapper()->Update(); + } + +// if ( visibility ) + ac->SetVisibility(visibility); +// ac->VisibilityOn(); +// else +// ac->VisibilityOff(); + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::EraseActor(SMESH_Actor* ac) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + //NRI- : 02/12/2002 : Fixed bugId 882 + // ac->EdgeDevice->VisibilityOff(); + // ac->EdgeShrinkDevice->VisibilityOff(); + // ac->VisibilityOff(); + ac->SetVisibility( false ); + + theRenderer->Render(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::AddActorInSelection(SMESH_Actor* ac) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + if ( ac->hasIO() ) + return Sel->AddIObject( ac->getIO() ); + else + return -1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +QString SMESHGUI::CheckHomogeneousSelection() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + /* copy the list */ + SALOME_ListIO List; + SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + List.Append(Itinit.Value()); + } + + QString RefType = CheckTypeObject( Sel->firstIObject() ); + SALOME_ListIteratorOfListIO It( List ); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + QString Type = CheckTypeObject( IObject ); + if ( Type.compare( RefType ) != 0 ) + return "Heterogeneous Selection"; + } + + Sel->ClearIObjects(); + SALOME_ListIteratorOfListIO It1( List ); + for(;It1.More();It1.Next()) { + int res = Sel->AddIObject( It1.Value() ); + if ( res == -1 ) + myActiveStudy->highlight( It1.Value(), false ); + if ( res == 0 ) + myActiveStudy->highlight( It1.Value(), true ); + } + return RefType; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO) +{ + SALOMEDS::SObject_var sobj = smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); + if (!sobj->_is_nil()) { + SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); + if (strcmp(scomp->GetID(), IO->getEntry()) == 0) { // component is selected + return "Component"; + } + } + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + + Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter( HYPOTHESIS ); + Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter( ALGORITHM ); + Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter( MESH ); + Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter( SUBMESH ); + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + Handle(SMESH_TypeFilter) aSubMeshVextexFilter = new SMESH_TypeFilter( SUBMESH_VERTEX ); + Handle(SMESH_TypeFilter) aSubMeshEdgeFilter = new SMESH_TypeFilter( SUBMESH_EDGE ); + Handle(SMESH_TypeFilter) aSubMeshFaceFilter = new SMESH_TypeFilter( SUBMESH_FACE ); + Handle(SMESH_TypeFilter) aSubMeshSolidFilter = new SMESH_TypeFilter( SUBMESH_SOLID ); + Handle(SMESH_TypeFilter) aSubMeshCompoundFilter = new SMESH_TypeFilter( SUBMESH_COMPOUND ); + + Sel->AddFilter(aHypFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "Hypothesis"; + } + + Sel->ClearFilters(); + Sel->AddFilter(anAlgoFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "Algorithm"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aMeshFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "Mesh"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "SubMesh"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshVextexFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "SubMeshVertex"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshEdgeFilter); + if ( Sel->AddIObject( IO ) != -1 ){ + Sel->ClearFilters(); + return "SubMeshEdge"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshFaceFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "SubMeshFace"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshSolidFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "SubMeshSolid"; + } + + Sel->ClearFilters(); + Sel->AddFilter(aSubMeshCompoundFilter); + if ( Sel->AddIObject( IO ) != -1 ) { + Sel->ClearFilters(); + return "SubMeshCompound"; + } + + Sel->ClearFilters(); + Sel->AddIObject( IO ); + return "NoType"; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + /* Create or retrieve an object SMESHGUI */ + SMESHGUI::GetOrCreateSMESHGUI(parent); + + // NRI : Temporary added + if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) { + return false; + } + //NRI + + // QAD_Viewer3d* v3d; + OCCViewer_Viewer3d* v3d; + + Handle(AIS_InteractiveContext) ic; + vtkRenderer* Renderer; + vtkRenderWindow* RenWin; + + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) { + v3d =((OCCViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); + ic = v3d->getAISContext(); + } else if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + Renderer = ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + RenWin = Renderer->GetRenderWindow(); + } + + switch (theCommandID) + { + case 33: // DELETE + smeshGUI->OnEditDelete(); + break; + + case 113: // IMPORT + case 112: + case 111: + { + Import_Document(parent,theCommandID);//NBU + //Import_Mesh(parent,theCommandID); + break; + } + + case 122: // EXPORT MED + case 121: + case 123: + { + Export_Mesh(parent, theCommandID); + break; + } + + case 200: // SCALAR BAR + { + smeshGUI->DisplayScalarBar(false); + break; + } + case 201: + { + SMESHGUI_EditScalarBarDlg *aDlg = new SMESHGUI_EditScalarBarDlg( parent, "", false ) ; + aDlg->show(); + break; + } + case 202: + { + smeshGUI->DisplayScalarBar( true ); + break; + } + + case 1133: // DISPLAY MODE : WireFrame, Surface, Shrink + case 1132: + case 213: + case 212: + case 211: + { + smeshGUI->SetViewMode(theCommandID); + break; + } + + case 214 : // UPDATE + { + smeshGUI->Update(); + break; + } + + case 300 : // ERASE + { + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + if ( IOS->hasEntry() ) { + Standard_Boolean res; + SMESH_Actor *ac = smeshGUI->FindActorByEntry(IOS->getEntry(), res, true ); + if ( res ) smeshGUI->EraseActor( ac ); + } + } + } + Sel->ClearIObjects(); + smeshGUI->myActiveStudy->updateObjBrowser( true ); + } + + case 301 : // DISPLAY + { + if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + // VTK + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOMEDS::SObject_var fatherSF = + smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->getActiveStudyFrame()->entry()); + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if ( IObject->hasEntry() ) { + Standard_Boolean res; + SMESH_Actor *ac = smeshGUI->FindActorByEntry(IObject->getEntry(), res, true ); + if ( res ) { + smeshGUI->DisplayActor( ac, true ); + smeshGUI->DisplayEdges( ac ); + smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() ); + } + } + } + QApplication::restoreOverrideCursor(); + } + break; + } + + case 302 : // DISPLAY ONLY + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SMESH_Actor") ) { + SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( ac ); + if(!anActor->isHighlighted()) { + //anActor->VisibilityOff(); + //NRI- : 02/12/2002 : Fixed bugId 882 + // anActor->EdgeDevice->VisibilityOff(); + // anActor->EdgeShrinkDevice->VisibilityOff(); + anActor->SetVisibility( false ); + } + } + ac = theActors->GetNextActor(); + } + + // Display selection + SALOMEDS::SObject_var fatherSF = smeshGUI->myStudy->FindObjectID(smeshGUI->myActiveStudy->getActiveStudyFrame()->entry()); + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SALOMEDS::SObject_var obj = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); + + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + // vtkQGLRenderWindowInteractor* myRenderInter= smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor(); + + if(myRenderInter->isInViewer(IObject)) { + if ( IObject->hasEntry() ) { + Standard_Boolean res; + SMESH_Actor *ac = smeshGUI->FindActorByEntry(IObject->getEntry(), res, true ); + if ( res ) { + smeshGUI->DisplayActor( ac, true ); + smeshGUI->DisplayEdges( ac ); + smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() ); + } + } + } + } + smeshGUI->myActiveStudy->updateObjBrowser( true ); + QApplication::restoreOverrideCursor(); + } + break; + } + + case 400: // NODES + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + + case 405: // MOVE NODE + { + smeshGUI->myDesktop->SetSelectionMode(1, true); + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg( parent, "", Sel ) ; + break; + } + + case 701: // COMPUTE MESH + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + if ( nbSel != 1 ) { + QApplication::restoreOverrideCursor(); + break; + } + + SMESH::SMESH_Mesh_var aM; + SMESH::SMESH_subMesh_var aSubM; + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if ( IObject->hasEntry() ) { + SALOMEDS::SObject_var aMorSM = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !aMorSM->_is_nil() ) { + if (aMorSM->FindAttribute(anAttr, "AttributeIOR") ) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + MESSAGE( "SMESHGUI::OnGUIEvent - Compute mesh : IOR = " << anIOR->Value() ) + CORBA::Object_var cobj; + try { + cobj = _orb->string_to_object(anIOR->Value()); + if ( CORBA::is_nil(cobj) ) { + MESSAGE( "SMESHGUI::OnGUIEvent - Compute mesh : nil object" ) + } + } + catch(CORBA::COMM_FAILURE& ex) { + MESSAGE( "SMESHGUI::OnGUIEvent - Compute mesh : exception (1)" ) + } + aM = SMESH::SMESH_Mesh::_narrow(cobj); + //aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + aSubM = SMESH::SMESH_subMesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + if ( !aM->_is_nil() ) { + GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMorSM); + if ( !refShape->_is_nil() ) { + bool compute = smeshGUI->myComponentMesh->IsReadyToCompute(aM, refShape); + if ( !compute ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_MISSING_PARAMETERS"), tr ("SMESH_BUT_YES") ); + break; + } + try { + smeshGUI->myComponentMesh->Compute( aM, refShape); + smeshGUI->myStudyAPI.ModifiedMesh( aMorSM, true ); + // TO Do : change icon of all submeshes + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + } else if ( !aSubM->_is_nil() ) { + aM = aSubM->GetFather(); + GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMorSM); + if ( !refShape->_is_nil() ) { + bool compute = smeshGUI->myComponentMesh->IsReadyToCompute(aM, refShape); + if ( !compute ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_MISSING_PARAMETERS"), tr ("SMESH_BUT_YES") ); + break; + } + try { + smeshGUI->myComponentMesh->Compute( aM, refShape); + smeshGUI->myStudyAPI.ModifiedMesh( aMorSM, true ); + // TO Do : change icon of all submeshes + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + } + } + } + } + + // Check whether the actor for the mesh exists at least in one view + Standard_Boolean res; + SMESH_Actor* ac = smeshGUI->FindActorByEntry(IObject->getEntry(), res, false); + if (!res) + smeshGUI->InitActor( aM ); + else { + // Check whether the actor belongs to the active view + VTKViewer_RenderWindowInteractor* rwInter = + ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + // The actor belongs to inactive view -> create a copy and add it in the active view + if (!rwInter->isInViewer(IObject)) { + SMESH_Actor* acCopy = SMESH_Actor::New(); + acCopy->ShallowCopy(ac); + + smeshGUI->DisplayActor( acCopy, false ); + } + } + + if ( smeshGUI->myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aM); + if ( Mesh != NULL ) { +#ifdef TRACE + Dump( Mesh ); +#endif + smeshGUI->DisplayActor( Mesh, true ); + smeshGUI->DisplayEdges( Mesh, true ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + } + } + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + QApplication::restoreOverrideCursor(); + break; + } + + case 702: // ADD SUB MESH + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + + case 703: // INIT MESH + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg( parent, "", Sel ) ; + break; + } + + case 704: // EDIT Hypothesis + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg( parent, "", Sel ) ; + break; + } + + case 705: // EDIT Global Hypothesis + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg( parent, "", Sel ) ; + break; + } + + case 706: // EDIT Local Hypothesis + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg( parent, "", Sel ) ; + break; + } + + case 806: // ORIENTATION ELEMENTS + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + smeshGUI->myDesktop->SetSelectionMode(3, true); + SMESHGUI_OrientationElementsDlg *aDlg = new SMESHGUI_OrientationElementsDlg( parent, "", Sel ) ; + break; + } + + case 807: // DIAGONAL INVERSION + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(2, true); + SMESHGUI_DiagonalInversionDlg *aDlg = new SMESHGUI_DiagonalInversionDlg( parent, "", Sel ) ; + break; + } + + case 900: // MESH INFOS + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg( parent, "", Sel ) ; + break; + } + + case 1001: // AUTOMATIC UPDATE PREFERENCES + { + parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001) ); + if ( parent->menuBar()->isItemChecked(1001) ) { + QAD_CONFIG->addSetting("SMESH:AutomaticUpdate","true"); + smeshGUI->myAutomaticUpdate = true; + } else { + QAD_CONFIG->addSetting("SMESH:AutomaticUpdate","false"); + smeshGUI->myAutomaticUpdate = false; + } + break; + } + + case 1003: // MESH PREFERENCES + { + smeshGUI->SetDisplaySettings(); + break; + } + + case 1005: + { + QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold"); + QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic"); + QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow"); + QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily"); + QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation"); + float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat(); + float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat(); + int NumberOfLabels = QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt(); + int NumberOfColors = QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt(); + + if ( Width == 0 ) Width = 0.17; + if ( Height == 0 ) Height = 0.8; + if ( NumberOfLabels == 0 ) NumberOfLabels = 5; + if ( NumberOfColors == 0) NumberOfColors = 64; + + SMESHGUI_Preferences_ScalarBarDlg *aDlg = new SMESHGUI_Preferences_ScalarBarDlg( parent, "", true) ; + + if ( Bold.compare("true") == 0 ) + aDlg->Bold->setChecked(true); else aDlg->Bold->setChecked(false); + if ( Italic.compare("true") == 0 ) + aDlg->Italic->setChecked(true); else aDlg->Italic->setChecked(false); + if ( Shadow.compare("true") == 0 ) + aDlg->Shadow->setChecked(true); else aDlg->Shadow->setChecked(false); + + if ( Orientation.compare("Horizontal") == 0 ) + aDlg->RadioHoriz->setChecked(true); else aDlg->RadioVert->setChecked(true); + + int NbItems = aDlg->ComboBox1->count(); + int i = 0; + aDlg->ComboBox1->setCurrentItem( i ); + while ( i < NbItems ) { + if ( FontFamily.compare( aDlg->ComboBox1->text( i ) ) == 0 ) + aDlg->ComboBox1->setCurrentItem( i ); + i++; + } + + aDlg->LineEditWidth->setText( QString("%1").arg(Width) ); + aDlg->LineEditHeight->setText( QString("%1").arg(Height) ); + + aDlg->SpinBoxLabels->setValue( NumberOfLabels ); + aDlg->SpinBoxColors->setValue( NumberOfColors ); + + aDlg->show(); + if ( aDlg->result() ) { + if ( aDlg->RadioHoriz->isChecked() ) + Orientation = "Horizontal"; else Orientation = "Vertical"; + if ( aDlg->Bold->isChecked() ) + Bold = "true"; else Bold = "false"; + if ( aDlg->Italic->isChecked() ) + Italic = "true"; else Italic = "false"; + if ( aDlg->Shadow->isChecked() ) + Shadow = "true"; else Shadow = "false"; + + FontFamily = aDlg->ComboBox1->currentText(); + Width = aDlg->LineEditWidth->text().toFloat(); + Height = aDlg->LineEditHeight->text().toFloat(); + NumberOfColors = aDlg->SpinBoxColors->text().toInt(); + NumberOfLabels = aDlg->SpinBoxLabels->text().toInt(); + + + vtkScalarBarActor* aScalarBar = smeshGUI->GetScalarBar(); + if ( aScalarBar != NULL ) { + smeshGUI->SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow, + FontFamily, Orientation, + Width, Height, NumberOfColors, NumberOfLabels); + } + + QAD_CONFIG->addSetting("ScalarBar:Bold", Bold); + QAD_CONFIG->addSetting("ScalarBar:Italic", Italic); + QAD_CONFIG->addSetting("ScalarBar:Shadow", Shadow); + QAD_CONFIG->addSetting("ScalarBar:FontFamily", FontFamily); + QAD_CONFIG->addSetting("ScalarBar:Orientation", Orientation); + QAD_CONFIG->addSetting("ScalarBar:Width", Width); + QAD_CONFIG->addSetting("ScalarBar:Height", Height); + QAD_CONFIG->addSetting("ScalarBar:NumberOfLabels", NumberOfLabels); + QAD_CONFIG->addSetting("ScalarBar:NumberOfColors", NumberOfColors); + } + break; + } + + case 1100: // EDIT HYPOTHESIS + { + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount() ; + + if ( nbSel == 1 ) { + Standard_Boolean res; + SMESH::SMESH_Hypothesis_var Hyp = smeshGUI->ConvertIOinSMESHHypothesis( Sel->firstIObject(), res ); + + /* Look for all mesh objects that have this hupothesis affected in order to flag as ModifiedMesh */ + /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */ + /* Warning : however by internal mechanism all subMeshes icons are changed ! */ + SALOMEDS::Study::ListOfSObject_var listSOmesh = smeshGUI->GetMeshesUsingAlgoOrHypothesis( Hyp) ; + + if ( res ) { + QString Name = Hyp->GetName(); + + if ( Name.compare("LocalLength") == 0 ) { + SMESH::SMESH_LocalLength_var LL = SMESH::SMESH_LocalLength::_narrow( Hyp ); + double beforeLength = LL->GetLength() ; + double Length = smeshGUI->Parameter( res, + beforeLength, + tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"), + tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6 ) ; + if ( res && Length != beforeLength ) { + LL->SetLength( Length ); + for( int i=0; ilength(); i++ ) { + smeshGUI->GetStudyAPI().ModifiedMesh( listSOmesh[i], false ) ; + } + break; + } + + } else if ( Name.compare("NumberOfSegments") == 0 ) { + SMESH::SMESH_NumberOfSegments_var NOS = SMESH::SMESH_NumberOfSegments::_narrow( Hyp ); + int beforeNbSeg = NOS->GetNumberOfSegments() ; + int NbSeg = smeshGUI->Parameter( res, + beforeNbSeg, + tr("SMESH_NB_SEGMENTS_HYPOTHESIS"), + tr("SMESH_VALUE"), + 1, 1000000 ) ; + + if ( res && NbSeg != beforeNbSeg ) { + NOS->SetNumberOfSegments( NbSeg ); + for( int i=0; ilength(); i++ ) { + SALOMEDS::SObject_var SO = listSOmesh[i] ; + smeshGUI->GetStudyAPI().ModifiedMesh( listSOmesh[i], false ) ; + } + break; + } + + } else if ( Name.compare("MaxElementArea") == 0 ) { + SMESH::SMESH_MaxElementArea_var MEA = SMESH::SMESH_MaxElementArea::_narrow( Hyp ); + double beforeMaxArea = MEA->GetMaxElementArea() ; + double MaxArea = smeshGUI->Parameter( res, + beforeMaxArea, + tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"), + tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6 ) ; + if ( res && MaxArea != beforeMaxArea ) { + MEA->SetMaxElementArea( MaxArea ); + for( int i=0; ilength(); i++ ) { + smeshGUI->GetStudyAPI().ModifiedMesh( listSOmesh[i], false ) ; + } + break; + } + + } else if ( Name.compare("MaxElementVolume") == 0 ) { + SMESH::SMESH_MaxElementVolume_var MEV = SMESH::SMESH_MaxElementVolume::_narrow( Hyp ); + double beforeMaxVolume = MEV->GetMaxElementVolume() ; + double MaxVolume = smeshGUI->Parameter( res, + beforeMaxVolume, + tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"), + tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6 ) ; + if ( res && MaxVolume != beforeMaxVolume ) { + MEV->SetMaxElementVolume( MaxVolume ); + for( int i=0; ilength(); i++ ) { + smeshGUI->GetStudyAPI().ModifiedMesh( listSOmesh[i], false ) ; + } + break; + } + + } else if ( Name.compare("Regular_1D") == 0 ) { + } else if ( Name.compare("MEFISTO_2D") == 0 ) { + } else { + } + + } + } + break; + } + + case 1101: // RENAME + { + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + SALOMEDS::SObject_var obj = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !obj->_is_nil() ) { + if (obj->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + QString newName = QString( aName->Value() ); + newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName); + if ( !newName.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + smeshGUI->myActiveStudy->renameIObject( IObject, newName ); + } + QApplication::restoreOverrideCursor(); + } + } + } + break; + } + + case 1102: // REMOVE HYPOTHESIS / ALGORITHMS + { + QApplication::setOverrideCursor( Qt::waitCursor ); + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( int i=0; It.More(); It.Next(), i++ ) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + smeshGUI->RemoveHypothesisOrAlgorithmOnMesh( IObject ); + } + Sel->ClearIObjects(); + smeshGUI->myActiveStudy->updateObjBrowser( true ); + QApplication::restoreOverrideCursor(); + break; + } + + case 401: // GEOM::EDGE + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_AddEdgeDlg *aDlg = new SMESHGUI_AddEdgeDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + case 4021: // TRIANGLE + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg( parent, "", Sel, 3 ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + case 4022: // QUAD + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg( parent, "", Sel, 4 ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + case 4031: // TETRA + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg( parent, "", Sel, 4 ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + case 4032: // HEXA + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg( parent, "", Sel, 8 ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + + case 4041: // REMOVES NODES + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(1, true); + parent->menuBar()->setItemChecked(9010, false ); + parent->menuBar()->setItemChecked(9011, false ); + smeshGUI->ViewNodes(); + SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + case 4042: // REMOVES ELEMENTS + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + smeshGUI->myDesktop->SetSelectionMode(3, true); + SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + + case 5000: // HYPOTHESIS - ALGO + { + smeshGUI->CreateAlgorithm("Regular_1D","Wire Discretisation"); + break; + } + case 5010: + { + smeshGUI->CreateAlgorithm("MEFISTO_2D","Triangle (Mefisto)"); + break; + } + case 5011: + { + smeshGUI->CreateAlgorithm("Quadrangle_2D","Quadrangle (Mapping)"); + break; + } + case 5020: + { + smeshGUI->CreateAlgorithm("Hexa_3D","Hexaedral (i,j,k)"); + break; + } + + case 5030: // HYPOTHESIS - LOCAL LENGTH + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_LocalLengthDlg *aDlg = new SMESHGUI_LocalLengthDlg( parent, "" ) ; + break; + } + case 5031: // HYPOTHESIS - NB SEGMENTS + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_NbSegmentsDlg *aDlg = new SMESHGUI_NbSegmentsDlg( parent, "" ) ; + break; + } + + case 5032: // HYPOTHESIS - MAX ELEMENT AREA + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_MaxElementAreaDlg *aDlg = new SMESHGUI_MaxElementAreaDlg( parent, "" ) ; + break; + } + + case 5033: // HYPOTHESIS - MAX ELEMENT VOLUME + { + smeshGUI->EmitSignalDeactivateDialog() ; + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_MaxElementVolumeDlg *aDlg = new SMESHGUI_MaxElementVolumeDlg( parent, "" ) ; + break; + } + + case 6016: // CONTROLS + case 6015: + case 6014: + case 6013: + case 6012: + case 6011: + case 6001: + { + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + if ( nbSel != 1 ) + break; + smeshGUI->Control(theCommandID); + break; + } + + case 6002: + { + if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SMESHGUI_EdgesConnectivityDlg *Dlg = new SMESHGUI_EdgesConnectivityDlg( parent, "", Sel ) ; + } else { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_VIEWER_VTK"), tr ("SMESH_BUT_YES") ); + } + break; + } + + case 9010: + { + if ( !parent->menuBar()->isItemChecked(9010) ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + parent->menuBar()->setItemChecked(9011, false ); + + smeshGUI->EraseSimulationActors(); + smeshGUI->mySimulationActors2D = vtkActor2DCollection::New(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Standard_Boolean res; + SMESH_Actor* MeshActor = smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(), res, true); + if ( res ) { + parent->menuBar()->setItemChecked(9010, !parent->menuBar()->isItemChecked(9010) ); + + // It's necessary to display SMDS IDs instead of VTK ones, so + // vtkIdFilter is unacceptable here. We have to do it manually :( + vtkUnstructuredGrid* ptGrid = vtkUnstructuredGrid::New(); + ptGrid->CopyStructure(MeshActor->DataSource); + + int numPts = MeshActor->DataSource->GetNumberOfPoints(); + + // Loop over points and generate ids + vtkIntArray *ptIds = vtkIntArray::New(); + ptIds->SetNumberOfValues(numPts); + + for (int id=0; id < numPts; id++) { + int idSMDS = MeshActor->GetIdSMESHDSNode(id); + ptIds->SetValue(id, idSMDS); + } + + vtkScalars* newScalars = vtkScalars::New(); + newScalars->SetData(ptIds); + ptGrid->GetPointData()->SetScalars(newScalars); + + newScalars->Delete(); + ptIds->Delete(); + + vtkMaskPoints* mask = vtkMaskPoints::New(); + mask->SetInput(ptGrid); + mask->SetOnRatio( 1 ); + // mask->SetMaximumNumberOfPoints( 50 ); + // mask->RandomModeOn(); + + vtkSelectVisiblePoints* visPts = vtkSelectVisiblePoints::New(); + visPts->SetInput(mask->GetOutput()); + visPts->SetRenderer(((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()); + //visPts->SetSelectInvisible(1); + visPts->SelectInvisibleOff(); + visPts->SetTolerance(0.1); + + vtkLabeledDataMapper* ldm = vtkLabeledDataMapper::New(); + ldm->SetInput(visPts->GetOutput()); + ldm->SetLabelFormat("%g"); + ldm->SetLabelModeToLabelScalars(); + //ldm->SetLabelModeToLabelFieldData(); + + ldm->SetFontFamilyToTimes(); + ldm->SetFontSize(6 * parent->font().pointSize() / 5); + ldm->SetBold(1); + ldm->SetItalic(0); + ldm->SetShadow(0); + + vtkActor2D* pointLabels = vtkActor2D::New(); + pointLabels->SetMapper(ldm); + pointLabels->GetProperty()->SetColor(0,1,0); + + visPts->Delete(); + ldm->Delete(); + smeshGUI->mySimulationActors2D->AddItem( pointLabels ); + ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->AddActor2D( pointLabels ); + } + } + } else { + QApplication::setOverrideCursor( Qt::waitCursor ); + parent->menuBar()->setItemChecked(9010, !parent->menuBar()->isItemChecked(9010) ); + smeshGUI->EraseSimulationActors(); + smeshGUI->ScalarVisibilityOff(); + } + QApplication::restoreOverrideCursor(); + break; + } + case 9011: + { + if ( !parent->menuBar()->isItemChecked(9011) ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + parent->menuBar()->setItemChecked(9010, false ); + + smeshGUI->EraseSimulationActors(); + smeshGUI->mySimulationActors2D = vtkActor2DCollection::New(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Standard_Boolean res; + SMESH_Actor* MeshActor = smeshGUI->FindActorByEntry(Sel->firstIObject()->getEntry(), res, true); + if ( res ) { + parent->menuBar()->setItemChecked(9011, !parent->menuBar()->isItemChecked(9011) ); + + // It's necessary to display SMDS IDs instead of VTK ones, so + // vtkIdFilter is unacceptable here. We have to do it manually :( + vtkUnstructuredGrid* elGrid = vtkUnstructuredGrid::New(); + elGrid->CopyStructure(MeshActor->DataSource); + + int numCells = MeshActor->DataSource->GetNumberOfCells(); + + // Loop over points and generate ids + vtkIntArray *cellIds = vtkIntArray::New(); + cellIds->SetNumberOfValues(numCells); + + for (int id=0; id < numCells; id++) { + int idSMDS = MeshActor->GetIdSMESHDSElement(id); + cellIds->SetValue(id, idSMDS); + } + + vtkScalars* newScalars = vtkScalars::New(); + newScalars->SetData(cellIds); + elGrid->GetCellData()->SetScalars(newScalars); + + newScalars->Delete(); + cellIds->Delete(); + + vtkCellCenters* cc = vtkCellCenters::New(); + cc->SetInput(elGrid); + + vtkSelectVisiblePoints* visCells = vtkSelectVisiblePoints::New(); + visCells->SetInput(cc->GetOutput()); + visCells->SetRenderer(((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()); + visCells->SelectInvisibleOff(); + visCells->SetTolerance(0.1); + // visCells->SetSelectInvisible(1); + + vtkLabeledDataMapper* ldm = vtkLabeledDataMapper::New(); + ldm->SetInput(visCells->GetOutput()); + ldm->SetLabelFormat("%g"); + ldm->SetLabelModeToLabelScalars(); + + ldm->SetFontFamilyToTimes(); + ldm->SetFontSize(6 * parent->font().pointSize() / 5); + ldm->SetBold(1); + ldm->SetItalic(0); + ldm->SetShadow(0); + + vtkActor2D* cellLabels = vtkActor2D::New(); + cellLabels->SetMapper(ldm); + cellLabels->GetProperty()->SetColor(1,0,0); + + cc->Delete(); + visCells->Delete(); + ldm->Delete(); + smeshGUI->mySimulationActors2D->AddItem( cellLabels ); + ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer()->AddActor2D( cellLabels ); + } + } + } else { + QApplication::setOverrideCursor( Qt::waitCursor ); + parent->menuBar()->setItemChecked(9011, !parent->menuBar()->isItemChecked(9011) ); + smeshGUI->EraseSimulationActors(); + smeshGUI->ScalarVisibilityOff(); + } + QApplication::restoreOverrideCursor(); + break; + } + + case 10001: // DISPLAY MODE PREFERENCE + { + parent->menuBar()->setItemChecked(10001, !parent->menuBar()->isItemChecked(10001) ); + parent->menuBar()->setItemChecked(10002, false ); + parent->menuBar()->setItemChecked(10003, false ); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe"); + break; + } + case 10002: + { + parent->menuBar()->setItemChecked(10002, !parent->menuBar()->isItemChecked(10002) ); + parent->menuBar()->setItemChecked(10001, false ); + parent->menuBar()->setItemChecked(10003, false ); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); + break; + } + case 10003: + { + parent->menuBar()->setItemChecked(10003, !parent->menuBar()->isItemChecked(10003) ); + parent->menuBar()->setItemChecked(10002, false ); + parent->menuBar()->setItemChecked(10001, false ); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shrink"); + break; + } + + } + + smeshGUI->myActiveStudy->updateObjBrowser(true); + return true ; +} + + +//============================================================================= +/*! function : GetMeshesUsingAlgoOrHypothesis() + * purpose : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected. + * : However is supposed here that father of father of an hypothesis is a Mesh Object. + */ +//============================================================================= +SALOMEDS::Study::ListOfSObject* SMESHGUI::GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) +{ + SALOMEDS::Study::ListOfSObject_var listSOmesh = new SALOMEDS::Study::ListOfSObject ; + listSOmesh->length(0) ; + unsigned int index = 0 ; + if( !AlgoOrHyp->_is_nil() ) { + SALOMEDS::SObject_var SO_Hypothesis = smeshGUI->GetStudyAPI().FindHypothesisOrAlgorithms( AlgoOrHyp ); + if( !SO_Hypothesis->_is_nil() ) { + SALOMEDS::Study::ListOfSObject_var listSO = smeshGUI->myStudy->FindDependances(SO_Hypothesis) ; + for( unsigned int i=0; ilength(); i++ ) { + SALOMEDS::SObject_var SO = listSO[i] ; + if( !SO->_is_nil() ) { + SALOMEDS::SObject_var SOfatherFather = SO->GetFather()->GetFather() ; + if( !SOfatherFather->_is_nil() ) { + index++ ; + listSOmesh->length(index) ; + listSOmesh[index-1] = SOfatherFather ; + } + } + } + } + } + return listSOmesh._retn() ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Import_Mesh(QAD_Desktop* parent, int theCommandID) +{ + QString filter; + string myExtension; + Mesh_Reader* myReader; + + if (theCommandID==113) { + filter = tr("MED files (*.med)"); + myExtension = string("MED"); + myReader = new DriverMED_R_SMESHDS_Mesh; + } + else if (theCommandID==112) { + filter = tr("IDEAS files (*.unv)"); + myExtension = string("UNV"); + } + else if (theCommandID==111) { + filter = tr("DAT files (*.dat)"); + myExtension = string("MED"); + myReader = new DriverDAT_R_SMESHDS_Mesh; + } + + QString filename = QAD_FileDlg::getFileName(parent, + "", + filter, + tr("Import mesh"), + true); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + string myClass = string("SMESHDS_Mesh"); +// Mesh_Reader* myReader = SMESHDriver::GetMeshReader(myExtension, myClass); + + int myMeshId = (smeshGUI->myDocument)->NewMesh(); + Handle(SMDS_Mesh) myMesh = (smeshGUI->myDocument)->GetMesh(myMeshId); + + myReader->SetFile(string(filename.latin1())); + myReader->SetMesh(myMesh); + myReader->SetMeshId(myMeshId); + myReader->Read(); + + QApplication::restoreOverrideCursor(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Export_Mesh(QAD_Desktop* parent, int theCommandID) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount() ; + if ( nbSel == 1 ) { + Standard_Boolean res; + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh( IObject, res ); + if ( res ) { + if (theCommandID==122) { // EXPORT MED + QString filename = QAD_FileDlg::getFileName(parent, + "", + tr("MED files (*.med)"), + tr("Export mesh"), + false); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + aMesh->ExportMED( filename.latin1() ); + QApplication::restoreOverrideCursor(); + } + } + else if (theCommandID==121) { // EXPORT DAT + QString filename = QAD_FileDlg::getFileName(parent, + "", + tr("DAT files (*.dat)"), + tr("Export mesh"), + false); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + aMesh->ExportDAT( filename.latin1() ); + QApplication::restoreOverrideCursor(); + } + } + else if (theCommandID==123) { // EXPORT UNV + QString filename = QAD_FileDlg::getFileName(parent, + "", + tr("IDEAS files (*.unv)"), + tr("Export mesh"), + false); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + aMesh->ExportUNV( filename.latin1() ); + QApplication::restoreOverrideCursor(); + } + else + aMesh->ExportDAT( filename.latin1() ); + + QApplication::restoreOverrideCursor(); + + if ( IObject->hasEntry() ) + { + MESSAGE("---"); + SALOMEDS::SObject_var SO = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeComment_var aFileName; + SALOMEDS::StudyBuilder_var aStudyBuilder = smeshGUI->myStudy->NewBuilder(); + anAttr = aStudyBuilder->FindOrCreateAttribute(SO, "AttributeComment"); + aFileName = SALOMEDS::AttributeComment::_narrow(anAttr); + aFileName->SetValue(filename.latin1()); + } + } + } + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Import_Document(QAD_Desktop* parent, int theCommandID) +{ + QString filter; + string myExtension; + Document_Reader* myReader; + + if (theCommandID==113) { + filter = tr("MED files (*.med)"); + myExtension = string("MED"); + myReader = new DriverMED_R_SMESHDS_Document; + } + else if (theCommandID==112) { + filter = tr("IDEAS files (*.unv)"); + myExtension = string("UNV"); + myReader = new DriverUNV_R_SMESHDS_Document; + } + else if (theCommandID==111) { + filter = tr("DAT files (*.dat)"); + myExtension = string("DAT"); + myReader = new DriverDAT_R_SMESHDS_Document; + } + + QString filename = QAD_FileDlg::getFileName(parent, + "", + filter, + tr("Import document"), + true); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + string myClass = string("SMESHDS_Document"); +// Document_Reader* myReader = SMESHDriver::GetDocumentReader(myExtension, myClass); + Handle(SMESHDS_Document) newDocument = new SMESHDS_Document(1); + + myReader->SetFile(string(filename.latin1())); + myReader->SetDocument(smeshGUI->myDocument); + myReader->Read(); + QApplication::restoreOverrideCursor(); + } +} + +void SMESHGUI::Export_Document(QAD_Desktop* parent, int theCommandID) +{ + QString filter; + Document_Writer* myWriter; + string myExtension; + + if (theCommandID==122) { + filter = tr("MED files (*.med)"); + myExtension = string("MED"); + myWriter = new DriverMED_W_SMESHDS_Document; + } + else if (theCommandID==121) { + filter = tr("DAT files (*.dat)"); + myExtension = string("DAT"); + myWriter = new DriverDAT_W_SMESHDS_Document; + } else if (theCommandID==123) { + filter = tr("IDEAS files (*.unv)"); + myExtension = string("UNV"); + myWriter = new DriverUNV_W_SMESHDS_Document; + } + + QString filename = QAD_FileDlg::getFileName(parent, + "", + filter, + tr("Export document"), + false); + if ( !filename.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + string myClass = string("SMESHDS_Document"); + //Document_Writer* myWriter = SMESHDriver::GetDocumentWriter(myExtension, myClass); + + myWriter->SetFile(string(filename.latin1())); + myWriter->SetDocument(smeshGUI->myDocument); + + //StudyContextStruct* myStudyContext = _impl.GetStudyContext(myStudyId); + //Handle(SMESHDS_Document) myDocument = myStudyContext->myDocument; + //myWriter->SetDocument(myDocument); + + myWriter->Write(); + QApplication::restoreOverrideCursor(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::OnMousePress(QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + SMESHGUI::GetOrCreateSMESHGUI(parent); + return false ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + SMESHGUI::GetOrCreateSMESHGUI(parent); + + return true; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + SMESHGUI::GetOrCreateSMESHGUI(parent); + + return true ; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::SetSettings( QAD_Desktop* parent ) +{ + SMESHGUI::GetOrCreateSMESHGUI(parent); + + /* Display mode */ + QString DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + if ( DisplayMode.compare("") == 0 ) { + DisplayMode = "Shading"; + QAD_CONFIG->addSetting("SMESH:DisplayMode","Shading"); + } + + if ( DisplayMode.compare("Wireframe") == 0 ){ + parent->menuBar()->setItemChecked(10003, false ); + parent->menuBar()->setItemChecked(10002, false ); + parent->menuBar()->setItemChecked(10001, true ); + } else if ( DisplayMode.compare("Shading") == 0 ){ + parent->menuBar()->setItemChecked(10003, false ); + parent->menuBar()->setItemChecked(10002, true ); + parent->menuBar()->setItemChecked(10001, false ); + } else if ( DisplayMode.compare("Shrink") == 0 ) { + parent->menuBar()->setItemChecked(10003, true ); + parent->menuBar()->setItemChecked(10002, false ); + parent->menuBar()->setItemChecked(10001, false ); + } + + /* Automatic Update */ + QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate"); + if ( AutoUpdate.compare("true") == 0 ) { + parent->menuBar()->setItemChecked(1001, true ); + smeshGUI->myAutomaticUpdate = true; + } else { + parent->menuBar()->setItemChecked(1001, false ); + smeshGUI->myAutomaticUpdate = false; + } + + /* menus disable */ + parent->menuBar()->setItemEnabled( 11, false); // IMPORT + + return true; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) +{ + /* Create or retrieve an object SMESHGUI */ + SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop()); + + // NRI : Temporary added + // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) { + // theObject = "NothingSelected"; + // theContext = "NothingSelected"; + // } + // NRI + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + if (nbSel == 0) { + if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + vtkScalarBarActor* aScalarBar = smeshGUI->GetScalarBar(); + if ((aScalarBar != NULL) && (aScalarBar->GetVisibility() == 1) ) { + theObject = "ScalarBar"; + theContext = ""; + } else { + theObject = "NothingSelected"; + theContext = "NothingSelected"; + } + } else { + theObject = "NothingSelected"; + theContext = "NothingSelected"; + } + } else if (nbSel == 1 ) { + theObject = smeshGUI->CheckTypeObject( Sel->firstIObject() ); + theContext = ""; + } else { + theObject = smeshGUI->CheckHomogeneousSelection(); + theContext = ""; + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +bool SMESHGUI::CustomPopup( QAD_Desktop* parent, + QPopupMenu* popup, + const QString& theContext, + const QString& theParent, + const QString& theObject ) +{ + // Popup should be customized for any viewer since some meaningless commands may be present in the popup + //if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) //Test du type de viewer true=OCC false=VTK + // return false; + /* Create or retrieve an object SMESHGUI */ + SMESHGUI::GetOrCreateSMESHGUI(parent); + + // NRI : Temporary added + // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) { + // return false; + // } + // NRI + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame(); + int nbSel = Sel->IObjectCount(); + + if (nbSel == 0) { + if (studyFrame->getTypeView() != VIEW_VTK) + popup->clear(); + return false; + } else if (nbSel == 1 ) { + QString parentComp = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection(); + // First check type of active viewer (VTK required) + if (/*studyFrame->getTypeView() != VIEW_VTK ||*/ parentComp != parent->getActiveComponent()) + { + //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items") + while (1) { + int id = popup->idAt(0); + if (id <= QAD_TopLabel_Popup_ID) + popup->removeItemAt(0); + else + break; + } + if (theObject.compare("Component") == 0) { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + } + return false; + } + + // Remove common popup items for Submesh, Hypothesis and Algorithm + if (theObject.compare("SubMesh") == 0 || + theObject.compare("Hypothesis") == 0 || + theObject.compare("Algorithm") == 0 ) { + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + int id = popup->idAt(popup->count()-1); // last item + if (id < 0 && id != -1) popup->removeItem(id); // separator + } + + if (theObject.compare("Component") == 0) { + popup->removeItem(QAD_DisplayOnly_Popup_ID); + return true; + } + + int id = QAD_TopLabel_Popup_ID;//popup->idAt(0); + QFont f = QApplication::font(); + f.setBold( TRUE ); + + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + + if ( theParent.compare("Viewer")==0 ) { + if (popup->idAt(0) == id) { + popup->removeItem(id); + popup->insertItem( new CustomItem ( QString(IObject->getName()), f ), id, 0 ); + } + + Standard_Boolean res; + SMESH_Actor* ac = smeshGUI->FindActorByEntry( IObject->getEntry(), res, false ); + if ( res && studyFrame->getTypeView() == VIEW_VTK) { + VTKViewer_RenderWindowInteractor* myRenderInter= + ((VTKViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getRWInteractor(); + if ( myRenderInter->isVisible( IObject ) ) { + popup->removeItem(QAD_Display_Popup_ID); + } else { + popup->removeItem(QAD_Erase_Popup_ID); + } + } else { + popup->removeItem(QAD_Erase_Popup_ID); + if (!res) {// mesh not computed -> can't display it + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItemAt(popup->count() - 1);//separator + } + } + } else if ( theParent.compare("ObjectBrowser")==0 ) { + if (theObject.compare("Mesh") == 0 || + theObject.compare("SubMesh") == 0 || + theObject.compare("Hypothesis") == 0 || + theObject.compare("Algorithm") == 0 ) { + popup->removeItemAt(0); + } else { + if (popup->idAt(0) == id) { + popup->removeItem(id); + popup->removeItemAt(0);//separator + } + } + + Standard_Boolean res; + SMESH_Actor* ac = smeshGUI->FindActorByEntry( IObject->getEntry(), res, false ); + if ( res && studyFrame->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter= + ((VTKViewer_ViewFrame*)studyFrame->getRightFrame()->getViewFrame())->getRWInteractor(); + if ( myRenderInter->isVisible( IObject ) ) { + popup->removeItem(QAD_Display_Popup_ID); + } else { + popup->removeItem(QAD_Erase_Popup_ID); + } + } else { + if (theObject.compare("Mesh") == 0 || + theObject.compare("SubMesh") == 0 || + theObject.compare("Hypothesis") == 0 || + theObject.compare("Algorithm") == 0 ) { + } else { + popup->removeItem(QAD_Erase_Popup_ID); + if (!res) {// mesh not computed -> can't display it + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItemAt(popup->count() - 1);//separator + } + } + } + } + } else { + QString parentComp = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection(); + QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame(); + if (/*studyFrame->getTypeView() != VIEW_VTK ||*/ parentComp != parent->getActiveComponent()) + { + //MESSAGE("CustomPopup(): VTK viewer required, removing all SMESH-specific popup menu items") + while (1) { + int id = popup->idAt(0); + if (id <= QAD_TopLabel_Popup_ID && id != -1) + popup->removeItemAt(0); + else + break; + } + if (parentComp.isNull()) { // objects from several components are selected + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + int id = popup->idAt(popup->count()-1); // last item + if (id < 0 && id != -1) popup->removeItem(id); // separator + } + return false; + } + + QString type = smeshGUI->CheckHomogeneousSelection(); + if ( type.compare("Heterogeneous Selection") != 0 ) { + int id = QAD_TopLabel_Popup_ID;//popup->idAt(0); + QFont f = QApplication::font(); + f.setBold( TRUE ); + popup->removeItem(id); + popup->insertItem( new CustomItem ( QString("%1 ").arg(nbSel) + type + " (s) ", f), id, 0 ); + } + } + return false; +} + +//============================================================================= +/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) + * Purpose: ensures that the actor for the given exists in the active VTK view + */ +//============================================================================= +void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +{ + /* Create or retrieve an object SMESHGUI */ + SMESHGUI::GetOrCreateSMESHGUI(QAD_Application::getDesktop()); + + QAD_StudyFrame* activeFrame = smeshGUI->myActiveStudy->getActiveStudyFrame(); + if (activeFrame->getTypeView() == VIEW_VTK) { + // VTK + SALOMEDS::SObject_var fatherSF = + smeshGUI->myStudy->FindObjectID(activeFrame->entry()); + + SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + +// for(;It.More();It.Next()) { +// Handle(SALOME_InteractiveObject) IObject = It.Value(); + Handle(SALOME_InteractiveObject) IObject = theIO; + if ( IObject->hasEntry() ) { + // Look for the actor in all views + Standard_Boolean res; + SMESH_Actor *ac = smeshGUI->FindActorByEntry(IObject->getEntry(), res, false); + + // Actor not found at all -> mesh is not computed -> do nothing!!! + if ( !res ) { + /*SMESH::SMESH_Mesh_var aM; + SALOMEDS::SObject_var aMorSM = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::SObject_var father = aMorSM->GetFather(); + SALOMEDS::SObject_var fatherComp = aMorSM->GetFatherComponent(); + + // Non-displayable objects (Hypo, Algo) have tags < 3 or have a father different from component + if (aMorSM->Tag() < 3 || strcmp(father->GetID(), fatherComp->GetID()) != 0) + continue; + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( !aMorSM->_is_nil() ) { + if (aMorSM->FindAttribute(anAttr, "AttributeIOR") ) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aM = SMESH::SMESH_Mesh::_narrow( _orb->string_to_object(anIOR->Value()) ); + } + } + + if (!aM->_is_nil()) { + smeshGUI->InitActor(aM); + ac = smeshGUI->ReadScript(aM); + } + + if (ac) { + smeshGUI->DisplayActor( ac, true ); + smeshGUI->DisplayEdges( ac ); + smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() ); + }*/ +// continue; + } else { // The actor exists in some view + // Check whether the actor belongs to the active view + VTKViewer_RenderWindowInteractor* rwInter = + ((VTKViewer_ViewFrame*)activeFrame->getRightFrame()->getViewFrame())->getRWInteractor(); + + // The actor belongs to inactive view -> create a copy and display it in the active view + if (!rwInter->isInViewer(IObject)) { + SMESH_Actor* acCopy = SMESH_Actor::New(); + acCopy->ShallowCopy(ac); + ac = acCopy; + } + smeshGUI->DisplayActor( ac, false ); + smeshGUI->DisplayEdges( ac ); + smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() ); + } + } +// } + } else { + MESSAGE("BuildPresentation() must not be called while non-VTK view is active") + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::setOrb() +{ + try { + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init( 0 , 0 ); + } catch (...) { + INFOS("internal error : orb not found"); + _orb = 0; + } + ASSERT(! CORBA::is_nil(_orb)); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH_Actor* SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr aMesh) +{ + SMESH_Actor* MeshActor; + if ( !aMesh->_is_nil() ) { + Standard_Boolean result; + MeshActor = FindActor(aMesh, result, true); + if ( result ) { + SMESH::log_array_var aSeq = aMesh->GetLog(true); + + if (aSeq->length() == 0) { + MESSAGE("ReadScript(): log is empty") + return MeshActor; + } + + for (unsigned int ind = 0; ind < aSeq->length();ind++) { + switch ( aSeq[ind].commandType ) + { + case SMESH::ADD_NODE : + { + AddNodes( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::ADD_EDGE : + { + // AddEdges( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::ADD_TRIANGLE : + { + AddTriangles( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::ADD_QUADRANGLE : + { + AddQuadrangles( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::ADD_TETRAHEDRON : + { + AddTetras( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::ADD_PYRAMID : + { + break; + } + case SMESH::ADD_PRISM : + { + break; + } + case SMESH::ADD_HEXAHEDRON : + { + AddHexaedres( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::REMOVE_NODE : + { + RemoveNodes( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + case SMESH::REMOVE_ELEMENT : + { + RemoveElements( MeshActor, aSeq[ind].number, aSeq[ind].coords, aSeq[ind].indexes ); + break; + } + } + } + return MeshActor; + } + } + return NULL; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Dump(SMESH_Actor* Mactor) +{ + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + vtkPoints *Pts = ugrid->GetPoints(); + int nbPts = Pts->GetNumberOfPoints(); + int nbCells = ugrid->GetNumberOfCells(); + + FILE *In; + int i,j; + In = fopen("/tmp/dumpMesh","w+"); + fprintf(In,"%d %d\n",nbPts,nbCells); + for ( int i = 0; i < nbPts; i++ ) { + float *p = ugrid->GetPoint(i); + fprintf(In,"%d %e %e %e\n",i, p[0], p[1], p[2] ); + } + + for ( int i = 0; i < nbCells; i++ ) { + fprintf(In,"%d %d",i,ugrid->GetCell(i)->GetCellType()); + vtkIdList *Id = ugrid->GetCell(i)->GetPointIds(); + for (j=0; jGetNumberOfIds(); j++) { + fprintf(In," %d",Id->GetId(j)); + } + fprintf(In,"\n"); + } + fclose(In); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddNodes( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, + const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + if ( Mactor->GetMapper() == NULL ) { + vtkPoints *Pts = vtkPoints::New(); + SMESH_Grid *ugrid = SMESH_Grid::New(); + ugrid->Allocate(); + + int i = 1; + int j = 1; + while ( i <= number ) { + int idVTK = Pts->InsertNextPoint( coords[j-1], coords[j], coords[j+1] ); + //Mactor->AddNode( indexes[i-1], idVTK ); + ugrid->AddNode( indexes[i-1], idVTK ); + i++; + j = j + 3; + } + //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New(); + ugrid->SetPoints(Pts); + vtkDataSetMapper * PtsMapper = vtkDataSetMapper::New(); + PtsMapper->SetInput( ugrid ); + Mactor->DataSource = PtsMapper->GetInput(); + Mactor->SetMapper(PtsMapper); + } else { + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + int idVTK = ugrid->GetPoints()->InsertNextPoint( coords[j-1], coords[j], coords[j+1] ); + ugrid->AddNode( indexes[i-1], idVTK ); + i++; + j = j + 3; + } + vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New(); + PtsMapper->SetInput( ugrid ); + Mactor->DataSource = PtsMapper->GetInput(); + Mactor->SetMapper(PtsMapper); + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddNode(SMESH_Actor* Mactor, int idnode, float x, float y, float z) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + MESSAGE ( "SMESHGUI::AddNode " << idnode << " : " << x << ";" << y << ";" << z ) + if ( Mactor->GetMapper() == NULL ) { + vtkPoints *Pts = vtkPoints::New(); + int idVTK = Pts->InsertNextPoint( x, y, z ); + //Mactor->AddNode( idnode, idVTK ); + //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New(); + SMESH_Grid *ugrid = SMESH_Grid::New(); + ugrid->Allocate(); + ugrid->AddNode( idnode, idVTK ); + ugrid->SetPoints(Pts); + vtkDataSetMapper * PtsMapper = vtkDataSetMapper::New(); + PtsMapper->SetInput( ugrid ); + Mactor->DataSource = PtsMapper->GetInput(); + Mactor->SetMapper(PtsMapper); + } else { + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int idVTK = ugrid->GetPoints()->InsertNextPoint( x, y, z ); + //Mactor->AddNode( idnode, idVTK ); + ugrid->AddNode( idnode, idVTK ); + vtkDataSetMapper *PtsMapper = vtkDataSetMapper::New(); + PtsMapper->SetInput( ugrid ); + Mactor->DataSource = PtsMapper->GetInput(); + Mactor->SetMapper(PtsMapper); + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveNode(SMESH_Actor* Mactor, int idnode) +{ + MESSAGE ( " OLD RemoveNode method " ) +// int id = Mactor->GetIdVTKNode( idnode ); +// MESSAGE ( " RemoveNode id VTK " << id ) +// if ( Mactor->GetMapper() != NULL ) { +// vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); +// vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New(); +// vtkPoints *Pts = ugrid->GetPoints(); +// vtkPoints *newPts = vtkPoints::New(); +// int nbPts = Pts->GetNumberOfPoints(); +// bool findPt = false; +// for ( int i = 0; i < nbPts; i++ ) { +// if ( id != i ) { +// if ( !findPt) +// newPts->InsertPoint(i, Pts->GetPoint(i) ); +// else +// newPts->InsertPoint(i-1, Pts->GetPoint(i) ); +// } else { +// findPt = true; +// Mactor->RemoveNode( idnode ); +// } +// } + +// newUgrid->SetPoints(newPts); +// int nbCells = ugrid->GetNumberOfCells(); +// for ( int i = 0; i < nbCells; i++ ) { +// vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds(); +// vtkIdList *newIds = vtkIdList::New(); +// int nbIds = Ids->GetNumberOfIds(); +// newIds->SetNumberOfIds(nbIds); +// for ( int j = 0; j < nbIds; j++ ) { +// int theid = Ids->GetId(j); +// if ( theid > id ) { +// newIds->SetId( j, theid-1 ); +// } else +// newIds->SetId( j, theid ); +// } +// int idSMDSel = Mactor->GetIdSMESHDSElement( i ); +// Mactor->RemoveElement( idSMDSel, false ); +// int idVTKel = newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), newIds ); +// Mactor->AddElement( idSMDSel, idVTKel ); +// } + + +// vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); +// Mapper->SetInput( newUgrid ); +// Mactor->DataSource = Mapper->GetInput(); +// Mactor->SetMapper(Mapper); + +// UpdateView(); +// } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveNodes(SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + int i = 1; + while ( i <= number ) { + Mactor->RemoveNode( indexes[i-1] ); + i++; + } + + TColStd_DataMapOfIntegerInteger newMapVTKNodes; + TColStd_DataMapOfIntegerInteger newMapSMESHDSNodes; + TColStd_DataMapOfIntegerInteger MapOldNodesToNewNodes; + + if ( Mactor->GetMapper() != NULL ) { + SMESH_Grid *ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid *newUgrid = SMESH_Grid::New(); + newUgrid->CopyMaps(ugrid); + + vtkPoints *Pts = ugrid->GetPoints(); + vtkPoints *newPts = vtkPoints::New(); + int nbPts = Pts->GetNumberOfPoints(); + int j = 0; + for ( int i = 0; i < nbPts; i++ ) { + int idSMESHDSNode = Mactor->GetIdSMESHDSNode(i); + if ( idSMESHDSNode != -1 ) { + newPts->InsertPoint(j, Pts->GetPoint(i) ); + + newMapVTKNodes.Bind(j, idSMESHDSNode); + newMapSMESHDSNodes.Bind(idSMESHDSNode, j); + + MapOldNodesToNewNodes.Bind(i,j); + j++; + } + } + + newUgrid->SetIdsVTKNode(newMapVTKNodes); + newUgrid->SetIdsSMESHDSNode(newMapSMESHDSNodes); + newUgrid->SetPoints(newPts); + + TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK; + TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS; + + int nbCells = ugrid->GetNumberOfCells(); + for ( int i = 0; i < nbCells; i++ ) { + vtkIdList *Ids = ugrid->GetCell(i)->GetPointIds(); + vtkIdList *newIds = vtkIdList::New(); + int nbIds = Ids->GetNumberOfIds(); + newIds->SetNumberOfIds(nbIds); + bool isGood = true; + for ( int j = 0; j < nbIds; j++ ) { + int theid = Ids->GetId(j); + if ( MapOldNodesToNewNodes.IsBound( theid ) ) { + newIds->SetId( j, MapOldNodesToNewNodes.Find( theid ) ); + } else { + isGood = false; + break; + } + } + + // Filtering out cells based on non-existing nodes + if (isGood) { + int idSMDSel = Mactor->GetIdSMESHDSElement( i ); + int idVTKel = newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), newIds ); + + newMapElementSMDStoVTK.Bind(idSMDSel, idVTKel); + newMapElementVTKtoSMDS.Bind(idVTKel, idSMDSel); + } + } + + newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS); + newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK); + + // Copy new data to the old DatSource: keep the single DataSource for all actors + ugrid->DeepCopy(newUgrid); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( ugrid ); + Mactor->SetMapper(Mapper); + + // Commented to avoid multiple viewer updates when called by ReadScript() + //UpdateView(); + + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(MapIndex.Extent()); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + for ( ; ite.More(); ite.Next() ) { + // MESSAGE ( " RemoveNode : id " << ac->GetIdSMESHDSNode(ite.Key()) ) + anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key()); + i++; + } + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->RemoveNodes(anArrayOfIdeces); + + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); + } + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveElement(SMESH_Actor* Mactor, int idelement) +{ + MESSAGE ( " OLD RemoveElement method " ) +// int id = Mactor->GetIdVTKElement( idelement ); +// MESSAGE ( " RemoveElement id VTK : " << id ) +// if ( Mactor->GetMapper() != NULL ) { +// vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); +// vtkUnstructuredGrid* newUgrid = vtkUnstructuredGrid::New(); + +// int nbCells = ugrid->GetNumberOfCells(); +// for ( int i = 0; i < nbCells; i++ ) { +// if ( id != i ) { +// newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), +// ugrid->GetCell(i)->GetPointIds() ); +// } else +// Mactor->RemoveElement( idelement ); +// } +// newUgrid->SetPoints(ugrid->GetPoints()); + +// vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); +// Mapper->SetInput( newUgrid ); +// Mactor->DataSource = Mapper->GetInput(); +// Mactor->SetMapper(Mapper); + +// UpdateView(); +// } +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveElements(SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + int i = 1; + while ( i <= number ) { + Mactor->RemoveElement( indexes[i-1] ); + i++; + } + TColStd_DataMapOfIntegerInteger newMapElementSMDStoVTK; + TColStd_DataMapOfIntegerInteger newMapElementVTKtoSMDS; + + if ( Mactor->GetMapper() != NULL ) { + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* newUgrid = SMESH_Grid::New(); + newUgrid->CopyMaps(ugrid); + + int nbCells = ugrid->GetNumberOfCells(); + for ( int i = 0; i < nbCells; i++ ) { + int idSMESHDSElement = Mactor->GetIdSMESHDSElement(i); + if ( idSMESHDSElement != -1 ) { + int newId = newUgrid->InsertNextCell( ugrid->GetCell(i)->GetCellType(), + ugrid->GetCell(i)->GetPointIds() ); + newMapElementSMDStoVTK.Bind(idSMESHDSElement, newId); + newMapElementVTKtoSMDS.Bind(newId, idSMESHDSElement); + } + } + + newUgrid->SetIdsVTKElement(newMapElementVTKtoSMDS); + newUgrid->SetIdsSMESHDSElement(newMapElementSMDStoVTK); + + newUgrid->SetPoints(ugrid->GetPoints()); + + // Copy new data to the old DatSource: keep the single DataSource for all actors + ugrid->DeepCopy(newUgrid); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( ugrid ); + Mactor->SetMapper(Mapper); + + // Commented to avoid multiple viewer updates when called by ReadScript() + //UpdateView(); + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(MapIndex.Extent()); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + for ( ; ite.More(); ite.Next() ) { + // MESSAGE ( " RemoveElement : id " << ite.Key() << "," << ac->GetIdSMESHDSElement(ite.Key()) ) + anArrayOfIdeces[i] = ac->GetIdSMESHDSElement(ite.Key()); + i++; + } + + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->RemoveElements(anArrayOfIdeces); + } + + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); +#ifdef TRACE + Dump( Mesh ); +#endif + } + } + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New(); + SMESH_Grid* UGrid = SMESH_Grid::New(); + SMESH_Grid* oldGrid = SMESH_Grid::SafeDownCast(ac->DataSource); + UGrid->CopyMaps(oldGrid); + + vtkGeometryFilter *gf = vtkGeometryFilter::New(); + gf->SetInput( ac->DataSource ); + + vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New(); + Mapper->SetInput( gf->GetOutput() ); + Mapper->Update(); + + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + for ( ; ite.More(); ite.Next() ) { + Mapper->GetInput()->ReverseCell( ite.Key() ); + } + + UGrid->SetPoints( Mapper->GetInput()->GetPoints() ); + int nbCells = Mapper->GetInput()->GetNumberOfCells(); + for ( int i = 0; i < nbCells; i++ ) { + UGrid->InsertNextCell( Mapper->GetInput()->GetCellType(i), Mapper->GetInput()->GetCell(i)->GetPointIds() ); + } + + // Copy new data to the old DatSource: keep the single DataSource for all actors + oldGrid->DeepCopy(UGrid); + + vtkDataSetMapper *NewMapper = vtkDataSetMapper::New(); + //NewMapper->SetInput( UGrid ); + NewMapper->SetInput( oldGrid ); + NewMapper->Update(); + + //ac->DataSource = NewMapper->GetInput(); + ac->SetMapper( NewMapper ); + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + //vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::New(); + SMESH_Grid* UGrid = SMESH_Grid::New(); + vtkGeometryFilter *gf = vtkGeometryFilter::New(); + gf->SetInput( ac->DataSource ); + + vtkExtractEdges *edges = vtkExtractEdges::New(); + edges->SetInput( ac->DataSource ); + + vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New(); + Mapper->SetInput( edges->GetOutput() ); + Mapper->Update(); + + int nb = Mapper->GetInput()->GetNumberOfCells(); + //MESSAGE ( "nb : " << nb ) + + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + for ( ; ite.More(); ite.Next() ) { + vtkCell* StartEdge = Mapper->GetInput()->GetCell(ite.Key()); + //MESSAGE( "DCQ : Edge Id = " << ite.Key()) + int CellType = StartEdge->GetCellType(); + //MESSAGE( "DCQ : Cell Type = " << CellType) + int nbPoints = StartEdge->GetNumberOfPoints(); + + //MESSAGE( "DCQ : Nb Point = " << nbPoints) + if ( nbPoints == 2 ) { + vtkUnstructuredGrid* StartUGrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + + vtkIdList *IdCells = vtkIdList::New(); + vtkIdList *IdPoints = StartEdge->GetPointIds(); + float p1[3]; + float p2[3]; + + Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(0),p1); + Mapper->GetInput()->GetPoints()->GetPoint(IdPoints->GetId(1),p2); + + int idp1 = StartUGrid->FindPoint(p1); + int idp2 = StartUGrid->FindPoint(p2); + + StartUGrid->GetPointCells( idp1, IdCells ); + + //MESSAGE ( " pt 0 : " << IdPoints->GetId(0) ) + //MESSAGE ( " pt 1 : " << IdPoints->GetId(1) ) + + //MESSAGE ( " pt 0 : " << idp1 ) + //MESSAGE ( " pt 1 : " << idp2 ) + + vtkIdList *IdPts = vtkIdList::New(); + if (IdCells->GetNumberOfIds() >= 2) { + int nbCells = IdCells->GetNumberOfIds(); + //MESSAGE ( " nbCells : " << nbCells ) + for (int j=0; jGetCellPoints( IdCells->GetId(j), IdPts ); + if ( IdPts->IsId( idp2 ) == -1 ) { + IdCells->DeleteId( IdCells->GetId(j) ); + } + } + + + //MESSAGE ( " IdCells " << IdCells->GetNumberOfIds() ) + + vtkIdList *IdPts0 = vtkIdList::New(); + vtkIdList *IdPts1 = vtkIdList::New(); + + if (IdCells->GetNumberOfIds() == 2) { + StartUGrid->GetCellPoints( IdCells->GetId(0), IdPts0 ); + StartUGrid->GetCellPoints( IdCells->GetId(1), IdPts1 ); + + //Create new faces + TColStd_MapOfInteger EndMapIndex; + for (int j = 0; j < 3; j++ ) { + if ( IdPts0->GetId(j) != idp1 && IdPts0->GetId(j) != idp2 ) { + EndMapIndex.Add( IdPts0->GetId(j) ); + } + if ( IdPts1->GetId(j) != idp1 && IdPts1->GetId(j) != idp2 ) { + EndMapIndex.Add( IdPts1->GetId(j) ); + } + } + + bool MyAU = myAutomaticUpdate ; + myAutomaticUpdate = false ; + + EndMapIndex.Add( idp1 ); + TColStd_MapIteratorOfMapOfInteger ite1( EndMapIndex ); + int i = 1; + while ( ite1.More() ) { + if ( ite1.Key() == idp1 ) + break; + i++; + ite1.Next(); + } + bool reverse1 = ( i == 2 ); + this->AddFace( aMesh, EndMapIndex, reverse1 ); + + EndMapIndex.Remove( idp1 ); + EndMapIndex.Add( idp2 ); + TColStd_MapIteratorOfMapOfInteger ite2( EndMapIndex ); + i = 1; + while ( ite2.More() ) { + if ( ite2.Key() == idp2 ) + break; + i++; + ite2.Next(); + } + bool reverse2 = ( i == 2 ); + this->AddFace( aMesh, EndMapIndex, !(reverse1 == reverse2) ); + + myAutomaticUpdate = MyAU ; + //MESSAGE ( " myAutomaticUpdate = " << MyAU ) + Mapper->Update(); + //Remove old faces + TColStd_MapOfInteger StartMapIndex; + StartMapIndex.Add( IdCells->GetId(0) ); + StartMapIndex.Add( IdCells->GetId(1) ); + this->RemoveElements( aMesh, StartMapIndex ); + + Mapper->Update(); + } + } + } + } + + // UGrid->SetPoints( Mapper->GetInput()->GetPoints() ); + // int nbCells = Mapper->GetInput()->GetNumberOfCells(); + // for ( int i = 0; i < nbCells; i++ ) { + // UGrid->InsertNextCell( Mapper->GetInput()->GetCellType(i), Mapper->GetInput()->GetCell(i)->GetPointIds() ); + // } + + // vtkDataSetMapper *NewMapper = vtkDataSetMapper::New(); + // NewMapper->SetInput( UGrid ); + // NewMapper->Update(); + + // ac->DataSource = NewMapper->GetInput(); + // ac->SetMapper( NewMapper ); + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddEdges( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+1] ) ); + int id = ugrid->InsertNextCell(VTK_LINE, Ids); + Mactor->AddElement( indexes[j-1], id ); + i++; + j = j + 3; + } + vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New(); + EdgeMapper->SetInput( ugrid ); + Mactor->DataSource = EdgeMapper->GetInput(); + Mactor->SetMapper(EdgeMapper); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddEdge(SMESH_Actor* Mactor, int idedge, int idnode1, int idnode2) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + MESSAGE ( "SMESHGUI::AddEdge " << idedge << " : " << idnode1 << ";" << idnode2 ) + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode1 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode2 ) ); + + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int id = ugrid->InsertNextCell(VTK_LINE, Ids); + Mactor->AddElement( idedge, id ); + + MESSAGE ( " Edge VTK id " << id ) + + vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New(); + EdgeMapper->SetInput( ugrid ); + Mactor->DataSource = EdgeMapper->GetInput(); + Mactor->SetMapper(EdgeMapper); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddTriangles( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+1] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+2] ) ); + int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids); + Mactor->AddElement( indexes[j-1], id ); + i++; + j = j + 4; + } + vtkDataSetMapper *TriMapper = vtkDataSetMapper::New(); + TriMapper->SetInput( ugrid ); + Mactor->DataSource = TriMapper->GetInput(); + Mactor->SetMapper(TriMapper); + QApplication::restoreOverrideCursor(); +} +void SMESHGUI::AddTriangle(SMESH_Actor* Mactor, int idtri, int idnode1, int idnode2, int idnode3) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode1 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode2 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode3 ) ); + + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int id = ugrid->InsertNextCell(VTK_TRIANGLE, Ids); + Mactor->AddElement( idtri, id ); + + vtkDataSetMapper *TriMapper = vtkDataSetMapper::New(); + TriMapper->SetInput( ugrid ); + Mactor->DataSource = TriMapper->GetInput(); + Mactor->SetMapper(TriMapper); + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddQuadrangles( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+1] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+2] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+3] ) ); + int id = ugrid->InsertNextCell(VTK_QUAD, Ids); + Mactor->AddElement( indexes[j-1], id ); + i++; + j = j + 5; + } + vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New(); + QuadMapper->SetInput( ugrid ); + Mactor->DataSource = QuadMapper->GetInput(); + Mactor->SetMapper(QuadMapper); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddQuadrangle(SMESH_Actor* Mactor, int idquad, int idnode1, int idnode2, + int idnode3, int idnode4) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode1 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode2 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode3 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode4 ) ); + + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int id = ugrid->InsertNextCell(VTK_QUAD, Ids); + Mactor->AddElement( idquad, id ); + + vtkDataSetMapper *QuadMapper = vtkDataSetMapper::New(); + QuadMapper->SetInput( ugrid ); + Mactor->DataSource = QuadMapper->GetInput(); + Mactor->SetMapper(QuadMapper); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddTetras( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+1] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+2] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+3] ) ); + int id = ugrid->InsertNextCell(VTK_TETRA, Ids); + Mactor->AddElement( indexes[j-1], id ); + i++; + j = j + 5; + } + vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New(); + TetraMapper->SetInput( ugrid ); + Mactor->DataSource = TetraMapper->GetInput(); + Mactor->SetMapper(TetraMapper); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddTetra(SMESH_Actor* Mactor, int idtetra, int idnode1, int idnode2, + int idnode3, int idnode4) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + MESSAGE ( "SMESHGUI::AddTetra " << idtetra << " : " << idnode1 << ";" << idnode2 + << ";" << idnode3 << ";" << idnode4 ) + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode1 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode2 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode3 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode4 ) ); + + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int id = ugrid->InsertNextCell(VTK_TETRA, Ids); + Mactor->AddElement( idtetra, id ); + + MESSAGE ( " Tetra VTK id " << id ) + + vtkDataSetMapper *TetraMapper = vtkDataSetMapper::New(); + TetraMapper->SetInput( ugrid ); + Mactor->DataSource = TetraMapper->GetInput(); + Mactor->SetMapper(TetraMapper); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddHexaedres( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + //vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int i = 1; + int j = 1; + while ( i <= number ) { + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+1] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+2] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+3] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+4] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+5] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+6] ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( indexes[j+7] ) ); + int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids); + Mactor->AddElement( indexes[j-1], id ); + i++; + j = j + 9; + } + vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New(); + HexaMapper->SetInput( ugrid ); + Mactor->DataSource = HexaMapper->GetInput(); + Mactor->SetMapper(HexaMapper); + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddHexaedre(SMESH_Actor* Mactor, int idhexa, int idnode1, int idnode2, + int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + MESSAGE ( "SMESHGUI::AddHexaedre " << idhexa << " : " << idnode1 << ";" << idnode2 + << ";" << idnode3 << ";" << idnode4 << ";" << idnode5 << ";" << idnode6 + << ";" << idnode7 << ";" << idnode8) + + vtkIdList *Ids = vtkIdList::New(); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode1 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode2 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode3 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode4 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode5 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode6 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode7 ) ); + Ids->InsertNextId( Mactor->GetIdVTKNode( idnode8 ) ); + + //vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + SMESH_Grid* ugrid = SMESH_Grid::SafeDownCast( Mactor->DataSource ); + int id = ugrid->InsertNextCell(VTK_HEXAHEDRON, Ids); + Mactor->AddElement( idhexa, id ); + + MESSAGE ( " Hexa VTK id " << id ) + + vtkDataSetMapper *HexaMapper = vtkDataSetMapper::New(); + HexaMapper->SetInput( ugrid ); + Mactor->DataSource = HexaMapper->GetInput(); + Mactor->SetMapper(HexaMapper); + QApplication::restoreOverrideCursor(); +} + +//===================================================================================== +// EXPORTED METHODS +//===================================================================================== +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + { + return SMESHGUI::OnGUIEvent(theCommandID, parent); + } + + bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return SMESHGUI::OnKeyPress (pe, parent, studyFrame); + } + + bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return SMESHGUI::OnMousePress (pe, parent, studyFrame); + } + + bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + return SMESHGUI::OnMouseMove (pe, parent, studyFrame); + } + + bool SetSettings ( QAD_Desktop* parent ) + { + return SMESHGUI::SetSettings( parent ); + } + + bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ) + { + return SMESHGUI::CustomPopup( parent, popup, theContext, theParent, theObject ); + } + + void definePopup ( QString & theContext, QString & theParent, QString & theObject ) + { + SMESHGUI::DefinePopup( theContext, theParent, theObject ); + } + + bool activeStudyChanged ( QAD_Desktop* parent ) + { + SMESHGUI::activeStudyChanged( parent ); + } + + void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) + { + SMESHGUI::BuildPresentation(theIO); + } + + void supportedViewType(int* buffer, int bufferSize) + { + if (!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_VTK; + } + +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::ViewNodes() +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* theActors = theRenderer->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SMESH_Actor") ) { + SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( ac ); + if ( anActor->GetVisibility() == 1 ) { + vtkGeometryFilter *gf = vtkGeometryFilter::New(); + gf->SetInput( anActor->DataSource ); + vtkMaskPoints *verts = vtkMaskPoints::New(); + verts->SetInput(gf->GetOutput()); + verts->GenerateVerticesOn(); + verts->SetOnRatio(1); + + vtkPolyDataMapper *vertMapper = vtkPolyDataMapper::New(); + vertMapper->SetInput(verts->GetOutput()); + vertMapper->ScalarVisibilityOff(); + + vtkActor *vertActor = vtkActor::New(); + vertActor->SetMapper(vertMapper); + + float r, g , b ; + anActor->GetNodeColor(r, g, b ) ; + vertActor->GetProperty()->SetColor( r, g, b ) ; + + vertActor->GetProperty()->SetPointSize( anActor->GetNodeSize() ); + + vertActor->PickableOff(); + + mySimulationActors->AddItem( vertActor ); + theRenderer->AddActor( vertActor ); + } + } + ac = theActors->GetNextActor(); + } + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Control(int theCommandID) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + QApplication::setOverrideCursor( Qt::waitCursor ); + DisplayScalarBar( false ); + + vtkScalars *scalars = vtkScalars::New(); + vtkDataSetMapper* meshMapper = 0; + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + Standard_Boolean result; + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + SMESH_Actor* MeshActor = FindActorByEntry(IObject->getEntry(), result, true); + + // Mesh may be not updated after Compute + if (!MeshActor->DataSource || !MeshActor->GetMapper()) { + QApplication::restoreOverrideCursor(); + return; + } + + bool ValidateScalars = false; + if ( result ) { + QString type; + switch (theCommandID) + { + case 6001: //Length Edges + { + type = tr( "SMESH_CONTROL_LENGTH_EDGES"); + meshMapper = (vtkDataSetMapper*)MeshActor->EdgeDevice->GetMapper(); + vtkUnstructuredGrid* grid = (vtkUnstructuredGrid*)meshMapper->GetInput(); + MESSAGE ( " init minimum length " << grid->GetNumberOfCells() ) + for (int i=0; iGetNumberOfCells(); i++ ) { + vtkCell* cell = grid->GetCell(i); + float len = SMESHGUI_ComputeScalarValue::LengthEdges(cell); + if (len == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,len); + } + } + if (ValidateScalars && (MeshActor->getDisplayMode()!=0)) + ChangeRepresentation( MeshActor, 1 );// limitation; in Wireframe, colored edges are not visible + break; + } + case 6011: // Area Elements + { + type = tr( "SMESH_CONTROL_AREA_ELEMENTS"); + for (int i=0; i< MeshActor->GetMapper()->GetInput()->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->GetMapper()->GetInput()->GetCell(i); + float area = SMESHGUI_ComputeScalarValue::AreaElements(cell); + if (area == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,area); + } + } + if (ValidateScalars && (MeshActor->getDisplayMode()!=1)) + ChangeRepresentation( MeshActor, 1 ); + break; + } + case 6012: // Taper + { + type = tr( "SMESH_CONTROL_TAPER_ELEMENTS"); + for (int i=0; i< MeshActor->DataSource->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->DataSource->GetCell(i); + float taper = SMESHGUI_ComputeScalarValue::Taper(cell); + if (taper == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,taper); + } + } + break; + } + case 6013: // Aspect ratio + { + type = tr( "SMESH_CONTROL_ASPECTRATIO_ELEMENTS"); + for (int i=0; iDataSource->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->DataSource->GetCell(i); + float aspect = SMESHGUI_ComputeScalarValue::AspectRatio(cell); + if (aspect == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,aspect); + } + } + if (ValidateScalars && (MeshActor->getDisplayMode()!=1)) + ChangeRepresentation( MeshActor, 1 ); + break; + } + case 6014: // Minimum angle + { + type = tr( "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS"); + for (int i=0; iDataSource->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->DataSource->GetCell(i); + float angle = SMESHGUI_ComputeScalarValue::MinimumAngle(cell); + if (angle == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,angle); + } + } + if (ValidateScalars && (MeshActor->getDisplayMode()!=1)) + ChangeRepresentation( MeshActor, 1 ); + break; + } + case 6015: // Warp + { + type = tr( "SMESH_CONTROL_WARP_ELEMENTS"); + for (int i=0; iDataSource->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->DataSource->GetCell(i); + float Warp = SMESHGUI_ComputeScalarValue::Warp(cell); + if (Warp == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,Warp); + } + } + break; + } + case 6016: // Skew + { + type = tr( "SMESH_CONTROL_SKEW_ELEMENTS"); + for (int i=0; iDataSource->GetNumberOfCells(); i++ ) { + vtkCell* cell = MeshActor->DataSource->GetCell(i); + float angle = SMESHGUI_ComputeScalarValue::Skew(cell); + if (angle == 0) continue; + else { + ValidateScalars = true; + scalars->InsertScalar(i,angle); + } + } + break; + } + } + + if ( !ValidateScalars ) { + QApplication::restoreOverrideCursor(); + return; + } + + float range[2]; + scalars->GetRange(range); + + vtkLookupTable* wat = vtkLookupTable::New(); + wat->SetRange( range ); + wat->Build(); + + scalars->SetLookupTable(wat); + + if (!meshMapper) meshMapper = (vtkDataSetMapper*) (MeshActor->getMapper()); + meshMapper->SetScalarModeToUseCellData(); + meshMapper->GetInput()->GetCellData()->SetScalars(scalars); + meshMapper->SetScalarRange( range ); + meshMapper->ScalarVisibilityOn(); + + vtkScalarBarActor* aScalarBar = GetScalarBar(); + if ( aScalarBar == NULL ) { + aScalarBar = vtkScalarBarActor::New(); + QString Bold = QAD_CONFIG->getSetting("ScalarBar:Bold"); + QString Italic = QAD_CONFIG->getSetting("ScalarBar:Italic"); + QString Shadow = QAD_CONFIG->getSetting("ScalarBar:Shadow"); + QString FontFamily = QAD_CONFIG->getSetting("ScalarBar:FontFamily"); + QString Orientation = QAD_CONFIG->getSetting("ScalarBar:Orientation"); + float Width = QAD_CONFIG->getSetting("ScalarBar:Width").toFloat(); + float Height = QAD_CONFIG->getSetting("ScalarBar:Height").toFloat(); + int NumberOfLabels = QAD_CONFIG->getSetting("ScalarBar:NumberOfLabels").toInt(); + int NumberOfColors = QAD_CONFIG->getSetting("ScalarBar:NumberOfColors").toInt(); + + SetSettingsScalarBar(aScalarBar, Bold, Italic, Shadow, FontFamily, Orientation, + Width, Height, NumberOfColors, NumberOfLabels); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + theRenderer->AddActor2D(aScalarBar); + } + aScalarBar->SetLookupTable( wat ); + aScalarBar->SetTitle( type.latin1() ); + + scalars->Delete(); + // wat->Delete(); + DisplayScalarBar( true ); + } + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor* theScalarBar, + QString Bold, QString Italic, + QString Shadow, QString FontFamily, + QString Orientation, float Width, float Height, + int NbColors, int NbLabels ) +{ + if ( Bold.isNull() || Bold.isEmpty() || (Bold.compare( "true" ) == 0) ) + theScalarBar->BoldOn(); + else + theScalarBar->BoldOff(); + + if ( Italic.isNull() || Italic.isEmpty() || (Italic.compare( "true" ) == 0) ) + theScalarBar->ItalicOn(); + else + theScalarBar->ItalicOff(); + + if ( Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare( "true" ) == 0) ) + theScalarBar->ShadowOn(); + else + theScalarBar->ShadowOff(); + + if ( FontFamily.compare( "Arial" ) == 0 ) + theScalarBar->SetFontFamilyToArial(); + else if ( FontFamily.compare( "Courier" ) == 0 ) + theScalarBar->SetFontFamilyToCourier(); + else if ( FontFamily.compare( "Times" ) == 0 ) + theScalarBar->SetFontFamilyToTimes(); + else + theScalarBar->SetFontFamilyToArial(); + + if ( Orientation.isNull() || Orientation.isEmpty() || (Orientation.compare( "Vertical" ) == 0) ) + theScalarBar->SetOrientationToVertical(); + else + theScalarBar->SetOrientationToHorizontal(); + + + theScalarBar->SetWidth((Width == 0)? 0.17 : Width); + theScalarBar->SetHeight((Height == 0)? 0.8 : Height); + + theScalarBar->SetNumberOfLabels((NbLabels == 0)? 5 : NbLabels); + theScalarBar->SetMaximumNumberOfColors((NbColors == 0)? 64 : NbColors); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplayScalarBar(bool visibility) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkScalarBarActor* aScalarBar = GetScalarBar(); + + if ( aScalarBar == NULL ) { + MESSAGE("myScalarBar is NULL"); + return; + } + + if ( visibility ) + aScalarBar->VisibilityOn(); + else { + aScalarBar->VisibilityOff(); + //Turn off mesh coloring (influences on all views) + vtkActorCollection* actorList=theRenderer->GetActors(); + actorList->InitTraversal(); + vtkActor *ac = actorList->GetNextActor(); + while(ac!=NULL) { + if (ac->GetMapper() != NULL) { + ac->GetMapper()->ScalarVisibilityOff(); + } + ac = actorList->GetNextActor(); + } + // Turn off ScalarBar in all views + /*QList aFrames = myActiveStudy->getStudyFrames(); + for ( QAD_StudyFrame* aFrame = aFrames.first(); aFrame; aFrame = aFrames.next() ) { + if (aFrame->getTypeView() == VIEW_VTK) { + vtkRenderer *aRenderer = ((VTKViewer_ViewFrame*) aFrame->getRightFrame()->getViewFrame())->getRenderer(); + vtkActor2DCollection* actor2DList = aRenderer->GetActors2D(); + actor2DList->InitTraversal(); + vtkActor2D* aActor2d = actor2DList->GetNextActor2D(); + while (aActor2d != NULL) { + if (aActor2d->IsA("vtkScalarBarActor")) { + aActor2d->VisibilityOff(); + break; + } + actor2DList->GetNextActor2D(); + } + } + }*/ + } + myActiveStudy->update3dViewers(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::UpdateScalarBar(float MinRange, float MaxRange) +{ + vtkScalarBarActor* aScalarBar = GetScalarBar(); + if ( aScalarBar == NULL ) { + MESSAGE("myScalarBar is NULL"); + return; + } + DisplayScalarBar(false); + + aScalarBar->GetLookupTable()->SetRange(MinRange, MaxRange); + vtkRenderer *aRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* aActorList = aRenderer->GetActors(); + aActorList->InitTraversal(); + vtkActor *aActor = aActorList->GetNextActor(); + while(aActor != NULL) { + if (aActor->IsA("SMESH_Actor")) { + SMESH_Actor* aMeshActor = SMESH_Actor::SafeDownCast(aActor); + vtkDataSetMapper* aMeshMapper = (vtkDataSetMapper*) (aMeshActor->getMapper()); + if ((aMeshMapper != NULL)) { + aMeshMapper->SetScalarRange( MinRange, MaxRange ); + aMeshMapper->ScalarVisibilityOn(); + } + } + aActor = aActorList->GetNextActor(); + } + DisplayScalarBar(true); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::SetDisplaySettings() +{ + EmitSignalDeactivateDialog() ; + SMESHGUI_Preferences_ColorDlg *aDlg = new SMESHGUI_Preferences_ColorDlg( QAD_Application::getDesktop(), "") ; + + QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed"); + QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen"); + QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue"); + QColor color = QColor (SCr.toInt(), SCg.toInt(), SCb.toInt()); + aDlg->SetColor(1,color); + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue"); + color = QColor (SCr.toInt(), SCg.toInt(), SCb.toInt()); + aDlg->SetColor(2,color); + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); + color = QColor (SCr.toInt(), SCg.toInt(), SCb.toInt()); + aDlg->SetColor(3,color); + + QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed"); + QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen"); + QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue"); + color = QColor (SBr.toInt(), SBg.toInt(), SBb.toInt()); + aDlg->SetColor(4,color); + + QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth"); + aDlg->SetIntValue(1,intValue.toInt()); + intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize"); + aDlg->SetIntValue(2,intValue.toInt()); + intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff"); + aDlg->SetIntValue(3,intValue.toInt()); + + if ( aDlg->exec() ) { + QColor colorFill = aDlg->GetColor( 1 ); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red()); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green()); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue()); + + QColor colorOutline = aDlg->GetColor( 2 ); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red()); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green()); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue()); + + QColor colorNode = aDlg->GetColor( 3 ); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red()); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green()); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue()); + + QColor colorBackFace = aDlg->GetColor( 4 ); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red()); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green()); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue()); + + int width = aDlg->GetIntValue( 1 ); + QAD_CONFIG->addSetting("SMESH:SettingsWidth", width); + + int nodes_size = aDlg->GetIntValue( 2 ); + QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size); + + int shrink_coeff = aDlg->GetIntValue( 3 ); + QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff); + } + + delete aDlg; +} + +//======================================================================= +// function : Parameter() +// purpose : return a parameter (double) from a dialog box +// +// aValue : is a double used as a default value displayed +// aLabel : is the title for aValue1 +// aTitle : is the main title +// bottom : maximum value to be entered +// top : minimum value to be entered +// decimals : number of decimals +//======================================================================= +double SMESHGUI::Parameter( Standard_Boolean& res, + const double aValue, + const char* aLabel, + const char* aTitle, + const double bottom, + const double top, + const int decimals ) +{ + SMESHGUI_aParameterDlg* Dialog = + new SMESHGUI_aParameterDlg( QAD_Application::getDesktop(), + aTitle, + aLabel, + bottom, top, decimals, + TRUE ); + Dialog->setValue( aValue ); + double X = 0.0; + res = ( Dialog->exec() == QDialog::Accepted ); + if ( res ) + X = Dialog->getDblValue(); + return X; +} + +//======================================================================= +// function : Parameter() +// purpose : return a parameter (int) from a dialog box +// +// aValue : is a int used as a default value displayed +// aLabel : is the title for aValue1 +// aTitle : is the main title +// bottom : maximum value to be entered +// top : minimum value to be entered +//======================================================================= +int SMESHGUI::Parameter( Standard_Boolean& res, + const int aValue, + const char* aLabel, + const char* aTitle, + const int bottom, + const int top ) +{ + SMESHGUI_aParameterDlg* Dialog = + new SMESHGUI_aParameterDlg( QAD_Application::getDesktop(), + aTitle, + aLabel, + bottom, top, + TRUE ); + Dialog->setValue( aValue ); + int X = 0; + res = ( Dialog->exec() == QDialog::Accepted ); + if ( res ) + X = Dialog->getIntValue(); + return X; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplayEdges(SMESH_Actor* ac, bool visibility) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + if (ac->DataSource == NULL || ac->GetMapper() == NULL) + return; + + vtkGeometryFilter *gf = vtkGeometryFilter::New(); + gf->SetInput(ac->DataSource); + vtkFeatureEdges *edges = vtkFeatureEdges::New(); + edges->SetInput(gf->GetOutput()); + edges->BoundaryEdgesOn(); + edges->ManifoldEdgesOn(); + + vtkPolyDataMapper *edgeMapper = vtkPolyDataMapper::New(); + edgeMapper->SetInput(edges->GetOutput()); + edgeMapper->ScalarVisibilityOff(); + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* actorList=theRenderer->GetActors(); + + int test=actorList->IsItemPresent(ac->EdgeDevice); + if (test==0) { + vtkProperty* prop = vtkProperty::New(); + prop->SetColor( QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat()/255. ) ; + prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt()); + prop->SetLineWidth( QAD_CONFIG->getSetting("SMESH:SettingsWidth").toInt() ); + ac->EdgeDevice->SetProperty(prop); + ac->SetEdgeColor( QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat()/255. ); + ac->EdgeDevice->SetMapper(edgeMapper); + + theRenderer->AddActor(ac->EdgeDevice); + } else { + ac->EdgeDevice->SetMapper(edgeMapper); + edgeMapper->Update(); + } + + vtkShrinkFilter *shrink = vtkShrinkFilter::New(); + shrink->SetInput(ac->DataSource); + shrink->SetShrinkFactor(ac->GetShrinkFactor()); + vtkGeometryFilter *Shrinkgf = vtkGeometryFilter::New(); + Shrinkgf->SetInput( shrink->GetOutput() ); + vtkFeatureEdges *ShrinkEdges = vtkFeatureEdges::New(); + ShrinkEdges->SetInput(Shrinkgf->GetOutput()); + ShrinkEdges->BoundaryEdgesOn(); + ShrinkEdges->ManifoldEdgesOn(); + + vtkPolyDataMapper *ShrinkEdgeMapper = vtkPolyDataMapper::New(); + ShrinkEdgeMapper->SetInput(ShrinkEdges->GetOutput()); + ShrinkEdgeMapper->ScalarVisibilityOff(); + + test=actorList->IsItemPresent(ac->EdgeShrinkDevice); + if (test==0) { + vtkProperty* prop = vtkProperty::New(); + prop->SetColor( QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat()/255. ) ; + prop->SetPointSize(QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt()); + prop->SetLineWidth( QAD_CONFIG->getSetting("SMESH:SettingsWidth").toInt() ); + ac->EdgeShrinkDevice->SetProperty(prop); + ac->SetEdgeColor( QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen").toFloat()/255., + QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue").toFloat()/255. ); + ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper); + + theRenderer->AddActor(ac->EdgeShrinkDevice); + } else { + ac->EdgeShrinkDevice->SetMapper(ShrinkEdgeMapper); + ShrinkEdgeMapper->Update(); + } + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::InitActor(SMESH::SMESH_Mesh_ptr aMesh) +{ + SALOMEDS::SObject_var aSO_M = myStudyAPI.FindMesh( aMesh ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !aSO_M->_is_nil() ) { + if (aSO_M->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + Standard_Boolean result; + SMESH_Actor* MeshActor = smeshGUI->FindActorByEntry(aSO_M->GetID(), result, true); + if ( !result ) { + SMESH_Actor* amesh = SMESH_Actor::New(); + Handle(SALOME_InteractiveObject) IO = new SALOME_InteractiveObject(aSO_M->GetID(), + "MESH", + aName->Value()); + amesh->setIO( IO ); + amesh->setName( aName->Value() ); + DisplayActor(amesh, false); + } + } + } +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Update() +{ + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { //VTK + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + if ( nbSel == 0 ) { + vtkActorCollection* actorList=theRenderer->GetActors(); + actorList->InitTraversal(); + vtkActor *ac = actorList->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SMESH_Actor") ) { + SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = anActor->getIO(); + Update( IO ); + } + } + ac = actorList->GetNextActor(); + } + } else { + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IO = It.Value(); + Update( IO ); + } + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); + } + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::Update(const Handle(SALOME_InteractiveObject)& IO) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + if ( IO->hasEntry() ) { + Standard_Boolean res; + SMESH::SMESH_Mesh_var aMesh = ConvertIOinMesh( IO, res ); + if ( res ) { + SMESH_Actor* ac = FindActorByEntry( IO->getEntry(), res, false ); + if ( res ) { + // Check whether the actor belongs to the active view + VTKViewer_RenderWindowInteractor* rwInter = + ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + + // The actor belongs to inactive view -> create a copy and display it in the active view + if (!rwInter->isInViewer(IO)) { + SMESH_Actor* acCopy = SMESH_Actor::New(); + acCopy->ShallowCopy(ac); + + smeshGUI->DisplayActor( acCopy, false ); + } + ac = ReadScript( aMesh ); + if ( ac != NULL ) { +#ifdef TRACE + Dump( ac ); +#endif + DisplayActor( ac ); + DisplayEdges( ac ); + smeshGUI->ChangeRepresentation( ac, ac->getDisplayMode() ); + } + } + } + } +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +vtkActor* SMESHGUI::SimulationMoveNode(SMESH_Actor* Mactor, int idnode) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return NULL; + + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( Mactor->DataSource ); + vtkIdList *IdCells = vtkIdList::New(); + ugrid->GetPointCells( idnode, IdCells ); + + vtkPoints *Pts = vtkPoints::New(); + Pts = ugrid->GetPoints(); + + vtkUnstructuredGrid *ugridSimulation = vtkUnstructuredGrid::New(); + ugridSimulation->SetPoints( Pts ); + vtkIdList *IdPts = vtkIdList::New(); + for (int j=0; jGetNumberOfIds(); j++) { + ugrid->GetCellPoints( IdCells->GetId(j), IdPts ); + ugridSimulation->InsertNextCell( ugrid->GetCellType( IdCells->GetId(j) ), IdPts ); + } + + vtkProperty* prop = vtkProperty::New(); + prop->SetColor( 1., 0., 0. ); + prop->SetRepresentationToWireframe(); + + int Edgewidth = (int)Mactor->EdgeDevice->GetProperty()->GetLineWidth(); + if ( Edgewidth == 0 ) + Edgewidth = 1; + prop->SetLineWidth( Edgewidth+1 ); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( ugridSimulation ); + vtkActor* ac = vtkActor::New(); + ac->SetMapper( Mapper ); + ac->SetProperty( prop ); + + ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer(); + ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02); + + mySimulationActors->AddItem( ac ); + theRenderer->AddActor( ac ); + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); + + return ac; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer* theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + + if ( result ) { + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + + vtkPoints *Pts = ugrid->GetPoints(); + vtkPoints *newPts = vtkPoints::New(); + int nbPts = Pts->GetNumberOfPoints(); + for ( int i = 0; i < nbPts; i++ ) { + newPts->InsertPoint(i, Pts->GetPoint(i) ); + } + + newugrid->SetPoints(newPts); + newugrid->GetPoints()->InsertNextPoint( x, y, z ); + + vtkMaskPoints* verts = vtkMaskPoints::New(); + verts->SetInput(newugrid); + verts->SetGenerateVertices(1); + verts->SetOnRatio(1); + + vtkPolyDataMapper* vertMapper = vtkPolyDataMapper::New(); + vertMapper->SetInput( verts->GetOutput() ); + vertMapper->ScalarVisibilityOff(); + + vtkActor* node = vtkActor::New(); + node->SetMapper( vertMapper ); + + QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); + QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); + QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); + QColor nodecolor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + if ( !nodecolor.isValid() ) + nodecolor = QColor(0.,1.,0.); + + node->GetProperty()->SetColor( float(nodecolor.red())/255., + float(nodecolor.green())/255., + float(nodecolor.blue())/255.); + + int intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt(); + if ( intValue < 1 ) + intValue == 1; + + node->GetProperty()->SetPointSize( intValue ); + + node->VisibilityOn(); + + mySimulationActors->AddItem( node ); + theRenderer->AddActor(node); + } + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + float *pt = ac->GetMapper()->GetInput()->GetPoint(idnode); + pt[0] = x; pt[1] = y; pt[2] = z; + + ac->GetMapper()->ImmediateModeRenderingOn(); + ac->GetProperty()->SetRepresentationToWireframe(); + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z) +{ + Standard_Boolean result; + + SMESH_Actor* MeshActor = FindActor(aMesh, result, true); + if ( result ) { + } +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::ScalarVisibilityOff() +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* actorList=theRenderer->GetActors(); + + actorList->InitTraversal(); + vtkActor *ac = actorList->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SMESH_Actor") ) { + SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( ac ); + if ( anActor->GetVisibility() == 1 ) { + vtkDataSetMapper* meshMapper = (vtkDataSetMapper*) (anActor->getMapper()); + meshMapper->ScalarVisibilityOff(); + meshMapper->SetInput( anActor->DataSource ); + ChangeRepresentation( anActor, anActor->getDisplayMode() ); + } + } + ac = actorList->GetNextActor(); + } + + theRenderer->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int idNodes[2]; + int pts[2]; + int i = 0; + vtkIdList *Ids = vtkIdList::New(); + for ( ; ite.More(); ite.Next() ) { + idNodes[i] = ite.Key(); + i++; + } + + Ids->InsertId( 0, idNodes[0] ); + pts[0] = idNodes[0]; + Ids->InsertId( 1, idNodes[1] ); + pts[1] = idNodes[1]; + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + newugrid->SetPoints( ugrid->GetPoints() ) ; + newugrid->InsertNextCell(VTK_LINE, 2, pts); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( newugrid ); + Mapper->Update(); + + vtkActor* edge = vtkActor::New(); + edge->SetMapper( Mapper ); + edge->SetProperty( ac->GetProperty() ); + edge->SetBackfaceProperty( ac->GetBackfaceProperty() ); + edge->VisibilityOn(); + mySimulationActors->AddItem( edge ); + theRenderer->AddActor(edge); + } + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int idNodes[3]; + int pts[3]; + int i = 0; + vtkIdList *Ids = vtkIdList::New(); + for ( ; ite.More(); ite.Next() ) { + idNodes[i] = ite.Key(); + i++; + } + + if ( reverse ) { + Ids->InsertId( 0, idNodes[2] ); + pts[0] = idNodes[2]; + Ids->InsertId( 1, idNodes[1] ); + pts[1] = idNodes[1]; + Ids->InsertId( 2, idNodes[0] ); + pts[2] = idNodes[0]; + } else { + Ids->InsertId( 0, idNodes[0] ); + pts[0] = idNodes[0]; + Ids->InsertId( 1, idNodes[1] ); + pts[1] = idNodes[1]; + Ids->InsertId( 2, idNodes[2] ); + pts[2] = idNodes[2]; + } + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + newugrid->SetPoints( ugrid->GetPoints() ) ; + newugrid->InsertNextCell(VTK_TRIANGLE, 3, pts); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( newugrid ); + Mapper->Update(); + + vtkActor* tri = vtkActor::New(); + tri->SetMapper( Mapper ); + tri->SetProperty( ac->GetProperty() ); + tri->SetBackfaceProperty( ac->GetBackfaceProperty() ); + tri->VisibilityOn(); + mySimulationActors->AddItem( tri ); + theRenderer->AddActor(tri); + } + + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + int idNodes[4]; + vtkIdList *Ids = vtkIdList::New(); + for ( ; ite.More(); ite.Next() ) { + idNodes[i] = ite.Key(); + i++; + } + + float *p0 = ugrid->GetPoint(idNodes[0]); + float *p1 = ugrid->GetPoint(idNodes[1]); + float *p2 = ugrid->GetPoint(idNodes[2]); + float *p3 = ugrid->GetPoint(idNodes[3]); + + gp_Pnt P0(p0[0],p0[1],p0[2]); + + gp_Vec V1( P0, gp_Pnt(p1[0],p1[1],p1[2]) ); + gp_Vec V2( P0, gp_Pnt(p2[0],p2[1],p2[2]) ); + gp_Vec V3( P0, gp_Pnt(p3[0],p3[1],p3[2]) ); + + gp_Vec Cross1 = V1 ^ V2; + gp_Vec Cross2 = V2 ^ V3; + + int tmp; + if ( Cross1.Dot(Cross2) < 0 ) { + V1 = gp_Vec(P0, gp_Pnt(p2[0],p2[1],p2[2]) ); + V2 = gp_Vec(P0, gp_Pnt(p1[0],p1[1],p1[2]) ); + Cross1 = V1 ^ V2; + Cross2 = V2 ^ V3; + + if ( Cross1.Dot(Cross2) < 0 ) { + tmp = idNodes[2]; + idNodes[2] = idNodes[3]; + idNodes[3] = tmp; + } else { + tmp = idNodes[1]; + idNodes[1] = idNodes[2]; + idNodes[2] = tmp; + } + } + + if ( reverse ) { + Ids->InsertId( 0, idNodes[3] ); + Ids->InsertId( 1, idNodes[2] ); + Ids->InsertId( 2, idNodes[1] ); + Ids->InsertId( 3, idNodes[0] ); + } else { + Ids->InsertId( 0, idNodes[0] ); + Ids->InsertId( 1, idNodes[1] ); + Ids->InsertId( 2, idNodes[2] ); + Ids->InsertId( 3, idNodes[3] ); + } + + // vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + newugrid->SetPoints( ugrid->GetPoints() ) ; + newugrid->InsertNextCell(VTK_QUAD, Ids); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( newugrid ); + Mapper->Update(); + + vtkActor* quad = vtkActor::New(); + quad->SetMapper( Mapper ); + quad->SetProperty( ac->GetProperty() ); + quad->SetBackfaceProperty( ac->GetBackfaceProperty() ); + quad->VisibilityOn(); + mySimulationActors->AddItem( quad ); + theRenderer->AddActor(quad); + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + int idNodes[4]; + vtkIdList *Ids = vtkIdList::New(); + for ( ; ite.More(); ite.Next() ) { + idNodes[i] = ite.Key(); + i++; + } + + Ids->InsertId( 0, idNodes[0] ); + Ids->InsertId( 1, idNodes[1] ); + Ids->InsertId( 2, idNodes[2] ); + Ids->InsertId( 3, idNodes[3] ); + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + newugrid->SetPoints( ugrid->GetPoints() ) ; + newugrid->InsertNextCell(VTK_TETRA, Ids); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( newugrid ); + Mapper->Update(); + + vtkActor* tetra = vtkActor::New(); + tetra->SetMapper( Mapper ); + tetra->SetProperty( ac->GetProperty() ); + tetra->SetBackfaceProperty( ac->GetBackfaceProperty() ); + tetra->VisibilityOn(); + mySimulationActors->AddItem( tetra ); + theRenderer->AddActor(tetra); + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors = vtkActorCollection::New(); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + int idNodes[8]; + vtkIdList *Ids = vtkIdList::New(); + for ( ; ite.More(); ite.Next() ) { + idNodes[i] = ite.Key(); + i++; + } + + Ids->InsertId( 0, idNodes[0] ); + Ids->InsertId( 1, idNodes[1] ); + Ids->InsertId( 2, idNodes[2] ); + Ids->InsertId( 3, idNodes[3] ); + Ids->InsertId( 4, idNodes[4] ); + Ids->InsertId( 5, idNodes[5] ); + Ids->InsertId( 6, idNodes[6] ); + Ids->InsertId( 7, idNodes[7] ); + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + vtkUnstructuredGrid* newugrid = vtkUnstructuredGrid::New(); + newugrid->SetPoints( ugrid->GetPoints() ) ; + newugrid->InsertNextCell(VTK_HEXAHEDRON, Ids); + + vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); + Mapper->SetInput( newugrid ); + Mapper->Update(); + + vtkActor* hexa = vtkActor::New(); + hexa->SetMapper( Mapper ); + hexa->SetProperty( ac->GetProperty() ); + hexa->SetBackfaceProperty( ac->GetBackfaceProperty() ); + hexa->VisibilityOn(); + mySimulationActors->AddItem( hexa ); + theRenderer->AddActor(hexa); + } + vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); + renWin->Render(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(MapIndex.Extent()); + + int i = 0; + for ( ; ite.More(); ite.Next() ) { + anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key()); + i++; + } + + int tmp; + if ( MapIndex.Extent() == 4 ) { + int idNodes[4]; + int i = 0; + TColStd_MapIteratorOfMapOfInteger ite1( MapIndex ); + for ( ; ite1.More(); ite1.Next() ) { + idNodes[i] = ite1.Key(); + i++; + } + + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + float *p0 = ugrid->GetPoint(idNodes[0]); + float *p1 = ugrid->GetPoint(idNodes[1]); + float *p2 = ugrid->GetPoint(idNodes[2]); + float *p3 = ugrid->GetPoint(idNodes[3]); + + gp_Pnt P0(p0[0],p0[1],p0[2]); + + gp_Vec V1( P0, gp_Pnt(p1[0],p1[1],p1[2]) ); + gp_Vec V2( P0, gp_Pnt(p2[0],p2[1],p2[2]) ); + gp_Vec V3( P0, gp_Pnt(p3[0],p3[1],p3[2]) ); + + gp_Vec Cross1 = V1 ^ V2; + gp_Vec Cross2 = V2 ^ V3; + + if ( Cross1.Dot(Cross2) < 0 ) { + + V1 = gp_Vec(P0, gp_Pnt(p2[0],p2[1],p2[2]) ); + V2 = gp_Vec(P0, gp_Pnt(p1[0],p1[1],p1[2]) ); + Cross1 = V1 ^ V2; + Cross2 = V2 ^ V3; + + if ( Cross1.Dot(Cross2) < 0 ) { + tmp = anArrayOfIdeces[2]; + anArrayOfIdeces[2] = anArrayOfIdeces[3]; + anArrayOfIdeces[3] = tmp; + } else { + tmp = anArrayOfIdeces[1]; + anArrayOfIdeces[1] = anArrayOfIdeces[2]; + anArrayOfIdeces[2] = tmp; + } + } + } + + // int tmp; + if ( reverse ) { + for (i=0; i < (MapIndex.Extent()/2); i++) { + tmp = anArrayOfIdeces[i]; + anArrayOfIdeces[i] = anArrayOfIdeces[MapIndex.Extent()-i-1]; + anArrayOfIdeces[MapIndex.Extent()-i-1] = tmp; + } + } + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->AddFace(anArrayOfIdeces); + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); + } + } + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(MapIndex.Extent()); + + int i = 0; + for ( ; ite.More(); ite.Next() ) { + anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key()); + i++; + } + + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->AddVolume(anArrayOfIdeces); + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); + } + } + QApplication::restoreOverrideCursor(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length(MapIndex.Extent()); + + int i = 0; + for ( ; ite.More(); ite.Next() ) { + anArrayOfIdeces[i] = ac->GetIdSMESHDSNode(ite.Key()); + i++; + } + + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->AddEdge(anArrayOfIdeces); + } + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); + } + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z) +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + Standard_Boolean result; + SMESH_Actor* ac = FindActor( aMesh, result, true ); + if ( result ) { + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + aMeshEditor->AddNode(x,y,z); + + if ( myAutomaticUpdate ) { + SMESH_Actor* Mesh = smeshGUI->ReadScript(aMesh); + if ( Mesh != NULL ) { + smeshGUI->DisplayActor( Mesh ); + smeshGUI->DisplayEdges( Mesh ); + smeshGUI->ChangeRepresentation( Mesh, Mesh->getDisplayMode() ); + AddActorInSelection( Mesh ); + } + } + } + QApplication::restoreOverrideCursor(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +void SMESHGUI::DisplayEdgesConnectivityLegendBox(vtkActor *ac) +{ + if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return; + + EraseSimulationActors(); + mySimulationActors2D = vtkActor2DCollection::New(); + + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + vtkGlyphSource2D *gs2 = vtkGlyphSource2D::New(); + gs2->SetGlyphTypeToTriangle(); + gs2->FilledOff(); + + vtkLegendBoxActor *legend = vtkLegendBoxActor::New(); + legend->GetPositionCoordinate()->SetValue(0.025, 0.025, 0.); + legend->GetPosition2Coordinate()->SetValue(0.3, 0.3, 0.); //relative to Position + + legend->SetNumberOfEntries(4); + legend->SetEntryString( 0, tr( "SMESH_BOUNDARYEDGES" ) ); + legend->SetEntrySymbol( 0, gs2->GetOutput() ); + legend->SetEntryColor(0, ac->GetMapper()->GetLookupTable()->GetColor(0.) ); + legend->SetEntryString( 1, tr( "SMESH_MANIFOLDEDGES" ) ); + legend->SetEntrySymbol( 1, gs2->GetOutput() ); + legend->SetEntryColor(1, ac->GetMapper()->GetLookupTable()->GetColor(0.666667) ); + legend->SetEntryString( 2, tr( "SMESH_NONMANIFOLDEDGES" ) ); + legend->SetEntrySymbol( 2, gs2->GetOutput() ); + legend->SetEntryColor(2, ac->GetMapper()->GetLookupTable()->GetColor(0.222222) ); + legend->SetEntryString( 3, tr( "SMESH_FEATUREEDGES" ) ); + legend->SetEntrySymbol( 3, gs2->GetOutput() ); + legend->SetEntryColor(3, ac->GetMapper()->GetLookupTable()->GetColor(0.444444) ); + legend->SetPadding( 5 ); + // legend->GetProperty()->SetColor(); + + mySimulationActors2D->AddItem( legend ); + theRenderer->AddActor2D( legend ); + + // Update the view + myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Repaint(); +} + +//=============================================================================== +// function : OnEditDelete() +// purpose : +//=============================================================================== +void SMESHGUI::OnEditDelete() +{ + if ( QAD_MessageBox::warn2 + ( QAD_Application::getDesktop(), + tr ("SMESH_WRN_WARNING"), + tr ("SMESH_REALLY_DELETE"), + tr ("SMESH_BUT_YES"), tr ("SMESH_BUT_NO"), 1, 0, 0 ) != 1 ) + return; + + int nbSf = myActiveStudy->getStudyFramesCount(); + + Standard_Boolean found; + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if ( IObject->hasEntry() ) { + SALOMEDS::SObject_var SO = myStudy->FindObjectID( IObject->getEntry() ); + + /* Erase child graphical objects */ + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var CSO= it->Value(); + if (CSO->FindAttribute(anAttr, "AttributeIOR") ) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + SMESH_Actor* ac = smeshGUI->FindActorByEntry( CSO->GetID(), found, false ); + if ( found ) { + Renderer->RemoveActor(ac->EdgeDevice); + Renderer->RemoveActor(ac->EdgeShrinkDevice); + Renderer->RemoveActor(ac); + } + } + } + } + } + + /* Erase main graphical object */ + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)smeshGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRWInteractor(); + SMESH_Actor* ac = smeshGUI->FindActorByEntry( IObject->getEntry(), found, false ); + if (found) { + Renderer->RemoveActor(ac->EdgeDevice); + Renderer->RemoveActor(ac->EdgeShrinkDevice); + } + myRenderInter->Remove( IObject ); + } + } + + /* Erase objects in Study */ + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IObject->getEntry() ); + if ( !obj->_is_nil() ) { + QAD_Operation* op = new SALOMEGUI_ImportOperation( myActiveStudy ); + op->start(); + aStudyBuilder->RemoveObject(obj); + op->finish(); + } + + } /* IObject->hasEntry() */ + } /* more/next */ + + /* Clear any previous selection */ + Sel->ClearIObjects() ; + myActiveStudy->updateObjBrowser(); +} diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h new file mode 100644 index 000000000..29ffb9702 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI.h @@ -0,0 +1,297 @@ +// File : SMESHGUI.h +// Created : Sun May 05 11:45:40 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SMESHGUI_HeaderFile +#define SMESHGUI_HeaderFile + +#include "TColStd_MapOfInteger.hxx" + +#include "SMESHDS_Document.hxx" + +// SALOME Includes +#include "QAD_Desktop.h" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" + +#include "SMESH_Actor.h" + +#include "SMESHGUI_StudyAPI.h" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// QT Includes +#include + +// VTK Inlcudes +#include + +//================================================================================= +// class : SMESHGUI +// purpose : +//================================================================================= +class SMESHGUI : public QObject +{ + Q_OBJECT + +private : + + QAD_Desktop* myDesktop; + QAD_Study* myActiveStudy; + SMESH::SMESH_Gen_var myComponentMesh; + GEOM::GEOM_Gen_var myComponentGeom; + + QDialog* myActiveDialogBox; + int myNbMesh ; + int myState ; + + vtkActorCollection* mySimulationActors; + vtkActor2DCollection* mySimulationActors2D; + + SMESH_Actor* myCurrentMesh; + + SALOMEDS::Study_var myStudy; + int myStudyId; + + SMESHGUI_StudyAPI myStudyAPI; + + // vtkScalarBarActor* myScalarBar; + + Handle_SMESHDS_Document myDocument;//NBU + + bool myAutomaticUpdate; + +public : + + SMESHGUI(); + ~SMESHGUI(); + + static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop ); + static SMESHGUI* GetSMESHGUI() ; + + QAD_Study* GetActiveStudy() ; + QAD_Desktop* GetDesktop() ; + SALOMEDS::Study_ptr GetStudy(); + SMESHGUI_StudyAPI GetStudyAPI(); + + vtkScalarBarActor* GetScalarBar(); + + QDialog* GetActiveDialogBox() ; + void SetActiveDialogBox(QDialog* aDlg) ; + + void SetState(int aState) ; + void ResetState() ; + bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; + + + /* Managed by IAPP */ + Standard_EXPORT static bool OnGUIEvent ( int theCommandID, QAD_Desktop* parent) ; + Standard_EXPORT static bool OnMousePress ( QMouseEvent* pe, QAD_Desktop* parent, + QAD_StudyFrame* studyFrame ); + Standard_EXPORT static bool OnMouseMove ( QMouseEvent* pe, QAD_Desktop* parent, + QAD_StudyFrame* studyFrame ); + Standard_EXPORT static bool OnKeyPress ( QKeyEvent* pe, QAD_Desktop* parent, + QAD_StudyFrame* studyFrame ); + Standard_EXPORT static void activeStudyChanged ( QAD_Desktop* parent ); + Standard_EXPORT static bool SetSettings ( QAD_Desktop* parent ); + Standard_EXPORT static void DefinePopup( QString & theContext, + QString & theParent, + QString & theObject ); + Standard_EXPORT static bool CustomPopup ( QAD_Desktop* parent, + QPopupMenu* popup, + const QString& theContext, + const QString& theParent, + const QString& theObject ); + Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + + void OnEditDelete(); + + /* Mesh Management */ + SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh ); + SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh ); + + /* Hypothesis Management */ + SMESH::SMESH_Hypothesis_ptr CreateHypothesis( QString TypeHypothesis, QString NameHypothesis ); + void AddHypothesisOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ; + void AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ) ; + + void RemoveHypothesisOrAlgorithmOnMesh( const Handle(SALOME_InteractiveObject)& IObject ) ; + void RemoveHypothesisOrAlgorithmOnMesh( SALOMEDS::SObject_ptr MorSM, SMESH::SMESH_Hypothesis_ptr anHyp ) ; + + void CreateLocalLength( QString TypeHypothesis, QString NameHypothesis, double Length ); + void CreateNbSegments( QString TypeHypothesis, QString NameHypothesis, double nbSegments ); + void CreateMaxElementArea( QString TypeHypothesis, QString NameHypothesis, double MaxArea ); + void CreateMaxElementVolume( QString TypeHypothesis, QString NameHypothesis, double MaxVolume ); + + /* Algorithms Management */ + void AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp ); + void AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp ); + void CreateAlgorithm( QString TypeAlgo, QString NameAlgo ); + + /* NODES */ + void ViewNodes(); + vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode); + void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z); + void AddNode(SMESH_Actor*, int idnode, float x, float y, float z) ; + void AddNodes( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + + void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z); + void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z); + + void RemoveNode(SMESH_Actor*, int idnode) ; + void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ; + void RemoveNodes(SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + + /* EDGES */ + void AddEdge(SMESH_Actor*, int idedge, int idnode1, int idnode2) ; + void AddEdges( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void DisplayEdges(SMESH_Actor* ac, bool visibility = true); + void DisplayEdgesConnectivityLegendBox(vtkActor *ac); + void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); + + /* TRIANGLES */ + void AddTriangle(SMESH_Actor*, int idtri, int idnode1, int idnode2, int idnode3) ; + void AddTriangles( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); + + /* QUADRANGLES */ + void AddQuadrangle(SMESH_Actor*, int idquad, int idnode1, int idnode2, + int idnode3, int idnode4) ; + void AddQuadrangles( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); + + /* VOLUMES */ + void AddTetra(SMESH_Actor*, int idtetra, int idnode1, int idnode2, + int idnode3, int idnode4) ; + void AddHexaedre(SMESH_Actor*, int idhexa, int idnode1, int idnode2, + int idnode3, int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) ; + void AddTetras( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void AddHexaedres( SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); + void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); + + /* ELEMENTS */ + void RemoveElement(SMESH_Actor*, int idnode); + void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ; + void RemoveElements(SMESH_Actor* Mactor, int number, + const SMESH::double_array& coords, const SMESH::long_array& indexes); + void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex); + void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex); + + void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); + void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); + void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); + void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z); + + /* Simulation management */ + void EraseSimulationActors() ; + + /* Non modal dialog boxes magement */ + void EmitSignalDeactivateDialog() ; + void EmitSignalCloseAllDialogs() ; + + /* Selection management */ + int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ; + int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ; + int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ; + int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ; + + SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult ) ; + + SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ; + SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ; + + /* Geometry Client */ + GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, + Standard_Boolean& testResult ) ; + + /* Popup management */ + QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO); + QString CheckHomogeneousSelection(); + + /* Scripts management */ + SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh); + + /* Actors management */ + void Dump(SMESH_Actor* Mactor); + + void SetViewMode(int commandId); + void ChangeRepresentation( SMESH_Actor* ac, int type ); + + SMESH_Actor* FindActor(SMESH::SMESH_Mesh_ptr aMesh, + Standard_Boolean& testResult, + bool onlyInActiveView); + SMESH_Actor* FindActorByEntry(QString entry, + Standard_Boolean& testResult, + bool onlyInActiveView); + + void InitActor(SMESH::SMESH_Mesh_ptr aMesh); + void DisplayActor(SMESH_Actor* ac, bool visibility = true); + void EraseActor(SMESH_Actor* ac); + bool AddActorInSelection(SMESH_Actor* ac); + + void UpdateView(); + + void Update(); + void Update(const Handle(SALOME_InteractiveObject)& IO); + + void ScalarVisibilityOff(); + + + /* Settings management */ + void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar, + QString Bold, QString Italic, QString Shadow, QString Font, + QString Orientation, float Width, float Height, + int NbColors, int NbLabels); + void DisplayScalarBar(bool visibility); + void UpdateScalarBar(float MinRange, float MaxRange); + + void SetDisplaySettings(); + + SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; + + /* Control management */ + void Control(int theCommandID); + + /* Parameter functions */ + double Parameter( Standard_Boolean& res, const double aValue, + const char* aLabel, const char* aTitle, + const double bottom, const double top, const int decimals ) ; + int Parameter( Standard_Boolean& res, const int aValue, + const char* aLabel, const char* aTitle, + const int bottom, const int top ) ; + + static void setOrb(); + + /* Import/Export */ //NBU + static void Import_Document(QAD_Desktop* parent, int theCommandID); + static void Export_Document(QAD_Desktop* parent, int theCommandID); + static void Import_Mesh(QAD_Desktop* parent, int theCommandID); + static void Export_Mesh(QAD_Desktop* parent, int theCommandID); + +signals: + void SignalDeactivateActiveDialog() ; + void SignalCloseAllDialogs() ; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx new file mode 100644 index 000000000..cc8a93076 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx @@ -0,0 +1,448 @@ +using namespace std; +// File : SMESHGUI_AddAlgorithmDlg.cxx +// Created : Wed May 22 19:05:31 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESHGUI +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_AddAlgorithmDlg.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddAlgorithmDlg() +// purpose : Constructs a SMESHGUI_AddAlgorithmDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_AddAlgorithmDlg::SMESHGUI_AddAlgorithmDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_ALGORITHM"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddAlgorithmDlg" ); + resize( 322, 220 ); + setCaption( tr( "SMESH_ADD_ALGORITHM_TITLE" ) ); + setSizeGripEnabled( TRUE ); + + SMESHGUI_AddAlgorithmDlgLayout = new QGridLayout( this ); + SMESHGUI_AddAlgorithmDlgLayout->setSpacing( 6 ); + SMESHGUI_AddAlgorithmDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_ADD_ALGORITHM" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" ); + LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 ); + LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 ); + SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" ); + SelectButtonC1A1Hyp->setText( tr( "" ) ); + SelectButtonC1A1Hyp->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 ); + SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" ); + SelectButtonC1A2Mesh->setText( tr( "" ) ); + SelectButtonC1A2Mesh->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 ); + TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" ); + TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) ); + TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 ); + TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" ); + TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_ALGORITHM" ) ); + TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 ); + SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_1, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /* Initialisation */ + Init( Sel ) ; +} + + +//================================================================================= +// function : ~SMESHGUI_AddAlgorithmDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddAlgorithmDlg::~SMESHGUI_AddAlgorithmDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ + this->destroy(TRUE, TRUE) ; +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel ; + myConstructorId = 0 ; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + GroupConstructor1->show(); + myConstructorId = 0 ; + myEditCurrentArgument = LineEditC1A1Hyp ; + Constructor1->setChecked( TRUE ); + myOkMesh = myOkSubMesh = myOkAlgorithm = false ; + + myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); + myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::ConstructorsClicked(int constructorId) +{ + switch (constructorId) + { + case 0: + { + GroupConstructor1->show(); + myConstructorId = constructorId ; + myEditCurrentArgument = LineEditC1A1Hyp ; + LineEditC1A2Mesh->setText(tr("")) ; + Constructor1->setChecked( TRUE ); + myOkMesh = myOkSubMesh = myOkAlgorithm = false ; + break; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkMesh && myOkAlgorithm ) { + SALOME_ListIteratorOfListIO It( AlgoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ; + } + } else if ( myOkSubMesh && myOkAlgorithm ) { + SALOME_ListIteratorOfListIO It( AlgoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ; + } + } + break ; + } + } +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + if ( myEditCurrentArgument == LineEditC1A2Mesh ) { + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); + QString aName = IObject->getName(); + Standard_Boolean testResult; + myOkMesh = true ; + myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ; + if( !testResult ) { + myOkMesh = false; + myOkSubMesh = true; + mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ; + if( !testResult ) { + myOkSubMesh = false; + return ; + } + } + LineEditC1A2Mesh->setText(aString) ; + } + else { + myOkMesh = myOkSubMesh = false ; + return ; + } + } + else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + if ( nbSel >= 1 ) { + AlgoList.Clear(); // = mySelection->StoredIObjects() ; + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + AlgoList.Append(Itinit.Value()); + } + myOkAlgorithm = true ; + if (nbSel > 1) + aString = tr("%1 Algorithms").arg(nbSel) ; + LineEditC1A1Hyp->setText(aString) ; + } + else { + myOkAlgorithm = false ; + return ; + } + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if( send == SelectButtonC1A1Hyp ) { + LineEditC1A1Hyp->setFocus() ; + myEditCurrentArgument = LineEditC1A1Hyp ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myAlgorithmFilter) ; + } + else if(send == SelectButtonC1A2Mesh) { + LineEditC1A2Mesh->setFocus() ; + myEditCurrentArgument = LineEditC1A2Mesh; + mySelection->ClearFilters() ; + mySelection->AddFilter(myMeshOrSubMeshFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::LineEditReturnPressed() +{ + + return ; +} + + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + } + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::enterEvent( QEvent * ) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddAlgorithmDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate any active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h new file mode 100644 index 000000000..f82300f0a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h @@ -0,0 +1,112 @@ +// File : SMESHGUI_AddAlgorithmDlg.h +// Created : Wed May 22 19:05:13 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESHGUI +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ADD_ALGORITHM_H +#define DIALOGBOX_ADD_ALGORITHM_H + +#include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" +#include "SALOME_ListIO.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) + +// QT Includes +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_AddAlgorithmDlg +// purpose : +//================================================================================= +class SMESHGUI_AddAlgorithmDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddAlgorithmDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddAlgorithmDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESH::SMESH_Gen_var myCompMesh ; + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + SMESH::SMESH_Hypothesis_var myAlgorithm; + + Handle(SMESH_TypeFilter) myAlgorithmFilter; + Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + + bool myOkMesh ; + bool myOkSubMesh ; + bool myOkAlgorithm; + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SALOME_ListIO AlgoList; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1Hyp; + QLineEdit* LineEditC1A2Mesh; + QPushButton* SelectButtonC1A1Hyp; + QPushButton* SelectButtonC1A2Mesh; + QLabel* TextLabelC1A2Mesh; + QLabel* TextLabelC1A1Hyp; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_AddAlgorithmDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructor1Layout; +}; + +#endif // DIALOGBOX_ADD_ALGORITHM_H diff --git a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx b/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx new file mode 100644 index 000000000..f2fe8f5c0 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx @@ -0,0 +1,370 @@ +using namespace std; +// File : SMESHGUI_AddEdgeDlg.cxx +// Created : Wed Jun 26 21:00:14 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_AddEdgeDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddEdgeDlg() +// purpose : +//================================================================================= +SMESHGUI_AddEdgeDlg::SMESHGUI_AddEdgeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myNodes = 2; + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_LINE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddEdgeDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_ADD_EDGE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_AddEdgeDlgLayout = new QGridLayout( this ); + SMESHGUI_AddEdgeDlgLayout->setSpacing( 6 ); + SMESHGUI_AddEdgeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_EDGE" ) ); + + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_AddEdgeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddEdgeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ADD_EDGE" ) ); + + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + SMESHGUI_AddEdgeDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_AddEdgeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddEdgeDlg::~SMESHGUI_AddEdgeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkNodes = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddEdgeDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkNodes) { + mySMESHGUI->EraseSimulationActors(); + mySMESHGUI->AddEdge( myMesh, myMapIndex ) ; + mySMESHGUI->ViewNodes(); + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_AddEdgeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkNodes = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes < 1) + return ; + + if ( mySelection->SelectionMode() != 1 ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + + if ( myNodes == 2 && nbNodes == 2 ) { + mySMESHGUI->DisplaySimulationEdge(myMesh, myMapIndex); + myOkNodes = true ; + } else { + // mySMESHGUI->EraseSimulationActors(); + myOkNodes = false ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->EraseSimulationActors() ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddEdgeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + diff --git a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.h b/src/SMESHGUI/SMESHGUI_AddEdgeDlg.h new file mode 100644 index 000000000..aa82b6d94 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddEdgeDlg.h @@ -0,0 +1,97 @@ +// File : SMESHGUI_AddEdgeDlg.h +// Created : Wed Jun 26 21:00:41 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ADD_EDGE_H +#define DIALOGBOX_ADD_EDGE_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_AddEdgeDlg +// purpose : +//================================================================================= +class SMESHGUI_AddEdgeDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddEdgeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddEdgeDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + + int myNodes ; + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_AddEdgeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ADD_EDGE_H diff --git a/src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx b/src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx new file mode 100644 index 000000000..f870c2765 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx @@ -0,0 +1,414 @@ +using namespace std; +// File : SMESHGUI_AddFaceDlg.cxx +// Created : Wed Jun 26 21:00:14 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_AddFaceDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddFaceDlg() +// purpose : +//================================================================================= +SMESHGUI_AddFaceDlg::SMESHGUI_AddFaceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + int nbNodes, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myNodes = nbNodes; + QPixmap image0; + if ( myNodes == 3 ) + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_TRIANGLE"))); + else if ( myNodes == 4 ) + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_QUADRANGLE"))); + + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddFaceDlg" ); + resize( 303, 185 ); + if ( myNodes == 3 ) + setCaption( tr( "SMESH_ADD_TRIANGLE_TITLE" ) ); + else if ( myNodes == 4 ) + setCaption( tr( "SMESH_ADD_QUADRANGLE_TITLE" ) ); + + setSizeGripEnabled( TRUE ); + SMESHGUI_AddFaceDlgLayout = new QGridLayout( this ); + SMESHGUI_AddFaceDlgLayout->setSpacing( 6 ); + SMESHGUI_AddFaceDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + if ( myNodes == 3 ) + GroupConstructors->setTitle( tr( "SMESH_TRIANGLE" ) ); + else if ( myNodes == 4 ) + GroupConstructors->setTitle( tr( "SMESH_QUADRANGLE" ) ); + + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_AddFaceDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddFaceDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + if ( myNodes == 3 ) + GroupC1->setTitle( tr( "SMESH_ADD_TRIANGLE" ) ); + else if ( myNodes == 4 ) + GroupC1->setTitle( tr( "SMESH_ADD_QUADRANGLE" ) ); + + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + Reverse = new QCheckBox( GroupC1, "Reverse" ); + Reverse->setText( tr( "SMESH_REVERSE" ) ); + GroupC1Layout->addWidget( Reverse, 1, 0 ); + + SMESHGUI_AddFaceDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_AddFaceDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddFaceDlg::~SMESHGUI_AddFaceDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkNodes = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + + reverse = false; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddFaceDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkNodes) { + mySMESHGUI->EraseSimulationActors(); + mySMESHGUI->AddFace( myMesh, myMapIndex, reverse ) ; + mySMESHGUI->ViewNodes(); + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_AddFaceDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkNodes = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes < 1) + return ; + + if ( mySelection->SelectionMode() != 1 ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex ); + + if ( myNodes == 3 && nbNodes == 3 ) { + mySMESHGUI->DisplaySimulationTriangle(myMesh, myMapIndex, reverse); + myOkNodes = true ; + } else if ( myNodes == 4 && nbNodes == 4 ) { + mySMESHGUI->DisplaySimulationQuadrangle(myMesh, myMapIndex, reverse); + myOkNodes = true ; + } else { + // mySMESHGUI->EraseSimulationActors(); + myOkNodes = false ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->EraseSimulationActors() ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddFaceDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +void SMESHGUI_AddFaceDlg::CheckBox( int state ) +{ + if( Reverse->isOn() ) reverse = true; + else reverse = false; + + if ( myOkNodes == false ) + return; + + if ( state >= 0 ) { + mySMESHGUI->EraseSimulationActors(); + if ( myNodes == 3 ) + mySMESHGUI->DisplaySimulationTriangle( myMesh, myMapIndex, reverse); + else if ( myNodes == 4 ) { + mySMESHGUI->DisplaySimulationQuadrangle( myMesh, myMapIndex, reverse); + } + } +} diff --git a/src/SMESHGUI/SMESHGUI_AddFaceDlg.h b/src/SMESHGUI/SMESHGUI_AddFaceDlg.h new file mode 100644 index 000000000..d99bf7729 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddFaceDlg.h @@ -0,0 +1,102 @@ +// File : SMESHGUI_AddFaceDlg.h +// Created : Wed Jun 26 21:00:41 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ADD_FACE_H +#define DIALOGBOX_ADD_FACE_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_AddFaceDlg +// purpose : +//================================================================================= +class SMESHGUI_AddFaceDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddFaceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, + int nbNode = 3, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddFaceDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + + int myNodes ; + bool reverse ; + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + + QCheckBox* Reverse; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void CheckBox( int ); + +protected: + QGridLayout* SMESHGUI_AddFaceDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ADD_FACE_H diff --git a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx new file mode 100644 index 000000000..a11d1ad51 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx @@ -0,0 +1,449 @@ +using namespace std; +// File : SMESHGUI_AddHypothesisDlg.cxx +// Created : Wed May 22 19:05:31 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESHGUI +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_AddHypothesisDlg.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddHypothesisDlg() +// purpose : Constructs a SMESHGUI_AddHypothesisDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_AddHypothesisDlg::SMESHGUI_AddHypothesisDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_HYPOTHESIS"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddHypothesisDlg" ); + resize( 322, 220 ); + setCaption( tr( "SMESH_ADD_HYPOTHESIS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + + SMESHGUI_AddHypothesisDlgLayout = new QGridLayout( this ); + SMESHGUI_AddHypothesisDlgLayout->setSpacing( 6 ); + SMESHGUI_AddHypothesisDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_ADD_HYPOTHESIS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); + GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupConstructor1->setColumnLayout(0, Qt::Vertical ); + GroupConstructor1->layout()->setSpacing( 0 ); + GroupConstructor1->layout()->setMargin( 0 ); + GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); + GroupConstructor1Layout->setAlignment( Qt::AlignTop ); + GroupConstructor1Layout->setSpacing( 6 ); + GroupConstructor1Layout->setMargin( 11 ); + LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" ); + LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 ); + LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); + GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 ); + SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" ); + SelectButtonC1A1Hyp->setText( tr( "" ) ); + SelectButtonC1A1Hyp->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 ); + SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" ); + SelectButtonC1A2Mesh->setText( tr( "" ) ); + SelectButtonC1A2Mesh->setPixmap( image1 ); + GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 ); + TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" ); + TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) ); + TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 ); + TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" ); + TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) ); + TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); + GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 ); + SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructor1, 1, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_1, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /* Initialisation */ + Init( Sel ) ; +} + + +//================================================================================= +// function : ~SMESHGUI_AddHypothesisDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddHypothesisDlg::~SMESHGUI_AddHypothesisDlg() +{ + /* no need to delete child widgets, Qt does it all for us */ + this->destroy(TRUE, TRUE) ; +} + + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel ; + myConstructorId = 0 ; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + GroupConstructor1->show(); + myConstructorId = 0 ; + myEditCurrentArgument = LineEditC1A1Hyp ; + Constructor1->setChecked( TRUE ); + myOkMesh = myOkSubMesh = myOkHypothesis = false ; + + myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); + myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddHypothesisDlg::ConstructorsClicked(int constructorId) +{ + switch (constructorId) + { + case 0: + { + GroupConstructor1->show(); + myConstructorId = constructorId ; + myEditCurrentArgument = LineEditC1A1Hyp ; + LineEditC1A2Mesh->setText(tr("")) ; + Constructor1->setChecked( TRUE ); + myOkMesh = myOkSubMesh = myOkHypothesis = false ; + break; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkMesh && myOkHypothesis ) { + SALOME_ListIteratorOfListIO It( HypoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ; + } + } else if( myOkSubMesh && myOkHypothesis ) { + SALOME_ListIteratorOfListIO It( HypoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ; + } + } + break ; + } + } +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void SMESHGUI_AddHypothesisDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + if ( myEditCurrentArgument == LineEditC1A2Mesh ) { + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); + QString aName = IObject->getName(); + Standard_Boolean testResult; + myOkMesh = true ; + myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ; + if( !testResult ) { + myOkMesh = false; + myOkSubMesh = true; + mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ; + if( !testResult ) { + myOkSubMesh = false; + return ; + } + } + LineEditC1A2Mesh->setText(aString) ; + } + else { + myOkMesh = myOkSubMesh = false ; + return ; + } + } + else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + if ( nbSel >= 1 ) { + HypoList.Clear(); // = mySelection->StoredIObjects() ; + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + HypoList.Append(Itinit.Value()); + } + myOkHypothesis = true ; + if (nbSel > 1) + aString = tr("%1 Hypothesis").arg(nbSel) ; + LineEditC1A1Hyp->setText(aString) ; + } + else { + myOkHypothesis = false ; + return ; + } + } + + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if( send == SelectButtonC1A1Hyp ) { + myEditCurrentArgument = LineEditC1A1Hyp ; + LineEditC1A1Hyp->setFocus() ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myHypothesisFilter) ; + } + else if(send == SelectButtonC1A2Mesh) { + myEditCurrentArgument = LineEditC1A2Mesh; + LineEditC1A2Mesh->setFocus() ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myMeshOrSubMeshFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + + + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::LineEditReturnPressed() +{ + + return ; +} + + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + + GroupConstructors->setEnabled(false) ; + GroupConstructor1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + disconnect( mySelection, 0, this, 0 ); + } + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void SMESHGUI_AddHypothesisDlg::enterEvent( QEvent * ) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddHypothesisDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate any active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupConstructor1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h new file mode 100644 index 000000000..b12103593 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h @@ -0,0 +1,114 @@ +// File : SMESHGUI_AddHypothesisDlg.h +// Created : Wed May 22 19:05:13 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESHGUI +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ADD_HYPOTHESIS_H +#define DIALOGBOX_ADD_HYPOTHESIS_H + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" +#include "SMESH_TypeFilter.hxx" +#include "SALOME_ListIO.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) + +// QT Includes +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_AddHypothesisDlg +// purpose : +//================================================================================= +class SMESHGUI_AddHypothesisDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddHypothesisDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddHypothesisDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESH::SMESH_Gen_var myCompMesh ; + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + + SMESH::SMESH_Hypothesis_var myHypothesis; + + Handle(SMESH_TypeFilter) myHypothesisFilter; + Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + + bool myOkMesh ; + bool myOkSubMesh ; + bool myOkHypothesis; + + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SALOME_ListIO HypoList; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + + QGroupBox* GroupConstructor1; + QLineEdit* LineEditC1A1Hyp; + QLineEdit* LineEditC1A2Mesh; + QPushButton* SelectButtonC1A1Hyp; + QPushButton* SelectButtonC1A2Mesh; + QLabel* TextLabelC1A2Mesh; + QLabel* TextLabelC1A1Hyp; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void LineEditReturnPressed() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_AddHypothesisDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructor1Layout; +}; + +#endif // DIALOGBOX_ADD_HYPOTHESIS_H diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx new file mode 100644 index 000000000..ea806f0ab --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -0,0 +1,516 @@ +using namespace std; +// File : SMESHGUI_AddSubMeshDlg.cxx +// Created : Mon May 27 10:20:11 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_AddSubMeshDlg.h" +#include "SMESHGUI.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddSubMeshDlg() +// purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_ADD_SUBMESH"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + if ( !name ) + setName( "SMESHGUI_AddSubMeshDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_ADD_SUBMESH" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_AddSubMeshDlgLayout = new QGridLayout( this ); + SMESHGUI_AddSubMeshDlgLayout->setSpacing( 6 ); + SMESHGUI_AddSubMeshDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_SUBMESH" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image1 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESH" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image0 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); + TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); + SelectButtonC1A2->setText( tr( "" ) ); + SelectButtonC1A2->setPixmap( image0 ); + SelectButtonC1A2->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" ); + TextLabel_NameMesh->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameMesh, 2, 0 ); + LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" ); + GroupC1Layout->addWidget( LineEdit_NameMesh, 2, 2 ); + + TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" ); + TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) ); + TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1Hyp, 3, 0 ); + SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" ); + SelectButtonC1A1Hyp->setText( tr( "" ) ); + SelectButtonC1A1Hyp->setPixmap( image0 ); + GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 ); + LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 ); + + TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" ); + TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) ); + TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Algo->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1Algo, 4, 0 ); + SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" ); + SelectButtonC1A1Algo->setText( tr( "" ) ); + SelectButtonC1A1Algo->setPixmap( image0 ); + GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 ); + LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); + LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 ); + + SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + + Init(Sel) ; +} + + +//================================================================================= +// function : ~SMESHGUI_AddSubMeshDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddSubMeshDlg::~SMESHGUI_AddSubMeshDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::Init( SALOME_Selection* Sel ) +{ + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myGeomFilter = new SALOME_TypeFilter( "GEOM" ); + myMeshFilter = new SMESH_TypeFilter( MESH ); + + myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); + myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); + + myNameSubMesh = "SubMesh"; + + myGeomShape = GEOM::GEOM_Shape::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddSubMeshDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if ( !myNameSubMesh.isEmpty() && !myNameSubMesh.isNull() && + !myGeomShape->_is_nil() && !myMesh->_is_nil()) { + mySubMesh = mySMESHGUI->AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ; + } + + if( myOkHypothesis && !mySubMesh->_is_nil() ) { + SALOME_ListIteratorOfListIO It( HypoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ; + } + } + + if( myOkAlgorithm && !mySubMesh->_is_nil() ) { + SALOME_ListIteratorOfListIO It( AlgoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ; + } + } + + break ; + } + } +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySelection->ClearFilters() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + switch (myConstructorId) + { + case 0: + { + if ( myEditCurrentArgument == LineEditC1A1 ) { + if ( nbSel != 1 ) { + myOkHypothesis = false; + myOkAlgorithm = false; + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ; + if( !testResult ) { + myMesh = SMESH::SMESH_Mesh::_nil(); + return ; + } + } + } else if ( myEditCurrentArgument == LineEditC1A2 ) { + if ( nbSel != 1 ) { + myOkHypothesis = false; + myOkAlgorithm = false; + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) { + myGeomShape = GEOM::GEOM_Shape::_nil(); + return ; + } + } + } else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + if ( nbSel >= 1 ) { + HypoList.Clear(); + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + HypoList.Append(Itinit.Value()); + } + myOkHypothesis = true ; + if (nbSel > 1) + aString = tr("%1 Hypothesis").arg(nbSel) ; + LineEditC1A1Hyp->setText(aString) ; + } + else { + myOkHypothesis = false ; + return ; + } + } else if ( myEditCurrentArgument == LineEditC1A1Algo ) { + if ( nbSel >= 1 ) { + AlgoList.Clear(); + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + AlgoList.Append(Itinit.Value()); + } + myOkAlgorithm = true ; + if (nbSel > 1) + aString = tr("%1 Algorithms").arg(nbSel) ; + LineEditC1A1Algo->setText(aString) ; + } + else { + myOkAlgorithm = false ; + return ; + } + } + break; + } + } + + myEditCurrentArgument->setText(aString) ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->ClearFilters() ; + mySelection->AddFilter(myMeshFilter) ; + } else if (send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2; + mySelection->ClearFilters() ; + mySelection->AddFilter(myGeomFilter) ; + } else if( send == SelectButtonC1A1Hyp ) { + LineEditC1A1Hyp->setFocus() ; + myEditCurrentArgument = LineEditC1A1Hyp ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myHypothesisFilter) ; + } else if( send == SelectButtonC1A1Algo ) { + LineEditC1A1Algo->setFocus() ; + myEditCurrentArgument = LineEditC1A1Algo ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myAlgorithmFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_AddSubMeshDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameMesh) { + myNameSubMesh = newText; + } + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h new file mode 100644 index 000000000..fc6eaf27d --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h @@ -0,0 +1,126 @@ +// File : SMESHGUI_AddSubMeshDlg.h +// Created : Mon May 27 10:23:17 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_ADD_SUBMESH_H +#define DIALOGBOX_ADD_SUBMESH_H + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" +#include "SMESH_TypeFilter.hxx" + +// QT Includes +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_AddSubMeshDlg +// purpose : +//================================================================================= +class SMESHGUI_AddSubMeshDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddSubMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddSubMeshDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + + GEOM::GEOM_Shape_var myGeomShape ; + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + + QString myNameSubMesh ; + + Handle(SALOME_TypeFilter) myGeomFilter; + Handle(SMESH_TypeFilter) myMeshFilter; + Handle(SMESH_TypeFilter) myHypothesisFilter; + Handle(SMESH_TypeFilter) myAlgorithmFilter; + + SALOME_ListIO HypoList; + SALOME_ListIO AlgoList; + + bool myOkHypothesis; + bool myOkAlgorithm; + + SMESH::SMESH_Hypothesis_var myHypothesis; + SMESH::SMESH_Hypothesis_var myAlgorithm; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabel_NameMesh ; + QLineEdit* LineEdit_NameMesh ; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + QLabel* TextLabelC1A2; + QPushButton* SelectButtonC1A2; + QLineEdit* LineEditC1A2; + + QLabel* TextLabelC1A1Hyp; + QPushButton* SelectButtonC1A1Hyp; + QLineEdit* LineEditC1A1Hyp; + + QLabel* TextLabelC1A1Algo; + QPushButton* SelectButtonC1A1Algo; + QLineEdit* LineEditC1A1Algo; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* SMESHGUI_AddSubMeshDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ADD_SUBMESH_H diff --git a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx new file mode 100644 index 000000000..6ed711d25 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx @@ -0,0 +1,388 @@ +using namespace std; +// File : SMESHGUI_AddVolumeDlg.cxx +// Created : Wed Jun 26 21:00:14 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_AddVolumeDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_AddVolumeDlg() +// purpose : +//================================================================================= +SMESHGUI_AddVolumeDlg::SMESHGUI_AddVolumeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + int nbNodes, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myNodes = nbNodes; + QPixmap image0; + if ( myNodes == 4 ) + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_TETRAS"))); + else if ( myNodes == 8 ) + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_HEXAS"))); + + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddVolumeDlg" ); + resize( 303, 185 ); + if ( myNodes == 4 ) + setCaption( tr( "SMESH_ADD_TETRAS_TITLE" ) ); + else if ( myNodes == 8 ) + setCaption( tr( "SMESH_ADD_HEXAS_TITLE" ) ); + + setSizeGripEnabled( TRUE ); + SMESHGUI_AddVolumeDlgLayout = new QGridLayout( this ); + SMESHGUI_AddVolumeDlgLayout->setSpacing( 6 ); + SMESHGUI_AddVolumeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + if ( myNodes == 4 ) + GroupConstructors->setTitle( tr( "SMESH_TETRAS" ) ); + else if ( myNodes == 8 ) + GroupConstructors->setTitle( tr( "SMESH_HEXAS" ) ); + + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_AddVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + if ( myNodes == 4 ) + GroupC1->setTitle( tr( "SMESH_ADD_TETRAS" ) ); + else if ( myNodes == 8 ) + GroupC1->setTitle( tr( "SMESH_ADD_HEXAS" ) ); + + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + SMESHGUI_AddVolumeDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_AddVolumeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddVolumeDlg::~SMESHGUI_AddVolumeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkNodes = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_AddVolumeDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkNodes) { + mySMESHGUI->EraseSimulationActors(); + mySMESHGUI->AddVolume( myMesh, myMapIndex ) ; + mySMESHGUI->ViewNodes(); + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_AddVolumeDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkNodes = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes < 1) + return ; + + if ( mySelection->SelectionMode() != 1 ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + + if ( myNodes == 4 && nbNodes == 4 ) { + mySMESHGUI->DisplaySimulationTetra(myMesh, myMapIndex); + myOkNodes = true ; + } else if ( myNodes == 8 && nbNodes == 8 ) { + mySMESHGUI->DisplaySimulationHexa(myMesh, myMapIndex); + myOkNodes = true ; + } else { + // mySMESHGUI->EraseSimulationActors(); + myOkNodes = false ; + } + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->EraseSimulationActors() ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddVolumeDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + diff --git a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.h b/src/SMESHGUI/SMESHGUI_AddVolumeDlg.h new file mode 100644 index 000000000..c09c9e502 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddVolumeDlg.h @@ -0,0 +1,98 @@ +// File : SMESHGUI_AddVolumeDlg.h +// Created : Wed Jun 26 21:00:41 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ADD_VOLUME_H +#define DIALOGBOX_ADD_VOLUME_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_AddVolumeDlg +// purpose : +//================================================================================= +class SMESHGUI_AddVolumeDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_AddVolumeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, + int nbNode = 4, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddVolumeDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + + int myNodes ; + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_AddVolumeDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ADD_VOLUME_H diff --git a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx b/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx new file mode 100644 index 000000000..4f7decb2e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx @@ -0,0 +1,409 @@ +using namespace std; +// File : SMESHGUI_ComputeScalarValue.cxx +// Created : Mon Jun 24 14:06:00 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_ComputeScalarValue.h" +#include "utilities.h" +#include + + + + +//============================================================================= +/*! + * + */ +//============================================================================= +static double ComputeLength(float* p1, float* p2) { + float a1,a2,a3,b1,b2,b3; + a1 = p1[0]; + a2 = p1[1]; + a3 = p1[2]; + b1 = p2[0]; + b2 = p2[1]; + b3 = p2[2]; + // MESSAGE( a1 << " "<< a2 << " "<< a3 << " " << b1 << " "<< b2 << " "<< b3 ); + float X1,Y1,Z1,X2,Z2,Y2; + X1 = b1 - a1; + Y1 = b2 - a2; + Z1 = b3 - a3; + // MESSAGE( X1 << " "<< Y1 << " "<< Z1 ); + float e1; + e1 = sqrt( X1*X1 + Y1*Y1 + Z1*Z1 ) ; + // MESSAGE( "Length = " << e1 ); + return e1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +double SMESHGUI_ComputeScalarValue::LengthEdges(vtkCell* theCell) { + int num_points = theCell->GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points != 2 ) return 0; + float* pnt1 = points->GetPoint(0); + float* pnt2 = points->GetPoint(1); + return ComputeLength(pnt1,pnt2); +}; + +//============================================================================= +/*! + * + */ +//============================================================================= +static double ComputeAreaOfTriangle(float* p1, float* p2, float* p3) { + double a1,a2,a3,b1,b2,b3,c1,c2,c3; + a1 = p1[0]; + a2 = p1[1]; + a3 = p1[2]; + b1 = p2[0]; + b2 = p2[1]; + b3 = p2[2]; + c1 = p3[0]; + c2 = p3[1]; + c3 = p3[2]; + + float e1, e2, e3; + e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; + e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; + e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ; + + // MESSAGE( "e = " << e1 << " " << e2 <<" " << e3 ); + float s = (e1+e2+e3)/2; + double area = sqrt(s*(s-e1)*(s-e2)*(s-e3)); + // MESSAGE( "area = " << area ); + return area; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +double SMESHGUI_ComputeScalarValue::AreaElements(vtkCell* theCell){ + // MESSAGE ( " SMESHGUI_ComputeScalarValue::AreaElements " ) + int num_points = theCell->GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + // MESSAGE( "num_points = "<< num_points ); + for (int j = 0; j < theCell->GetNumberOfPoints (); j++) { + float* pnt = points->GetPoint(j); + // MESSAGE( pnt[0] << " " << pnt[1] << " " << pnt[2] ); + } + if (num_points < 3 ) return 0; + if (num_points == 3) { + float* p1 = points->GetPoint(0); + float* p2 = points->GetPoint(1); + float* p3 = points->GetPoint(2); + double area = ComputeAreaOfTriangle(p1,p2,p3); + return area; + } else if (num_points == 4) { + float* p1 = points->GetPoint(0); + float* p2 = points->GetPoint(1); + float* p3 = points->GetPoint(2); + float* p4 = points->GetPoint(3); + double area1 = ComputeAreaOfTriangle(p1,p2,p3); + double area2 = ComputeAreaOfTriangle(p3,p4,p1); + return area1+area2; + } +}; + +//============================================================================= +/*! + * + */ +//============================================================================= +double SMESHGUI_ComputeScalarValue::Taper(vtkCell* theCell){ + int num_points = theCell->GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points != 4 ) return 0; + float* p1 = points->GetPoint(0); + float* p2 = points->GetPoint(1); + float* p3 = points->GetPoint(2); + float* p4 = points->GetPoint(3); + double A1 = ComputeAreaOfTriangle(p4,p1,p2); + double A2 = ComputeAreaOfTriangle(p3,p1,p2); + double A3 = ComputeAreaOfTriangle(p2,p3,p4); + double A4 = ComputeAreaOfTriangle(p3,p4,p1); + double JA = 0.25 * (A1 + A2 + A3 + A4); + double taper = fabs(A1/(JA-1)); + if (fabs(A2/(JA-1)) > taper) taper = fabs(A2/(JA-1)); + if (fabs(A3/(JA-1)) > taper) taper = fabs(A3/(JA-1)); + if (fabs(A4/(JA-1)) > taper) taper = fabs(A4/(JA-1)); + // MESSAGE( "Taper = " << taper); + return taper; +}; + +//============================================================================= +/*! + * + */ +//============================================================================= +double SMESHGUI_ComputeScalarValue::AspectRatio(vtkCell* theCell) { + int num_points = theCell->GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points < 3 ) return 0; + if (num_points == 3) { + float a1,a2,a3,b1,b2,b3,c1,c2,c3; + float* pnt = points->GetPoint(0); + a1 = pnt[0]; + a2 = pnt[1]; + a3 = pnt[2]; + pnt = points->GetPoint(1); + b1 = pnt[0]; + b2 = pnt[1]; + b3 = pnt[2]; + pnt = points->GetPoint(2); + c1 = pnt[0]; + c2 = pnt[1]; + c3 = pnt[2]; + + float e1, e2, e3; + e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; + e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; + e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ; + + float amax,p,s; + + amax=e1; + if (e2>amax) amax=e2; + if (e3>amax) amax=e3; + + p=(e1+e2+e3)/2; + s=AreaElements(theCell); + + double aspectRatio=amax*p*sqrt(double(3))/(s*6); + // MESSAGE( "aspectRatio = " << aspectRatio ); + return(aspectRatio); + } + else if (num_points == 4) { + float a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3; + float* pnt = points->GetPoint(0); + a1 = pnt[0]; + a2 = pnt[1]; + a3 = pnt[2]; + pnt = points->GetPoint(1); + b1 = pnt[0]; + b2 = pnt[1]; + b3 = pnt[2]; + pnt = points->GetPoint(2); + c1 = pnt[0]; + c2 = pnt[1]; + c3 = pnt[2]; + pnt = points->GetPoint(3); + d1 = pnt[0]; + d2 = pnt[1]; + d3 = pnt[2]; + + float e1, e2, e3, e4; + float len_min, len_max; + e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; + e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; + e3 = sqrt( (c1-d1)*(c1-d1) + (c2-d2)*(c2-d2) + (c3-d3)*(c3-d3) ) ; + e4 = sqrt( (d1-a1)*(d1-a1) + (d2-a2)*(d2-a2) + (d3-a3)*(d3-a3) ) ; + + len_min = e1; len_max = e1; + + if (e2 >len_max ) len_max = e2; + if (e3 >len_max ) len_max = e3; + if (e4 >len_max ) len_max = e4; + if (e2 GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points < 3 ) return 0; + float* pnt1 = points->GetPoint(0); + float* pnt2 = points->GetPoint(1); + float* pnt3 = points->GetPoint(2); + if (num_points == 3) { + double a1,a2,a3,amin; + a1=fabs(ComputeAngle(pnt1,pnt2,pnt3)); + amin=a1; + a2=fabs(ComputeAngle(pnt2,pnt3,pnt1)); + if (a2GetPoint(3); + double a1,a2,a3,a4,amin; + a1=fabs(ComputeAngle(pnt1,pnt2,pnt3)); + amin=a1; + a2=fabs(ComputeAngle(pnt2,pnt3,pnt4)); + if (a2GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points < 3 ) return 0; + //triangle case + if (num_points == 3) { + float* pnt1 = points->GetPoint(0); + float* pnt2 = points->GetPoint(1); + float* pnt3 = points->GetPoint(2); + double a1,a2,a3,amax; + a1=fabs(60 - fabs(ComputeAngle(pnt1,pnt2,pnt3))); + amax=a1; + a2=fabs(60 - fabs(ComputeAngle(pnt2,pnt3,pnt1))); + if (a2>amax) amax=a2; + a3=fabs(60 - fabs(ComputeAngle(pnt3,pnt1,pnt2))); + if (a3>amax) amax=a3; + // MESSAGE( "Skew = " << amax ); + return amax; + } + //quadrangle case + else if (num_points == 4) { + float* pnt1 = points->GetPoint(0); + float* pnt2 = points->GetPoint(1); + float* pnt3 = points->GetPoint(2); + float* pnt4 = points->GetPoint(3); + + double a1,a2,a3,a4,amax; + a1=fabs(90 - fabs(ComputeAngle(pnt1,pnt2,pnt3))); + amax=a1; + a2=fabs(90 - fabs(ComputeAngle(pnt2,pnt3,pnt4))); + if (a2>amax) amax=a2; + a3=fabs(90 - fabs(ComputeAngle(pnt3,pnt4,pnt1))); + if (a3>amax) amax=a3; + a4=fabs(90 - fabs(ComputeAngle(pnt4,pnt1,pnt2))); + if (a4>amax) amax=a4; + // MESSAGE( "Skew = " << amax ); + return amax; + } +}; + +//============================================================================= +/*! + * + */ +//============================================================================= +static double ComputeA(float* p1, float* p2, float* p3, float* G) { + double e1 = sqrt(pow(p2[0]-p1[0], 2)+pow(p2[1]-p1[1], 2)+pow(p2[2]-p1[2], 2)); + double e2 = sqrt(pow(p3[0]-p2[0], 2)+pow(p3[1]-p2[1], 2)+pow(p3[2]-p2[2], 2)); + double l; + if (e1 < e2) l = 0.5*e1; + else l = 0.5*e2; + float GI[3], GJ[3], N[3];; + GI[0] = (p2[0]-p1[0])/2-G[0]; + GI[1] = (p2[1]-p1[1])/2-G[1]; + GI[2] = (p2[2]-p1[2])/2-G[2]; + + GJ[0] = (p3[0]-p2[0])/2-G[0]; + GJ[1] = (p3[1]-p2[1])/2-G[1]; + GJ[2] = (p3[2]-p2[2])/2-G[2]; + + N[0] = GI[1]*GJ[2] - GI[2]*GJ[1]; + N[1] = GI[2]*GJ[0] - GI[0]*GJ[2]; + N[2] = GI[0]*GJ[1] - GI[1]*GJ[0]; + + double H; + float T[3]; + T[0] = (p1[0]-G[0])*N[0]; + T[1] = (p1[1]-G[1])*N[1]; + T[2] = (p1[2]-G[2])*N[2]; + + H = sqrt(pow(T[0],2)+pow(T[1],2)+pow(T[2],2))/sqrt(pow(N[0],2)+pow(N[1],2)+pow(N[2],2)); + double A = H/l; + return A; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +double SMESHGUI_ComputeScalarValue::Warp(vtkCell* theCell) { + int num_points = theCell->GetNumberOfPoints (); + vtkPoints* points = theCell->GetPoints(); + if (num_points != 4 ) return 0; + float* p1 = points->GetPoint(0); + float* p2 = points->GetPoint(1); + float* p3 = points->GetPoint(2); + float* p4 = points->GetPoint(3); + double G1, G2, G3; + float G[3]; + G[0] = (p1[0]+p2[0]+p3[0]+p4[0])/4; + G[1] = (p1[1]+p2[1]+p3[1]+p4[1])/4; + G[2] = (p1[2]+p2[2]+p3[2]+p4[2])/4; + double amax = ComputeA(p1, p2, p3, G); + double nextA = ComputeA(p2, p3, p4, G); + if (nextA > amax) amax = nextA; + nextA = ComputeA(p3, p4, p1, G); + if (nextA > amax) amax = nextA; + nextA = ComputeA(p4, p1, p2, G); + if (nextA > amax) amax = nextA; + // MESSAGE( "Warp = " << amax ); + return amax; +} diff --git a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.h b/src/SMESHGUI/SMESHGUI_ComputeScalarValue.h new file mode 100644 index 000000000..25d05e676 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ComputeScalarValue.h @@ -0,0 +1,26 @@ +// File : SMESHGUI_ComputeScalarValue.h +// Created : Mon Jun 24 14:06:00 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SMESHGUI_CONTROLALGORITHMS_H +#define SMESHGUI_CONTROLALGORITHMS_H + +#include + +class SMESHGUI_ComputeScalarValue { + public: + static double LengthEdges(vtkCell* theCell); + static double AreaElements(vtkCell* theCell); + static double Taper(vtkCell* theCell); + static double AspectRatio(vtkCell* theCell); + static double MinimumAngle(vtkCell* theCell); + static double Skew(vtkCell* theCell); + static double Warp(vtkCell* theCell); +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx b/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx new file mode 100644 index 000000000..98d6f955b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx @@ -0,0 +1,351 @@ +using namespace std; +// File : SMESHGUI_DiagonalInversionDlg.cxx +// Created : +// Author : Damien COQUERET + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_DiagonalInversionDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_DiagonalInversionDlg() +// purpose : +//================================================================================= +SMESHGUI_DiagonalInversionDlg::SMESHGUI_DiagonalInversionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MESH_DIAGONAL"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_DiagonalInversionDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_DIAGONAL_INVERSION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_DiagonalInversionDlgLayout = new QGridLayout( this ); + SMESHGUI_DiagonalInversionDlgLayout->setSpacing( 6 ); + SMESHGUI_DiagonalInversionDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_DIAGONAL" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_DIAGONAL" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_DIAGONAL" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_DiagonalInversionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_DiagonalInversionDlg::~SMESHGUI_DiagonalInversionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkElements = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkElements) { + mySMESHGUI->DiagonalInversion( myMesh, myMapIndex ) ; + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkElements = false; + QString aString = ""; + + if ( mySelection->SelectionMode() != 2 ) { + return; + } + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbElements = mySMESHGUI->GetNameOfSelectedEdges(mySelection, aString) ; + if(nbElements < 1) + return ; + MESSAGE( "DCQ : nb. elements = " << nbElements ) + + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + myOkElements = true ; + myEditCurrentArgument->setText(aString) ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_DiagonalInversionDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h b/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h new file mode 100644 index 000000000..cd2dde34f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h @@ -0,0 +1,94 @@ +// File : SMESHGUI_DiagonalInversionDlg.h +// Created : +// Author : Damien COQUERET + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_DIAGONAL_INVERSION_H +#define DIALOGBOX_DIAGONAL_INVERSION_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_DiagonalInversionDlg +// purpose : +//================================================================================= +class SMESHGUI_DiagonalInversionDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_DiagonalInversionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_DiagonalInversionDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkElements ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_DiagonalInversionDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_DIAGONAL_INVERSION_H diff --git a/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.cxx b/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.cxx new file mode 100644 index 000000000..893230a21 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.cxx @@ -0,0 +1,429 @@ +using namespace std; +// File : SMESHGUI_EdgesConnectivityDlg.cxx +// Created : Tue Jun 25 21:22:12 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_EdgesConnectivityDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// VTK Include +#include + +//================================================================================= +// class : SMESHGUI_EdgesConnectivityDlg() +// purpose : +//================================================================================= +SMESHGUI_EdgesConnectivityDlg::SMESHGUI_EdgesConnectivityDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_CONNECTIVITY"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_EdgesConnectivityDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_EDGES_CONNECTIVITY_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_EdgesConnectivityDlgLayout = new QGridLayout( this ); + SMESHGUI_EdgesConnectivityDlgLayout->setSpacing( 6 ); + SMESHGUI_EdgesConnectivityDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_EDGES_CONNECTIVITY" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + //buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + //buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + //buttonOk->setAutoDefault( TRUE ); + //buttonOk->setDefault( TRUE ); + //GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_EDGES_CONNECTIVITY" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_MESH" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + BoundaryEdges = new QCheckBox( GroupC1, "BoundaryEdges" ); + BoundaryEdges->setText( tr( "SMESH_BOUNDARYEDGES" ) ); + GroupC1Layout->addWidget( BoundaryEdges, 1, 0 ); + + ManifoldEdges = new QCheckBox( GroupC1, "ManifoldEdges" ); + ManifoldEdges->setText( tr( "SMESH_MANIFOLDEDGES" ) ); + GroupC1Layout->addWidget( ManifoldEdges, 2, 0 ); + + NonManifoldEdges = new QCheckBox( GroupC1, "NonManifoldEdges" ); + NonManifoldEdges->setText( tr( "SMESH_NONMANIFOLDEDGES" ) ); + GroupC1Layout->addWidget( NonManifoldEdges, 1, 2 ); + + FeatureEdges = new QCheckBox( GroupC1, "FeatureEdges" ); + FeatureEdges->setText( tr( "SMESH_FEATUREEDGES" ) ); + GroupC1Layout->addWidget( FeatureEdges, 2, 2 ); + + FeatureAngle= new QLabel( GroupC1, "FeatureAngle" ); + FeatureAngle->setText( tr( "SMESH_FEATUREANGLE" ) ); + FeatureAngle->setMinimumSize( QSize( 50, 0 ) ); + FeatureAngle->setFrameShape( QLabel::NoFrame ); + FeatureAngle->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( FeatureAngle, 3, 0 ); + + SpinBox_FeatureAngle = new SMESHGUI_SpinBox( GroupC1, "SpinBox_FeatureAngle" ) ; + GroupC1Layout->addWidget( SpinBox_FeatureAngle , 3, 2 ); + + SMESHGUI_EdgesConnectivityDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_EdgesConnectivityDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_EdgesConnectivityDlg::~SMESHGUI_EdgesConnectivityDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkActor = false ; + + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 5.0 ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_FeatureAngle->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_FeatureAngle->SetValue( 30.0 ) ; + + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + //connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( BoundaryEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + connect( ManifoldEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + connect( NonManifoldEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + connect( FeatureEdges, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkActor) { + Standard_Boolean res; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + if ( !IO->hasEntry() ) + break; + + SMESH_Actor* ac = mySMESHGUI->FindActorByEntry( IO->getEntry(), res, true ); + if ( !res ) + break; + + mySMESHGUI->ChangeRepresentation( ac, 0 ); + + vtkGeometryFilter *gf = vtkGeometryFilter::New(); + gf->SetInput(ac->DataSource); + vtkFeatureEdges *edges = vtkFeatureEdges::New(); + edges->SetInput( gf->GetOutput() ); + edges->ColoringOn(); + if ( BoundaryEdges->isOn() ) edges->BoundaryEdgesOn(); + else edges->BoundaryEdgesOff(); + if ( ManifoldEdges->isOn() ) edges->ManifoldEdgesOn(); + else edges->ManifoldEdgesOff(); + if ( NonManifoldEdges->isOn() ) edges->NonManifoldEdgesOn(); + else edges->NonManifoldEdgesOff(); + if ( FeatureEdges->isOn() ) edges->FeatureEdgesOn(); + else edges->FeatureEdgesOff(); + + double angle = SpinBox_FeatureAngle->GetValue() ; + edges->SetFeatureAngle( angle ); + + vtkDataSetMapper *EdgeMapper = vtkDataSetMapper::New(); + EdgeMapper->SetInput( edges->GetOutput() ); + EdgeMapper->SetScalarModeToUseCellData(); + ac->SetMapper(EdgeMapper); + + mySMESHGUI->DisplayEdgesConnectivityLegendBox(ac); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::ClickOnCancel() +{ + mySMESHGUI->ScalarVisibilityOff(); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + mySMESHGUI->ScalarVisibilityOff(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkActor = false; + QString aString = ""; + + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if(nbSel != 1) { + mySMESHGUI->ScalarVisibilityOff(); + return; + } + + myEditCurrentArgument->setText(aString) ; + myOkActor = true ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_EdgesConnectivityDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + +void SMESHGUI_EdgesConnectivityDlg::CheckBox( int state ) +{ + QCheckBox* send = (QCheckBox*)sender(); + if( send == BoundaryEdges ) { + } else if( send == ManifoldEdges ) { + } else if( send == NonManifoldEdges ) { + } else { + } +} + diff --git a/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.h b/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.h new file mode 100644 index 000000000..13544f273 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EdgesConnectivityDlg.h @@ -0,0 +1,104 @@ +// File : SMESHGUI_EdgesConnectivityDlg.h +// Created : Tue Jun 25 21:22:54 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_EDGES_CONNECTIVITY_H +#define DIALOGBOX_EDGES_CONNECTIVITY_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; +class SMESHGUI_SpinBox; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_EdgesConnectivityDlg +// purpose : +//================================================================================= +class SMESHGUI_EdgesConnectivityDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_EdgesConnectivityDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_EdgesConnectivityDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + bool myOkActor ; + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + + QCheckBox* BoundaryEdges; + QCheckBox* ManifoldEdges; + QCheckBox* NonManifoldEdges; + QCheckBox* FeatureEdges; + + QLabel* FeatureAngle; + SMESHGUI_SpinBox* SpinBox_FeatureAngle ; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + + void CheckBox( int ); + +protected: + QGridLayout* SMESHGUI_EdgesConnectivityDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + + QHBoxLayout* hbox_2; + QVBoxLayout* vbox; + QVBoxLayout* vbox_2; +}; + +#endif // DIALOGBOX_EDGES_CONNECTIVITY_H diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx new file mode 100644 index 000000000..f839d12e9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx @@ -0,0 +1,824 @@ +using namespace std; +// File : SMESHGUI_EditHypothesesDlg.cxx +// Created : Fri Aug 02 09:14:56 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_EditHypothesesDlg.h" +#include "SMESHGUI.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +//================================================================================= +// class : SMESHGUI_EditHypothesesDlg() +// purpose : Constructs a SMESHGUI_EditHypothesesDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_EDIT_MESH"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + if ( !name ) + setName( "SMESHGUI_EditHypothesesDlg" ); + resize( 417, 573 ); + setCaption( tr( "SMESH_EDIT_HYPOTHESES" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_EditHypothesesDlgLayout = new QGridLayout( this ); + SMESHGUI_EditHypothesesDlgLayout->setSpacing( 6 ); + SMESHGUI_EditHypothesesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_HYPOTHESES" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image1 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 96 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + buttonCancel->setDefault( TRUE ); + buttonCancel->setEnabled( TRUE ) ; + + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( FALSE ); + buttonApply->setEnabled( FALSE ) ; + + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( FALSE ); + buttonOk->setEnabled( FALSE ) ; + + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupButtons, 5, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image0 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + TextLabelC1A2 = new QLabel( GroupC1, "TextLabelC1A2" ); + TextLabelC1A2->setText( tr( "SMESH_OBJECT_GEOM" ) ); + TextLabelC1A2->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A2->setFrameShape( QLabel::NoFrame ); + TextLabelC1A2->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A2, 1, 0 ); + SelectButtonC1A2 = new QPushButton( GroupC1, "SelectButtonC1A2" ); + SelectButtonC1A2->setText( tr( "" ) ); + SelectButtonC1A2->setPixmap( image0 ); + SelectButtonC1A2->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); + LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); + + GroupHypotheses = new QGroupBox( this, "GroupHypotheses" ); + GroupHypotheses->setTitle( tr( "SMESH_HYPOTHESES" ) ); + GroupHypotheses->setColumnLayout(0, Qt::Vertical ); + GroupHypotheses->layout()->setSpacing( 0 ); + GroupHypotheses->layout()->setMargin( 0 ); + grid_3 = new QGridLayout( GroupHypotheses->layout() ); + grid_3->setGeometry( QRect( 12, 18, 139, 110 ) ); + grid_3->setAlignment( Qt::AlignTop ); + grid_3->setSpacing( 6 ); + grid_3->setMargin( 11 ); + + hbox_2 = new QHBoxLayout; + hbox_2->setSpacing( 6 ); + hbox_2->setMargin( 0 ); + + vbox = new QVBoxLayout; + vbox->setSpacing( 6 ); + vbox->setMargin( 0 ); + + TextHypDefinition = new QLabel( GroupHypotheses, "TextHypDefinition" ); + TextHypDefinition->setText( tr( "SMESH_AVAILABLE" ) ); + vbox->addWidget( TextHypDefinition ); + + ListHypDefinition = new QListBox( GroupHypotheses, "ListHypDefinition" ); + ListHypDefinition->setMinimumSize( 100, 50); +// ListHypDefinition->setRowMode(4); +// ListHypDefinition->setRowMode( QListBox::FixedNumber ); +// ListHypDefinition->setLineWidth( 4 ); +// ListHypDefinition->setColumnMode( QListBox::Variable ); +// ListHypDefinition->setVariableHeight( FALSE ); +// ListHypDefinition->insertItem( tr( "New Item" ) ); + vbox->addWidget( ListHypDefinition ); + hbox_2->addLayout( vbox ); + + vbox_2 = new QVBoxLayout; + vbox_2->setSpacing( 6 ); + vbox_2->setMargin( 0 ); + + TextHypAssignation = new QLabel( GroupHypotheses, "TextHypAssignation" ); + TextHypAssignation->setText( tr( "SMESH_EDIT_USED" ) ); + vbox_2->addWidget( TextHypAssignation ); + + ListHypAssignation = new QListBox( GroupHypotheses, "ListHypAssignation" ); + ListHypAssignation->setMinimumSize( 100, 50); +// ListHypAssignation->setRowMode(4); +// ListHypAssignation->setRowMode( QListBox::FixedNumber ); +// ListHypAssignation->setLineWidth( 4 ); +// ListHypAssignation->setColumnMode( QListBox::Variable ); +// ListHypAssignation->setVariableHeight( FALSE ); +// ListHypAssignation->insertItem( tr( "New Item" ) ); + vbox_2->addWidget( ListHypAssignation ); + hbox_2->addLayout( vbox_2 ); + + grid_3->addLayout( hbox_2, 0, 0 ); + + SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupHypotheses, 2, 0 ); + + GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" ); + GroupAlgorithms->setTitle( tr( "SMESH_ADD_ALGORITHM" ) ); + GroupAlgorithms->setColumnLayout(0, Qt::Vertical ); + GroupAlgorithms->layout()->setSpacing( 0 ); + GroupAlgorithms->layout()->setMargin( 0 ); + grid_4 = new QGridLayout( GroupAlgorithms->layout() ); + grid_4->setGeometry( QRect( 12, 18, 139, 110 ) ); + grid_4->setAlignment( Qt::AlignTop ); + grid_4->setSpacing( 6 ); + grid_4->setMargin( 11 ); + + hbox_3 = new QHBoxLayout; + hbox_3->setSpacing( 6 ); + hbox_3->setMargin( 0 ); + + vbox_3 = new QVBoxLayout; + vbox_3->setSpacing( 6 ); + vbox_3->setMargin( 0 ); + + TextAlgoDefinition = new QLabel( GroupAlgorithms, "TextAlgoDefinition" ); + TextAlgoDefinition->setText( tr( "SMESH_AVAILABLE" ) ); + vbox_3->addWidget( TextAlgoDefinition ); + + ListAlgoDefinition = new QListBox( GroupAlgorithms, "ListAlgoDefinition" ); + ListAlgoDefinition->setMinimumSize( 100, 50); +// ListAlgoDefinition->setRowMode(4); +// ListAlgoDefinition->setRowMode( QListBox::FixedNumber ); +// ListAlgoDefinition->setLineWidth( 4 ); +// ListAlgoDefinition->setColumnMode( QListBox::Variable ); +// ListAlgoDefinition->setVariableHeight( FALSE ); +// ListAlgoDefinition->insertItem( tr( "New Item" ) ); + vbox_3->addWidget( ListAlgoDefinition ); + hbox_3->addLayout( vbox_3 ); + + vbox_4 = new QVBoxLayout; + vbox_4->setSpacing( 6 ); + vbox_4->setMargin( 0 ); + + TextAlgoAssignation = new QLabel( GroupAlgorithms, "TextAlgoAssignation" ); + TextAlgoAssignation->setText( tr( "SMESH_EDIT_USED" ) ); + vbox_4->addWidget( TextAlgoAssignation ); + + ListAlgoAssignation = new QListBox( GroupAlgorithms, "ListAlgoAssignation" ); + ListAlgoAssignation ->setMinimumSize( 100, 50); +// ListAlgoAssignation->setRowMode(4); +// ListAlgoAssignation->setRowMode( QListBox::FixedNumber ); +// ListAlgoAssignation->setLineWidth( 4 ); +// ListAlgoAssignation->setColumnMode( QListBox::Variable ); +// ListAlgoAssignation->setVariableHeight( FALSE ); +// ListAlgoAssignation->insertItem( tr( "New Item" ) ); + vbox_4->addWidget( ListAlgoAssignation ); + hbox_3->addLayout( vbox_4 ); + + grid_4->addLayout( hbox_3, 0, 0 ); + SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupAlgorithms, 3, 0 ); + + SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + + Init(Sel) ; + +} + + +//================================================================================= +// function : ~SMESHGUI_EditHypothesesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_EditHypothesesDlg::~SMESHGUI_EditHypothesesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel ) +{ + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + InitHypDefinition(); + InitAlgoDefinition(); + + InitHypAssignation(); + InitAlgoAssignation(); + + myGeomFilter = new SALOME_TypeFilter( "GEOM" ); + myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + + myGeomShape = GEOM::GEOM_Shape::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( ListHypAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) ); + connect( ListAlgoAssignation, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( removeItem(QListBoxItem*) ) ); + + connect( ListHypDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) ); + connect( ListAlgoDefinition, SIGNAL( clicked(QListBoxItem*) ), this, SLOT( addItem(QListBoxItem*) ) ); + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_EditHypothesesDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::ClickOnCancel() +{ + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySelection->ClearFilters() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + + switch (myConstructorId) + { + case 0: + { + if ( myEditCurrentArgument == LineEditC1A1 ) { + if ( nbSel != 1 ) { + myOkHypothesis = false; + myOkAlgorithm = false; + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ; + if( !testResult ) { + myMesh = SMESH::SMESH_Mesh::_nil(); + + mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ; + if( !testResult ) { + mySubMesh = SMESH::SMESH_subMesh::_nil(); + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + return ; + } + } + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + } + } else if ( myEditCurrentArgument == LineEditC1A2 ) { + if ( nbSel != 1 ) { + myOkHypothesis = false; + myOkAlgorithm = false; + myGeomShape = GEOM::GEOM_Shape::_nil(); + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) { + myGeomShape = GEOM::GEOM_Shape::_nil(); + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + return ; + } + InitHypAssignation(); + InitAlgoAssignation(); + InitGeom(); + } + } + break; + } + } + + myEditCurrentArgument->setText(aString) ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->ClearFilters() ; + mySelection->AddFilter(myMeshOrSubMeshFilter) ; + } else if (send == SelectButtonC1A2) { + LineEditC1A2->setFocus() ; + myEditCurrentArgument = LineEditC1A2; + mySelection->ClearFilters() ; + mySelection->AddFilter(myGeomFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + return ; +} + +void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* i) +{ + if (!i) return; + + SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); + int index = ListHypAssignation->index( i ); + if ( index != -1 ) { + if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) { + SMESH::SMESH_Hypothesis_var Hyp = + SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR( mapNameIOR[ string(i->text()) ].c_str() ) ); + + if ( !myMesh->_is_nil() ) { + SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh); + mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp); + // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false ); + mySMESHGUI->GetActiveStudy()->updateObjBrowser(); + } + if ( !mySubMesh->_is_nil() ) { + SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh); + mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp); + // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false ); + mySMESHGUI->GetActiveStudy()->updateObjBrowser(); + } + + ListHypAssignation->removeItem( index ); + } + return; + } + index = ListAlgoAssignation->index( i ); + if ( index != -1 ) { + if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) { + SMESH::SMESH_Hypothesis_var Hyp = + SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) ); + + if ( !myMesh->_is_nil() ) { + SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh(myMesh); + mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aMesh, Hyp); + // mySMESHGUI->GetStudyAPI().ModifiedMesh( aMesh, false ); + mySMESHGUI->GetActiveStudy()->updateObjBrowser(); + } + if ( !mySubMesh->_is_nil() ) { + SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh(mySubMesh); + mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh(aSubMesh, Hyp); + // mySMESHGUI->GetStudyAPI().ModifiedMesh( aSubMesh, false ); + mySMESHGUI->GetActiveStudy()->updateObjBrowser(); + } + + ListAlgoAssignation->removeItem( index ); + } + } +} + + +//================================================================================= +// function : addItem() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* i) +{ + if (!i) return; + + SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); + if ( ListHypDefinition->findItem( i->text() ) ) { + if ( !ListHypAssignation->findItem( i->text() ) ) { + ListHypAssignation->insertItem( i->text() ); + + if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) { + SMESH::SMESH_Hypothesis_var Hyp = + SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) ); + + if ( !myMesh->_is_nil() ) + mySMESHGUI->AddHypothesisOnMesh(myMesh, Hyp); + if ( !mySubMesh->_is_nil() ) + mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, Hyp); + } + } + return; + } + if ( ListAlgoDefinition->findItem( i->text() ) ) { + if ( !ListAlgoAssignation->findItem( i->text() ) ) { + ListAlgoAssignation->insertItem( i->text() ); + + if (mapNameIOR.find( string(i->text()) ) != mapNameIOR.end()) { + SMESH::SMESH_Hypothesis_var Hyp = + SMESH::SMESH_Hypothesis::_narrow( myStudyAPI.StringToIOR(mapNameIOR[ string(i->text()) ].c_str()) ); + + if ( !myMesh->_is_nil() ) + mySMESHGUI->AddAlgorithmOnMesh(myMesh, Hyp); + if ( !mySubMesh->_is_nil() ) + mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, Hyp); + } + } + } + mySMESHGUI->GetActiveStudy()->updateObjBrowser(); +} + + +//================================================================================= +// function : InitHypDefinition() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::InitHypDefinition() +{ + SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH"); + SALOMEDS::SObject_var HypothesisRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + int Tag_HypothesisRoot = 1; + if (father->FindSubObject (1, HypothesisRoot)) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListHypDefinition->insertItem(aName->Value()); + + if (Obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + mapNameIOR[ aName->Value() ] = anIOR->Value(); + } + } + } + } +} + +//================================================================================= +// function : InitHypAssignation() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::InitHypAssignation() +{ + MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() ) + MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() ) + ListHypAssignation->clear(); + SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); + int Tag_RefOnAppliedHypothesis = 2; + SALOMEDS::SObject_var AHR, aRef; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + + if ( !myMesh->_is_nil() ) { + SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh ); + if ( aMesh->FindSubObject (2, AHR)) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListHypAssignation->insertItem(aName->Value()); + } + } + } + } + } + if ( !mySubMesh->_is_nil() ) { + SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh ); + if ( aSubMesh->FindSubObject (2, AHR)) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListHypAssignation->insertItem(aName->Value()); + } + } + } + } + } +} + +//================================================================================= +// function : InitAlgoDefinition() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition() +{ + SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH"); + SALOMEDS::SObject_var AlgorithmsRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + int Tag_AlgorithmsRoot = 2; + if (father->FindSubObject (2, AlgorithmsRoot)) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if (Obj->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListAlgoDefinition->insertItem(aName->Value()); + + if (Obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + mapNameIOR[ aName->Value() ] = anIOR->Value(); + } + } + } + } +} + + +//================================================================================= +// function : InitAlgoAssignation() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() +{ + MESSAGE ( " InitAlgoAssignation " << myMesh->_is_nil() ) + MESSAGE ( " InitAlgoAssignation " << mySubMesh->_is_nil() ) + ListAlgoAssignation->clear(); + SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); + int Tag_RefOnAppliedAlgorithms = 3; + SALOMEDS::SObject_var AHR, aRef; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + + if ( !myMesh->_is_nil() ) { + SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh ); + if ( aMesh->FindSubObject (3, AHR) ) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListAlgoAssignation->insertItem(aName->Value()); + } + } + } + } + } + if ( !mySubMesh->_is_nil() ) { + SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh ); + if ( aSubMesh->FindSubObject (3, AHR) ) { + SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( Obj->ReferencedObject(aRef) ) { + if (aRef->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + ListAlgoAssignation->insertItem(aName->Value()); + } + } + } + } + } +} + +//================================================================================= +// function : InitGeom() +// purpose : +//================================================================================= +void SMESHGUI_EditHypothesesDlg::InitGeom() +{ + LineEditC1A2->setText("") ; + SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); + + if ( !myMesh->_is_nil() ) { + SALOMEDS::SObject_var aMesh = myStudyAPI.FindMesh( myMesh ); + if ( !aMesh->_is_nil() ) + myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh); + } + if ( !mySubMesh->_is_nil() ) { + SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindSubMesh( mySubMesh ); + if ( !aSubMesh->_is_nil() ) + myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh); + } + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) { + SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() ); + if ( !aSO->_is_nil() ) { + if (aSO->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + LineEditC1A2->setText( QString(aName->Value()) ) ; + } + } + } +} diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h new file mode 100644 index 000000000..76788d743 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h @@ -0,0 +1,158 @@ +// File : SMESHGUI_EditHypothesesDlg.h +// Created : Fri Aug 02 09:15:40 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_EDIT_HYPOTHESES_H +#define DIALOGBOX_EDIT_HYPOTHESES_H + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" +#include "SMESH_TypeFilter.hxx" + +// QT Includes +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include +#include + +using namespace std; + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QListBox; +class QListBoxItem; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_EditHypothesesDlg +// purpose : +//================================================================================= +class SMESHGUI_EditHypothesesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_EditHypothesesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_EditHypothesesDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + void InitHypDefinition(); + void InitAlgoDefinition(); + void InitHypAssignation(); + void InitAlgoAssignation(); + + void InitGeom(); + + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + + GEOM::GEOM_Shape_var myGeomShape ; + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + + Handle(SALOME_TypeFilter) myGeomFilter; + Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + + map mapNameIOR; + + SALOME_ListIO HypoList; + SALOME_ListIO AlgoList; + + bool myOkHypothesis; + bool myOkAlgorithm; + + SMESH::SMESH_Hypothesis_var myHypothesis; + SMESH::SMESH_Hypothesis_var myAlgorithm; + + SMESH::ListOfHypothesis_var myLHypothesis; + SMESH::ListOfHypothesis_var myLAlgorithm; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + + QLabel* TextLabelC1A2; + QPushButton* SelectButtonC1A2; + QLineEdit* LineEditC1A2; + + QGroupBox* GroupHypotheses; + QLabel* TextHypDefinition; + QListBox* ListHypDefinition; + QLabel* TextHypAssignation; + QListBox* ListHypAssignation; + + QGroupBox* GroupAlgorithms; + QLabel* TextAlgoDefinition; + QListBox* ListAlgoDefinition; + QLabel* TextAlgoAssignation; + QListBox* ListAlgoAssignation; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnCancel(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + + void removeItem(QListBoxItem*); + void addItem(QListBoxItem*); + +protected: + QGridLayout* SMESHGUI_EditHypothesesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + + QGridLayout* grid_3; + QGridLayout* grid_4; + + QHBoxLayout* hbox_2; + QHBoxLayout* hbox_3; + + QVBoxLayout* vbox; + QVBoxLayout* vbox_2; + QVBoxLayout* vbox_3; + QVBoxLayout* vbox_4; + +}; + +#endif // DIALOGBOX_EDIT_HYPOTHESES_H diff --git a/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.cxx new file mode 100644 index 000000000..c5ba0d13e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.cxx @@ -0,0 +1,127 @@ +using namespace std; +// File : SMESHGUI_EditScalarBarDlg.cxx +// Created : Wed Jun 12 12:01:26 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_EditScalarBarDlg.h" +#include "SMESHGUI.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a SMESHGUI_EditScalarBarDlg which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SMESHGUI_EditScalarBarDlg::SMESHGUI_EditScalarBarDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SMESHGUI_EditScalarBarDlg" ); + resize( 124, 122 ); + setCaption( tr( "SMESH_SCALARBAR" ) ); + setSizeGripEnabled( TRUE ); + grid = new QGridLayout( this ); + grid->setSpacing( 6 ); + grid->setMargin( 11 ); + + grid_2 = new QGridLayout; + grid_2->setSpacing( 6 ); + grid_2->setMargin( 0 ); + + PushButtonUpdateView = new QPushButton( this, "PushButtonUpdateView" ); + PushButtonUpdateView->setText( tr( "SMESH_UPDATEVIEW" ) ); + + grid_2->addWidget( PushButtonUpdateView, 1, 0 ); + + grid_3 = new QGridLayout; + grid_3->setSpacing( 6 ); + grid_3->setMargin( 0 ); + + grid_4 = new QGridLayout; + grid_4->setSpacing( 6 ); + grid_4->setMargin( 0 ); + + grid_5 = new QGridLayout; + grid_5->setSpacing( 6 ); + grid_5->setMargin( 0 ); + + LineEditMax = new QLineEdit( this, "LineEditMax" ); + + grid_5->addWidget( LineEditMax, 0, 0 ); + + LineEditMin = new QLineEdit( this, "LineEditMin" ); + + grid_5->addWidget( LineEditMin, 1, 0 ); + + grid_4->addLayout( grid_5, 0, 1 ); + + grid_6 = new QGridLayout; + grid_6->setSpacing( 6 ); + grid_6->setMargin( 0 ); + + TextLabelMax = new QLabel( this, "TextLabelMax" ); + TextLabelMax->setText( tr( "SMESH_MAX" ) ); + + grid_6->addWidget( TextLabelMax, 0, 0 ); + + TextLabelMin = new QLabel( this, "TextLabelMin" ); + TextLabelMin->setText( tr( "SMESH_MIN" ) ); + + grid_6->addWidget( TextLabelMin, 1, 0 ); + + grid_4->addLayout( grid_6, 0, 0 ); + + grid_3->addLayout( grid_4, 0, 0 ); + + Line1 = new QFrame( this, "Line1" ); + Line1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + + grid_3->addWidget( Line1, 1, 0 ); + + grid_2->addLayout( grid_3, 0, 0 ); + + grid->addLayout( grid_2, 0, 0 ); + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + if ( mySMESHGUI && mySMESHGUI->GetScalarBar() && mySMESHGUI->GetScalarBar()->GetLookupTable() ) { + float *range = mySMESHGUI->GetScalarBar()->GetLookupTable()->GetRange(); + LineEditMin->setText( QString("%1").arg(range[0]) ); + LineEditMax->setText( QString("%1").arg(range[1]) ); + } + + // signals and slots connections + connect( PushButtonUpdateView, SIGNAL( clicked() ), this, SLOT( updateView() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( reject() ) ) ; +} + +/* + * Destroys the object and frees any allocated resources + */ +SMESHGUI_EditScalarBarDlg::~SMESHGUI_EditScalarBarDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +void SMESHGUI_EditScalarBarDlg::updateView() +{ + float MinRange = LineEditMin->text().toFloat(); + float MaxRange = LineEditMax->text().toFloat(); + mySMESHGUI->UpdateScalarBar(MinRange,MaxRange); +} diff --git a/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.h b/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.h new file mode 100644 index 000000000..d95406d7b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_EditScalarBarDlg.h @@ -0,0 +1,54 @@ +// File : SMESHGUI_EditScalarBarDlg.h +// Created : Wed Jun 12 12:01:39 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SMESHGUI_EDITSCALARBARDLG_H +#define SMESHGUI_EDITSCALARBARDLG_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QFrame; +class QLabel; +class QLineEdit; +class QPushButton; + +class SMESHGUI; + +class SMESHGUI_EditScalarBarDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_EditScalarBarDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_EditScalarBarDlg(); + + QPushButton* PushButtonUpdateView; + QLineEdit* LineEditMax; + QLineEdit* LineEditMin; + QLabel* TextLabelMax; + QLabel* TextLabelMin; + QFrame* Line1; + + SMESHGUI *mySMESHGUI; + +public slots: + void updateView(); + +protected: + QGridLayout* grid; + QGridLayout* grid_2; + QGridLayout* grid_3; + QGridLayout* grid_4; + QGridLayout* grid_5; + QGridLayout* grid_6; +}; + +#endif // SMESHGUI_EDITSCALARBARDLG_H diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx new file mode 100644 index 000000000..f51fbf94a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -0,0 +1,473 @@ +using namespace std; +// File : SMESHGUI_InitMeshDlg.cxx +// Created : Mon May 27 10:20:11 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_InitMeshDlg.h" +#include "SMESHGUI.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_InitMeshDlg() +// purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_INIT_MESH"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + if ( !name ) + setName( "SMESHGUI_InitMeshDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_INIT_MESH" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_InitMeshDlgLayout = new QGridLayout( this ); + SMESHGUI_InitMeshDlgLayout->setSpacing( 6 ); + SMESHGUI_InitMeshDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_INIT" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image1 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_InitMeshDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_OBJECT_GEOM" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image0 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" ); + TextLabel_NameMesh->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameMesh, 1, 0 ); + LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" ); + GroupC1Layout->addWidget( LineEdit_NameMesh, 1, 2 ); + + TextLabelC1A1Hyp = new QLabel( GroupC1, "TextLabelC1A1Hyp" ); + TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) ); + TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1Hyp, 2, 0 ); + SelectButtonC1A1Hyp = new QPushButton( GroupC1, "SelectButtonC1A1Hyp" ); + SelectButtonC1A1Hyp->setText( tr( "" ) ); + SelectButtonC1A1Hyp->setPixmap( image0 ); + GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 ); + LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 ); + + TextLabelC1A1Algo = new QLabel( GroupC1, "TextLabelC1A1Algo" ); + TextLabelC1A1Algo->setText( tr( "SMESH_OBJECT_ALGORITHM" ) ); + TextLabelC1A1Algo->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1Algo->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1Algo->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1Algo, 3, 0 ); + SelectButtonC1A1Algo = new QPushButton( GroupC1, "SelectButtonC1A1Algo" ); + SelectButtonC1A1Algo->setText( tr( "" ) ); + SelectButtonC1A1Algo->setPixmap( image0 ); + GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 ); + LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); + LineEditC1A1Algo->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Algo->sizePolicy().hasHeightForWidth() ) ); + GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 ); + + SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + + Init(Sel) ; +} + + +//================================================================================= +// function : ~SMESHGUI_InitMeshDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_InitMeshDlg::~SMESHGUI_InitMeshDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel ) +{ + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myGeomFilter = new SALOME_TypeFilter( "GEOM" ); + myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); + myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); + + myNameMesh = "Mesh"; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButtonC1A1Algo, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_InitMeshDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + MESSAGE ( " myNameMesh " << myNameMesh.isEmpty() ) + MESSAGE ( " myGeomShape " << myGeomShape->_is_nil() ) + if ( !myNameMesh.isEmpty() && !myNameMesh.isNull() && !myGeomShape->_is_nil() ) + myMesh = mySMESHGUI->InitMesh( myGeomShape, myNameMesh ) ; + + MESSAGE ( " myMesh " << myMesh->_is_nil() ) + MESSAGE ( " myOkHypothesis " ) + MESSAGE ( " myOkAlgorithm " ) + if( myOkHypothesis && !myMesh->_is_nil() ) { + SALOME_ListIteratorOfListIO It( HypoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ; + } + } + + if( myOkAlgorithm && !myMesh->_is_nil() ) { + SALOME_ListIteratorOfListIO It( AlgoList ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + Standard_Boolean testResult; + myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; + if( testResult ) + mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ; + } + } + break ; + } + } +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_InitMeshDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( myEditCurrentArgument == LineEditC1A1 ) { + if ( nbSel != 1 ) { + myOkHypothesis = false; + myOkAlgorithm = false; + myGeomShape = GEOM::GEOM_Shape::_nil(); + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) { + myOkHypothesis = false; + myOkAlgorithm = false; + return ; + } + } + } + else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { + if ( nbSel >= 1 ) { + HypoList.Clear(); + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + HypoList.Append(Itinit.Value()); + } + myOkHypothesis = true ; + if (nbSel > 1) + aString = tr("%1 Hypothesis").arg(nbSel) ; + LineEditC1A1Hyp->setText(aString) ; + } + else { + myOkHypothesis = false ; + return ; + } + } else if ( myEditCurrentArgument == LineEditC1A1Algo ) { + if ( nbSel >= 1 ) { + AlgoList.Clear(); + SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + AlgoList.Append(Itinit.Value()); + } + myOkAlgorithm = true ; + if (nbSel > 1) + aString = tr("%1 Algorithms").arg(nbSel) ; + LineEditC1A1Algo->setText(aString) ; + } + else { + myOkAlgorithm = false ; + return ; + } + } + + myEditCurrentArgument->setText(aString) ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + mySelection->ClearFilters() ; + mySelection->AddFilter(myGeomFilter) ; + } else if( send == SelectButtonC1A1Hyp ) { + LineEditC1A1Hyp->setFocus() ; + myEditCurrentArgument = LineEditC1A1Hyp ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myHypothesisFilter) ; + } else if( send == SelectButtonC1A1Algo ) { + LineEditC1A1Algo->setFocus() ; + myEditCurrentArgument = LineEditC1A1Algo ; + mySelection->ClearFilters() ; + mySelection->AddFilter(myAlgorithmFilter) ; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_InitMeshDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameMesh) { + myNameMesh = newText; + } + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h new file mode 100644 index 000000000..24ea166a5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h @@ -0,0 +1,121 @@ +// File : SMESHGUI_InitMeshDlg.h +// Created : Mon May 27 10:23:17 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_INIT_MESH_H +#define DIALOGBOX_INIT_MESH_H + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" +#include "SMESH_TypeFilter.hxx" + +// QT Includes +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SMESH_Gen) + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_InitMeshDlg +// purpose : +//================================================================================= +class SMESHGUI_InitMeshDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_InitMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_InitMeshDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + SALOME_Selection* mySelection ; + + GEOM::GEOM_Shape_var myGeomShape ; + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QString myNameMesh ; + + Handle(SALOME_TypeFilter) myGeomFilter; + Handle(SMESH_TypeFilter) myHypothesisFilter; + Handle(SMESH_TypeFilter) myAlgorithmFilter; + + SALOME_ListIO HypoList; + SALOME_ListIO AlgoList; + + bool myOkHypothesis; + bool myOkAlgorithm; + + SMESH::SMESH_Hypothesis_var myHypothesis; + SMESH::SMESH_Hypothesis_var myAlgorithm; + + SMESH::SMESH_Mesh_var myMesh; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabel_NameMesh ; + QLineEdit* LineEdit_NameMesh ; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + + QLabel* TextLabelC1A1Hyp; + QPushButton* SelectButtonC1A1Hyp; + QLineEdit* LineEditC1A1Hyp; + + QLabel* TextLabelC1A1Algo; + QPushButton* SelectButtonC1A1Algo; + QLineEdit* LineEditC1A1Algo; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* SMESHGUI_InitMeshDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_INIT_MESH_H diff --git a/src/SMESHGUI/SMESHGUI_LocalLengthDlg.cxx b/src/SMESHGUI/SMESHGUI_LocalLengthDlg.cxx new file mode 100644 index 000000000..c94f34dda --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_LocalLengthDlg.cxx @@ -0,0 +1,315 @@ +using namespace std; +// File : SMESHGUI_LocalLengthDlg.cxx +// Created : Mon May 27 11:38:27 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_LocalLengthDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_LocalLengthDlg() +// purpose : Constructs a SMESHGUI_LocalLengthDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_LocalLengthDlg::SMESHGUI_LocalLengthDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_LOCAL_LENGTH"))); + + if ( !name ) + setName( "SMESHGUI_LocalLengthDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_LOCAL_LENGTH_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_LocalLengthDlgLayout = new QGridLayout( this ); + SMESHGUI_LocalLengthDlgLayout->setSpacing( 6 ); + SMESHGUI_LocalLengthDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_LocalLengthDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + SMESHGUI_LocalLengthDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabel_Length = new QLabel(GroupC1 , "TextLabel_Length" ); + TextLabel_Length->setText( tr( "SMESH_LENGTH" ) ); + GroupC1Layout->addWidget( TextLabel_Length, 1, 0 ); + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + SpinBox_Length = new SMESHGUI_SpinBox( GroupC1, "SpinBox_Length" ) ; + GroupC1Layout->addWidget( SpinBox_Length, 1, 1 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed ); + GroupC1Layout->addItem( spacer1, 1, 3 ); + SMESHGUI_LocalLengthDlgLayout->addWidget(GroupC1 , 1, 0 ); + + /***************************************************************/ + + Init() ; +} + + +//================================================================================= +// function : ~SMESHGUI_LocalLengthDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_LocalLengthDlg::~SMESHGUI_LocalLengthDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::Init() +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEdit_NameHypothesis ; + + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 1.0 ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_Length->RangeStepAndValidator( 0.001, 999.999, step, 3 ) ; + SpinBox_Length->SetValue( 1.0 ) ; /* is myLength */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + LineEdit_NameHypothesis->setText("") ; + + myLength = 1.0 ; + myNameHypothesis = "" ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_LocalLengthDlg::ConstructorsClicked(int constructorId) +{ + return; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + myLength = SpinBox_Length->GetValue() ; + mySMESHGUI->CreateLocalLength( "LocalLength", myNameHypothesis, myLength ); + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::ClickOnCancel() +{ + mySMESHGUI->ResetState() ; + reject() ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameHypothesis) { + myNameHypothesis = newText ; + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_LocalLengthDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_LocalLengthDlg.h b/src/SMESHGUI/SMESHGUI_LocalLengthDlg.h new file mode 100644 index 000000000..dddd00256 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_LocalLengthDlg.h @@ -0,0 +1,89 @@ +// File : SMESHGUI_LocalLengthDlg.h +// Created : Mon May 27 11:38:37 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_LOCAL_LENGTH_H +#define DIALOGBOX_LOCAL_LENGTH_H + +// QT Includes +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + + +//================================================================================= +// class : SMESHGUI_LocalLengthDlg +// purpose : +//================================================================================= +class SMESHGUI_LocalLengthDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_LocalLengthDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_LocalLengthDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + + QString myNameHypothesis ; + double myLength ; + bool myOkNameHypothesis ; + bool myOkLength ; + + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLabel* TextLabel_Length ; + QLineEdit* LineEdit_NameHypothesis ; + SMESHGUI_SpinBox* SpinBox_Length ; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* SMESHGUI_LocalLengthDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_LOCAL_LENGTH_H diff --git a/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.cxx b/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.cxx new file mode 100644 index 000000000..a95b5d1e0 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.cxx @@ -0,0 +1,315 @@ +using namespace std; +// File : SMESHGUI_MaxElementAreaDlg.cxx +// Created : Mon May 27 11:38:27 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_MaxElementAreaDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_MaxElementAreaDlg() +// purpose : Constructs a SMESHGUI_MaxElementAreaDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_MaxElementAreaDlg::SMESHGUI_MaxElementAreaDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MAX_ELEMENT_AREA"))); + + if ( !name ) + setName( "SMESHGUI_MaxElementAreaDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_MAX_ELEMENT_AREA_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_MaxElementAreaDlgLayout = new QGridLayout( this ); + SMESHGUI_MaxElementAreaDlgLayout->setSpacing( 6 ); + SMESHGUI_MaxElementAreaDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_MaxElementAreaDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + SMESHGUI_MaxElementAreaDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabel_MaxElementArea = new QLabel(GroupC1 , "TextLabel_MaxElementArea" ); + TextLabel_MaxElementArea->setText( tr( "SMESH_MAX_ELEMENT_AREA" ) ); + GroupC1Layout->addWidget( TextLabel_MaxElementArea, 1, 0 ); + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + SpinBox_MaxElementArea = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementArea" ) ; + GroupC1Layout->addWidget( SpinBox_MaxElementArea, 1, 1 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed ); + GroupC1Layout->addItem( spacer1, 1, 3 ); + SMESHGUI_MaxElementAreaDlgLayout->addWidget(GroupC1 , 1, 0 ); + + /***************************************************************/ + + Init() ; +} + + +//================================================================================= +// function : ~SMESHGUI_MaxElementAreaDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MaxElementAreaDlg::~SMESHGUI_MaxElementAreaDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::Init() +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEdit_NameHypothesis ; + + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 1.0 ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_MaxElementArea->setPrecision( 10 ); + SpinBox_MaxElementArea->RangeStepAndValidator( 0.001, 999999.999, step, 3 ) ; + SpinBox_MaxElementArea->SetValue( 1.0 ) ; /* is myMaxElementArea */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + LineEdit_NameHypothesis->setText("") ; + myNameHypothesis = "" ; + myMaxElementArea = 1.0 ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::ConstructorsClicked(int constructorId) +{ + return; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + myMaxElementArea = SpinBox_MaxElementArea->GetValue() ; + mySMESHGUI->CreateMaxElementArea( "MaxElementArea", myNameHypothesis, myMaxElementArea ); + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::ClickOnCancel() +{ + mySMESHGUI->ResetState() ; + reject() ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameHypothesis) { + myNameHypothesis = newText ; + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementAreaDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.h b/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.h new file mode 100644 index 000000000..6c9b4a33b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MaxElementAreaDlg.h @@ -0,0 +1,89 @@ +// File : SMESHGUI_MaxElementAreaDlg.h +// Created : Mon May 27 11:38:37 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_MAX_ELEMENT_AREA_H +#define DIALOGBOX_MAX_ELEMENT_AREA_H + +// QT Includes +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + + +//================================================================================= +// class : SMESHGUI_MaxElementAreaDlg +// purpose : +//================================================================================= +class SMESHGUI_MaxElementAreaDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MaxElementAreaDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_MaxElementAreaDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + + QString myNameHypothesis ; + double myMaxElementArea ; + bool myOkNameHypothesis ; + bool myOkMaxElementArea ; + + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLabel* TextLabel_MaxElementArea ; + QLineEdit* LineEdit_NameHypothesis ; + SMESHGUI_SpinBox* SpinBox_MaxElementArea ; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* SMESHGUI_MaxElementAreaDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_MAX_ELEMENT_AREA_H diff --git a/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.cxx new file mode 100644 index 000000000..135e7cd81 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.cxx @@ -0,0 +1,319 @@ +using namespace std; +// File : SMESHGUI_MaxElementVolumeDlg.cxx +// Created : Wed Jun 12 21:17:51 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_MaxElementVolumeDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_MaxElementVolumeDlg() +// purpose : Constructs a SMESHGUI_MaxElementVolumeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_MaxElementVolumeDlg::SMESHGUI_MaxElementVolumeDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MAX_ELEMENT_VOLUME"))); + + if ( !name ) + setName( "SMESHGUI_MaxElementVolumeDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_MAX_ELEMENT_VOLUME_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_MaxElementVolumeDlgLayout = new QGridLayout( this ); + SMESHGUI_MaxElementVolumeDlgLayout->setSpacing( 6 ); + SMESHGUI_MaxElementVolumeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_MaxElementVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + SMESHGUI_MaxElementVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabel_MaxElementVolume = new QLabel(GroupC1 , "TextLabel_MaxElementVolume" ); + TextLabel_MaxElementVolume->setText( tr( "SMESH_MAX_ELEMENT_VOLUME" ) ); + GroupC1Layout->addWidget( TextLabel_MaxElementVolume, 1, 0 ); + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + // LineEdit_MaxElementVolume = new QLineEdit(GroupC1 , "LineEdit_MaxElementVolume" ); + // GroupC1Layout->addWidget( LineEdit_MaxElementVolume, 1, 1 ); + SpinBox_MaxElementVolume = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementVolume" ) ; + GroupC1Layout->addWidget( SpinBox_MaxElementVolume, 1, 1 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed ); + GroupC1Layout->addItem( spacer1, 1, 3 ); + SMESHGUI_MaxElementVolumeDlgLayout->addWidget(GroupC1 , 1, 0 ); + + /***************************************************************/ + + Init() ; +} + + +//================================================================================= +// function : ~SMESHGUI_MaxElementVolumeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MaxElementVolumeDlg::~SMESHGUI_MaxElementVolumeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::Init() +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEdit_NameHypothesis ; + + + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 1.0 ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_MaxElementVolume->setPrecision( 10 ); + SpinBox_MaxElementVolume->RangeStepAndValidator( 0.001, 999999.999, step, 3 ) ; + SpinBox_MaxElementVolume->SetValue( 1.0 ) ; /* is myMaxElementVolume */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + LineEdit_NameHypothesis->setText("") ; + + myNameHypothesis = "" ; + myMaxElementVolume = 1.0 ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::ConstructorsClicked(int constructorId) +{ + return; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + myMaxElementVolume = SpinBox_MaxElementVolume->GetValue() ; + mySMESHGUI->CreateMaxElementVolume( "MaxElementVolume", myNameHypothesis, myMaxElementVolume ); + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::ClickOnCancel() +{ + mySMESHGUI->ResetState() ; + reject() ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameHypothesis) { + myNameHypothesis = newText ; + } + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MaxElementVolumeDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.h b/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.h new file mode 100644 index 000000000..582f5d5f9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MaxElementVolumeDlg.h @@ -0,0 +1,89 @@ +// File : SMESHGUI_MaxElementVolumeDlg.h +// Created : Wed Jun 12 21:18:15 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_MAX_ELEMENT_VOLUME_H +#define DIALOGBOX_MAX_ELEMENT_VOLUME_H + +// QT Includes +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + + +//================================================================================= +// class : SMESHGUI_MaxElementVolumeDlg +// purpose : +//================================================================================= +class SMESHGUI_MaxElementVolumeDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MaxElementVolumeDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_MaxElementVolumeDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + + QString myNameHypothesis ; + double myMaxElementVolume ; + bool myOkNameHypothesis ; + bool myOkMaxElementVolume ; + + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLabel* TextLabel_MaxElementVolume ; + QLineEdit* LineEdit_NameHypothesis ; + SMESHGUI_SpinBox* SpinBox_MaxElementVolume ; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* SMESHGUI_MaxElementVolumeDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_MAX_ELEMENT_VOLUME_H diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx new file mode 100644 index 000000000..ed5e38efe --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx @@ -0,0 +1,428 @@ +using namespace std; +// File : SMESHGUI_MeshInfosDlg.cxx +// Created : Sat Jun 08 15:31:16 2002 +// Author : Nicolas BARBEROU + +// Project : SALOME +// Module : SMESH +// Copyright : EADS CCR 2002 +// $Header$ + +#include "SMESHGUI_MeshInfosDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a SMESHGUI_MeshInfosDlg which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SMESHGUI_MeshInfosDlg::SMESHGUI_MeshInfosDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SMESHGUI_MeshInfosDlg" ); + setCaption( tr( "SMESH_MESHINFO_TITLE" ) ); + setSizeGripEnabled( TRUE ); + + SMESHGUI_MeshInfosDlgLayout = new QVBoxLayout( this ); + SMESHGUI_MeshInfosDlgLayout->setSpacing( 6 ); + SMESHGUI_MeshInfosDlgLayout->setMargin( 11 ); + + /****************************************************************/ + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setTitle( tr( "SMESH_MESHINFO_NB1D" ) ); + GroupBox1->setColumnLayout(0, Qt::Vertical ); + GroupBox1->layout()->setSpacing( 0 ); + GroupBox1->layout()->setMargin( 0 ); + QGridLayout* GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); + GroupBox1Layout->setAlignment( Qt::AlignTop ); + GroupBox1Layout->setSpacing( 6 ); + GroupBox1Layout->setMargin( 11 ); + + TextLabel11 = new QLabel( GroupBox1, "TextLabel11" ); + TextLabel11->setMinimumWidth( 100 ); + TextLabel11->setText( tr( "SMESH_MESHINFO_NODES" ) ); + GroupBox1Layout->addWidget( TextLabel11, 0, 0 ); + + TextLabel12 = new QLabel( GroupBox1, "TextLabel12" ); + TextLabel12->setMinimumWidth( 100 ); + TextLabel12->setText( tr( "SMESH_MESHINFO_EDGES" ) ); + GroupBox1Layout->addWidget( TextLabel12, 1, 0 ); + + TextLabel13 = new QLabel( GroupBox1, "TextLabel13" ); + TextLabel13->setMinimumWidth( 100 ); + GroupBox1Layout->addWidget( TextLabel13, 0, 1 ); + + TextLabel14 = new QLabel( GroupBox1, "TextLabel14" ); + TextLabel14->setMinimumWidth( 100 ); + GroupBox1Layout->addWidget( TextLabel14, 1, 1 ); + SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox1 ); + + /****************************************************************/ + GroupBox2 = new QGroupBox( this, "GroupBox2" ); + GroupBox2->setTitle( tr( "SMESH_MESHINFO_NB2D" ) ); + GroupBox2->setColumnLayout(0, Qt::Vertical ); + GroupBox2->layout()->setSpacing( 0 ); + GroupBox2->layout()->setMargin( 0 ); + QGridLayout* GroupBox2Layout = new QGridLayout( GroupBox2->layout() ); + GroupBox2Layout->setAlignment( Qt::AlignTop ); + GroupBox2Layout->setSpacing( 6 ); + GroupBox2Layout->setMargin( 11 ); + + TextLabel21 = new QLabel( GroupBox2, "TextLabel21" ); + TextLabel21->setMinimumWidth( 100 ); + TextLabel21->setText( tr( "SMESH_MESHINFO_TRIANGLES" ) ); + GroupBox2Layout->addWidget( TextLabel21, 0, 0 ); + + TextLabel22 = new QLabel( GroupBox2, "TextLabel22" ); + TextLabel22->setMinimumWidth( 100 ); + TextLabel22->setText( tr( "SMESH_MESHINFO_QUADRANGLES" ) ); + GroupBox2Layout->addWidget( TextLabel22, 1, 0 ); + + TextLabel23 = new QLabel( GroupBox2, "TextLabel23" ); + TextLabel23->setMinimumWidth( 100 ); + GroupBox2Layout->addWidget( TextLabel23, 0, 1 ); + + TextLabel24 = new QLabel( GroupBox2, "TextLabel24" ); + TextLabel24->setMinimumWidth( 100 ); + GroupBox2Layout->addWidget( TextLabel24, 1, 1 ); + SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox2 ); + + /****************************************************************/ + GroupBox3 = new QGroupBox( this, "GroupBox3" ); + GroupBox3->setTitle( tr( "SMESH_MESHINFO_NB3D" ) ); + GroupBox3->setColumnLayout(0, Qt::Vertical ); + GroupBox3->layout()->setSpacing( 0 ); + GroupBox3->layout()->setMargin( 0 ); + QGridLayout* GroupBox3Layout = new QGridLayout( GroupBox3->layout() ); + GroupBox3Layout->setAlignment( Qt::AlignTop ); + GroupBox3Layout->setSpacing( 6 ); + GroupBox3Layout->setMargin( 11 ); + + TextLabel31 = new QLabel( GroupBox3, "TextLabel31" ); + TextLabel31->setMinimumWidth( 100 ); + TextLabel31->setText( tr( "SMESH_MESHINFO_TETRAS" ) ); + GroupBox3Layout->addWidget( TextLabel31, 0, 0 ); + + TextLabel32 = new QLabel( GroupBox3, "TextLabel32" ); + TextLabel32->setMinimumWidth( 100 ); + TextLabel32->setText( tr( "SMESH_MESHINFO_HEXAS" ) ); + GroupBox3Layout->addWidget( TextLabel32, 1, 0 ); + + TextLabel33 = new QLabel( GroupBox3, "TextLabel33" ); + TextLabel33->setMinimumWidth( 100 ); + GroupBox3Layout->addWidget( TextLabel33, 0, 1 ); + + TextLabel34 = new QLabel( GroupBox3, "TextLabel34" ); + TextLabel34->setMinimumWidth( 100 ); + GroupBox3Layout->addWidget( TextLabel34, 1, 1 ); + SMESHGUI_MeshInfosDlgLayout->addWidget( GroupBox3 ); + + /****************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + SMESHGUI_MeshInfosDlgLayout->addWidget( GroupButtons ); + /****************************************************************/ + + Init( Sel ) ; +} + +/* + * Destroys the object and frees any allocated resources + */ +SMESHGUI_MeshInfosDlg::~SMESHGUI_MeshInfosDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::Init( SALOME_Selection* Sel ) +{ + mySelection = Sel ; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + myStudy = mySMESHGUI->GetActiveStudy()->getStudyDocument(); + + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH"); + myCompMesh = SMESH::SMESH_Gen::_narrow(comp); + + int nbSel = mySelection->IObjectCount(); + + TextLabel13->setText( "0" ); + TextLabel14->setText( "0" ); + TextLabel23->setText( "0" ); + TextLabel24->setText( "0" ); + TextLabel33->setText( "0" ); + TextLabel34->setText( "0" ); + + //gets the selected mesh + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res ); + if ( res ) + DumpMeshInfos(); + } + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays Dialog */ + + return ; +} + +//================================================================================= +// function : genEdgeKey +// purpose : edge counting helper; +// packs two long integers into one 8-byte value (treated as double by the caller); +// the order of arguments is insignificant +//================================================================================= +void genEdgeKey(long a, long b, void* key) +{ + long* lKey = (long*)key; + *lKey = (a < b) ? a : b; + *(++lKey) = (a < b) ? b : a; +} + +//================================================================================= +// function : DumpMeshInfos() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::DumpMeshInfos() +{ + int nbOfNodes = myMesh->NbNodes(); + int nbOfEdges = myMesh->NbEdges(); + int nbOfTriangles = myMesh->NbTriangles(); + int nbOfQuadrangles = myMesh->NbQuadrangles(); + int nbOfTetras = myMesh->NbTetras(); + int nbOfHexas = myMesh->NbHexas(); + + /* + int nbOfNodes = 0 ; + int nbOfEdges = 0 ; + int nbOfTriangles = 0 ; + int nbOfQuadrangles = 0 ; + int nbOfTetras = 0 ; + int nbOfHexas = 0 ; + int nbCells = 0 ; + int CellType = 0 ; + QMap aMapOfEdges; + + Standard_Boolean result; + SMESH_Actor* MeshActor = mySMESHGUI->FindActor(myMesh, result, true); + + if ( result ) { + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( MeshActor->DataSource ); + vtkPoints *Pts = ugrid->GetPoints(); + nbOfNodes = Pts->GetNumberOfPoints(); + int nbCells = ugrid->GetNumberOfCells(); + + for ( int i = 0; i < nbCells; i++ ) { + vtkCell* cellPtr = ugrid->GetCell(i); + CellType = cellPtr->GetCellType(); + switch (CellType) + { + case 3: //Edges + { + nbOfEdges++; + break; + } + case 5: //Triangles + { + nbOfTriangles++; + + for (int edgeNum = 0; edgeNum < 3; edgeNum++) { + vtkCell* edgePtr = cellPtr->GetEdge(edgeNum); + double anEdgeKey; + genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey); + if (!aMapOfEdges.contains(anEdgeKey)) { + nbOfEdges++; + aMapOfEdges.insert(anEdgeKey, 0); + } + } + break; + } + case 9: //Quadrangles + { + nbOfQuadrangles++; + + for (int edgeNum = 0; edgeNum < 4; edgeNum++) { + vtkCell* edgePtr = cellPtr->GetEdge(edgeNum); + double anEdgeKey; + genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey); + if (!aMapOfEdges.contains(anEdgeKey)) { + nbOfEdges++; + aMapOfEdges.insert(anEdgeKey, 0); + } + } + break; + } + case 10: //Tetraedras + { + nbOfTetras++; + + for (int edgeNum = 0; edgeNum < 6; edgeNum++) { + vtkCell* edgePtr = cellPtr->GetEdge(edgeNum); + double anEdgeKey; + genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey); + if (!aMapOfEdges.contains(anEdgeKey)) { + nbOfEdges++; + aMapOfEdges.insert(anEdgeKey, 0); + } + } + break; + } + case 12: //Hexahedras + { + nbOfHexas++; + + for (int edgeNum = 0; edgeNum < 12; edgeNum++) { + vtkCell* edgePtr = cellPtr->GetEdge(edgeNum); + double anEdgeKey; + genEdgeKey(edgePtr->GetPointId(0), edgePtr->GetPointId(1), &anEdgeKey); + if (!aMapOfEdges.contains(anEdgeKey)) { + nbOfEdges++; + aMapOfEdges.insert(anEdgeKey, 0); + } + } + break; + } + } + } + } + */ + TextLabel13->setText( tr( "%1" ).arg(nbOfNodes) ); + TextLabel14->setText( tr( "%1" ).arg(nbOfEdges) ); + TextLabel23->setText( tr( "%1" ).arg(nbOfTriangles) ); + TextLabel24->setText( tr( "%1" ).arg(nbOfQuadrangles) ); + TextLabel33->setText( tr( "%1" ).arg(nbOfTetras) ); + TextLabel34->setText( tr( "%1" ).arg(nbOfHexas) ); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::ClickOnOk() +{ + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void SMESHGUI_MeshInfosDlg::SelectionIntoArgument() +{ + TextLabel13->setText( "0" ); + TextLabel14->setText( "0" ); + TextLabel23->setText( "0" ); + TextLabel24->setText( "0" ); + TextLabel33->setText( "0" ); + TextLabel34->setText( "0" ); + + int nbSel = mySelection->IObjectCount(); + if ( nbSel == 1 ) { + Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( IObject, res ); + if ( res ) + DumpMeshInfos(); + } + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::closeEvent( QCloseEvent* e ) +{ + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : when mouse enter onto the QWidget +//================================================================================= +void SMESHGUI_MeshInfosDlg::enterEvent( QEvent * ) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::DeactivateActiveDialog() +{ + disconnect( mySelection, 0, this, 0 ); + + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MeshInfosDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate any active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + + return ; +} + diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h new file mode 100644 index 000000000..e2a352678 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h @@ -0,0 +1,83 @@ +// File : SMESHGUI_MeshInfosDlg.h +// Created : Sat Jun 08 15:31:16 2002 +// Author : Nicolas BARBEROU + +// Project : SALOME +// Module : SMESH +// Copyright : EADS CCR 2002 2002 +// $Header$ + +#ifndef SMESHGUI_MESHINFOSDLG_H +#define SMESHGUI_MESHINFOSDLG_H + +#include "SALOME_Selection.h" +#include "QAD_Study.h" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +// QT Includes +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QGroupBox; +class QLabel; +class QPushButton; +class SMESHGUI; + +class SMESHGUI_MeshInfosDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MeshInfosDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_MeshInfosDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void DumpMeshInfos(); + + SMESH::SMESH_Gen_var myCompMesh ; + SMESHGUI* mySMESHGUI ; + SMESH::SMESH_Mesh_var myMesh ; + SALOME_Selection* mySelection ; + SALOMEDS::Study_var myStudy; + + QGroupBox* GroupBox1; + QLabel* TextLabel12; + QLabel* TextLabel11; + QLabel* TextLabel13; + QLabel* TextLabel14; + QGroupBox* GroupBox2; + QLabel* TextLabel21; + QLabel* TextLabel22; + QLabel* TextLabel23; + QLabel* TextLabel24; + QGroupBox* GroupBox3; + QLabel* TextLabel31; + QLabel* TextLabel32; + QLabel* TextLabel33; + QLabel* TextLabel34; + QPushButton* buttonOk; + +private slots: + + void ClickOnOk(); + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QVBoxLayout* SMESHGUI_MeshInfosDlgLayout; + QHBoxLayout* Layout1; + +}; + +#endif // SMESHGUI_MESHINFOSDLG_H diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx new file mode 100644 index 000000000..8c2c18f22 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -0,0 +1,467 @@ +using namespace std; +// File : SMESHGUI_MoveNodesDlg.cxx +// Created : Thu Jun 20 22:30:09 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_MoveNodesDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Open CASCADE Include +#include + +// VTK Include +#include + +//================================================================================= +// class : SMESHGUI_MoveNodesDlg() +// purpose : +//================================================================================= +SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MOVE_NODE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_MoveNodesDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_MOVE_NODES_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_MoveNodesDlgLayout = new QGridLayout( this ); + SMESHGUI_MoveNodesDlgLayout->setSpacing( 6 ); + SMESHGUI_MoveNodesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_MoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_MoveNodesDlgLayout->addWidget( GroupButtons, 3, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_MOVE" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + SMESHGUI_MoveNodesDlgLayout->addWidget( GroupC1, 1, 0 ); + + /***************************************************************/ + GroupCoordinates = new QGroupBox( this, "GroupCoordinates" ); + GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) ); + GroupCoordinates->setColumnLayout(0, Qt::Vertical ); + GroupCoordinates->layout()->setSpacing( 0 ); + GroupCoordinates->layout()->setMargin( 0 ); + GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() ); + GroupCoordinatesLayout->setAlignment( Qt::AlignTop ); + GroupCoordinatesLayout->setSpacing( 6 ); + GroupCoordinatesLayout->setMargin( 11 ); + TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" ); + TextLabel_X->setText( tr( "SMESH_X" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 ); + TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" ); + TextLabel_Y->setText( tr( "SMESH_Y" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 ); + + SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 ); + + SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 ); + + SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 ); + + + TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" ); + TextLabel_Z->setText( tr( "SMESH_Z" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 ); + + SMESHGUI_MoveNodesDlgLayout->addWidget( GroupCoordinates, 2, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_MoveNodesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* Sel ) +{ + + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 25.0 ; + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkNodes = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_X->SetValue( 0.0 ) ; + SpinBox_Y->SetValue( 0.0 ) ; + SpinBox_Z->SetValue( 0.0 ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_MoveNodesDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkNodes) { + mySMESHGUI->EraseSimulationActors(); +// mySMESHGUI->MoveNode( myMesh, myIdnode, LineEdit_X->text().toFloat(), LineEdit_Y->text().toFloat(), LineEdit_Z->text().toFloat() ) ; +// mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_MoveNodesDlg::SelectionIntoArgument() +{ + + disconnect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + disconnect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + disconnect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + mySMESHGUI->EraseSimulationActors(); + + myEditCurrentArgument->setText("") ; + myOkNodes = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return ; + + int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes != 1) { + SpinBox_X->SetValue(0.0) ; + SpinBox_Y->SetValue(0.0) ; + SpinBox_Z->SetValue(0.0) ; + return ; + } + + if ( mySelection->SelectionMode() != 1 ){ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + SMESH_Actor* ac = mySMESHGUI->FindActorByEntry( mySelection->firstIObject()->getEntry(), res, false ); + if ( !res ) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + + TColStd_MapIteratorOfMapOfInteger ite( myMapIndex ); + if ( ite.More() ) { + myIdnode = ite.Key(); + mySimulationActor = mySMESHGUI->SimulationMoveNode( ac, myIdnode ); + } else + return ; + + MESSAGE ( " myIdnode " << myIdnode ); + + float *pt = ac->GetMapper()->GetInput()->GetPoint(myIdnode); + MESSAGE ( " pt " << pt[0] << ";" << pt[1] << ";" << pt[2] ) + + SpinBox_X->SetValue( (double)pt[0] ) ; + SpinBox_Y->SetValue( (double)pt[1] ) ; + SpinBox_Z->SetValue( (double)pt[2] ) ; + + connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + myOkNodes = true ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->EraseSimulationActors() ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void SMESHGUI_MoveNodesDlg::ValueChangedInSpinBox( double newValue ) +{ + double vx = SpinBox_X->GetValue() ; + double vy = SpinBox_Y->GetValue() ; + double vz = SpinBox_Z->GetValue() ; + + mySMESHGUI->DisplaySimulationMoveNode( mySimulationActor, myIdnode, vx, vy , vz ); +} diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h new file mode 100644 index 000000000..d1c733138 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h @@ -0,0 +1,111 @@ +// File : SMESHGUI_MoveNodesDlg.h +// Created : Thu Jun 20 22:30:22 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_MOVE_NODES_H +#define DIALOGBOX_MOVE_NODES_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +// VTK Include +#include + +//================================================================================= +// class : SMESHGUI_MoveNodesDlg +// purpose : +//================================================================================= +class SMESHGUI_MoveNodesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_MoveNodesDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + int myIdnode; + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + vtkActor *mySimulationActor; + + QGroupBox* GroupCoordinates; + QLabel* TextLabel_X; + QLabel* TextLabel_Y; + QLabel* TextLabel_Z; + SMESHGUI_SpinBox* SpinBox_X; + SMESHGUI_SpinBox* SpinBox_Y; + SMESHGUI_SpinBox* SpinBox_Z; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + QGridLayout* SMESHGUI_MoveNodesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupCoordinatesLayout; +}; + +#endif // DIALOGBOX_MOVE_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.cxx b/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.cxx new file mode 100644 index 000000000..aa6826383 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.cxx @@ -0,0 +1,310 @@ +using namespace std; +// File : SMESHGUI_NbSegmentsDlg.cxx +// Created : Mon May 27 11:38:27 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_NbSegmentsDlg.h" +#include "SMESHGUI.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_NbSegmentsDlg() +// purpose : Constructs a SMESHGUI_NbSegmentsDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_NbSegmentsDlg::SMESHGUI_NbSegmentsDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_NB_SEGMENTS"))); + + if ( !name ) + setName( "SMESHGUI_NbSegmentsDlg" ); + resize( 303, 175 ); + setCaption( tr( "SMESH_NB_SEGMENTS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_NbSegmentsDlgLayout = new QGridLayout( this ); + SMESHGUI_NbSegmentsDlgLayout->setSpacing( 6 ); + SMESHGUI_NbSegmentsDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_NbSegmentsDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_NB_SEGMENTS_HYPOTHESIS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_3, 0, 1 ); + SMESHGUI_NbSegmentsDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabel_NbSeg = new QLabel(GroupC1 , "TextLabel_NbSeg" ); + TextLabel_NbSeg->setText( tr( "SMESH_SEGMENTS" ) ); + GroupC1Layout->addWidget( TextLabel_NbSeg, 1, 0 ); + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + SpinBox_NbSeg = new QSpinBox( GroupC1, "SpinBox_NbSeg" ); + GroupC1Layout->addWidget( SpinBox_NbSeg, 1, 1 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + QSpacerItem* spacer1 = new QSpacerItem( 20, 24, QSizePolicy::Minimum, QSizePolicy::Fixed ); + GroupC1Layout->addItem( spacer1, 1, 3 ); + SMESHGUI_NbSegmentsDlgLayout->addWidget(GroupC1 , 1, 0 ); + + /***************************************************************/ + + Init() ; +} + + +//================================================================================= +// function : ~SMESHGUI_NbSegmentsDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_NbSegmentsDlg::~SMESHGUI_NbSegmentsDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::Init() +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEdit_NameHypothesis ; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + LineEdit_NameHypothesis->setText("") ; + + SpinBox_NbSeg->setMinValue( 1 ); + SpinBox_NbSeg->setMaxValue( 9999 ); + SpinBox_NbSeg->setValue(3) ; /* myNbSeg */ + + myNbSeg = 3.0 ; + myNameHypothesis = "" ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( LineEdit_NameHypothesis, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_NbSegmentsDlg::ConstructorsClicked(int constructorId) +{ + return; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + myNbSeg = SpinBox_NbSeg->value() ; + mySMESHGUI->CreateNbSegments( "NumberOfSegments", myNameHypothesis, myNbSeg ); + break ; + } + } + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::ClickOnCancel() +{ + mySMESHGUI->ResetState() ; + reject() ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameHypothesis) { + myNameHypothesis = newText ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_NbSegmentsDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.h b/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.h new file mode 100644 index 000000000..4ceedc2b4 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NbSegmentsDlg.h @@ -0,0 +1,89 @@ +// File : SMESHGUI_NbSegmentsDlg.h +// Created : Mon May 27 11:38:37 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_NB_SEGMENTS_H +#define DIALOGBOX_NB_SEGMENTS_H + +// QT Includes +#include +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QSpinBox; +class QPushButton; +class QRadioButton; +class SMESHGUI; + + +//================================================================================= +// class : SMESHGUI_NbSegmentsDlg +// purpose : +//================================================================================= +class SMESHGUI_NbSegmentsDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_NbSegmentsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_NbSegmentsDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + + QString myNameHypothesis ; + double myNbSeg ; + bool myOkNameHypothesis ; + QDoubleValidator *myVa ; + + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLabel* TextLabel_NbSeg ; + QLineEdit* LineEdit_NameHypothesis ; + QSpinBox* SpinBox_NbSeg ; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void DeactivateActiveDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_NbSegmentsDlgLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupC1Layout; + QGridLayout* GroupC2Layout; +}; + +#endif // DIALOGBOX_NB_SEGMENTS_H diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx new file mode 100644 index 000000000..e8121447e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -0,0 +1,397 @@ +using namespace std; +// File : SMESHGUI_NodesDlg.cxx +// Created : Tue May 14 21:35:46 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_NodesDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" +#include "QAD_MessageBox.h" + +#include "SMESH_Actor.h" +#include +#include + +// VTK Includes +#include +#include +#include +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_NodesDlg() +// purpose : +//================================================================================= +SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( QWidget* parent, + const char* name, + SALOME_Selection* Sel, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_NODE"))); + if ( !name ) + setName( "SMESHGUI_NodesDlg" ); + resize( 303, 185 ); + setCaption( tr( "MESH_NODE_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_NodesDlgLayout = new QGridLayout( this ); + SMESHGUI_NodesDlgLayout->setSpacing( 6 ); + SMESHGUI_NodesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_NodesDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "MESH_NODE" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer_2, 0, 1 ); + SMESHGUI_NodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupCoordinates = new QGroupBox( this, "GroupCoordinates" ); + GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) ); + GroupCoordinates->setColumnLayout(0, Qt::Vertical ); + GroupCoordinates->layout()->setSpacing( 0 ); + GroupCoordinates->layout()->setMargin( 0 ); + GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() ); + GroupCoordinatesLayout->setAlignment( Qt::AlignTop ); + GroupCoordinatesLayout->setSpacing( 6 ); + GroupCoordinatesLayout->setMargin( 11 ); + TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" ); + TextLabel_X->setText( tr( "SMESH_X" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 ); + TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" ); + TextLabel_Y->setText( tr( "SMESH_Y" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 ); + + TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" ); + TextLabel_Z->setText( tr( "SMESH_Z" ) ); + GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 ); + + SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 ); + + SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 ); + + SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ; + GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 ); + + SMESHGUI_NodesDlgLayout->addWidget( GroupCoordinates, 1, 0 ); + + /* Initialisation and display */ + Init(Sel) ; +} + + +//======================================================================= +// function : ~SMESHGUI_NodesDlg() +// purpose : Destructor +//======================================================================= +SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg() +{} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) +{ + /* Get setting of step value from file configuration */ + double step ; + // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO + // step = St.toDouble() ; TODO + step = 25.0 ; + + /* min, max, step and decimals for spin boxes */ + SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; + SpinBox_X->SetValue( 0.0 ) ; + SpinBox_Y->SetValue( 0.0 ) ; + SpinBox_Z->SetValue( 0.0 ) ; + + mySelection = Sel ; + myMeshGUI = SMESHGUI::GetSMESHGUI() ; + myMeshGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + + connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myMeshGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( myMeshGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + myMeshGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; + + SelectionIntoArgument(); +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue ) +{ + double vx = SpinBox_X->GetValue() ; + double vy = SpinBox_Y->GetValue() ; + double vz = SpinBox_Z->GetValue() ; + myMeshGUI->DisplaySimulationNode( myMesh, vx, vy, vz ); + //myMeshGUI->ViewNodes(); + + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_NodesDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//======================================================================= +// function : ClickOnApply() +// purpose : +//======================================================================= +void SMESHGUI_NodesDlg::ClickOnApply() +{ + if ( myMeshGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) { + return; + } + + if ( Constructor1->isChecked() ) { + /* Recup args and call method */ + double x = SpinBox_X->GetValue() ; + double y = SpinBox_Y->GetValue() ; + double z = SpinBox_Z->GetValue() ; + myMeshGUI->EraseSimulationActors() ; + myMeshGUI->AddNode( myMesh, x, y, z ) ; + myMeshGUI->ViewNodes(); + mySelection->ClearIObjects(); + } +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void SMESHGUI_NodesDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + myMeshGUI->ResetState() ; + myMeshGUI->EraseSimulationActors() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_NodesDlg::SelectionIntoArgument() +{ + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) { + SpinBox_X->SetValue(0.0) ; + SpinBox_Y->SetValue(0.0) ; + SpinBox_Z->SetValue(0.0) ; + return; + } + + Standard_Boolean res; + myMesh = myMeshGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) { + SpinBox_X->SetValue(0.0) ; + SpinBox_Y->SetValue(0.0) ; + SpinBox_Z->SetValue(0.0) ; + return ; + } + + if ( mySelection->SelectionMode() != 1 ) { + SpinBox_X->SetValue(0.0) ; + SpinBox_Y->SetValue(0.0) ; + SpinBox_Z->SetValue(0.0) ; + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + QString aString = ""; + int nbNodes = myMeshGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes != 1) { + SpinBox_X->SetValue(0.0) ; + SpinBox_Y->SetValue(0.0) ; + SpinBox_Z->SetValue(0.0) ; + return ; + } + + if ( nbNodes == 1 ) { + TColStd_MapOfInteger myMapIndex; + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + TColStd_MapIteratorOfMapOfInteger ite( myMapIndex ); + int idNodes[1]; + for ( ; ite.More(); ite.Next() ) { + idNodes[0] = ite.Key(); + } + + Standard_Boolean result; + SMESH_Actor* ac = myMeshGUI->FindActor( myMesh, result, true ); + vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->DataSource ); + float *p0 = ugrid->GetPoint(idNodes[0]); + + SpinBox_X->SetValue( p0[0] ) ; + SpinBox_Y->SetValue( p0[1] ) ; + SpinBox_Z->SetValue( p0[2] ) ; + + myMeshGUI->DisplaySimulationNode( myMesh, p0[0], p0[1], p0[2] ); + // myMeshGUI->ViewNodes(); + } + + return ; +} + + +//======================================================================= +// function : closeEvent() +// purpose : +//======================================================================= +void SMESHGUI_NodesDlg::closeEvent(QCloseEvent* e) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : to reactivate this dialog box when mouse enter onto the window +//================================================================================= +void SMESHGUI_NodesDlg::enterEvent( QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : public slot to deactivate if active +//================================================================================= +void SMESHGUI_NodesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupCoordinates->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + myMeshGUI->EraseSimulationActors() ; + myMeshGUI->ResetState() ; + myMeshGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_NodesDlg::ActivateThisDialog( ) +{ + myMeshGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupCoordinates->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h new file mode 100644 index 000000000..ee70b7a80 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -0,0 +1,96 @@ +// File : SMESHGUI_NodesDlg.h +// Created : Tue May 14 21:36:44 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_NODES_H +#define DIALOGBOX_NODES_H + +#include "SALOME_Selection.h" + +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QFrame; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_NodesDlg +// purpose : +//================================================================================= +class SMESHGUI_NodesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_NodesDlg( QWidget* parent = 0, const char* name = 0, + SALOME_Selection* Sel = 0, + bool modal = FALSE, + WFlags fl = 0 ); + + ~SMESHGUI_NodesDlg(); + +private : + + SALOME_Selection* mySelection ; + SMESHGUI* myMeshGUI ; + + SMESH::SMESH_Mesh_var myMesh; + + void Init(SALOME_Selection* Sel) ; + void enterEvent(QEvent* e); + void closeEvent(QCloseEvent* e) ; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupCoordinates; + SMESHGUI_SpinBox* SpinBox_X; + SMESHGUI_SpinBox* SpinBox_Y; + SMESHGUI_SpinBox* SpinBox_Z; + + QLabel* TextLabel_X; + QLabel* TextLabel_Y; + QLabel* TextLabel_Z; + + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void SelectionIntoArgument() ; + void ValueChangedInSpinBox( double newValue ) ; + +protected: + QGridLayout* SMESHGUI_NodesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupCoordinatesLayout; + QGridLayout* GroupButtonsLayout; +}; + +#endif // DIALOGBOX_NODES_H + diff --git a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx new file mode 100644 index 000000000..a08361407 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx @@ -0,0 +1,354 @@ +using namespace std; +// File : SMESHGUI_OrientationElementsDlg.cxx +// Created : Tue Jun 25 14:28:17 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_OrientationElementsDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_OrientationElementsDlg() +// purpose : +//================================================================================= +SMESHGUI_OrientationElementsDlg::SMESHGUI_OrientationElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_MESH_ORIENTATION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_OrientationElementsDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_ORIENTATION_ELEMENTS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_OrientationElementsDlgLayout = new QGridLayout( this ); + SMESHGUI_OrientationElementsDlgLayout->setSpacing( 6 ); + SMESHGUI_OrientationElementsDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ORIENTATION" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_OrientationElementsDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_OrientationElementsDlg::~SMESHGUI_OrientationElementsDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkElements = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_OrientationElementsDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkElements) { + mySMESHGUI->OrientationElements( myMesh, myMapIndex ) ; + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_OrientationElementsDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkElements = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ; + if(nbElements < 1) + return ; + + if ( mySelection->SelectionMode() != 3 ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + myOkElements = true ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_OrientationElementsDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h b/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h new file mode 100644 index 000000000..22a2a1f8d --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h @@ -0,0 +1,94 @@ +// File : SMESHGUI_OrientationElementsDlg.h +// Created : Tue Jun 25 14:30:34 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_ORIENTATION_ELEMENTS_H +#define DIALOGBOX_ORIENTATION_ELEMENTS_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_OrientationElementsDlg +// purpose : +//================================================================================= +class SMESHGUI_OrientationElementsDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_OrientationElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_OrientationElementsDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkElements ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_OrientationElementsDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_ORIENTATION_ELEMENTS_H diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx new file mode 100644 index 000000000..a978d821e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx @@ -0,0 +1,375 @@ +using namespace std; +// File : SMESHGUI_Preferences_ColorDlg.cxx +// Created : Mon Jun 17 19:11:27 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_Preferences_ColorDlg.h" +#include "SMESHGUI.h" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a SMESHGUI_Preferences_ColorDlg which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( QWidget* parent, const char* name ) + : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SMESHGUI_Preferences_ColorDlg" ); + setCaption( tr( "Preferences - Set Color" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* SMESHGUI_Preferences_ColorDlgLayout = new QGridLayout( this ); + SMESHGUI_Preferences_ColorDlgLayout->setSpacing( 6 ); + SMESHGUI_Preferences_ColorDlgLayout->setMargin( 11 ); + + ButtonGroup1 = new QButtonGroup( tr( "Elements" ), this, "ButtonGroup1" ); + ButtonGroup1->setColumnLayout(0, Qt::Vertical ); + ButtonGroup1->layout()->setSpacing( 0 ); + ButtonGroup1->layout()->setMargin( 0 ); + QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() ); + ButtonGroup1Layout->setAlignment( Qt::AlignTop ); + ButtonGroup1Layout->setSpacing( 6 ); + ButtonGroup1Layout->setMargin( 11 ); + + TextLabel_Fill = new QLabel( tr( "Fill" ), ButtonGroup1, "TextLabel_2D_Fill" ); + ButtonGroup1Layout->addWidget( TextLabel_Fill, 0, 0 ); + + btnFillColor = new QPushButton( ButtonGroup1, "btnFillColor" ); + btnFillColor->setFixedSize( QSize( 25, 25 ) ); + ButtonGroup1Layout->addWidget( btnFillColor, 0, 1 ); + + TextLabel_Outine = new QLabel( tr( "Outline" ), ButtonGroup1, "TextLabel_2D_Outine" ); + ButtonGroup1Layout->addWidget( TextLabel_Outine, 0, 2 ); + + btnOutlineColor = new QPushButton( ButtonGroup1, "btnOutlineColor" ); + btnOutlineColor->setFixedSize( QSize( 25, 25 ) ); + ButtonGroup1Layout->addWidget( btnOutlineColor, 0, 3 ); + + TextLabel_Width = new QLabel( tr( "Width" ), ButtonGroup1, "TextLabel_2D_Width" ); + ButtonGroup1Layout->addWidget( TextLabel_Width, 0, 4 ); + + SpinBox_Width = new QSpinBox( 0, 5, 1, ButtonGroup1, "SpinBox_Width" ); + SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBox_Width->setWrapping( FALSE ); + SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus ); + ButtonGroup1Layout->addWidget( SpinBox_Width, 0, 5 ); + + TextLabel_BackFace = new QLabel( tr( "Back Face" ), ButtonGroup1, "TextLabel_BackFace" ); + ButtonGroup1Layout->addWidget( TextLabel_BackFace, 1, 0 ); + + btnBackFaceColor = new QPushButton( ButtonGroup1, "btnBackFaceColor" ); + btnBackFaceColor->setFixedSize( QSize( 25, 25 ) ); + ButtonGroup1Layout->addWidget( btnBackFaceColor, 1, 1 ); + + TextLabel_ShrinkCoeff = new QLabel( tr( "Shrink coef." ), ButtonGroup1, "TextLabel_ShrinkCoeff" ); + ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, 2, 0 ); + + SpinBox_Shrink = new QSpinBox( 20, 100, 1, ButtonGroup1, "SpinBox_Shrink" ); + SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus ); + ButtonGroup1Layout->addMultiCellWidget( SpinBox_Shrink, 2, 2, 1, 5); + + SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup1, 0, 0 ); + + ButtonGroup2 = new QButtonGroup( tr( "Nodes" ), this, "ButtonGroup2" ); + ButtonGroup2->setColumnLayout(0, Qt::Vertical ); + ButtonGroup2->layout()->setSpacing( 0 ); + ButtonGroup2->layout()->setMargin( 0 ); + QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2->layout() ); + ButtonGroup2Layout->setAlignment( Qt::AlignTop ); + ButtonGroup2Layout->setSpacing( 6 ); + ButtonGroup2Layout->setMargin( 11 ); + + TextLabel_Nodes_Color = new QLabel( tr( "Color" ), ButtonGroup2, "TextLabel_Nodes_Color" ); + ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, 0, 0 ); + + btnNodeColor = new QPushButton( ButtonGroup2, "btnNodeColor" ); + btnNodeColor->setFixedSize( QSize( 25, 25 ) ); + ButtonGroup2Layout->addWidget( btnNodeColor, 0, 1 ); + + TextLabel_Nodes_Size = new QLabel( tr( "Size" ), ButtonGroup2, "TextLabel_Nodes_Size" ); + ButtonGroup2Layout->addWidget( TextLabel_Nodes_Size, 0, 2 ); + + SpinBox_Nodes_Size = new QSpinBox( 0, 5, 1, ButtonGroup2, "SpinBox_Nodes_Size" ); + SpinBox_Nodes_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBox_Nodes_Size->setWrapping( FALSE ); + SpinBox_Nodes_Size->setButtonSymbols( QSpinBox::PlusMinus ); + ButtonGroup2Layout->addWidget( SpinBox_Nodes_Size, 0, 3 ); + + SMESHGUI_Preferences_ColorDlgLayout->addWidget( ButtonGroup2, 1, 0 ); + + GroupButtons = new QButtonGroup( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + SMESHGUI_Preferences_ColorDlgLayout->addWidget( GroupButtons, 2, 0 ); + + Init(); +} + +/* + * Destroys the object and frees any allocated resources + */ +SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::Init() +{ + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( btnFillColor, SIGNAL( clicked() ), this, SLOT( SelectFillColor() ) ) ; + connect( btnOutlineColor, SIGNAL( clicked() ), this, SLOT( SelectOutlineColor() ) ) ; + connect( btnNodeColor, SIGNAL( clicked() ), this, SLOT( SelectNodeColor() ) ) ; + connect( btnBackFaceColor, SIGNAL( clicked() ), this, SLOT( SelectBackFaceColor() ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; +} + +//================================================================================= +// function : SelectFillColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SelectFillColor() +{ + QColor color = btnFillColor->palette().active().button(); + color = QColorDialog::getColor( color ); + if ( color.isValid() ) { + QPalette pal = btnFillColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnFillColor->setPalette(pal); + } +} + +//================================================================================= +// function : SelectBackFaceColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SelectBackFaceColor() +{ + QColor color = btnBackFaceColor->palette().active().button(); + color = QColorDialog::getColor( color ); + if ( color.isValid() ) { + QPalette pal = btnBackFaceColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnBackFaceColor->setPalette(pal); + } +} + +//================================================================================= +// function : SelectOutlineColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SelectOutlineColor() +{ + QColor color = btnOutlineColor->palette().active().button(); + color = QColorDialog::getColor( color ); + if ( color.isValid() ) { + QPalette pal = btnOutlineColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnOutlineColor->setPalette(pal); + } +} + +//================================================================================= +// function : SelectNodeColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SelectNodeColor() +{ + QColor color = btnNodeColor->palette().active().button(); + color = QColorDialog::getColor( color ); + if ( color.isValid() ) { + QPalette pal = btnNodeColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnNodeColor->setPalette(pal); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::ClickOnOk() +{ + mySMESHGUI->ResetState(); + accept(); +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::ClickOnCancel() +{ + mySMESHGUI->ResetState(); + reject() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog() +{ + return ; +} + + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; /* same than click on cancel button */ +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate any active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + + return ; +} + +//================================================================================= +// function : SetColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SetColor(int type, QColor color) +{ + switch (type) { + case 1 : // fill + { + QPalette pal = btnFillColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnFillColor->setPalette(pal); + break; + } + case 2 : // outline + { + QPalette pal = btnOutlineColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnOutlineColor->setPalette(pal); + break; + } + case 3 : // node + { + QPalette pal = btnNodeColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnNodeColor->setPalette(pal); + break; + } + case 4 : // back face + { + QPalette pal = btnBackFaceColor->palette(); + pal.setColor(QColorGroup::Button, color); + btnBackFaceColor->setPalette(pal); + break; + } + } +} + +//================================================================================= +// function : GetColor() +// purpose : +//================================================================================= +QColor SMESHGUI_Preferences_ColorDlg::GetColor(int type) +{ + QColor color; + switch (type) { + case 1 : color = btnFillColor->palette().active().button(); break; // fill + case 2 : color = btnOutlineColor->palette().active().button(); break; // outline + case 3 : color = btnNodeColor->palette().active().button(); break; // node + case 4 : color = btnBackFaceColor->palette().active().button(); break; // back face + } + return color; +} + +//================================================================================= +// function : SetIntValue() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_ColorDlg::SetIntValue(int type, int value) +{ + switch (type) { + case 1 : SpinBox_Width->setValue(value); break; // width + case 2 : SpinBox_Nodes_Size->setValue(value); break; // nodes size = value; break; + case 3 : SpinBox_Shrink->setValue(value); break; // shrink coeff + } +} + +//================================================================================= +// function : GetIntValue() +// purpose : +//================================================================================= +int SMESHGUI_Preferences_ColorDlg::GetIntValue(int type) +{ + int res = 0; + switch (type) { + case 1 : res = SpinBox_Width->value(); break; // width + case 2 : res = SpinBox_Nodes_Size->value(); break; // nodes size + case 3 : res = SpinBox_Shrink->value(); break; // shrink coeff + } + return res; +} diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h new file mode 100644 index 000000000..1f5afc3c5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h @@ -0,0 +1,86 @@ +// File : SMESHGUI_Preferences_ColorDlg.h +// Created : Mon Jun 17 19:11:46 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SMESHGUI_PREFERENCES_COLORDLG_H +#define SMESHGUI_PREFERENCES_COLORDLG_H + +// SALOME Includes +#include "QAD_Config.h" +#include "QAD_Settings.h" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) + +// QT Includes +#include + +class QButtonGroup; +class QFrame; +class QLabel; +class QPushButton; +class QSpinBox; +class QColor; +class SMESHGUI; + +class SMESHGUI_Preferences_ColorDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_Preferences_ColorDlg( QWidget* parent = 0, const char* name = 0 ); + ~SMESHGUI_Preferences_ColorDlg(); + + void SetColor(int type, QColor color); + QColor GetColor(int type); + void SetIntValue(int type, int value); + int GetIntValue(int type); + +private: + void closeEvent( QCloseEvent* e ) ; + void Init(); + +private slots: +// void RadioButtonClicked(int radioButtonId); + void ClickOnOk(); + void ClickOnCancel(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + + void SelectFillColor(); + void SelectBackFaceColor(); + void SelectOutlineColor(); + void SelectNodeColor(); + +private: + SMESH::SMESH_Gen_var myCompMesh ; + SMESHGUI* mySMESHGUI ; + + QButtonGroup* ButtonGroup1; + QLabel* TextLabel_Fill; + QPushButton* btnFillColor; + QLabel* TextLabel_Outine; + QPushButton* btnOutlineColor; + QLabel* TextLabel_Width; + QSpinBox* SpinBox_Width; + QLabel* TextLabel_BackFace; + QPushButton* btnBackFaceColor; + QLabel* TextLabel_ShrinkCoeff; + QSpinBox* SpinBox_Shrink; + QButtonGroup* ButtonGroup2; + QLabel* TextLabel_Nodes_Color; + QPushButton* btnNodeColor; + QLabel* TextLabel_Nodes_Size; + QSpinBox* SpinBox_Nodes_Size; + QButtonGroup* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // SMESHGUI_PREFERENCES_COLORDLG_H diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx new file mode 100644 index 000000000..eeefd0357 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -0,0 +1,187 @@ +using namespace std; +// File : SMESHGUI_Preferences_ScalarBarDlg.cxx +// Created : Tue Jun 11 17:23:32 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_Preferences_ScalarBarDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a SMESHGUI_Preferences_ScalarBarDlg which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SMESHGUI_Preferences_ScalarBarDlg::SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SMESHGUI_Preferences_ScalarBarDlg" ); + setCaption( tr( "SMESH_PREFERENCES_SCALARBAR" ) ); + setSizeGripEnabled( TRUE ); + + grid = new QGridLayout( this ); + grid->setSpacing( 6 ); + grid->setMargin( 11 ); + + /******************************************************************************/ + Properties = new QGroupBox( this, "Properties" ); + Properties->setTitle( tr( "SMESH_PROPERTIES" ) ); + Properties->setColumnLayout(0, Qt::Vertical ); + Properties->layout()->setSpacing( 0 ); + Properties->layout()->setMargin( 0 ); + grid_4 = new QGridLayout( Properties->layout() ); + grid_4->setAlignment( Qt::AlignTop ); + grid_4->setSpacing( 6 ); + grid_4->setMargin( 11 ); + + /* Font */ + grid_5 = new QGridLayout; + grid_5->setSpacing( 6 ); + grid_5->setMargin( 0 ); + TextLabel2 = new QLabel( Properties, "TextLabel2" ); + TextLabel2->setText( tr( "SMESH_FONT" ) ); + grid_5->addWidget( TextLabel2, 0, 0 ); + ComboBox1 = new QComboBox( FALSE, Properties, "ComboBox1" ); + ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ComboBox1->insertItem( tr( "SMESH_FONT_ARIAL" ) ); + ComboBox1->insertItem( tr( "SMESH_FONT_COURIER" ) ); + ComboBox1->insertItem( tr( "SMESH_FONT_TIMES" ) ); + grid_5->addWidget( ComboBox1, 0, 1 ); + grid_4->addLayout( grid_5, 0, 0 ); + + /* Font attributes */ + grid_6 = new QGridLayout; + grid_6->setSpacing( 6 ); + grid_6->setMargin( 0 ); + Bold = new QCheckBox( Properties, "Bold" ); + Bold->setText( tr( "SMESH_FONT_BOLD" ) ); + grid_6->addWidget( Bold, 0, 0 ); + Italic = new QCheckBox( Properties, "Italic" ); + Italic->setText( tr( "SMESH_FONT_ITALIC" ) ); + grid_6->addWidget( Italic, 0, 1 ); + Shadow = new QCheckBox( Properties, "Shadow" ); + Shadow->setText( tr( "SMESH_FONT_SHADOW" ) ); + grid_6->addWidget( Shadow, 0, 2 ); + grid_4->addLayout( grid_6, 1, 0 ); + + grid_7 = new QGridLayout; + grid_7->setSpacing( 6 ); + grid_7->setMargin( 0 ); + NumberColors = new QLabel( Properties, "NumberColors" ); + NumberColors->setText( tr( "SMESH_NUMBEROFCOLORS" ) ); + grid_7->addWidget( NumberColors, 0, 0 ); + SpinBoxColors = new QSpinBox( Properties, "SpinBoxColors" ); + SpinBoxColors->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBoxColors->setMinValue( 1 ); + grid_7->addWidget( SpinBoxColors, 0, 1 ); + NumberLabels = new QLabel( Properties, "NumberLabels" ); + NumberLabels->setText( tr( "SMESH_NUMBEROFLABELS" ) ); + grid_7->addWidget( NumberLabels, 1, 0 ); + SpinBoxLabels = new QSpinBox( Properties, "SpinBoxLabels" ); + SpinBoxLabels->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBoxLabels->setMinValue( 1 ); + grid_7->addWidget( SpinBoxLabels, 1, 1 ); + grid_4->addLayout( grid_7, 2, 0 ); + + grid->addWidget( Properties, 0, 0 ); + + /******************************************************************************/ + ButtonGroup_Orientation = new QButtonGroup( this, "ButtonGroup_Orientation" ); + ButtonGroup_Orientation->setTitle( tr( "SMESH_ORIENTATION" ) ); + ButtonGroup_Orientation->setColumnLayout(0, Qt::Vertical ); + ButtonGroup_Orientation->layout()->setSpacing( 0 ); + ButtonGroup_Orientation->layout()->setMargin( 0 ); + grid_2 = new QGridLayout( ButtonGroup_Orientation->layout() ); + grid_2->setAlignment( Qt::AlignTop ); + grid_2->setSpacing( 6 ); + grid_2->setMargin( 11 ); + RadioVert = new QRadioButton( ButtonGroup_Orientation, "RadioVert" ); + RadioVert->setText( tr( "SMESH_VERTICAL" ) ); + RadioHoriz = new QRadioButton( ButtonGroup_Orientation, "RadioHoriz" ); + RadioHoriz->setText( tr( "SMESH_HORIZONTAL" ) ); + grid_2->addWidget( RadioVert, 0, 0 ); + grid_2->addWidget( RadioHoriz, 0, 1 ); + + grid->addWidget( ButtonGroup_Orientation, 1, 0 ); + + /******************************************************************************/ + GroupBox5 = new QGroupBox( this, "GroupBox5" ); + GroupBox5->setTitle( tr( "SMESH_DIMENSIONS" ) ); + GroupBox5->setColumnLayout(0, Qt::Vertical ); + GroupBox5->layout()->setSpacing( 0 ); + GroupBox5->layout()->setMargin( 0 ); + grid_11 = new QGridLayout( GroupBox5->layout() ); + grid_11->setAlignment( Qt::AlignTop ); + grid_11->setSpacing( 6 ); + grid_11->setMargin( 11 ); + + LineEditWidth = new QLineEdit( GroupBox5, "LineEditWidth" ); + grid_11->addWidget( LineEditWidth, 0, 0 ); + Width = new QLabel( GroupBox5, "Width" ); + Width->setText( tr( "SMESH_WIDTH" ) ); + grid_11->addWidget( Width, 0, 1 ); + LineEditHeight = new QLineEdit( GroupBox5, "LineEditHeight" ); + grid_11->addWidget( LineEditHeight, 1, 0 ); + Height = new QLabel( GroupBox5, "Height" ); + Height->setText( tr( "SMESH_HEIGHT" ) ); + grid_11->addWidget( Height, 1, 1 ); + + grid->addWidget( GroupBox5, 2, 0 ); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + grid_15 = new QGridLayout( GroupButtons->layout() ); + grid_15->setAlignment( Qt::AlignTop ); + grid_15->setSpacing( 6 ); + grid_15->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + grid_15->addWidget( buttonOk, 0, 0 ); + grid_15->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CANCEL" ) ); + buttonCancel->setAutoDefault( TRUE ); + grid_15->addWidget( buttonCancel, 0, 2 ); + + grid->addWidget( GroupButtons, 3, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +SMESHGUI_Preferences_ScalarBarDlg::~SMESHGUI_Preferences_ScalarBarDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h new file mode 100644 index 000000000..5dbae2436 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.h @@ -0,0 +1,75 @@ +// File : SMESHGUI_Preferences_ScalarBarDlg.h +// Created : Tue Jun 11 17:23:15 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SMESHGUI_PREFERENCES_SCALARBARDLG_H +#define SMESHGUI_PREFERENCES_SCALARBARDLG_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QCheckBox; +class QComboBox; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QSpinBox; + +class SMESHGUI_Preferences_ScalarBarDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_Preferences_ScalarBarDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_Preferences_ScalarBarDlg(); + + QButtonGroup* ButtonGroup_Orientation; + QRadioButton* RadioHoriz; + QRadioButton* RadioVert; + QGroupBox* Properties; + QLabel* NumberLabels; + QLabel* NumberColors; + QSpinBox* SpinBoxLabels; + QSpinBox* SpinBoxColors; + QLabel* TextLabel2; + QComboBox* ComboBox1; + QCheckBox* Shadow; + QCheckBox* Italic; + QCheckBox* Bold; + QGroupBox* GroupBox5; + QLineEdit* LineEditWidth; + QLineEdit* LineEditHeight; + QLabel* Height; + QLabel* Width; + QPushButton* buttonCancel; + QPushButton* buttonOk; + +protected: + QGridLayout* grid; + QGridLayout* grid_2; + QGridLayout* grid_3; + QGridLayout* grid_4; + QGridLayout* grid_5; + QGridLayout* grid_6; + QGridLayout* grid_7; + QGridLayout* grid_8; + QGridLayout* grid_9; + QGridLayout* grid_10; + QGridLayout* grid_11; + QGridLayout* grid_12; + QGridLayout* grid_13; + QGridLayout* grid_14; + QGridLayout* grid_15; +}; + +#endif // SMESHGUI_PREFERENCES_SCALARBARDLG_H diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx new file mode 100644 index 000000000..f691de9d9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -0,0 +1,351 @@ +using namespace std; +// File : SMESHGUI_RemoveElementsDlg.cxx +// Created : Fri Jun 07 11:18:31 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_RemoveElementsDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_RemoveElementsDlg() +// purpose : +//================================================================================= +SMESHGUI_RemoveElementsDlg::SMESHGUI_RemoveElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_REM_ELEMENT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_RemoveElementsDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_REMOVE_ELEMENTS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_RemoveElementsDlgLayout = new QGridLayout( this ); + SMESHGUI_RemoveElementsDlgLayout->setSpacing( 6 ); + SMESHGUI_RemoveElementsDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_REMOVE" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_RemoveElementsDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_RemoveElementsDlg::~SMESHGUI_RemoveElementsDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkElements = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_RemoveElementsDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkElements) { + mySMESHGUI->RemoveElements( myMesh, myMapIndex ) ; + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkElements = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ; + if(nbElements < 1) + return ; + + if ( mySelection->SelectionMode() != 3 ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + myOkElements = true ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_RemoveElementsDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h new file mode 100644 index 000000000..66a1809c2 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h @@ -0,0 +1,93 @@ +// File : SMESHGUI_RemoveElementsDlg.h +// Created : Fri Jun 07 11:18:42 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_REMOVE_ELEMENTS_H +#define DIALOGBOX_REMOVE_ELEMENTS_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_RemoveElementsDlg +// purpose : +//================================================================================= +class SMESHGUI_RemoveElementsDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_RemoveElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_RemoveElementsDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkElements ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_RemoveElementsDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_REMOVE_ELEMENTS_H diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx new file mode 100644 index 000000000..c3a989e44 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -0,0 +1,362 @@ +using namespace std; +// File : SMESHGUI_RemoveNodesDlg.cxx +// Created : Fri Jun 07 11:18:31 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_RemoveNodesDlg.h" + +#include "SMESHGUI.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_RemoveNodesDlg() +// purpose : +//================================================================================= +SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_DLG_REM_NODE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESHGUI",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_RemoveNodesDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_REMOVE_NODES_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_RemoveNodesDlgLayout = new QGridLayout( this ); + SMESHGUI_RemoveNodesDlgLayout->setSpacing( 6 ); + SMESHGUI_RemoveNodesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_REMOVE" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_RemoveNodesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + this->myOkNodes = false ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + SelectionIntoArgument(); + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_RemoveNodesDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if(myOkNodes) { + mySMESHGUI->EraseSimulationActors(); + mySMESHGUI->RemoveNodes( myMesh, myMapIndex ) ; + mySMESHGUI->ViewNodes(); + mySelection->ClearIObjects(); + } + break ; + } + } + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::ClickOnCancel() +{ + QAD_Application::getDesktop()->SetSelectionMode( 4 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + mySMESHGUI->EraseSimulationActors(); + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + myOkNodes = false; + QString aString = ""; + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return ; + + int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes < 1) + return ; + + if ( mySelection->SelectionMode() != 1 ){ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), + tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_YES") ); + return; + } + + myEditCurrentArgument->setText(aString) ; + Standard_Boolean res; + myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); + if (!res) + return ; + + mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + + myOkNodes = true ; + return ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->EraseSimulationActors() ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_RemoveNodesDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h new file mode 100644 index 000000000..28c2358cc --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -0,0 +1,93 @@ +// File : SMESHGUI_RemoveNodesDlg.h +// Created : Fri Jun 07 11:18:42 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_REMOVE_NODES_H +#define DIALOGBOX_REMOVE_NODES_H + +#include "SALOME_Selection.h" + +// QT Includes +#include +#include + +// Open CASCADE Includes +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class SMESHGUI; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +//================================================================================= +// class : SMESHGUI_RemoveNodesDlg +// purpose : +//================================================================================= +class SMESHGUI_RemoveNodesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_RemoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_RemoveNodesDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + int myConstructorId ; /* Current constructor id = radio button id */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + SMESH::SMESH_Mesh_var myMesh; + TColStd_MapOfInteger myMapIndex; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_RemoveNodesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_REMOVE_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.cxx b/src/SMESHGUI/SMESHGUI_SpinBox.cxx new file mode 100644 index 000000000..86966ab50 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SpinBox.cxx @@ -0,0 +1,77 @@ +using namespace std; +// File : SMESHGUI_SpinBox.cxx +// Created : 14 august 2002 +// Author : Lucien PIGNOLONI +// Project : SALOME +// Module : SMESHGUI +// Copyright : OPEN CASCADE +// $Header$ + +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI.h" +#include + +//================================================================================= +// class : SMESHGUI_SpinBox() +// purpose : constructor of specific widget accepting floats in double precision. +//================================================================================= +SMESHGUI_SpinBox::SMESHGUI_SpinBox( QWidget* parent, const char* name ) +: QAD_SpinBoxDbl( parent, name) +{ +} + + +//================================================================================= +// function : SetStep() [SLOT] +// purpose : +//================================================================================= +void SMESHGUI_SpinBox::SetStep( double newStep ) +{ + setLineStep( newStep ); +} + +//================================================================================= +// function : ~SMESHGUI_SpinBox() +// purpose : destructor +//================================================================================= +SMESHGUI_SpinBox::~SMESHGUI_SpinBox() +{ +} + +//================================================================================= +// function : SetValue() +// purpose : +//================================================================================= +void SMESHGUI_SpinBox::SetValue( double v ) +{ + setValue( v ); +} + +//================================================================================= +// function : GetValue() +// purpose : returns a double +//================================================================================= +double SMESHGUI_SpinBox::GetValue( ) +{ + return value(); +} + +//================================================================================= +// function : GetString() +// purpose : returns a QString +//================================================================================= +QString SMESHGUI_SpinBox::GetString( ) +{ + return cleanText(); +} + +//================================================================================= +// function : RangeStepAndValidator() +// purpose : +//================================================================================= +void SMESHGUI_SpinBox::RangeStepAndValidator( double min, double max, double step, unsigned short decimals ) +{ + setRange( min, max ); + setLineStep( step ); + ( ( QDoubleValidator* )validator() )->setRange( min, max, decimals ) ; +} diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.h b/src/SMESHGUI/SMESHGUI_SpinBox.h new file mode 100644 index 000000000..1461aa26a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SpinBox.h @@ -0,0 +1,39 @@ +// File : SMESHGUI_SpinBox.h +// Created : 14 august 2002 +// Author : Lucien PIGNOLONI +// Project : SALOME +// Module : SMESHGUI +// Copyright : OPEN CASCADE +// $Header$ + +#ifndef SMESHSPINBOX_H +#define SMESHSPINBOX_H + +#include "QAD_SpinBoxDbl.h" + +//================================================================================= +// class : SMESHGUI_SpinBox +// purpose : Derivated from QAD_SpinBoxDbl class +//================================================================================= +class SMESHGUI_SpinBox : public QAD_SpinBoxDbl +{ + Q_OBJECT + +public : + + SMESHGUI_SpinBox( QWidget* parent, const char* name = 0 ) ; + ~SMESHGUI_SpinBox() ; + + void RangeStepAndValidator( double min = -1000000.0, + double max = +1000000.0, + double step = 100.0, + unsigned short decimals = 3 ) ; + void SetValue( double v ) ; + double GetValue() ; + QString GetString() ; + +public slots: + void SetStep( double newStep ); + +}; +#endif // SMESHSPINBOX_H diff --git a/src/SMESHGUI/SMESHGUI_StudyAPI.cxx b/src/SMESHGUI/SMESHGUI_StudyAPI.cxx new file mode 100644 index 000000000..ff871b1c5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_StudyAPI.cxx @@ -0,0 +1,691 @@ +using namespace std; +// File : SMESHGUI_StudyAPI.cxx +// Created : Fri May 17 15:23:35 CEST 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE +// $Header: + +#include "SMESHGUI_StudyAPI.h" +#include "utilities.h" +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +#include "QAD_MessageBox.h" +#include "QAD_Application.h" + +// QT Includes +#include + +// Open CASCADE Includes +#include "Standard_CString.hxx" + +static CORBA::ORB_var _orb; + +// Tags definition +long Tag_HypothesisRoot = 1; +long Tag_AlgorithmsRoot = 2; + +long Tag_RefOnShape = 1; +long Tag_RefOnAppliedHypothesis = 2; +long Tag_RefOnAppliedAlgorithms = 3; + +long Tag_SubMeshOnVertex = 4; +long Tag_SubMeshOnEdge = 5; +long Tag_SubMeshOnFace = 6; +long Tag_SubMeshOnSolid = 7; +long Tag_SubMeshOnCompound = 8; + + + +static char* IORToString (CORBA::Object_ptr obj) +{ + // MESSAGE ( " IORToString " << _orb->object_to_string(obj) ) + return _orb->object_to_string(obj); +} + +CORBA::Object_ptr SMESHGUI_StudyAPI::StringToIOR (const char* IOR) +{ + // MESSAGE ( " StringToIOR " << _orb->string_to_object(IOR) ) + return _orb->string_to_object(IOR); +} +//======================================================================= +// function : +// purpose : Constructor +//======================================================================= +SMESHGUI_StudyAPI::SMESHGUI_StudyAPI () +{ +} + +SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy, + SMESH::SMESH_Gen_ptr CompMesh) +{ + myStudy = aStudy; + myStudyBuilder = aStudy->NewBuilder(); + + setOrb(); + + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + + return; + } + // NRI + + SALOMEDS::SComponent_var father = aStudy->FindComponent("MESH"); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + + if (father->_is_nil()) { + father = myStudyBuilder->NewComponent("MESH"); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + //NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT")); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) ); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); + } + myStudyBuilder->DefineComponentInstance(father, CompMesh ); + mySComponentMesh = SALOMEDS::SComponent::_narrow( father ); +} + +//======================================================================= +// function : +// purpose : Destructor +//======================================================================= +SMESHGUI_StudyAPI::~SMESHGUI_StudyAPI () +{ +} + +//======================================================================= +// function : +// purpose : Update +//======================================================================= +void SMESHGUI_StudyAPI::Update(SMESH::SMESH_Gen_ptr CompMesh) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + + SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH"); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + + if (father->_is_nil()) { + father = myStudyBuilder->NewComponent("MESH"); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + //NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT")); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) ); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); + } + myStudyBuilder->DefineComponentInstance(father, CompMesh ); + mySComponentMesh = SALOMEDS::SComponent::_narrow( father ); +} + +//======================================================================= +// function : AddNewMesh +// purpose : +//======================================================================= + +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewMesh (SMESH::SMESH_Mesh_ptr M) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + //Find or Create Hypothesis root + SALOMEDS::SObject_var HypothesisRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) { + HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + + SALOMEDS::SObject_var AlgorithmsRoot; + if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) { + AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + + // Add New Mesh + SALOMEDS::SObject_var newMesh = myStudyBuilder->NewObject(mySComponentMesh); + anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IORToString(M)); + return SALOMEDS::SObject::_narrow( newMesh ); +} + + +//======================================================================= +// function : SetShape +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::SetShape (SALOMEDS::SObject_ptr SO_MorSM, + SALOMEDS::SObject_ptr SO_GeomShape ) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + SALOMEDS::SObject_var SO = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnShape); + myStudyBuilder->Addreference (SO,SO_GeomShape); +} + +//======================================================================= +// function : GetShapeOnMeshOrSubMesh +// purpose : +//======================================================================= +GEOM::GEOM_Shape_ptr SMESHGUI_StudyAPI::GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return GEOM::GEOM_Shape::_nil(); + } + // NRI + + GEOM::GEOM_Shape_var Shape; + SALOMEDS::SObject_var aSO, aGeom; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + if ( SO_Mesh_Or_SubMesh->FindSubObject( Tag_RefOnShape, aSO ) ) { + if ( aSO->ReferencedObject(aGeom) ) { + if (aGeom->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + return GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) ); + } + } + } + return GEOM::GEOM_Shape::_nil(); +} + +//======================================================================= +// function : AddNewHypothesis +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewHypothesis (SMESH::SMESH_Hypothesis_ptr H) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + //Find or Create Hypothesis root + SALOMEDS::SObject_var HypothesisRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) { + HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + } + // Add New Hypothesis + SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + QString aType = H->GetName(); + MESSAGE ( " aType " << aType ) + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_" + aType ); + // if ( aType.compare("LocalLength") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_LENGTH" ); + // else if ( aType.compare("NumberOfSegments") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_SEGMENT" ); + // else if ( aType.compare("MaxElementArea") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_AREA" ); + // else if ( aType.compare("MaxElementVolume") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_VOLUME" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IORToString(H)); + return SALOMEDS::SObject::_narrow(newHypo); +} + +//======================================================================= +// function : AddNewAlgorithms +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddNewAlgorithms (SMESH::SMESH_Hypothesis_ptr H) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + //Find or Create Algorithms root + SALOMEDS::SObject_var AlgorithmsRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) { + AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + } + // Add New Algorithms + SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + QString aType = H->GetName(); + // if ( aType.compare("Regular_1D") == 0 ) + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_" + aType ); + // aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_REGULAR" ); + // else if ( aType.compare("MEFISTO_2D") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_MEFISTO" ); + // else if ( aType.compare("Quadrangle_2D") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_QUAD" ); + // else if ( aType.compare("Hexa_3D") == 0 ) + // aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_HEXA" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IORToString(H)); + return SALOMEDS::SObject::_narrow(newHypo); +} + + +//======================================================================= +// function : AddSubMeshOnShape +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, + SMESH::SMESH_subMesh_ptr SM, + GEOM::shape_type ST) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + long Tag_Shape ; + Standard_CString Name; + + if (ST == GEOM::SOLID) {Tag_Shape = Tag_SubMeshOnSolid; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnSolid"));} + else if (ST == GEOM::FACE) {Tag_Shape = Tag_SubMeshOnFace; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnFace"));} + else if (ST == GEOM::EDGE) {Tag_Shape = Tag_SubMeshOnEdge; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnEdge"));} + else if (ST == GEOM::VERTEX){Tag_Shape = Tag_SubMeshOnVertex; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnVertex"));} + else { + Tag_Shape = Tag_SubMeshOnCompound; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnCompound")); + } + + SALOMEDS::SObject_var SubmeshesRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + + if (!SO_Mesh->FindSubObject (Tag_Shape,SubmeshesRoot )) { + SubmeshesRoot = myStudyBuilder->NewObjectToTag (SO_Mesh, Tag_Shape); + anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(Name); + anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IORToString(SM)); + return SALOMEDS::SObject::_narrow( SO ); +} + +//======================================================================= +// function : AddSubMeshOnShape +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, + SALOMEDS::SObject_ptr SO_GeomShape, + SMESH::SMESH_subMesh_ptr SM, + GEOM::shape_type ST) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + SALOMEDS::SObject_var SO_SM = AddSubMeshOnShape (SO_Mesh,SM,ST); + SetShape (SO_SM,SO_GeomShape); + // SetShapeOnSubMesh (SO_SM,SO_GeomShape); + return SALOMEDS::SObject::_narrow( SO_SM ); +} + + +//======================================================================= +// function : SetHypothesis +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::SetHypothesis (SALOMEDS::SObject_ptr SO_MorSM, + SALOMEDS::SObject_ptr SO_Hypothesis) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + + //Find or Create Applied Hypothesis root + SALOMEDS::SObject_var AHR; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedHypothesis, AHR)) { + AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); + myStudyBuilder->Addreference (SO,SO_Hypothesis); +} + +//======================================================================= +// function : SetAlgorithms +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::SetAlgorithms (SALOMEDS::SObject_ptr SO_MorSM, + SALOMEDS::SObject_ptr SO_Algorithms) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + + //Find or Create Applied Algorithms root + SALOMEDS::SObject_var AHR; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedAlgorithms, AHR)) { + AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); + myStudyBuilder->Addreference (SO,SO_Algorithms); +} + + +//======================================================================= +// function : +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindMesh (SMESH::SMESH_Mesh_ptr M) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(M)) ); +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(H)) ); +} + + +//======================================================================= +// function : +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindSubMesh (SMESH::SMESH_subMesh_ptr SM) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + return SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR (IORToString(SM)) ); +} + + +void SMESHGUI_StudyAPI::setOrb() +{ + try { + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init( 0 , 0 ); + } catch (...) { + INFOS("internal error : orb not found"); + _orb = 0; + } + ASSERT(! CORBA::is_nil(_orb)); +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::SetTagHypothesisRoot() +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(mySComponentMesh); + int i = 0; + for (; it->More();it->Next()) { + i++; + } + Tag_HypothesisRoot = i++; +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::SetName( SALOMEDS::SObject_ptr SO, const char* Name ) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(Name); +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + myStudyBuilder->RemoveObject(SO_Applied_Hypothesis); +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +void SMESHGUI_StudyAPI::UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return; + } + // NRI + myStudyBuilder->RemoveObject(SO_Applied_Algorithm); +} + +//======================================================================= +// function : +// purpose : +//======================================================================= +SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return SALOMEDS::SObject::_nil(); + } + // NRI + + SALOMEDS::SObject_var MorSM,SB; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if (SO->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + GEOM::GEOM_Shape_var Shape = GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) ); + if (!Shape->_is_nil()) { + //It s a shape + MorSM = SO->GetFather(); + // MESSAGE ( " MorSM shape " << MorSM->GetID() ) + return SALOMEDS::SObject::_narrow( MorSM); + } + } + + if (SO->ReferencedObject(SB)) { + //It's Reference on Hypothesis or Algorithm + MorSM = SO->GetFather()->GetFather(); + // MESSAGE ( " MorSM reference " << MorSM->GetID() ) + return SALOMEDS::SObject::_narrow( MorSM); + } + // It's SMESH_MEN_APPLIED_HYPOTHESIS or SMESH_MEN_APPLIED_ALGORITHMS or SubMeshesOnFace etc... + MorSM = SO->GetFather(); + // MESSAGE ( " MorSM banniere " << MorSM->GetID() ) + return SALOMEDS::SObject::_narrow( MorSM); +} + +void SMESHGUI_StudyAPI::ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right) +{ + // NRI : Temporary added + if ( myStudy->GetProperties()->IsLocked() ) { + return ; + } + // NRI + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + anAttr = myStudyBuilder->FindOrCreateAttribute(MorSM, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if (right) { + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); + } else { + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" ); + } + + int i = 1; + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(MorSM); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Obj = it->Value(); + if ( i >= 4 ) { + int j = 1; + SALOMEDS::ChildIterator_var it1 = myStudy->NewChildIterator(Obj); + for (; it1->More();it1->Next()) { + SALOMEDS::SObject_var Obj1 = it1->Value(); + anAttr = myStudyBuilder->FindOrCreateAttribute(Obj1, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if (right) { + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); + } else { + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" ); + } + } + } + i++; + } +} diff --git a/src/SMESHGUI/SMESHGUI_StudyAPI.h b/src/SMESHGUI/SMESHGUI_StudyAPI.h new file mode 100644 index 000000000..a24863eeb --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_StudyAPI.h @@ -0,0 +1,86 @@ +// File : SMESHGUI_StudyAPI.h +// Created : Fri May 17 15:23:35 CEST 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE +// $Header: + +#ifndef _INCLUDE_SMESHGUI_StudyAPI_ +#define _INCLUDE_SMESHGUI_StudyAPI_ + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class SMESH_subMesh_ptr; + +class SMESHGUI_StudyAPI { + + public: + + SMESHGUI_StudyAPI (); + + SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy, SMESH::SMESH_Gen_ptr Gen); + + ~SMESHGUI_StudyAPI (); + + // Adding in Study + CORBA::Object_ptr StringToIOR(const char* IOR); + + SALOMEDS::SObject_ptr AddNewMesh (SMESH::SMESH_Mesh_ptr M); + + SALOMEDS::SObject_ptr AddNewHypothesis (SMESH::SMESH_Hypothesis_ptr H); + SALOMEDS::SObject_ptr AddNewAlgorithms (SMESH::SMESH_Hypothesis_ptr H); + + SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST); + + SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SALOMEDS::SObject_ptr SO_GeomShape, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST); + + void Update(SMESH::SMESH_Gen_ptr Gen); + + void ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right); + + + void SetShape (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_GeomShape); + GEOM::GEOM_Shape_ptr GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh); + + void SetHypothesis (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Hypothesis); + void SetAlgorithms (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Algorithms); + + void UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis); + void UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm); + + void SetTagHypothesisRoot(); + + void SetName( SALOMEDS::SObject_ptr SO, const char* Name ) ; + + //Exploration + + SALOMEDS::SObject_ptr GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO); + + SALOMEDS::SObject_ptr FindMesh (SMESH::SMESH_Mesh_ptr M); + + SALOMEDS::SObject_ptr FindHypothesisOrAlgorithms (SMESH::SMESH_Hypothesis_ptr H); + + SALOMEDS::SObject_ptr FindSubMesh (SMESH::SMESH_subMesh_ptr SM); + + //SALOMEDS::ListOfSObject_ptr FindMesh (SALOMEDS_SObject_ptr SO_GeomShape); + //SALOMEDS_SObject_ptr FindSubMesh (SALOMEDS_SObject_ptr SO_Mesh, SALOMEDS_SObject_ptr SO_GeomShape); + + static void setOrb(); + + private: + //fields + SALOMEDS::Study_var myStudy; + SALOMEDS::StudyBuilder_var myStudyBuilder; + SALOMEDS::SComponent_var mySComponentMesh; + +}; +#endif + diff --git a/src/SMESHGUI/SMESHGUI_Swig.cxx b/src/SMESHGUI/SMESHGUI_Swig.cxx new file mode 100644 index 000000000..b57199092 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Swig.cxx @@ -0,0 +1,405 @@ +using namespace std; +// File : SMESH_Swig.cxx +// Created : Mon Jun 17 13:41:43 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_Swig.hxx" + +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +// SALOME Includes +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_ResourceMgr.h" + +#include "utilities.h" + +// Open CASCADE Includes +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) +#include CORBA_SERVER_HEADER(GEOM_Shape) + +static CORBA::ORB_var _orb; + +static char* ObjectToString (CORBA::Object_ptr obj) +{ + return _orb->object_to_string(obj); +} + +static CORBA::Object_ptr StringToObject (const char* ior) +{ + return _orb->string_to_object(ior); +} + +SMESH_Swig::SMESH_Swig() +{ + MESSAGE("Constructeur"); + setOrb(); +} + +void SMESH_Swig::Init(int studyID) +{ + MESSAGE("Init"); + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "SMESH"); + SMESH::SMESH_Gen_var CompMesh = SMESH::SMESH_Gen::_narrow(comp); + + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) { + QString msg; + if (!resMgr->loadResources( "SMESH", msg )) + MESSAGE ( msg ) + } + + CORBA::Object_var obj = QAD_Application::getDesktop()->getNameService()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); + myStudy = myStudyMgr->GetStudyByID(studyID); + myStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePixMap_var aPixmap; + + SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH"); + + if (father->_is_nil()) { + father = myStudyBuilder->NewComponent("MESH"); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + //NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT")); + aName->SetValue( QAD_Application::getDesktop()->getComponentUserName( "SMESH" ) ); + anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_OBJBROWSER_SMESH" ); + } + myStudyBuilder->DefineComponentInstance(father, CompMesh ); + mySComponentMesh = SALOMEDS::SComponent::_narrow( father ); + + // Tags definition + Tag_HypothesisRoot = 1; + Tag_AlgorithmsRoot = 2; + + Tag_RefOnShape = 1; + Tag_RefOnAppliedHypothesis = 2; + Tag_RefOnAppliedAlgorithms = 3; + + Tag_SubMeshOnVertex = 4; + Tag_SubMeshOnEdge = 5; + Tag_SubMeshOnFace = 6; + Tag_SubMeshOnSolid = 7; + Tag_SubMeshOnCompound = 8; +} + +SMESH_Swig::~SMESH_Swig() +{ + MESSAGE("Destructeur"); +} + + +const char* SMESH_Swig::AddNewMesh(const char* IOR) +{ + MESSAGE("AddNewMesh"); + //Find or Create Hypothesis root + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + SALOMEDS::SObject_var HypothesisRoot; + if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) { + HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + + SALOMEDS::SObject_var AlgorithmsRoot; + if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) { + AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + + // Add New Mesh + SALOMEDS::SObject_var newMesh = myStudyBuilder->NewObject(mySComponentMesh); + anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newMesh, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IOR); + return SALOMEDS::SObject::_narrow( newMesh )->GetID(); +} + +const char* SMESH_Swig::AddNewHypothesis(const char* IOR) +{ + MESSAGE("AddNewHypothesis"); + //Find or Create Hypothesis root + SALOMEDS::SObject_var HypothesisRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!mySComponentMesh->FindSubObject (Tag_HypothesisRoot, HypothesisRoot)) { + HypothesisRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + } + // Add New Hypothesis + SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(HypothesisRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + SMESH::SMESH_Hypothesis_var H = SMESH::SMESH_Hypothesis::_narrow( StringToObject(IOR) ); + QString aType = H->GetName(); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_" + aType ); +// if ( aType.compare("LocalLength") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_LENGTH" ); +// else if ( aType.compare("NumberOfSegments") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_SEGMENT" ); +// else if ( aType.compare("MaxElementArea") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_AREA" ); +// else if ( aType.compare("MaxElementVolume") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO_VOLUME" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IOR); + return SALOMEDS::SObject::_narrow(newHypo)->GetID(); +} + +const char* SMESH_Swig::AddNewAlgorithms(const char* IOR) +{ + MESSAGE("AddNewAlgorithms"); + //Find or Create Algorithms root + SALOMEDS::SObject_var AlgorithmsRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if (!mySComponentMesh->FindSubObject (Tag_AlgorithmsRoot, AlgorithmsRoot)) { + AlgorithmsRoot = myStudyBuilder->NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_ALGORITHMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + } + // Add New Algorithms + SALOMEDS::SObject_var newHypo = myStudyBuilder->NewObject(AlgorithmsRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + SMESH::SMESH_Hypothesis_var H = SMESH::SMESH_Hypothesis::_narrow( StringToObject(IOR) ); + QString aType = H->GetName(); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_" + aType ); +// if ( aType.compare("Regular_1D") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_REGULAR" ); +// else if ( aType.compare("MEFISTO_2D") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_MEFISTO" ); +// else if ( aType.compare("Quadrangle_2D") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_QUAD" ); +// else if ( aType.compare("Hexa_3D") == 0 ) +// aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO_HEXA" ); + anAttr = myStudyBuilder->FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(IOR); + return SALOMEDS::SObject::_narrow(newHypo)->GetID(); +} + +void SMESH_Swig::SetShape(const char* ShapeEntry, const char* MeshEntry) +{ + SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( MeshEntry ); + SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectID( ShapeEntry ); + + if ( !SO_MorSM->_is_nil() && !SO_GeomShape->_is_nil() ) { + SALOMEDS::SObject_var SO = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnShape); + myStudyBuilder->Addreference (SO,SO_GeomShape); + } +} + +void SMESH_Swig::SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry) +{ + SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( Mesh_Or_SubMesh_Entry ); + SALOMEDS::SObject_var SO_Hypothesis = myStudy->FindObjectID( Hypothesis_Entry ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if ( !SO_MorSM->_is_nil() && !SO_Hypothesis->_is_nil() ) { + + //Find or Create Applied Hypothesis root + SALOMEDS::SObject_var AHR; + if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedHypothesis, AHR)) { + AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); + myStudyBuilder->Addreference (SO,SO_Hypothesis); + } +} +void SMESH_Swig::SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry) +{ + SALOMEDS::SObject_var SO_MorSM = myStudy->FindObjectID( Mesh_Or_SubMesh_Entry ); + SALOMEDS::SObject_var SO_Algorithms = myStudy->FindObjectID( Algorithms_Entry ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeSelectable_var aSelAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + if ( !SO_MorSM->_is_nil() && !SO_Algorithms->_is_nil() ) { + //Find or Create Applied Algorithms root + SALOMEDS::SObject_var AHR; + if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedAlgorithms, AHR)) { + AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS")); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); + myStudyBuilder->Addreference (SO,SO_Algorithms); + } +} + +void SMESH_Swig::UnSetHypothesis(const char* Applied_Hypothesis_Entry ) +{ + SALOMEDS::SObject_var SO_Applied_Hypothesis = myStudy->FindObjectID( Applied_Hypothesis_Entry ); + if ( !SO_Applied_Hypothesis->_is_nil() ) + myStudyBuilder->RemoveObject(SO_Applied_Hypothesis); +} + + +const char* SMESH_Swig::AddSubMesh(const char* SO_Mesh_Entry, const char* SM_IOR, int ST) +{ + SALOMEDS::SObject_var SO_Mesh = myStudy->FindObjectID( SO_Mesh_Entry ); + if ( !SO_Mesh->_is_nil() ) { + + long Tag_Shape ; + Standard_CString Name; + + if (ST == TopAbs_SOLID) {Tag_Shape = Tag_SubMeshOnSolid; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnSolid"));} + else if (ST == TopAbs_FACE) {Tag_Shape = Tag_SubMeshOnFace; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnFace"));} + else if (ST == TopAbs_EDGE) {Tag_Shape = Tag_SubMeshOnEdge; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnEdge"));} + else if (ST == TopAbs_VERTEX){Tag_Shape = Tag_SubMeshOnVertex; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnVertex"));} + else { + Tag_Shape = Tag_SubMeshOnCompound; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnCompound")); + } + SALOMEDS::SObject_var SubmeshesRoot; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelAttr; + if (!SO_Mesh->FindSubObject (Tag_Shape,SubmeshesRoot )) { + SubmeshesRoot = myStudyBuilder->NewObjectToTag (SO_Mesh, Tag_Shape); + anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(Name); + anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot); + anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR"); + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + anIOR->SetValue(SM_IOR); + return SALOMEDS::SObject::_narrow( SO )->GetID(); + } + return ""; +} + +const char* SMESH_Swig::AddSubMeshOnShape(const char* Mesh_Entry, const char* GeomShape_Entry, + const char* SM_IOR, int ST) +{ + SALOMEDS::SObject_var SO_GeomShape = myStudy->FindObjectID( GeomShape_Entry ); + if ( !SO_GeomShape->_is_nil() ) { + const char * SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST); + SALOMEDS::SObject_var SO_SM = myStudy->FindObjectID( SM_Entry ); + if ( !SO_SM->_is_nil() ) { + SetShape (GeomShape_Entry, SM_Entry); + return SALOMEDS::SObject::_narrow( SO_SM )->GetID(); + } + } + return ""; +} + +void SMESH_Swig::CreateAndDisplayActor( const char* Mesh_Entry ) +{ + // SMESH_Actor* Mesh = smeshGUI->ReadScript(aM); +} + +void SMESH_Swig::SetName(const char* Entry, const char* Name) +{ + SALOMEDS::SObject_var SO = myStudy->FindObjectID( Entry ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !SO->_is_nil() ) { + anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(Name); + } +} + + +void SMESH_Swig::setOrb() +{ + try { + ORB_INIT &init = *SINGLETON_::Instance(); + ASSERT(SINGLETON_::IsAlreadyExisting()); + _orb = init( 0 , 0 ); + } catch (...) { + INFOS("internal error : orb not found"); + _orb = 0; + } + ASSERT(! CORBA::is_nil(_orb)); +} diff --git a/src/SMESHGUI/SMESHGUI_Swig.hxx b/src/SMESHGUI/SMESHGUI_Swig.hxx new file mode 100644 index 000000000..d502517a3 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Swig.hxx @@ -0,0 +1,69 @@ +// File : SMESHGUI_Swig.hxx +// Created : Mon Jun 17 13:41:12 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef _SMESHGUI_SWIG_HXX_ +#define _SMESHGUI_SWIG_HXX_ + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class SMESH_Swig +{ +public: + SMESH_Swig(); + ~SMESH_Swig(); + + static void setOrb(); + + void Init(int studyID); + + const char* AddNewMesh(const char* IOR); + + const char* AddNewHypothesis(const char* IOR); + const char* AddNewAlgorithms(const char* IOR); + + void SetShape(const char* ShapeEntry, const char* MeshEntry); + + void SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry); + void SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry); + + void UnSetHypothesis(const char* Applied_Hypothesis_Entry ); + + const char* AddSubMesh (const char* Mesh_Entry, const char* SM_IOR, int ST); + const char* AddSubMeshOnShape (const char* Mesh_Entry, const char* GeomShape_Entry, const char* SM_IOR, int ST); + + void CreateAndDisplayActor( const char* Mesh_Entry ); + + void SetName(const char* Entry, const char* Name); + +private: + SALOMEDS::Study_var myStudy; + SALOMEDS::StudyBuilder_var myStudyBuilder; + SALOMEDS::SComponent_var mySComponentMesh; + + // Tags definition + long Tag_HypothesisRoot; + long Tag_AlgorithmsRoot; + + long Tag_RefOnShape; + long Tag_RefOnAppliedHypothesis; + long Tag_RefOnAppliedAlgorithms; + + long Tag_SubMeshOnVertex; + long Tag_SubMeshOnEdge; + long Tag_SubMeshOnFace; + long Tag_SubMeshOnSolid; + long Tag_SubMeshOnCompound; +}; + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_Swig.i b/src/SMESHGUI/SMESHGUI_Swig.i new file mode 100644 index 000000000..d53badd3a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Swig.i @@ -0,0 +1,40 @@ +// File : SMESHGUI_Swig.i +// Created : Mon Jun 17 13:40:36 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +%{ +#include "SMESHGUI_Swig.hxx" +%} + +%include "typemaps.i" + +class SMESH_Swig +{ + public: + SMESH_Swig(); + ~SMESH_Swig(); + + void Init(int studyID); + + const char* AddNewMesh(const char* IOR); + const char* AddNewHypothesis(const char* IOR); + const char* AddNewAlgorithms(const char* IOR); + + void SetShape(const char* ShapeEntry, const char* MeshEntry); + + void SetHypothesis(const char* Mesh_Or_SubMesh_Entry, const char* Hypothesis_Entry); + void SetAlgorithms(const char* Mesh_Or_SubMesh_Entry, const char* Algorithms_Entry); + + void UnSetHypothesis(const char* Applied_Hypothesis_Entry ); + + const char* AddSubMesh (const char* Mesh_Entry, const char* SM_IOR, int ST); + const char* AddSubMeshOnShape (const char* Mesh_Entry, const char* GeomShape_Entry, const char* SM_IOR, int ST); + + void SetName(const char* Entry, const char* Name); +}; diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx new file mode 100644 index 000000000..cb35a3538 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx @@ -0,0 +1,191 @@ +using namespace std; +// File : SMESHGUI_TransparencyDlg.cxx +// Created : Thu Jun 06 16:41:42 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SMESHGUI_TransparencyDlg.h" +#include "SMESHGUI.h" + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindowInteractor.h" +#include "QAD_RightFrame.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : SMESHGUI_TransparencyDlg() +// purpose : +// +//================================================================================= +SMESHGUI_TransparencyDlg::SMESHGUI_TransparencyDlg( QWidget* parent, + const char* name, + SALOME_Selection* Sel, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SMESHGUI_TransparencyDlg" ); + resize( 152, 107 ); + setCaption( tr( "SMESH_TRANSPARENCY_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_TransparencyDlgLayout = new QGridLayout( this ); + SMESHGUI_TransparencyDlgLayout->setSpacing( 6 ); + SMESHGUI_TransparencyDlgLayout->setMargin( 11 ); + + /*************************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "GEOM_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 0 ); + GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 2 ); + + /*************************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelOpaque = new QLabel( GroupC1, "TextLabelOpaque" ); + TextLabelOpaque->setText( tr( "SMESH_TRANSPARENCY_OPAQUE" ) ); + TextLabelOpaque->setAlignment( int( QLabel::AlignLeft ) ); + GroupC1Layout->addWidget( TextLabelOpaque, 0, 0 ); + GroupC1Layout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + TextLabelTransparent = new QLabel( GroupC1, "TextLabelTransparent" ); + TextLabelTransparent->setText( tr( "SMESH_TRANSPARENCY_TRANSPARENT" ) ); + TextLabelTransparent->setAlignment( int( QLabel::AlignRight ) ); + GroupC1Layout->addWidget( TextLabelTransparent, 0, 2 ); + + Slider1 = new QSlider( 0, 10, 1, 5, Horizontal, GroupC1, "Slider1" ); + Slider1->setMinimumSize( 300, 0 ); + Slider1->setTickmarks( QSlider::Left ); + GroupC1Layout->addMultiCellWidget( Slider1, 1, 1, 0, 2 ); + + SMESHGUI_TransparencyDlgLayout->addWidget( GroupC1, 0, 0 ); + SMESHGUI_TransparencyDlgLayout->addWidget( GroupButtons, 1, 0 ); + + /* Initialisations */ + this->mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + this->mySel = Sel ; + + /* First call valueChanged() method for initialisation */ + /* The default value of transparency will change with the selection */ + this->myFirstInit = true ; +// Slider1->setMaxValue( 10 ); +// Slider1->setValue( 5 ) ; + + + this->ValueHasChanged( Slider1->value() ) ; + + // signals and slots connections : after ValueHasChanged() + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( Slider1, SIGNAL( valueChanged(int) ), this, SLOT( ValueHasChanged(int) ) ); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* Displays this Dialog */ +} + + + + +//================================================================================= +// function : ~SMESHGUI_TransparencyDlg() +// purpose : +//================================================================================= +SMESHGUI_TransparencyDlg::~SMESHGUI_TransparencyDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//======================================================================= +// function : ClickOnOk() +// purpose : +//======================================================================= +void SMESHGUI_TransparencyDlg::ClickOnOk() +{ + accept() ; + return ; +} + + +//======================================================================= +// function : ClickOnClose() +// purpose : +//======================================================================= +void SMESHGUI_TransparencyDlg::ClickOnClose() +{ + accept() ; + return ; +} + + +//================================================================================= +// function : ValueHasChanged() +// purpose : Called when value of slider change +// : or the first time as initilisation +//================================================================================= +void SMESHGUI_TransparencyDlg::ValueHasChanged( int newValue ) +{ + + if ( mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)mySMESHGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + SALOME_ListIteratorOfListIO It( this->mySel->StoredIObjects() ); + Handle(SALOME_InteractiveObject) FirstIOS = mySel->firstIObject(); + if( !FirstIOS.IsNull() ) { + /* The first time as initialisation */ + if( this->myFirstInit ) { + this->myFirstInit = false ; + float transp = ( myRenderInter->GetTransparency(FirstIOS))*10.0 ; + this->Slider1->setValue( int(transp) ) ; + return; + } + } + + QApplication::setOverrideCursor( Qt::waitCursor ); + for( ;It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + myRenderInter->SetTransparency( IOS, newValue/10.0 ); + } + QApplication::restoreOverrideCursor(); + } + QApplication::restoreOverrideCursor(); + return ; +} diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.h b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h new file mode 100644 index 000000000..7eaeee1f7 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.h @@ -0,0 +1,71 @@ +// File : SMESHGUI_TransparencyDlg.h +// Created : Thu Jun 06 16:41:57 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_TRANSPARENCYDLG_H +#define DIALOGBOX_TRANSPARENCYDLG_H + +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" + +// QT Includes +#include +#include + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QFrame; +class QLabel; +class QPushButton; +class QSlider; +class SMESHGUI; + +//================================================================================= +// class : SMESHGUI_TransparencyDlg +// purpose : +//================================================================================= +class SMESHGUI_TransparencyDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_TransparencyDlg( QWidget* parent = 0, + const char* name = 0, + SALOME_Selection* Sel = 0, + bool modal = TRUE, + WFlags fl = 0 ); + + ~SMESHGUI_TransparencyDlg(); + +private : + + SMESHGUI* mySMESHGUI ; /* Current GeomGUI object */ + bool myFirstInit ; /* Inform for the first init */ + SALOME_Selection* mySel; /* User selection */ + + QPushButton* buttonOk; + QLabel* TextLabelOpaque; + QLabel* TextLabelTransparent; + QSlider* Slider1; + +public slots: + + void ClickOnOk(); + void ClickOnClose(); + void ValueHasChanged( int newValue ) ; + +protected: + QGridLayout* SMESHGUI_TransparencyDlgLayout; + QHBoxLayout* Layout1; + QHBoxLayout* Layout2; +}; + +#endif // DIALOGBOX_TRANSPARENCYDLG_H + diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx new file mode 100644 index 000000000..d4c27bc10 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx @@ -0,0 +1,234 @@ +using namespace std; +// File : SMESHGUI_aParameterDlg.cxx +// Created : Wed Jun 12 21:06:21 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SMESHGUI_aParameterDlg.h" +#include "SMESHGUI.h" +#include "QAD_SpinBoxDbl.h" +#include "QAD_Tools.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +//====================================================================================== +// function : SMESHGUI_aParameterDlg() +// purpose : Constructs a SMESHGUI_aParametertDlg for double values +// +// parent : parent widget +// title : is the title for the user in dialog box +// label : text label for the value +// +// bottom : the minimal value to be entered +// top : the maximum value to be entered +// decimals : number of decimals to be entered +// +// The dialog will by default be modal, unless you set 'modal' to +// false when constructing dialog +// +//====================================================================================== +SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent, + QString title, + QString label, + const double bottom, + const double top, + const int decimals, + bool modal ) +: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myIntSpin( 0 ), myDblSpin( 0 ) +{ + /* creating widgets */ + init( true ); + /* title */ + setCaption( title ); + /* caption */ + myTextLabel->setText( label ); + /* range */ + myDblSpin->setRange( bottom, top ); + ((QDoubleValidator*)(myDblSpin->validator()))->setRange( bottom, top, decimals ); + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget( this, parent ); +} + +//====================================================================================== +// function : SMESHGUI_aParameterDlg() +// purpose : Constructs a SMESHGUI_aParametertDlg for int values +// +// parent : parent widget +// title : is the title for the user in dialog box +// label : text label for the value +// +// bottom : the minimal value to be entered +// top : the maximum value to be entered +// +// The dialog will by default be modal, unless you set 'modal' to +// false when constructing dialog +// +//====================================================================================== +SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent, + QString title, + QString label, + const int bottom, + const int top, + bool modal ) +: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myIntSpin( 0 ), myDblSpin( 0 ) +{ + /* creating widgets */ + init( false ); + /* title */ + setCaption( title ); + /* caption */ + myTextLabel->setText( label ); + /* range */ + myIntSpin->setRange( bottom, top ); + ((QIntValidator*)(myIntSpin->validator()))->setRange( bottom, top ); + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget( this, parent ); +} + +//====================================================================================== +// function : SMESHGUI_aParameterDlg::init() +// purpose : creates dialog's layout +//====================================================================================== +void SMESHGUI_aParameterDlg::init( bool isDouble ) +{ + setSizeGripEnabled( TRUE ); + + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + + /***************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + /* Label */ + /* aTitle1 : text prompt on left of edit line */ + myTextLabel = new QLabel( GroupC1, "TextLabel" ); + GroupC1Layout->addWidget( myTextLabel, 0, 0 ); + /* Spin box */ + if ( isDouble ) { + myIntSpin = 0; + myDblSpin = new QAD_SpinBoxDbl( GroupC1 ); + myDblSpin->setPrecision( 12 ); + myDblSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + myDblSpin->setMinimumSize( 150, 0 ); + GroupC1Layout->addWidget( myDblSpin, 0, 1 ); + } + else { + myDblSpin = 0; + myIntSpin = new QSpinBox( GroupC1 ); + myIntSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + myIntSpin->setMinimumSize( 150, 0 ); + GroupC1Layout->addWidget( myIntSpin, 0, 1 ); + } + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + /* Ok button */ + myButtonOk = new QPushButton( GroupButtons, "buttonOk" ); + myButtonOk->setText( tr("SMESH_BUT_OK") ); + myButtonOk->setAutoDefault( TRUE ); + myButtonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonOk, 0, 0 ); + /* add spacer between buttons */ + GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + /* Cancel button */ + myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + myButtonCancel->setText( tr("SMESH_BUT_CANCEL") ); + myButtonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonCancel, 0, 2 ); + + /***************************************************************/ + topLayout->addWidget( GroupC1, 0, 0); + topLayout->addWidget( GroupButtons, 1, 0); + + /* signals and slots connections */ + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Retrieve SMESHGUI */ + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; +} + + +//====================================================================================== +// function : ~SMESHGUI_aParameterDlg() +// purpose : Destructor +//====================================================================================== +SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg() +{ +} + +//====================================================================================== +// function : SMESHGUI_aParameterDlg::setValue +// purpose : sets double value +//====================================================================================== +void SMESHGUI_aParameterDlg::setValue( const double val ) +{ + if ( myDblSpin ) + myDblSpin->setValue( val ); +} +//====================================================================================== +// function : SMESHGUI_aParameterDlg::setValue +// purpose : sets int value +//====================================================================================== +void SMESHGUI_aParameterDlg::setValue( const int val ) +{ + if ( myIntSpin ) + myIntSpin->setValue( val ); +} +//====================================================================================== +// function : SMESHGUI_aParameterDlg::getDblValue +// purpose : returns double value entered by user +//====================================================================================== +double SMESHGUI_aParameterDlg::getDblValue() +{ + if ( myDblSpin ) + return myDblSpin->value(); + return 0.0; +} + +//====================================================================================== +// function : SMESHGUI_aParameterDlg::getIntValu +// purpose : returns int value entered by user +//====================================================================================== +int SMESHGUI_aParameterDlg::getIntValue() +{ + if ( myIntSpin ) + return myIntSpin->value(); + return 0; +} + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.h b/src/SMESHGUI/SMESHGUI_aParameterDlg.h new file mode 100644 index 000000000..cd7a7e056 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.h @@ -0,0 +1,65 @@ +// File : SMESHGUI_aParameterDlg.h +// Created : Wed Jun 12 21:04:41 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SMESH +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SMESHGUI_aParameterDlg_H +#define SMESHGUI_aParameterDlg_H + +// QT Includes +#include + +class QLabel; +class QPushButton; +class QSpinBox; +class SMESHGUI; +class QAD_SpinBoxDbl; + +//================================================================================= +// class : SMESHGUI_aParameterDlg +// purpose : +//================================================================================= +class SMESHGUI_aParameterDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_aParameterDlg( QWidget* parent = 0, + QString title = QString::null, + QString label = QString::null, + const double bottom = -1E6, + const double top = +1E6, + const int decimals = 3, + bool modal = TRUE ); + SMESHGUI_aParameterDlg( QWidget* parent = 0, + QString title = QString::null, + QString label = QString::null, + const int bottom = 0, + const int top = 1000, + bool modal = TRUE ); + + ~SMESHGUI_aParameterDlg(); + + void setValue( const double val ); + void setValue( const int val ); + double getDblValue(); + int getIntValue(); + +protected: + void init( bool isDouble ); + +private: + SMESHGUI* mySMESHGUI ; + + QPushButton* myButtonOk; + QPushButton* myButtonCancel; + QLabel* myTextLabel; + QSpinBox* myIntSpin; + QAD_SpinBoxDbl* myDblSpin; +}; + +#endif // SMESHGUI_aParameterDlg.h diff --git a/src/SMESHGUI/SMESH_icons.po b/src/SMESHGUI/SMESH_icons.po new file mode 100644 index 000000000..60f92f2d7 --- /dev/null +++ b/src/SMESHGUI/SMESH_icons.po @@ -0,0 +1,170 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#----------------------------------------------------------- +# Divers Mesh +#----------------------------------------------------------- + +#ObjectBrowser Icon +msgid "ICON_OBJBROWSER_SMESH" +msgstr "mesh.png" + +#Select Icon +msgid "ICON_SELECT" +msgstr "select1.png" + +#Mesh Init +msgid "ICON_DLG_INIT_MESH" +msgstr "mesh_init.png" + +# +msgid "ICON_DLG_ADD_SUBMESH" +msgstr "mesh_add_sub.png" + +#Move Node +msgid "ICON_DLG_MOVE_NODE" +msgstr "mesh_move_node.png" + +#Remove Node +msgid "ICON_DLG_REM_NODE" +msgstr "mesh_rem_node.png" + +#Remove Element +msgid "ICON_DLG_REM_ELEMENT" +msgstr "mesh_rem_element.png" + +#Orientation +msgid "ICON_DLG_MESH_ORIENTATION" +msgstr "mesh_orientation.png" + +# +msgid "ICON_DLG_MESH_DIAGONAL" +msgstr "mesh_diagonal.png" + +#Connectivity +msgid "ICON_DLG_CONNECTIVITY" +msgstr "mesh_connectivity.png" + + +#----------------------------------------------------------- +# Hypothesis +#----------------------------------------------------------- + +#Hypo Local Length +msgid "ICON_DLG_LOCAL_LENGTH" +msgstr "mesh_hypo_length.png" + +#Hypo Nb Segments +msgid "ICON_DLG_NB_SEGMENTS" +msgstr "mesh_hypo_segment.png" + +#Hypo Max Area +msgid "ICON_DLG_MAX_ELEMENT_AREA" +msgstr "mesh_hypo_area.png" + +#Hypo Max Volume +msgid "ICON_DLG_MAX_ELEMENT_VOLUME" +msgstr "mesh_hypo_volume.png" + +#Set Algo +msgid "ICON_DLG_ADD_ALGORITHM" +msgstr "mesh_set_algo.png" + +#Set Hypo +msgid "ICON_DLG_ADD_HYPOTHESIS" +msgstr "mesh_set_hypo.png" + +#Edit Hypo. +msgid "ICON_DLG_EDIT_MESH" +msgstr "mesh_edit.png" + + +#----------------------------------------------------------- +# Elements +#----------------------------------------------------------- + +#Vertex +msgid "ICON_DLG_NODE" +msgstr "mesh_vertex.png" + +#Line +msgid "ICON_DLG_LINE" +msgstr "mesh_line.png" + +#triangle +msgid "ICON_DLG_TRIANGLE" +msgstr "mesh_triangle.png" + +#Quadrangle +msgid "ICON_DLG_QUADRANGLE" +msgstr "mesh_quad.png" + +#triangle +msgid "ICON_DLG_TETRAS" +msgstr "mesh_tetra.png" + +#Quadrangle +msgid "ICON_DLG_HEXAS" +msgstr "mesh_hexa.png" + + +#----------------------------------------------------------- +# ObjectBrother +#----------------------------------------------------------- + +#mesh_tree_mesh +msgid "ICON_SMESH_TREE_MESH" +msgstr "mesh_tree_mesh.png" + +#mesh_tree_algo +msgid "ICON_SMESH_TREE_ALGO" +msgstr "mesh_tree_algo.png" + +#mesh_tree_algo_regular +msgid "ICON_SMESH_TREE_ALGO_Regular_1D" +msgstr "mesh_tree_algo_regular.png" + +#mesh_tree_algo_hexa +msgid "ICON_SMESH_TREE_ALGO_Hexa_3D" +msgstr "mesh_tree_algo_hexa.png" + +#mesh_tree_algo_mefisto +msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D" +msgstr "mesh_tree_algo_mefisto.png" + +#mesh_tree_algo_quad +msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D" +msgstr "mesh_tree_algo_quad.png" + +#mesh_tree_hypo +msgid "ICON_SMESH_TREE_HYPO" +msgstr "mesh_tree_hypo.png" + +#mesh_tree_hypo_area +msgid "ICON_SMESH_TREE_HYPO_MaxElementArea" +msgstr "mesh_tree_hypo_area.png" + +#mesh_tree_hypo_length +msgid "ICON_SMESH_TREE_HYPO_LocalLength" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_segment +msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments" +msgstr "mesh_tree_hypo_segment.png" + +#mesh_tree_hypo_volume +msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume" +msgstr "mesh_tree_hypo_volume.png" + +#mesh_tree_mesh_warn +msgid "ICON_SMESH_TREE_MESH_WARN" +msgstr "mesh_tree_mesh_warn.png" diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po new file mode 100644 index 000000000..c593f9571 --- /dev/null +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -0,0 +1,638 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#------------------------------------------------------------------------- +# BUTTON +#------------------------------------------------------------------------- + +#Apply +msgid "SMESH_BUT_APPLY" +msgstr "&Apply" + +#Close +msgid "SMESH_BUT_CLOSE" +msgstr "&Close" + +#Ok +msgid "SMESH_BUT_OK" +msgstr "&Ok" + +#Yes +msgid "SMESH_BUT_YES" +msgstr "&Yes" + +#No +msgid "SMESH_BUT_NO" +msgstr "&No" + +#Cancel +msgid "SMESH_BUT_CANCEL" +msgstr "&Cancel" + + +#------------------------------------------------------------------------- +# WARNING +#------------------------------------------------------------------------- + +#Warning +msgid "SMESH_WRN_WARNING" +msgstr "Warning" + +#: SMESHGUI.cxx:465 +msgid "SMESH_REALLY_DELETE" +msgstr "Do you really want to delete object(s) ?" + +#Hypothesis or Algorithm not exists +msgid "SMESH_WRN_HYPOTHESIS_NOTEXIST" +msgstr "Hypothesis or Algorithm not exists" + +#Hypothesis already exists +msgid "SMESH_WRN_HYPOTHESIS_ALREADYEXIST" +msgstr "Hypothesis already exists" + +#Algorithm already exists +msgid "SMESH_WRN_ALGORITHM_ALREADYEXIST" +msgstr "Algorithm already exists" + +#Missing parameters +msgid "SMESH_WRN_MISSING_PARAMETERS" +msgstr "Missing parameters" + +#Study frame with VTK Viewer must be activated +msgid "SMESH_WRN_VIEWER_VTK" +msgstr "Study frame with VTK Viewer must be activated" + +#Activate Elements Selection Mode +msgid "SMESH_WRN_SELECTIONMODE_ELEMENTS" +msgstr "Activate Elements Selection Mode" + +#Activate Nodes Selection Mode +msgid "SMESH_WRN_SELECTIONMODE_NODES" +msgstr "Activate Nodes Selection Mode" + +#Activate Link Selection Mode +msgid "SMESH_WRN_SELECTIONMODE_DIAGONAL" +msgstr "Activate Link Selection Mode" + + +#------------------------------------------------------------------------- +# MEN +#------------------------------------------------------------------------- + +#SMESH +msgid "SMESH_MEN_COMPONENT" +msgstr "SMESH" + +#SubMeshes On Vertex +msgid "SMESH_MEN_SubMeshesOnVertex" +msgstr "SubMeshes On Vertex" + +#SubMeshes On Edge +msgid "SMESH_MEN_SubMeshesOnEdge" +msgstr "SubMeshes On Edge" + +#SubMeshes On Face +msgid "SMESH_MEN_SubMeshesOnFace" +msgstr "SubMeshes On Face" + +#SubMeshes On Solid +msgid "SMESH_MEN_SubMeshesOnSolid" +msgstr "SubMeshes On Solid" + +#SubMeshes On Compound +msgid "SMESH_MEN_SubMeshesOnCompound" +msgstr "SubMeshes On Compound" + +#Applied Algorithm +msgid "SMESH_MEN_APPLIED_ALGORIHTMS" +msgstr "Applied Algorithm" + +#Applied Hypothesis +msgid "SMESH_MEN_APPLIED_HYPOTHESIS" +msgstr "Applied Hypothesis" + +#Hypothesis Definition +msgid "SMESH_MEN_HYPOTHESIS" +msgstr "Hypothesis Definition" + +#Algorithms Definition +msgid "SMESH_MEN_ALGORITHMS" +msgstr "Algorithms Definition" + + +#------------------------------------------------------------------------- +# DIVERS +#------------------------------------------------------------------------- + +#Arguments +msgid "SMESH_ARGUMENTS" +msgstr "Arguments" + +#Value +msgid "SMESH_VALUE" +msgstr "Value" + +#%1_objects +msgid "SMESH_OBJECTS_SELECTED" +msgstr "%1_objects" + +#Name +msgid "SMESH_NAME" +msgstr "Name" + +#Geometrical Object +msgid "SMESH_OBJECT_GEOM" +msgstr "Geometrical Object" + +#Length +msgid "SMESH_LENGTH" +msgstr "Length" + +#Coordinates +msgid "SMESH_COORDINATES" +msgstr "Coordinates" + +#X +msgid "SMESH_X" +msgstr "X" + +#Y +msgid "SMESH_Y" +msgstr "Y" + +#Z +msgid "SMESH_Z" +msgstr "Z" + + +#------------------------------------------------------------------------- +# DLG +#------------------------------------------------------------------------- + +# -------------- Init -------------- + +#Mesh +msgid "SMESH_INIT" +msgstr "Mesh" + +#Mesh or SubMesh +msgid "SMESH_OBJECT_MESHorSUBMESH" +msgstr "Mesh or SubMesh" + +#Mesh Construction +msgid "SMESH_INIT_MESH" +msgstr "Mesh Construction" + +#SubMesh Construction +msgid "SMESH_ADD_SUBMESH" +msgstr "SubMesh Construction" + +#Mesh +msgid "SMESH_OBJECT_MESH" +msgstr "Mesh" + +#SubMesh +msgid "SMESH_SUBMESH" +msgstr "SubMesh" + + +# -------------- Hypothesis / Algorithm -------------- + +#Hypothesis +msgid "SMESH_ADD_HYPOTHESIS" +msgstr "Hypothesis" + +#Hypothesis Construction +msgid "SMESH_ADD_HYPOTHESIS_TITLE" +msgstr "Hypothesis Assignation" + +#Hypothesis +msgid "SMESH_OBJECT_HYPOTHESIS" +msgstr "Hypothesis" + +#Local Length +msgid "SMESH_LOCAL_LENGTH_HYPOTHESIS" +msgstr "Local Length" + +#Hypothesis Construction +msgid "SMESH_LOCAL_LENGTH_TITLE" +msgstr "Hypothesis Construction" + +#Algorithms +msgid "SMESH_ADD_ALGORITHM" +msgstr "Algorithms" + +#Algorithms Construction +msgid "SMESH_ADD_ALGORITHM_TITLE" +msgstr "Algorithms Assignation" + +#Algorithm +msgid "SMESH_OBJECT_ALGORITHM" +msgstr "Algorithm" + +#Number of Segments +msgid "SMESH_NB_SEGMENTS_HYPOTHESIS" +msgstr "Number of Segments" + +#Hypothesis Construction +msgid "SMESH_NB_SEGMENTS_TITLE" +msgstr "Hypothesis Construction" + +#Max. Area +msgid "SMESH_MAX_ELEMENT_AREA" +msgstr "Max. Area" + +#Max. Element Area +msgid "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" +msgstr "Max. Element Area" + +#Hypothesis Construction +msgid "SMESH_MAX_ELEMENT_AREA_TITLE" +msgstr "Hypothesis Construction" + +#Max. Volume +msgid "SMESH_MAX_ELEMENT_VOLUME" +msgstr "Max. Volume" + +#Max. Element Volume +msgid "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" +msgstr "Max. Element Volume" + +#Hypothesis Construction +msgid "SMESH_MAX_ELEMENT_VOLUME_TITLE" +msgstr "Hypothesis Construction" + + +# -------------- Nodes / Segments / Elements -------------- + +#Node +msgid "MESH_NODE" +msgstr "Node" + +#Node Construction +msgid "MESH_NODE_TITLE" +msgstr "Node Construction" + +#Segments +msgid "SMESH_SEGMENTS" +msgstr "Segments" + +#Elements +msgid "SMESH_ELEMENTS" +msgstr "Elements" + +#Id Elements +msgid "SMESH_ID_ELEMENTS" +msgstr "Id Elements" + +#Remove +msgid "SMESH_REMOVE" +msgstr "Remove" + +#Remove Elements +msgid "SMESH_REMOVE_ELEMENTS_TITLE" +msgstr "Remove Elements" + +#Id Nodes +msgid "SMESH_ID_NODES" +msgstr "Id Nodes" + +#Nodes +msgid "SMESH_NODES" +msgstr "Nodes" + +#Remove Nodes +msgid "SMESH_REMOVE_NODES_TITLE" +msgstr "Remove Nodes" + +#Move +msgid "SMESH_MOVE" +msgstr "Move" + +#Move Node +msgid "SMESH_MOVE_NODES_TITLE" +msgstr "Move Node" + +#Add Triangle +msgid "SMESH_ADD_TRIANGLE_TITLE" +msgstr "Add Triangle" + +#Add Quadrangle +msgid "SMESH_ADD_QUADRANGLE_TITLE" +msgstr "Add Quadrangle" + +#Add Edge +msgid "SMESH_ADD_EDGE_TITLE" +msgstr "Add Edge" + +#Add Tetrahedron +msgid "SMESH_ADD_TETRAS_TITLE" +msgstr "Add Tetrahedron" + +#Add Hexahedron +msgid "SMESH_ADD_HEXAS_TITLE" +msgstr "Add Hexahedron" + +#Reverse +msgid "SMESH_REVERSE" +msgstr "Reverse" + +#Triangle +msgid "SMESH_TRIANGLE" +msgstr "Triangle" + +#Quadrangle +msgid "SMESH_QUADRANGLE" +msgstr "Quadrangle" + +#Edge +msgid "SMESH_EDGE" +msgstr "Edge" + +#Tetrahedron +msgid "SMESH_TETRAS" +msgstr "Tetrahedron" + +#Hexahedron +msgid "SMESH_HEXAS" +msgstr "Hexahedron" + +#Add Triangle +msgid "SMESH_ADD_TRIANGLE" +msgstr "Add Triangle" + +#Add Quadrangle +msgid "SMESH_ADD_QUADRANGLE" +msgstr "Add Quadrangle" + +#Add Edge +msgid "SMESH_ADD_EDGE" +msgstr "Add Edge" + +#Add Tetrahedron +msgid "SMESH_ADD_TETRAS" +msgstr "Add Tetrahedron" + +#Add Hexahedron +msgid "SMESH_ADD_HEXAS" +msgstr "Add Hexahedron" + + +# -------------- Transparency -------------- + +#Opacity +msgid "SMESH_TRANSPARENCY_OPAQUE" +msgstr "Opacity" + +#Transparency +msgid "SMESH_TRANSPARENCY_TITLE" +msgstr "Transparency" + +#Fully Transparency +msgid "SMESH_TRANSPARENCY_TRANSPARENT" +msgstr "Fully Transparency" + + +# -------------- Preferences ----------- + +#Arial +msgid "SMESH_FONT_ARIAL" +msgstr "Arial" + +#Bold +msgid "SMESH_FONT_BOLD" +msgstr "Bold" + +#Courier +msgid "SMESH_FONT_COURIER" +msgstr "Courier" + +#Dimensions +msgid "SMESH_DIMENSIONS" +msgstr "Dimensions" + +#Font +msgid "SMESH_FONT" +msgstr "Font" + +#Height +msgid "SMESH_HEIGHT" +msgstr "Height" + +#Horizontal +msgid "SMESH_HORIZONTAL" +msgstr "Horizontal" + +#Italic +msgid "SMESH_FONT_ITALIC" +msgstr "Italic" + +#Scalar Bar Preferences +msgid "SMESH_PREFERENCES_SCALARBAR" +msgstr "Scalar Bar Preferences" + +#Number Of Colors +msgid "SMESH_NUMBEROFCOLORS" +msgstr "Number Of Colors" + +#Number Of Labels +msgid "SMESH_NUMBEROFLABELS" +msgstr "Number Of Labels" + +#Orientation +msgid "SMESH_ORIENTATION" +msgstr "Orientation" + +#Properties +msgid "SMESH_PROPERTIES" +msgstr "Properties" + +#Shadow +msgid "SMESH_FONT_SHADOW" +msgstr "Shadow" + +#Times +msgid "SMESH_FONT_TIMES" +msgstr "Times" + +#Vertical +msgid "SMESH_VERTICAL" +msgstr "Vertical" + +#Width +msgid "SMESH_WIDTH" +msgstr "Width" + + +# -------------- ScalarBar -------------- + +#Max +msgid "SMESH_MAX" +msgstr "Max" + +#Min +msgid "SMESH_MIN" +msgstr "Min" + +#ScalarBar +msgid "SMESH_SCALARBAR" +msgstr "ScalarBar" + +#Update View +msgid "SMESH_UPDATEVIEW" +msgstr "Update View" + + +# -------------- Connectivity -------------- + +#Boundary Edges +msgid "SMESH_BOUNDARYEDGES" +msgstr "Boundary Edges" + +#Feature Edges +msgid "SMESH_FEATUREEDGES" +msgstr "Feature Edges" + +#Manifold Edges +msgid "SMESH_MANIFOLDEDGES" +msgstr "Manifold Edges" + +#Non Manifold Edges +msgid "SMESH_NONMANIFOLDEDGES" +msgstr "Non Manifold Edges" + +#Edges Connectivity +msgid "SMESH_EDGES_CONNECTIVITY" +msgstr "Edges Connectivity" + +#Edges Connectivity +msgid "SMESH_EDGES_CONNECTIVITY_TITLE" +msgstr "Edges Connectivity" + +#Mesh +msgid "SMESH_MESH" +msgstr "Mesh" + +#Feature Angle +msgid "SMESH_FEATUREANGLE" +msgstr "Feature Angle" + +# -------------- Operations -------------- + +#Change Orientation +msgid "SMESH_ORIENTATION_ELEMENTS_TITLE" +msgstr "Change Orientation" + +#Id Diagonal +msgid "SMESH_ID_DIAGONAL" +msgstr "Id Edges" + +#Diagonal Inversion +msgid "SMESH_DIAGONAL" +msgstr "Diagonal Inversion" + +#Diagonal Inversion +msgid "SMESH_DIAGONAL_INVERSION_TITLE" +msgstr "Diagonal Inversion" + + +# -------------- Mesh Infos -------------- + +#Mesh Infos +msgid "SMESH_MESHINFO_TITLE" +msgstr "Mesh Infos" + +#Number Of 1D Elements +msgid "SMESH_MESHINFO_NB1D" +msgstr "Number Of 1D Elements" + +#Number Of 2D Elements +msgid "SMESH_MESHINFO_NB2D" +msgstr "Number Of 2D Elements" + +#Number Of 3D Elements +msgid "SMESH_MESHINFO_NB3D" +msgstr "Number Of 3D Elements" + +#Edges : +msgid "SMESH_MESHINFO_EDGES" +msgstr "Edges :" + +#Nodes : +msgid "SMESH_MESHINFO_NODES" +msgstr "Nodes :" + +#Triangles : +msgid "SMESH_MESHINFO_TRIANGLES" +msgstr "Triangles :" + +#Quadrangles : +msgid "SMESH_MESHINFO_QUADRANGLES" +msgstr "Quadrangles :" + +#Tetrahedrons : +msgid "SMESH_MESHINFO_TETRAS" +msgstr "Tetrahedrons :" + +#Hexahedrons : +msgid "SMESH_MESHINFO_HEXAS" +msgstr "Hexahedrons :" + + +# -------------- Controls -------------- + +#Length +msgid "SMESH_CONTROL_LENGTH_EDGES" +msgstr "Length" + +#Area +msgid "SMESH_CONTROL_AREA_ELEMENTS" +msgstr "Area" + +#Taper +msgid "SMESH_CONTROL_TAPER_ELEMENTS" +msgstr "Taper" + +#Aspect Ratio +msgid "SMESH_CONTROL_ASPECTRATIO_ELEMENTS" +msgstr "Aspect Ratio" + +#Minimum Angle +msgid "SMESH_CONTROL_MINIMUMANGLE_ELEMENTS" +msgstr "Minimum Angle" + +#Warp +msgid "SMESH_CONTROL_WARP_ELEMENTS" +msgstr "Warp" + +#Skew +msgid "SMESH_CONTROL_SKEW_ELEMENTS" +msgstr "Skew" + +# -------------- Edit -------------- + +#Hypotheses Assignation +msgid "SMESH_EDIT_HYPOTHESES" +msgstr "Hypotheses Assignation" + +#Hypotheses +msgid "SMESH_HYPOTHESES" +msgstr "Hypotheses" + +#Available +msgid "SMESH_AVAILABLE" +msgstr "Available" + +#Used +msgid "SMESH_EDIT_USED" +msgstr "Used" + diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in new file mode 100644 index 000000000..56a008c03 --- /dev/null +++ b/src/SMESH_SWIG/Makefile.in @@ -0,0 +1,43 @@ +# File : Makefile.in +# Created : Tue Mar 26 15:04:48 2002 +# Author : Nicolas REJNERI, Paul RASCLE +# Project : SALOME +# Module : GEOM +# Copyright : Open CASCADE, EDF 2002 +# $Header$ + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSMESH_Swigcmodule.la +LIB_SRC = + +SWIG_DEF = libSMESH_Swig.i +EXPORT_PYSCRIPTS = libSMESH_Swig.py \ + SMESH_test0.py SMESH_test1.py SMESH_test2.py SMESH_test3.py SMESH_mechanic.py SMESH_fixation.py batchmode_smesh.py + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_Exception.idl \ + GEOM_Gen.idl \ + GEOM_Shape.idl \ + SMESH_Gen.idl \ + SMESH_Mesh.idl \ + SMESH_Hypothesis.idl \ + SMESH_BasicHypothesis.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + MED.idl + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H +LIBS+= $(PYTHON_LIBS) +LDFLAGS+= -lSMESHGUI + +@CONCLUDE@ diff --git a/src/SMESH_SWIG/SMESH_fixation.py b/src/SMESH_SWIG/SMESH_fixation.py new file mode 100644 index 000000000..2864e93b2 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_fixation.py @@ -0,0 +1,464 @@ +#============================================================================== +# File : SMESH_fix_volute.py +# Created : mer sep 4 09:58:49 CEST 2002 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2002 +# $Header$ +#============================================================================== + +# +# les numeros d'edge dans les explode sont parfois decales de 1 entre +# le script et le gui +# piece1 --> piece : memes numeros +# ellipse : il faut decrementer de 1 dans le script +# + +import salome +from salome import sg + +import geompy + +##import SMESH +##import smeshpy +##import SMESH_BasicHypothesis_idl + +import math + +# ----------------------------------------------------------------------------- + +def MakeFace(lstEdges) : + """ + Creates a face from 4 edges + """ + lstWire = [] + for edge in lstEdges : + lstWire.append(edge._get_Name()) + wire = geompy.MakeWire(lstWire) + face = geompy.MakeFace(wire, 1) + return face + +def MakeShell(lstFaces) : + """ + Creates a shell from 6 faces + """ + lstShell = [] + for face in lstFaces : + lstShell.append(face._get_Name()) + shell = geompy.MakeSewing(lstShell, 0.00001) + return shell + +def MakeCompound(lstShells) : + """ + Creates a compound from several shells + """ + lstCompound = [] + for shell in lstShells : + lstCompound.append(shell._get_Name()) + compound = geompy.MakeCompound(lstCompound) + return compound + +# ----------------------------------------------------------------------------- + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") +myBuilder = salome.myStudy.NewBuilder() + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +# ---- dimensions + +##longueurPlq = 0.686 +##largeurPlq = 0.573 +##epaisseurPlq = 0.150 + +##hauteurFlanc = 0.380 +##epaisseurFlanc = 0.112 +##rayonConge = 0.150 - epaisseurFlanc + +##epaisseurFond = 0.162 +##rayonTrou = 0.075 +##posAxeTrou = hauteurFlanc -(0.180 + rayonTrou) +##marge = 0.01 +##tol3d = 1.e-5 + +longueurPlq = 686 +largeurPlq = 573 +epaisseurPlq = 150 + +hauteurFlanc = 380 +epaisseurFlanc = 112 +rayonConge = 150 - epaisseurFlanc + +epaisseurFond = 162 +rayonTrou = 75 +posAxeTrou = hauteurFlanc -(180 + rayonTrou) +marge = 10 +tol3d = 1.e-3 + +# ---- points, directions de base + +p0 = geom.MakePointStruct(0., 0., 0.) +px = geom.MakePointStruct(100., 0., 0.) +vx = geom.MakeDirection(px) +py = geom.MakePointStruct(0., 100., 0.) +vy = geom.MakeDirection(py) +pz = geom.MakePointStruct(0., 0., 100.) +vz = geom.MakeDirection(pz) + +# ---- volumes de controle + +volglob = geom.MakeBox( 0., 0., 0., + longueurPlq, + largeurPlq, + hauteurFlanc + epaisseurPlq +marge) +idvolglob = geompy.addToStudy(volglob, "volglob") +volhaut = geom.MakeBox(-marge, + 0.5*(largeurPlq - epaisseurFond), + hauteurFlanc + epaisseurPlq, + longueurPlq+marge, + largeurPlq+marge, + hauteurFlanc + epaisseurPlq +2*marge) +idvolhaut = geompy.addToStudy(volhaut, "volhaut") + +# ---- base + +#plaque = geom.MakeBox( 0., 0., 0., longueurPlq, largeurPlq, epaisseurPlq ) +plaque = geom.MakeBox( -marge, -marge/2, 0., + longueurPlq +2*marge, largeurPlq, epaisseurPlq ) +# ---- fond + +fond = geom.MakeBox( rayonConge, + largeurPlq - epaisseurFond, + epaisseurPlq, + longueurPlq - rayonConge, + largeurPlq, + epaisseurPlq + hauteurFlanc +marge/2) + +# ---- trou du fond + +pAxe1 = geom.MakePointStruct( 0.5*longueurPlq, + 0., + epaisseurPlq + posAxeTrou) +cylFond = geom.MakeCylinder(pAxe1, vy, rayonTrou, 1.1*largeurPlq) +fondTroue = geom.MakeBoolean(fond, cylFond, 2) + +piece = geom.MakeBoolean(plaque, fondTroue, 3) +idPiece = geompy.addToStudy(piece, "piece") + +# ---- cotes + +cote1 = geom.MakeBox(rayonConge, + -marge/2, + epaisseurPlq, + epaisseurFlanc + rayonConge, + largeurPlq - epaisseurFond, + hauteurFlanc + epaisseurPlq +marge/2) +piece = geom.MakeBoolean(piece, cote1, 3) + +cote2 = geom.MakeBox(longueurPlq -epaisseurFlanc -rayonConge, + -marge/2, + epaisseurPlq, + longueurPlq -rayonConge, + largeurPlq - epaisseurFond, + hauteurFlanc + epaisseurPlq +marge/2) +piece = geom.MakeBoolean(piece, cote2, 3) +idPiece = geompy.addToStudy(piece, "piece1") + +# ---- ellipse du flanc + +he = hauteurFlanc -2*rayonConge +re = 0.5*(largeurPlq - epaisseurFond) - rayonConge +sine = re/he +cose = math.sqrt(1.-sine*sine) +pe = geom.MakePointStruct(sine, 0., cose) +ve = geom.MakeDirection(pe) +cyl0 = geom.MakeCylinder(p0, ve, re, 2*he) +axecy = geom.MakeAxisStruct(0., 0., 0.,sine, 0., cose) +cyl1 = geom.MakeRotation(cyl0, axecy, 0.5) +cyle = geom.MakeTranslation(cyl1, + -marge*sine, 0., -marge*cose) +boxe = geom.MakeBox(0., 0., 0., 3*he, -2*re, 3*he) +#idcyle = geompy.addToStudy(cyle, "cyle") +#idboxe = geompy.addToStudy(boxe, "boxe") +cylcoup = geom.MakeBoolean(cyle, boxe, 2) +idcylcoup = geompy.addToStudy(cylcoup, "cylcoup") +aretes = [] +aretes = geompy.SubShapeAll(cylcoup, ShapeTypeEdge) +# OCC3.1 : aretes[3], OCC4.0 aretes[5] +shape = geom.MakeCopy(aretes[5]) +aShape = geom.MakeTranslation(shape, + 0., rayonConge +re, epaisseurPlq +2*rayonConge) + +# ---- segments face objet decoupe des flancs + +pf1 = geom.MakePointStruct(0., + -marge, + hauteurFlanc + epaisseurPlq +marge) +pf2 = geom.MakePointStruct(0., + 0.5*(largeurPlq - epaisseurFond), + hauteurFlanc + epaisseurPlq +marge) +pf3 = geom.MakePointStruct(0., + 0.5*(largeurPlq - epaisseurFond), + hauteurFlanc + epaisseurPlq) +pf4 = geom.MakePointStruct(0., + rayonConge, + epaisseurPlq +2*rayonConge) +pf5 = geom.MakePointStruct(0., + rayonConge, + epaisseurPlq) +pf6 = geom.MakePointStruct(0., + -marge, + epaisseurPlq) + +vf1 = geom.MakeEdge(pf1,pf2) +vf2 = geom.MakeEdge(pf2,pf3) +vf4 = geom.MakeEdge(pf4,pf5) +vf5 = geom.MakeEdge(pf5,pf6) +vf6 = geom.MakeEdge(pf6,pf1) + +id1 = geompy.addToStudy(vf1,"vf1") +id2 = geompy.addToStudy(vf2,"vf2") +ids = geompy.addToStudy(aShape,"aShape") +id4 = geompy.addToStudy(vf4,"vf4") +id5 = geompy.addToStudy(vf5,"vf5") +id6 = geompy.addToStudy(vf6,"vf6") + +faceDec = MakeFace([vf1,vf2,aShape,vf4,vf5,vf6]) +idf = geompy.addToStudy(faceDec,"faceDec") + +# forme de decoupe par extrusion + +pfe = geom.MakePointStruct(longueurPlq+4*marge, 0., 0.) +decoupe = geom.MakePrism(faceDec, p0, pfe) +decoupe = geom.MakeTranslation(decoupe, -2*marge, 0., 0.) +idec = geompy.addToStudy(decoupe, "decoupe") + +# decoupe piece1 par decoupe + +piece2 = geom.MakeBoolean(piece, decoupe, 2) +idpiece = geompy.addToStudy(piece2, "piece2") + +# conges +conges = [] +conges = geompy.SubShapeAllSorted(piece2, ShapeTypeEdge) + + +# boucle pour trouver les bons indices +#ind = 0 +#for ff in conges: +# print ind, ff._get_Index() +# name = "edge%d"%(ind) +# geompy.addToStudy(ff, name) +# ind = ind + 1 + + +index1 = conges[7]._get_Index() +index2 = conges[11]._get_Index() +index3 = conges[36]._get_Index() +index4 = conges[43]._get_Index() + +#piece3 = geompy.MakeFillet (piece2, rayonConge, ShapeTypeEdge, [3,4,8,9]) +piece3 = geompy.MakeFillet (piece2, rayonConge, ShapeTypeEdge, [index1[0],index2[0],index3[0],index4[0]]) + +idPiece = geompy.addToStudy(piece3, "piece3") + +# partie incluse dans le volume de controle (devient non valide) + +piece4 = geom.MakeBoolean(piece3, volglob, 1) +idPiece = geompy.addToStudy(piece4, "piece4") + +# enlever volume haut + +piece = geom.MakeBoolean(piece4, volhaut, 2) +idpiece = geompy.addToStudy(piece, "piece") + +# ----------------------------------------------------------------------------- +# ---- decoupage de la piece en volumes a 6 faces de 4 cotes +# ----------------------------------------------------------------------------- + +# ---- cotes x + +x0 = 0. +x0h = rayonConge +x1 = rayonConge + epaisseurFlanc +xc = longueurPlq/2 +x2 = longueurPlq - rayonConge - epaisseurFlanc +x3h = longueurPlq - rayonConge +x3 = longueurPlq + +# ---- cotes y + +y0 = 0. +y0h = rayonConge +y1 = largeurPlq - epaisseurFond +y1m = y1 -marge +y2 = largeurPlq +y2p = largeurPlq + marge + +# ---- cotes z + +z0 = 0. +z1m = epaisseurPlq -marge +z1 = epaisseurPlq +z2 = epaisseurPlq + rayonConge +z3 = epaisseurPlq + 2*rayonConge +z4 = epaisseurPlq + hauteurFlanc +z4p = epaisseurPlq + hauteurFlanc + marge + +zc = epaisseurPlq + posAxeTrou +zc2 = epaisseurPlq + (posAxeTrou -rayonTrou)/3 +zc3 = epaisseurPlq + 2*(posAxeTrou -rayonTrou)/3 + +# ---- decoupe du fond + +p11 = geom.MakePointStruct(x1, y1m, z1) +p12 = geom.MakePointStruct(x1, y1m, z2) +p13 = geom.MakePointStruct(x1, y1m, z3) +p14 = geom.MakePointStruct(x1, y1m, z4) +pc1 = geom.MakePointStruct(xc, y1m, z1) +pc2 = geom.MakePointStruct(xc, y1m, zc2) +pc3 = geom.MakePointStruct(xc, y1m, zc3) +pcc = geom.MakePointStruct(xc, y1m, zc) +pc4 = geom.MakePointStruct(xc, y1m, z4) +p21 = geom.MakePointStruct(x2, y1m, z1) +p22 = geom.MakePointStruct(x2, y1m, z2) +p23 = geom.MakePointStruct(x2, y1m, z3) +p24 = geom.MakePointStruct(x2, y1m, z4) +pcf = geom.MakePointStruct(xc, y2p, zc) + +arc2 = geom.MakeArc(p12,pc2,p22) +arc3 = geom.MakeArc(p13,pc3,p23) + +segz1 = geom.MakeVector(p11,p21) +#segz4 = geom.MakeVector(p14,p24) +segz41 = geom.MakeVector(p14,pc4) +segz42 = geom.MakeVector(pc4,p24) +segx11 = geom.MakeVector(p11,p12) +segx12 = geom.MakeVector(p12,p13) +segx13 = geom.MakeVector(p13,p14) +segxc2 = geom.MakeVector(pc1,pc2) +segxc3 = geom.MakeVector(pc2,pc3) +segxc4 = geom.MakeVector(pcc,pc4) +segx21 = geom.MakeVector(p21,p22) +segx22 = geom.MakeVector(p22,p23) +segx23 = geom.MakeVector(p23,p24) +segx1c1 = geom.MakeVector(p13,pcc) +segx1c2 = geom.MakeVector(p14,pcc) +segx2c1 = geom.MakeVector(p23,pcc) +segx2c2 = geom.MakeVector(p24,pcc) + +facef = [] +facef.append(MakeFace([segx13,segx1c2,segx1c1])) +facef.append(MakeFace([segx23,segx2c2,segx2c1])) +facef.append(MakeFace([segx2c2,segxc4,segz42])) +facef.append(MakeFace([segx1c2,segz41,segxc4])) +facef.append(MakeFace([segx1c1,arc3,segx2c1])) +facef.append(MakeFace([segx12,arc2,segx22,arc3])) +facef.append(MakeFace([segx11,segz1,segx21,arc2])) + +decf =[] +for face in facef: + decf.append(geom.MakePrism(face,pcc,pcf)) + +axeCyl = geom.MakeAxisStruct( 0.5*longueurPlq, + 0., + epaisseurPlq + posAxeTrou, + 0., + largeurPlq, + 0.) +cylFond2 = geom.MakeRotation(geom.MakeCopy(cylFond),axeCyl,math.pi) +idcylfond2 = geompy.addToStudy(cylFond2,"cylFond2") + +fondec =[] +for id in (0,1,2,3): + fondec.append(geom.MakeBoolean(decf[id],cylFond2,2)) +fondec.append(geom.MakeBoolean(decf[4],cylFond,2)) +for id in (5,6): + fondec.append(decf[id]) + +iff=0 +for ff in fondec: + idfo = geompy.addToStudy(ff, "ff%d"%(iff)) + iff = iff +1 + +# ----- autres blocs de decoupe + +bcong1=geom.MakeBox(x0,y0,z1, x1,y1,z2) +bcong2=geom.MakeBox(x0,y1,z1, x1,y2,z2) +bcong3=geom.MakeBox(x2,y0,z1, x3,y1,z2) +bcong4=geom.MakeBox(x2,y1,z1, x3,y2,z2) + +pcylx0 = geom.MakePointStruct(0., -marge, z2) +cylcongx0 = geom.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq +2*marge) +idcylcongx0 = geompy.addToStudy(cylcongx0,"cylcongx0") +pcylx3 = geom.MakePointStruct(longueurPlq, -marge, z2) +cylcongx3 = geom.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq +2*marge) +idcylcongx3 = geompy.addToStudy(cylcongx3,"cylcongx3") +pcyly0 = geom.MakePointStruct(-marge, 0., z2) +cylcongy0 = geom.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq +2*marge) +idcylcongy0 = geompy.addToStudy(cylcongy0,"cylcongy0") + +bcong1=geom.MakeBoolean(bcong1,cylcongx0,2) +bcong2=geom.MakeBoolean(bcong2,cylcongx0,2) +bcong1=geom.MakeBoolean(bcong1,cylcongy0,2) +bcong3=geom.MakeBoolean(bcong3,cylcongx3,2) +bcong4=geom.MakeBoolean(bcong4,cylcongx3,2) +bcong3=geom.MakeBoolean(bcong3,cylcongy0,2) + +pf1 = geom.MakePointStruct(0., y0h, z3) +pf2 = geom.MakePointStruct(0., y1, z3) +pf3 = geom.MakePointStruct(0., y1, z4) +pf4 = geom.MakePointStruct(0.,0.5*(largeurPlq - epaisseurFond) , z4) +vf1 = geom.MakeEdge(pf1,pf2) +vf2 = geom.MakeEdge(pf2,pf3) +vf3 = geom.MakeEdge(pf3,pf4) +faceFlanc = MakeFace([vf1,vf2,vf3,aShape]) +idfaceFlanc = geompy.addToStudy(faceFlanc,"faceFlanc") +pfe = geom.MakePointStruct(epaisseurFlanc, 0., 0.) +flanc1 = geom.MakePrism(faceFlanc, p0, pfe) +flanc2 = geom.MakeCopy(flanc1) +flanc1 = geom.MakeTranslation(flanc1, + rayonConge,0.,0.) +flanc2 = geom.MakeTranslation(flanc2, + longueurPlq-rayonConge-epaisseurFlanc,0.,0.) + +# ---- constitution et decoupe des blocs +boxfond2 = geom.MakeBox(x0, y1, z0, x3, y2, z4p) +idboxfond2 = geompy.addToStudy(boxfond2,"boxfond2") + +blocs = [] +for dec in fondec: + blocs.append(geom.MakeBoolean(boxfond2, dec, 1)) +blocs.append(geom.MakeBox(x0,y1,z0, x1,y2,z1)) +blocs.append(geom.MakeBox(x1,y1,z0, x2,y2,z1)) +blocs.append(geom.MakeBox(x2,y1,z0, x3,y2,z1)) +blocs.append(geom.MakeBox(x0,y0,z0, x1,y1,z1)) +blocs.append(geom.MakeBox(x1,y0,z0, x2,y1,z1)) +blocs.append(geom.MakeBox(x2,y0,z0, x3,y1,z1)) +blocs.append(bcong2) +blocs.append(bcong4) +blocs.append(bcong1) +blocs.append(bcong3) +blocs.append(geom.MakeBox(x0h,y1, z2, x1, y2, z3)) +blocs.append(geom.MakeBox(x2, y1, z2, x3h,y2, z3)) +blocs.append(geom.MakeBox(x0h,y0h,z2, x1, y1, z3)) +blocs.append(geom.MakeBox(x2, y0h,z2, x3h,y1, z3)) +blocs.append(geom.MakeBox(x0h,y1, z3, x1, y2, z4)) +blocs.append(geom.MakeBox(x2, y1, z3, x3h,y2, z4)) +blocs.append(flanc1) +blocs.append(flanc2) + +compbloc = MakeCompound(blocs) +idcomp = geompy.addToStudy(compbloc,"compbloc") + +# ---- eliminer les faces en double, solid-->shell + +compshell = geom.MakeGlueFaces(compbloc,tol3d) +idcomp = geompy.addToStudy(compshell,"compshell") + diff --git a/src/SMESH_SWIG/SMESH_mechanic.py b/src/SMESH_SWIG/SMESH_mechanic.py new file mode 100644 index 000000000..c7ed695c7 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_mechanic.py @@ -0,0 +1,308 @@ +#============================================================================== +# File : SMESH_withHole.py +# Created : 26 august 2002 +# Author : Lucien PIGNOLONI +# Project : SALOME +# Copyright : Open CASCADE, 2002 +# $Header$ +#============================================================================== + +import SMESH +import smeshpy +import salome +from salome import sg +import math +#import SMESH_BasicHypothesis_idl + +import geompy + + + +# ---------------------------- GEOM -------------------------------------- +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") +myBuilder = salome.myStudy.NewBuilder() +#from geompy import gg + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + + +# ---- define contigous arcs and segment to define a closed wire + +p1 = geom.MakePointStruct( 100.0, 0.0, 0.0 ) +p2 = geom.MakePointStruct( 50.0, 50.0, 0.0 ) +p3 = geom.MakePointStruct( 100.0, 100.0, 0.0 ) +arc1 = geom.MakeArc( p1, p2, p3 ) + +p4 = geom.MakePointStruct( 170.0, 100.0, 0.0 ) +seg1 = geom.MakeVector( p3, p4 ) + +p5 = geom.MakePointStruct( 200.0, 70.0, 0.0 ) +p6 = geom.MakePointStruct( 170.0, 40.0, 0.0 ) +arc2 = geom.MakeArc( p4, p5, p6 ) + +p7 = geom.MakePointStruct( 120.0, 30.0, 0.0 ) +arc3 = geom.MakeArc( p6, p7, p1 ) + + +# ---- define a closed wire with arcs and segment + +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +ListIOR1 = [] +for S in List1 : + ListIOR1.append( S._get_Name() ) +wire1 = geom.MakeWire( ListIOR1 ) + +Id_wire1 = geompy.addToStudy( wire1, "wire1") + + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geom.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1") + + +# ---- create a shape by extrusion +pO = geom.MakePointStruct( 0.0, 0.0, 0.0 ) +pz = geom.MakePointStruct( 0.0, 0.0, 100.0 ) + +prism1 = geom.MakePrism( face1, pO, pz ) +Id_prism1 = geompy.addToStudy( prism1, "prism1") + + + +# ---- create two cylinders + +pc1 = geom.MakePointStruct( 90.0, 50.0, -40.0 ) +pc2 = geom.MakePointStruct( 170.0, 70.0, -40.0 ) +vz = geom.MakeDirection( pz ) +radius = 20.0 +height = 180.0 +cyl1 = geom.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geom.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + + +# ---- cut with cyl1 +shape = geom.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 +shape1 = geom.MakeBoolean( shape, cyl2, 3 ) + +Id_shape1 = geompy.addToStudy( shape1, "shape1") + + +# ---- add a face sub shape in study to be meshed different +IdSubFaceList = [] +IdSubFaceList.append(10) +sub_face = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceList ) +name = geompy.SubShapeName( sub_face._get_Name(), shape1._get_Name() ) + +Id_SubFace = geompy.addToStudyInFather( shape1, sub_face, name ) + + +# ---- add a face sub shape in study to be meshed different +IdSubFaceL = [] +IdSubFaceL.append(7) +sub_face2 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL ) +name = geompy.SubShapeName( sub_face2._get_Name(), shape1._get_Name() ) + +Id_SubFace2 = geompy.addToStudyInFather( shape1, sub_face2, name ) + + + + +# ---------------------------- SMESH -------------------------------------- + +# ---- launch SMESH, init a Mesh with shape 'shape1' +gen = smeshpy.smeshpy() +mesh = gen.Init( Id_shape1 ) + +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName( idmesh, "Mesh_meca" ); +smeshgui.SetShape( Id_shape1, idmesh ); + + +# ------------------------------ Length Hypothesis + +print "-------------------------- create Hypothesis" +print "-------------------------- LocalLength" +hyp1 = gen.CreateHypothesis( "LocalLength" ) +hypLen1 = hyp1._narrow( SMESH.SMESH_LocalLength ) +hypLen1.SetLength( 100.0 ) +print hypLen1.GetName() +print hypLen1.GetId() +print hypLen1.GetLength() + +idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) ); +smeshgui.SetName(idlength, "Local_Length_100"); + + +print "-------------------------- NumberOfSegments" + +hyp2 = gen.CreateHypothesis( "NumberOfSegments" ) +hypNbSeg1 = hyp2._narrow( SMESH.SMESH_NumberOfSegments ) +hypNbSeg1.SetNumberOfSegments( 10 ) +print hypNbSeg1.GetName() +print hypNbSeg1.GetId() +print hypNbSeg1.GetNumberOfSegments() + +idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) ); +smeshgui.SetName(idseg, "NumberOfSegments_12"); + + +print "-------------------------- MaxElementArea" + +hyp3 = gen.CreateHypothesis( "MaxElementArea" ) +hypArea1 = hyp3._narrow( SMESH.SMESH_MaxElementArea ) +hypArea1.SetMaxElementArea( 25 ) +print hypArea1.GetName() +print hypArea1.GetId() +print hypArea1.GetMaxElementArea() + +idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) ); +smeshgui.SetName(idarea1, "MaxElementArea_20"); + + + +print "-------------------------- MaxElementArea" + +hyp4 = gen.CreateHypothesis( "MaxElementArea" ) +hypArea2 = hyp4._narrow( SMESH.SMESH_MaxElementArea ) +hypArea2.SetMaxElementArea( 35 ) +print hypArea2. GetName() +print hypArea2.GetId() +print hypArea2.GetMaxElementArea() + +idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) ); +smeshgui.SetName(idarea2, "MaxElementArea_30"); + + +print "-------------------------- Regular_1D" + +alg1 = gen.CreateHypothesis( "Regular_1D" ) +algo1 = alg1._narrow( SMESH.SMESH_Algo ) +listHyp =algo1.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +algoReg1d = alg1._narrow( SMESH.SMESH_Regular_1D ) +print algoReg1d.GetName() +print algoReg1d.GetId() + +idreg1d = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg1d) ); +smeshgui.SetName( idreg1d, "Regular_1D" ); + + + +print "-------------------------- MEFISTO_2D" + +alg2 = gen.CreateHypothesis( "MEFISTO_2D" ) +algo2 = alg2._narrow( SMESH.SMESH_Algo ) +listHyp = algo2.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +algoMef = alg2._narrow( SMESH.SMESH_MEFISTO_2D ) +print algoMef.GetName() +print algoMef.GetId() + +idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) ); +smeshgui.SetName( idmef, "MEFISTO_2D" ); + + + +print "-------------------------- SMESH_Quadrangle_2D" + +alg3 = gen.CreateHypothesis( "Quadrangle_2D" ) +algo3 = alg3._narrow( SMESH.SMESH_2D_Algo ) +listHyp = algo3.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +algoQad2 = alg3._narrow( SMESH.SMESH_Quadrangle_2D ) +print algoQad2.GetName() +print algoQad2.GetId() + +idqad2 = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoQad2) ); +smeshgui.SetName( idqad2, "SMESH_Quadrangle_2D" ); + + + +print "-------------------------- add hypothesis to main shape1" + +shape_mesh = salome.IDToObject( Id_shape1 ) +submesh = mesh.GetElementsOnShape( shape_mesh ) + +ret = mesh.AddHypothesis( shape_mesh, algoReg1d ) # Regular 1D/wire discretisation +print ret +ret = mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D +print ret +ret = mesh.AddHypothesis( shape_mesh, hypNbSeg1 ) # nb segments +print ret +ret = mesh.AddHypothesis( shape_mesh, hypArea1 ) # max area +print ret + +smeshgui.SetAlgorithms( idmesh, idreg1d ); # Regular 1D/wire discretisation +smeshgui.SetAlgorithms( idmesh, idmef ); # MEFISTO 2D +smeshgui.SetHypothesis( idmesh, idseg ); # nb segments +smeshgui.SetHypothesis( idmesh, idarea1 ); # max area + + + +print "-------------------------- add hypothesis and algorith to sub face" + +sub_face = salome.IDToObject( Id_SubFace ) +submesh = mesh.GetElementsOnShape( sub_face ) + +ret = mesh.AddHypothesis( sub_face, algoQad2 ) # Quadrangle 2D +print ret +ret = mesh.AddHypothesis( sub_face, hypArea2 ) # max area +print ret + +idsm2 = smeshgui.AddSubMeshOnShape( idmesh, + Id_SubFace, + salome.orb.object_to_string(submesh), + ShapeTypeFace ) + +smeshgui.SetName(idsm2, "SubMeshFace") +smeshgui.SetAlgorithms( idsm2, idqad2 ); # Quadrangle 2D +smeshgui.SetHypothesis( idsm2, idarea2 ); # max area + + + +print "-------------------------- add hypothesis and algorith to sub face" + +sub_face2 = salome.IDToObject( Id_SubFace2 ) +submesh = mesh.GetElementsOnShape( sub_face2 ) + +ret = mesh.AddHypothesis( sub_face2, algoQad2 ) # Quadrangle 2D +print ret +ret = mesh.AddHypothesis( sub_face2, hypArea2 ) # max area +print ret + +idsm3 = smeshgui.AddSubMeshOnShape( idmesh, + Id_SubFace2, + salome.orb.object_to_string(submesh), + ShapeTypeFace ) + +smeshgui.SetName(idsm3, "SubMeshFace2") +smeshgui.SetAlgorithms( idsm3, idqad2 ); # Quadrangle 2D +smeshgui.SetHypothesis( idsm3, idarea2 ); # max area + + + + +sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_test0.py b/src/SMESH_SWIG/SMESH_test0.py new file mode 100644 index 000000000..efa887ea2 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test0.py @@ -0,0 +1,54 @@ +import SMESH +import smeshpy +import salome +from salome import sg +import math +#import SMESH_BasicHypothesis_idl + +import geompy + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") +myBuilder = salome.myStudy.NewBuilder() +from geompy import gg + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box,"box") + +# ---- add first face of box in study + +subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) +face=subShapeList[0] +name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) +print name +idface=geompy.addToStudyInFather(box,face,name) + +# ---- add shell from box in study + +subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +shell = subShellList[0] +name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) +print name +idshell=geompy.addToStudyInFather(box,shell,name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) +edge=edgeList[0]; +name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) +print name +idedge=geompy.addToStudyInFather(face,edge,name) + +sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_test1.py b/src/SMESH_SWIG/SMESH_test1.py new file mode 100644 index 000000000..d36f7bec4 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test1.py @@ -0,0 +1,185 @@ +import SMESH +import smeshpy +import salome +from salome import sg +import math +#import SMESH_BasicHypothesis_idl + +import geompy + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") +myBuilder = salome.myStudy.NewBuilder() +from geompy import gg + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +# ---- define a box + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box,"box") + +# ---- add first face of box in study + +subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) +face=subShapeList[0] +name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) +print name +idface=geompy.addToStudyInFather(box,face,name) + +# ---- add shell from box in study + +subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +shell = subShellList[0] +name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) +print name +idshell=geompy.addToStudyInFather(box,shell,name) + +# ---- add first edge of face in study + +edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) +edge=edgeList[0]; +name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) +print name +idedge=geompy.addToStudyInFather(face,edge,name) + +# ---- launch SMESH, init a Mesh with the box +gen=smeshpy.smeshpy() +mesh=gen.Init(idbox) + +idmesh = smeshgui.AddNewMesh( salome.orb.object_to_string(mesh) ) +smeshgui.SetName(idmesh, "Meshbox"); +smeshgui.SetShape(idbox, idmesh); + +# ---- create Hypothesis + +print "-------------------------- create Hypothesis" +print "-------------------------- LocalLength" +hyp1=gen.CreateHypothesis("LocalLength") +hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength) +hypLen1.SetLength(100) +print hypLen1.GetName() +print hypLen1.GetId() +print hypLen1.GetLength() + +idlength = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypLen1) ); +smeshgui.SetName(idlength, "Local_Length_100"); + +print "-------------------------- NumberOfSegments" +hyp2=gen.CreateHypothesis("NumberOfSegments") +hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments) +hypNbSeg1.SetNumberOfSegments(7) +print hypNbSeg1.GetName() +print hypNbSeg1.GetId() +print hypNbSeg1.GetNumberOfSegments() + +idseg = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypNbSeg1) ); +smeshgui.SetName(idseg, "NumberOfSegments_7"); + +print "-------------------------- MaxElementArea" +hyp3=gen.CreateHypothesis("MaxElementArea") +hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea) +hypArea1.SetMaxElementArea(2500) +print hypArea1.GetName() +print hypArea1.GetId() +print hypArea1.GetMaxElementArea() + +idarea1 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea1) ); +smeshgui.SetName(idarea1, "MaxElementArea_2500"); + +print "-------------------------- MaxElementArea" +hyp3=gen.CreateHypothesis("MaxElementArea") +hypArea2=hyp3._narrow(SMESH.SMESH_MaxElementArea) +hypArea2.SetMaxElementArea(500) +print hypArea2.GetName() +print hypArea2.GetId() +print hypArea2.GetMaxElementArea() + +idarea2 = smeshgui.AddNewHypothesis( salome.orb.object_to_string(hypArea2) ); +smeshgui.SetName(idarea2, "MaxElementArea_500"); + +print "-------------------------- Regular_1D" +alg1=gen.CreateHypothesis("Regular_1D") +algo1=alg1._narrow(SMESH.SMESH_Algo) +listHyp=algo1.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +algoReg=alg1._narrow(SMESH.SMESH_Regular_1D) +print algoReg.GetName() +print algoReg.GetId() + +idreg = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoReg) ); +smeshgui.SetName(idreg, "Regular_1D"); + +print "-------------------------- MEFISTO_2D" +alg2=gen.CreateHypothesis("MEFISTO_2D") +algo2=alg2._narrow(SMESH.SMESH_Algo) +listHyp=algo2.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D) +print algoMef.GetName() +print algoMef.GetId() + +idmef = smeshgui.AddNewAlgorithms( salome.orb.object_to_string(algoMef) ); +smeshgui.SetName(idmef, "MEFISTO_2D"); + +# ---- add hypothesis to edge + +print "-------------------------- add hypothesis to edge" +edge=salome.IDToObject(idedge) +submesh=mesh.GetElementsOnShape(edge) +ret=mesh.AddHypothesis(edge,algoReg) +print ret +ret=mesh.AddHypothesis(edge,hypLen1) +print ret + +idsm1 = smeshgui.AddSubMeshOnShape( idmesh, + idedge, + salome.orb.object_to_string(submesh), + ShapeTypeEdge ) +smeshgui.SetName(idsm1, "SubMeshEdge") +smeshgui.SetAlgorithms( idsm1, idreg ); +smeshgui.SetHypothesis( idsm1, idlength ); + +print "-------------------------- add hypothesis to face" +face=salome.IDToObject(idface) +submesh=mesh.GetElementsOnShape(face) +ret=mesh.AddHypothesis(face,hypArea2) +print ret + +idsm2 = smeshgui.AddSubMeshOnShape( idmesh, + idface, + salome.orb.object_to_string(submesh), + ShapeTypeFace ) +smeshgui.SetName(idsm2, "SubMeshFace") +smeshgui.SetHypothesis( idsm2, idarea2 ); + +# ---- add hypothesis to box + +print "-------------------------- add hypothesis to box" +box=salome.IDToObject(idbox) +submesh=mesh.GetElementsOnShape(box) +ret=mesh.AddHypothesis(box,algoReg) +print ret +ret=mesh.AddHypothesis(box,hypNbSeg1) +print ret +ret=mesh.AddHypothesis(box,algoMef) +print ret +ret=mesh.AddHypothesis(box,hypArea1) +print ret + +smeshgui.SetAlgorithms( idmesh, idreg ); +smeshgui.SetHypothesis( idmesh, idseg ); +smeshgui.SetAlgorithms( idmesh, idmef ); +smeshgui.SetHypothesis( idmesh, idarea1 ); + +sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_test2.py b/src/SMESH_SWIG/SMESH_test2.py new file mode 100644 index 000000000..e35b2c467 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test2.py @@ -0,0 +1,43 @@ + +from SMESH_test1 import * + +# ---- compute box + +print "-------------------------- compute box" +ret=gen.Compute(mesh,idbox) +print ret +log=mesh.GetLog(0); # no erase trace +for linelog in log: + print linelog + + +sg.updateObjBrowser(1); + +# ---- compute edge + +##print "-------------------------- compute edge" +##ret=gen.Compute(mesh,idedge) +##print ret +##log=mesh.GetLog(1); +##for a in log: +## print a + +# ---- add hypothesis to face + +# ---- compute face + +#print "-------------------------- compute face" +#ret=gen.Compute(mesh,idface) +#print ret +#log=mesh.GetLog(1); +#for a in log: +# print a + +##shell=salome.IDToObject(ids) +##submesh=mesh.GetElementsOnShape(shell) +##ret=mesh.AddHypothesis(shell,algoReg) +##print ret +##ret=mesh.AddHypothesis(shell,hypLen1) +##print ret +##ret=gen.Compute(mesh,ids) +##print ret diff --git a/src/SMESH_SWIG/SMESH_test3.py b/src/SMESH_SWIG/SMESH_test3.py new file mode 100644 index 000000000..f2267a112 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test3.py @@ -0,0 +1,90 @@ +#import SMESH +import smeshpy +import salome +from salome import sg +import math +#import SMESH_BasicHypothesis_idl + +import geompy + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "Geometry") +myBuilder = salome.myStudy.NewBuilder() +from geompy import gg + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +pi=math.pi + +# --------------------------------------------- +xa=math.sin(pi/12) +ya=0 +za=math.cos(pi/12) + +xb=0 +yb=math.sin(pi/18) +zb=math.cos(pi/18) + +xc=math.cos(-pi/18) +yc=0 +zc=math.sin(-pi/18) + +rc1=150 +hc1=300 +rc2=150 +rc3=150 +rc4=300 +# --------------------------------------------- +point_0 = geom.MakePointStruct(0, 0, 0) +point_z = geom.MakePointStruct(0, 0, 1) + +point_a = geom.MakePointStruct(xa, ya, za) +point_b = geom.MakePointStruct(xb, yb, zb) +point_c = geom.MakePointStruct(xc, yc, zc) + +dir_z = geom.MakeDirection(point_z) +axe_z = geom.MakeAxisStruct(0, 0, 0, 0, 0, 1) + +dir_a = geom.MakeDirection(point_a) +axe_a = geom.MakeAxisStruct(0, 0, 0, xa, ya, za) + +dir_b = geom.MakeDirection(point_b) +axe_b = geom.MakeAxisStruct(0, 0, 0, xb, yb, zb) + +dir_c = geom.MakeDirection(point_c) +axe_c = geom.MakeAxisStruct(0, 0, 0, xc, yc, zc) + +cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1) + +hc2=2*hc1 +cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2) +cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1) + +hc3=2*hc1 +cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3) +cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1) + +hc4=2*hc1 +cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4) +cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2) +cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0) +cyl_d = geompy.MakeTranslation(cyl_t, -hc1, 0, 1.3*rc4) + +inter_t = geompy.MakeBoolean(cyl_c,cyl_d, 1) # common + +blob_t = geompy.MakeBoolean(cyl_1, cyl_a, 2) # cut +blob_t = geompy.MakeBoolean(blob_t, cyl_b, 2) + +blob = geompy.MakeBoolean(blob_t, inter_t, 1) # common + +idblob = geompy.addToStudy(blob,"blob") +#idc = geompy.addToStudy(cyl_c,"cyl_c") +#idd = geompy.addToStudy(cyl_d,"cyl_d") diff --git a/src/SMESH_SWIG/batchmode_smesh.py b/src/SMESH_SWIG/batchmode_smesh.py new file mode 100644 index 000000000..6ee609495 --- /dev/null +++ b/src/SMESH_SWIG/batchmode_smesh.py @@ -0,0 +1,302 @@ +#============================================================================== +# File : batchmode_smesh.py +# Created : Fri Nov 15 13:51:00 2002 +# Author : Oksana TCHEBANOVA +# Project : SALOME +# Copyright : OPEN CASCADE 2002 +# $Header$ +#============================================================================== + +#-------------------------------------------------------------------------- + +from batchmode_salome import * +import SMESH + +#-------------------------------------------------------------------------- +modulecatalog = naming_service.Resolve("/Kernel/ModulCatalog") + +smesh = lcc.FindOrLoadComponent("FactoryServer", "SMESH") +myStudyBuilder = myStudy.NewBuilder() + +if myStudyBuilder is None: + raise RuntimeError, " Null myStudyBuilder" + +father = myStudy.FindComponent("MESH") +if father is None: + father = myStudyBuilder.NewComponent("MESH") + A1 = myStudyBuilder.FindOrCreateAttribute(father, "AttributeName"); + FName = A1._narrow(SALOMEDS.AttributeName) +# FName.SetValue("Mesh") + + Comp = modulecatalog.GetComponent( "SMESH" ) + FName.SetValue( Comp._get_componentusername() ) + + A2 = myStudyBuilder.FindOrCreateAttribute(father, "AttributePixMap"); + aPixmap = A2._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "ICON_OBJBROWSER_Mesh" ); + +myStudyBuilder.DefineComponentInstance(father,smesh) + +mySComponentMesh = father._narrow(SALOMEDS.SComponent) + +Tag_HypothesisRoot = 1; +Tag_AlgorithmsRoot = 2; + +Tag_RefOnShape = 1; +Tag_RefOnAppliedHypothesis = 2; +Tag_RefOnAppliedAlgorithms = 3; + +Tag_SubMeshOnVertex = 4; +Tag_SubMeshOnEdge = 5; +Tag_SubMeshOnFace = 6; +Tag_SubMeshOnSolid = 7; +Tag_SubMeshOnCompound = 8; + +Tag = {"HypothesisRoot":1,"AlgorithmsRoot":2,"RefOnShape":1,"RefOnAppliedHypothesis":2,"RefOnAppliedAlgorithms":3,"SubMeshOnVertex":4,"SubMeshOnEdge":5,"SubMeshOnFace":6,"SubMeshOnSolid":7,"SubMeshOnCompound":8} + +# -- enumeration -- +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +# -- enumeration ShapeType as a dictionary -- +ShapeType = {"CompSolid":1, "Solid":2, "Shell":3, "Face":4, "Wire":5, "Edge":6, "Vertex":7} + +#------------------------------------------------------------ +def Init(): + pass +#------------------------------------------------------------ +def AddNewMesh(IOR): + res,HypothesisRoot = mySComponentMesh.FindSubObject ( Tag_HypothesisRoot ) + if HypothesisRoot is None or res == 0: + HypothesisRoot = myStudyBuilder.NewObjectToTag(mySComponentMesh, Tag_HypothesisRoot) + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName") + aName = anAttr._narrow(SALOMEDS.AttributeName) + aName.SetValue("Hypothesis Definition") + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap") + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap) + aPixmap.SetPixMap( "mesh_tree_hypo.png" ) + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable") + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable) + aSelAttr.SetSelectable(0); + + res, AlgorithmsRoot = mySComponentMesh.FindSubObject (Tag_AlgorithmsRoot) + if AlgorithmsRoot is None or res == 0: + AlgorithmsRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot) + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName") + aName = anAttr._narrow(SALOMEDS.AttributeName) + aName.SetValue("Algorithms Definition"); + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "mesh_tree_algo.png" ); + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + + HypothesisRoot = HypothesisRoot._narrow(SALOMEDS.SObject) + newMesh = myStudyBuilder.NewObject(mySComponentMesh) + newMesh = newMesh._narrow(SALOMEDS.SObject) + anAttr = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributePixMap") + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap) + aPixmap.SetPixMap( "mesh_tree_mesh.png" ) + anAttr = myStudyBuilder.FindOrCreateAttribute(newMesh, "AttributeIOR") + anIOR = anAttr._narrow(SALOMEDS.AttributeIOR) + anIOR.SetValue(IOR) + return newMesh.GetID() + +#------------------------------------------------------------ +def AddNewHypothesis(IOR): + res, HypothesisRoot = mySComponentMesh.FindSubObject (Tag_HypothesisRoot) + if HypothesisRoot is None or res == 0: + HypothesisRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot) + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName"); + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue("Hypothesis Definition"); + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + anAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "mesh_tree_hypo.png" ); + + # Add New Hypothesis + newHypo = myStudyBuilder.NewObject(HypothesisRoot) + newHypo = newHypo._narrow(SALOMEDS.SObject) + anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap") + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap) + H = orb.string_to_object(IOR) + H = H._narrow( SMESH.SMESH_Hypothesis ); + aType = H.GetName(); + aPixmap.SetPixMap( "mesh_tree_hypo.png_" + aType ); + anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = anAttr._narrow(SALOMEDS.AttributeIOR); + anIOR.SetValue(IOR); + return newHypo.GetID(); + +#------------------------------------------------------------ +def AddNewAlgorithms(IOR): + res, AlgorithmsRoot = mySComponentMesh.FindSubObject (Tag_AlgorithmsRoot) + if AlgorithmsRoot is None or res == 0: + AlgorithmsRoot = myStudyBuilde.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot) + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName") + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue("Algorithms Definition"); + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable") + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + anAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "mesh_tree_algo.png" ); + + # Add New Algorithms + newHypo = myStudyBuilder.NewObject(AlgorithmsRoot) + newHypo = newHypo._narrow(SALOMEDS.SObject) + anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + H = orb.string_to_object(IOR) + H = H._narrow( SMESH.SMESH_Hypothesis); + aType = H.GetName(); #QString in fact + aPixmap.SetPixMap( "mesh_tree_algo.png_" + aType ); + anAttr = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR"); + anIOR = anAttr._narrow(SALOMEDS.AttributeIOR); + anIOR.SetValue(IOR); + return newHypo.GetID(); + + +#------------------------------------------------------------ +def SetShape(ShapeEntry, MeshEntry): + + SO_MorSM = myStudy.FindObjectID( MeshEntry ) + SO_MorSM = SO_MorSM._narrow(SALOMEDS.SObject) + SO_GeomShape = myStudy.FindObjectID( ShapeEntry ); + SO_GeomShape = SO_GeomShape._narrow(SALOMEDS.SObject) + + if SO_MorSM is not None and SO_GeomShape is not None : + SO = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnShape); + SO = SO._narrow(SALOMEDS.SObject) + myStudyBuilder.Addreference (SO,SO_GeomShape); + + +#------------------------------------------------------------ +def SetHypothesis(Mesh_Or_SubMesh_Entry, Hypothesis_Entry): + SO_MorSM = myStudy.FindObjectID( Mesh_Or_SubMesh_Entry ); + SO_Hypothesis = myStudy.FindObjectID( Hypothesis_Entry ); + + if SO_MorSM is not None and SO_Hypothesis is not None : + + #Find or Create Applied Hypothesis root + res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedHypothesis) + if AHR is None or res == 0: + AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName"); + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue("Applied Hypothesis"); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "mesh_tree_hypo.png" ); + + SO = myStudyBuilder.NewObject(AHR); + SO = SO._narrow(SALOMEDS.SObject) + myStudyBuilder.Addreference (SO,SO_Hypothesis); + +#------------------------------------------------------------ +def SetAlgorithms(Mesh_Or_SubMesh_Entry, Algorithms_Entry): + SO_MorSM = myStudy.FindObjectID( Mesh_Or_SubMesh_Entry ) + SO_Algorithms = myStudy.FindObjectID( Algorithms_Entry ) + if SO_MorSM != None and SO_Algorithms != None : + #Find or Create Applied Algorithms root + res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedAlgorithms); + if AHR is None or res == 0: + AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName"); + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue("Applied Algorithm"); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable"); + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + anAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap"); + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap.SetPixMap( "mesh_tree_algo.png" ); + + SO = myStudyBuilder.NewObject(AHR); + myStudyBuilder.Addreference (SO,SO_Algorithms); + + +#------------------------------------------------------------ +def UnSetHypothesis( Applied_Hypothesis_Entry ): + SO_Applied_Hypothesis = myStudy.FindObjectID( Applied_Hypothesis_Entry ); + if SO_Applied_Hypothesis : + myStudyBuilder.RemoveObject(SO_Applied_Hypothesis); + + +#------------------------------------------------------------ +def AddSubMesh ( SO_Mesh_Entry, SM_IOR, ST): + SO_Mesh = myStudy.FindObjectID( SO_Mesh_Entry ) + if ( SO_Mesh ) : + + if ST == ShapeTypeCompSolid : + Tag_Shape = Tag_SubMeshOnSolid; + Name = "SubMeshes On Solid"; + elif ST == ShapeTypeFace : + Tag_Shape = Tag_SubMeshOnFace; + Name = "SubMeshes On Face"; + elif ST == ShapeTypeEdge : + Tag_Shape = Tag_SubMeshOnEdge; + Name = "SubMeshes On Edge"; + elif ST == ShapeTypeVertex : + Tag_Shape = Tag_SubMeshOnVertex; + Name = "SubMeshes On Vertex"; + else : + Tag_Shape = Tag_SubMeshOnCompound; + Name = "SubMeshes On Compound"; + + res, SubmeshesRoot = SO_Mesh.FindSubObject (Tag_Shape) + if SubmeshesRoot is None or res == 0: + SubmeshesRoot = myStudyBuilder.NewObjectToTag (SO_Mesh, Tag_Shape); + anAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeName"); + + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue(Name); + anAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable"); + aSelAttr = anAttr._narrow(SALOMEDS.AttributeSelectable); + aSelAttr.SetSelectable(0); + + SO = myStudyBuilder.NewObject (SubmeshesRoot); + SO = SO._narrow(SALOMEDS.SObject) + anAttr = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeIOR"); + anIOR = anAttr._narrow(SALOMEDS.AttributeIOR); + anIOR.SetValue(SM_IOR); + return SO.GetID(); + + return None; + +#------------------------------------------------------------ +def AddSubMeshOnShape (Mesh_Entry, GeomShape_Entry, SM_IOR, ST) : + SO_GeomShape = myStudy.FindObjectID( GeomShape_Entry ); + if SO_GeomShape != None : + SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST); + SO_SM = myStudy.FindObjectID( SM_Entry ); + + if SO_SM != None : + SetShape (GeomShape_Entry, SM_Entry); + return SO_SM.GetID(); + + return None; + + +#------------------------------------------------------------ +def SetName(Entry, Name): + SO = myStudy.FindObjectID( Entry ); + if SO != None : + anAttr = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName"); + aName = anAttr._narrow(SALOMEDS.AttributeName); + aName.SetValue(Name); + + diff --git a/src/SMESH_SWIG/libSMESH_Swig.i b/src/SMESH_SWIG/libSMESH_Swig.i new file mode 100644 index 000000000..ff2e47467 --- /dev/null +++ b/src/SMESH_SWIG/libSMESH_Swig.i @@ -0,0 +1,12 @@ +// File : libGeometry_Swig.i +// Created : Tue Mar 26 15:04:48 2002 +// Author : Nicolas REJNERI, Paul RASCLE +// Project : SALOME +// Module : GEOM +// Copyright : Open CASCADE, EDF 2002 +// $Header$ + +%module libSMESH_Swig + +%include "SMESHGUI_Swig.i" +