clipping plane

This commit is contained in:
Joachim Schoeberl 2012-11-05 11:28:36 +00:00
parent ff3e491863
commit eaf9ec57ac
7 changed files with 67 additions and 37 deletions

View File

@ -831,28 +831,20 @@ namespace netgen
for (int i = 0; i < nsurf; i++) for (int i = 0; i < nsurf; i++)
isidenticto[i] = i; isidenticto[i] = i;
//(*testout) << "jetzt!" << endl;
for (int i = 0; i < nsurf; i++) for (int i = 0; i < nsurf; i++)
for (int j = i+1; j < nsurf; j++) for (int j = i+1; j < nsurf; j++)
{ {
//(*testout) << "surf" << i << " surf" << j << endl;
if (GetSurface(j) -> IsIdentic (*GetSurface(i), inv, eps)) if (GetSurface(j) -> IsIdentic (*GetSurface(i), inv, eps))
{ {
INDEX_2 i2(i, j); INDEX_2 i2(i, j);
identicsurfaces.Set (i2, inv); identicsurfaces.Set (i2, inv);
isidenticto[j] = isidenticto[i]; isidenticto[j] = isidenticto[i];
//(*testout) << "surfaces " << i2 << " are identic" << endl;
} }
} }
(*testout) << "identicmap:" << endl; (*testout) << "identicmap:" << endl;
for (int i = 0; i < isidenticto.Size(); i++) for (int i = 0; i < isidenticto.Size(); i++)
(*testout) << i << " -> " << isidenticto[i] << endl; (*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); ReducePrimitiveIterator rpi(box);
UnReducePrimitiveIterator urpi; UnReducePrimitiveIterator urpi;
((Solid*)sol) -> IterateSolid (rpi); const_cast<Solid*> (sol) -> IterateSolid (rpi);
sol -> GetSurfaceIndices (locsurf); sol -> GetSurfaceIndices (locsurf);
((Solid*)sol) -> IterateSolid (urpi); const_cast<Solid*> (sol) -> IterateSolid (urpi);
for (int i = locsurf.Size()-1; i >= 0; i--) for (int i = locsurf.Size()-1; i >= 0; i--)
{ {
@ -944,7 +936,7 @@ namespace netgen
*/ */
} }
/*
void CSGeometry :: void CSGeometry ::
GetIndependentSurfaceIndices (const Solid * sol, GetIndependentSurfaceIndices (const Solid * sol,
const Point<3> & p, Vec<3> & v, const Point<3> & p, Vec<3> & v,
@ -957,7 +949,7 @@ namespace netgen
box.CalcDiamCenter(); box.CalcDiamCenter();
GetIndependentSurfaceIndices (sol, box, locsurf); GetIndependentSurfaceIndices (sol, box, locsurf);
} }
*/
void CSGeometry :: void CSGeometry ::
GetIndependentSurfaceIndices (Array<int> & locsurf) const GetIndependentSurfaceIndices (Array<int> & locsurf) const

View File

@ -253,9 +253,11 @@ namespace netgen
const BoxSphere<3> & box, const BoxSphere<3> & box,
Array<int> & locsurf) const; Array<int> & locsurf) const;
/// ///
/*
void GetIndependentSurfaceIndices (const Solid * sol, void GetIndependentSurfaceIndices (const Solid * sol,
const Point<3> & p, Vec<3> & v, const Point<3> & p, Vec<3> & v,
Array<int> & locsurf) const; Array<int> & locsurf) const;
*/
/// ///
void GetIndependentSurfaceIndices (Array<int> & locsurf) const; void GetIndependentSurfaceIndices (Array<int> & locsurf) const;

View File

@ -666,7 +666,7 @@ namespace netgen
// Philippose - 30/01/2009 // Philippose - 30/01/2009
// Enable clipping planes for Selection mode in OCC Geometry // 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]); Vec<3> n(clipplane[0], clipplane[1], clipplane[2]);
double len = Abs(n); double len = Abs(n);

View File

@ -357,14 +357,14 @@ namespace netgen
void VisualScene :: SetClippingPlane () void VisualScene :: SetClippingPlane ()
{ {
if (vispar.clipenable) if (vispar.clipping.enable)
{ {
Vec3d n = vispar.clipnormal; Vec3d n = vispar.clipping.normal;
n /= (n.Length()+1e-10); n /= (n.Length()+1e-10);
clipplane[0] = n.X(); clipplane[0] = n.X();
clipplane[1] = n.Y(); clipplane[1] = n.Y();
clipplane[2] = n.Z(); 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); glClipPlane(GL_CLIP_PLANE0, clipplane);
glEnable(GL_CLIP_PLANE0); glEnable(GL_CLIP_PLANE0);

View File

@ -16,10 +16,27 @@ public:
char selectvisual[20]; char selectvisual[20];
int showstltrias; int showstltrias;
/*
Vec3d clipnormal; Vec3d clipnormal;
double clipdist; double clipdist;
int clipenable; int clipenable;
int clipplanetimestamp; 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; int colormeshsize;

View File

@ -1724,7 +1724,7 @@ namespace netgen
{ {
if (tettimestamp > mesh->GetTimeStamp () && if (tettimestamp > mesh->GetTimeStamp () &&
tettimestamp > vispar.clipplanetimestamp ) tettimestamp > vispar.clipping.timestamp )
return; return;
if (!lock) if (!lock)
@ -1775,7 +1775,7 @@ namespace netgen
Array<Element2d> faces; Array<Element2d> faces;
BitArray shownode(mesh->GetNP()); BitArray shownode(mesh->GetNP());
if (vispar.clipenable) if (vispar.clipping.enable)
{ {
shownode.Clear(); shownode.Clear();
for (int i = 1; i <= shownode.Size(); i++) for (int i = 1; i <= shownode.Size(); i++)
@ -2082,7 +2082,7 @@ namespace netgen
void VisualSceneMesh :: BuildPrismList() void VisualSceneMesh :: BuildPrismList()
{ {
if (prismtimestamp > mesh->GetTimeStamp () && if (prismtimestamp > mesh->GetTimeStamp () &&
prismtimestamp > vispar.clipplanetimestamp ) prismtimestamp > vispar.clipping.timestamp )
return; return;
if (!lock) if (!lock)
@ -2410,7 +2410,7 @@ namespace netgen
void VisualSceneMesh :: BuildHexList() void VisualSceneMesh :: BuildHexList()
{ {
if (hextimestamp > mesh->GetTimeStamp () && if (hextimestamp > mesh->GetTimeStamp () &&
hextimestamp > vispar.clipplanetimestamp ) hextimestamp > vispar.clipping.timestamp )
return; return;
if (!lock) if (!lock)
@ -2618,7 +2618,7 @@ namespace netgen
void VisualSceneMesh :: BuildPyramidList() void VisualSceneMesh :: BuildPyramidList()
{ {
if (pyramidtimestamp > mesh->GetTimeStamp () && if (pyramidtimestamp > mesh->GetTimeStamp () &&
pyramidtimestamp > vispar.clipplanetimestamp ) pyramidtimestamp > vispar.clipping.timestamp )
return; return;
if (!lock) if (!lock)
@ -3330,7 +3330,7 @@ namespace netgen
glDisable(GL_CLIP_PLANE0); glDisable(GL_CLIP_PLANE0);
if (vispar.clipenable) if (vispar.clipping.enable)
{ {
Vec<3> n(clipplane[0], clipplane[1], clipplane[2]); Vec<3> n(clipplane[0], clipplane[1], clipplane[2]);
double len = Abs(n); double len = Abs(n);

View File

@ -603,13 +603,13 @@ namespace netgen
else else
{ {
if (mesh->GetTimeStamp () > surfeltimestamp || if (mesh->GetTimeStamp () > surfeltimestamp ||
vispar.clipplanetimestamp > clipplanetimestamp || vispar.clipping.timestamp > clipplanetimestamp ||
solutiontimestamp > surfeltimestamp) solutiontimestamp > surfeltimestamp)
{ {
GetMinMax (scalfunction, scalcomp, minval, maxval); GetMinMax (scalfunction, scalcomp, minval, maxval);
} }
} }
if (mesh->GetTimeStamp() > surfeltimestamp || if (mesh->GetTimeStamp() > surfeltimestamp ||
solutiontimestamp > surfeltimestamp || solutiontimestamp > surfeltimestamp ||
zoomall) zoomall)
@ -672,12 +672,12 @@ namespace netgen
} }
if (clipplanetimestamp < vispar.clipplanetimestamp || if (clipplanetimestamp < vispar.clipping.timestamp ||
clipplanetimestamp < solutiontimestamp) clipplanetimestamp < solutiontimestamp)
{ {
// cout << "clipsolution = " << clipsolution << endl; // cout << "clipsolution = " << clipsolution << endl;
if (vispar.clipenable && clipsolution == 2) if (vispar.clipping.enable && clipsolution == 2)
{ {
// lock->UnLock(); // lock->UnLock();
NgLock mlock (mesh->Mutex(), 0); 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 (); DrawClipPlaneTrigs ();
if (clipplanelist_vec) if (clipplanelist_vec)
@ -698,7 +698,7 @@ namespace netgen
clipplanelist_vec = glGenLists (1); clipplanelist_vec = glGenLists (1);
glNewList (clipplanelist_vec, GL_COMPILE); glNewList (clipplanelist_vec, GL_COMPILE);
if (vispar.clipenable && clipsolution == 2 && vsol) if (vispar.clipping.enable && clipsolution == 2 && vsol)
{ {
SetTextureMode (usetexture); SetTextureMode (usetexture);
@ -794,7 +794,7 @@ namespace netgen
if ( if (
numisolines && numisolines &&
(clipplanetimestamp < vispar.clipplanetimestamp || (clipplanetimestamp < vispar.clipping.timestamp ||
clipplanetimestamp < solutiontimestamp) clipplanetimestamp < solutiontimestamp)
) )
{ {
@ -925,7 +925,7 @@ namespace netgen
if (clipplane_isolinelist) glDeleteLists (clipplane_isolinelist, 1); if (clipplane_isolinelist) glDeleteLists (clipplane_isolinelist, 1);
if (vispar.clipenable && clipsolution == 1 && sol) if (vispar.clipping.enable && clipsolution == 1 && sol)
{ {
clipplane_isolinelist = glGenLists (1); clipplane_isolinelist = glGenLists (1);
glNewList (clipplane_isolinelist, GL_COMPILE); glNewList (clipplane_isolinelist, GL_COMPILE);
@ -961,7 +961,7 @@ namespace netgen
glEnd(); glEnd();
} }
clipplanetimestamp = max2 (vispar.clipplanetimestamp, solutiontimestamp); clipplanetimestamp = max2 (vispar.clipping.timestamp, solutiontimestamp);
} }
@ -1115,6 +1115,7 @@ namespace netgen
bool drawelem = false; bool drawelem = false;
/*
if (sol && sol->draw_surface) if (sol && sol->draw_surface)
{ {
if (usetexture == 2) if (usetexture == 2)
@ -1124,6 +1125,22 @@ namespace netgen
for (int ii = 0; ii < npt; ii++) for (int ii = 0; ii < npt; ii++)
drawelem = GetSurfValue (sol, sei, -1, pref[ii](0), pref[ii](1), scalcomp, values[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) if (deform)
for (int ii = 0; ii < npt; ii++) for (int ii = 0; ii < npt; ii++)
@ -3823,9 +3840,10 @@ namespace netgen
if (scalfunction != -1) if (scalfunction != -1)
sol = soldata[scalfunction]; sol = soldata[scalfunction];
if (sol -> draw_volume)
glBegin (GL_TRIANGLES); {
glBegin (GL_TRIANGLES);
int maxlpnr = 0; int maxlpnr = 0;
for (int i = 0; i < trigs.Size(); i++) for (int i = 0; i < trigs.Size(); i++)
@ -3851,7 +3869,7 @@ namespace netgen
for (int i = 0; i < trigs.Size(); i++) for (int i = 0; i < trigs.Size(); i++)
{ {
bool ok = true; bool ok; // = true;
const ClipPlaneTrig & trig = trigs[i]; const ClipPlaneTrig & trig = trigs[i];
if (trig.elnr != lastelnr) if (trig.elnr != lastelnr)
{ {
@ -3887,7 +3905,8 @@ namespace netgen
// cout << "have multivalues, comps = " << sol->components << endl; // cout << "have multivalues, comps = " << sol->components << endl;
if (!drawelem) ok = false; // if (!drawelem) ok = false;
ok = drawelem;
if (usetexture != 2 || !sol->iscomplex) if (usetexture != 2 || !sol->iscomplex)
for (int ii = 0; ii < nlp; ii++) for (int ii = 0; ii < nlp; ii++)
vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]);
@ -3919,7 +3938,7 @@ namespace netgen
} }
glEnd(); glEnd();
}
glEndList (); glEndList ();