Pipe-like surfaces.

 

Let's create a pipe-like surface with an arc-clip and a contour-profile consitsing of arcs and line segments.

 

This code creates arc-clips:

 

SG_ARC   ArcGeo;

 SG_POINT    ArP1 = {1.0, -4.0, 0.0};

 SG_POINT    ArP2 = {1.0, -3.6, 0.0};

 SG_POINT    ArP3 = {1.2, -3.5, 0.0};

 ArcGeo.FromTreePoints(ArP1,ArP2,ArP3,false);

 sgC2DObject*  ar = sgCreateArc(ArcGeo);

 sgGetScene()->AttachObject(ar);

 ar->SetAttribute(SG_OA_COLOR,12);

 ar->SetAttribute(SG_OA_LINE_THICKNESS, 2);

 

 

Now let's create a contour-profile consisting of 2 line segments and 4 arcs:

 

 sgCObject*   objcts[6];

 

 objcts[0] = sgCreateLine(0.0, -4.0, 0.0, 0.0, -2.0, 0.0);

 

 ArP1.x = 0.0; ArP1.y = -2.0; ArP1.z = 0.0;

 ArP2.x = 1.0; ArP2.y = -1.0; ArP2.z = 0.0;

 ArP3.x = 0.4; ArP3.y = -1.2; ArP3.z = 0.0;

 ArcGeo.FromTreePoints(ArP1,ArP2,ArP3,false);

 objcts[1] = sgCreateArc(ArcGeo);

 

 ArP1.x = 1.0; ArP1.y = -1.0; ArP1.z = 0.0;

 ArP2.x = 2.0; ArP2.y = 0.0; ArP2.z = 0.0;

 ArP3.x = 1.9; ArP3.y = -0.5; ArP3.z = 0.0;

 ArcGeo.FromTreePoints(ArP1,ArP2,ArP3,false);

 objcts[2] = sgCreateArc(ArcGeo);

 

 ArP1.x = 2.0; ArP1.y = 0.0; ArP1.z = 0.0;

 ArP2.x = 1.0; ArP2.y = 1.0; ArP2.z = 0.0;

 ArP3.x = 1.6; ArP3.y = 0.8; ArP3.z = 0.0;

 ArcGeo.FromTreePoints(ArP1,ArP2,ArP3,false);

 objcts[3] = sgCreateArc(ArcGeo);

 

 objcts[4] = sgCreateLine(1.0, 1.0, 0.0, -1.0, 1.0, 0.0);

 

 ArP1.x = -1.0; ArP1.y = 1.0; ArP1.z = 0.0;

 ArP2.x = -1.0; ArP2.y = 0.0; ArP2.z = 1.0;

 ArP3.x = -1.1; ArP3.y = 1.0; ArP3.z = 0.0;

 ArcGeo.FromTreePoints(ArP1,ArP2,ArP3,false);

 objcts[5] = sgCreateArc(ArcGeo);

 

 sgCContour* cnt1 = sgCContour::CreateContour(objcts,6);

 sgGetScene()->AttachObject(cnt1);

 cnt1->SetAttribute(SG_OA_COLOR,12);

 cnt1->SetAttribute(SG_OA_LINE_THICKNESS, 2);

 

Further you must define both a point in the arc-clip plane which will move along the profile, and a rotation angle around this point. Let this point be (1, -4, 0) and the rotation angle 0 degrees. Let's build a surface:

 

SG_POINT point_in_plane = {1.0, -4.0, 0.0};

 

 bool  close = false;

 sgC3DObject* pipO = (sgC3DObject*)sgKinematic::Pipe((const sgC2DObject&)(*ar),NULL,0,

         (const sgC2DObject&)(*cnt1), point_in_plane, 0.0, close);

 

 sgGetScene()->AttachObject(pipO);

 pipO->SetAttribute(SG_OA_COLOR,25);

 

Then we'll move the obtained surface:

 

 SG_VECTOR transV1 = {2.5,1,0};

 pipO->InitTempMatrix()->Translate(transV1);

 pipO->ApplyTempMatrix();

 pipO->DestroyTempMatrix();

 

See also:

sgKinematic::Pipe  

sgCArc   SG_ARC

sgCLine SG_LINE

sgCContour   sgCContour::CreateContour

sgGetScene sgCScene::AttachObject   sgCObject::SetAttribute

 

Illustration:

kin_pip_s