Ruled surface from clips.
Let's create three ruled surfaces from two contours - a circle and a spline with different spiral degrees.
To start with, let's draw a circle and a spline:
SG_POINT tmpPnt;
SG_SPLINE* spl1 = SG_SPLINE::Create();
int fl=0;
for (double i=0.0;i<2.0*3.14159265;i+=0.4)
{
tmpPnt.x = ((double)(fl%3+2))*cos(i);
tmpPnt.y = ((double)(fl%3+2))*sin(i);
tmpPnt.z = 0.0;
spl1->AddKnot(tmpPnt,fl);
fl++;
}
spl1->Close();
sgCSpline* spl1_obj = sgCreateSpline(*spl1);
sgGetScene()->AttachObject(spl1_obj);
spl1_obj->SetAttribute(SG_OA_COLOR,12);
spl1_obj->SetAttribute(SG_OA_LINE_THICKNESS, 2);
SG_SPLINE::Delete(spl1);
SG_CIRCLE cirGeo;
cirGeo.center.x = 2.0; cirGeo.center.y = -2.0; cirGeo.center.z = 8.0;
cirGeo.normal.x = 0.0; cirGeo.normal.y = 0.0; cirGeo.normal.z = 1.0;
cirGeo.radius = 1.5;
sgCCircle* cir = sgCreateCircle(cirGeo);
sgGetScene()->AttachObject(cir);
cir->SetAttribute(SG_OA_COLOR,12);
cir->SetAttribute(SG_OA_LINE_THICKNESS, 2);
Then we'll construct the ruled surfaces and move them at once.
The first surface:
sgC3DObject* linO1 = (sgC3DObject*)sgSurfaces::LinearSurfaceFromSections((const sgC2DObject&)(*spl1_obj),
(const sgC2DObject&)(*cir),0.5,false);
sgGetScene()->AttachObject(linO1);
linO1->SetAttribute(SG_OA_COLOR,90);
SG_VECTOR transV1 = {0,7,0};
linO1->InitTempMatrix()->Translate(transV1);
linO1->ApplyTempMatrix();
linO1->DestroyTempMatrix();
The second surface:
sgC3DObject* linO2 = (sgC3DObject*)sgSurfaces::LinearSurfaceFromSections((const sgC2DObject&)(*spl1_obj),
(const sgC2DObject&)(*cir),0.7,false);
sgGetScene()->AttachObject(linO2);
linO2->SetAttribute(SG_OA_COLOR,150);
transV1.x = 8.0; transV1.y = 0.0;
linO2->InitTempMatrix()->Translate(transV1);
linO2->ApplyTempMatrix();
linO2->DestroyTempMatrix();
The third surface:
sgC3DObject* linO3 = (sgC3DObject*)sgSurfaces::LinearSurfaceFromSections((const sgC2DObject&)(*spl1_obj),
(const sgC2DObject&)(*cir),0.3,false);
sgGetScene()->AttachObject(linO3);
linO3->SetAttribute(SG_OA_COLOR,30);
transV1.x = -8.0; transV1.y = 0.0;
linO3->InitTempMatrix()->Translate(transV1);
linO3->ApplyTempMatrix();
linO3->DestroyTempMatrix();
See also:
sgSurcfaces::LinearSurfaceFromSections
sgGetScene sgCScene::AttachObject sgCObject::SetAttribute
Illustration: