nsresult nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext, nsIDirIndex* aIndex) { nsCOMPtr<nsIRDFResource> parentRes = do_QueryInterface(aContext); if (!parentRes) { NS_ERROR("Could not obtain parent resource"); return(NS_ERROR_UNEXPECTED); } const char* baseStr; parentRes->GetValueConst(&baseStr); if (! baseStr) { NS_ERROR("Could not reconstruct base uri"); return NS_ERROR_UNEXPECTED; } // we found the filename; construct a resource for its entry nsCAutoString entryuriC(baseStr); nsXPIDLCString filename; nsresult rv = aIndex->GetLocation(getter_Copies(filename)); if (NS_FAILED(rv)) return rv; entryuriC.Append(filename); // if its a directory, make sure it ends with a trailing slash. PRUint32 type; rv = aIndex->GetType(&type); if (NS_FAILED(rv)) return rv; PRBool isDirType = (type == nsIDirIndex::TYPE_DIRECTORY); if (isDirType && entryuriC.Last() != '/') { entryuriC.Append('/'); } nsCOMPtr<nsIRDFResource> entry; rv = mDirRDF->GetResource(entryuriC, getter_AddRefs(entry)); // At this point, we'll (hopefully) have found the filename and // constructed a resource for it, stored in entry. So now take a // second pass through the values and add as statements to the RDF // datasource. if (entry && NS_SUCCEEDED(rv)) { nsCOMPtr<nsIRDFLiteral> lit; nsString str; str.AssignWithConversion(entryuriC.get()); rv = mDirRDF->GetLiteral(str.get(), getter_AddRefs(lit)); if (NS_SUCCEEDED(rv)) { rv = Assert(entry, kNC_URL, lit, PR_TRUE); if (NS_FAILED(rv)) return rv; nsXPIDLString xpstr; // description rv = aIndex->GetDescription(getter_Copies(xpstr)); if (NS_FAILED(rv)) return rv; if (xpstr.Last() == '/') xpstr.Truncate(xpstr.Length() - 1); rv = mDirRDF->GetLiteral(xpstr.get(), getter_AddRefs(lit)); if (NS_FAILED(rv)) return rv; rv = Assert(entry, kNC_Description, lit, PR_TRUE); if (NS_FAILED(rv)) return rv; // contentlength PRInt64 size; rv = aIndex->GetSize(&size); if (NS_FAILED(rv)) return rv; PRInt64 minus1 = LL_MAXUINT; if (LL_NE(size, minus1)) { PRInt32 intSize; LL_L2I(intSize, size); // XXX RDF should support 64 bit integers (bug 240160) nsCOMPtr<nsIRDFInt> val; rv = mDirRDF->GetIntLiteral(intSize, getter_AddRefs(val)); if (NS_FAILED(rv)) return rv; rv = Assert(entry, kNC_ContentLength, val, PR_TRUE); if (NS_FAILED(rv)) return rv; } // lastmodified PRTime tm; rv = aIndex->GetLastModified(&tm); if (NS_FAILED(rv)) return rv; if (tm != -1) { nsCOMPtr<nsIRDFDate> val; rv = mDirRDF->GetDateLiteral(tm, getter_AddRefs(val)); if (NS_FAILED(rv)) return rv; rv = Assert(entry, kNC_LastModified, val, PR_TRUE); } // filetype PRUint32 type; rv = aIndex->GetType(&type); switch (type) { case nsIDirIndex::TYPE_UNKNOWN: rv = mDirRDF->GetLiteral(NS_LITERAL_STRING("UNKNOWN").get(), getter_AddRefs(lit)); break; case nsIDirIndex::TYPE_DIRECTORY: rv = mDirRDF->GetLiteral(NS_LITERAL_STRING("DIRECTORY").get(), getter_AddRefs(lit)); break; case nsIDirIndex::TYPE_FILE: rv = mDirRDF->GetLiteral(NS_LITERAL_STRING("FILE").get(), getter_AddRefs(lit)); break; case nsIDirIndex::TYPE_SYMLINK: rv = mDirRDF->GetLiteral(NS_LITERAL_STRING("SYMLINK").get(), getter_AddRefs(lit)); break; } if (NS_FAILED(rv)) return rv; rv = Assert(entry, kNC_FileType, lit, PR_TRUE); if (NS_FAILED(rv)) return rv; } // Since the definition of a directory depends on the protocol, we would have // to do string comparisons all the time. // But we're told if we're a container right here - so save that fact if (isDirType) Assert(entry, kNC_IsContainer, kTrueLiteral, PR_TRUE); else Assert(entry, kNC_IsContainer, kFalseLiteral, PR_TRUE); // instead of // rv = Assert(parentRes, kNC_Child, entry, PR_TRUE); // if (NS_FAILED(rv)) return rv; // defer insertion onto a timer so that the UI isn't starved AddElement(parentRes, kNC_Child, entry); } return rv; }
bool NFCComponentManager::AddComponent(const std::string& strComponentName, NF_SHARE_PTR<NFIComponent> pNewComponent) { return AddElement(strComponentName, pNewComponent); }
InputDialog::InputDialog(std::shared_ptr<n8::Window> p_window, std::string id, int p_x, int p_y, int p_w, int p_h) : AlertDialog(p_window, p_x, p_y, p_w, p_h){ mInputBox = std::make_shared<InputBox>(p_window, id, INPUTBOX_HORIZONTAL_MARGIN, INPUTBOX_VERTICAL_MARGIN, m_w - 2 * INPUTBOX_HORIZONTAL_MARGIN, INPUTBOX_HEIGHT); AddElement(mInputBox); }
void Mesh::Refine() { // reduce 2nd order size_t nb_vertices = ComputeNVertices(); points.resize(nb_vertices); IndexPair_map<PointIndex> between(nb_vertices + 5); size_t oldns = segments.size(); for (size_t si = 0; si < oldns; si++) { const Segment& seg = segments[si]; const MeshPoint& p1 = points[seg[0]]; const MeshPoint& p2 = points[seg[1]]; IndexPair i2(seg[0], seg[1]); i2.Sort(); PointIndex pi_new; if (between.count(i2) == 1) { pi_new = between[i2]; } else { Point2d pnew; pnew.X() = 0.5 * (p1.X() + p2.X()); pnew.Y() = 0.5 * (p1.Y() + p2.Y()); pi_new = AddPoint(pnew); between[i2] = pi_new; } Segment ns1 = seg; Segment ns2 = seg; ns1[1] = pi_new; ns2[0] = pi_new; segments[si] = ns1; AddSegment(ns2); } // refine surface elements size_t oldnf = elements.size(); for (size_t sei = 0; sei < oldnf; sei++) { int j, k; const Element2d& el = elements[sei]; PointIndex pnums[6]; static int betw[3][3] = {{1, 2, 3}, {0, 2, 4}, {0, 1, 5}}; for (j = 0; j < 3; j++) { pnums[j] = el.PointID(j); } for (j = 0; j < 3; j++) { PointIndex pi1 = pnums[betw[j][0]]; PointIndex pi2 = pnums[betw[j][1]]; IndexPair i2(pi1, pi2); i2.Sort(); if (between.count(i2) == 0) { const MeshPoint& p1 = points[pi1]; const MeshPoint& p2 = points[pi2]; Point2d pnew; pnew.X() = 0.5 * (p1.X() + p2.X()); pnew.Y() = 0.5 * (p1.Y() + p2.Y()); between[i2] = AddPoint(pnew); } pnums[3 + j] = between[i2]; } static int reftab[4][3] = {{0, 5, 4}, {1, 3, 5}, {2, 4, 3}, {5, 3, 4}}; DomainIndex ind = el.FaceID(); for (j = 0; j < 4; j++) { Element2d new_element; for (k = 0; k < 3; k++) { new_element.PointID(k) = pnums[reftab[j][k]]; } new_element.SetFaceID(ind); if (j == 0) { elements[sei] = new_element; } else { AddElement(new_element); } } } ComputeNVertices(); RebuildSurfaceElementLists(); }
int main () { hash_table hash_array; hash_table* hash_info = &hash_array; hash_info->size = 256; CreateHash(hash_info); struct timespec start, stop; double worktime; // test AddElement unsigned long j; char tmp[LENGTH] = {0}; if (clock_gettime( CLOCK_REALTIME, &start) == -1) { perror ("clock gettime"); return -1; } for ( j = 0; j < 10000; ++j ) { AddElement(GenerateRandomString(tmp), hash_info); } if (clock_gettime( CLOCK_REALTIME, &stop) == -1) { perror ("clock gettime"); return -1; } worktime = ((( stop.tv_sec - start.tv_sec )*1e9 + ( stop.tv_nsec - start.tv_nsec ))*1e-9)/10000; printf ("%.10f sec for AddElement cycle \n", worktime); // test SearchElement if (clock_gettime( CLOCK_REALTIME, &start) == -1) { perror ("clock gettime"); return -1; } for ( j = 0; j < 10000; ++j ) { SearchElement(GenerateRandomString(tmp), hash_info); } if (clock_gettime( CLOCK_REALTIME, &stop) == -1) { perror( "clock gettime" ); return -1; } worktime = ((( stop.tv_sec - start.tv_sec )*1e9 + ( stop.tv_nsec - start.tv_nsec ))*1e-9)/10000; printf("%.10f sec for SearchElement cycle \n", worktime); // test Remove if (clock_gettime( CLOCK_REALTIME, &start) == -1) { perror( "clock gettime" ); return -1; } int k; for ( j = 0; j < 10000; ++j ) { k = Remove(GenerateRandomString(tmp), hash_info); } if (clock_gettime( CLOCK_REALTIME, &stop) == -1) { perror( "clock gettime" ); return -1; } worktime = ((( stop.tv_sec - start.tv_sec )*1e9 + ( stop.tv_nsec - start.tv_nsec ))*1e-9)/10000; printf ("%.10f sec for Remove cycle \n", worktime); // test CleanMemory if (clock_gettime( CLOCK_REALTIME, &start) == -1) { perror ("clock gettime"); return -1; } for ( j = 0; j < 10000; ++j ) { hash_table hash_array; hash_table* hash_info = &hash_array; hash_info->size = 256; CreateHash(hash_info); CleanMemory(hash_info); } if (clock_gettime( CLOCK_REALTIME, &stop) == -1) { perror( "clock gettime" ); return -1; } worktime = ((( stop.tv_sec - start.tv_sec )*1e9 + ( stop.tv_nsec - start.tv_nsec ))*1e-9)/10000; printf ("%.10f sec for CreateHash and CleanMemory cycle\n", worktime); return 0; }
int CreateRR_GapElements(struct region **reg, struct region **next_reg, struct Element *e, int *psteperiodic, int *ssteperiodic, struct Element *pseblade, struct Element *sseblade, struct Element *pseteperiodic, struct Element *sseteperiodic, struct Element *ewall, struct Element *shroud, int reg_num, int gpreg_num, int offset, int itip, int ishroud #ifdef DEBUG_GAPELEM , struct node **n #endif ) { int i, j, k; int maxreg_num, first, dfine; int elem[8], blelem[8], perielem[8]; int pericount, new_elems, inew_sselems; int *nod0, *nod, *nod0_next, *nod_next; struct Ilist *nodes0; struct region *tmpreg; #ifdef DEBUG_GAPELEM int **elm; char fn[111]; FILE *fp; static int count = 0; sprintf(fn,"rr_gapelem_%02d.txt", count++); if( (fp = fopen(fn,"w+")) == NULL) { fprintf(stderr,"Shit happened opening file '%s'!\n",fn); exit(-1); } fprintf(fp," CreateRR_GapElements %d\n",count); fprintf(fp," offset = %d\n",offset); fprintf(fp," itip = %d, ishroud = %d\n\n",itip, ishroud); fprintf(fp," Elem. ID node IDs\n\n"); #endif new_elems = e->nume; #ifdef DEBUG_GAPELEM fprintf(fp," new_elems = %d\n",new_elems); #endif #ifdef DEBUG if(itip == 0) fprintf(stderr,"\n"); fprintf(stderr,"CreateRR_GapElements: creating tip clearance elements ... "); fflush(stderr); #endif // ************************************************** // create elements in tip clearance region maxreg_num = reg_num + gpreg_num; perielem[5] = perielem[6] = perielem[7] = -1; for(i = reg_num; i < maxreg_num; i++) { if(i == reg_num+1) inew_sselems = e->nume; tmpreg = reg[i]; nodes0 = tmpreg->nodes[0]; nod0 = tmpreg->nodes[tmpreg->numl]->list; nod0_next = next_reg[i]->nodes[next_reg[i]->numl]->list; // le element first = nodes0->list[0] - 1; // index of first chord node nod = nod0; nod_next = nod0_next; elem[0] = *(nod++); elem[1] = *(nod++); elem[2] = *(nod++); elem[3] = *nod; elem[4] = *(nod_next++); elem[5] = *(nod_next++); elem[6] = *(nod_next++); elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif for(j = 1; j < nodes0->num-1; j++) { first += nodes0->list[j-1]; nod = nod0 + first; nod_next = nod0_next + first; dfine = nodes0->list[j+1] - nodes0->list[j]; // discretization is constant if(dfine == 0) { #ifdef DEBUG_GAPELEM fprintf(fp,"dfine = %d\n",dfine); #endif for(k = 0; k < nodes0->list[j]-1; k++) { elem[0] = *nod; nod += nodes0->list[j]; elem[1] = *nod; elem[2] = *(++nod); nod -= nodes0->list[j]; elem[3] = *nod; elem[4] = *nod_next; nod_next += nodes0->list[j]; elem[5] = *nod_next; elem[6] = *(++nod_next); nod_next -= nodes0->list[j]; elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } } // dfine == 0 // discretization changes by +/- 2 nodes else if (dfine == 2) { #ifdef DEBUG_GAPELEM fprintf(fp,"dfine = %d\n",dfine); #endif // first element elem[0] = *(nod - nodes0->list[j]); nod += nodes0->list[j]; elem[1] = *nod; elem[2] = *(++nod); nod -= nodes0->list[j]+1; elem[3] = *nod; elem[4] = *(nod_next - nodes0->list[j]); nod_next += nodes0->list[j]; elem[5] = *nod_next; elem[6] = *(++nod_next); nod_next -= nodes0->list[j]+1; elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif // other elems for(k = 0; k < nodes0->list[j]-1; k++) { elem[0] = *nod; nod += nodes0->list[j]+1; elem[1] = *nod; elem[2] = *(++nod); nod -= nodes0->list[j]+1; elem[3] = *nod; elem[4] = *nod_next; nod_next += nodes0->list[j]+1; elem[5] = *nod_next; elem[6] = *(++nod_next); nod_next -= nodes0->list[j]+1; elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } // last element elem[0] = *nod; nod += nodes0->list[j]+1; elem[1] = *nod; elem[2] = *(++nod); elem[3] = *(nod - nodes0->list[j+1] - nodes0->list[j]); elem[4] = *nod_next; nod_next += nodes0->list[j]+1; elem[5] = *nod_next; elem[6] = *(++nod_next); elem[7] = *(nod_next - nodes0->list[j+1] - nodes0->list[j]); AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } // dfine == 2 else if (dfine == -2) { #ifdef DEBUG_GAPELEM fprintf(fp,"dfine = %d\n",dfine); #endif // first elem. elem[0] = *nod; elem[1] = *(nod + nodes0->list[j] + nodes0->list[j+1]); elem[2] = *(nod + nodes0->list[j]); elem[3] = *(++nod); elem[4] = *nod_next; elem[5] = *(nod_next + nodes0->list[j] + nodes0->list[j+1]); elem[6] = *(nod_next + nodes0->list[j]); elem[7] = *(++nod_next); AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif // others for(k = 1; k < nodes0->list[j]-2; k++) { elem[0] = *nod; nod += nodes0->list[j]-1; elem[1] = *nod; elem[2] = *(++nod); nod -= nodes0->list[j]-1; elem[3] = *nod; elem[4] = *nod_next; nod_next += nodes0->list[j]-1; elem[5] = *nod_next; elem[6] = *(++nod_next); nod_next -= nodes0->list[j]-1; elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } // last elem. elem[0] = *nod; elem[1] = *(nod + nodes0->list[j]-1); elem[2] = *(nod + nodes0->list[j]-1 + nodes0->list[j+1]); elem[3] = *(++nod); elem[4] = *nod_next; elem[5] = *(nod_next + nodes0->list[j]-1); elem[6] = *(nod_next + nodes0->list[j]-1 + nodes0->list[j+1]); elem[7] = *(++nod_next); AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } // dfine == -2 // switch from odd to even (reduction by 1) else if (dfine == -1) { #ifdef DEBUG_GAPELEM fprintf(fp,"dfine = %d\n",dfine); #endif for(k = 0; k < nodes0->list[j+1]-1; k++) { elem[0] = *nod; nod += nodes0->list[j]; elem[1] = *nod; elem[2] = *(++nod); nod -= nodes0->list[j]; elem[3] = *nod; elem[4] = *nod_next; nod_next += nodes0->list[j]; elem[5] = *nod_next; elem[6] = *(++nod_next); nod_next -= nodes0->list[j]; elem[7] = *nod_next; AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } elem[0] = *nod; nod += nodes0->list[j]; elem[1] = *nod; nod += nodes0->list[j+1]; elem[2] = *nod; elem[3] = *(nod - nodes0->list[j+1] - nodes0->list[j] + 1); elem[4] = *nod_next; nod_next += nodes0->list[j]; elem[5] = *nod_next; nod_next += nodes0->list[j+1]; elem[6] = *nod_next; elem[7] = *(nod_next - nodes0->list[j+1] - nodes0->list[j] + 1); AddElement(e, elem); #ifdef DEBUG_GAPELEM fprintf(fp," %8d %8d %8d %8d %8d %8d %8d %8d %8d\n", e->nume-1, elem[0],elem[1],elem[2],elem[3], elem[4],elem[5],elem[6],elem[7]); #endif } // dfine == -1 // other cases are not supported yet! else { #ifdef DEBUG_GAPELEM fprintf(fp,"dfine = %d\n",dfine); #endif fprintf(stderr,"\n invalid change in number of nodes (%d)\n",dfine); fprintf(stderr," on chord no. %d of region no. %d!\n",j+1,i+1); fprintf(stderr," src: %s, line: %d\n\n",__FILE__,__LINE__); exit(-1); } } // end j (number of chords) #ifdef DEBUG_GAPELEM fprintf(fp,"\n\n# ps\n"); #endif } // end i (tip regions) // ************************************************** // determine boundary elements and set boundary conditions new_elems = e->nume - new_elems; fprintf(fp,"\n#\n new_elems = %d, inew_sselems = %d\n",new_elems, inew_sselems); // get blade surface elems. and shroud elems. blelem[5] = blelem[6] = blelem[7] = -1; if(itip == 0) { for(i = e->nume - new_elems; i < e->nume; i++) { blelem[0] = i; blelem[1] = e->e[i][0]; blelem[2] = e->e[i][1]; blelem[4] = e->e[i][2]; blelem[3] = e->e[i][3]; if(i < inew_sselems) AddElement(sseblade, blelem); else AddElement(pseblade, blelem); AddElement(ewall, blelem); } } if(ishroud == 0) { for(i = e->nume - new_elems; i < e->nume; i++) { blelem[0] = i; blelem[1] = e->e[i][4]; blelem[2] = e->e[i][5]; blelem[4] = e->e[i][6]; blelem[3] = e->e[i][7]; AddElement(shroud, blelem); } } // periodic boundaries for(i = e->nume - new_elems; i < e->nume; i++) { blelem[0] = i; pericount = 0; for(j = 0; j < 8; j++) { if(psteperiodic[e->e[i][j]]) { blelem[++pericount] = e->e[i][j]; if(pericount == 4) { AddElement(pseteperiodic, blelem); break; } } if(ssteperiodic[e->e[i][j]]) { blelem[++pericount] = e->e[i][j]; if(pericount == 4) { AddElement(sseteperiodic, blelem); break; } } continue; } } // end i // ************************************************** #ifdef DEBUG_GAPELEM fprintf(fp,"\n\n"); elm = e->e + e->nume-new_elems; fprintf(fp,"# element no. %7d (%8d%8d%8d%8d)\n", e->nume-new_elems+i+1, (*elm)[0]+1, (*elm)[1]+1, (*elm)[2]+1, (*elm)[3]+1); for(j = 0; j < 4; j++) { fprintf(fp,"%8d %16.6f %16.6f %16.6f\n",(*elm)[j]+1, n[(*elm)[j]]->x, n[(*elm)[j]]->y, n[(*elm)[j]]->z); } fprintf(fp,"%8d %16.6f %16.6f %16.6f\n\n",(*elm)[0]+1, n[(*elm)[0]]->x, n[(*elm)[0]]->y, n[(*elm)[0]]->z); elm++; for(i = 1; i < new_elems; i++) { fprintf(fp,"# element no. %7d (%8d%8d%8d%8d)\n", e->nume-new_elems+i+1, (*elm)[0]+1, (*elm)[1]+1, (*elm)[2]+1, (*elm)[3]+1); for(j = 0; j < 4; j++) { fprintf(fp,"%8d %16.6f %16.6f %16.6f\n",(*elm)[j]+1, n[(*elm)[j]]->x, n[(*elm)[j]]->y, n[(*elm)[j]]->z); } fprintf(fp,"\n"); elm++; } if(ishroud == 0) { fprintf(fp,"\n\n"); elm = e->e + e->nume-new_elems; fprintf(fp,"# element no. %7d (%8d%8d%8d%8d)\n", e->nume-new_elems+i+1, (*elm)[0]+1, (*elm)[1]+1, (*elm)[2]+1, (*elm)[3]+1); for(j = 4; j < 8; j++) { fprintf(fp,"%8d %16.6f %16.6f %16.6f\n",(*elm)[j]+1, n[(*elm)[j]]->x, n[(*elm)[j]]->y, n[(*elm)[j]]->z); } fprintf(fp,"%8d %16.6f %16.6f %16.6f\n\n",(*elm)[4]+1, n[(*elm)[4]]->x, n[(*elm)[4]]->y, n[(*elm)[4]]->z); elm++; for(i = 1; i < new_elems; i++) { fprintf(fp,"# element no. %7d (%8d%8d%8d%8d)\n", e->nume-new_elems+i+1, (*elm)[0]+1, (*elm)[1]+1, (*elm)[2]+1, (*elm)[3]+1); for(j = 4; j < 8; j++) { fprintf(fp,"%8d %16.6f %16.6f %16.6f\n",(*elm)[j]+1, n[(*elm)[j]]->x, n[(*elm)[j]]->y, n[(*elm)[j]]->z); } fprintf(fp,"\n"); elm++; } } fclose(fp); #endif #ifdef DEBUG fprintf(stderr,"done!\n"); #endif return (0); }
SourceList2D::SourceList2D(ComputationalMatrix2D* f, InputData* d) { int NumSrc; int GasSource_SX; int GasSource_SY; int GasSource_EX; int GasSource_EY; int GasSourceIndex; int StartSrcIter; FP Msrc; FP Tsrc; FP Tf_src; FP Cp=0.; FP Y_mix[4]; char Str[255]; Source2D* TmpSrc; Table* Cp_cp; Table* Cp_Ox; Table* Cp_Fuel; Table* Cp_air; data = d; F = f; if(data) { Cp_cp = data->GetTable((char*)"Cp_cp"); Cp_Ox = data->GetTable((char*)"Cp_OX"); Cp_Fuel = data->GetTable((char*)"Cp_Fuel"); Cp_air = data->GetTable((char*)"Cp_air"); NumSrc = data->GetIntVal((char*)"NumSrc"); for (int i=0; i< NumSrc;i++ ) { snprintf(Str,255,"Src%i.GasSrcSX",i+1); GasSource_SX = data->GetIntVal(Str); snprintf(Str,255,"Src%i.GasSrcSY",i+1); GasSource_SY = data->GetIntVal(Str); snprintf(Str,255,"Src%i.GasSrcEX",i+1); GasSource_EX = data->GetIntVal(Str); snprintf(Str,255,"Src%i.GasSrcEY",i+1); GasSource_EY = data->GetIntVal(Str); snprintf(Str,255,"Src%i.GasSrcIndex",i+1); GasSourceIndex = data->GetIntVal(Str); snprintf(Str,255,"Src%i.Msrc",i+1); Msrc = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.Tsrc",i+1); Tsrc = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.Tf_src",i+1); Tf_src = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.StartIter",i+1); StartSrcIter = data->GetFloatVal(Str); if ( GasSourceIndex==0 ) // Fuel Cp = Cp_Fuel->GetVal(Tsrc); else if ( GasSourceIndex==1 ) // Ox Cp = Cp_Ox->GetVal(Tsrc); else if ( GasSourceIndex==2 ) // Combustion products Cp = Cp_cp->GetVal(Tsrc); else if ( GasSourceIndex==3 ) // Air Cp = Cp_air->GetVal(Tsrc); else if ( GasSourceIndex==4 ) { // Mixture snprintf(Str,255,"Src%i.Y_fuel",i+1); Y_mix[0] = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.Y_ox",i+1); Y_mix[1] = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.Y_cp",i+1); Y_mix[2] = data->GetFloatVal(Str); snprintf(Str,255,"Src%i.Y_air",i+1); Y_mix[3] = 1 - Y_mix[0] + Y_mix[1] + Y_mix[2]; Cp = Y_mix[0]*Cp_Fuel->GetVal(Tsrc) + Y_mix[1]*Cp_Ox->GetVal(Tsrc) + Y_mix[2]*Cp_cp->GetVal(Tsrc)+ Y_mix[3]*Cp_air->GetVal(Tsrc); } if ( GasSourceIndex > 4 ) { *data->GetMessageStream() << "\nERROR: "; *data->GetMessageStream() << "Error component index" << GasSourceIndex << " in point gas source.\n" << flush; data->GetMessageStream()->flush(); } TmpSrc = new Source2D(F,GasSource_SX,GasSource_SY,GasSource_EX,GasSource_EY,GasSourceIndex,Cp,Msrc,Tsrc,Tf_src,StartSrcIter); AddElement(&TmpSrc); } } }
bool SequenceElements::LoadSequencerFile(xLightsXmlFile& xml_file, const wxString &ShowDir) { mFilename = xml_file; wxXmlDocument& seqDocument = xml_file.GetXmlDocument(); wxXmlNode* root=seqDocument.GetRoot(); std::vector<std::string> effectStrings; std::vector<std::string> colorPalettes; Clear(); for(wxXmlNode* e=root->GetChildren(); e!=NULL; e=e->GetNext() ) { if (e->GetName() == "DisplayElements") { for(wxXmlNode* element=e->GetChildren(); element!=NULL; element=element->GetNext() ) { bool active=false; bool selected=false; bool collapsed=false; std::string name = element->GetAttribute(STR_NAME).ToStdString(); std::string type = element->GetAttribute(STR_TYPE).ToStdString(); bool visible = element->GetAttribute("visible")=='1'?true:false; if (type==STR_TIMING) { active = element->GetAttribute("active")=='1'?true:false; } else { collapsed = element->GetAttribute("collapsed")=='1'?true:false; } if (ElementExists(name)) { log4cpp::Category &logger_base = log4cpp::Category::getInstance(std::string("log_base")); logger_base.warn("Duplicate "+type+": '" + name + "'. Second instance ignored."); wxMessageBox("Duplicate "+type+": '" + name + "'. Second instance ignored.", _("ERROR")); } else { Element* elem = AddElement(name, type, visible, collapsed, active, selected); if (type == STR_TIMING) { std::string views = element->GetAttribute("views", "").ToStdString(); elem->SetViews(views); } } } } else if (e->GetName() == "EffectDB") { effectStrings.clear(); for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() ) { if(elementNode->GetName()==STR_EFFECT) { if (elementNode->GetNodeContent().Find("E_FILEPICKER_Pictures_Filename") >= 0) { elementNode->SetContent(xml_file.FixEffectFileParameter("E_FILEPICKER_Pictures_Filename", elementNode->GetNodeContent(), ShowDir)); } else if (elementNode->GetNodeContent().Find("E_TEXTCTRL_Glediator_Filename") >= 0) { elementNode->SetContent(xml_file.FixEffectFileParameter("E_TEXTCTRL_Glediator_Filename", elementNode->GetNodeContent(), ShowDir)); } effectStrings.push_back(elementNode->GetNodeContent().ToStdString()); } } } else if (e->GetName() == "ColorPalettes") { colorPalettes.clear(); for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() ) { if(elementNode->GetName() == STR_COLORPALETTE) { colorPalettes.push_back(elementNode->GetNodeContent().ToStdString()); } } } else if (e->GetName() == "ElementEffects") { for(wxXmlNode* elementNode=e->GetChildren(); elementNode!=NULL; elementNode=elementNode->GetNext() ) { if(elementNode->GetName()==STR_ELEMENT) { Element* element = GetElement(elementNode->GetAttribute(STR_NAME).ToStdString()); if (element !=NULL) { // check for fixed timing interval int interval = 0; if( elementNode->GetAttribute(STR_TYPE) == STR_TIMING ) { interval = wxAtoi(elementNode->GetAttribute("fixed")); } if( interval > 0 ) { element->SetFixedTiming(interval); EffectLayer* effectLayer = element->AddEffectLayer(); int time = 0; int end_time = xml_file.GetSequenceDurationMS(); int startTime, endTime, next_time; while( time <= end_time ) { next_time = (time + interval <= end_time) ? time + interval : end_time; startTime = TimeLine::RoundToMultipleOfPeriod(time,mFrequency); endTime = TimeLine::RoundToMultipleOfPeriod(next_time,mFrequency); effectLayer->AddEffect(0,"","","",startTime,endTime,EFFECT_NOT_SELECTED,false); time += interval; } } else { for(wxXmlNode* effectLayerNode=elementNode->GetChildren(); effectLayerNode!=NULL; effectLayerNode=effectLayerNode->GetNext()) { if (effectLayerNode->GetName() == STR_EFFECTLAYER || effectLayerNode->GetName() == STR_STRAND) { EffectLayer* effectLayer = NULL; if (effectLayerNode->GetName() == STR_EFFECTLAYER) { effectLayer = element->AddEffectLayer(); } else { effectLayer = element->GetStrandLayer(wxAtoi(effectLayerNode->GetAttribute(STR_INDEX)), true); if (effectLayerNode->GetAttribute(STR_NAME, STR_EMPTY) != STR_EMPTY) { ((StrandLayer*)effectLayer)->SetName(effectLayerNode->GetAttribute(STR_NAME).ToStdString()); } } LoadEffects(effectLayer, elementNode->GetAttribute(STR_TYPE).ToStdString(), effectLayerNode, effectStrings, colorPalettes); } } } } } } } } for (size_t x = 0; x < GetElementCount(); x++) { Element *el = GetElement(x); if (el->GetEffectLayerCount() == 0) { el->AddEffectLayer(); } } // Select view and set current view models as visible int last_view = xml_file.GetLastView(); for(wxXmlNode* view=mViewsNode->GetChildren(); view!=NULL; view=view->GetNext() ) { std::string viewName = view->GetAttribute(STR_NAME).ToStdString(); std::string models = view->GetAttribute("models").ToStdString(); std::vector <Element*> new_view; mAllViews.push_back(new_view); int view_index = mAllViews.size()-1; if( view_index == last_view ) { AddMissingModelsToSequence(models); PopulateView(models, view_index); SetCurrentView(view_index); } } if (mModelsNode != nullptr) { PopulateRowInformation(); } // Set to the first model/view mFirstVisibleModelRow = 0; return true; }