* Added a new Compiler Switch (MSVC_EXPRESS) to enable Netgen to be compiled using the Express Editions of Microsoft Visual C++

This commit is contained in:
Philippose Rajan 2009-01-30 22:12:17 +00:00
parent 64ae03d661
commit 34bfd4a349
3 changed files with 395 additions and 206 deletions

View File

@ -28,6 +28,61 @@ public:
#ifdef _MSC_VER
#ifdef MSVC_EXPRESS
// #include <pthread.h>
class NgMutex
{
pthread_mutex_t mut;
public:
NgMutex ()
{
pthread_mutex_init (&mut, NULL);
}
friend class NgLock;
};
class NgLock
{
pthread_mutex_t & mut;
bool locked;
public:
NgLock (NgMutex & ngmut, bool lock = false)
: mut (ngmut.mut)
{
if (lock)
pthread_mutex_lock (&mut);
locked = lock;
};
~NgLock()
{
if (locked)
pthread_mutex_unlock (&mut);
}
void Lock ()
{
pthread_mutex_lock (&mut);
locked = true;
}
void UnLock ()
{
pthread_mutex_unlock (&mut);
locked = false;
}
/*
int TryLock ()
{
return pthread_mutex_trylock (&mut);
}
*/
};
#else // Using MS VC++ Standard / Enterprise / Professional edition...
class NgMutex
{
CCriticalSection cs;
@ -68,6 +123,8 @@ public:
}
};
#endif // MSVC_EXPRESS
#else

View File

@ -62,17 +62,23 @@ namespace metis { extern "C" {
#ifdef _MSC_VER
# define WIN32_LEAN_AND_MEAN
# ifndef NO_PARALLEL_THREADS
# ifdef MSVC_EXPRESS
# include <pthread.h>
# else
# include <afxwin.h>
# include <afxmt.h>
# endif // MSVC_EXPRESS
# endif
# include <windows.h>
# undef WIN32_LEAN_AND_MEAN
# include <winnt.h>
#else
#else // Not using MC VC++
# ifndef NO_PARALLEL_THREADS
# include <pthread.h>
# endif
#endif

View File

@ -168,6 +168,29 @@ namespace netgen
#ifdef _MSC_VER
// Philippose - 30/01/2009
// MSVC Express Edition Support
#ifdef MSVC_EXPRESS
// #include <pthread.h>
static pthread_t meshingthread;
void RunParallel ( void * (*fun)(void *), void * in)
{
if (mparam.parthread)
{
pthread_attr_t attr;
pthread_attr_init (&attr);
// the following call can be removed if not available:
pthread_attr_setstacksize(&attr, 1000000);
//pthread_create (&meshingthread, &attr, fun, NULL);
pthread_create (&meshingthread, &attr, fun, in);
}
else
fun (in);
}
#else // Using MS VC++ Standard / Enterprise / Professional edition
// Afx - Threads need different return - value:
@ -188,7 +211,9 @@ namespace netgen
fun (in);
}
#else
#endif // #ifdef MSVC_EXPRESS
#else // For #ifdef _MSC_VER
// #include <pthread.h>
@ -208,7 +233,7 @@ namespace netgen
fun (in);
}
#endif
#endif // #ifdef _MSC_VER
@ -1422,6 +1447,101 @@ namespace netgen
}
// Philippose - 30/01/2009
// TCL interface function for the Local Face Mesh size
// definition functionality
int Ng_SurfaceMeshSize (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
static char buf[100];
if (argc < 2)
{
Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize needs arguments", TCL_STATIC);
return TCL_ERROR;
}
if (!occgeometry)
{
Tcl_SetResult (interp, (char *)"Ng_SurfaceMeshSize currently supports only OCC (STEP/IGES) Files", TCL_STATIC);
return TCL_ERROR;
}
// Update the face mesh sizes to reflect the global maximum mesh size
for(int i = 1; i <= occgeometry->NrFaces(); i++)
{
occgeometry->SetFaceMaxH(i, min(mparam.maxh,occgeometry->GetFaceMaxH(i)));
}
if (strcmp (argv[1], "setsurfms") == 0)
{
int facenr = atoi (argv[2]);
double surfms = atof (argv[3]);
if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
occgeometry->SetFaceMaxH(facenr, surfms);
}
if (strcmp (argv[1], "setall") == 0)
{
double surfms = atof (argv[2]);
if (occgeometry)
{
int nrFaces = occgeometry->NrFaces();
for (int i = 1; i <= nrFaces; i++)
occgeometry->SetFaceMaxH(i, surfms);
}
}
if (strcmp (argv[1], "getsurfms") == 0)
{
int facenr = atoi (argv[2]);
if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
{
sprintf (buf, "%5.2f", occgeometry->GetFaceMaxH(facenr));
}
else
{
sprintf (buf, "%5.2f", mparam.maxh);
}
Tcl_SetResult (interp, buf, TCL_STATIC);
}
if (strcmp (argv[1], "getactive") == 0)
{
sprintf (buf, "%d", occgeometry->SelectedFace());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
if (strcmp (argv[1], "setactive") == 0)
{
int facenr = atoi (argv[2]);
if (occgeometry && facenr >= 1 && facenr <= occgeometry->NrFaces())
{
occgeometry->SetSelectedFace (facenr);
occgeometry->LowLightAll();
occgeometry->fvispar[facenr-1].Highlight();
occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
}
}
if (strcmp (argv[1], "getnfd") == 0)
{
if (occgeometry)
sprintf (buf, "%d", occgeometry->NrFaces());
else
sprintf (buf, "0");
Tcl_SetResult (interp, buf, TCL_STATIC);
}
return TCL_OK;
}
int Ng_SetNextTimeStamp (ClientData clientData,
Tcl_Interp * interp,
int argqc, tcl_const char *argv[])
@ -4751,6 +4871,12 @@ namespace netgen
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
// Philippose - 30/01/2009
// Register the TCL Interface Command for local face mesh size
// definition
Tcl_CreateCommand (interp, "Ng_SurfaceMeshSize", Ng_SurfaceMeshSize,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);