Lesson 2: OCC and VTK - number of curve segments.

Gordan

CAD practitioner
Hello all,

When bridging the TopoDS_Shape to polygonal representation using IVtkTools_ShapeDataSource, how would one increase the number of curved segments? For example when the shape contains and arc or a circle and it is wanted to have it approximated with a higher number of segments in the polygon data.

I'm looking through the documentation but with little luck. Perhaps I'm missing something?

Once more, thank you for all the tutorials!

Best regards!
- Gordan
 

JSlyadne

Administrator
Staff member
Hi Gordan,

As I can see out of code the IVtkOCC_ShapeMesher class is responsible for baking a polygonal data for a given shape. Examining its internalBuild() method, you can see that linear and angular deflections (these parameters actually control the accuracy of curved primitives segmentation) can be passed through some anOcctDrawer object which is a member of GetShapeObj()->Attributes(). So, to achieve your goal, I suppose you should set the required values for those deflections of drawer object and be sure you do it before internalBuild() method execution.

Code:
void IVtkOCC_ShapeMesher::internalBuild()
{
  const TopoDS_Shape& anOcctShape = GetShapeObj()->GetShape();
  if (anOcctShape.IsNull())
  {
    return;
  }

  const Handle(Prs3d_Drawer)& anOcctDrawer = GetShapeObj()->Attributes();
  const Standard_Real aShapeDeflection = StdPrs_ToolTriangulatedShape::GetDeflection (anOcctShape, anOcctDrawer);
  if (anOcctDrawer->IsAutoTriangulation())
  {
    StdPrs_ToolTriangulatedShape::ClearOnOwnDeflectionChange (anOcctShape, anOcctDrawer, true);
    StdPrs_ToolTriangulatedShape::Tessellate (anOcctShape, anOcctDrawer);
  }
 

Gordan

CAD practitioner
Hi JSlyadne,

Thank you, got it working. There are a couple of options available in Prs3d_Drawer, such as SetDeviationCoefficient() and SetDeviationAngle(), both of which work for me.

Thanks!
- Gordan
 
Top