Exemplo n.º 1
0
void TimeLine::addPoint(int _x, int _y){
    addPoint(ofPoint(_x,_y));
}
void TubeGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
	buffer.rebaseOffset();
	buffer.estimateVertexCount((mNumSegHeight+1)*(mNumSegBase+1)*2+(mNumSegBase+1)*4);
	buffer.estimateIndexCount(6*(mNumSegBase+1)*mNumSegHeight*2+6*mNumSegBase*2);

	Real deltaAngle = (Math::TWO_PI / mNumSegBase);
	Real deltaHeight = mHeight/(Real)mNumSegHeight;
	int offset = 0;

	for (unsigned int i = 0; i <=mNumSegHeight; i++)
		for (unsigned int j = 0; j<=mNumSegBase; j++)
		{
			Real x0 = mOuterRadius * cosf(j*deltaAngle);
			Real z0 = mOuterRadius * sinf(j*deltaAngle);
			addPoint(buffer, Vector3(x0, i*deltaHeight, z0),
			         Vector3(x0,0,z0).normalisedCopy(),
			         Vector2(j/(Real)mNumSegBase, i/(Real)mNumSegHeight));

			if (i != mNumSegHeight)
			{
				buffer.index(offset + mNumSegBase + 1);
				buffer.index(offset);
				buffer.index(offset + mNumSegBase);
				buffer.index(offset + mNumSegBase + 1);
				buffer.index(offset + 1);
				buffer.index(offset);
			}
			offset ++;
		}

	for (unsigned int i = 0; i <=mNumSegHeight; i++)
		for (unsigned int j = 0; j<=mNumSegBase; j++)
		{
			Real x0 = mInnerRadius * cosf(j*deltaAngle);
			Real z0 = mInnerRadius * sinf(j*deltaAngle);
			addPoint(buffer, Vector3(x0, i*deltaHeight, z0),
			         -Vector3(x0,0,z0).normalisedCopy(),
			         Vector2(j/(Real)mNumSegBase, i/(Real)mNumSegHeight));

			if (i != mNumSegHeight)
			{
				buffer.index(offset + mNumSegBase + 1);
				buffer.index(offset + mNumSegBase);
				buffer.index(offset);
				buffer.index(offset + mNumSegBase + 1);
				buffer.index(offset);
				buffer.index(offset + 1);
			}
			offset ++;
		}


	//low cap
	for (unsigned int j=0; j<=mNumSegBase; j++)
	{
		Real x0 = mInnerRadius * cosf(j*deltaAngle);
		Real z0 = mInnerRadius * sinf(j*deltaAngle);

		addPoint(buffer, Vector3(x0, 0.0f, z0),
		         Vector3::NEGATIVE_UNIT_Y,
		         Vector2(j/(Real)mNumSegBase,1.));

		x0 = mOuterRadius * cosf(j*deltaAngle);
		z0 = mOuterRadius * sinf(j*deltaAngle);

		addPoint(buffer, Vector3(x0, 0.0f, z0),
		         Vector3::NEGATIVE_UNIT_Y,
		         Vector2(j/(Real)mNumSegBase,0.));

		if (j!=mNumSegBase)
		{
			buffer.index(offset);
			buffer.index(offset+1);
			buffer.index(offset+3);
			buffer.index(offset+2);
			buffer.index(offset);
			buffer.index(offset+3);
		}
		offset+=2;
	}


	//high cap
	for (unsigned int j=0; j<=mNumSegBase; j++)
	{
		Real x0 = mInnerRadius * cosf(j*deltaAngle);
		Real z0 = mInnerRadius * sinf(j*deltaAngle);

		addPoint(buffer, Vector3(x0, mHeight, z0),
		         Vector3::UNIT_Y,
		         Vector2(j/(Real)mNumSegBase,0.));

		x0 = mOuterRadius * cosf(j*deltaAngle);
		z0 = mOuterRadius * sinf(j*deltaAngle);

		addPoint(buffer, Vector3(x0, mHeight, z0),
		         Vector3::UNIT_Y,
		         Vector2(j/(Real)mNumSegBase,1.));

		if (j!=mNumSegBase)
		{
			buffer.index(offset+1);
			buffer.index(offset);
			buffer.index(offset+3);
			buffer.index(offset);
			buffer.index(offset+2);
			buffer.index(offset+3);
		}
		offset+=2;
	}
}
Exemplo n.º 3
0
// Assignment operator
void ColourScale::operator=(const ColourScale& source)
{
    clear();
    useHSV_ = source.useHSV_;
    for (ColourScalePoint* csp = source.points_.first(); csp != NULL; csp = csp->next) addPoint( csp->value(), csp->colour() );
    interpolated_ = source.interpolated_;
}
Exemplo n.º 4
0
/// add each vertex of the Triangle      
void Bbox::addTriangle(const Triangle &t) {   
    addPoint( t.p[0] );
    addPoint( t.p[1] );
    addPoint( t.p[2] );
    return;
}
Exemplo n.º 5
0
	//-----------------------------------------------------------------------
	void Extruder::_extrudeBodyImpl(TriangleBuffer& buffer, const Shape* shapeToExtrude) const
	{
		assert(mExtrusionPath && shapeToExtrude && "Shape and Path must not be null!");
		unsigned int numSegPath = mExtrusionPath->getSegCount();
		unsigned int numSegShape = shapeToExtrude->getSegCount();
		assert(numSegPath>0 && numSegShape>0 && "Shape and path must contain at least two points");
				
		Real totalPathLength = mExtrusionPath->getTotalLength();
		Real totalShapeLength = shapeToExtrude->getTotalLength();
		
		// Merge shape and path with tracks
		Ogre::Real lineicPos=0.;
		Path path = *mExtrusionPath;
		if (mRotationTrack)
			path = path.mergeKeysWithTrack(*mRotationTrack);
		if (mScaleTrack)
			path = path.mergeKeysWithTrack(*mScaleTrack);
		if (mPathTextureTrack)
			path = path.mergeKeysWithTrack(*mPathTextureTrack);
		numSegPath = path.getSegCount();
		Shape shape = *shapeToExtrude;
		if (mShapeTextureTrack)
			shape = shape.mergeKeysWithTrack(*mShapeTextureTrack);
		numSegShape = shape.getSegCount();
		
		// Estimate vertex and index count
		buffer.rebaseOffset();
		buffer.estimateIndexCount(numSegShape*numSegPath*6);
		buffer.estimateVertexCount((numSegShape+1)*(numSegPath+1));
				
		Vector3 oldup;
		for (unsigned int i = 0; i <= numSegPath; ++i)
		{
			Vector3 v0 = path.getPoint(i);
			Vector3 direction = path.getAvgDirection(i);

			Quaternion q = Utils::_computeQuaternion(direction);
						
			Radian angle = (q*Vector3::UNIT_Y).angleBetween(oldup);
			if (i>0 && angle>(Radian)Math::HALF_PI/2.)
			{
				q = Utils::_computeQuaternion(direction, oldup);
			}
			oldup = q * Vector3::UNIT_Y;

			Real scale=1.;
					
			if (i>0) lineicPos += (v0-path.getPoint(i-1)).length();
			
			// Get the values of angle and scale
			if (mRotationTrack)
			{
				Real angle;
				angle = mRotationTrack->getValue(lineicPos, lineicPos / totalPathLength, i);

				q = q*Quaternion((Radian)angle, Vector3::UNIT_Z);
			}
			if (mScaleTrack)
			{
				scale = mScaleTrack->getValue(lineicPos, lineicPos / totalPathLength, i);
			}
			Real uTexCoord;
			if (mPathTextureTrack)
				uTexCoord = mPathTextureTrack->getValue(lineicPos, lineicPos / totalPathLength, i);
			else
				uTexCoord = lineicPos / totalPathLength;
			
			Real lineicShapePos = 0.;
			// Insert new points
			for (unsigned int j =0; j <= numSegShape; ++j)
			{				
				Vector2 vp2 = shapeToExtrude->getPoint(j);
				//Vector2 vp2direction = shapeToExtrude->getAvgDirection(j);
				Vector2 vp2normal = shapeToExtrude->getAvgNormal(j);
				Vector3 vp(vp2.x, vp2.y, 0);
				Vector3 normal(vp2normal.x, vp2normal.y, 0);							
				buffer.rebaseOffset();
				Vector3 newPoint = v0+q*(scale*vp);				
				if (j>0)
					lineicShapePos += (vp2 - shape.getPoint(j-1)).length();
				Real vTexCoord;
				if (mShapeTextureTrack)
					vTexCoord = mShapeTextureTrack->getValue(lineicShapePos, lineicShapePos / totalShapeLength, j);
				else
					vTexCoord = lineicShapePos / totalShapeLength;				

				addPoint(buffer, newPoint,
					q*normal, 
					Vector2(uTexCoord, vTexCoord));

				if (j <numSegShape && i <numSegPath)
				{		
					if (shapeToExtrude->getOutSide() == SIDE_LEFT)
					{
						buffer.triangle(numSegShape + 1, numSegShape + 2, 0);
						buffer.triangle(0, numSegShape + 2, 1);
					}
					else 
					{
						buffer.triangle(numSegShape + 2, numSegShape + 1, 0);
						buffer.triangle(numSegShape + 2, 0, 1);
					}
				}			
			}			
		}			
	}
Exemplo n.º 6
0
bool Statsdb::addPoint(StatKey *sk,StatData *sd,StatState *ss , Label *label){
	 
	 // if measuring "queries per second" or "disk reads per sec"
	 // then compare our start time to start time of the operation
	 // before us.
	 float val;
	 if      ( label->m_graphType == GRAPH_QUANTITY )
		 val = sd->m_totalQuantity;
	 else if ( label->m_graphType == GRAPH_OPS )
		 val = sd->m_totalOps;
	 else if ( label->m_graphType == GRAPH_LATENCY )
		 val = sd->m_totalTime / sd->m_totalOps;
	 else if ( label->m_graphType == GRAPH_RATE )
		 val = sd->m_totalQuantity / sd->m_totalTime;
	 else if ( label->m_graphType == GRAPH_QUANTITY_PER_OP )
		 val = sd->m_totalQuantity / sd->m_totalOps;
	 else { g_process.shutdownAbort(true); }

	 // remove tail. this ringbuffer is used to make the moving average.
	 int32_t k = ss->m_i;
	 for ( ; ss->m_valid[k] ; ) {
		 // remove from accumulated sum from moving avg calc
		 ss->m_sumVal -= ss->m_ringBuf[k];
		 // this too
		 ss->m_numSamples--;
		 // invalidate it
		 ss->m_valid[k] = false;
		 // stop if time within range
		 if ( ss->m_ringBufTime[k] >= sk->m_time1 - m_samples )
			 break;
		 // otherwise, keep removing samples from moving avg
		 // if outside of time range. wrap around when k hits
		 // m_samples. thus, the "ring" in "ring buffer"
		 if ( ++k >= m_samples ) k = 0;
	 }

	 // must not be valid!
	 if ( ss->m_valid[ss->m_i] ) { g_process.shutdownAbort(true); }

	 // we are valid now
	 ss->m_valid[ss->m_i] = true; 

	 // set time stamp
	 ss->m_ringBufTime[ss->m_i] = sk->m_time1;

	 // set value
	 ss->m_ringBuf[ss->m_i] = val;
	 
	 // show the individual point
	 //if ( doLatency )
	 //	logf(LOG_DEBUG,"statsdb: (%" PRIu64", %" PRIu64") [%s]",
	 //	     sp->getTime1(),delta,label->m_label);
	 //else
	 //	logf(LOG_DEBUG,"statsdb: (%" PRIu64", %.03f) [%s]",
	 //	     sp->getTime1(),quantity,label->m_label);
	 
	 // inc and wrap
	 if ( ++ss->m_i >= m_samples ) ss->m_i = 0;
	 
	 // add it up
	 ss->m_numSamples += 1;
	 // . quantity should always be one
	 ss->m_sumVal  += val;
	 
	 // do not destroy ourselves
	 if ( ss->m_numSamples > m_samples ) 
		 log("statsdb: bad engineer.");
	 
	 // . do not add it if before m_t1
	 // . we set m_startKey lower than m_t1 in order to get
	 //   a running start on our moving average algorithm
	 if ( sk->m_time1 < m_t1 ) return true;

	 // do not start showing points until we got 20 so we can
	 // make a decent average and avoid initial spikes!!!
	 //if ( ss->m_numSamples < m_samples ) // 5 )
	 //	continue;
	 
	 // . plot that point
	 // . should make a line between it and the last point added
	 //if(! addPoint ( sp->getTime1() , val , colorRGB , weight ) )

	 // now the moving average at time "sk->m_time1" is
	 // ss->m_sumVal / (float)ss->m_numSamples, so add that point to
	 // our graph.
	 if ( ! addPoint ( sk->m_time1 , 
			   ss->m_sumVal / (float)ss->m_numSamples ,
			   label->m_graphHash , 
			   1 , 
			   ss ) )
		 return false;

	return true;
}
Exemplo n.º 7
0
	BufferElementGroupSPtr Submesh::addPoint( Point3r const & value )
	{
		return addPoint( value[0], value[1], value[2] );
	}
Exemplo n.º 8
0
void TriangleBrush::addPoint(ofVec2f pos){
    addPoint(history, pos);
}
Exemplo n.º 9
0
bool  HullLibrary::CleanupVertices(unsigned int svcount,
                                   const btVector3 *svertices,
                                   unsigned int stride,
                                   unsigned int &vcount,       // output number of vertices
                                   btVector3 *vertices,                 // location to store the results.
                                   btScalar  normalepsilon,
                                   btVector3& scale)
{
    if ( svcount == 0 ) return false;

    m_vertexIndexMapping.resize(0);


#define EPSILON btScalar(0.000001) /* close enough to consider two btScalaring point numbers to be 'the same'. */

    vcount = 0;

    btScalar recip[3]= {0.f,0.f,0.f};

    if ( scale )
    {
        scale[0] = 1;
        scale[1] = 1;
        scale[2] = 1;
    }

    btScalar bmin[3] = {  FLT_MAX,  FLT_MAX,  FLT_MAX };
    btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };

    const char *vtx = (const char *) svertices;

//	if ( 1 )
    {
        for (unsigned int i=0; i<svcount; i++)
        {
            const btScalar *p = (const btScalar *) vtx;

            vtx+=stride;

            for (int j=0; j<3; j++)
            {
                if ( p[j] < bmin[j] ) bmin[j] = p[j];
                if ( p[j] > bmax[j] ) bmax[j] = p[j];
            }
        }
    }

    btScalar dx = bmax[0] - bmin[0];
    btScalar dy = bmax[1] - bmin[1];
    btScalar dz = bmax[2] - bmin[2];

    btVector3 center;

    center[0] = dx*btScalar(0.5) + bmin[0];
    center[1] = dy*btScalar(0.5) + bmin[1];
    center[2] = dz*btScalar(0.5) + bmin[2];

    if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || svcount < 3 )
    {

        btScalar len = FLT_MAX;

        if ( dx > EPSILON && dx < len ) len = dx;
        if ( dy > EPSILON && dy < len ) len = dy;
        if ( dz > EPSILON && dz < len ) len = dz;

        if ( len == FLT_MAX )
        {
            dx = dy = dz = btScalar(0.01); // one centimeter
        }
        else
        {
            if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge.
            if ( dy < EPSILON ) dy = len * btScalar(0.05);
            if ( dz < EPSILON ) dz = len * btScalar(0.05);
        }

        btScalar x1 = center[0] - dx;
        btScalar x2 = center[0] + dx;

        btScalar y1 = center[1] - dy;
        btScalar y2 = center[1] + dy;

        btScalar z1 = center[2] - dz;
        btScalar z2 = center[2] + dz;

        addPoint(vcount,vertices,x1,y1,z1);
        addPoint(vcount,vertices,x2,y1,z1);
        addPoint(vcount,vertices,x2,y2,z1);
        addPoint(vcount,vertices,x1,y2,z1);
        addPoint(vcount,vertices,x1,y1,z2);
        addPoint(vcount,vertices,x2,y1,z2);
        addPoint(vcount,vertices,x2,y2,z2);
        addPoint(vcount,vertices,x1,y2,z2);

        return true; // return cube


    }
    else
    {
        if ( scale )
        {
            scale[0] = dx;
            scale[1] = dy;
            scale[2] = dz;

            recip[0] = 1 / dx;
            recip[1] = 1 / dy;
            recip[2] = 1 / dz;

            center[0]*=recip[0];
            center[1]*=recip[1];
            center[2]*=recip[2];

        }

    }



    vtx = (const char *) svertices;

    for (unsigned int i=0; i<svcount; i++)
    {
        const btVector3 *p = (const btVector3 *)vtx;
        vtx+=stride;

        btScalar px = p->getX();
        btScalar py = p->getY();
        btScalar pz = p->getZ();

        if ( scale )
        {
            px = px*recip[0]; // normalize
            py = py*recip[1]; // normalize
            pz = pz*recip[2]; // normalize
        }

//		if ( 1 )
        {
            unsigned int j;

            for (j=0; j<vcount; j++)
            {
                /// XXX might be broken
                btVector3& v = vertices[j];

                btScalar x = v[0];
                btScalar y = v[1];
                btScalar z = v[2];

                btScalar dx = fabsf(x - px );
                btScalar dy = fabsf(y - py );
                btScalar dz = fabsf(z - pz );

                if ( dx < normalepsilon && dy < normalepsilon && dz < normalepsilon )
                {
                    // ok, it is close enough to the old one
                    // now let us see if it is further from the center of the point cloud than the one we already recorded.
                    // in which case we keep this one instead.

                    btScalar dist1 = GetDist(px,py,pz,center);
                    btScalar dist2 = GetDist(v[0],v[1],v[2],center);

                    if ( dist1 > dist2 )
                    {
                        v[0] = px;
                        v[1] = py;
                        v[2] = pz;

                    }

                    break;
                }
            }

            if ( j == vcount )
            {
                btVector3& dest = vertices[vcount];
                dest[0] = px;
                dest[1] = py;
                dest[2] = pz;
                vcount++;
            }
            m_vertexIndexMapping.push_back(j);
        }
    }

    // ok..now make sure we didn't prune so many vertices it is now invalid.
//	if ( 1 )
    {
        btScalar bmin[3] = {  FLT_MAX,  FLT_MAX,  FLT_MAX };
        btScalar bmax[3] = { -FLT_MAX, -FLT_MAX, -FLT_MAX };

        for (unsigned int i=0; i<vcount; i++)
        {
            const btVector3& p = vertices[i];
            for (int j=0; j<3; j++)
            {
                if ( p[j] < bmin[j] ) bmin[j] = p[j];
                if ( p[j] > bmax[j] ) bmax[j] = p[j];
            }
        }

        btScalar dx = bmax[0] - bmin[0];
        btScalar dy = bmax[1] - bmin[1];
        btScalar dz = bmax[2] - bmin[2];

        if ( dx < EPSILON || dy < EPSILON || dz < EPSILON || vcount < 3)
        {
            btScalar cx = dx*btScalar(0.5) + bmin[0];
            btScalar cy = dy*btScalar(0.5) + bmin[1];
            btScalar cz = dz*btScalar(0.5) + bmin[2];

            btScalar len = FLT_MAX;

            if ( dx >= EPSILON && dx < len ) len = dx;
            if ( dy >= EPSILON && dy < len ) len = dy;
            if ( dz >= EPSILON && dz < len ) len = dz;

            if ( len == FLT_MAX )
            {
                dx = dy = dz = btScalar(0.01); // one centimeter
            }
            else
            {
                if ( dx < EPSILON ) dx = len * btScalar(0.05); // 1/5th the shortest non-zero edge.
                if ( dy < EPSILON ) dy = len * btScalar(0.05);
                if ( dz < EPSILON ) dz = len * btScalar(0.05);
            }

            btScalar x1 = cx - dx;
            btScalar x2 = cx + dx;

            btScalar y1 = cy - dy;
            btScalar y2 = cy + dy;

            btScalar z1 = cz - dz;
            btScalar z2 = cz + dz;

            vcount = 0; // add box

            addPoint(vcount,vertices,x1,y1,z1);
            addPoint(vcount,vertices,x2,y1,z1);
            addPoint(vcount,vertices,x2,y2,z1);
            addPoint(vcount,vertices,x1,y2,z1);
            addPoint(vcount,vertices,x1,y1,z2);
            addPoint(vcount,vertices,x2,y1,z2);
            addPoint(vcount,vertices,x2,y2,z2);
            addPoint(vcount,vertices,x1,y2,z2);

            return true;
        }
    }

    return true;
}
Exemplo n.º 10
0
bool DirtyListVisit::add(Feature* F)
{
    if (DeletePass) return false;
    if (F->isDeleted()) return false;
    // TODO Needed to add children of updated imported features. Sure there is no advert cases?
    //if (!F->isDirty()) return false;

    // Allow "Force Upload" of OSM objects
    //if (F->hasOSMId()) return false;

    if (Future.willBeErased(F))
        return EraseFromHistory;
    for (int i=0; i<AlreadyAdded.size(); ++i)
        if (AlreadyAdded[i] == F)
            return EraseResponse[i];

    bool x;
    if (Node* Pt = CAST_NODE(F))
    {
        if (Pt->isInteresting())
        {
            if (F->hasOSMId())
                x = updatePoint(Pt);
            else
                x = addPoint(Pt);
            AlreadyAdded.push_back(F);
            EraseResponse.push_back(x);
            return x;
        }
        else
            return EraseFromHistory;
    }
    else if (Way* R = dynamic_cast<Way*>(F))
    {
        for (int i=0; i<R->size(); ++i)
            if (!R->getNode(i)->isVirtual())
                if (!(R->get(i)->hasOSMId()) && notYetAdded(R->get(i)))
                    add(R->get(i));
        if (F->hasOSMId())
            x = updateRoad(R);
        else
            x = addRoad(R);
        AlreadyAdded.push_back(F);
        EraseResponse.push_back(x);
        return x;
    }
    else if (Relation* Rel = dynamic_cast<Relation*>(F))
    {
        for (int i=0; i<Rel->size(); ++i)
            if (!(Rel->get(i)->hasOSMId()) && notYetAdded(Rel->get(i)))
                add(Rel->get(i));
        if (F->hasOSMId())
            x = updateRelation(Rel);
        else
            x = addRelation(Rel);
        AlreadyAdded.push_back(F);
        EraseResponse.push_back(x);
        return x;
    }
    return EraseFromHistory;
}
Exemplo n.º 11
0
void TIGLViewerWindow::connectSignals()
{
    connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
    connect(openAction, SIGNAL(triggered()), this, SLOT(open()));
    connect(openScriptAction, SIGNAL(triggered()), this, SLOT(openScript()));
    connect(closeAction, SIGNAL(triggered()), this, SLOT(closeConfiguration()));

    for (int i = 0; i < MaxRecentFiles; ++i) {
        recentFileActions[i] = new QAction(this);
        recentFileActions[i]->setVisible(false);
        connect(recentFileActions[i], SIGNAL(triggered()),
                this, SLOT(openRecentFile()));
    }

    connect(saveAction, SIGNAL(triggered()), this, SLOT(save()));
    connect(saveScreenshotAction, SIGNAL(triggered()), this, SLOT(makeScreenShot()));
    connect(setBackgroundAction, SIGNAL(triggered()), this, SLOT(setBackgroundImage()));
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
    connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt()));

    // Misc drawing actions
    connect(drawPointAction, SIGNAL(triggered()), this, SLOT(drawPoint()));
    connect(drawVectorAction, SIGNAL(triggered()), this, SLOT(drawVector()));
    

    // view->actions menu
    connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents()));
    connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll()));
    //connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea()));
    connect(zoomAction, SIGNAL(triggered()),myOCC, SLOT(zoom()));
    connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan()));
    connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation()));
    connect(selectAction, SIGNAL(triggered()), myOCC, SLOT(selecting()));

    // view->grid menu
    connect(gridOnAction, SIGNAL(toggled(bool)), myScene, SLOT(toggleGrid(bool)));
    connect(gridXYAction, SIGNAL(triggered()), myScene, SLOT(gridXY()));
    connect(gridXZAction, SIGNAL(triggered()), myScene, SLOT(gridXZ()));
    connect(gridYZAction, SIGNAL(triggered()), myScene, SLOT(gridYZ()));
    connect(gridRectAction, SIGNAL(triggered()), myScene, SLOT(gridRect()));
    connect(gridCircAction, SIGNAL(triggered()), myScene, SLOT(gridCirc()));

    // Standard View
    connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront()));
    connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack()));
    connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop()));
    connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom()));
    connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft()));
    connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight()));
    connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo()));
    connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid()));
    connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset()));
    connect(viewZoomInAction, SIGNAL(triggered()), myOCC, SLOT(zoomIn()));
    connect(viewZoomOutAction, SIGNAL(triggered()), myOCC, SLOT(zoomOut()));
    connect(showConsoleAction, SIGNAL(toggled(bool)), consoleDockWidget, SLOT(setVisible(bool)));
    connect(consoleDockWidget, SIGNAL(visibilityChanged(bool)), showConsoleAction, SLOT(setChecked(bool)));
    connect(showWireframeAction, SIGNAL(toggled(bool)), myScene, SLOT(wireFrame(bool)));

    connect(openTimer, SIGNAL(timeout()), this, SLOT(reopenFile()));

    // The co-ordinates from the view
    connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
             this,   SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );

    // Add a point from the view
    connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)),
             this,   SLOT (addPoint    (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) );

    connect( myOCC, SIGNAL(sendStatus(const QString)), this,  SLOT  (statusMessage(const QString)) );

    connect(stdoutStream, SIGNAL(sendString(QString)), console, SLOT(output(QString)));
    connect(errorStream , SIGNAL(sendString(QString)), console, SLOT(output(QString)));

    connect(logDirect.get(), SIGNAL(newMessage(QString)), console, SLOT(output(QString)));

    connect(scriptEngine, SIGNAL(scriptResult(QString)), console, SLOT(output(QString)));
    connect(scriptEngine, SIGNAL(scriptError(QString)), console, SLOT(outputError(QString)));
    connect(scriptEngine, SIGNAL(evalDone()), console, SLOT(endCommand()));
    connect(console, SIGNAL(onChange(QString)), scriptEngine, SLOT(textChanged(QString)));
    connect(console, SIGNAL(onCommand(QString)), scriptEngine, SLOT(eval(QString)));

    connect(settingsAction, SIGNAL(triggered()), this, SLOT(changeSettings()));
}
Exemplo n.º 12
0
void Presenter::setupView()
{
    // Initialize the elements
    for(const auto& segment : m_model.segments())
    {
        addSegment(new SegmentView{&segment, m_style, m_view});
    }

    for(PointModel* pt : m_model.points())
    {
        addPoint(new PointView{pt, m_style, m_view});
    }

    // Setup the actions
    m_actions = new QActionGroup{this};
    m_actions->setExclusive(true);

    auto shiftact = new QAction{m_actions};
    shiftact->setCheckable(true);
    m_actions->addAction(shiftact);

    auto ctrlact = new QAction{m_actions};
    ctrlact->setCheckable(true);
    m_actions->addAction(ctrlact);

    m_actions->setEnabled(true);

    connect(shiftact, &QAction::toggled, this, [&] (bool b) {
        if(b)
        {
            editionSettings().setTool(Curve::Tool::SetSegment);
        }
        else
        {
            editionSettings().setTool(Curve::Tool::Select);
        }
    });
    connect(ctrlact, &QAction::toggled, this, [&] (bool b) {
        if(b)
        {
            editionSettings().setTool(Curve::Tool::Create);
        }
        else
        {
            editionSettings().setTool(Curve::Tool::Select);
        }
    });

    connect(m_view, &View::keyPressed, this, [=] (int key)
    {
        if(key == Qt::Key_Shift)
        {
            shiftact->setChecked(true);
        }
        if(key == Qt::Key_Control)
        {
            ctrlact->setChecked(true);
        }
    });

    connect(m_view, &View::keyReleased, this, [=] (int key)
    {
        if(key == Qt::Key_Shift)
        {
            shiftact->setChecked(false);
            editionSettings().setTool(Curve::Tool::Select);
        }
        if(key == Qt::Key_Control)
        {
            ctrlact->setChecked(false);
            editionSettings().setTool(Curve::Tool::Select);
        }
    });
}
Exemplo n.º 13
0
void QgsRubberBand::addGeometry( QgsGeometry* geom, QgsVectorLayer* layer )
{
  if ( !geom )
  {
    return;
  }

  //maprender object of canvas
  QgsMapRenderer* mr = mMapCanvas->mapRenderer();
  if ( !mr )
  {
    return;
  }

  int idx = mPoints.size();

  switch ( geom->wkbType() )
  {

    case QGis::WKBPoint:
    case QGis::WKBPoint25D:
    {
      double d = mMapCanvas->extent().width() * 0.005;
      QgsPoint pt;
      if ( layer )
      {
        pt = mr->layerToMapCoordinates( layer, geom->asPoint() );
      }
      else
      {
        pt = geom->asPoint();
      }
      addPoint( QgsPoint( pt.x() - d, pt.y() - d ), false, idx );
      addPoint( QgsPoint( pt.x() + d, pt.y() - d ), false, idx );
      addPoint( QgsPoint( pt.x() + d, pt.y() + d ), false, idx );
      addPoint( QgsPoint( pt.x() - d, pt.y() + d ), false, idx );
    }
    break;

    case QGis::WKBMultiPoint:
    case QGis::WKBMultiPoint25D:
    {
      double d = mMapCanvas->extent().width() * 0.005;
      QgsMultiPoint mpt = geom->asMultiPoint();
      for ( int i = 0; i < mpt.size(); ++i, ++idx )
      {
        QgsPoint pt = mpt[i];
        if ( layer )
        {
          addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() - d, pt.y() - d ) ), false, idx );
          addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() + d, pt.y() - d ) ), false, idx );
          addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() + d, pt.y() + d ) ), false, idx );
          addPoint( mr->layerToMapCoordinates( layer, QgsPoint( pt.x() - d, pt.y() + d ) ), false, idx );
        }
        else
        {
          addPoint( QgsPoint( pt.x() - d, pt.y() - d ), false, idx );
          addPoint( QgsPoint( pt.x() + d, pt.y() - d ), false, idx );
          addPoint( QgsPoint( pt.x() + d, pt.y() + d ), false, idx );
          addPoint( QgsPoint( pt.x() - d, pt.y() + d ), false, idx );
        }
      }
    }
    break;

    case QGis::WKBLineString:
    case QGis::WKBLineString25D:
    {
      QgsPolyline line = geom->asPolyline();
      for ( int i = 0; i < line.count(); i++ )
      {
        if ( layer )
        {
          addPoint( mr->layerToMapCoordinates( layer, line[i] ), false, idx );
        }
        else
        {
          addPoint( line[i], false, idx );
        }
      }
    }
    break;

    case QGis::WKBMultiLineString:
    case QGis::WKBMultiLineString25D:
    {
      mPoints.clear();

      QgsMultiPolyline mline = geom->asMultiPolyline();
      for ( int i = 0; i < mline.size(); ++i, ++idx )
      {
        QgsPolyline line = mline[i];

        if ( line.size() == 0 )
        {
          --idx;
        }

        for ( int j = 0; j < line.size(); ++j )
        {
          if ( layer )
          {
            addPoint( mr->layerToMapCoordinates( layer, line[j] ), false, idx );
          }
          else
          {
            addPoint( line[j], false, idx );
          }
        }
      }
    }
    break;

    case QGis::WKBPolygon:
    case QGis::WKBPolygon25D:
    {
      QgsPolygon poly = geom->asPolygon();
      QgsPolyline line = poly[0];
      for ( int i = 0; i < line.count(); i++ )
      {
        if ( layer )
        {
          addPoint( mr->layerToMapCoordinates( layer, line[i] ), false, idx );
        }
        else
        {
          addPoint( line[i], false, idx );
        }
      }
    }
    break;

    case QGis::WKBMultiPolygon:
    case QGis::WKBMultiPolygon25D:
    {
      mPoints.clear();

      QgsMultiPolygon multipoly = geom->asMultiPolygon();
      for ( int i = 0; i < multipoly.size(); ++i, ++idx )
      {
        QgsPolygon poly = multipoly[i];
        QgsPolyline line = poly[0];
        for ( int j = 0; j < line.count(); ++j )
        {
          if ( layer )
          {
            addPoint( mr->layerToMapCoordinates( layer, line[j] ), false, idx );
          }
          else
          {
            addPoint( line[j], false, idx );
          }
        }
      }
    }
    break;

    case QGis::WKBUnknown:
    default:
      return;
  }

  updateRect();
  update();
}
Exemplo n.º 14
0
void sampleCell::mousePressed(ofMouseEventArgs & args){
    tempPoint.x = args.x;
    tempPoint.y = args.y;
    addPoint();
}
Exemplo n.º 15
0
CollisionActor* CollisionActor::addPoint(float x, float y) {
  Ogre::Vector2 point(x, y);
  addPoint(point);
  return this;
}
Exemplo n.º 16
0
const Elem *
DiracKernel::addPointWithValidId(Point p, unsigned id)
{
  // The Elem we'll eventually return.  We can't return early on some
  // processors, because we may need to call parallel_only() functions in
  // the remainder of this scope.
  const Elem * return_elem = NULL;

  // May be set if the Elem is found in our cache, otherwise stays as NULL.
  const Elem * cached_elem = NULL;

  // OK, the user gave us an ID, let's see if we already have it...
  point_cache_t::iterator it = _point_cache.find(id);

  // Was the point found in a _point_cache on at least one processor?
  unsigned int i_found_it = static_cast<unsigned int>(it != _point_cache.end());
  unsigned int we_found_it = i_found_it;
  comm().max(we_found_it);

  // If nobody found it in their local caches, it means we need to
  // do the PointLocator look-up and update the caches.  This is
  // safe, because all processors have the same value of we_found_it.
  if (!we_found_it)
  {
    const Elem * elem = _dirac_kernel_info.findPoint(p, _mesh);

    // Only add the point to the cache on this processor if the Elem is local
    if (elem && (elem->processor_id() == processor_id()))
    {
      // Add the point to the cache...
      _point_cache[id] = std::make_pair(elem, p);

      // ... and to the reverse cache.
      std::vector<std::pair<Point, unsigned>> & points = _reverse_point_cache[elem];
      points.push_back(std::make_pair(p, id));
    }

    // Call the other addPoint() method.  This method ignores non-local
    // and NULL elements automatically.
    addPoint(elem, p, id);
    return_elem = elem;
  }

  // If the point was found in a cache, but not my cache, I'm not
  // responsible for it.
  //
  // We can't return early here: then we aren't allowed to call any more
  // parallel_only() functions in the remainder of this function!
  if (we_found_it && !i_found_it)
    return_elem = NULL;

  // This flag may be set by the processor that cached the Elem because it
  // needs to call findPoint() (due to moving mesh, etc.). If so, we will
  // call it at the end of the while loop below.
  bool i_need_find_point = false;

  // Now that we only cache local data, some processors may enter
  // this if statement and some may not.  Therefore we can't call
  // any parallel_only() functions inside this if statement.
  while (i_found_it)
  {
    // We have something cached, now make sure it's actually the same Point.
    // TODO: we should probably use this same comparison in the DiracKernelInfo code!
    Point cached_point = (it->second).second;

    if (cached_point.relative_fuzzy_equals(p))
    {
      // Find the cached element associated to this point
      cached_elem = (it->second).first;

      // If the cached element's processor ID doesn't match ours, we
      // are no longer responsible for caching it.  This can happen
      // due to adaptivity...
      if (cached_elem->processor_id() != processor_id())
      {
        // Update the caches, telling them to drop the cached Elem.
        // Analogously to the rest of the DiracKernel system, we
        // also return NULL because the Elem is non-local.
        updateCaches(cached_elem, NULL, p, id);
        return_elem = NULL;
        break; // out of while loop
      }

      bool active = cached_elem->active();
      bool contains_point = cached_elem->contains_point(p);

      // If the cached Elem is active and the point is still
      // contained in it, call the other addPoint() method and
      // return its result.
      if (active && contains_point)
      {
        addPoint(cached_elem, p, id);
        return_elem = cached_elem;
        break; // out of while loop
      }

      // Is the Elem not active (been refined) but still contains the point?
      // Then search in its active children and update the caches.
      else if (!active && contains_point)
      {
        // Get the list of active children
        std::vector<const Elem *> active_children;
        cached_elem->active_family_tree(active_children);

        // Linear search through active children for the one that contains p
        for (unsigned c = 0; c < active_children.size(); ++c)
          if (active_children[c]->contains_point(p))
          {
            updateCaches(cached_elem, active_children[c], p, id);
            addPoint(active_children[c], p, id);
            return_elem = active_children[c];
            break; // out of for loop
          }

        // If we got here without setting return_elem, it means the Point was
        // found in the parent element, but not in any of the active
        // children... this is not possible under normal
        // circumstances, so something must have gone seriously
        // wrong!
        if (!return_elem)
          mooseError("Error, Point not found in any of the active children!");

        break; // out of while loop
      }

      else if (
          // Is the Elem active but the point is not contained in it any
          // longer?  (For example, did the Mesh move out from under
          // it?)  Then we fall back to the expensive Point Locator
          // lookup.  TODO: we could try and do something more optimized
          // like checking if any of the active neighbors contains the
          // point.  Update the caches.
          (active && !contains_point) ||

          // The Elem has been refined *and* the Mesh has moved out
          // from under it, we fall back to doing the expensive Point
          // Locator lookup.  TODO: We could try and look in the
          // active children of this Elem's neighbors for the Point.
          // Update the caches.
          (!active && !contains_point))
      {
        i_need_find_point = true;
        break; // out of while loop
      }

      else
        mooseError("We'll never get here!");
    } // if (cached_point.relative_fuzzy_equals(p))
    else
      mooseError("Cached Dirac point ",
                 cached_point,
                 " already exists with ID: ",
                 id,
                 " and does not match point ",
                 p);

    // We only want one iteration of this while loop at maximum.
    i_found_it = false;
  } // while (i_found_it)

  // We are back to all processors here because we do not return
  // early in the code above...

  // Does we need to call findPoint() on all processors.
  unsigned int we_need_find_point = static_cast<unsigned int>(i_need_find_point);
  comm().max(we_need_find_point);

  if (we_need_find_point)
  {
    // findPoint() is a parallel-only function
    const Elem * elem = _dirac_kernel_info.findPoint(p, _mesh);

    updateCaches(cached_elem, elem, p, id);
    addPoint(elem, p, id);
    return_elem = elem;
  }

  return return_elem;
}
Exemplo n.º 17
0
void
StatefulPointSource::addPoints()
{
  addPoint(_p);
}
Exemplo n.º 18
0
void FreehandGeometry::addPoint(double x, double y)
{
    unsigned int thisTime = 0; //QT SDL_GetTicks();
	addPoint(x, y, thisTime);
}
Exemplo n.º 19
0
void initAFSM_ (
	surface_mesh *pm,
	CGMmodel model
) {
	int i, j, k, iLine, iSurface, iVert;

	int nVVert = CGM_NumVertices(model);
	int nLine = CGM_NumEdges(model);
	int nSurface = CGM_NumFaces(model);
	
	int vBegin, vEnd, iSurf, iNorm, iV_U;
	double tBegin, tEnd;
	double uMin, uMax, vMin, vMax;
	

	int bInverse, bCut, iLabel, nBoundTria=0;

	int nSub;
	int nVert;
	double x, y, z, u, p[3], uv[2], pmin[3], pmax[3];
	int *boundVert, *vVert;
	double *boundT;
	StrucLine3 *line;
	StrucSurface *surface;
	CGMvertex vertex;
	CGMedge edge;
	CGMface face;
	
	init(pm);
	user3initCGM(pm);

	CGM_ModelBoundingBox(model, pmin, pmax);
//	printf("BOX:%lf %lf %lf -- %lf %lf %lf\n", pmin[0], pmin[1], pmin[2], pmax[0], pmax[1], pmax[2]);
	pm->S0 = (pmax[0]-pmin[0]);
	if (pmax[1]-pmin[1] > pm->S0)  pm->S0 = pmax[1]-pmin[1];
	if (pmax[2]-pmin[2] > pm->S0)  pm->S0 = pmax[2]-pmin[2];
	pm->S0 *= surfacesizeratio;
//	printf("S0: %lf\n", S0);
	
	pm->boxcx = 0.5*(pmin[0]+pmax[0]);
	pm->boxcy = 0.5*(pmin[1]+pmax[1]);
	pm->boxcz = 0.5*(pmin[2]+pmax[2]);
	pm->boxsize = pmax[0]-pmin[0];
	if (pmax[1]-pmin[1]>pm->boxsize) pm->boxsize = pmax[1]-pmin[1];
	if (pmax[2]-pmin[2]>pm->boxsize) pm->boxsize = pmax[2]-pmin[2];

	vVert = (int*)myAlloc(nVVert*sizeof(int));
	for (i=0; i<nVVert; i++) {
		vertex = CGM_ithVertex(model, i);
		CGM_GetVertexCoords(vertex, p);
		vVert[i] = pm->nPoint;
		addPoint(pm, p[0], p[1], p[2]);
	}
	
	line = (StrucLine3 *)myAlloc(2*nLine * sizeof(StrucLine3) );

	for (iLine=0; iLine<nLine; iLine++) {
		edge = CGM_ithEdge(model, iLine);
		vBegin = CGM_VertexIndex(model, CGM_EdgeStartVertex(edge));
		vEnd   = CGM_VertexIndex(model, CGM_EdgeEndVertex(edge));
		nSub   = 1;
		line[iLine].vBegin = vBegin;
		line[iLine].vEnd   = vEnd;
		line[iLine].nSub   = nSub;
		line[iLine].sub = (StrucSub *)myAlloc(nSub * sizeof(StrucSub));
		iSurf = -1;
		iV_U  = iLine;
		tBegin = CGM_EdgeStartParam(edge);
		tEnd   = CGM_EdgeEndParam(edge);
		line[iLine].sub[0].iSurf = iSurf;
		line[iLine].sub[0].iV_U = iV_U;
		line[iLine].sub[0].tBegin = tBegin;
		line[iLine].sub[0].tEnd = tEnd;
	}

	surface = (StrucSurface *)myAlloc(nSurface * sizeof(StrucSurface));

	for (iSurface=0; iSurface<nSurface; iSurface++) {
	        if (VERBOSE_CONSTRUCT)  printf("Surface %d:\n", iSurface);
		face = CGM_ithFace(model, iSurface);
		i      = CGM_NumEdgesInFace(face);
		iSurf  = -1;
		iLabel = iSurface + 1; // 
		bCut = -1;
		iNorm = 0;
		for (j=0; j<CGM_NumVolumes(model); j++) {
			k = CGM_VolumeFaceOrientation(CGM_ithVolume(model, j), face);
			if (VERBOSE_CONSTRUCT)  printf("Surface %d, volume %d, orientation: %d\n", iSurface, j, k);
			if (k<0)  {
//			    printf("AniFrtCad: CGM_VolumeFaceOrientation returned %d\n", k);
			    continue;
			}
			bCut++;
			iNorm = k;
		}
		if ((bCut<0) || (bCut>1)) {
			printf("Face #%d share %d volumes\n", iSurface, bCut+1);
			bCut = 0;
		}
		CGM_GetFaceParamRange(face, &uMin, &uMax, &vMin, &vMax);
		surface[iSurface].nLine = i;
		surface[iSurface].line = (int *)myAlloc(i * sizeof(int));
		surface[iSurface].inverse = (int *)myAlloc(i * sizeof(int));
//		printf("surface %d:\n", iSurface);
		for (j=0; j<i; j++) {
			edge = CGM_ithEdgeInFace(face, j);
			k        = CGM_EdgeIndex(model, edge);
			bInverse = CGM_FaceEdgeOrientation(face, edge);
			if (VERBOSE_CONSTRUCT)  printf("Surface %d, edge %d, orientation: %d\n", iSurface, j, bInverse);
//			if (bInverse < 0) {
//			    printf("AniFrtCad: CGM_FaceEdgeOrientation returned %d\nAssuming internal edge\n", bInverse);
//			}
//			if (iNorm && bInverse==0)  bInverse = 1;
//			if (iNorm && bInverse==1)  bInverse = 0;
			surface[iSurface].line[j] = k;
			surface[iSurface].inverse[j] = bInverse;
//			printf("\tline %d [%c]\n", k, (bInverse==1)?'*':((bInverse==0)?' ':'?'));
		}
		surface[iSurface].iSurf = iSurf;
		surface[iSurface].iLabel = iLabel;
		surface[iSurface].bCut = bCut;
		surface[iSurface].iNorm = iNorm;
		surface[iSurface].uMin = uMin;
		surface[iSurface].uMax = uMax;
		surface[iSurface].vMin = vMin;
		surface[iSurface].vMax = vMax;
	}
	
	boundVert = (int *)myAlloc(MAX1 * sizeof(int));
	boundT = (double *)myAlloc(MAX1 * sizeof(double));
	for (iLine=0; iLine<nLine; iLine++) {
		edge = CGM_ithEdge(model, iLine);
		vBegin = line[iLine].vBegin;
		vEnd = line[iLine].vEnd;
		iSurf = line[iLine].sub[0].iSurf;
		pm->tBegin = tBegin = line[iLine].sub[0].tBegin;
		pm->tEnd = tEnd = line[iLine].sub[0].tEnd;
		iV_U = line[iLine].sub[0].iV_U;
		nVert = 0;
		boundT[nVert] = tBegin;
		boundVert[nVert++] = vVert[vBegin];
		u = tBegin;
		for (j=0; ; j++) {
			if (nVert >= MAX1)
				errorExit3(4, "MAX1");
			if (nextUinEdge(pm, edge, u, &u)) break;

			pm->vert[pm->nPoint].u = u;
			CGM_GetEdgeCoordsFromU(edge, u, p);
			x = p[0];  y = p[1];  z = p[2];
			boundT[nVert] = u;
			boundVert[nVert++] = pm->nPoint;
			addPoint(pm, x, y, z);
		}/* for(j) */
		boundT[nVert] = tEnd;
		boundVert[nVert++] = vVert[vEnd];
		smoothingLineCGM(pm, boundVert, boundT, 0, 0, iSurf, iV_U, nVert, edge); 

		line[iLine].nVert = nVert;
		line[iLine].vert = (int *)myAlloc(nVert * sizeof(int));
		line[iLine].sub[0].u = (double *)myAlloc(nVert * sizeof(double));
		line[iLine].sub[0].v = 0;
		for (j=0; j<nVert; j++) {
			line[iLine].vert[j] = boundVert[j];
			line[iLine].sub[0].u[j] = boundT[j];
		}
	}/* for iLine */

	pm->nLinePoint = pm->nPoint;

	pm->maxTria = pm->maxFace;
	pm->v1 = (int *)myAlloc(pm->maxTria * sizeof(int));
	pm->v2 = (int *)myAlloc(pm->maxTria * sizeof(int));
	pm->v3 = (int *)myAlloc(pm->maxTria * sizeof(int));

	pm->countCrvT = 0;
	pm->cbnd = (int *)myAlloc(pm->maxTria * sizeof(int));
	pm->ciSurf = (int *)myAlloc(pm->maxTria * sizeof(int));
	pm->cu1 = (double *)myAlloc(pm->maxTria * sizeof(double));
	pm->cu2 = (double *)myAlloc(pm->maxTria * sizeof(double));
	pm->cu3 = (double *)myAlloc(pm->maxTria * sizeof(double));
	pm->cv1 = (double *)myAlloc(pm->maxTria * sizeof(double));
	pm->cv2 = (double *)myAlloc(pm->maxTria * sizeof(double));
	pm->cv3 = (double *)myAlloc(pm->maxTria * sizeof(double));


	for (iSurf=0; iSurf<nSurface; iSurf++) {
		face = CGM_ithFace(model, iSurf);
		pm->nEdge = 0;
		nLine = surface[iSurf].nLine;
		iLabel = surface[iSurf].iLabel;
		bCut = surface[iSurf].bCut;
		prepTree32(pm, pm->nnEdge);

		pm->nTria = 0;
		pm->uMin = surface[iSurf].uMin;
		pm->uMax = surface[iSurf].uMax;
		pm->vMin = surface[iSurf].vMin;
		pm->vMax = surface[iSurf].vMax;
		pm->iSurf = surface[iSurf].iSurf;
		pm->iNorm = surface[iSurf].iNorm;
		pm->cgmface = face;
		for (iLine=0; iLine<nLine; iLine++) {
			i = surface[iSurf].line[iLine];
			j = line[i].nSub;
			for (k=0; k<line[i].nVert; k++) {
				iVert = line[i].vert[k];
				p[0] = pm->vert[iVert].x;
				p[1] = pm->vert[iVert].y;
				p[2] = pm->vert[iVert].z;
				CGM_GetFaceUVFromCoords(face, p, uv);
				pm->vert[iVert].u = uv[0];
				pm->vert[iVert].v = uv[1];
//				printf("Vertex %d: x=%lf, y=%lf, z=%lf, \tu=%lf, v=%lf\n", iVert,  pm->vert[iVert].x,  pm->vert[iVert].y,  pm->vert[iVert].z,  pm->vert[iVert].u, pm->vert[iVert].v);
			}
			bInverse = surface[iSurf].inverse[iLine];
			makeAFLine(pm, line[i].vert, line[i].nVert, bInverse);
		}/*for(iLine<nLine)*/

		makeTria(pm);
		for (i=0; i<5; i++) {
			smoothingSurf(pm); 
		}
		nBoundTria += writeBoundCGM(pm);

		/* make AF for surface  */
		for (i=0; i<pm->nTria; i++) {
			addFace(pm, pm->v1[i], pm->v2[i], pm->v3[i], 0, iLabel);
			if (bCut)
				addFace(pm, pm->v1[i], pm->v3[i], pm->v2[i], 1, iLabel);
		}
	}/*for(iSurf<nSurface)*/

	pm->nBoundPoint = pm->nPoint;
//	outBound(nBoundTria);
	free(boundVert);
	free(boundT);
	free(vVert);
	nLine = CGM_NumEdges(model);
	for (iLine=0; iLine<nLine; iLine++) {
		free(line[iLine].vert);
		free(line[iLine].sub[0].u);
		free(line[iLine].sub);
	}
	free(line);
	for (iLine=0; iLine<nSurface; iLine++) {
		free(surface[iLine].line);
		free(surface[iLine].inverse);
	}
	free(surface);
	free(pm->v1);
	free(pm->v2);
	free(pm->v3);
	free(pm->cbnd);
	free(pm->ciSurf);
	free(pm->cu1);
	free(pm->cu2);
	free(pm->cu3);
	free(pm->cv1);
	free(pm->cv2);
	free(pm->cv3);
	return;
}
void
PorousFlowSquarePulsePointSource::addPoints()
{
  addPoint(_p, 0);
}
Exemplo n.º 21
0
	BufferElementGroupSPtr Submesh::addPoint( real * value )
	{
		return addPoint( value[0], value[1], value[2] );
	}
Exemplo n.º 22
0
 void DynamicLines::addPoint(Ogre::Real x, Ogre::Real y, Ogre::Real z)
 {
     addPoint( {x, y, z});
 }
Exemplo n.º 23
0
	//-----------------------------------------------------------------------
	void Extruder::_extrudeCapImpl(TriangleBuffer& buffer) const
	{
		std::vector<int> indexBuffer;
		PointList pointList;

		buffer.rebaseOffset();

		Triangulator t;
		if (mShapeToExtrude)
			t.setShapeToTriangulate(mShapeToExtrude);
		else
			t.setMultiShapeToTriangulate(mMultiShapeToExtrude);
		t.triangulate(indexBuffer, pointList);
		buffer.estimateIndexCount(2*indexBuffer.size());
		buffer.estimateVertexCount(2*pointList.size());


		//begin cap
		buffer.rebaseOffset();
		Quaternion qBegin = Utils::_computeQuaternion(mExtrusionPath->getDirectionAfter(0));
		if (mRotationTrack)
		{
			Real angle = mRotationTrack->getFirstValue();
			qBegin = qBegin*Quaternion((Radian)angle, Vector3::UNIT_Z);
		}	
		Real scaleBegin=1.;
		if (mScaleTrack)
			scaleBegin = mScaleTrack->getFirstValue();
		for (size_t j =0;j<pointList.size();j++)
		{
			Vector2 vp2 = pointList[j];
			Vector3 vp(vp2.x, vp2.y, 0);
			Vector3 normal = -Vector3::UNIT_Z;				

			Vector3 newPoint = mExtrusionPath->getPoint(0)+qBegin*(scaleBegin*vp);
			addPoint(buffer, newPoint,
				qBegin*normal,
				vp2);
		}

		for (size_t i=0;i<indexBuffer.size()/3;i++)
		{				
			buffer.index(indexBuffer[i*3]);
			buffer.index(indexBuffer[i*3+2]);
			buffer.index(indexBuffer[i*3+1]);
		}

		// end cap
		buffer.rebaseOffset();
		Quaternion qEnd = Utils::_computeQuaternion(mExtrusionPath->getDirectionBefore(mExtrusionPath->getSegCount()));
		if (mRotationTrack)
		{
			Real angle = mRotationTrack->getLastValue();
			qEnd = qEnd*Quaternion((Radian)angle, Vector3::UNIT_Z);
		}			
		Real scaleEnd=1.;
		if (mScaleTrack)
			scaleEnd = mScaleTrack->getLastValue();

		for (size_t j =0;j<pointList.size();j++)
		{
			Vector2 vp2 = pointList[j];
			Vector3 vp(vp2.x, vp2.y, 0);
			Vector3 normal = Vector3::UNIT_Z;				

			Vector3 newPoint = mExtrusionPath->getPoint(mExtrusionPath->getSegCount())+qEnd*(scaleEnd*vp);
			addPoint(buffer, newPoint,
				qEnd*normal,
				vp2);
		}

		for (size_t i=0;i<indexBuffer.size()/3;i++)
		{				
			buffer.index(indexBuffer[i*3]);
			buffer.index(indexBuffer[i*3+1]);
			buffer.index(indexBuffer[i*3+2]);
		}

	}
Exemplo n.º 24
0
 void DynamicLines::addPoint(const Ogre::Vector2 &p)
 {
     addPoint( {p.x, p.y, 0});
 }
Exemplo n.º 25
0
void Ribbon::setup(float _x, float _y){
    addPoint(_x, _y);
}
Exemplo n.º 26
0
 void DynamicLines::addPoint(Ogre::Real x, Ogre::Real y)
 {
     addPoint( {x, y, .0f});
 }
Exemplo n.º 27
0
const Elem *
DiracKernel::addPoint(Point p, unsigned id)
{
  if (id != libMesh::invalid_uint)
  {
    // OK, the user gave us an ID, let's see if we already have it...
    point_cache_t::iterator it = _point_cache.find(id);

    // Was the point found in a _point_cache on at least one processor?
    unsigned int i_found_it = static_cast<unsigned int>(it != _point_cache.end());
    unsigned int we_found_it = i_found_it;
    comm().max(we_found_it);

    // If the point was found in a cache, but not my cache, I'm not responsible for it.
    if (we_found_it && !i_found_it)
      return NULL;

    // Now that we only cache local data, some processors may enter
    // this if statement and some may not.  Therefore we can't call
    // any parallel_only() functions inside this if statement.
    if (i_found_it)
    {
      // We have something cached, now make sure it's actually the same Point.
      // TODO: we should probably use this same comparison in the DiracKernelInfo code!
      Point cached_point = (it->second).second;

      if (cached_point.relative_fuzzy_equals(p))
      {
        // Find the cached element associated to this point
        const Elem * cached_elem = (it->second).first;

        // If the cached element's processor ID doesn't match ours, we
        // are no longer responsible for caching it.  This can happen
        // due to adaptivity...
        if (cached_elem->processor_id() != processor_id())
        {
          // Update the caches, telling them to drop the cached Elem.
          // Analogously to the rest of the DiracKernel system, we
          // also return NULL because the Elem is non-local.
          updateCaches(cached_elem, NULL, p, id);
          return NULL;
        }

        bool active = cached_elem->active();
        bool contains_point = cached_elem->contains_point(p);

        // If the cached Elem is active and the point is still
        // contained in it, call the other addPoint() method and
        // return its result.
        if (active && contains_point)
        {
          // FIXME/TODO:
          // A given Point can be located in multiple elements if it
          // is on an edge or a node in the grid.  How are we handling
          // that case?  In other words, the same id would need to
          // appear multiple times in the _point_cache object...
          addPoint(cached_elem, p, id);
          return cached_elem;
        }

        // Is the Elem not active (been refined) but still contains the point?
        // Then search in its active children and update the caches.
        else if (!active && contains_point)
        {
          // Get the list of active children
          std::vector<const Elem*> active_children;
          cached_elem->active_family_tree(active_children);

          // Linear search through active children for the one that contains p
          for (unsigned c=0; c<active_children.size(); ++c)
            if (active_children[c]->contains_point(p))
            {
              updateCaches(cached_elem, active_children[c], p, id);
              addPoint(active_children[c], p, id);
              return active_children[c];
            }

          // If we got here without returning, it means the Point was
          // found in the parent element, but not in any of the active
          // children... this is not possible under normal
          // circumstances, so something must have gone seriously
          // wrong!
          mooseError("Error, Point not found in any of the active children!");
        }

        else if (
          // Is the Elem active but the point is not contained in it any
          // longer?  (For example, did the Mesh move out from under
          // it?)  Then we fall back to the expensive Point Locator
          // lookup.  TODO: we could try and do something more optimized
          // like checking if any of the active neighbors contains the
          // point.  Update the caches.
          (active && !contains_point) ||

          // The Elem has been refined *and* the Mesh has moved out
          // from under it, we fall back to doing the expensive Point
          // Locator lookup.  TODO: We could try and look in the
          // active children of this Elem's neighbors for the Point.
          // Update the caches.
          (!active && !contains_point))
        {
          const Elem * elem = _dirac_kernel_info.findPoint(p, _mesh);

          updateCaches(cached_elem, elem, p, id);
          addPoint(elem, p, id);
          return elem;
        }

        else
          mooseError("We'll never get here!");
      }
      else
        mooseError("Cached Dirac point " << cached_point << " already exists with ID: " << id << " and does not match point " << p);
    }
  }

  // If we made it here, we either didn't have the point already cached or
  // id == libMesh::invalid_uint.  So now do the more expensive PointLocator lookup,
  // possibly cache the result, and call the other addPoint() method.
  const Elem * elem = _dirac_kernel_info.findPoint(p, _mesh);

  // Only add the point to the cache on this processor if the Elem is local
  if (elem && (elem->processor_id() == processor_id()) && (id != libMesh::invalid_uint))
  {
    // Add the point to the cache...
    _point_cache[id] = std::make_pair(elem, p);

    // ... and to the reverse cache.
    std::vector<std::pair<Point, unsigned> > & points = _reverse_point_cache[elem];
    points.push_back(std::make_pair(p, id));
  }

  // Call the other addPoint() method.  This method ignores non-local
  // and NULL elements automatically.
  addPoint(elem, p, id);
  return elem;
}
void Plotter::addPoint(qreal x, qreal y)
{
    addPoint(x, y, "default");
}
Exemplo n.º 29
0
 /** Enlarges (if necessary) an AABB to contain the given point. */
 const AABB& operator+=(const vec3& p)
 {
   addPoint(p);
   return *this;
 }
Exemplo n.º 30
0
void analyzeEventsSlice(double onDelta = 100.0) {
  gStyle->SetOptFit(1);
  initialize();

  int decodedTDC;
  for (Long64_t iEvent=0; iEvent<myTree->GetEntries();iEvent++) {
    std::cout << "Processing Event " << iEvent << std::endl;
    myTree->GetEntry(iEvent);
    decodedTDC = TDC-4;
    if (decodedTDC<0) continue;
    if (decodedTDC>8) {
      std::cerr << "Help, this should not happen" << std::endl;
      continue;
    }
    if (nHits>0) myHistoIntegral[decodedTDC]->Fill(thresh, 1 /* nHits*/ );
    //myHistoIntegral[decodedTDC]->Fill(thresh, nHits );
  }


  TH1D* antani = new TH1D("diff", Form("diffTDC_%f", onDelta), 10, -0.5, 9.5);
  bool gotTDC[13];
  for (int i=0; i<13; ++i) { gotTDC[i]=false; }
  for (int iTDC=0; iTDC<9; ++iTDC) {
    double thisVal, prevVal;
    double thisX, prevX;
    prevVal=0;
    prevX=-9999;
    bool firstVal = true;
    for (int iBin=1; iBin<myHistoIntegral[iTDC]->GetNbinsX(); ++iBin) {
      thisVal = myHistoIntegral[iTDC]->GetBinContent(iBin);
      thisX = myHistoIntegral[iTDC]->GetXaxis()->GetBinCenter(iBin);
      if (thisVal==0) continue;

      if (!firstVal) {
	addPoint(myGraphDifferential[iTDC],
		 (thisX+prevX)/2., prevVal-thisVal
		 , fabs(thisX-prevX)/2., sqrt(prevVal+thisVal));	
        if (((thisX+prevX)/2.>onDelta)&&(!gotTDC[iTDC])) {
            gotTDC[iTDC]=true;
            antani->Fill(iTDC, (prevVal-thisVal)/(thisX-prevX));
        } 
      } else firstVal=false;
      // myHistoDifferential[iTDC]->SetBinContent(iBin, prevVal-thisVal);
      prevVal = thisVal;
      prevX = thisX;
    }

    TCanvas* myCanvas;
    
    //myCanvas = new TCanvas();
    //myCanvas->cd();
    //myCanvas->SetLogy();

    myGraphDifferential[iTDC]->SetMarkerStyle(8);
    // myGraphDifferential[iTDC]->Draw("ap");

		//edit G. Auzinger: fit distribution for every TDC with a landau in range 30 to 200
//		TF1* myLandau = new TF1("fit", "TMath::Landau(x)", 30, 200);
//		myGraphDifferential[iTDC]->Fit("landau", "RM+","same", 50, 250);

    // myGraphDifferential[iTDC]->Fit(
    
    // myHistoDifferential[iTDC]->Rebin(2);
    // myHistoDifferential[iTDC]->Draw();
    
    // myCanvas = new TCanvas();
    // myCanvas->SetLogy();
    // myHistoIntegral[iTDC]->Draw();
    
  }

  new TCanvas();
  antani->Draw();
}