本文整理汇总了C++中image::pointer::getSceneGraphNode方法的典型用法代码示例。如果您正苦于以下问题:C++ pointer::getSceneGraphNode方法的具体用法?C++ pointer::getSceneGraphNode怎么用?C++ pointer::getSceneGraphNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类image::pointer
的用法示例。
在下文中一共展示了pointer::getSceneGraphNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createIGTLTransformMessage
static igtl::TransformMessage::Pointer createIGTLTransformMessage(Image::pointer image) {
// Create transform message from the scene graph information of image
igtl::Matrix4x4 matrix;
AffineTransformation::pointer T = image->getSceneGraphNode()->getTransformation();
for(int i = 0; i < 4; i++) {
for(int j = 0; j < 4; j++) {
matrix[i][j] = T->getTransform().matrix()(i,j);
}}
igtl::TransformMessage::Pointer message = igtl::TransformMessage::New();
message->SetDeviceName("DummyTransform");
message->SetMatrix(matrix);
return message;
}
示例2: execute
//.........这里部分代码省略.........
if(values.size() == 2) {
spacing[2] = 1;
} else {
spacing[2] = boost::lexical_cast<float>(values[2]);
}
}
} else if(key == "CenterOfRotation") {
//reportInfo() << "WARNING: CenterOfRotation in Metaimage file ignored" << Reporter::end;
std::vector<std::string> values;
boost::split(values, value, boost::is_any_of(" "));
// Remove any empty values:
values.erase(std::remove(values.begin(), values.end(), ""), values.end());
if(imageIs3D) {
if(values.size() != 3)
throw Exception("CenterOfRotation in MetaImage file did not contain 3 numbers");
centerOfRotation[0] = boost::lexical_cast<float>(values[0]);
centerOfRotation[1] = boost::lexical_cast<float>(values[1]);
centerOfRotation[2] = boost::lexical_cast<float>(values[2]);
} else {
if(values.size() != 2 && values.size() != 3)
throw Exception("CenterOfRotation in MetaImage file did not contain 2 or 3 numbers");
centerOfRotation[0] = boost::lexical_cast<float>(values[0]);
centerOfRotation[1] = boost::lexical_cast<float>(values[1]);
if(values.size() == 2) {
centerOfRotation[2] = 0;
} else {
centerOfRotation[2] = boost::lexical_cast<float>(values[2]);
}
}
} else if(key == "Offset" || key == "Origin" || key == "Position") {
std::vector<std::string> values;
boost::split(values, value, boost::is_any_of(" "));
// Remove any empty values:
values.erase(std::remove(values.begin(), values.end(), ""), values.end());
if(values.size() != 3)
throw Exception("Offset/Origin/Position in MetaImage file did not contain 3 numbers");
offset[0] = boost::lexical_cast<float>(values[0].c_str());
offset[1] = boost::lexical_cast<float>(values[1].c_str());
offset[2] = boost::lexical_cast<float>(values[2].c_str());
} else if(key == "TransformMatrix" || key == "Rotation" || key == "Orientation") {
std::vector<std::string> values;
boost::split(values, value, boost::is_any_of(" "));
// Remove any empty values:
values.erase(std::remove(values.begin(), values.end(), ""), values.end());
if(values.size() != 9)
throw Exception("Encountered a transform/orientation/rotation matrix with incorrect number of elements in the MetaImageImporter");
for(unsigned int i = 0; i < 3; i++) {
for(unsigned int j = 0; j < 3; j++) {
transformMatrix(j,i) = boost::lexical_cast<float>(values[j+i*3].c_str());
}}
}
} while(!mhdFile.eof());
mhdFile.close();
if(!sizeFound || !rawFilenameFound || !typeFound || !dimensionsFound)
throw Exception("Error reading the mhd file", __LINE__, __FILE__);
void * data;
DataType type;
if(typeName == "MET_SHORT") {
type = TYPE_INT16;
data = readRawData<short>(rawFilename, width, height, depth, nrOfComponents, isCompressed, compressedDataSize);
} else if(typeName == "MET_USHORT") {
type = TYPE_UINT16;
data = readRawData<unsigned short>(rawFilename, width, height, depth, nrOfComponents, isCompressed, compressedDataSize);
} else if(typeName == "MET_CHAR") {
type = TYPE_INT8;
data = readRawData<char>(rawFilename, width, height, depth, nrOfComponents, isCompressed, compressedDataSize);
} else if(typeName == "MET_UCHAR") {
type = TYPE_UINT8;
data = readRawData<unsigned char>(rawFilename, width, height, depth, nrOfComponents, isCompressed, compressedDataSize);
} else if(typeName == "MET_FLOAT") {
type = TYPE_FLOAT;
data = readRawData<float>(rawFilename, width, height, depth, nrOfComponents, isCompressed, compressedDataSize);
}
if(imageIs3D) {
output->create(width,height,depth,type,nrOfComponents,getMainDevice(),data);
} else {
output->create(width,height,type,nrOfComponents,getMainDevice(),data);
}
output->setSpacing(spacing);
// Create transformation
AffineTransformation::pointer T = AffineTransformation::New();
T->translation() = offset;
T->linear() = transformMatrix;
output->getSceneGraphNode()->setTransformation(T);
// Clean up
deleteArray(data, type);
}