void TFGeometry2D::computeCenterAndSortKeyPoints() { if (_keyPoints.empty()) return; cgt::vec2 cPos(0.f); cgt::vec4 cCol(0.f); for (std::vector<KeyPoint>::const_iterator it = _keyPoints.begin(); it != _keyPoints.end(); ++it) { cPos += it->_position; cCol += toVec(it->_color); } cPos /= static_cast<float>(_keyPoints.size()); cCol /= static_cast<float>(_keyPoints.size()); _center = KeyPoint(cPos, toCol(cCol)); std::sort(_keyPoints.begin(), _keyPoints.end(), KeyPointSorter(_center._position)); }
TPos calcEndPos( Tpath& P ) { int i = P.Starti; int j = P.Startj; char w; for ( int k = 0; k != P.path.length(); k++ ) { w = P.path[k] - 48; if ( ( w & 1 ) == 1 || ( w & 2 ) == 2 ) i--; if ( ( w & 1 ) == 1 || ( w & 4 ) == 4 ) j--; } return cPos( i, j ); }
const Color CinderDSAPI::getColorFromDepthSpace(float pX, float pY, float pZ) { float cZCamera[3]{pX, pY, pZ}; float cRgbCamera[3]{0}; float cRgbImage[2]{0}; DSTransformFromZCameraToRectOtherCamera(mZToRgb, cZCamera, cRgbCamera); DSTransformFromOtherCameraToRectOtherImage(mRgbIntrinsics, cRgbCamera, cRgbImage); /* mRgbIter = mRgbFrame.getIter(); float cR = mRgbIter.r((int)cRgbImage[0], (int)cRgbImage[1]) / 255.0f; float cG = mRgbIter.g((int)cRgbImage[0], (int)cRgbImage[1]) / 255.0f; float cB = mRgbIter.b((int)cRgbImage[0], (int)cRgbImage[1]) / 255.0f; return Color(cR, cG, cB); */ ivec2 cPos(static_cast<int>(cRgbImage[0]), static_cast<int>(cRgbImage[1])); ColorA cColor = mRgbFrame.getPixel(cPos); return Color(cColor.r, cColor.g, cColor.b); }
BitmapView::BitmapView( BRect cFrame, BBitmap* pcBitmap ) : BView( cFrame, "_bitmap_view", B_FOLLOW_ALL, B_WILL_DRAW ) { m_pcBitmap = pcBitmap; struct stat sStat; m_cIcons.push_back( new Icon( "Root (List)", "icons/root.icon", sStat ) ); m_cIcons.push_back( new Icon( "Root (Icon)", "icons/root.icon", sStat ) ); m_cIcons.push_back( new Icon( "Terminal", "icons/terminal.icon", sStat ) ); //m_cIcons.push_back( new Icon( "Prefs", "icons/prefs.icon", sStat ) ); m_cIcons.push_back( new Icon( "Pulse", "icons/cpumon.icon", sStat ) ); m_cIcons.push_back( new Icon( "Calculator", "icons/cpumon.icon", sStat ) ); //m_cIcons.push_back( new Icon( "Editor", "icons/cpumon.icon", sStat ) ); m_cIcons.push_back( new Icon( "Guido", "icons/cpumon.icon", sStat ) ); //m_cIcons.push_back( new Icon( "CPU usage", "icons/cpumon.icon", sStat ) ); //m_cIcons.push_back( new Icon( "Memory usage", "icons/memmon.icon", sStat ) ); m_bCanDrag = false; m_bSelRectActive = false; BPoint cPos( 20, 20 ); for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) { m_cIcons[i]->m_cPosition.x = cPos.x + 16; m_cIcons[i]->m_cPosition.y = cPos.y; cPos.y += 50; if ( cPos.y > 500 ) { cPos.y = 20; cPos.x += 50; } } m_nHitTime = 0; }
int OPS_Layer() { // num args if(OPS_GetNumRemainingInputArgs() < 1) { opserr<<"WARNING insufficient args: layer type ...\n"; return -1; } // create patch ReinfLayer *theLayer = 0; const char* type = OPS_GetString(); if(strcmp(type,"straight")==0) { theLayer = (ReinfLayer*) OPS_StraightReinfLayer(); } else if(strcmp(type,"circ")==0 || strcmp(type,"circular")==0) { theLayer = (ReinfLayer*) OPS_CircReinfLayer(); } else { opserr<<"ERROR unknow layer type\n"; return -1; } if (theLayer == 0) { opserr<<"WARNING failed to create layer\n"; return -1; } // add fibers to the section int numReinfBars = theLayer->getNumReinfBars(); ReinfBar* reinfBar = theLayer->getReinfBars(); int matTag = theLayer->getMaterialID(); if(reinfBar == 0) { opserr<<"ERROR out of run to create fibers\n"; delete theLayer; return -1; } for(int j=0; j<numReinfBars; j++) { // get fiber data double area = reinfBar[j].getArea(); const Vector& cPos = reinfBar[j].getPosition(); // create fibers Fiber *theFiber = 0; UniaxialMaterial *material = 0; NDMaterial *ndmaterial = 0; if (theActiveFiberSection2d != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new UniaxialFiber2d(j,*material,area,cPos(0)); theActiveFiberSection2d->addFiber(*theFiber); } else if (theActiveFiberSection2dThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new UniaxialFiber2d(j,*material,area,cPos(0)); theActiveFiberSection2dThermal->addFiber(*theFiber); } else if (theActiveFiberSection3d != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSection3d->addFiber(*theFiber); } else if (theActiveFiberSection3dThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSection3dThermal->addFiber(*theFiber); } else if (theActiveFiberSectionGJThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSectionGJThermal->addFiber(*theFiber); } else if (theActiveNDFiberSection2d != 0) { ndmaterial = OPS_getNDMaterial(matTag); if (ndmaterial == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new NDFiber2d(j,*ndmaterial,area,cPos(0)); theActiveNDFiberSection2d->addFiber(*theFiber); } else if (theActiveNDFiberSection3d != 0) { ndmaterial = OPS_getNDMaterial(matTag); if (ndmaterial == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete theLayer; return -1; } theFiber = new NDFiber3d(j,*ndmaterial,area,cPos(0),cPos(1)); theActiveNDFiberSection3d->addFiber(*theFiber); } } delete [] reinfBar; delete theLayer; return 0; }
int OPS_Patch() { // num args if(OPS_GetNumRemainingInputArgs() < 1) { opserr<<"WARNING insufficient args: patch type ...\n"; return -1; } // create patch Patch *thePatch = 0; const char* type = OPS_GetString(); if(strcmp(type,"quad")==0 || strcmp(type,"quadr")==0 || strcmp(type,"quadrilateral")==0) { thePatch = (QuadPatch*) OPS_QuadPatch(); } else if(strcmp(type,"rect")==0 || strcmp(type,"rectangular")==0) { thePatch = (QuadPatch*) OPS_RectPatch(); } else if(strcmp(type,"circ")==0 || strcmp(type,"circular")==0) { thePatch = (CircPatch*) OPS_CircPatch(); } else { opserr<<"ERROR unknow patch type\n"; return -1; } if (thePatch == 0) { opserr<<"WARNING failed to create patch\n"; return -1; } // add fibers to the section int numCells = thePatch->getNumCells(); int matTag = thePatch->getMaterialID(); Cell** cells = thePatch->getCells(); if(cells == 0) { opserr << "ERROR out of run to create fibers\n"; delete thePatch; return -1; } for(int j=0; j<numCells; j++) { // get fiber data double area = cells[j]->getArea(); const Vector& cPos = cells[j]->getCentroidPosition(); // create fibers Fiber *theFiber = 0; UniaxialMaterial *material = 0; NDMaterial *ndmaterial = 0; if (theActiveFiberSection2d != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new UniaxialFiber2d(j,*material,area,cPos(0)); theActiveFiberSection2d->addFiber(*theFiber); } else if (theActiveFiberSection2dThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new UniaxialFiber2d(j,*material,area,cPos(0)); theActiveFiberSection2dThermal->addFiber(*theFiber); } else if (theActiveFiberSection3d != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSection3d->addFiber(*theFiber); } else if (theActiveFiberSection3dThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSection3dThermal->addFiber(*theFiber); } else if (theActiveFiberSectionGJThermal != 0) { material = OPS_getUniaxialMaterial(matTag); if (material == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new UniaxialFiber3d(j,*material,area,cPos); theActiveFiberSectionGJThermal->addFiber(*theFiber); } else if (theActiveNDFiberSection2d != 0) { ndmaterial = OPS_getNDMaterial(matTag); if (ndmaterial == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new NDFiber2d(j,*ndmaterial,area,cPos(0)); theActiveNDFiberSection2d->addFiber(*theFiber); } else if (theActiveNDFiberSection3d != 0) { ndmaterial = OPS_getNDMaterial(matTag); if (ndmaterial == 0) { opserr << "WARNING material "<<matTag<<" cannot be found\n"; delete thePatch; return -1; } theFiber = new NDFiber3d(j,*ndmaterial,area,cPos(0),cPos(1)); theActiveNDFiberSection3d->addFiber(*theFiber); } delete cells[j]; } delete [] cells; delete thePatch; return 0; }
void RecalcSizesL() { CALLSTACKITEM_N_NOSTATS(_CL("CJuikBoxSizer"), _CL("RecalcSizesL")); if ( ! iChildren.Count() ) return; // Calculate delta = extra space (distributed between proportional children) TInt delta = 0; if ( iTotalStretch ) { if ( iOrient == Juik::EHorizontal ) delta = iSize.iWidth - iFixedsSize.iWidth; else delta = iSize.iHeight - iFixedsSize.iHeight; } // TPoint currentPos = iPos; for (TInt i=0; i < iChildren.Count(); i++) { CJuikSizerItem* child = iChildren[i]; if ( iOrient == Juik::EVertical ) { // Calculate child's height // c-prefix means child's TSize cMinSz = child->MinSize(); TInt cHeight = 0; if ( child->Proportion() ) cHeight = (delta * child->Proportion()) / iTotalStretch; else cHeight = cMinSz.iHeight; TPoint cPos( currentPos ); TSize cSize( cMinSz.iWidth, cHeight ); // These flags control non-stretch axis if ( child->Flags() & Juik::EExpand ) cSize.iWidth = iSize.iWidth; else if ( child->Flags() & Juik::EAlignRight ) cPos.iX += iSize.iWidth - cSize.iWidth; else if ( child->Flags() & Juik::EAlignCenterHorizontal ) cPos.iX += (iSize.iWidth - cSize.iWidth) / 2; child->SetDimensionL( cPos, cSize ); currentPos += TSize( 0, cHeight ); } else { // Calculate child's width // c-prefix means child's TSize cMinSz = child->MinSize(); TInt cWidth = 0; if ( child->Proportion() ) cWidth = (delta * child->Proportion()) / iTotalStretch; else cWidth = cMinSz.iWidth; TPoint cPos( currentPos ); TSize cSize(cWidth, cMinSz.iHeight ); // These flags control non-stretch axis if ( child->Flags() & Juik::EExpand ) cSize.iHeight = iSize.iHeight; else if ( child->Flags() & Juik::EAlignBottom ) cPos.iY += iSize.iHeight - cSize.iHeight; else if ( child->Flags() & Juik::EAlignCenterVertical ) cPos.iY += (iSize.iHeight - cSize.iHeight) / 2; child->SetDimensionL( cPos, cSize ); currentPos += TSize( cWidth, 0 ); } } }