# How can I generate the same Meniscus model?

**URL:** https://discourse.vtk.org/t/how-can-i-generate-the-same-meniscus-model/10164
**Category:** Support
**Tags:** code
**Created:** [December 12, 2022, 7:10am UTC](https://discourse.vtk.org/t/how-can-i-generate-the-same-meniscus-model/10164 "2022-12-12T07:10:03Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![wyc7894512](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/w/e47c2d/32.png) [@wyc7894512](https://discourse.vtk.org/u/wyc7894512)
#### Post date: [December 12, 2022, 7:10am UTC](https://discourse.vtk.org/t/how-can-i-generate-the-same-meniscus-model/10164/1 "2022-12-12T07:10:03Z")

</div>

Hello,

I split the meniscus from MRI and input it, but this result is not what I expected. I would like to generate a model similar to the real meniscus. I attach the snippet code.  
Please, could you help me to find a solution?

Thank you very much in advance!

 ![2022-12-12 150814](https://discourse.vtk.org/uploads/default/original/2X/9/98ed74d2e8979dc952862700606770fc704d667f.png)

```auto
#include <vtkAutoInit.h>    
VTK_MODULE_INIT(vtkRenderingOpenGL2);
VTK_MODULE_INIT(vtkInteractionStyle);
#include <vtkSmartPointer.h>               
#include <vtkStructuredPointsReader.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkStripper.h>
#include <vtkSmoothPolyDataFilter.h>
#include <vtkProperty.h>
#include <vtkPolyDataNormals.h>
#include <vtkJPEGReader.h>
#include <vtkContourFilter.h>

int main(int argc, char* argv[]) {
	vtkSmartPointer<vtkJPEGReader> reader = vtkSmartPointer<vtkJPEGReader>::New();

	reader->SetDataScalarTypeToUnsignedChar();
	reader->SetFileDimensionality(3);
	reader->SetDataOrigin(0, 0, 0);

	reader->SetFilePrefix("D:/VS/source/repos/file/");  
	reader->SetFilePattern("%s%02d.jpg");
	reader->SetDataExtent(0, 383, 0, 383, 1, 52);
	reader->Update();

	vtkSmartPointer<vtkContourFilter> skinExtractor = vtkSmartPointer<vtkContourFilter>::New(); 
	skinExtractor->SetInputConnection(reader->GetOutputPort());
	skinExtractor->SetValue(0, 50);
	skinExtractor->ComputeGradientsOn();
	skinExtractor->ComputeScalarsOn();

	vtkSmartPointer<vtkSmoothPolyDataFilter> pSmoothPolyDataFilter = vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
	pSmoothPolyDataFilter->SetInputConnection(skinExtractor->GetOutputPort());
	pSmoothPolyDataFilter->BoundarySmoothingOn();
	pSmoothPolyDataFilter->SetRelaxationFactor(0.05);
	pSmoothPolyDataFilter->SetNumberOfIterations(500);  

	vtkSmartPointer<vtkPolyDataNormals> pPolyDataNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
	pPolyDataNormals->SetInputConnection(pSmoothPolyDataFilter->GetOutputPort());
	pPolyDataNormals->SetFeatureAngle(200); 

	vtkSmartPointer<vtkStripper> boneStripper = vtkSmartPointer<vtkStripper>::New();
	boneStripper->SetInputConnection(pPolyDataNormals->GetOutputPort());
	boneStripper->Update();

	auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(boneStripper->GetOutputPort());

	auto actor = vtkSmartPointer<vtkActor>::New();
	actor->SetMapper(mapper);
	actor->GetProperty()->SetColor(1, 1, 1);

	auto renderer = vtkSmartPointer<vtkRenderer>::New();
	renderer->AddActor(actor);
	renderer->SetBackground(1.0, 1.0, 1.0);
	
	auto renWin = vtkSmartPointer<vtkRenderWindow>::New();
	renWin->AddRenderer(renderer);

	auto interactor = vtkSmartPointer<vtkRenderWindowInteractor>::New();
	interactor->SetRenderWindow(renWin);
	renWin->Render();
	auto style = vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
	interactor->SetInteractorStyle(style);

	interactor->Initialize();
	interactor->Start();

	return 0;
}

```

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [December 14, 2022, 3:53pm UTC](https://discourse.vtk.org/t/how-can-i-generate-the-same-meniscus-model/10164/2 "2022-12-14T15:53:11Z")

</div>

Hello,

Can you, please, indicate in the figure what is wrong? Also, can you add more details of what you expect?

best,

Paulo
