Commit 3e46232c authored by miller86's avatar miller86
Browse files

Fixed #666: "Investigate if we have cmake configure issues

out of the box when only a subset of 3rd party libs are used."

Fixed poor design/use of a map object in vtkCSGGrid for keeping
track of already generated nodes in the adaptive discretization
algorithm which could lead to very inefficient use of memory.
I switched from using map<float, map<float, map<float, int> > >
to map<float[3], int> (essentially).


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@14540 18c085ea-50e0-402c-830e-de6fd14e8384
parent 9eb1bf2d
......@@ -230,6 +230,10 @@
# 3rd party FOO lib. It was not working previously. I also removed
# redundancy in args passed to VISIT_3RDPARTY_VAR/DEP macros
# (VISIT_FOO_DIR and FOO_DIR replaced with just FOO_DIR).
#
# Mark C. Miller, Wed Mar 30 09:30:49 PDT 2011
# Fixed VISIT_3RDPARTY_VAR/DEP macros to define empty string ("") when
# a lib's symbols are not defined instead of -NOTFOUND.
#****************************************************************************/
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
......@@ -432,8 +436,8 @@ OPTION(IGNORE_THIRD_PARTY_LIB_PROBLEMS "Ignore problems finding requested third
MACRO(VISIT_3RDPARTY_VAR libvar comment)
IF(NOT DEFINED VISIT_${libvar})
# Create an entry for this path variable
SET(VISIT_${libvar} "VISIT_${libvar}-NOTFOUND" CACHE PATH "${comment}")
# Create an empty entry for this path variable
SET(VISIT_${libvar} "" CACHE PATH "${comment}")
ELSE(NOT DEFINED VISIT_${libvar})
IF(DEFINED ${libvar})
# Ensure VISIT_FOO_DIR=FOO_DIR (override from CL)
......@@ -448,7 +452,7 @@ ENDMACRO(VISIT_3RDPARTY_VAR libvar comment)
MACRO(VISIT_3RDPARTY_DEP libvar comment)
IF(NOT DEFINED VISIT_${libvar})
# Create an entry for this string variable
SET(VISIT_${libvar} "VISIT_${libvar}-NOTSET" CACHE STRING "${comment}")
SET(VISIT_${libvar} "" CACHE STRING "${comment}")
ELSE(NOT DEFINED VISIT_${libvar})
IF(DEFINED ${libvar})
# Ensure VISIT_FOO_LIBDEP=FOO_LIBDEP (override from CL)
......
......@@ -2354,11 +2354,10 @@ vtkCSGGrid::GetMultiPassDiscretization(int specificZone)
#endif
bool
vtkCSGGrid::AddCutZones(vtkUnstructuredGrid *cutBox,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap)
coordmap_t& nodemap)
{
bool addedAPiece = false;
for (int i = 0; i < cutBox->GetNumberOfCells(); i++)
......@@ -2382,11 +2381,12 @@ vtkCSGGrid::AddCutZones(vtkUnstructuredGrid *cutBox,
int Iz = (int) (z / epsTol * 10000.0 + 0.5);
float fz = Iz * epsTol / 10000.0;
int mapId = nodemap[fx][fy][fz];
coord_t coord(fx,fy,fz);
int mapId = nodemap[coord];
if (mapId == 0)
{
points->InsertNextPoint(fx,fy,fz);
nodemap[fx][fy][fz] = points->GetNumberOfPoints()-1;
nodemap[coord] = points->GetNumberOfPoints()-1;
pointIds[j] = points->GetNumberOfPoints()-1;
}
else
......@@ -2410,7 +2410,7 @@ vtkCSGGrid::AddCutZones(vtkUnstructuredGrid *cutBox,
void
vtkCSGGrid::MakeMeshZone(const Box *theBox,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap)
coordmap_t& nodemap)
{
// Add points first
int pointIds[8] = {0,0,0,0,0,0,0,0};
......@@ -2437,11 +2437,12 @@ vtkCSGGrid::MakeMeshZone(const Box *theBox,
int Iz = (int) (z / epsTol * 10000.0 + 0.5);
float fz = Iz * epsTol / 10000.0;
int mapId = nodemap[fx][fy][fz];
coord_t coord(fx,fy,fz);
int mapId = nodemap[coord];
if (mapId == 0)
{
points->InsertNextPoint(fx,fy,fz);
nodemap[fx][fy][fz] = points->GetNumberOfPoints()-1;
nodemap[coord] = points->GetNumberOfPoints()-1;
pointIds[i] = points->GetNumberOfPoints()-1;
}
else
......@@ -2495,7 +2496,7 @@ vtkCSGGrid::MakeMeshZonesByCuttingBox4(const Box *theBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap)
coordmap_t& nodemap)
{
//
// Start by making an initial vtkUnstructuredGrid from the box
......@@ -2505,7 +2506,7 @@ vtkCSGGrid::MakeMeshZonesByCuttingBox4(const Box *theBox,
vtkUnstructuredGrid *boxUgrid = vtkUnstructuredGrid::New();
boxUgrid->SetPoints(boxPoints);
boxPoints->Delete();
map<float, map<float, map<float, int> > > dummyNodemap;
coordmap_t dummyNodemap;
MakeMeshZone(theBox, boxPoints, boxUgrid, dummyNodemap);
//
......@@ -2689,7 +2690,7 @@ vtkCSGGrid::MakeMeshZonesByCuttingBox2(const Box *theBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap)
coordmap_t& nodemap)
{
//
// Start by making an initial vtkUnstructuredGrid from the box
......@@ -2699,7 +2700,7 @@ vtkCSGGrid::MakeMeshZonesByCuttingBox2(const Box *theBox,
vtkUnstructuredGrid *boxUgrid = vtkUnstructuredGrid::New();
boxUgrid->SetPoints(boxPoints);
boxPoints->Delete();
map<float, map<float, map<float, int> > > dummyNodemap;
coordmap_t dummyNodemap;
MakeMeshZone(theBox, boxPoints, boxUgrid, dummyNodemap);
//
......@@ -2779,7 +2780,7 @@ vtkCSGGrid::DiscretizeSpace3(
vtkUnstructuredGrid *ugrid = vtkUnstructuredGrid::New();
ugrid->SetPoints(points);
points->Delete();
map<float, map<float, map<float, int> > > nodemap;
coordmap_t nodemap;
//
// Convert list of zones to list of boundaries (leaves in
......
......@@ -599,59 +599,109 @@ public:
vector<int> zids;
};
static bool AddCutZones(vtkUnstructuredGrid *cutBox, vtkPoints *points,
vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap);
static void MakeMeshZone(const Box *aBox, vtkPoints *points,
vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap);
bool MakeMeshZonesByCuttingBox4(const Box *aBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap);
bool MakeMeshZonesByCuttingBox2(const Box *aBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap);
static void MakeMeshZonesByCuttingBox(const Box *aBox,
map<vtkImplicitFunction*,Box::FuncState> funcToStateMap,
vector<RegionOp> senses,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
map<float, map<float, map<float, int> > >& nodemap);
void AddBoundariesForZone2(int, vector<int> *bnds, vector<int> *senses);
void AddBoundariesForZone(vtkImplicitFunction *func,
vector<vtkImplicitFunction*> *bnds,
vector<RegionOp> *senses);
int EvalBoxStateOfRegion(const Box *const curBox, int regId,
map<int,int>& boundaryToStateMap, double tol);
double tmpFloats[32]; // temporary storage to help satisfy interface
// requirements of vtkDataSet
vtkPlanes *Universe; // The "universe" set (a maximally sized box)
map<vtkImplicitFunction *, vtkIdType> funcMap;
vtkImplicitFunction *GetBoundaryFunc(vtkIdType id) const;
vtkImplicitFunction *GetRegionFunc(vtkIdType id) const;
vtkCSGGrid(const vtkCSGGrid&); // Not implemented.
void operator=(const vtkCSGGrid&); // Not implemented.
class coord_t {
public:
float c[3];
coord_t() {c[0]=0; c[1]=0; c[2]=0;};
coord_t(const float c_[3])
{c[0]=c_[0]; c[1]=c_[1]; c[2]=c_[2];};
coord_t(float a0, float a1, float a2)
{c[0]=a0; c[1]=a1; c[2]=a2; };
coord_t& operator=(const coord_t& rhs)
{ c[0]=rhs.c[0]; c[1]=rhs.c[1]; c[2]=rhs.c[2]; return *this;};
};
struct coordcomp {
bool operator() (const coord_t& lhs, const coord_t& rhs) const
{
if (lhs.c[0] < rhs.c[0])
{
return true;
}
else if (lhs.c[0] == rhs.c[0])
{
if (lhs.c[1] < rhs.c[1])
{
return true;
}
else if (lhs.c[1] == rhs.c[1])
{
if (lhs.c[2] < rhs.c[2])
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
};
typedef map<coord_t,int,coordcomp> coordmap_t;
static bool AddCutZones(vtkUnstructuredGrid *cutBox, vtkPoints *points,
vtkUnstructuredGrid *ugrid,
coordmap_t& nodemap);
static void MakeMeshZone(const Box *aBox, vtkPoints *points,
vtkUnstructuredGrid *ugrid,
coordmap_t& nodemap);
bool MakeMeshZonesByCuttingBox4(const Box *aBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
coordmap_t& nodemap);
bool MakeMeshZonesByCuttingBox2(const Box *aBox,
const map<int,int>& boundaryToStateMap,
map<int,int>& boundaryToSenseMap, int zoneId,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
coordmap_t& nodemap);
static void MakeMeshZonesByCuttingBox(const Box *aBox,
map<vtkImplicitFunction*,Box::FuncState> funcToStateMap,
vector<RegionOp> senses,
vtkPoints *points, vtkUnstructuredGrid *ugrid,
coordmap_t& nodemap);
void AddBoundariesForZone2(int, vector<int> *bnds, vector<int> *senses);
void AddBoundariesForZone(vtkImplicitFunction *func,
vector<vtkImplicitFunction*> *bnds,
vector<RegionOp> *senses);
int EvalBoxStateOfRegion(const Box *const curBox, int regId,
map<int,int>& boundaryToStateMap, double tol);
double tmpFloats[32]; // temporary storage to help satisfy interface
// requirements of vtkDataSet
vtkPlanes *Universe; // The "universe" set (a maximally sized box)
map<vtkImplicitFunction *, vtkIdType> funcMap;
vtkImplicitFunction *GetBoundaryFunc(vtkIdType id) const;
vtkImplicitFunction *GetRegionFunc(vtkIdType id) const;
vtkCSGGrid(const vtkCSGGrid&); // Not implemented.
void operator=(const vtkCSGGrid&); // Not implemented.
};
inline vtkIdType vtkCSGGrid::GetNumberOfPoints()
{
vtkErrorMacro("GetNumberOfPoints() means GetNumberOfBoundaries()");
vtkErrorMacro("Use GetNumberOfBoundaries() to avoid this message");
return GetNumberOfBoundaries();
vtkErrorMacro("GetNumberOfPoints() means GetNumberOfBoundaries()");
vtkErrorMacro("Use GetNumberOfBoundaries() to avoid this message");
return GetNumberOfBoundaries();
};
inline vtkIdType vtkCSGGrid::GetNumberOfBoundaries() const
{
return (vtkIdType) this->Boundaries->GetNumberOfItems();
return (vtkIdType) this->Boundaries->GetNumberOfItems();
};
inline vtkIdType vtkCSGGrid::GetNumberOfCells()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment