Nasyrov Posted September 12, 2008 Share Posted September 12, 2008 Hi. I want to know the arc length of the curve segment inside geometry shader. But mantra got crash. GU_Detail *gdpCurve = new GU_Detail; gdpCurve->copy(*gdpSkin); GU_PrimRBezCurve *shaft = GU_PrimRBezCurve::build(gdpCurve, 1, 4, 0, 0); { int ind1, ind2; GU_Curve *temp = shaft->cut(0, 1, ind1, ind2, 0); GEO_Curve *test = (GEO_Curve*)temp; float size = test->arcLength(0.1,0.5, 0, 1); } or { GEO_Curve *test = shaft ->getCurve(); float size = test->arcLength(0.1, 0.5, 0, 1); } Quote Link to comment Share on other sites More sharing options...
Nasyrov Posted September 12, 2008 Author Share Posted September 12, 2008 some updates, but results are the same GU_PrimRBezCurve *shaft = new GU_PrimRBezCurve(gdpCurve); shaft->build(gdpCurve, 1, 4, 0, 0); GEO_Curve *test = shaft->getCurve(); float size = test->arcLength(0.1,0.5, 0, 1); Quote Link to comment Share on other sites More sharing options...
Nasyrov Posted September 12, 2008 Author Share Posted September 12, 2008 Some NURB stuff gave me -1 or 0 arc length GU_PrimNURBCurve *shaft = new GU_PrimNURBCurve(gdpCurve); shaft = GU_PrimNURBCurve::build(gdpCurve, 4); GEO_Curve *test = shaft->extract(0.5, 1); float arc = test->arcLength(0, 1); Quote Link to comment Share on other sites More sharing options...
Nasyrov Posted September 15, 2008 Author Share Posted September 15, 2008 Ok, guys. Something awful. const GU_Detail *cgdpSkin = new GU_Detail; .................................. cgdpSkin = queryGeometry(handleSkin, samplesSkin); GU_Detail *gdpSkin = (GU_Detail*)cgdpSkin; GU_Detail *gdpCurve = new GU_Detail; gdpCurve->copy(*gdpSkin); GU_PrimNURBCurve *shaft = new GU_PrimNURBCurve(gdpCurve); shaft = GU_PrimNURBCurve::build(gdpCurve, 4, 4, 0, 1, 1); float start, end; shaft->validRange(start, end); std::cout << "start: " << start << " end: " << end << std::endl; float arcLenCurve = shaft->arcLength(0, 1, 0, 10); std::cout << "arcLenCurve: " << arcLenCurve << std::endl; UT_Vector4 testpos; int test = shaft->evaluatePoint(testpos, 0.5); std::cout << "test: " << test << std::endl; std::cout << "x:" << testpos.x() << " y:" << testpos.y() << " z:" << testpos.z() << std::endl; And all results: start: 0 end: 2 arcLenCurve: 0 test: 0 x:0 y:0 z:0 Bad results. I want to take curve from sops and to create the same curve into my procedural. And than to calculate length of this curve and lengths of its segments. Does anyone know what is wrong? Thanks Quote Link to comment Share on other sites More sharing options...
DoctorBuzz Posted September 17, 2008 Share Posted September 17, 2008 Hi Nasyrov, you can take a look at the GEO_PrimNURBCurve::getKnotLengths(GB_ParmType ptype, UT_FloatArray &lengths) So you should have: UT_FloatArray lengths; float curveLength; curveLength = shaft->getKnotLengths(GB_PARM_CHORD, lengths); I hope this can help you. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.