# cee::ug::DataPart

class `DataPart` : public RefCountedObject

  A part in the geometry.

  Consists of a collection of node coordinates and a collection element connectivities.

  A DataPart has an element object and a nodes object.

  - DataNodes Array of node positions. Set with setNodes().
  - DataElements Element connectivity array. Set with setElements()

  A DataGeometry contains a collection of DataPart objects.

  Each part will have its own part settings (visibility/color/result visibility/highlighting/…). Part settings are available through UnstructGridModel::partSettings() specifying the geometry index and id of the requested part.

  Each part needs a unique id. This id is set in the constructor. Get the id of an existing part using id().

  Example

  Example of a simple part containing two triangles:

  Create the DataNodes object and set the node coordinates for this part.

      cee::PtrRef<cee::ug::DataNodes> nodes = new cee::ug::DataNodes(false);
      nodes->resize(5);
      nodes->setNode(0, cee::Vec3d(0, 1, 0));
      nodes->setNode(1, cee::Vec3d(0, 0, 0));
      nodes->setNode(2, cee::Vec3d(1, 0, 0));
      nodes->setNode(3, cee::Vec3d(2, 0, 0));
      nodes->setNode(4, cee::Vec3d(2, 1, 0));

  Create the DataElements object and specify the connectivities for this part. This part contains two triangles.

      int c[] = {0, 1, 2, 2, 3, 4};
      std::vector<unsigned int> eltNodes1(c, c+3);    // First triangle
      std::vector<unsigned int> eltNodes2(c+3, c+6);  // Second triangle
      cee::PtrRef<cee::ug::DataElements> elements = new cee::ug::DataElements(false, 0);
      elements->addElement(cee::ug::Element::TRIANGLES, eltNodes1);
      elements->addElement(cee::ug::Element::TRIANGLES, eltNodes2);

  Create the part object and set newly created nodes and elements objects to this part. Specify a unique id when creating the DataPart.

      int partId = 1;
      cee::PtrRef<cee::ug::DataPart> part = new cee::ug::DataPart(partId);
      part->setNodes(nodes.get());
      part->setElements(elements.get());

  Add the part to the geometry. (geo is the DataGeometry object this part belongs to.)

      geo->addPart(part.get());

  See the complete source code at: UnstructGrid: Simple Model with Two Triangles

  Tutorials

  - UnstructGrid: Simple Model with Two Triangles
  - UnstructGrid: A Simple Model with Results

  See also

  DataGeometry, DataElements, DataNodes, and PartSettings

  Public Functions

  `DataPart`(int id)

    Constructs an empty part with the given id.

  int `partId`() const

    Returns the id of the part.

  const DataNodes *`nodes`() const

    Returns a pointer to the nodes objects of this part.

  DataNodes *`nodes`()

    Returns a pointer to the nodes objects of this part.

  void `setNodes`(DataNodes *nodes)

    Specifies the nodes for this part.

    Warning

    The added object is reference counted and should never be created on the stack or deleted!

  const DataElements *`elements`() const

    Returns a pointer to the elements object of this part.

  DataElements *`elements`()

    Returns a pointer to the elements objects of this part.

  void `setElements`(DataElements *elements)

    Specifies the elements of this part.

    See DataElements for more information on supported element types.

    Warning

    The added object is reference counted and should never be created on the stack or deleted!

Conversation saved
HOOPSY BETA

### Hello! I'm HOOPSY

Your multilingual generative AI assistant for documentation. Ask me anything about HOOPS Envision for Desktop in your own language, or choose a sample question below to start a conversation:

What is HOOPS Envision for Desktop?
What are the latest release notes for HOOPS Envision for Desktop?
How do I start evaluating HOOPS Envision for Desktop?
How do I write my first sample application?
How can I get assistance?

HOOPSY may store conversations according to OpenAI's policy. Responses may not always be accurate.

HOOPSY is thinking...