Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit 400c883d authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

some fixes.

parent 12843382
......@@ -163,7 +163,6 @@ namespace campvis {
MultiIndexedGeometry* GeometryDataFactory::createSphere(uint16_t numStacks /*= 6*/, uint16_t numSlices /*= 12*/, const cgt::vec3& exponents /*= cgt::vec3(1.f)*/) {
cgtAssert(numStacks > 1 && numSlices > 2, "Sphere must have minimum 2 stacks and 3 slices!");
std::vector<cgt::vec3> vertices;
std::vector<cgt::vec3> vertices2;
std::vector<cgt::vec3> textureCoordinates;
// add top vertex
......
......@@ -215,7 +215,7 @@ namespace campvis {
template<typename T>
const T* campvis::ImageData::getRepresentation(bool performConversion) const {
// look, whether we already have a suitable representation
for (auto it = _representations.rbegin(); it != _representations.rend(); ++it) {
for (auto it = _representations.begin(); it != _representations.end(); ++it) {
if (const T* tester = dynamic_cast<const T*>(*it)) {
return tester;
}
......@@ -226,7 +226,7 @@ namespace campvis {
tbb::spin_mutex::scoped_lock lock(_conversionMutex);
// in the meantime, there something might have changed, so check again whether there is a new rep.
for (auto it = _representations.rbegin(); it != _representations.rend(); ++it) {
for (auto it = _representations.begin(); it != _representations.end(); ++it) {
if (const T* tester = dynamic_cast<const T*>(*it)) {
return tester;
}
......@@ -240,7 +240,7 @@ namespace campvis {
template<typename T>
const T* campvis::ImageData::tryPerformConversion() const {
for (auto it = _representations.rbegin(); it != _representations.rend(); ++it) {
for (auto it = _representations.begin(); it != _representations.end(); ++it) {
const T* tester = ImageRepresentationConverter::getRef().tryConvertFrom<T>(*it);
if (tester != 0) {
//LDEBUG("Performed a image representation conversion from " + std::string(typeid(**it).name()) + " to " + std::string(typeid(T).name()) + ".");
......
......@@ -78,16 +78,24 @@ namespace campvis {
return toReturn;
}
std::vector<std::string> StringUtils::split(const std::string& line, const std::string& delimiter) {
std::vector<std::string> StringUtils::split(const std::string& line, const std::string& delimiter, bool delimiterIsSet /*= false*/) {
std::vector<std::string> toReturn;
std::string::size_type linepos = 0;
std::string::size_type endpos = 0;
// we are at the beginning of an entry, skip whitespaces and check if not already reached end of line
while (endpos != std::string::npos) {
endpos = line.find_first_of(delimiter, linepos);
if (delimiterIsSet)
endpos = line.find_first_of(delimiter, linepos);
else
endpos = line.find(delimiter, linepos);
toReturn.push_back(line.substr(linepos, endpos - linepos));
linepos = endpos + 1;
if (delimiterIsSet)
linepos = endpos + 1;
else
linepos = endpos + delimiter.length();
}
return toReturn;
}
......
......@@ -79,10 +79,11 @@ namespace campvis {
/**
* Splits the string \a str into pieces separated by the delimiters in \a delimiter.
* \param str String to split.
* \param delimiter Set of delimiters.
* \param delimiter Delimiter, if \a delimiterIsSet is true, this either character of this string is considered a delimiter.
* \param delimiterIsSet Flag, whether \a delimiter is considered as set or as multi char string; defaults to false.
* \return Vector of the split substrings.
*/
static std::vector<std::string> split(const std::string& str, const std::string& delimiter);
static std::vector<std::string> split(const std::string& str, const std::string& delimiter, bool delimiterIsSet = false);
/**
* Splits the string \a str into trimmed pieces separated by the delimiters in \a delimiter.
......
......@@ -38,14 +38,6 @@
#include <string>
#include <vector>
namespace {
std::string getLine(std::istream s, char delim) {
std::string toReturn;
std::getline(s, toReturn, delim);
return toReturn;
}
}
namespace campvis {
/**
......
......@@ -21,5 +21,5 @@ IF(${ModuleEnabled})
SET(ThisModShaderDirectories "modules/dti/glsl")
ENDIF(${ModuleEnabled})
SET(ThisModStatus EXPERIMENTAL)
SET(ThisModStatus TESTING)
SET(ThisModExternalDependencies FALSE)
......@@ -93,6 +93,7 @@ namespace {
// cppcheck-suppress stlIfStrFind
if (curLine.find("# AmiraMesh") != 0)
throw cgt::FileException("Could not identify as AmiraMesh file.", p_url.getValue());
// cppcheck-suppress stlIfStrFind
if (curLine.find("# AmiraMesh BINARY-LITTLE-ENDIAN") != 0)
throw cgt::FileException("Unsupported format in AmiraMesh file.", p_url.getValue());
......@@ -185,7 +186,7 @@ namespace {
// compute offset
if ((curLine = advanceTo(file, "# Data section follows")).empty())
if (advanceTo(file, "# Data section follows").empty())
throw cgt::FileException("Malformed (or unsupported?) AmiraMesh file.", p_url.getValue());
getTrimmedLine(file);
......
......@@ -170,7 +170,7 @@ namespace campvis {
}
if (rootNode->hasKey("TransformationMatrix")) {
std::string s = rootNode->getString("TransformationMatrix");
std::vector<std::string> elements = StringUtils::split(s, " \t");
std::vector<std::string> elements = StringUtils::split(s, " \t", true);
if (elements.size() == 16) {
for (size_t i = 0; i < 16; ++i) {
transformationMatrix.elem[i] = StringUtils::fromString<float>(elements[i]);
......
......@@ -123,11 +123,14 @@ namespace campvis {
_flairReader.p_targetImageID.addSharedProperty(&_mvr.p_sourceImage3);
_flairReader.s_validated.connect(this, &ViscontestDemo::onReaderValidated);
Geometry1DTransferFunction* t1_tf = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .023f));
t1_tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.06f, .11f), cgt::col4(57, 57, 57, 32), cgt::col4(196, 196, 196, 16)));
_mvmpr2D.p_transferFunction1.replaceTF(t1_tf);
_mvmpr3D.p_transferFunction1.replaceTF(t1_tf->clone());
_mvr.p_transferFunction1.replaceTF(t1_tf->clone());
Geometry1DTransferFunction* t1_tf_rc = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .023f));
t1_tf_rc->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.06f, .11f), cgt::col4(57, 57, 57, 32), cgt::col4(196, 196, 196, 16)));
_mvr.p_transferFunction1.replaceTF(t1_tf_rc);
Geometry1DTransferFunction* t1_tf_mpr = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .023f));
t1_tf_mpr->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.06f, .4f), cgt::col4(57, 57, 57, 32), cgt::col4(196, 196, 196, 16)));
_mvmpr2D.p_transferFunction1.replaceTF(t1_tf_mpr);
_mvmpr3D.p_transferFunction1.replaceTF(t1_tf_mpr->clone());
Geometry1DTransferFunction* ct_tf = new Geometry1DTransferFunction(128, cgt::vec2(0.f, .0421f));
ct_tf->addGeometry(TFGeometry1D::createQuad(cgt::vec2(.381f, .779f), cgt::col4(0, 100, 150, 128), cgt::col4(0, 192, 255, 172)));
......@@ -160,7 +163,6 @@ namespace campvis {
_mvmpr3D.p_showWireframe.setValue(true);
_mvmpr3D.p_transparency.setValue(0.5f);
_mvmpr3D.p_outputImageId.addSharedProperty(&_rtc2.p_firstImageId);
//_mvmpr3D.p_outputImageId.addSharedProperty(&_mvr.p_geometryImageId);
_mvr.p_outputImageId.setValue("result.rc");
_mvr.p_outputImageId.addSharedProperty(&_rtc1.p_secondImageId);
......@@ -168,7 +170,7 @@ namespace campvis {
_rtc1.p_compositingMethod.selectByOption(RenderTargetCompositor::CompositingModeDepth);
_rtc1.p_targetImageId.setValue("composed1");
_rtc1.p_targetImageId.addSharedProperty(&_rtc2.p_firstImageId);
_rtc1.p_targetImageId.addSharedProperty(&_rtc2.p_secondImageId);
_rtc2.p_compositingMethod.selectByOption(RenderTargetCompositor::CompositingModeDepth);
_rtc2.p_targetImageId.setValue("composed");
......@@ -190,8 +192,6 @@ namespace campvis {
void ViscontestDemo::onSplitterEvent(size_t index, cgt::Event* e) {
if (typeid(*e) == typeid(cgt::MouseEvent)) {
cgt::MouseEvent* me = static_cast<cgt::MouseEvent*>(e);
if (index == 0) {
_slicePositionEventHandler.onEvent(e);
}
......
......@@ -151,15 +151,15 @@ namespace neuro {
glEnable(GL_DEPTH_TEST);
_shader->activate();
if (p_showWireframe.getValue()) {
// calculate viewport matrix for NDC -> viewport conversion
cgt::vec2 halfViewport = cgt::vec2(getEffectiveViewportSize()) / 2.f;
cgt::mat4 viewportMatrix = cgt::mat4::createTranslation(cgt::vec3(halfViewport, 0.f)) * cgt::mat4::createScale(cgt::vec3(halfViewport, 1.f));
_shader->setUniform("_viewportMatrix", viewportMatrix);
_shader->setUniform("_lineWidth", p_lineWidth.getValue());
_shader->setUniform("_transparency", p_transparency.getValue());
}
// calculate viewport matrix for NDC -> viewport conversion
cgt::vec2 halfViewport = cgt::vec2(getEffectiveViewportSize()) / 2.f;
cgt::mat4 viewportMatrix = cgt::mat4::createTranslation(cgt::vec3(halfViewport, 0.f)) * cgt::mat4::createScale(cgt::vec3(halfViewport, 1.f));
_shader->setUniform("_viewportMatrix", viewportMatrix);
if (p_use2DProjection.getValue()) {
// generate a camera position that simulates 2D rendering
// this way it is easier to achieve the correct aspect ratio in all cases
......
......@@ -113,7 +113,7 @@ TEST_F(StringUtilTest, splitTest) {
parsed = StringUtils::splitStringsafe("one two three", " ", '|');
parsed = StringUtils::splitStringsafe("one 'two three' 'four fi\'\'ve' six \' \' ", " ", '\'');
std::string str2[] = { "one", "two three", "four fi\'ve", "six", " " , "^_^"};//{"one", "two", "three", "^_^"}; // "^_^" is used to indicate last token
std::string str2[] = { "one", "two three", "four fi\'ve", "six", "" , "^_^"};//{"one", "two", "three", "^_^"}; // "^_^" is used to indicate last token
for (int i= 0; "^_^" != str2[i] ; i++) {
expected.push_back(str2[i]);
......
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