Contours.

 

Let's create two contours.

 

The first one will be flat and closed. It will consist of an array of alternating arcs and line segments lying on a circle.

 

The color of the first contour will be number 0 from the palette, line thickness will be 1:

  std::vector<sgCObject*> objts;

 

 for (double i=0.0;i<2.0*3.14159265;i+=2.0*3.14159265/12.0)

 {

 SG_POINT   arP1 = {5.0*cos(i),5.0*sin(i),0.0};

 SG_POINT   arP2 = {5.0*cos(i+2.0*3.14159265/24.0),5.0*sin(i+2.0*3.14159265/24.0),0.0};

 SG_POINT   arP3 = {7.0*cos(i+2.0*3.14159265/48.0),7.0*sin(i+2.0*3.14159265/48.0),0.0};

 SG_ARC     arGeo;

 if (arGeo.FromTreePoints(arP1, arP2, arP3,false))

 {

         sgCArc* ar = sgCreateArc(arGeo);

         if (ar)

         {

                 objts.push_back(ar);

         }

 }

 objts.push_back(sgCreateLine(5.0*cos(i+2.0*3.14159265/24.0),5.0*sin(i+2.0*3.14159265/24.0),0.0,

                 5.0*cos(i+2.0*3.14159265/12.0),5.0*sin(i+2.0*3.14159265/12.0),0.0));

 }

 

 sgCContour* cnt1 = sgCContour::CreateContour(&objts[0],objts.size());

 objts.clear();

 sgGetScene()->AttachObject(cnt1);

 cnt1->SetAttribute(SG_OA_COLOR,0);

 cnt1->SetAttribute(SG_OA_LINE_THICKNESS, 1);

 

The second contour will be closed but not flat. It will also consist of an array of alternating arcs and line segments, but the arcs will be turned in space - the Z coordinate of the arc middle point will be 2.

 

The color of the second contour will be number 10 from the palette, line thickness will be 2:

 

  for (double i=0.0;i<2.0*3.14159265;i+=2.0*3.14159265/6.0)

 {

 SG_POINT   arP1 = {2.0*cos(i),2.0*sin(i),0.0};

 SG_POINT   arP2 = {2.0*cos(i+2.0*3.14159265/12.0),2.0*sin(i+2.0*3.14159265/12.0),0.0};

 SG_POINT   arP3 = {3.0*cos(i+2.0*3.14159265/24.0),3.0*sin(i+2.0*3.14159265/24.0),2.0};

 SG_ARC     arGeo;

 if (arGeo.FromTreePoints(arP1, arP2, arP3,false))

 {

         sgCArc* ar = sgCreateArc(arGeo);

         if (ar)

         {

                 objts.push_back(ar);

         }

 }

 objts.push_back(sgCreateLine(2.0*cos(i+2.0*3.14159265/12.0),2.0*sin(i+2.0*3.14159265/12.0),0.0,        2.0*cos(i+2.0*3.14159265/6.0),2.0*sin(i+2.0*3.14159265/6.0),0.0));

 }

 

 sgCContour* cnt2 = sgCContour::CreateContour(&objts[0],objts.size());

 objts.clear();

 sgGetScene()->AttachObject(cnt2);

 cnt2->SetAttribute(SG_OA_COLOR,10);

 cnt2->SetAttribute(SG_OA_LINE_THICKNESS, 2);

 

See also:

sgCContour   sgCContour::CreateContour sgGetScene sgCScene::AttachObject   sgCObject::SetAttribute

 

 

Illustration:

contours