1478
// == Voxels filter ==
1480
VoxeliseFilter::VoxeliseFilter()
1481
: fixedWidth(false), bc(), normaliseType(VOXEL_NORMALISETYPE_NONE)
1487
bc.setBounds(0, 0, 0, 1, 1, 1);
1488
representation=VOXEL_REPRESENT_POINTCLOUD;
1489
for (int i = 0; i < INDEX_LENGTH; i++) {
1492
calculateWidthsFromNumBins(binWidth, nBins);
1493
numeratorAll = false;
1494
denominatorAll = true;
1500
Filter *VoxeliseFilter::cloneUncached() const
1502
VoxeliseFilter *p=new VoxeliseFilter();
1503
p->splatSize=splatSize;
1509
p->isoLevel=isoLevel;
1510
p->representation=representation;
1511
p->splatSize=splatSize;
1513
p->numeratorAll=numeratorAll;
1514
p->denominatorAll=denominatorAll;
1518
for(size_t ui=0;ui<INDEX_LENGTH;ui++)
1520
p->nBins[ui] = nBins[ui];
1521
p->binWidth[ui] = binWidth[ui];
1524
p->enabledIons[0].resize(enabledIons[0].size());
1525
std::copy(enabledIons[0].begin(),enabledIons[0].end(),p->enabledIons[0].begin());
1527
p->enabledIons[1].resize(enabledIons[1].size());
1528
std::copy(enabledIons[1].begin(),enabledIons[1].end(),p->enabledIons[1].begin());
1532
p->rsdIncoming=new RangeStreamData();
1533
*(p->rsdIncoming) = *rsdIncoming;
1542
size_t VoxeliseFilter::numBytesForCache(size_t nObjects) const
1547
void VoxeliseFilter::initFilter(const std::vector<const FilterStreamData *> &dataIn,
1548
std::vector<const FilterStreamData *> &dataOut)
1550
const RangeStreamData *c=0;
1551
//Determine if we have an incoming range
1552
for (size_t i = 0; i < dataIn.size(); i++)
1554
if(dataIn[i]->getStreamType() == STREAM_TYPE_RANGE)
1556
c=(const RangeStreamData *)dataIn[i];
1562
//we no longer (or never did) have any incoming ranges. Not much to do
1565
//delete the old incoming range pointer
1570
enabledIons[0].clear(); //clear numerator options
1571
enabledIons[1].clear(); //clear denominator options
1577
//If we didn't have an incoming rsd, then make one up!
1580
rsdIncoming = new RangeStreamData;
1583
//set the numerator to all disabled
1584
enabledIons[0].resize(rsdIncoming->rangeFile->getNumIons(),0);
1585
//set the denominator to have all enabled
1586
enabledIons[1].resize(rsdIncoming->rangeFile->getNumIons(),1);
1591
//OK, so we have a range incoming already (from last time)
1592
//-- the question is, is it the same
1594
//Do a pointer comparison (its a hack, yes, but it should work)
1595
if(rsdIncoming->rangeFile != c->rangeFile)
1597
//hmm, it is different. well, trash the old incoming rng
1600
rsdIncoming = new RangeStreamData;
1603
//set the numerator to all disabled
1604
enabledIons[0].resize(rsdIncoming->rangeFile->getNumIons(),0);
1605
//set the denominator to have all enabled
1606
enabledIons[1].resize(rsdIncoming->rangeFile->getNumIons(),1);
1613
// TODO: create plotstream
1614
unsigned int VoxeliseFilter::refresh(const std::vector<const FilterStreamData *> &dataIn,
1615
std::vector<const FilterStreamData *> &getOut, unsigned int &progress, bool (*callback)(void))
1620
bc.setInverseLimits();
1622
for (size_t i = 0; i < dataIn.size(); i++)
1624
//Check for ion stream types. Block others from propagation.
1625
if (dataIn[i]->getStreamType() != STREAM_TYPE_IONS) continue;
1627
const IonStreamData *is = (const IonStreamData *)dataIn[i];
1628
//Don't work on empty or single object streams (bounding box needs to be defined)
1629
if (is->GetNumBasicObjects() < 2) continue;
1631
//Build a bounding box
1632
dataLimits(is->data,minP,maxP);
1635
bcTmp.setBounds(minP,maxP);
1637
//Bounds could be invalid if, for example, we had coplanar axis aligned points
1638
if (!bcTmp.isValid()) continue;
1641
//No bounding box? Tough cookies
1642
if (!bc.isValid()) return VOXEL_BOUNDS_INVALID_ERR;
1644
bc.getBounds(minP,maxP);
1646
calculateNumBinsFromWidths(binWidth, nBins);
1648
calculateWidthsFromNumBins(binWidth, nBins);
1650
//Disallow empty bounding boxes (ie, produce no output)
1654
VoxelStreamData *vs = new VoxelStreamData();
1656
vs->data.setCallbackMethod(callback);
1657
vs->data.init(nBins[0], nBins[1], nBins[2], bc);
1658
vs->representationType= representation;
1659
vs->splatSize = splatSize;
1660
vs->isoLevel=isoLevel;
1667
VoxelStreamData *vsDenom = NULL;
1668
if (normaliseType == VOXEL_NORMALISETYPE_COUNT2INVOXEL ||
1669
normaliseType == VOXEL_NORMALISETYPE_ALLATOMSINVOXEL) {
1670
//Check we actually have incoming data
1671
ASSERT(rsdIncoming);
1672
vsDenom = new VoxelStreamData();
1673
vsDenom->cached = false;
1674
vsDenom->data.setCallbackMethod(callback);
1675
vsDenom->data.init(nBins[0], nBins[1], nBins[2], bc);
1676
vsDenom->representationType= representation;
1677
vsDenom->splatSize = splatSize;
1678
vsDenom->isoLevel=isoLevel;
1679
vsDenom->data.fill(0);
1683
const IonStreamData *is;
1687
for (size_t i = 0; i < dataIn.size(); i++)
1690
//Check for ion stream types. Don't use anything else in counting
1691
if (dataIn[i]->getStreamType() != STREAM_TYPE_IONS) continue;
1693
is= (const IonStreamData *)dataIn[i];
1696
//Count the numerator ions
1699
//Check what Ion type this stream belongs to. Assume all ions
1700
//in the stream belong to the same group
1702
ionID = rsdIncoming->rangeFile->getIonID(is->data[0].getMassToCharge());
1704
bool thisIonEnabled;
1705
if(ionID!=(unsigned int)-1)
1706
thisIonEnabled=enabledIons[0][ionID];
1708
thisIonEnabled=false;
1711
vs->data.countPoints(is->data,true,false);
1714
//If the user requests normalisation, compute the denominator datset
1715
if (normaliseType == VOXEL_NORMALISETYPE_COUNT2INVOXEL) {
1718
//Check what Ion type this stream belongs to. Assume all ions
1719
//in the stream belong to the same group
1721
ionID = rsdIncoming->rangeFile->getIonID(is->data[0].getMassToCharge());
1723
bool thisIonEnabled;
1724
if(ionID!=(unsigned int)-1)
1725
thisIonEnabled=enabledIons[1][ionID];
1727
thisIonEnabled=false;
1730
vsDenom->data.countPoints(is->data,true,false);
1732
} else if (normaliseType == VOXEL_NORMALISETYPE_ALLATOMSINVOXEL)
1733
vsDenom->data.countPoints(is->data,true,false);
1738
return VOXEL_ABORT_ERR;
1742
//Perform normalsiation
1743
if (normaliseType == VOXEL_NORMALISETYPE_VOLUME)
1744
vs->data.calculateDensity();
1745
else if (normaliseType == VOXEL_NORMALISETYPE_COUNT2INVOXEL ||
1746
normaliseType == VOXEL_NORMALISETYPE_ALLATOMSINVOXEL)
1747
vs->data /= vsDenom->data;
1751
//No range data. Just count
1752
for (size_t i = 0; i < dataIn.size(); i++)
1755
is= (const IonStreamData *)dataIn[i];
1756
vs->data.countPoints(is->data,true,false);
1761
return VOXEL_ABORT_ERR;
1764
ASSERT(normaliseType != VOXEL_NORMALISETYPE_COUNT2INVOXEL
1765
&& normaliseType!=VOXEL_NORMALISETYPE_ALLATOMSINVOXEL);
1766
if (normaliseType == VOXEL_NORMALISETYPE_VOLUME)
1767
vs->data.calculateDensity();
1771
getOut.push_back(vs);
1776
std::string VoxeliseFilter::getNormaliseTypeString(int type) const {
1778
case VOXEL_NORMALISETYPE_NONE:
1779
return std::string("None (Raw count)");
1781
case VOXEL_NORMALISETYPE_VOLUME:
1782
return std::string("Volume (Density)");
1784
case VOXEL_NORMALISETYPE_COUNT2INVOXEL:
1785
return std::string("Ratio (Num/Denom)");
1787
case VOXEL_NORMALISETYPE_ALLATOMSINVOXEL:
1788
return std::string("All Ions (conc)");
1796
std::string VoxeliseFilter::getRepresentTypeString(int type) const {
1798
case VOXEL_REPRESENT_POINTCLOUD:
1799
return std::string("Point Cloud");
1801
case VOXEL_REPRESENT_ISOSURF:
1802
return std::string("Isosurface");
1810
void VoxeliseFilter::getProperties(FilterProperties &propertyList) const
1812
propertyList.data.clear();
1813
propertyList.keys.clear();
1814
propertyList.types.clear();
1816
vector<unsigned int> type,keys;
1817
vector<pair<string,string> > s;
1820
stream_cast(tmpStr, fixedWidth);
1821
s.push_back(std::make_pair("Fixed width", tmpStr));
1822
keys.push_back(KEY_VOXEL_FIXEDWIDTH);
1823
type.push_back(PROPERTY_TYPE_BOOL);
1827
stream_cast(tmpStr,binWidth[0]);
1828
keys.push_back(KEY_VOXEL_WIDTHBINSX);
1829
s.push_back(make_pair("Bin width x", tmpStr));
1830
type.push_back(PROPERTY_TYPE_REAL);
1832
stream_cast(tmpStr,binWidth[1]);
1833
keys.push_back(KEY_VOXEL_WIDTHBINSY);
1834
s.push_back(make_pair("Bin width y", tmpStr));
1835
type.push_back(PROPERTY_TYPE_REAL);
1837
stream_cast(tmpStr,binWidth[2]);
1838
keys.push_back(KEY_VOXEL_WIDTHBINSZ);
1839
s.push_back(make_pair("Bin width z", tmpStr));
1840
type.push_back(PROPERTY_TYPE_REAL);
1844
stream_cast(tmpStr,nBins[0]);
1845
keys.push_back(KEY_VOXEL_NBINSX);
1846
s.push_back(make_pair("Num bins x", tmpStr));
1847
type.push_back(PROPERTY_TYPE_INTEGER);
1849
stream_cast(tmpStr,nBins[1]);
1850
keys.push_back(KEY_VOXEL_NBINSY);
1851
s.push_back(make_pair("Num bins y", tmpStr));
1852
type.push_back(PROPERTY_TYPE_INTEGER);
1854
stream_cast(tmpStr,nBins[2]);
1855
keys.push_back(KEY_VOXEL_NBINSZ);
1856
s.push_back(make_pair("Num bins z", tmpStr));
1857
type.push_back(PROPERTY_TYPE_INTEGER);
1860
//Let the user know what the valid values for voxel value types are
1862
vector<pair<unsigned int,string> > choices;
1863
tmpStr=getNormaliseTypeString(VOXEL_NORMALISETYPE_NONE);
1864
choices.push_back(make_pair((unsigned int)VOXEL_NORMALISETYPE_NONE,tmpStr));
1865
tmpStr=getNormaliseTypeString(VOXEL_NORMALISETYPE_VOLUME);
1866
choices.push_back(make_pair((unsigned int)VOXEL_NORMALISETYPE_VOLUME,tmpStr));
1869
//Concentration mode
1870
tmpStr=getNormaliseTypeString(VOXEL_NORMALISETYPE_ALLATOMSINVOXEL);
1871
choices.push_back(make_pair((unsigned int)VOXEL_NORMALISETYPE_ALLATOMSINVOXEL,tmpStr));
1872
//Ratio is only valid if we have a way of seperation for the ions i.e. range
1873
tmpStr=getNormaliseTypeString(VOXEL_NORMALISETYPE_COUNT2INVOXEL);
1874
choices.push_back(make_pair((unsigned int)VOXEL_NORMALISETYPE_COUNT2INVOXEL,tmpStr));
1876
tmpStr= choiceString(choices,normaliseType);
1877
s.push_back(make_pair(string("Normalise by"),tmpStr));
1878
type.push_back(PROPERTY_TYPE_CHOICE);
1879
keys.push_back(KEY_VOXEL_NORMALISE_TYPE);
1887
propertyList.data.push_back(s);
1888
propertyList.types.push_back(type);
1889
propertyList.keys.push_back(keys);
1898
s.push_back(make_pair("Numerator", numeratorAll ? "1" : "0"));
1899
type.push_back(PROPERTY_TYPE_BOOL);
1900
keys.push_back(KEY_VOXEL_ENABLE_NUMERATOR);
1902
ASSERT(rsdIncoming->enabledIons.size()==enabledIons[0].size());
1903
ASSERT(rsdIncoming->enabledIons.size()==enabledIons[1].size());
1905
//Look at the numerator
1906
for(unsigned int ui=0; ui<rsdIncoming->enabledIons.size(); ui++)
1909
if(enabledIons[0][ui])
1914
//Append the ion name with a checkbox
1915
s.push_back(make_pair(
1916
rsdIncoming->rangeFile->getName(ui), str));
1917
type.push_back(PROPERTY_TYPE_BOOL);
1918
keys.push_back(KEY_VOXEL_ENABLE_NUMERATOR*1000+ui);
1920
propertyList.types.push_back(type);
1921
propertyList.data.push_back(s);
1922
propertyList.keys.push_back(keys);
1929
if (normaliseType == VOXEL_NORMALISETYPE_COUNT2INVOXEL && rsdIncoming) {
1931
s.push_back(make_pair("Denominator", denominatorAll ? "1" : "0"));
1932
type.push_back(PROPERTY_TYPE_BOOL);
1933
keys.push_back(KEY_VOXEL_ENABLE_DENOMINATOR);
1935
for(unsigned int ui=0; ui<rsdIncoming->enabledIons.size(); ui++)
1938
if(enabledIons[1][ui])
1943
//Append the ion name with a checkbox
1944
s.push_back(make_pair(
1945
rsdIncoming->rangeFile->getName(ui), str));
1947
type.push_back(PROPERTY_TYPE_BOOL);
1948
keys.push_back(KEY_VOXEL_ENABLE_DENOMINATOR*1000+ui);
1950
propertyList.types.push_back(type);
1951
propertyList.data.push_back(s);
1952
propertyList.keys.push_back(keys);
1959
//start a new set for the visual representation
1960
//----------------------------
1962
tmpStr=getRepresentTypeString(VOXEL_REPRESENT_POINTCLOUD);
1963
choices.push_back(make_pair((unsigned int)VOXEL_REPRESENT_POINTCLOUD,tmpStr));
1964
tmpStr=getRepresentTypeString(VOXEL_REPRESENT_ISOSURF);
1965
choices.push_back(make_pair((unsigned int)VOXEL_REPRESENT_ISOSURF,tmpStr));
1968
tmpStr= choiceString(choices,representation);
1969
s.push_back(make_pair(string("Representation"),tmpStr));
1970
type.push_back(PROPERTY_TYPE_CHOICE);
1971
keys.push_back(KEY_VOXEL_REPRESENTATION_MODE);
1972
switch(representation)
1974
case VOXEL_REPRESENT_POINTCLOUD:
1976
stream_cast(tmpStr,splatSize);
1977
s.push_back(make_pair("Spot size",tmpStr));
1978
type.push_back(PROPERTY_TYPE_REAL);
1979
keys.push_back(KEY_VOXEL_SPOTSIZE);
1981
stream_cast(tmpStr,1.0-a);
1982
s.push_back(make_pair("Transparency",tmpStr));
1983
type.push_back(PROPERTY_TYPE_REAL);
1984
keys.push_back(KEY_VOXEL_TRANSPARANCY);
1987
case VOXEL_REPRESENT_ISOSURF:
1989
stream_cast(tmpStr,isoLevel);
1990
s.push_back(make_pair("Isovalue",tmpStr));
1991
type.push_back(PROPERTY_TYPE_REAL);
1992
keys.push_back(KEY_VOXEL_ISOLEVEL);
1996
//Convert the ion colour to a hex string
1997
genColString((unsigned char)(r*255),(unsigned char)(g*255),
1998
(unsigned char)(b*255),(unsigned char)(a*255),tmpStr);
1999
s.push_back(make_pair("Colour",tmpStr));
2000
type.push_back(PROPERTY_TYPE_COLOUR);
2001
keys.push_back(KEY_VOXEL_COLOUR);
2010
//----------------------------
2012
propertyList.data.push_back(s);
2013
propertyList.types.push_back(type);
2014
propertyList.keys.push_back(keys);
2017
bool VoxeliseFilter::setProperty( unsigned int set, unsigned int key,
2018
const std::string &value, bool &needUpdate)
2024
case KEY_VOXEL_FIXEDWIDTH:
2027
if(stream_cast(b,value))
2033
case KEY_VOXEL_NBINSX:
2036
if(stream_cast(i,value))
2042
calculateWidthsFromNumBins(binWidth, nBins);
2045
case KEY_VOXEL_NBINSY:
2048
if(stream_cast(i,value))
2054
calculateWidthsFromNumBins(binWidth, nBins);
2057
case KEY_VOXEL_NBINSZ:
2060
if(stream_cast(i,value))
2066
calculateWidthsFromNumBins(binWidth, nBins);
2069
case KEY_VOXEL_WIDTHBINSX:
2072
if(stream_cast(f,value))
2078
calculateNumBinsFromWidths(binWidth, nBins);
2081
case KEY_VOXEL_WIDTHBINSY:
2084
if(stream_cast(f,value))
2090
calculateNumBinsFromWidths(binWidth, nBins);
2093
case KEY_VOXEL_WIDTHBINSZ:
2096
if(stream_cast(f,value))
2102
calculateNumBinsFromWidths(binWidth, nBins);
2105
case KEY_VOXEL_NORMALISE_TYPE:
2108
for (i = 0; i < VOXEL_NORMALISETYPE_MAX; i++)
2109
if (value == getNormaliseTypeString(i)) break;
2110
if (i == VOXEL_NORMALISETYPE_MAX)
2112
if(normaliseType!=i)
2117
case KEY_VOXEL_SPOTSIZE:
2120
if(stream_cast(f,value))
2128
case KEY_VOXEL_TRANSPARANCY:
2131
if(stream_cast(f,value))
2133
if(f <= 0.0f || f > 1.0)
2136
//Alpha is opacity, which is 1-transparancy
2140
case KEY_VOXEL_ISOLEVEL:
2143
if(stream_cast(f,value))
2151
case KEY_VOXEL_COLOUR:
2153
unsigned char newR,newG,newB,newA;
2155
parseColString(value,newR,newG,newB,newA);
2157
if(newB != b || newR != r ||
2158
newG !=g || newA != a)
2165
case KEY_VOXEL_REPRESENTATION_MODE:
2168
for (i = 0; i < VOXEL_REPRESENT_END; i++)
2169
if (value == getRepresentTypeString(i)) break;
2170
if (i == VOXEL_REPRESENT_END)
2176
case KEY_VOXEL_ENABLE_NUMERATOR:
2179
if(stream_cast(b,value))
2181
//Set them all to enabled or disabled as a group
2182
for (size_t i = 0; i < enabledIons[0].size(); i++)
2183
enabledIons[0][i] = b;
2188
case KEY_VOXEL_ENABLE_DENOMINATOR:
2191
if(stream_cast(b,value))
2194
//Set them all to enabled or disabled as a group
2195
for (size_t i = 0; i < enabledIons[1].size(); i++)
2196
enabledIons[1][i] = b;
2204
if (key >= KEY_VOXEL_ENABLE_DENOMINATOR*1000) {
2206
if(stream_cast(b,value))
2208
// if (b && !rsdIncoming->enabledIons[key - KEY_VOXEL_ENABLE_DENOMINATOR*1000]) {
2211
enabledIons[1][key - KEY_VOXEL_ENABLE_DENOMINATOR*1000]=b;
2213
denominatorAll = false;
2216
} else if (key >= KEY_VOXEL_ENABLE_NUMERATOR*1000) {
2218
if(stream_cast(b,value))
2220
// if (b && !rsdIncoming->enabledIons[key - KEY_VOXEL_ENABLE_NUMERATOR*1000]) {
2223
enabledIons[0][key - KEY_VOXEL_ENABLE_NUMERATOR*1000]=b;
2225
numeratorAll = false;
2239
std::string VoxeliseFilter::getErrString(unsigned int code) const
2243
case VOXEL_ABORT_ERR:
2245
return std::string("Voxelisation aborted");
2247
case VOXEL_BOUNDS_INVALID_ERR:
2249
return std::string("Voxelisation bounds are invalid");
2253
return std::string("BUG! Should not see this (VoxeliseFilter)");
2256
bool VoxeliseFilter::writeState(std::ofstream &f,unsigned int format, unsigned int depth) const
2261
case STATE_FORMAT_XML:
2263
f << tabs(depth) << "<voxelise>" << endl;
2264
f << tabs(depth+1) << "<fixedWidth value=\""<<fixedWidth << "\"/>" << endl;
2265
f << tabs(depth+1) << "<nBins values=\""<<nBins[0] << ","<<nBins[1]<<","<<nBins[2] << "\"/>" << endl;
2266
f << tabs(depth+1) << "<binWidth values=\""<<binWidth[0] << ","<<binWidth[1]<<","<<binWidth[2] << "\"/>" << endl;
2267
f << tabs(depth+1) << "<normaliseType value=\""<<normaliseType << "\"/>" << endl;
2268
f << tabs(depth+1) << "<representation value=\""<<representation << "\"/>" << endl;
2269
f << tabs(depth+1) << "<colour r=\"" << r<< "\" g=\"" << g << "\" b=\"" <<b
2270
<< "\" a=\"" << a << "\"/>" <<endl;
2271
f << tabs(depth) << "</voxelise>" << endl;
2282
bool VoxeliseFilter::readState(xmlNodePtr &nodePtr)
2288
//Retrieve fixedWidth mode
2289
if(XMLHelpFwdToElem(nodePtr,"fixedWidth"))
2292
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"value");
2296
tmpStr=(char *)xmlString;
2299
else if(tmpStr== "0")
2310
if(XMLHelpFwdToElem(nodePtr,"nBins"))
2312
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"values");
2315
std::vector<string> v1;
2316
splitStrsRef((char *)xmlString,',',v1);
2317
for (size_t i = 0; i < INDEX_LENGTH && i < v1.size(); i++)
2319
if(stream_cast(nBins[i],v1[i]))
2328
if(XMLHelpFwdToElem(nodePtr,"binWidth"))
2330
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"values");
2333
std::vector<string> v2;
2334
splitStrsRef((char *)xmlString,',',v2);
2335
for (size_t i = 0; i < INDEX_LENGTH && i < v2.size(); i++)
2337
if(stream_cast(binWidth[i],v2[i]))
2340
if(binWidth[i] <= 0)
2345
//Retrieve normaliseType
2346
if(XMLHelpFwdToElem(nodePtr,"normaliseType"))
2349
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"value");
2352
tmpStr=(char *)xmlString;
2354
if(stream_cast(normaliseType,tmpStr))
2359
//Retrieve representation
2360
if(XMLHelpFwdToElem(nodePtr,"representation"))
2363
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"value");
2366
tmpStr=(char *)xmlString;
2368
if(stream_cast(representation,tmpStr))
2372
if(representation >=VOXEL_REPRESENT_END)
2378
if(XMLHelpFwdToElem(nodePtr,"colour"))
2382
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"r");
2385
tmpStr=(char *)xmlString;
2387
//convert from string to digit
2388
if(stream_cast(r,tmpStr))
2391
//disallow negative or values gt 1.
2392
if(r < 0.0f || r > 1.0f)
2396
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"g");
2399
tmpStr=(char *)xmlString;
2401
//convert from string to digit
2402
if(stream_cast(g,tmpStr))
2405
//disallow negative or values gt 1.
2406
if(g < 0.0f || g > 1.0f)
2410
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"b");
2413
tmpStr=(char *)xmlString;
2415
//convert from string to digit
2416
if(stream_cast(b,tmpStr))
2419
//disallow negative or values gt 1.
2420
if(b < 0.0f || b > 1.0f)
2424
xmlString=xmlGetProp(nodePtr,(const xmlChar *)"a");
2427
tmpStr=(char *)xmlString;
2429
//convert from string to digit
2430
if(stream_cast(a,tmpStr))
2433
//disallow negative or values gt 1.
2434
if(a < 0.0f || a > 1.0f)
2442
void VoxeliseFilter::setPropFromBinding(const SelectionBinding &b)
1219
2446
//== Range File Filter ==
1221
2448
RangeFileFilter::RangeFileFilter()
4898
6146
const std::string &value, bool &needUpdate)
4901
if(key == KEY_COMPPROFILE_ENABLED)
4903
string stripped=stripWhite(value);
4905
if (!(stripped == "1"|| stripped == "0"))
4908
bool lastVal=enabled;
4914
//if the result is different, the
4915
//cache should be invalidated
4916
if (lastVal!=enabled)
4926
case 0://Primitive settings
4931
case KEY_COMPPROFILE_BINWIDTH:
4934
if(stream_cast(newBinWidth,value))
4937
if(newBinWidth < sqrt(std::numeric_limits<float>::epsilon()))
4940
binWidth=newBinWidth;
4945
case KEY_COMPPROFILE_FIXEDBINS:
4947
unsigned int valueInt;
4948
if(stream_cast(valueInt,value))
4951
if(valueInt ==0 || valueInt == 1)
4953
if(fixedBins!= valueInt)
4967
case KEY_COMPPROFILE_NORMAL:
4970
if(!newPt.parse(value))
4973
if(!(vectorParams[1] == newPt ))
4975
vectorParams[1] = newPt;
4981
case KEY_COMPPROFILE_NUMBINS:
4983
unsigned int newNumBins;
4984
if(stream_cast(newNumBins,value))
4993
case KEY_COMPPROFILE_ORIGIN:
4996
if(!newPt.parse(value))
4999
if(!(vectorParams[0] == newPt ))
5001
vectorParams[0] = newPt;
5008
case KEY_COMPPROFILE_PRIMITIVETYPE:
5010
unsigned int newPrimitive;
5011
if(stream_cast(newPrimitive,value) ||
5012
newPrimitive >= COMPPROFILE_PRIMITIVE_END)
5016
//TODO: Convert the type data as best we can.
5017
primitiveType=newPrimitive;
5019
//In leiu of covnersion, just reset the primitive
5020
//values to some nominal defaults.
5021
vectorParams.clear();
5022
scalarParams.clear();
5023
switch(primitiveType)
5025
case IONCLIP_PRIMITIVE_CYLINDER:
5026
vectorParams.push_back(Point3D(0,0,0));
5027
vectorParams.push_back(Point3D(0,20,0));
5028
scalarParams.push_back(10.0f);
5039
case KEY_COMPPROFILE_RADIUS:
5042
if(stream_cast(newRad,value))
5045
if(scalarParams[0] != newRad )
5047
scalarParams[0] = newRad;
5053
case KEY_COMPPROFILE_SHOWPRIMITIVE:
5055
unsigned int valueInt;
5056
if(stream_cast(valueInt,value))
5059
if(valueInt ==0 || valueInt == 1)
5061
if(showPrimitive!= valueInt)
5064
showPrimitive=valueInt;
5074
case KEY_COMPPROFILE_NORMALISE:
5076
unsigned int valueInt;
5077
if(stream_cast(valueInt,value))
5080
if(valueInt ==0 || valueInt == 1)
5082
if(normalise!= valueInt)
5098
case 1: //Plot settings
5102
case KEY_COMPPROFILE_PLOTTYPE:
5104
unsigned int tmpPlotType;
5106
tmpPlotType=plotID(value);
5108
if(tmpPlotType >= PLOT_TYPE_ENDOFENUM)
5111
plotType = tmpPlotType;
5115
case KEY_COMPPROFILE_COLOUR:
5117
unsigned char newR,newG,newB,newA;
5118
parseColString(value,newR,newG,newB,newA);
5120
r=((float)newR)/255.0f;
5121
g=((float)newG)/255.0f;
5122
b=((float)newB)/255.0f;
6151
case 0://Primitive settings
6156
case KEY_COMPPROFILE_BINWIDTH:
6159
if(stream_cast(newBinWidth,value))
6162
if(newBinWidth < sqrt(std::numeric_limits<float>::epsilon()))
6165
binWidth=newBinWidth;
6170
case KEY_COMPPROFILE_FIXEDBINS:
6172
unsigned int valueInt;
6173
if(stream_cast(valueInt,value))
6176
if(valueInt ==0 || valueInt == 1)
6178
if(fixedBins!= valueInt)
6192
case KEY_COMPPROFILE_NORMAL:
6195
if(!newPt.parse(value))
6198
if(!(vectorParams[1] == newPt ))
6200
vectorParams[1] = newPt;
6206
case KEY_COMPPROFILE_NUMBINS:
6208
unsigned int newNumBins;
6209
if(stream_cast(newNumBins,value))
6218
case KEY_COMPPROFILE_ORIGIN:
6221
if(!newPt.parse(value))
6224
if(!(vectorParams[0] == newPt ))
6226
vectorParams[0] = newPt;
6233
case KEY_COMPPROFILE_PRIMITIVETYPE:
6235
unsigned int newPrimitive;
6236
if(stream_cast(newPrimitive,value) ||
6237
newPrimitive >= COMPPROFILE_PRIMITIVE_END)
6241
//TODO: Convert the type data as best we can.
6242
primitiveType=newPrimitive;
6244
//In leiu of covnersion, just reset the primitive
6245
//values to some nominal defaults.
6246
vectorParams.clear();
6247
scalarParams.clear();
6248
switch(primitiveType)
6250
case IONCLIP_PRIMITIVE_CYLINDER:
6251
vectorParams.push_back(Point3D(0,0,0));
6252
vectorParams.push_back(Point3D(0,20,0));
6253
scalarParams.push_back(10.0f);
6264
case KEY_COMPPROFILE_RADIUS:
6267
if(stream_cast(newRad,value))
6270
if(scalarParams[0] != newRad )
6272
scalarParams[0] = newRad;
6278
case KEY_COMPPROFILE_SHOWPRIMITIVE:
6280
unsigned int valueInt;
6281
if(stream_cast(valueInt,value))
6284
if(valueInt ==0 || valueInt == 1)
6286
if(showPrimitive!= valueInt)
6289
showPrimitive=valueInt;
6299
case KEY_COMPPROFILE_NORMALISE:
6301
unsigned int valueInt;
6302
if(stream_cast(valueInt,value))
6305
if(valueInt ==0 || valueInt == 1)
6307
if(normalise!= valueInt)
6323
case 1: //Plot settings
6327
case KEY_COMPPROFILE_PLOTTYPE:
6329
unsigned int tmpPlotType;
6331
tmpPlotType=plotID(value);
6333
if(tmpPlotType >= PLOT_TYPE_ENDOFENUM)
6336
plotType = tmpPlotType;
6340
case KEY_COMPPROFILE_COLOUR:
6342
unsigned char newR,newG,newB,newA;
6343
parseColString(value,newR,newG,newB,newA);
6345
r=((float)newR)/255.0f;
6346
g=((float)newG)/255.0f;
6347
b=((float)newB)/255.0f;
6356
case 2: //Error estimation settings
6360
case KEY_COMPPROFILE_ERRMODE:
6362
unsigned int tmpMode;
6363
tmpMode=plotErrmodeID(value);
6365
if(tmpMode >= PLOT_ERROR_ENDOFENUM)
6368
errMode.mode= tmpMode;
6373
case KEY_COMPPROFILE_AVGWINSIZE:
6375
unsigned int tmpNum;
6376
stream_cast(tmpNum,value);
6380
errMode.movingAverageNum=tmpNum;