void transform_render() { glClear(GL_COLOR_BUFFER_BIT); // clear the screen glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); camera->Update(); glPushMatrix(); //transform entire scene doTransform( pTransInfo[0] ); glutWireCube(1.0); glPushMatrix(); doTransform( pTransInfo[1] ); glutWireSphere(0.50, 10, 8); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[2] ); glutWireCone(0.2, 0.5, 10, 8); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[3] ); glutSolidTeapot(0.2); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[4] ); glutWireTorus(0.1, 0.3, 10,10); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[5] ); glutWireDodecahedron(); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[6] ); glutWireCube(0.25); glPopMatrix(); glPushMatrix(); doTransform( pTransInfo[7] ); gluCylinder(qobj, 0.2, 0.2, 0.4, 8,8); glPopMatrix(); glPopMatrix(); // refresh image glutSwapBuffers(); glutPostRedisplay(); }
void ProcessorPointPatchField <PatchField, Mesh, PointPatch, ProcessorPointPatch, MatrixType, Type>:: evaluate ( const Pstream::commsTypes commsType ) { if (this->isPointField()) { // Get the neighbour side values tmp<Field<Type> > tpNeighbour = receivePointField<Type>(commsType); Field<Type>& tpn = tpNeighbour(); if (doTransform()) { const processorPolyPatch& ppp = procPatch_.procPolyPatch(); const tensorField& forwardT = ppp.forwardT(); transform(tpn, forwardT[0], tpn); } // Average over two sides tpn = 0.5*(patchInternalField(this->internalField()) + tpn); // Get internal field to insert values into Field<Type>& iF = const_cast<Field<Type>&>(this->internalField()); this->setInInternalField(iF, tpn); } }
void Foam::processorFvPatchField<Type>::evaluate ( const Pstream::commsTypes commsType ) { if (Pstream::parRun()) { if (commsType == Pstream::nonBlocking && !Pstream::floatTransfer) { // Fast path. Received into *this if ( outstandingRecvRequest_ >= 0 && outstandingRecvRequest_ < Pstream::nRequests() ) { UPstream::waitRequest(outstandingRecvRequest_); } outstandingSendRequest_ = -1; outstandingRecvRequest_ = -1; } else { procPatch_.compressedReceive<Type>(commsType, *this); } if (doTransform()) { transform(*this, procPatch_.getForwardT(), *this); } } }
void Foam::processorCyclicPointPatchField<Type>::swapAddSeparated ( const Pstream::commsTypes commsType, Field<Type>& pField ) const { if (Pstream::parRun()) { Field<Type> pnf(this->size()); IPstream::read ( commsType, procPatch_.neighbProcNo(), reinterpret_cast<char*>(pnf.begin()), pnf.byteSize(), procPatch_.tag() ); if (doTransform()) { const processorCyclicPolyPatch& ppp = procPatch_.procCyclicPolyPatch(); const tensor& forwardT = ppp.forwardT()[0]; transform(pnf, forwardT, pnf); } // All points are separated this->addToInternalField(pField, pnf); } }
bool MdpCtrl::set() { //deferred calcs, so APIs could be called in any order. doTransform(); utils::Whf whf = getSrcWhf(); if(utils::isYuv(whf.format)) { normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w); normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h); utils::even_floor(mOVInfo.dst_rect.w); utils::even_floor(mOVInfo.dst_rect.h); } if(this->ovChanged()) { if(!mdp_wrapper::setOverlay(mFd.getFD(), mOVInfo)) { ALOGE("MdpCtrl failed to setOverlay, restoring last known " "good ov info"); mdp_wrapper::dump("== Bad OVInfo is: ", mOVInfo); mdp_wrapper::dump("== Last good known OVInfo is: ", mLkgo); this->restore(); return false; } this->save(); } return true; }
void DotBuilder::doElement(ASTElement* element) { switch (element->getElementType()) { case MELEMENT_BLOCK: doBlock(reinterpret_cast<ASTBlock*>(element)); break; case MELEMENT_CONSTANT: doConstant(reinterpret_cast<ASTConstant*>(element)); break; case MELEMENT_VARIABLE: doVariable(reinterpret_cast<ASTVariable*>(element)); break; case MELEMENT_OPERATOR: doOperator(reinterpret_cast<ASTOperator*>(element)); break; case MELEMENT_CALL: doCall(reinterpret_cast<ASTCall*>(element)); break; case MELEMENT_TRANSFORM: doTransform(reinterpret_cast<ASTTransform*>(element)); break; default: MP_ASSERT_NOT_REACHED(); } }
PhotoKitView::PhotoKitView(QWidget *parent) : QGraphicsView(parent),mPressed(false),mMachine(0),mCanTransform(true),mZoomOnMove(false) { //setDragMode(QGraphicsView::NoDrag); //setAlignment(Qt::AlignBottom); //setTransformationAnchor(QGraphicsView::AnchorUnderMouse); setTransformationAnchor(QGraphicsView::AnchorViewCenter); setResizeAnchor(QGraphicsView::AnchorUnderMouse); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //TODO: always on when debug. setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); //setBackgroundBrush(QBrush(Qt::gray)); mScene = new PhotoKitScene(this); setRenderingSystem(); mScene->setSceneRect(qApp->desktop()->rect()); setScene(mScene); mMachine = new TransformMachine;//QGraphicsItemAnimation; connect(mMachine, SIGNAL(transformChanged(QTransform)), SLOT(doTransform(QTransform))); QTimeLine *timer = new QTimeLine(kAniDuration); timer->setEasingCurve(QEasingCurve::OutQuad); timer->setFrameRange(0, 100); mMachine->setTimeLine(timer); }
bool MdpCtrl::set() { int mdpVersion = MDPVersion::getInstance().getMDPVersion(); //deferred calcs, so APIs could be called in any order. doTransform(); utils::Whf whf = getSrcWhf(); if(utils::isYuv(whf.format)) { utils::normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w); utils::normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h); if(mdpVersion < MDSS_V5) { utils::even_floor(mOVInfo.dst_rect.w); utils::even_floor(mOVInfo.dst_rect.h); } else if (mOVInfo.flags & MDP_DEINTERLACE) { // For interlaced, crop.h should be 4-aligned if (!(mOVInfo.flags & MDP_SOURCE_ROTATED_90) && (mOVInfo.src_rect.h % 4)) mOVInfo.src_rect.h = utils::aligndown(mOVInfo.src_rect.h, 4); // For interlaced, width must be multiple of 4 when rotated 90deg. else if ((mOVInfo.flags & MDP_SOURCE_ROTATED_90) && (mOVInfo.src_rect.w % 4)) mOVInfo.src_rect.w = utils::aligndown(mOVInfo.src_rect.w, 4); } } else { if (mdpVersion >= MDSS_V5) { // Check for 1-pixel down-scaling if (mOVInfo.src_rect.w - mOVInfo.dst_rect.w == 1) mOVInfo.src_rect.w -= 1; if (mOVInfo.src_rect.h - mOVInfo.dst_rect.h == 1) mOVInfo.src_rect.h -= 1; } } doDownscale(); return true; }
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField() const { const Field<Type>& iField = this->primitiveField(); const labelUList& nbrFaceCells = cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells(); Field<Type> pnf(iField, nbrFaceCells); tmp<Field<Type>> tpnf; if (cyclicAMIPatch_.applyLowWeightCorrection()) { tpnf = cyclicAMIPatch_.interpolate(pnf, this->patchInternalField()()); } else { tpnf = cyclicAMIPatch_.interpolate(pnf); } if (doTransform()) { tpnf.ref() = transform(forwardT(), tpnf()); } return tpnf; }
void Buggy::drawModel(float yRot, float xRot, float x, float y, float z) { float f[3]; f[0] = 0; f[1] = 0; f[2] = 0; //Draw the saved model if (_model != NULL) { glPushMatrix(); glTranslatef(x, y, z); doTransform(f, R); drawArrow(); glRotatef(-180.0f, 1.0f, 0.0f, 0.0f); //glRotatef(yRot, 0.0f, 1.0f, 0.0f); //glRotatef(xRot, 1.0f, 0.0f, 0.0f); //doMaterial(); _model->draw(); glPopMatrix(); } else { printf ("model is null\n"); } }
Foam::tmp<Foam::gpuField<Type> > Foam::cyclicACMIFvPatchField<Type>::patchNeighbourField() const { const gpuField<Type>& iField = this->internalField(); const labelgpuList& nbrFaceCellsCoupled = cyclicACMIPatch_.cyclicACMIPatch().neighbPatch().getFaceCells(); const labelgpuList& faceCellsNonOverlap = cyclicACMIPatch_.cyclicACMIPatch().nonOverlapPatch().getFaceCells(); gpuField<Type> pnfCoupled(iField, nbrFaceCellsCoupled); gpuField<Type> pfNonOverlap(iField, faceCellsNonOverlap); tmp<gpuField<Type> > tpnf ( new gpuField<Type> ( cyclicACMIPatch_.interpolate ( pnfCoupled, pfNonOverlap ) ) ); if (doTransform()) { tpnf() = transform(getForwardT(), tpnf()); } return tpnf; }
/** * Transform will apply the stylesheet source to the parsed xml source * and write the transformation output to the target. * * @param theParsedXML the parsed input source * @param theStylesheetSource stylesheet source * @param theResultTarget output source * @return 0 for success */ int transform( const XalanParsedSource& theParsedXML, const XSLTInputSource& theStylesheetSource, const XSLTResultTarget& theResultTarget) { return doTransform(theParsedXML, 0, &theStylesheetSource, theResultTarget); }
/** * Transform will apply the compiled stylesheet to the parsed xml source * and write the transformation output to the target. * * @param theParsedXML the parsed input source * @param theCompiledStylesheet pointer to a compiled stylesheet. Must not be null. * @param theResultTarget output source * @return 0 for success */ int transform( const XalanParsedSource& theParsedXML, const XalanCompiledStylesheet* theCompiledStylesheet, const XSLTResultTarget& theResultTarget) { assert(theCompiledStylesheet != 0); return doTransform(theParsedXML, theCompiledStylesheet, 0, theResultTarget); }
bool MdssRot::commit() { doTransform(); mRotInfo.flags |= MDSS_MDP_ROT_ONLY; if(!overlay::mdp_wrapper::setOverlay(mFd.getFD(), mRotInfo)) { ALOGE("MdssRot commit failed!"); dump(); return false; } mRotData.id = mRotInfo.id; return true; }
AREXPORT void ArTransform::doTransform(std::list<ArPoseWithTime *> *poseList) { std::list<ArPoseWithTime *>::iterator it; ArPoseWithTime *pose; for (it = poseList->begin(); it != poseList->end(); it++) { pose = (*it); *pose = doTransform(*pose); } }
/*! Renders a Drawable instance using OpenGL. */ void RendererGL::render(boost::shared_ptr<Drawable> pDrawable) const { std::string MeshName = pDrawable->getMeshName(); DeformableGeometry* pMesh = MeshManager::getInstance()->getMesh(MeshName); if(!pMesh) return; glPushMatrix(); glMultMatrixf(m_globalTransform.getLocalTransform()); if(pDrawable->needUpdate()) { if (pDrawable->getBinding() == "LeftEye") { Vector3 eye = pDrawable->getPivot(); //double eyePos[3] = { -33.8, -33.2, -28.8 }; glTranslatef (-eye.x, -eye.y, -eye.z); glRotatef (pDrawable->getAPs()[24], 0.0, 1.0, 0.0); glRotatef (pDrawable->getAPs()[22], 1.0, 0.0, 0.0); glTranslatef (eye.x, eye.y, eye.z); } if (pDrawable->getBinding() == "RightEye") { Vector3 eye = pDrawable->getPivot(); ///double eyePos[3] = { 33.8, -33.2, -28.8 }; glTranslatef (-eye.x, -eye.y, -eye.z); glRotatef (pDrawable->getAPs()[25], 0.0, 1.0, 0.0); glRotatef (pDrawable->getAPs()[23], 1.0, 0.0, 0.0); glTranslatef (eye.x, eye.y, eye.z); } pDrawable->updateAnimation(); } doTransform(pDrawable->getTransform()); if(pDrawable->isTextureOn()) { const ITexture* pTexture = TextureManager::getInstance()->getTexture(pDrawable->getTexName()); if(pTexture) doTexture(*pTexture); } doGeometry(*pMesh); glBindTexture(GL_TEXTURE_2D, 0); glPopMatrix(); }
bool MdssRot::commit() { doTransform(); mRotInfo.flags |= MDSS_MDP_ROT_ONLY; if(!overlay::mdp_wrapper::setOverlay(mFd.getFD(), mRotInfo)) { ALOGE("MdssRot commit failed!"); dump(); return false; } mRotData.id = mRotInfo.id; // reset rotation flags to avoid stale orientation values mRotInfo.flags &= ~MDSS_ROT_MASK; return true; }
void processorFvPatchField<Type>::evaluate ( const Pstream::commsTypes commsType ) { if (Pstream::parRun()) { procPatch_.compressedReceive<Type>(commsType, *this); if (doTransform()) { transform(*this, procPatch_.forwardT(), *this); } } }
bool MdpRot::commit() { doTransform(); if(rotConfChanged()) { mRotImgInfo.enable = 1; if(!overlay::mdp_wrapper::startRotator(mFd.getFD(), mRotImgInfo)) { ALOGE("MdpRot commit failed"); dump(); mRotImgInfo.enable = 0; return false; } save(); mRotDataInfo.session_id = mRotImgInfo.session_id; } return true; }
bool MdpCtrl::set() { //deferred calcs, so APIs could be called in any order. doTransform(); if(this->ovChanged()) { if(!mdp_wrapper::setOverlay(mFd.getFD(), mOVInfo)) { ALOGE("MdpCtrl failed to setOverlay, restoring last known " "good ov info"); mdp_wrapper::dump("== Bad OVInfo is: ", mOVInfo); mdp_wrapper::dump("== Last good known OVInfo is: ", mLkgo); this->restore(); return false; } this->save(); } return true; }
void Foam::processorLduInterfaceField::transformCoupleField ( scalarField& f, const direction cmpt ) const { if (doTransform()) { if (forwardT().size() == 1) { f *= pow(diag(forwardT()[0]).component(cmpt), rank()); } else { f *= pow(diag(forwardT())().component(cmpt), rank()); } } }
void Balaenidae::drawModel(float yRot, float xRot, float x, float y, float z) { float f[3]; f[0] = 0; f[1] = 0; f[2] = 0; //Draw the saved model if (_model != NULL) { glPushMatrix(); glTranslatef(x, y, z); glScalef(50.0f,20.0f,50.0f); doTransform(f, R); //drawArrow(); //drawArrow(S[0],S[1],S[2],1.0,0.0,0.0); //drawArrow(V[0],V[1],V[2],0.0,1.0,0.0); //drawRectangularBox(100.0f/50.0f, 40.0f/20.0f, 500.f/50.0f); glRotatef(-180.0f, 1.0f, 0.0f, 0.0f); glRotatef(-180.0f, 0.0f, 0.0f, 1.0f); glRotatef(-90.0f, 0.0f, 1.0f, 0.0f); glRotatef(-180.0f, 0.0f, 1.0f, 0.0f); //glRotatef(yRot, 0.0f, 0.0f, 1.0f); //glRotatef(xRot, 1.0f, 0.0f, 0.0f); _model->draw(); //glTranslatef(-0.4f,0.62f,-0.5f); //drawTheRectangularBox(_textureRoad,8.0f, 1.0f, 1.0f); glPopMatrix(); } else { printf ("model is null\n"); } }
void Foam::cyclicLduInterfaceField::transformCoupleField ( scalarField& pnf, const direction cmpt ) const { if (doTransform()) { label sizeby2 = pnf.size()/2; scalar forwardScale = pow(diag(forwardT()[0]).component(cmpt), rank()); scalar reverseScale = pow(diag(reverseT()[0]).component(cmpt), rank()); for (label facei=0; facei<sizeby2; facei++) { pnf[facei] *= forwardScale; pnf[facei + sizeby2] *= reverseScale; } } }
tmp<Field<Type> > cyclicFvPatchField<Type>::patchNeighbourField() const { const Field<Type>& iField = this->internalField(); const unallocLabelList& faceCells = cyclicPatch_.faceCells(); tmp<Field<Type> > tpnf(new Field<Type>(this->size())); Field<Type>& pnf = tpnf(); label sizeby2 = this->size()/2; if (doTransform()) { for (label facei=0; facei<sizeby2; facei++) { pnf[facei] = transform ( forwardT()[0], iField[faceCells[facei + sizeby2]] ); pnf[facei + sizeby2] = transform ( reverseT()[0], iField[faceCells[facei]] ); } } else { for (label facei=0; facei<sizeby2; facei++) { pnf[facei] = iField[faceCells[facei + sizeby2]]; pnf[facei + sizeby2] = iField[faceCells[facei]]; } } return tpnf; }
void CTransform<S, D>::Transform(CImage<S> * src, CImage<D> * dst) { m_timer.start(); doTransform(src, dst); m_timer.stop(); }
void InverseBWTransform::doTransform(BWTBlock& block) { byte *data = block.begin(); *block.end() = data[block.LFpowers()[0]]; doTransform(block.begin(), block.size()+1, block.LFpowers()); }
OsStatus MappingRulesUrlMapping::parsePermMatchContainer(const Url& requestUri, const UtlString& vdigits, ResultSet& rContactResultSet, ResultSet& rPermissions, UtlString& callTag, const TiXmlNode* pUserMatchNode //parent node ) const { OsStatus doTransformStatus = OS_FAILED; UtlBoolean bPermissionFound = false; UtlString requestUriStr; callTag = "UNK"; requestUri.toString(requestUriStr); const TiXmlNode* pPermMatchNode = NULL; while ( (pPermMatchNode = pUserMatchNode->IterateChildren( pPermMatchNode ) ) && (doTransformStatus != OS_SUCCESS) ) { if(pPermMatchNode && pPermMatchNode->Type() == TiXmlNode::ELEMENT) { UtlString tagValue = pPermMatchNode->Value(); if( tagValue.compareTo(XML_TAG_CALLTAG) == 0 ) { // Found call tag element. Read the text value for it. textContentShallow(callTag, pPermMatchNode); } if( tagValue.compareTo(XML_TAG_PERMISSIONMATCH) == 0 ) { //practically there should always be only one permission match tag const TiXmlElement* pPermissionMatchElement = pPermMatchNode->ToElement(); UtlBoolean bPermNodePresent = false; //get the user text value from it for( const TiXmlNode* pPermissionNode = pPermissionMatchElement->FirstChild( XML_TAG_PERMISSION ); pPermissionNode; pPermissionNode = pPermissionNode->NextSibling( XML_TAG_PERMISSION ) ) { bPermNodePresent = true; const TiXmlElement* pPermissionElement = pPermissionNode->ToElement(); //get permission Name const TiXmlNode* pPermissionText = pPermissionElement->FirstChild(); if(pPermissionText) { UtlString permission = pPermissionText->Value(); UtlHashMap record; UtlString* pIdentityKey = new UtlString ( "identity" ); UtlString* pPermissionKey = new UtlString ( "permission" ); UtlString* pIdentityValue = new UtlString ( requestUriStr ); UtlString* pPermissionValue = new UtlString ( permission ); record.insertKeyAndValue ( pIdentityKey, pIdentityValue ); record.insertKeyAndValue ( pPermissionKey, pPermissionValue ); rPermissions.addValue(record); bPermissionFound = true; } } //if no permission node - then it means no permission required - allow all if((!bPermNodePresent || bPermissionFound ) ) { //if the premission matches in the permissions database //go ahead and get the transform tag doTransformStatus = doTransform(requestUri, vdigits, rContactResultSet, pPermMatchNode); } } } } return doTransformStatus; }
forAll (masterPatch_, faceMi) { // First, we make sure that all the master faces points are // recomputed onto the 2D plane defined by the master faces // normals. // For triangles, this is useless, but for N-gons // with more than 3 points, this is essential. // The intersection between the master and slave faces will be // done in these 2D reference frames // A few basic information to keep close-by vector currentMasterFaceNormal = masterPatchNormals[faceMi]; vector currentMasterFaceCentre = masterPatch_[faceMi].centre(masterPatchPoints); scalarField facePolygonErrorProjection; // Project the master faces points onto the normal face plane to // form a flattened polygon masterFace2DPolygon[faceMi] = projectPointsOnPlane ( masterPatch_[faceMi].points(masterPatchPoints), currentMasterFaceCentre, currentMasterFaceNormal, facePolygonErrorProjection ); // Next we compute an orthonormal basis (u, v, w) aligned with // the face normal for doing the 3D to 2D projection. // // "w" is aligned on the face normal. We need to select a "u" // direction, it can be anything as long as it lays on the // projection plane. We chose to use the direction from the // master face center to the most distant projected master face // point on the plane. Finally, we get "v" by evaluating the // cross-product w^u = v. And we make sure that u, v, and w are // normalized. // // // u = vector from face center to most distant projected master face point. // / . // ^y / | . .w = normal to master face // | / | . . // | / | . . // | | | . // | | / . // | | / . // | | / . // ---------> x |/ . // / v = w^u // / // / // z // // orthoNormalBasis uvw = computeOrthonormalBasis ( currentMasterFaceCentre, currentMasterFaceNormal, masterFace2DPolygon[faceMi] ); // Recompute the master polygon into this orthoNormalBasis // We should only see a rotation along the normal of the face here List<point2D> masterPointsInUV; scalarField masterErrorProjectionAlongW; masterPointsInUV = projectPoints3Dto2D ( uvw, currentMasterFaceCentre, masterFace2DPolygon[faceMi], masterErrorProjectionAlongW // Should be at zero all the way ); // Compute the surface area of the polygon; // We need this for computing the weighting factors scalar surfaceAreaMasterPointsInUV = area2D(masterPointsInUV); // Check if polygon is CW.. Should not, it should be CCW; but // better and cheaper to check here if (surfaceAreaMasterPointsInUV < 0.0) { reverse(masterPointsInUV); surfaceAreaMasterPointsInUV = -surfaceAreaMasterPointsInUV; // Just generate a warning until we can verify this is a non issue InfoIn ( "void GGIInterpolation<MasterPatch, SlavePatch>::" "calcAddressing()" ) << "The master projected polygon was CW instead of CCW. " << "This is strange..." << endl; } // Next, project the candidate master neighbours faces points // onto the same plane using the new orthonormal basis const labelList& curCMN = candidateMasterNeighbors[faceMi]; forAll (curCMN, neighbI) { // For each points, compute the dot product with u,v,w. The // [u,v] component will gives us the 2D cordinates we are // looking for for doing the 2D intersection The w component // is basically the projection error normal to the projection // plane // NB: this polygon is most certainly CW w/r to the uvw // axis because of the way the normals are oriented on // each side of the GGI interface... We will switch the // polygon to CCW in due time... List<point2D> neighbPointsInUV; scalarField neighbErrorProjectionAlongW; // We use the xyz points directly, with a possible transformation pointField curSlaveFacePoints = slavePatch_[curCMN[neighbI]].points(slavePatch_.points()); if (doTransform()) { // Transform points to master plane if (forwardT_.size() == 1) { transform ( curSlaveFacePoints, forwardT_[0], curSlaveFacePoints ); } else { transform ( curSlaveFacePoints, forwardT_[curCMN[neighbI]], curSlaveFacePoints ); } } // Apply the translation offset in order to keep the // neighbErrorProjectionAlongW values to a minimum if (doSeparation()) { if (forwardSep_.size() == 1) { curSlaveFacePoints += forwardSep_[0]; } else { curSlaveFacePoints += forwardSep_[curCMN[neighbI]]; } } neighbPointsInUV = projectPoints3Dto2D ( uvw, currentMasterFaceCentre, curSlaveFacePoints, neighbErrorProjectionAlongW ); // We are now ready to filter out the "bad" neighbours. // For this, we will apply the Separating Axes Theorem // http://en.wikipedia.org/wiki/Separating_axis_theorem. // This will be the second and last quick reject test. // We will use the 2D projected points for both the master // patch and its neighbour candidates if ( detect2dPolygonsOverlap ( masterPointsInUV, neighbPointsInUV, sqrt(areaErrorTol_()) // distErrorTol ) ) { // We have an overlap between the master face and this // neighbor face. label faceMaster = faceMi; label faceSlave = curCMN[neighbI]; // Compute the surface area of the neighbour polygon; // We need this for computing the weighting factors scalar surfaceAreaNeighbPointsInUV = area2D(neighbPointsInUV); // Check for CW polygons. It most certainly is, and // the polygon intersection algorithms are expecting // to work with CCW point ordering for the polygons if (surfaceAreaNeighbPointsInUV < 0.0) { reverse(neighbPointsInUV); surfaceAreaNeighbPointsInUV = -surfaceAreaNeighbPointsInUV; } // We compute the intersection area using the // Sutherland-Hodgman algorithm. Of course, if the // intersection area is 0, that would constitute the last and // final reject test, but it would also be an indication that // our 2 previous rejection tests are a bit laxed... or that // maybe we are in presence of concave polygons.... scalar intersectionArea = polygonIntersection ( masterPointsInUV, neighbPointsInUV ); if (intersectionArea > VSMALL) // Or > areaErrorTol_ ??? { // We compute the GGI weights based on this // intersection area, and on the individual face // area on each side of the GGI. // Since all the intersection have been computed // in the projected UV space we need to compute // the weights using the surface area from the // faces projection as well. That way, we make // sure all our factors will sum up to 1.0. masterNeighbors[faceMaster].append(faceSlave); slaveNeighbors[faceSlave].append(faceMaster); masterNeighborsWeights[faceMaster].append ( intersectionArea/surfaceAreaMasterPointsInUV ); slaveNeighborsWeights[faceSlave].append ( intersectionArea/surfaceAreaNeighbPointsInUV ); } else { WarningIn ( "GGIInterpolation<MasterPatch, SlavePatch>::" "calcAddressing()" ) << "polygonIntersection is returning a " << "zero surface area between " << nl << " Master face: " << faceMi << " and Neighbour face: " << curCMN[neighbI] << " intersection area = " << intersectionArea << nl << "Please check the two quick-check algorithms for " << "GGIInterpolation. Something is missing." << endl; } } }
void SceneTransformDialog::createControls() { logMessage("SceneTransformDialog::createControls()"); // translate txtTranslateX = new ValueLineEdit(); txtTranslateY = new ValueLineEdit(); lstTranslateX = new QLabel(); lstTranslateY = new QLabel(); QGridLayout *layoutTranslate = new QGridLayout(); layoutTranslate->addWidget(lstTranslateX, 0, 0); layoutTranslate->addWidget(txtTranslateX, 0, 1); layoutTranslate->addWidget(lstTranslateY, 1, 0); layoutTranslate->addWidget(txtTranslateY, 1, 1); layoutTranslate->addWidget(new QLabel(""), 2, 0); widTranslate = new QWidget(); widTranslate->setLayout(layoutTranslate); // rotate txtRotateBasePointX = new ValueLineEdit(); txtRotateBasePointY = new ValueLineEdit(); txtRotateAngle = new ValueLineEdit(); lstRotateBasePointX = new QLabel(); lstRotateBasePointY = new QLabel(); QGridLayout *layoutRotate = new QGridLayout(); layoutRotate->addWidget(lstRotateBasePointX, 0, 0); layoutRotate->addWidget(txtRotateBasePointX, 0, 1); layoutRotate->addWidget(lstRotateBasePointY, 1, 0); layoutRotate->addWidget(txtRotateBasePointY, 1, 1); layoutRotate->addWidget(new QLabel(tr("Angle:")), 2, 0); layoutRotate->addWidget(txtRotateAngle, 2, 1); widRotate = new QWidget(); widRotate->setLayout(layoutRotate); // scale txtScaleBasePointX = new ValueLineEdit(); txtScaleBasePointY = new ValueLineEdit(); txtScaleFactor = new ValueLineEdit(); lstScaleBasePointX = new QLabel(); lstScaleBasePointY = new QLabel(); QGridLayout *layoutScale = new QGridLayout(); layoutScale->addWidget(lstScaleBasePointX, 0, 0); layoutScale->addWidget(txtScaleBasePointX, 0, 1); layoutScale->addWidget(lstScaleBasePointY, 1, 0); layoutScale->addWidget(txtScaleBasePointY, 1, 1); layoutScale->addWidget(new QLabel(tr("Scaling factor:")), 2, 0); layoutScale->addWidget(txtScaleFactor, 2, 1); widScale = new QWidget(); widScale->setLayout(layoutScale); // copy chkCopy = new QCheckBox(tr("Copy objects")); // dialog buttons QPushButton *btnApply = new QPushButton(tr("Apply")); btnApply->setDefault(true); connect(btnApply, SIGNAL(clicked()), this, SLOT(doTransform())); QPushButton *btnClose = new QPushButton(tr("Close")); connect(btnClose, SIGNAL(clicked()), this, SLOT(doClose())); QHBoxLayout *layoutButtonBox = new QHBoxLayout(); layoutButtonBox->addStretch(); layoutButtonBox->addWidget(btnApply); layoutButtonBox->addWidget(btnClose); // tab widget tabWidget = new QTabWidget(); tabWidget->addTab(widTranslate, icon(""), tr("Translate")); tabWidget->addTab(widRotate, icon(""), tr("Rotate")); tabWidget->addTab(widScale, icon(""), tr("Scale")); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(tabWidget); layout->addWidget(chkCopy); layout->addStretch(); layout->addLayout(layoutButtonBox); setLayout(layout); }
void Foam::cyclicAMIPointPatchField<Type>::swapAddSeparated ( const Pstream::commsTypes, gpuField<Type>& pField ) const { if (cyclicAMIPatch_.cyclicAMIPatch().owner()) { // We inplace modify pField. To prevent the other side (which gets // evaluated at a later date) using already changed values we do // all swaps on the side that gets evaluated first. // Get neighbouring pointPatch const cyclicAMIPointPatch& nbrPatch = cyclicAMIPatch_.neighbPatch(); // Get neighbouring pointPatchField const GeometricField<Type, pointPatchField, pointMesh>& fld = refCast<const GeometricField<Type, pointPatchField, pointMesh> > ( this->dimensionedInternalField() ); const cyclicAMIPointPatchField<Type>& nbr = refCast<const cyclicAMIPointPatchField<Type> > ( fld.boundaryField()[nbrPatch.index()] ); Field<Type> ptFld(this->patchInternalField(pField)().asField()); Field<Type> nbrPtFld(nbr.patchInternalField(pField)().asField()); if (doTransform()) { const tensor& forwardT = this->forwardT()[0]; const tensor& reverseT = this->reverseT()[0]; transform(ptFld, reverseT, ptFld); transform(nbrPtFld, forwardT, nbrPtFld); } // convert point field to face field, AMI interpolate, then // face back to point { // add neighbour side contribution to owner Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld)); // interpolate to owner if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection()) { Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld)); nbrFcFld = cyclicAMIPatch_.cyclicAMIPatch().interpolate ( nbrFcFld, fcFld ); } else { nbrFcFld = cyclicAMIPatch_.cyclicAMIPatch().interpolate(nbrFcFld); } // add to internal field this->addToInternalField ( pField, gpuField<Type>(ppi().faceToPointInterpolate(nbrFcFld)()) ); } { // add owner side contribution to neighbour Field<Type> fcFld(ppi().pointToFaceInterpolate(ptFld)); // interpolate to neighbour if (cyclicAMIPatch_.cyclicAMIPatch().applyLowWeightCorrection()) { Field<Type> nbrFcFld(nbrPpi().pointToFaceInterpolate(nbrPtFld)); fcFld = cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate ( fcFld, nbrFcFld ); } else { fcFld = cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().interpolate ( fcFld ); } // add to internal field nbr.addToInternalField ( pField, gpuField<Type>(nbrPpi().faceToPointInterpolate(fcFld)()) ); } } }