Esempio n. 1
0
	//-------------------------------------------------------------------
	void Vob::readPacked(ZenArchive* _zenArchive, ushort _version)
	{
		PackedVob packedVob;
		size_t sz = _zenArchive->readRaw("dataRaw", &packedVob, sizeof(packedVob));

		if(sz == 0x53)
		{
			// Gothic 2
		}
		else if(sz == 0x4A) 
		{
			// Gothic 1 old format: flags occupy two bytes, visualAnimModeStrength
			// and vobFarClipZScale are not used
			packedVob.flags[3] = 0;
			packedVob.visualAniModeStrength = 0;
			packedVob.vobFarClipZScale = 1;
		}
		else
		{
			// Unknown format
			GOTHOGRE_EXCEPT("Vob: Unexpected dataRaw size: " << sz);
		}

		Vector3 pos( (Real) packedVob.pos[0], (Real) packedVob.pos[1], (Real) packedVob.pos[2] );
		Matrix3 rot( (Real) packedVob.rot[0], (Real) packedVob.rot[1], (Real) packedVob.rot[2] ,
					 (Real) packedVob.rot[3], (Real) packedVob.rot[4], (Real) packedVob.rot[5] ,
					 (Real) packedVob.rot[6], (Real) packedVob.rot[7], (Real) packedVob.rot[8] );
		setDerivedPosition(exchangeYZ(pos));
		setDerivedOrientation(exchangeYZ(rot));

		AxisAlignedBox bbox( (Real) packedVob.bbox3DWS[0], (Real) packedVob.bbox3DWS[1], (Real) packedVob.bbox3DWS[2], 
		                     (Real) packedVob.bbox3DWS[3], (Real) packedVob.bbox3DWS[4], (Real) packedVob.bbox3DWS[5]);
		setWorldBounds(exchangeYZ(bbox));

		PackedVobBits bits;
		memset(&bits, 0, sizeof(bits));
		memcpy(&bits, &packedVob.flags, sizeof(packedVob.flags));

		if(bits.presetName)
			setPresetName(_zenArchive->readString("presetName"));

		if(bits.vobName)
			setName(_zenArchive->readString("vobName"));

		if(bits.visual)
			setVisual(_zenArchive->readString("visual"));

		setShowVisual(bits.showVisual);
		setVisualCamAlign( (VisualCamAlign::Enum) bits.visualCamAlign);
		setCdStatic(bits.cdStatic);
		setCdDyn(bits.cdDyn);
		setStaticVob(bits.staticVob);
		setDynShadow( (DynShadow::Enum) bits.dynShadow);
	}
const EDA_RECT GERBER_DRAW_ITEM::GetBoundingBox() const
{
    // return a rectangle which is (pos,dim) in nature.  therefore the +1
    EDA_RECT bbox( m_Start, wxSize( 1, 1 ) );

    bbox.Inflate( m_Size.x / 2, m_Size.y / 2 );

    bbox.SetOrigin( GetABPosition( bbox.GetOrigin() ) );
    bbox.SetEnd( GetABPosition( bbox.GetEnd() ) );
    return bbox;
}
Esempio n. 3
0
void Rest::setMMWidth(qreal val)
      {
      _mmWidth = val;
      Segment* s = segment();
      if (s && s->measure() && s->measure()->multiMeasure()) {
            qreal _spatium = spatium();
            qreal h = _spatium * 2;
            qreal w = _mmWidth;                       // + 1*lineWidth of vertical lines
            bbox().setRect(0.0, -h * .5, w, h);
            }
      }
Esempio n. 4
0
SG_BBox SG_BBox::transform(const MT_Transform &world) const
{
    SG_BBox bbox(world(m_min), world(m_max));
    bbox += world(MT_Point3(m_min[0], m_min[1], m_max[2]));
    bbox += world(MT_Point3(m_min[0], m_max[1], m_min[2]));
    bbox += world(MT_Point3(m_min[0], m_max[1], m_max[2]));
    bbox += world(MT_Point3(m_max[0], m_min[1], m_min[2]));
    bbox += world(MT_Point3(m_max[0], m_min[1], m_max[2]));
    bbox += world(MT_Point3(m_max[0], m_max[1], m_min[2]));
    return bbox;
}
Esempio n. 5
0
void OpticalFlow::PrepareTracking(IplImage* rgbImage,
                                  IplImage* currGrayImage, int curr_indx,
                                  ProbDistrProvider* pProbProv,
                                  const CuScanMatch& match,
                                  ConstMaskIt mask,
                                  int target_num_features,
                                  int winsize_width,
                                  int winsize_height,
                                  double min_distance,
                                  double max_feature_error)
{
  m_pProbDistrProvider = pProbProv;
  m_target_num_features = target_num_features;
  m_num_features_tracked = 0;
  m_prev_buf_meaningful = false;
  m_winsize_width = winsize_width;
  m_winsize_height = winsize_height;
  m_min_distance = min_distance;
  m_max_feature_error = max_feature_error;
  
  // first find a big set of features that sits on corners
  int num_corners = m_target_num_features*3;
  CPointVector corners;
  corners.resize(num_corners);
  CRect bbox(match);
  FindGoodFeatures(currGrayImage, bbox, corners);

  // then play with the color probability distribution to pick
  // the ones that are on skin color, or if those aren't enough,
  // pick some additional ones on skin colored pixels
  m_features[0].resize(m_target_num_features);
  m_features[1].resize(m_target_num_features);
  m_feature_status.resize(m_target_num_features);
  m_errors.resize(m_target_num_features);
  PickSkinColoredFeatures(rgbImage, corners, m_features[curr_indx], match, mask);

  // fine-tune feature locations
  cvFindCornerSubPix(currGrayImage,
                     (CvPoint2D32f*) &m_features[curr_indx][0],
                     m_target_num_features, 
                     cvSize(5,5), cvSize(-1,-1),
                     cvTermCriteria( CV_TERMCRIT_ITER, 10, 0.1f ));

  // set status right for these features
  for (int i=0; i<m_target_num_features; i++) {
    m_feature_status[i] = 1;
  }
  GetAverage(m_features[curr_indx], m_mean_feature_pos);

  m_condens_is_tracking = false;
  m_condens_init_rect = CRect(match);

  m_prepared = true;
}
Esempio n. 6
0
Shape HairpinSegment::shape() const
      {
      switch (hairpin()->hairpinType()) {
            case Hairpin::Type::CRESC_HAIRPIN:
            case Hairpin::Type::DECRESC_HAIRPIN:
                  return Shape(bbox());
            case Hairpin::Type::DECRESC_LINE:
            case Hairpin::Type::CRESC_LINE:
            default:
                  return TextLineSegment::shape();
            }
      }
bool
shape_composite::scale(double x, double y, double z)
{
  bool temp = true;
  for(std::vector<shape*>::iterator i = data_.begin(); i != data_.end(); std::advance(i ,1))
  {
    bool akt = (*i)->scale(x,y,z);
    temp = temp && akt;
  }
  bbox();
  return temp;
}
bool
shape_composite::rotatez(double angle)
{
  bool temp = true;
  for(std::vector<shape*>::iterator i = data_.begin(); i != data_.end(); std::advance(i ,1))
  {
    bool akt = (*i)->rotatez(angle);
    temp = temp && akt;
  }
  bbox();
  return temp;
}
    void Mesh::GetFaceBounds(int faceidx, bool objectspace, bbox& bounds) const
    {
        float3 verts[4];
        const int numVert = GetTransformedFace(faceidx, objectspace ? matrix() : worldmat_, verts);
        bounds = bbox(verts[0], verts[1]);
        bounds.grow(verts[2]);

        if(numVert == 4 )
        {
            bounds.grow(verts[3]);
        }
    }
Esempio n. 10
0
File: eps.c Progetto: EQ4/SPTK
/* epsf_setup: setup epsf */
void epsf_setup(FILE * fp, float shrink, int xoffset, int yoffset,
                struct bbmargin bbm, int ncopy)
{
   int xmin = 9999, ymin = 9999, xmax = 0, ymax = 0;

   if (!psmode)
      bbox(fp, &xmin, &ymin, &xmax, &ymax, shrink, xoffset, yoffset, bbm);
   epsf_init(&xmin, &ymin, &xmax, &ymax, ncopy);
   epsf_scale(shrink, xoffset, yoffset);

   return;
}
Scene_textured_polyhedron_item::Bbox
Scene_textured_polyhedron_item::bbox() const {
    const Point& p = *(poly->points_begin());
    CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z());
    for(Textured_polyhedron::Point_iterator it = poly->points_begin();
        it != poly->points_end();
        ++it) {
        bbox = bbox + it->bbox();
    }
    return Bbox(bbox.xmin(),bbox.ymin(),bbox.zmin(),
                bbox.xmax(),bbox.ymax(),bbox.zmax());
}
Esempio n. 12
0
void Rest::setMMWidth(qreal val)
      {
      _mmWidth = val;
      Segment* s = segment();
      if (s && s->measure() && s->measure()->multiMeasure()) {
            qreal _spatium = spatium();
            qreal h = _spatium * 6.5;
            qreal w = _mmWidth;
            // setbbox(QRectF(-w * .5, -h + 2 * _spatium, w, h));
            bbox().setRect(0.0, -h + 2 * _spatium, w, h);
            }
      }
Esempio n. 13
0
SG_Tree* SG_TreeFactory::MakeTree()
{
	if (m_objects.size() < 8)
		return MakeTreeUp();

	TreeSet::iterator it = m_objects.begin();
	SG_BBox bbox((*it)->BBox());
	for (++it; it != m_objects.end(); ++it)
		bbox += (*it)->BBox();
	
	return MakeTreeDown(bbox);
}
Esempio n. 14
0
BBox GameHud::minimap_bbox(GameState* gs) {
	int minimap_relposx = 20, minimap_relposy = 64 + 45;
	int sx = sidebar_box.x1 + minimap_relposx, sy = sidebar_box.y1
			+ minimap_relposy;
	BBox bbox(sx, sy, sx + gs->get_level()->tile_width(),
			sy + gs->get_level()->tile_height());
	int minimap_w = bbox.width(), minimap_h = bbox.height();
	int minimap_x = bbox.x1 + (128 - minimap_w) / 2, minimap_y = bbox.y1
			+ (128 - minimap_w) / 2;
	return BBox(minimap_x, minimap_y, minimap_x + minimap_w,
			minimap_y + minimap_h);
}
Esempio n. 15
0
void
CQGnuPlotColorBox::
draw(CGnuPlotRenderer *renderer)
{
  if (! isEnabled())
    return;

  CGnuPlotColorBox::draw(renderer);

  if (isSelected())
    renderer->drawRect(bbox(), CRGBA(1,0,0), 2);
}
Esempio n. 16
0
/// \brief This function uses a pseudo-random technique to populate the
/// forest with trees. This algorithm as the following essental properties:
///
///   - It is repeatable. It can be repeated on the client and the server,
///     and give identical results.
///
///   - It is location independant. It gives the same results even if the
///     forest is in a different place.
///
///   - It is shape and size independant. A given area of the forest is
///     the same even if the borders of the forest change.
///
///   - It is localisable. It is possible to only partially populate the
///     the forest, and still get the same results in that area.
///
/// This function will have no effect if the area defining the forest remains
/// uninitialised. Any previously generated contents are erased.
/// For each instance a new seed is used to ensure it is repeatable, and
/// height, displacement and orientation are calculated.
void Forest::populate()
{
    if (!m_area) return;
    WFMath::AxisBox<2> bbox(m_area->bbox());
    
    // Fill the plant store with plants.
    m_plants.clear();
    WFMath::MTRand rng;

    int lx = I_ROUND(bbox.lowCorner().x()),
        ly = I_ROUND(bbox.lowCorner().y()),
        hx = I_ROUND(bbox.highCorner().x()),
        hy = I_ROUND(bbox.highCorner().y());

    PlantSpecies::const_iterator I;
    PlantSpecies::const_iterator Iend = m_species.end();

    for(int j = ly; j < hy; ++j) {
        for(int i = lx; i < hx; ++i) {
            if (!m_area->contains(i,j)) {
                continue;
            }
            double prob = m_randCache(i,j);
            I = m_species.begin();
            for (; I != Iend; ++I) {
                const Species & species = *I;
                if (prob > species.m_probability) {
                    prob -= species.m_probability;
                    // Next species
                    continue;
                }
                
//                std::cout << "Plant at [" << i << ", " << j << "]"
//                          << std::endl << std::flush;
                //this is a bit of a hack
                rng.seed((int)(prob / I->m_probability * 123456));

                Plant & plant = m_plants[i][j];
                // plant.setHeight(rng() * plant_height_range + plant_min_height);
                plant.setDisplacement(WFMath::Point<2>(
                    (rng.rand<WFMath::CoordType>() - 0.5f) * species.m_deviation,
                    (rng.rand<WFMath::CoordType>() - 0.5f) * species.m_deviation));
                plant.setOrientation(WFMath::Quaternion(2, rng.rand<WFMath::CoordType>() * 2 * WFMath::numeric_constants<WFMath::CoordType>::pi()));
                ParameterDict::const_iterator J = species.m_parameters.begin();
                ParameterDict::const_iterator Jend = species.m_parameters.end();
                for (; J != Jend; ++J) {
                    plant.setParameter(J->first, rng.rand<WFMath::CoordType>() * J->second.range + J->second.min);
                }
                break;
            }
        }
    }
}
Esempio n. 17
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
      foreach(Element* e, _el) {
            if (e->isText()) {
                  Text* text = static_cast<Text*>(e);
                  text->layout();
                  qreal h;
                  if (text->isEmpty()) {
                        QFontMetricsF fm(text->font());
                        h = fm.lineSpacing();
                        }
                  else
                        h = text->height();
                  text->setPos(leftMargin() * MScore::DPMM, topMargin() * MScore::DPMM);
                  bbox().setRect(0.0, 0.0, system()->width(), h);
                  }
            }
      MeasureBase::layout();  // layout LayoutBreak's
      }
void
Scene_polyhedron_transform_item::compute_bbox() const {
    const Kernel::Point_3& p = *(poly->points_begin());
    CGAL::Bbox_3 bbox(p.x(), p.y(), p.z(), p.x(), p.y(), p.z());
    for(Polyhedron::Point_const_iterator it = poly->points_begin();
        it != poly->points_end();
        ++it) {
        bbox = bbox + it->bbox();
    }
    _bbox = Bbox(bbox.xmin(),bbox.ymin(),bbox.zmin(),
                bbox.xmax(),bbox.ymax(),bbox.zmax());
}
Esempio n. 19
0
void GameScene::update(float dt)
{
    for (Entity* d : decorations_)
    {
        d->update(dt);
    }

    for (Entity* p : platforms_)
    {
        p->update(dt);
    }

    for (Entity* g : goalflags_)
    {
        g->update(dt);
    }

    update_effects(dt);

    for (Entity* c : collectibles_)
    {
        c->update(dt);

        sf::FloatRect bbox(c->collision_area());
        if (!c->animation().hidden() &&
            bbox.Intersects(player_.collision_area()))
        {
            explode(c,true);
            collectsnd_.Play();
        }
    }

    update_player(dt);

    bool out_of_bounds = true;
    for (Entity* p : platforms_)
    {
        if (vector_magnitude(
            p->position() - player_.position())
            < 1000)
        {
            out_of_bounds = false;
        }
    }

    if (out_of_bounds)
    {
        init_world();
    }

    update_camera(dt);
}
Esempio n. 20
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), 0);
      _text->layout();

      qreal h = _text->height();
      qreal y = topMargin() * DPMM;
#if 0
      if (_text->align() & Align::BOTTOM)
            y += h;
      else if (_text->align() & Align::VCENTER)
            y +=  h * .5;
      else
            ; // y = 0;
#endif
      _text->setPos(leftMargin() * DPMM, y);
      h += topMargin() * DPMM + bottomMargin() * DPMM;
      bbox().setRect(0.0, 0.0, system()->width(), h);

      MeasureBase::layout();  // layout LayoutBreak's
      }
Esempio n. 21
0
void Tremolo::draw(QPainter* painter) const
      {
      painter->setBrush(QBrush(curColor()));
      painter->setPen(Qt::NoPen);
      painter->drawPath(path);
      if ((parent() == 0) && !twoNotes()) {
            qreal x = 0.0; // bbox().width() * .25;
            QPen pen(curColor(), point(score()->styleS(ST_stemWidth)));
            painter->setPen(pen);
            qreal _spatium = spatium();
            painter->drawLine(QLineF(x, -_spatium*.5, x, bbox().height() + _spatium));
            }
      }
Esempio n. 22
0
AABox BBoxDeco::getBoundingBox(const AABox& in_bbox) const
{
  AABox bbox(in_bbox);

  Vertex marklen = getMarkLength(bbox);

  Vertex v = marklen * 2;

  bbox += bbox.vmin - v;
  bbox += bbox.vmax + v;

  return bbox;
}
Esempio n. 23
0
AABox BBoxDeco::getBoundingBox(const AABox& in_bbox) const
{
  AABox bbox(in_bbox);

  float marklen = getMarkLength(bbox);

  Vertex v = Vertex(1,1,1) * 2 * marklen;

  bbox += bbox.vmin - v;
  bbox += bbox.vmax + v;

  return bbox;
}
Esempio n. 24
0
void Box::draw(QPainter* painter) const
      {
      if (score() && score()->printing())
            return;
      if (selected() || editMode || dropTarget() || score()->showFrames()) {
            qreal w = 2.0 / painter->transform().m11();
            painter->setPen(QPen(
               (selected() || editMode || dropTarget()) ? Qt::blue : Qt::gray, w));
            painter->setBrush(Qt::NoBrush);
            w *= .5;
            painter->drawRect(bbox().adjusted(w, w, -w, -w));
            }
      }
Esempio n. 25
0
void Image::draw(QPainter* painter) const
      {
      bool emptyImage = false;
      if (imageType == ImageType::SVG) {
            if (!svgDoc)
                  emptyImage = true;
            else
                  svgDoc->render(painter, bbox());
            }
      else if (imageType == ImageType::RASTER) {
            if (rasterDoc == nullptr)
                  emptyImage = true;
            else {
                  painter->save();
                  QSizeF s;
                  if (_sizeIsSpatium)
                        s = _size * spatium();
                  else
                        s = _size * MScore::DPMM;
                  if (score()->printing()) {
                        // use original image size for printing
                        painter->scale(s.width() / rasterDoc->width(), s.height() / rasterDoc->height());
                        painter->drawPixmap(QPointF(0, 0), QPixmap::fromImage(*rasterDoc));
                        }
                  else {
                        QTransform t = painter->transform();
                        QSize ss = QSizeF(s.width() * t.m11(), s.height() * t.m22()).toSize();
                        t.setMatrix(1.0, t.m12(), t.m13(), t.m21(), 1.0, t.m23(), t.m31(), t.m32(), t.m33());
                        painter->setWorldTransform(t);
                        if ((buffer.size() != ss || _dirty) && rasterDoc && !rasterDoc->isNull()) {
                              buffer = QPixmap::fromImage(rasterDoc->scaled(ss, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
                              _dirty = false;
                              }
                        if (buffer.isNull())
                              emptyImage = true;
                        else
                              painter->drawPixmap(QPointF(0.0, 0.0), buffer);
                        }
                  painter->restore();
                  }
            }
      if (emptyImage) {
            painter->setBrush(Qt::NoBrush);
            painter->setPen(Qt::black);
            painter->drawRect(bbox());
            painter->drawLine(0.0, 0.0, bbox().width(), bbox().height());
            painter->drawLine(bbox().width(), 0.0, 0.0, bbox().height());
            }
      if (selected() && !(score() && score()->printing())) {
            painter->setBrush(Qt::NoBrush);
            painter->setPen(MScore::selectColor[0]);
            painter->drawRect(bbox());
            }
      }
Esempio n. 26
0
void EpubFormatter::HandleTagPagebreak(HtmlToken *t)
{
    AttrInfo *attr = t->GetAttrByName("page_path");
    if (!attr || pagePath)
        ForceNewPage();
    if (attr) {
        RectF bbox(0, currY, pageDx, 0);
        currPage->instructions.Append(DrawInstr::Anchor(attr->val, attr->valLen, bbox));
        pagePath.Set(str::DupN(attr->val, attr->valLen));
        // reset CSS style rules for the new document
        styleRules.Reset();
    }
}
Esempio n. 27
0
static void drawTree(const TransformState& transState, const OctreeNode* node)
{
    Imath::Box3f bbox(node->center - Imath::V3f(node->radius),
                        node->center + Imath::V3f(node->radius));
    drawBoundingBox(transState, bbox, Imath::C3f(1));
    drawBoundingBox(transState, node->bbox, Imath::C3f(1,0,0));
    for (int i = 0; i < 8; ++i)
    {
        OctreeNode* n = node->children[i];
        if (n)
            drawTree(transState, n);
    }
}
Esempio n. 28
0
bool TextStyleBuilder::prepareLabel(TextStyle::Parameters& _params, Label::Type _type) {

    if (_params.text.empty() || _params.fontSize <= 0.f) {
        LOGD("invalid params: '%s' %f", _params.text.c_str(), _params.fontSize);
        return false;
    }

    // Apply text transforms
    const std::string* renderText;
    std::string text;

    if (_params.transform == TextLabelProperty::Transform::none) {
        renderText = &_params.text;
    } else {
        text = applyTextTransform(_params, _params.text);
        renderText = &text;
    }

    // Scale factor by which the texture glyphs are scaled to match fontSize
    _params.fontScale = _params.fontSize / _params.font->size();

    // Stroke width is normalized by the distance of the SDF spread, then
    // scaled to 255 and packed into the "alpha" channel of stroke.
    // Maximal strokeWidth is 3px, attribute is normalized to 0-1 range.

    auto ctx = m_style.context();

    uint32_t strokeAttrib = std::max(_params.strokeWidth / ctx->maxStrokeWidth() * 255.f, 0.f);
    if (strokeAttrib > 255) {
        LOGN("stroke_width too large: %f / %f", _params.strokeWidth, strokeAttrib/255.f);
        strokeAttrib = 255;
    }
    m_attributes.stroke = (_params.strokeColor & 0x00ffffff) + (strokeAttrib << 24);
    m_attributes.fill = _params.fill;
    m_attributes.fontScale = _params.fontScale * 64.f;
    if (m_attributes.fontScale > 255) {
        LOGN("Too large font scale %f, maximal scale is 4", _params.fontScale);
        m_attributes.fontScale = 255;
    }
    m_attributes.quadsStart = m_quads.size();

    m_attributes.textRanges = TextRange{};

    glm::vec2 bbox(0);
    if (ctx->layoutText(_params, *renderText, m_quads, m_atlasRefs, bbox, m_attributes.textRanges)) {
        m_attributes.width = bbox.x;
        m_attributes.height = bbox.y;
        return true;
    }
    return false;
}
Esempio n. 29
0
void
NodeGraph::centerOnAllNodes()
{
    assert( QThread::currentThread() == qApp->thread() );
    double xmin = INT_MAX;
    double xmax = INT_MIN;
    double ymin = INT_MAX;
    double ymax = INT_MIN;
    //_imp->_root->setPos(0,0);

    if ( _imp->_selection.empty() ) {
        QMutexLocker l(&_imp->_nodesMutex);

        for (NodesGuiList::iterator it = _imp->_nodes.begin(); it != _imp->_nodes.end(); ++it) {
            if ( /*(*it)->isActive() &&*/ (*it)->isVisible() ) {
                QSize size = (*it)->getSize();
                QPointF pos = (*it)->mapToScene( (*it)->mapFromParent( (*it)->pos() ) );
                xmin = std::min( xmin, pos.x() );
                xmax = std::max( xmax, pos.x() + size.width() );
                ymin = std::min( ymin, pos.y() );
                ymax = std::max( ymax, pos.y() + size.height() );
            }
        }
    } else {
        for (NodesGuiList::iterator it = _imp->_selection.begin(); it != _imp->_selection.end(); ++it) {
            if ( /*(*it)->isActive() && */ (*it)->isVisible() ) {
                QSize size = (*it)->getSize();
                QPointF pos = (*it)->mapToScene( (*it)->mapFromParent( (*it)->pos() ) );
                xmin = std::min( xmin, pos.x() );
                xmax = std::max( xmax, pos.x() + size.width() );
                ymin = std::min( ymin, pos.y() );
                ymax = std::max( ymax, pos.y() + size.height() );
            }
        }
    }
    QRectF bbox( xmin, ymin, (xmax - xmin), (ymax - ymin) );
    fitInView(bbox, Qt::KeepAspectRatio);

    double currentZoomFactor = transform().mapRect( QRectF(0, 0, 1, 1) ).width();
    assert(currentZoomFactor != 0);
    //we want to fit at scale 1 at most
    if (currentZoomFactor > 1.) {
        double scaleFactor = 1. / currentZoomFactor;
        setTransformationAnchor(QGraphicsView::AnchorViewCenter);
        scale(scaleFactor, scaleFactor);
        setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    }

    _imp->_refreshOverlays = true;
    update();
} // NodeGraph::centerOnAllNodes
Esempio n. 30
0
BaseMesh* BSPBoolOp::ComputeBoolean(PlaneMesh* mesh1, PlaneMesh* mesh2, BOOL_OP op)
{
    BSPTree::SET_OP BSPOp;
    switch (op)
    {
        case eUnion:
            BSPOp = BSPTree::OP_UNION;
            break;
        case eIntersect:
            BSPOp = BSPTree::OP_INTERSECT;
            break;
        case eDiff:
            BSPOp = BSPTree::OP_DIFFERENCE;
            break;
        default :
            break;
    }
	Box3 bbox(mesh1->AABB());
	bbox.IncludeBox(mesh2->AABB());

    BSPTree* pTree1 =  mesh1->ToBSPTree();
    pTree1->FormSubHyperPlane(bbox);
	pTree1->OutputDebugInfo("D:\\x1.txt");

    BSPTree* pTree2 = mesh2->ToBSPTree();
    if (BSPOp == BSPTree::OP_DIFFERENCE)
    {
        pTree2->Negate();
        BSPOp = BSPTree::OP_INTERSECT;
    }
    pTree2->FormSubHyperPlane(bbox);
	pTree2->OutputDebugInfo("D:\\y1.txt");

    BSPTree* pResultTree = pTree1->Merge(pTree2, BSPOp);
	pResultTree->OutputDebugInfo("D:\\z1.txt");
    delete pTree2;
    delete pTree1;

   PlaneMesh* pPlaneMesh1 = new PlaneMesh(pResultTree);
   //PlaneMesh* pPlaneMesh1 = new PlaneMesh(pTree1);
    //delete pTree1;
    BaseMesh* pMesh = pPlaneMesh1->ToBaseMesh();
    if (pMesh && pMesh->PrimitiveCount() ==0 )
	{
        delete pMesh;
        pMesh = NULL;
    }
    delete pPlaneMesh1;

    return pMesh;
}