From eaf9ec57ac6bb6724b5351907ca060832634262d Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 5 Nov 2012 11:28:36 +0000 Subject: [PATCH] clipping plane --- libsrc/csg/csgeom.cpp | 16 +++------- libsrc/csg/csgeom.hpp | 2 ++ libsrc/occ/vsocc.cpp | 2 +- libsrc/visualization/mvdraw.cpp | 6 ++-- libsrc/visualization/vispar.hpp | 17 ++++++++++ libsrc/visualization/vsmesh.cpp | 12 +++---- libsrc/visualization/vssolution.cpp | 49 ++++++++++++++++++++--------- 7 files changed, 67 insertions(+), 37 deletions(-) diff --git a/libsrc/csg/csgeom.cpp b/libsrc/csg/csgeom.cpp index bd515ee1..cba59c06 100644 --- a/libsrc/csg/csgeom.cpp +++ b/libsrc/csg/csgeom.cpp @@ -831,28 +831,20 @@ namespace netgen for (int i = 0; i < nsurf; i++) isidenticto[i] = i; - //(*testout) << "jetzt!" << endl; for (int i = 0; i < nsurf; i++) for (int j = i+1; j < nsurf; j++) { - //(*testout) << "surf" << i << " surf" << j << endl; if (GetSurface(j) -> IsIdentic (*GetSurface(i), inv, eps)) { INDEX_2 i2(i, j); identicsurfaces.Set (i2, inv); isidenticto[j] = isidenticto[i]; - //(*testout) << "surfaces " << i2 << " are identic" << endl; } } (*testout) << "identicmap:" << endl; for (int i = 0; i < isidenticto.Size(); i++) (*testout) << i << " -> " << isidenticto[i] << endl; - - /* - for (int i = 0; i < nsurf; i++) - GetSurface(i)->Print (*testout); - */ } @@ -865,9 +857,9 @@ namespace netgen ReducePrimitiveIterator rpi(box); UnReducePrimitiveIterator urpi; - ((Solid*)sol) -> IterateSolid (rpi); + const_cast (sol) -> IterateSolid (rpi); sol -> GetSurfaceIndices (locsurf); - ((Solid*)sol) -> IterateSolid (urpi); + const_cast (sol) -> IterateSolid (urpi); for (int i = locsurf.Size()-1; i >= 0; i--) { @@ -944,7 +936,7 @@ namespace netgen */ } - + /* void CSGeometry :: GetIndependentSurfaceIndices (const Solid * sol, const Point<3> & p, Vec<3> & v, @@ -957,7 +949,7 @@ namespace netgen box.CalcDiamCenter(); GetIndependentSurfaceIndices (sol, box, locsurf); } - + */ void CSGeometry :: GetIndependentSurfaceIndices (Array & locsurf) const diff --git a/libsrc/csg/csgeom.hpp b/libsrc/csg/csgeom.hpp index 64badd49..4f0ef5ab 100644 --- a/libsrc/csg/csgeom.hpp +++ b/libsrc/csg/csgeom.hpp @@ -253,9 +253,11 @@ namespace netgen const BoxSphere<3> & box, Array & locsurf) const; /// + /* void GetIndependentSurfaceIndices (const Solid * sol, const Point<3> & p, Vec<3> & v, Array & locsurf) const; + */ /// void GetIndependentSurfaceIndices (Array & locsurf) const; diff --git a/libsrc/occ/vsocc.cpp b/libsrc/occ/vsocc.cpp index 64a07dff..5107a62b 100644 --- a/libsrc/occ/vsocc.cpp +++ b/libsrc/occ/vsocc.cpp @@ -666,7 +666,7 @@ namespace netgen // Philippose - 30/01/2009 // Enable clipping planes for Selection mode in OCC Geometry - if (vispar.clipenable) + if (vispar.clipping.enable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 7a17f285..5297ed84 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -357,14 +357,14 @@ namespace netgen void VisualScene :: SetClippingPlane () { - if (vispar.clipenable) + if (vispar.clipping.enable) { - Vec3d n = vispar.clipnormal; + Vec3d n = vispar.clipping.normal; n /= (n.Length()+1e-10); clipplane[0] = n.X(); clipplane[1] = n.Y(); clipplane[2] = n.Z(); - clipplane[3] = -(Vec3d(center) * n) + rad * vispar.clipdist; + clipplane[3] = -(Vec3d(center) * n) + rad * vispar.clipping.dist; glClipPlane(GL_CLIP_PLANE0, clipplane); glEnable(GL_CLIP_PLANE0); diff --git a/libsrc/visualization/vispar.hpp b/libsrc/visualization/vispar.hpp index da139826..3308bfe5 100644 --- a/libsrc/visualization/vispar.hpp +++ b/libsrc/visualization/vispar.hpp @@ -16,10 +16,27 @@ public: char selectvisual[20]; int showstltrias; + /* Vec3d clipnormal; double clipdist; int clipenable; int clipplanetimestamp; + */ + class Clipping + { + public: + Vec3d normal; + double dist; + int enable; + int timestamp; + bool operator== (Clipping & clip2) + { + return + (normal == clip2.normal) && (dist == clip2.dist) + && (enable == clip2.enable); + } + }; + Clipping clipping; int colormeshsize; diff --git a/libsrc/visualization/vsmesh.cpp b/libsrc/visualization/vsmesh.cpp index fd9ab2e6..23408838 100644 --- a/libsrc/visualization/vsmesh.cpp +++ b/libsrc/visualization/vsmesh.cpp @@ -1724,7 +1724,7 @@ namespace netgen { if (tettimestamp > mesh->GetTimeStamp () && - tettimestamp > vispar.clipplanetimestamp ) + tettimestamp > vispar.clipping.timestamp ) return; if (!lock) @@ -1775,7 +1775,7 @@ namespace netgen Array faces; BitArray shownode(mesh->GetNP()); - if (vispar.clipenable) + if (vispar.clipping.enable) { shownode.Clear(); for (int i = 1; i <= shownode.Size(); i++) @@ -2082,7 +2082,7 @@ namespace netgen void VisualSceneMesh :: BuildPrismList() { if (prismtimestamp > mesh->GetTimeStamp () && - prismtimestamp > vispar.clipplanetimestamp ) + prismtimestamp > vispar.clipping.timestamp ) return; if (!lock) @@ -2410,7 +2410,7 @@ namespace netgen void VisualSceneMesh :: BuildHexList() { if (hextimestamp > mesh->GetTimeStamp () && - hextimestamp > vispar.clipplanetimestamp ) + hextimestamp > vispar.clipping.timestamp ) return; if (!lock) @@ -2618,7 +2618,7 @@ namespace netgen void VisualSceneMesh :: BuildPyramidList() { if (pyramidtimestamp > mesh->GetTimeStamp () && - pyramidtimestamp > vispar.clipplanetimestamp ) + pyramidtimestamp > vispar.clipping.timestamp ) return; if (!lock) @@ -3330,7 +3330,7 @@ namespace netgen glDisable(GL_CLIP_PLANE0); - if (vispar.clipenable) + if (vispar.clipping.enable) { Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); double len = Abs(n); diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index 0c545c28..58eb62f5 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -603,13 +603,13 @@ namespace netgen else { if (mesh->GetTimeStamp () > surfeltimestamp || - vispar.clipplanetimestamp > clipplanetimestamp || + vispar.clipping.timestamp > clipplanetimestamp || solutiontimestamp > surfeltimestamp) { GetMinMax (scalfunction, scalcomp, minval, maxval); } } - + if (mesh->GetTimeStamp() > surfeltimestamp || solutiontimestamp > surfeltimestamp || zoomall) @@ -672,12 +672,12 @@ namespace netgen } - if (clipplanetimestamp < vispar.clipplanetimestamp || + if (clipplanetimestamp < vispar.clipping.timestamp || clipplanetimestamp < solutiontimestamp) { // cout << "clipsolution = " << clipsolution << endl; - if (vispar.clipenable && clipsolution == 2) + if (vispar.clipping.enable && clipsolution == 2) { // lock->UnLock(); NgLock mlock (mesh->Mutex(), 0); @@ -689,7 +689,7 @@ namespace netgen } - if (vispar.clipenable && clipsolution == 1 && sol) + if (vispar.clipping.enable && clipsolution == 1 && sol) DrawClipPlaneTrigs (); if (clipplanelist_vec) @@ -698,7 +698,7 @@ namespace netgen clipplanelist_vec = glGenLists (1); glNewList (clipplanelist_vec, GL_COMPILE); - if (vispar.clipenable && clipsolution == 2 && vsol) + if (vispar.clipping.enable && clipsolution == 2 && vsol) { SetTextureMode (usetexture); @@ -794,7 +794,7 @@ namespace netgen if ( numisolines && - (clipplanetimestamp < vispar.clipplanetimestamp || + (clipplanetimestamp < vispar.clipping.timestamp || clipplanetimestamp < solutiontimestamp) ) { @@ -925,7 +925,7 @@ namespace netgen if (clipplane_isolinelist) glDeleteLists (clipplane_isolinelist, 1); - if (vispar.clipenable && clipsolution == 1 && sol) + if (vispar.clipping.enable && clipsolution == 1 && sol) { clipplane_isolinelist = glGenLists (1); glNewList (clipplane_isolinelist, GL_COMPILE); @@ -961,7 +961,7 @@ namespace netgen glEnd(); } - clipplanetimestamp = max2 (vispar.clipplanetimestamp, solutiontimestamp); + clipplanetimestamp = max2 (vispar.clipping.timestamp, solutiontimestamp); } @@ -1115,6 +1115,7 @@ namespace netgen bool drawelem = false; + /* if (sol && sol->draw_surface) { if (usetexture == 2) @@ -1124,6 +1125,22 @@ namespace netgen for (int ii = 0; ii < npt; ii++) drawelem = GetSurfValue (sol, sei, -1, pref[ii](0), pref[ii](1), scalcomp, values[ii]); } + */ + if (sol && sol->draw_surface) + { + drawelem = GetMultiSurfValues (sol, sei, -1, npt, + &pref[0](0), &pref[1](0)-&pref[0](0), + &points[0](0), &points[1](0)-&points[0](0), + &dxdxis[0](0), &dxdxis[1](0)-&dxdxis[0](0), + &mvalues[0], sol->components); + if (usetexture == 2) + for (int ii = 0; ii < npt; ii++) + valuesc[ii] = ExtractValueComplex(sol, scalcomp, &mvalues[ii*sol->components]); + else + for (int ii = 0; ii < npt; ii++) + values[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); + } + if (deform) for (int ii = 0; ii < npt; ii++) @@ -3823,9 +3840,10 @@ namespace netgen if (scalfunction != -1) sol = soldata[scalfunction]; - - - glBegin (GL_TRIANGLES); + + if (sol -> draw_volume) + { + glBegin (GL_TRIANGLES); int maxlpnr = 0; for (int i = 0; i < trigs.Size(); i++) @@ -3851,7 +3869,7 @@ namespace netgen for (int i = 0; i < trigs.Size(); i++) { - bool ok = true; + bool ok; // = true; const ClipPlaneTrig & trig = trigs[i]; if (trig.elnr != lastelnr) { @@ -3887,7 +3905,8 @@ namespace netgen // cout << "have multivalues, comps = " << sol->components << endl; - if (!drawelem) ok = false; + // if (!drawelem) ok = false; + ok = drawelem; if (usetexture != 2 || !sol->iscomplex) for (int ii = 0; ii < nlp; ii++) vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); @@ -3919,7 +3938,7 @@ namespace netgen } glEnd(); - + } glEndList ();