void Draw2D::drawCube(SDL_Surface *screen,Point3D _pt1, Point3D _pt2, Point3D _pt3, Point3D _pt4) { // 4----6 // /| /| // 7----8| // |1---|2 // |/ |/ // 3----5 // with the 4 points we can find the 4 others Point3D pt5 = _pt2+_pt3-_pt1; Point3D pt6 = _pt2+_pt4-_pt1; Point3D pt7 = _pt3+_pt4-_pt1; Point3D pt8 = pt5+_pt4-_pt1; // construct all segments Segment3D seg1(_pt1,_pt2); Segment3D seg2(_pt1,_pt3); Segment3D seg3(_pt1,_pt4); Segment3D seg4(_pt3,pt5); Segment3D seg5(pt5,pt8); Segment3D seg6(pt5,_pt2); Segment3D seg7(_pt3,pt7); Segment3D seg8(_pt2,pt6); Segment3D seg9(pt7,_pt4); Segment3D seg10(_pt4,pt6); Segment3D seg11(pt6,pt8); Segment3D seg12(pt7,pt8); // draw all segments drawSegment(screen,seg1); drawSegment(screen,seg2); drawSegment(screen,seg3); drawSegment(screen,seg4); drawSegment(screen,seg5); drawSegment(screen,seg6); drawSegment(screen,seg7); drawSegment(screen,seg8); drawSegment(screen,seg9); drawSegment(screen,seg10); drawSegment(screen,seg11); drawSegment(screen,seg12); }
void DIGIT::displayMonth(int month) { bool display[8]; switch (month) { case 1: seg0(true); seg1(true); seg2(true); seg3(true); x += 9; seg0(true); seg1(true); seg2(true); seg4(true); seg5(true); seg6(true); seg7(true); x += 9; seg1(true); seg2(true); seg4(true); seg5(true); seg8(true); seg13(true); break; case 2: seg0(true); seg4(true); seg5(true); seg6(true); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); seg6(true); x += 9; for(int i=0; i<8; i++) (this->*ptr[i])(true); break; case 3: seg1(true); seg2(true); seg4(true); seg5(true); seg8(true); seg9(true); x += 9; seg0(true); seg1(true); seg2(true); seg4(true); seg5(true); seg6(true); seg7(true); x += 9; seg0(true); seg1(true); seg4(true); seg5(true); seg6(true); seg7(true); seg13(true); break; case 4: seg0(true); seg1(true); seg2(true); seg4(true); seg5(true); seg6(true); seg7(true); x += 9; seg0(true); seg1(true); seg4(true); seg5(true); seg6(true); seg7(true); seg13(true); x += 9; seg0(true); seg1(true); seg4(true); seg5(true); seg6(true); seg7(true); seg13(true); break; case 5: seg1(true); seg2(true); seg4(true); seg5(true); seg8(true); seg9(true); x += 9; seg0(true); seg1(true); seg2(true); seg4(true); seg5(true); seg6(true); seg7(true); x += 9; seg8(true); seg10(true); seg12(true); break; case 6: seg0(true); seg1(true); seg2(true); seg3(true); x += 9; seg1(true); seg2(true); seg3(true); seg4(true); seg5(true); x += 9; seg1(true); seg2(true); seg4(true); seg5(true); seg8(true); seg13(true); break; case 7: seg0(true); seg1(true); seg2(true); seg3(true); x += 9; seg1(true); seg2(true); seg3(true); seg4(true); seg5(true); x += 9; seg1(true); seg2(true); break; case 8: seg0(true); seg1(true); seg2(true); seg4(true); seg5(true); seg6(true); seg7(true); x += 9; seg1(true); seg2(true); seg3(true); seg4(true); seg5(true); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); seg6(true); break; case 9: lookup(5, display); for(int i=0; i<8; i++) (this->*ptr[i])(display[i]); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); seg6(true); x += 9; seg0(true); seg1(true); seg4(true); seg5(true); seg6(true); seg7(true); seg13(true); break; case 10: lookup(0, display); for(int i=0; i<8; i++) (this->*ptr[i])(display[i]); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); x += 9; seg0(true); seg9(true); seg12(true); break; case 11: seg1(true); seg2(true); seg4(true); seg5(true); seg8(true); seg13(true); x += 9; lookup(0, display); for(int i=0; i<8; i++) (this->*ptr[i])(display[i]); x += 9; seg1(true); seg2(true); seg8(true); seg13(true); break; case 12: lookup(0, display); for(int i=0; i<8; i++) (this->*ptr[i])(display[i]); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); seg6(true); x += 9; seg0(true); seg3(true); seg4(true); seg5(true); break; } }
std::vector<std::string> StrainMeasures::getSixteenSegmentTorsions(double wall_xi) { //The measure of change due to helix rotation between the walls //Setup segments const double base_start = 1.0; const double mid_start = 0.7; const double apex_start = 0.5; const double apex_end = 0.001; const double wall_epi = 1.0; if (wall_xi == 1.0) wall_xi = 0.99; std::vector<WallSegment> segments; //APLAX const double apexAngle = 0.0; //Base WallSegment seg1(3, 7); //Segment 2 seg1.setXIA(apexAngle, 0.5 * (base_start + mid_start), wall_xi); seg1.setXIB(apexAngle, 0.5 * (base_start + mid_start), wall_epi); WallSegment seg2(5, 1); //Segment 5 seg2.setXIA(apexAngle, 0.5 * (base_start + mid_start), wall_xi); seg2.setXIB(apexAngle, 0.5 * (base_start + mid_start), wall_epi); //Mid WallSegment seg3(7, 11); //Segment 8 seg3.setXIA(apexAngle, 0.5 * (mid_start + apex_start), wall_xi); seg3.setXIB(apexAngle, 0.5 * (mid_start + apex_start), wall_epi); WallSegment seg4(5, 9); //Segment 11 seg4.setXIA(apexAngle, 0.5 * (mid_start + apex_start), wall_xi); seg4.setXIB(apexAngle, 0.5 * (mid_start + apex_start), wall_epi); //Apex WallSegment seg5(12, 16); //Segment 13 seg5.setXIA(0.8, 0.5 * (apex_start + apex_end), wall_xi); seg5.setXIB(0.8, 0.5 * (apex_start + apex_end), wall_epi); WallSegment seg6(9, 13); //Segment 15 seg6.setXIA(0.1, 0.5 * (apex_start + apex_end), wall_xi); seg6.setXIB(0.1, 0.5 * (apex_start + apex_end), wall_epi); //TCH const double tchAngle = 2.5 / 3.0; //Base WallSegment tseg1(4, 8); //Segment 3 tseg1.setXIA(tchAngle, 0.5 * (base_start + mid_start), wall_xi); tseg1.setXIB(tchAngle, 0.5 * (base_start + mid_start), wall_epi); WallSegment tseg2(6, 2); //Segment 6 tseg2.setXIA(tchAngle, 0.5 * (base_start + mid_start), wall_xi); tseg2.setXIB(tchAngle, 0.5 * (base_start + mid_start), wall_epi); //Mid WallSegment tseg3(8, 12); //Segment 9 tseg3.setXIA(tchAngle, 0.5 * (mid_start + apex_start), wall_xi); tseg3.setXIB(tchAngle, 0.5 * (mid_start + apex_start), wall_epi); WallSegment tseg4(6, 10); //Segment 12 tseg4.setXIA(tchAngle, 0.5 * (mid_start + apex_start), wall_xi); tseg4.setXIB(tchAngle, 0.5 * (mid_start + apex_start), wall_epi); //Apex WallSegment tseg5(12, 16); //Segment 14 tseg5.setXIA(tchAngle, 0.5 * (apex_start + apex_end), wall_xi); tseg5.setXIB(tchAngle, 0.5 * (apex_start + apex_end), wall_epi); WallSegment tseg6(10, 14); //Segment 16 tseg6.setXIA(tchAngle, 0.5 * (apex_start + apex_end), wall_xi); tseg6.setXIB(tchAngle, 0.5 * (apex_start + apex_end), wall_epi); //FCH const double fchAngle = 1.0 / 3.0; //Base WallSegment fseg1(1, 5); //Segment 4 fseg1.setXIA(fchAngle, 0.5 * (base_start + mid_start), wall_xi); fseg1.setXIB(fchAngle, 0.5 * (base_start + mid_start), wall_epi); WallSegment fseg2(7, 3); //Segment 1 fseg2.setXIA(fchAngle, 0.5 * (base_start + mid_start), wall_xi); fseg2.setXIB(fchAngle, 0.5 * (base_start + mid_start), wall_epi); //Mid WallSegment fseg3(5, 9); //Segment 10 fseg3.setXIA(fchAngle, 0.5 * (mid_start + apex_start), wall_xi); fseg3.setXIB(fchAngle, 0.5 * (mid_start + apex_start), wall_epi); WallSegment fseg4(7, 11); //Segment 7 fseg4.setXIA(fchAngle, 0.5 * (mid_start + apex_start), wall_xi); fseg4.setXIB(fchAngle, 0.5 * (mid_start + apex_start), wall_epi); //Apex WallSegment fseg5(9, 13); //Segment 14+15 fseg5.setXIA(fchAngle, apex_start, wall_xi); fseg5.setXIB(fchAngle, apex_end, wall_epi); WallSegment fseg6(11, 15); //Segment 13+16 fseg6.setXIA(fchAngle, apex_start, wall_xi); fseg6.setXIB(fchAngle, apex_end, wall_epi); segments.clear(); segments.push_back(fseg2); //1 segments.push_back(seg1); //2 segments.push_back(tseg1); //3 segments.push_back(fseg1); //4 segments.push_back(seg2); //5 segments.push_back(tseg2); //6 segments.push_back(fseg4); //7 segments.push_back(seg3); //8 segments.push_back(tseg3); //9 segments.push_back(fseg3); //10 segments.push_back(seg4); //11 segments.push_back(tseg4); //12 segments.push_back(seg5); //13 segments.push_back(tseg5); //14 segments.push_back(seg6); //15 segments.push_back(tseg6); //16 //Setup the active strain segments int aplaxStrainIds[] = { 1, 7, 12, 14, 10, 4 }; int tchStrainIds[] = { 2, 8, 13, 15, 11, 5 }; int fchStrainIds[] = { 0, 6, 9, 3 }; int activeStrainSegments[16]; unsigned int totalActiveSegments = 0; memset(activeStrainSegments, 0, sizeof(int) * 16); for (int i = 0; i < 6; i++) activeStrainSegments[aplaxStrainIds[i]] = 1; totalActiveSegments += 6; for (int i = 0; i < 6; i++) activeStrainSegments[tchStrainIds[i]] = 1; totalActiveSegments += 6; for (int i = 0; i < 4; i++) activeStrainSegments[fchStrainIds[i]] = 1; totalActiveSegments += 4; //Compute the strain for each segment over time unsigned int samples = numberOfModelFrames_; double* length = new double[samples]; double* nstrain = new double[numberOfModelFrames_]; double* avgstrain = new double[numberOfModelFrames_]; double temp_array[3], temp_array1[3]; unsigned int numSegments = segments.size(); memset(avgstrain, 0, numberOfModelFrames_ * sizeof(double)); std::vector<std::string> strains; std::stringstream ss; //Setup the header for (unsigned int i = 0; i < numSegments; i++) { WallSegment& seg = segments[i]; for (unsigned int dt = 0; dt < samples; dt++) { double time = ((double) dt) / (samples - 1.0); Cmiss_field_cache_set_time(fieldCache, time); temp_array1[0] = temp_array1[1] = temp_array1[2] = 0.0; //Since cmiss id starts at 1 subtract 1 from seg.elementid? Cmiss_field_cache_set_mesh_location(fieldCache, elements[seg.elementida - 1], 3, seg.xia); Cmiss_field_evaluate_real(coordianteField, fieldCache, 3, temp_array); Cmiss_field_cache_set_mesh_location(fieldCache, elements[seg.elementida - 1], 3, seg.xib); Cmiss_field_evaluate_real(coordianteField, fieldCache, 3, temp_array1); length[dt] = fabs(temp_array1[2]); } ss << " 0.0"; avgstrain[0] = 0.0; for (unsigned int dt = 1; dt < samples - 1; dt++) { nstrain[dt] = length[dt] - length[0]; ss << "," << nstrain[dt]; avgstrain[dt] += nstrain[dt] * activeStrainSegments[i]; } ss << "," << nstrain[0]; avgstrain[numberOfModelFrames_ - 1] += nstrain[0] * activeStrainSegments[i]; strains.push_back(ss.str()); //Clear the buffer ss.str(""); } ss << avgstrain[0]; for (unsigned int dt = 1; dt < numberOfModelFrames_; dt++) { ss << "," << avgstrain[dt] / totalActiveSegments; } strains.push_back(ss.str()); delete[] length; delete[] nstrain; delete[] avgstrain; return strains; }
std::vector<std::string> StrainMeasures::getSixteenSegmentStrains(std::string fieldName, double wall_xi) { #ifdef printcoord std::cout << "Linear 3D " << fieldName << "\t" << wall_xi << std::endl; #endif std::vector<WallSegment> segments; //APLAX 10 22 34 46 46 40 28 16 4 // 13 9 5 1 1 3 7 11 15 //Base WallSegment seg1(13, 9); seg1.setXIA(0, 1, wall_xi); seg1.setXIB(0, 1, wall_xi); WallSegment seg2(9, 5); seg2.setXIA(0, 1, wall_xi); seg2.setXIB(0, 1, wall_xi); //Mid WallSegment seg3(5, 1); seg3.setXIA(0, 1, wall_xi); seg3.setXIB(0, 1, wall_xi); WallSegment seg4(1, 1); seg4.setXIA(0, 1, wall_xi); seg4.setXIB(0, 0, wall_xi); //Apex WallSegment seg5(1, 3); seg5.setXIA(0, 0, wall_xi); seg5.setXIB(0, 1, wall_xi); WallSegment seg6(3, 7); seg6.setXIA(0, 1, wall_xi); seg6.setXIB(0, 1, wall_xi); WallSegment seg7(7, 11); seg7.setXIA(0, 1, wall_xi); seg7.setXIB(0, 1, wall_xi); WallSegment seg8(11, 15); seg8.setXIA(0, 1, wall_xi); seg8.setXIB(0, 1, wall_xi); //TCH 12 24 36 48 48 42 30 18 6 // 45 41 37 33 33 35 39 43 47 //Base WallSegment tseg1(45, 41); tseg1.setXIA(0, 1, wall_xi); tseg1.setXIB(0, 1, wall_xi); WallSegment tseg2(41, 37); tseg2.setXIA(0, 1, wall_xi); tseg2.setXIB(0, 1, wall_xi); //Mid WallSegment tseg3(37, 33); tseg3.setXIA(0, 1, wall_xi); tseg3.setXIB(0, 1, wall_xi); WallSegment tseg4(33, 33); tseg4.setXIA(0, 1, wall_xi); tseg4.setXIB(0, 0, wall_xi); //Apex WallSegment tseg5(33, 35); tseg5.setXIA(0, 0, wall_xi); tseg5.setXIB(0, 1, wall_xi); WallSegment tseg6(35, 39); tseg6.setXIA(0, 1, wall_xi); tseg6.setXIB(0, 1, wall_xi); WallSegment tseg7(39, 43); tseg7.setXIA(0, 1, wall_xi); tseg7.setXIB(0, 1, wall_xi); WallSegment tseg8(43, 47); tseg8.setXIA(0, 1, wall_xi); tseg8.setXIB(0, 1, wall_xi); //FCH 2 14 26 38 38 44 32 20 8 // 32 28 24 20 20 18 22 26 30 //Base WallSegment fseg1(32, 28); fseg1.setXIA(0, 1, wall_xi); fseg1.setXIB(0, 1, wall_xi); WallSegment fseg2(28, 24); fseg2.setXIA(0, 1, wall_xi); fseg2.setXIB(0, 1, wall_xi); //Mid WallSegment fseg3(24, 20); fseg3.setXIA(0, 1, wall_xi); fseg3.setXIB(0, 1, wall_xi); WallSegment fseg4(20, 20); fseg4.setXIA(0, 1, wall_xi); fseg4.setXIB(0, 0, wall_xi); //Apex WallSegment fseg5(20, 18); fseg5.setXIA(0, 0, wall_xi); fseg5.setXIB(0, 1, wall_xi); WallSegment fseg6(18, 22); fseg6.setXIA(0, 1, wall_xi); fseg6.setXIB(0, 1, wall_xi); WallSegment fseg7(22, 26); fseg7.setXIA(0, 1, wall_xi); fseg7.setXIB(0, 1, wall_xi); WallSegment fseg8(26, 30); fseg8.setXIA(0, 1, wall_xi); fseg8.setXIB(0, 1, wall_xi); segments.clear(); segments.push_back(seg1); segments.push_back(seg2); segments.push_back(seg3); segments.push_back(seg4); segments.push_back(seg5); segments.push_back(seg6); segments.push_back(seg7); segments.push_back(seg8); segments.push_back(tseg1); segments.push_back(tseg2); segments.push_back(tseg3); segments.push_back(tseg4); segments.push_back(tseg5); segments.push_back(tseg6); segments.push_back(tseg7); segments.push_back(tseg8); segments.push_back(fseg1); segments.push_back(fseg2); segments.push_back(fseg3); segments.push_back(fseg4); segments.push_back(fseg5); segments.push_back(fseg6); segments.push_back(fseg7); segments.push_back(fseg8); mySegments = &segments; return getSegmentStrains(fieldName); }