예제 #1
0
/*public*/
Geometry*
GeometryFactory::toGeometry(const Envelope* envelope) const
{
	Coordinate coord;

	if (envelope->isNull()) {
		return createPoint();
	}
	if (envelope->getMinX()==envelope->getMaxX() && envelope->getMinY()==envelope->getMaxY()) {
		coord.x = envelope->getMinX();
		coord.y = envelope->getMinY();
		return createPoint(coord);
	}
	CoordinateSequence *cl=CoordinateArraySequenceFactory::instance()->
        create((size_t) 0, 2);
	coord.x = envelope->getMinX();
	coord.y = envelope->getMinY();
	cl->add(coord);
	coord.x = envelope->getMaxX();
	coord.y = envelope->getMinY();
	cl->add(coord);
	coord.x = envelope->getMaxX();
	coord.y = envelope->getMaxY();
	cl->add(coord);
	coord.x = envelope->getMinX();
	coord.y = envelope->getMaxY();
	cl->add(coord);
	coord.x = envelope->getMinX();
	coord.y = envelope->getMinY();
	cl->add(coord);

	Polygon *p = createPolygon(createLinearRing(cl), NULL);
	return p;
}
FixtureDef* TiledBodyCreator::createFixture(cocos2d::ValueMap object)
{
	int fixtureType = RECT_FIXTURE;
	for(auto propObj : object)
	{
		if(propObj.first == "points") {
			fixtureType = POLYGON_FIXTURE;
		} else if(propObj.first == "polylinePoints") {
			fixtureType = POLYLINE_FIXTURE;
		}
	}
	if(object["type"].asString() == "Circle") {
		fixtureType = CIRCLE_FIXTURE;
	}


	if(fixtureType == POLYGON_FIXTURE) {
		return createPolygon(object);
	} else if(fixtureType == POLYLINE_FIXTURE) {
		return createPolyline(object);
	} else if(fixtureType == CIRCLE_FIXTURE) {
		return createCircle(object);
	} else if(fixtureType == RECT_FIXTURE) {
		return createRect(object);
	}
}
예제 #3
0
bool WaterObjectView::load()
{
	if (mIsLoaded)
	{
		return false;			
	}

	if (mWaterObject->getMap() != mMapView->getMap())
	{
		return false;
	}

	if (mWaterObject->getPointCount() == 1)
	{
		createPoint();
	}
	else if (mWaterObject->getIsRiver() || (mWaterObject->getPointCount() == 2))
	{
		createLine();
	}
	else
	{
		createPolygon();
	}

	mEntity = mMapView->createEntity(mMesh->getName(), mMesh->getName());
	mEntity->setUserAny(Ogre::Any(this));

	mSceneNode = mMapView->createSceneNode();
	mSceneNode->attachObject(mEntity);

	return mIsLoaded = true;
}
예제 #4
0
파일: polygon.c 프로젝트: Almamu/portalDS
polygon_struct* createQuad(vect3D v1, vect3D v2, vect3D v3, vect3D v4)
{
	polygon_struct *p, *pp;
	p=pp=createPolygon(v1);
	if(!p)return NULL;
	p->next=createPolygon(v2);
	p=p->next;
	if(!p)return NULL;
	p->next=createPolygon(v3);
	p=p->next;
	if(!p)return NULL;
	p->next=createPolygon(v4);
	p=p->next;
	if(!p)return NULL;
	return pp;
}
예제 #5
0
파일: polygon.c 프로젝트: Almamu/portalDS
polygon_struct* createEllipse(vect3D po, vect3D v1, vect3D v2, int n)
{
	int i;
	polygon_struct *p, *pp;
	p=pp=createPolygon(addVect(po,v1));
	if(!p)return NULL;
	for(i=1;i<n;i++)
	{
		const u16 a1=i*32768/n;
		vect3D v=addVect(po,addVect(vectMult(v1,cosLerp(a1)),vectMult(v2,sinLerp(a1))));
		p->next=createPolygon(v);
		p=p->next;
		if(!p)return NULL;
	}
	return pp;
}
예제 #6
0
void AreaSettingsDialog::loadFromLineEdits()
{
    qDebug() << "void AreaSettingsDialog::loadFromLineEdits()";
    QLineEdit *edit = qobject_cast<QLineEdit *>(sender());
    int position = 5;
    if(edit == ui->lineEdit_p1) position = 0;
    else if(edit == ui->lineEdit_p2) position = 1;
    else if(edit == ui->lineEdit_p3) position = 2;
    else if(edit == ui->lineEdit_p4) position = 3;
    else return;

    QRegExp rx("(\\d{1,3})[°dh,\\s]{1,}(\\d{1,3})['m,\\s]{1,}(\\d{1,3}.\\d{1,})[s,'' ]{1,2}[ x,]{1,}(\\d{1,3})[°dh,\\s]{1,}(\\d{1,3})['m,\\s]{1,}(\\d{1,3}.\\d{1,})[s,']{1,2}");
    rx.exactMatch(edit->text());
    QStringList captured = rx.capturedTexts();

    QPalette palette;

    if(captured.size() == 7 && rx.exactMatch(edit->text()))
    {
        qDebug() << "if(captured.size() == 7 && rx.exactMatch(edit->text())) true";
        DegMinSec longitude(captured.at(1).toInt(),captured.at(2).toInt(),captured.at(3).toFloat());
        DegMinSec latitude(captured.at(4).toInt(),captured.at(5).toInt(),captured.at(6).toFloat());
        qDebug() << "lat: " << latitude.toDMSString();
        qDebug() << "lon: " << longitude.toDMSString();

        points.at(position) = PointWorldCoord(longitude.toDecimalDegress(),latitude.toDecimalDegress());
        createPolygon();
        emit areaChanged(polygon);
        palette.setColor(QPalette::Foreground,Qt::black);;
    }

    else palette.setColor(QPalette::Foreground,Qt::red);
    edit->setPalette(palette);
}
예제 #7
0
void RoundedRectItem::setRoundedCorners(unsigned corners)
{
	if(corners > ALL_CORNERS)
		corners=ALL_CORNERS;

	this->corners=corners;
	createPolygon();
}
예제 #8
0
파일: polygon.c 프로젝트: Almamu/portalDS
void clipSegmentPlane(plane_struct* pl, polygon_struct** o, polygon_struct* pp1, polygon_struct* pp2)
{
	if(!pl || !o)return;
	const vect3D v1=pp1->v;const vect3D v2=pp2->v;
	int32 val1=evaluatePlanePoint(pl,v1);
	int32 val2=evaluatePlanePoint(pl,v2);
	// const int32 val1=pp1->val;
	// const int32 val2=pp2->val=evaluatePlanePoint(pl,v2);
	if(val1>=0)
	{
		polygon_struct* p=createPolygon(v1);
		if(!p)return;
		p->next=*o;
		*o=p;
		if(val2<0)
		{
			vect3D dir=vectDifference(v2,v1);
			dir=vect(dir.x<<8,dir.y<<8,dir.z<<8); //improves precision, but limits polygon size; so be careful not to use polygons that are too big
			int32 dist=magnitude(dir); //not the actual distance between v1 and v2 but intersectSegmentPlane doesn't need it so...
			dir=divideVect(dir,dist);
			
			vect3D v=intersectSegmentPlane(pl,v1,dir,dist);
			
			p=createPolygon(v);
			if(!p)return;
			p->next=*o;
			*o=p;
		}
	}else{
		if(val2>=0)
		{
			vect3D dir=vectDifference(v2,v1);
			dir=vect(dir.x<<8,dir.y<<8,dir.z<<8); //improves precision, but limits polygon size; so be careful not to use polygons that are too big
			int32 dist=magnitude(dir); //not the actual distance between v1 and v2 but intersectSegmentPlane doesn't need it so...
			dir=divideVect(dir,dist);
			
			vect3D v=intersectSegmentPlane(pl,v1,dir,dist);
			
			polygon_struct* p=createPolygon(v);
			if(!p)return;
			p->next=*o;
			*o=p;
		}
	}
}
예제 #9
0
void AreaSettingsDialog::onPointSelected(PointWorldCoord point)
{
    if(!PointToSelectOnMap) return;
    points.at(PointToSelectOnMap-1) = point;
    PointToSelectOnMap = 0;
    createPolygon();
    fillLineEdits();
    show();
    emit areaChanged(polygon);
}
void QGeoTiledMapPolygonObjectInfo::pathChanged(const QList<QGeoCoordinate> &path)
{
    points = createPolygon(polygon->path(), tiledMapData, true);
    if (points.size() >= 3) {
        polygonItem->setPolygon(points);
        setValid(true);
    } else {
        setValid(false);
    }
    updateItem();
}
예제 #11
0
void ObjModel::makeFace(vec3_t face[], int numPts, bool isTextured)	{
	polygon_t* poly = createPolygon();

	// set the material name
	strcpy(poly->materialName, curMat);

	if( strcmp(curMat, "(null)") )
		poly->hasMaterial = true;
	else
		poly->hasMaterial = false;

	poly->isTextured = isTextured;

	// FIXME Account for models without normals
	poly->hasNormals = true;


	// IMPORTANT: Face values aren't zero based, they begin at 1
	// this poses the -1 onto the face index, we store in zero based vector
	poly->numPoints = numPts;
	for(int x=0; x < numPts; x++)	{
		poly->points[x][0] = v[(face[x][0]-1)][0];
		poly->points[x][1] = v[(face[x][0]-1)][1];
		poly->points[x][2] = v[(face[x][0]-1)][2];

		if( isTextured )	{
			poly->texpts[x][0] = vt[(face[x][1]-1)][0];
			poly->texpts[x][1] = vt[(face[x][1]-1)][1];
			poly->texpts[x][2] = vt[(face[x][1]-1)][2];
		}

		poly->normpts[x][0] = vn[(face[x][2]-1)][0];
		poly->normpts[x][1] = vn[(face[x][2]-1)][1];
		poly->normpts[x][2] = vn[(face[x][2]-1)][2];
	}

	polygonListCount++;
	polygonList = doublyLinkPolygons(polygonList, poly);

#ifdef OBJDEBUG
	int tempCount = 0;

	polygon_t* t = polygonList;
	while( t )	{
		tempCount++;
		t = t->next;
	}
	Con_print("Running polygon count: %d", polygonListCount);
	Con_print("Confirmed polygon count: %d", tempCount);
#endif
}
예제 #12
0
void AreaSettingsDialog::restore()
{
    points.clear();
    points.push_back(PointWorldCoord( 20.4617, 50.7831));
    points.push_back(PointWorldCoord( 20.4627, 50.7828));
    points.push_back(PointWorldCoord( 20.4614, 50.782));
    points.push_back(PointWorldCoord( 20.4603, 50.7824));

    ui->lineEdit_p1->setText(DegMinSec(points.at(0).longitude()).toDMSString() + " x " + DegMinSec(points.at(0).latitude()).toDMSString());
    ui->lineEdit_p2->setText(DegMinSec(points.at(1).longitude()).toDMSString() + " x " + DegMinSec(points.at(1).latitude()).toDMSString());
    ui->lineEdit_p3->setText(DegMinSec(points.at(2).longitude()).toDMSString() + " x " + DegMinSec(points.at(2).latitude()).toDMSString());
    ui->lineEdit_p4->setText(DegMinSec(points.at(3).longitude()).toDMSString() + " x " + DegMinSec(points.at(3).latitude()).toDMSString());
    createPolygon();
    emit areaChanged(polygon);
}
/*----------------------------------------------------------------------------*/
void ChannelEdit :: mousePressEvent(QMouseEvent *event)
{
  if(m_audioOpened)
  {
    qreal dX = (qreal)width() / (qreal) m_windowSize;
    if(effectController->mode() == EffectController::SelectMode)
    {
      int size = effects.size();
      int i;
      for(i = 0; i < size; i++)
      {
        EffectProperties *prop = effects[i];
        if(prop->channel() == m_channelId)
        {
          int pos = (int)(dX * (audioController->duration2quants(prop->timeStart()) - m_startPosition));
          QPolygon pol = createPolygon(pos);
          if(pol.containsPoint(event->pos(),Qt::OddEvenFill))
          {
            effectController->selectEffect(prop->id());
            m_selected = prop->id();
            break;
          }
        }
      }
      if(i >= size)
      {
        effectController->selectEffect(-1);
        m_selected = -1;
      }
    }
    else
    if(effectController->mode() == EffectController::AddMode)
    {
      qreal d =  (qreal) m_windowSize/ (qreal)width();
      EffectProperties *prop = effectController->newEffect(effectController->effectToAdd(), m_channelId);
      prop->setTimeStart(audioController->quants2duration(m_startPosition + (qint64)(event->pos().x() * d)));
      effectController->selectEffect(prop->id());
      effectController->setMode(EffectController::SelectMode);
    }
  }

  Inherited::mousePressEvent(event);
}
예제 #14
0
파일: pascal.cpp 프로젝트: magdov/Diagonals
int main() {
   int n, a;

   Vert vertices;
   std::vector<int> distances;
   std::vector<int> toConsider;
   std::set<std::vector<int>,CompareResults> results;

   printf("Liczba wierzcholkow wielokata: \n");
   scanf("%d", &n);

   createPolygon(n, vertices);

   printf("Konfiguracja do zbadania:\n");
   
   for (int i = 0; i < 6; ++i) {
       scanf("%d", &a);
       distances.push_back(a);
   }

   transformDistancesToVertex(distances, toConsider);
   checkAllPairs(toConsider, vertices, results);
   writeResults(results);
}
예제 #15
0
void RoundedRectItem::setRect(const QRectF &rect)
{
	QGraphicsRectItem::setRect(rect);
	createPolygon();
}
예제 #16
0
void RoundedRectItem::setBorderRadius(double radius)
{
	this->radius=radius;
	createPolygon();
}
/*----------------------------------------------------------------------------*/
void ChannelEdit :: paintEvent(QPaintEvent *event)
{
  QPainter painter(this);

  painter.fillRect(rect(), m_bgColor);
  painter.setPen(Qt::darkCyan);
  painter.drawText(QRectF(0,0,50, height()),
                   Qt::AlignCenter,
                   tr("Channel\n%1").arg(QString::number(m_channelId)));
  if(m_audioOpened)
  {
    qreal dX = (qreal)width() / (qreal) m_windowSize;

    QPen pen(m_markerColor);
    painter.setPen(pen);
    //Draw position line
    painter.drawLine(QPointF(dX * (m_position - m_startPosition), 0), QPointF(dX * (m_position - m_startPosition), height()));

    QPen pen1(m_fgColor);
    painter.setPen(pen1);


    int size = effects.size();
    for(int i = 0; i < size; i++)
    {
      EffectProperties *prop = effects[i];
      int pos = (int)(dX * (audioController->duration2quants(prop->timeStart()) - m_startPosition));
      painter.drawLine(QPoint(pos, 0), QPoint(pos, height()));
      if(prop->channel() < m_channelId)
      {
        //draw bottom arrow
        painter.drawLine(QPoint(pos - 2, height() - 8), QPoint(pos, height()));
        painter.drawLine(QPoint(pos + 2, height() - 8), QPoint(pos, height()));
      }
      else
      if(prop->channel() > m_channelId)
      {
        //draw top arrow
        painter.drawLine(QPoint(pos - 2, 8), QPoint(pos, 0));
        painter.drawLine(QPoint(pos + 2, 8), QPoint(pos, 0));
      }
      else
//      if(prop->channel() == m_channelId)
      {
        //draw effect
        if(effectController->effectSelected() == prop->id())
        {
          QBrush brush(Qt::darkBlue);
          painter.setBrush(brush);
        }
        else
        {
          QBrush brush(Qt::yellow);
          painter.setBrush(brush);
        }

        QPolygon pol = createPolygon(pos);
        painter.drawPolygon(pol);
        painter.drawPixmap(QRect(pos - 15, 1, 30, 30), effectController->effectIcon(prop->effectId()));
/*
        qreal radius = (height() - 10) / 2;
        qreal left = pos - radius;
        qreal top = 5;

        QRectF r(left, top, 2 * radius, 2 * radius);
        painter.drawEllipse(r);
*/
      }
    }
  }

  Inherited::paintEvent(event);
}