Add 3d text in polydata

Hello all,

I want to add some 3d text in the polydata. What I do is to check the intersecting points of the 3d text (polydata extruded) into the polydata where I want to add the text. So what I want is to get the intersecting points and do some extrussion according to the oriented bounding box and to append it to the polydata.

The problem that the text hasn´t points in the extrusion only at the beginning and the end to make the shape. Do you know if it is possible to generate points in the polydata to be able to get the intersecting points and generate the extrusion to obtain the 3d text.

Thanks

   vtkNew<vtkPolyData> clipped_text_engraved;

		//Contains all the conected    components separated by the
		//splint
		vtkNew<vtkPolyData>    polydata_groups;
		vtkNew<vtkPoints> points_groups;
		for (unsigned int i = 0; i < text_engraved->GetNumberOfPoints(); i++)
		{
			if (!selectEnclosedPoints->IsInside(i)) {
				std::cout << "Point " << i << ": " << selectEnclosedPoints->IsInside(i) << std::endl;
				ids->InsertNextValue(i);
			}
		}//en for text engraved

		vtkSmartPointer<vtkSelectionNode> selectionNode =
			vtkSmartPointer<vtkSelectionNode>::New();
		selectionNode->SetFieldType(vtkSelectionNode::POINT);
		selectionNode->SetContentType(vtkSelectionNode::INDICES);
		selectionNode->SetSelectionList(ids);
		selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(), 1);

		vtkSmartPointer<vtkSelection> selection =
			vtkSmartPointer<vtkSelection>::New();
		selection->AddNode(selectionNode);

		vtkSmartPointer<vtkExtractSelection> extractSelection =
			vtkSmartPointer<vtkExtractSelection>::New();

		extractSelection->SetInputData(0, text_engraved);
		extractSelection->SetInputData(1, selection);
		extractSelection->Update();

maybe this gets you close to you want to achieve, in python using vedo:

from vedo import *
s = Sphere().c('lightblue')
t = Text('H_2 O', s=.3, depth=1).pos(-0.4,0,0.8).cutWithMesh(s, invert=1)
m = merge(s,t) # vtkAppend
show(m)

image
if that’s the case you can check the code of how cutWithMesh works and translate it to c++.

Thank you. Yes it was that. I will have a look. Thanks !! I tried the code but I have the same problem as I have with my code when I extrude the text the points do not match the other polydata to intersect. the idea is similar what I do. I suppose I need to increase the number of points of the text to coincide with the polydata. vtkSubdivideTetra could do that?

Thank you

this seems to work using vtkBooleanOperationPolyDataFilter:

from vedo import *
s = Sphere().c('lightblue')
t = Text('H_2 O', s=.3, depth=1).reverse().pos(-0.4,0,0.8)
st = booleanOperation(s,'+',t)
st.computeNormals().flat().lineWidth(0.1)
show(st)

image

Thank you both options work if I add the linear subdivision filter in the text. Thanks !!!

1 Like