SpiecsEngine
 
Loading...
Searching...
No Matches

◆ Curve_Node()

static void HoudiniEngine::Curve_Node ( )
static

Definition at line 531 of file HoudiniTestSource.h.

532 {
533 HAPI_Session session;
534
535 HAPI_ThriftServerOptions serverOptions{ 0 };
536 serverOptions.autoClose = true;
537 serverOptions.timeoutMs = 3000.0f;
538
539 HE_CHECK(HAPI_StartThriftNamedPipeServer(&serverOptions, "hapi", nullptr, nullptr))
540
541 HAPI_SessionInfo sessionInfo = HAPI_SessionInfo_Create();
542
543 HE_CHECK(HAPI_CreateThriftNamedPipeSession(&session, "hapi", &sessionInfo))
544
545 HAPI_CookOptions cookOptions = HAPI_CookOptions_Create();
546 HE_CHECK(HAPI_Initialize(&session, &cookOptions, true, -1, nullptr, nullptr, nullptr, nullptr, nullptr))
547
548 HAPI_NodeId curveNode;
549
550 HE_CHECK(HAPI_CreateNode(&session, -1, "sop/curve", "NURBS", false, &curveNode))
551 HE_CHECK(HAPI_CookNode(&session, curveNode, &cookOptions))
552
553 int cookStatus;
554 HAPI_Result cookResult;
555
556 do
557 {
558 cookResult = HAPI_GetStatus(&session, HAPI_STATUS_COOK_STATE, &cookStatus);
559 }
560 while(cookStatus > HAPI_STATE_MAX_READY_STATE && cookResult == HAPI_RESULT_SUCCESS);
561
562 HE_CHECK(cookResult)
563 HE_CHECK_COOK(cookStatus)
564
565 HAPI_NodeInfo curveNodeInfo;
566 HE_CHECK(HAPI_GetNodeInfo(&session, curveNode, &curveNodeInfo))
567
568 std::vector<HAPI_ParmInfo> paramInfos;
569 paramInfos.resize(curveNodeInfo.parmCount);
570 HE_CHECK(HAPI_GetParameters(&session, curveNode, paramInfos.data(), 0, curveNodeInfo.parmCount))
571
572 int coordsParmIndex = -1;
573 int typeParmIndex = -1;
574 for (int i = 0; i < curveNodeInfo.parmCount; i++)
575 {
576 std::string parmName = GetString(session, paramInfos[i].nameSH);
577 if (parmName == "coords")
578 {
579 coordsParmIndex = i;
580 }
581 if (parmName == "type")
582 {
583 typeParmIndex = i;
584 }
585 }
586
587 if (coordsParmIndex == -1 || typeParmIndex == -1)
588 {
589 std::stringstream ss;
590 ss << "Could not find coords/type parameter on curve node";
591
592 SPICES_CORE_WARN(ss.str());
593 HE_CHECK(HAPI_Cleanup(&session))
594 return;
595 }
596
597 HAPI_ParmInfo parm;
598 HE_CHECK(HAPI_GetParameters(&session, curveNode, &parm, typeParmIndex, 1))
599
600 int typeValue = 1;
601 HE_CHECK(HAPI_SetParmIntValues(&session, curveNode, &typeValue, parm.intValuesIndex, 1))
602
603 HE_CHECK(HAPI_GetParameters(&session, curveNode, &parm, coordsParmIndex, 1))
604 HE_CHECK(HAPI_SetParmStringValue(&session, curveNode, "-4, 0, 4, -4, 0, -4, 4, 0, -4, 4, 0, 4", parm.id, 0))
605 HE_CHECK(HAPI_SaveHIPFile(&session, "C:/Users/Administrator/Desktop/Curve_Node.hip", true))
606
607 HE_CHECK(HAPI_Cleanup(&session))
608
609 return;
610 }
#define HE_CHECK_COOK(expr)
HoudiniEngine Check Cook macro. Verify HoudiniEngine Cook API Effectiveness.
Definition HoudiniCore.h:32
#define HE_CHECK(expr)
HoudiniEngine Check macro. Verify HoudiniEngine API Effectiveness.
Definition HoudiniCore.h:17
static std::string GetString(HAPI_Session &session, HAPI_StringHandle stringHandle)