void Precompute_Patch_Values(BICUBIC_PATCH *Shape) { int i, j; VECTOR Control_Points[16]; VECTOR(*Patch_Ptr)[4][4] = (VECTOR(*)[4][4]) Shape->Control_Points; int max_depth_reached = 0; /* Calculate the bounding sphere for the entire patch. */ for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { Assign_Vector(Control_Points[4*i + j], Shape->Control_Points[i][j]); } } find_average(16, Control_Points, Shape->Bounding_Sphere_Center, &Shape->Bounding_Sphere_Radius); if (Shape->Patch_Type == 1) { if (Shape->Node_Tree != NULL) { bezier_tree_deleter(Shape->Node_Tree); } Shape->Node_Tree = bezier_tree_builder(Shape, Patch_Ptr, 0.0, 1.0, 0.0, 1.0, 0, max_depth_reached); } }
void BicubicPatch::bezier_tree_deleter(BEZIER_NODE *Node) { int i; BEZIER_CHILDREN *Children; /* If this is an interior node then continue the descent. */ if (Node->Node_Type == BEZIER_INTERIOR_NODE) { Children = reinterpret_cast<BEZIER_CHILDREN *>(Node->Data_Ptr); for (i = 0; i < Node->Count; i++) { bezier_tree_deleter(Children->Children[i]); } POV_FREE(Children); } else { if (Node->Node_Type == BEZIER_LEAF_NODE) { /* Free the memory used for the vertices. */ POV_FREE(Node->Data_Ptr); } } /* Free the memory used for the node. */ POV_FREE(Node); }
BicubicPatch::~BicubicPatch() { if (Patch_Type == 1) { if (Node_Tree != NULL) { bezier_tree_deleter(Node_Tree); } } if (Weights != NULL) POV_FREE(Weights); }
void BicubicPatch::Precompute_Patch_Values() { int max_depth_reached = 0; if (Patch_Type == 1) { if (Node_Tree != NULL) { bezier_tree_deleter(Node_Tree); } Node_Tree = bezier_tree_builder(&Control_Points, 0.0, 1.0, 0.0, 1.0, 0, max_depth_reached); } }
static void Destroy_Bicubic_Patch(OBJECT *Object) { BICUBIC_PATCH *Patch; Patch = (BICUBIC_PATCH *)Object; if (Patch->Patch_Type == 1) { if (Patch->Node_Tree != NULL) { bezier_tree_deleter(Patch->Node_Tree); } } if ( Patch->Weights != NULL ) POV_FREE(Patch->Weights); POV_FREE(Patch); }