本文整理汇总了C++中vtkSmartPointer类的典型用法代码示例。如果您正苦于以下问题:C++ vtkSmartPointer类的具体用法?C++ vtkSmartPointer怎么用?C++ vtkSmartPointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了vtkSmartPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
vtkSmartPointer<vtkArrayType> FlowAnalysis::vtkMakeArray(const vtkSmartPointer<vtkUniformGrid>& grid, const string& name, size_t numComponents, bool fillZero){
auto arr=vtkSmartPointer<vtkArrayType>::New();
arr->SetNumberOfComponents(numComponents);
arr->SetNumberOfTuples(boxCells.prod());
arr->SetName(name.c_str());
if(cellData) grid->GetCellData()->AddArray(arr);
else grid->GetPointData()->AddArray(arr);
if(fillZero){ for(int _i=0; _i<(int)numComponents; _i++) arr->FillComponent(_i,0.); }
return arr;
}
示例2: GetColumsWithString
std::vector<std::string> GetColumsWithString( std::string colName, vtkSmartPointer<vtkTable> table ){
std::vector<std::string> retVect;
for( int i=0; i<table->GetNumberOfColumns(); ++i ){
std::string current_column;
current_column = table->GetColumnName(i);
if( current_column.find(colName.c_str()) != std::string::npos ){
retVect.push_back( current_column );
}
}
return retVect;
}
示例3: setActiveEdgeActor
void FieldDataVisualizer::setActiveEdgeActor(vtkSmartPointer<vtkActor>& _edgeActor) {
//Edge vis
vtkSmartPointer<vtkExtractEdges> edgeExtractorTemp = vtkExtractEdges::New();
edgeExtractorTemp->SetInputData(warpFilter->GetUnstructuredGridOutput());
vtkSmartPointer<vtkPolyDataMapper> edgeMapperTemp = vtkPolyDataMapper::New();
edgeMapperTemp->SetInputConnection(edgeExtractorTemp->GetOutputPort());
_edgeActor->SetMapper(edgeMapperTemp);
_edgeActor->GetProperty()->SetColor(0., 0., 0.);
_edgeActor->GetProperty()->SetLineWidth(3);
edgeMapperTemp->ScalarVisibilityOff();
}
示例4: VtkWriter
VtkWriter(const std::string &data_path, bool write_binary = true) :
m_file_counter(0),
m_data_path(data_path),
m_writer(vtkSmartPointer<vtk_writer_type>::New()),
m_write_binary(write_binary)
{
vtksys::SystemTools::MakeDirectory(data_path.c_str());
if (m_write_binary)
m_writer->SetDataModeToBinary();
else
m_writer->SetDataModeToAscii();
}
示例5: setActiveHueLut
void FieldDataVisualizer::setActiveHueLut(vtkSmartPointer<vtkLookupTable>& _hueLut) {
double scalarRange[2];
myHMeshToVtkUnstructuredGrid->getVtkUnstructuredGrid()->GetPointData()->GetScalars()->GetRange(scalarRange);
mySelectedMapper->UseLookupTableScalarRangeOn();
// Create a lookup table to share between the mapper and the scalarbar
_hueLut->SetTableRange(scalarRange[0], scalarRange[1]);
_hueLut->SetHueRange(0.667, 0.0);
_hueLut->SetValueRange(1, 1);
_hueLut->Build();
mySelectedMapper->SetLookupTable(_hueLut);
}
示例6: Append
//Update the features in this table whose names match (sets doFeat)
void AssociativeFeatureCalculator::Append(vtkSmartPointer<vtkTable> table)
{
//Compute features:
ftk::NuclearAssociationRules *assoc;
if( inputs_set ){
assoc = new ftk::NuclearAssociationRules("",0,lab_im, inp_im);
assoc->AddAssociation( input_association->GetRuleName(), "", input_association->GetOutDistance(), input_association->GetInDistance(), input_association->IsUseWholeObject(), input_association->IsUseBackgroundSubtraction(), input_association->IsUseMultiLevelThresholding(), input_association->GetNumberOfThresholds(), input_association->GetNumberIncludedInForeground(), input_association->GetAssocType(), input_association->get_path() );
}
else{
assoc = new ftk::NuclearAssociationRules("",0);
assoc->ReadRulesFromXML(inFilename);
}
assoc->PrintSelf();
assoc->Compute();
//Init the table (headers):
for (int i=0; i < assoc->GetNumofAssocRules(); ++i)
{
vtkSmartPointer<vtkDoubleArray> column = vtkSmartPointer<vtkDoubleArray>::New();
column->SetName( (fPrefix+assoc->GetAssociationRules().at(i).GetRuleName()).c_str() );
column->SetNumberOfValues( table->GetNumberOfRows() );
table->AddColumn(column);
}
//Now update the table:
std::vector<unsigned short> labels = assoc->GetLabels();
float** vals = assoc->GetAssocFeaturesList();
//#pragma omp parallel for num_threads(4)
for (int i=0; i<(int)labels.size(); ++i)
{
unsigned short id = labels.at(i);
if(id == 0) continue;
int row = -1;
for(int r=0; r<table->GetNumberOfRows(); ++r)
{
if( table->GetValue(r,0) == id )
{
row = r;
break;
}
}
if(row == -1) continue;
for (int f=0; f<assoc->GetNumofAssocRules(); ++f)
{
table->SetValueByName(row,(fPrefix+assoc->GetAssociationRules().at(f).GetRuleName()).c_str(), vtkVariant(vals[f][i]));
}
}
delete assoc;
}
示例7:
void cv::viz::vtkImageMatSource::copyGrayImage(const Mat &source, vtkSmartPointer<vtkImageData> output)
{
unsigned char* dptr = reinterpret_cast<unsigned char*>(output->GetScalarPointer());
size_t elem_step = output->GetIncrements()[1]/sizeof(unsigned char);
for (int y = 0; y < source.rows; ++y)
{
unsigned char* drow = dptr + elem_step * y;
const unsigned char *srow = source.ptr<unsigned char>(y);
for (int x = 0; x < source.cols; ++x)
drow[x] = *srow++;
}
}
示例8: AppendTables
vtkSmartPointer<vtkTable> AppendTables(vtkSmartPointer<vtkTable> table_initial,vtkSmartPointer<vtkTable> table_new )
{
/*!
* Adds on table to the end of another
*/
//!fill the table with values
unsigned int counter = 0;
for(vtkIdType r = 0; r < table_new->GetNumberOfRows() ; r++ )
{
table_initial->InsertNextRow(table_new->GetRow(r));
}
return table_initial;
}
示例9: sizeof
template <typename PointT> void
pcl::visualization::PointCloudGeometryHandlerXYZ<PointT>::getGeometry (vtkSmartPointer<vtkPoints> &points) const
{
if (!capable_)
return;
if (!points)
points = vtkSmartPointer<vtkPoints>::New ();
points->SetDataTypeToFloat ();
vtkSmartPointer<vtkFloatArray> data = vtkSmartPointer<vtkFloatArray>::New ();
data->SetNumberOfComponents (3);
vtkIdType nr_points = cloud_->points.size ();
// Add all points
vtkIdType j = 0; // true point index
float* pts = static_cast<float*> (malloc (nr_points * 3 * sizeof (float)));
// If the dataset has no invalid values, just copy all of them
if (cloud_->is_dense)
{
for (vtkIdType i = 0; i < nr_points; ++i)
{
pts[i * 3 + 0] = cloud_->points[i].x;
pts[i * 3 + 1] = cloud_->points[i].y;
pts[i * 3 + 2] = cloud_->points[i].z;
}
data->SetArray (&pts[0], nr_points * 3, 0);
points->SetData (data);
}
// Need to check for NaNs, Infs, ec
else
{
for (vtkIdType i = 0; i < nr_points; ++i)
{
// Check if the point is invalid
if (!pcl_isfinite (cloud_->points[i].x) || !pcl_isfinite (cloud_->points[i].y) || !pcl_isfinite (cloud_->points[i].z))
continue;
pts[j * 3 + 0] = cloud_->points[i].x;
pts[j * 3 + 1] = cloud_->points[i].y;
pts[j * 3 + 2] = cloud_->points[i].z;
// Set j and increment
j++;
}
data->SetArray (&pts[0], j * 3, 0);
points->SetData (data);
}
}
示例10:
void CDialog_subSTL::OnBnClickedButton4() //scaled
{
vtkSmartPointer<vtkQuadricDecimation> decimate = vtkSmartPointer<vtkQuadricDecimation>::New();//scale method in VTK
decimate->SetInputConnection(STLReader->GetOutputPort());
decimate->Update();
vtkSmartPointer<vtkPolyData> decimated = vtkSmartPointer<vtkPolyData>::New();
decimated->ShallowCopy(decimate->GetOutput());
vtkSmartPointer<vtkSTLWriter> stlWriter = vtkSmartPointer<vtkSTLWriter>::New();
stlWriter->SetFileName("test_saled.stl");
stlWriter->SetInput(decimated); //stlWriter->SetInput(map->GetOutput());
stlWriter->Write();
MessageBox(_T("Scaled Done"));
renderWindowInteractor_STL->GetRenderWindow()->Finalize(); // close renderwindow
renderWindowInteractor_STL->TerminateApp();
}
示例11: return
template <typename PointT> bool
pcl::visualization::PointCloudColorHandlerRandom<PointT>::getColor (vtkSmartPointer<vtkDataArray> &scalars) const
{
if (!capable_ || !cloud_)
return (false);
if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
vtkIdType nr_points = cloud_->points.size ();
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetNumberOfTuples (nr_points);
// Get a random color
unsigned char* colors = new unsigned char[nr_points * 3];
double r, g, b;
pcl::visualization::getRandomColors (r, g, b);
int r_ = static_cast<int> (pcl_lrint (r * 255.0)),
g_ = static_cast<int> (pcl_lrint (g * 255.0)),
b_ = static_cast<int> (pcl_lrint (b * 255.0));
// Color every point
for (vtkIdType cp = 0; cp < nr_points; ++cp)
{
colors[cp * 3 + 0] = static_cast<unsigned char> (r_);
colors[cp * 3 + 1] = static_cast<unsigned char> (g_);
colors[cp * 3 + 2] = static_cast<unsigned char> (b_);
}
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetArray (colors, 3 * nr_points, 0, vtkUnsignedCharArray::VTK_DATA_ARRAY_DELETE);
return (true);
}
示例12: return
template <typename PointT> bool
pcl::visualization::PointCloudColorHandlerCustom<PointT>::getColor (vtkSmartPointer<vtkDataArray> &scalars) const
{
if (!capable_ || !cloud_)
return (false);
if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
vtkIdType nr_points = cloud_->points.size ();
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetNumberOfTuples (nr_points);
// Get a random color
unsigned char* colors = new unsigned char[nr_points * 3];
// Color every point
for (vtkIdType cp = 0; cp < nr_points; ++cp)
{
colors[cp * 3 + 0] = static_cast<unsigned char> (r_);
colors[cp * 3 + 1] = static_cast<unsigned char> (g_);
colors[cp * 3 + 2] = static_cast<unsigned char> (b_);
}
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetArray (colors, 3 * nr_points, 0);
return (true);
}
示例13: getVoxelActors
void
getVoxelActors (pcl::PointCloud<pcl::PointXYZ>& voxelCenters,
double voxelSideLen, Eigen::Vector3f color,
vtkSmartPointer<vtkActorCollection> coll)
{
vtkSmartPointer < vtkAppendPolyData > treeWireframe = vtkSmartPointer<vtkAppendPolyData>::New ();
double s = voxelSideLen/2.0;
for (const auto &point : voxelCenters.points)
{
double x = point.x;
double y = point.y;
double z = point.z;
treeWireframe->AddInputData (getCuboid (x - s, x + s, y - s, y + s, z - s, z + s));
}
vtkSmartPointer < vtkLODActor > treeActor = vtkSmartPointer<vtkLODActor>::New ();
vtkSmartPointer < vtkDataSetMapper > mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInputData (treeWireframe->GetOutput ());
treeActor->SetMapper (mapper);
treeActor->GetProperty ()->SetRepresentationToWireframe ();
treeActor->GetProperty ()->SetColor (color[0], color[1], color[2]);
treeActor->GetProperty ()->SetLineWidth (4);
coll->AddItem (treeActor);
}
示例14:
template <typename PointT> void
pcl::visualization::PointCloudColorHandlerRandom<PointT>::getColor (vtkSmartPointer<vtkDataArray> &scalars) const
{
if (!capable_)
return;
if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
vtkIdType nr_points = cloud_->points.size ();
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetNumberOfTuples (nr_points);
// Get a random color
unsigned char* colors = new unsigned char[nr_points * 3];
double r, g, b;
pcl::visualization::getRandomColors (r, g, b);
int r_ = pcl_lrint (r * 255.0), g_ = pcl_lrint (g * 255.0), b_ = pcl_lrint (b * 255.0);
// Color every point
for (vtkIdType cp = 0; cp < nr_points; ++cp)
{
colors[cp * 3 + 0] = r_;
colors[cp * 3 + 1] = g_;
colors[cp * 3 + 2] = b_;
}
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetArray (colors, 3 * nr_points, 0);
}
示例15: return
bool
pcl::visualization::PointCloudColorHandlerRandom<pcl::PCLPointCloud2>::getColor (vtkSmartPointer<vtkDataArray> &scalars) const
{
if (!capable_ || !cloud_)
return (false);
if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);
vtkIdType nr_points = cloud_->width * cloud_->height;
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetNumberOfTuples (nr_points);
// Get a random color
unsigned char* colors = new unsigned char[nr_points * 3];
double r, g, b;
pcl::visualization::getRandomColors (r, g, b);
long r_ = pcl_lrint (r * 255.0), g_ = pcl_lrint (g * 255.0), b_ = pcl_lrint (b * 255.0);
// Color every point
for (vtkIdType cp = 0; cp < nr_points; ++cp)
{
colors[cp * 3 + 0] = static_cast<unsigned char> (r_);
colors[cp * 3 + 1] = static_cast<unsigned char> (g_);
colors[cp * 3 + 2] = static_cast<unsigned char> (b_);
}
reinterpret_cast<vtkUnsignedCharArray*>(&(*scalars))->SetArray (colors, 3 * nr_points, 0);
return (true);
}