PRIORITY_QUEUE *Create_Priority_Queue(unsigned QSize) { PRIORITY_QUEUE *New; New = (PRIORITY_QUEUE *)POV_MALLOC(sizeof(PRIORITY_QUEUE), "priority queue"); New->Queue = (QELEM *)POV_MALLOC(QSize*sizeof(QELEM), "priority queue"); New->QSize = 0; New->Max_QSize = QSize; return (New); }
void Initialize_VLBuffer_Code() { Node_Queue = (PROJECT_QUEUE *)POV_MALLOC(sizeof(PROJECT_QUEUE), "vista/light buffer node queue"); Node_Queue->QSize = 0; Node_Queue->Max_QSize = INITIAL_NUMBER_OF_ENTRIES; Node_Queue->Queue = (PROJECT_TREE_NODE **)POV_MALLOC(Node_Queue->Max_QSize*sizeof(PROJECT_TREE_NODE *), "vista/light buffer node queue"); VLBuffer_Queue = Create_Priority_Queue(INITIAL_NUMBER_OF_ENTRIES); }
UCS2 *Parser::String_To_UCS2(const char *str) { UCS2 *char_string = nullptr; UCS2 *char_array = nullptr; int char_array_size = 0; int utf8arraysize = 0; unsigned char *utf8array = nullptr; int index_in = 0; int index_out = 0; char *dummy_ptr = nullptr; int i = 0; if(strlen(str) == 0) { char_string = reinterpret_cast<UCS2 *>(POV_MALLOC(sizeof(UCS2), "UCS2 String")); char_string[0] = 0; return char_string; } char_array_size = (int)strlen(str); char_array = reinterpret_cast<UCS2 *>(POV_MALLOC(char_array_size * sizeof(UCS2), "Character Array")); for(i = 0; i < char_array_size; i++) { if(sceneData->EffectiveLanguageVersion() < 350) char_array[i] = (unsigned char)(str[i]); else { char_array[i] = str[i] & 0x007F; if(char_array[i] != str[i]) { char_array[i] = ' '; PossibleError("Unexpected non-ASCII character has been replaced by space character."); } } } char_string = reinterpret_cast<UCS2 *>(POV_MALLOC((char_array_size + 1) * sizeof(UCS2), "UCS2 String")); for(index_in = 0, index_out = 0; index_in < char_array_size; index_in++, index_out++) char_string[index_out] = char_array[index_in]; char_string[index_out] = 0; index_out++; if (char_array != nullptr) POV_FREE(char_array); return char_string; }
CONE *Create_Cylinder() { CONE *New; New = (CONE *)POV_MALLOC(sizeof(CONE), "cone"); INIT_OBJECT_FIELDS(New, CONE_OBJECT, &Cone_Methods) Make_Vector(New->apex, 0.0, 0.0, 1.0); Make_Vector(New->base, 0.0, 0.0, 0.0); New->apex_radius = 1.0; New->base_radius = 1.0; New->dist = 0.0; New->Trans = Create_Transform(); Set_Flag(New, CYLINDER_FLAG); /* This is a cylinder. */ Set_Flag(New, CLOSED_FLAG); /* Has capped ends. */ /* Default bounds */ Make_BBox(New->BBox, -1.0, -1.0, 0.0, 2.0, 2.0, 1.0); return (New); }
SKYSPHERE *Copy_Skysphere(const SKYSPHERE *Old) { int i; SKYSPHERE *New; New = Create_Skysphere(); Destroy_Transform(New->Trans); *New = *Old; New->Trans = Copy_Transform(Old->Trans); if (New->Count > 0) { New->Pigments = reinterpret_cast<PIGMENT **>(POV_MALLOC(New->Count*sizeof(PIGMENT *), "skysphere pigment")); for (i = 0; i < New->Count; i++) { New->Pigments[i] = Copy_Pigment(Old->Pigments[i]); } } return (New); }
PARAMETRIC* Create_Parametric() { PARAMETRIC *New; New = (PARAMETRIC *)POV_MALLOC(sizeof(PARAMETRIC), "parametric"); INIT_OBJECT_FIELDS(New, PARAMETRIC_OBJECT, &Parametric_Methods); Make_Vector(New->container.box.corner1, -1.0, -1.0, -1.0); Make_Vector(New->container.box.corner2, 1.0, 1.0, 1.0); Make_BBox(New->BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); New->Trans = Create_Transform(); New->Function[0] = NULL; New->Function[1] = NULL; New->Function[2] = NULL; New->accuracy = 0.001; New->max_gradient = 1; New->Inverted = false; New->PData = NULL; New->container_shape = 0; return New; }
FUNCTION POVFPU_AddConstant(DBL v) { unsigned int i; if(POVFPU_Consts == NULL) { POVFPU_Consts = (DBL *)POV_MALLOC(sizeof(DBL), "fn: constant floats"); POVFPU_Consts[0] = v; POVFPU_ConstCnt = 1; return 0; } for(i = 0; i < POVFPU_ConstCnt; i++) { if(POVFPU_Consts[i] == v) return (unsigned int)i; } if(POVFPU_ConstCnt == MAX_K) Error("More than %d constants in all functions are not supported.", (int)MAX_K); POVFPU_ConstCnt++; POVFPU_Consts = (DBL *)POV_REALLOC(POVFPU_Consts, sizeof(DBL) * POVFPU_ConstCnt, "fn: constant floats"); POVFPU_Consts[POVFPU_ConstCnt - 1] = v; return POVFPU_ConstCnt - 1; }
UCS2 *Parser::Parse_Substr(bool pathname) { UCS2 *str; UCS2 *New; int l, d; GET(LEFT_PAREN_TOKEN); str = Parse_String(pathname); Parse_Comma(); l = (int)Parse_Float(); Parse_Comma(); d = (int)Parse_Float(); GET(RIGHT_PAREN_TOKEN); if(((l + d - 1) > UCS2_strlen(str)) || (l < 0) || (d < 0)) Error("Illegal parameters in substr."); New = reinterpret_cast<UCS2 *>(POV_MALLOC(sizeof(UCS2) * (d + 1), "temporary string")); UCS2_strncpy(New, &(str[l - 1]), d); New[d] = 0; POV_FREE(str); return New; }
IsoSurface::IsoSurface() : ObjectBase(ISOSURFACE_OBJECT) { container = shared_ptr<ContainedByShape>(new ContainedByBox()); Make_BBox(BBox, -1.0, -1.0, -1.0, 2.0, 2.0, 2.0); Trans = Create_Transform(); Function = NULL; accuracy = 0.001; max_trace = 1; eval_param[0] = 0.0; // 1.1; // not necessary eval_param[1] = 0.0; // 1.4; // not necessary eval_param[2] = 0.0; // 0.99; // not necessary eval = false; closed = true; isCopy = false; max_gradient = 1.1; gradient = 0.0; threshold = 0.0; mginfo = reinterpret_cast<ISO_Max_Gradient *>(POV_MALLOC(sizeof(ISO_Max_Gradient), "isosurface max_gradient info")); mginfo->refcnt = 1; mginfo->max_gradient = 0.0; mginfo->gradient = 0.0; // not really necessary yet [trf] mginfo->eval_max = 0.0; mginfo->eval_cnt = 0.0; mginfo->eval_gradient_sum = 0.0; }
UCS4 *Parser::Convert_UTF8_To_UCS4(const unsigned char *text_array, int text_array_size, int *char_array_size) { UCS4 *char_array = NULL; UCS4 chr; int i, j, k, seqlen; if((text_array == NULL) || (text_array_size == 0) || (char_array_size == NULL)) return NULL; char_array = reinterpret_cast<UCS4 *>(POV_MALLOC(text_array_size * sizeof(UCS4), "Character Array")); if(char_array == NULL) throw POV_EXCEPTION_CODE(kOutOfMemoryErr); for(i = 0, k = 0; i < text_array_size; k++, i++) { seqlen = gUTF8SequenceArray[text_array[i]]; chr = 0; for(j = seqlen; j > 0; j--) { chr += text_array[i]; chr <<= 6; i++; } chr += text_array[i]; char_array[k] = chr - gUTF8Offsets[seqlen]; } char_array = reinterpret_cast<UCS4 *>(POV_REALLOC(char_array, k * sizeof(UCS4), "Character Array")); *char_array_size = k; return char_array; }
TRIANGLE *Create_Triangle() { TRIANGLE *New; New = (TRIANGLE *)POV_MALLOC(sizeof(TRIANGLE), "triangle"); INIT_OBJECT_FIELDS(New,TRIANGLE_OBJECT,&Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE this three points doesn't belong to the normal vector, created above: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis is computed when Parse_Triangle calls * Compute_Triangle. vAxis is used only for smooth triangles. */ return(New); }
SMOOTH_TRIANGLE *Create_Smooth_Triangle() { SMOOTH_TRIANGLE *New; New = (SMOOTH_TRIANGLE *)POV_MALLOC(sizeof(SMOOTH_TRIANGLE), "smooth triangle"); INIT_OBJECT_FIELDS(New,SMOOTH_TRIANGLE_OBJECT,&Smooth_Triangle_Methods) Make_Vector(New->Normal_Vector, 0.0, 1.0, 0.0); New->Distance = 0.0; /* BEG ROSE The normal vectors are not matching the triangle, given by the points: END ROSE */ Make_Vector(New->P1, 0.0, 0.0, 0.0); Make_Vector(New->P2, 1.0, 0.0, 0.0); Make_Vector(New->P3, 0.0, 1.0, 0.0); Make_Vector(New->N1, 0.0, 1.0, 0.0); Make_Vector(New->N2, 0.0, 1.0, 0.0); Make_Vector(New->N3, 0.0, 1.0, 0.0); /* * NOTE: Dominant_Axis and vAxis are computed when * Parse_Triangle calls Compute_Triangle. */ return(New); }
RAINBOW *Create_Rainbow() { RAINBOW *New; New = (RAINBOW *)POV_MALLOC(sizeof(RAINBOW), "fog"); New->Distance = MAX_DISTANCE; New->Jitter = 0.0; New->Angle = 0.0; New->Width = 0.0; New->Falloff_Width = 0.0; New->Arc_Angle = 180.0; New->Falloff_Angle = 180.0; New->Pigment = NULL; Make_Vector(New->Antisolar_Vector, 0.0, 0.0, 0.0); Make_Vector(New->Right_Vector, 1.0, 0.0, 0.0); Make_Vector(New->Up_Vector, 0.0, 1.0, 0.0); New->Next = NULL; return (New); }
BEGIN_POV_NAMESPACE /***************************************************************************** * Local preprocessor defines ******************************************************************************/ /***************************************************************************** * Local typedefs ******************************************************************************/ /***************************************************************************** * Local variables ******************************************************************************/ /***************************************************************************** * Static functions ******************************************************************************/ /***************************************************************************** * * FUNCTION * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ COLOUR *Create_Colour () { COLOUR *New; New = (COLOUR *)POV_MALLOC(sizeof (COLOUR), "color"); Make_ColourA (*New, 0.0, 0.0, 0.0, 0.0, 0.0); return (New); }
BEZIER_NODE *BicubicPatch::create_new_bezier_node() { BEZIER_NODE *Node = reinterpret_cast<BEZIER_NODE *>(POV_MALLOC(sizeof(BEZIER_NODE), "bezier node")); Node->Data_Ptr = NULL; return (Node); }
BEZIER_CHILDREN *BicubicPatch::create_bezier_child_block() { BEZIER_CHILDREN *Children; Children = reinterpret_cast<BEZIER_CHILDREN *>(POV_MALLOC(sizeof(BEZIER_CHILDREN), "bezier children")); return (Children); }
BEZIER_VERTICES *BicubicPatch::create_bezier_vertex_block() { BEZIER_VERTICES *Vertices; Vertices = reinterpret_cast<BEZIER_VERTICES *>(POV_MALLOC(sizeof(BEZIER_VERTICES), "bezier vertices")); return (Vertices); }
static BEZIER_VERTICES *create_bezier_vertex_block() { BEZIER_VERTICES *Vertices; Vertices = (BEZIER_VERTICES *)POV_MALLOC(sizeof(BEZIER_VERTICES), "bezier vertices"); return (Vertices); }
FPUContext *POVFPU_NewContext() { FPUContext *context = (FPUContext *)POV_MALLOC(sizeof(FPUContext), "fn: context"); context->next = POVFPU_Context_Root; context->maxdblstacksize = 256; context->dblstackbase = (DBL *)POV_MALLOC(sizeof(DBL) * context->maxdblstacksize, "fn: dblstack"); context->pstackbase = (StackFrame *)POV_MALLOC(sizeof(StackFrame) * MAX_CALL_STACK_SIZE, "fn: pstack"); #if (SYS_FUNCTIONS == 1) context->dblstack = context->dblstackbase; #endif POVFPU_Context_Root = context; return context; }
static BEZIER_CHILDREN *create_bezier_child_block() { BEZIER_CHILDREN *Children; Children = (BEZIER_CHILDREN *)POV_MALLOC(sizeof(BEZIER_CHILDREN), "bezier children"); return (Children); }
UCS2 *Parser::UCS2_strdup(const UCS2 *s) { UCS2 *New; New=reinterpret_cast<UCS2 *>(POV_MALLOC((UCS2_strlen(s)+1) * sizeof(UCS2), UCS2toASCIIString(s).c_str())); UCS2_strcpy(New,s); return (New); }
char *pov_strdup(const char *s) { char *New; New=reinterpret_cast<char *>(POV_MALLOC(strlen(s)+1,s)); strcpy(New,s); return (New); }
char *pov_strdup(const char *s) { char *New; New=(char *)POV_MALLOC(strlen(s)+1,s); strcpy(New,s); return (New); }
SPLINE * Copy_Spline(SPLINE * Old) { SPLINE * New; New = (SPLINE *)POV_MALLOC(sizeof(SPLINE), "spline"); New->SplineEntries = (SPLINE_ENTRY *)POV_MALLOC(Old->Number_Of_Entries*sizeof(SPLINE_ENTRY), "spline entry"); POV_MEMCPY(New->SplineEntries, Old->SplineEntries, Old->Number_Of_Entries*sizeof(SPLINE_ENTRY)); New->Max_Entries = Old->Number_Of_Entries; New->Number_Of_Entries = Old->Number_Of_Entries; New->Type = Old->Type; New->Coeffs_Computed = Old->Coeffs_Computed; New->Terms = Old->Terms; New->Cache_Valid = false; // we don't copy the cache so mark it as invalid return New; }
static BEZIER_NODE *create_new_bezier_node() { BEZIER_NODE *Node = (BEZIER_NODE *)POV_MALLOC(sizeof(BEZIER_NODE), "bezier node"); Node->Data_Ptr = NULL; return (Node); }
void Fractal::Allocate_Iteration_Stack(DBL **IStack, int Len) { Free_Iteration_Stack(IStack); if (Len == 0) return ; const int len = (Len + 1) * sizeof(DBL); for (int i = 0 ; i < 4 ; i++) IStack [i] = reinterpret_cast<DBL *>(POV_MALLOC(len, "fractal iteration stack")); }
BBOX_TREE *create_bbox_node(int size) { BBOX_TREE *New; New = reinterpret_cast<BBOX_TREE *>(POV_MALLOC(sizeof(BBOX_TREE), "bounding box node")); New->Infinite = false; New->Entries = size; Make_BBox(New->BBox, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); if(size) New->Node = reinterpret_cast<BBOX_TREE **>(POV_MALLOC(size*sizeof(BBOX_TREE *), "bounding box node")); else New->Node = NULL; return (New); }
FUNCTION_PTR Parser::Copy_Function(FunctionVM *functionVM, FUNCTION_PTR Function) { FUNCTION_PTR ptr = (FUNCTION_PTR)POV_MALLOC(sizeof(FUNCTION), "Function ID"); functionVM->GetFunctionAndReference(*Function); // increase the reference count *ptr = *Function; return ptr; }
SPLINE * Create_Spline(int Type) { SPLINE * New; New = (SPLINE *)POV_MALLOC(sizeof(SPLINE), "spline"); New->SplineEntries = (SPLINE_ENTRY *)POV_MALLOC(INIT_SPLINE_SIZE*sizeof(SPLINE_ENTRY), "spline entry"); New->Max_Entries = INIT_SPLINE_SIZE; New->Number_Of_Entries = 0; New->Type = Type; New->Coeffs_Computed = false; New->Terms = 2; New->Cache_Valid = false; int i; for (i=0; i< New->Max_Entries; i++) { New->SplineEntries[i].par=-1e6; //this should be a negative large number } return New; }
DBL *Create_Float () { DBL *New_Float; New_Float = (DBL *)POV_MALLOC(sizeof (DBL), "float"); *New_Float = 0.0; return (New_Float); }