Cube::Cube(const position_type &where, std::shared_ptr<Texture> texture ) : Object3D(where) { // 8 points, 6 surfaces position_type blf(-1.0, -1.0, 1.0) // front rectangle , brf(1.0, -1.0, 1.0) , trf(1.0, 1.0, 1.0) , tlf(-1.0, 1.0, 1.0) , blr(-1.0, -1.0, -1.0) // rear rectangle , brr(1.0, -1.0, -1.0) , trr(1.0, 1.0, -1.0) , tlr(-1.0, 1.0, -1.0); position_type negZ(0.0, 0.0, -1.0) , posZ(0.0, 0.0, 1.0) , negY(0.0, -1.0, 0.0) , posY(0.0, 1.0, 0.0) , negX(-1.0, 0.0, 0.0) , posX(1.0, 0.0, 0.0); // if changing the order, make sure to change accessors so they grab the correct object this->add_child(new Rectangle(POSITION_INHERIT, { blf, blr, brr, brf }, { negY, negY, negY, negY }, texture)); // bottom negY this->add_child(new Rectangle(POSITION_INHERIT, { trr, brr, blr, tlr }, { negZ, negZ, negZ, negZ }, texture)); // rear negZ this->add_child(new Rectangle(POSITION_INHERIT, { trf, brf, brr, trr }, { posX, posX, posX, posX }, texture)); // right posX this->add_child(new Rectangle(POSITION_INHERIT, { tlr, blr, blf, tlf }, { negX, negX, negX, negX }, texture)); // left negX this->add_child(new Rectangle(POSITION_INHERIT, { tlf, blf, brf, trf }, { posZ, posZ, posZ, posZ }, texture)); // front posZ this->add_child(new Rectangle(POSITION_INHERIT, { tlr, tlf, trf, trr }, { posY, posY, posY, posY }, texture)); // top posY } // Cube
void test( const std::string & filename, const Vector3<uint_t> & size, const std::string & datatype, const bool vtkOut ) { WALBERLA_LOG_INFO( "Testing unscaled" ); BinaryRawFile brf( filename, size, datatype ); auto blocks = blockforest::createUniformBlockGrid( uint_t(1), uint_t( 1 ), uint_t( 1 ), size[0], size[1], size[2], real_t( 1 ), uint_t( 1 ), uint_t( 1 ), uint_t( 1 ) ); typedef GhostLayerField< uint8_t, uint_t( 1 ) > ScalarField; BlockDataID scalarFieldID = field::addToStorage<ScalarField>( blocks, "BinaryRawFile" ); for ( auto & block : *blocks) { auto field = block.getData<ScalarField>( scalarFieldID ); CellInterval ci( 0, 0, 0, cell_idx_c( size[0] ) - 1, cell_idx_c( size[1] ) - 1, cell_idx_c( size[2] ) - 1 ); for (const Cell & c : ci) { field->get( c ) = brf.get( uint_c( c[0] ), uint_c( c[1] ), uint_c( c[2] ) ); } } if (vtkOut) { WALBERLA_LOG_INFO( "Writing unscaled" ); auto vtkOutput = vtk::createVTKOutput_BlockData( blocks, "BinaryRawFile" ); vtkOutput->addCellDataWriter( make_shared< field::VTKWriter< ScalarField, uint8_t > >( scalarFieldID, "BinaryRawFile" ) ); writeFiles( vtkOutput, true )(); } }
bool RobotBrainServiceService::start(int argc, char* argv[]) #endif { MYLOGVERB = LOG_INFO; char adapterStr[255]; //Create the adapter int port = RobotBrainObjects::RobotBrainPort; bool connected = false; // try to connect to ports until successful LDEBUG("Opening Connection"); while(!connected) { try { LINFO("Trying Port:%d", port); sprintf(adapterStr, "default -p %i", port); itsAdapter = communicator()->createObjectAdapterWithEndpoints ("GistSal_Navigation", adapterStr); connected = true; } catch(Ice::SocketException) { port++; } } //Create the manager and its objects itsMgr = new ModelManager("BeoRoadFinderService"); LINFO("Starting BeoRoadFinder System"); nub::ref<BeoRoadFinder> brf(new BeoRoadFinder(*itsMgr, "BeoRoadFinder", "BeoRoadFinder")); LINFO("BeoRoadFinder created"); itsMgr->addSubComponent(brf); LINFO("BeoRoadFinder Added As a subcomponent"); brf->init(communicator(), itsAdapter); LINFO("BeoRoadFinder initiated"); // check command line inputs/options if (itsMgr->parseCommandLine((const int)argc, (const char**)argv, "", 0, 0) == false) return(1); // activate manager and adapter itsAdapter->activate(); itsMgr->start(); return true; }
void testScaled( const std::string & filename, const Vector3<uint_t> & size, const std::string & datatype, const bool vtkOut ) { WALBERLA_LOG_INFO( "Testing scaled" ); BinaryRawFile brf( filename, size, datatype ); Vector3<uint_t> scaledSize( std::max( uint_t( 1 ), size[0] / uint_t( 2 ) ), std::max( uint_t( 1 ), size[1] / uint_t( 3 ) ), std::max( uint_t( 1 ), size[2] / uint_t( 5 ) ) ); auto blocks = blockforest::createUniformBlockGrid( uint_t( 1 ), uint_t( 1 ), uint_t( 1 ), scaledSize[0], scaledSize[1], scaledSize[2], real_t( 1 ), uint_t( 1 ), uint_t( 1 ), uint_t( 1 ) ); BinaryRawFileInterpolator brfi( blocks->getDomain(), brf, BinaryRawFileInterpolator::NEAREST_NEIGHBOR ); typedef GhostLayerField< uint8_t, uint_t( 1 ) > ScalarField; BlockDataID scalarFieldID = field::addToStorage<ScalarField>( blocks, "BinaryRawFile" ); for (auto & block : *blocks) { auto field = block.getData<ScalarField>( scalarFieldID ); CellInterval ci( 0, 0, 0, cell_idx_c( scaledSize[0] ) - 1, cell_idx_c( scaledSize[1] ) - 1, cell_idx_c( scaledSize[2] ) - 1 ); for (const Cell & c : ci) { auto pos = blocks->getBlockLocalCellCenter( block, c ); field->get( c ) = brfi.get( pos ); } } if (vtkOut) { WALBERLA_LOG_INFO( "Writing scaled" ); auto vtkOutput = vtk::createVTKOutput_BlockData( blocks, "BinaryRawFileScaled" ); vtkOutput->addCellDataWriter( make_shared< field::VTKWriter< ScalarField, uint8_t > >( scalarFieldID, "BinaryRawFile" ) ); writeFiles( vtkOutput, true )(); } }
Cube::Cube( const position_type &where, Texture::pointer_type texture ) : Object( where, texture ) { glm::vec3 blf( -1.0, -1.0, 1.0 ) // front rectangle , brf( 1.0, -1.0, 1.0 ) , trf( 1.0, 1.0, 1.0 ) , tlf( -1.0, 1.0, 1.0 ) , blr( -1.0, -1.0, -1.0 ) // rear rectangle , brr( 1.0, -1.0, -1.0 ) , trr( 1.0, 1.0, -1.0 ) , tlr( -1.0, 1.0, -1.0 ) ; glm::vec3 negZ( 0.0, 0.0, -1.0 ) , posZ( 0.0, 0.0, 1.0 ) , negY( 0.0, -1.0, 0.0 ) , posY( 0.0, 1.0, 0.0 ) , negX( -1.0, 0.0, 0.0 ) , posX( 1.0, 0.0, 0.0 ) ; // gl_triangle strip // for ccw winding: top left, bottom left, top right, bottom right auto add_components = [ &]( const std::vector<Component::pointer_type>& vec ) { for ( auto& v : vec ) this->components.emplace_back( v ); }; add_components( Triangle::from_quad( std::vector<glm::vec3>( { blf, blr, brf, brr } ), negY, texture ) ); // bottom add_components( Triangle::from_quad( std::vector<glm::vec3>( { trr, brr, tlr, blr } ), negZ, texture ) ); // rear add_components( Triangle::from_quad( std::vector<glm::vec3>( { trf, brf, trr, brr } ), posX, texture ) ); // right posX add_components( Triangle::from_quad( std::vector<glm::vec3>( { tlr, blr, tlf, blf } ), negX, texture ) ); // left negX add_components( Triangle::from_quad( std::vector<glm::vec3>( { tlf, blf, trf, brf } ), posZ, texture ) ); // front posZ add_components( Triangle::from_quad( std::vector<glm::vec3>( { tlr, tlf, trr, trf } ), posY, texture ) ); // top posY }
QString KicadSchematic2Svg::convertField(const QString & xString, const QString & yString, const QString & fontSizeString, const QString &orientation, const QString & hjustify, const QString & vjustify, const QString & t) { QString text = t; bool notName = false; if (text.startsWith("~")) { notName = true; text.remove(0, 1); } int x = xString.toInt(); int y = -yString.toInt(); // KiCad flips y-axis w.r.t. svg int fontSize = fontSizeString.toInt(); bool rotate = (orientation == "V"); QString rotation; QMatrix m; if (rotate) { m = QMatrix().translate(-x, -y) * QMatrix().rotate(-90) * QMatrix().translate(x, y); // store x, y, and r so they can be shifted correctly later rotation = QString("transform='%1' _x='%2' _y='%3' _r='-90'").arg(TextUtils::svgMatrix(m)).arg(x).arg(y); } QFont font; font.setFamily(OCRAFontName); font.setWeight(QFont::Normal); font.setPointSizeF(72.0 * fontSize / GraphicsUtils::StandardFritzingDPI); QString style; if (vjustify.contains("I")) { style += "font-style='italic' "; font.setStyle(QFont::StyleItalic); } if (vjustify.endsWith("B")) { style += "font-weight='bold' "; font.setWeight(QFont::Bold); } QString anchor = "middle"; if (vjustify.startsWith("T")) { anchor = "end"; } else if (vjustify.startsWith("B")) { anchor = "start"; } if (hjustify.contains("L")) { anchor = "start"; } else if (hjustify.contains("R")) { anchor = "end"; } QFontMetricsF metrics(font); QRectF bri = metrics.boundingRect(text); // convert back to 1000 dpi QRectF brf(0, 0, bri.width() * GraphicsUtils::StandardFritzingDPI / GraphicsUtils::SVGDPI, bri.height() * GraphicsUtils::StandardFritzingDPI / GraphicsUtils::SVGDPI); if (anchor == "start") { brf.translate(x, y - (brf.height() / 2)); } else if (anchor == "end") { brf.translate(x - brf.width(), y - (brf.height() / 2)); } else if (anchor == "middle") { brf.translate(x - (brf.width() / 2), y - (brf.height() / 2)); } if (rotate) { brf = m.map(QPolygonF(brf)).boundingRect(); } checkXLimit(brf.left()); checkXLimit(brf.right()); checkYLimit(brf.top()); checkYLimit(brf.bottom()); QString s = QString("<text x='%1' y='%2' font-size='%3' font-family='%8' stroke='none' fill='#000000' text-anchor='%4' %5 %6>%7</text>\n") .arg(x) .arg(y + (fontSize / 3)) .arg(fontSize) .arg(anchor) .arg(style) .arg(rotation) .arg(TextUtils::escapeAnd(unquote(text))) .arg(OCRAFontName) ; if (notName) { s += QString("<line fill='none' stroke='#000000' x1='%1' y1='%2' x2='%3' y2='%4' stroke-width='2' />\n") .arg(brf.left()) .arg(brf.top()) .arg(rotate ? brf.left() : brf.right()) .arg(rotate ? brf.bottom() : brf.top()); } return s; }