bool CCTPlate3d :: computeLocalCoordinates(FloatArray &answer, const FloatArray &coords) //converts global coordinates to local planar area coordinates, //does not return a coordinate in the thickness direction, but //does check that the point is in the element thickness { // rotate the input point Coordinate System into the element CS FloatArray inputCoords_ElCS; std::vector< FloatArray > lc(3); FloatArray llc; this->giveLocalCoordinates( inputCoords_ElCS, const_cast< FloatArray & >(coords) ); for ( int _i = 0; _i < 3; _i++ ) { this->giveLocalCoordinates( lc [ _i ], * this->giveNode(_i + 1)->giveCoordinates() ); } FEI2dTrLin _interp(1, 2); bool inplane = _interp.global2local(llc, inputCoords_ElCS, FEIVertexListGeometryWrapper(lc)) > 0; answer.resize(2); answer.at(1) = inputCoords_ElCS.at(1); answer.at(2) = inputCoords_ElCS.at(2); GaussPoint _gp(NULL, 1, new FloatArray ( answer ), 2.0, _2dPlate); // now check if the third local coordinate is within the thickness of element bool outofplane = ( fabs( inputCoords_ElCS.at(3) ) <= this->giveCrossSection()->give(CS_Thickness, & _gp) / 2. ); return inplane && outofplane; }
static void _limit(Span *s, int c1, int c2, int nocol) { if (s->x1 < c1) { s->u[0] = _interp(s->x1, s->x2, c1, s->u[0], s->u[1]); s->v[0] = _interp(s->x1, s->x2, c1, s->v[0], s->v[1]); if (!nocol) s->col[0] = _interp_col(s->x1, s->x2, c1, s->col[0], s->col[1]); s->x1 = c1; s->o1 = c1 << FP; // FIXME: do s->z1 } if (s->x2 > c2) { s->u[1] = _interp(s->x1, s->x2, c2, s->u[0], s->u[1]); s->v[1] = _interp(s->x1, s->x2, c2, s->v[0], s->v[1]); if (!nocol) s->col[1] = _interp_col(s->x1, s->x2, c2, s->col[0], s->col[1]); s->x2 = c2; s->o2 = c2 << FP; // FIXME: do s->z2 } }
int CCTPlate3d :: computeLocalCoordinates(FloatArray &answer, const FloatArray &coords) //converts global coordinates to local planar area coordinates, //does not return a coordinate in the thickness direction, but //does check that the point is in the element thickness { // rotate the input point Coordinate System into the element CS FloatArray inputCoords_ElCS; FloatArray lc[3], llc; const FloatArray *lcptr[3] = {lc, lc+1, lc+2}; this->giveLocalCoordinates( inputCoords_ElCS, const_cast< FloatArray & >(coords) ); for (int _i=0; _i<3; _i++) { this->giveLocalCoordinates( lc[_i], *this->giveNode(_i+1)->giveCoordinates()); } FEIVertexListGeometryWrapper wr(3, lcptr); FEI2dTrLin _interp(1,2); bool inplane = _interp.global2local(llc, inputCoords_ElCS, wr); // now check if the thid local coordinate is within the thickness of element bool outofplane = (fabs(inputCoords_ElCS.at(3)) <= this->giveCrossSection()->give(CS_Thickness)/2.); return inplane && outofplane; }
void SDIFfile::_copyInterpolatePartials(const double requestedTime, const long targetIndex1, const long targetIndex2) { Frame *target1 = _frames[targetIndex1]; if (targetIndex1 == targetIndex2 || _equalDouble(requestedTime, target1->time())) { _copyPartials(targetIndex1); return; } Frame *target2 = _frames[targetIndex2]; if (_equalDouble(requestedTime, target2->time())) { _copyPartials(targetIndex2); return; } PartialNode **srcPartials1 = target1->partials(); PartialNode **srcPartials2 = target2->partials(); PartialNode **destPartials = _curFrame->partials(); const int numSrcPartials1 = target1->numPartials(); const int numSrcPartials2 = target2->numPartials(); int numDestPartials = 0; double frac = (requestedTime - target1->time()) / (target2->time() - target1->time()); // Keep track of unfiltered IDs shared between the two frames. const int commonIDsCapacity = numSrcPartials1 + numSrcPartials2; int commonIDs[commonIDsCapacity]; for (int i = 0; i < commonIDsCapacity; i++) commonIDs[i] = -1; int numCommonIDs = 0; // Search frame 1 for unfiltered partials. If one with the same ID is also // in frame 2, interpolate between them and store in destination list. If no // match found, store the frame 1 partial, with amp interpolated from zero. for (int i = 0; i < numSrcPartials1; i++) { PartialNode *partial1 = srcPartials1[i]; const int id = partial1->id(); if (!_filterPartials[id]) { PartialNode *partial2 = target2->partialFromID(id); if (partial2) { // interpolate two partial breakpoints and store result const float freq = _interp(frac, partial1->freq(), partial2->freq()); const float amp = _interp(frac, partial1->amp(), partial2->amp()); //FIXME: how to interpolate phase? const float phase = partial1->phase(); destPartials[numDestPartials++]->set(id, freq, amp, phase); commonIDs[numCommonIDs++] = id; } else { // use only partial1 breakpoint const float amp = _interp(frac, partial1->amp(), 0.0); destPartials[numDestPartials++]->set(id, partial1->freq(), amp, partial1->phase()); } } } // Include any eligible partials from target2 that haven't been used. for (int i = 0; i < numSrcPartials2; i++) { PartialNode *partial2 = srcPartials2[i]; const int id = partial2->id(); if (!_filterPartials[id]) { bool found = false; for (int j = 0; j < numCommonIDs; j++) { if (id == commonIDs[j]) { found = true; break; } } if (!found) { // use only partial2 breakpoint const float amp = _interp(frac, 0.0, partial2->amp()); if (numDestPartials < _maxSimultaneousPartials) { destPartials[numDestPartials++]->set(id, partial2->freq(), amp, partial2->phase()); } } } } _curFrame->numPartials(numDestPartials); _curFrame->time(requestedTime); _filterChanged = false; }